/** * 阅读消息页 */ public function read() { $uid = (int) $this->input->get('uid'); if ($this->input->get('action') == 'more') { // ajax更多数据 list($touid, $list) = $this->pm_model->read_limit_page($uid, max(1, (int) $this->input->get('page'))); if (!$list) { exit('null'); } $this->template->assign(array('list' => $list)); $this->template->display('pm_read_data.html'); exit; } list($touid, $list) = $this->pm_model->read_limit_page($uid, max(1, (int) $this->input->get('page'))); $username = get_member_value($touid); if (IS_POST) { $data = $this->input->post('data', TRUE); $data['username'] = $username; $error = $this->pm_model->send($this->uid, $this->member['username'], $data); if ($error === NULL) { $this->member_msg(lang('000'), dr_url('pm/read', array('uid' => $uid)), 1); } } $this->template->assign(array('list' => $list, 'username' => $username, 'searchurl' => 'index.php?c=' . $this->router->class . '&m=' . $this->router->method . '&uid=' . $uid . '&plid=' . $plid . '&action=more', 'meta_name' => lang('m-009'), 'result_error' => $error)); $this->template->display('pm_read.html'); }
/** * 数据显示 * * @param intval $uid uid * @param intval $page 页数 * @return array */ public function limit_page($uid, $page) { $members = $touidarr = $tousernamearr = array(); $data = $this->db->query("SELECT * FROM " . $this->db->dbprefix('pm_members') . " m LEFT JOIN " . $this->db->dbprefix('pm_lists') . " t ON t.plid=m.plid WHERE m.uid={$uid} ORDER BY m.lastdateline DESC LIMIT " . $this->pagesize * ($page - 1) . ", " . $this->pagesize)->result_array(); foreach ($data as $member) { if ($member['pmtype'] == 1) { $users = explode('_', $member['min_max']); $member['touid'] = $users[0] == $uid ? $users[1] : $users[0]; } else { $member['touid'] = 0; } $touidarr[$member['touid']] = $member['touid']; $members[] = $member; } $this->db->query("DELETE FROM " . $this->db->dbprefix('newpm') . " WHERE uid={$uid}"); $array = array(); if ($members) { $today = SYS_TIME - SYS_TIME % 86400; foreach ($members as $key => $data) { $daterange = 5; $data['founddateline'] = $data['dateline']; $data['dateline'] = $data['lastdateline']; $data['pmid'] = $data['plid']; $lastmessage = dr_string2array($data['lastmessage']); if ($lastmessage['firstauthorid']) { $data['firstauthorid'] = $lastmessage['firstauthorid']; $data['firstauthor'] = $lastmessage['firstauthor']; $data['firstsummary'] = $lastmessage['firstsummary']; } if ($lastmessage['lastauthorid']) { $data['lastauthorid'] = $lastmessage['lastauthorid']; $data['lastauthor'] = $lastmessage['lastauthor']; $data['lastsummary'] = $lastmessage['lastsummary']; } $data['msgfromid'] = $lastmessage['lastauthorid']; $data['msgfrom'] = $lastmessage['lastauthor']; $data['message'] = $lastmessage['lastsummary']; $data['new'] = $data['isnew']; $data['msgtoid'] = $data['touid']; if ($data['lastdateline'] >= $today) { $daterange = 1; } elseif ($data['lastdateline'] >= $today - 86400) { $daterange = 2; } elseif ($data['lastdateline'] >= $today - 172800) { $daterange = 3; } elseif ($data['lastdateline'] >= $today - 604800) { $daterange = 4; } $data['daterange'] = $daterange; $data['tousername'] = get_member_value($data['touid']); unset($data['min_max']); $array[] = $data; } } return $array; }