1 <?php
2 3 4 5 6 7
8 class Notifications extends Object {
9 protected static $events = array();
10
11 12 13 14 15 16 17 18
19 static function event($eventType, $item, $notifyMemberID) {
20 Notifications::$events[$eventType][$notifyMemberID][] = $item;
21 }
22
23 24 25 26 27
28
29 static function notifyByEmail($eventType, $emailTemplateClass) {
30 $count = 0;
31 if(class_exists($emailTemplateClass)) {
32 foreach(Notifications::$events[$eventType] as $memberID => $items) {
33 if($memberID) {
34 $email = new $emailTemplateClass();
35 $email->populateTemplate(new ArrayData(array(
36 "Recipient" => DataObject::get_by_id("Member", $memberID),
37 "BrokenPages" => new DataObjectSet($items),
38 )));
39 $email->debug();
40 $email->send();
41 $count++;
42 }
43 }
44 }
45 return $count;
46 }
47
48 49 50 51
52 static function getItems($eventType) {
53 $allItems = array();
54 if(isset(Notifications::$events[$eventType])) {
55 foreach(Notifications::$events[$eventType] as $memberID => $items) {
56 $allItems = array_merge($allItems, (array)$items);
57 }
58 }
59 return $allItems;
60 }
61
62 }
63
64 ?>
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-