Attached Files |
login_as_user_1105.patch [^] (6,842 bytes) 2011-10-06 10:05
[Show Content]
Index: admin/system_presets/simple/users_u.php
===================================================================
--- admin/system_presets/simple/users_u.php (revision 14643)
+++ admin/system_presets/simple/users_u.php (working copy)
@@ -25,7 +25,7 @@
// toolbar buttons
$remove_buttons = Array (
// list of users; section: Users Management -> Users
- 'users_list' => Array (/*'new_item', 'edit', 'delete', 'approve', 'decline', 'e-mail',*/ 'export', /*'view', 'dbl-click'*/),
+ 'users_list' => Array (/*'new_item', 'edit', 'delete', 'approve', 'decline', 'e-mail',*/ 'export', 'frontend_mail', /*'view', 'dbl-click'*/),
// "General" tab during user adding/editing
// 'users_edit' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
Index: core/admin_templates/users/users_list.tpl
===================================================================
--- core/admin_templates/users/users_list.tpl (revision 14643)
+++ core/admin_templates/users/users_list.tpl (working copy)
@@ -7,6 +7,28 @@
<tr>
<td>
<script type="text/javascript">
+
+ function getFirstSelected()
+ {
+ var items = document.getElementById('kernel_form').elements;
+ var ilength = items.length;
+ var counter = 0;
+ var user_id;
+ for(var i=0; i < ilength; i++) {
+ if(items[i].name.match(/^u\.regular\[.+\]\[PortalUserId\]$/) && items[i].checked == true) {
+ var name_elems = items[i].name.split('[');
+ name_elems = name_elems[1].split(']');
+ counter++;
+ if (counter > 1) {
+ return false;
+ }
+ user_id = name_elems[0];
+ }
+ }
+
+ return user_id;
+ }
+
//do not rename - this function is used in default grid for double click!
function edit()
{
@@ -55,6 +77,22 @@
a_toolbar.AddButton( new ToolBarSeparator('sep2') );
+ a_toolbar.AddButton( new ToolBarButton('frontend_mail', '<inp2:m_phrase label="la_ToolTip_LoginAs" escape="1"/>',
+ function() {
+ var user_id = getFirstSelected();
+
+ if(user_id) {
+ var $url = '<inp2:m_Link t="index" index_file="../index.php" user="#USER_ID#" no_amp="1" />&events[u]=OnLoginAs';
+ $url = $url.replace('#USER_ID#', user_id);
+ window.open($url, 'frontend' + user_id, '');
+ } else {
+ alert('<inp2:m_phrase label="la_error_YouMustSelectOnlyOneUser" escape="1"/>');
+ }
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep3') );
+
<inp2:m_if check="m_ModuleEnabled" module="In-Portal">
a_toolbar.AddButton(
new ToolBarButton(
@@ -75,7 +113,7 @@
}
) );
- a_toolbar.AddButton( new ToolBarSeparator('sep3') );
+ a_toolbar.AddButton( new ToolBarSeparator('sep4') );
a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() {
show_viewmenu(a_toolbar,'view');
@@ -93,6 +131,6 @@
<inp2:m_RenderElement name="grid" PrefixSpecial="u.regular" IdField="PortalUserId" grid="RegularUsers"/>
<script type="text/javascript">
- Grids['u.regular'].SetDependantToolbarButtons( new Array('edit', 'delete', 'setprimary', 'e-mail', 'approve', 'decline') );
+ Grids['u.regular'].SetDependantToolbarButtons( new Array('edit', 'delete', 'setprimary', 'e-mail', 'approve', 'decline', 'frontend_mail') );
</script>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Index: core/install/english.lang
===================================================================
--- core/install/english.lang (revision 14643)
+++ core/install/english.lang (working copy)
@@ -1513,6 +1513,7 @@
<PHRASE Label="lu_opt_AutoDetect" Module="Core" Type="1">QXV0by1EZXRlY3Q=</PHRASE>
<PHRASE Label="lu_opt_Cookies" Module="Core" Type="1">Q29va2llcw==</PHRASE>
<PHRASE Label="lu_opt_QueryString" Module="Core" Type="1">UXVlcnkgU3RyaW5nIChTSUQp</PHRASE>
+ <PHRASE Label="la_error_YouMustSelectOnlyOneUser" Module="Custom" Type="1">WW91IG11c3Qgc2VsZWN0IG9ubHkgb25lIHVzZXI=</PHRASE>
</PHRASES>
<EVENTS>
<EVENT MessageType="html" Event="CATEGORY.ADD" Type="0">U3ViamVjdDogTmV3IENhdGVnb3J5ICI8aW5wMjpjX0ZpZWxkIG5hbWU9Ik5hbWUiLz4iIC0gQWRkZWQKCllvdXIgc3VnZ2VzdGVkIGNhdGVnb3J5ICI8aW5wMjpjX0ZpZWxkIG5hbWU9Ik5hbWUiLz4iIGhhcyBiZWVuIGFkZGVkLg==</EVENT>
Index: core/units/users/users_config.php
===================================================================
--- core/units/users/users_config.php (revision 14643)
+++ core/units/users/users_config.php (working copy)
@@ -123,7 +123,7 @@
'users_list' => Array (
'prefixes' => Array ('u_List'), 'format' => "!la_title_Users!",
- 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'approve', 'decline', 'e-mail', 'export', 'view', 'dbl-click'),
+ 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'approve', 'decline', 'e-mail', 'export', 'view', 'dbl-click', 'frontend_mail'),
),
'users_edit' => Array (
Index: core/units/users/users_event_handler.php
===================================================================
--- core/units/users/users_event_handler.php (revision 14643)
+++ core/units/users/users_event_handler.php (working copy)
@@ -115,6 +115,29 @@
}
}
+ private function _hasAdminSession()
+ {
+ $adm_sid = $_COOKIE['adm_sid'];
+
+ $sql = 'SELECT PortalUserId
+ FROM '.TABLE_PREFIX.'UserSession
+ WHERE SessionKey = '.$this->Conn->qstr($_COOKIE['adm_sid']);
+ $admin_id = $this->Conn->GetOne($sql);
+
+ if (!$admin_id) {
+ return false;
+ }
+
+ if ($admin_id == -1) {
+ return true;
+ }
+
+ $sql = 'SELECT GroupId
+ FROM ' . TABLE_PREFIX . 'UserGroup
+ WHERE (PortalUserId = ' . $admin_id . ') AND ( (MembershipExpires IS NULL) OR (MembershipExpires >= ' . adodb_mktime() . ') ) AND GroupId = 11';
+ return ($this->Conn->GetOne($sql) == 11);
+ }
+
/**
* Checks user permission to execute given $event
*
@@ -133,6 +156,10 @@
return defined('DBG_RESET_ROOT') && DBG_RESET_ROOT;
}
+ if ( $event->Name == 'OnLoginAs' ) {
+ return $this->_hasAdminSession();
+ }
+
if ( !$this->Application->isAdminUser ) {
$user_id = $this->Application->RecallVar('user_id');
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
@@ -1761,4 +1788,21 @@
$event->SetRedirectParam('reset', 1);
$event->SetRedirectParam('pass', 'm');
}
+
+
+ /**
+ * Login for front-end user when admin session is present
+ *
+ * @param kEvent $event
+ * @return void
+ * @access protected
+ */
+ protected function OnLoginAs(&$event)
+ {
+
+ $user_helper =& $this->Application->recallObject('UserHelper');
+ /* @var $user_helper UserHelper */
+
+ $user_helper->loginUserById( $this->Application->GetVar('user') );
+ }
}
login_as_user_1105.2.patch [^] (6,972 bytes) 2011-10-11 09:30
[Show Content]
Index: admin/system_presets/simple/users_u.php
===================================================================
--- admin/system_presets/simple/users_u.php (revision 14653)
+++ admin/system_presets/simple/users_u.php (working copy)
@@ -25,7 +25,7 @@
// toolbar buttons
$remove_buttons = Array (
// list of users; section: Users Management -> Users
- 'users_list' => Array (/*'new_item', 'edit', 'delete', 'approve', 'decline', 'e-mail',*/ 'export', /*'view', 'dbl-click'*/),
+ 'users_list' => Array (/*'new_item', 'edit', 'delete', 'approve', 'decline', 'e-mail',*/ 'export', 'frontend_mail', /*'view', 'dbl-click'*/),
// "General" tab during user adding/editing
// 'users_edit' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
Index: core/admin_templates/users/users_list.tpl
===================================================================
--- core/admin_templates/users/users_list.tpl (revision 14653)
+++ core/admin_templates/users/users_list.tpl (working copy)
@@ -1,12 +1,12 @@
<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" section="in-portal:user_list" grid="RegularUsers" title_preset="users_list" pagination="1" prefix="u.regular"/>
-
<!-- ToolBar -->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td>
<script type="text/javascript">
+
//do not rename - this function is used in default grid for double click!
function edit()
{
@@ -55,6 +55,22 @@
a_toolbar.AddButton( new ToolBarSeparator('sep2') );
+ a_toolbar.AddButton( new ToolBarButton('frontend_mail', '<inp2:m_phrase label="la_ToolTip_LoginAs" escape="1"/>',
+ function() {
+
+ if (Grids['u.regular'].GetSelected()[1]) {
+ alert('<inp2:m_phrase label="la_error_YouMustSelectOnlyOneUser" escape="1"/>');
+ } else {
+ var user_id = Grids['u.regular'].GetSelected().shift();
+ var $url = '<inp2:m_Link t="index" index_file="../index.php" user="#USER_ID#" pass="m,u" u_event="OnLoginAs" no_amp="1"/>';
+ $url = $url.replace('#USER_ID#', user_id);
+ window.open($url, 'frontend' + user_id, '');
+ }
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep3') );
+
<inp2:m_if check="m_ModuleEnabled" module="In-Portal">
a_toolbar.AddButton(
new ToolBarButton(
@@ -75,7 +91,7 @@
}
) );
- a_toolbar.AddButton( new ToolBarSeparator('sep3') );
+ a_toolbar.AddButton( new ToolBarSeparator('sep4') );
a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() {
show_viewmenu(a_toolbar,'view');
@@ -93,6 +109,6 @@
<inp2:m_RenderElement name="grid" PrefixSpecial="u.regular" IdField="PortalUserId" grid="RegularUsers"/>
<script type="text/javascript">
- Grids['u.regular'].SetDependantToolbarButtons( new Array('edit', 'delete', 'setprimary', 'e-mail', 'approve', 'decline') );
+ Grids['u.regular'].SetDependantToolbarButtons( new Array('edit', 'delete', 'setprimary', 'e-mail', 'approve', 'decline', 'frontend_mail') );
</script>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Index: core/install/english.lang
===================================================================
--- core/install/english.lang (revision 14653)
+++ core/install/english.lang (working copy)
@@ -257,6 +257,7 @@
<PHRASE Label="la_error_unknown_category" Module="Core" Type="1">VW5rbm93biBzZWN0aW9u</PHRASE>
<PHRASE Label="la_error_UserBanned" Module="Core" Type="1">VXNlciBCYW5uZWQ=</PHRASE>
<PHRASE Label="LA_ERROR_USERNOTFOUND" Module="Core" Type="1">dXNlciBub3QgZm91bmQ=</PHRASE>
+ <PHRASE Label="la_error_YouMustSelectOnlyOneUser" Module="Custom" Type="1">WW91IG11c3Qgc2VsZWN0IG9ubHkgb25lIHVzZXI=</PHRASE>
<PHRASE Label="la_err_bad_date_format" Module="Core" Type="1">SW5jb3JyZWN0IGRhdGUgZm9ybWF0LCBwbGVhc2UgdXNlICglcykgZXguICglcyk=</PHRASE>
<PHRASE Label="la_err_bad_type" Module="Core" Type="1">SW5jb3JyZWN0IGRhdGEgZm9ybWF0LCBwbGVhc2UgdXNlICVz</PHRASE>
<PHRASE Label="la_err_invalid_format" Module="Core" Type="1">SW52YWxpZCBGb3JtYXQ=</PHRASE>
@@ -1373,6 +1374,7 @@
<PHRASE Label="la_ToolTip_Home" Module="Core" Type="1">SG9tZQ==</PHRASE>
<PHRASE Label="la_ToolTip_Import" Module="Core" Type="1">SW1wb3J0</PHRASE>
<PHRASE Label="la_ToolTip_ImportLanguage" Module="Core" Type="1">SW1wb3J0IExhbmd1YWdl</PHRASE>
+ <PHRASE Label="la_ToolTip_LoginAs" Module="Core" Type="1">TG9naW4gQXM=</PHRASE>
<PHRASE Label="la_ToolTip_MoveDown" Module="Core" Type="1">TW92ZSBEb3du</PHRASE>
<PHRASE Label="la_ToolTip_MoveUp" Module="Core" Type="1">TW92ZSBVcA==</PHRASE>
<PHRASE Label="la_ToolTip_NewAgent" Module="Core" Type="1">TmV3IEFnZW50</PHRASE>
Index: core/units/users/users_config.php
===================================================================
--- core/units/users/users_config.php (revision 14653)
+++ core/units/users/users_config.php (working copy)
@@ -123,7 +123,7 @@
'users_list' => Array (
'prefixes' => Array ('u_List'), 'format' => "!la_title_Users!",
- 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'approve', 'decline', 'e-mail', 'export', 'view', 'dbl-click'),
+ 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'approve', 'decline', 'e-mail', 'export', 'view', 'dbl-click', 'frontend_mail'),
),
'users_edit' => Array (
Index: core/units/users/users_event_handler.php
===================================================================
--- core/units/users/users_event_handler.php (revision 14653)
+++ core/units/users/users_event_handler.php (working copy)
@@ -133,6 +133,16 @@
return defined('DBG_RESET_ROOT') && DBG_RESET_ROOT;
}
+ if ( $event->Name == 'OnLoginAs' ) {
+
+ $admin_session =& $this->Application->recallObject('Session.admin');
+ /* @var $admin_session Session */
+
+ $user = (int)$admin_session->RecallVar('user_id');
+
+ return ($user != 0);
+ }
+
if ( !$this->Application->isAdminUser ) {
$user_id = $this->Application->RecallVar('user_id');
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
@@ -1761,4 +1771,30 @@
$event->SetRedirectParam('reset', 1);
$event->SetRedirectParam('pass', 'm');
}
+
+
+ /**
+ * Login for front-end user when admin session is present
+ *
+ * @param kEvent $event
+ * @return void
+ * @access protected
+ */
+ protected function OnLoginAs(&$event)
+ {
+
+ $user_helper =& $this->Application->recallObject('UserHelper');
+ /* @var $user_helper UserHelper */
+
+ $user =& $user_helper->getUserObject();
+ $user->Load( $this->Application->GetVar('user') );
+
+ if ( !$user->isLoaded() ) {
+ return ;
+ }
+
+ if ( $user_helper->checkLoginPermission() ) {
+ $user_helper->loginUserById( $user->GetID() );
+ }
+ }
}
login_as_user_1105.3.patch [^] (6,928 bytes) 2011-10-11 12:29
[Show Content]
Index: admin/system_presets/simple/users_u.php
===================================================================
--- admin/system_presets/simple/users_u.php (revision 14656)
+++ admin/system_presets/simple/users_u.php (working copy)
@@ -25,7 +25,7 @@
// toolbar buttons
$remove_buttons = Array (
// list of users; section: Users Management -> Users
- 'users_list' => Array (/*'new_item', 'edit', 'delete', 'approve', 'decline', 'e-mail',*/ 'export', /*'view', 'dbl-click'*/),
+ 'users_list' => Array (/*'new_item', 'edit', 'delete', 'approve', 'decline', 'e-mail',*/ 'export', 'frontend_mail', /*'view', 'dbl-click'*/),
// "General" tab during user adding/editing
// 'users_edit' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
Index: core/admin_templates/users/users_list.tpl
===================================================================
--- core/admin_templates/users/users_list.tpl (revision 14656)
+++ core/admin_templates/users/users_list.tpl (working copy)
@@ -1,12 +1,12 @@
<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" section="in-portal:user_list" grid="RegularUsers" title_preset="users_list" pagination="1" prefix="u.regular"/>
-
<!-- ToolBar -->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td>
<script type="text/javascript">
+
//do not rename - this function is used in default grid for double click!
function edit()
{
@@ -55,6 +55,22 @@
a_toolbar.AddButton( new ToolBarSeparator('sep2') );
+ a_toolbar.AddButton( new ToolBarButton('frontend_mail', '<inp2:m_phrase label="la_ToolTip_LoginAs" escape="1"/>',
+ function() {
+
+ if (Grids['u.regular'].GetSelected().length > 1) {
+ alert('<inp2:m_phrase label="la_error_YouMustSelectOnlyOneUser" escape="1"/>');
+ } else {
+ var user_id = Grids['u.regular'].GetSelected().shift();
+ var $url = '<inp2:m_Link t="index" index_file="../index.php" user="#USER_ID#" pass="m,u" u_event="OnLoginAs" no_amp="1"/>';
+ $url = $url.replace('#USER_ID#', user_id);
+ window.open($url, 'frontend' + user_id, '');
+ }
+ }
+ ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep3') );
+
<inp2:m_if check="m_ModuleEnabled" module="In-Portal">
a_toolbar.AddButton(
new ToolBarButton(
@@ -75,7 +91,7 @@
}
) );
- a_toolbar.AddButton( new ToolBarSeparator('sep3') );
+ a_toolbar.AddButton( new ToolBarSeparator('sep4') );
a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() {
show_viewmenu(a_toolbar,'view');
@@ -93,6 +109,6 @@
<inp2:m_RenderElement name="grid" PrefixSpecial="u.regular" IdField="PortalUserId" grid="RegularUsers"/>
<script type="text/javascript">
- Grids['u.regular'].SetDependantToolbarButtons( new Array('edit', 'delete', 'setprimary', 'e-mail', 'approve', 'decline') );
+ Grids['u.regular'].SetDependantToolbarButtons( new Array('edit', 'delete', 'setprimary', 'e-mail', 'approve', 'decline', 'frontend_mail') );
</script>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Index: core/install/english.lang
===================================================================
--- core/install/english.lang (revision 14656)
+++ core/install/english.lang (working copy)
@@ -257,6 +257,7 @@
<PHRASE Label="la_error_unknown_category" Module="Core" Type="1">VW5rbm93biBzZWN0aW9u</PHRASE>
<PHRASE Label="la_error_UserBanned" Module="Core" Type="1">VXNlciBCYW5uZWQ=</PHRASE>
<PHRASE Label="LA_ERROR_USERNOTFOUND" Module="Core" Type="1">dXNlciBub3QgZm91bmQ=</PHRASE>
+ <PHRASE Label="la_error_YouMustSelectOnlyOneUser" Module="Core" Type="1">WW91IG11c3Qgc2VsZWN0IG9ubHkgb25lIHVzZXI=</PHRASE>
<PHRASE Label="la_err_bad_date_format" Module="Core" Type="1">SW5jb3JyZWN0IGRhdGUgZm9ybWF0LCBwbGVhc2UgdXNlICglcykgZXguICglcyk=</PHRASE>
<PHRASE Label="la_err_bad_type" Module="Core" Type="1">SW5jb3JyZWN0IGRhdGEgZm9ybWF0LCBwbGVhc2UgdXNlICVz</PHRASE>
<PHRASE Label="la_err_invalid_format" Module="Core" Type="1">SW52YWxpZCBGb3JtYXQ=</PHRASE>
@@ -1373,6 +1374,7 @@
<PHRASE Label="la_ToolTip_Home" Module="Core" Type="1">SG9tZQ==</PHRASE>
<PHRASE Label="la_ToolTip_Import" Module="Core" Type="1">SW1wb3J0</PHRASE>
<PHRASE Label="la_ToolTip_ImportLanguage" Module="Core" Type="1">SW1wb3J0IExhbmd1YWdl</PHRASE>
+ <PHRASE Label="la_ToolTip_LoginAs" Module="Core" Type="1">TG9naW4gQXM=</PHRASE>
<PHRASE Label="la_ToolTip_MoveDown" Module="Core" Type="1">TW92ZSBEb3du</PHRASE>
<PHRASE Label="la_ToolTip_MoveUp" Module="Core" Type="1">TW92ZSBVcA==</PHRASE>
<PHRASE Label="la_ToolTip_NewAgent" Module="Core" Type="1">TmV3IEFnZW50</PHRASE>
Index: core/units/users/users_config.php
===================================================================
--- core/units/users/users_config.php (revision 14656)
+++ core/units/users/users_config.php (working copy)
@@ -123,7 +123,7 @@
'users_list' => Array (
'prefixes' => Array ('u_List'), 'format' => "!la_title_Users!",
- 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'approve', 'decline', 'e-mail', 'export', 'view', 'dbl-click'),
+ 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'approve', 'decline', 'e-mail', 'export', 'view', 'dbl-click', 'frontend_mail'),
),
'users_edit' => Array (
Index: core/units/users/users_event_handler.php
===================================================================
--- core/units/users/users_event_handler.php (revision 14656)
+++ core/units/users/users_event_handler.php (working copy)
@@ -133,6 +133,14 @@
return defined('DBG_RESET_ROOT') && DBG_RESET_ROOT;
}
+ if ( $event->Name == 'OnLoginAs' ) {
+
+ $admin_session =& $this->Application->recallObject('Session.admin');
+ /* @var $admin_session Session */
+
+ return $admin_session->LoggedIn();
+ }
+
if ( !$this->Application->isAdminUser ) {
$user_id = $this->Application->RecallVar('user_id');
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
@@ -1761,4 +1769,30 @@
$event->SetRedirectParam('reset', 1);
$event->SetRedirectParam('pass', 'm');
}
+
+
+ /**
+ * Login for front-end user when admin session is present
+ *
+ * @param kEvent $event
+ * @return void
+ * @access protected
+ */
+ protected function OnLoginAs(&$event)
+ {
+
+ $user_helper =& $this->Application->recallObject('UserHelper');
+ /* @var $user_helper UserHelper */
+
+ $user =& $user_helper->getUserObject();
+ $user->Load( $this->Application->GetVar('user') );
+
+ if ( !$user->isLoaded() ) {
+ return ;
+ }
+
+ if ( $user_helper->checkLoginPermission() ) {
+ $user_helper->loginUserById( $user->GetID() );
+ }
+ }
}
login_as_user_v4.patch [^] (11,565 bytes) 2011-10-12 05:56
[Show Content]
Index: admin/system_presets/simple/users_u.php
===================================================================
--- admin/system_presets/simple/users_u.php (revision 14653)
+++ admin/system_presets/simple/users_u.php (working copy)
@@ -25,7 +25,7 @@
// toolbar buttons
$remove_buttons = Array (
// list of users; section: Users Management -> Users
- 'users_list' => Array (/*'new_item', 'edit', 'delete', 'approve', 'decline', 'e-mail',*/ 'export', /*'view', 'dbl-click'*/),
+ 'users_list' => Array (/*'new_item', 'edit', 'delete', 'approve', 'decline',*/ 'frontend_mail', /*'e-mail',*/ 'export', /*'view', 'dbl-click'*/),
// "General" tab during user adding/editing
// 'users_edit' => Array ('select', 'cancel', 'reset_edit', 'prev', 'next'),
Index: core/admin_templates/users/users_list.tpl
===================================================================
--- core/admin_templates/users/users_list.tpl (revision 14653)
+++ core/admin_templates/users/users_list.tpl (working copy)
@@ -55,6 +55,22 @@
a_toolbar.AddButton( new ToolBarSeparator('sep2') );
+ a_toolbar.AddButton( new ToolBarButton('frontend_mail', '<inp2:m_phrase label="la_ToolTip_LoginAs" escape="1"/>',
+ function() {
+ var $user_ids = Grids['u.regular'].GetSelected();
+
+ if ($user_ids.length > 1) {
+ alert('<inp2:m_Phrase label="la_error_YouMustSelectOnlyOneUser" js_escape="1"/>');
+ }
+ else {
+ var $user_id = $user_ids.shift(),
+ $url = '<inp2:m_Link template="index" index_file="../index.php" user_id="#USER_ID#" u_event="OnLoginAs" pass="m,u" no_amp="1" js_escape="1"/>';
+
+ window.open($url.replace('#USER_ID#', $user_id), 'frontend_login');
+ }
+ }
+ ) );
+
<inp2:m_if check="m_ModuleEnabled" module="In-Portal">
a_toolbar.AddButton(
new ToolBarButton(
@@ -93,6 +109,6 @@
<inp2:m_RenderElement name="grid" PrefixSpecial="u.regular" IdField="PortalUserId" grid="RegularUsers"/>
<script type="text/javascript">
- Grids['u.regular'].SetDependantToolbarButtons( new Array('edit', 'delete', 'setprimary', 'e-mail', 'approve', 'decline') );
+ Grids['u.regular'].SetDependantToolbarButtons( new Array('edit', 'delete', 'setprimary', 'frontend_mail', 'e-mail', 'approve', 'decline') );
</script>
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Index: core/install/english.lang
===================================================================
--- core/install/english.lang (revision 14662)
+++ core/install/english.lang (working copy)
@@ -258,6 +258,7 @@
<PHRASE Label="la_error_unknown_category" Module="Core" Type="1">VW5rbm93biBzZWN0aW9u</PHRASE>
<PHRASE Label="la_error_UserBanned" Module="Core" Type="1">VXNlciBCYW5uZWQ=</PHRASE>
<PHRASE Label="LA_ERROR_USERNOTFOUND" Module="Core" Type="1">dXNlciBub3QgZm91bmQ=</PHRASE>
+ <PHRASE Label="la_error_YouMustSelectOnlyOneUser" Module="Core" Type="1">WW91IG11c3Qgc2VsZWN0IG9ubHkgb25lIHVzZXI=</PHRASE>
<PHRASE Label="la_err_bad_date_format" Module="Core" Type="1">SW5jb3JyZWN0IGRhdGUgZm9ybWF0LCBwbGVhc2UgdXNlICglcykgZXguICglcyk=</PHRASE>
<PHRASE Label="la_err_bad_type" Module="Core" Type="1">SW5jb3JyZWN0IGRhdGEgZm9ybWF0LCBwbGVhc2UgdXNlICVz</PHRASE>
<PHRASE Label="la_err_invalid_format" Module="Core" Type="1">SW52YWxpZCBGb3JtYXQ=</PHRASE>
@@ -1377,6 +1378,7 @@
<PHRASE Label="la_ToolTip_Home" Module="Core" Type="1">SG9tZQ==</PHRASE>
<PHRASE Label="la_ToolTip_Import" Module="Core" Type="1">SW1wb3J0</PHRASE>
<PHRASE Label="la_ToolTip_ImportLanguage" Module="Core" Type="1">SW1wb3J0IExhbmd1YWdl</PHRASE>
+ <PHRASE Label="la_ToolTip_LoginAs" Module="Core" Type="1">TG9naW4gQXM=</PHRASE>
<PHRASE Label="la_ToolTip_MoveDown" Module="Core" Type="1">TW92ZSBEb3du</PHRASE>
<PHRASE Label="la_ToolTip_MoveUp" Module="Core" Type="1">TW92ZSBVcA==</PHRASE>
<PHRASE Label="la_ToolTip_NewAgent" Module="Core" Type="1">TmV3IEFnZW50</PHRASE>
Index: core/kernel/managers/request_manager.php
===================================================================
--- core/kernel/managers/request_manager.php (revision 14653)
+++ core/kernel/managers/request_manager.php (working copy)
@@ -117,7 +117,7 @@
if ( !$this->Application->EventManager->verifyEventPrefix($event, true) ) {
$false = false;
-
+
return $false;
}
@@ -167,7 +167,7 @@
protected function performRedirect(&$event)
{
// we need to pass category if the action was submitted to self-template, with the category passed
- // and it has not explicly set redirect template or pass_cateogry param
+ // and it has not explicitly set redirect template or pass_cateogry param
if ( $this->samePageRedirect($event) && ($event->getEventParam('pass_category') === false) && $this->Application->GetVar('m_cat_id') ) {
$event->SetRedirectParam('pass_category', 1);
}
Index: core/kernel/utility/http_query.php
===================================================================
--- core/kernel/utility/http_query.php (revision 14653)
+++ core/kernel/utility/http_query.php (working copy)
@@ -19,7 +19,7 @@
/**
* Cache of QueryString parameters
* from config, that are represented
- * in enviroment variable
+ * in environment variable
*
* @var Array
*/
@@ -96,7 +96,6 @@
* related arrays into common place
*
* @param string $order
- * @return HTTPQuery
* @access public
*/
public function __construct($order = 'CGPF')
@@ -276,7 +275,7 @@
/**
* Allow POST variables, that names were transformed by PHP ("." replaced with "_") to
- * override variables, that were virtually created through enviroment variable parsing
+ * override variables, that were virtually created through environment variable parsing
*
*/
function _processPostEnvVariables()
@@ -454,7 +453,7 @@
foreach ($work_copy as $prefix_file_key) {
$inner_anchor =& $inner_anchor[$prefix_file_key];
}
-
+
$anchor[$field_name][$file_key] = $inner_anchor[$field_name];
}
}
@@ -499,7 +498,7 @@
if ( is_array($events) ) {
$events = array_filter($events);
-
+
foreach ($events as $prefix_special => $event_name) {
$this->Set($prefix_special . '_event', $event_name);
}
@@ -534,32 +533,42 @@
{
$mod_rw_helper =& $this->Application->recallObject('ModRewriteHelper');
/* @var $mod_rw_helper kModRewriteHelper */
-
+
$mod_rw_helper->processRewriteURL();
}
function getDefaultTemplate($t)
{
- $t = $this->getTemplateName( trim($t, '/') );
- if (!$t) $t = 'index';
+ $t = $this->getTemplateName(trim($t, '/'));
+
+ if ( !$t ) {
+ $t = 'index';
+ }
+
return trim($t, '/');
}
function extractSIDAndTemplate(&$parts)
{
+ $template = '';
$vars = Array ();
- $sub_parts = array_shift($parts);
- list ($sid, $t) = explode('-', $sub_parts, 2);
+ if ( preg_match('/^([\d]+|)-(.*)$/', $parts[0], $regs) ) {
+ // first "env" component matches "sid-template" format
+ // (will be false, when mod-rewrite url to home page is built)
+ $sid = $regs[1];
+ $template = $regs[2];
+ array_shift($parts);
- if ($sid) {
- // Save Session ID
- $this->Set('sid', $sid);
- $vars['sid'] = $sid;
+ if ( $sid ) {
+ // Save Session ID
+ $this->Set('sid', $sid);
+ $vars['sid'] = $sid;
+ }
}
// Save Template Name
- $vars['t'] = $this->getDefaultTemplate($t);
+ $vars['t'] = $this->getDefaultTemplate($template);
return $vars;
}
@@ -570,13 +579,13 @@
* set template name and sid in
* desired application variables.
*
- * @param string $env_var enviroment string value
+ * @param string $env_var environment string value
*
* @access public
*/
function processQueryString($env_var, $pass_name = 'passed')
{
- // env=SID:TEMPLATE:m-1-1-1-1:l0-0-0:n-0-0-0:bb-0-0-1-1-1-0
+ // env=SID-TEMPLATE:m-1-1-1-1:l0-0-0:n-0-0-0:bb-0-0-1-1-1-0
$vars = Array ();
if ($env_var) {
$more_vars = strpos($env_var, '&');
@@ -612,7 +621,7 @@
}
/**
- * Converts enviroment part into variable array (based on query map for given prefix)
+ * Converts environment part into variable array (based on query map for given prefix)
*
* @param string $mixed_part
* @return Array
@@ -659,13 +668,13 @@
*/
function getTemplateName($t)
{
- if (array_key_exists('t', $this->Get) && $this->Get['t']) {
+ if ( array_key_exists('t', $this->Get) && $this->Get['t'] ) {
// template name is passed directly in url (GET method)
$t = $this->Get['t'];
}
// if t was set through env, even in mod_rewrite mode!
- if ($this->Get('env') && $this->Application->RewriteURLs() && $this->Get('t')) {
+ if ( $this->Get('env') && $this->Application->RewriteURLs() && $this->Get('t') ) {
$t = $this->Get('t');
}
Index: core/units/users/users_config.php
===================================================================
--- core/units/users/users_config.php (revision 14653)
+++ core/units/users/users_config.php (working copy)
@@ -123,7 +123,7 @@
'users_list' => Array (
'prefixes' => Array ('u_List'), 'format' => "!la_title_Users!",
- 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'approve', 'decline', 'e-mail', 'export', 'view', 'dbl-click'),
+ 'toolbar_buttons' => Array ('new_item', 'edit', 'delete', 'setprimary', 'approve', 'decline', 'frontend_mail', 'e-mail', 'export', 'view', 'dbl-click'),
),
'users_edit' => Array (
Index: core/units/users/users_event_handler.php
===================================================================
--- core/units/users/users_event_handler.php (revision 14653)
+++ core/units/users/users_event_handler.php (working copy)
@@ -133,6 +133,13 @@
return defined('DBG_RESET_ROOT') && DBG_RESET_ROOT;
}
+ if ( $event->Name == 'OnLoginAs' ) {
+ $admin_session =& $this->Application->recallObject('Session.admin');
+ /* @var $admin_session Session */
+
+ return $admin_session->LoggedIn();
+ }
+
if ( !$this->Application->isAdminUser ) {
$user_id = $this->Application->RecallVar('user_id');
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
@@ -1761,4 +1768,28 @@
$event->SetRedirectParam('reset', 1);
$event->SetRedirectParam('pass', 'm');
}
+
+ /**
+ * Perform login of user, selected in Admin Console, on Front-End in a separate window
+ *
+ * @param kEvent $event
+ * @return void
+ * @access protected
+ */
+ protected function OnLoginAs(kEvent &$event)
+ {
+ $user_helper =& $this->Application->recallObject('UserHelper');
+ /* @var $user_helper UserHelper */
+
+ $user =& $user_helper->getUserObject();
+ $user->Load( $this->Application->GetVar('user_id') );
+
+ if ( !$user->isLoaded() ) {
+ return ;
+ }
+
+ if ( $user_helper->checkLoginPermission() ) {
+ $user_helper->loginUserById( $user->GetID() );
+ }
+ }
}
Index: core/units/users/users_tag_processor.php
===================================================================
--- core/units/users/users_tag_processor.php (revision 14653)
+++ core/units/users/users_tag_processor.php (working copy)
@@ -19,7 +19,7 @@
function LogoutLink($params)
{
- $pass = Array('pass' => 'all,m,u', 'u_event' => 'OnLogout', 'm_cat_id' => 0, '__NO_REWRITE__' => 1);
+ $pass = Array('pass' => 'all,m,u', 'u_event' => 'OnLogout', 'm_cat_id' => 0);
$logout_template = $this->SelectParam($params, 'template,t');
return $this->Application->HREF($logout_template, '', $pass);
}
|