1: <?php
2: 3: 4: 5:
6: if (!defined('XOOPS_ROOT_PATH')) exit();
7: class MessageOutboxObject extends XoopsSimpleObject
8: {
9: public function __construct()
10: {
11: $this->initVar('outbox_id', XOBJ_DTYPE_INT, 0, true);
12: $this->initVar('uid', XOBJ_DTYPE_INT, 0, true);
13: $this->initVar('to_uid', XOBJ_DTYPE_INT, 0, true);
14: $this->initVar('title', XOBJ_DTYPE_STRING, '', true, 255);
15: $this->initVar('message', XOBJ_DTYPE_TEXT, '', true);
16: $this->initVar('utime', XOBJ_DTYPE_INT, time(), true);
17: }
18: }
19:
20: class MessageOutboxHandler extends XoopsObjectGenericHandler
21: {
22: public $mTable = 'message_outbox';
23: public $mPrimary = 'outbox_id';
24: public $mClass = 'MessageOutboxObject';
25:
26: public function __construct(&$db)
27: {
28: parent::XoopsObjectGenericHandler($db);
29: }
30:
31: public function getOutboxCount($uid)
32: {
33: $criteria = new CriteriaCompo(new Criteria('uid', $uid));
34: return $this->getCount($criteria);
35: }
36:
37: public function deleteDays($day)
38: {
39: if ( $day < 1 ) {
40: return;
41: }
42: $time = time() - ($day * 86400);
43: $sql = "DELETE FROM `".$this->mTable."` ";
44: $sql.= "WHERE `utime` < ".$time;
45: $this->db->queryF($sql);
46: }
47:
48: public function getReceiveUserList($uid = 0, $fuid = 0)
49: {
50: $ret = array();
51: $sql = "SELECT u.`uname`,u.`uid` FROM `".$this->db->prefix('users')."` u, ";
52: $sql.= '`'.$this->mTable."` i ";
53: $sql.= "WHERE i.`to_uid` = u.`uid` ";
54: $sql.= "AND i.`uid` = ".$uid." ";
55: $sql.= "GROUP BY u.`uname`, u.`uid`";
56:
57: $result = $this->db->query($sql);
58: while ($row = $this->db->fetchArray($result)) {
59: if ( $fuid == $row['uid'] ) {
60: $row['select'] = true;
61: } else {
62: $row['select'] = false;
63: }
64: $ret[] = $row;
65: }
66: return $ret;
67: }
68: }
69: ?>
70: