1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: if (!defined('XOOPS_ROOT_PATH')) exit();
12:
13: require_once XOOPS_ROOT_PATH . "/include/notification_functions.php";
14:
15: require_once XOOPS_MODULE_PATH . "/legacy/forms/NotifyDeleteForm.class.php";
16:
17: 18: 19: 20: 21:
22: class Legacy_NotifyListAction extends Legacy_Action
23: {
24: var $mModules = array();
25: var $mActionForm = null;
26:
27: function prepare(&$controller, &$xoopsUser)
28: {
29: $root =& $controller->mRoot;
30: $root->mLanguageManager->loadPageTypeMessageCatalog('notification');
31: $root->mLanguageManager->loadModuleMessageCatalog('legacy');
32:
33: $this->mActionForm =new Legacy_NotifyDeleteForm();
34: $this->mActionForm->prepare();
35: }
36:
37: function hasPermission(&$controller, &$xoopsUser)
38: {
39: return is_object($xoopsUser);
40: }
41:
42: function getDefaultView(&$contoller, &$xoopsUser)
43: {
44: $criteria =new Criteria('not_uid', $xoopsUser->get('uid'));
45: $criteria->setSort('not_modid, not_category, not_itemid');
46:
47: $handler =& xoops_gethandler('notification');
48: $notificationArr =& $handler->getObjects($criteria);
49:
50: $moduleHandler =& xoops_gethandler('module');
51:
52: $prev_modid = -1;
53: $prev_category = -1;
54: $prev_item = -1;
55: foreach ($notificationArr as $notify) {
56: $t_modid = $notify->get('not_modid');
57:
58: $module =& $moduleHandler->get($t_modid);
59: if (!is_object($module)) {
60: continue;
61: }
62:
63: if ($t_modid != $prev_modid) {
64: $prev_modid = $t_modid;
65: $prev_category = -1;
66: $prev_item = -1;
67:
68: $this->mModules[$t_modid] = array (
69: 'id' => $t_modid,
70: 'name' => $module->getShow('name'),
71: 'categories' => array()
72: );
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89: $notifyConfig = $module->getInfo('notification');
90: $lookupFunc = '';
91: if (!empty($notifyConfig['lookup_file'])) {
92: $t_filepath = XOOPS_ROOT_PATH . '/modules/' . $module->get('dirname') . '/' . $notifyConfig['lookup_file'];
93: if (file_exists($t_filepath)) {
94: require_once $t_filepath;
95: if (!empty($notifyConfig['lookup_func']) && function_exists($notifyConfig['lookup_func'])) {
96: $lookupFunc = $notifyConfig['lookup_func'];
97: }
98: }
99: }
100: }
101:
102: $t_category = $notify->get('not_category');
103: if ($t_category != $prev_category) {
104: $prev_category = $t_category;
105: $prev_item = -1;
106: $categoryInfo =& notificationCategoryInfo($t_category, $t_modid);
107: }
108:
109: $t_item = $notify->get('not_itemid');
110: if ($t_item != $prev_item) {
111: $prev_item = $t_item;
112: if (!empty($lookupFunc)) {
113: $itemInfo = $lookupFunc($t_category, $t_item);
114: }
115: else {
116: $itemInfo = array ('name' => '[' . _NOT_NAMENOTAVAILABLE . ']', 'url' => '');
117: }
118: $this->mModules[$t_modid]['categories'][$t_category]['items'][$t_item] = array(
119: 'id' => $t_item,
120: 'name' => $itemInfo['name'],
121: 'url' => $itemInfo['url'],
122: 'notifications' => array()
123: );
124: }
125:
126: $eventInfo =& notificationEventInfo($t_category, $notify->get('not_event'), $notify->get('not_modid'));
127: $this->mModules[$t_modid]['categories'][$t_category]['items'][$t_item]['notifications'][] = array(
128: 'id' => $notify->get('not_id'),
129: 'module_id' => $notify->get('not_modid'),
130: 'category' => $notify->get('not_category'),
131: 'category_title' => $categoryInfo['title'],
132: 'item_id' => $notify->get('not_itemid'),
133: 'event' => $notify->get('not_event'),
134: 'event_title' => $eventInfo['title'],
135: 'user_id' => $notify->get('not_uid')
136: );
137: }
138:
139: return LEGACY_FRAME_VIEW_INDEX;
140: }
141:
142: function executeViewIndex(&$controller, &$xoopsUser, &$render)
143: {
144: $render->setTemplateName("legacy_notification_list.html");
145:
146: $render->setAttribute('modules', $this->mModules);
147: $render->setAttribute('currentUser', $xoopsUser);
148: $render->setAttribute('actionForm', $this->mActionForm);
149: }
150:
151: function executeViewError(&$controller, &$xoopsUser, &$render)
152: {
153: $controller->executeForward("./index.php?action=NotifyList");
154: }
155: }
156:
157: ?>
158: