示例#1
0
 public function afterSave()
 {
     $model = $this->getOwner();
     $class = get_class($model);
     AuthObject::model()->deleteAllByAttributes(array('object_id' => $model->id, 'model_id' => $class));
     if (isset($_POST[$class]['roles'])) {
         foreach ($_POST[$class]['roles'] as $role) {
             $auth_object = new AuthObject();
             $auth_object->model_id = $class;
             $auth_object->object_id = $model->id;
             $auth_object->role = $role;
             $auth_object->save();
         }
     }
     return true;
 }
示例#2
0
    public function authObject()
    {
        $object_ids = AuthObject::model()->getObjectsIds(get_class($this), Yii::app()->user->role);

        $criteria = $this->getDbCriteria();
        $criteria->addInCondition('id', $object_ids);
        return $this;
    }