Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
ucp_notifications.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 /**
015 * @ignore
016 */
017 if (!defined('IN_PHPBB'))
018 {
019 exit;
020 }
021
022 class ucp_notifications
023 {
024 public $u_action;
025
026 public function main($id, $mode)
027 {
028 global $config, $template, $user, $request, $phpbb_container;
029 global $phpbb_root_path, $phpEx;
030
031 add_form_key('ucp_notification');
032
033 $start = $request->variable('start', 0);
034 $form_time = $request->variable('form_time', 0);
035 $form_time = ($form_time <= 0 || $form_time > time()) ? time() : $form_time;
036
037 $phpbb_notifications = $phpbb_container->get('notification_manager');
038 $pagination = $phpbb_container->get('pagination');
039
040 switch ($mode)
041 {
042 case 'notification_options':
043 $subscriptions = $phpbb_notifications->get_global_subscriptions(false);
044
045 // Add/remove subscriptions
046 if ($request->is_set_post('submit'))
047 {
048 if (!check_form_key('ucp_notification'))
049 {
050 trigger_error('FORM_INVALID');
051 }
052
053 $notification_methods = $phpbb_notifications->get_subscription_methods();
054
055 foreach($phpbb_notifications->get_subscription_types() as $group => $subscription_types)
056 {
057 foreach($subscription_types as $type => $data)
058 {
059 foreach($notification_methods as $method => $method_data)
060 {
061 if ($request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && (!isset($subscriptions[$type]) || !in_array($method_data['id'], $subscriptions[$type])))
062 {
063 $phpbb_notifications->add_subscription($type, 0, $method_data['id']);
064 }
065 else if (!$request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type]))
066 {
067 $phpbb_notifications->delete_subscription($type, 0, $method_data['id']);
068 }
069 }
070
071 if ($request->is_set_post(str_replace('.', '_', $type) . '_notification') && !isset($subscriptions[$type]))
072 {
073 $phpbb_notifications->add_subscription($type);
074 }
075 else if (!$request->is_set_post(str_replace('.', '_', $type) . '_notification') && isset($subscriptions[$type]))
076 {
077 $phpbb_notifications->delete_subscription($type);
078 }
079 }
080 }
081
082 meta_refresh(3, $this->u_action);
083 $message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
084 trigger_error($message);
085 }
086
087 $this->output_notification_methods($phpbb_notifications, $template, $user, 'notification_methods');
088
089 $this->output_notification_types($subscriptions, $phpbb_notifications, $template, $user, 'notification_types');
090
091 $this->tpl_name = 'ucp_notifications';
092 $this->page_title = 'UCP_NOTIFICATION_OPTIONS';
093 break;
094
095 case 'notification_list':
096 default:
097 // Mark all items read
098 if ($request->variable('mark', '') == 'all' && check_link_hash($request->variable('token', ''), 'mark_all_notifications_read'))
099 {
100 $phpbb_notifications->mark_notifications_read(false, false, $user->data['user_id'], $form_time);
101
102 meta_refresh(3, $this->u_action);
103 $message = $user->lang['NOTIFICATIONS_MARK_ALL_READ_SUCCESS'];
104
105 if ($request->is_ajax())
106 {
107 $json_response = new \phpbb\json_response();
108 $json_response->send(array(
109 'MESSAGE_TITLE' => $user->lang['INFORMATION'],
110 'MESSAGE_TEXT' => $message,
111 'success' => true,
112 ));
113 }
114 $message .= '<br /><br />' . $user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>');
115
116 trigger_error($message);
117 }
118
119 // Mark specific notifications read
120 if ($request->is_set_post('submit'))
121 {
122 if (!check_form_key('ucp_notification'))
123 {
124 trigger_error('FORM_INVALID');
125 }
126
127 $mark_read = $request->variable('mark', array(0));
128
129 if (!empty($mark_read))
130 {
131 $phpbb_notifications->mark_notifications_read_by_id($mark_read, $form_time);
132 }
133 }
134
135 $notifications = $phpbb_notifications->load_notifications(array(
136 'start' => $start,
137 'limit' => $config['topics_per_page'],
138 'count_total' => true,
139 ));
140
141 foreach ($notifications['notifications'] as $notification)
142 {
143 $template->assign_block_vars('notification_list', $notification->prepare_for_display());
144 }
145
146 $base_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=ucp_notifications&mode=notification_list");
147 $start = $pagination->validate_start($start, $config['topics_per_page'], $notifications['total_count']);
148 $pagination->generate_template_pagination($base_url, 'pagination', 'start', $notifications['total_count'], $config['topics_per_page'], $start);
149
150 $template->assign_vars(array(
151 'TOTAL_COUNT' => $notifications['total_count'],
152 'U_MARK_ALL' => $base_url . '&mark=all&token=' . generate_link_hash('mark_all_notifications_read'),
153 ));
154
155 $this->tpl_name = 'ucp_notifications';
156 $this->page_title = 'UCP_NOTIFICATION_LIST';
157 break;
158 }
159
160 $template->assign_vars(array(
161 'TITLE' => $user->lang($this->page_title),
162 'TITLE_EXPLAIN' => $user->lang($this->page_title . '_EXPLAIN'),
163
164 'MODE' => $mode,
165
166 'FORM_TIME' => time(),
167 ));
168 }
169
170 /**
171 * Output all the notification types to the template
172 *
173 * @param array $subscriptions Array containing global subscriptions
174 * @param \phpbb\notification\manager $phpbb_notifications
175 * @param \phpbb\template\template $template
176 * @param \phpbb\user $user
177 * @param string $block
178 */
179 public function output_notification_types($subscriptions, \phpbb\notification\manager $phpbb_notifications, \phpbb\template\template $template, \phpbb\user $user, $block = 'notification_types')
180 {
181 $notification_methods = $phpbb_notifications->get_subscription_methods();
182
183 foreach($phpbb_notifications->get_subscription_types() as $group => $subscription_types)
184 {
185 $template->assign_block_vars($block, array(
186 'GROUP_NAME' => $user->lang($group),
187 ));
188
189 foreach($subscription_types as $type => $data)
190 {
191 $template->assign_block_vars($block, array(
192 'TYPE' => $type,
193
194 'NAME' => $user->lang($data['lang']),
195 'EXPLAIN' => (isset($user->lang[$data['lang'] . '_EXPLAIN'])) ? $user->lang($data['lang'] . '_EXPLAIN') : '',
196
197 'SUBSCRIBED' => (isset($subscriptions[$type])) ? true : false,
198 ));
199
200 foreach($notification_methods as $method => $method_data)
201 {
202 $template->assign_block_vars($block . '.notification_methods', array(
203 'METHOD' => $method_data['id'],
204
205 'NAME' => $user->lang($method_data['lang']),
206
207 'SUBSCRIBED' => (isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type])) ? true : false,
208 ));
209 }
210 }
211 }
212
213 $template->assign_vars(array(
214 strtoupper($block) . '_COLS' => sizeof($notification_methods) + 2,
215 ));
216 }
217
218 /**
219 * Output all the notification methods to the template
220 *
221 * @param \phpbb\notification\manager $phpbb_notifications
222 * @param \phpbb\template\template $template
223 * @param \phpbb\user $user
224 * @param string $block
225 */
226 public function output_notification_methods(\phpbb\notification\manager $phpbb_notifications, \phpbb\template\template $template, \phpbb\user $user, $block = 'notification_methods')
227 {
228 $notification_methods = $phpbb_notifications->get_subscription_methods();
229
230 foreach($notification_methods as $method => $method_data)
231 {
232 $template->assign_block_vars($block, array(
233 'METHOD' => $method_data['id'],
234
235 'NAME' => $user->lang($method_data['lang']),
236 ));
237 }
238 }
239 }
240