function process(Vtiger_Request $request) { $viewer = $this->getViewer($request); $moduleName = $this->getModule($request); $template = $request->get('template'); $srcField = $request->get('src_field'); $srcRecord = $request->get('src_record'); if (!empty($template)) { $recordModel = Settings_TreesManager_Record_Model::getInstanceById($template); } else { Vtiger_Functions::throwNewException(vtranslate('ERR_TREE_NOT_FOUND', $moduleName)); } if (!$recordModel) { Vtiger_Functions::throwNewException(vtranslate('ERR_TREE_NOT_FOUND', $moduleName)); } $tree = $recordModel->getTree(); $viewer->assign('TREE', Zend_Json::encode($tree)); $viewer->assign('SRC_RECORD', $srcRecord); $viewer->assign('SRC_FIELD', $srcField); $viewer->assign('TEMPLATE', $template); $viewer->assign('MODULE', $moduleName); $viewer->assign('TRIGGER_EVENT_NAME', $request->get('triggerEventName')); $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel()); $viewer->view('TreePopup.tpl', $moduleName); }
public function showTree(Vtiger_Request $request) { $moduleName = $request->getModule(); $sourceModule = $request->get('selectedModule'); $viewer = $this->getViewer($request); $this->template = $this->getTemplate(); if ($this->template) { $recordModel = Settings_TreesManager_Record_Model::getInstanceById($this->template); } else { Vtiger_Functions::throwNewException(vtranslate('ERR_TREE_NOT_FOUND', $moduleName)); } if (!$recordModel) { Vtiger_Functions::throwNewException(vtranslate('ERR_TREE_NOT_FOUND', $moduleName)); } if (!in_array($sourceModule, $this->modules)) { Vtiger_Functions::throwNewException(vtranslate('ERR_MODULE_NOT_FOUND', $moduleName)); } $tree = $this->getCategory(); $treeWithItems = $this->getRecords(); $tree = array_merge($tree, $treeWithItems); $viewer->assign('TREE', Zend_Json::encode($tree)); $viewer->assign('MODULES', $this->modules); $viewer->assign('MODULE', $moduleName); $viewer->assign('SELECTED_MODULE_NAME', $sourceModule); $viewer->assign('CUSTOM_VIEWS', CustomView_Record_Model::getAllByGroup($moduleName)); $viewer->view('AccountsListTree.tpl', $moduleName); }
public function process(Vtiger_Request $request) { $this->preProcess($request); $viewer = $this->getViewer($request); $moduleName = $this->moduleName = $request->getModule(); $srcRecord = $this->src_record = $request->get('src_record'); $srcModule = $this->src_module = $request->get('src_module'); $template = $this->template = $this->getTemplate(); if ($template) { $recordModel = Settings_TreesManager_Record_Model::getInstanceById($template); } else { Vtiger_Functions::throwNewException(vtranslate('ERR_TREE_NOT_FOUND', $moduleName)); } if (!$recordModel) { Vtiger_Functions::throwNewException(vtranslate('ERR_TREE_NOT_FOUND', $moduleName)); } $tree = $this->getCategory(); $treeWithItems = $this->getRecords(); $tree = array_merge($tree, $treeWithItems); $viewer->assign('TREE', Zend_Json::encode($tree)); $viewer->assign('SRC_RECORD', $srcRecord); $viewer->assign('SRC_MODULE', $srcModule); $viewer->assign('TEMPLATE', $template); $viewer->assign('MODULE', $moduleName); $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel()); $viewer->view('TreeCategory.tpl', $moduleName); $this->postProcess($request); }
/** * Load tree field info * @return array */ public function getTreeField() { if ($this->has('fieldTemp')) { return $this->get('fieldTemp'); } $db = PearDatabase::getInstance(); $result = $db->pquery('SELECT tablename,columnname,fieldname,fieldparams FROM vtiger_field WHERE uitype = ? AND tabid = ?', [302, Vtiger_Functions::getModuleId($this->getModuleName())]); if ($db->getRowCount($result) == 0) { Vtiger_Functions::throwNewException(vtranslate('ERR_TREE_NOT_FOUND', $this->getModuleName())); } $fieldTemp = $db->getRow($result); $this->set('fieldTemp', $fieldTemp); return $fieldTemp; }
public function process(Vtiger_Request $request) { if (vglobal('systemMode') == 'demo') { die(Vtiger_Functions::throwNewException('Demo mode is enabled, the installation of modules is disabled')); } $mode = $request->getMode(); if (!empty($mode)) { $this->invokeExposedMethod($mode, $request); return; } $qualifiedModuleName = $request->getModule(false); $viewer = $this->getViewer($request); $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName); $viewer->view('Step1.tpl', $qualifiedModuleName); }
public function process(Vtiger_Request $request) { $systemMode = vglobal('systemMode'); if ($systemMode == 'demo') { die(Vtiger_Functions::throwNewException(vtranslate('LBL_ERROR_IMPORT_IN_DEMO'))); } $mode = $request->getMode(); if (!empty($mode)) { $this->invokeExposedMethod($mode, $request); return; } $qualifiedModuleName = $request->getModule(false); $viewer = $this->getViewer($request); $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName); $viewer->view('Step1.tpl', $qualifiedModuleName); }
public static function imapThrowError($error) { $log = vglobal('log'); $log->error("Error OSSMail_Record_Model::imapConnect(): " . $error); Vtiger_Functions::throwNewException(vtranslate('IMAP_ERROR', 'OSSMailScanner') . ': ' . $error); }
function checkError($message, $dieOnError = false, $query = false, $params = false) { if ($this->hasActiveTransaction) { $this->rollbackTransaction(); } if ($this->dieOnError || $dieOnError) { if (SysDebug::get('DISPLAY_DEBUG_BACKTRACE')) { $queryInfo = ''; if ($query !== false) { $queryInfo .= 'Query: ' . $query . PHP_EOL; } if ($params !== false && $params != NULL) { $queryInfo .= 'Params: ' . implode(',', $params) . PHP_EOL; } $backtrace = Vtiger_Functions::getBacktrace(); $trace = '<pre>' . $queryInfo . $backtrace . '</pre>'; } Vtiger_Functions::throwNewException('Database ERROR: ' . PHP_EOL . $message . PHP_EOL . $trace); } }
/** Function to check the file access is made within web root directory. */ static function checkFileAccess($filepath) { if (!self::isFileAccessible($filepath)) { $log = vglobal('log'); $log->error(__CLASS__ . ':' . __FUNCTION__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($realfilepath, true)); die(Vtiger_Functions::throwNewException("Sorry! Attempt to access restricted file. '" . htmlspecialchars($realfilepath, ENT_QUOTES, vglobal('default_charset')) . "'")); } }
function process(Vtiger_Request $request) { vglobal('log', LoggerManager::getLogger('System')); Vtiger_Session::init(); $forceSSL = vglobal('forceSSL'); if ($forceSSL && !Vtiger_Functions::getBrowserInfo()->https) { header("Location: https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"); } // Better place this here as session get initiated //skipping the csrf checking for the forgot(reset) password $csrfProtection = vglobal('csrfProtection'); if ($csrfProtection) { if ($request->get('mode') != 'reset' && $request->get('action') != 'Login') { require_once 'libraries/csrf-magic/csrf-magic.php'; } require_once 'config/csrf_config.php'; } // TODO - Get rid of global variable $current_user // common utils api called, depend on this variable right now $currentUser = $this->getLogin(); vglobal('current_user', $currentUser); $currentLanguage = Vtiger_Language_Handler::getLanguage(); vglobal('current_language', $currentLanguage); $module = $request->getModule(); $qualifiedModuleName = $request->getModule(false); if ($currentUser && $qualifiedModuleName) { $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage, $qualifiedModuleName); vglobal('mod_strings', $moduleLanguageStrings['languageStrings']); } if ($currentUser) { $moduleLanguageStrings = Vtiger_Language_Handler::getModuleStringsFromFile($currentLanguage); vglobal('app_strings', $moduleLanguageStrings['languageStrings']); } $view = $request->get('view'); $action = $request->get('action'); $response = false; try { if ($this->isInstalled() === false && $module != 'Install') { header('Location:install/Install.php'); exit; } if (empty($module)) { if ($this->hasLogin()) { $defaultModule = vglobal('default_module'); if (!empty($defaultModule) && $defaultModule != 'Home') { $module = $defaultModule; $qualifiedModuleName = $defaultModule; $view = 'List'; if ($module == 'Calendar') { // To load MyCalendar instead of list view for calendar //TODO: see if it has to enhanced and get the default view from module model $view = 'Calendar'; } } else { $module = 'Home'; $qualifiedModuleName = 'Home'; $view = 'DashBoard'; } } else { $module = 'Users'; $qualifiedModuleName = 'Settings:Users'; $view = 'Login'; } $request->set('module', $module); $request->set('view', $view); } if (!empty($action)) { $componentType = 'Action'; $componentName = $action; } else { $componentType = 'View'; if (empty($view)) { $view = 'Index'; } $componentName = $view; } $handlerClass = Vtiger_Loader::getComponentClassName($componentType, $componentName, $qualifiedModuleName); $handler = new $handlerClass(); if ($handler) { vglobal('currentModule', $module); $csrfProtection = vglobal('csrfProtection'); if ($csrfProtection) { // Ensure handler validates the request $handler->validateRequest($request); } if ($handler->loginRequired()) { $this->checkLogin($request); } //TODO : Need to review the design as there can potential security threat $skipList = array('Users', 'Home', 'CustomView', 'Import', 'Export', 'Inventory', 'Vtiger', 'PriceBooks', 'Migration', 'Install'); if (!in_array($module, $skipList) && stripos($qualifiedModuleName, 'Settings') === false) { $this->triggerCheckPermission($handler, $request); } // Every settings page handler should implement this method if (stripos($qualifiedModuleName, 'Settings') === 0 || $module == 'Users') { $handler->checkPermission($request); } $notPermittedModules = array('ModComments', 'Integration', 'DashBoard'); if (in_array($module, $notPermittedModules) && $view == 'List') { header('Location:index.php?module=Home&view=DashBoard'); } $this->triggerPreProcess($handler, $request); $response = $handler->process($request); $this->triggerPostProcess($handler, $request); } else { throw new AppException(vtranslate('LBL_HANDLER_NOT_FOUND')); } } catch (Exception $e) { if ($view) { // Log for developement. error_log($e->getTraceAsString(), E_NOTICE); Vtiger_Functions::throwNewException($e->getMessage()); } else { $response = new Vtiger_Response(); $response->setEmitType(Vtiger_Response::$EMIT_JSON); $response->setError($e->getMessage()); //Vtiger_Functions::throwNewException($e->getMessage()); } } if ($response) { $response->emit(); } }
/** to get the getModuleColumnsList for the given customview * @param $cvid :: Type Integer * @returns $columnlist Array in the following format * $columnlist = Array( $columnindex => $columnname, * $columnindex1 => $columnname1, * | * $columnindexn => $columnnamen) */ function getColumnsListByCvid($cvid) { global $adb, $log; $log->debug("Entering getColumnsListByCvid({$cvid}) method ..."); $sSQL = "select vtiger_cvcolumnlist.* from vtiger_cvcolumnlist"; $sSQL .= " inner join vtiger_customview on vtiger_customview.cvid = vtiger_cvcolumnlist.cvid"; $sSQL .= " where vtiger_customview.cvid =? order by vtiger_cvcolumnlist.columnindex"; $result = $adb->pquery($sSQL, array($cvid)); if ($adb->num_rows($result) == 0 && $this->customviewmodule != 'Users') { $log->debug("Error !!!: " . vtranslate('LBL_NO_FOUND_VIEW') . " ID: {$cvid}"); die(Vtiger_Functions::throwNewException('LBL_NO_FOUND_VIEW')); } while ($columnrow = $adb->fetch_array($result)) { $columnlist[$columnrow['columnindex']] = $columnrow['columnname']; } $log->debug("Exiting getColumnsListByCvid() method ..."); return $columnlist; }
/** Function to save the user information into the database * @param $module -- module name:: Type varchar * */ function save($module_name) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); //Event triggering code require_once "include/events/include.inc"; //In Bulk mode stop triggering events if (!self::isBulkSaveMode()) { $em = new VTEventsManager($adb); // Initialize Event trigger cache $em->initTriggerCache(); $entityData = VTEntityData::fromCRMEntity($this); $em->triggerEvent("vtiger.entity.beforesave.modifiable", $entityData); $em->triggerEvent("vtiger.entity.beforesave", $entityData); $em->triggerEvent("vtiger.entity.beforesave.final", $entityData); } if ($this->mode != 'edit') { $sql = 'SELECT id FROM vtiger_users WHERE user_name = ? OR email1 = ?'; $result = $adb->pquery($sql, array($this->column_fields['user_name'], $this->column_fields['email1'])); if ($adb->num_rows($result) > 0) { Vtiger_Functions::throwNewException('LBL_USER_EXISTS'); throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_USER_EXISTS')); return false; } } else { $query = 'SELECT `roleid` FROM `vtiger_user2role` WHERE `userid` = ? LIMIT 1;'; $oldRoleResult = $adb->pquery($query, [$this->id]); $oldRole = $adb->query_result($oldRoleResult, 0, 'roleid'); if ($oldRole != $this->column_fields['roleid']) { $query = 'DELETE FROM `vtiger_module_dashboard_widgets` WHERE `userid` = ?;'; $adb->pquery($query, [$this->id]); } } //Save entity being called with the modulename as parameter $this->saveentity($module_name); if ($em) { //Event triggering code $em->triggerEvent("vtiger.entity.aftersave", $entityData); $em->triggerEvent("vtiger.entity.aftersave.final", $entityData); //Event triggering code ends } // Added for Reminder Popup support $query_prev_interval = $adb->pquery("SELECT reminder_interval from vtiger_users where id=?", array($this->id)); $prev_reminder_interval = $adb->query_result($query_prev_interval, 0, 'reminder_interval'); //$focus->imagename = $image_upload_array['imagename']; $this->saveHomeStuffOrder($this->id); SaveTagCloudView($this->id); // Added for Reminder Popup support $this->resetReminderInterval($prev_reminder_interval); //Creating the Privileges Flat File if (isset($this->column_fields['roleid'])) { updateUser2RoleMapping($this->column_fields['roleid'], $this->id); } //After adding new user, set the default activity types for new user Vtiger_Util_Helper::setCalendarDefaultActivityTypesForUser($this->id); require_once 'modules/Users/CreateUserPrivilegeFile.php'; createUserPrivilegesfile($this->id); createUserSharingPrivilegesfile($this->id); }
/** to get the getModuleColumnsList for the given customview * @param $cvid :: Type Integer * @returns $columnlist Array in the following format * $columnlist = Array( $columnindex => $columnname, * $columnindex1 => $columnname1, * | * $columnindexn => $columnnamen) */ function getColumnsListByCvid($cvid) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); $log->debug("Entering getColumnsListByCvid({$cvid}) method ..."); $sSQL = 'select vtiger_cvcolumnlist.* from vtiger_cvcolumnlist'; $sSQL .= ' inner join vtiger_customview on vtiger_customview.cvid = vtiger_cvcolumnlist.cvid'; $sSQL .= ' where vtiger_customview.cvid =? order by vtiger_cvcolumnlist.columnindex'; $result = $adb->pquery($sSQL, [$cvid]); if ($adb->num_rows($result) == 0 && is_numeric($cvid) && $this->customviewmodule != 'Users') { $log->debug("Error !!!: " . vtranslate('LBL_NO_FOUND_VIEW') . " ID: {$cvid}"); die(Vtiger_Functions::throwNewException(vtranslate('LBL_NO_FOUND_VIEW'))); } else { if (!is_numeric($cvid) && $this->customviewmodule != 'Users') { $filterDir = 'modules' . DIRECTORY_SEPARATOR . $this->customviewmodule . DIRECTORY_SEPARATOR . 'filters' . DIRECTORY_SEPARATOR . $cvid . '.php'; if (file_exists($filterDir)) { $handlerClass = Vtiger_Loader::getComponentClassName('Filter', $cvid, $this->customviewmodule); if (class_exists($handlerClass)) { $handler = new $handlerClass(); $columnlist = $handler->getColumnList(); } } else { $log->debug("Error !!!: " . vtranslate('LBL_NO_FOUND_VIEW') . " Filter: {$cvid}"); die(Vtiger_Functions::throwNewException(vtranslate('LBL_NO_FOUND_VIEW'))); } } else { while ($columnrow = $adb->fetch_array($result)) { $columnlist[$columnrow['columnindex']] = $columnrow['columnname']; } } } $log->debug("Exiting getColumnsListByCvid() method ..."); return $columnlist; }
public static function imap_open_error($error) { global $log; $log->error("Error OSSMail_Record_Model::imap_connect(): " . $error); Vtiger_Functions::throwNewException(vtranslate('IMAP_ERROR', 'OSSMailScanner') . ': ' . $error); }
/** Function to check the file access is made within web root directory. */ static function checkFileAccess($filepath) { if (!self::isFileAccessible($filepath)) { global $log; $log->error(__CLASS__ . ':' . __FUNCTION__ . '(' . $filepath . ') - Sorry! Attempt to access restricted file. realfilepath: ' . print_r($realfilepath, true)); die(Vtiger_Functions::throwNewException("Sorry! Attempt to access restricted file. '" . $realfilepath . "'")); } }
/** Function to save the user information into the database * @param $module -- module name:: Type varchar * */ function save($module_name) { $adb = PearDatabase::getInstance(); $log = vglobal('log'); if ($this->mode != 'edit') { $sql = 'SELECT id FROM vtiger_users WHERE user_name = ? OR email1 = ?'; $result = $adb->pquery($sql, array($this->column_fields['user_name'], $this->column_fields['email1'])); if ($adb->num_rows($result) > 0) { Vtiger_Functions::throwNewException('LBL_USER_EXISTS'); throw new WebServiceException(WebServiceErrorCode::$DATABASEQUERYERROR, vtws_getWebserviceTranslatedString('LBL_USER_EXISTS')); return false; } } //Save entity being called with the modulename as parameter $this->saveentity($module_name); // Added for Reminder Popup support $query_prev_interval = $adb->pquery("SELECT reminder_interval from vtiger_users where id=?", array($this->id)); $prev_reminder_interval = $adb->query_result($query_prev_interval, 0, 'reminder_interval'); //$focus->imagename = $image_upload_array['imagename']; $this->saveHomeStuffOrder($this->id); SaveTagCloudView($this->id); // Added for Reminder Popup support $this->resetReminderInterval($prev_reminder_interval); //Creating the Privileges Flat File if (isset($this->column_fields['roleid'])) { updateUser2RoleMapping($this->column_fields['roleid'], $this->id); } //After adding new user, set the default activity types for new user Vtiger_Util_Helper::setCalendarDefaultActivityTypesForUser($this->id); require_once 'modules/Users/CreateUserPrivilegeFile.php'; createUserPrivilegesfile($this->id); createUserSharingPrivilegesfile($this->id); }
public function checkError($message, $dieOnError = false, $query = false, $params = false) { if ($this->hasActiveTransaction) { $this->rollbackTransaction(); } if ($this->dieOnError || $dieOnError) { $backtrace = false; if (AppConfig::debug('DISPLAY_DEBUG_BACKTRACE')) { $backtrace = Vtiger_Functions::getBacktrace(); } $message = ['message' => $message, 'trace' => $backtrace, 'query' => $query, 'params' => $params]; Vtiger_Functions::throwNewException($message, true, 'DatabaseException.tpl'); } }