Ejemplo n.º 1
0
 function getAllPermissions($sRolUid, $sUsrUid)
 {
     $con = Propel::getConnection(RolesPermissionsPeer::DATABASE_NAME);
     try {
         $c = new Criteria('rbac');
         //      $c->clearSelectColumns();
         $c->addSelectColumn(RolesPermissionsPeer::PER_UID);
         $c->addSelectColumn(PermissionsPeer::PER_CODE);
         $c->addJoin(RolesPermissionsPeer::PER_UID, PermissionsPeer::PER_UID);
         $c->add(RolesPermissionsPeer::ROL_UID, $sRolUid);
         $rs = RolesPermissionsPeer::doSelectRs($c);
         $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $rs->next();
         $row = $rs->getRow();
         $rows = array();
         while (is_array($row)) {
             $rows[] = $row;
             $rs->next();
             $row = $rs->getRow();
         }
         return $rows;
     } catch (Exception $oError) {
         throw $oError;
     }
 }
Ejemplo n.º 2
0
 function create($aData)
 {
     try {
         $oCriteria = new Criteria('rbac');
         $oCriteria->add(RolesPermissionsPeer::ROL_UID, $aData['ROL_UID']);
         $oCriteria->add(RolesPermissionsPeer::PER_UID, $aData['PER_UID']);
         $oDataset = RolesPermissionsPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $aRow = $oDataset->getRow();
         if (is_array($aRow)) {
             return true;
         }
         $oRolesPermissions = new RolesPermissions();
         $oRolesPermissions->fromArray($aData, BasePeer::TYPE_FIELDNAME);
         $iResult = $oRolesPermissions->save();
         return true;
     } catch (Exception $oError) {
         throw $oError;
     }
 }
Ejemplo n.º 3
0
 function deletePermissionRole($ROL_UID, $PER_UID)
 {
     $crit = new Criteria();
     $crit->add(RolesPermissionsPeer::ROL_UID, $ROL_UID);
     $crit->add(RolesPermissionsPeer::PER_UID, $PER_UID);
     RolesPermissionsPeer::doDelete($crit);
     $o = new RolesPermissions();
     $o->setPerUid($PER_UID);
     $permission = $o->getPermissionName($PER_UID);
     $role = $this->load($ROL_UID);
     G::auditLog("DeletePermissionToRole", "Delete Permission " . $permission . " (" . $PER_UID . ") from Role " . $role['ROL_NAME'] . " (" . $ROL_UID . ") ");
 }
 /**
 * Retrieve object using using composite pkey values.
 * @param string $rol_uid
   @param string $per_uid
   
 * @param      Connection $con
 * @return     RolesPermissions
 */
 public static function retrieveByPK($rol_uid, $per_uid, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $criteria = new Criteria();
     $criteria->add(RolesPermissionsPeer::ROL_UID, $rol_uid);
     $criteria->add(RolesPermissionsPeer::PER_UID, $per_uid);
     $v = RolesPermissionsPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
Ejemplo n.º 5
0
 function deletePermissionRole($ROL_UID, $PER_UID)
 {
     $crit = new Criteria();
     $crit->add(RolesPermissionsPeer::ROL_UID, $ROL_UID);
     $crit->add(RolesPermissionsPeer::PER_UID, $PER_UID);
     RolesPermissionsPeer::doDelete($crit);
 }
Ejemplo n.º 6
0
 /**
  * Verify if not it's assigned the Permission to Role
  *
  * @param string $roleUid               Unique id of Role
  * @param string $permissionUid         Unique id of Permission
  * @param string $fieldNameForException Field name for the exception
  *
  * return void Throw exception if not it's assigned the Permission to Role
  */
 public function throwExceptionIfNotItsAssignedPermissionToRole($roleUid, $permissionUid, $fieldNameForException)
 {
     try {
         $obj = \RolesPermissionsPeer::retrieveByPK($roleUid, $permissionUid);
         if (is_null($obj)) {
             throw new \Exception(\G::LoadTranslation("ID_ROLE_PERMISSION_IS_NOT_ASSIGNED", array($fieldNameForException, $permissionUid)));
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
 /**
  * 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 = RolesPermissionsPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setRolUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setPerUid($arr[$keys[1]]);
     }
 }