2 namespace wcf\data\user\notification\recipient;
3 use wcf\data\user\notification\type\UserNotificationType;
4 use wcf\data\user\User;
5 use wcf\data\DatabaseObjectDecorator;
9 * Decorates the user object to provide special functions for handling recipients of user notifications.
12 * @copyright 2001-2011 WoltLab GmbH
13 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14 * @package com.woltlab.wcf.notification
15 * @subpackage data.user.notification.user
16 * @category Community Framework
18 class UserNotificationRecipient extends DatabaseObjectDecorator {
20 * @see DatabaseObjectDecorator::$baseClass
22 protected static $baseClass = 'wcf\data\user\User';
25 * Creates a new UserNotificationRecipient object.
27 * @param wcf\data\user\User $object
29 public function __construct(User $object) {
30 parent::__construct($object);
32 // get notification types
33 if (!isset($this->object->data['notificationTypes'])) {
34 $this->object->data['notificationTypes'] = array();
35 $sql = "SELECT event_to_user.eventID, notification_type.*
36 FROM wcf".WCF_N."_user_notification_event_to_user event_to_user
37 LEFT JOIN wcf".WCF_N."_user_notification_type notification_type
38 ON (notification_type.notificationTypeID = event_to_user.notificationTypeID)
39 WHERE event_to_user.userID = ?
40 AND event_to_user.enabled = ?";
41 $statement = WCF::getDB()->prepareStatement($sql);
42 $statement->execute(array($this->userID, 1));
43 while ($row = $statement->fetchArray()) {
44 $this->object->data['notificationTypes'][$row['eventID']] = new UserNotificationType(null, $row);
50 * Returns the enabled notification types for the given event.
52 * @param integer $eventID
53 * @return array<wcf\data\user\notification\type\UserNotificationType>
55 public function getNotificationTypes($eventID) {
56 if (isset($this->notificationTypes[$eventID])) {
57 return $this->notificationTypes[$eventID];