mirror of
https://github.com/e107inc/e107.git
synced 2025-07-25 17:01:43 +02:00
Issue #5476 - Emulation mode. (beta)
This commit is contained in:
29
class2.php
29
class2.php
@@ -524,6 +524,33 @@ if(!isset($_E107['no_session']) && !isset($_E107['no_lan']))
|
|||||||
|
|
||||||
$dbg->logTime('Set User Language Session');
|
$dbg->logTime('Set User Language Session');
|
||||||
e107::getLanguage()->set(); // set e_LANGUAGE, USERLAN, Language Session / Cookies etc. requires $pref;
|
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 <b>".$emulatedUser['user_name']."</b>";
|
||||||
|
$msg .= "<br />This is a temporary emulation mode and will be cleared when you log out.";
|
||||||
|
$msg .= "<pre>userclasses: ".$emulatedUser['user_class']."\nadminperms: ".$emulatedUser['user_perms']."</pre>";
|
||||||
|
e107::getMessage()->setTitle('User Access Emulation Mode', E_MESSAGE_WARNING)->addWarning($msg);
|
||||||
|
|
||||||
|
$text = "<form action='".e_REQUEST_URI."' method='post'>\n";
|
||||||
|
$text .= "<input class='btn btn-dark' type='submit' name='stopEmulation' value='Stop Emulating' />\n";
|
||||||
|
$text .= "</form>\n";
|
||||||
|
|
||||||
|
e107::getMessage()->addWarning($text);
|
||||||
|
|
||||||
|
define('USERCLASS_LIST', $emulatedUser['user_class']);
|
||||||
|
define('ADMINPERMS', $emulatedUser['user_perms']);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -536,6 +563,8 @@ if(!empty($pref['multilanguage']) && (e_LANGUAGE !== $pref['sitelanguage']))
|
|||||||
$sql2->mySQLlanguage = e_LANGUAGE;
|
$sql2->mySQLlanguage = e_LANGUAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//do it only once and with the proper function
|
//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.'.php');
|
||||||
// e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'_custom.php');
|
// e107_include_once(e_LANGUAGEDIR.e_LANGUAGE.'/'.e_LANGUAGE.'_custom.php');
|
||||||
|
@@ -182,6 +182,13 @@ JS;
|
|||||||
->setMode('main')
|
->setMode('main')
|
||||||
->setAction('logoutas');
|
->setAction('logoutas');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'emulate':
|
||||||
|
$this->getRequest()
|
||||||
|
->setQuery(array())
|
||||||
|
->setMode('main')
|
||||||
|
->setAction('emulate');
|
||||||
|
break;
|
||||||
|
|
||||||
// redirect to AdminObserver/AdminPage()
|
// redirect to AdminObserver/AdminPage()
|
||||||
case 'admin':
|
case 'admin':
|
||||||
@@ -862,6 +869,26 @@ class users_admin_ui extends e_admin_ui
|
|||||||
{
|
{
|
||||||
// System Message only on non-successful logout as another user
|
// 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
|
* Remove admin status trigger
|
||||||
@@ -2723,6 +2750,8 @@ class users_admin_form_ui extends e_admin_form_ui
|
|||||||
// login/logout As
|
// login/logout As
|
||||||
if(getperms('0') && !($row['user_admin'] && getperms('0', $row['user_perms'])))
|
if(getperms('0') && !($row['user_admin'] && getperms('0', $row['user_perms'])))
|
||||||
{
|
{
|
||||||
|
$opts['emulate'] = 'Emulate Permissions';
|
||||||
|
|
||||||
if(e107::getUser()->getSessionDataAs() == $row['user_id'])
|
if(e107::getUser()->getSessionDataAs() == $row['user_id'])
|
||||||
{
|
{
|
||||||
// $text .= "<option value='logoutas'>".sprintf(USRLAN_AS_2, $row['user_name'])."</option>";
|
// $text .= "<option value='logoutas'>".sprintf(USRLAN_AS_2, $row['user_name'])."</option>";
|
||||||
|
Reference in New Issue
Block a user