1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17:
18:
19: function b_notification_show()
20: {
21: $xoops = Xoops::getInstance();
22: $helper = Notifications::getInstance();
23: include_once $helper->path('include/notification_functions.php');
24:
25: $helper->loadLanguage('main');
26:
27: if (!$xoops->isUser() || !notificationEnabled('block')) {
28: return false;
29: }
30: $notification_handler = $helper->getHandlerNotification();
31:
32:
33: $block = array();
34: $categories = notificationSubscribableCategoryInfo();
35: if (empty($categories)) {
36: return false;
37: }
38: foreach ($categories as $category) {
39: $section['name'] = $category['name'];
40: $section['title'] = $category['title'];
41: $section['description'] = $category['description'];
42: $section['itemid'] = $category['item_id'];
43: $section['events'] = array();
44: $subscribed_events = $notification_handler->getSubscribedEvents($category['name'], $category['item_id'], $xoops->module->getVar('mid'), $xoops->user->getVar('uid'));
45: foreach (notificationEvents($category['name'], true) as $event) {
46: if (!empty($event['admin_only']) && !$xoops->user->isAdmin($xoops->module->getVar('mid'))) {
47: continue;
48: }
49: $subscribed = in_array($event['name'], $subscribed_events) ? 1 : 0;
50: $section['events'][$event['name']] = array(
51: 'name' => $event['name'], 'title' => $event['title'], 'caption' => $event['caption'],
52: 'description' => $event['description'], 'subscribed' => $subscribed
53: );
54: }
55: $block['categories'][$category['name']] = $section;
56: }
57:
58: $block['target_page'] = "notification_update.php";
59:
60: $script_url = explode('/', $_SERVER['PHP_SELF']);
61: $script_name = $script_url[count($script_url) - 1];
62: $block['redirect_script'] = $script_name;
63: $block['submit_button'] = _MD_NOTIFICATIONS_UPDATENOW;
64: $block['notification_token'] = $xoops->security()->createToken();
65: return $block;
66: }
67: