/**
  * 后台首页 
  */
 public function indexAction()
 {
     $admin_service = new AdminService();
     $admin = $admin_service->checkLogin();
     $admin_id = $admin['admin_id'];
     $department_id = $admin['department_id'];
     //管理员菜单列表
     $admin_menus = $admin_service->getAdminMenus($admin_id, $department_id);
     //一级菜单
     $top_menus = $admin_service->getTopMenu();
     $this->view->assign(array('menus' => json_encode($admin_menus), 'top_menus' => json_encode($top_menus), 'admin' => $admin));
 }
 /**
  * 修改菜单
  * 
  * @return type 
  */
 public function editmenuAction()
 {
     $second_menus = array();
     $request = $this->getRequest();
     $menu_id = (int) $request->getParam('menu_id');
     $admin_service = new AdminService();
     $menu_info = $admin_service->getMenuById($menu_id);
     if (empty($menu_info)) {
         return $this->showWarning('对不起,菜单不存在。', '/system/menumanage');
     }
     if ($request->isPost()) {
         $parent_id = $menu_info['parent_id'];
         $top_id = $menu_info['top_id'];
         $menu_name = Star_String::escape($request->getParam('menu_name'));
         $sort = (int) $request->getParam('sort');
         $is_show = (int) $request->getParam('is_show');
         $controller = $request->getParam('controller');
         $action = $request->getParam('action');
         if (empty($menu_name)) {
             return $this->showWarning('对不起,菜单名称不能为空。');
         }
         if ($parent_id == 0) {
             $controller = '';
             $action = '';
             $is_show = 1;
         }
         if ($parent_id && $parent_id == $top_id) {
             $menu_info = $admin_service->getMenuByid($parent_id);
             if (!$menu_info) {
                 return $this->showWarning('对不起,上级菜单不存在,请确认数据是否有误。');
             }
             if ($menu_info['menu_level'] != 1) {
                 return $this->showWarning('对不起,上级菜单不是为一级菜单。');
             }
             $is_show = 1;
             $controller = '';
             $action = 0;
         }
         if ($parent_id && $parent_id != $top_id) {
             if (empty($controller)) {
                 return $this->showWarning('对不起,Controller不能为空。');
             }
             if (empty($action)) {
                 return $this->showWarning('对不起,Action不能为空。');
             }
         }
         $menu_data = array('controller' => $controller, 'action' => $action, 'menu_name' => $menu_name, 'sort' => $sort, 'is_show' => $is_show, 'update_time' => time());
         $rs = $admin_service->updateMenu($menu_id, $menu_data);
         if ($rs) {
             return $this->showMessage('恭喜您,修改成功。', '/system/menumanage');
         } else {
             return $this->showWarning('很遗憾,修改失败。');
         }
     }
     $top_id = $menu_info['menu_level'] == 1 ? $menu_info['menu_id'] : $menu_info['top_id'];
     $second_menus = $admin_service->getMenuByParent($top_id);
     $menus = $admin_service->getTopMenu();
     $this->view->assign(array('menu' => $menu_info, 'menus' => $menus, 'second_menus' => $second_menus));
     $this->render('menuinfo');
 }