Exemplo n.º 1
0
 /**
  * Function to get the detail view links (links and widgets)
  * @param <array> $linkParams - parameters which will be used to calicaulate the params
  * @return <array> - array of link models in the format as below
  *                   array('linktype'=>list of link models);
  */
 public function getDetailViewLinks($linkParams)
 {
     $linkTypes = array('DETAILVIEWBASIC', 'DETAILVIEW');
     $moduleModel = $this->getModule();
     $recordModel = $this->getRecord();
     $currentUserModel = Users_Record_Model::getCurrentUserModel();
     $moduleName = $moduleModel->getName();
     $recordId = $recordModel->getId();
     $detailViewLinks = [];
     $adb = PearDatabase::getInstance();
     vimport('~~modules/com_vtiger_workflow/include.inc');
     vimport('~~modules/com_vtiger_workflow/VTEntityMethodManager.inc');
     $wfs = new VTWorkflowManager($adb);
     $workflows = $wfs->getWorkflowsForModule($moduleName, VTWorkflowManager::$TRIGGER);
     if (Users_Privileges_Model::isPermitted($moduleName, 'WorkflowTrigger') && count($workflows) > 0) {
         $detailViewLinks[] = array('linktype' => 'DETAILVIEWBASIC', 'linklabel' => '', 'linkurl' => 'Vtiger_Detail_Js.showWorkflowTriggerView(this)', 'linkicon' => 'glyphicon glyphicon-plus-sign', 'linkhint' => 'BTN_WORKFLOW_TRIGGER');
     }
     $lockEdit = Users_Privileges_Model::checkLockEdit($moduleName, $recordId);
     $currentUserPriviligesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
     if (Users_Privileges_Model::isPermitted($moduleName, 'EditView', $recordId) && !$lockEdit) {
         $detailViewLinks[] = array('linktype' => 'DETAILVIEWBASIC', 'linklabel' => '', 'linkurl' => $recordModel->getEditViewUrl(), 'linkicon' => 'glyphicon glyphicon-pencil', 'linkclass' => 'btn', 'linkhint' => 'BTN_RECORD_EDIT');
     }
     foreach ($detailViewLinks as $detailViewLink) {
         $linkModelList['DETAILVIEWBASIC'][] = Vtiger_Link_Model::getInstanceFromValues($detailViewLink);
     }
     $linkModelListDetails = Vtiger_Link_Model::getAllByType($moduleModel->getId(), $linkTypes, $linkParams);
     //Mark all detail view basic links as detail view links.
     //Since ui will be look ugly if you need many basic links
     $detailViewBasiclinks = $linkModelListDetails['DETAILVIEWBASIC'];
     unset($linkModelListDetails['DETAILVIEWBASIC']);
     if (Users_Privileges_Model::isPermitted($moduleName, 'Delete', $recordId) && $recordPermissionToEditView) {
         $deletelinkModel = array('linktype' => 'DETAILVIEW', 'linklabel' => sprintf("%s %s", getTranslatedString('LBL_DELETE', $moduleName), vtranslate('SINGLE_' . $moduleName, $moduleName)), 'linkurl' => 'javascript:Vtiger_Detail_Js.deleteRecord("' . $recordModel->getDeleteUrl() . '")', 'linkicon' => 'glyphicon glyphicon-trash', 'title' => vtranslate('LBL_DELETE_RECORD'));
         $linkModelList['DETAILVIEW'][] = Vtiger_Link_Model::getInstanceFromValues($deletelinkModel);
     }
     if (Users_Privileges_Model::isPermitted($moduleName, 'DuplicateRecord')) {
         $duplicateLinkModel = array('linktype' => 'DETAILVIEWBASIC', 'linklabel' => 'LBL_DUPLICATE', 'linkurl' => $recordModel->getDuplicateRecordUrl(), 'linkicon' => 'glyphicon glyphicon-retweet', 'title' => vtranslate('LBL_DUPLICATE_RECORD'));
         $linkModelList['DETAILVIEW'][] = Vtiger_Link_Model::getInstanceFromValues($duplicateLinkModel);
     }
     if (!empty($detailViewBasiclinks)) {
         foreach ($detailViewBasiclinks as $linkModel) {
             // Remove view history, needed in vtiger5 to see history but not in vtiger6
             if ($linkModel->linklabel == 'View History') {
                 continue;
             }
             $linkModelList['DETAILVIEW'][] = $linkModel;
         }
     }
     $relatedLinks = $this->getDetailViewRelatedLinks();
     foreach ($relatedLinks as $relatedLinkEntry) {
         $relatedLink = Vtiger_Link_Model::getInstanceFromValues($relatedLinkEntry);
         $linkModelList[$relatedLink->getType()][] = $relatedLink;
     }
     if ($currentUserModel->isAdminUser()) {
         $settingsLinks = $moduleModel->getSettingLinks();
         foreach ($settingsLinks as $settingsLink) {
             $linkModelList['DETAILVIEWSETTING'][] = Vtiger_Link_Model::getInstanceFromValues($settingsLink);
         }
     }
     return $linkModelList;
 }
Exemplo n.º 2
0
 public function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     vimport('~~modules/' . $moduleName . '/' . $moduleName . '.php');
     $bag = false;
     $paymentsIn = $request->get('paymentsIn');
     foreach ($paymentsIn as $fields) {
         $ossPaymentsIn = new $moduleName();
         $ossPaymentsIn->column_fields['paymentsname'] = 'Name';
         $ossPaymentsIn->column_fields['paymentsvalue'] = $fields['amount'];
         $ossPaymentsIn->column_fields['paymentscurrency'] = $fields['third_letter_currency_code'];
         $ossPaymentsIn->column_fields['paymentstitle'] = $fields['details']['title'];
         $ossPaymentsIn->column_fields['bank_account'] = $fields['details']['contAccount'];
         $saved = $ossPaymentsIn->save('PaymentsIn');
         if ($saved == false) {
             $bag = true;
         }
     }
     if ($bag) {
         $result = array('success' => true, 'return' => vtranslate('MSG_SAVE_OK', $moduleName));
     } else {
         $result = array('success' => false, 'return' => vtranslate('MSG_SAVE_ERROR', $moduleName));
     }
     $response = new Vtiger_Response();
     $response->setResult($result);
     $response->emit();
 }
Exemplo n.º 3
0
 public function getGroupsIdsForUsers($userId)
 {
     vimport('~include/utils/GetUserGroups.php');
     $userGroupInstance = new GetUserGroups();
     $userGroupInstance->getAllUserGroups($userId);
     return $userGroupInstance->user_groups;
 }
Exemplo n.º 4
0
 function process(Vtiger_Request $request)
 {
     $moduleName = $request->getModule();
     $record = $request->get('record');
     vimport('~~modules/com_vtiger_workflow/include.inc');
     vimport('~~modules/com_vtiger_workflow/VTEntityCache.inc');
     vimport('~~modules/com_vtiger_workflow/include.inc');
     vimport('~~include/Webservices/Utils.php');
     vimport('~~include/Webservices/Retrieve.php');
     $adb = PearDatabase::getInstance();
     $wfs = new VTWorkflowManager($adb);
     $workflows = $wfs->getWorkflowsForModule($moduleName, VTWorkflowManager::$TRIGGER);
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $wsId = vtws_getWebserviceEntityId($moduleName, $record);
     $entityCache = new VTEntityCache($currentUser);
     $entityData = $entityCache->forId($wsId);
     foreach ($workflows as $id => $workflow) {
         if (!$workflow->evaluate($entityCache, $entityData->getId())) {
             unset($workflows[$id]);
         }
     }
     $viewer = $this->getViewer($request);
     $viewer->assign('RECORD', $record);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('WORKFLOWS', $workflows);
     $viewer->assign('USER_MODEL', Users_Record_Model::getCurrentUserModel());
     $viewer->view('WorkflowTrigger.tpl', $moduleName);
 }
Exemplo n.º 5
0
 public function updateUserModuleStep3(Vtiger_Request $request)
 {
     $importModuleName = $request->get('module_import_name');
     $uploadFile = $request->get('module_import_file');
     $uploadDir = Settings_ModuleManager_Module_Model::getUploadDirectory();
     $uploadFileName = "{$uploadDir}/{$uploadFile}";
     checkFileAccess($uploadFileName);
     $importType = strtolower($request->get('module_import_type'));
     if ($importType == 'language') {
         $package = new Vtiger_Language();
     } else {
         if ($importType == 'layout') {
             vimport('vtlib.Vtiger.Layout');
             $package = new Vtiger_Layout();
         } else {
             $package = new Vtiger_Package();
         }
     }
     if ($importType == 'language' || $importType == 'layout') {
         $package->import($uploadFileName);
     } else {
         $package->update(Vtiger_Module::getInstance($importModuleName), $uploadFileName);
     }
     checkFileAccessForDeletion($uploadFileName);
     unlink($uploadFileName);
     $result = array('success' => true, 'importModuleName' => $importModuleName);
     $response = new Vtiger_Response();
     $response->setResult($result);
     $response->emit();
 }
Exemplo n.º 6
0
 function handleEvent($eventName, $data)
 {
     $moduleName = $data->getModuleName();
     if ($eventName == 'vtiger.entity.aftersave.final' && $moduleName == 'ProjectTask') {
         $recordId = $data->getId();
         if ($data->isNew()) {
             $recordModel = Vtiger_Module_Model::getInstance('ProjectMilestone');
             $recordModel->updateProgressMilestone($data->get('projectmilestoneid'));
         } else {
             vimport('include.events.VTEntityDelta');
             $vtEntityDelta = new VTEntityDelta();
             $delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true);
             foreach ($delta as $name => $value) {
                 if ($name == 'projectmilestoneid' || $name == 'estimated_work_time' || $name == 'projecttaskprogress') {
                     $recordModel = Vtiger_Module_Model::getInstance('ProjectMilestone');
                     if ($name == 'projectmilestoneid') {
                         $recordModel->updateProgressMilestone($value['currentValue']);
                         $recordModel->updateProgressMilestone($value['oldValue']);
                     } else {
                         $recordModel->updateProgressMilestone($data->get('projectmilestoneid'));
                     }
                 }
             }
         }
     } elseif ($eventName == 'vtiger.entity.afterdelete' && $moduleName == 'ProjectTask') {
         $recordModel = Vtiger_Module_Model::getInstance('ProjectMilestone');
         $recordModel->updateProgressMilestone($data->get('projectmilestoneid'));
     } elseif ($eventName == 'vtiger.entity.afterrestore' && $moduleName == 'ProjectTask') {
         $recordModel = Vtiger_Module_Model::getInstance('ProjectMilestone');
         $recordModel->updateProgressMilestone($data->get('projectmilestoneid'));
     }
 }
Exemplo n.º 7
0
 private function _createXLS($tmpFile, $reportId)
 {
     vimport('~~/modules/SQLReports/ReportRunSQL.php');
     /**
      * @var $reportRun \ReportRunSQL
      */
     $reportRun = \ReportRunSQL::getInstance($reportId);
     $reportRun->writeReportToExcelFile($tmpFile, false);
 }
Exemplo n.º 8
0
 /**
  * Function to save record
  * @param <Vtiger_Request> $request - values of the record
  * @return <RecordModel> - record Model of saved record
  */
 public function saveRecord($request)
 {
     $adb = PearDatabase::getInstance();
     $recordModel = $this->getRecordModelFromRequest($request);
     $recordModel->save();
     $originalRecordId = $recordModel->getId();
     if ($request->get('relationOperation')) {
         $parentModuleName = $request->get('sourceModule');
         $parentModuleModel = Vtiger_Module_Model::getInstance($parentModuleName);
         $parentRecordId = $request->get('sourceRecord');
         $relatedModule = $recordModel->getModule();
         if ($relatedModule->getName() == 'Events') {
             $relatedModule = Vtiger_Module_Model::getInstance('Calendar');
         }
         $relatedRecordId = $recordModel->getId();
         $relationModel = Vtiger_Relation_Model::getInstance($parentModuleModel, $relatedModule);
         $relationModel->addRelation($parentRecordId, $relatedRecordId);
     }
     // Handled to save follow up event
     $followupMode = $request->get('followup');
     //Start Date and Time values
     $startTime = Vtiger_Time_UIType::getTimeValueWithSeconds($request->get('followup_time_start'));
     $startDateTime = Vtiger_Datetime_UIType::getDBDateTimeValue($request->get('followup_date_start') . " " . $startTime);
     list($startDate, $startTime) = explode(' ', $startDateTime);
     $subject = $request->get('subject');
     if ($followupMode == 'on' && $startTime != '' && $startDate != '') {
         $recordModel->set('eventstatus', 'Planned');
         $recordModel->set('subject', '[Followup] ' . $subject);
         $recordModel->set('date_start', $startDate);
         $recordModel->set('time_start', $startTime);
         $currentUser = Users_Record_Model::getCurrentUserModel();
         $activityType = $recordModel->get('activitytype');
         if ($activityType == 'Call') {
             $minutes = $currentUser->get('callduration');
         } else {
             $minutes = $currentUser->get('othereventduration');
         }
         $dueDateTime = date('Y-m-d H:i:s', strtotime("{$startDateTime}+{$minutes} minutes"));
         list($startDate, $startTime) = explode(' ', $dueDateTime);
         $recordModel->set('due_date', $startDate);
         $recordModel->set('time_end', $startTime);
         $recordModel->set('recurringtype', '');
         $recordModel->set('mode', 'create');
         $recordModel->save();
         $heldevent = true;
     }
     //TODO: remove the dependency on $_REQUEST
     if ($_REQUEST['recurringtype'] != '' && $_REQUEST['recurringtype'] != '--None--') {
         vimport('~modules/Calendar/RepeatEvents.php');
         $focus = new Activity();
         //get all the stored data to this object
         $focus->column_fields = $recordModel->getData();
         Calendar_RepeatEvents::repeatFromRequest($focus);
     }
     return $recordModel;
 }
Exemplo n.º 9
0
 public function getSettingLinks()
 {
     vimport('~~modules/com_vtiger_workflow/VTWorkflowUtils.php');
     $layoutEditorImagePath = Vtiger_Theme::getImagePath('LayoutEditor.gif');
     $settingsLinks = array();
     $db = PearDatabase::getInstance();
     $result = $db->query("SELECT fieldid FROM vtiger_settings_field WHERE name =  'OSSMail' AND description =  'OSSMail'", true);
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_MODULE_CONFIGURATION', 'linkurl' => 'index.php?module=OSSMail&parent=Settings&view=index&block=4&fieldid=' . $db->query_result($result, 0, 'fieldid'), 'linkicon' => $layoutEditorImagePath);
     return $settingsLinks;
 }
Exemplo n.º 10
0
 /**
  * Function to get Settings links
  * @return <Array>
  */
 public function getSettingLinks()
 {
     vimport('~~modules/com_vtiger_workflow/VTWorkflowUtils.php');
     $editWorkflowsImagePath = Vtiger_Theme::getImagePath('EditWorkflows.png');
     $settingsLinks = array();
     if (VTWorkflowUtils::checkModuleWorkflow($this->getName())) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_WORKFLOWS', 'linkurl' => 'index.php?parent=Settings&module=Workflows&view=List&sourceModule=' . $this->getName(), 'linkicon' => $editWorkflowsImagePath);
     }
     return $settingsLinks;
 }
Exemplo n.º 11
0
 public function recalculate()
 {
     $php_max_execution_time = vglobal('php_max_execution_time');
     set_time_limit($php_max_execution_time);
     vimport('~~modules/Users/CreateUserPrivilegeFile.php');
     $userIdsList = Settings_Profiles_Record_Model::getUsersList(true);
     if ($userIdsList) {
         foreach ($userIdsList as $userId) {
             createUserPrivilegesfile($userId);
         }
     }
 }
Exemplo n.º 12
0
 public function getSummary($type, $bank, $file)
 {
     $adres = vglobal('cache_dir');
     if ($bank == 'Default') {
         vimport('~~modules/PaymentsIn/helpers/' . $type . '.php');
         $records = new $type($adres . $file);
         return $records;
     }
     vimport('~~modules/PaymentsIn/helpers/subclass/' . $type . '_' . $bank . '.php');
     $class = $type . '_' . $bank;
     $records = new $class($adres . $file);
     return $records;
 }
Exemplo n.º 13
0
function Contacts_createPortalLoginDetails($entityData)
{
    vimport('modules.Settings.CustomerPortal.helpers.CustomerPortalPassword');
    $encodePass = vglobal('encode_customer_portal_passwords');
    $adb = PearDatabase::getInstance();
    $wsId = $entityData->getId();
    $parts = explode('x', $wsId);
    $entityId = $parts[1];
    $email = $entityData->get('email');
    if (($entityData->get('portal') == 'on' || $entityData->get('portal') == '1') && $entityData->get('contactstatus') != 'Inactive') {
        $sql = "SELECT id, user_name, user_password, isactive FROM vtiger_portalinfo WHERE id=?";
        $result = $adb->pquery($sql, array($entityId));
        $insert = false;
        if ($adb->num_rows($result) == 0) {
            $insert = true;
        } else {
            $dbusername = $adb->query_result($result, 0, 'user_name');
            $isactive = $adb->query_result($result, 0, 'isactive');
            if ($email == $dbusername && $isactive == 1 && !$entityData->isNew()) {
                $update = false;
            } else {
                if ($entityData->get('portal') == 'on' || $entityData->get('portal') == '1') {
                    $sql = "UPDATE vtiger_portalinfo SET user_name=?, isactive=1 WHERE id=?";
                    $adb->pquery($sql, array($email, $entityId));
                    $password = $adb->query_result($result, 0, 'user_password');
                    $update = true;
                } else {
                    $sql = "UPDATE vtiger_portalinfo SET user_name=?, isactive=? WHERE id=?";
                    $adb->pquery($sql, array($email, 0, $entityId));
                    $update = false;
                }
            }
        }
        if ($insert == true) {
            $password = makeRandomPassword();
            $truePassword = $password;
            if ($encodePass) {
                $password = CustomerPortalPassword::encryptPassword($password, $email);
                $params = array($entityId, $email, $password, 'C', 1, CustomerPortalPassword::getCryptType(), $truePassword);
                $sql = "INSERT INTO vtiger_portalinfo(`id`, `user_name`, `user_password`, `type`, `isactive`, `crypt_type`, `password_sent`) VALUES(" . generateQuestionMarks($params) . ")";
            } else {
                $params = array($entityId, $email, $password, 'C', 1, $truePassword);
                $sql = "INSERT INTO vtiger_portalinfo(`id`, `user_name`, `user_password`, `type`, `isactive`, `password_sent`) VALUES(" . generateQuestionMarks($params) . ")";
            }
            $adb->pquery($sql, $params);
        }
    } else {
        $sql = "UPDATE vtiger_portalinfo SET user_name=?,isactive=0 WHERE id=?";
        $adb->pquery($sql, array($email, $entityId));
    }
}
Exemplo n.º 14
0
 /**
  * Function starts applying schema changes
  */
 public function initialize()
 {
     global $YetiForce_current_version;
     $this->initializeDatabase($this->sql_directory, array('scheme', 'data'));
     $this->setDefaultUsersAccess();
     $currencyName = $_SESSION['config_file_info']['currency_name'];
     $currencyCode = $_SESSION['config_file_info']['currency_code'];
     $currencySymbol = $_SESSION['config_file_info']['currency_symbol'];
     $this->db->pquery("UPDATE vtiger_currency_info SET currency_name = ?, currency_code = ?, currency_symbol = ?", [$currencyName, $currencyCode, $currencySymbol]);
     $this->db->pquery("UPDATE vtiger_version SET `current_version` = ? ;", [$YetiForce_current_version]);
     // recalculate all sharing rules for users
     vimport('~include/utils/UserInfoUtil.php');
     RecalculateSharingRules();
 }
Exemplo n.º 15
0
 /**
  * Function to get Settings links
  * @return <Array>
  */
 public function getSettingLinks()
 {
     if (!$this->isEntityModule()) {
         return array();
     }
     vimport('~~modules/com_vtiger_workflow/VTWorkflowUtils.php');
     $layoutEditorImagePath = Vtiger_Theme::getImagePath('LayoutEditor.gif');
     $editWorkflowsImagePath = Vtiger_Theme::getImagePath('EditWorkflows.png');
     $settingsLinks = array();
     if (VTWorkflowUtils::checkModuleWorkflow($this->getName())) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_WORKFLOWS', 'linkurl' => 'index.php?parent=Settings&module=Workflows&view=List&sourceModule=' . $this->getName(), 'linkicon' => $editWorkflowsImagePath);
     }
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTINGS', 'linklabel' => 'LBL_SERVER_CONFIGURATION', 'linkurl' => 'index.php?parent=Settings&module=PBXManager&view=Index', 'linkicon' => '');
     return $settingsLinks;
 }
Exemplo n.º 16
0
 function handleEvent($eventName, $entityData)
 {
     $adb = PearDatabase::getInstance();
     $log = vglobal('log');
     if ($eventName == 'user.logout.before') {
         $log->debug("Start LogoutHandler: user.logout.before");
         $mainUrl = OSSMail_Record_Model::GetSite_URL() . 'modules/OSSMail/roundcube/';
         vimport('~modules/OSSMail/RoundcubeLogin.class.php');
         $rcl = new RoundcubeLogin($mainUrl);
         if ($rcl->isLoggedIn()) {
             $rcl->logout();
         }
         $log->debug("End LogoutHandler: user.logout.before");
     }
 }
Exemplo n.º 17
0
 public function getSettingLinks()
 {
     vimport('~~modules/com_vtiger_workflow/VTWorkflowUtils.php');
     $layoutEditorImagePath = Vtiger_Theme::getImagePath('LayoutEditor.gif');
     $editWorkflowsImagePath = Vtiger_Theme::getImagePath('EditWorkflows.png');
     $settingsLinks = array();
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_FIELDS', 'linkurl' => 'index.php?parent=Settings&module=LayoutEditor&sourceModule=' . $this->getName(), 'linkicon' => $layoutEditorImagePath);
     if (VTWorkflowUtils::checkModuleWorkflow($this->getName())) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_WORKFLOWS', 'linkurl' => 'index.php?parent=Settings&module=Workflow&sourceModule=' . $this->getName(), 'linkicon' => $editWorkflowsImagePath);
     }
     $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_EDIT_PICKLIST_VALUES', 'linkurl' => 'index.php?parent=Settings&module=Picklist&source_module=' . $this->getName(), 'linkicon' => '');
     if ($this->hasSequenceNumberField()) {
         $settingsLinks[] = array('linktype' => 'LISTVIEWSETTING', 'linklabel' => 'LBL_MODULE_SEQUENCE_NUMBERING', 'linkurl' => 'index.php?parent=Settings&module=Vtiger&view=CustomRecordNumbering&sourceModule=' . $this->getName(), 'linkicon' => '');
     }
     return $settingsLinks;
 }
Exemplo n.º 18
0
 function handleEvent($eventName, $entityData)
 {
     $adb = PearDatabase::getInstance();
     $log = vglobal('log');
     if ($eventName == 'user.logout.before') {
         $log->debug("Start LogoutHandler: user.logout.before");
         $mainUrl = OSSMail_Record_Model::GetSite_URL() . 'modules/OSSMail/roundcube/';
         vimport('~modules/OSSMail/RoundcubeLogin.class.php');
         $rcl = new RoundcubeLogin($mainUrl);
         try {
             $rcl->logout();
         } catch (RoundcubeLoginException $ex) {
             $log->error('OSSMail_index_View|RoundcubeLoginException: ' . $ex->getMessage());
         }
         $log->debug("End LogoutHandler: user.logout.before");
     }
 }
Exemplo n.º 19
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');
 }
Exemplo n.º 20
0
 public function transferRecordsOwnership($module, $transferOwnerId, $relatedModuleRecordIds)
 {
     $currentUser = vglobal('current_user');
     $db = PearDatabase::getInstance();
     $db->update('vtiger_crmentity', ['smownerid' => $transferOwnerId, 'modifiedby' => $currentUser->id, 'modifiedtime' => date('Y-m-d H:i:s')], 'crmid IN (' . implode(',', $relatedModuleRecordIds) . ')');
     vimport('~modules/ModTracker/ModTracker.php');
     $flag = ModTracker::isTrackingEnabledForModule($module);
     if ($flag) {
         foreach ($relatedModuleRecordIds as $record) {
             $id = $db->getUniqueID('vtiger_modtracker_basic');
             $query = 'INSERT INTO vtiger_modtracker_basic ( id, whodid, whodidsu, changedon, crmid, module ) SELECT ? , ? , ?, ?, crmid, setype FROM vtiger_crmentity WHERE crmid = ?';
             $db->pquery($query, [$id, $currentUser->id, Vtiger_Session::get('baseUserId'), date('Y-m-d H:i:s', time()), $record]);
             $query = 'INSERT INTO vtiger_modtracker_detail ( id, fieldname, postvalue , prevalue ) SELECT ? , ? ,? , smownerid FROM vtiger_crmentity WHERE crmid = ?';
             $db->pquery($query, [$id, 'assigned_user_id', $currentUser->id, $record]);
         }
     }
 }
Exemplo n.º 21
0
 public function process(Vtiger_Request $request)
 {
     $db = PearDatabase::getInstance();
     $id = $request->get('record');
     $newModuleId = $request->get('moduleid');
     $recordModel = $this->saveRecord($request);
     vimport('~~modules/OSSPdf/helpers/Conditions.php');
     Conditions::saveCondition($recordModel, $request);
     if ($request->get('relationOperation')) {
         $parentModuleName = $request->get('sourceModule');
         $parentRecordId = $request->get('sourceRecord');
         $parentRecordModel = Vtiger_Record_Model::getInstanceById($parentRecordId, $parentModuleName);
         //TODO : Url should load the related list instead of detail view of record
         $loadUrl = $parentRecordModel->getDetailViewUrl();
     } else {
         $loadUrl = $recordModel->getDetailViewUrl();
     }
     header("Location: {$loadUrl}");
 }
Exemplo n.º 22
0
 public function getType($module = false)
 {
     $moduleName = Vtiger_Functions::getModuleName($module);
     $dir = 'modules/Vtiger/widgets/';
     $ffs = scandir($dir);
     foreach ($ffs as $ff) {
         $action = str_replace('.php', "", $ff);
         if ($ff != '.' && $ff != '..' && !is_dir($dir . '/' . $ff) && $action != 'Basic') {
             $folderFiles[$action] = $action;
             vimport('~~' . $dir . $ff);
             $modelClassName = Vtiger_Loader::getComponentClassName('Widget', $action, 'Vtiger');
             $instance = new $modelClassName();
             if ($instance->allowedModules && !in_array($moduleName, $instance->allowedModules)) {
                 unset($folderFiles[$action]);
             }
         }
     }
     return $folderFiles;
 }
Exemplo n.º 23
0
 public function process(Vtiger_Request $request)
 {
     vimport('~~modules/OSSPdf/helpers/Conditions.php');
     $moduleSettingsName = $request->getModule(false);
     $moduleName = $request->getModule();
     $record = $request->get('record');
     $baseModule = Vtiger_Functions::getModuleName($request->get('base_module'));
     $num = $request->get('num');
     if ("" == $num) {
         $num = 0;
     }
     $viewer = $this->getViewer($request);
     $viewer->assign('NUM', ++$num);
     $viewer->assign('MODULE', $moduleName);
     $viewer->assign('BASE_MODULE', $baseModule);
     $viewer->assign('CONDITION_LIST', Conditions::getListBaseModuleField($baseModule));
     $viewer->assign('FIELD_LIST', Conditions::getListBaseModuleField($baseModule));
     echo $viewer->view('Condition.tpl', $moduleSettingsName, true);
 }
Exemplo n.º 24
0
 public function execute($moduleName, $record, $ids)
 {
     vimport('~~modules/com_vtiger_workflow/VTEntityCache.inc');
     vimport('~~modules/com_vtiger_workflow/include.inc');
     vimport('~~include/Webservices/Utils.php');
     vimport('~~include/Webservices/Retrieve.php');
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $wsId = vtws_getWebserviceEntityId($moduleName, $record);
     $adb = PearDatabase::getInstance();
     $wfs = new VTWorkflowManager($adb);
     $entityCache = new VTEntityCache($currentUser);
     $entityData = $entityCache->forId($wsId);
     foreach ($ids as $id) {
         $workflow = $wfs->retrieve($id);
         if ($workflow->evaluate($entityCache, $entityData->getId())) {
             $workflow->performTasks($entityData);
         }
     }
 }
Exemplo n.º 25
0
 function showTags(Vtiger_Request $request)
 {
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $record = $request->get('record');
     if ($record) {
         $module = $request->getModule();
         if ($module == 'Events') {
             $module = 'Calendar';
         }
         vimport('~~/libraries/freetag/freetag.class.php');
         $freeTagInstance = new freetag();
         $maxTagLength = $freeTagInstance->_MAX_TAG_LENGTH;
         $tags = Vtiger_Tag_Model::getAll($currentUser->id, $module, $record);
         $viewer = $this->getViewer($request);
         $viewer->assign('MAX_TAG_LENGTH', $maxTagLength);
         $viewer->assign('TAGS', $tags);
         $viewer->assign('MODULE', $module);
         echo $viewer->view('ShowTagCloud.tpl', $module, true);
     }
 }
 public function save($request)
 {
     vimport('~~/modules/Emails/mail.php');
     $currentUser = Users_Record_Model::getCurrentUserModel();
     $from_email = $request->get('from_email_field');
     $to_email = getUserEmailId('id', $currentUser->getId());
     $subject = $this->getSubject();
     $description = $this->getBody();
     // This is added so that send_mail API will treat it as user initiated action
     $olderAction = $_REQUEST['action'];
     $_REQUEST['action'] = 'Save';
     if ($to_email != '') {
         $mail_status = send_mail('Users', $to_email, $currentUser->get('user_name'), $from_email, $subject, $description, '', '', '', '', '', true);
     }
     $_REQUEST['action'] = $olderAction;
     if ($mail_status != 1 && !$this->isDefaultSettingLoaded()) {
         throw new Exception('Error occurred while sending mail');
     }
     return parent::save();
 }
Exemplo n.º 27
0
 /**
  * Function to check whether it is compatible with vtiger or not
  * @return <boolean> true/false
  */
 public function isVtigerCompatible()
 {
     vimport('~~/vtlib/Vtiger/Version.php');
     $vtigerVersion = $this->get('vtigerVersion');
     $vtigerMaxVersion = $this->get('vtigerMaxVersion');
     if (Vtiger_Version::check($vtigerVersion, '>=') && $vtigerMaxVersion && Vtiger_Version::check($vtigerMaxVersion, '<') || Vtiger_Version::check($vtigerVersion, '=')) {
         return true;
     }
     return false;
 }
Exemplo n.º 28
0
<?php

/*+***********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 *************************************************************************************/
vimport('~~/modules/Calendar/iCal/iCalendar_rfc2445.php');
vimport('~~/modules/Calendar/iCal/iCalendar_components.php');
vimport('~~/modules/Calendar/iCal/iCalendar_properties.php');
vimport('~~/modules/Calendar/iCal/iCalendar_parameters.php');
vimport('~~/modules/Calendar/iCal/ical-parser-class.php');
vimport('~~/modules/Calendar/iCalLastImport.php');
class Calendar_ImportICS_Action extends Vtiger_Action_Controller
{
    public function checkPermission(Vtiger_Request $request)
    {
        $moduleName = $request->getModule();
        $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
        $userPrivilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
        $permission = $userPrivilegesModel->hasModulePermission($moduleModel->getId());
        if (!$permission) {
            throw new AppException('LBL_PERMISSION_DENIED');
        }
    }
    public function process(Vtiger_Request $request)
    {
        $moduleName = $request->getModule();
Exemplo n.º 29
0
 public static function runScheduledReports()
 {
     vimport('~~modules/com_vtiger_workflow/VTWorkflowUtils.php');
     $util = new VTWorkflowUtils();
     $util->adminUser();
     $currentModule = vglobal('currentModule');
     $current_language = vglobal('current_language');
     if (empty($currentModule)) {
         $currentModule = 'Reports';
     }
     if (empty($current_language)) {
         vglobal('current_language', 'en_us');
     }
     $scheduledReports = self::getScheduledReports();
     foreach ($scheduledReports as $scheduledReport) {
         $status = $scheduledReport->sendEmail();
         Vtiger_Utils::ModuleLog('ScheduleReprot Send Mail Status ', $status);
         if ($status) {
             $scheduledReport->updateNextTriggerTime();
         }
     }
     $util->revertUser();
     return $status;
 }
Exemplo n.º 30
0
<?php

/*+**********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.1
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is: SalesPlatform Ltd
 * The Initial Developer of the Original Code is SalesPlatform Ltd.
 * All Rights Reserved.
 * If you have any questions or comments, please email: devel@salesplatform.ru
 ************************************************************************************/
vimport('~~/modules/Act/ActPDFController.php');
class Act_ExportPDF_Action extends Inventory_ExportPDF_Action
{
    public function process(Vtiger_Request $request)
    {
        $moduleName = $request->getModule();
        $recordId = $request->get('record');
        ob_clean();
        // always '/n' in buffer  ???
        //SalesPlatform.ru begin get PDF template
        $templateId = $request->get('templateid');
        $recordModel = Vtiger_Record_Model::getInstanceById($recordId, $moduleName);
        //$recordModel->getPDF();
        $recordModel->getSalesPlatformPDF($templateId);
        //SalesPlatform.ru end
    }
}