27 public $mModules = [];
28 public $mActionForm =
null;
30 public function prepare(&$controller, &$xoopsUser)
32 $root =& $controller->mRoot;
33 $root->mLanguageManager->loadPageTypeMessageCatalog(
'notification');
34 $root->mLanguageManager->loadModuleMessageCatalog(
'legacy');
37 $this->mActionForm->prepare();
40 public function hasPermission(&$controller, &$xoopsUser)
42 return is_object($xoopsUser);
45 public function getDefaultView(&$contoller, &$xoopsUser)
47 $criteria =
new Criteria(
'not_uid', $xoopsUser->get(
'uid'));
48 $criteria->setSort(
'not_modid, not_category, not_itemid');
50 $handler =& xoops_gethandler(
'notification');
51 $notificationArr =& $handler->getObjects($criteria);
53 $moduleHandler =& xoops_gethandler(
'module');
58 foreach ($notificationArr as $notify) {
59 $t_modid = $notify->get(
'not_modid');
61 $module =& $moduleHandler->get($t_modid);
62 if (!is_object($module)) {
66 if ($t_modid != $prev_modid) {
67 $prev_modid = $t_modid;
71 $this->mModules[$t_modid] = [
73 'name' => $module->getShow(
'name'),
92 $notifyConfig = $module->getInfo(
'notification');
94 if (!empty($notifyConfig[
'lookup_file'])) {
95 $t_filepath = XOOPS_ROOT_PATH .
'/modules/' . $module->get(
'dirname') .
'/' . $notifyConfig[
'lookup_file'];
96 if (file_exists($t_filepath)) {
97 require_once $t_filepath;
98 if (!empty($notifyConfig[
'lookup_func']) && function_exists($notifyConfig[
'lookup_func'])) {
99 $lookupFunc = $notifyConfig[
'lookup_func'];
105 $t_category = $notify->get(
'not_category');
106 if ($t_category != $prev_category) {
107 $prev_category = $t_category;
109 $categoryInfo =& notificationCategoryInfo($t_category, $t_modid);
112 $t_item = $notify->get(
'not_itemid');
113 if ($t_item != $prev_item) {
114 $prev_item = $t_item;
115 if (!empty($lookupFunc)) {
116 $itemInfo = $lookupFunc($t_category, $t_item);
118 $itemInfo = [
'name' =>
'[' . _NOT_NAMENOTAVAILABLE .
']',
'url' =>
''];
120 $this->mModules[$t_modid][
'categories'][$t_category][
'items'][$t_item] = [
122 'name' => $itemInfo[
'name'],
123 'url' => $itemInfo[
'url'],
124 'notifications' => []
128 $eventInfo =& notificationEventInfo($t_category, $notify->get(
'not_event'), $notify->get(
'not_modid'));
129 $this->mModules[$t_modid][
'categories'][$t_category][
'items'][$t_item][
'notifications'][] = [
130 'id' => $notify->get(
'not_id'),
131 'module_id' => $notify->get(
'not_modid'),
132 'category' => $notify->get(
'not_category'),
133 'category_title' => $categoryInfo[
'title'],
134 'item_id' => $notify->get(
'not_itemid'),
135 'event' => $notify->get(
'not_event'),
136 'event_title' => $eventInfo[
'title'],
137 'user_id' => $notify->get(
'not_uid')
141 return LEGACY_FRAME_VIEW_INDEX;
144 public function executeViewIndex(&$controller, &$xoopsUser, &$render)
146 $render->setTemplateName(
'legacy_notification_list.html');
148 $render->setAttribute(
'modules', $this->mModules);
149 $render->setAttribute(
'currentUser', $xoopsUser);
150 $render->setAttribute(
'actionForm', $this->mActionForm);
153 public function executeViewError(&$controller, &$xoopsUser, &$render)
155 $controller->executeForward(
'./index.php?action=NotifyList');