Пример #1
0
	public function process(Vtiger_Request $request) {
		$moduleName = $request->getModule();
		$userName = $request->get('user_name');
		$viewer = $this->getViewer($request);
		$userModel = Users_Record_Model::getCurrentUserModel();
		$userModuleModel = Users_Module_Model::getInstance($moduleName);
		$userSetupStatus = $userModel->isFirstTimeLogin($userModel->id);
		if($userSetupStatus) {
			$isFirstUser = Users_CRMSetup::isFirstUser($userModel);
			if($isFirstUser) {
				$defaultCurrencyKey = 'USA, Dollars';
				$currencies = $userModuleModel->getCurrenciesList();
				$defaultCurrencyValue = $currencies[$defaultCurrencyKey];
				unset($currencies[$defaultCurrencyKey]);
				$defaultcurrency[$defaultCurrencyKey] = $defaultCurrencyValue;
				$currenciesList = array_merge($defaultcurrency, $currencies);
				$viewer->assign('IS_FIRST_USER', $isFirstUser);
				$viewer->assign('CURRENCIES', $currenciesList);
			}
			$viewer->assign('CURRENT_USER_MODEL',$userModel);
			$viewer->assign('MODULE', $moduleName);
			$viewer->assign('USER_NAME', $userName);
			$viewer->assign('TIME_ZONES', $userModuleModel->getTimeZonesList());
			$viewer->assign('LANGUAGES', $userModuleModel->getLanguagesList());
			$viewer->assign('USER_ID', $request->get('record'));
			$viewer->view('UserSetup.tpl', $moduleName);
		} else {
			header("Location: index.php");
		}
	}
Пример #2
0
 function process(Vtiger_Request $request)
 {
     $username = $request->get('username');
     $password = $request->get('password');
     $user = CRMEntity::getInstance('Users');
     $user->column_fields['user_name'] = $username;
     if ($user->doLogin($password)) {
         $userid = $user->retrieve_user_id($username);
         Vtiger_Session::set('AUTHUSERID', $userid);
         // For Backward compatability
         // TODO Remove when switch-to-old look is not needed
         $_SESSION['authenticated_user_id'] = $userid;
         $_SESSION['app_unique_key'] = vglobal('application_unique_key');
         $_SESSION['authenticated_user_language'] = vglobal('default_language');
         //Enabled session variable for KCFINDER
         $_SESSION['KCFINDER'] = array();
         $_SESSION['KCFINDER']['disabled'] = false;
         $_SESSION['KCFINDER']['uploadURL'] = "test/upload";
         $_SESSION['KCFINDER']['uploadDir'] = "test/upload";
         $deniedExts = implode(" ", vglobal('upload_badext'));
         $_SESSION['KCFINDER']['deniedExts'] = $deniedExts;
         // End
         //Track the login History
         $moduleModel = Users_Module_Model::getInstance('Users');
         $moduleModel->saveLoginHistory($user->column_fields['user_name']);
         //End
         header('Location: index.php?module=Users&parent=Settings&view=SystemSetup');
         exit;
     } else {
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=1');
         exit;
     }
 }
Пример #3
0
	public function process(Vtiger_Request $request) {
		$moduleName = $request->getModule();
		$packages = $request->get(packages);
		$userModuleModel = Users_Module_Model::getInstance($moduleName);
		$userModuleModel::savePackagesInfo($packages);
		header ('Location: index.php?module=Users&parent=Settings&view=UserSetup');
		exit();
	}
Пример #4
0
 function process(Vtiger_Request $request)
 {
     $username = $request->get('username');
     $password = $request->get('password');
     if ($request->get('mode') == 'install') {
         error_reporting(0);
         $dirPath = 'install';
         foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirPath, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) {
             $path->isDir() ? rmdir($path->getPathname()) : unlink($path->getPathname());
         }
         rmdir($dirPath);
     }
     $checkBlocked = Settings_BruteForce_Module_Model::checkBlocked();
     $bruteForceSettings = Settings_BruteForce_Module_Model::getBruteForceSettings();
     if ($checkBlocked && $bruteForceSettings['active']) {
         Settings_BruteForce_Module_Model::sendNotificationEmail();
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=2');
         exit;
     }
     $user = CRMEntity::getInstance('Users');
     $user->column_fields['user_name'] = $username;
     $moduleModel = Users_Module_Model::getInstance('Users');
     if ($user->doLogin($password)) {
         if (vglobal('session_regenerate_id')) {
             session_regenerate_id(true);
         }
         // to overcome session id reuse.
         $userid = $user->retrieve_user_id($username);
         Vtiger_Session::set('AUTHUSERID', $userid);
         // For Backward compatability
         // TODO Remove when switch-to-old look is not needed
         $_SESSION['authenticated_user_id'] = $userid;
         $_SESSION['app_unique_key'] = vglobal('application_unique_key');
         $_SESSION['authenticated_user_language'] = vglobal('default_language');
         $_SESSION['user_name'] = $username;
         $_SESSION['full_user_name'] = Vtiger_Functions::getUserRecordLabel($userid);
         //Enabled session variable for KCFINDER
         $_SESSION['KCFINDER'] = array();
         $_SESSION['KCFINDER']['disabled'] = false;
         $_SESSION['KCFINDER']['uploadURL'] = "cache/upload";
         $_SESSION['KCFINDER']['uploadDir'] = "../../cache/upload";
         $deniedExts = implode(" ", vglobal('upload_badext'));
         $_SESSION['KCFINDER']['deniedExts'] = $deniedExts;
         // End
         //Track the login History
         $moduleModel->saveLoginHistory($user->column_fields['user_name']);
         //End
         header('Location: index.php');
         exit;
     } else {
         //Track the login History
         $browser = Settings_BruteForce_Module_Model::browserDetect();
         $moduleModel->saveLoginHistory($username, 'Failed login', $browser);
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=1');
         exit;
     }
 }
Пример #5
0
 function process(Vtiger_Request $request)
 {
     Vtiger_Session::destroy();
     //Track the logout History
     $moduleName = $request->getModule();
     $moduleModel = Users_Module_Model::getInstance($moduleName);
     $moduleModel->saveLogoutHistory();
     //End
     header('Location: index.php');
 }
Пример #6
0
 function process(Vtiger_Request $request)
 {
     session_regenerate_id(true);
     // to overcome session id reuse.
     Vtiger_Session::destroy();
     //Track the logout History
     $moduleName = $request->getModule();
     $moduleModel = Users_Module_Model::getInstance($moduleName);
     $moduleModel->saveLogoutHistory();
     //End
     header('Location: index.php');
 }
 public function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $packages = $request->get(packages);
     $userModuleModel = Users_Module_Model::getInstance($moduleName);
     $userModuleModel::savePackagesInfo($packages);
     //SalesPlatform.ru begin
     create_tab_data_file();
     create_parenttab_data_file();
     //SalesPlatform.ru end
     header('Location: index.php?module=Users&parent=Settings&view=UserSetup');
     exit;
 }
Пример #8
0
 public function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $userId = vtws_getWebserviceEntityId($moduleName, $request->get('userid'));
     $transformUserId = vtws_getWebserviceEntityId($moduleName, $request->get('transfer_user_id'));
     $userModel = Users_Record_Model::getCurrentUserModel();
     $userModuleModel = Users_Module_Model::getInstance($moduleName);
     $result = vtws_deleteUser($userId, $transformUserId, $userModel);
     $listViewUrl = $userModuleModel->getListViewUrl();
     $response = new Vtiger_Response();
     $response->setResult(array('message' => vtranslate('LBL_USER_DELETED_SUCCESSFULLY', $moduleName), 'listViewUrl' => $listViewUrl));
     $response->emit();
 }
Пример #9
0
 public function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $qualifiedModuleName = $request->getModule(false);
     $settingsModel = Settings_Users_Module_Model::getInstance();
     $usersModel = Users_Module_Model::getInstance($moduleName);
     $notAdminUsers = $usersModel::getNotAdminUsers();
     $viewer = $this->getViewer($request);
     $viewer->assign('NOT_ADMIN_USERS', $notAdminUsers);
     $viewer->assign('MODULE_MODEL', $settingsModel);
     $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName);
     $viewer->assign('MODULE', $moduleName);
     $viewer->view('Auth.tpl', $qualifiedModuleName);
 }
Пример #10
0
 function process(Vtiger_Request $request)
 {
     vimport('~include/events/include.inc');
     $db = PearDatabase::getInstance();
     $em = new VTEventsManager($db);
     $em->initTriggerCache();
     $em->triggerEvent('user.logout.before', []);
     Vtiger_Session::regenerateId(true);
     // to overcome session id reuse.
     Vtiger_Session::destroy();
     //Track the logout History
     $moduleName = $request->getModule();
     $moduleModel = Users_Module_Model::getInstance($moduleName);
     $moduleModel->saveLogoutHistory();
     //End
     header('Location: index.php');
 }
Пример #11
0
 public function process(Vtiger_Request $request)
 {
     $searchValue = $request->get('search_value');
     $searchModule = $request->get('search_module');
     $parentRecordId = $request->get('parent_id');
     $parentModuleName = $request->get('parent_module');
     $searchModuleModel = Users_Module_Model::getInstance($searchModule);
     $records = $searchModuleModel->searchRecord($searchValue, $parentRecordId, $parentModuleName);
     $result = array();
     foreach ($records as $moduleName => $recordModels) {
         foreach ($recordModels as $recordModel) {
             $result[] = array('label' => decode_html($recordModel->getName()), 'value' => decode_html($recordModel->getName()), 'id' => $recordModel->getId());
         }
     }
     $response = new Vtiger_Response();
     $response->setResult($result);
     $response->emit();
 }
Пример #12
0
 public function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $userModuleModel = Users_Module_Model::getInstance($moduleName);
     $userRecordModel = Users_Record_Model::getCurrentUserModel();
     //Handling the user preferences
     $userRecordModel->set('mode', 'edit');
     $userRecordModel->set('language', $request->get('lang_name'));
     $userRecordModel->set('time_zone', $request->get('time_zone'));
     $userRecordModel->set('date_format', $request->get('date_format'));
     $userRecordModel->save();
     //End
     //Handling the System Setup
     $currencyName = $request->get('currency_name');
     if (!empty($currencyName)) {
         $userModuleModel->updateBaseCurrency($currencyName);
     }
     $userModuleModel->insertEntryIntoCRMSetup($userRecordModel->getId());
     //End
     header("Location: index.php");
     //End
 }
Пример #13
0
 /**
  * Function to save user fields in vtiger_profile2field table
  * We need user field values to generating the Email Templates variable valuues.
  * @param type $profileId
  */
 public function saveUserAccessbleFieldsIntoProfile2Field()
 {
     $profileId = $this->getId();
     if (!empty($profileId)) {
         $db = PearDatabase::getInstance();
         $userRecordModel = Users_Record_Model::getCurrentUserModel();
         $module = $userRecordModel->getModuleName();
         $tabId = getTabid($module);
         $userModuleModel = Users_Module_Model::getInstance($module);
         $moduleFields = $userModuleModel->getFields();
         $userAccessbleFields = array();
         $skipFields = array(98, 115, 116, 31, 32);
         foreach ($moduleFields as $fieldName => $fieldModel) {
             if ($fieldModel->getFieldDataType() == 'string' || $fieldModel->getFieldDataType() == 'email' || $fieldModel->getFieldDataType() == 'phone') {
                 if (!in_array($fieldModel->get('uitype'), $skipFields) && $fieldName != 'asterisk_extension') {
                     $userAccessbleFields[$fieldModel->get('id')] .= $fieldName;
                 }
             }
         }
         //Added user fields into vtiger_profile2field and vtiger_def_org_field
         //We are using this field information in Email Templates.
         foreach ($userAccessbleFields as $fieldId => $fieldName) {
             $insertQuery = 'INSERT INTO vtiger_profile2field VALUES(?,?,?,?,?)';
             $db->pquery($insertQuery, array($profileId, $tabId, $fieldId, Settings_Profiles_Module_Model::FIELD_ACTIVE, Settings_Profiles_Module_Model::FIELD_READWRITE));
         }
         $sql = 'SELECT fieldid FROM vtiger_def_org_field WHERE tabid = ?';
         $result1 = $db->pquery($sql, array($tabId));
         $def_org_fields = array();
         for ($j = 0; $j < $db->num_rows($result1); $j++) {
             array_push($def_org_fields, $db->query_result($result1, $j, 'fieldid'));
         }
         foreach ($userAccessbleFields as $fieldId => $fieldName) {
             if (!in_array($fieldId, $def_org_fields)) {
                 $insertQuery = 'INSERT INTO vtiger_def_org_field VALUES(?,?,?,?)';
                 $db->pquery($insertQuery, array($tabId, $fieldId, 0, 0));
             }
         }
     }
 }
Пример #14
0
 public function restoreUser(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $record = $request->get('userid');
     $recordModel = Users_Record_Model::getInstanceById($record, $moduleName);
     $recordModel->set('status', 'Active');
     $recordModel->set('id', $record);
     $recordModel->set('mode', 'edit');
     $recordModel->set('user_hash', $recordModel->getUserHash());
     $recordModel->save();
     $db = PearDatabase::getInstance();
     $db->pquery("UPDATE vtiger_users SET deleted=? WHERE id=?", array(0, $record));
     $userModuleModel = Users_Module_Model::getInstance($moduleName);
     $listViewUrl = $userModuleModel->getListViewUrl();
     $response = new Vtiger_Response();
     $response->setResult(array('message' => vtranslate('LBL_USER_RESTORED_SUCCESSFULLY', $moduleName), 'listViewUrl' => $listViewUrl));
     $response->emit();
 }
Пример #15
0
 function process(Vtiger_Request $request)
 {
     $username = $request->get('username');
     $password = $request->get('password');
     if ($request->get('mode') == 'install') {
         $dirPath = 'install';
         Users_Module_Model::deleteLangFiles();
         $configTemplate = "config/config.template.php";
         if (file_exists($configTemplate)) {
             unlink($configTemplate);
         }
         Vtiger_Functions::recurseDelete($dirPath);
     }
     $checkBlocked = Settings_BruteForce_Module_Model::checkBlocked();
     $bruteForceSettings = Settings_BruteForce_Module_Model::getBruteForceSettings();
     if ($checkBlocked && $bruteForceSettings['active']) {
         Settings_BruteForce_Module_Model::sendNotificationEmail();
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=2');
         exit;
     }
     $user = CRMEntity::getInstance('Users');
     $user->column_fields['user_name'] = $username;
     $moduleModel = Users_Module_Model::getInstance('Users');
     if ($user->doLogin($password)) {
         if (vglobal('session_regenerate_id')) {
             Vtiger_Session::regenerateId(true);
         }
         // to overcome session id reuse.
         $userid = $user->retrieve_user_id($username);
         Vtiger_Session::set('AUTHUSERID', $userid);
         // For Backward compatability
         // TODO Remove when switch-to-old look is not needed
         Vtiger_Session::set('authenticated_user_id', $userid);
         Vtiger_Session::set('app_unique_key', vglobal('application_unique_key'));
         Vtiger_Session::set('authenticated_user_language', vglobal('default_language'));
         Vtiger_Session::set('user_name', $username);
         Vtiger_Session::set('full_user_name', Vtiger_Functions::getUserRecordLabel($userid));
         if ($request->has('language') && vglobal('langInLoginView')) {
             Vtiger_Session::set('language', $request->get('language'));
         }
         if ($request->has('layout')) {
             Vtiger_Session::set('layout', $request->get('layout'));
         }
         //Enabled session variable for KCFINDER
         $_SESSION['KCFINDER'] = array();
         $_SESSION['KCFINDER']['disabled'] = false;
         $_SESSION['KCFINDER']['uploadURL'] = "cache/upload";
         $_SESSION['KCFINDER']['uploadDir'] = "../../cache/upload";
         $deniedExts = implode(" ", vglobal('upload_badext'));
         $_SESSION['KCFINDER']['deniedExts'] = $deniedExts;
         // End
         //Track the login History
         $moduleModel->saveLoginHistory($user->column_fields['user_name']);
         //End
         if (isset($_SESSION['return_params'])) {
             $return_params = urldecode($_SESSION['return_params']);
             header("Location: index.php?{$return_params}");
             exit;
         } else {
             header('Location: index.php');
             exit;
         }
     } else {
         //Track the login History
         $browser = Settings_BruteForce_Module_Model::browserDetect();
         $moduleModel->saveLoginHistory($username, 'Failed login', $browser);
         header('Location: index.php?module=Users&parent=Settings&view=Login&error=1');
         exit;
     }
 }