Ejemplo n.º 1
0
 public function bearers()
 {
     $user_model = M('Users');
     $medal_model = M('Medal');
     $medal = $medal_model->find($_GET['id']);
     //从session中读取搜索条件
     if (isset($_SESSION['admin_bearers_condition']) && !isset($_GET['clear'])) {
         $admin_bearers_condition = $_SESSION['admin_bearers_condition'];
     } else {
         $_GET['medal_id'] = $_GET['id'];
         $admin_bearers_condition = array('type' => 'all');
     }
     //用传入的搜索条件覆盖现有的搜索条件
     //XXX: sql injection prevention relies on PHP settings. see get_magic_quotes_gpc()
     foreach ($_GET as $key => $value) {
         $admin_bearers_condition[$key] = $value;
     }
     if ($_GET['q'] == 'all') {
         $admin_bearers_condition['q'] = '';
     }
     //保存搜索条件
     $_SESSION['admin_bearers_condition'] = $admin_bearers_condition;
     extract($admin_bearers_condition);
     //筛选
     $where_clause = array();
     if ($type != 'all') {
         $where_clause['type'] = $type;
     }
     if (!empty($q)) {
         $where_clause['name'] = array('like', "%{$q}%");
     }
     import("ORG.Util.TBPage");
     $listRows = C('ADMIN_ROW_LIST');
     $user_count = $user_model->where($where_clause)->count();
     $Page = new TBPage($user_count, $listRows);
     $user_model->field("*, (select count(*) from medalmap where user_id=users.id and medal_id={$medal_id}) is_granted");
     $user_result = $user_model->where($where_clause)->order('create_time desc')->limit($Page->firstRow . ',' . $listRows)->select();
     $page_bar = $Page->show();
     $bearer_info = $this->get_bearer_names($medal['id']);
     $bearer_count = $bearer_info[0];
     $bearer_names = $bearer_info[1];
     $this->assign('medal', $medal);
     $this->assign('q', $q);
     $this->assign('check', $check);
     $this->assign('type', $type);
     $this->assign('user_result', $user_result);
     $this->assign('page', $page_bar);
     $this->assign('bearer_count', $bearer_count);
     $this->assign('bearer_names', $bearer_names);
     $this->display();
 }
Ejemplo n.º 2
0
 public function index()
 {
     $news_model = new NewsModel();
     import("ORG.Util.TBPage");
     $listRows = C('ADMIN_ROW_LIST');
     $news_count = $news_model->news()->count();
     $Page = new TBPage($news_count, $listRows);
     $news_result = $news_model->order('create_time desc')->limit($Page->firstRow . ',' . $listRows)->select();
     $page_bar = $Page->show();
     $this->assign('q', $q);
     $this->assign('check', $check);
     $this->assign('type', $type);
     $this->assign('news_result', $news_result);
     $this->assign('page', $page_bar);
     $this->display();
 }
Ejemplo n.º 3
0
 public function post_list($local_id, $content_id)
 {
     $local_map_model = new LocalMapModel();
     $local_content_model = new LocalContentModel();
     $local_map = $local_map_model->find($local_id);
     $query_map = array('local_id' => $local_id, 'key' => $content_id);
     if (isset($_GET['q'])) {
         $query_map['_complex'] = array('name' => array('like', '%' . $_GET['q'] . '%'), 'content' => array('like', '%' . $_GET['q'] . '%'), '_logic' => 'or');
     }
     import("ORG.Util.TBPage");
     $listRows = C('ADMIN_ROW_LIST');
     $post_count = $local_content_model->where($query_map)->count();
     $posts = T('local_content')->where($query_map)->attach('users')->select();
     $Page = new TBPage($post_count, $listRows);
     $page_bar = $Page->show();
     $module = M('local_modules')->find($content_id);
     $this->assign('local_map', $local_map);
     $this->assign('module', $module);
     $this->assign('posts', $posts);
     $this->assign('page_bar', $page_bar);
     $this->display();
 }
Ejemplo n.º 4
0
 public function list_index()
 {
     $map_data_model = D('MapData');
     $record_per_page = C('LIST_RECORD_PER_PAGE');
     if (!isset($query_param)) {
         $query_param = array();
     }
     if (isset($_GET['clear_all'])) {
         unset($_SESSION['list_queries']);
         $query_param = array();
     } else {
         $query_param = $_SESSION['list_queries'];
     }
     foreach ($_GET as $k => $v) {
         if (isset($query_param[$k]) && $v === '0') {
             unset($query_param[$k]);
         } else {
             $query_param[$k] = $v;
         }
     }
     if (!isset($query_param['model'])) {
         $query_param['model'] = 'users';
     }
     if (!isset($query_param['type'])) {
         $query_param['type'] = 'ngo';
     }
     if (isset($query_param['province']) && $this->is_province_master($query_param['province'])) {
         $is_expert_mode = true;
     } else {
         $is_expert_mode = false;
     }
     $_SESSION['list_queries'] = $query_param;
     $user_fields = "*, 'users' model";
     $event_fields = "*, 'events' model";
     if (!empty($query_param['model'])) {
         if ($query_param['model'] == 'users') {
             $query_param['user_fields'] = $user_fields;
         } else {
             if ($query_param['model'] == 'events') {
                 $query_param['event_fields'] = $event_fields;
             }
         }
     } else {
         $query_param['user_fields'] = $user_fields;
         $query_param['event_fields'] = $event_fields;
     }
     // export excel
     if (isset($_GET['export']) && $is_expert_mode) {
         $result = $map_data_model->query_map($query_param);
         if ($query_param['model'] == 'users') {
             $fields = array('name' => '名称', 'contact_name' => '联系人', 'public_email' => '电子邮箱', 'phone' => '联系电话', 'website' => '网站', 'city' => '所在城市', 'county' => '所在乡镇', 'place' => '地址', 'aim' => '机构使命', 'introduction' => '简介', 'work_field' => '服务领域', 'register_type' => '注册类型', 'register_year' => '注册年份', 'staff_fulltime' => '全职人数', 'staff_parttime' => '兼职人数', 'staff_volunteer' => '志愿者人数', 'financial_link' => '财务报告链接');
         } else {
             if ($query_param['model'] == 'events') {
                 $fields = array('name' => '名称', 'description' => '简介', 'contact_name' => '联系人', 'contact_email' => '电子邮箱', 'contact_phone' => '联系电话', 'contact_qq' => '联系qq', 'begin_time' => '开始时间', 'item_field' => '项目领域', 'city' => '所在城市', 'county' => '所在乡镇');
             }
         }
         $this->output_excel($fields, $result);
         return;
     }
     if ($is_expert_mode) {
         // if expert mode, do display unchecked items
         $query_param['expert_mode'] = 1;
     }
     $total_number = $map_data_model->query_number($query_param);
     if (isset($_GET['p'])) {
         $page = $_GET['p'];
     } else {
         $page = 1;
     }
     $limit_start = ($page - 1) * $record_per_page;
     $query_param['limit'] = $limit_start . ',' . $record_per_page;
     if ($query_param['model'] == 'users') {
         $query_param['order'] = "medal_score desc, create_time desc";
     } else {
         $query_param['order'] = "create_time desc";
     }
     import("ORG.Util.TBPage");
     $Page = new TBPage($total_number, $record_per_page);
     $page_bar = $Page->show();
     $data = $map_data_model->query_map($query_param);
     $medal_model = new MedalModel();
     $this->assign('medal_map', $medal_model->select_as_assoc_array());
     $this->assign('pager', $page_bar);
     $this->assign('params', $query_param);
     $this->assign('page', $page);
     $this->assign('total_number', $total_number);
     $this->assign('result', $data);
     $this->assign('is_expert_mode', $is_expert_mode);
     $this->display();
 }
Ejemplo n.º 5
0
 public function users()
 {
     admin_only();
     $user_model = M('Users');
     //从session中读取搜索条件
     if (isset($_SESSION['admin_users_condition']) && !isset($_GET['clear'])) {
         $admin_users_condition = $_SESSION['admin_users_condition'];
         if (isset($_GET['hold_page']) && !isset($_GET['p'])) {
             $_GET['p'] = $admin_users_condition['p'];
         }
     } else {
         $admin_users_condition = array('type' => 'all', 'check' => 'all');
     }
     //用传入的搜索条件覆盖现有的搜索条件
     //XXX: sql injection prevention relies on PHP settings. see get_magic_quotes_gpc()
     foreach ($_GET as $key => $value) {
         $admin_users_condition[$key] = $value;
     }
     if ($_GET['q'] == 'all' || $_GET['q'] === '') {
         $admin_users_condition['q'] = '';
     }
     //保存搜索条件
     $_SESSION['admin_users_condition'] = $admin_users_condition;
     extract($admin_users_condition);
     //筛选
     $where_clause = array();
     if ($type != 'all') {
         $where_clause['type'] = $type;
     }
     if ($check == 'deleted') {
         $where_clause['enabled'] = 0;
     } else {
         if ($check == 'pending') {
             $where_clause['is_checked'] = 0;
             $where_clause['enabled'] = 1;
         } else {
             if ($check == 'checked') {
                 $where_clause['is_checked'] = 1;
                 $where_clause['enabled'] = 1;
             } else {
                 $where_clause['enabled'] = 1;
             }
         }
     }
     if (!empty($q)) {
         $where_clause['name'] = array('like', "%{$q}%");
     }
     import("ORG.Util.TBPage");
     $listRows = C('ADMIN_ROW_LIST');
     $user_count = $user_model->where($where_clause)->count();
     $Page = new TBPage($user_count, $listRows);
     $user_result = $user_model->where($where_clause)->order('create_time desc')->limit($Page->firstRow . ',' . $listRows)->select();
     $page_bar = $Page->show();
     $this->assign('q', $q);
     $this->assign('check', $check);
     $this->assign('type', $type);
     $this->assign('user_result', $user_result);
     $this->assign('page', $page_bar);
     $this->display();
 }