public function setAction()
 {
     $nResource = $this->_getParam('res_id', 0);
     $nRole = $this->_getParam('ucr_id', 0);
     $nEnable = $this->_getBoolParam('enable', 1);
     $this->_model = User_AccessList::Table();
     $selectResult = $this->_model->select()->where('ucal_resource_id = ?', $nResource)->where('ucal_role_id = ?', $nRole);
     $this->_object = $this->_model->fetchRow($selectResult);
     if (!is_object($this->_object)) {
         if ($nEnable) {
             $this->_object = $this->_model->createRow();
             $this->_object->ucal_resource_id = $nResource;
             $this->_object->ucal_role_id = $nRole;
             $this->_object->save();
         }
     } else {
         if (!$nEnable) {
             $this->_object->delete();
             $this->_object = null;
         }
     }
     $this->view->object = $this->_object;
 }
示例#2
0
 /**
  * @return void
  */
 public function _delete()
 {
     if (!$this->isPredefined()) {
         //delete all user-roles with this role
         $selectRoles = User_UserRole::Table()->select()->where('ucur_role_id = ?', $this->getId());
         foreach (User_UserRole::Table()->fetchAll($selectRoles) as $objUserRole) {
             $objUserRole->delete();
         }
         //delete all access list for this resource
         $selectList = User_AccessList::Table()->select()->where('ucal_role_id = ? ', $this->getId());
         foreach (User_AccessList::Table()->fetchAll($selectList) as $objAccessList) {
             $objAccessList->delete();
         }
     }
 }
示例#3
0
 /**
  * @return array
  */
 public static function getTables()
 {
     return array(User_Option::TableName(), User_Account::TableName(), User_Role::TableName(), User_UserRole::TableName(), User_AccessList::TableName());
 }