/**
  * 编辑管理员
  */
 public function editadminAction()
 {
     $request = $this->getRequest();
     $admin_service = new AdminService();
     $admin_id = (int) $request->getParam('admin_id');
     $admin_info = $admin_service->getAdminById($admin_id);
     if (empty($admin_info)) {
         return $this->showWarning('对不起,管理员不存在', '/system/adminmanage');
     }
     if ($request->isPost()) {
         $username = Star_String::escape($request->getParam('username'));
         $admin_name = Star_String::escape($request->getParam('admin_name'));
         $department_id = (int) $request->getParam('department_id');
         $password = $request->getParam('password');
         if ($password && Star_String::strLength($password) < 6) {
             return $this->showWarning('对不起,密码不能少于6个字符。');
         }
         if (empty($username)) {
             return $this->showWarning('对不起,用户名不能为空。');
         }
         $admin_data = array('admin_name' => $admin_name, 'department_id' => $department_id, 'update_time' => time());
         $password && ($admin_data['password'] = Password::Encryption($username, $password));
         $rs = $admin_service->updateAdmin($admin_id, $admin_data);
         if ($rs) {
             $admin_service->deleteAuth('admin_id = ' . (int) $admin_info['admin_id']);
             //删除用户权限
             $menu_ids = $request->getParam('menu_ids');
             if (!empty($menu_ids)) {
                 $menu_ids = array_unique($menu_ids);
                 foreach ($menu_ids as $menu_id) {
                     $auth_data = array('menu_id' => (int) $menu_id, 'department_id' => 0, 'admin_id' => $admin_id, 'add_time' => time(), 'update_time' => time());
                     //添加权限
                     $admin_service->insertAuth($auth_data);
                 }
             }
             return $this->showWarning('恭喜您,修改成功。', '/system/adminmanage');
         } else {
             return $this->showWarning('很遗憾,修改失败。');
         }
     }
     $departments = $admin_service->getDepartmentOption();
     $menus = $admin_service->getAllSortMenu();
     //返回所有菜单
     $department_auth_options = $admin_service->getDepartmentAuthOption($admin_info['department_id']);
     //返回部门所有权限
     $admin_auth_options = $admin_service->getAdminAuthOption($admin_info['admin_id']);
     $this->view->assign(array('admin' => $admin_info, 'departments' => $departments, 'menus' => $menus, 'department_auth_options' => $department_auth_options, 'admin_auth_options' => $admin_auth_options));
     $this->render('admininfo');
 }