Ejemplo n.º 1
0
 public function indexAction()
 {
     $id = $this->getRequest()->getParam('id');
     $admin = $this->session->get('admin_user');
     $admin = unserialize($admin);
     if ($id != $admin['id']) {
         $admin = $this->verify(__METHOD__);
     }
     $data = array();
     $data['self'] = 1;
     /* 取全部管理组 */
     //        $show['group_list'] = db_admin_group::get_admin_group_list(' id desc ', 'all');
     $data['group_list'] = Admin_GroupModel::instance()->fetchAll(array('order' => 'id desc'));
     /* 取全部项目 */
     //        $show['porject_list'] = db_fqa_project::get_fqa_project_list();
     $data['project_list'] = Admin_ProjectModel::instance()->fetchAll();
     if (empty($id)) {
         $data['pagename'] = '添加管理员';
         $data['url'] = '/admin/user/list';
     } else {
         $data['pagename'] = '编辑管理员';
         //            $data['info'] = db_admin::get_admin_by_id($id);
         $data['info'] = Admin_AdminModel::instance()->fetchRow(array('condition' => 'id = ?', 'bind' => array($id)));
         $data['info']['gid'] = explode(',', $data['info']['gid']);
         $data['info']['project_id'] = explode(',', $data['info']['project_id']);
         if ($data['info']['id'] == $admin['id']) {
             $data['self'] = 0;
         }
         $data['id'] = $id;
         $data['url'] = $this->getRequest()->getParam('url');
     }
     $data['menu'] = Widget_Admin_MenuModel::headerMenu();
     $this->setInvokeArg('layout', 'admin2_layout');
     $this->render($data);
 }
Ejemplo n.º 2
0
 public static function instance()
 {
     if (null == self::$_instance) {
         self::$_instance = new self();
     }
     self::$_instance->selectTable(self::$_table);
     return self::$_instance;
 }
Ejemplo n.º 3
0
 public function indexAction()
 {
     //        $this->verify(__METHOD__);
     //@todo $this->verify(__METHOD__);
     $id = $this->getRequest()->getParam('id');
     Admin_GroupModel::instance()->delete(array('id' => $id));
     $this->sendMsg(1, '删除成功');
     //        db_admin_group::delete_admin_group_by_id($id);
 }
Ejemplo n.º 4
0
 public function indexAction()
 {
     //        $this->verify(__METHOD__);
     //@todo $this->verify(__METHOD__);
     $data = array();
     $data['list'] = Admin_GroupModel::instance()->fetchAll(array('order' => 'group_name asc'));
     $data['menu'] = Widget_Admin_MenuModel::headerMenu();
     $this->setInvokeArg('layout', 'admin2_layout');
     $this->render($data);
 }
Ejemplo n.º 5
0
 public function indexAction()
 {
     //        $this->verify(__METHOD__);
     //@todo $this->verify(__METHOD__);
     $data = array();
     $id = $this->getRequest()->getParam('id');
     $data['menu_list'] = Admin_MenuModel::instance()->fetchAll(array('condition' => 'no_verify = 0', 'order' => 'id desc'));
     $data['menu_list'] = Widget_Admin_MenuModel::tree($data['menu_list'], 'parent_id');
     if (!empty($id)) {
         $data['info'] = Admin_GroupModel::instance()->fetchRow(array('condition' => 'id = ? and status = 1', 'bind' => array($id)));
         $data['info']['menu_id'] = explode(',', $data['info']['menu_id']);
         $data['info']['menu_id'] = array_unique($data['info']['menu_id']);
         $data['info']['menu_id'] = array_flip($data['info']['menu_id']);
         $data['pagename'] = '编辑账号组';
     } else {
         $data['pagename'] = '添加账号组';
     }
     $data['menu'] = Widget_Admin_MenuModel::headerMenu();
     $this->setInvokeArg('layout', 'admin2_layout');
     $this->render($data);
 }
Ejemplo n.º 6
0
 public function indexAction()
 {
     //        $this->verify(__METHOD__);
     //@todo $this->verify(__METHOD__);
     $menu_id = $this->getRequest()->getPost('menu_id');
     $menu_id = join(',', $menu_id);
     $id = $this->getRequest()->getPost('id');
     $group_name = $this->getRequest()->getPost('group_name');
     //        $_POST['menu_id'] = implode(',',$_POST['menu_id']);
     if (!empty($menu_id)) {
         $menu_id = ',' . $menu_id . ',';
     }
     if (empty($id)) {
         /* 插入 */
         //            db_admin_group::insert_admin_group($_POST['group_name'], $_POST['menu_id']);
         Admin_GroupModel::instance()->add(array('group_name' => $group_name, 'menu_id' => $menu_id, 'status' => 1));
     } else {
         /* 更新 */
         //            db_admin_group::update_admin_group_by_id($_POST['id'], $_POST['group_name'], $_POST['menu_id']);
         Admin_GroupModel::instance()->update(array('group_name' => $group_name, 'menu_id' => $menu_id, 'status' => 1), array('id' => $id));
     }
     $this->_redirect('/admin/group/list');
 }
Ejemplo n.º 7
0
 public function indexAction()
 {
     if ($this->getRequest()->getMethod() != 'POST') {
         $params = array('title' => '好教乐学');
         $this->render($params);
     } else {
         $params = $this->getRequest()->getPost();
         $params['password'] = md5($params['password'] . md5($params['password']));
         $admin_user = Admin_AdminModel::instance()->fetchRow(array('condition' => 'username = ? and password = ? and status = 1', 'bind' => array($params['username'], $params['password'])));
         if ($admin_user === false) {
             $return = array('status' => -1, 'msg' => '用户名或密码错误', 'data' => array());
             echo json_encode($return);
             exit;
         }
         if (!empty($admin_user['gid'])) {
             /* 查询账号组 */
             $admin_group = Admin_GroupModel::instance()->getAdminGroupByIds($admin_user['gid']);
             foreach ($admin_group as $val) {
                 $menu_id[] = $val['menu_id'];
             }
             $admin_group['menu_id'] = implode(',', $menu_id);
             /* 删除menu_id 第一位和最后一位 */
             $admin_group['menu_id'] = substr($admin_group['menu_id'], 1, strlen($admin_group['menu_id']) - 2);
             /* 查询菜单 */
             if (!empty($admin_group['menu_id'])) {
                 //                    $admin_menu_list = db_admin_menu::get_admin_menu_list_by_ids($admin_group['menu_id']);
                 $admin_menu_list = Admin_MenuModel::instance()->getAdminMenuListByIds($admin_group['menu_id']);
             }
             /* 转换菜单数组,取出action和fun */
             $admin_menu_list_temp = array();
             foreach ($admin_menu_list as $key => $val) {
                 //                    $admin_menu_list_temp[$val['modle'] . '_' . $val['action']] = 1;
                 $admin_menu_list_temp[$val['modle'] . '/' . $val['action']] = 1;
             }
             /* 设置默认菜单,此方法不需要后台赋予权限 */
             $admin_menu_list_temp['admin/index'] = 1;
             $admin_menu_list_temp['admin/right'] = 1;
             $admin_menu_list_temp['admin/menu'] = 1;
             /* 日志 */
             $admin_menu_list_temp['daily_lists'] = 1;
             $admin_menu_list_temp['daily_edit'] = 1;
             $admin_menu_list_temp['api_json_insert_daily'] = 1;
             $admin_menu_list = $admin_menu_list_temp;
             /* 设置COOKIE */
             $admin_user['menu_id'] = $admin_group['menu_id'];
             $admin_user['menu_list'] = $admin_menu_list;
             //var_dump($admin_user);exit;
             //                cookie::set_cookie('admin_user', $admin_user);
             $this->session->add('admin_user', serialize($admin_user));
             /* 更新登陆时间和登陆ip */
             //                db_admin::update_admin_login_by_id($admin_user['id']);
             $data = array('logintime' => date("Y-m-d H:i:s"), 'login_ip' => $this->getRequest()->getClientIp());
             Admin_AdminModel::instance()->update($data, array('id' => $admin_user['id']));
         }
         $callback_url = $this->getRequest()->getPost('url');
         if (empty($callback_url)) {
             $callback_url = '/admin/index';
         }
         $return = array('status' => 0, 'msg' => '登陆成功', 'data' => array('callback' => $callback_url));
         echo json_encode($return);
         exit;
         // $this->_redirect($callback_url);
     }
 }
Ejemplo n.º 8
0
 public function indexAction()
 {
     //检查权限
     $this->verify(__METHOD__);
     $show['pagename'] = '管理员列表';
     $username = $this->getRequest()->getQuery('username', '');
     $perpage = 20;
     $page = intval($this->getRequest()->getQuery('page'));
     $page = $page ? $page : 1;
     $project_list = Admin_ProjectModel::instance()->fetchAll();
     $project_list_tmp = array();
     foreach ($project_list as $val) {
         $project_list_tmp[$val['id']] = $val;
     }
     $option = array('condition' => 'status = 1', 'order' => 'id desc', 'limit' => array('offset' => ($page - 1) * $perpage, 'count' => $perpage));
     if (!empty($username)) {
         $option['condition'] .= " and username like ?";
         $option['bind'] = array("%{$username}%");
     }
     $data['list'] = Admin_AdminModel::instance()->fetchAll($option);
     $gids = array();
     foreach ($data['list'] as $val) {
         $gids[] = $val['gid'];
     }
     $gids = join(',', $gids);
     $gids = explode(',', $gids);
     $group_list_tmp = array();
     if (!empty($gids[0])) {
         //            $gids = array_unique($gids);
         //            $group_list = db_admin_group::get_admin_group_by_ids($gids);
         $group_list = Admin_GroupModel::instance()->getAdminGroupByIds($gids);
         foreach ($group_list as $key => $val) {
             $group_list_tmp[$val['id']] = $val;
         }
         foreach ($data['list'] as $key => $val) {
             $val['gid'] = explode(',', $val['gid']);
             foreach ($val['gid'] as $val2) {
                 $data['list'][$key]['group'][] = isset($group_list_tmp[$val2]['group_name']) ? $group_list_tmp[$val2]['group_name'] : '';
             }
             $val['project_id'] = explode(',', $val['project_id']);
             foreach ($val['project_id'] as $val2) {
                 //var_dump($val['project_id'], $val2, $val['gid']);exit;
                 $data['list'][$key]['project'][] = isset($project_list_tmp[$val2]['project_name']) ? $project_list_tmp[$val2]['project_name'] : '';
             }
             $data['list'][$key]['project'] = implode(' , ', $data['list'][$key]['project']);
             $data['list'][$key]['group'] = implode(' , ', $data['list'][$key]['group']);
         }
     }
     if (!empty($username)) {
         $count_opt = array('condition' => "username like ? and status = 1", 'bind' => array("%{$username}%"));
     } else {
         $count_opt = array('condition' => 'status = 1');
     }
     $data['count'] = Admin_AdminModel::instance()->count($count_opt);
     $pagination = new Pagination();
     $data['page'] = $pagination->maxnum($data['count'], $perpage)->show('page_metronic');
     $data['menu'] = Widget_Admin_MenuModel::headerMenu();
     $data['username'] = $username;
     $data['url'] = rawurlencode($this->getRequest()->getServer('REQUEST_URI'));
     $this->setInvokeArg('layout', 'admin2_layout');
     $this->render($data);
 }
Ejemplo n.º 9
0
 /**
  * 函数名称:saverulebygroupAction
  * 功能描述:保存编辑用户组的权限
  */
 public function saverulebygroupAction()
 {
     $groupid = $this->getPost('groupid');
     if (is_numeric($groupid) && $groupid != 1) {
         $checkedArr = $this->getPost('checkbox');
         $model = new Admin_GroupModel();
         $result = $model->saveEditRuleByGroupId($groupid, $checkedArr);
         $this->redirect('list');
     } else {
         $this->redirect('list');
         return false;
     }
 }