Ejemplo n.º 1
0
 public function index()
 {
     $user_query_struct = array('where' => array(), 'like' => array(), 'orderby' => array(), 'limit' => array('per_page' => 20, 'offset' => 0));
     /* 搜索功能 */
     $search_arr = array('id', 'email', 'firstname', 'lastname', 'ip', 'mobile', 'real_name');
     $search_value = $this->input->get('search_value');
     $search_type = $this->input->get('search_type');
     $where_view = array();
     if ($search_arr) {
         foreach ($search_arr as $value) {
             if ($search_type == $value && strlen($search_value) > 0) {
                 $user_query_struct['like'][$value] = $search_value;
                 //$user_query_struct['where'][$value] = $search_value;
                 if ($value == 'ip') {
                     $user_query_struct['like'][$value] = tool::myip2long($search_value);
                     //$user_query_struct['where'][$value] = tool::myip2long($search_value);
                 }
             }
         }
         $where_view['search_type'] = $search_type;
         $where_view['search_value'] = $search_value;
     }
     /* 列表排序 */
     $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 4 => array('email' => 'ASC'), 5 => array('email' => 'DESC'), 6 => array('firstname' => 'ASC'), 7 => array('firstname' => 'DESC'), 8 => array('lastname' => 'ASC'), 9 => array('lastname' => 'DESC'), 10 => array('date_add' => 'ASC'), 11 => array('date_add' => 'DESC'), 12 => array('ip' => 'ASC'), 13 => array('ip' => 'DESC'), 14 => array('active' => 'ASC'), 15 => array('active' => 'DESC'), 16 => array('register_mail_active' => 'ASC'), 17 => array('register_mail_active' => 'DESC'));
     $orderby = controller_tool::orderby($orderby_arr);
     $user_query_struct['orderby'] = $orderby;
     /* 每页显示条数 */
     $per_page = controller_tool::per_page();
     $user_query_struct['limit']['per_page'] = $per_page;
     /* 调用分页 */
     $this->pagination = new Pagination(array('total_items' => Myuser::instance()->query_count($user_query_struct), 'items_per_page' => $per_page));
     $user_query_struct['limit']['offset'] = $this->pagination->sql_offset;
     $user_list = Myuser::instance()->query_assoc($user_query_struct);
     //找出所有的站点的用户等级信息
     $user_levelservice = User_levelService::get_instance();
     $query_struct = array('where' => array('active' => 1));
     $user_levels = $user_levelservice->index($query_struct);
     $tmp = array();
     foreach ($user_levels as $user_level) {
         if ($user_level['is_default']) {
             $tmp['default'] = $user_level;
         }
         $tmp[$user_level['id']] = $user_level;
     }
     $user_levels = $tmp;
     foreach ($user_list as $key => $value) {
         $users[$key]['level'] = '';
         if (!empty($user_levels[$value['level_id']])) {
             $users[$key]['level'] = $user_levels[$value['level_id']]['name_manage'];
         } else {
             //$users[$key]['level'] = $user_levels['default']['name_manage'];
         }
     }
     $this->template->content = new View("superplaner/agent_select_list");
     $this->template->content->where = $where_view;
     $this->template->content->user_list = $user_list;
 }
Ejemplo n.º 2
0
 /**
  * 取得用户的等级
  */
 public static function user_level()
 {
     $session = Session::instance();
     $user = $session->get('user');
     if (empty($user)) {
         return false;
     } else {
         $user_level = User_levelService::get_instance()->get_level($user['level_id']);
         return !empty($user_level['name']) ? $user_level['name'] : '';
     }
 }
Ejemplo n.º 3
0
 /**
  * 刷新用户的等级
  * @param int $user_id
  */
 public function refresh_user_level($user_id)
 {
     if (empty(self::$users[$user_id])) {
         $users = $this->lists(array('where' => array('id' => $user_id)));
         self::$users[$user_id] = !empty($users) ? $users[0] : NULL;
     }
     $user = self::$users[$user_id];
     if (empty($user)) {
         return false;
     } else {
         //取得level的信息
         $query_struct = array('where' => array(), 'orderby' => array('score' => 'ASC'));
         $user_levels = User_levelService::get_instance()->index($query_struct);
         //判断用户级别是否为特殊等级
         foreach ($user_levels as $user_level) {
             //特殊等级不能够自动的升级
             if ($user_level['id'] == $user['level_id'] && $user_level['is_special']) {
                 return false;
             }
         }
         //普通等级自动升级
         $user_level_id = $user['level_id'];
         foreach ($user_levels as $user_level) {
             if (!$user_level['is_special']) {
                 if ($user['score'] >= $user_level['score']) {
                     $user_level_id = $user_level['id'];
                 }
                 if ($user['score'] < $user_level['score']) {
                     break;
                 }
             }
         }
         if ($user_level_id != $user['level_id']) {
             $this->set($user_id, array('level_id' => $user_level_id));
         }
     }
 }
Ejemplo n.º 4
0
 public function formula()
 {
     role::check('user_level');
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => '');
     try {
         //调用底层服务
         $site_detail_service = Mysite_detail::instance();
         $user_level_service = User_levelService::get_instance();
         //取得当前的站点详细信息
         $site_detail = array();
         $site_detail = $site_detail_service->get_by_site_id();
         if (empty($site_detail)) {
             $site_detail = $user_level_service->set_default_level();
         }
         $this->template->content = new View('user/site_score_formula');
         $this->template->content->site_detail = $site_detail;
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }