예제 #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;
 }
예제 #2
0
	public function checkPermission(Vtiger_Request $request) {
		$currentUserModel = Users_Record_Model::getCurrentUserModel();
		$record = $request->get('record');

		if (!SysSecurity::getBoolean('SHOW_MY_PREFERENCES')) {
			throw new AppException('LBL_PERMISSION_DENIED');
		}
		if($currentUserModel->isAdminUser() == true || $currentUserModel->get('id') == $record) {
			return true;
		} else {
			throw new AppException('LBL_PERMISSION_DENIED');
		}
	}
예제 #3
0
	public function checkPermission(Vtiger_Request $request)
	{
		$moduleName = $request->getModule();
		$currentUserModel = Users_Record_Model::getCurrentUserModel();
		$record = $request->get('record');
		if (!SysSecurity::getBoolean('SHOW_MY_PREFERENCES')) {
			throw new AppException('LBL_PERMISSION_DENIED');
		}
		if (!empty($record) && $currentUserModel->get('id') != $record) {
			$recordModel = Vtiger_Record_Model::getInstanceById($record, $moduleName);
			if ($recordModel->get('status') != 'Active') {
				throw new AppException('LBL_PERMISSION_DENIED');
			}
		}
		if (($currentUserModel->isAdminUser() == true || $currentUserModel->get('id') == $record)) {
			return true;
		} else {
			throw new AppException('LBL_PERMISSION_DENIED');
		}
	}
예제 #4
0
 public static function run($request)
 {
     $instance = new self();
     if (isset($_REQUEST['user_name']) && isset($_REQUEST['emailId'])) {
         if (SysSecurity::get('RESET_LOGIN_PASSWORD')) {
             $instance->requestForgotPassword($request);
         } else {
             die(vtranslate('LBL_PERMISSION_DENIED'));
         }
     } else {
         $instance->changePassword($request);
     }
 }
예제 #5
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;
 }