Пример #1
0
 /**
  * 编辑菜单
  */
 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);
         }
         $aMenu = $this->_checkData('update');
         if (empty($aMenu)) {
             return null;
         }
         $aMenu['iMenuID'] = intval($this->getParam('iMenuID'));
         $aOldMenu = Model_Menu::getDetail($aMenu['iMenuID']);
         if (empty($aOldMenu)) {
             return $this->showMsg('菜单不存在!', false);
         }
         //更新排序,加在最后面
         if ($aOldMenu['iParentID'] != $aMenu['iParentID']) {
             $aMenu['iOrder'] = Model_Menu::getNextOrder($aMenu['iParentID']);
         }
         if (1 == Model_Menu::updData($aMenu)) {
             return $this->showMsg('菜单信息更新成功!', true);
         } else {
             return $this->showMsg('菜单信息更新失败!', false);
         }
     } else {
         $iMenuID = intval($this->getParam('id'));
         $aMenu = Model_Menu::getDetail($iMenuID);
         $aTree = Model_Menu::getMenus();
         $this->assign('aTree', $aTree);
         $this->assign('aMenu', $aMenu);
     }
 }