a7bbaf3a6818ad5cc4a3b51d7f81c012d5ea4c14
[GitHub/WoltLab/WCF.git] /
1 <?php
2 namespace wcf\system\cache;
3 use wcf\data\user\notification\event\UserNotificationEvent;
4 use wcf\data\user\notification\object\type\UserNotificationObjectType;
5 use wcf\system\WCF;
6
7 /**
8 * Caches user notification object types and events.
9 *
10 * @author Marcell Werk, Oliver Kliebisch
11 * @copyright 2001-2011 WoltLab GmbH, Oliver Kliebisch
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package com.woltlab.wcf.notification
14 * @subpackage system.cache
15 * @category Community Framework
16 */
17 class CacheBuilderUserNotificationObjectType implements CacheBuilder {
18 /**
19 * @see CacheBuilder::getData()
20 */
21 public function getData($cacheResource) {
22 $data = array();
23
24 // get package id
25 $tmp = explode('-', $cacheResource['cache']);
26 $packageID = array_pop($packageID);
27
28 // get object types
29 $typeIDArray = array();
30 $sql = "SELECT object_type.*
31 FROM wcf".WCF_N."_user_notification_object_type object_type,
32 wcf".WCF_N."_package_dependency package_dependency
33 WHERE object_type.packageID = package_dependency.dependency
34 AND package_dependency.packageID = ?
35 ORDER BY package_dependency.priority DESC";
36 $statement = WCF::getDB()->prepareStatement($sql);
37 $statement->execute(array($packageID));
38 while ($row = $statement->fetchArray()) {
39 if (!isset($data[$row['objectType']])) {
40 $data[$row['objectType']] = array(
41 'object' => new UserNotificationObjectType(null, $row),
42 'events' => array()
43 );
44 }
45 }
46
47 // get events
48 $sql = "SELECT event.*, object_type.objectType
49 FROM wcf".WCF_N."_package_dependency package_dependency,
50 wcf".WCF_N."_user_notification_event event
51 LEFT JOIN wcf".WCF_N."_user_notification_object_type object_type
52 ON (object_type.objectTypeID = event.objectTypeID)
53 WHERE event.packageID = package_dependency.dependency
54 AND package_dependency.packageID = ?
55 ORDER BY package_dependency.priority DESC";
56 $statement = WCF::getDB()->prepareStatement($sql);
57 $statement->execute(array($packageID));
58 while ($row = $statement->fetchArray()) {
59 if (isset($data[$row['objectType']]) && !isset($data[$row['objectType']]['events'][$row['eventName']])) {
60 $data[$row['objectType']]['events'][$row['eventName']] = new UserNotificationEvent(null, $row);
61 }
62 }
63
64 return $data;
65 }
66 }