/** * {@inheritDoc} * @see IPluggableAccessManager::saveAuthAssignment() */ public function saveAuthAssignment(IPluggableModule $module, IPluggableAccessAssignment $assignment) { $role = $assignment->getAccessRole(); if (!$role instanceof AccessRole) { $role = $this->getAuthItem($module, $assignment->getAccessRole()->getRoleName()); if ($role === null) { return false; } } $criteria = new CDbCriteria(); $criteria->with = array('accessRole' => array('alias' => 'r')); $criteria->compare('r.module_name', $module->getId()); $criteria->compare('access_role_id', $role->access_role_id); $criteria->compare('user_profile_id', $assignment->getUserProfile()->getId()); $aaa = AccessAssignment::model()->find($criteria); if ($aaa === null) { $aaa = new AccessAssignment(); $aaa->access_role_id = $role->access_role_id; $aaa->user_profile_id = $assignment->getUserProfile()->getId(); } $aaa->biz_rule = $assignment->getBusinessRule(); $aaa->setData($assignment->getData()); return $aaa->save(); }
/** * {@inheritDoc} * @see IPluggableAccessManager::saveAuthAssignment() */ public function saveAuthAssignment(IPluggableModule $module, IPluggableAccessAssignment $assignment) { $authAssignment = new CAuthAssignment($this, $assignment->getAccessRole()->getRoleName(), $assignment->getUserProfile()->getId(), $assignment->getBusinessRule(), $assignment->getData()); $this->_manager->saveAuthAssignment($authAssignment); return true; }