Example #1
0
 public function index()
 {
     if (!$GLOBALS['user_info']) {
         app_redirect(url("user#login"));
     }
     $all = intval($_REQUEST['all']);
     $page_size = 20;
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * $page_size . "," . $page_size;
     if ($all == 0) {
         $cond = " and is_read = 0 ";
     } else {
         $cond = " and 1=1 ";
     }
     $GLOBALS['tmpl']->assign("all", $all);
     $sql = "select * from " . DB_PREFIX . "user_notify  where user_id = " . intval($GLOBALS['user_info']['id']) . " {$cond}  order by log_time desc limit " . $limit;
     $sql_count = "select count(*) from " . DB_PREFIX . "user_notify  where user_id = " . intval($GLOBALS['user_info']['id']) . " {$cond}  ";
     $notify_list = $GLOBALS['db']->getAll($sql);
     $notify_count = $GLOBALS['db']->getOne($sql_count);
     foreach ($notify_list as $k => $v) {
         $notify_list[$k]['url'] = parse_url_tag("u:" . $v['url_route'] . "|" . $v['url_param']);
     }
     $GLOBALS['tmpl']->assign("notify_list", $notify_list);
     require APP_ROOT_PATH . 'app/Lib/page.php';
     $page = new Page($notify_count, $page_size);
     //初始化分页对象
     //$p  =  $page->show();
     $p = $page->new_para_show("notify#index", array('all' => $all));
     $GLOBALS['tmpl']->assign('pages', $p);
     $GLOBALS['tmpl']->assign("page_title", "站内通知");
     $GLOBALS['tmpl']->display("notify.html");
 }
 public function support()
 {
     $access = get_level_access($GLOBALS['user_info'], $deal_info);
     $GLOBALS['tmpl']->assign("access", $access);
     $id = intval($_REQUEST['id']);
     $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . "))");
     $deal_info['deal_type'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $deal_info['cate_id']);
     if (!$deal_info) {
         app_redirect(url("index"));
     }
     $deal_info = cache_deal_extra($deal_info);
     $this->init_deal_page($deal_info);
     $page_size = DEAL_SUPPORT_PAGE_SIZE;
     $page = intval($_REQUEST['p']);
     if ($page == 0) {
         $page = 1;
     }
     $limit = ($page - 1) * $page_size . "," . $page_size;
     $support_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_support_log where deal_id = " . $id . " order by create_time desc limit " . $limit);
     $support_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_support_log where deal_id = " . $id);
     //支持者优化 start
     $user_ids = array();
     foreach ($support_list as $k => $v) {
         $user_ids[] = $v['user_id'];
     }
     $support_user_info = $GLOBALS['db']->getAll("select id,user_name from " . DB_PREFIX . "user where id in (" . implode(",", $user_ids) . ")");
     foreach ($support_user_info as $k => $v) {
         foreach ($support_list as $kk => $vv) {
             if ($support_list[$kk]['user_id'] == $support_user_info[$k]['id']) {
                 $support_list[$kk]['user_info'] = $support_user_info[$k];
             }
         }
     }
     //支持者优化 end
     $GLOBALS['tmpl']->assign("support_list", $support_list);
     require APP_ROOT_PATH . 'app/Lib/page.php';
     $page = new Page($support_count, $page_size);
     //初始化分页对象
     $p = $page->show();
     $p = $page->new_para_show("deal#support", array('id' => $id));
     $GLOBALS['tmpl']->assign('pages', $p);
     $comment_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_comment where deal_id = " . $id . " and log_id = 0 and status=1");
     $GLOBALS['tmpl']->assign('comment_count', $comment_count);
     $GLOBALS['tmpl']->display("deal_support.html");
 }