XOOPS  2.6.0
notifications_blocks.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
20 {
23  include_once $helper->path('include/notification_functions.php');
24 
25  $helper->loadLanguage('main');
26  // Notification must be enabled, and user must be logged in
27  if (!$xoops->isUser() || !notificationEnabled('block')) {
28  return false; // do not display block
29  }
30  $notification_handler = $helper->getHandlerNotification();
31  // Now build the a nested associative array of info to pass
32  // to the block template.
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  // Additional form data
58  $block['target_page'] = "notification_update.php";
59  // FIXME: better or more standardized way to do this?
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 }
static getInstance()
Definition: Xoops.php:160
$notification_handler
Definition: update.php:64
static getInstance()
Definition: helper.php:47
$_SERVER['REQUEST_URI']
const _MD_NOTIFICATIONS_UPDATENOW
Definition: main.php:21
$xoops
Definition: admin.php:25
b_notification_show()
$helper