diff --git a/class2.php b/class2.php
index a18adb38a..661969838 100755
--- a/class2.php
+++ b/class2.php
@@ -525,33 +525,23 @@ 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(deftrue('e_ADMIN_AREA') && getperms('0') && ($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);
+ if(!empty($_POST['stopEmulation']))
+ {
+ e107::getSession()->clear('emulate');
+ e107::getMessage()->addSuccess("Admin access emulation mode has been stopped.");
+ }
+ else
+ {
+ $emulatedUser = e107::user($id);
+ define('USERCLASS_LIST', $emulatedUser['user_class']);
+ define('ADMINPERMS', $emulatedUser['user_perms']);
+ // define('USERID', $emulatedUser['user_id']); // Don't emulate user id. It will mess with logs.
+ define('USERNAME', $emulatedUser['user_name']);
+ }
- $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']); - // define('USERID', $emulatedUser['user_id']); Don't emulate user id. It will mess with logs. - define('USERNAME', $emulatedUser['user_name']); - } + unset($id); } } else diff --git a/e107_admin/users.php b/e107_admin/users.php index efe7eb604..bcf4511be 100644 --- a/e107_admin/users.php +++ b/e107_admin/users.php @@ -882,7 +882,10 @@ class users_admin_ui extends e_admin_ui if(getperms('0') && !empty($_POST['userid'])) { - e107::getSession()->set('emulate', (int) $_POST['userid']); + $uid = (int) $_POST['userid']; + e107::getSession()->set('emulate',$uid); + $user = e107::user($uid); + e107::getMessage()->addSuccess("Emulation of ".$user['user_name']." activated.", 'default', true);; } $this->redirect('list', 'main', true); @@ -2749,7 +2752,7 @@ 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']) { @@ -2814,6 +2817,11 @@ class users_admin_form_ui extends e_admin_form_ui // $text .= "\n"; // $text .= "\n"; + if(getperms('0')) + { + $opts['emulate'] = 'Emulate permissions'; + } + $opts['adminperms'] = USRLAN_221; $opts['unadmin'] = USRLAN_34; } diff --git a/e107_core/shortcodes/batch/admin_shortcodes.php b/e107_core/shortcodes/batch/admin_shortcodes.php index 3cc4f07eb..959fc9d34 100644 --- a/e107_core/shortcodes/batch/admin_shortcodes.php +++ b/e107_core/shortcodes/batch/admin_shortcodes.php @@ -426,7 +426,7 @@ class admin_shortcodes extends e_shortcode { $text .= $sql->mySQLlanguage; $text .= ' (' .$slng->convert($sql->mySQLlanguage).") - :