public function addToBackup ($workspace)
 {
     //verifing if workspace exists.
     if (! $workspace->workspaceExists()) {
         echo "Workspace {$workspace->name} not found\n";
         return false;
     }
     //create destination path
     if (! file_exists( PATH_DATA . "upgrade/" )) {
         mkdir( PATH_DATA . "upgrade/" );
     }
     $tempDirectory = PATH_DATA . "upgrade/" . basename( tempnam( __FILE__, '' ) );
     mkdir( $tempDirectory );
     $metadata = $workspace->getMetadata();
     CLI::logging( "Temporing up database...\n" );
     $metadata["databases"] = $workspace->exportDatabase( $tempDirectory );
     $metadata["directories"] = array ("{$workspace->name}.files");
     $metadata["version"] = 1;
     $metaFilename = "$tempDirectory/{$workspace->name}.meta";
     if (! file_put_contents( $metaFilename, str_replace( array (",","{","}"), array (",\n  ","{\n  ","\n}\n"), G::json_encode( $metadata ) ) )) {
         CLI::logging( "Could not create backup metadata" );
     }
     CLI::logging( "Adding database to backup...\n" );
     $this->addDirToBackup( $tempDirectory );
     CLI::logging( "Adding files to backup...\n" );
     $this->addDirToBackup( $workspace->path );
     $this->tempDirectories[] = $tempDirectory;
 }
Ejemplo n.º 2
0
 /**
  * post Note Action
  *
  * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION'])
  * @return array containg the case notes
  */
 function postNote($httpData)
 {
     require_once "classes/model/AppNotes.php";
     //extract(getExtJSParams());
     if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
         $appUid = $httpData->appUid;
     } else {
         $appUid = $_SESSION['APPLICATION'];
     }
     if (!isset($appUid)) {
         throw new Exception('Can\'t resolve the Apllication ID for this request.');
     }
     $usrUid = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : "";
     $noteContent = addslashes($httpData->noteText);
     //Disabling the controller response because we handle a special behavior
     $this->setSendResponse(false);
     //Add note case
     $appNote = new AppNotes();
     $response = $appNote->addCaseNote($appUid, $usrUid, $noteContent, intval($httpData->swSendMail));
     //Send the response to client
     @ini_set("implicit_flush", 1);
     ob_start();
     echo G::json_encode($response);
     @ob_flush();
     @flush();
     @ob_end_flush();
     ob_implicit_flush(1);
 }
Ejemplo n.º 3
0
 /**
  * WebResource
  *
  * @param string $uri
  * @param string $post
  *
  * @return none
  */
 function WebResource($uri, $post)
 {
     $this->_uri = $uri;
     if (isset($post['function']) && $post['function'] != '') {
         /*Call a function*/
         header('Content-Type: text/json');
         //$parameters=G::json_decode((urldecode($post['parameters']))); //for %AC
         $parameters = G::json_decode($post['parameters']);
         $paramsRef = array();
         foreach ($parameters as $key => $value) {
             if (is_string($key)) {
                 $paramsRef[] = "\$parameters['" . addcslashes($key, '\\\'') . "']";
             } else {
                 $paramsRef[] = '$parameters[' . $key . ']';
             }
         }
         $paramsRef = implode(',', $paramsRef);
         G::LoadSystem('inputfilter');
         $filter = new InputFilter();
         $post['function'] = $filter->validateInput($post['function']);
         $paramsRef = $filter->validateInput($paramsRef);
         $res = eval('return ($this->' . $post['function'] . '(' . $paramsRef . '));');
         $res = G::json_encode($res);
         print $res;
     } else {
         /*Print class definition*/
         $this->_encode();
     }
 }
Ejemplo n.º 4
0
function sendJsonResultGeneric($response, $callback)
{
    header("Content-Type: application/json");
    $finalResponse = G::json_encode($response);
    if ($callback != '') {
        print $callback . "({$finalResponse});";
    } else {
        print $finalResponse;
    }
}
Ejemplo n.º 5
0
 /**
  * Save new process
  *
  * @param object $httpData
  */
 public function saveProcess($httpData)
 {
     require_once 'classes/model/Task.php';
     G::LoadClass('processMap');
     $oProcessMap = new ProcessMap();
     $httpData->PRO_TITLE = trim($httpData->PRO_TITLE);
     if (!isset($httpData->PRO_UID)) {
         if (Process::existsByProTitle($httpData->PRO_TITLE)) {
             $result = array('success' => false, 'msg' => G::LoadTranslation('ID_SAVE_PROCESS_ERROR'), 'errors' => array('PRO_TITLE' => G::LoadTranslation('ID_PROCESSTITLE_ALREADY_EXISTS', SYS_LANG, array('PRO_TITLE' => $httpData->PRO_TITLE))));
             print G::json_encode($result);
             exit(0);
         }
         $processData['USR_UID'] = $_SESSION['USER_LOGGED'];
         $processData['PRO_TITLE'] = $httpData->PRO_TITLE;
         $processData['PRO_DESCRIPTION'] = $httpData->PRO_DESCRIPTION;
         $processData['PRO_CATEGORY'] = $httpData->PRO_CATEGORY;
         $sProUid = $oProcessMap->createProcess($processData);
         //call plugins
         $oData['PRO_UID'] = $sProUid;
         $oData['PRO_TEMPLATE'] = isset($httpData->PRO_TEMPLATE) && $httpData->PRO_TEMPLATE != '' ? $httpData->PRO_TEMPLATE : '';
         $oData['PROCESSMAP'] = $oProcessMap;
         $oPluginRegistry =& PMPluginRegistry::getSingleton();
         $oPluginRegistry->executeTriggers(PM_NEW_PROCESS_SAVE, $oData);
     } else {
         //$oProcessMap->updateProcess($_POST['form']);
         $sProUid = $httpData->PRO_UID;
     }
     //Save Calendar ID for this process
     if (isset($httpData->PRO_CALENDAR)) {
         G::LoadClass("calendar");
         $calendarObj = new Calendar();
         $calendarObj->assignCalendarTo($sProUid, $httpData->PRO_CALENDAR, 'PROCESS');
     }
     $this->success = true;
     $this->PRO_UID = $sProUid;
     $this->msg = G::LoadTranslation('ID_CREATE_PROCESS_SUCCESS');
 }
Ejemplo n.º 6
0
 /**
  * post Note Action
  * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION'])
  * @return array containg the case notes
  */
 function postNote($httpData)
 {
     //extract(getExtJSParams());
     if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
         $appUid = $httpData->appUid;
     } else {
         $appUid = $_SESSION['APPLICATION'];
     }
     if (!isset($appUid)) {
         throw new Exception('Can\'t resolve the Apllication ID for this request.');
     }
     $usrUid = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : "";
     require_once "classes/model/AppNotes.php";
     $appNotes = new AppNotes();
     $noteContent = addslashes($httpData->noteText);
     $result = $appNotes->postNewNote($appUid, $usrUid, $noteContent, false);
     // Disabling the controller response because we handle a special behavior
     $this->setSendResponse(false);
     //send the response to client
     @ini_set('implicit_flush', 1);
     ob_start();
     echo G::json_encode($result);
     @ob_flush();
     @flush();
     @ob_end_flush();
     ob_implicit_flush(1);
     //send notification in background
     $noteRecipientsList = array();
     G::LoadClass('case');
     $oCase = new Cases();
     $p = $oCase->getUsersParticipatedInCase($appUid);
     foreach ($p['array'] as $key => $userParticipated) {
         $noteRecipientsList[] = $key;
     }
     $noteRecipients = implode(",", $noteRecipientsList);
     $appNotes->sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients);
 }
/**
 *
 * @method Get DWS Document Versions
 *
 * @name getDWSDocumentVersions
 * @label Get DWS Document Versions
 *
 * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL
 * @param string | $auth | Valid Auth string to connect to server | user:password
 * @param string | $newFileName | Name of New File
 * @param string | $dwsname | Name of DWS
 *
 * @return string | $result | Response
 *
 */
function getDWSDocumentVersions($sharepointServer, $auth, $newFileName, $dwsname)
{
    require_once PATH_CORE . 'classes' . PATH_SEP . 'triggers' . PATH_SEP . 'class.pmTrSharepoint.php';
    $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth);
    $result = $pmTrSharepoint->getDWSDocumentVersions($newFileName, $dwsname);
    if (isset($result->GetVersionsResult)) {
        /*
         * Code to get the Document's Version/s
         */
        $xml = $result->GetVersionsResult->any;
        // in Result we get string in Xml format
        $xmlNew = simplexml_load_string($xml);
        // used to parse string to xml
        $xmlArray = @G::json_decode(@G::json_encode($xmlNew), 1);
        // used to convert Objects to array
        $resultCount = count($xmlArray['result']);
        for ($i = 0; $i < $resultCount; $i++) {
            $version[] = $xmlArray['result'][$i]['@attributes']['version'];
        }
        $serializeResult = serialize($version);
        // serializing the Array for Returning.
        return $serializeResult;
    } else {
        return "No version found";
    }
}
Ejemplo n.º 8
0
         $res = $appCache->triggerApplicationDelete($lang, true);
         //$result->info[] = array ('name' => 'Trigger APPLICATION DELETE',              'value'=> $res);
         //CONTENT UPDATE
         $res = $appCache->triggerContentUpdate($lang, true);
         //$result->info[] = array("name" => "Trigger CONTENT UPDATE", "value" => $res);
         //build using the method in AppCacheView Class
         $res = $appCache->fillAppCacheView($lang);
         //$result->info[] = array ('name' => 'build APP_CACHE_VIEW',              'value'=> $res);
         //set status in config table
         $confParams = array('LANG' => $lang, 'STATUS' => 'active');
         $conf->aConfig = $confParams;
         $conf->saveConfig('APP_CACHE_VIEW_ENGINE', '', '', '');
         $response = new StdClass();
         $result->success = true;
         $result->msg = "Completed successfully";
         echo G::json_encode($result);
     } catch (Exception $e) {
         $confParams = array('lang' => $lang, 'status' => 'failed');
         $appCacheViewEngine = $oServerConf->setProperty('APP_CACHE_VIEW_ENGINE', $confParams);
         echo '{success: false, msg:"' . $e->getMessage() . '"}';
     }
     break;
 case 'recreate-root':
     $sh = md5(filemtime(PATH_GULLIVER . "/class.g.php"));
     $h = G::encrypt($_POST['host'] . $sh . $_POST['user'] . $sh . $_POST['password'] . $sh . 1, $sh);
     $insertStatements = "define ( 'HASH_INSTALLATION','{$h}' );  \ndefine ( 'SYSTEM_HASH', '{$sh}' ); \n";
     $lines = array();
     $content = '';
     $filename = PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths_installed.php';
     $lines = file($filename);
     $count = 1;
 /**
  * Prints the DynaformEditor
  *
  * @return void
  */
 public function _render()
 {
     global $G_PUBLISH;
     $script = '';
     /* Start Block: Load (Create if doesn't exist) the xmlform */
     $Parameters = array('SYS_LANG' => SYS_LANG, 'URL' => G::encrypt($this->file, URL_KEY), 'DYN_UID' => $this->dyn_uid, 'PRO_UID' => $this->pro_uid, 'DYNAFORM_NAME' => $this->dyn_title, 'FILE' => $this->file, 'DYN_EDITOR' => $this->dyn_editor);
     $_SESSION['Current_Dynafom']['Parameters'] = $Parameters;
     $XmlEditor = array('URL' => G::encrypt($this->file, URL_KEY), 'XML' => '');
     $JSEditor = array('URL' => G::encrypt($this->file, URL_KEY));
     $A = G::encrypt($this->file, URL_KEY);
     try {
         $openDoc = new Xml_Document();
         $fileName = $this->home . $this->file . '.xml';
         if (file_exists($fileName)) {
             $openDoc->parseXmlFile($fileName);
         } else {
             $this->_createDefaultXmlForm($fileName);
             $openDoc->parseXmlFile($fileName);
         }
         //$form = new Form( $this->file , $this->home, SYS_LANG, true );
         $Properties = dynaformEditorAjax::get_properties($A, $this->dyn_uid);
         /* Start Block: Prepare the XMLDB connection */
         define('DB_XMLDB_HOST', PATH_DYNAFORM . $this->file . '.xml');
         define('DB_XMLDB_USER', '');
         define('DB_XMLDB_PASS', '');
         define('DB_XMLDB_NAME', '');
         define('DB_XMLDB_TYPE', 'myxml');
         /* Start Block: Prepare the dynaformEditor */
         $G_PUBLISH = new Publisher();
         $sName = 'dynaformEditor';
         $G_PUBLISH->publisherId = $sName;
         $oHeadPublisher =& headPublisher::getSingleton();
         $labesTrans = G::getTranslations(array('ID_FIELD_DYNAFORM_TEXT', 'ID_FIELD_DYNAFORM_CURRENCY', 'ID_FIELD_DYNAFORM_PERCENTAGE', 'ID_FIELD_DYNAFORM_PASSWORD', 'ID_FIELD_DYNAFORM_SUGGEST', 'ID_FIELD_DYNAFORM_TEXTAREA', 'ID_FIELD_DYNAFORM_TITLE', 'ID_FIELD_DYNAFORM_SUBTITLE', 'ID_FIELD_DYNAFORM_BUTTON', 'ID_FIELD_DYNAFORM_SUBMIT', 'ID_FIELD_DYNAFORM_RESET', 'ID_FIELD_DYNAFORM_DROPDOWN', 'ID_FIELD_DYNAFORM_YESNO', 'ID_FIELD_DYNAFORM_LISTBOX', 'ID_FIELD_DYNAFORM_CHECKBOX', 'ID_FIELD_DYNAFORM_CHECKGROUP', 'ID_FIELD_DYNAFORM_RADIOGROUP', 'DATE_LABEL', 'ID_FIELD_DYNAFORM_HIDDEN', 'ID_FIELD_DYNAFORM_LINK', 'ID_FIELD_DYNAFORM_LINK', 'ID_FIELD_DYNAFORM_FILE', 'ID_FIELD_DYNAFORM_JAVASCRIPT', 'ID_FIELD_DYNAFORM_GRID', 'ID_INDEX'));
         $oHeadPublisher->addScriptCode("var TRANSLATIONS = " . G::json_encode($labesTrans) . ";");
         $oHeadPublisher->setTitle(G::LoadTranslation('ID_DYNAFORM_EDITOR') . ' - ' . $Properties['DYN_TITLE']);
         $G_PUBLISH->AddContent('blank');
         $this->panelConf['title'] = '';
         $G_PUBLISH->AddContent('panel-init', 'mainPanel', $this->panelConf);
         if ($Properties['DYN_TYPE'] == 'xmlform') {
             $G_PUBLISH->AddContent('xmlform', 'toolbar', 'dynaforms/fields_Toolbar', 'display:none', $Parameters, '', '');
         } else {
             $G_PUBLISH->AddContent('xmlform', 'toolbar', 'dynaforms/fields_ToolbarGrid', 'display:none', $Parameters, '', '');
         }
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_Editor', 'display:none', $Parameters, '', '');
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_XmlEditor', 'display:none', $XmlEditor, '', '');
         $G_PUBLISH->AddContent('blank');
         $i = 0;
         $aFields = array();
         $aFields[] = array('XMLNODE_NAME' => 'char', 'TYPE' => 'char', 'UP' => 'char', 'DOWN' => 'char');
         $oSession = new DBSession(new DBConnection(PATH_DYNAFORM . $this->file . '.xml', '', '', '', 'myxml'));
         $oDataset = $oSession->Execute('SELECT * FROM dynaForm WHERE NOT( XMLNODE_NAME = "" ) AND TYPE <> "pmconnection"');
         $iMaximun = $oDataset->count();
         while ($aRow = $oDataset->Read()) {
             $aFields[] = array('XMLNODE_NAME' => $aRow['XMLNODE_NAME'], 'TYPE' => $aRow['TYPE'], 'UP' => $i > 0 ? G::LoadTranslation('ID_UP') : '', 'DOWN' => $i < $iMaximun - 1 ? G::LoadTranslation('ID_DOWN') : '', 'row__' => $i + 1);
             $i++;
             break;
         }
         global $_DBArray;
         $_DBArray['fields'] = $aFields;
         $_SESSION['_DBArray'] = $_DBArray;
         G::LoadClass('ArrayPeer');
         $oCriteria = new Criteria('dbarray');
         $oCriteria->setDBArrayTable('fields');
         /**
          * *@Erik-> this is deprecated,.
          * (unuseful) $G_PUBLISH->AddContent('propeltable', 'paged-table', 'dynaforms/fields_List', $oCriteria, $Parameters, '', SYS_URI.'dynaforms/dynaforms_PagedTableAjax');**
          */
         $G_PUBLISH->AddContent('blank');
         $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_JSEditor', 'display:none', $JSEditor, '', '');
     } catch (Exception $e) {
     }
     $G_PUBLISH->AddContent('xmlform', 'xmlform', 'dynaforms/dynaforms_Properties', 'display:none', $Properties, '', '');
     //for showHide tab option @Neyek
     $G_PUBLISH->AddContent('blank');
     $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_PREVIEW"), $sName . '[3]', 'dynaformEditor.changeToPreview', 'dynaformEditor.saveCurrentView');
     $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_XML"), $sName . '[4]', 'dynaformEditor.changeToXmlCode', 'dynaformEditor.saveCurrentView');
     $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_HTML"), $sName . '[5]', 'dynaformEditor.changeToHtmlCode', 'dynaformEditor.saveCurrentView');
     $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_FIELDS_LIST"), $sName . '[6]', 'dynaformEditor.changeToFieldsList', 'dynaformEditor.saveCurrentView');
     $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_JAVASCRIPTS"), $sName . '[7]', 'dynaformEditor.changeToJavascripts', 'dynaformEditor.saveCurrentView');
     $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_PROPERTIES"), $sName . '[8]', 'dynaformEditor.changeToProperties', 'dynaformEditor.saveCurrentView');
     //for showHide tab option @Neyek
     $G_PUBLISH->AddContent('panel-tab', G::LoadTranslation("ID_CONDITIONS_EDITOR"), $sName . '[9]', 'dynaformEditor.changeToShowHide', 'dynaformEditor.saveShowHide');
     $G_PUBLISH->AddContent('panel-close');
     $oHeadPublisher->addScriptFile("/js/maborak/core/maborak.loader.js", 2);
     $oHeadPublisher->addScriptFile('/jscore/dynaformEditor/core/dynaformEditor.js');
     //$oHeadPublisher->addScriptFile('/js/dveditor/core/dveditor.js');
     //$oHeadPublisher->addScriptFile('/codepress/codepress.js',1);
     $oHeadPublisher->addScriptFile('/js/codemirror/js/codemirror.js', 1);
     $oHeadPublisher->addScriptFile('/js/grid/core/grid.js');
     $oHeadPublisher->addScriptCode('
 var DYNAFORM_URL="' . $Parameters['URL'] . '";
 leimnud.event.add(window,"load",function(){ loadEditor(); });
 ');
     $oHeadPublisher->addScriptCode(' var jsMeta;var usernameLogged = "' . (isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME'] : '') . '";var SYS_LANG = "' . SYS_LANG . '";');
     G::RenderPage("publish", 'blank');
 }
Ejemplo n.º 10
0
function deleteSkin()
{
    G::LoadSystem('inputfilter');
    $filter = new InputFilter();
    try {
        $_REQUEST['SKIN_FOLDER_ID'] = $filter->xssFilterHard($_REQUEST['SKIN_FOLDER_ID']);
        if (!isset($_REQUEST['SKIN_FOLDER_ID'])) {
            throw new Exception(G::LoadTranslation('ID_SKIN_FOLDER_REQUIRED'));
        }
        if ($_REQUEST['SKIN_FOLDER_ID'] == "classic") {
            throw new Exception(G::LoadTranslation('ID_SKIN_FOLDER_NOT_DELETEABLE'));
        }
        $folderId = $_REQUEST['SKIN_FOLDER_ID'];
        if (!is_dir(PATH_CUSTOM_SKINS . $folderId)) {
            throw new Exception(G::LoadTranslation('ID_SKIN_NOT_EXISTS'));
        }
        //Delete
        G::rm_dir(PATH_CUSTOM_SKINS . $folderId);
        $response['success'] = true;
        $response['message'] = "{$folderId} deleted";
        G::auditLog("DeleteSkin", "Skin Name: " . $folderId);
    } catch (Exception $e) {
        $response['success'] = false;
        $response['error'] = $response['message'] = $e->getMessage();
        $response = $filter->xssFilterHard($response);
        print_r(G::json_encode($response));
    }
}
    }
    $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
    $rs->next();
    $totalCount = 0;
    for ($j = 0; $j < $rs->getRecordCount(); $j++) {
        $result = $rs->getRow();
        $result["FILEDOCEXIST"] = casesShowOuputDocumentExist($result["FILEDOC"]);
        $result["FILEPDFEXIST"] = casesShowOuputDocumentExist($result["FILEPDF"]);
        $aProcesses[] = $result;
        $rs->next();
        $totalCount++;
    }
    //!dateFormat
    G::LoadClass('configuration');
    $conf = new Configurations();
    try {
        $generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');
    } catch (Exception $e) {
        $generalConfCasesList = array();
    }
    $dateFormat = "";
    if (isset($generalConfCasesList['casesListDateFormat']) && !empty($generalConfCasesList['casesListDateFormat'])) {
        $dateFormat = $generalConfCasesList['casesListDateFormat'];
    }
    $newDir = '/tmp/test/directory';
    $r = G::verifyPath($newDir);
    $r->data = $aProcesses;
    $r->totalCount = $totalCount;
    $r->dataFormat = $dateFormat;
    echo G::json_encode($r);
}
Ejemplo n.º 12
0
}
$realPath = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/' . $sAppDocUid . '_' . $iDocVersion . '.' . $ext;
$realPath1 = PATH_DOCUMENT . G::getPathFromUID($oAppDocument->Fields['APP_UID']) . '/' . $sAppDocUid . '.' . $ext;
$sw_file_exists = false;
if (file_exists($realPath)) {
    $sw_file_exists = true;
} elseif (file_exists($realPath1)) {
    $sw_file_exists = true;
    $realPath = $realPath1;
}
if (!$sw_file_exists) {
    $error_message = "'" . $oAppDocument->Fields['APP_DOC_FILENAME'] . "' " . G::LoadTranslation('ID_ERROR_STREAMING_FILE');
    if (isset($_POST['request']) && $_POST['request'] == true) {
        $res['success'] = 'failure';
        $res['message'] = $error_message;
        print G::json_encode($res);
    } else {
        G::SendMessageText($error_message, "ERROR");
        $backUrlObj = explode("sys" . SYS_SYS, $_SERVER['HTTP_REFERER']);
        G::header("location: " . "/sys" . SYS_SYS . $backUrlObj[1]);
        die;
    }
} else {
    if (isset($_POST['request']) && $_POST['request'] == true) {
        $res['success'] = 'success';
        $res['message'] = $oAppDocument->Fields['APP_DOC_FILENAME'];
        print G::json_encode($res);
    } else {
        G::streamFile($realPath, $bDownload, $oAppDocument->Fields['APP_DOC_FILENAME']);
    }
}
Ejemplo n.º 13
0
        $oResult = $oTrigger->verifyDependecies($_POST['TRI_UID']);
        $oResult->passed = false;
        if ($oResult->code == 0) {
            $oResult->passed = true;
            $oResult->message = G::LoadTranslation('ID_TRIGGERS_VALIDATION');
            //"No Dependencies were found for this trigger in Events definitions\n";
        } else {
            $oResult->message = '';
            foreach ($oResult->dependencies as $Object => $aDeps) {
                $nDeps = count($aDeps);
                $message = str_replace('{N}', $nDeps, G::LoadTranslation('ID_TRIGGERS_VALIDATION_ERR2'));
                $message = str_replace('{Object}', $Object, $message);
                $oResult->message .= $message . "\n";
                foreach ($aDeps as $dep) {
                    if (substr($Object, -1) == 's') {
                        $Object = substr($Object, 0, strlen($Object) - 1);
                    }
                    $message = str_replace('{Object}', $Object, G::LoadTranslation('ID_TRIGGERS_VALIDATION_ERR3'));
                    $message = str_replace('{Description}', '"' . $dep['DESCRIPTION'] . '"', $message);
                    $oResult->message .= $message . "\n";
                }
                $oResult->message .= "\n";
            }
        }
        $oResult->success = true;
        //print_r($oResult);
        print G::json_encode($oResult);
        break;
    default:
        echo 'default';
}
Ejemplo n.º 14
0
function deleteSkin()
{
    try {
        if (!isset($_REQUEST['SKIN_FOLDER_ID'])) {
            throw new Exception(G::LoadTranslation('ID_SKIN_FOLDER_REQUIRED'));
        }
        if ($_REQUEST['SKIN_FOLDER_ID'] == "classic") {
            throw new Exception(G::LoadTranslation('ID_SKIN_FOLDER_NOT_DELETEABLE'));
        }
        $folderId = $_REQUEST['SKIN_FOLDER_ID'];
        if (!is_dir(PATH_CUSTOM_SKINS . $folderId)) {
            throw new Exception(G::LoadTranslation('ID_SKIN_NOT_EXISTS'));
        }
        //Delete
        G::rm_dir(PATH_CUSTOM_SKINS . $folderId);
        $response['success'] = true;
        $response['message'] = "{$folderId} deleted";
    } catch (Exception $e) {
        $response['success'] = false;
        $response['error'] = $response['message'] = $e->getMessage();
        print_r(G::json_encode($response));
    }
}
Ejemplo n.º 15
0
 /**
  * streaming the translation.<lang>.js file
  * take the WEB-INF/translation.<lang> file and append it to file js/widgets/lang/<lang>.js file
  *
  * @author Fernando Ontiveros Lira <*****@*****.**>
  * @access public
  * @param string $file
  * @param boolean $download
  * @param string $downloadFileName
  * @return string
  */
 public function streamJSTranslationFile($filename, $locale = 'en')
 {
     $defaultTranslations = array();
     $foreignTranslations = array();
     //if the default translations table doesn't exist we can't proceed
     if (!is_file(PATH_LANGUAGECONT . 'translation.en')) {
         return;
     }
     //load the translations table
     require_once PATH_LANGUAGECONT . 'translation.en';
     $defaultTranslations = $translation;
     //if some foreign language was requested and its translation file exists
     if ($locale != 'en' && file_exists(PATH_LANGUAGECONT . 'translation.' . $locale)) {
         require_once PATH_LANGUAGECONT . 'translation.' . $locale;
         //load the foreign translations table
         $foreignTranslations = $translation;
     }
     if (defined("SHOW_UNTRANSLATED_AS_TAG") && SHOW_UNTRANSLATED_AS_TAG != 0) {
         $translation = $foreignTranslations;
     } else {
         $translation = array_merge($defaultTranslations, $foreignTranslations);
     }
     $calendarJs = '';
     $calendarJsFile = PATH_GULLIVER_HOME . "js/widgets/js-calendar/lang/" . $locale . ".js";
     if (!file_exists($calendarJsFile)) {
         $calendarJsFile = PATH_GULLIVER_HOME . "js/widgets/js-calendar/lang/en.js";
     }
     $calendarJs = file_get_contents($calendarJsFile) . "\n";
     return $calendarJs . 'var TRANSLATIONS = ' . G::json_encode($translation) . ';';
 }
Ejemplo n.º 16
0
                }
            } catch (Exception $e) {
                $response["message"] = $e->getMessage();
                $status = 0;
            }
            if ($status == 0) {
                $response["status"] = "ERROR";
            }
            echo G::json_encode($response);
            exit(0);
            break;
        case "addonslist":
            $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'plugin';
            $result = AddonsStore::addonList($type);
            break;
            break;
        default:
            throw new Exception("Action \"{$action}\" is not valid");
    }
    if (!isset($result["success"])) {
        $result["success"] = true;
    }
    if (isset($result["addons"])) {
        $result["addons"] = array_values($result["addons"]);
    } else {
        $result["addons"] = array();
    }
    echo G::json_encode($result);
} catch (Exception $e) {
    echo G::json_encode(array("success" => false, "errors" => $e->getMessage()));
}
 /**
  * call to execute a internal proxy method and handle its exceptions
  *
  * @param string $name
  */
 public function call($name)
 {
     try {
         $result = $this->{$name}($this->__request__);
         if (!$this->jsonResponse) {
             return null;
         }
         if (!$result) {
             $result = $this->__data__;
         }
     } catch (Exception $e) {
         $result->success = false;
         $result->message = $result->msg = $e->getMessage();
         switch (get_class($e)) {
             case 'Exception':
                 $error = "SYSTEM ERROR";
                 break;
             case 'PMException':
                 $error = "PROCESSMAKER ERROR";
                 break;
             case 'PropelException':
                 $error = "DATABASE ERROR";
                 break;
             case 'UserException':
                 $error = "USER ERROR";
                 break;
         }
         $result->error = $e->getMessage();
         $result->exception->class = get_class($e);
         $result->exception->code = $e->getCode();
         $result->exception->trace = $e->getTraceAsString();
     }
     if ($this->sendResponse) {
         print G::json_encode($result);
     }
 }
Ejemplo n.º 18
0
 public function getPMVariables($param)
 {
     G::LoadClass('processMap');
     $oProcessMap = new processMap(new DBConnection());
     $response->rows = getDynaformsVars($param['PRO_UID']);
     foreach ($response->rows as $i => $var) {
         $response->rows[$i]['sName'] = "@@{$var['sName']}";
     }
     print G::json_encode($response);
 }
Ejemplo n.º 19
0
    public function changeLogTab()
    {
        if (!isset($_SESSION['USER_LOGGED'])) {
            $response = new stdclass();
            $response->message = G::LoadTranslation('ID_LOGIN_AGAIN');
            $response->lostSession = true;
            print G::json_encode($response);
            die;
        }
        try {
            global $G_PUBLISH;
            require_once 'classes/model/AppHistory.php';
            //!dataInput
            $idHistory = $_REQUEST["idHistory"];
            //!dataInput
            //!dataSytem
            $idHistoryArray = explode("_", $idHistory);
            $_REQUEST["PRO_UID"] = $idHistoryArray[0];
            $_REQUEST["APP_UID"] = $idHistoryArray[1];
            $_REQUEST["TAS_UID"] = $idHistoryArray[2];
            $_REQUEST["DYN_UID"] = "";
            $G_PUBLISH = new Publisher();
            $G_PUBLISH->AddContent('view', 'cases/cases_DynaformHistory');
            ?>
            <link rel="stylesheet" type="text/css" href="/css/classic.css" />
            <style type="text/css">
                html {
                    color: black !important;
                }

                body {
                    color: black !important;
                }
            </style>
            <script language="javascript">
                function ajaxPostRequest(url, callback_function, id) {
                    var d = new Date();
                    var time = d.getTime();
                    url = url + '&nocachetime=' + time;
                    var return_xml = false;
                    var http_request = false;

                    if (window.XMLHttpRequest) {
                        // Mozilla, Safari,...
                        http_request = new XMLHttpRequest();
                        if (http_request.overrideMimeType) {
                            http_request.overrideMimeType('text/xml');
                        }
                    }
                    else if (window.ActiveXObject) {
                        // IE
                        try {
                            http_request = new ActiveXObject("Msxml2.XMLHTTP");
                        }
                        catch (e) {
                            try {
                                http_request = new ActiveXObject("Microsoft.XMLHTTP");
                            }
                            catch (e) {
                            }
                        }
                    }

                    if (!http_request) {
                        alert('This browser is not supported.');
                        return false;
                    }

                    http_request.onreadystatechange = function() {
                        if (http_request.readyState == 4) {
                            if (http_request.status == 200) {
                                if (return_xml) {
                                    eval(callback_function + '(http_request.responseXML)');
                                }
                                else {
                                    eval(callback_function + '(http_request.responseText, \'' + id + '\')');
                                }
                            }
                            else {
                                alert('Error found on request:(Code: ' + http_request.status + ')');
                            }
                        }
                    }
                    http_request.open('GET', url, true);
                    http_request.send(null);
                }

                function toggleTable(tablename) {
                    table = document.getElementById(tablename);

                    if (table.style.display == '') {
                        table.style.display = 'none';
                    } else {
                        table.style.display = '';
                    }
                }

                function noesFuncion(idIframe) {
                    window.parent.tabIframeWidthFix2(idIframe);
                }

                function onResizeIframe(idIframe) {
                    window.onresize = noesFuncion(idIframe);
                }

                function showDynaformHistoryGetNomDynaform_RSP(response, id) {
                    //!showDynaformHistoryGlobal
                    showDynaformHistoryGlobal.idDin = showDynaformHistoryGlobal.idDin;
                    showDynaformHistoryGlobal.idHistory = showDynaformHistoryGlobal.idHistory;
                    showDynaformHistoryGlobal.dynDate = showDynaformHistoryGlobal.dynDate;

                    //!dataSystem
                    var idDin = showDynaformHistoryGlobal.idDin;
                    var idHistory = showDynaformHistoryGlobal.idHistory;
                    var dynDate = showDynaformHistoryGlobal.dynDate;

                    //!windowParent
                    window.parent.historyGridListChangeLogGlobal.viewIdDin = idDin;
                    window.parent.historyGridListChangeLogGlobal.viewIdHistory = idHistory;
                    window.parent.historyGridListChangeLogGlobal.viewDynaformName = response;
                    window.parent.historyGridListChangeLogGlobal.dynDate = dynDate;

                    window.parent.Actions.tabFrame('dynaformViewFromHistory');
                }

                showDynaformHistoryGlobal = {};
                showDynaformHistoryGlobal.idDin = "";
                showDynaformHistoryGlobal.idHistory = "";
                showDynaformHistoryGlobal.dynDate = "";

                function showDynaformHistory(idDin, idHistory, dynDate) {
                    //!showDynaformHistoryGlobal
                    showDynaformHistoryGlobal.idDin = showDynaformHistoryGlobal.idDin;
                    showDynaformHistoryGlobal.idHistory = showDynaformHistoryGlobal.idHistory;
                    showDynaformHistoryGlobal.dynDate = showDynaformHistoryGlobal.dynDate;

                    //!dataSystem
                    showDynaformHistoryGlobal.idDin = idDin;
                    showDynaformHistoryGlobal.idHistory = idHistory;
                    showDynaformHistoryGlobal.dynDate = dynDate;

                    var url = "caseHistory_Ajax.php?actionAjax=showDynaformHistoryGetNomDynaform_JXP&idDin=" + idDin + "&dynDate=" + dynDate;
                    ajaxPostRequest(url, 'showDynaformHistoryGetNomDynaform_RSP');
                }
            </script>
            <?php 
            G::RenderPage('publish', 'raw');
            $result->success = true;
            $result->msg = G::LoadTranslation('ID_CASE_REACTIVATED_SUCCESSFULLY', SYS_LANG, "success");
        } catch (Exception $e) {
            $result->success = false;
            $result->msg = $e->getMessage();
        }
    }
Ejemplo n.º 20
0
 /**
  * create a backup of this workspace
  *
  * Exports the database and copies the files to an archive specified, so this
  * workspace can later be restored.
  *
  * @param string|archive $filename archive filename to use as backup or
  * archive object created by createBackup
  * @param bool $compress specifies wheter the backup is compressed or not
  */
 public function backup($backupFile, $compress = true)
 {
     /* $filename can be a string, in which case it's used as the filename of
      * the backup, or it can be a previously created tar, which allows for
      * multiple workspaces in one backup.
      */
     if (!$this->workspaceExists()) {
         throw new Exception("Workspace '{$this->name}' not found");
     }
     if (is_string($backupFile)) {
         $backup = $this->createBackup($backupFile);
         $filename = $backupFile;
     } else {
         $backup = $backupFile;
         $filename = $backup->_tarname;
     }
     if (!file_exists(PATH_DATA . "upgrade/")) {
         mkdir(PATH_DATA . "upgrade/");
     }
     $tempDirectory = PATH_DATA . "upgrade/" . basename(tempnam(__FILE__, ''));
     mkdir($tempDirectory);
     $metadata = $this->getMetadata();
     CLI::logging("Backing up database...\n");
     $metadata["databases"] = $this->exportDatabase($tempDirectory);
     $metadata["directories"] = array("{$this->name}.files");
     $metadata["version"] = 1;
     $metaFilename = "{$tempDirectory}/{$this->name}.meta";
     /* Write metadata to file, but make it prettier before. The metadata is just
      * a JSON codified array.
      */
     if (!file_put_contents($metaFilename, str_replace(array(",", "{", "}"), array(",\n  ", "{\n  ", "\n}\n"), G::json_encode($metadata)))) {
         throw new Exception("Could not create backup metadata");
     }
     CLI::logging("Copying database to backup...\n");
     $this->addToBackup($backup, $tempDirectory, $tempDirectory);
     CLI::logging("Copying files to backup...\n");
     $this->addToBackup($backup, $this->path, $this->path, "{$this->name}.files");
     //Remove leftovers.
     G::rm_dir($tempDirectory);
 }
Ejemplo n.º 21
0
function getAllCounters()
{
    $userUid = isset($_SESSION['USER_LOGGED']) && $_SESSION['USER_LOGGED'] != '' ? $_SESSION['USER_LOGGED'] : null;
    $oAppCache = new AppCacheView();
    $aTypes = array();
    $aTypes['to_do'] = 'CASES_INBOX';
    $aTypes['draft'] = 'CASES_DRAFT';
    $aTypes['cancelled'] = 'CASES_CANCELLED';
    $aTypes['sent'] = 'CASES_SENT';
    $aTypes['paused'] = 'CASES_PAUSED';
    $aTypes['completed'] = 'CASES_COMPLETED';
    $aTypes['selfservice'] = 'CASES_SELFSERVICE';
    //$aTypes['to_revise']   = 'CASES_TO_REVISE';
    //$aTypes['to_reassign'] = 'CASES_TO_REASSIGN';
    $solrEnabled = false;
    if (($solrConf = System::solrEnv()) !== false) {
        G::LoadClass('AppSolr');
        $ApplicationSolrIndex = new AppSolr($solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance']);
        if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
            $solrEnabled = true;
        }
    }
    if ($solrEnabled) {
        $aCount = $ApplicationSolrIndex->getCasesCount($userUid);
        //get paused count
        $aCountMissing = $oAppCache->getAllCounters(array('completed', 'cancelled'), $userUid);
        $aCount = array_merge($aCount, $aCountMissing);
    } else {
        $aCount = $oAppCache->getAllCounters(array_keys($aTypes), $userUid);
    }
    $response = array();
    $i = 0;
    foreach ($aCount as $type => $count) {
        $response[$i] = new stdclass();
        $response[$i]->item = $aTypes[$type];
        $response[$i]->count = $count;
        $i++;
    }
    echo G::json_encode($response);
}
Ejemplo n.º 22
0
            $color = 'red';
            $img = '/images/delete.png';
            $dataVar['USER_ID'] = $_POST['NEW_USERNAME'];
            $text = G::LoadTranslation('ID_USERNAME_ALREADY_EXISTS', $dataVar);
            $text = $_POST['NEW_USERNAME'] == '' ? G::LoadTranslation('ID_MSG_ERROR_USR_USERNAME') : $text;
            $response['exists'] = true;
        } else {
            $color = 'green';
            $img = '/images/dialog-ok-apply.png';
            $text = G::LoadTranslation('ID_USERNAME_CORRECT');
            $response['exists'] = false;
        }
        $span = '<span style="color: ' . $color . '; font: 9px tahoma,arial,helvetica,sans-serif;">';
        $gif = '<img width="13" height="13" border="0" src="' . $img . '">';
        $response['descriptionText'] = $span . $gif . $text . '</span>';
        echo G::json_encode($response);
        break;
    case "passwordValidate":
        $messageResultLogin = "";
        $password = $_POST["password"];
        $resultLogin = $RBAC->VerifyLogin($_SESSION["USR_USERNAME"], $password);
        if ($resultLogin == $_SESSION["USER_LOGGED"]) {
            $messageResultLogin = "******";
        } else {
            $messageResultLogin = "******";
        }
        $response = array();
        $response["result"] = $messageResultLogin;
        echo G::json_encode($response);
        break;
}
Ejemplo n.º 23
0
            try {
                $oStepSupervisor = new StepSupervisor();
                $fields2 = $oStepSupervisor->loadInfo($_POST['INP_DOC_UID']);
                $oStepSupervisor->remove($fields2['STEP_UID']);
                $oPermission = new ObjectPermission();
                $fields3 = $oPermission->loadInfo($_POST['INP_DOC_UID']);
                if (is_array($fields3)) {
                    $oPermission->remove($fields3['OP_UID']);
                }
                $oInputDocument = new InputDocument();
                $fields = $oInputDocument->load($_POST['INP_DOC_UID']);
                $oInputDocument->remove($_POST['INP_DOC_UID']);
                $oStep = new Step();
                $oStep->removeStep('INPUT_DOCUMENT', $_POST['INP_DOC_UID']);
                $oOP = new ObjectPermission();
                $oOP->removeByObject('INPUT', $_POST['INP_DOC_UID']);
                //refresh dbarray with the last change in inputDocument
                $oMap = new processMap();
                $oCriteria = $oMap->getInputDocumentsCriteria($fields['PRO_UID']);
                $result->success = true;
                $result->msg = G::LoadTranslation('ID_INPUTDOCUMENT_REMOVED');
            } catch (Exception $e) {
                $result->success = false;
                $result->msg = $e->getMessage();
            }
            print G::json_encode($result);
            break;
    }
} catch (Exception $oException) {
    die($oException->getMessage());
}
Ejemplo n.º 24
0
    /**
     * Get Data Generate
     *
     * @access public
     * @param string $pro_uid, Process Uid
     * @param string $tas_uid, Task Uid
     * @param string $dyn_uid, Dynaform Uid
     * @return string
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
    */
    public function getDataGenerate($pro_uid, $tas_uid, $dyn_uid)
    {
        G::LoadClass ('case');
        G::LoadClass ('pmFunctions');
        G::LoadClass ("configuration");
        $hasTextArea = false;

        $conf = new \Configurations();
        $generalConfCasesList = $conf->getConfiguration("ENVIRONMENT_SETTINGS", "");
        if (isset($generalConfCasesList["casesListDateFormat"]) && !empty($generalConfCasesList["casesListDateFormat"])) {
            $dateFormat = $generalConfCasesList["casesListDateFormat"];
        } else {
            $dateFormat = "Y/m/d";
        }

        $oDyna = new \Dynaform();
        $dataTask = $oDyna->load($dyn_uid);
        if ($dataTask['DYN_VERSION'] > 0) {
            G::LoadClass("pmDynaform");
            $pmDyna = new \pmDynaform(array('APP_DATA' => array()));
            $pmDyna->fields["CURRENT_DYNAFORM"] = $dyn_uid;
            $json = G::json_decode($dataTask["DYN_CONTENT"]);
            $pmDyna->jsonr($json);
            $fieldsDyna = $json->items[0]->items;

            $xmlfrm = new \stdclass();
            $xmlfrm->fields = array();
            foreach ($fieldsDyna as $key => $value) {
                if ($value[0]->type == 'title' || $value[0]->type == 'submit') {
                    continue;
                }
                $temp = new \stdclass();
                $temp->type = $value[0]->type;
                $temp->label = $value[0]->label;
                $temp->name = $value[0]->name;
                $temp->required = (isset($value[0]->required)) ? $value[0]->required : 0;
                $temp->mode = (isset($value[0]->mode)) ? $value[0]->mode : 'edit';

                if (!empty($value[0]->options)) {
                    $temp->storeData = '[';
                    foreach ($value[0]->options as $valueOption) {
                        $temp->storeData .= '["' . $valueOption['value'] . '", "' . $valueOption['label'] . '"],';
                    }
                    $temp->storeData = substr($temp->storeData,0,-1);
                    $temp->storeData .= ']';
                }

                $temp->readOnly = ($temp->mode == 'view') ? "1" : "0";
                $temp->colWidth = 200;
                $xmlfrm->fields[] = $temp;
            }
        } else {
            $filename = $pro_uid . PATH_SEP . $dyn_uid . ".xml";
            if (!class_exists('Smarty')) {
                require_once(PATH_THIRDPARTY . 'smarty' . PATH_SEP . 'libs' . PATH_SEP . 'Smarty.class.php');  
            }
            $xmlfrm = new \XmlForm();
            $xmlfrm->home = PATH_DYNAFORM;
            $xmlfrm->parseFile($filename, SYS_LANG, true);    
        }

        $caseColumns      = array();
        $caseReaderFields = array();

        $dropList          = array();
        $comboBoxYesNoList = array();

        $caseColumns[] = array("header" => "APP_UID", "dataIndex" => "APP_UID", "width" => 100, "hidden" => true, "hideable" => false);
        $caseColumns[] = array("header" => "#", "dataIndex" => "APP_NUMBER", "width" => 40, "sortable" => true);
        $caseColumns[] = array("header" => G::LoadTranslation("ID_TITLE"), "dataIndex" => "APP_TITLE", "width" => 180, "renderer" => "renderTitle", "sortable" => true);
        $caseColumns[] = array("header" => G::LoadTranslation("ID_SUMMARY"), "width" => 60, "renderer" => "renderSummary", "align" => "center");
        $caseColumns[] = array("header" => "DEL_INDEX", "dataIndex" => "DEL_INDEX", "width" => 100, "hidden" => true, "hideable" => false);

        $caseReaderFields[] = array("name" => "APP_UID");
        $caseReaderFields[] = array("name" => "APP_NUMBER");
        $caseReaderFields[] = array("name" => "APP_TITLE");
        $caseReaderFields[] = array("name" => "DEL_INDEX");

        //$caseColumns[] = array("header" => "FLAG", "dataIndex" => "FLAG", "width" => 55, "xtype"=>"checkcolumn");
        //$caseReaderFields[] = array("name" => "FLAG", "type"=>"bool");

        foreach ($xmlfrm->fields as $index => $value) {
            $field = $value;

            $editor = null;
            $renderer = null;

            $readOnly = (isset($field->readOnly))? $field->readOnly : null;
            $required = (isset($field->required))? $field->required : null;
            $validate = (isset($field->validate))? strtolower($field->validate) : null;

            $fieldReadOnly = ($readOnly . "" == "1")? "readOnly: true," : null;
            $fieldRequired = ($required . "" == "1")? "allowBlank: false," : null;
            $fieldValidate = ($validate == "alpha" || $validate == "alphanum" || $validate == "email" || $validate == "int" || $validate == "real")? "vtype: \"$validate\"," : null;

            $fieldLabel = (($fieldRequired != null)? "<span style='color: red;'>&#42;</span> ": null) . $field->label;
            $fieldDisabled = ($field->mode != "edit")? "true" : "false";

            switch ($field->type) {
                case "dropdown":
                    $dropList[] = $field->name;
                    $align = "left";

                    if (empty($field->storeData)) {
                        $editor = "* new Ext.form.ComboBox({
                               id: \"cbo" . $field->name . "_" . $pro_uid . "\",

                               valueField:   'value',
                               displayField: 'text',

                               /*store: comboStore,*/
                               store: new Ext.data.JsonStore({
                                 storeId: \"store" . $field->name . "_" . $pro_uid . "\",
                                 proxy: new Ext.data.HttpProxy({
                                   url: 'proxyDataCombobox'
                                 }),
                                 root: 'records',
                                 fields: [{name: 'value'},
                                          {name: 'text'}
                                         ]
                               }),

                               triggerAction: 'all',
                               mode:     'local',
                               editable: false,
                               disabled: $fieldDisabled,
                               lazyRender: false,

                               $fieldReadOnly
                               $fieldRequired
                               $fieldValidate
                               cls: \"\"
                             }) *";
                    } else {
                        $editor = "* new Ext.form.ComboBox({
                                   id: \"cbo" . $field->name . "_" . $pro_uid . "\",

                                   typeAhead: true,
                                   autocomplete:true,
                                   editable:false,
                                   lazyRender:true,
                                   mode:'local',
                                   triggerAction:'all',
                                   forceSelection:true,

                                   valueField:   'value',
                                   displayField: 'text',
                                   store:new Ext.data.SimpleStore({
                                        fields: [{name: 'value'},
                                              {name: 'text'}],
                                        data: " . htmlspecialchars_decode($field->storeData) . ",
                                        sortInfo:{field:'text',direction:'ASC'}
                                    }),

                                   $fieldReadOnly
                                   $fieldRequired
                                   $fieldValidate
                                   cls: \"\"
                                 }) *";    
                    }

                    
                    $editor = eregi_replace("[\n|\r|\n\r]", ' ', $editor);
                    $width = $field->colWidth;
                    
                    $caseColumns[] = array("xtype" => "combocolumn", "gridId" => "gridId", "header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => "true", "clicksToEdit" => "1");
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "date":
                    //minValue: '01/01/06',
                    //disabledDays: [0, 6],
                    //disabledDaysText: 'Plants are not available on the weekends'

                    $align = "center";
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;

                    $editor = "* new Ext.form.DateField({
                                     format: \"$dateFormat\",

                                     $fieldReadOnly
                                     $fieldRequired
                                     $fieldValidate
                                     cls: \"\"
                                 }) *";

                    //$renderer = "* formatDate *";
                    $renderer = "* function (value){
                                     return Ext.isDate(value)? value.dateFormat('{$dateFormat}') : value;
                                   } *";

                    if ($field->mode != "edit") {
                        $editor = null;
                    }

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name, "type" => "date");
                    break;
                case "currency":
                    //align: 'right',
                    //renderer: 'usMoney',
                    //allowBlank: false,
                    //allowNegative: false,
                    $align = 'right';
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;

                    $editor = "* new Ext.form.NumberField({
                                   maxValue: 1000000,
                                   allowDecimals: true,
                                   allowNegative: true,

                                   $fieldReadOnly
                                   $fieldRequired
                                   $fieldValidate
                                   cls: \"\"
                                 }) *";

                    if ($field->mode != "edit") {
                        $editor = null;
                    }

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "percentage":
                    $align = 'right';
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;

                    $editor = "* new Ext.form.NumberField({
                                   maxValue: 100,
                                   allowDecimals: true,

                                   $fieldReadOnly
                                   $fieldRequired
                                   $fieldValidate
                                   cls: \"\"
                                 }) *";

                    $renderer = "* function (value){
                                     return (value + ' %');
                                   } *";

                    if ($field->mode != "edit") {
                        $editor = null;
                    }

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "textarea":
                    $align = 'left';
                    $size = 200;

                    if (isset($field->size)) {
                        $size = $field->size * 15;
                    }

                    $width = $size;

                    $editor   = "* new Ext.form.TextArea({
                                     growMin: 60,
                                     growMax: 1000,
                                     grow: true,
                                     autoHeight: true,
                                     disabled: $fieldDisabled,
                                     enterIsSpecial: false,
                                     preventScrollbars: false,

                                     $fieldReadOnly
                                     $fieldRequired
                                     $fieldValidate
                                     cls: \"\"
                                   }) *";

                    $renderer = "* function (value) {  return (value);  } *";

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name);

                    $hasTextArea = true;
                    break;
                case "link":
                    $align = 'center';
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;
                    $editor = null;

                    $renderer = "* function (value)
                                   {
                                       return linkRenderer(value);
                                   } *";

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "renderer" => $renderer, "frame" => true, "hidden" => false, "hideable" => false, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "hidden":
                    $align = 'left';
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;

                    $editor = "* new Ext.form.TextField({ allowBlank: false }) *";

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)$width, "align" => $align, "editor" => $editor, "frame" => "true", "hidden" => "true", "hideable" => false, "clicksToEdit" => "1");
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "yesno":
                    $align = "right";
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;
                    $dropList[] = $field->name;
                    $comboBoxYesNoList[] = $field->name;

                    $editor="* new Ext.form.ComboBox({
                                 id: \"cbo" . $field->name . "_" . $pro_uid . "\",

                                 valueField:   'value',
                                 displayField: 'text',

                                 store: new Ext.data.ArrayStore({
                                   storeId: \"store" . $field->name . "_" . $pro_uid . "\",
                                   fields: ['value', 'text'],
                                   data: [[1, 'YES'],
                                          [0, 'NO']
                                         ]
                                 }),

                                 typeAhead: true,

                                 triggerAction: 'all',
                                 mode: 'local',
                                 editable: false,
                                 disabled : $fieldDisabled,
                                 lazyRender: true,

                                 $fieldReadOnly
                                 $fieldRequired
                                 $fieldValidate
                                 cls: \"\"
                               }) *";

                    /*
                    $renderer = "* function(value) {
                                     idx = this.editor.store.find(this.editor.valueField, value);
                                     if (currentFieldEdited == '{$field->name}') {
                                       if (rec = this.editor.store.getAt(idx)) {
                                         rowLabels['{$field->name}'] = rec.get(this.editor.displayField);
                                                       return rec.get(this.editor.displayField);
                                       }
                                       else {
                                         return value;
                                       }
                                     }
                                     else {
                                       if (typeof(currentFieldEdited) == 'undefined') {
                                         return value;
                                       }
                                       else {
                                         return (rowLabels['{$field->name}']);
                                       }
                                     }
                                   } *";
                    */

                    //$caseColumns[] = array('header' => $fieldLabel, 'dataIndex' => $field->name, 'width' => (int)$width, 'align' => $align, 'editor' => $editor, 'renderer' => $renderer, 'frame' => 'true', 'clicksToEdit' => '1');
                    $caseColumns[] = array("xtype" => "combocolumn", "gridId" => "gridId", "header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => "true", "clicksToEdit" => "1");
                    $caseReaderFields[] = array("name" => $field->name);
                    break;
                case "text":
                default:
                    $align = "left";
                    $size = 100;

                    if (isset($field->size)) {
                        $size = $field->size * 10;
                    }

                    $width = $size;
                    $editor = "* new Ext.form.TextField({ $fieldReadOnly $fieldRequired $fieldValidate cls: \"\"}) *";

                    if ($field->mode != "edit" && $field->mode != "parent") {
                        $editor = null;
                    }

                    $caseColumns[] = array("header" => $fieldLabel, "dataIndex" => $field->name, "width" => (int)($width), "align" => $align, "editor" => $editor, "frame" => true, "clicksToEdit" => 1, "sortable" => true);
                    $caseReaderFields[] = array("name" => $field->name);
            }
        }

        @unlink(PATH_C . "ws" . PATH_SEP . SYS_SYS . PATH_SEP . "xmlform" . PATH_SEP . $pro_uid . PATH_SEP . $dyn_uid . "." . SYS_LANG);


        
        $array ['columnModel']          = $caseColumns;
        $array ['readerFields']         = $caseReaderFields;
        $array ["dropList"]             = $dropList;
        $array ["comboBoxYesNoList"]    = $comboBoxYesNoList;
        $array ['hasTextArea']          = $hasTextArea;
        
        $temp = G::json_encode($array);

        //$temp = str_replace("***","'",$temp);
        $temp = str_replace('"*','',  $temp);
        $temp = str_replace('*"','',  $temp);
        $temp = str_replace('\t','',  $temp);
        $temp = str_replace('\n','',  $temp);
        $temp = str_replace('\/','/', $temp);
        $temp = str_replace('\"','"', $temp);
        $temp = str_replace('"checkcolumn"','\'checkcolumn\'',$temp);

        print $temp;
        die();
    }
Ejemplo n.º 25
0
 /**
  * import a pm table
  *
  * @param string $httpData->id
  */
 public function import($httpData)
 {
     require_once 'classes/model/AdditionalTables.php';
     try {
         $errors = '';
         $overWrite = isset($_POST['form']['OVERWRITE']) ? true : false;
         //save the file
         if ($_FILES['form']['error']['FILENAME'] !== 0) {
             throw new Exception(G::loadTranslation('ID_PMTABLE_UPLOADING_FILE_PROBLEM'));
         }
         $oAdditionalTables = new AdditionalTables();
         $tableNameMap = array();
         $processQueue = array();
         $processQueueTables = array();
         $PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . SYS_SYS . PATH_SEP . 'public' . PATH_SEP;
         $filename = $_FILES['form']['name']['FILENAME'];
         $tempName = $_FILES['form']['tmp_name']['FILENAME'];
         G::uploadFile($tempName, $PUBLIC_ROOT_PATH, $filename);
         $fileContent = file_get_contents($PUBLIC_ROOT_PATH . $filename);
         if (strpos($fileContent, '-----== ProcessMaker Open Source Private Tables ==-----') === false) {
             throw new Exception(G::loadTranslation('ID_PMTABLE_INVALID_FILE'));
         }
         $fp = fopen($PUBLIC_ROOT_PATH . $filename, "rb");
         $fsData = intval(fread($fp, 9));
         //reading the metadata
         $sType = fread($fp, $fsData);
         // first create the tables structures
         while (!feof($fp)) {
             switch ($sType) {
                 case '@META':
                     $fsData = intval(fread($fp, 9));
                     $METADATA = fread($fp, $fsData);
                     break;
                 case '@SCHEMA':
                     $fsUid = intval(fread($fp, 9));
                     $uid = fread($fp, $fsUid);
                     $fsData = intval(fread($fp, 9));
                     $schema = fread($fp, $fsData);
                     $contentSchema = unserialize($schema);
                     $additionalTable = new additionalTables();
                     $tableExists = $additionalTable->loadByName($contentSchema['ADD_TAB_NAME']);
                     $tableNameMap[$contentSchema['ADD_TAB_NAME']] = $contentSchema['ADD_TAB_NAME'];
                     if ($overWrite) {
                         if ($tableExists !== false) {
                             $additionalTable->deleteAll($tableExists['ADD_TAB_UID']);
                         }
                     } else {
                         if ($tableExists !== false) {
                             // some table exists with the same name
                             // renaming...
                             $tNameOld = $contentSchema['ADD_TAB_NAME'];
                             $newTableName = $contentSchema['ADD_TAB_NAME'] . '_' . date('YmdHis');
                             $contentSchema['ADD_TAB_UID'] = G::generateUniqueID();
                             $contentSchema['ADD_TAB_NAME'] = $newTableName;
                             $contentSchema['ADD_TAB_CLASS_NAME'] = additionalTables::getPHPName($newTableName);
                             //mapping the table name for posterior uses
                             $tableNameMap[$tNameOld] = $contentSchema['ADD_TAB_NAME'];
                         }
                     }
                     // validating invalid bds_uid in old tables definition -> mapped to workflow
                     if (!$contentSchema['DBS_UID'] || $contentSchema['DBS_UID'] == '0' || !$contentSchema['DBS_UID']) {
                         $contentSchema['DBS_UID'] = 'workflow';
                     }
                     $columns = array();
                     foreach ($contentSchema['FIELDS'] as $field) {
                         $column = array('uid' => '', 'field_uid' => '', 'field_name' => $field['FLD_NAME'], 'field_dyn' => isset($field['FLD_DYN_NAME']) ? $field['FLD_DYN_NAME'] : '', 'field_label' => isset($field['FLD_DESCRIPTION']) ? $field['FLD_DESCRIPTION'] : '', 'field_type' => $field['FLD_TYPE'], 'field_size' => $field['FLD_SIZE'], 'field_key' => isset($field['FLD_KEY']) ? $field['FLD_KEY'] : 0, 'field_null' => isset($field['FLD_NULL']) ? $field['FLD_NULL'] : 1, 'field_autoincrement' => isset($field['FLD_AUTO_INCREMENT']) ? $field['FLD_AUTO_INCREMENT'] : 0);
                         $columns[] = $column;
                     }
                     $tableData = new stdClass();
                     $tableData->REP_TAB_UID = $contentSchema['ADD_TAB_UID'];
                     $tableData->REP_TAB_NAME = $contentSchema['ADD_TAB_NAME'];
                     $tableData->REP_TAB_DSC = $contentSchema['ADD_TAB_DESCRIPTION'];
                     $tableData->REP_TAB_CONNECTION = $contentSchema['DBS_UID'];
                     if (isset($_POST["form"]["PRO_UID"]) && !empty($_POST["form"]["PRO_UID"])) {
                         $tableData->PRO_UID = $_POST["form"]["PRO_UID"];
                     } else {
                         $tableData->PRO_UID = isset($contentSchema["PRO_UID"]) ? $contentSchema["PRO_UID"] : "";
                     }
                     $tableData->REP_TAB_TYPE = isset($contentSchema['ADD_TAB_TYPE']) ? $contentSchema['ADD_TAB_TYPE'] : '';
                     $tableData->REP_TAB_GRID = isset($contentSchema['ADD_TAB_GRID']) ? $contentSchema['ADD_TAB_GRID'] : '';
                     $tableData->columns = G::json_encode($columns);
                     $tableData->forceUid = true;
                     //save the table
                     $alterTable = false;
                     $result = $this->save($tableData, $alterTable);
                     if ($result->success) {
                         $processQueueTables[$contentSchema['DBS_UID']][] = $contentSchema['ADD_TAB_NAME'];
                     } else {
                         $errors .= 'Error creating table: ' . $tableData->REP_TAB_NAME . '-> ' . $result->message . "\n\n";
                     }
                     break;
                 case '@DATA':
                     $fstName = intval(fread($fp, 9));
                     $tableName = fread($fp, $fstName);
                     $fsData = intval(fread($fp, 9));
                     if ($fsData > 0) {
                         $data = fread($fp, $fsData);
                     }
                     break;
             }
             $fsData = intval(fread($fp, 9));
             //reading the metadata
             if ($fsData > 0) {
                 // reading next block type
                 $sType = fread($fp, $fsData);
             } else {
                 break;
             }
         }
         fclose($fp);
         G::loadClass('pmTable');
         foreach ($processQueueTables as $dbsUid => $tables) {
             $pmTable = new pmTable();
             ob_start();
             $pmTable->buildModelFor($dbsUid, $tables);
             $buildResult = ob_get_contents();
             ob_end_clean();
             $errors .= $pmTable->upgradeDatabaseFor($pmTable->getDataSource(), $tables);
         }
         $fp = fopen($PUBLIC_ROOT_PATH . $filename, "rb");
         $fsData = intval(fread($fp, 9));
         $sType = fread($fp, $fsData);
         // data processing
         while (!feof($fp)) {
             switch ($sType) {
                 case '@META':
                     $fsData = intval(fread($fp, 9));
                     $METADATA = fread($fp, $fsData);
                     break;
                 case '@SCHEMA':
                     $fsUid = intval(fread($fp, 9));
                     $uid = fread($fp, $fsUid);
                     $fsData = intval(fread($fp, 9));
                     $schema = fread($fp, $fsData);
                     $contentSchema = unserialize($schema);
                     $additionalTable = new additionalTables();
                     $table = $additionalTable->loadByName($tableNameMap[$contentSchema['ADD_TAB_NAME']]);
                     if ($table['PRO_UID'] != '') {
                         // is a report table, try populate it
                         $additionalTable->populateReportTable($table['ADD_TAB_NAME'], pmTable::resolveDbSource($table['DBS_UID']), $table['ADD_TAB_TYPE'], $table['PRO_UID'], $table['ADD_TAB_GRID'], $table['ADD_TAB_UID']);
                     }
                     break;
                 case '@DATA':
                     $fstName = intval(fread($fp, 9));
                     $tableName = fread($fp, $fstName);
                     $fsData = intval(fread($fp, 9));
                     if ($fsData > 0) {
                         $data = fread($fp, $fsData);
                         $contentData = unserialize($data);
                         $tableName = $tableNameMap[$tableName];
                         $oAdditionalTables = new AdditionalTables();
                         $table = $oAdditionalTables->loadByName($tableName);
                         $isReport = $table['PRO_UID'] !== '' ? true : false;
                         if ($table !== false) {
                             if (!$isReport) {
                                 if (count($contentData) > 0) {
                                     foreach ($contentData as $row) {
                                         $data = new StdClass();
                                         $data->id = $table['ADD_TAB_UID'];
                                         $data->rows = base64_encode(serialize($row));
                                         $res = $this->dataCreate($data, 'base64');
                                         if (!$res->success) {
                                             $errors .= $res->message;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     break;
             }
             $fsData = intval(fread($fp, 9));
             if ($fsData > 0) {
                 $sType = fread($fp, $fsData);
             } else {
                 break;
             }
         }
         ////////////
         if ($errors == '') {
             $result->success = true;
             $msg = G::loadTranslation('ID_PMTABLE_IMPORT_SUCCESS', array($filename));
         } else {
             $result->success = false;
             $result->errorType = 'warning';
             $msg = G::loadTranslation('ID_PMTABLE_IMPORT_WITH_ERRORS', array($filename)) . "\n\n" . $errors;
         }
         $result->message = $msg;
     } catch (Exception $e) {
         $result->errorType = 'error';
         $result->buildResult = ob_get_contents();
         ob_end_clean();
         $result->success = false;
         // if it is a propel exception message
         if (preg_match('/(.*)\\s\\[(.*):\\s(.*)\\]\\s\\[(.*):\\s(.*)\\]/', $e->getMessage(), $match)) {
             $result->message = $match[3];
             $result->type = G::loadTranslation('ID_ERROR');
         } else {
             $result->message = $e->getMessage();
             $result->type = G::loadTranslation('ID_EXCEPTION');
         }
         //$result->trace = $e->getTraceAsString();
     }
     return $result;
 }
Ejemplo n.º 26
0
        }
        if ($key == 'FILENAME') {
            $Fields[$key] = myTruncate($value, 60, '_', '...pm');
        }
        if ($length >= 250) {
            if ($key == 'FILENAME_LINK') {
                list($file, $rest) = explode('p=', $value);
                list($filenameLink, $rest) = explode('&', $rest);
                $Fields[$key] = myTruncate($filenameLink, 250 - $pathLength, '_', '');
                $Fields[$key] = $file . "p=" . $Fields[$key] . '&' . $rest;
            }
        }
    }
    /* Render page */
    if (isset($_REQUEST["processMap"]) && $_REQUEST["processMap"] == 1) {
        $G_PUBLISH = new Publisher();
        $G_PUBLISH->AddContent("xmlform", "xmlform", "processes/processes_Export", "", $Fields);
        G::RenderPage("publish", "raw");
    } else {
        $xmlFrm = new XmlForm();
        $xmlFrm->home = PATH_XMLFORM . "processes" . PATH_SEP;
        $xmlFrm->parseFile("processes_Export.xml", SYS_LANG, true);
        $Fields["xmlFrmFieldLabel"] = array("title" => $xmlFrm->fields["TITLE"]->label, "proTitle" => $xmlFrm->fields["PRO_TITLE"]->label, "proDescription" => $xmlFrm->fields["PRO_DESCRIPTION"]->label, "size" => $xmlFrm->fields["SIZE"]->label, "fileName" => $xmlFrm->fields["FILENAME_LABEL"]->label);
        echo G::json_encode($Fields);
    }
} catch (Exception $e) {
    $G_PUBLISH = new Publisher();
    $aMessage['MESSAGE'] = $e->getMessage();
    $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage);
    G::RenderPage('publish', 'raw');
}
Ejemplo n.º 27
0
<?php

if (!isset($_SESSION['USER_LOGGED'])) {
    $response = new stdclass();
    $response->message = G::LoadTranslation('ID_LOGIN_AGAIN');
    $response->lostSession = true;
    print G::json_encode($response);
    die;
}
/**
 * cases_Ajax.php
 *
 * ProcessMaker Open Source Edition
 * Copyright (C) 2004 - 2008 Colosa Inc.23
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
 * Coral Gables, FL, 33134, USA, or email info@colosa.com.
 */
Ejemplo n.º 28
0
    public function deleteLanguage($dyn_uid, $lang)
    {
        $con = Propel::getConnection(DynaformPeer::DATABASE_NAME);
        $con->begin();
        $oPro = DynaformPeer::retrieveByPk($dyn_uid);

        $dyn_labels = \G::json_decode($oPro->getDynLabel());
        unset($dyn_labels->{$lang});

        $oPro->setDynLabel(G::json_encode($dyn_labels));
        $oPro->save();
        $con->commit();
    }
Ejemplo n.º 29
0
function getDefaultDashboard()
{
    $defaultDashboard['defaultTab'] = "mainDashboard";
    if (isset($_SESSION['__currentTabDashboard'])) {
        $defaultDashboard['defaultTab'] = $_SESSION['__currentTabDashboard'];
    }
    print_r(G::json_encode($defaultDashboard));
}
Ejemplo n.º 30
0
 /**
  *
  *
  * Creates a Dynaform based on a PMTable
  *
  * @name createFromPMTable
  * @author gustavo cruz gustavo[at]colosa[dot]com
  * @param array $aData Fields with :
  * $aData['DYN_UID'] the dynaform id
  * $aData['USR_UID'] the userid
  * string $pmTableUid uid of the PMTable
  *
  */
 public function createFromPMTable($aData, $pmTableUid)
 {
     $this->create($aData, $pmTableUid);
     $aData['DYN_UID'] = $this->getDynUid();
     //krumo(BasePeer::getFieldnames('Content'));
     $fields = array();
     //$oCriteria = new Criteria('workflow');
     $pmTable = AdditionalTablesPeer::retrieveByPK($pmTableUid);
     $addTabName = $pmTable->getAddTabName();
     $keys = '';
     if (isset($aData['FIELDS'])) {
         foreach ($aData['FIELDS'] as $iRow => $row) {
             if ($keys != '') {
                 $keys = $keys . '|' . $row['PRO_VARIABLE'];
             } else {
                 $keys = $row['PRO_VARIABLE'];
             }
         }
     } else {
         $keys = ' ';
     }
     //      $addTabKeys = $pmTable->getAddTabDynavars();
     //      $addTabKeys = unserialize($addTabKeys);
     //      $keys = '';
     //      foreach ( $addTabKeys as $addTabKey ){
     //        if (trim($addTabKey['CASE_VARIABLE'])!=''&&$keys!=''){
     //            $keys = $keys.'|'.$addTabKey['CASE_VARIABLE'];
     //        } else {
     //            $keys = $addTabKey['CASE_VARIABLE'];
     //        }
     //
     //      }
     // Determines the engine to use
     // For a description of a table
     $sDataBase = 'database_' . strtolower(DB_ADAPTER);
     if (G::LoadSystemExist($sDataBase)) {
         G::LoadSystem($sDataBase);
         $oDataBase = new database();
         $sql = $oDataBase->getTableDescription($addTabName);
     } else {
         $sql = 'DESC ' . $addTabName;
     }
     $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
     $sth = $dbh->createStatement();
     $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     $file = $aData['PRO_UID'] . '/' . $aData['DYN_UID'];
     $dbc = new DBConnection(PATH_DYNAFORM . $file . '.xml', '', '', '', 'myxml');
     $ses = new DBSession($dbc);
     $fieldXML = new DynaFormField($dbc);
     $pmConnectionName = $addTabName . '_CONNECTION';
     if ($aData['DYN_TYPE'] == 'xmlform') {
         $labels = array();
         $options = array();
         $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $pmConnectionName, 'TYPE' => 'pmconnection', 'PMTABLE' => $pmTableUid, 'KEYS' => $keys);
         $fieldXML->Save($attributes, $labels, $options);
     }
     $keyRequered = '';
     $countKeys = 0;
     while ($res->next()) {
         if ($res->get('Key') != '') {
             $countKeys++;
         }
         if ($res->get('Extra') == 'auto_increment') {
             $keyRequered .= $res->get('Field');
         }
     }
     $dbh = Propel::getConnection(AdditionalTablesPeer::DATABASE_NAME);
     $sth = $dbh->createStatement();
     $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
     while ($res->next()) {
         // if(strtoupper($res->get('Null'))=='NO') {
         if (strtoupper($res->get($oDataBase->getFieldNull())) == 'NO') {
             if ($countKeys == 1 && $res->get('Field') == $keyRequered) {
                 $required = '0';
             } else {
                 $required = '1';
             }
         } else {
             $required = '0';
         }
         $fieldName = $res->get('Field');
         $defaultValue = $res->get('Default');
         $labels = array(SYS_LANG => $fieldName);
         $options = array();
         $type = explode('(', $res->get('Type'));
         switch ($type[0]) {
             case 'text':
                 $type = 'textarea';
                 break;
             case 'date':
                 $type = 'date';
                 break;
             default:
                 $type = 'text';
                 break;
         }
         if ($aData['DYN_TYPE'] == 'xmlform') {
             $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $fieldName, 'TYPE' => $type, 'PMCONNECTION' => $pmConnectionName, 'PMFIELD' => $fieldName, 'REQUIRED' => $required, 'DEFAULTVALUE' => $defaultValue);
         } else {
             $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => $fieldName, 'TYPE' => $type, 'REQUIRED' => $required, 'DEFAULTVALUE' => $defaultValue);
         }
         $fieldXML->Save($attributes, $labels, $options);
     }
     $labels = array(SYS_LANG => 'Submit');
     $attributes = array('XMLNODE_NAME_OLD' => '', 'XMLNODE_NAME' => 'SUBMIT', 'TYPE' => 'submit');
     $fieldXML->Save($attributes, $labels, $options);
     //update content if version is 2
     if ($this->getDynVersion() === 2) {
         $items = array();
         $variables = array();
         $res = $sth->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
         while ($res->next()) {
             //data type
             $type = "text";
             $dataType = explode('(', $res->get('Type'));
             error_log(print_r($dataType, true));
             switch ($dataType[0]) {
                 case 'bigint':
                     $type = 'text';
                     $dataType = 'integer';
                     break;
                 case 'int':
                     $type = 'text';
                     $dataType = 'integer';
                     break;
                 case 'smallint':
                     $type = 'text';
                     $dataType = 'integer';
                     break;
                 case 'tinyint':
                     $type = 'text';
                     $dataType = 'integer';
                     break;
                 case 'decimal':
                     $type = 'text';
                     $dataType = 'float';
                     break;
                 case 'double':
                     $type = 'text';
                     $dataType = 'float';
                     break;
                 case 'float':
                     $type = 'text';
                     $dataType = 'float';
                     break;
                 case 'datetime':
                     $type = 'datetime';
                     $dataType = 'datetime';
                     break;
                 case 'date':
                     $type = 'datetime';
                     $dataType = 'datetime';
                     break;
                 case 'time':
                     $type = 'datetime';
                     $dataType = 'datetime';
                     break;
                 case 'char':
                     $type = 'text';
                     $dataType = 'string';
                     break;
                 case 'varchar':
                     $type = 'text';
                     $dataType = 'string';
                     break;
                 case 'mediumtext':
                     $type = 'textarea';
                     $dataType = 'string';
                     break;
                 default:
                     $type = "text";
                     $dataType = 'string';
                     break;
             }
             //variables
             $arrayData = array("var_name" => $res->get('Field'), "var_label" => $res->get('Field'), "var_field_type" => $dataType, "var_field_size" => 10, "var_null" => 1, "var_dbconnection" => "none", "var_sql" => "", "var_options_control" => "", "var_default" => "", "var_accepted_values" => array());
             $objVariable = new \ProcessMaker\BusinessModel\Variable();
             try {
                 $objVariable->existsName($this->getProUid(), $res->get('Field'));
                 $variable = $objVariable->create($this->getProUid(), $arrayData);
             } catch (\Exception $e) {
                 $data = $objVariable->getVariables($this->getProUid());
                 foreach ($data as $datavariable) {
                     if ($datavariable["var_name"] === $res->get('Field')) {
                         $variable = $datavariable;
                         break;
                     }
                 }
             }
             array_push($variables, $variable);
             array_push($items, array(array("type" => $type, "dataType" => $dataType, "id" => $res->get('Field'), "name" => $res->get('Field'), "label" => $res->get('Field'), "hint" => "", "required" => false, "defaultValue" => "", "dependentFields" => array(), "textTransform" => "none", "validate" => "any", "mask" => "", "maxLength" => 1000, "formula" => "", "mode" => "parent", "var_uid" => $variable["var_uid"], "var_name" => $variable["var_name"], "colSpan" => 12)));
         }
         //submit button
         array_push($items, array(array("type" => "submit", "id" => "FormDesigner-" . \ProcessMaker\Util\Common::generateUID(), "name" => "submit", "label" => "submit", "colSpan" => 12)));
         $json = array("name" => $this->getDynTitle(), "description" => $this->getDynDescription(), "items" => array(array("type" => "form", "id" => $this->getDynUid(), "name" => $this->getDynTitle(), "description" => $this->getDynDescription(), "mode" => "edit", "script" => "", "items" => $items, "variables" => $variables)));
         $aData = $this->Load($this->getDynUid());
         $aData["DYN_CONTENT"] = G::json_encode($json);
         $this->update($aData);
     }
 }