XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
legacy_notification.php
1<?php
14
15function b_legacy_notification_show()
16{
17 global $xoopsConfig, $xoopsUser, $xoopsModule;
18 include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
19
20 $root =& XCube_Root::getSingleton();
21 $root->mLanguageManager->loadPageTypeMessageCatalog('notification');
22
23 // Notification must be enabled, and user must be logged in
24 if (empty($xoopsUser) || !notificationEnabled('block')) {
25 return false; // do not display block
26 }
27 $notification_handler =& xoops_gethandler('notification');
28 // Now build a nested associative array of info to pass
29 // to the block template.
30 $block = [];
31 $categories =& notificationSubscribableCategoryInfo();
32 if (empty($categories)) {
33 return false;
34 }
35 foreach ($categories as $category) {
36 $section['name'] = $category['name'];
37 $section['title'] = $category['title'];
38 $section['description'] = $category['description'];
39 $section['itemid'] = $category['item_id'];
40 $section['events'] = [];
41 $subscribed_events =& $notification_handler->getSubscribedEvents($category['name'], $category['item_id'], $xoopsModule->getVar('mid'), $xoopsUser->getVar('uid'));
42 foreach (notificationEvents($category['name'], true) as $event) {
43 if (!empty($event['admin_only']) && !$xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
44 continue;
45 }
46 $subscribed = in_array($event['name'], $subscribed_events, true) ? 1 : 0;
47 $section['events'][$event['name']] = ['name' => $event['name'], 'title' => $event['title'], 'caption' => $event['caption'], 'description' => $event['description'], 'subscribed' =>$subscribed];
48 }
49 $block['categories'][$category['name']] = $section;
50 }
51 // Additional form data
52 $block['target_page'] = 'notification_update.php';
53 // FIXME: better or more standardized way to do this?
54 $script_url = explode('/', xoops_getenv('PHP_SELF'));
55 $script_name = $script_url[count($script_url)-1];
56 $block['redirect_script'] = $script_name;
57 $block['submit_button'] = _NOT_UPDATENOW;
58 return $block;
59}