示例#1
0
 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__);
 }
示例#2
0
	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();
	}