XOOPS  2.6.0
preload.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 
13 
22 {
31  public static function eventCoreIncludeCommonClassmaps($args)
32  {
33  $path = dirname(__DIR__);
34  XoopsLoad::addMap(array(
35  'notifications' => $path . '/class/helper.php',
36  ));
37  }
38 
39  public static function eventCoreFooterStart($args)
40  {
43 
44  $notifications = array();
45  $notifications['show'] = $xoops->isModule() && $xoops->isUser() && $helper->enabled('inline') ? 1 : 0;
46  if ($notifications['show']) {
47  $helper->loadLanguage('main');
48  $categories = $helper->getSubscribableCategories();
49  $event_count = 0;
50  if (!empty($categories)) {
51  $notification_handler = $helper->getHandlerNotification();
52  foreach ($categories as $category) {
53  $section['name'] = $category['name'];
54  $section['title'] = $category['title'];
55  $section['description'] = $category['description'];
56  $section['itemid'] = $category['item_id'];
57  $section['events'] = array();
58  $subscribed_events = $notification_handler->getSubscribedEvents($category['name'], $category['item_id'], $xoops->module->getVar('mid'), $xoops->user->getVar('uid'));
59  foreach ($helper->getEvents($category['name'], true, $xoops->module->getVar('dirname')) as $event) {
60  if (!empty($event['admin_only']) && !$xoops->user->isAdmin($xoops->module->getVar('mid'))) {
61  continue;
62  }
63  if (!empty($event['invisible'])) {
64  continue;
65  }
66  $subscribed = in_array($event['name'], $subscribed_events) ? 1 : 0;
67  $section['events'][$event['name']] = array(
68  'name' => $event['name'],
69  'title' => $event['title'],
70  'caption' => $event['caption'],
71  'description' => $event['description'],
72  'subscribed' => $subscribed
73  );
74  ++$event_count;
75  }
76  $notifications['categories'][$category['name']] = $section;
77  }
78  $notifications['target_page'] = $helper->url('update.php');
79  $notifications['mid'] = $xoops->module->getVar('mid');
80  $notifications['redirect_script'] = $xoops->getEnv('PHP_SELF');
81  $xoops->tpl()->assign(array(
82  'lang_activenotifications' => _MD_NOTIFICATIONS_ACTIVENOTIFICATIONS,
83  'lang_notificationoptions' => _MD_NOTIFICATIONS_NOTIFICATIONOPTIONS,
84  'lang_updateoptions' => _MD_NOTIFICATIONS_UPDATEOPTIONS,
85  'lang_updatenow' => _MD_NOTIFICATIONS_UPDATENOW,
86  'lang_category' => _MD_NOTIFICATIONS_CATEGORY,
87  'lang_event' => _MD_NOTIFICATIONS_EVENT,
88  'lang_events' => _MD_NOTIFICATIONS_EVENTS,
89  'lang_checkall' => _MD_NOTIFICATIONS_CHECKALL,
90  'lang_notificationmethodis' => _MD_NOTIFICATIONS_NOTIFICATIONMETHODIS,
91  'lang_change' => _MD_NOTIFICATIONS_CHANGE,
92  'editprofile_url' => XOOPS_URL . '/edituser.php?uid=' . $xoops->user->getVar('uid')
93  ));
94  switch ($xoops->user->getVar('notify_method')) {
95  case NOTIFICATIONS_METHOD_DISABLE:
96  $xoops->tpl()->assign('user_method', _MD_NOTIFICATIONS_DISABLE);
97  break;
98  case NOTIFICATIONS_METHOD_PM:
99  $xoops->tpl()->assign('user_method', _MD_NOTIFICATIONS_PM);
100  break;
101  case NOTIFICATIONS_METHOD_EMAIL:
102  $xoops->tpl()->assign('user_method', _MD_NOTIFICATIONS_EMAIL);
103  break;
104  }
105  } else {
106  $notifications['show'] = 0;
107  }
108  if ($event_count == 0) {
109  $notifications['show'] = 0;
110  }
111  }
112  $xoops->tpl()->assign('notifications', $notifications);
113  }
114 
115  public static function eventOnModuleUpdateConfigs($args)
116  {
117  /* @var $module XoopsModule */
118  $module = $args[0];
119  $configs =& $args[1];
120  $helper = Notifications::getInstance(); //init helper to load defines na language
121 
122  if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'notifications', true)) {
123  $notConfigs = $helper->getPluginableConfigs($module);
124  foreach ($notConfigs as $notConfig) {
125  array_push($configs, $notConfig);
126  }
127  }
128  }
129 
130  public static function eventOnModuleInstallConfigs($args)
131  {
132  /* @var $module XoopsModule */
133  $module = $args[0];
134  if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'notifications', true)) {
135  Notifications::getInstance()->insertModuleRelations($module);
136  }
137  }
138 
139  public static function eventOnModuleUnistall($args)
140  {
141  /* @var $module XoopsModule */
142  $module = $args[0];
143  if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'notifications')) {
144  Notifications::getInstance()->deleteModuleRelations($module);
145  }
146  }
147 
148  public static function eventOnSystemPreferencesForm($args)
149  {
150  /* @var $module XoopsModule */
151  $module = $args[0];
152  if ($plugin = \Xoops\Module\Plugin::getPlugin($module->getVar('dirname'), 'notifications')) {
153  Notifications::getInstance()->loadLanguage('main');
154  }
155  }
156 
162  public static function eventCoreIncludeCheckloginSuccess()
163  {
164  // This was in include checklogin.php, moving here for now
165  // RMV-NOTIFY
166  // Perform some maintenance of notification records
168  if ($xoops->user instanceof \XoopsUser) {
169  Notifications::getInstance()->getHandlerNotification()->doLoginMaintenance($xoops->user->getVar('uid'));
170  }
171  }
172 }
static eventOnModuleUpdateConfigs($args)
Definition: preload.php:115
$path
Definition: execute.php:31
const _MD_NOTIFICATIONS_UPDATEOPTIONS
Definition: main.php:22
static eventOnSystemPreferencesForm($args)
Definition: preload.php:148
static getInstance()
Definition: Xoops.php:160
$notification_handler
Definition: update.php:64
static getInstance()
Definition: helper.php:47
const _MD_NOTIFICATIONS_EMAIL
Definition: main.php:41
static eventCoreFooterStart($args)
Definition: preload.php:39
const _MD_NOTIFICATIONS_PM
Definition: main.php:42
const _MD_NOTIFICATIONS_ACTIVENOTIFICATIONS
Definition: main.php:31
const _MD_NOTIFICATIONS_UPDATENOW
Definition: main.php:21
const _MD_NOTIFICATIONS_NOTIFICATIONMETHODIS
Definition: main.php:40
const _MD_NOTIFICATIONS_EVENTS
Definition: main.php:30
$xoops
Definition: admin.php:25
const _MD_NOTIFICATIONS_NOTIFICATIONOPTIONS
Definition: main.php:20
static eventCoreIncludeCommonClassmaps($args)
Definition: preload.php:31
$module
Definition: main.php:52
$configs
Definition: config.php:27
const _MD_NOTIFICATIONS_CHANGE
Definition: main.php:44
const _MD_NOTIFICATIONS_EVENT
Definition: main.php:29
const _MD_NOTIFICATIONS_DISABLE
Definition: main.php:43
$helper
static eventCoreIncludeCheckloginSuccess()
Definition: preload.php:162
static eventOnModuleInstallConfigs($args)
Definition: preload.php:130
static addMap(array $map)
Definition: xoopsload.php:40
static eventOnModuleUnistall($args)
Definition: preload.php:139
const _MD_NOTIFICATIONS_CHECKALL
Definition: main.php:24
const _MD_NOTIFICATIONS_CATEGORY
Definition: main.php:26