|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* XOOPS Kernel Class |
|
4
|
|
|
* |
|
5
|
|
|
* You may not change or alter any portion of this comment or credits |
|
6
|
|
|
* of supporting developers from this source code or any supporting source code |
|
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
8
|
|
|
* This program is distributed in the hope that it will be useful, |
|
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
* |
|
12
|
|
|
* @copyright XOOPS Project (http://xoops.org) |
|
13
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
|
14
|
|
|
* @package kernel |
|
15
|
|
|
* @since 2.0.0 |
|
16
|
|
|
* @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/ |
|
17
|
|
|
* @version $Id$ |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace Xoops\Core\Kernel\Handlers; |
|
21
|
|
|
|
|
22
|
|
|
use Xoops\Core\Database\Connection; |
|
23
|
|
|
use Xoops\Core\Kernel\XoopsPersistableObjectHandler; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* XOOPS private message handler class. |
|
27
|
|
|
* |
|
28
|
|
|
* This class is responsible for providing data access mechanisms to the data source |
|
29
|
|
|
* of XOOPS private message class objects. |
|
30
|
|
|
* |
|
31
|
|
|
* @category Xoops\Core\Kernel\Handlers\XoopsPrivateMessageHandler |
|
32
|
|
|
* @package Xoops\Core\Kernel |
|
33
|
|
|
* @author Kazumi Ono <[email protected]> |
|
34
|
|
|
* @copyright 2000-2015 XOOPS Project (http://xoops.org) |
|
35
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
|
36
|
|
|
* @link http://xoops.org |
|
37
|
|
|
*/ |
|
38
|
|
|
class XoopsPrivateMessageHandler extends XoopsPersistableObjectHandler |
|
39
|
|
|
{ |
|
40
|
|
|
/** |
|
41
|
|
|
* Constructor |
|
42
|
|
|
* |
|
43
|
|
|
* @param Connection|null $db database |
|
44
|
|
|
*/ |
|
45
|
5 |
|
public function __construct(Connection $db = null) |
|
46
|
|
|
{ |
|
47
|
5 |
|
parent::__construct( |
|
48
|
5 |
|
$db, |
|
49
|
5 |
|
'system_privatemessage', |
|
50
|
5 |
|
'\Xoops\Core\Kernel\Handlers\XoopsPrivateMessage', |
|
51
|
5 |
|
'msg_id', |
|
52
|
5 |
|
'subject' |
|
53
|
|
|
); |
|
54
|
5 |
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Mark a message as read |
|
58
|
|
|
* |
|
59
|
|
|
* @param XoopsPrivateMessage $pm XoopsPrivateMessage object |
|
60
|
|
|
* |
|
61
|
|
|
* @return bool |
|
62
|
|
|
**/ |
|
63
|
1 |
|
public function setRead(XoopsPrivateMessage $pm) |
|
64
|
|
|
{ |
|
65
|
1 |
|
$qb = $this->db2->createXoopsQueryBuilder() |
|
66
|
1 |
|
->update($this->table) |
|
67
|
1 |
|
->set('read_msg', ':readmsg') |
|
68
|
1 |
|
->where('msg_id = :msgid') |
|
69
|
1 |
|
->setParameter(':readmsg', 1, \PDO::PARAM_INT) |
|
70
|
1 |
|
->setParameter(':msgid', (int)$pm->getVar('msg_id'), \PDO::PARAM_INT); |
|
71
|
1 |
|
$result = $qb->execute(); |
|
72
|
|
|
|
|
73
|
1 |
|
if (!$result) { |
|
74
|
|
|
return false; |
|
75
|
|
|
} |
|
76
|
1 |
|
return true; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|