コード例 #1
0
 /**
  * Create a new output document for a project
  * @param string $sProcessUID
  * @param array  $outputDocumentData
  * @return array
  *
  * @access public
  */
 public function addOutputDocument($sProcessUID, $outputDocumentData)
 {
     $pemission = $outputDocumentData['out_doc_pdf_security_permissions'];
     $pemission = explode("|", $pemission);
     foreach ($pemission as $row) {
         if ($row == "print" || $row == "modify" || $row == "copy" || $row == "forms" || $row == "") {
             $outputDocumentData['out_doc_pdf_security_permissions'] = $outputDocumentData['out_doc_pdf_security_permissions'];
         } else {
             throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('out_doc_pdf_security_permissions')));
         }
     }
     try {
         require_once PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "OutputDocument.php";
         $outputDocumentData = array_change_key_case($outputDocumentData, CASE_UPPER);
         $outputDocumentData['PRO_UID'] = $sProcessUID;
         //Verify data
         Validator::proUid($sProcessUID, '$pro_uid');
         if ($outputDocumentData["OUT_DOC_TITLE"] == "") {
             throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('out_doc_title')));
         }
         if (isset($outputDocumentData["OUT_DOC_TITLE"]) && $this->existsTitle($sProcessUID, $outputDocumentData["OUT_DOC_TITLE"])) {
             throw new \Exception(\G::LoadTranslation("ID_OUTPUT_NOT_SAVE"));
         }
         $oOutputDocument = new \OutputDocument();
         if (isset($outputDocumentData['OUT_DOC_TITLE']) && $outputDocumentData['OUT_DOC_TITLE'] != '') {
             if (isset($outputDocumentData['OUT_DOC_PDF_SECURITY_ENABLED']) && $outputDocumentData['OUT_DOC_PDF_SECURITY_ENABLED'] == "0") {
                 $outputDocumentData['OUT_DOC_PDF_SECURITY_OPEN_PASSWORD'] = "";
                 $outputDocumentData['OUT_DOC_PDF_SECURITY_OWNER_PASSWORD'] = "";
                 $outputDocumentData['OUT_DOC_PDF_SECURITY_PERMISSIONS'] = "";
             }
         }
         if (isset($outputDocumentData['OUT_DOC_CURRENT_REVISION'])) {
             $oOutputDocument->setOutDocCurrentRevision($outputDocumentData['OUT_DOC_CURRENT_REVISION']);
         } else {
             $oOutputDocument->setOutDocCurrentRevision(0);
         }
         if (isset($outputDocumentData['OUT_DOC_FIELD_MAPPING'])) {
             $oOutputDocument->setOutDocFieldMapping($outputDocumentData['OUT_DOC_FIELD_MAPPING']);
         } else {
             $oOutputDocument->setOutDocFieldMapping(null);
         }
         $outDocUid = $oOutputDocument->create($outputDocumentData);
         $outputDocumentData = array_change_key_case($outputDocumentData, CASE_LOWER);
         $this->updateOutputDocument($sProcessUID, $outputDocumentData, 1, $outDocUid);
         //Return
         unset($outputDocumentData["PRO_UID"]);
         $outputDocumentData = array_change_key_case($outputDocumentData, CASE_LOWER);
         $outputDocumentData["out_doc_uid"] = $outDocUid;
         return $outputDocumentData;
     } catch (\Exception $e) {
         throw $e;
     }
 }