Esempio n. 1
0
File: Role.php Progetto: pancke/yyaf
 /**
  * 编辑角色
  * @return NULL|boolean
  */
 public function editAction()
 {
     if ($this->isPost()) {
         //修改密码验证
         $aCookie = Util_Cookie::get(Yaf_G::getConf('authkey', 'cookie'));
         $iAdminID = $aCookie['iAdminID'];
         $aUser = Model_Admin::getDetail($iAdminID);
         $pwd = $this->getParam('pwd');
         if (!isset($pwd) || $pwd == '') {
             return $this->showMsg('修改密码不可以为空', false);
         }
         if ($aUser['sEditPassword'] != md5($pwd)) {
             return $this->showMsg('修改密码不正确', false);
         }
         $aRole = $this->_checkData('update');
         if (empty($aRole)) {
             return null;
         }
         $aRole['iRoleID'] = intval($this->getParam('iRoleID'));
         if (1 == Model_Role::updData($aRole)) {
             return $this->showMsg('角色信息更新成功!', true);
         } else {
             return $this->showMsg('角色信息更新失败!', false);
         }
     } else {
         $iRoleID = intval($this->getParam('id'));
         $aRole = Model_Role::getDetail($iRoleID);
         $aRole['aPermission'] = explode(',', $aRole['sPermission']);
         $aRole['aModule'] = explode(',', $aRole['sModule']);
         $this->assign('aRole', $aRole);
         $this->assign('aPermissionList', Model_Permission::getAllPermissions());
         $this->assign('aMenuList', Model_Menu::getMenus());
     }
 }