/**
  * Returns the assignments authorised for the specified item.
  * @param string the item name.
  * @return array CAuthAssignments authorised for the item
  */
 public function getItemEAuthAssignments($name)
 {
     $owner = $this->getOwner();
     $roles = array();
     if ($owner->getAuthItem($name)->getType() == CAuthItem::TYPE_ROLE) {
         $roles[] = $owner->db->quoteValue($name);
     }
     $authItems = $this->getEAncestors($name);
     foreach ($authItems as $authItem) {
         if ($authItem->getType() == CAuthItem::TYPE_ROLE) {
             $roles[] = $owner->db->quoteValue($authItem->getName());
         }
     }
     $assignments = array();
     if (!empty($roles)) {
         $sql = "SELECT* FROM {$owner->assignmentTable} WHERE itemname IN (" . join(', ', $roles) . ')';
         foreach ($owner->db->createCommand($sql)->queryAll() as $row) {
             $assignment = new CAuthAssignment($this, $row['itemname'], $row['userid'], $row['bizrule'], unserialize($row['data']));
             $assignment->attachBehavior('RbamAuthAssignmentBehavior', array('class' => 'RbamAuthAssignmentBehavior', 'module' => $this->module));
             $assignments[] = $assignment;
         }
         // foreach
     }
     return $assignments;
 }
Example #2
0
 /**
  * Saves the changes to an authorization assignment.
  * @param CAuthAssignment $assignment the assignment that has been changed.
  */
 public function saveAuthAssignment($assignment)
 {
     $this->db->createCommand()->update($this->assignmentTable, array('bizrule' => $assignment->getBizRule(), 'data' => serialize($assignment->getData())), 'itemname=:itemname AND userid=:userid', array('itemname' => $assignment->getItemName(), 'userid' => $assignment->getUserId()));
 }
 /**
  * Saves the changes to an authorization assignment.
  * @param CAuthAssignment $assignment the assignment that has been changed.
  */
 public function saveAuthAssignment($assignment)
 {
     $sql = "UPDATE {$this->assignmentTable} SET bizrule=:bizrule, data=:data WHERE itemname=:itemname AND userid=:userid";
     $command = $this->db->createCommand($sql);
     $command->bindValue(':bizrule', $assignment->getBizRule());
     $command->bindValue(':data', serialize($assignment->getData()));
     $command->bindValue(':itemname', $assignment->getItemName());
     $command->bindValue(':userid', $assignment->getUserId());
     $command->execute();
 }
Example #4
0
 public function __construct($auth, $itemName, $userId, $bizRule = null, $data = null, $condition = null)
 {
     parent::__construct($auth, $itemName, $userId, $bizRule, $data);
     $this->_condition = $condition;
 }