Пример #1
0
 function metodillo()
 {
     $sSQL = "SELECT * FROM PM_PARAMETERS WHERE PRM_ID = 'CAS_URL' ";
     $aResSQL = executeQuery($sSQL);
     if (count($aResSQL)) {
         $sURL = $aResSQL[1]['PRM_VALUE'];
         $sURI = $aResSQL[1]['PRM_VALUE_2'];
         $res = false;
         $RBAC = RBAC::getSingleton();
         $RBAC->initRBAC();
         require_once 'CAS-1.2.2/CAS.php';
         phpCAS::client(CAS_VERSION_2_0, $sURL, 443, $sURI, false);
         phpCAS::setNoCasServerValidation();
         phpCAS::forceAuthentication();
         if (phpCAS::isAuthenticated() == true) {
             $sCasUser = phpCAS::getUser();
             $sSQL = "SELECT USR_UID FROM USERS WHERE USR_USERNAME = '******' ";
             $aResSQL = executeQuery($sSQL);
             if (count($aResSQL)) {
                 $nUserId = $aResSQL[1]['USR_UID'];
                 $RBAC->singleSignOn = true;
                 $RBAC->userObj->fields['USR_UID'] = $nUserId;
                 $RBAC->userObj->fields['USR_USERNAME'] = $sCasUser;
                 $res = true;
             } else {
                 $res = false;
             }
         } else {
             $res = false;
         }
     } else {
         $res = false;
     }
     return $res;
 }
Пример #2
0
        $_SESSION['phpFileNotFound'] = $_SERVER['REQUEST_URI'];
        header("location: /errors/error404.php?url=" . urlencode($_SERVER['REQUEST_URI']));
        die;
    }
}
//redirect to login, if user changed the workspace in the URL
if (!$avoidChangedWorkspaceValidation && isset($_SESSION['WORKSPACE']) && $_SESSION['WORKSPACE'] != SYS_SYS) {
    $_SESSION['WORKSPACE'] = SYS_SYS;
    G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', "error");
    // verify if the current skin is a 'ux' variant
    $urlPart = substr(SYS_SKIN, 0, 2) == 'ux' && SYS_SKIN != 'uxs' ? '/main/login' : '/login/login';
    header('Location: /sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . $urlPart);
    die;
}
// enable rbac
$RBAC =& RBAC::getSingleton(PATH_DATA, session_id());
$RBAC->sSystem = 'PROCESSMAKER';
// define and send Headers for all pages
if (!defined('EXECUTE_BY_CRON')) {
    header("Expires: " . gmdate("D, d M Y H:i:s", mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'))) . " GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    // get the language direction from ServerConf
    define('SYS_LANG_DIRECTION', $oServerConf->getLanDirection());
    if (isset($_SESSION['USER_LOGGED']) && !isset($_GET['sid'])) {
        $RBAC->initRBAC();
        //using optimization with memcache, the user data will be in memcache 8 hours, or until session id goes invalid
        $memKey = 'rbacSession' . session_id();
        if (($RBAC->aUserInfo = $memcache->get($memKey)) === false) {
Пример #3
0
    /**

     * get all roles, to see all roles

     *

     * @param none

     * @return $result will return an object

     */

    public function roleList ()

    {

        try {

            $result = array ();



            $RBAC = & RBAC::getSingleton();

            $RBAC->initRBAC();

            $oCriteria = $RBAC->listAllRoles();

            $oDataset = GulliverBasePeer::doSelectRs( $oCriteria );

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

            $oDataset->next();



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

                $result[] = array ('guid' => $aRow['ROL_UID'],'name' => $aRow['ROL_CODE']

                );

                $oDataset->next();

            }



            return $result;

        } catch (Exception $e) {

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

            );



            return $result;

        }

    }
Пример #4
0
function ifPermission($sessionId, $permission)
{
    global $RBAC;
    $RBAC->initRBAC();
    G::LoadClass('sessions');
    $oSession = new Sessions();
    $user = $oSession->getSessionUser($sessionId);
    $oRBAC = RBAC::getSingleton();
    $oRBAC->loadUserRolePermission($oRBAC->sSystem, $user['USR_UID']);
    $aPermissions = $oRBAC->aUserInfo[$oRBAC->sSystem]['PERMISSIONS'];
    $sw = 0;
    foreach ($aPermissions as $aPermission) {
        if ($aPermission['PER_CODE'] == $permission) {
            $sw = 1;
        }
    }
    return $sw;
}
Пример #5
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();

            }

        }

    }
Пример #6
0
 /**
  * listExtNoProcessesUser for Extjs
  *
  * @param string $sProcessUID
  * @return array(aAvailableUser) $aAvailableUser
  */
 public function listExtNoProcessesUser($sProcessUID)
 {
     G::LoadSystem('rbac');
     $memcache =& PMmemcached::getSingleton(SYS_SYS);
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(ProcessUserPeer::USR_UID);
     $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
     $oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
     $oDataset = ProcessUserPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aUIDS = array();
     while ($aRow = $oDataset->getRow()) {
         $aUIDS[] = $aRow['USR_UID'];
         $oDataset->next();
     }
     $sDelimiter = DBAdapter::getStringDelimiter();
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(UsersPeer::USR_UID);
     $oCriteria->add(UsersPeer::USR_UID, $aUIDS, Criteria::NOT_IN);
     $oDataset = UsersPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aUIDS = array();
     $oRBAC = RBAC::getSingleton();
     while ($aRow = $oDataset->getRow()) {
         $memKey = 'rbacSession' . session_id();
         if (($oRBAC->aUserInfo = $memcache->get($memKey)) === false) {
             $oRBAC->loadUserRolePermission($oRBAC->sSystem, $aRow['USR_UID']);
             $memcache->set($memKey, $oRBAC->aUserInfo, PMmemcached::EIGHT_HOURS);
         }
         $aPermissions = $oRBAC->aUserInfo[$oRBAC->sSystem]['PERMISSIONS'];
         $bInclude = false;
         foreach ($aPermissions as $aPermission) {
             if ($aPermission['PER_CODE'] == 'PM_SUPERVISOR') {
                 $bInclude = true;
             }
         }
         if ($bInclude) {
             $aUIDS[] = $aRow['USR_UID'];
         }
         $oDataset->next();
     }
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(UsersPeer::USR_UID);
     $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
     $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
     $oCriteria->add(UsersPeer::USR_UID, $aUIDS, Criteria::IN);
     $oDataset = UsersPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aAvailableUser = '';
     while ($aRow = $oDataset->getRow()) {
         $aAvailableUser[] = array('USR_UID' => $aRow['USR_UID'], 'USR_FIRSTNAME' => $aRow['USR_FIRSTNAME'], 'USR_LASTNAME' => $aRow['USR_LASTNAME']);
         $oDataset->next();
     }
     return $aAvailableUser;
 }
Пример #7
0
 public function checkUserCredentials($username, $password)
 {
     $RBAC = \RBAC::getSingleton();
     $RBAC->initRBAC();
     $uid = $RBAC->VerifyLogin($username , $password);
     if($uid < 0){
        return false;
     }
     if($uid != ''){
        return true;
     }
     return false;
 }
Пример #8
0
global $G_ENVIRONMENTS;
if (isset($G_ENVIRONMENTS)) {
    $dbfile = $G_ENVIRONMENTS[G_TEST_ENV]['dbfile'];
    if (!file_exists($dbfile)) {
        printf("%s \n", pakeColor::colorize("dbfile {$dbfile} doesn't exist for environment " . G_ENVIRONMENT, 'ERROR'));
        exit(200);
    } else {
        include $dbfile;
    }
} else {
    exit(201);
}
G::LoadThirdParty('pear/json', 'class.json');
G::LoadThirdParty('smarty/libs', 'Smarty.class');
G::LoadSystem('xmlform');
G::LoadSystem('xmlDocument');
G::LoadSystem('form');
G::LoadSystem('rbac');
$method = array();
$method = get_class_methods('RBAC');
$t = new lime_test(8, new lime_output_color());
$obj =& RBAC::getSingleton();
$t->diag('class RBAC');
$t->is(count($method), 46, "class RBAC " . count($method) . " methods.");
$t->isa_ok($obj, 'RBAC', 'class RBAC created');
$t->can_ok($obj, 'VerifyLogin', 'VerifyLogin()');
$t->can_ok($obj, 'userCanAccess', 'userCanAccess()');
$t->can_ok($obj, 'load', 'load()');
$t->can_ok($obj, 'createUser', 'createUser()');
$t->can_ok($obj, 'listAllRoles', 'listAllRoles()');
$t->todo('review all pendings in this class');
Пример #9
0
    /**
     * lista de usuarios a reasignar
     */
    public function getUsersToReassign($usr_uid, $task_uid)
    {
        //G::LoadClass( 'tasks' );
        G::LoadSystem( 'rbac' );
        G::LoadClass( 'memcached' );
        $memcache = \PMmemcached::getSingleton( SYS_SYS );
        $RBAC = \RBAC::getSingleton( PATH_DATA, session_id() );
        $RBAC->sSystem = 'PROCESSMAKER';
        $RBAC->initRBAC();
        $memKey = 'rbacSession' . session_id();
        if (($RBAC->aUserInfo = $memcache->get( $memKey )) === false) {
            $RBAC->loadUserRolePermission( $RBAC->sSystem, $usr_uid );
            $memcache->set( $memKey, $RBAC->aUserInfo, \PMmemcached::EIGHT_HOURS );
        }
        $GLOBALS['RBAC'] = $RBAC;

        $task = new \Task();
        $tasks = $task->load($task_uid);
        $case = new \Cases();
        $result = new \stdclass();
        $result->data = $case->getUsersToReassign($task_uid, $usr_uid, $tasks['PRO_UID']);
        return $result;
    }
Пример #10
0
 /**
   function executed by the cron
   this function will synchronize users from ldap/active directory to PM users tables
   @return void
 */
 public function executeCron($debug)
 {
     $rbac =& RBAC::getSingleton();
     if (is_null($rbac->authSourcesObj)) {
         $rbac->authSourcesObj = new AuthenticationSource();
     }
     $plugin = new ldapAdvanced();
     $plugin->sSystem = $rbac->sSystem;
     $plugin->setFrontEnd(true);
     $plugin->setDebug($debug);
     //Get all authsource for this plugin ( ldapAdvanced plugin, because other authsources are not needed )
     $arrayAuthenticationSource = $plugin->getAuthSources();
     $aDepartments = $plugin->getDepartments("");
     $aGroups = $plugin->getGroups();
     //$arrayDepartmentUserAd = array(); //(D) Update Users
     //$arrayGroupUserAd = array(); //(G) Update Users
     //echo "\n";
     $plugin->frontEndShow("START");
     $plugin->debugLog("START");
     foreach ($arrayAuthenticationSource as $value) {
         $arrayAuthenticationSourceData = $value;
         $plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$arrayAuthenticationSourceData ---->\n" . print_r($arrayAuthenticationSourceData, true));
         $plugin->sAuthSource = $arrayAuthenticationSourceData["AUTH_SOURCE_UID"];
         $plugin->ldapcnn = null;
         $plugin->setArrayDepartmentUserSynchronizedChecked(array());
         $plugin->setArrayUserUpdateChecked(array());
         //Get all User (USR_UID, USR_USERNAME, USR_AUTH_USER_DN) registered in RBAC with this Authentication Source
         $plugin->setArrayAuthenticationSourceUsers($arrayAuthenticationSourceData["AUTH_SOURCE_UID"]);
         //INITIALIZE DATA
         $plugin->frontEndShow("TEXT", "Authentication Source: " . $arrayAuthenticationSourceData["AUTH_SOURCE_NAME"]);
         $plugin->log(null, "Executing cron for Authentication Source: " . $arrayAuthenticationSourceData["AUTH_SOURCE_NAME"]);
         //Get all departments from Ldap/ActiveDirectory and build a hierarchy using dn (ou->ou parent)
         $aLdapDepts = $plugin->searchDepartments();
         //Obtain all departments from PM with a valid department in LDAP/ActiveDirectory
         $aRegisteredDepts = $plugin->getRegisteredDepartments($aLdapDepts, $aDepartments);
         $plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$aRegisteredDepts ---->\n" . print_r($aRegisteredDepts, true));
         //Get all group from Ldap/ActiveDirectory
         $aLdapGroups = $plugin->searchGroups();
         //Obtain all groups from PM with a valid group in LDAP/ActiveDirectory
         $aRegisteredGroups = $plugin->getRegisteredGroups($aLdapGroups, $aGroups);
         $plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$aRegisteredGroups ---->\n" . print_r($aRegisteredGroups, true));
         //Get all users from Removed OU
         $this->usersRemovedOu = $plugin->getUsersFromRemovedOu($arrayAuthenticationSourceData);
         $plugin->deactiveArrayOfUsers($this->usersRemovedOu);
         //Variables
         $this->deletedRemoved = count($this->usersRemovedOu);
         $this->deletedRemovedUsers = "";
         $this->dAlready = 0;
         $this->dMoved = 0;
         $this->dImpossible = 0;
         $this->dCreated = 0;
         $this->dRemoved = 0;
         $this->dAlreadyUsers = "";
         $this->dMovedUsers = "";
         $this->dImpossibleUsers = "";
         $this->dCreatedUsers = "";
         $this->dRemovedUsers = "";
         $this->gAlready = 0;
         $this->gMoved = 0;
         $this->gImpossible = 0;
         $this->gCreated = 0;
         $this->gRemoved = 0;
         $this->gAlreadyUsers = "";
         $this->gMovedUsers = "";
         $this->gImpossibleUsers = "";
         $this->gCreatedUsers = "";
         $this->gRemovedUsers = "";
         //Department - Synchronize Users
         $numDepartments = count($aRegisteredDepts);
         $count = 0;
         $plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$numDepartments ----> {$numDepartments}");
         foreach ($aRegisteredDepts as $registeredDept) {
             $count++;
             //(D) Update Users
             //if (!isset($arrayDepartmentUserAd[$registeredDept["DEP_UID"]])) {
             //    $arrayDepartmentUserAd[$registeredDept["DEP_UID"]] = array(); //Current users in department based in Active Directory
             //}
             //
             //$arrayAux = $this->departmentSynchronizeUsers($plugin, $numDepartments, $count, $registeredDept);
             //$arrayAux = array_merge($arrayDepartmentUserAd[$registeredDept["DEP_UID"]], $arrayAux);
             //
             //$arrayDepartmentUserAd[$registeredDept["DEP_UID"]] = array_unique($arrayAux);
             $arrayAux = $this->departmentSynchronizeUsers($plugin, $numDepartments, $count, $registeredDept);
         }
         //Department - Print log
         $logResults = sprintf("- Departments -> Existing users: %d, moved: %d, impossible: %d, created: %d, removed: %d", $this->dAlready, $this->dMoved, $this->dImpossible, $this->dCreated, $this->dRemoved);
         $plugin->frontEndShow("TEXT", $logResults);
         $plugin->log(null, $logResults);
         //Group - Synchronize Users
         $numGroups = count($aRegisteredGroups);
         $count = 0;
         $plugin->debugLog("ldapadvanced.php > function executeCron() > foreach > \$numGroups ----> {$numGroups}");
         foreach ($aRegisteredGroups as $registeredGroup) {
             $count++;
             //(G) Update Users
             //if (!isset($arrayGroupUserAd[$registeredGroup["GRP_UID"]])) {
             //    $arrayGroupUserAd[$registeredGroup["GRP_UID"]] = array(); //Current users in group based in Active Directory
             //}
             //
             //$arrayAux = $this->groupSynchronizeUsers($plugin, $numGroups, $count, $registeredGroup);
             //$arrayAux = array_merge($arrayGroupUserAd[$registeredGroup["GRP_UID"]], $arrayAux);
             //
             //$arrayGroupUserAd[$registeredGroup["GRP_UID"]] = array_unique($arrayAux);
             $arrayAux = $this->groupSynchronizeUsers($plugin, $numGroups, $count, $registeredGroup);
         }
         //Group - Print log
         $logResults = sprintf("- Groups -> Existing users: %d, moved: %d, impossible: %d, created: %d, removed: %d", $this->gAlready, $this->gMoved, $this->gImpossible, $this->gCreated, $this->gRemoved);
         $plugin->frontEndShow("TEXT", $logResults);
         $plugin->log(null, $logResults);
         //Manager
         $plugin->clearManager($this->managersToClear);
         if (isset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"])) {
             if (is_array($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"])) {
                 foreach ($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"] as $departmentUID) {
                     // Delete manager assignments
                     $criteriaSet = new Criteria("workflow");
                     $criteriaSet->add(UsersPeer::USR_REPORTS_TO, "");
                     $criteriaWhere = new Criteria("workflow");
                     $criteriaWhere->add(UsersPeer::DEP_UID, $departmentUID);
                     $criteriaWhere->add(UsersPeer::USR_REPORTS_TO, "", Criteria::NOT_EQUAL);
                     $this->deletedManager = BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow"));
                     // Delete department assignments
                     $criteriaSet = new Criteria("workflow");
                     $criteriaSet->add(UsersPeer::DEP_UID, "");
                     $criteriaWhere = new Criteria("workflow");
                     $criteriaWhere->add(UsersPeer::DEP_UID, $departmentUID);
                     $this->dMoved += UsersPeer::doCount($criteriaWhere);
                     BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow"));
                 }
             }
             unset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["DEPARTMENTS_TO_UNASSIGN"]);
             $rbac =& RBAC::getSingleton();
             $rbac->authSourcesObj->update($arrayAuthenticationSourceData);
         }
         if (isset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"])) {
             if (is_array($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"])) {
                 foreach ($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"] as $groupUID) {
                     // Delete manager assignments
                     $groupsInstance = new Groups();
                     $criteria = $groupsInstance->getUsersGroupCriteria($groupUID);
                     $dataset = UsersPeer::doSelectRS($criteria);
                     $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
                     $dataset->next();
                     $users = array();
                     while ($row = $dataset->getRow()) {
                         $users[] = $row["USR_UID"];
                         $dataset->next();
                     }
                     $criteriaSet = new Criteria("workflow");
                     $criteriaSet->add(UsersPeer::USR_REPORTS_TO, "");
                     $criteriaWhere = new Criteria("workflow");
                     $criteriaWhere->add(UsersPeer::USR_UID, $users, Criteria::IN);
                     $criteriaWhere->add(UsersPeer::USR_REPORTS_TO, "", Criteria::NOT_EQUAL);
                     $this->deletedManager = BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow"));
                     // Delete group assignments
                     $criteria = new Criteria("workflow");
                     $criteria->add(GroupUserPeer::GRP_UID, $groupUID);
                     $this->gMoved += GroupUserPeer::doCount($criteria);
                     BasePeer::doDelete($criteria, Propel::getConnection("workflow"));
                 }
             }
             unset($arrayAuthenticationSourceData["AUTH_SOURCE_DATA"]["GROUPS_TO_UNASSIGN"]);
             $rbac =& RBAC::getSingleton();
             $rbac->authSourcesObj->update($arrayAuthenticationSourceData);
         }
         // Delete the managers that not exists in PM
         $criteria = new Criteria("rbac");
         $criteria->addSelectColumn(RbacUsersPeer::USR_AUTH_USER_DN);
         $criteria->add(RbacUsersPeer::USR_AUTH_USER_DN, "", Criteria::NOT_EQUAL);
         $dataset = RbacUsersPeer::doSelectRS($criteria);
         $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $dataset->next();
         $existingUsers = array();
         while ($row = $dataset->getRow()) {
             $existingUsers[] = $row["USR_AUTH_USER_DN"];
             $dataset->next();
         }
         foreach ($this->managersHierarchy as $managerDN => $subordinates) {
             if (!in_array($managerDN, $existingUsers)) {
                 unset($this->managersHierarchy[$managerDN]);
             }
         }
         // Get the managers assigments counters
         $plugin->synchronizeManagers($this->managersHierarchy);
         $deletedManagersAssignments = self::array_diff_assoc_recursive($this->oldManagersHierarchy, $this->managersHierarchy);
         $newManagersAssignments = self::array_diff_assoc_recursive($this->managersHierarchy, $this->oldManagersHierarchy);
         $deletedManagers = array();
         $newManagers = array();
         $movedManagers = array();
         if (is_array($deletedManagersAssignments)) {
             foreach ($deletedManagersAssignments as $dn1 => $subordinates1) {
                 foreach ($subordinates1 as $subordinate) {
                     if (!in_array($subordinate, $deletedManagers)) {
                         $deletedManagers[] = $subordinate;
                     }
                     foreach ($newManagersAssignments as $dn2 => $subordinates2) {
                         if (isset($subordinates2[$subordinate])) {
                             $movedManagers[] = $subordinate;
                         }
                     }
                 }
             }
         }
         if (is_array($newManagersAssignments)) {
             foreach ($newManagersAssignments as $dn1 => $subordinates1) {
                 foreach ($subordinates1 as $subordinate) {
                     if (!in_array($subordinate, $newManagers)) {
                         $newManagers[] = $subordinate;
                     }
                     foreach ($deletedManagersAssignments as $dn2 => $subordinates2) {
                         if (isset($subordinates2[$subordinate])) {
                             if (!in_array($subordinate, $movedManagers)) {
                                 $movedManagers[] = $subordinate;
                             }
                         }
                     }
                 }
             }
         }
         //Print and log the users's information
         //Deleted/Removed Users
         $logResults = sprintf("- Deleted/Removed Users: %d", $this->deletedRemoved);
         $plugin->frontEndShow("TEXT", $logResults);
         $plugin->log(null, $logResults);
         if ($this->deletedRemoved > 0) {
             $plugin->log(null, "Deleted/Removed Users: ");
             $plugin->log(null, $this->deletedRemovedUsers);
         }
         if ($this->dAlready + $this->gAlready > 0) {
             $plugin->log(null, "Existing Users: ");
             $plugin->log(null, $this->dAlreadyUsers . " " . $this->gAlreadyUsers);
         }
         if ($this->dMoved + $this->gMoved > 0) {
             $plugin->log(null, "Moved Users: ");
             $plugin->log(null, $this->dMovedUsers . " " . $this->gMovedUsers);
         }
         if ($this->dImpossible + $this->gImpossible > 0) {
             $plugin->log(null, "Impossible Users: ");
             $plugin->log(null, $this->dImpossibleUsers . " " . $this->gImpossibleUsers);
         }
         if ($this->dCreated + $this->gCreated > 0) {
             $plugin->log(null, "Created Users: ");
             $plugin->log(null, $this->dCreatedUsers . " " . $this->gCreatedUsers);
         }
         if ($this->dRemoved + $this->gRemoved > 0) {
             $plugin->log(null, "Removed Users: ");
             $plugin->log(null, $this->dRemovedUsers . " " . $this->gRemovedUsers);
         }
         //Print and log the managers assignments"s information
         $logResults = sprintf("- Managers assignments: created %d, moved %d, removed %d", count($newManagers) - count($movedManagers), count($movedManagers), count($deletedManagers) - count($movedManagers) + $this->deletedManager);
         $plugin->frontEndShow("TEXT", $logResults);
         $plugin->log(null, $logResults);
         //Update Users data based on the LDAP Server
         $plugin->usersUpdateData($arrayAuthenticationSourceData["AUTH_SOURCE_UID"]);
     }
     $plugin->frontEndShow("END");
     //(D) Update Users
     ////Department //Upgrade users in departments
     //foreach ($arrayDepartmentUserAd as $departmentUid => $arrayUserAd) {
     //    $plugin->setArrayDepartmentUsers($departmentUid); //INITIALIZE DATA
     //
     //    $arrayAux = array_diff(array_keys($plugin->arrayDepartmentUsersByUid), $arrayUserAd);
     //
     //    $this->departmentRemoveUsers($departmentUid, $arrayAux);
     //}
     //(G) Update Users
     ////Group //Upgrade users in groups
     //foreach ($arrayGroupUserAd as $groupUid => $arrayUserAd) {
     //    $plugin->setArrayGroupUsers($groupUid); //INITIALIZE DATA
     //
     //    $arrayAux = array_diff(array_keys($plugin->arrayGroupUsersByUid), $arrayUserAd);
     //
     //    $this->groupRemoveUsers($groupUid, $arrayAux);
     //}
     //// Developed by Gary and Ronald
     //$usersInfo = $plugin->ASUpdateInfo('');
     //if (isset($usersInfo) && $usersInfo > 0) {
     //    $this->dMoved = $usersInfo;
     //}
     //// End Developed by Gary and Ronald
     $plugin->debugLog("END");
 }
Пример #11
0
function run_new_project($task, $args)
{
    global $pathHome;
    global $projectName;
    //the class filename in the first argument
    $projectName = $args[0];
    if (trim($projectName) == '') {
        printf("Error: %s\n", pakeColor::colorize("you must specify a valid name for the project", 'ERROR'));
        exit(0);
    }
    $createProject = strtolower(prompt("Do you want to create the project '{$projectName}' ? [Y/n]"));
    if ($createProject == 'n') {
        die;
    }
    G::LoadSystem('templatePower');
    define('PATH_SHARED', PATH_SEP . 'shared' . PATH_SEP . $projectName . '_data' . PATH_SEP);
    $pathHome = PATH_TRUNK . $projectName;
    printf("creating project %s in %s\n", pakeColor::colorize($projectName, 'INFO'), pakeColor::colorize($pathHome, 'INFO'));
    define('G_ENVIRONMENT', G_DEV_ENV);
    require_once "propel/Propel.php";
    //create project.conf for httpd conf
    //$dbFile = PATH_TRUNK . $projectName . PATH_SEP . 'shared' . PATH_SEP . 'sites'. PATH_SEP . 'dev'. PATH_SEP . 'db.php';
    $dbFile = PATH_SEP . PATH_SHARED . 'sites' . PATH_SEP . $projectName . PATH_SEP . 'db.php';
    $dbn = "db_" . $projectName;
    $dbrn = "rb_" . $projectName;
    $dbnpass = substr(G::GenerateUniqueId(), 0, 8);
    if (1 || !file_exists($dbFile)) {
        if (!defined('HASH_INSTALLATION')) {
            printf("%s\n", pakeColor::colorize('HASH INSTALLATION is invalid or does not exist. Please check the paths_installed.php file', 'ERROR'));
            exit(0);
        }
        $dbOpt = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));
        $connectionDatabase = mysql_connect($dbOpt[0], $dbOpt[1], $dbOpt[2]);
        if (!$connectionDatabase) {
            printf("%s\n", pakeColor::colorize('HASH INSTALLATION has invalid credentials. Please check the paths_installed.php file', 'ERROR'));
            exit(0);
        }
        printf("creating database %s \n", pakeColor::colorize($dbn, 'INFO'));
        $q = "CREATE DATABASE IF NOT EXISTS {$dbn} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
        $ac = @mysql_query($q, $connectionDatabase);
        if (!$ac) {
            printf("%s\n", pakeColor::colorize(mysql_error(), 'ERROR'));
            exit(0);
        }
        printf("creating database %s \n", pakeColor::colorize($dbrn, 'INFO'));
        $q = "CREATE DATABASE IF NOT EXISTS {$dbrn} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
        $ac = @mysql_query($q, $connectionDatabase);
        if (!$ac) {
            printf("%s\n", pakeColor::colorize(mysql_error(), 'ERROR'));
            exit(0);
        }
        $q = "GRANT ALL PRIVILEGES ON `{$dbn}`.* TO {$dbn}@'localhost' IDENTIFIED BY '{$dbnpass}' WITH GRANT OPTION";
        $ac = @mysql_query($q, $connectionDatabase);
        if (!$ac) {
            printf("%s\n", pakeColor::colorize(mysql_error(), 'ERROR'));
            exit(0);
        }
        $q = "GRANT ALL PRIVILEGES ON `{$dbrn}`.* TO {$dbn}@'localhost' IDENTIFIED BY '{$dbnpass}' WITH GRANT OPTION";
        $ac = @mysql_query($q, $connectionDatabase);
        if (!$ac) {
            printf("%s\n", pakeColor::colorize(mysql_error(), 'ERROR'));
            exit(0);
        }
        $rbSql = PATH_RBAC_MYSQL_DATA . 'schema.sql';
        printf("executing %s \n", pakeColor::colorize($rbSql, 'INFO'));
        mysql_select_db($dbrn, $connectionDatabase);
        $qrs = query_sql_file($rbSql, $connectionDatabase);
        $q = "INSERT INTO `USERS` VALUES ('00000000000000000000000000000001','admin',md5('admin'),'Administrator','','*****@*****.**','2020-01-01','2007-08-03 12:24:36','2008-02-13 07:24:07',1);";
        $ac = @mysql_query($q, $connectionDatabase);
        $q = "INSERT INTO `USERS` VALUES ('00000000000000000000000000000002','operator',md5('operator'),'Operator','','*****@*****.**','2020-01-01','2007-08-03 12:24:36','2008-02-13 07:24:07',1);";
        $ac = @mysql_query($q, $connectionDatabase);
        //database wf_  db_
        $dbInsertSql = PATH_GULLIVER_HOME . 'bin' . PATH_SEP . 'tasks' . PATH_SEP . 'templates' . PATH_SEP . 'db_insert.sql';
        printf("executing %s \n", pakeColor::colorize($dbInsertSql, 'INFO'));
        mysql_select_db($dbn, $connectionDatabase);
        $qrs = query_sql_file($dbInsertSql, $connectionDatabase);
        G::mk_dir(PATH_SHARED . 'sites' . PATH_SEP);
        G::mk_dir(PATH_SHARED . 'sites' . PATH_SEP . $projectName);
        $dbFields['rootUser'] = $dbn;
        $dbFields['rootPass'] = $dbnpass;
        create_file_from_tpl('db.php', $dbFile, $dbFields);
    }
    global $G_ENVIRONMENTS;
    $G_ENVIRONMENTS['DEVELOPMENT']['dbfile'] = $dbFile;
    //print_r ( $G_ENVIRONMENTS );
    Propel::init(PATH_CORE . "config/databases.php");
    $configuration = Propel::getConfiguration();
    $connectionDSN = $configuration['datasources']['workflow']['connection'];
    printf("using DSN Connection %s \n", pakeColor::colorize($connectionDSN, 'INFO'));
    $rbacProjectName = strtoupper($projectName);
    G::LoadSystem('rbac');
    $RBAC = RBAC::getSingleton();
    $RBAC->sSystem = $rbacProjectName;
    $RBAC->initRBAC();
    $RBAC->createSystem($rbacProjectName);
    $RBAC->createPermision(substr($rbacProjectName, 0, 3) . '_LOGIN');
    $RBAC->createPermision(substr($rbacProjectName, 0, 3) . '_ADMIN');
    $RBAC->createPermision(substr($rbacProjectName, 0, 3) . '_OPERATOR');
    $systemData = $RBAC->systemObj->LoadByCode($rbacProjectName);
    $roleData['ROL_UID'] = G::GenerateUniqueId();
    $roleData['ROL_PARENT'] = '';
    $roleData['ROL_SYSTEM'] = $systemData['SYS_UID'];
    $roleData['ROL_CODE'] = substr($rbacProjectName, 0, 3) . '_ADMIN';
    $roleData['ROL_CREATE_DATE'] = date('Y-m-d H:i:s');
    $roleData['ROL_UPDATE_DATE'] = date('Y-m-d H:i:s');
    $roleData['ROL_STATUS'] = '1';
    $RBAC->createRole($roleData);
    $roleData['ROL_UID'] = G::GenerateUniqueId();
    $roleData['ROL_PARENT'] = '';
    $roleData['ROL_SYSTEM'] = $systemData['SYS_UID'];
    $roleData['ROL_CODE'] = substr($rbacProjectName, 0, 3) . '_OPERATOR';
    $roleData['ROL_CREATE_DATE'] = date('Y-m-d H:i:s');
    $roleData['ROL_UPDATE_DATE'] = date('Y-m-d H:i:s');
    $roleData['ROL_STATUS'] = '1';
    $RBAC->createRole($roleData);
    $roleData = $RBAC->rolesObj->LoadByCode(substr($rbacProjectName, 0, 3) . '_ADMIN');
    //Assign permissions to ADMIN
    $roleData = $RBAC->rolesObj->LoadByCode(substr($rbacProjectName, 0, 3) . '_ADMIN');
    $permData = $RBAC->permissionsObj->LoadByCode(substr($rbacProjectName, 0, 3) . '_LOGIN');
    $RBAC->assignPermissionToRole($roleData['ROL_UID'], $permData['PER_UID']);
    $permData = $RBAC->permissionsObj->LoadByCode(substr($rbacProjectName, 0, 3) . '_ADMIN');
    $RBAC->assignPermissionToRole($roleData['ROL_UID'], $permData['PER_UID']);
    $userRoleData['ROL_UID'] = $roleData['ROL_UID'];
    $userRoleData['USR_UID'] = '00000000000000000000000000000001';
    $RBAC->assignUserToRole($userRoleData);
    //Assign permissions to OPERATOR
    $roleData = $RBAC->rolesObj->LoadByCode(substr($rbacProjectName, 0, 3) . '_OPERATOR');
    $permData = $RBAC->permissionsObj->LoadByCode(substr($rbacProjectName, 0, 3) . '_LOGIN');
    $RBAC->assignPermissionToRole($roleData['ROL_UID'], $permData['PER_UID']);
    $permData = $RBAC->permissionsObj->LoadByCode(substr($rbacProjectName, 0, 3) . '_OPERATOR');
    $RBAC->assignPermissionToRole($roleData['ROL_UID'], $permData['PER_UID']);
    $userRoleData['ROL_UID'] = $roleData['ROL_UID'];
    $userRoleData['USR_UID'] = '00000000000000000000000000000002';
    $RBAC->assignUserToRole($userRoleData);
    //create folder and structure
    G::mk_dir($pathHome);
    G::mk_dir($pathHome . PATH_SEP . 'public_html');
    G::mk_dir($pathHome . PATH_SEP . 'public_html' . PATH_SEP . 'images');
    G::mk_dir($pathHome . PATH_SEP . 'public_html' . PATH_SEP . 'skins');
    G::mk_dir($pathHome . PATH_SEP . 'public_html' . PATH_SEP . 'skins' . PATH_SEP . 'green');
    G::mk_dir($pathHome . PATH_SEP . 'public_html' . PATH_SEP . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'images');
    G::mk_dir($pathHome . PATH_SEP . 'engine');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'classes');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'model');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'map');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'om');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'config');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'content');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'content' . PATH_SEP . 'languages');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'content' . PATH_SEP . 'translations');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'data');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'data' . PATH_SEP . 'mysql');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'js');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'js' . PATH_SEP . 'labels');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'menus');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'methods');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'login');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'users');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'skins');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'templates');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'test');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'test' . PATH_SEP . 'bootstrap');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'test' . PATH_SEP . 'fixtures');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'test' . PATH_SEP . 'unit');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'xmlform');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'login');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'gulliver');
    G::mk_dir($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'users');
    //create project.conf for httpd conf
    create_file_from_tpl('httpd.conf', $projectName . '.conf');
    create_file_from_tpl('sysGeneric.php', 'public_html' . PATH_SEP . 'sysGeneric.php');
    copy_file_from_tpl('bm.jpg', 'public_html' . PATH_SEP . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'images' . PATH_SEP . 'bm.jpg');
    copy_file_from_tpl('bsm.jpg', 'public_html' . PATH_SEP . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'images' . PATH_SEP . 'bsm.jpg');
    create_file_from_tpl('index.html', 'public_html' . PATH_SEP . 'index.html');
    create_file_from_tpl('paths.php', 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
    create_file_from_tpl('defines.php', 'engine' . PATH_SEP . 'config' . PATH_SEP . 'defines.php');
    create_file_from_tpl('databases.php', 'engine' . PATH_SEP . 'config' . PATH_SEP . 'databases.php');
    $fields['dbName'] = 'mysql';
    create_file_from_tpl('propel.ini', 'engine' . PATH_SEP . 'config' . PATH_SEP . 'propel.ini', $fields);
    create_file_from_tpl('propel.ini', 'engine' . PATH_SEP . 'config' . PATH_SEP . 'propel.mysql.ini', $fields);
    if (file_exists($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'schema.xml')) {
        $createSchema = strtolower(prompt("schema.xml exists!. Do you want to overwrite the schema.xml file? [y/N]"));
        if ($createSchema == 'y') {
            create_file_from_tpl('schema.xml', 'engine' . PATH_SEP . 'config' . PATH_SEP . 'schema.xml');
        }
    } else {
        create_file_from_tpl('schema.xml', 'engine' . PATH_SEP . 'config' . PATH_SEP . 'schema.xml');
    }
    create_file_from_tpl('sysLogin.php', 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'login' . PATH_SEP . 'sysLogin.php');
    create_file_from_tpl('login.php', 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'login' . PATH_SEP . 'login.php');
    create_file_from_tpl('authentication.php', 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'login' . PATH_SEP . 'authentication.php');
    create_file_from_tpl('welcome.php', 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'login' . PATH_SEP . 'welcome.php');
    create_file_from_tpl('dbInfo.php', 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'login' . PATH_SEP . 'dbInfo.php');
    create_file_from_tpl('usersList.php', 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'users' . PATH_SEP . 'usersList.php');
    create_file_from_tpl('rolesList.php', 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'users' . PATH_SEP . 'rolesList.php');
    create_file_from_tpl('permissionsList.php', 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'users' . PATH_SEP . 'permissionsList.php');
    create_file_from_tpl('sysLogin.xml', 'engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'login' . PATH_SEP . 'sysLogin.xml');
    create_file_from_tpl('login.xml', 'engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'login' . PATH_SEP . 'login.xml');
    create_file_from_tpl('showMessage.xml', 'engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'login' . PATH_SEP . 'showMessage.xml');
    create_file_from_tpl('welcome.xml', 'engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'login' . PATH_SEP . 'welcome.xml');
    copy_file_from_tpl('xmlform.html', 'engine' . PATH_SEP . 'templates' . PATH_SEP . 'xmlform.html');
    copy_file_from_tpl('publish.php', 'engine' . PATH_SEP . 'templates' . PATH_SEP . 'publish.php');
    copy_file_from_tpl('publish-treeview.php', 'engine' . PATH_SEP . 'templates' . PATH_SEP . 'publish-treeview.php');
    create_file_from_tpl('dbInfo.xml', 'engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'login' . PATH_SEP . 'dbInfo.xml');
    create_file_from_tpl('usersList.xml', 'engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'users' . PATH_SEP . 'usersList.xml');
    create_file_from_tpl('rolesList.xml', 'engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'users' . PATH_SEP . 'rolesList.xml');
    create_file_from_tpl('permissionsList.xml', 'engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'users' . PATH_SEP . 'permissionsList.xml');
    create_file_from_tpl('mainmenu.php', 'engine' . PATH_SEP . 'menus' . PATH_SEP . $projectName . '.php');
    create_file_from_tpl('users.menu.php', 'engine' . PATH_SEP . 'menus' . PATH_SEP . 'users.php');
    copy_file('public_html' . PATH_SEP . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'style.css');
    copy_file('public_html' . PATH_SEP . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'images' . PATH_SEP . 'bsms.jpg');
    copy_file('public_html' . PATH_SEP . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'images' . PATH_SEP . 'ftl.png');
    copy_file('public_html' . PATH_SEP . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'images' . PATH_SEP . 'ftr.png');
    copy_file('public_html' . PATH_SEP . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'images' . PATH_SEP . 'fbl.png');
    copy_file('public_html' . PATH_SEP . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'images' . PATH_SEP . 'fbr.png');
    copy_file('public_html' . PATH_SEP . 'skins' . PATH_SEP . 'green' . PATH_SEP . 'images' . PATH_SEP . 'fbc.png');
    copy_file('public_html' . PATH_SEP . 'images' . PATH_SEP . 'favicon.ico');
    copy_file('public_html' . PATH_SEP . 'images' . PATH_SEP . 'bulletButton.gif');
    copy_file('public_html' . PATH_SEP . 'images' . PATH_SEP . 'bulletSubMenu.jpg');
    copy_file('public_html' . PATH_SEP . 'images' . PATH_SEP . 'users.png');
    copy_file('public_html' . PATH_SEP . 'images' . PATH_SEP . 'trigger.gif');
    copy_file('engine' . PATH_SEP . 'skins' . PATH_SEP . 'green.html');
    copy_file('engine' . PATH_SEP . 'skins' . PATH_SEP . 'green.php');
    copy_file('engine' . PATH_SEP . 'skins' . PATH_SEP . 'blank.html');
    copy_file('engine' . PATH_SEP . 'skins' . PATH_SEP . 'blank.php');
    copy_file('engine' . PATH_SEP . 'skins' . PATH_SEP . 'raw.html');
    copy_file('engine' . PATH_SEP . 'skins' . PATH_SEP . 'raw.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.ArrayPeer.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.BasePeer.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.configuration.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.plugin.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.pluginRegistry.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.popupMenu.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.propelTable.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'Application.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'ApplicationPeer.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'Content.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'ContentPeer.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'Configuration.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'ConfigurationPeer.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'om' . PATH_SEP . 'BaseApplication.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'om' . PATH_SEP . 'BaseApplicationPeer.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'om' . PATH_SEP . 'BaseContent.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'om' . PATH_SEP . 'BaseContentPeer.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'om' . PATH_SEP . 'BaseConfiguration.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'om' . PATH_SEP . 'BaseConfigurationPeer.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'map' . PATH_SEP . 'ApplicationMapBuilder.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'map' . PATH_SEP . 'ContentMapBuilder.php');
    copy_file('engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP . 'map' . PATH_SEP . 'ConfigurationMapBuilder.php');
    copy_file('engine' . PATH_SEP . 'config' . PATH_SEP . 'environments.php');
    copy_file('engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'login' . PATH_SEP . 'login.xml');
    copy_file('engine' . PATH_SEP . 'xmlform' . PATH_SEP . 'gulliver' . PATH_SEP . 'pagedTable_PopupMenu.xml');
    copy_file('engine' . PATH_SEP . 'templates' . PATH_SEP . 'popupMenu.html');
    copy_file('engine' . PATH_SEP . 'templates' . PATH_SEP . 'paged-table.html');
    copy_file('engine' . PATH_SEP . 'templates' . PATH_SEP . 'xmlmenu.html');
    copy_file('engine' . PATH_SEP . 'templates' . PATH_SEP . 'filterform.html');
    copy_file('engine' . PATH_SEP . 'templates' . PATH_SEP . 'tree.html');
    copy_file('engine' . PATH_SEP . 'templates' . PATH_SEP . 'dummyTemplate.html');
    $filePng = $pathHome . PATH_SEP . 'public_html' . PATH_SEP . 'images' . PATH_SEP . 'processmaker.logo.jpg';
    createPngLogo($filePng, $projectName);
    if (!PHP_OS == "WINNT") {
        printf("creating symlinks %s \n", pakeColor::colorize($pathHome . PATH_SEP . 'engine' . PATH_SEP . 'gulliver', 'INFO'));
        symlink(PATH_GULLIVER_HOME . 'bin' . PATH_SEP . 'gulliver', $pathHome . PATH_SEP . 'engine' . PATH_SEP . 'gulliver');
    }
    //create schema.xml with empty databases
    exit(0);
}
Пример #12
0
    /**
     * Put execute trigger case
     *
     * @access public
     * @param string $app_uid , Uid for case
     * @param string $usr_uid , Uid for user
     * @param bool|string $del_index , Index for case
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
     */
    public function putExecuteTriggerCase($app_uid, $tri_uid, $usr_uid, $del_index = false)
    {
        Validator::isString($app_uid, '$app_uid');
        Validator::isString($tri_uid, '$tri_uid');
        Validator::isString($usr_uid, '$usr_uid');

        Validator::appUid($app_uid, '$app_uid');
        Validator::triUid($tri_uid, '$tri_uid');
        Validator::usrUid($usr_uid, '$usr_uid');

        if ($del_index === false) {
            $del_index = \AppDelegation::getCurrentIndex($app_uid);
        }
        Validator::isInteger($del_index, '$del_index');

        global $RBAC;
        if (!method_exists($RBAC, 'initRBAC')) {
            $RBAC = \RBAC::getSingleton( PATH_DATA, session_id() );
            $RBAC->sSystem = 'PROCESSMAKER';
        }

        $case = new \wsBase();
        $result = $case->executeTrigger($usr_uid, $app_uid, $tri_uid, $del_index);

        if ($result->status_code != 0) {
            throw new \Exception($result->message);
        }
    }
Пример #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
 }
Пример #14
0
 function searchUsers($sKeyword)
 {
     $sKeyword = trim($sKeyword);
     $RBAC = RBAC::getSingleton();
     $aAuthSource = $RBAC->authSourcesObj->load($this->sAuthSource);
     $pass = explode("_", $aAuthSource['AUTH_SOURCE_PASSWORD']);
     foreach ($pass as $index => $value) {
         if ($value == '2NnV3ujj3w') {
             $aAuthSource['AUTH_SOURCE_PASSWORD'] = G::decrypt($pass[0], $aAuthSource['AUTH_SOURCE_SERVER_NAME']);
         }
     }
     $oLink = @ldap_connect($aAuthSource['AUTH_SOURCE_SERVER_NAME'], $aAuthSource['AUTH_SOURCE_PORT']);
     @ldap_set_option($oLink, LDAP_OPT_PROTOCOL_VERSION, $aAuthSource['AUTH_SOURCE_VERSION']);
     @ldap_set_option($oLink, LDAP_OPT_REFERRALS, 0);
     if (isset($aAuthSource['AUTH_SOURCE_ENABLED_TLS']) && $aAuthSource['AUTH_SOURCE_ENABLED_TLS']) {
         @ldap_start_tls($oLink);
     }
     if ($aAuthSource['AUTH_ANONYMOUS'] == '1') {
         $bBind = @ldap_bind($oLink);
     } else {
         $bBind = @ldap_bind($oLink, $aAuthSource['AUTH_SOURCE_SEARCH_USER'], $aAuthSource['AUTH_SOURCE_PASSWORD']);
     }
     if (!$bBind) {
         throw new Exception('Unable to bind to server : ' . $aAuthSource['AUTH_SOURCE_SERVER_NAME'] . ' in port ' . $aAuthSource['AUTH_SOURCE_PORT']);
     }
     if (substr($sKeyword, -1) != '*') {
         if ($sKeyword != '') {
             $sKeyword = '*' . $sKeyword . '*';
         } else {
             $sKeyword .= '*';
         }
     }
     $additionalFilter = isset($aAuthSource['AUTH_SOURCE_DATA']['AUTH_SOURCE_ADDITIONAL_FILTER']) ? trim($aAuthSource['AUTH_SOURCE_DATA']['AUTH_SOURCE_ADDITIONAL_FILTER']) : '';
     $sFilter = '(&(|(objectClass=*))';
     if (isset($aAuthSource['AUTH_SOURCE_DATA']['LDAP_TYPE']) && $aAuthSource['AUTH_SOURCE_DATA']['LDAP_TYPE'] == 'ad') {
         $sFilter = "(&(|(objectClass=*))(|(samaccountname={$sKeyword})(userprincipalname={$sKeyword})){$additionalFilter})";
     } else {
         $sFilter = "(&(|(objectClass=*))(|(uid={$sKeyword})(cn={$sKeyword})){$additionalFilter})";
     }
     //G::pr($sFilter);
     $aUsers = array();
     $oSearch = @ldap_search($oLink, $aAuthSource['AUTH_SOURCE_BASE_DN'], $sFilter, array('dn', 'uid', 'samaccountname', 'cn', 'givenname', 'sn', 'mail', 'userprincipalname', 'objectcategory', 'manager'));
     if ($oError = @ldap_errno($oLink)) {
         return $aUsers;
     } else {
         if ($oSearch) {
             if (@ldap_count_entries($oLink, $oSearch) > 0) {
                 $sUsername = '';
                 $oEntry = @ldap_first_entry($oLink, $oSearch);
                 $uidUser = isset($aAuthSource['AUTH_SOURCE_DATA']['AUTH_SOURCE_IDENTIFIER_FOR_USER']) ? $aAuthSource['AUTH_SOURCE_DATA']['AUTH_SOURCE_IDENTIFIER_FOR_USER'] : '******';
                 do {
                     $aAttr = $this->getLdapAttributes($oLink, $oEntry);
                     $sUsername = isset($aAttr[$uidUser]) ? $aAttr[$uidUser] : '';
                     if ($sUsername != '') {
                         // note added by gustavo cruz gustavo-at-colosa.com
                         // assign the givenname and sn fields if these are set
                         $aUsers[] = array('sUsername' => $sUsername, 'sFullname' => $aAttr['cn'], 'sFirstname' => isset($aAttr['givenname']) ? $aAttr['givenname'] : '', 'sLastname' => isset($aAttr['sn']) ? $aAttr['sn'] : '', 'sEmail' => isset($aAttr['mail']) ? $aAttr['mail'] : (isset($aAttr['userprincipalname']) ? $aAttr['userprincipalname'] : ''), 'sDN' => $aAttr['dn']);
                     }
                 } while ($oEntry = @ldap_next_entry($oLink, $oEntry));
             }
         }
         return $aUsers;
     }
 }