public function preProcess(Vtiger_Request $request, $display = true) { $viewer = $this->getViewer($request); $viewer->assign('SUPPORTED_MODULE_MODELS', Settings_Workflows_Module_Model::getSupportedModules()); $viewer->assign('CRON_RECORD_MODEL', Settings_CronTasks_Record_Model::getInstanceByName('Workflow')); parent::preProcess($request, $display); }
public function process(Vtiger_Request $request) { $log = vglobal('log'); $log->debug('Start ' . __CLASS__ . ':' . __FUNCTION__); $qualifiedModule = $request->getModule(false); $viewer = $this->getViewer($request); if ($request->has('upload') && $request->get('upload') == 'true') { $xmlName = $_FILES['imported_xml']['name']; $uploadedXml = $_FILES['imported_xml']['tmp_name']; $xmlError = $_FILES['imported_xml']['error']; $extension = end(explode('.', $xmlName)); if ($xmlError == UPLOAD_ERR_OK && $extension === 'xml') { $xml = simplexml_load_file($uploadedXml); $params = []; $taskIndex = $methodIndex = 0; foreach ($xml as $fieldsKey => $fieldsValue) { foreach ($fieldsValue as $fieldKey => $fieldValue) { foreach ($fieldValue as $columnKey => $columnValue) { if ($columnKey === 'conditions') { $columnKey = 'test'; } else { if ($columnKey == 'type' && empty($columnValue)) { $columnValue = 'basic'; } } switch ($fieldKey) { case 'workflow_method': $params[$fieldsKey][$methodIndex][$columnKey] = (string) $columnValue; break; case 'workflow_task': $params[$fieldsKey][$taskIndex][$columnKey] = (string) $columnValue; break; default: $params[$fieldsKey][$columnKey] = (string) $columnValue; } } if ($fieldKey === 'workflow_task') { $taskIndex++; } elseif ($fieldKey === 'workflow_method') { $methodIndex++; } } } $workflowModel = Settings_Workflows_Module_Model::getInstance('Settings:Workflows'); $messages = $workflowModel->importWorkflow($params); $viewer->assign('RECORDID', $messages['id']); $viewer->assign('UPLOAD', true); $viewer->assign('MESSAGES', $messages); } else { $viewer->assign('UPLOAD_ERROR', vtranslate('LBL_UPLOAD_ERROR', $qualifiedModule)); $viewer->assign('UPLOAD', false); } } $viewer->assign('QUALIFIED_MODULE', $qualifiedModule); $viewer->view('Import.tpl', $qualifiedModule); $log->debug('End ' . __CLASS__ . ':' . __FUNCTION__); }
public function process(Vtiger_Request $request) { $recordId = $request->get('record'); $moduleName = $request->getModule(); $qualifiedModuleName = $request->getModule(false); $recordModel = Settings_CronTasks_Record_Model::getInstanceById($recordId, $qualifiedModuleName); $viewer = $this->getViewer($request); $viewer->assign('RECORD_MODEL', $recordModel); $viewer->assign('MODULE', $moduleName); $viewer->assign('MODULE_LIST', Settings_Workflows_Module_Model::getSupportedModules()); $viewer->assign('RECORD', $recordId); $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName); $viewer->view('AddAjax.tpl', $qualifiedModuleName); }
public function process(Vtiger_Request $request) { $qualifiedModuleName = $request->getModule(false); $sequencesList = $request->get('sequencesList'); $workflow_id = $request->get('workflow_id'); $moduleModel = Settings_Workflows_Module_Model::getInstance($qualifiedModuleName); $response = new Vtiger_Response(); if ($sequencesList) { $uresult = $moduleModel->updateTaskSequence($sequencesList, $workflow_id); $response->setResult($uresult); } else { $response->setError(); } $response->emit(); }
public function process(Vtiger_Request $request) { $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $qualifiedModuleName = $request->getModule(false); $workflowId = $request->get('for_workflow'); $workflowModel = Settings_Workflows_Record_Model::getInstance($workflowId); $relatedModule = $request->get('relatedModule'); $relatedModuleModel = Vtiger_Module_Model::getInstance($relatedModule); $workflowModuleModel = $workflowModel->getModule(); $viewer->assign('WORKFLOW_MODEL', $workflowModel); $viewer->assign('REFERENCE_FIELD_NAME', $workflowModel->getReferenceFieldName($relatedModule)); $viewer->assign('RELATED_MODULE_MODEL', $relatedModuleModel); $viewer->assign('FIELD_EXPRESSIONS', Settings_Workflows_Module_Model::getExpressions()); $viewer->assign('MODULE_MODEL', $workflowModuleModel); $viewer->assign('SOURCE_MODULE', $workflowModuleModel->getName()); $viewer->assign('RELATED_MODULE_MODEL_NAME', ''); $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName); $viewer->view('CreateEntity.tpl', $qualifiedModuleName); }
public function preProcess(Vtiger_Request $request, $display=true) { $viewer = $this->getViewer($request); $viewer->assign('SUPPORTED_MODULE_MODELS', Settings_Workflows_Module_Model::getSupportedModules()); $sourceProcess = $request->get('sourceProcess'); if(!($sourceProcess > -1) || $sourceProcess === '') { $sourceProcess = -1; $request->set('sourceProcess', $sourceProcess); } $viewer->assign('SOURCE_PROCESS', $sourceProcess); $filterActive = $request->get('filterActive'); if(!($filterActive > -1) || $filterActive === '') { $filterActive = -1; $request->set('filterActive', $filterActive); } $viewer->assign('FILTER_ACTIVE', $filterActive); $viewer->assign('ACTIVE_PROCESS_LIST', Settings_Workflows_Module_Model::getActiveProcesses()); $viewer->assign('PROCESS_UNASSIGNED_COUNT', Settings_Workflows_Module_Model::getUnassignedWorkflowsCount()); $viewer->assign('CRON_RECORD_MODEL', Settings_CronTasks_Record_Model::getInstanceByName('Workflow')); parent::preProcess($request, $display); }
public function process(Vtiger_Request $request) { $currentUser = Users_Record_Model::getCurrentUserModel(); $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $qualifiedModuleName = $request->getModule(false); $recordId = $request->get('task_id'); $workflowId = $request->get('for_workflow'); $workflowModel = Settings_Workflows_Record_Model::getInstance($workflowId); $taskTypes = $workflowModel->getTaskTypes(); if ($recordId) { $taskModel = Settings_Workflows_TaskRecord_Model::getInstance($recordId); } else { $taskType = $request->get('type'); if (empty($taskType)) { $taskType = !empty($taskTypes[0]) ? $taskTypes[0]->getName() : 'VTEmailTask'; } $taskModel = Settings_Workflows_TaskRecord_Model::getCleanInstance($workflowModel, $taskType); } $taskTypeModel = $taskModel->getTaskType(); $viewer->assign('TASK_TYPE_MODEL', $taskTypeModel); $viewer->assign('TASK_TEMPLATE_PATH', $taskTypeModel->getTemplatePath()); $recordStructureInstance = Settings_Workflows_RecordStructure_Model::getInstanceForWorkFlowModule($workflowModel, Settings_Workflows_RecordStructure_Model::RECORD_STRUCTURE_MODE_EDITTASK); $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance); $viewer->assign('RECORD_STRUCTURE', $recordStructureInstance->getStructure()); $moduleModel = $workflowModel->getModule(); $dateTimeFields = $moduleModel->getFieldsByType(array('date', 'datetime')); $taskObject = $taskModel->getTaskObject(); $taskType = get_class($taskObject); if ($taskType === 'VTCreateEntityTask') { if ($taskObject->entity_type) { $relationModuleModel = Vtiger_Module_Model::getInstance($taskObject->entity_type); $ownerFieldModels = $relationModuleModel->getFieldsByType('owner'); $fieldMapping = Zend_Json::decode($taskObject->field_value_mapping); foreach ($fieldMapping as $key => $mappingInfo) { if (array_key_exists($mappingInfo['fieldname'], $ownerFieldModels)) { $userRecordModel = Users_Record_Model::getInstanceByName($mappingInfo['value']); if ($userRecordModel) { $ownerName = $userRecordModel->getId(); } else { $groupRecordModel = Settings_Groups_Record_Model::getInstance($mappingInfo['value']); $ownerName = $groupRecordModel->getId(); } $fieldMapping[$key]['value'] = $ownerName; } } $taskObject->field_value_mapping = Zend_Json::encode($fieldMapping); } } if ($taskType === 'VTUpdateFieldsTask') { if ($moduleModel->getName() == "Documents") { $restrictFields = array('folderid', 'filename', 'filelocationtype'); $viewer->assign('RESTRICTFIELDS', $restrictFields); } } $viewer->assign('SOURCE_MODULE', $moduleModel->getName()); $viewer->assign('MODULE_MODEL', $moduleModel); $viewer->assign('TASK_ID', $recordId); $viewer->assign('WORKFLOW_ID', $workflowId); $viewer->assign('DATETIME_FIELDS', $dateTimeFields); $viewer->assign('WORKFLOW_MODEL', $workflowModel); $viewer->assign('TASK_TYPES', $taskTypes); $viewer->assign('TASK_MODEL', $taskModel); $viewer->assign('CURRENTDATE', date('Y-n-j')); $metaVariables = Settings_Workflows_Module_Model::getMetaVariables(); if ($moduleModel->getName() == 'Invoice' || $moduleModel->getName() == 'Quotes') { $metaVariables['Portal Pdf Url'] = '(general : (__VtigerMeta__) portalpdfurl)'; } // Adding option Line Item block for Individual tax mode $individualTaxBlockLabel = vtranslate("LBL_LINEITEM_BLOCK_GROUP", $qualifiedModuleName); $individualTaxBlockValue = $viewer->view('LineItemsGroupTemplate.tpl', $qualifiedModuleName, $fetch = true); // Adding option Line Item block for group tax mode $groupTaxBlockLabel = vtranslate("LBL_LINEITEM_BLOCK_INDIVIDUAL", $qualifiedModuleName); $groupTaxBlockValue = $viewer->view('LineItemsIndividualTemplate.tpl', $qualifiedModuleName, $fetch = true); $templateVariables = array($individualTaxBlockValue => $individualTaxBlockLabel, $groupTaxBlockValue => $groupTaxBlockLabel); $viewer->assign('META_VARIABLES', $metaVariables); $viewer->assign('TEMPLATE_VARIABLES', $templateVariables); $viewer->assign('TASK_OBJECT', $taskObject); $viewer->assign('FIELD_EXPRESSIONS', Settings_Workflows_Module_Model::getExpressions()); $repeat_date = $taskModel->getTaskObject()->calendar_repeat_limit_date; if (!empty($repeat_date)) { $repeat_date = Vtiger_Date_UIType::getDisplayDateValue($repeat_date); } $viewer->assign('REPEAT_DATE', $repeat_date); $userModel = Users_Record_Model::getCurrentUserModel(); $viewer->assign('dateFormat', $userModel->get('date_format')); $viewer->assign('timeFormat', $userModel->get('hour_format')); $viewer->assign('MODULE', $moduleName); $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName); $emailFields = $recordStructureInstance->getAllEmailFields(); foreach ($emailFields as $metaKey => $emailField) { $emailFieldoptions .= '<option value=",$' . $metaKey . '">' . $emailField->get('workflow_columnlabel') . '</option>'; } $nameFields = $recordStructureInstance->getNameFields(); $fromEmailFieldOptions = '<option value="">' . vtranslate('Optional', $qualifiedModuleName) . '</option>'; $fromEmailFieldOptions .= '<option value="$(general : (__VtigerMeta__) supportName)<$(general : (__VtigerMeta__) supportEmailId)>" >' . vtranslate('LBL_HELPDESK_SUPPORT_EMAILID', $qualifiedModuleName) . '</option>'; foreach ($emailFields as $metaKey => $emailField) { list($relationFieldName, $rest) = explode(' ', $metaKey); $value = '<$' . $metaKey . '>'; if ($nameFields) { $nameFieldValues = ''; foreach (array_keys($nameFields) as $fieldName) { if (strstr($fieldName, $relationFieldName) || count(explode(' ', $metaKey)) === 1 && count(explode(' ', $fieldName)) === 1) { $fieldName = '$' . $fieldName; $nameFieldValues .= ' ' . $fieldName; } } $value = trim($nameFieldValues) . $value; } $fromEmailFieldOptions .= '<option value="' . $value . '">' . $emailField->get('workflow_columnlabel') . '</option>'; } $structure = $recordStructureInstance->getStructure(); // for inventory modules we shouldn't show item detail fields if ($taskType == "VTEmailTask" && in_array($workflowModel->getModule()->name, getInventoryModules())) { $itemsBlock = "LBL_ITEM_DETAILS"; unset($structure[$itemsBlock]); } foreach ($structure as $fields) { foreach ($fields as $field) { $allFieldoptions .= '<option value="$' . $field->get('workflow_columnname') . '">' . $field->get('workflow_columnlabel') . '</option>'; } } $userList = $currentUser->getAccessibleUsers(); $groupList = $currentUser->getAccessibleGroups(); $assignedToValues = array(); $assignedToValues[vtranslate('LBL_USERS', 'Vtiger')] = $userList; $assignedToValues[vtranslate('LBL_GROUPS', 'Vtiger')] = $groupList; $viewer->assign('ASSIGNED_TO', $assignedToValues); $viewer->assign('EMAIL_FIELD_OPTION', $emailFieldoptions); $viewer->assign('FROM_EMAIL_FIELD_OPTION', $fromEmailFieldOptions); $viewer->assign('ALL_FIELD_OPTIONS', $allFieldoptions); $viewer->view('EditTask.tpl', $qualifiedModuleName); }
public function step2(Vtiger_Request $request) { $viewer = $this->getViewer($request); $moduleName = $request->getModule(); $qualifiedModuleName = $request->getModule(false); $recordId = $request->get('record'); if ($recordId) { $workFlowModel = Settings_Workflows_Record_Model::getInstance($recordId); $selectedModule = $workFlowModel->getModule(); $selectedModuleName = $selectedModule->getName(); } else { $selectedModuleName = $request->get('module_name'); $selectedModule = Vtiger_Module_Model::getInstance($selectedModuleName); $workFlowModel = Settings_Workflows_Record_Model::getCleanInstance($selectedModuleName); } $requestData = $request->getAll(); foreach ($requestData as $name => $value) { if ($name == 'schdayofweek' || $name == 'schdayofmonth' || $name == 'schannualdates') { if (is_string($value)) { // need to save these as json data $value = array($value); } } if ($name == 'summary') { $value = htmlspecialchars($value); } $workFlowModel->set($name, $value); } //Added to support advance filters $recordStructureInstance = Settings_Workflows_RecordStructure_Model::getInstanceForWorkFlowModule($workFlowModel, Settings_Workflows_RecordStructure_Model::RECORD_STRUCTURE_MODE_FILTER); $viewer->assign('RECORD_STRUCTURE_MODEL', $recordStructureInstance); $recordStructure = $recordStructureInstance->getStructure(); if (in_array($selectedModuleName, getInventoryModules())) { $itemsBlock = "LBL_ITEM_DETAILS"; unset($recordStructure[$itemsBlock]); } $viewer->assign('RECORD_STRUCTURE', $recordStructure); $viewer->assign('WORKFLOW_MODEL', $workFlowModel); $viewer->assign('MODULE_MODEL', $selectedModule); $viewer->assign('SELECTED_MODULE_NAME', $selectedModuleName); $dateFilters = Vtiger_Field_Model::getDateFilterTypes(); foreach ($dateFilters as $comparatorKey => $comparatorInfo) { $comparatorInfo['startdate'] = DateTimeField::convertToUserFormat($comparatorInfo['startdate']); $comparatorInfo['enddate'] = DateTimeField::convertToUserFormat($comparatorInfo['enddate']); $comparatorInfo['label'] = vtranslate($comparatorInfo['label'], $qualifiedModuleName); $dateFilters[$comparatorKey] = $comparatorInfo; } $viewer->assign('DATE_FILTERS', $dateFilters); $viewer->assign('ADVANCED_FILTER_OPTIONS', Settings_Workflows_Field_Model::getAdvancedFilterOptions()); $viewer->assign('ADVANCED_FILTER_OPTIONS_BY_TYPE', Settings_Workflows_Field_Model::getAdvancedFilterOpsByFieldType()); $viewer->assign('COLUMNNAME_API', 'getWorkFlowFilterColumnName'); $viewer->assign('FIELD_EXPRESSIONS', Settings_Workflows_Module_Model::getExpressions()); $viewer->assign('META_VARIABLES', Settings_Workflows_Module_Model::getMetaVariables()); // Added to show filters only when saved from vtiger6 if ($workFlowModel->isFilterSavedInNew()) { $viewer->assign('ADVANCE_CRITERIA', $workFlowModel->transformToAdvancedFilterCondition()); } else { $viewer->assign('ADVANCE_CRITERIA', ""); } $viewer->assign('IS_FILTER_SAVED_NEW', $workFlowModel->isFilterSavedInNew()); $viewer->assign('MODULE', $moduleName); $viewer->assign('QUALIFIED_MODULE', $qualifiedModuleName); $viewer->view('Step2.tpl', $qualifiedModuleName); }
public function preProcess(Vtiger_Request $request, $display = true) { $viewer = $this->getViewer($request); $viewer->assign('SUPPORTED_MODULE_MODELS', Settings_Workflows_Module_Model::getSupportedModules()); parent::preProcess($request, $display); }
public function process(Vtiger_Request $request) { $recordId = $request->get('id'); $workflowModel = Settings_Workflows_Record_Model::getInstance($recordId); $workflowObject = $workflowModel->getWorkflowObject(); $workflowMethods = []; header('content-type: application/xml; charset=utf-8'); header('Pragma: public'); header('Cache-Control: private'); header('Content-Disposition: attachment; filename=' . $recordId . '_workflow.xml'); header('Content-Description: PHP Generated Data'); $xml = new DOMDocument('1.0', 'utf-8'); $xml->preserveWhiteSpace = false; $xml->formatOutput = true; $xmlTemplate = $xml->createElement('workflow'); $xmlFields = $xml->createElement('fields'); $xmlField = $xml->createElement('field'); $cDataColumns = ['conditions']; foreach (Settings_Workflows_Module_Model::$allFields as $field) { if ($workflowModel->has($field)) { if (in_array($field, $cDataColumns)) { $name = $xmlField->appendChild($xml->createElement($field)); $name->appendChild($xml->createCDATASection(json_encode($workflowModel->get($field)))); } else { $value = $workflowModel->get($field); $xmlColumn = $xml->createElement($field, html_entity_decode($value, ENT_COMPAT, 'UTF-8')); } } else { $value = $workflowObject->{$field}; $xmlColumn = $xml->createElement($field, html_entity_decode($value, ENT_COMPAT, 'UTF-8')); } $xmlField->appendChild($xmlColumn); } $xmlFields->appendChild($xmlField); $xmlTemplate->appendChild($xmlFields); $xmlTasks = $xml->createElement('workflow_tasks'); foreach ($workflowModel->getTasksForExport() as $task) { $xmlTask = $xml->createElement('workflow_task'); $xmlColumn = $xml->createElement('summary', html_entity_decode($task['summary'], ENT_COMPAT, 'UTF-8')); $xmlTask->appendChild($xmlColumn); if (strpos($task['task'], 'VTEntityMethodTask') !== false) { require_once 'modules/com_vtiger_workflow/tasks/VTEntityMethodTask.inc'; $taskObject = unserialize(html_entity_decode($task['task'])); $method = Settings_Workflows_Module_Model::exportTaskMethod($taskObject->methodName); if (!array_key_exists($method['workflowtasks_entitymethod_id'], $method)) { $workflowMethods[$method['workflowtasks_entitymethod_id']] = $method; } } $name = $xmlTask->appendChild($xml->createElement('task')); $name->appendChild($xml->createCDATASection(html_entity_decode($task['task']))); $xmlTasks->appendChild($xmlTask); $xmlTemplate->appendChild($xmlTasks); } $xmlMethods = $xml->createElement('workflow_methods'); foreach ($workflowMethods as $method) { $xmlMethod = $xml->createElement('workflow_method'); $xmlMethod->appendChild($xml->createElement('module_name', html_entity_decode($method['module_name'], ENT_COMPAT, 'UTF-8'))); $xmlMethod->appendChild($xml->createElement('method_name', html_entity_decode($method['method_name'], ENT_COMPAT, 'UTF-8'))); $xmlMethod->appendChild($xml->createElement('function_path', html_entity_decode($method['function_path'], ENT_COMPAT, 'UTF-8'))); $xmlMethod->appendChild($xml->createElement('function_name', html_entity_decode($method['function_name'], ENT_COMPAT, 'UTF-8'))); $script = $xmlMethod->appendChild($xml->createElement('script_content')); $script->appendChild($xml->createCDATASection(html_entity_decode($method['script_content']))); $xmlMethods->appendChild($xmlMethod); $xmlTemplate->appendChild($xmlMethods); } $xml->appendChild($xmlTemplate); print $xml->saveXML(); }
public function process(Vtiger_Request $request) { if (!Settings_Vtiger_Index_View::$loadOlderSettingUi) { //NOTE: We plan to embed UI5 Settings until we are complete. $viewer = $this->getViewer($request); $qualifiedModuleName = $request->getModule(false); $usersCount = Users_Record_Model::getCount(true); $activeWorkFlows = Settings_Workflows_Module_Model::getActiveWorkflowCount(); $activeModules = Settings_ModuleManager_Module_Model::getModulesCount(true); $pinnedSettingsShortcuts = Settings_Vtiger_MenuItem_Model::getPinnedItems(); $viewer->assign('USERS_COUNT', $usersCount); $viewer->assign('ACTIVE_WORKFLOWS', $activeWorkFlows); $viewer->assign('ACTIVE_MODULES', $activeModules); $viewer->assign('SETTINGS_SHORTCUTS', $pinnedSettingsShortcuts); $viewer->assign('MODULE', $qualifiedModuleName); $viewer->view('Index.tpl', $qualifiedModuleName); } }
/** * Delete this instance */ function delete() { $moduleInstance = Vtiger_Module_Model::getInstance($this->name); require_once "modules/{$this->name}/{$this->name}.php"; $focus = new $this->name(); $this->tableName = $focus->table_name; if ($this->isentitytype) { $this->deleteFromCRMEntity(); Vtiger_Access::deleteTools($this); Vtiger_Filter::deleteForModule($this); Vtiger_Block::deleteForModule($this); if (method_exists($this, 'deinitWebservice')) { $this->deinitWebservice(); } } $this->deleteIcons(); $this->unsetAllRelatedList($moduleInstance); ModComments_Module_Model::deleteForModule($moduleInstance); Vtiger_Language::deleteForModule($moduleInstance); Vtiger_Access::deleteSharing($moduleInstance); $this->deleteFromModentityNum(); Vtiger_Cron::deleteForModule($moduleInstance); Vtiger_Profile::deleteForModule($moduleInstance); Settings_Workflows_Module_Model::deleteForModule($moduleInstance); Vtiger_Menu::deleteForModule($moduleInstance); $this->deleteGroup2Modules(); $this->deleteModuleTables(); $this->deleteCRMEntityRel(); Vtiger_Profile::deleteForModule($this); Vtiger_Link::deleteAll($this->id); $this->deleteDir($moduleInstance); $this->__delete(); self::syncfile(); }