-
Notifications
You must be signed in to change notification settings - Fork 453
/
PrivateMessageList.php
35 lines (29 loc) · 1.05 KB
/
PrivateMessageList.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace Concrete\Core\User\PrivateMessage;
use Concrete\Core\Legacy\DatabaseItemList;
use Concrete\Core\User\PrivateMessage\PrivateMessage as UserPrivateMessage;
class PrivateMessageList extends DatabaseItemList
{
protected $itemsPerPage = 10;
protected $mailbox;
public function filterByMailbox($mailbox)
{
$this->filter('msgMailboxID', $mailbox->getMailboxID());
$this->filter('uID', $mailbox->getMailboxUserID());
$this->mailbox = $mailbox;
}
public function __construct()
{
$this->setQuery("select UserPrivateMessagesTo.msgID from UserPrivateMessagesTo inner join UserPrivateMessages on UserPrivateMessagesTo.msgID = UserPrivateMessages.msgID");
$this->sortBy('msgDateCreated', 'desc');
}
public function get($itemsToGet = 0, $offset = 0)
{
$messages = array();
$r = parent::get($itemsToGet, $offset);
foreach ($r as $row) {
$messages[] = UserPrivateMessage::getByID($row['msgID'], $this->mailbox);
}
return $messages;
}
}