Ejemplo n.º 1
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 tables \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



        //close connection

        if (substr(PHP_OS, 0, 3) != 'WIN') {

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



            $sql_sleep = "SELECT * FROM information_schema.processlist WHERE command = 'Sleep' and user = SUBSTRING_INDEX(USER(),'@',1) and db = DATABASE() ORDER BY id;";

            $stmt_sleep = $connection->createStatement();

            $rs_sleep = $stmt_sleep->executeQuery( $sql_sleep, ResultSet::FETCHMODE_ASSOC );



            while ($rs_sleep->next()) {

                $row_sleep = $rs_sleep->getRow();

                $oStatement_sleep = $connection->prepareStatement( "kill ". $row_sleep['ID'] );

                $oStatement_sleep->executeQuery();

            }



            $sql_query = "SELECT * FROM information_schema.processlist WHERE user = SUBSTRING_INDEX(USER(),'@',1) and db = DATABASE() and time > 0 ORDER BY id;";

            $stmt_query = $connection->createStatement();

            $rs_query = $stmt_query->executeQuery( $sql_query, ResultSet::FETCHMODE_ASSOC );



            while ($rs_query->next()) {

                $row_query = $rs_query->getRow();

                $oStatement_query = $connection->prepareStatement( "kill ". $row_query['ID'] );

                $oStatement_query->executeQuery();

            }

        }

    }
Ejemplo n.º 2
0
            }
            $pro['datasources']['workflow']['connection'] = $dsn;
            $pro['datasources']['workflow']['adapter'] = $DB_ADAPTER;
            $pro['datasources']['rbac']['connection'] = $dsnRbac;
            $pro['datasources']['rbac']['adapter'] = $DB_ADAPTER;
            $pro['datasources']['rp']['connection'] = $dsnRp;
            $pro['datasources']['rp']['adapter'] = $DB_ADAPTER;
            //$pro['datasources']['dbarray']['connection'] = 'dbarray://*****:*****@localhost/pm_os';
            //$pro['datasources']['dbarray']['adapter']    = 'dbarray';
            $oFile = fopen(PATH_CORE . 'config/_databases_.php', 'w');
            fwrite($oFile, '<?php global $pro;return $pro; ?>');
            fclose($oFile);
            Propel::init(PATH_CORE . 'config/_databases_.php');
            //Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
            // enable rbac
            Bootstrap::LoadSystem('rbac');
            $RBAC =& RBAC::getSingleton(PATH_DATA, session_id());
            $RBAC->sSystem = 'PROCESSMAKER';
            eprintln("Processing workspace: " . $sObject, "green");
            try {
                processWorkspace();
            } catch (Exception $e) {
                echo $e->getMessage();
                eprintln("Probelm in workspace: " . $sObject . " it was omitted.", "red");
            }
            eprintln();
        }
    }
    unlink(PATH_CORE . 'config/_databases_.php');
} else {
    processWorkspace();
Ejemplo n.º 3
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
 }
Ejemplo n.º 4
0
 /**
  * If the class is not defined by the aplication, it
  * attempt to load the class from gulliver.system
  *
  * @author Fernando Ontiveros Lira <*****@*****.**>, David S. Callizaya
  * @access public
  * @param string $strClass
  * @return void
  */
 public static function LoadClass($strClass)
 {
     Bootstrap::LoadSystem('inputfilter');
     $filter = new InputFilter();
     $path = PATH_GULLIVER . 'class.' . $strClass . '.php';
     $path = $filter->validateInput($path, "path");
     $classfile = Bootstrap::ExpandPath("classes") . 'class.' . $strClass . '.php';
     $classfile = $filter->validateInput($classfile, "path");
     if (!file_exists($classfile)) {
         if (file_exists($path)) {
             return require_once $path;
         } else {
             return false;
         }
     } else {
         return require_once $classfile;
     }
 }
     $pro = array();
     $pro["datasources"]["workflow"]["connection"] = $dsn;
     $pro["datasources"]["workflow"]["adapter"] = $DB_ADAPTER;
     $pro["datasources"]["rbac"]["connection"] = $dsnRbac;
     $pro["datasources"]["rbac"]["adapter"] = $DB_ADAPTER;
     $pro["datasources"]["rp"]["connection"] = $dsnRp;
     $pro["datasources"]["rp"]["adapter"] = $DB_ADAPTER;
     //$pro["datasources"]["dbarray"]["connection"] = "dbarray://*****:*****@localhost/pm_os";
     //$pro["datasources"]["dbarray"]["adapter"]    = "dbarray";
     $oFile = fopen(PATH_CORE . "config" . PATH_SEP . "_databases_.php", "w");
     fwrite($oFile, "<?php global \$pro; return \$pro; ?>");
     fclose($oFile);
     Propel::init(PATH_CORE . "config" . PATH_SEP . "_databases_.php");
     //Creole::registerDriver("dbarray", "creole.contrib.DBArrayConnection");
     //Enable RBAC
     Bootstrap::LoadSystem("rbac");
     $rbac =& RBAC::getSingleton(PATH_DATA, session_id());
     $rbac->sSystem = "PROCESSMAKER";
     if (!defined("DB_ADAPTER")) {
         define("DB_ADAPTER", $DB_ADAPTER);
     }
     eprintln("Processing workspace: " . $workflow, "green");
     try {
         $timerEvent = new \ProcessMaker\BusinessModel\TimerEvent();
         $timerEvent->startContinueCaseByTimerEvent(date("Y-m-d H:i:s"), true);
     } catch (Exception $e) {
         echo $e->getMessage() . "\n";
         eprintln("Problem in workspace: " . $workflow . " it was omitted.", "red");
     }
     eprintln();
 }