public static function display_login($record, $nolink, $desc) { $v = $record[$desc['id']]; if (!$v) { return '---'; } if (!is_numeric($v)) { return $v; } $login = Base_UserCommon::get_user_login($v); if (!$nolink && Base_AclCommon::i_am_admin() && is_numeric($v)) { $login = Utils_RecordBrowserCommon::record_link_open_tag('contact', $record['id']) . $login . Utils_RecordBrowserCommon::record_link_close_tag(); } if (!Base_UserCommon::is_active($v)) { $login = $login . ' [' . 'user inactive' . ']'; } return $login; }
public function user_actions($r, $gb_row) { static $admin_levels = false; static $my_level = false; if ($admin_levels === false) { $admin_levels = DB::GetAssoc('SELECT id,admin FROM user_login'); } if ($my_level === false) { $my_level = isset($admin_levels[Base_AclCommon::get_user()]) ? $admin_levels[Base_AclCommon::get_user()] : 0; } $mod = 'Base_User_Administrator'; $log_as_user = Base_AdminCommon::get_access($mod, 'log_as_user'); $log_as_admin = Base_AdminCommon::get_access($mod, 'log_as_admin'); $user_level = isset($admin_levels[$r['login']]) ? $admin_levels[$r['login']] : 0; // 2 is superadmin, 1 admin, 0 user if ($my_level == 2 || $my_level == 1 && ($user_level == 0 && $log_as_user || $user_level == 1 && $log_as_admin)) { // contact is admin and I can login as admin if (Base_UserCommon::is_active($r['login'])) { $gb_row->add_action($this->create_callback_href(array($this, 'change_user_active_state'), array($r['login'], false)), 'Deactivate user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'active-on.png')); $gb_row->add_action(Module::create_href(array('log_as_user' => $r['login'])), 'Log as user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'restore.png')); // action! if (isset($_REQUEST['log_as_user']) && $_REQUEST['log_as_user'] == $r['login']) { Acl::set_user($r['login'], true); Epesi::redirect(); return; } } else { $gb_row->add_action($this->create_callback_href(array($this, 'change_user_active_state'), array($r['login'], true)), 'Activate user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'active-off.png')); } } }