Example #1
0
 /**
  * Function getRolesBySystem
  * access public
  */
 function getRolesBySystem($SysUid, $UsrUid)
 {
     $con = Propel::getConnection(UsersRolesPeer::DATABASE_NAME);
     try {
         $c = new Criteria('rbac');
         $c->clearSelectColumns();
         $c->addSelectColumn(RolesPeer::ROL_UID);
         $c->addSelectColumn(RolesPeer::ROL_CODE);
         $c->addJoin(UsersRolesPeer::ROL_UID, RolesPeer::ROL_UID);
         $c->add(UsersRolesPeer::USR_UID, $UsrUid);
         $c->add(RolesPeer::ROL_SYSTEM, $SysUid);
         $rs = UsersRolesPeer::doSelectRs($c);
         $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $rs->next();
         $row = $rs->getRow();
         /*  return only the first row, no other rows can be permitted
             while ( is_array ( $row ) ) {
               $rows[] = $row;
               $rs->next();
               $row = $rs->getRow();
             }
             */
         return $row;
     } catch (Exception $oError) {
         throw $oError;
     }
 }
 /**
  * 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 = UsersRolesPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setUsrUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setRolUid($arr[$keys[1]]);
     }
 }
Example #3
0
 /**
  * remove a role from an user
  *
  * @access public
  * @param array $sUserUID
  * @return void
  */
 public function removeRolesFromUser($sUserUID = '')
 {
     $oCriteria = new Criteria('rbac');
     $oCriteria->add(UsersRolesPeer::USR_UID, $sUserUID);
     UsersRolesPeer::doDelete($oCriteria);
 }
Example #4
0
 function deleteUserRole($ROL_UID, $USR_UID)
 {
     $crit = new Criteria();
     $crit->add(UsersRolesPeer::USR_UID, $USR_UID);
     if ($ROL_UID != '%') {
         $crit->add(UsersRolesPeer::ROL_UID, $ROL_UID);
     }
     UsersRolesPeer::doDelete($crit);
     $rol = $this->load($ROL_UID);
     $oUsersRbac = new RbacUsers();
     $user = $oUsersRbac->load($USR_UID);
     G::auditLog("DeleteUserToRole", "Delete user " . $user['USR_USERNAME'] . " (" . $USR_UID . ") to Role " . $rol['ROL_NAME'] . " (" . $ROL_UID . ") ");
 }
 /**
 * Retrieve object using using composite pkey values.
 * @param string $usr_uid
   @param string $rol_uid
   
 * @param      Connection $con
 * @return     UsersRoles
 */
 public static function retrieveByPK($usr_uid, $rol_uid, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $criteria = new Criteria();
     $criteria->add(UsersRolesPeer::USR_UID, $usr_uid);
     $criteria->add(UsersRolesPeer::ROL_UID, $rol_uid);
     $v = UsersRolesPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
Example #6
0
 function deleteUserRole($ROL_UID, $USR_UID)
 {
     $crit = new Criteria();
     $crit->add(UsersRolesPeer::USR_UID, $USR_UID);
     if ($ROL_UID != '%') {
         $crit->add(UsersRolesPeer::ROL_UID, $ROL_UID);
     }
     UsersRolesPeer::doDelete($crit);
 }
Example #7
0
 public function getUserRole($UsrUid)
 {
     $con = Propel::getConnection(UsersRolesPeer::DATABASE_NAME);
     try {
         $c = new Criteria('rbac');
         $c->clearSelectColumns();
         $c->addSelectColumn(RolesPeer::ROL_UID);
         $c->addSelectColumn(RolesPeer::ROL_CODE);
         $c->addSelectColumn(RolesPeer::ROL_STATUS);
         $c->addJoin(UsersRolesPeer::ROL_UID, RolesPeer::ROL_UID);
         $c->add(UsersRolesPeer::USR_UID, $UsrUid);
         $rs = UsersRolesPeer::doSelectRs($c);
         $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $rs->next();
         $row = $rs->getRow();
         return $row;
     } catch (Exception $oError) {
         throw $oError;
     }
 }
Example #8
0
 /**
  * Verify if not it's assigned the User to Role
  *
  * @param string $roleUid               Unique id of Role
  * @param string $userUid               Unique id of User
  * @param string $fieldNameForException Field name for the exception
  *
  * return void Throw exception if not it's assigned the User to Role
  */
 public function throwExceptionIfNotItsAssignedUserToRole($roleUid, $userUid, $fieldNameForException)
 {
     try {
         $obj = \UsersRolesPeer::retrieveByPK($userUid, $roleUid);
         if (is_null($obj)) {
             throw new \Exception(\G::LoadTranslation("ID_ROLE_USER_IS_NOT_ASSIGNED", array($fieldNameForException, $userUid)));
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }