2 namespace wcf\data\user\notification\recipient;
3 use wcf\system\database\util\PreparedStatementConditionBuilder;
4 use wcf\data\user\notification\type\UserNotificationType;
5 use wcf\data\user\UserList;
8 * Decorates the user object to provide special functions for handling recipients of user notifications.
11 * @copyright 2001-2011 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf.notification
14 * @subpackage data.user.notification.user
15 * @category Community Framework
17 class UserNotificationRecipientList extends UserList {
19 * @see wcf\data\DatabaseObjectList\DatabaseObjectList::readObjects()
21 public function readObjects() {
22 if ($this->objectIDs === null) {
23 $this->readObjectIDs();
26 if (!count($this->objectIDs)) {
30 // get notification types
31 $notificationTypes = array();
32 $conditionBuilder = new PreparedStatementConditionBuilder();
33 $conditionBuilder->add('event_to_user.userID IN (?)', array($this->objectIDs));
34 $conditionBuilder->add('event_to_user.enabled = ?', array(1));
36 $sql = "SELECT event_to_user.eventID, event_to_user.userID, notification_type.*
37 FROM wcf".WCF_N."_user_notification_event_to_user event_to_user
38 LEFT JOIN wcf".WCF_N."_user_notification_type notification_type
39 ON (notification_type.notificationTypeID = event_to_user.notificationTypeID)
40 ".$conditionBuilder->__toString();
41 $statement = WCF::getDB()->prepareStatement($sql);
42 $statement->execute($conditionBuilder->getParameters());
43 while ($row = $statement->fetchArray()) {
44 $notificationTypes[$row['userID']][$row['eventID']] = new UserNotificationType(null, $row);
48 $sql = "SELECT ".(!empty($this->sqlSelects) ? $this->sqlSelects.',' : '')."
49 ".$this->getDatabaseTableAlias().".*
50 FROM ".$this->getDatabaseTableName()." ".$this->getDatabaseTableAlias()."
52 WHERE ".$this->getDatabaseTableAlias().".".$this->getDatabaseTableIndexName()." IN (?".str_repeat(',?', count($this->objectIDs)).")
53 ".(!empty($this->sqlOrderBy) ? "ORDER BY ".$this->sqlOrderBy : '');
54 $statement = WCF::getDB()->prepareStatement($sql);
55 $statement->execute($this->objectIDs);
56 while ($row = $statement->fetchArray()) {
57 $row['notificationTypes'] = (isset($notificationTypes[$row['userID']]) ? $notificationTypes[$row['userID']] : array());
58 $this->objects[] = new UserNotificationRecipient(null, $row);