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 @@ \ 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 @@ QXV0by1EZXRlY3Q= Q29va2llcw== UXVlcnkgU3RyaW5nIChTSUQp + WW91IG11c3Qgc2VsZWN0IG9ubHkgb25lIHVzZXI= U3ViamVjdDogTmV3IENhdGVnb3J5ICI8aW5wMjpjX0ZpZWxkIG5hbWU9Ik5hbWUiLz4iIC0gQWRkZWQKCllvdXIgc3VnZ2VzdGVkIGNhdGVnb3J5ICI8aW5wMjpjX0ZpZWxkIG5hbWU9Ik5hbWUiLz4iIGhhcyBiZWVuIGFkZGVkLg== 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') ); + } }