/** * Create a Dynaform based on a PMTable * * @param string $processUid Unique id of Process * @param array $arrayData Data * * return array Return data of the new DynaForm created */ public function createBasedPmTable($processUid, $arrayData) { try { $arrayData = \G::array_change_key_case2($arrayData, CASE_UPPER); unset($arrayData["DYN_UID"]); unset($arrayData["COPY_IMPORT"]); //Verify data $process = new \ProcessMaker\BusinessModel\Process(); $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); if ($arrayData["DYN_TYPE"] == "grid") { throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES", array($this->arrayFieldNameForException["dynaFormType"], "xmlform"))); } if (!isset($arrayData["PMTABLE"])) { throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->getFieldNameByFormatFieldName("PMTABLE")))); } if (!isset($arrayData["PMTABLE"]["TAB_UID"])) { throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->getFieldNameByFormatFieldName("PMTABLE.TAB_UID")))); } $arrayData["PMTABLE"]["TAB_UID"] = trim($arrayData["PMTABLE"]["TAB_UID"]); if ($arrayData["PMTABLE"]["TAB_UID"] == "") { throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->getFieldNameByFormatFieldName("PMTABLE.TAB_UID")))); } if (!isset($arrayData["PMTABLE"]["FIELDS"])) { throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->getFieldNameByFormatFieldName("PMTABLE.FIELDS")))); } if (count($arrayData["PMTABLE"]["FIELDS"]) == 0) { throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->getFieldNameByFormatFieldName("PMTABLE.FIELDS")))); } $this->throwExceptionIfExistsTitle($processUid, $arrayData["DYN_TITLE"], $this->arrayFieldNameForException["dynaFormTitle"]); $process->throwExceptionIfNotExistsPmTable($arrayData["PMTABLE"]["TAB_UID"], $this->getFieldNameByFormatFieldName("PMTABLE.TAB_UID")); //Validate PMTABLE.FIELDS //Valid Keys $flagValidFieldKey = 1; foreach ($arrayData["PMTABLE"]["FIELDS"] as $key => $value) { if (!isset($value["FLD_NAME"]) || !isset($value["PRO_VARIABLE"])) { $flagValidFieldKey = 0; break; } } if ($flagValidFieldKey == 0) { throw new \Exception(\G::LoadTranslation("ID_ATTRIBUTE_HAS_INVALID_ELEMENT_KEY", array($this->getFieldNameByFormatFieldName("PMTABLE.FIELDS")))); } //Is Primary Key $arrayFieldPk = $process->getPmTablePrimaryKeyFields($arrayData["PMTABLE"]["TAB_UID"], $this->getFieldNameByFormatFieldName("PMTABLE.TAB_UID")); $flagValidFieldPk = 1; $invalidFieldPk = ""; $arrayFieldPkAux = array(); foreach ($arrayData["PMTABLE"]["FIELDS"] as $key => $value) { $arrayFieldPkAux[] = $value["FLD_NAME"]; if (!in_array($value["FLD_NAME"], $arrayFieldPk)) { $flagValidFieldPk = 0; $invalidFieldPk = $value["FLD_NAME"]; break; } } if ($flagValidFieldPk == 0) { throw new \Exception(\G::LoadTranslation("ID_PMTABLE_FIELD_IS_NOT_PRIMARY_KEY", array($this->getFieldNameByFormatFieldName("PMTABLE.FIELDS.FLD_NAME"), $invalidFieldPk))); } //All Primary Keys $flagAllFieldPk = 1; $missingFieldPk = ""; foreach ($arrayFieldPk as $key => $value) { if (!in_array($value, $arrayFieldPkAux)) { $flagAllFieldPk = 0; $missingFieldPk = $value; break; } } if ($flagAllFieldPk == 0) { throw new \Exception(\G::LoadTranslation("ID_PMTABLE_PRIMARY_KEY_FIELD_IS_MISSING_IN_ATTRIBUTE", array($missingFieldPk, $this->getFieldNameByFormatFieldName("PMTABLE.FIELDS")))); } //Total of Primary Keys $n1 = count($arrayFieldPk); $n2 = count($arrayFieldPkAux); if ($n1 != $n2) { throw new \Exception(\G::LoadTranslation("ID_PMTABLE_TOTAL_PRIMARY_KEY_FIELDS_IS_NOT_EQUAL_IN_ATTRIBUTE", array($n1, $this->getFieldNameByFormatFieldName("PMTABLE.FIELDS"), $n2))); } //Set data $tableUid = $arrayData["PMTABLE"]["TAB_UID"]; $arrayFields = $arrayData["PMTABLE"]["FIELDS"]; unset($arrayData["PMTABLE"]); //Create $dynaForm = new \Dynaform(); $arrayData["PRO_UID"] = $processUid; $arrayData["DYN_TYPE"] = "xmlform"; $arrayData["FIELDS"] = $arrayFields; $dynaForm->createFromPMTable($arrayData, $tableUid); $dynaFormUid = $dynaForm->getDynUid(); //Return unset($arrayData["PRO_UID"]); unset($arrayData["FIELDS"]); $arrayData = array_merge(array("DYN_UID" => $dynaFormUid), $arrayData); if (!$this->formatFieldNameInUppercase) { $arrayData = array_change_key_case($arrayData, CASE_LOWER); } return $arrayData; } catch (\Exception $e) { throw $e; } }
public function listNewWebEntry($sProcessUID, $sEventUID) { try { global $G_PUBLISH; global $G_FORM; $G_PUBLISH = new Publisher(); require_once 'classes/model/Event.php'; $oEvent = new Event(); $arlink = ''; $oEvent = EventPeer::retrieveByPK($sEventUID); if (!is_null($oEvent)) { $oData = $oEvent->load($sEventUID); $dynTitle = ''; $dynUid = ''; $task_name = ''; $usr_uid_evn = $oEvent->getEvnConditions(); if ($oData['EVN_ACTION'] != '' && $oData['EVN_ACTION'] != 'WEB_ENTRY') { require_once 'classes/model/Content.php'; require_once 'classes/model/Task.php'; require_once 'classes/model/Dynaform.php'; $oContent = new Content(); $dynTitle = $oContent->load('DYN_TITLE', '', $oData['EVN_ACTION'], 'en'); $task_uid = $oEvent->getEvnTasUidTo(); $dyn = new Dynaform(); $dyn->load($oData['EVN_ACTION']); $dynUid = $dyn->getDynUid(); $task = new Task(); $task->load($task_uid); $task_name = $task->getTasTitle(); if (G::is_https()) { $http = 'https://'; } else { $http = 'http://'; } $link = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/' . $sProcessUID . '/'; $row = array(); $c = 0; /* $oTask = new Task ( ); $TaskFields = $oTask->kgetassigType ( $sProcessUID , $tas=''); */ $TaskFields['TAS_ASSIGN_TYPE'] = ''; //$row [] = array ('W_TITLE' => '', 'W_DELETE' => '', 'TAS_ASSIGN_TYPE' => $TaskFields ['TAS_ASSIGN_TYPE'] ); if (is_dir(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $sProcessUID)) { $dir = opendir(PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "public" . PATH_SEP . $sProcessUID); $dynTitle = str_replace(' ', '_', str_replace('/', '_', $dynTitle)); $arlink = $link . $dynTitle . '.php'; //$arlink = "<a href='" . $alink . "' target='blank'><font color='#9999CC'>" . $alink . "</font></a>"; } } } $row = array('W_LINK' => $arlink, 'DYN_TITLE' => $dynTitle, 'TAS_TITLE' => $task_name, 'USR_UID' => $usr_uid_evn, 'DYN_UID' => $dynUid); // $oJSON = new Services_JSON ( ); // $tmpData = $oJSON->encode( $row ) ; // $tmpData = str_replace("\\/","/",'{success:true,data:'.$tmpData.'}'); // unescape the slashes // $result = $tmpData; $result = array(); $result['success'] = true; $result['data'] = $row; return $result; } catch (Exception $oError) { throw $oError; } }
$arrayParameterAux = @unserialize(rawurldecode($_REQUEST["dynaformEditorParams"])); if (!empty($arrayParameterAux) && isset($arrayParameterAux["DYNAFORM_NAME"])) { $arrayParameterAux["DYNAFORM_NAME"] = base64_decode($arrayParameterAux["DYNAFORM_NAME"]); $_SESSION["Current_Dynafom"]["Parameters"] = $arrayParameterAux; if (isset($_REQUEST['DYN_UID'])) { if (class_exists('Dynaform')) { require_once 'classes/model/Dynaform.php'; } $dynaform = new Dynaform(); $dynaform->load($_REQUEST['DYN_UID']); G::LoadClass('dynaformEditor'); $editor = new dynaformEditor(array()); $editor->file = $dynaform->getDynFilename(); $editor->home = PATH_DYNAFORM; $editor->title = $dynaform->getDynTitle(); $editor->dyn_uid = $dynaform->getDynUid(); $editor->pro_uid = $dynaform->getProUid(); $editor->dyn_type = $dynaform->getDynType(); $editor->dyn_title = $dynaform->getDynTitle(); $editor->dyn_description = $dynaform->getDynDescription(); $editor->dyn_editor = 'processmap'; $editor->_setUseTemporalCopy(true); $A = isset($_SESSION['Current_Dynafom']['Parameters']['URL']) ? $_SESSION['Current_Dynafom']['Parameters']['URL'] : ''; $form = new Form($dynaform->getProUid() . '/' . $dynaform->getDynUid(), PATH_DYNAFORM, SYS_LANG, true); $properties = array('A' => $A, 'DYN_UID' => $dynaform->getDynUid(), 'PRO_UID' => $dynaform->getProUid(), 'DYN_TITLE' => $dynaform->getDynTitle(), 'DYN_TYPE' => $dynaform->getDynType(), 'DYN_DESCRIPTION' => $dynaform->getDynDescription(), 'WIDTH' => $form->width, 'MODE' => $form->mode, 'PRINTDYNAFORM' => $form->printdynaform, 'ADJUSTGRIDSWIDTH' => $form->adjustgridswidth, 'NEXTSTEPSAVE' => $form->nextstepsave); $tmp = $editor->_getTmpData(); $tmp['Properties'] = $properties; $editor->_setTmpData($tmp); } } }