/**

     * make_site

     *

     * @return array $test

     */

    private function make_site()

    {

        $test = $this->create_site_test();



        if ($test["created"] == true || $this->options["advanced"]["ao_db_drop"] == true) {

            /* Check if the hostname is local (localhost or 127.0.0.1) */

            $islocal = (strcmp(substr($this->options['database']['hostname'], 0, strlen('localhost')), 'localhost') === 0) || (strcmp(substr($this->options['database']['hostname'], 0, strlen('127.0.0.1')), '127.0.0.1') === 0);



            $this->wf_site_name = $wf = $this->options['advanced']['ao_db_wf'];



            $this->rbac_site_name = $rb = $this->options['advanced']['ao_db_rb'];

            $this->report_site_name = $rp = $this->options['advanced']['ao_db_rp'];



            $schema = "schema.sql";

            $values = "insert.sql";



            if ($this->options['advanced']['ao_db_drop'] === true) {

                //Delete workspace directory if exists

                //Drop databases

                $this->run_query("DROP DATABASE IF EXISTS " . $wf, "Drop database $wf");

            }



            $this->run_query("CREATE DATABASE IF NOT EXISTS " . $wf . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database $wf");



            if ($this->cc_status == 1) {

                $host = ($islocal) ? "localhost" : "%";

                $this->run_query("GRANT ALL PRIVILEGES ON `$wf`.* TO $wf@'$host' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user $wf on database $wf");

            }



            /* Dump schema workflow && data  */



            $this->log("Import database schema:\n");

            $myPortA = explode(":", $this->options['database']['hostname']);

            if (count($myPortA) < 2) {

                $myPortA[1] = "3306";

            }

            $myPort = $myPortA[1];

            $this->options['database']['hostname'] = $myPortA[0];



            mysql_select_db($wf, $this->connection_database);

            $pws = PATH_WORKFLOW_MYSQL_DATA . $schema;

            $qws = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $schema, $this->connection_database);

            $this->log($qws, isset($qws['errors']));

            $qwv = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $values, $this->connection_database);

            $this->log($qwv, isset($qwv['errors']));



            $http = (G::is_https() == true) ? 'https' : 'http';

            $lang = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';

            $host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '');

            $workspace = $this->options['name'];



            $endpoint = sprintf(

            		'%s://%s/sys%s/%s/%s/oauth2/grant',

            		$http,

            		$host,

            		$workspace,

            		$lang,

            		SYS_SKIN

            );



            // inserting the outh_client

            $query = ( "INSERT INTO OAUTH_CLIENTS (CLIENT_ID,CLIENT_SECRET,CLIENT_NAME,CLIENT_DESCRIPTION,CLIENT_WEBSITE,REDIRECT_URI,USR_UID ) VALUES

            		   ('x-pm-local-client','179ad45c6ce2cb97cf1029e212046e81','PM Web Designer','ProcessMaker Web Designer App','www.processmaker.com','" . $endpoint . "','00000000000000000000000000000001' )");

            $this->run_query( $query );



            /* Dump schema rbac && data  */

            $pws = PATH_RBAC_MYSQL_DATA . $schema;

            mysql_select_db($rb, $this->connection_database);

            $qrs = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $schema, $this->connection_database);

            $this->log($qrs, isset($qrs['errors']));

            $qrv = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $values, $this->connection_database);

            $this->log($qrv, isset($qrv['errors']));



            mysql_select_db($wf, $this->connection_database);



            require_once ("propel/Propel.php");

            require_once ('classes/model/AppCacheView.php');



            $appCache = new AppCacheView();

            $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup/setupSchemas/');

            $triggers = $appCache->getTriggers("en");

            $this->log("Create 'cases list cache' triggers");

            foreach ($triggers as $triggerName => $trigger) {

                $this->run_query($trigger, "-> Trigger $triggerName");

            }



            $path_site = $this->options['path_data'] . "/sites/" . $this->options['name'] . "/";

            $db_file = $path_site . "db.php";

            @mkdir($path_site, 0777, true);

            @mkdir($path_site . "files/", 0777, true);

            @mkdir($path_site . "mailTemplates/", 0777, true);

            @mkdir($path_site . "public/", 0777, true);

            @mkdir($path_site . "reports/", 0777, true);

            @mkdir($path_site . "xmlForms", 0777, true);



            $db_text = "<?php\n" . "// Processmaker configuration\n" . "define ('DB_ADAPTER', 'mysql' );\n" . "define ('DB_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_NAME', '" . $wf . "' );\n" . "define ('DB_USER', '" . (($this->cc_status == 1) ? $wf : $this->options['database']['username']) . "' );\n" . "define ('DB_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n" . "define ('DB_RBAC_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_RBAC_NAME', '" . $rb . "' );\n" . "define ('DB_RBAC_USER', '" . (($this->cc_status == 1) ? $rb : $this->options['database']['username']) . "' );\n" . "define ('DB_RBAC_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n" . "define ('DB_REPORT_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_REPORT_NAME', '" . $rp . "' );\n" . "define ('DB_REPORT_USER', '" . (($this->cc_status == 1) ? $rp : $this->options['database']['username']) . "' );\n" . "define ('DB_REPORT_PASS', '" . (($this->cc_status == 1) ? $this->options['password'] : $this->options['database']['password']) . "' );\n";

            if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {

                $db_text .= "define ('PARTNER_FLAG', " . ((defined('PARTNER_FLAG') && PARTNER_FLAG != '') ? PARTNER_FLAG : ((isset($_REQUEST['PARTNER_FLAG'])) ? $_REQUEST['PARTNER_FLAG']:'false')) . ");\n";

                if (defined('SYSTEM_NAME')) {

                    $db_text .= "  define ('SYSTEM_NAME', '" . SYSTEM_NAME . "');\n";

                }

            }

            $db_text .="?>";

            $fp = @fopen($db_file, "w");

            $this->log("Create: " . $db_file . "  => " . ((!$fp) ? $fp : "OK") . "\n", $fp === false);

            $ff = @fputs($fp, $db_text, strlen($db_text));

            $this->log("Write: " . $db_file . "  => " . ((!$ff) ? $ff : "OK") . "\n", $ff === false);



            fclose($fp);

            $this->setPartner();

            $this->setAdmin();



            $querySql = "INSERT INTO EMAIL_SERVER(MESS_UID, MESS_ENGINE) VALUES('" . \ProcessMaker\Util\Common::generateUID() . "', 'MAIL')";



            $this->run_query($querySql);

        }

        return $test;

    }
Example #2
0
                $users[] = array("USR_UID" => $row["USR_UID"], "USR_FULLNAME" => $usrFullName);
            }
            break;
        default:
            return $users;
            break;
    }
    //return $users;
    return print G::json_encode($users);
}
if ($actionAjax == "processListExtJs") {
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $categoryUid = isset($_REQUEST['CATEGORY_UID']) ? $_REQUEST['CATEGORY_UID'] : null;
    $userUid = isset($_SESSION['USER_LOGGED']) && $_SESSION['USER_LOGGED'] != '' ? $_SESSION['USER_LOGGED'] : null;
    global $oAppCache;
    $oAppCache = new AppCacheView();
    $processes = array();
    $processes[] = array('', G::LoadTranslation('ID_ALL_PROCESS'));
    //get the list based in the action provided
    switch ($action) {
        case 'draft':
            $cProcess = $oAppCache->getDraftListCriteria($userUid);
            //fast enough
            break;
        case 'sent':
            $cProcess = $oAppCache->getSentListProcessCriteria($userUid);
            // fast enough
            break;
        case 'simple_search':
        case 'search':
            //in search action, the query to obtain all process is too slow, so we need to query directly to
 public function getAll($userUid, $start = null, $limit = null, $action = null, $filter = null, $search = null, $process = null, $status = null, $type = null, $dateFrom = null, $dateTo = null, $callback = null, $dir = null, $sort = "APP_CACHE_VIEW.APP_NUMBER", $category = null)
 {
     $callback = isset($callback) ? $callback : "stcCallback1001";
     $dir = isset($dir) ? $dir : "DESC";
     $sort = isset($sort) ? $sort : "";
     $start = isset($start) ? $start : "0";
     $limit = isset($limit) ? $limit : "25";
     $filter = isset($filter) ? $filter : "";
     $search = isset($search) ? $search : "";
     $process = isset($process) ? $process : "";
     $category = isset($category) ? $category : "";
     $status = isset($status) ? $status : "";
     $action = isset($action) ? $action : "todo";
     $type = isset($type) ? $type : "extjs";
     $dateFrom = isset($dateFrom) ? $dateFrom : "";
     $dateTo = isset($dateTo) ? $dateTo : "";
     G::LoadClass("BasePeer");
     G::LoadClass("configuration");
     //require_once ("classes/model/AppCacheView.php");
     //require_once ("classes/model/AppDelegation.php");
     //require_once ("classes/model/AdditionalTables.php");
     //require_once ("classes/model/AppDelay.php");
     //require_once ("classes/model/Fields.php");
     //require_once ("classes/model/Users.php");
     //require_once ("classes/model/Process.php");
     $oAppCache = new AppCacheView();
     //get data configuration
     $conf = new Configurations();
     $confCasesList = $conf->getConfiguration('casesList', $action == 'search' || $action == 'simple_search' ? 'sent' : $action);
     $oAppCache->confCasesList = $confCasesList;
     // get the action based list
     switch ($action) {
         case "draft":
             $Criteria = $oAppCache->getDraftListCriteria($userUid);
             $CriteriaCount = $oAppCache->getDraftCountCriteria($userUid);
             break;
         case "sent":
             $Criteria = $oAppCache->getSentListCriteria($userUid);
             $CriteriaCount = $oAppCache->getSentCountCriteria($userUid);
             if (!empty($status)) {
                 $Criteria->add(AppCacheViewPeer::APP_STATUS, $status);
                 $CriteriaCount->add(AppCacheViewPeer::APP_STATUS, $status);
             }
             break;
         case "selfservice":
         case "unassigned":
             //$userUid can't be empty or null
             $Criteria = $oAppCache->getUnassignedListCriteria($userUid);
             $CriteriaCount = $oAppCache->getUnassignedCountCriteria($userUid);
             break;
         case "paused":
             $Criteria = $oAppCache->getPausedListCriteria($userUid);
             $CriteriaCount = $oAppCache->getPausedCountCriteria($userUid);
             break;
         case "completed":
             $Criteria = $oAppCache->getCompletedListCriteria($userUid);
             $CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid);
             break;
         case "cancelled":
             $Criteria = $oAppCache->getCancelledListCriteria($userUid);
             $CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid);
             break;
         case "search":
             //$Criteria = $oAppCache->getSearchListCriteria();
             //$CriteriaCount = $oAppCache->getSearchCountCriteria();
             switch ($status) {
                 case "TO_DO":
                     $Criteria = $oAppCache->getToDoListCriteria($userUid);
                     $CriteriaCount = $oAppCache->getToDoCountCriteria($userUid);
                     break;
                 case "DRAFT":
                     $Criteria = $oAppCache->getDraftListCriteria($userUid);
                     $CriteriaCount = $oAppCache->getDraftCountCriteria($userUid);
                     break;
                 case "PAUSED":
                     $Criteria = $oAppCache->getPausedListCriteria($userUid);
                     $CriteriaCount = $oAppCache->getPausedCountCriteria($userUid);
                     break;
                 case "CANCELLED":
                     $Criteria = $oAppCache->getCancelledListCriteria($userUid);
                     $CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid);
                     break;
                 case "COMPLETED":
                     $Criteria = $oAppCache->getCompletedListCriteria($userUid);
                     $CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid);
                     break;
                 default:
                     //All status
                     $Criteria = $oAppCache->getAllCasesListCriteria2($userUid);
                     $CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid);
                     break;
             }
             break;
         case "simple_search":
             $Criteria = $oAppCache->getSimpleSearchListCriteria();
             $CriteriaCount = $oAppCache->getSimpleSearchCountCriteria();
             break;
         case "to_revise":
             $Criteria = $oAppCache->getToReviseListCriteria($userUid);
             $CriteriaCount = $oAppCache->getToReviseCountCriteria($userUid);
             break;
         case "to_reassign":
             $Criteria = $oAppCache->getToReassignListCriteria($userUid);
             $CriteriaCount = $oAppCache->getToReassignCountCriteria($userUid);
             break;
         case "all":
             $Criteria = $oAppCache->getAllCasesListCriteria($userUid);
             $CriteriaCount = $oAppCache->getAllCasesCountCriteria($userUid);
             break;
         case "gral":
             //General criteria probably will be deprecated
             $Criteria = $oAppCache->getGeneralListCriteria();
             $CriteriaCount = $oAppCache->getGeneralCountCriteria();
             break;
         case "todo":
             $Criteria = $oAppCache->getToDoListCriteria($userUid);
             $CriteriaCount = $oAppCache->getToDoCountCriteria($userUid);
             break;
         default:
             //All status
             $Criteria = $oAppCache->getAllCasesListCriteria2($userUid);
             $CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid);
             break;
     }
     $Criteria->addAlias('CU', 'USERS');
     $Criteria->addJoin(AppCacheViewPeer::USR_UID, 'CU.USR_UID', Criteria::LEFT_JOIN);
     $Criteria->addAsColumn('USR_UID', 'CU.USR_UID');
     $Criteria->addAsColumn('USR_FIRSTNAME', 'CU.USR_FIRSTNAME');
     $Criteria->addAsColumn('USR_LASTNAME', 'CU.USR_LASTNAME');
     $Criteria->addAsColumn('USR_USERNAME', 'CU.USR_USERNAME');
     // Fix for previous user
     if ($action == "todo" || $action == "selfservice" || $action == "unassigned" || $action == "paused" || $action == "to_revise" || $action == "sent" || ($status == "TO_DO" || $status == "DRAFT" || $status == "PAUSED" || $status == "CANCELLED" || $status == "COMPLETED")) {
         $Criteria->addAlias('PU', 'USERS');
         $Criteria->addJoin(AppCacheViewPeer::PREVIOUS_USR_UID, 'PU.USR_UID', Criteria::LEFT_JOIN);
         $Criteria->addAsColumn('PREVIOUS_USR_FIRSTNAME', 'PU.USR_FIRSTNAME');
         $Criteria->addAsColumn('PREVIOUS_USR_LASTNAME', 'PU.USR_LASTNAME');
         $Criteria->addAsColumn('PREVIOUS_USR_USERNAME', 'PU.USR_USERNAME');
     }
     /*
     if (! is_array( $confCasesList )) {
         $rows = $this->getDefaultFields( $action );
         $result = $this->genericJsonResponse( '', array (), $rows, 20, '' );
         //$conf->saveObject($result,'casesList',$action,'','','');
     }
     */
     //Add the process filter
     if (!empty($process)) {
         $Criteria->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL);
         $CriteriaCount->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL);
     }
     //Add the category filter
     if (!empty($category)) {
         $Criteria->addAlias("CP", "PROCESS");
         $Criteria->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL);
         $Criteria->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN);
         $Criteria->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY");
         $CriteriaCount->addAlias("CP", "PROCESS");
         $CriteriaCount->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL);
         $CriteriaCount->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN);
         $CriteriaCount->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY");
     }
     // add the user filter
     /*
     if ($user != '') {
         $Criteria->add( AppCacheViewPeer::USR_UID, $user, Criteria::EQUAL );
         $CriteriaCount->add( AppCacheViewPeer::USR_UID, $user, Criteria::EQUAL );
     }
     */
     /*
     if ($status != '') {
         $Criteria->add( AppCacheViewPeer::APP_STATUS, $status, Criteria::EQUAL );
         $CriteriaCount->add( AppCacheViewPeer::APP_STATUS, $status, Criteria::EQUAL );
     }
     */
     if ($dateFrom != '') {
         if ($dateTo != '') {
             $Criteria->add($Criteria->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL)->addAnd($Criteria->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL)));
             $CriteriaCount->add($CriteriaCount->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL)->addAnd($Criteria->getNewCriterion(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL)));
         } else {
             $Criteria->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL);
             $CriteriaCount->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL);
         }
     } elseif ($dateTo != '') {
         $Criteria->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL);
         $CriteriaCount->add(AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL);
     }
     //add the filter
     if ($filter != '') {
         switch ($filter) {
             case 'read':
                 $Criteria->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL);
                 $CriteriaCount->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL);
                 break;
             case 'unread':
                 $Criteria->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL);
                 $CriteriaCount->add(AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL);
                 break;
             case 'started':
                 $Criteria->add(AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL);
                 $CriteriaCount->add(AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL);
                 break;
             case 'completed':
                 $Criteria->add(AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL);
                 $CriteriaCount->add(AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL);
                 break;
         }
     }
     //add the search filter
     if ($search != '') {
         $defaultFields = $oAppCache->getDefaultFields();
         $oTmpCriteria = '';
         // if there is PMTABLE for this case list:
         if (!empty($oAppCache->confCasesList) && isset($oAppCache->confCasesList['PMTable']) && trim($oAppCache->confCasesList['PMTable']) != '') {
             // getting the table name
             $oAdditionalTables = AdditionalTablesPeer::retrieveByPK($oAppCache->confCasesList['PMTable']);
             $tableName = $oAdditionalTables->getAddTabName();
             $oNewCriteria = new Criteria('workflow');
             $counter = 0;
             foreach ($oAppCache->confCasesList['second']['data'] as $fieldData) {
                 if (!in_array($fieldData['name'], $defaultFields)) {
                     $fieldName = $tableName . '.' . $fieldData['name'];
                     if ($counter == 0) {
                         $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, '%' . $search . '%', Criteria::LIKE);
                     } else {
                         $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, '%' . $search . '%', Criteria::LIKE)->addOr($oTmpCriteria);
                     }
                     $counter++;
                 }
             }
             //add the default and hidden DEL_INIT_DATE
         }
         // the criteria adds new fields if there are defined PM Table Fields in the cases list
         if ($oTmpCriteria != '') {
             $Criteria->add($Criteria->getNewCriterion(AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE)->addOr($oTmpCriteria))));
         } else {
             $Criteria->add($Criteria->getNewCriterion(AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($Criteria->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE))));
         }
         // the count query needs to be the normal criteria query if there are defined PM Table Fields in the cases list
         if ($oTmpCriteria != '') {
             $CriteriaCount = $Criteria;
         } else {
             $CriteriaCount->add($CriteriaCount->getNewCriterion(AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($CriteriaCount->getNewCriterion(AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE)->addOr($CriteriaCount->getNewCriterion(AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE))));
         }
     }
     // this is the optimal way or query to render the cases search list
     // fixing the bug related to the wrong data displayed in the list
     /*
     if ($action == 'search') {
         $oDatasetIndex = AppCacheViewPeer::doSelectRS( $Criteria );
         $oDatasetIndex->setFetchmode( ResultSet::FETCHMODE_ASSOC );
         $oDatasetIndex->next();
         $maxDelIndexList = array ();
         // a list of MAX_DEL_INDEXES is required in order to validate the right row
         while ($aRow = $oDatasetIndex->getRow()) {
             $maxDelIndexList[] = $aRow['MAX_DEL_INDEX'];
             $oDatasetIndex->next();
         }
         // adding the validation condition in order to get the right row using the group by sentence
         $Criteria->add( AppCacheViewPeer::DEL_INDEX, $maxDelIndexList, Criteria::IN );
         //
         //$params = array($maxDelIndexList);
     }
     */
     //here we count how many records exists for this criteria.
     //BUT there are some special cases, and if we dont optimize them the server will crash.
     $doCountAlreadyExecuted = false;
     //case 1. when the SEARCH action is selected and none filter, search criteria is defined,
     //we need to count using the table APPLICATION, because APP_CACHE_VIEW takes 3 seconds
     /*
     if ($action == 'search' && $filter == '' && $search == '' && $process == '' && $status == '' && $dateFrom == '' && $dateTo == '' && $category == '') {
         $totalCount = $oAppCache->getSearchAllCount();
         $doCountAlreadyExecuted = true;
     }
     if ($category != '') {
         $totalCount = $oAppCache->getSearchCountCriteria();
         $doCountAlreadyExecuted = true;
     }
     */
     if ($doCountAlreadyExecuted == false) {
         // in the case of reassign the distinct attribute shows a diferent count result comparing to the
         // original list
         //Check also $distinct in the method getListCounters(), this in AppCacheView.php
         $distinct = true;
         if ($action == "todo" || $action == "to_reassign" || $status == "TO_DO") {
             $distinct = false;
         }
         // first check if there is a PMTable defined within the list,
         // the issue that brokes the normal criteria query seems to be fixed
         if (isset($oAppCache->confCasesList['PMTable']) && !empty($oAppCache->confCasesList['PMTable'])) {
             // then
             $oAdditionalTables = AdditionalTablesPeer::retrieveByPK($oAppCache->confCasesList['PMTable']);
             $tableName = $oAdditionalTables->getAddTabName();
             $tableName = strtolower($tableName);
             $tableNameArray = explode('_', $tableName);
             foreach ($tableNameArray as $item) {
                 $newTableName[] = ucfirst($item);
             }
             $tableName = implode('', $newTableName);
             // so the pm table class can be invoqued from the pm table model clases
             if (!class_exists($tableName)) {
                 require_once PATH_DB . SYS_SYS . PATH_SEP . "classes" . PATH_SEP . $tableName . ".php";
             }
         }
         $totalCount = AppCacheViewPeer::doCount($CriteriaCount, $distinct);
     }
     //add sortable options
     if ($sort != '') {
         if ($dir == 'DESC') {
             $Criteria->addDescendingOrderByColumn($sort);
         } else {
             $Criteria->addAscendingOrderByColumn($sort);
         }
     }
     //limit the results according the interface
     $Criteria->setLimit($limit);
     $Criteria->setOffset($start);
     //execute the query
     $oDataset = AppCacheViewPeer::doSelectRS($Criteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $result = array();
     $result['totalCount'] = $totalCount;
     $rows = array();
     $aPriorities = array('1' => 'VL', '2' => 'L', '3' => 'N', '4' => 'H', '5' => 'VH');
     $index = $start;
     while ($aRow = $oDataset->getRow()) {
         //$aRow = $oAppCache->replaceRowUserData($aRow);
         /*
          * For participated cases, we want the last step in the case, not only the last step this user participated. To do that we get every case information again for the last step. (This could be solved by a subquery, but Propel might not support it and subqueries can be slower for larger
          * datasets).
          */
         /*if ($action == 'sent' || $action == 'search') {
                      $maxCriteria = new Criteria('workflow');
                      $maxCriteria->add(AppCacheViewPeer::APP_UID, $aRow['APP_UID'], Criteria::EQUAL);
                      $maxCriteria->addDescendingOrderByColumn(AppCacheViewPeer::DEL_INDEX);
                      $maxCriteria->setLimit(1);
         
                      $maxDataset = AppCacheViewPeer::doSelectRS( $maxCriteria );
                      $maxDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
                      $maxDataset->next();
         
                      $newData = $maxDataset->getRow();
                      foreach ($aRow as $col => $value) {
                      if (array_key_exists($col, $newData))
                      $aRow[$col] = $newData[$col];
                      }
         
                      $maxDataset->close();
                       }*/
         if (!isset($aRow['APP_CURRENT_USER'])) {
             $aRow['APP_CURRENT_USER'] = "******";
         }
         // replacing the status data with their respective translation
         if (isset($aRow['APP_STATUS'])) {
             $aRow['APP_STATUS'] = G::LoadTranslation("ID_{$aRow['APP_STATUS']}");
         }
         // replacing the priority data with their respective translation
         if (isset($aRow['DEL_PRIORITY'])) {
             $aRow['DEL_PRIORITY'] = G::LoadTranslation("ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}");
         }
         $rows[] = $aRow;
         $oDataset->next();
     }
     $result['data'] = $rows;
     return $result;
 }
Example #4
0
     $arr['dateSave'] = date('Y-m-d H:i:s');
     $config = array();
     $config[] = $arr;
     $c->aConfig = $config;
     $c->saveConfig('usersList', 'pageSize', '', $_SESSION['USER_LOGGED']);
     echo '{success: true}';
     break;
 case 'summaryUserData':
     require_once 'classes/model/Users.php';
     require_once 'classes/model/Department.php';
     require_once 'classes/model/AppCacheView.php';
     G::LoadClass('configuration');
     $oUser = new Users();
     $data = $oUser->loadDetailed($_REQUEST['USR_UID']);
     $data['USR_STATUS'] = G::LoadTranslation('ID_' . $data['USR_STATUS']);
     $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';
     $aCount = $oAppCache->getAllCounters(array_keys($aTypes), $_REQUEST['USR_UID']);
     $dep = new Department();
     if ($dep->existsDepartment($data['DEP_UID'])) {
         $dep->Load($data['DEP_UID']);
         $dep_name = $dep->getDepTitle();
     } else {
         $dep_name = '';
Example #5
0
    /**

     * Get unassigned case list

     *

     * @param string $userId

     * @return $result will return an object

     */

    public function unassignedCaseList ($userId)

    {

        try {

            $result = array ();

            $oAppCache = new AppCacheView();

            $Criteria = $oAppCache->getUnassignedListCriteria( $userId );

            $oDataset = AppCacheViewPeer::doSelectRS( $Criteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();



            while ($aRow = $oDataset->getRow()) {

                $result[] = array ('guid' => $aRow['APP_UID'],

                                   'name' => $aRow['APP_NUMBER'],

                                   'delIndex' => $aRow['DEL_INDEX'],

                                   'processId' => $aRow['PRO_UID']);



                $oDataset->next();

            }



            return $result;

        } catch (Exception $e) {

            $result[] = array ('guid' => $e->getMessage(),

                               'name' => $e->getMessage(),

                               'status' => $e->getMessage(),

                               'status' => $e->getMessage(),

                               'processId' => $e->getMessage());



            return $result;

        }

    }
Example #6
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);
}
Example #7
0
    /**
     * @param $action
     * @param $categoryUid
     * @param $userUid
     * @return array
     * @throws \PropelException
     */
    public function getProcessList ($action, $categoryUid, $userUid)
    {
        //$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : null;
        //$categoryUid = isset( $_REQUEST['CATEGORY_UID'] ) ? $_REQUEST['CATEGORY_UID'] : null;
        //$userUid = (isset( $_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '') ? $_SESSION['USER_LOGGED'] : null;

        // global $oAppCache;
        $oAppCache = new \AppCacheView();
        $processes = array ();
        $processes[] = array ('',G::LoadTranslation( 'ID_ALL_PROCESS' ));

        //get the list based in the action provided
        switch ($action) {
            case 'draft':
                $cProcess = $oAppCache->getDraftListCriteria( $userUid ); //fast enough
                break;
            case 'sent':
                $cProcess = $oAppCache->getSentListProcessCriteria( $userUid ); // fast enough
                break;
            case 'simple_search':
            case 'search':
                //in search action, the query to obtain all process is too slow, so we need to query directly to
                //process and content tables, and for that reason we need the current language in AppCacheView.
                G::loadClass( 'configuration' );
                $oConf = new \Configurations();
                $oConf->loadConfig( $x, 'APP_CACHE_VIEW_ENGINE', '', '', '', '' );
                $appCacheViewEngine = $oConf->aConfig;
                $lang = isset( $appCacheViewEngine['LANG'] ) ? $appCacheViewEngine['LANG'] : 'en';

                $cProcess = new Criteria( 'workflow' );
                $cProcess->clearSelectColumns();
                $cProcess->addSelectColumn( \ProcessPeer::PRO_UID );
                $cProcess->addSelectColumn( \ContentPeer::CON_VALUE );
                if ($categoryUid) {
                    $cProcess->add( \ProcessPeer::PRO_CATEGORY, $categoryUid );
                }
                $del = DBAdapter::getStringDelimiter();
                $conds = array ();
                $conds[] = array (ProcessPeer::PRO_UID,ContentPeer::CON_ID);
                $conds[] = array (ContentPeer::CON_CATEGORY,$del . 'PRO_TITLE' . $del);
                $conds[] = array (ContentPeer::CON_LANG,$del . $lang . $del);
                $cProcess->addJoinMC( $conds, Criteria::LEFT_JOIN );
                $cProcess->add( ProcessPeer::PRO_STATUS, 'ACTIVE' );
                $cProcess->addAscendingOrderByColumn(ContentPeer::CON_VALUE);

                $oDataset = ProcessPeer::doSelectRS( $cProcess );
                $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
                $oDataset->next();

                while ($aRow = $oDataset->getRow()) {
                    $processes[] = array ($aRow['PRO_UID'],$aRow['CON_VALUE']
                    );
                    $oDataset->next();
                }
                return print G::json_encode( $processes );
                break;
            case 'unassigned':
                $cProcess = $oAppCache->getUnassignedListCriteria( $userUid );
                break;
            case 'paused':
                $cProcess = $oAppCache->getPausedListCriteria( $userUid );
                break;
            case 'to_revise':
                $cProcess = $oAppCache->getToReviseListCriteria( $userUid );
                break;
            case 'to_reassign':
                $cProcess = $oAppCache->getToReassignListCriteria($userUid);
                break;
            case 'gral':
                $cProcess = $oAppCache->getGeneralListCriteria();
                break;
            case 'todo':
            default:
                $cProcess = $oAppCache->getToDoListCriteria( $userUid ); //fast enough
                break;
        }
        //get the processes for this user in this action
        $cProcess->clearSelectColumns();
        $cProcess->addSelectColumn( \AppCacheViewPeer::PRO_UID );
        $cProcess->addSelectColumn( \AppCacheViewPeer::APP_PRO_TITLE );
        $cProcess->setDistinct( \AppCacheViewPeer::PRO_UID );
        if ($categoryUid) {
            require_once 'classes/model/Process.php';
            $cProcess->addAlias( 'CP', 'PROCESS' );
            $cProcess->add( 'CP.PRO_CATEGORY', $categoryUid, Criteria::EQUAL );
            $cProcess->addJoin( \AppCacheViewPeer::PRO_UID, 'CP.PRO_UID', Criteria::LEFT_JOIN );
            $cProcess->addAsColumn( 'CATEGORY_UID', 'CP.PRO_CATEGORY' );
        }

        $cProcess->addAscendingOrderByColumn(\AppCacheViewPeer::APP_PRO_TITLE);

        $oDataset = \AppCacheViewPeer::doSelectRS( $cProcess, \Propel::getDbConnection('workflow_ro') );
        $oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
        $oDataset->next();

        while ($aRow = $oDataset->getRow()) {
            $processes[] = array ($aRow['PRO_UID'],$aRow['APP_PRO_TITLE']
            );
            $oDataset->next();
        }
        return $processes;
    }
     $aUserInfo[] = array('USR_UID' => $aRow1['USR_UID'], 'USER_FULLNAME' => $infoUser);
 }
 global $_DBArray;
 $_DBArray['aUserInfo'] = $aUserInfo;
 $_SESSION['_DBArray'] = $_DBArray;
 //////////////////
 $G_PUBLISH = new Publisher();
 $G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_ReassignBy', '', $_GET);
 $sUserToReassign = trim($_GET['REASSIGN_USER']);
 if ($_GET['REASSIGN_USER'] != '') {
     G::LoadClass('tasks');
     G::LoadClass('groups');
     $oTasks = new Tasks();
     $oGroups = new Groups();
     $oUser = new Users();
     $oAppCache = new AppCacheView();
     $oCriteriaToDo = $oAppCache->getToDoListCriteria($sUserToReassign);
     $oCriteriaDraft = $oAppCache->getDraftListCriteria($sUserToReassign);
     $aCasesList = array();
     $oDataset = ApplicationPeer::doSelectRS($oCriteriaToDo);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     while ($oDataset->next()) {
         array_push($aCasesList, $oDataset->getRow());
     }
     $oDataset = ApplicationPeer::doSelectRS($oCriteriaDraft);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     while ($oDataset->next()) {
         array_push($aCasesList, $oDataset->getRow());
     }
     $filedNames = array("APP_UID", "APP_NUMBER", "APP_UPDATE_DATE", "DEL_PRIORITY", "DEL_INDEX", "TAS_UID", "DEL_INIT_DATE", "DEL_FINISH_DATE", "USR_UID", "APP_STATUS", "DEL_TASK_DUE_DATE", "APP_CURRENT_USER", "APP_TITLE", "APP_PRO_TITLE", "APP_TAS_TITLE", "APP_DEL_PREVIOUS_USER");
     $aCasesList = array_merge(array($filedNames), $aCasesList);
Example #9
0
 public function update($fields)
 {
     require_once "classes/model/AppCacheView.php";
     require_once "classes/model/Configuration.php";
     $con = Propel::getConnection(TaskPeer::DATABASE_NAME);
     try {
         $con->begin();
         $this->load($fields["TAS_UID"]);
         $this->fromArray($fields, BasePeer::TYPE_FIELDNAME);
         if ($this->validate()) {
             $taskDefTitlePrevious = null;
             $criteria = new Criteria("workflow");
             $criteria->addSelectColumn(ContentPeer::CON_VALUE);
             $criteria->add(ContentPeer::CON_CATEGORY, "TAS_DEF_TITLE");
             $criteria->add(ContentPeer::CON_ID, $fields["TAS_UID"]);
             $criteria->add(ContentPeer::CON_LANG, SYS_LANG);
             $rsCriteria = ContentPeer::doSelectRS($criteria);
             $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($rsCriteria->next()) {
                 $row = $rsCriteria->getRow();
                 $taskDefTitlePrevious = $row["CON_VALUE"];
             }
             $contentResult = 0;
             if (array_key_exists("TAS_TITLE", $fields)) {
                 $contentResult += $this->setTasTitle($fields["TAS_TITLE"]);
             }
             if (array_key_exists("TAS_DESCRIPTION", $fields)) {
                 $contentResult += $this->setTasDescription($fields["TAS_DESCRIPTION"]);
             }
             if (array_key_exists("TAS_DEF_TITLE", $fields)) {
                 $contentResult += $this->setTasDefTitle($fields["TAS_DEF_TITLE"]);
             }
             if (array_key_exists("TAS_DEF_DESCRIPTION", $fields)) {
                 $contentResult += $this->setTasDefDescription($fields["TAS_DEF_DESCRIPTION"]);
             }
             if (array_key_exists("TAS_DEF_PROC_CODE", $fields)) {
                 $contentResult += $this->setTasDefProcCode($fields["TAS_DEF_PROC_CODE"]);
             }
             if (array_key_exists("TAS_DEF_MESSAGE", $fields)) {
                 $contentResult += $this->setTasDefMessage(trim($fields["TAS_DEF_MESSAGE"]));
             }
             if (array_key_exists("TAS_DEF_SUBJECT_MESSAGE", $fields)) {
                 $contentResult += $this->setTasDefSubjectMessage(trim($fields["TAS_DEF_SUBJECT_MESSAGE"]));
             }
             if (array_key_exists("TAS_CALENDAR", $fields)) {
                 $contentResult += $this->setTasCalendar($fields['TAS_UID'], $fields["TAS_CALENDAR"]);
             }
             $result = $this->save();
             $result = $result == 0 ? $contentResult > 0 ? 1 : 0 : $result;
             $con->commit();
             if ($result == 1 && array_key_exists("TAS_DEF_TITLE", $fields) && $fields["TAS_DEF_TITLE"] != $taskDefTitlePrevious) {
                 $criteria = new Criteria("workflow");
                 $criteria->addAsColumn("APPCV_NUM_ROWS", "COUNT(DISTINCT " . AppCacheViewPeer::APP_UID . ")");
                 $criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN");
                 $criteria->add(AppCacheViewPeer::TAS_UID, $fields["TAS_UID"]);
                 $rsCriteria = AppCacheViewPeer::doSelectRS($criteria);
                 $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                 $rsCriteria->next();
                 $row = $rsCriteria->getRow();
                 $appcvNumRows = intval($row["APPCV_NUM_ROWS"]);
                 if ($appcvNumRows <= 1000) {
                     $appcv = new AppCacheView();
                     $appcv->appTitleByTaskCaseLabelUpdate($fields["TAS_UID"], SYS_LANG);
                     $result = 2;
                 } else {
                     //Delete record
                     $criteria = new Criteria("workflow");
                     $criteria->add(ConfigurationPeer::CFG_UID, "TAS_APP_TITLE_UPDATE");
                     $criteria->add(ConfigurationPeer::OBJ_UID, $fields["TAS_UID"]);
                     $criteria->add(ConfigurationPeer::CFG_VALUE, SYS_LANG);
                     $numRowDeleted = ConfigurationPeer::doDelete($criteria);
                     //Insert record
                     $conf = new Configuration();
                     $conf->create(array("CFG_UID" => "TAS_APP_TITLE_UPDATE", "OBJ_UID" => $fields["TAS_UID"], "CFG_VALUE" => SYS_LANG, "PRO_UID" => "", "USR_UID" => "", "APP_UID" => ""));
                     $result = 3;
                 }
             }
             return $result;
         } else {
             $con->rollback();
             throw new Exception("Failed Validation in class " . get_class($this) . ".");
         }
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }
Example #10
0
    public function getAll(
        $userUid,
        $start = null,
        $limit = null,
        $action = null,
        $filter = null,
        $search = null,
        $process = null,
        $status = null,
        $type = null,
        $dateFrom = null,
        $dateTo = null,
        $callback = null,
        $dir = null,
        $sort = "APP_CACHE_VIEW.APP_NUMBER",
        $category = null,
        $configuration = true,
        $paged = true
    ) {
        $callback = isset($callback)? $callback : "stcCallback1001";
        $dir = isset($dir)? $dir : "DESC";

        if (isset($sort)) {
            G::LoadClass('phpSqlParser');
            $parser = new PHPSQLParser($sort);
            $sort = $parser->parsed;
            $sort = $sort[''][0];
        }

        $sort = isset($sort)? $sort : "";
        $start = isset($start)? $start : "0";
        $limit = isset($limit)? $limit : "25";
        $filter = isset($filter)? $filter : "";
        $search = isset($search)? $search : "";
        $process = isset($process)? $process : "";
        $category = isset($category)? $category : "";
        $status = isset($status)? $status : "";
        $action = isset($action)? $action : "todo";
        $type = isset($type)? $type : "extjs";
        $dateFrom = isset($dateFrom)? $dateFrom : "";
        $dateTo = isset($dateTo)? $dateTo : "";

        G::LoadClass("BasePeer");
        G::LoadClass("configuration");
        //require_once ("classes/model/AppCacheView.php");
        //require_once ("classes/model/AppDelegation.php");
        //require_once ("classes/model/AdditionalTables.php");
        //require_once ("classes/model/AppDelay.php");
        //require_once ("classes/model/Fields.php");
        //require_once ("classes/model/Users.php");
        //require_once ("classes/model/Process.php");

        $oAppCache = new AppCacheView();

        if ($configuration == true) {
            //get data configuration
            $conf = new Configurations();
            $confCasesList = $conf->getConfiguration("casesList", ($action == "search" || $action == "simple_search")? "search" : $action);
            $oAppCache->confCasesList = $confCasesList;
        }

        $delimiter = DBAdapter::getStringDelimiter();

        // get the action based list
        switch ($action) {
            case "draft":
                $Criteria = $oAppCache->getDraftListCriteria($userUid);
                $CriteriaCount = $oAppCache->getDraftCountCriteria($userUid);
                break;
            case "sent":
                $Criteria = $oAppCache->getSentListCriteria($userUid);
                $CriteriaCount = $oAppCache->getSentCountCriteria($userUid);

                if (!empty($status)) {
                    $Criteria->add(AppCacheViewPeer::APP_STATUS, $status);
                    $CriteriaCount->add(AppCacheViewPeer::APP_STATUS, $status);
                }
                break;
            case "selfservice":
            case "unassigned":
                //$userUid can't be empty or null
                $Criteria = $oAppCache->getUnassignedListCriteria($userUid);
                $CriteriaCount = $oAppCache->getUnassignedCountCriteria($userUid);
                break;
            case "paused":
                $Criteria = $oAppCache->getPausedListCriteria($userUid);
                $CriteriaCount = $oAppCache->getPausedCountCriteria($userUid);
                break;
            case "completed":
                $Criteria = $oAppCache->getCompletedListCriteria($userUid);
                $CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid);
                break;
            case "cancelled":
                $Criteria = $oAppCache->getCancelledListCriteria($userUid);
                $CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid);
                break;
            case "search":
                //$Criteria = $oAppCache->getSearchListCriteria();
                //$CriteriaCount = $oAppCache->getSearchCountCriteria();

                switch ($status) {
                    case "TO_DO":
                        $Criteria = $oAppCache->getToDoListCriteria($userUid);
                        $CriteriaCount = $oAppCache->getToDoCountCriteria($userUid);
                        break;
                    case "DRAFT":
                        $Criteria = $oAppCache->getDraftListCriteria($userUid);
                        $CriteriaCount = $oAppCache->getDraftCountCriteria($userUid);
                        break;
                    case "PAUSED":
                        $Criteria = $oAppCache->getPausedListCriteria($userUid);
                        $CriteriaCount = $oAppCache->getPausedCountCriteria($userUid);
                        break;
                    case "CANCELLED":
                        $Criteria = $oAppCache->getCancelledListCriteria($userUid);
                        $CriteriaCount = $oAppCache->getCancelledCountCriteria($userUid);
                        break;
                    case "COMPLETED":
                        $Criteria = $oAppCache->getCompletedListCriteria($userUid);
                        $CriteriaCount = $oAppCache->getCompletedCountCriteria($userUid);

                        $Criteria->add (AppCacheViewPeer::DEL_LAST_INDEX,"1");
                        $CriteriaCount->add (AppCacheViewPeer::DEL_LAST_INDEX,"1");
                        break;
                    default:
                        //All status
                        $Criteria = $oAppCache->getAllCasesListCriteria2($userUid);
                        $CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid);
                        break;
                }
                break;
            case "simple_search":
                $Criteria = $oAppCache->getSimpleSearchListCriteria();
                $CriteriaCount = $oAppCache->getSimpleSearchCountCriteria();
                break;
            case "to_revise":
                $Criteria = $oAppCache->getToReviseListCriteria($userUid);
                $CriteriaCount = $oAppCache->getToReviseCountCriteria($userUid);
                break;
            case "to_reassign":
                $Criteria = $oAppCache->getToReassignListCriteria($userUid);
                $CriteriaCount = $oAppCache->getToReassignCountCriteria($userUid);
                break;
            case "all":
                $Criteria = $oAppCache->getAllCasesListCriteria($userUid);
                $CriteriaCount = $oAppCache->getAllCasesCountCriteria($userUid);
                break;
            case "gral":
                //General criteria probably will be deprecated
                $Criteria = $oAppCache->getGeneralListCriteria();
                $CriteriaCount = $oAppCache->getGeneralCountCriteria();
                break;
            case "todo":
                $Criteria = $oAppCache->getToDoListCriteria($userUid);
                $CriteriaCount = $oAppCache->getToDoCountCriteria($userUid);
                break;
            default:
                //All status
                $Criteria = $oAppCache->getAllCasesListCriteria2($userUid);
                $CriteriaCount = $oAppCache->getAllCasesCountCriteria2($userUid);
                break;
        }

        $arrayTaskTypeToExclude = array("WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT");

        $Criteria->addJoin(AppCacheViewPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
        $Criteria->add(TaskPeer::TAS_TYPE, $arrayTaskTypeToExclude, Criteria::NOT_IN);

        $CriteriaCount->addJoin(AppCacheViewPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
        $CriteriaCount->add(TaskPeer::TAS_TYPE, $arrayTaskTypeToExclude, Criteria::NOT_IN);

        $Criteria->addAlias( 'CU', 'USERS' );
        $Criteria->addJoin( AppCacheViewPeer::USR_UID, 'CU.USR_UID', Criteria::LEFT_JOIN );
        $Criteria->addAsColumn( 'USR_UID', 'CU.USR_UID' );
        $Criteria->addAsColumn( 'USR_FIRSTNAME', 'CU.USR_FIRSTNAME' );
        $Criteria->addAsColumn( 'USR_LASTNAME', 'CU.USR_LASTNAME' );
        $Criteria->addAsColumn( 'USR_USERNAME', 'CU.USR_USERNAME' );

        $CriteriaCount->addAlias( 'CU', 'USERS' );
        $CriteriaCount->addJoin( AppCacheViewPeer::USR_UID, 'CU.USR_UID', Criteria::LEFT_JOIN );
        $CriteriaCount->addAsColumn( 'USR_UID', 'CU.USR_UID' );
        $CriteriaCount->addAsColumn( 'USR_FIRSTNAME', 'CU.USR_FIRSTNAME' );
        $CriteriaCount->addAsColumn( 'USR_LASTNAME', 'CU.USR_LASTNAME' );
        $CriteriaCount->addAsColumn( 'USR_USERNAME', 'CU.USR_USERNAME' );

        //Current delegation
        $appdelcrTableName = AppCacheViewPeer::TABLE_NAME;
        $appdelcrAppTasTitle = "APPDELCR.APP_TAS_TITLE";
        $appdelcrAppTasTitleCount = $appdelcrAppTasTitle;

        switch ($action) {
            case "sent":
                $appdelcrTableName = AppDelegationPeer::TABLE_NAME;
                $appdelcrAppTasTitle = "(SELECT CON_VALUE FROM CONTENT WHERE CON_ID = APPDELCR.TAS_UID AND CON_LANG = " . $delimiter . SYS_LANG . $delimiter . " AND CON_CATEGORY = " . $delimiter . "TAS_TITLE" . $delimiter . ")";
                $appdelcrAppTasTitleCount = "APPDELCR.TAS_UID";
                break;
            case "to_reassign":
                $appdelcrAppTasTitle = "APP_CACHE_VIEW.APP_TAS_TITLE";
                $appdelcrAppTasTitleCount = $appdelcrAppTasTitle;
                break;
        }

        $Criteria->addAsColumn("APPDELCR_APP_TAS_TITLE", $appdelcrAppTasTitle);
        $CriteriaCount->addAsColumn("APPDELCR_APP_TAS_TITLE", $appdelcrAppTasTitleCount);

        $Criteria->addAsColumn("USRCR_USR_UID", "USRCR.USR_UID");
        $Criteria->addAsColumn("USRCR_USR_FIRSTNAME", "USRCR.USR_FIRSTNAME");
        $Criteria->addAsColumn("USRCR_USR_LASTNAME", "USRCR.USR_LASTNAME");
        $Criteria->addAsColumn("USRCR_USR_USERNAME", "USRCR.USR_USERNAME");

        $CriteriaCount->addAsColumn("USRCR_USR_UID", "USRCR.USR_UID");
        $CriteriaCount->addAsColumn("USRCR_USR_FIRSTNAME", "USRCR.USR_FIRSTNAME");
        $CriteriaCount->addAsColumn("USRCR_USR_LASTNAME", "USRCR.USR_LASTNAME");
        $CriteriaCount->addAsColumn("USRCR_USR_USERNAME", "USRCR.USR_USERNAME");

        $Criteria->addAlias("APPDELCR", $appdelcrTableName);
        $Criteria->addAlias("USRCR", UsersPeer::TABLE_NAME);

        $CriteriaCount->addAlias("APPDELCR", $appdelcrTableName);
        $CriteriaCount->addAlias("USRCR", UsersPeer::TABLE_NAME);

        $arrayCondition = array();
        $arrayCondition[] = array(AppCacheViewPeer::APP_UID, "APPDELCR.APP_UID");
        $arrayCondition[] = array("APPDELCR.DEL_LAST_INDEX", 1);
        $Criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
        $CriteriaCount->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);

        $arrayCondition = array();
        $arrayCondition[] = array("APPDELCR.USR_UID", "USRCR.USR_UID");
        $Criteria->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
        $CriteriaCount->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);

        //Previous user

        if (($action == "todo" || $action == "selfservice" || $action == "unassigned" || $action == "paused" || $action == "to_revise" || $action == "sent") || ($status == "TO_DO" || $status == "DRAFT" || $status == "PAUSED" || $status == "CANCELLED" || $status == "COMPLETED")) {
            $Criteria->addAlias( 'PU', 'USERS' );
            $Criteria->addJoin( AppCacheViewPeer::PREVIOUS_USR_UID, 'PU.USR_UID', Criteria::LEFT_JOIN );
            $Criteria->addAsColumn( 'PREVIOUS_USR_FIRSTNAME', 'PU.USR_FIRSTNAME' );
            $Criteria->addAsColumn( 'PREVIOUS_USR_LASTNAME', 'PU.USR_LASTNAME' );
            $Criteria->addAsColumn( 'PREVIOUS_USR_USERNAME', 'PU.USR_USERNAME' );

            $CriteriaCount->addAlias( 'PU', 'USERS' );
            $CriteriaCount->addJoin( AppCacheViewPeer::PREVIOUS_USR_UID, 'PU.USR_UID', Criteria::LEFT_JOIN );
            $CriteriaCount->addAsColumn( 'PREVIOUS_USR_FIRSTNAME', 'PU.USR_FIRSTNAME' );
            $CriteriaCount->addAsColumn( 'PREVIOUS_USR_LASTNAME', 'PU.USR_LASTNAME' );
            $CriteriaCount->addAsColumn( 'PREVIOUS_USR_USERNAME', 'PU.USR_USERNAME' );
        }

        /*
        if (! is_array( $confCasesList )) {
            $rows = $this->getDefaultFields( $action );
            $result = $this->genericJsonResponse( '', array (), $rows, 20, '' );
            //$conf->saveObject($result,'casesList',$action,'','','');
        }
        */

        //Add the process filter
        if (!empty($process)) {
            $Criteria->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL);
            $CriteriaCount->add(AppCacheViewPeer::PRO_UID, $process, Criteria::EQUAL);
        }

        //Add the category filter
        if (!empty($category)) {
            require_once 'classes/model/Process.php';
            $Criteria->addAlias("CP", "PROCESS");
            $Criteria->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL);
            $Criteria->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN);
            $Criteria->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY");

            $CriteriaCount->addAlias("CP", "PROCESS");
            $CriteriaCount->add("CP.PRO_CATEGORY", $category, Criteria::EQUAL);
            $CriteriaCount->addJoin(AppCacheViewPeer::PRO_UID, "CP.PRO_UID", Criteria::LEFT_JOIN);
            $CriteriaCount->addAsColumn("CATEGORY_UID", "CP.PRO_CATEGORY");
        }

        // add the user filter
        /*
        if ($user != '') {
            $Criteria->add( AppCacheViewPeer::USR_UID, $user, Criteria::EQUAL );
            $CriteriaCount->add( AppCacheViewPeer::USR_UID, $user, Criteria::EQUAL );
        }
        if ($status != '') {
            $Criteria->add( AppCacheViewPeer::APP_STATUS, $status, Criteria::EQUAL );
            $CriteriaCount->add( AppCacheViewPeer::APP_STATUS, $status, Criteria::EQUAL );
        }
        */

        if ($dateFrom != "") {
            if ($dateTo != "") {
                if ($dateFrom == $dateTo) {
                    $dateSame = $dateFrom;
                    $dateFrom = $dateSame . " 00:00:00";
                    $dateTo = $dateSame . " 23:59:59";
                } else {
                    $dateFrom = $dateFrom . " 00:00:00";
                    $dateTo = $dateTo . " 23:59:59";
                }

                $Criteria->add( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL ) ) );
                $CriteriaCount->add( $CriteriaCount->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL )->addAnd( $Criteria->getNewCriterion( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL ) ) );
            } else {
                $dateFrom = $dateFrom . " 00:00:00";

                $Criteria->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL );
                $CriteriaCount->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateFrom, Criteria::GREATER_EQUAL );
            }
        } elseif ($dateTo != "") {
            $dateTo = $dateTo . " 23:59:59";

            $Criteria->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL );
            $CriteriaCount->add( AppCacheViewPeer::DEL_DELEGATE_DATE, $dateTo, Criteria::LESS_EQUAL );
        }

        //add the filter
        if ($filter != '') {
            switch ($filter) {
                case 'read':
                    $Criteria->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL );
                    $CriteriaCount->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL );
                    break;
                case 'unread':
                    $Criteria->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL );
                    $CriteriaCount->add( AppCacheViewPeer::DEL_INIT_DATE, null, Criteria::ISNULL );
                    break;
                case 'started':
                    $Criteria->add( AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL );
                    $CriteriaCount->add( AppCacheViewPeer::DEL_INDEX, 1, Criteria::EQUAL );
                    break;
                case 'completed':
                    $Criteria->add( AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL );
                    $CriteriaCount->add( AppCacheViewPeer::APP_STATUS, 'COMPLETED', Criteria::EQUAL );
                    break;
            }
        }

        //Add the search filter
        if ($search != '') {
            $oTmpCriteria = '';

            //If there is PMTable for this case list
            if (is_array($oAppCache->confCasesList) && count($oAppCache->confCasesList) > 0 && isset($oAppCache->confCasesList["PMTable"]) && trim($oAppCache->confCasesList["PMTable"]) != "") {
                //Default configuration fields array
                $defaultFields = $oAppCache->getDefaultFields();

                //Getting the table name
                $additionalTableUid = $oAppCache->confCasesList["PMTable"];

                $additionalTable = AdditionalTablesPeer::retrieveByPK($additionalTableUid);
                $tableName = $additionalTable->getAddTabName();

                $additionalTable = new AdditionalTables();
                $tableData = $additionalTable->load($additionalTableUid, true);

                $tableField = array();

                foreach ($tableData["FIELDS"] as $arrayField) {
                    $tableField[] = $arrayField["FLD_NAME"];
                }

                $oNewCriteria = new Criteria("workflow");
                $sw = 0;

                foreach ($oAppCache->confCasesList["second"]["data"] as $fieldData) {
                    if (!in_array($fieldData["name"], $defaultFields)) {
                        if (in_array($fieldData["name"], $tableField)) {
                            $fieldName = $tableName . "." . $fieldData["name"];

                            if ($sw == 0) {
                                $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, "%" . $search . "%", Criteria::LIKE);
                            } else {
                                $oTmpCriteria = $oNewCriteria->getNewCriterion($fieldName, "%" . $search . "%", Criteria::LIKE)->addOr($oTmpCriteria);
                            }

                            $sw = 1;
                        }
                    }
                }

                //add the default and hidden DEL_INIT_DATE
            }

            // the criteria adds new fields if there are defined PM Table Fields in the cases list
            if ($oTmpCriteria != '') {
                $Criteria->add( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE )->addOr( $oTmpCriteria ) ) ) );
            } else {
                $Criteria->add( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $Criteria->getNewCriterion( AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE ) ) ) );
            }

            // the count query needs to be the normal criteria query if there are defined PM Table Fields in the cases list
            if ($oTmpCriteria != '') {
                $CriteriaCount = $Criteria;
            } else {
                $CriteriaCount->add( $CriteriaCount->getNewCriterion( AppCacheViewPeer::APP_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $CriteriaCount->getNewCriterion( AppCacheViewPeer::APP_TAS_TITLE, '%' . $search . '%', Criteria::LIKE )->addOr( $CriteriaCount->getNewCriterion( AppCacheViewPeer::APP_NUMBER, $search, Criteria::LIKE ) ) ) );
            }
        }

        // this is the optimal way or query to render the cases search list
        // fixing the bug related to the wrong data displayed in the list
        /*
        if ($action == 'search') {
            $oDatasetIndex = AppCacheViewPeer::doSelectRS( $Criteria );
            $oDatasetIndex->setFetchmode( ResultSet::FETCHMODE_ASSOC );
            $oDatasetIndex->next();
            $maxDelIndexList = array ();
            // a list of MAX_DEL_INDEXES is required in order to validate the right row
            while ($aRow = $oDatasetIndex->getRow()) {
                $maxDelIndexList[] = $aRow['MAX_DEL_INDEX'];
                $oDatasetIndex->next();
            }
            // adding the validation condition in order to get the right row using the group by sentence
            $Criteria->add( AppCacheViewPeer::DEL_INDEX, $maxDelIndexList, Criteria::IN );
            //
            //$params = array($maxDelIndexList);
        }
        */

        //here we count how many records exists for this criteria.
        //BUT there are some special cases, and if we dont optimize them the server will crash.
        $doCountAlreadyExecuted = $paged;
        //case 1. when the SEARCH action is selected and none filter, search criteria is defined,
        //we need to count using the table APPLICATION, because APP_CACHE_VIEW takes 3 seconds

        /*
        if ($action == 'search' && $filter == '' && $search == '' && $process == '' && $status == '' && $dateFrom == '' && $dateTo == '' && $category == '') {
            $totalCount = $oAppCache->getSearchAllCount();
            $doCountAlreadyExecuted = true;
        }
        if ($category != '') {
            $totalCount = $oAppCache->getSearchCountCriteria();
            $doCountAlreadyExecuted = true;
        }
        */
        $tableNameAux = '';
        $totalCount = 0;
        if ($doCountAlreadyExecuted == true) {
            // in the case of reassign the distinct attribute shows a diferent count result comparing to the
            // original list
            //Check also $distinct in the method getListCounters(), this in AppCacheView.php
            $distinct = true;

            if ($action != "sent" && (($action == "todo" || $action == "selfservice" || $action == "unassigned" || $action == "to_reassign" || $action == "to_revise") || ($status == "TO_DO"))) {
                $distinct = false;
            }

            // first check if there is a PMTable defined within the list,
            // the issue that brokes the normal criteria query seems to be fixed
            if (isset( $oAppCache->confCasesList['PMTable'] ) && ! empty( $oAppCache->confCasesList['PMTable'] )) {
                // then
                $oAdditionalTables = AdditionalTablesPeer::retrieveByPK( $oAppCache->confCasesList['PMTable'] );
                $tableName = $oAdditionalTables->getAddTabName();
                $tableNameAux = $tableName;
                $tableName = strtolower( $tableName );
                $tableNameArray = explode( '_', $tableName );
                foreach ($tableNameArray as $item) {
                    $newTableName[] = ucfirst( $item );
                }
                $tableName = implode( '', $newTableName );
                // so the pm table class can be invoqued from the pm table model clases
                if (! class_exists( $tableName )) {
                    require_once (PATH_DB . SYS_SYS . PATH_SEP . "classes" . PATH_SEP . $tableName . ".php");
                }
            }
            $totalCount = AppCacheViewPeer::doCount($CriteriaCount, $distinct);
        }

        //Add sortable options
        $sortBk = $sort;

        if ($sortBk != "") {
            $sort = "";

            //Current delegation (*)
            if (($action == "sent" || $action == "search" || $action == "simple_search" || $action == "to_revise" || $action == "to_reassign") && ($status != "TO_DO")) {
                switch ($sortBk) {
                    case "APP_CACHE_VIEW.APP_CURRENT_USER":
                        $sort = "USRCR_" . $conf->userNameFormatGetFirstFieldByUsersTable();
                        break;
                    case "APP_CACHE_VIEW.APP_TAS_TITLE":
                        $sort = "APPDELCR_APP_TAS_TITLE";
                        break;
                }
            }

            if (isset( $oAppCache->confCasesList['PMTable'] ) && ! empty( $oAppCache->confCasesList['PMTable'] ) && $tableNameAux != '') {
                $sortTable = explode(".", $sortBk);

                $additionalTableUid = $oAppCache->confCasesList["PMTable"];

                require_once 'classes/model/Fields.php';
                $oCriteria = new Criteria('workflow');

                $oCriteria->addSelectColumn(FieldsPeer::FLD_UID);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_INDEX);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_NAME);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_DESCRIPTION);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_TYPE);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_SIZE);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_NULL);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_AUTO_INCREMENT);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_KEY);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_FOREIGN_KEY);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_FOREIGN_KEY_TABLE);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_DYN_NAME);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_DYN_UID);
                $oCriteria->addSelectColumn(FieldsPeer::FLD_FILTER);
                $oCriteria->add(FieldsPeer::ADD_TAB_UID, $additionalTableUid);
                $oCriteria->add(FieldsPeer::FLD_NAME, $sortTable[1]);
                $oCriteria->addAscendingOrderByColumn(FieldsPeer::FLD_INDEX);

                $oDataset = FieldsPeer::doSelectRS($oCriteria);
                $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                $oDataset->next();
                $row = $oDataset->getRow();
                if (is_array($row)) {
                    $sort = $tableNameAux . "." . $sortTable[1];
                }
            }

            if ($sort == "") {
                $sort = $sortBk;
            }

            if (!in_array($sort, $Criteria->getSelectColumns())) {
                $sort = AppCacheViewPeer::APP_NUMBER; //DEFAULT VALUE
            }

            if ($dir == "DESC") {
                $Criteria->addDescendingOrderByColumn($sort);
            } else {
                $Criteria->addAscendingOrderByColumn($sort);
            }
        }

        //limit the results according the interface
        $Criteria->setLimit( $limit );
        $Criteria->setOffset( $start );

        //execute the query
        $oDataset = AppCacheViewPeer::doSelectRS( $Criteria, Propel::getDbConnection('workflow_ro') );

        $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

        $result = array ();
        $result['totalCount'] = $totalCount;
        $rows = array ();
        $aPriorities = array ('1' => 'VL','2' => 'L','3' => 'N','4' => 'H','5' => 'VH');
        $index = $start;

        while ($oDataset->next()) {
            $aRow = $oDataset->getRow();

            //$aRow = $oAppCache->replaceRowUserData($aRow);

            /*
             * For participated cases, we want the last step in the case, not only the last step this user participated. To do that we get every case information again for the last step. (This could be solved by a subquery, but Propel might not support it and subqueries can be slower for larger
             * datasets).
             */
             /*if ($action == 'sent' || $action == 'search') {
             $maxCriteria = new Criteria('workflow');
             $maxCriteria->add(AppCacheViewPeer::APP_UID, $aRow['APP_UID'], Criteria::EQUAL);
             $maxCriteria->addDescendingOrderByColumn(AppCacheViewPeer::DEL_INDEX);
             $maxCriteria->setLimit(1);

             $maxDataset = AppCacheViewPeer::doSelectRS( $maxCriteria );
             $maxDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
             $maxDataset->next();

             $newData = $maxDataset->getRow();
             foreach ($aRow as $col => $value) {
             if (array_key_exists($col, $newData))
             $aRow[$col] = $newData[$col];
             }

             $maxDataset->close();
              }*/

            //Current delegation (*) || $action == "search" || $action == "to_revise"
            if (($action == "sent" || $action == "simple_search" || $action == "to_reassign") && ($status != "TO_DO")) {
                //Current task
                $aRow["APP_TAS_TITLE"] = $aRow["APPDELCR_APP_TAS_TITLE"];

                //Current user
                //if ($action != "to_reassign" ) {
                if (($action != "to_reassign") && ($action != "search") && ($action != "to revise")) {
                    $aRow["USR_UID"] = $aRow["USRCR_USR_UID"];
                    $aRow["USR_FIRSTNAME"] = $aRow["USRCR_USR_FIRSTNAME"];
                    $aRow["USR_LASTNAME"] = $aRow["USRCR_USR_LASTNAME"];
                    $aRow["USR_USERNAME"] = $aRow["USRCR_USR_USERNAME"];
                }
            }

            //Unassigned user
            if (! isset( $aRow['APP_CURRENT_USER'] )) {
                $aRow['APP_CURRENT_USER'] = "******" . strtoupper(G::LoadTranslation("ID_UNASSIGNED")) . "]";
            }

            // replacing the status data with their respective translation
            if (isset( $aRow['APP_STATUS'] )) {
                $aRow['APP_STATUS_LABEL'] = G::LoadTranslation( "ID_{$aRow['APP_STATUS']}" );
            }

            // replacing the priority data with their respective translation
            if (isset( $aRow['DEL_PRIORITY'] )) {
                $aRow['DEL_PRIORITY'] = G::LoadTranslation( "ID_PRIORITY_{$aPriorities[$aRow['DEL_PRIORITY']]}" );
            }

            $rows[] = $aRow;
        }

        $result['data'] = $rows;

        return $result;
    }
Example #11
0
 /**
  * make_site
  *
  * @return array $test
  */
 private function make_site()
 {
     $test = $this->create_site_test();
     if ($test["created"] == true || $this->options["advanced"]["ao_db_drop"] == true) {
         /* Check if the hostname is local (localhost or 127.0.0.1) */
         $islocal = strcmp(substr($this->options['database']['hostname'], 0, strlen('localhost')), 'localhost') === 0 || strcmp(substr($this->options['database']['hostname'], 0, strlen('127.0.0.1')), '127.0.0.1') === 0;
         $this->wf_site_name = $wf = $this->options['advanced']['ao_db_wf'];
         $this->rbac_site_name = $rb = $this->options['advanced']['ao_db_rb'];
         $this->report_site_name = $rp = $this->options['advanced']['ao_db_rp'];
         $schema = "schema.sql";
         $values = "insert.sql";
         if ($this->options['advanced']['ao_db_drop'] === true) {
             //Delete workspace directory if exists
             //Drop databases
             $this->run_query("DROP DATABASE IF EXISTS " . $wf, "Drop database {$wf}");
             $this->run_query("DROP DATABASE IF EXISTS " . $rb, "Drop database {$rb}");
             $this->run_query("DROP DATABASE IF EXISTS " . $rp, "Drop database {$rp}");
         }
         $this->run_query("CREATE DATABASE IF NOT EXISTS " . $wf . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database {$wf}");
         $this->run_query("CREATE DATABASE IF NOT EXISTS " . $rb . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database {$rb}");
         $this->run_query("CREATE DATABASE IF NOT EXISTS " . $rp . " DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci", "Create database {$rp}");
         if ($this->cc_status == 1) {
             $host = $islocal ? "localhost" : "%";
             $this->run_query("GRANT ALL PRIVILEGES ON `{$wf}`.* TO {$wf}@'{$host}' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user {$wf} on database {$wf}");
             $this->run_query("GRANT ALL PRIVILEGES ON `{$rb}`.* TO {$rb}@'{$host}' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user {$rb} on database {$rb}");
             $this->run_query("GRANT ALL PRIVILEGES ON `{$rp}`.* TO {$rp}@'{$host}' IDENTIFIED BY '{$this->options['password']}' WITH GRANT OPTION", "Grant privileges for user {$rp} on database {$rp}");
         }
         /* Dump schema workflow && data  */
         $this->log("Import database schema:\n");
         $myPortA = explode(":", $this->options['database']['hostname']);
         if (count($myPortA) < 2) {
             $myPortA[1] = "3306";
         }
         $myPort = $myPortA[1];
         $this->options['database']['hostname'] = $myPortA[0];
         mysql_select_db($wf, $this->connection_database);
         $pws = PATH_WORKFLOW_MYSQL_DATA . $schema;
         $qws = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $schema, $this->connection_database);
         $this->log($qws, isset($qws['errors']));
         $qwv = $this->query_sql_file(PATH_WORKFLOW_MYSQL_DATA . $values, $this->connection_database);
         $this->log($qwv, isset($qwv['errors']));
         /* Dump schema rbac && data  */
         $pws = PATH_RBAC_MYSQL_DATA . $schema;
         mysql_select_db($rb, $this->connection_database);
         $qrs = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $schema, $this->connection_database);
         $this->log($qrs, isset($qrs['errors']));
         $qrv = $this->query_sql_file(PATH_RBAC_MYSQL_DATA . $values, $this->connection_database);
         $this->log($qrv, isset($qrv['errors']));
         mysql_select_db($wf, $this->connection_database);
         require_once "propel/Propel.php";
         require_once 'classes/model/AppCacheView.php';
         $appCache = new AppCacheView();
         $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup/setupSchemas/');
         $triggers = $appCache->getTriggers("en");
         $this->log("Create 'cases list cache' triggers");
         foreach ($triggers as $triggerName => $trigger) {
             $this->run_query($trigger, "-> Trigger {$triggerName}");
         }
         $path_site = $this->options['path_data'] . "/sites/" . $this->options['name'] . "/";
         $db_file = $path_site . "db.php";
         @mkdir($path_site, 0777, true);
         @mkdir($path_site . "files/", 0777, true);
         @mkdir($path_site . "mailTemplates/", 0777, true);
         @mkdir($path_site . "public/", 0777, true);
         @mkdir($path_site . "reports/", 0777, true);
         @mkdir($path_site . "xmlForms", 0777, true);
         $db_text = "<?php\n" . "// Processmaker configuration\n" . "define ('DB_ADAPTER', 'mysql' );\n" . "define ('DB_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_NAME', '" . $wf . "' );\n" . "define ('DB_USER', '" . ($this->cc_status == 1 ? $wf : $this->options['database']['username']) . "' );\n" . "define ('DB_PASS', '" . ($this->cc_status == 1 ? $this->options['password'] : $this->options['database']['password']) . "' );\n" . "define ('DB_RBAC_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_RBAC_NAME', '" . $rb . "' );\n" . "define ('DB_RBAC_USER', '" . ($this->cc_status == 1 ? $rb : $this->options['database']['username']) . "' );\n" . "define ('DB_RBAC_PASS', '" . ($this->cc_status == 1 ? $this->options['password'] : $this->options['database']['password']) . "' );\n" . "define ('DB_REPORT_HOST', '" . $this->options['database']['hostname'] . ":" . $myPort . "' );\n" . "define ('DB_REPORT_NAME', '" . $rp . "' );\n" . "define ('DB_REPORT_USER', '" . ($this->cc_status == 1 ? $rp : $this->options['database']['username']) . "' );\n" . "define ('DB_REPORT_PASS', '" . ($this->cc_status == 1 ? $this->options['password'] : $this->options['database']['password']) . "' );\n";
         if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {
             $db_text .= "define ('PARTNER_FLAG', " . (defined('PARTNER_FLAG') ? PARTNER_FLAG : (isset($_REQUEST['PARTNER_FLAG']) ? $_REQUEST['PARTNER_FLAG'] : 'false')) . ");\n";
             if (defined('SYSTEM_NAME')) {
                 $db_text .= "  define ('SYSTEM_NAME', '" . SYSTEM_NAME . "');\n";
             }
         }
         $db_text .= "?>";
         $fp = @fopen($db_file, "w");
         $this->log("Create: " . $db_file . "  => " . (!$fp ? $fp : "OK") . "\n", $fp === false);
         $ff = @fputs($fp, $db_text, strlen($db_text));
         $this->log("Write: " . $db_file . "  => " . (!$ff ? $ff : "OK") . "\n", $ff === false);
         fclose($fp);
         $this->setPartner();
         $this->setAdmin();
     }
     return $test;
 }
Example #12
0
    /**
     * Put Set Case Variables
     *
     * @access public
     * @param string $app_uid, Uid for case
     * @param array $app_data, Data for case variables
     * @param string $dyn_uid, Uid for dynaform
     * @param string $usr_uid, Uid for user
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
     */
    public function setCaseVariables($app_uid, $app_data, $dyn_uid = null, $usr_uid)
    {
        Validator::isString($app_uid, '$app_uid');
        Validator::appUid($app_uid, '$app_uid');
        Validator::isArray($app_data, '$app_data');
        Validator::isString($usr_uid, '$usr_uid');
        Validator::usrUid($usr_uid, '$usr_uid');

        $arrayResult = $this->getStatusInfo($app_uid);

        if ($arrayResult["APP_STATUS"] == "CANCELLED") {
            throw new \Exception(\G::LoadTranslation("ID_CASE_CANCELLED", array($app_uid)));
        }

        if ($arrayResult["APP_STATUS"] == "COMPLETED") {
            throw new \Exception(\G::LoadTranslation("ID_CASE_IS_COMPLETED", array($app_uid)));
        }

        $appCacheView = new \AppCacheView();
        $isProcessSupervisor = $appCacheView->getProUidSupervisor($usr_uid);
        $criteria = new \Criteria("workflow");
        $criteria->addSelectColumn(\AppDelegationPeer::APP_UID);
        $criteria->add(\AppDelegationPeer::APP_UID, $app_uid, \Criteria::EQUAL);
        $criteria->add(\AppDelegationPeer::USR_UID, $usr_uid, \Criteria::EQUAL);
        $criteria->add(
            $criteria->getNewCriterion(\AppDelegationPeer::USR_UID, $usr_uid, \Criteria::EQUAL)->addOr(
            $criteria->getNewCriterion(\AppDelegationPeer::PRO_UID, $isProcessSupervisor, \Criteria::IN))
        );
        $rsCriteria = \AppDelegationPeer::doSelectRS($criteria);

        if (!$rsCriteria->next()) {
            throw (new \Exception(\G::LoadTranslation("ID_NO_PERMISSION_NO_PARTICIPATED", array($usr_uid))));
        }

        $_SESSION['APPLICATION'] = $app_uid;
        $_SESSION['USER_LOGGED'] = $usr_uid;

        $case = new \Cases();
        $fields = $case->loadCase($app_uid);
        $_POST['form'] = $app_data;

        if (!is_null($dyn_uid) && $dyn_uid != '') {
            $oDynaform = \DynaformPeer::retrieveByPK($dyn_uid);

            if ($oDynaform->getDynVersion() < 2) {
                $oForm = new \Form ( $fields['PRO_UID'] . "/" . $dyn_uid, PATH_DYNAFORM );
                $oForm->validatePost();
            }
        }

        $data['APP_DATA'] = array_merge($fields['APP_DATA'], $_POST['form']);
        $case->updateCase($app_uid, $data);
    }
Example #13
0
 /**
  * Upgrade the AppCacheView table to the latest system version.
  *
  * This recreates the table and populates with data.
  *
  * @param bool $checkOnly only check if the upgrade is needed if true
  * @param string $lang not currently used
  */
 public function upgradeCacheView($fill = true, $checkOnly = false, $lang = "en")
 {
     $this->initPropel(true);
     //require_once ('classes/model/AppCacheView.php');
     //check the language, if no info in config about language, the default is 'en'
     G::LoadClass("configuration");
     $oConf = new Configurations();
     $oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', '');
     $appCacheViewEngine = $oConf->aConfig;
     //setup the appcacheview object, and the path for the sql files
     $appCache = new AppCacheView();
     $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP);
     $userGrants = $appCache->checkGrantsForUser(false);
     $currentUser = $userGrants['user'];
     $currentUserIsSuper = $userGrants['super'];
     //if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user.
     if (!$currentUserIsSuper) {
         $appCache->checkGrantsForUser(true);
         $appCache->setSuperForUser($currentUser);
         $currentUserIsSuper = true;
     }
     CLI::logging("-> Creating table\n");
     //now check if table APPCACHEVIEW exists, and it have correct number of fields, etc.
     $res = $appCache->checkAppCacheView();
     CLI::logging("-> Update DEL_LAST_INDEX field in APP_DELEGATION table\n");
     //Update APP_DELEGATION.DEL_LAST_INDEX data
     $res = $appCache->updateAppDelegationDelLastIndex($lang, $checkOnly);
     CLI::logging("-> Verifying roles permissions in RBAC \n");
     //Update table RBAC permissions
     Bootstrap::LoadSystem('rbac');
     $RBAC =& RBAC::getSingleton();
     $RBAC->initRBAC();
     $result = $RBAC->verifyPermissions();
     if (count($result) > 1) {
         foreach ($result as $item) {
             CLI::logging("    {$item}... \n");
         }
     } else {
         CLI::logging("    All roles permissions already updated \n");
     }
     CLI::logging("-> Creating triggers\n");
     //now check if we have the triggers installed
     $triggers = array();
     $triggers[] = $appCache->triggerAppDelegationInsert($lang, $checkOnly);
     $triggers[] = $appCache->triggerAppDelegationUpdate($lang, $checkOnly);
     $triggers[] = $appCache->triggerApplicationUpdate($lang, $checkOnly);
     $triggers[] = $appCache->triggerApplicationDelete($lang, $checkOnly);
     $triggers[] = $appCache->triggerSubApplicationInsert($lang, $checkOnly);
     $triggers[] = $appCache->triggerContentUpdate($lang, $checkOnly);
     if ($fill) {
         CLI::logging("-> Rebuild Cache View with language {$lang}...\n");
         //build using the method in AppCacheView Class
         $res = $appCache->fillAppCacheView($lang);
         //set status in config table
         $confParams = array('LANG' => $lang, 'STATUS' => 'active');
     }
     $oConf->aConfig = $confParams;
     $oConf->saveConfig('APP_CACHE_VIEW_ENGINE', '', '', '');
     // removing casesList configuration records. TODO: removing these lines that resets all the configurations records
     $oCriteria = new Criteria();
     $oCriteria->add(ConfigurationPeer::CFG_UID, "casesList");
     $oCriteria->add(ConfigurationPeer::OBJ_UID, array("todo", "draft", "sent", "unassigned", "paused", "cancelled"), Criteria::NOT_IN);
     ConfigurationPeer::doDelete($oCriteria);
     // end of reset
 }
Example #14
0
    public function createMySQLWorkspace ()

    {

        G::LoadSystem('inputfilter');

        $filter = new InputFilter();

        ini_set( 'max_execution_time', '0' );

        $info = new StdClass();

        $info->result = false;

        $info->message = '';

        $info->canRedirect = true;



        $db_hostname = trim( $_REQUEST['db_hostname'] );

        $db_port = trim( $_REQUEST['db_port'] );

        $db_port = $filter->validateInput($db_port);

        $db_username = trim( $_REQUEST['db_username'] );

        $db_username = $filter->validateInput($db_username);

        $db_password = trim( $_REQUEST['db_password'] );

        $db_password = $filter->validateInput($db_password);

        $wf = trim( $_REQUEST['wfDatabase'] );

        $rb = trim( $_REQUEST['wfDatabase'] );

        $rp = trim( $_REQUEST['wfDatabase'] );

        $workspace = trim( $_REQUEST['workspace'] );

        $pathConfig = trim( $_REQUEST['pathConfig'] );

        $pathLanguages = trim( $_REQUEST['pathLanguages'] );

        $pathPlugins = trim( $_REQUEST['pathPlugins'] );

        $pathShared = trim( $_REQUEST['pathShared'] );

        $pathXmlforms = trim( $_REQUEST['pathXmlforms'] );

        $adminPassword = trim( $_REQUEST['adminPassword'] );

        $adminPassword = $filter->validateInput($adminPassword);

        $adminUsername = trim( $_REQUEST['adminUsername'] );

        $adminUsername = $filter->validateInput($adminUsername);

        $deleteDB = ($_REQUEST['deleteDB'] == 'true');

        $userLogged = (isset($_REQUEST['userLogged']) ? ($_REQUEST['userLogged'] == 'true') : false);

        $userLogged = $filter->validateInput($userLogged);



        if (substr( $pathShared, - 1 ) != '/') {

            $pathShared .= '/';

        }



        $this->installLog( '-------------------------------------------' );

        $this->installLog( G::LoadTranslation('ID_CREATING_WORKSPACE', SYS_LANG, Array($workspace)));



        try {

            $db_host = ($db_port != '' && $db_port != 3306) ? $db_hostname . ':' . $db_port : $db_hostname;

            $db_host = $filter->validateInput($db_host);

            $db_username = $filter->validateInput($db_username);

            $db_password = $filter->validateInput($db_password);

            $this->link = @mysql_connect( $db_host, $db_username, $db_password );

            $this->installLog( G::LoadTranslation('ID_CONNECT_TO_SERVER', SYS_LANG, Array($db_hostname, $db_port, $db_username ) ));



            if ($deleteDB) {

                $q = sprintf( 'DROP DATABASE IF EXISTS %s;', $wf, $wf );

                $this->mysqlQuery( $q );

            }



            // CREATE databases wf_workflow, rb_workflow and rp_workflow

            $q = sprintf( 'CREATE DATABASE IF NOT EXISTS %s;', $wf, $wf );

            $this->mysqlQuery( $q );



            // CREATE users and GRANT Privileges

            $wf_workpace = $wf;

            $rb_workpace = $wf;

            $rp_workpace = $wf;

            if (!$userLogged) {

                $wfPass = G::generate_password( 12 );

                $this->setGrantPrivilegesMySQL( $wf, $wfPass, $wf, $db_hostname );

                $this->setGrantPrivilegesMySQL( $rb, $wfPass, $wf, $db_hostname );

                $this->setGrantPrivilegesMySQL( $rp, $wfPass, $wf, $db_hostname );

            } else {

                $wfPass = $db_password;

                $rbPass = $db_password;

                $rpPass = $db_password;

                $wf = $db_username;

                $rb = $db_username;

                $rp = $db_username;

            }





            // Generate the db.php file and folders

            $pathSharedSites = $pathShared;

            $path_site = $pathShared . "/sites/" . $workspace . "/";

            $db_file = $path_site . "db.php";

            @mkdir( $path_site, 0777, true );

            @mkdir( $path_site . "files/", 0777, true );

            @mkdir( $path_site . "mailTemplates/", 0777, true );

            @mkdir( $path_site . "public/", 0777, true );

            @mkdir( $path_site . "reports/", 0777, true );

            @mkdir( $path_site . "xmlForms", 0777, true );



            $dbText = "<?php\n";

            $dbText .= sprintf( "// Processmaker configuration\n" );

            $dbText .= sprintf( "  define ('DB_ADAPTER',     '%s' );\n", 'mysql' );

            $dbText .= sprintf( "  define ('DB_HOST',        '%s' );\n", $db_host );

            $dbText .= sprintf( "  define ('DB_NAME',        '%s' );\n", $wf_workpace );

            $dbText .= sprintf( "  define ('DB_USER',        '%s' );\n", $wf );

            $dbText .= sprintf( "  define ('DB_PASS',        '%s' );\n", $wfPass );

            $dbText .= sprintf( "  define ('DB_RBAC_HOST',   '%s' );\n", $db_host );

            $dbText .= sprintf( "  define ('DB_RBAC_NAME',   '%s' );\n", $wf_workpace );

            $dbText .= sprintf( "  define ('DB_RBAC_USER',   '%s' );\n", $wf );

            $dbText .= sprintf( "  define ('DB_RBAC_PASS',   '%s' );\n", $wfPass );

            $dbText .= sprintf( "  define ('DB_REPORT_HOST', '%s' );\n", $db_host );

            $dbText .= sprintf( "  define ('DB_REPORT_NAME', '%s' );\n", $wf_workpace );

            $dbText .= sprintf( "  define ('DB_REPORT_USER', '%s' );\n", $wf );

            $dbText .= sprintf( "  define ('DB_REPORT_PASS', '%s' );\n", $wfPass );



            if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {

                $dbText .= "\n";

                $dbText .= "  define ('PARTNER_FLAG', " . ((defined('PARTNER_FLAG')) ? PARTNER_FLAG : ((isset($_REQUEST['PARTNER_FLAG'])) ? $_REQUEST['PARTNER_FLAG']:'false')) . ");\n";

                if ($this->systemName != '') {

                    $dbText .= "  define ('SYSTEM_NAME', '" . $this->systemName . "');\n";

                }

            }



            $this->installLog( G::LoadTranslation('ID_CREATING', SYS_LANG, Array($db_file) ));

            file_put_contents( $db_file, $dbText );



            // Generate the databases.php file

            $databases_file = $path_site . 'databases.php';

            $dbData = sprintf( "\$dbAdapter    = '%s';\n", 'mysql' );

            $dbData .= sprintf( "\$dbHost       = '%s';\n", $db_host );

            $dbData .= sprintf( "\$dbName       = '%s';\n", $wf_workpace );

            $dbData .= sprintf( "\$dbUser       = '******';\n", $wf );

            $dbData .= sprintf( "\$dbPass       = '******';\n", $wfPass );

            $dbData .= sprintf( "\$dbRbacHost   = '%s';\n", $db_host );

            $dbData .= sprintf( "\$dbRbacName   = '%s';\n", $wf_workpace );

            $dbData .= sprintf( "\$dbRbacUser   = '******';\n", $wf );

            $dbData .= sprintf( "\$dbRbacPass   = '******';\n", $wfPass );

            $dbData .= sprintf( "\$dbReportHost = '%s';\n", $db_host );

            $dbData .= sprintf( "\$dbReportName = '%s';\n", $wf_workpace );

            $dbData .= sprintf( "\$dbReportUser = '******';\n", $wf );

            $dbData .= sprintf( "\$dbReportPass = '******';\n", $wfPass );

            $databasesText = str_replace( '{dbData}', $dbData, @file_get_contents( PATH_HOME . 'engine/templates/installer/databases.tpl' ) );



            $this->installLog( G::LoadTranslation('ID_CREATING', SYS_LANG, Array($databases_file) ));

            file_put_contents( $databases_file, $databasesText );



            // Execute scripts to create and populates databases

            $query = sprintf( "USE %s;", $wf_workpace );

            $this->mysqlQuery( $query );



            $this->mysqlFileQuery( PATH_RBAC_HOME . 'engine/data/mysql/schema.sql' );

            $this->mysqlFileQuery( PATH_RBAC_HOME . 'engine/data/mysql/insert.sql' );

            

            $query = sprintf( "USE %s;", $wf_workpace );

            $this->mysqlQuery( $query );

            $this->mysqlFileQuery( PATH_HOME . 'engine/data/mysql/schema.sql' );

            $this->mysqlFileQuery( PATH_HOME . 'engine/data/mysql/insert.sql' );

            



            if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {

                $this->setPartner();

                //$this->setConfiguration();

            }



            // Create the triggers

            if (file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql' ) && file_exists( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql' )) {

                $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql' ) );

                $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql' ) );

                $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql' ) );

                $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql' ) );

                $this->mysqlQuery(@file_get_contents(PATH_HOME . "engine/methods/setup/setupSchemas/triggerSubApplicationInsert.sql"));

                $this->mysqlQuery( @file_get_contents( PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql' ) );



                $this->mysqlQuery( "INSERT INTO `CONFIGURATION` (

                            `CFG_UID`,

                            `CFG_VALUE`

                           )

                           VALUES (

                             'APP_CACHE_VIEW_ENGINE',

                             '" . mysql_real_escape_string( serialize( array ('LANG' => 'en','STATUS' => 'active'

                ) ) ) . "'

                           )" );



                $this->mysqlQuery("INSERT INTO EMAIL_SERVER(MESS_UID, MESS_ENGINE) VALUES('" . \ProcessMaker\Util\Common::generateUID() . "', 'MAIL')");

            }



            // Change admin user

            $query = sprintf( "USE %s;", $wf_workpace );

            $this->mysqlQuery( $query );



            $query = sprintf( "UPDATE USERS SET USR_USERNAME = '******', USR_LASTNAME = '%s', USR_PASSWORD = '******' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, $adminUsername, G::encryptOld( $adminPassword ) );

            $this->mysqlQuery( $query );



            $query = sprintf( "UPDATE RBAC_USERS SET USR_USERNAME = '******', USR_LASTNAME = '%s', USR_PASSWORD = '******' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, $adminUsername, G::encryptOld( $adminPassword ) );

            $this->mysqlQuery( $query );



            // Write the paths_installed.php file (contains all the information configured so far)

            if (! file_exists( FILE_PATHS_INSTALLED )) {

                $sh = G::encryptOld( filemtime( PATH_GULLIVER . '/class.g.php' ) );

                $h = G::encrypt( $db_hostname . $sh . $db_username . $sh . $db_password, $sh );

                $dbText = "<?php\n";

                $dbText .= sprintf( "  define('PATH_DATA',         '%s');\n", $pathShared );

                $dbText .= sprintf( "  define('PATH_C',            '%s');\n", $pathShared . 'compiled/' );

                $dbText .= sprintf( "  define('HASH_INSTALLATION', '%s');\n", $h );

                $dbText .= sprintf( "  define('SYSTEM_HASH',       '%s');\n", $sh );

                $this->installLog( G::LoadTranslation('ID_CREATING', SYS_LANG, Array(FILE_PATHS_INSTALLED) ));

                file_put_contents( FILE_PATHS_INSTALLED, $dbText );

            }



            /**

             * AppCacheView Build

             */

            define( 'HASH_INSTALLATION', $h );

            define( 'SYSTEM_HASH', $sh );

            define( 'PATH_DB', $pathShared . 'sites' . PATH_SEP );

            define( 'SYS_SYS', $workspace );



            require_once ("propel/Propel.php");



            Propel::init( PATH_CORE . "config/databases.php" );

            $con = Propel::getConnection( 'workflow' );



            require_once ('classes/model/AppCacheView.php');

            $lang = 'en';



            //setup the appcacheview object, and the path for the sql files

            $appCache = new AppCacheView();



            $appCache->setPathToAppCacheFiles( PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP );



            //Update APP_DELEGATION.DEL_LAST_INDEX data

            $res = $appCache->updateAppDelegationDelLastIndex($lang, true);



            //APP_DELEGATION INSERT

            $res = $appCache->triggerAppDelegationInsert( $lang, true );



            //APP_DELEGATION Update

            $res = $appCache->triggerAppDelegationUpdate( $lang, true );



            //APPLICATION UPDATE

            $res = $appCache->triggerApplicationUpdate( $lang, true );



            //APPLICATION DELETE

            $res = $appCache->triggerApplicationDelete( $lang, true );



            //SUB_APPLICATION INSERT

            $res = $appCache->triggerSubApplicationInsert($lang, false);



            //CONTENT UPDATE

            $res = $appCache->triggerContentUpdate( $lang, true );



            //build using the method in AppCacheView Class

            $res = $appCache->fillAppCacheView( $lang );



            //end AppCacheView Build





            //erik: for new env conf handling

            G::loadClass( 'system' );

            $envFile = PATH_CONFIG . 'env.ini';



            // getting configuration from env.ini

            $sysConf = System::getSystemConfiguration( $envFile );



            $langUri = 'en';

            if (isset($sysConf['default_lang'])) {

                $langUri = $sysConf['default_lang'];

            }



            $skinUri = 'neoclassic';

            if (isset($sysConf['default_skin'])) {

                $skinUri = $sysConf['default_skin'];

            }



            $updatedConf['default_lang'] = $langUri;

            $updatedConf['default_skin'] = $skinUri;

            $info->uri =  PATH_SEP . 'sys' . $_REQUEST['workspace'] . PATH_SEP . $langUri . PATH_SEP . $skinUri . PATH_SEP . 'login' . PATH_SEP . 'login';



            //register PMDesigner Client

            $http = (G::is_https() == true) ? 'https' : 'http';

            $host = $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '');



            $endpoint = sprintf(

                '%s://%s/sys%s/%s/%s/oauth2/grant',

                $http,

                $host,

                $workspace,

                $langUri,

                $skinUri

            );



            // inserting the outh_client

            if (!$userLogged) {

                $query = sprintf( "USE %s;", $wf );

            } else {

                $query = sprintf( "USE %s;", trim( $_REQUEST['wfDatabase']) );

            }

            $this->mysqlQuery( $query );

            $query = ( "INSERT INTO OAUTH_CLIENTS (CLIENT_ID,CLIENT_SECRET,CLIENT_NAME,CLIENT_DESCRIPTION,CLIENT_WEBSITE,REDIRECT_URI,USR_UID ) VALUES

                ('x-pm-local-client','179ad45c6ce2cb97cf1029e212046e81','PM Web Designer','ProcessMaker Web Designer App','www.processmaker.com','" . $endpoint . "','00000000000000000000000000000001' )");

            $this->mysqlQuery( $query );



            $indexFileUpdated = true;

            if (defined('PARTNER_FLAG') || isset($_REQUEST['PARTNER_FLAG'])) {

                $this->buildParternExtras($adminUsername, $adminPassword, $_REQUEST['workspace'], $langUri, $skinUri);

            } else {

                try {

                    G::update_php_ini( $envFile, $updatedConf );

                } catch (Exception $e) {

                    $info->result = false;

                    $info->message = G::LoadTranslation('ID_PROCESSMAKER_WRITE_CONFIG_INDEX', SYS_LANG, Array($envFile));

                    $info->message .= G::LoadTranslation('ID_PROCESSMAKER_UI_NOT_INSTALL');

                    $this->installLog( G::LoadTranslation('ID_INSTALL_BUT_ERROR', SYS_LANG, Array('env.ini')));

                    return $info;

                }



                try {

                    // update the main index file

                    $indexFileUpdated = System::updateIndexFile(array('lang' => 'en','skin' => $updatedConf['default_skin']));

                } catch (Exception $e) {

                    $info->result = false;

                    $info->message = G::LoadTranslation('ID_PROCESSMAKER_WRITE_CONFIG_INDEX', SYS_LANG, Array(PATH_HTML . "index.html."));

                    $info->message .= G::LoadTranslation('ID_PROCESSMAKER_UI_NOT_INSTALL');

                    $this->installLog( G::LoadTranslation('ID_INSTALL_BUT_ERROR', SYS_LANG, Array('index.html')));

                    return $info;

                }

            }



            $this->installLog( G::LoadTranslation('ID_INDEX_FILE_UPDATED', SYS_LANG, Array($indexFileUpdated, $sysConf['default_lang'],$sysConf['default_skin'])));

            $this->installLog( G::LoadTranslation('ID_INSTALL_SUCESS') );



            $info->result = true;

            $info->message = G::LoadTranslation('ID_INSTALL_SUCESS');

            $info->messageFinish = G::LoadTranslation('ID_PROCESSMAKER_SUCCESS_INSTALLED', SYS_LANG, Array($workspace));;

        } catch (Exception $e) {

            $info->canRedirect = false;

            $info->result = false;

            $info->message = $e->getMessage();

        }

        return $info;

    }
Example #15
0
function executeUpdateAppTitle()
{
    try {
        global $sFilter;
        if ($sFilter != "" && strpos($sFilter, "update-case-labels") === false) {
            return false;
        }
        $criteriaConf = new Criteria("workflow");
        $criteriaConf->addSelectColumn(ConfigurationPeer::OBJ_UID);
        $criteriaConf->addSelectColumn(ConfigurationPeer::CFG_VALUE);
        $criteriaConf->add(ConfigurationPeer::CFG_UID, "TAS_APP_TITLE_UPDATE");
        $rsCriteriaConf = ConfigurationPeer::doSelectRS($criteriaConf);
        $rsCriteriaConf->setFetchmode(ResultSet::FETCHMODE_ASSOC);
        setExecutionMessage("Update case labels");
        saveLog("updateCaseLabels", "action", "Update case labels", "c");
        while ($rsCriteriaConf->next()) {
            $row = $rsCriteriaConf->getRow();
            $taskUid = $row["OBJ_UID"];
            $lang = $row["CFG_VALUE"];
            //Update case labels
            $appcv = new AppCacheView();
            $appcv->appTitleByTaskCaseLabelUpdate($taskUid, $lang, 1);
            //Delete record
            $criteria = new Criteria("workflow");
            $criteria->add(ConfigurationPeer::CFG_UID, "TAS_APP_TITLE_UPDATE");
            $criteria->add(ConfigurationPeer::OBJ_UID, $taskUid);
            $criteria->add(ConfigurationPeer::CFG_VALUE, $lang);
            $numRowDeleted = ConfigurationPeer::doDelete($criteria);
            saveLog("updateCaseLabels", "action", "OK Task {$taskUid}");
        }
        setExecutionResultMessage("DONE");
    } catch (Exception $e) {
        setExecutionResultMessage("WITH ERRORS", "error");
        eprintln("  '-" . $e->getMessage(), "red");
        saveLog("updateCaseLabels", "error", "Error updating case labels: " . $e->getMessage());
    }
}
Example #16
0
    /**

     * Migrate all cases to New list

     *

     * return all LIST TABLES with data

     */

    public function migrateList ($workSpace)

    {

        if ($this->listFirstExecution('check')) {

            return 1;

        }

        $this->initPropel(true);

        $appCache = new AppCacheView();

        $users    = new Users();

        G::LoadClass("case");

        $case = new Cases();



        //Select data CANCELLED

        $canCriteria = $appCache->getSelAllColumns();

        $canCriteria->add(AppCacheViewPeer::APP_STATUS, "CANCELLED", CRITERIA::EQUAL);

        $canCriteria->add(AppCacheViewPeer::DEL_LAST_INDEX, "1", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($canCriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        //Insert data LIST_CANCELED

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $listCanceled = new ListCanceled();

              $listCanceled->remove($row["APP_UID"]);

              $listCanceled->setDeleted(false);

              $listCanceled->create($row);

        }

        CLI::logging("> Completed table LIST_CANCELED\n");



        //Select data COMPLETED

        $comCriteria = $appCache->getSelAllColumns();

        $comCriteria->add(AppCacheViewPeer::APP_STATUS, "COMPLETED", CRITERIA::EQUAL);

        $comCriteria->add(AppCacheViewPeer::DEL_LAST_INDEX, "1", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($comCriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        //Insert new data LIST_COMPLETED

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $listCompleted = new ListCompleted();

              $listCompleted->remove($row["APP_UID"]);

              $listCompleted->setDeleted(false);

              $listCompleted->create($row);

        }

        CLI::logging("> Completed table LIST_COMPLETED\n");



        //Select data TO_DO OR DRAFT

        $inbCriteria = $appCache->getSelAllColumns();

        $rsCriteria = AppCacheViewPeer::doSelectRS($inbCriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);



        $criteriaUser = new Criteria();

        $criteriaUser->addSelectColumn( UsersPeer::USR_UID );

        $criteriaUser->addSelectColumn( UsersPeer::USR_FIRSTNAME );

        $criteriaUser->addSelectColumn( UsersPeer::USR_LASTNAME );

        $criteriaUser->addSelectColumn( UsersPeer::USR_USERNAME );

        //Insert new data LIST_INBOX

        while ($rsCriteria->next()) {

            $row = $rsCriteria->getRow();

            $isSelfService = ($row['USR_UID'] == '') ? true : false;

            if($row["DEL_THREAD_STATUS"] == 'OPEN'){

                //Update information about the previous_user

                $row["DEL_PREVIOUS_USR_UID"] = $row["PREVIOUS_USR_UID"];

                $criteriaUser->add( UsersPeer::USR_UID, $row["PREVIOUS_USR_UID"] );

                $datasetU = UsersPeer::doSelectRS($criteriaUser);

                $datasetU->setFetchmode(ResultSet::FETCHMODE_ASSOC);

                $datasetU->next();

                $arrayUsers = $datasetU->getRow();

                $row["DEL_PREVIOUS_USR_USERNAME"] = $arrayUsers["USR_USERNAME"];

                $row["DEL_PREVIOUS_USR_FIRSTNAME"]= $arrayUsers["USR_FIRSTNAME"];

                $row["DEL_PREVIOUS_USR_LASTNAME"] = $arrayUsers["USR_LASTNAME"];

                //Update the due date

                $row["DEL_DUE_DATE"]         = $row["DEL_TASK_DUE_DATE"];

                $listInbox = new ListInbox();

                $listInbox->remove($row["APP_UID"],$row["DEL_INDEX"]);

                $listInbox->setDeleted(false);

                $listInbox->create($row, $isSelfService);

            } else {

                // create participated List when the thread is CLOSED

                $listParticipatedHistory = new ListParticipatedHistory();

                $listParticipatedHistory->remove($row['APP_UID'], $row['DEL_INDEX']);

                $listParticipatedHistory = new ListParticipatedHistory();

                $listParticipatedHistory->create($row);



                $oCriteria = new Criteria('workflow');

                $oCriteria->add(ListParticipatedLastPeer::APP_UID, $row['APP_UID']);

                $oCriteria->add(ListParticipatedLastPeer::USR_UID, $row['USR_UID']);

                ListParticipatedLastPeer::doDelete($oCriteria);



                $listParticipatedLast = new ListParticipatedLast();

                $listParticipatedLast->create($row);

                $listParticipatedLast = new ListParticipatedLast();

                $listParticipatedLast->refresh($row);

            }



        }



        CLI::logging("> Completed table LIST_INBOX\n");

        //With this List is populated the LIST_PARTICIPATED_HISTORY and LIST_PARTICIPATED_LAST

        CLI::logging("> Completed table LIST_PARTICIPATED_HISTORY\n");

        CLI::logging("> Completed table LIST_PARTICIPATED_LAST\n");



        //Select data TO_DO OR DRAFT CASES CREATED BY AN USER

        $myiCriteria = $appCache->getSelAllColumns();

        $myiCriteria->add(AppCacheViewPeer::DEL_INDEX, "1", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($myiCriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        //Insert new data LIST_MY_INBOX

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $listMyInbox = new ListMyInbox();

              $listMyInbox ->remove($row["APP_UID"],$row["USR_UID"]);

              $listMyInbox->setDeleted(false);

              $listMyInbox->create($row);

        }

        CLI::logging("> Completed table LIST_MY_INBOX\n");



        //Select data PAUSED

        $delaycriteria = new Criteria("workflow");

        $delaycriteria->addSelectColumn(AppDelayPeer::APP_UID);

        $delaycriteria->addSelectColumn(AppDelayPeer::PRO_UID);

        $delaycriteria->addSelectColumn(AppDelayPeer::APP_DEL_INDEX);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::APP_NUMBER);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::USR_UID);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::APP_STATUS);

        $delaycriteria->addSelectColumn(AppCacheViewPeer::TAS_UID);



        $delaycriteria->addJoin( AppCacheViewPeer::APP_UID, AppDelayPeer::APP_UID . ' AND ' . AppCacheViewPeer::DEL_INDEX . ' = ' . AppDelayPeer::APP_DEL_INDEX, Criteria::INNER_JOIN );

        $delaycriteria->add(AppDelayPeer::APP_DISABLE_ACTION_USER, "0", CRITERIA::EQUAL);

        $delaycriteria->add(AppDelayPeer::APP_TYPE, "PAUSE", CRITERIA::EQUAL);

        $rsCriteria = AppDelayPeer::doSelectRS($delaycriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        //Insert new data LIST_PAUSED

        while ($rsCriteria->next()) {

              $row = $rsCriteria->getRow();

              $data = $row;

              $data["DEL_INDEX"] = $row["APP_DEL_INDEX"];

              $listPaused = new ListPaused();

              $listPaused ->remove($row["APP_UID"],$row["APP_DEL_INDEX"],$data);

              $listPaused->setDeleted(false);

              $listPaused->create($data);

        }

        CLI::logging("> Completed table LIST_PAUSED\n");



        //Select and Insert LIST_UNASSIGNED

        $unaCriteria = $appCache->getSelAllColumns();

        $unaCriteria->add(AppCacheViewPeer::USR_UID, "", CRITERIA::EQUAL);

        $rsCriteria = AppCacheViewPeer::doSelectRS($unaCriteria);

        $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        $del = new ListUnassignedPeer();

        $del->doDeleteAll();

        $del = new ListUnassignedGroupPeer();

        $del->doDeleteAll();

        while ($rsCriteria->next()) {

            $row = $rsCriteria->getRow();

            $listUnassigned = new ListUnassigned();

            $unaUid = $listUnassigned->generateData($row["APP_UID"],$row["PREVIOUS_USR_UID"]);

        }

        CLI::logging("> Completed table LIST_UNASSIGNED\n");

        CLI::logging("> Completed table LIST_UNASSIGNED_GROUP\n");



        // ADD LISTS COUNTS

        $aTypes = array(

            'to_do',

            'draft',

            'cancelled',

            'sent',

            'paused',

            'completed',

            'selfservice'

        );



        $users = new Users();

        $criteria = new Criteria();

        $criteria->addSelectColumn(UsersPeer::USR_UID);

        $dataset = UsersPeer::doSelectRS($criteria);

        $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);

        while($dataset->next()) {

            $aRow = $dataset->getRow();

            $oAppCache = new AppCacheView();

            $aCount = $oAppCache->getAllCounters( $aTypes, $aRow['USR_UID'] );

            $newData = array(

                'USR_UID'                   => $aRow['USR_UID'],

                'USR_TOTAL_INBOX'           => $aCount['to_do'],

                'USR_TOTAL_DRAFT'           => $aCount['draft'],

                'USR_TOTAL_CANCELLED'       => $aCount['cancelled'],

                'USR_TOTAL_PARTICIPATED'    => $aCount['sent'],

                'USR_TOTAL_PAUSED'          => $aCount['paused'],

                'USR_TOTAL_COMPLETED'       => $aCount['completed'],

                'USR_TOTAL_UNASSIGNED'      => $aCount['selfservice']

            );

            $users->update($newData);

        }

        $this->listFirstExecution('insert');

        return true;

    }
function getProcessArray($action, $userUid)
{
    $processes = array();
    $processes[] = array("", G::LoadTranslation("ID_ALL_PROCESS"));

    switch ($action) {
        case "simple_search":
        case "search":
            //In search action, the query to obtain all process is too slow, so we need to query directly to
            //process and content tables, and for that reason we need the current language in AppCacheView.
            G::loadClass("configuration");
            $oConf = new Configurations;
            $oConf->loadConfig($x, "APP_CACHE_VIEW_ENGINE", "", "", "", "");
            $appCacheViewEngine = $oConf->aConfig;
            $lang = isset($appCacheViewEngine["LANG"])? $appCacheViewEngine["LANG"] : "en";

            $cProcess = new Criteria("workflow");
            $cProcess->clearSelectColumns();
            $cProcess->addSelectColumn(ProcessPeer::PRO_UID);
            $cProcess->addSelectColumn(ContentPeer::CON_VALUE);

            $del = DBAdapter::getStringDelimiter();

            $conds = array();
            $conds[] = array(ProcessPeer::PRO_UID,      ContentPeer::CON_ID);
            $conds[] = array(ContentPeer::CON_CATEGORY, $del . "PRO_TITLE" . $del);
            $conds[] = array(ContentPeer::CON_LANG,     $del . $lang . $del);
            $cProcess->addJoinMC($conds, Criteria::LEFT_JOIN);
            $cProcess->add(ProcessPeer::PRO_STATUS, "ACTIVE");
            $oDataset = ProcessPeer::doSelectRS($cProcess);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);

            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $processes[] = array($aRow["PRO_UID"], $aRow["CON_VALUE"]);
                $oDataset->next();
            }

            return ($processes);
            break;
        case "consolidated":
        default:
            $oAppCache = new AppCacheView();
            $cProcess = $oAppCache->getToDoListCriteria($userUid); //fast enough
            break;
    }

    $cProcess->clearSelectColumns();
    $cProcess->setDistinct();
    $cProcess->addSelectColumn(AppCacheViewPeer::PRO_UID);
    $cProcess->addSelectColumn(AppCacheViewPeer::APP_PRO_TITLE);
    $oDataset = AppCacheViewPeer::doSelectRS($cProcess);
    $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
    $oDataset->next();

    while ($aRow = $oDataset->getRow()) {
        $processes[] = array($aRow["PRO_UID"], $aRow["APP_PRO_TITLE"]);
        $oDataset->next();
    }

    return ($processes);
}
 /**
  * Upgrade the AppCacheView table to the latest system version.
  *
  * This recreates the table and populates with data.
  *
  * @param bool $checkOnly only check if the upgrade is needed if true
  * @param string $lang not currently used
  */
 public function upgradeCacheView($fill = true)
 {
     $this->initPropel(true);
     $lang = "en";
     require_once 'classes/model/AppCacheView.php';
     //check the language, if no info in config about language, the default is 'en'
     G::loadClass('configuration');
     $oConf = new Configurations();
     $oConf->loadConfig($x, 'APP_CACHE_VIEW_ENGINE', '', '', '', '');
     $appCacheViewEngine = $oConf->aConfig;
     //setup the appcacheview object, and the path for the sql files
     $appCache = new AppCacheView();
     $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP);
     $userGrants = $appCache->checkGrantsForUser(false);
     $currentUser = $userGrants['user'];
     $currentUserIsSuper = $userGrants['super'];
     //if user does not have the SUPER privilege we need to use the root user and grant the SUPER priv. to normal user.
     if (!$currentUserIsSuper) {
         $appCache->checkGrantsForUser(true);
         $appCache->setSuperForUser($currentUser);
         $currentUserIsSuper = true;
     }
     CLI::logging("-> Creating table\n");
     //now check if table APPCACHEVIEW exists, and it have correct number of fields, etc.
     $res = $appCache->checkAppCacheView();
     CLI::logging("-> Creating triggers\n");
     //now check if we have the triggers installed
     $triggers = array();
     $triggers[] = $appCache->triggerAppDelegationInsert($lang, $checkOnly);
     $triggers[] = $appCache->triggerAppDelegationUpdate($lang, $checkOnly);
     $triggers[] = $appCache->triggerApplicationUpdate($lang, $checkOnly);
     $triggers[] = $appCache->triggerApplicationDelete($lang, $checkOnly);
     $triggers[] = $appCache->triggerContentUpdate($lang, $checkOnly);
     if ($fill) {
         CLI::logging("-> Rebuild Cache View\n");
         //build using the method in AppCacheView Class
         $res = $appCache->fillAppCacheView($lang);
         //set status in config table
         $confParams = array('LANG' => $lang, 'STATUS' => 'active');
     }
     $oConf->aConfig = $confParams;
     $oConf->saveConfig('APP_CACHE_VIEW_ENGINE', '', '', '');
     // removing casesList configuration records. TODO: removing these lines that resets all the configurations records
     $oCriteria = new Criteria();
     $oCriteria->add(ConfigurationPeer::CFG_UID, "casesList");
     $oCriteria->add(ConfigurationPeer::OBJ_UID, array("todo", "draft", "sent", "unassigned", "paused", "cancelled"), Criteria::NOT_IN);
     ConfigurationPeer::doDelete($oCriteria);
     // end of reset
 }
$aData = G::json_decode($_POST['data']);
$appSelectedUids = array();
$items = explode(",", $_POST['APP_UIDS']);
foreach ($items as $item) {
    $dataUids = explode("|", $item);
    $appSelectedUids[] = $dataUids[0];
}
// var_dump($aData);
//var_dump($appSelectedUids);
$casesReassignedCount = 0;
$serverResponse = array();
G::LoadClass('case');
$oCases = new Cases();
require_once 'classes/model/Task.php';
require_once 'classes/model/AppCacheView.php';
$oAppCacheView = new AppCacheView();
$oCasesReassignList = $oAppCacheView->getToReassignListCriteria(null);
if (isset($_POST['selected']) && $_POST['selected'] == 'true') {
    $oCasesReassignList->add(AppCacheViewPeer::APP_UID, $appSelectedUids, Criteria::IN);
}
// if there are no records to save return -1
if (empty($aData)) {
    $serverResponse['TOTAL'] = -1;
    echo G::json_encode($serverResponse);
    die;
}
//      $params = array ();
//      $sql = BasePeer::createSelectSql($oCasesReassignList, $params);
//      var_dump($sql);
if (is_array($aData)) {
    $currentCasesReassigned = 0;
     $langs = $Translations->getTranslationEnvironments();
     foreach ($langs as $lang) {
         $result->rows[] = array('LAN_ID' => $lang['LOCALE'], 'LAN_NAME' => $lang['LANGUAGE']);
     }
     print G::json_encode($result);
     break;
 case 'build':
     $sqlToExe = array();
     G::LoadClass('configuration');
     $conf = new Configurations();
     //DEPRECATED $lang = $_POST['lang'];
     //there is no more support for other languages that english
     $lang = 'en';
     try {
         //setup the appcacheview object, and the path for the sql files
         $appCache = new AppCacheView();
         $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP);
         //APP_DELEGATION INSERT
         $res = $appCache->triggerAppDelegationInsert($lang, true);
         //$result->info[] = array ('name' => 'Trigger APP_DELEGATION INSERT',           'value'=> $res);
         //APP_DELEGATION Update
         $res = $appCache->triggerAppDelegationUpdate($lang, true);
         //$result->info[] = array ('name' => 'Trigger APP_DELEGATION UPDATE',           'value'=> $res);
         //APPLICATION UPDATE
         $res = $appCache->triggerApplicationUpdate($lang, true);
         //$result->info[] = array ('name' => 'Trigger APPLICATION UPDATE',              'value'=> $res);
         //APPLICATION DELETE
         $res = $appCache->triggerApplicationDelete($lang, true);
         //$result->info[] = array ('name' => 'Trigger APPLICATION DELETE',              'value'=> $res);
         //CONTENT UPDATE
         $res = $appCache->triggerContentUpdate($lang, true);
 /**
  * Get the application delegation record from database
  *
  * @param string $arrayAppUid array of Application identifiers
  * @param string $action Action (todo, draft, paused, sent, selfservice, unassigned, search)
  * @param string $appStatus Status of Application
  * @return array of arrays with delegation information.
  */
 public function getListApplicationDelegationData($arrayAppUid, $action, $appStatus)
 {
     $c = new Criteria();
     $c->addSelectColumn(AppDelegationPeer::APP_UID);
     $c->addSelectColumn(AppDelegationPeer::DEL_INDEX);
     $c->addAsColumn('USR_NAME', 'u.USR_FIRSTNAME');
     $c->addAsColumn('USR_LAST', 'u.USR_LASTNAME');
     $c->addAsColumn('USR_PREV_NAME', 'uprev.USR_FIRSTNAME');
     $c->addAsColumn('USR_PREV_LAST', 'uprev.USR_LASTNAME');
     $c->addAsColumn('PREVIOUS_USR_UID', 'uprev.USR_UID');
     $c->addAsColumn('APP_TAS_TITLE', 'ctastitle.CON_VALUE');
     $c->addAsColumn('APP_THREAD_STATUS', 'at.APP_THREAD_STATUS');
     $c->addSelectColumn(AppDelegationPeer::APP_OVERDUE_PERCENTAGE);
     $c->addSelectColumn(AppDelegationPeer::DEL_DELAYED);
     $c->addSelectColumn(AppDelegationPeer::DEL_DELAY_DURATION);
     $c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
     $c->addSelectColumn(AppDelegationPeer::DEL_DURATION);
     $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
     $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
     $c->addSelectColumn(AppDelegationPeer::DEL_QUEUE_DURATION);
     $c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
     $c->addSelectColumn(AppDelegationPeer::DEL_THREAD_STATUS);
     $c->addSelectColumn(AppDelegationPeer::TAS_UID);
     $c->addAlias("u", "USERS");
     $c->addAlias("uprev", "USERS");
     $c->addAlias("adprev", "APP_DELEGATION");
     $c->addAlias("ctastitle", "CONTENT");
     $c->addAlias("at", "APP_THREAD");
     $arrayCondition = array();
     $arrayCondition[] = array(AppDelegationPeer::APP_UID, ApplicationPeer::APP_UID);
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $arrayCondition = array();
     $arrayCondition[] = array(AppDelegationPeer::USR_UID, "u.USR_UID");
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $arrayCondition = array();
     $arrayCondition[] = array(AppDelegationPeer::APP_UID, "adprev.APP_UID");
     $arrayCondition[] = array(AppDelegationPeer::DEL_PREVIOUS, "adprev.DEL_INDEX");
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $arrayCondition = array();
     $arrayCondition[] = array(AppDelegationPeer::TAS_UID, "ctastitle.CON_ID");
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $arrayCondition = array();
     $arrayCondition[] = array("adprev.USR_UID", "uprev.USR_UID");
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $arrayCondition = array();
     $arrayCondition[] = array(AppDelegationPeer::APP_UID, "at.APP_UID");
     $arrayCondition[] = array(AppDelegationPeer::DEL_THREAD, "at.APP_THREAD_INDEX");
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $c->add(AppDelegationPeer::APP_UID, $arrayAppUid, Criteria::IN);
     //$c->add (AppDelegationPeer::DEL_INDEX, $delIndex);
     switch ($action) {
         case "sent":
             if (!empty($appStatus)) {
                 $c->add(ApplicationPeer::APP_STATUS, $appStatus);
             }
             break;
         default:
             $appCacheView = new AppCacheView();
             //Paused
             $sqlAppDelay = $appCacheView->getAppDelaySql(AppDelegationPeer::APP_UID, AppDelegationPeer::DEL_INDEX);
             //Criterions
             $criterionToDo = $c->getNewCriterion(ApplicationPeer::APP_STATUS, "TO_DO", CRITERIA::EQUAL)->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL))->addAnd($c->getNewCriterion("at.APP_THREAD_STATUS", "OPEN"))->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"));
             $criterionDraft = $c->getNewCriterion(ApplicationPeer::APP_STATUS, "DRAFT", CRITERIA::EQUAL)->addAnd($c->getNewCriterion("at.APP_THREAD_STATUS", "OPEN"))->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"));
             $criterionPaused = $c->getNewCriterion(ApplicationPeer::APP_STATUS, "PAUSED")->addAnd($c->getNewCriterion(AppDelegationPeer::APP_UID, AppDelegationPeer::APP_UID . " IN ({$sqlAppDelay})", Criteria::CUSTOM));
             $criterionCancelled = $c->getNewCriterion(ApplicationPeer::APP_STATUS, "CANCELLED", CRITERIA::EQUAL)->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "CLOSED"));
             $criterionCompleted = $c->getNewCriterion(ApplicationPeer::APP_STATUS, "COMPLETED");
             switch ($appStatus) {
                 case "TO_DO":
                     //ToDo
                     $c->add($criterionToDo);
                     break;
                 case "DRAFT":
                     //Draft
                     $c->add($criterionDraft);
                     break;
                 case "PAUSED":
                     //Paused
                     $c->add($criterionPaused);
                     break;
                 case "CANCELLED":
                     //Cancelled
                     $c->add($criterionCancelled);
                     break;
                 case "COMPLETED":
                     //Completed
                     $c->add($criterionCompleted);
                     break;
                 default:
                     //All status
                     $c->add($criterionToDo)->addOr($criterionDraft)->addOr($criterionPaused)->addOr($criterionCancelled)->addOr($criterionCompleted);
                     break;
             }
             break;
     }
     $c->add('ctastitle.CON_CATEGORY', 'TAS_TITLE');
     $c->add('ctastitle.CON_LANG', 'en');
     $rs = AppDelegationPeer::doSelectRS($c);
     $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     // echo $c->toString();
     $rs->next();
     $row = $rs->getRow();
     $appDataRows = array();
     while (is_array($row)) {
         $appDataRows[] = $row;
         $rs->next();
         $row = $rs->getRow();
     }
     return $appDataRows;
 }
Example #22
0
    /**

     * Get counters for lists

     *

     * @access public

     * @param array $userId, User Uid

     * @return array

     *

     * @author Brayan Pereyra (Cochalo) <*****@*****.**>

     * @copyright Colosa - Bolivia

     */

    public function getCounters($userId)

    {

        $criteria = new Criteria();

        $criteria->addSelectColumn(UsersPeer::USR_TOTAL_INBOX);

        $criteria->addSelectColumn(UsersPeer::USR_TOTAL_DRAFT);

        $criteria->addSelectColumn(UsersPeer::USR_TOTAL_CANCELLED);

        $criteria->addSelectColumn(UsersPeer::USR_TOTAL_PARTICIPATED);

        $criteria->addSelectColumn(UsersPeer::USR_TOTAL_PAUSED);

        $criteria->addSelectColumn(UsersPeer::USR_TOTAL_COMPLETED);

        $criteria->add( UsersPeer::USR_UID, $userId, Criteria::EQUAL );

        $dataset = UsersPeer::doSelectRS($criteria);

        $dataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);

        $dataset->next();

        $aRow = $dataset->getRow();



        $oAppCache = new \AppCacheView();

        $totalUnassigned = $oAppCache->getListCounters('selfservice', $userId, false);



        $response = array(

            array('count' => $aRow['USR_TOTAL_INBOX'],          'item' => 'CASES_INBOX'),

            array('count' => $aRow['USR_TOTAL_DRAFT'],          'item' => 'CASES_DRAFT'),

            array('count' => $aRow['USR_TOTAL_CANCELLED'],      'item' => 'CASES_CANCELLED'),

            array('count' => $aRow['USR_TOTAL_PARTICIPATED'],   'item' => 'CASES_SENT'),

            array('count' => $aRow['USR_TOTAL_PAUSED'],         'item' => 'CASES_PAUSED'),

            array('count' => $aRow['USR_TOTAL_COMPLETED'],      'item' => 'CASES_COMPLETED'),

            array('count' => $totalUnassigned,                  'item' => 'CASES_SELFSERVICE')

        );



        /*----------------------------------********---------------------------------*/



        return $response;

    }
Example #23
0
 public function createMySQLWorkspace()
 {
     ini_set('max_execution_time', '0');
     $info->result = false;
     $info->message = '';
     $info->canRedirect = true;
     $db_hostname = trim($_REQUEST['db_hostname']);
     $db_port = trim($_REQUEST['db_port']);
     $db_username = trim($_REQUEST['db_username']);
     $db_password = trim($_REQUEST['db_password']);
     $wf = trim($_REQUEST['wfDatabase']);
     $rb = trim($_REQUEST['rbDatabase']);
     $rp = trim($_REQUEST['rpDatabase']);
     $workspace = trim($_REQUEST['workspace']);
     $pathConfig = trim($_REQUEST['pathConfig']);
     $pathLanguages = trim($_REQUEST['pathLanguages']);
     $pathPlugins = trim($_REQUEST['pathPlugins']);
     $pathShared = trim($_REQUEST['pathShared']);
     $pathXmlforms = trim($_REQUEST['pathXmlforms']);
     $adminPassword = trim($_REQUEST['adminPassword']);
     $adminUsername = trim($_REQUEST['adminUsername']);
     $deleteDB = $_REQUEST['deleteDB'] == 'true';
     if (substr($pathShared, -1) != '/') {
         $pathShared .= '/';
     }
     $this->installLog('-------------------------------------------');
     $this->installLog(sprintf("Creating workspace '%s' ", $workspace));
     try {
         $db_host = $db_port != '' && $db_port != 3306 ? $db_hostname . ':' . $db_port : $db_hostname;
         $this->link = @mysql_connect($db_host, $db_username, $db_password);
         $this->installLog(sprintf("Connected to server %s:%d using user: '******' ", $db_hostname, $db_port, $db_username));
         if ($deleteDB) {
             $q = sprintf('DROP DATABASE IF EXISTS %s;', $wf, $wf);
             $this->mysqlQuery($q);
             $q = sprintf('DROP DATABASE IF EXISTS %s;', $rb, $rb);
             $this->mysqlQuery($q);
             $q = sprintf('DROP DATABASE IF EXISTS %s;', $rp, $rp);
             $this->mysqlQuery($q);
         }
         // CREATE databases wf_workflow, rb_workflow and rp_workflow
         $q = sprintf('CREATE DATABASE IF NOT EXISTS %s;', $wf, $wf);
         $this->mysqlQuery($q);
         $q = sprintf('CREATE DATABASE IF NOT EXISTS %s;', $rb, $rb);
         $this->mysqlQuery($q);
         $q = sprintf('CREATE DATABASE IF NOT EXISTS %s;', $rp, $rp);
         $this->mysqlQuery($q);
         // CREATE users and GRANT Privileges
         $wfPass = G::generate_password(12);
         $rbPass = G::generate_password(12);
         $rpPass = G::generate_password(12);
         $this->setGrantPrivilegesMySQL($wf, $wfPass, $wf, $db_hostname);
         $this->setGrantPrivilegesMySQL($rb, $rbPass, $rb, $db_hostname);
         $this->setGrantPrivilegesMySQL($rp, $rpPass, $rp, $db_hostname);
         // Generate the db.php file and folders
         $path_site = $pathShared . "/sites/" . $workspace . "/";
         $db_file = $path_site . "db.php";
         @mkdir($path_site, 0777, true);
         @mkdir($path_site . "files/", 0777, true);
         @mkdir($path_site . "mailTemplates/", 0777, true);
         @mkdir($path_site . "public/", 0777, true);
         @mkdir($path_site . "reports/", 0777, true);
         @mkdir($path_site . "xmlForms", 0777, true);
         $dbText = "<?php\n";
         $dbText .= sprintf("// Processmaker configuration\n");
         $dbText .= sprintf("  define ('DB_ADAPTER',     '%s' );\n", 'mysql');
         $dbText .= sprintf("  define ('DB_HOST',        '%s' );\n", $db_host);
         $dbText .= sprintf("  define ('DB_NAME',        '%s' );\n", $wf);
         $dbText .= sprintf("  define ('DB_USER',        '%s' );\n", $wf);
         $dbText .= sprintf("  define ('DB_PASS',        '%s' );\n", $wfPass);
         $dbText .= sprintf("  define ('DB_RBAC_HOST',   '%s' );\n", $db_host);
         $dbText .= sprintf("  define ('DB_RBAC_NAME',   '%s' );\n", $rb);
         $dbText .= sprintf("  define ('DB_RBAC_USER',   '%s' );\n", $rb);
         $dbText .= sprintf("  define ('DB_RBAC_PASS',   '%s' );\n", $rbPass);
         $dbText .= sprintf("  define ('DB_REPORT_HOST', '%s' );\n", $db_host);
         $dbText .= sprintf("  define ('DB_REPORT_NAME', '%s' );\n", $rp);
         $dbText .= sprintf("  define ('DB_REPORT_USER', '%s' );\n", $rp);
         $dbText .= sprintf("  define ('DB_REPORT_PASS', '%s' );\n", $rpPass);
         $this->installLog("Creating: " . $db_file);
         file_put_contents($db_file, $dbText);
         // Generate the databases.php file
         $databases_file = $path_site . 'databases.php';
         $dbData = sprintf("\$dbAdapter    = '%s';\n", 'mysql');
         $dbData .= sprintf("\$dbHost       = '%s';\n", $db_host);
         $dbData .= sprintf("\$dbName       = '%s';\n", $wf);
         $dbData .= sprintf("\$dbUser       = '******';\n", $wf);
         $dbData .= sprintf("\$dbPass       = '******';\n", $wfPass);
         $dbData .= sprintf("\$dbRbacHost   = '%s';\n", $db_host);
         $dbData .= sprintf("\$dbRbacName   = '%s';\n", $rb);
         $dbData .= sprintf("\$dbRbacUser   = '******';\n", $rb);
         $dbData .= sprintf("\$dbRbacPass   = '******';\n", $rbPass);
         $dbData .= sprintf("\$dbReportHost = '%s';\n", $db_host);
         $dbData .= sprintf("\$dbReportName = '%s';\n", $rp);
         $dbData .= sprintf("\$dbReportUser = '******';\n", $rp);
         $dbData .= sprintf("\$dbReportPass = '******';\n", $rpPass);
         $databasesText = str_replace('{dbData}', $dbData, @file_get_contents(PATH_HOME . 'engine/templates/installer/databases.tpl'));
         $this->installLog('Creating: ' . $databases_file);
         file_put_contents($databases_file, $databasesText);
         // Execute scripts to create and populates databases
         $query = sprintf("USE %s;", $rb);
         $this->mysqlQuery($query);
         $this->mysqlFileQuery(PATH_RBAC_HOME . 'engine/data/mysql/schema.sql');
         $this->mysqlFileQuery(PATH_RBAC_HOME . 'engine/data/mysql/insert.sql');
         $query = sprintf("USE %s;", $wf);
         $this->mysqlQuery($query);
         $this->mysqlFileQuery(PATH_HOME . 'engine/data/mysql/schema.sql');
         $this->mysqlFileQuery(PATH_HOME . 'engine/data/mysql/insert.sql');
         // Create the triggers
         if (file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql') && file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql') && file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql') && file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql') && file_exists(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql')) {
             $this->mysqlQuery(@file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationInsert.sql'));
             $this->mysqlQuery(@file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerAppDelegationUpdate.sql'));
             $this->mysqlQuery(@file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationUpdate.sql'));
             $this->mysqlQuery(@file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerApplicationDelete.sql'));
             $this->mysqlQuery(@file_get_contents(PATH_HOME . 'engine/methods/setup/setupSchemas/triggerContentUpdate.sql'));
             $this->mysqlQuery("INSERT INTO `CONFIGURATION` (\n                            `CFG_UID`,\n                            `CFG_VALUE`\n                           )\n                           VALUES (\n                             'APP_CACHE_VIEW_ENGINE',\n                             '" . mysql_real_escape_string(serialize(array('LANG' => 'en', 'STATUS' => 'active'))) . "'\n                           )");
         }
         // Change admin user
         $query = sprintf("USE %s;", $wf);
         $this->mysqlQuery($query);
         $query = sprintf("UPDATE USERS SET USR_USERNAME = '******', USR_PASSWORD = '******' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, md5($adminPassword));
         $this->mysqlQuery($query);
         $query = sprintf("USE %s;", $rb);
         $this->mysqlQuery($query);
         $query = sprintf("UPDATE USERS SET USR_USERNAME = '******', USR_PASSWORD = '******' WHERE USR_UID = '00000000000000000000000000000001' ", $adminUsername, md5($adminPassword));
         $this->mysqlQuery($query);
         // Write the paths_installed.php file (contains all the information configured so far)
         if (!file_exists(FILE_PATHS_INSTALLED)) {
             $sh = md5(filemtime(PATH_GULLIVER . '/class.g.php'));
             $h = G::encrypt($db_hostname . $sh . $db_username . $sh . $db_password, $sh);
             $dbText = "<?php\n";
             $dbText .= sprintf("  define('PATH_DATA',         '%s');\n", $pathShared);
             $dbText .= sprintf("  define('PATH_C',            '%s');\n", $pathShared . 'compiled/');
             $dbText .= sprintf("  define('HASH_INSTALLATION', '%s');\n", $h);
             $dbText .= sprintf("  define('SYSTEM_HASH',       '%s');\n", $sh);
             $this->installLog("Creating: " . FILE_PATHS_INSTALLED);
             file_put_contents(FILE_PATHS_INSTALLED, $dbText);
         }
         /**
          * AppCacheView Build
          */
         define('HASH_INSTALLATION', $h);
         define('SYSTEM_HASH', $sh);
         define('PATH_DB', $pathShared . 'sites' . PATH_SEP);
         define('SYS_SYS', 'workflow');
         require_once "propel/Propel.php";
         Propel::init(PATH_CORE . "config/databases.php");
         $con = Propel::getConnection('workflow');
         require_once 'classes/model/AppCacheView.php';
         $lang = 'en';
         //setup the appcacheview object, and the path for the sql files
         $appCache = new AppCacheView();
         $appCache->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP);
         //APP_DELEGATION INSERT
         $res = $appCache->triggerAppDelegationInsert($lang, true);
         //APP_DELEGATION Update
         $res = $appCache->triggerAppDelegationUpdate($lang, true);
         //APPLICATION UPDATE
         $res = $appCache->triggerApplicationUpdate($lang, true);
         //APPLICATION DELETE
         $res = $appCache->triggerApplicationDelete($lang, true);
         //CONTENT UPDATE
         $res = $appCache->triggerContentUpdate($lang, true);
         //build using the method in AppCacheView Class
         $res = $appCache->fillAppCacheView($lang);
         //end AppCacheView Build
         //erik: for new env conf handling
         G::loadClass('system');
         $envFile = PATH_CONFIG . 'env.ini';
         //writting for new installtions to use the new skin 'uxmind' with new Front End ExtJs Based
         $updatedConf['default_skin'] = 'uxmodern';
         $info->uri = '/sys' . $_REQUEST['workspace'] . '/en/uxmodern/main/login';
         try {
             G::update_php_ini($envFile, $updatedConf);
         } catch (Exception $e) {
             $info->result = false;
             $info->message = "ProcessMaker couldn't write on configuration file: {$envFile}.<br/>";
             $info->message .= "The new ProcessMaker UI couldn't be applied on installation, you can enable it after from Admin->System settings.";
             $this->installLog("Installed but with error, couldn't update env.ini");
             return $info;
         }
         // getting configuration from env.ini
         $sysConf = System::getSystemConfiguration($envFile);
         try {
             // update the main index file
             $indexFileUpdated = System::updateIndexFile(array('lang' => 'en', 'skin' => $updatedConf['default_skin']));
         } catch (Exception $e) {
             $info->result = false;
             $info->message = "ProcessMaker couldn't write on configuration file: " . PATH_HTML . "index.html.<br/>";
             $info->message .= "The new ProcessMaker UI couldn't be applied on installation, you can enable it after from Admin->System settings.";
             $this->installLog("Installed but with error, couldn't update index.html");
             return $info;
         }
         $this->installLog("Index File updated {$indexFileUpdated} with lang: {$sysConf['default_lang']}, skin: {$sysConf['default_skin']} ");
         $this->installLog("Install completed Succesfully");
         $info->result = true;
         $info->message = 'Succesfully OK';
     } catch (Exception $e) {
         $info->canRedirect = false;
         $info->result = false;
         $info->message = $e->getMessage();
     }
     return $info;
 }