diff --git a/class2.php b/class2.php
index b7cd44d71..b1233811f 100755
--- a/class2.php
+++ b/class2.php
@@ -524,6 +524,33 @@ if(!isset($_E107['no_session']) && !isset($_E107['no_lan']))
$dbg->logTime('Set User Language Session');
e107::getLanguage()->set(); // set e_LANGUAGE, USERLAN, Language Session / Cookies etc. requires $pref;
+
+ if($id = e107::getSession()->get('emulate'))
+ {
+ if(!empty($_POST['stopEmulation']))
+ {
+ e107::getSession()->clear('emulate');
+ e107::getMessage()->addSuccess("User access emulation mode has been stopped.");
+ }
+ else
+ {
+ $emulatedUser = e107::user($id);
+
+ $msg = "You are currently emulating the userclass and admin permissions of ".$emulatedUser['user_name']."";
+ $msg .= "
This is a temporary emulation mode and will be cleared when you log out.";
+ $msg .= "
userclasses: ".$emulatedUser['user_class']."\nadminperms: ".$emulatedUser['user_perms'].""; + e107::getMessage()->setTitle('User Access Emulation Mode', E_MESSAGE_WARNING)->addWarning($msg); + + $text = "\n"; + + e107::getMessage()->addWarning($text); + + define('USERCLASS_LIST', $emulatedUser['user_class']); + define('ADMINPERMS', $emulatedUser['user_perms']); + } + } } else { @@ -536,6 +563,8 @@ if(!empty($pref['multilanguage']) && (e_LANGUAGE !== $pref['sitelanguage'])) $sql2->mySQLlanguage = e_LANGUAGE; } + + //do it only once and with the proper function // e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'.php'); // e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'_custom.php'); diff --git a/e107_admin/users.php b/e107_admin/users.php index 993c7c935..fd620afc2 100644 --- a/e107_admin/users.php +++ b/e107_admin/users.php @@ -182,6 +182,13 @@ JS; ->setMode('main') ->setAction('logoutas'); break; + + case 'emulate': + $this->getRequest() + ->setQuery(array()) + ->setMode('main') + ->setAction('emulate'); + break; // redirect to AdminObserver/AdminPage() case 'admin': @@ -862,6 +869,26 @@ class users_admin_ui extends e_admin_ui { // System Message only on non-successful logout as another user } + + + /** + * Allows the emulation of a user ID if the current user has sufficient permissions and a user ID is provided. + * If the conditions are met, a message with the emulated User ID is displayed, and the session is updated to emulate the specified user ID. + * + * @return void + */ + public function emulatePage() + { + + if(getperms('0') && !empty($_POST['userid'])) + { + e107::getMessage()->addInfo("Emulating User ID".print_a($_POST,true)); + e107::getSession()->set('emulate', (int) $_POST['userid']); + } + + $this->redirect('list', 'main', true); + + } /** * Remove admin status trigger @@ -2723,6 +2750,8 @@ class users_admin_form_ui extends e_admin_form_ui // login/logout As if(getperms('0') && !($row['user_admin'] && getperms('0', $row['user_perms']))) { + $opts['emulate'] = 'Emulate Permissions'; + if(e107::getUser()->getSessionDataAs() == $row['user_id']) { // $text .= "";