function getAllUsers($ROL_UID, $filter = '') { try { $c = new Criteria(); $c->addSelectColumn(RbacUsersPeer::USR_UID); $c->add(RolesPeer::ROL_UID, $ROL_UID); $c->addJoin(RolesPeer::ROL_UID, UsersRolesPeer::ROL_UID); $c->addJoin(UsersRolesPeer::USR_UID, RbacUsersPeer::USR_UID); $result = RolesPeer::doSelectRS($c); $result->setFetchmode(ResultSet::FETCHMODE_ASSOC); $result->next(); $a = array(); while ($row = $result->getRow()) { $a[] = $row['USR_UID']; $result->next(); } $criteria = new Criteria(); $criteria->addSelectColumn(RbacUsersPeer::USR_UID); $criteria->addSelectColumn(RbacUsersPeer::USR_USERNAME); $criteria->addSelectColumn(RbacUsersPeer::USR_FIRSTNAME); $criteria->addSelectColumn(RbacUsersPeer::USR_LASTNAME); $criteria->add(RbacUsersPeer::USR_STATUS, 1, Criteria::EQUAL); $criteria->add(RbacUsersPeer::USR_UID, $a, Criteria::NOT_IN); if ($filter != '') { $criteria->add($criteria->getNewCriterion(RbacUsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($criteria->getNewCriterion(RbacUsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE)->addOr($criteria->getNewCriterion(RbacUsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE)))); } $oDataset = RbacUsersPeer::doSelectRS($criteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); return $oDataset; } catch (exception $e) { throw $e; } }
function getListUsersByAuthSource($auth_source) { $oCriteria = new Criteria('rbac'); $oCriteria->addSelectColumn(RbacUsersPeer::USR_UID); if ($auth_source == '00000000000000000000000000000000') { $oCriteria->add($oCriteria->getNewCriterion(RbacUsersPeer::UID_AUTH_SOURCE, $auth_source, Criteria::EQUAL)->addOr($oCriteria->getNewCriterion(RbacUsersPeer::UID_AUTH_SOURCE, '', Criteria::EQUAL))); } else { $oCriteria->add(RbacUsersPeer::UID_AUTH_SOURCE, $auth_source, Criteria::EQUAL); } $oCriteria->add(RbacUsersPeer::USR_STATUS, 0, Criteria::NOT_EQUAL); $oDataset = RbacUsersPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $aUsers = array(); while ($oDataset->next()) { $row = $oDataset->getRow(); $aUsers[] = $row['USR_UID']; } return $aUsers; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = RbacUsersPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setUsrUid($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setUsrUsername($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setUsrPassword($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setUsrFirstname($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setUsrLastname($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setUsrEmail($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setUsrDueDate($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setUsrCreateDate($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setUsrUpdateDate($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setUsrStatus($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setUsrAuthType($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setUidAuthSource($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setUsrAuthUserDn($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setUsrAuthSupervisorDn($arr[$keys[13]]); } }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param Connection $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(RbacUsersPeer::USR_UID, $pks, Criteria::IN); $objs = RbacUsersPeer::doSelect($criteria, $con); } return $objs; }
function getAllAuthSourcesByUser() { $oCriteria = new Criteria('rbac'); $oCriteria->addSelectColumn(RbacUsersPeer::USR_UID); $oCriteria->addSelectColumn(AuthenticationSourcePeer::AUTH_SOURCE_NAME); $oCriteria->addSelectColumn(AuthenticationSourcePeer::AUTH_SOURCE_PROVIDER); $oCriteria->add(RbacUsersPeer::USR_STATUS, 0, Criteria::NOT_EQUAL); $oCriteria->addJoin(RbacUsersPeer::UID_AUTH_SOURCE, AuthenticationSourcePeer::AUTH_SOURCE_UID, Criteria::INNER_JOIN); $oDataset = RbacUsersPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $aAuth = array(); while ($oDataset->next()) { $row = $oDataset->getRow(); $aAuth[$row['USR_UID']] = $row['AUTH_SOURCE_NAME'] . ' (' . $row['AUTH_SOURCE_PROVIDER'] . ')'; } return $aAuth; }
public function setHashPassword($object) { $type = array('md5', 'sha256'); if (!in_array($object->hash, $type)) { throw new Exception('Type: ' . $object->hash . ' No valid.'); return false; } G::LoadClass("configuration"); $config = new Configurations(); $typeEncrypt = $config->getConfiguration('ENTERPRISE_SETTING_ENCRYPT', ''); if ($typeEncrypt == null) { $typeEncrypt = array('current' => $object->hash, 'previous' => 'md5'); } else { $typeEncrypt['previous'] = $typeEncrypt['current']; $typeEncrypt['current'] = $object->hash; } if ($object->hash != $typeEncrypt['previous']) { $config->aConfig = $typeEncrypt; $config->saveConfig('ENTERPRISE_SETTING_ENCRYPT', ''); } require_once 'classes/model/RbacUsersPeer.php'; require_once 'classes/model/UsersProperties.php'; $userProperty = new UsersProperties(); $criteria = new Criteria($object->workspace->dbInfo['DB_RBAC_NAME']); $criteria->add(RbacUsersPeer::USR_STATUS, 0, Criteria::NOT_EQUAL); $dataset = RbacUsersPeer::doSelectRS($criteria); $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); while ($dataset->next()) { $row = $dataset->getRow(); $property = $userProperty->loadOrCreateIfNotExists($row['USR_UID'], array()); $property['USR_LOGGED_NEXT_TIME'] = 1; $userProperty->update($property); } }
/** 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"); }
/** * Get all Users of a Role * * @param string $roleUid Unique id of Role * @param string $option Option (USERS, AVAILABLE-USERS) * @param array $arrayFilterData Data of the filters * @param string $sortField Field name to sort * @param string $sortDir Direction of sorting (ASC, DESC) * @param int $start Start * @param int $limit Limit * * return array Return an array with all Users of a Role */ public function getUsers($roleUid, $option, array $arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null) { try { $arrayUser = array(); //Verify data $process = new \ProcessMaker\BusinessModel\Process(); $role = new \ProcessMaker\BusinessModel\Role(); $role->throwExceptionIfNotExistsRole($roleUid, $this->arrayFieldNameForException["roleUid"]); $process->throwExceptionIfDataNotMetFieldDefinition(array("OPTION" => $option), array("OPTION" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("USERS", "AVAILABLE-USERS"), "fieldNameAux" => "option")), array("option" => "\$option"), true); $process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), $this->arrayFieldNameForException); //Get data if (!is_null($limit) && $limit . "" == "0") { return $arrayUser; } //SQL switch ($option) { case "USERS": //Criteria $criteria = $this->getUserCriteria($roleUid); break; case "AVAILABLE-USERS": //Get Uids $arrayUid = array(); $criteria = $this->getUserCriteria($roleUid); $rsCriteria = \RbacUsersPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $arrayUid[] = $row["USR_UID"]; } //Criteria $criteria = $this->getUserCriteria("", $arrayUid); break; } if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") { $criteria->add($criteria->getNewCriterion(\RbacUsersPeer::USR_USERNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr($criteria->getNewCriterion(\RbacUsersPeer::USR_FIRSTNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)->addOr($criteria->getNewCriterion(\RbacUsersPeer::USR_LASTNAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE)))); } //SQL if (!is_null($sortField) && trim($sortField) != "") { $sortField = strtoupper($sortField); if (in_array($sortField, array("USR_UID", "USR_USERNAME", "USR_FIRSTNAME", "USR_LASTNAME", "USR_STATUS"))) { $sortField = \RbacUsersPeer::TABLE_NAME . "." . $sortField; } else { $sortField = \RbacUsersPeer::USR_USERNAME; } } else { $sortField = \RbacUsersPeer::USR_USERNAME; } if (!is_null($sortDir) && trim($sortDir) != "" && strtoupper($sortDir) == "DESC") { $criteria->addDescendingOrderByColumn($sortField); } else { $criteria->addAscendingOrderByColumn($sortField); } if (!is_null($start)) { $criteria->setOffset((int) $start); } if (!is_null($limit)) { $criteria->setLimit((int) $limit); } $rsCriteria = \RbacUsersPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $arrayUser[] = $this->getUserDataFromRecord($row); } //Return return $arrayUser; } catch (\Exception $e) { throw $e; } }
public function generateInfoSupport() { require_once PATH_CONTROLLERS . "installer.php"; $params = array(); $oServerConf =& serverConf::getSingleton(); $pluginRegistry =& PMPluginRegistry::getSingleton(); $licenseManager =& pmLicenseManager::getSingleton(); //License Information: $activeLicense = $licenseManager->getActiveLicense(); $licenseInfo = array(); $noInclude = array('licensedfeaturesList', 'result', 'serial'); foreach ($licenseManager as $index => $value) { if (!in_array($index, $noInclude)) { $licenseInfo[$index] = G::sanitizeInput($value); } } $params['l'] = $licenseInfo; //Operative System version (Linux, Windows) try { $os = ''; if (file_exists('/etc/redhat-release')) { $fnewsize = filesize('/etc/redhat-release'); $fp = fopen('/etc/redhat-release', 'r'); $os = trim(fread($fp, $fnewsize)); fclose($fp); } $os .= " (" . PHP_OS . ")"; } catch (Exception $e) { } $params['s'] = $os; //On premise or cloud $licInfo = $oServerConf->getProperty('LICENSE_INFO'); $params['lt'] = isset($licInfo[SYS_SYS]) ? isset($licInfo[SYS_SYS]['TYPE']) ? $licInfo[SYS_SYS]['TYPE'] : '' : ''; //ProcessMaker Version $params['v'] = System::getVersion(); if (file_exists(PATH_DATA . 'log/upgrades.log')) { $params['pmu'] = serialize(file_get_contents(PATH_DATA . 'log/upgrades.log', 'r')); } else { $params['pmu'] = serialize(G::LoadTranslation('ID_UPGRADE_NEVER_UPGRADE')); } //Database server Version (MySQL version) $installer = new Installer(); $systemInfo = $installer->getSystemInfo(); try { $params['mysql'] = mysql_get_server_info(); } catch (Exception $e) { $params['mysql'] = ''; } //PHP Version $params['php'] = $systemInfo->php->version; //Apache - IIS Version try { $params['apache'] = apache_get_version(); } catch (Exception $e) { $params['apache'] = ''; } //Installed Plugins (license info?) $arrayAddon = array(); if (file_exists(PATH_DATA_SITE . "ee")) { $arrayAddon = unserialize(trim(file_get_contents(PATH_DATA_SITE . "ee"))); } $plugins = array(); foreach ($arrayAddon as $addon) { $sFileName = substr($addon["sFilename"], 0, strpos($addon["sFilename"], "-")); if (file_exists(PATH_PLUGINS . $sFileName . ".php")) { $plugin = array(); $addonDetails = $pluginRegistry->getPluginDetails($sFileName . ".php"); $plugin['name'] = $addonDetails->sNamespace; $plugin['description'] = $addonDetails->sDescription; $plugin['version'] = $addonDetails->iVersion; $plugin['enable'] = $addonDetails->enabled; $plugins[] = $plugin; } } $params['pl'] = $plugins; //Number of Users registered in PM. Including LDAP users and PM users. require_once "classes/model/RbacUsers.php"; $criteria = new Criteria("rbac"); $criteria->addSelectColumn(RbacUsersPeer::USR_AUTH_TYPE); $criteria->addSelectColumn("COUNT(" . RbacUsersPeer::USR_UID . ") AS USERS_NUMBER"); $criteria->add(RbacUsersPeer::USR_UID, null, Criteria::ISNOTNULL); $criteria->addGroupByColumn(RbacUsersPeer::USR_AUTH_TYPE); $rs = RbacUsersPeer::doSelectRS($criteria); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $users = array('local' => 0); while ($rs->next()) { $row = $rs->getRow(); if ($row['USR_AUTH_TYPE'] == '' || $row['USR_AUTH_TYPE'] == 'MYSQL') { $users['local'] = (int) $users['local'] + (int) $row['USERS_NUMBER']; } else { $users['USR_AUTH_TYPE'] = $row['USERS_NUMBER']; } } $params['u'] = $users; //Number of cases. $oSequences = new Sequences(); $maxNumber = $oSequences->getSequeceNumber("APP_NUMBER"); $params['c'] = $maxNumber - 1; //Number of active processes. $criteria = new Criteria("workflow"); $criteria->addSelectColumn(ProcessPeer::PRO_STATUS); $criteria->addSelectColumn("COUNT(PROCESS.PRO_UID) AS NUMBER_PROCESS"); $criteria->addGroupByColumn(ProcessPeer::PRO_STATUS); $rs = UsersPeer::doSelectRS($criteria); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $process = array(); while ($rs->next()) { $row = $rs->getRow(); $process[$row['PRO_STATUS']] = $row['NUMBER_PROCESS']; } $params['p'] = $process; //Country/city (Timezone) $params['t'] = defined('TIME_ZONE') && TIME_ZONE != "Unknown" ? TIME_ZONE : date_default_timezone_get(); $params['w'] = count(System::listWorkspaces()); $support = PATH_DATA_SITE . G::sanitizeString($licenseManager->info['FIRST_NAME'] . '-' . $licenseManager->info['LAST_NAME'] . '-' . SYS_SYS . '-' . date('YmdHis'), false, false) . '.spm'; file_put_contents($support, serialize($params)); G::streamFile($support, true); G::rm_dir($support); }