Ejemplo n.º 1
0
 /**
  * Save a dynaForm
  *
  * @param object $A
  * @param string $DYN_UID
  * @return array
  */
 public function save($A, $DYN_UID)
 {
     try {
         $answer = 0;
         $file = G::decrypt($A, URL_KEY);
         $tmp = self::_getTmpData();
         if (isset($tmp['useTmpCopy'])) {
             /* Save Register */
             $dynaform = new dynaform();
             $dynaform->update($tmp['Properties']);
             /* Save file */
             $copy = implode('', file(PATH_DYNAFORM . $file . '.xml'));
             /*
              * added by krlos carlos/a/colosa.com
              * in here we are validation if a xmlform has a submit action
              */
             //      if (!preg_match("/type=\"submit\"/",$copy) && !preg_match("/type=\"grid\"/",$copy) && !isset($_SESSION['submitAction']) ){
             if (!preg_match("/type=\"submit\"/", $copy) && !preg_match("/type=\"grid\"/", $copy)) {
                 //        $_SESSION['submitAction'] = 1;
                 $answer = 'noSub';
             }
             $copyHtml = false;
             if (file_exists(PATH_DYNAFORM . $file . '.html')) {
                 $copyHtml = implode('', file(PATH_DYNAFORM . $file . '.html'));
             }
             $file = dynaformEditor::_getFilename($file);
             $fcopy = fopen(PATH_DYNAFORM . $file . '.xml', "w");
             fwrite($fcopy, $copy);
             fclose($fcopy);
             if ($copyHtml) {
                 $fcopy = fopen(PATH_DYNAFORM . $file . '.html', "w");
                 fwrite($fcopy, $copyHtml);
                 fclose($fcopy);
             }
         } else {
             //throw new Exception("It should not come here unless you have disabled the temporary copy.");
         }
         return $answer;
     } catch (Exception $e) {
         return (array) $e;
     }
 }
Ejemplo n.º 2
0
 $criteria->add(ContentPeer::CON_LANG, SYS_LANG);
 $rsCriteria = ContentPeer::doSelectRS($criteria);
 $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
 $rsCriteria->next();
 $row = $rsCriteria->getRow();
 $copyDynGrdDescription = $row["CON_VALUE"];
 //Create grid
 $dynaformGrid = new dynaform();
 $aDataAux = $aData;
 $aDataAux["DYN_TYPE"] = "grid";
 $aDataAux["DYN_TITLE"] = $copyDynGrdTitle . ($dynaFormAux->existsTitle($dynaform->getProUid(), $copyDynGrdTitle) ? " (" . $dynaform->getDynTitle() . ")" : "");
 $aDataAux["DYN_DESCRIPTION"] = $copyDynGrdDescription;
 $aFields = $dynaformGrid->create($aDataAux);
 $dynaformGridUid = $dynaformGrid->getDynUid();
 $aDataAux["DYN_UID"] = $dynaformGridUid;
 $dynaformGrid->update($aDataAux);
 //Copy files of the dynaform grid
 $fileGridXml = PATH_DYNAFORM . $aData["COPY_PROCESS_UID"] . PATH_SEP . $copyDynaformGridUid . ".xml";
 if (file_exists($fileGridXml)) {
     $fileGridXmlCopy = PATH_DYNAFORM . $aData["PRO_UID"] . PATH_SEP . $dynaformGridUid . ".xml";
     $fhGridXml = fopen($fileGridXml, "r");
     $fhGridXmlCopy = fopen($fileGridXmlCopy, "w");
     while (!feof($fhGridXml)) {
         $strLineAux = fgets($fhGridXml, 4096);
         $strLineAux = str_replace($aData["COPY_PROCESS_UID"] . "/" . $copyDynaformGridUid, $aData["PRO_UID"] . "/" . $dynaformGridUid, $strLineAux);
         fwrite($fhGridXmlCopy, $strLineAux);
     }
     fclose($fhGridXmlCopy);
     fclose($fhGridXml);
     chmod($fileGridXmlCopy, 0777);
 }
Ejemplo n.º 3
0
            unset($aData['DYN_UID']);
        }
    } else {
        $aData = $_POST;
        //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']);
    if (isset($aData['DYN_UID'])) {
        $dynaform->Save($aData);
    } else {
        if (!isset($aData['ADD_TABLE']) || $aData['ADD_TABLE'] == "") {
            $aFields = $dynaform->create($aData);
        } else {
            $aFields = $dynaform->createFromPMTable($aData, $aData['ADD_TABLE']);
        }
        $aData['DYN_UID'] = $dynaform->getDynUid();
        $dynaform->update($aData);
    }
    echo $dynaform->getDynUid();
}
 /**
  * Save a dynaForm
  *
  * @param object $A
  * @param string $DYN_UID
  * @return array
  */
 public function save($A, $DYN_UID)
 {
     try {
         $answer = 0;
         $file = G::decrypt($A, URL_KEY);
         $tmp = self::_getTmpData();
         if (isset($tmp['Properties'])) {
             $fileFirst = $tmp['Properties']['PRO_UID'] . '/' . $tmp['Properties']['DYN_UID'];
         }
         if (isset($tmp['useTmpCopy'])) {
             /* Save Register */
             $dynaform = new dynaform();
             $dynaform->update($tmp['Properties']);
             /* Save file */
             $copyFirst = implode('', file(PATH_DYNAFORM . $fileFirst . '.xml'));
             $copy = implode('', file(PATH_DYNAFORM . $file . '.xml'));
             /*Check differences between XML*/
             $elementFirst = new SimpleXMLElement($copyFirst);
             $elementCopy = new SimpleXMLElement($copy);
             $desAdd = '';
             $desDel = '';
             //Check the new fields
             foreach ($elementCopy as $key1 => $row1) {
                 $swAll = true;
                 foreach ($elementFirst as $key2 => $row2) {
                     if ($key1 == $key2) {
                         $swAll = false;
                         break;
                     }
                 }
                 if ($swAll) {
                     $desAdd .= $key1 . " ";
                 }
             }
             //Check the delete fields
             foreach ($elementFirst as $key1 => $row1) {
                 $swAll = true;
                 foreach ($elementCopy as $key2 => $row2) {
                     if ($key1 == $key2) {
                         $swAll = false;
                         break;
                     }
                 }
                 if ($swAll) {
                     $desDel .= $key1 . " ";
                 }
             }
             $mode = empty($tmp['Properties']['MODE']) ? 'Determined by Fields' : $tmp['Properties']['MODE'];
             $auditDescription = "Dynaform Title: " . $tmp['Properties']['DYN_TITLE'] . ", Type: " . $tmp['Properties']['DYN_TYPE'] . ", Description: " . $tmp['Properties']['DYN_DESCRIPTION'] . ", Mode: " . $mode;
             if ($desAdd != '') {
                 $auditDescription .= ", Field(s) Add: " . $desAdd;
             }
             if ($desDel != '') {
                 $auditDescription .= ", Field(s) Delete: " . $desDel;
             }
             //Add Audit Log
             G::auditLog("UpdateDynaform", $auditDescription);
             /*
              * added by krlos carlos/a/colosa.com
              * in here we are validation if a xmlform has a submit action
              */
             //      if (!preg_match("/type=\"submit\"/",$copy) && !preg_match("/type=\"grid\"/",$copy) && !isset($_SESSION['submitAction']) ){
             if (!preg_match("/type=\"submit\"/", $copy) && !preg_match("/type=\"grid\"/", $copy)) {
                 //        $_SESSION['submitAction'] = 1;
                 $answer = 'noSub';
             }
             $copyHtml = false;
             if (file_exists(PATH_DYNAFORM . $file . '.html')) {
                 $copyHtml = implode('', file(PATH_DYNAFORM . $file . '.html'));
             }
             $file = dynaformEditor::_getFilename($file);
             $fcopy = fopen(PATH_DYNAFORM . $file . '.xml', "w");
             fwrite($fcopy, $copy);
             fclose($fcopy);
             if ($copyHtml) {
                 $fcopy = fopen(PATH_DYNAFORM . $file . '.html', "w");
                 fwrite($fcopy, $copyHtml);
                 fclose($fcopy);
             }
         } else {
             //throw new Exception("It should not come here unless you have disabled the temporary copy.");
         }
         return $answer;
     } catch (Exception $e) {
         return (array) $e;
     }
 }