XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
Outbox.class.php
1<?php
12
13if (!defined('XOOPS_ROOT_PATH')) {
14 exit();
15}
16
18{
19 public function __construct()
20 {
21 $this->initVar('outbox_id', XOBJ_DTYPE_INT, 0, true);
22 $this->initVar('uid', XOBJ_DTYPE_INT, 0, true);
23 $this->initVar('to_uid', XOBJ_DTYPE_INT, 0, true);
24 $this->initVar('title', XOBJ_DTYPE_STRING, '', true, 255);
25 $this->initVar('message', XOBJ_DTYPE_TEXT, '', true);
26 $this->initVar('utime', XOBJ_DTYPE_INT, time(), true);
27 }
28}
29
31{
32 public $mTable = 'message_outbox';
33 public $mPrimary = 'outbox_id';
34 public $mClass = 'MessageOutboxObject';
35
36 public function __construct(&$db)
37 {
38 parent::__construct($db);
39 }
40
41 public function getOutboxCount($uid)
42 {
43 $criteria = new CriteriaCompo(new Criteria('uid', $uid));
44 return $this->getCount($criteria);
45 }
46
47 public function deleteDays($day)
48 {
49 if ($day < 1) {
50 return;
51 }
52 $time = time() - ($day * 86400);
53 $sql = 'DELETE FROM `' . $this->mTable . '` ';
54 $sql.= 'WHERE `utime` < ' . $time;
55 $this->db->queryF($sql);
56 }
57
58 public function getReceiveUserList($uid = 0, $fuid = 0)
59 {
60 $ret = [];
61 $sql = 'SELECT u.`uname`,u.`uid` FROM `' . $this->db->prefix('users') . '` u, ';
62 $sql.= '`'.$this->mTable . '` i ';
63 $sql.= 'WHERE i.`to_uid` = u.`uid` ';
64 $sql.= 'AND i.`uid` = ' . $uid . ' ';
65 $sql.= 'GROUP BY u.`uname`, u.`uid`';
66
67 $result = $this->db->query($sql);
68 while ($row = $this->db->fetchArray($result)) {
69 if ($fuid == $row['uid']) {
70 $row['select'] = true;
71 } else {
72 $row['select'] = false;
73 }
74 $ret[] = $row;
75 }
76 return $ret;
77 }
78}