public function show_notice() { $gScriptName = SCRIPTNAME; $n = intval($this->input['n']); $pp = intval($this->input['pp']) ? intval($this->input['pp']) : 0; $count = 50; switch ($n) { case 0: $this->page_title = '消息'; include_once ROOT_PATH . 'lib/messages/messages.class.php'; $mMessages = new messages(); $msg_members = array(); $from_who = $mMessages->get_members($this->user['id'], '', $pp, $count); $total = @array_shift($from_who); //分页 $data['totalpages'] = $total; $data['perpage'] = $count; $data['curpage'] = $pp; $data['onclick'] = ' onclick="javascript:document.location.href=re_back+\'?a=show_notice&pp=\'+(parseInt(this.title,10) - 1)+\'&n=0\';$(this).addClass(\'pages_current\');" '; $showpages = hg_build_pagelinks($data); ob_start(); include hg_load_template("user_msgs"); $html = ob_get_contents(); ob_end_clean(); break; case 1: $this->page_title = '通知'; include_once ROOT_PATH . 'lib/class/notify.class.php'; $mNotify = new notify(); $notice_arr = $un_notice = $notice = array(); $notice_arr = $mNotify->notify_get($this->user['id'], -1, $pp, $count); //分页,这个通知要区分一下,已读的通知和未知的通知要分开 $notice_count = $mNotify->notify_count($this->user['id'], -1); $total_count = $notice_count[0]; $total1 = array_sum($total_count); $data['totalpages'] = $total1; $data['perpage'] = $count; $data['curpage'] = $pp; $data['onclick'] = ' onclick="javascript:document.location.href=re_back+\'?a=show_notice&pp=\'+(parseInt(this.title,10) - 1)+\'&n=1\';$(this).addClass(\'pages_current\');" '; $showpages = hg_build_pagelinks($data); if ($notice_arr) { $sp = ''; foreach ($notice_arr as $key => $n) { if ($n['is_read'] == 0) { if (in_array($n['type'], array(0, 1, 2, 3))) { $un_notice[$n['type']]['idstr'] .= $sp . $n['id']; $un_notice[$n['type']]['content'] = unserialize($n['content']); } else { $un_notice[$n['type']][$n['id']]['content'] = unserialize($n['content']); $un_notice[$n['type']][$n['id']]['content']['notify_time'] = hg_get_date($n['notify_time']); } $a = $mNotify->notify_send_read($key, $this->user['id'], $n['type']); //将本页未读通知插入到已读表中 $sp = ','; } else { if ($n['type'] > 3) { $notice[$n['type']][$n['id']]['content'] = unserialize($n['content']); $notice[$n['type']][$n['id']]['content']['notify_time'] = hg_get_date($n['notify_time']); } } } } ob_start(); include hg_load_template("user_notices"); $html = ob_get_contents(); ob_end_clean(); break; } hg_add_head_element('js', RESOURCE_DIR . 'scripts/' . 'user.js'); include hg_load_template("user_show_n"); }
public function show_notice() { $user_info = $this->check('all'); $gScriptName = SCRIPTNAME; $n = intval($this->input['n']); $count = 50; $pp = intval($this->input['pp']) / $count; $user_id = $this->user['id']; hg_add_head_element('js', RESOURCE_DIR . 'scripts/' . 'user.js'); switch ($n) { case 0: $this->page_title = '消息'; include_once ROOT_PATH . 'lib/messages/messages.class.php'; $mMessages = new messages(); $msg_members = array(); $from_who = $mMessages->get_members($user_id, '', $pp, $count); $total = @array_shift($from_who); //分页 $data['totalpages'] = $total; $data['perpage'] = $count; $data['curpage'] = $pp; $data['onclick'] = ' onclick="javascript:document.location.href=re_back+\'?a=show_notice&pp=\'+(parseInt(this.title,10) - 1)+\'&n=0\';$(this).addClass(\'pages_current\');" '; $showpages = hg_build_pagelinks($data, 1); $this->tpl->addVar('msg_members', $msg_members); $this->tpl->addVar('mMessages', $mMessages); $this->tpl->addVar('from_who', $from_who); $this->tpl->addVar('total', $total); break; case 1: $this->page_title = '通知'; include_once ROOT_PATH . 'lib/class/notify.class.php'; $mNotify = new notify(); $un_notice = $notice = array(); $un_notice = $mNotify->notify_get_unread($user_id, -1, $pp, $count); $notice = $mNotify->notify_get_read($user_id, -1, $pp, $count); /*if(is_array($un_notice)) { $nids = $space = ""; foreach($un_notice as $key => $value) { $mNotify->notify_send_read($value['id'] , $user_id, $value['type']); } }*/ $total_count = $mNotify->notify_count($user_id, -1); if (is_array($un_notice)) { $data['totalpages'] = $total_count[0]; $data['perpage'] = $count; $data['curpage'] = $this->input['pp']; $data['pagelink'] = '?a=show_notice&n=1'; $showpages = hg_build_pagelinks($data); } //$a = $mNotify->notify_send_read($key,$user_id,$n['type']);//将本页未读通知插入到已读表中 $this->tpl->addVar('un_notice', $un_notice); $this->tpl->addVar('notice', $notice); break; } $this->tpl->addVar('showpages', $showpages); $this->tpl->addVar('n', $n); $this->tpl->addVar('gScriptName', $gScriptName); $this->tpl->addHeaderCode(hg_add_head_element('echo')); $this->tpl->setTemplateTitle($this->lang['pageTitle']); $this->tpl->outTemplate('user_show_n'); }