2a7950ccdae02dea4d220bf70469137e585119d3
[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 ICacheBuilder {
18 /**
19 * @see wcf\system\cache\ICacheBuilder::getData()
20 */
21 public function getData($cacheResource) {
22 $data = array();
23
24 // get package id
25 $tmp = explode('-', $cacheResource['cache']);
26 $packageID = array_pop($tmp);
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 $databaseObject = new UserNotificationObjectType(null, $row);
41 $data[$row['objectType']] = array(
42 'object' => $databaseObject->getProcessor(),
43 'events' => array()
44 );
45 }
46 }
47
48 // get events
49 $sql = "SELECT event.*, object_type.objectType
50 FROM wcf".WCF_N."_package_dependency package_dependency,
51 wcf".WCF_N."_user_notification_event event
52 LEFT JOIN wcf".WCF_N."_user_notification_object_type object_type
53 ON (object_type.objectTypeID = event.objectTypeID)
54 WHERE event.packageID = package_dependency.dependency
55 AND package_dependency.packageID = ?
56 ORDER BY package_dependency.priority DESC";
57 $statement = WCF::getDB()->prepareStatement($sql);
58 $statement->execute(array($packageID));
59 while ($row = $statement->fetchArray()) {
60 if (isset($data[$row['objectType']]) && !isset($data[$row['objectType']]['events'][$row['eventName']])) {
61 $databaseObject = new UserNotificationEvent(null, $row);
62 $data[$row['objectType']]['events'][$row['eventName']] = $databaseObject->getProcessor();
63 }
64 }
65
66 return $data;
67 }
68 }