Esempio n. 1
0
 public function addWebEntry($weUid)
 {
     try {
         $webEntry = new \WebEntry();
         $webEntryUid = $weUid;
         $webEntry->setWeUid($webEntryUid);
         $webEntry->setProUid($this->proUid);
         $webEntry->setWeMethod('');
         $webEntry->setWeCreateDate(date('Y-m-d H:i:s'));
         $webEntry->save();
         //Return
         self::log("Adding Web Entry success!, created Web Entry id: ", $webEntryUid);
         return $webEntryUid;
     } catch (\Exception $oError) {
         throw $oError;
     }
 }
Esempio n. 2
0
 /**
  * Create Web Entry for a Process
  *
  * @param string $processUid     Unique id of Process
  * @param string $userUidCreator Unique id of creator User
  * @param array  $arrayData      Data
  *
  * return array Return data of the new Web Entry created
  */
 public function create($processUid, $userUidCreator, array $arrayData)
 {
     try {
         //Verify data
         $process = new \ProcessMaker\BusinessModel\Process();
         $validator = new \ProcessMaker\BusinessModel\Validator();
         $validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData");
         $validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
         //Set data
         $arrayData = array_change_key_case($arrayData, CASE_UPPER);
         unset($arrayData["WE_UID"]);
         unset($arrayData["WE_DATA"]);
         //Verify data
         $process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
         $this->throwExceptionIfDataIsInvalid("", $processUid, $arrayData);
         //Create
         $cnn = \Propel::getConnection("workflow");
         try {
             $webEntry = new \WebEntry();
             $webEntry->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
             $webEntryUid = \ProcessMaker\Util\Common::generateUID();
             $webEntry->setWeUid($webEntryUid);
             $webEntry->setProUid($processUid);
             $webEntry->setWeCreateUsrUid($userUidCreator);
             $webEntry->setWeCreateDate("now");
             if ($webEntry->validate()) {
                 $cnn->begin();
                 $result = $webEntry->save();
                 $cnn->commit();
                 //Set WE_TITLE
                 if (isset($arrayData["WE_TITLE"])) {
                     $result = \Content::addContent("WE_TITLE", "", $webEntryUid, SYS_LANG, $arrayData["WE_TITLE"]);
                 }
                 if (isset($arrayData["WE_DESCRIPTION"])) {
                     $result = \Content::addContent("WE_DESCRIPTION", "", $webEntryUid, SYS_LANG, $arrayData["WE_DESCRIPTION"]);
                 }
                 //Set WE_DATA
                 $this->setWeData($webEntryUid);
                 //Return
                 return $this->getWebEntry($webEntryUid);
             } else {
                 $msg = "";
                 foreach ($webEntry->getValidationFailures() as $validationFailure) {
                     $msg = $msg . ($msg != "" ? "\n" : "") . $validationFailure->getMessage();
                 }
                 throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . ($msg != "" ? "\n" . $msg : ""));
             }
         } catch (\Exception $e) {
             $cnn->rollback();
             throw $e;
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }