Пример #1
0
 /**
  * @url POST /project/:prj_uid/dynaforms
  *
  * @param string $prj_uid {@min 32}{@max 32}
  *
  */
 public function doGetDynaFormsId($prj_uid, $request_data)
 {
     try {
         $dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
         $dynaForm->setFormatFieldNameInUppercase(false);
         \G::LoadClass("pmDynaform");
         $pmDynaForm = new \pmDynaform();
         $_SESSION['PROCESS'] = $prj_uid;
         $return = array();
         foreach ($request_data['formId'] as $dyn_uid) {
             $response = $dynaForm->getDynaForm($dyn_uid);
             $result   = $this->parserDataDynaForm($response);
             $result['formContent'] = (isset($result['formContent']) && $result['formContent'] != null)?json_decode($result['formContent']):"";
             $pmDynaForm->jsonr($result['formContent']);
             $return[] = $result;
         }
     } catch (\Exception $e) {
         throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
     }
     return $return;
 }
Пример #2
0
 /**
  * @url POST /:prj_uid/dynaform/:dyn_uid/history
  *
  * @param string $dyn_uid {@min 32}{@max 32}
  * @param string $prj_uid {@min 32}{@max 32}
  * @param array  $request_data
  */
 public function doGetDynaFormHistory($dyn_uid, $prj_uid, $request_data)
 {
     try {
         $dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
         $dynaForm->setFormatFieldNameInUppercase(false);
         $response = $dynaForm->getDynaFormHistory($prj_uid, $dyn_uid, $request_data);
         return $response;
     } catch (\Exception $e) {
         throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
     }
 }
Пример #3
0
 /**
  * Validate the data if they are invalid (INSERT and UPDATE)
  *
  * @param string $webEntryUid Unique id of Web Entry
  * @param string $processUid  Unique id of Process
  * @param array  $arrayData   Data
  *
  * return void Throw exception if data has an invalid value
  */
 public function throwExceptionIfDataIsInvalid($webEntryUid, $processUid, array $arrayData)
 {
     try {
         //Set variables
         $arrayWebEntryData = $webEntryUid == "" ? array() : $this->getWebEntry($webEntryUid, true);
         $flagInsert = $webEntryUid == "" ? true : false;
         $arrayDataMain = array_merge($arrayWebEntryData, $arrayData);
         //Verify data - Field definition
         $process = new \ProcessMaker\BusinessModel\Process();
         $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
         if ($arrayDataMain["WE_METHOD"] == "WS") {
             $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayUserFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
         }
         //Verify data
         if (isset($arrayData["WE_TITLE"])) {
             $this->throwExceptionIfExistsTitle($processUid, $arrayData["WE_TITLE"], $this->arrayFieldNameForException["webEntryTitle"], $webEntryUid);
         }
         if (isset($arrayData["TAS_UID"])) {
             $task = new \ProcessMaker\BusinessModel\Task();
             $task->throwExceptionIfNotExistsTask($processUid, $arrayData["TAS_UID"], $this->arrayFieldNameForException["taskUid"]);
         }
         if (isset($arrayData["DYN_UID"])) {
             $dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
             $dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $processUid, $this->arrayFieldNameForException["dynaFormUid"]);
         }
         if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["USR_UID"])) {
             $process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
         }
         $task = new \Task();
         $arrayTaskData = $task->load($arrayDataMain["TAS_UID"]);
         if (isset($arrayData["TAS_UID"])) {
             if ($arrayTaskData["TAS_START"] == "FALSE") {
                 throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_IS_NOT_INITIAL_ACTIVITY", array($arrayTaskData["TAS_TITLE"])));
             }
             if ($arrayTaskData["TAS_ASSIGN_TYPE"] != "BALANCED") {
                 throw new \Exception(\G::LoadTranslation("ID_WEB_ENTRY_ACTIVITY_DOES_NOT_HAVE_VALID_ASSIGNMENT_TYPE", array($arrayTaskData["TAS_TITLE"])));
             }
         }
         if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["TAS_UID"])) {
             $task = new \Tasks();
             if ($task->assignUsertoTask($arrayData["TAS_UID"]) == 0) {
                 throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_DOES_NOT_HAVE_USERS", array($arrayTaskData["TAS_TITLE"])));
             }
         }
         if (isset($arrayData["DYN_UID"])) {
             $dynaForm = new \Dynaform();
             $arrayDynaFormData = $dynaForm->Load($arrayData["DYN_UID"]);
             $step = new \ProcessMaker\BusinessModel\Step();
             if (!$step->existsRecord($arrayDataMain["TAS_UID"], "DYNAFORM", $arrayData["DYN_UID"])) {
                 throw new \Exception(\G::LoadTranslation("ID_DYNAFORM_IS_NOT_ASSIGNED_TO_ACTIVITY", array($arrayDynaFormData["DYN_TITLE"], $arrayTaskData["TAS_TITLE"])));
             }
         }
         if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["USR_UID"])) {
             $user = new \Users();
             $arrayUserData = $user->load($arrayData["USR_UID"]);
             //Verify if User is assigned to Task
             $projectUser = new \ProcessMaker\BusinessModel\ProjectUser();
             if (!$projectUser->userIsAssignedToTask($arrayData["USR_UID"], $arrayDataMain["TAS_UID"])) {
                 throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_HAVE_ACTIVITY_ASSIGNED", array($arrayUserData["USR_USERNAME"], $arrayTaskData["TAS_TITLE"])));
             }
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
Пример #4
0
 /**
  * Validate the data if they are invalid (INSERT and UPDATE)
  *
  * @param string $webEntryEventUid Unique id of WebEntry-Event
  * @param string $projectUid       Unique id of Project
  * @param array  $arrayData        Data
  *
  * return void Throw exception if data has an invalid value
  */
 public function throwExceptionIfDataIsInvalid($webEntryEventUid, $projectUid, array $arrayData)
 {
     try {
         //Set variables
         $arrayWebEntryEventData = $webEntryEventUid == "" ? array() : $this->getWebEntryEvent($webEntryEventUid, true);
         $flagInsert = $webEntryEventUid == "" ? true : false;
         $arrayFinalData = array_merge($arrayWebEntryEventData, $arrayData);
         //Verify data - Field definition
         $process = new \ProcessMaker\BusinessModel\Process();
         $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
         //Verify data
         if (isset($arrayData["EVN_UID"])) {
             $this->throwExceptionIfEventIsRegistered($projectUid, $arrayData["EVN_UID"], $this->arrayFieldNameForException["eventUid"], $webEntryEventUid);
         }
         if (isset($arrayData["EVN_UID"])) {
             $obj = \BpmnEventPeer::retrieveByPK($arrayData["EVN_UID"]);
             if (is_null($obj)) {
                 throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_EXIST", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"])));
             }
             if ($obj->getEvnType() != "START" || $obj->getEvnType() == "START" && $obj->getEvnMarker() != "EMPTY") {
                 throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_IS_START_EVENT", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"])));
             }
         }
         if (isset($arrayData["WEE_TITLE"])) {
             $this->throwExceptionIfExistsTitle($projectUid, $arrayData["WEE_TITLE"], $this->arrayFieldNameForException["webEntryEventTitle"], $webEntryEventUid);
         }
         if (isset($arrayData["ACT_UID"])) {
             $bpmn = new \ProcessMaker\Project\Bpmn();
             if (!$bpmn->activityExists($arrayData["ACT_UID"])) {
                 throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_DOES_NOT_EXIST", array($this->arrayFieldNameForException["activityUid"], $arrayData["ACT_UID"])));
             }
         }
         if (isset($arrayData["EVN_UID"]) || isset($arrayData["ACT_UID"])) {
             $criteria = new \Criteria("workflow");
             $criteria->addSelectColumn(\BpmnFlowPeer::FLO_UID);
             $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $arrayFinalData["EVN_UID"], \Criteria::EQUAL);
             $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE, "bpmnEvent", \Criteria::EQUAL);
             $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_DEST, $arrayFinalData["ACT_UID"], \Criteria::EQUAL);
             $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE, "bpmnActivity", \Criteria::EQUAL);
             $rsCriteria = \BpmnFlowPeer::doSelectRS($criteria);
             if (!$rsCriteria->next()) {
                 throw new \Exception(\G::LoadTranslation("ID_WEB_ENTRY_EVENT_FLOW_EVENT_TO_ACTIVITY_DOES_NOT_EXIST"));
             }
         }
         if (isset($arrayData["DYN_UID"])) {
             $dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
             $dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $projectUid, $this->arrayFieldNameForException["dynaFormUid"]);
         }
         if (isset($arrayData["USR_UID"])) {
             $process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
Пример #5
0
     //For Extjs (Since we are not using form in ExtJS)
     $aFields = array();
     $aVariables = array();
     if (isset($aData['FIELDS'])) {
         $aFields = G::json_decode($_POST['FIELDS']);
         $aVariables = G::json_decode($_POST['VARIABLES']);
     }
     $aData['FIELDS'] = array();
     for ($i = 0; $i < count($aFields); $i++) {
         $aData['FIELDS'][$i + 1]['FLD_NAME'] = $aFields[$i];
         $aData['FIELDS'][$i + 1]['PRO_VARIABLE'] = $aVariables[$i];
     }
 }
 //if ($aData['DYN_UID']==='') unset($aData['DYN_UID']);
 $dynaform = new dynaform();
 $dynaFormAux = new ProcessMaker\BusinessModel\DynaForm();
 if (isset($aData["DYN_UID"])) {
     $dynaform->Save($aData);
 } else {
     switch ($aData["ACTION"]) {
         case "copy":
             $aData["DYN_TYPE"] = $aData["COPY_TYPE"];
             $aData["DYN_TITLE"] = $aData["COPY_DYNAFORM_TITLE"];
             $aData["DYN_DESCRIPTION"] = $aData["COPY_DYNAFORM_DESCRIPTION"];
             $aFields = $dynaform->create($aData);
             $dynaformUid = $dynaform->getDynUid();
             //Copy files of the dynaform
             $umaskOld = umask(0);
             $fileXml = PATH_DYNAFORM . $aData["COPY_PROCESS_UID"] . PATH_SEP . $aData["COPY_DYNAFORM_UID"] . ".xml";
             if (file_exists($fileXml)) {
                 $fileXmlCopy = PATH_DYNAFORM . $aData["PRO_UID"] . PATH_SEP . $dynaformUid . ".xml";
Пример #6
0
    /**
     * Get Variables of a Process/Grid
     *
     * @param string $option     Option (GRID, GRIDVARS, ALL)
     * @param string $processUid Unique id of Process
     * @param string $gridUid    Unique id of Grid (DynaForm)
     *
     * return array Return an array with Variables of a Process/Grid
     */
    public function getVariables($option, $processUid, $gridUid = "")
    {
        try {
            $arrayVariable = array();

            //Verify data
            $this->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);

            //Get data
            switch ($option) {
                case "GRID":
                    $arrayVar = self::getGridsVars($processUid);

                    foreach ($arrayVar as $key => $value) {
                        $arrayVariableAux = $this->getVariableDataFromRecord(array("name" => $value["sName"], "label" => "[ " . \G::LoadTranslation("ID_GRID") . " ]", "type" => "grid"));

                        $arrayVariable[] = array_merge($arrayVariableAux, array($this->getFieldNameByFormatFieldName("GRID_UID") => $value["sXmlForm"]));
                    }
                    break;
                case "GRIDVARS":
                    //Verify data
                    $dynaForm = new \ProcessMaker\BusinessModel\DynaForm();

                    $dynaForm->throwExceptionIfNotExistsDynaForm($gridUid, $processUid, $this->arrayFieldNameForException["gridUid"]);
                    $dynaForm->throwExceptionIfNotIsGridDynaForm($gridUid, $this->arrayFieldNameForException["gridUid"]);

                    //Get data
                    $fields = self::getVarsGrid($processUid, $gridUid);
                    foreach ($fields as $field) {
                        $arrayVariable[] = $this->getVariableDataFromRecord(array("name" => $field["sName"], "label" => $field["sLabel"], "type" => $field["sType"]));
                    }

                    break;
                default:
                    //ALL
                    $arrayVar = self::getDynaformsVars($processUid);

                    foreach ($arrayVar as $key => $value) {
                        $arrayVariable[] = $this->getVariableDataFromRecord(array("name" => $value["sName"], "label" => $value["sLabel"], "type" => $value["sType"], "source" => $value["sUid"]));
                    }

                    $arrayHtmlVariable = self::getHtmlFormVars($processUid);
                    $arrayVariable = array_merge($arrayVariable, $arrayHtmlVariable);

                    break;
            }

            //Return
            return $arrayVariable;
        } catch (\Exception $e) {
            throw $e;
        }
    }