Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
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 /* @var $phpbb_notifications \phpbb\notification\manager */
038 $phpbb_notifications = $phpbb_container->get('notification_manager');
039
040 /* @var $pagination \phpbb\pagination */
041 $pagination = $phpbb_container->get('pagination');
042
043 switch ($mode)
044 {
045 case 'notification_options':
046 $subscriptions = $phpbb_notifications->get_global_subscriptions(false);
047
048 // Add/remove subscriptions
049 if ($request->is_set_post('submit'))
050 {
051 if (!check_form_key('ucp_notification'))
052 {
053 trigger_error('FORM_INVALID');
054 }
055
056 $notification_methods = $phpbb_notifications->get_subscription_methods();
057
058 foreach ($phpbb_notifications->get_subscription_types() as $group => $subscription_types)
059 {
060 foreach ($subscription_types as $type => $data)
061 {
062 foreach ($notification_methods as $method => $method_data)
063 {
064 if ($request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && (!isset($subscriptions[$type]) || !in_array($method_data['id'], $subscriptions[$type])))
065 {
066 $phpbb_notifications->add_subscription($type, 0, $method_data['id']);
067 }
068 else if (!$request->is_set_post(str_replace('.', '_', $type . '_' . $method_data['id'])) && isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type]))
069 {
070 $phpbb_notifications->delete_subscription($type, 0, $method_data['id']);
071 }
072 }
073 }
074 }
075
076 meta_refresh(3, $this->u_action);
077 $message = $user->lang['PREFERENCES_UPDATED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>');
078 trigger_error($message);
079 }
080
081 $this->output_notification_methods($phpbb_notifications, $template, $user, 'notification_methods');
082
083 $this->output_notification_types($subscriptions, $phpbb_notifications, $template, $user, 'notification_types');
084
085 $this->tpl_name = 'ucp_notifications';
086 $this->page_title = 'UCP_NOTIFICATION_OPTIONS';
087 break;
088
089 case 'notification_list':
090 default:
091 // Mark all items read
092 if ($request->variable('mark', '') == 'all' && check_link_hash($request->variable('token', ''), 'mark_all_notifications_read'))
093 {
094 $phpbb_notifications->mark_notifications(false, false, $user->data['user_id'], $form_time);
095
096 meta_refresh(3, $this->u_action);
097 $message = $user->lang['NOTIFICATIONS_MARK_ALL_READ_SUCCESS'];
098
099 if ($request->is_ajax())
100 {
101 $json_response = new \phpbb\json_response();
102 $json_response->send(array(
103 'MESSAGE_TITLE' => $user->lang['INFORMATION'],
104 'MESSAGE_TEXT' => $message,
105 'success' => true,
106 ));
107 }
108 $message .= '<br /><br />' . $user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>');
109
110 trigger_error($message);
111 }
112
113 // Mark specific notifications read
114 if ($request->is_set_post('submit'))
115 {
116 if (!check_form_key('ucp_notification'))
117 {
118 trigger_error('FORM_INVALID');
119 }
120
121 $mark_read = $request->variable('mark', array(0));
122
123 if (!empty($mark_read))
124 {
125 $phpbb_notifications->mark_notifications_by_id('notification.method.board', $mark_read, $form_time);
126 }
127 }
128
129 $notifications = $phpbb_notifications->load_notifications('notification.method.board', array(
130 'start' => $start,
131 'limit' => $config['topics_per_page'],
132 'count_total' => true,
133 ));
134
135 foreach ($notifications['notifications'] as $notification)
136 {
137 $template->assign_block_vars('notification_list', $notification->prepare_for_display());
138 }
139
140 $base_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=ucp_notifications&mode=notification_list");
141 $start = $pagination->validate_start($start, $config['topics_per_page'], $notifications['total_count']);
142 $pagination->generate_template_pagination($base_url, 'pagination', 'start', $notifications['total_count'], $config['topics_per_page'], $start);
143
144 $template->assign_vars(array(
145 'TOTAL_COUNT' => $notifications['total_count'],
146 'U_MARK_ALL' => $base_url . '&mark=all&token=' . generate_link_hash('mark_all_notifications_read'),
147 ));
148
149 $this->tpl_name = 'ucp_notifications';
150 $this->page_title = 'UCP_NOTIFICATION_LIST';
151 break;
152 }
153
154 $template->assign_vars(array(
155 'TITLE' => $user->lang($this->page_title),
156 'TITLE_EXPLAIN' => $user->lang($this->page_title . '_EXPLAIN'),
157
158 'MODE' => $mode,
159
160 'FORM_TIME' => time(),
161 ));
162 }
163
164 /**
165 * Output all the notification types to the template
166 *
167 * @param array $subscriptions Array containing global subscriptions
168 * @param \phpbb\notification\manager $phpbb_notifications
169 * @param \phpbb\template\template $template
170 * @param \phpbb\user $user
171 * @param string $block
172 */
173 public function output_notification_types($subscriptions, \phpbb\notification\manager $phpbb_notifications, \phpbb\template\template $template, \phpbb\user $user, $block = 'notification_types')
174 {
175 $notification_methods = $phpbb_notifications->get_subscription_methods();
176
177 foreach ($phpbb_notifications->get_subscription_types() as $group => $subscription_types)
178 {
179 $template->assign_block_vars($block, array(
180 'GROUP_NAME' => $user->lang($group),
181 ));
182
183 foreach ($subscription_types as $type => $data)
184 {
185 $template->assign_block_vars($block, array(
186 'TYPE' => $type,
187
188 'NAME' => $user->lang($data['lang']),
189 'EXPLAIN' => (isset($user->lang[$data['lang'] . '_EXPLAIN'])) ? $user->lang($data['lang'] . '_EXPLAIN') : '',
190 ));
191
192 foreach ($notification_methods as $method => $method_data)
193 {
194 $template->assign_block_vars($block . '.notification_methods', array(
195 'METHOD' => $method_data['id'],
196
197 'NAME' => $user->lang($method_data['lang']),
198
199 'SUBSCRIBED' => (isset($subscriptions[$type]) && in_array($method_data['id'], $subscriptions[$type])) ? true : false,
200 ));
201 }
202 }
203 }
204
205 $template->assign_vars(array(
206 strtoupper($block) . '_COLS' => sizeof($notification_methods) + 2,
207 ));
208 }
209
210 /**
211 * Output all the notification methods to the template
212 *
213 * @param \phpbb\notification\manager $phpbb_notifications
214 * @param \phpbb\template\template $template
215 * @param \phpbb\user $user
216 * @param string $block
217 */
218 public function output_notification_methods(\phpbb\notification\manager $phpbb_notifications, \phpbb\template\template $template, \phpbb\user $user, $block = 'notification_methods')
219 {
220 $notification_methods = $phpbb_notifications->get_subscription_methods();
221
222 foreach ($notification_methods as $method => $method_data)
223 {
224 $template->assign_block_vars($block, array(
225 'METHOD' => $method_data['id'],
226
227 'NAME' => $user->lang($method_data['lang']),
228 ));
229 }
230 }
231 }
232