Ejemplo n.º 1
0
 /**
  * Function to get the list of Header Links
  * @return <Array> - List of Vtiger_Link_Model instances
  */
 function getHeaderLinks()
 {
     $userModel = Users_Record_Model::getCurrentUserModel();
     $headerLinks = [];
     $userPersonalSettingsLinks = ['linktype' => 'HEADERLINK', 'linklabel' => $userModel->getDisplayName(), 'linkurl' => '', 'linkicon' => ''];
     if (SysSecurity::getBoolean('SHOW_MY_PREFERENCES')) {
         $userPersonalSettingsLinks['childlinks'][] = ['linktype' => 'HEADERLINK', 'linklabel' => 'LBL_MY_PREFERENCES', 'linkurl' => $userModel->getPreferenceDetailViewUrl(), 'linkicon' => ''];
     }
     $userPersonalSettingsLinks['childlinks'][] = ['linktype' => 'HEADERLINK', 'linklabel' => 'LBL_SIGN_OUT', 'linkurl' => '?module=Users&parent=Settings&action=Logout', 'linkicon' => ''];
     array_push($headerLinks, $userPersonalSettingsLinks);
     if ($userModel->isAdminUser()) {
         $crmSettingsLink = array('linktype' => 'HEADERLINK', 'linklabel' => 'LBL_SYSTEM_SETTINGS', 'linkurl' => '', 'linkicon' => 'setting.png', 'nocaret' => true, 'childlinks' => array(array('linktype' => 'HEADERLINK', 'linklabel' => 'LBL_SYSTEM_SETTINGS', 'linkurl' => '?module=Vtiger&parent=Settings&view=Index', 'linkicon' => ''), array('linktype' => 'HEADERLINK', 'linklabel' => 'LBL_MANAGE_USERS', 'linkurl' => '?module=Users&parent=Settings&view=List', 'linkicon' => '')));
         array_push($headerLinks, $crmSettingsLink);
     }
     require 'user_privileges/switchUsers.php';
     $baseUserId = $userModel->getId();
     if (Vtiger_Session::has('baseUserId') && Vtiger_Session::get('baseUserId') != '') {
         $baseUserId = Vtiger_Session::get('baseUserId');
     }
     if (key_exists($baseUserId, $switchUsers)) {
         $childlinks = [];
         if (Vtiger_Session::has('baseUserId') && Vtiger_Session::get('baseUserId') != '') {
             $user = new Users();
             $currentUser = $user->retrieveCurrentUserInfoFromFile($baseUserId);
             $userName = $currentUser->column_fields['first_name'] . ' ' . $currentUser->column_fields['last_name'];
             $childlinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => $userName, 'linkurl' => '?module=Users&action=SwitchUsers&id=' . $baseUserId, 'linkicon' => ''];
             $childlinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => NULL];
         }
         foreach ($switchUsers[$baseUserId] as $userid => $userName) {
             if ($userid != $baseUserId) {
                 $childlinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => $userName, 'linkurl' => '?module=Users&action=SwitchUsers&id=' . $userid, 'linkicon' => ''];
             }
         }
         $customHeaderLinks = ['linktype' => 'HEADERLINK', 'linklabel' => 'SwitchUsers', 'linkurl' => '', 'linkicon' => 'glyphicon glyphicon-transfer', 'nocaret' => true, 'childlinks' => $childlinks];
         array_push($headerLinks, $customHeaderLinks);
     }
     $headerLinkInstances = [];
     $index = 0;
     foreach ($headerLinks as $headerLink) {
         $headerLinkInstance = Vtiger_Link_Model::getInstanceFromValues($headerLink);
         if (isset($headerLink['childlinks'])) {
             foreach ($headerLink['childlinks'] as $childLink) {
                 $headerLinkInstance->addChildLink(Vtiger_Link_Model::getInstanceFromValues($childLink));
             }
         }
         $headerLinkInstances[$index++] = $headerLinkInstance;
     }
     $headerLinks = Vtiger_Link_Model::getAllByType(Vtiger_Link::IGNORE_MODULE, ['HEADERLINK']);
     foreach ($headerLinks as $headerType => $headerLinks) {
         foreach ($headerLinks as $headerLink) {
             $headerLinkInstances[$index++] = Vtiger_Link_Model::getInstanceFromLinkObject($headerLink);
         }
     }
     return $headerLinkInstances;
 }
Ejemplo n.º 2
0
 function checkPermission(Vtiger_Request $request)
 {
     $userId = $request->get('id');
     require 'user_privileges/switchUsers.php';
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $baseUserId = $currentUserModel->getId();
     if (Vtiger_Session::has('baseUserId') && Vtiger_Session::get('baseUserId') != '') {
         $baseUserId = Vtiger_Session::get('baseUserId');
     }
     if (!key_exists($baseUserId, $switchUsers) || !key_exists($userId, $switchUsers[$baseUserId])) {
         $dbLog = PearDatabase::getInstance('log');
         $dbLog->insert('l_yf_switch_users', ['baseid' => $baseUserId, 'destid' => $userId, 'busername' => $currentUserModel->getName(), 'dusername' => '', 'date' => date('Y-m-d H:i:s'), 'ip' => Vtiger_Functions::getRemoteIP(), 'agent' => $_SERVER['HTTP_USER_AGENT'], 'status' => 'Failed login - No permission']);
         throw new AppException('LBL_PERMISSION_DENIED');
     }
 }
Ejemplo n.º 3
0
 public function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $users = Users_Module_Model::getSwitchUsers();
     $userId = $request->get('id');
     $baseUserId = $userId;
     if (Vtiger_Session::has('baseUserId') && Vtiger_Session::get('baseUserId') != '') {
         $baseUserId = Vtiger_Session::get('baseUserId');
     }
     unset($users[$baseUserId]);
     unset($users[$userId]);
     $viewer = $this->getViewer($request);
     $viewer->assign('SWITCH_USERS', $users);
     $viewer->assign('MODULE_NAME', $moduleName);
     $viewer->assign('BASE_USER_ID', $baseUserId);
     $this->preProcess($request);
     $viewer->view('SwitchUsers.tpl', $moduleName);
     $this->postProcess($request);
 }
Ejemplo n.º 4
0
 /**
  * Function to get the list of Header Links
  * @return <Array> - List of Vtiger_Link_Model instances
  */
 public function getHeaderLinks(Vtiger_Request $request)
 {
     $userModel = Users_Record_Model::getCurrentUserModel();
     $headerLinks = [];
     if ($userModel->isAdminUser()) {
         if ($request->get('parent') != 'Settings') {
             $headerLinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => 'LBL_SYSTEM_SETTINGS', 'linkurl' => 'index.php?module=Vtiger&parent=Settings&view=Index', 'glyphicon' => 'glyphicon glyphicon-cog'];
         } else {
             $headerLinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => 'LBL_USER_PANEL', 'linkurl' => 'index.php', 'glyphicon' => 'glyphicon glyphicon-user'];
         }
     }
     //TODO To remove in the future
     if (SysSecurity::getBoolean('SHOW_MY_PREFERENCES')) {
         $headerLinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => 'LBL_MY_PREFERENCES', 'linkurl' => $userModel->getPreferenceDetailViewUrl(), 'glyphicon' => 'glyphicon glyphicon-tasks'];
     }
     $headerLinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => 'LBL_SIGN_OUT', 'linkurl' => 'index.php?module=Users&parent=Settings&action=Logout', 'glyphicon' => 'glyphicon glyphicon-off'];
     require 'user_privileges/switchUsers.php';
     $baseUserId = $userModel->getId();
     if (Vtiger_Session::has('baseUserId') && Vtiger_Session::get('baseUserId') != '') {
         $baseUserId = Vtiger_Session::get('baseUserId');
     }
     if (key_exists($baseUserId, $switchUsers)) {
         $childlinks = [];
         if (Vtiger_Session::has('baseUserId') && Vtiger_Session::get('baseUserId') != '') {
             $entityData = Vtiger_Functions::getEntityModuleInfo('Users');
             $user = new Users();
             $currentUser = $user->retrieveCurrentUserInfoFromFile($baseUserId);
             $colums = [];
             foreach (explode(',', $entityData['fieldname']) as $fieldname) {
                 $colums[] = $currentUser->column_fields[$fieldname];
             }
             $userName = implode(' ', $colums);
             $childlinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => $userName, 'linkurl' => '?module=Users&action=SwitchUsers&id=' . $baseUserId, 'linkicon' => ''];
             $childlinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => NULL];
         }
         foreach ($switchUsers[$baseUserId] as $userid => $userName) {
             if ($userid != $baseUserId) {
                 $childlinks[] = ['linktype' => 'HEADERLINK', 'linklabel' => $userName, 'linkurl' => '?module=Users&action=SwitchUsers&id=' . $userid, 'linkicon' => ''];
             }
         }
         $customHeaderLinks = ['linktype' => 'HEADERLINK', 'linklabel' => 'SwitchUsers', 'linkurl' => '', 'glyphicon' => 'glyphicon glyphicon-transfer', 'nocaret' => true, 'childlinks' => $childlinks];
         if (count($childlinks)) {
             array_push($headerLinks, $customHeaderLinks);
         }
     }
     $headerLinkInstances = [];
     foreach ($headerLinks as $headerLink) {
         $headerLinkInstance = Vtiger_Link_Model::getInstanceFromValues($headerLink);
         if (isset($headerLink['childlinks'])) {
             foreach ($headerLink['childlinks'] as $childLink) {
                 $headerLinkInstance->addChildLink(Vtiger_Link_Model::getInstanceFromValues($childLink));
             }
         }
         $headerLinkInstances[] = $headerLinkInstance;
     }
     $headerLinks = Vtiger_Link_Model::getAllByType(Vtiger_Link::IGNORE_MODULE, ['HEADERLINK']);
     foreach ($headerLinks as $headerType => $headerLinks) {
         foreach ($headerLinks as $headerLink) {
             $headerLinkInstances[] = Vtiger_Link_Model::getInstanceFromLinkObject($headerLink);
         }
     }
     return $headerLinkInstances;
 }
Ejemplo n.º 5
0
 public static function getSwitchUsers()
 {
     $userModel = Users_Record_Model::getCurrentUserModel();
     require 'user_privileges/switchUsers.php';
     $baseUserId = $userModel->getId();
     if (Vtiger_Session::has('baseUserId') && Vtiger_Session::get('baseUserId') != '') {
         $baseUserId = Vtiger_Session::get('baseUserId');
     }
     $users = [];
     if (array_key_exists($baseUserId, $switchUsers)) {
         foreach ($switchUsers[$baseUserId] as $userid => $userName) {
             $users[$userid] = $userName;
         }
         if (count($users) > 1) {
             return $users;
         }
     }
     return [];
 }
Ejemplo n.º 6
0
 public static function setSessionQuery($currentModule, $query, $viewid)
 {
     if (Vtiger_Session::has($currentModule . '_listquery')) {
         if (Vtiger_Session::get($currentModule . '_listquery') != $query) {
             Vtiger_Session::remove($currentModule . '_DetailView_Navigation' . $viewid);
         }
     }
     Vtiger_Session::set($currentModule . '_listquery', $query);
 }