@@ -19,7 +19,7 @@ |
||
19 | 19 | class MemberReport_Notify_Background extends SMF_BackgroundTask |
20 | 20 | { |
21 | 21 | /** |
22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
23 | 23 | * @return bool Always returns true. |
24 | 24 | */ |
25 | 25 | public function execute() |
@@ -46,9 +46,10 @@ discard block |
||
46 | 46 | |
47 | 47 | foreach ($prefs as $member => $pref_option) |
48 | 48 | { |
49 | - foreach ($alert_bits as $type => $bitvalue) |
|
50 | - if ($pref_option['member_report'] & $bitvalue) |
|
49 | + foreach ($alert_bits as $type => $bitvalue) { |
|
50 | + if ($pref_option['member_report'] & $bitvalue) |
|
51 | 51 | $notifies[$type][] = $member; |
52 | + } |
|
52 | 53 | } |
53 | 54 | |
54 | 55 | // Firstly, anyone who wants alerts. |
@@ -109,8 +110,9 @@ discard block |
||
109 | 110 | ); |
110 | 111 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
111 | 112 | { |
112 | - if (empty($row['lngfile'])) |
|
113 | - $row['lngfile'] = $language; |
|
113 | + if (empty($row['lngfile'])) { |
|
114 | + $row['lngfile'] = $language; |
|
115 | + } |
|
114 | 116 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
115 | 117 | } |
116 | 118 | $smcFunc['db_free_result']($request); |
@@ -129,8 +131,9 @@ discard block |
||
129 | 131 | $emaildata = loadEmailTemplate('report_member_profile', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
130 | 132 | |
131 | 133 | // And do the actual sending... |
132 | - foreach ($recipients as $id_member => $email_address) |
|
133 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'ureport' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
134 | + foreach ($recipients as $id_member => $email_address) { |
|
135 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'ureport' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
136 | + } |
|
134 | 137 | } |
135 | 138 | } |
136 | 139 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | class ApprovePost_Notify_Background extends SMF_BackgroundTask |
19 | 19 | { |
20 | 20 | /** |
21 | - * This executes the task - loads up the info, puts the email in the queue and inserts any alerts as needed. |
|
21 | + * This executes the task - loads up the info, puts the email in the queue and inserts any alerts as needed. |
|
22 | 22 | * @return bool Always returns true |
23 | 23 | */ |
24 | 24 | public function execute() |
@@ -54,8 +54,9 @@ discard block |
||
54 | 54 | } |
55 | 55 | $smcFunc['db_free_result']($request); |
56 | 56 | |
57 | - if (empty($members)) |
|
58 | - return true; |
|
57 | + if (empty($members)) { |
|
58 | + return true; |
|
59 | + } |
|
59 | 60 | |
60 | 61 | require_once($sourcedir . '/Subs-Notify.php'); |
61 | 62 | $members = array_unique($members); |
@@ -103,14 +104,15 @@ discard block |
||
103 | 104 | } |
104 | 105 | |
105 | 106 | // Insert the alerts if any |
106 | - if (!empty($alert_rows)) |
|
107 | - $smcFunc['db_insert']('', |
|
107 | + if (!empty($alert_rows)) { |
|
108 | + $smcFunc['db_insert']('', |
|
108 | 109 | '{db_prefix}user_alerts', |
109 | 110 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
110 | 111 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
111 | 112 | $alert_rows, |
112 | 113 | array() |
113 | 114 | ); |
115 | + } |
|
114 | 116 | |
115 | 117 | return true; |
116 | 118 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class Register_Notify_Background extends SMF_BackgroundTask |
20 | 20 | { |
21 | 21 | /** |
22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
23 | 23 | * @return bool Always returns true. |
24 | 24 | */ |
25 | 25 | public function execute() |
@@ -43,9 +43,10 @@ discard block |
||
43 | 43 | |
44 | 44 | foreach ($prefs as $member => $pref_option) |
45 | 45 | { |
46 | - foreach ($alert_bits as $type => $bitvalue) |
|
47 | - if ($pref_option['member_register'] & $bitvalue) |
|
46 | + foreach ($alert_bits as $type => $bitvalue) { |
|
47 | + if ($pref_option['member_register'] & $bitvalue) |
|
48 | 48 | $notifies[$type][] = $member; |
49 | + } |
|
49 | 50 | } |
50 | 51 | |
51 | 52 | // Firstly, anyone who wants alerts. |
@@ -101,8 +102,9 @@ discard block |
||
101 | 102 | ); |
102 | 103 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
103 | 104 | { |
104 | - if (empty($row['lngfile'])) |
|
105 | - $row['lngfile'] = $language; |
|
105 | + if (empty($row['lngfile'])) { |
|
106 | + $row['lngfile'] = $language; |
|
107 | + } |
|
106 | 108 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
107 | 109 | } |
108 | 110 | $smcFunc['db_free_result']($request); |
@@ -126,8 +128,9 @@ discard block |
||
126 | 128 | $emaildata = loadEmailTemplate($emailtype, $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
127 | 129 | |
128 | 130 | // And do the actual sending... |
129 | - foreach ($recipients as $id_member => $email_address) |
|
130 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'newmember' . $this->_details['new_member_id'], $emaildata['is_html'], 0); |
|
131 | + foreach ($recipients as $id_member => $email_address) { |
|
132 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'newmember' . $this->_details['new_member_id'], $emaildata['is_html'], 0); |
|
133 | + } |
|
131 | 134 | } |
132 | 135 | } |
133 | 136 |
@@ -19,7 +19,7 @@ |
||
19 | 19 | class MsgReport_Notify_Background extends SMF_BackgroundTask |
20 | 20 | { |
21 | 21 | /** |
22 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
22 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
23 | 23 | * @return bool Always returns true. |
24 | 24 | */ |
25 | 25 | public function execute() |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | 'current_board' => $this->_details['board_id'], |
41 | 41 | ) |
42 | 42 | ); |
43 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
44 | - $members[] = $row['id_member']; |
|
43 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
44 | + $members[] = $row['id_member']; |
|
45 | + } |
|
45 | 46 | $smcFunc['db_free_result']($request); |
46 | 47 | |
47 | 48 | // Thirdly, anyone assigned to be a moderator of this group as a group->board moderator. |
@@ -58,8 +59,9 @@ discard block |
||
58 | 59 | ) |
59 | 60 | ); |
60 | 61 | |
61 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
62 | - $members[] = $row['id_member']; |
|
62 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
63 | + $members[] = $row['id_member']; |
|
64 | + } |
|
63 | 65 | $smcFunc['db_free_result']($request); |
64 | 66 | |
65 | 67 | // And now weed out the duplicates. |
@@ -81,9 +83,10 @@ discard block |
||
81 | 83 | |
82 | 84 | foreach ($prefs as $member => $pref_option) |
83 | 85 | { |
84 | - foreach ($alert_bits as $type => $bitvalue) |
|
85 | - if ($pref_option['msg_report'] & $bitvalue) |
|
86 | + foreach ($alert_bits as $type => $bitvalue) { |
|
87 | + if ($pref_option['msg_report'] & $bitvalue) |
|
86 | 88 | $notifies[$type][] = $member; |
89 | + } |
|
87 | 90 | } |
88 | 91 | |
89 | 92 | // Firstly, anyone who wants alerts. |
@@ -143,8 +146,9 @@ discard block |
||
143 | 146 | ); |
144 | 147 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
145 | 148 | { |
146 | - if (empty($row['lngfile'])) |
|
147 | - $row['lngfile'] = $language; |
|
149 | + if (empty($row['lngfile'])) { |
|
150 | + $row['lngfile'] = $language; |
|
151 | + } |
|
148 | 152 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
149 | 153 | } |
150 | 154 | $smcFunc['db_free_result']($request); |
@@ -177,8 +181,9 @@ discard block |
||
177 | 181 | $emaildata = loadEmailTemplate('report_to_moderator', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
178 | 182 | |
179 | 183 | // And do the actual sending... |
180 | - foreach ($recipients as $id_member => $email_address) |
|
181 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'report' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
184 | + foreach ($recipients as $id_member => $email_address) { |
|
185 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'report' . $this->_details['report_id'], $emaildata['is_html'], 2); |
|
186 | + } |
|
182 | 187 | } |
183 | 188 | } |
184 | 189 |
@@ -18,10 +18,10 @@ |
||
18 | 18 | */ |
19 | 19 | class Update_TLD_Regex extends SMF_BackgroundTask |
20 | 20 | { |
21 | - /** |
|
22 | - * This executes the task. It just calls set_tld_regex() in Subs.php |
|
23 | - * @return bool Always returns true |
|
24 | - */ |
|
21 | + /** |
|
22 | + * This executes the task. It just calls set_tld_regex() in Subs.php |
|
23 | + * @return bool Always returns true |
|
24 | + */ |
|
25 | 25 | public function execute() |
26 | 26 | { |
27 | 27 | global $sourcedir; |
@@ -20,7 +20,7 @@ |
||
20 | 20 | class MemberReportReply_Notify_Background extends SMF_BackgroundTask |
21 | 21 | { |
22 | 22 | /** |
23 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
23 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts as needed. |
|
24 | 24 | * @return bool Always returns true. |
25 | 25 | */ |
26 | 26 | public function execute() |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | 'last_comment' => $this->_details['comment_id'], |
41 | 41 | ) |
42 | 42 | ); |
43 | - while ($row = $smcFunc['db_fetch_row']($request)) |
|
44 | - $possible_members[] = $row[0]; |
|
43 | + while ($row = $smcFunc['db_fetch_row']($request)) { |
|
44 | + $possible_members[] = $row[0]; |
|
45 | + } |
|
45 | 46 | $smcFunc['db_free_result']($request); |
46 | 47 | |
47 | 48 | // Presumably, there are some people? |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | $possible_members = array_flip(array_flip($possible_members)); |
51 | 52 | $possible_members = array_diff($possible_members, array($this->_details['sender_id'])); |
52 | 53 | } |
53 | - if (empty($possible_members)) |
|
54 | - return true; |
|
54 | + if (empty($possible_members)) { |
|
55 | + return true; |
|
56 | + } |
|
55 | 57 | |
56 | 58 | // We need to know who can moderate this board - and therefore who can see this report. |
57 | 59 | // First up, people who have moderate_board in the board this topic was in. |
@@ -73,8 +75,9 @@ discard block |
||
73 | 75 | { |
74 | 76 | foreach ($alert_bits as $type => $bitvalue) |
75 | 77 | { |
76 | - if ($pref_option['member_report_reply'] & $bitvalue) |
|
77 | - $notifies[$type][] = $member; |
|
78 | + if ($pref_option['member_report_reply'] & $bitvalue) { |
|
79 | + $notifies[$type][] = $member; |
|
80 | + } |
|
78 | 81 | } |
79 | 82 | } |
80 | 83 | |
@@ -136,8 +139,9 @@ discard block |
||
136 | 139 | ); |
137 | 140 | while ($row = $smcFunc['db_fetch_assoc']($request)) |
138 | 141 | { |
139 | - if (empty($row['lngfile'])) |
|
140 | - $row['lngfile'] = $language; |
|
142 | + if (empty($row['lngfile'])) { |
|
143 | + $row['lngfile'] = $language; |
|
144 | + } |
|
141 | 145 | $emails[$row['lngfile']][$row['id_member']] = $row['email_address']; |
142 | 146 | } |
143 | 147 | $smcFunc['db_free_result']($request); |
@@ -155,8 +159,9 @@ discard block |
||
155 | 159 | $emaildata = loadEmailTemplate('reply_to_user_reports', $replacements, empty($modSettings['userLanguage']) ? $language : $this_lang); |
156 | 160 | |
157 | 161 | // And do the actual sending... |
158 | - foreach ($recipients as $id_member => $email_address) |
|
159 | - sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'urptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
162 | + foreach ($recipients as $id_member => $email_address) { |
|
163 | + sendmail($email_address, $emaildata['subject'], $emaildata['body'], null, 'urptrpy' . $this->_details['comment_id'], $emaildata['is_html'], 3); |
|
164 | + } |
|
160 | 165 | } |
161 | 166 | } |
162 | 167 |
@@ -18,7 +18,7 @@ |
||
18 | 18 | class ApproveReply_Notify_Background extends SMF_BackgroundTask |
19 | 19 | { |
20 | 20 | /** |
21 | - * This executes the task - loads up the information, puts the email in the queue and inserts alerts. |
|
21 | + * This executes the task - loads up the information, puts the email in the queue and inserts alerts. |
|
22 | 22 | * @return bool Always returns true. |
23 | 23 | */ |
24 | 24 | public function execute() |
@@ -96,14 +96,15 @@ |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | // Insert the alerts if any |
99 | - if (!empty($alert_rows)) |
|
100 | - $smcFunc['db_insert']('', |
|
99 | + if (!empty($alert_rows)) { |
|
100 | + $smcFunc['db_insert']('', |
|
101 | 101 | '{db_prefix}user_alerts', |
102 | 102 | array('alert_time' => 'int', 'id_member' => 'int', 'id_member_started' => 'int', 'member_name' => 'string', |
103 | 103 | 'content_type' => 'string', 'content_id' => 'int', 'content_action' => 'string', 'is_read' => 'int', 'extra' => 'string'), |
104 | 104 | $alert_rows, |
105 | 105 | array() |
106 | 106 | ); |
107 | + } |
|
107 | 108 | |
108 | 109 | return true; |
109 | 110 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | class GroupReq_Notify_Background extends SMF_BackgroundTask |
21 | 21 | { |
22 | 22 | /** |
23 | - * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed. |
|
23 | + * This executes the task - loads up the information, puts the email in the queue and inserts any alerts as needed. |
|
24 | 24 | * @return bool Always returns true. |
25 | 25 | */ |
26 | 26 | public function execute() |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | ) |
38 | 38 | ); |
39 | 39 | $moderators = array(); |
40 | - while ($row = $smcFunc['db_fetch_assoc']($request)) |
|
41 | - $moderators[] = $row['id_member']; |
|
40 | + while ($row = $smcFunc['db_fetch_assoc']($request)) { |
|
41 | + $moderators[] = $row['id_member']; |
|
42 | + } |
|
42 | 43 | $smcFunc['db_free_result']($request); |
43 | 44 | |
44 | 45 | require_once($sourcedir . '/Subs-Members.php'); |
@@ -59,11 +60,13 @@ discard block |
||
59 | 60 | { |
60 | 61 | if (!empty($prefs[$mod]['request_group'])) |
61 | 62 | { |
62 | - if ($prefs[$mod]['request_group'] & 0x01) |
|
63 | - $data['alert'][] = $mod; |
|
63 | + if ($prefs[$mod]['request_group'] & 0x01) { |
|
64 | + $data['alert'][] = $mod; |
|
65 | + } |
|
64 | 66 | |
65 | - if ($prefs[$mod]['request_group'] & 0x02) |
|
66 | - $data['email'][] = $mod; |
|
67 | + if ($prefs[$mod]['request_group'] & 0x02) { |
|
68 | + $data['email'][] = $mod; |
|
69 | + } |
|
67 | 70 | } |
68 | 71 | } |
69 | 72 |
@@ -240,8 +240,8 @@ |
||
240 | 240 | $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
241 | 241 | |
242 | 242 | $js_time_string = str_replace( |
243 | - array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
244 | - array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
243 | + array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
|
244 | + array('H', 'G', 'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s'), |
|
245 | 245 | $time_string |
246 | 246 | ); |
247 | 247 |
@@ -14,8 +14,9 @@ discard block |
||
14 | 14 | * @version 2.1 Beta 4 |
15 | 15 | */ |
16 | 16 | |
17 | -if (!defined('SMF')) |
|
17 | +if (!defined('SMF')) { |
|
18 | 18 | die('No direct access...'); |
19 | +} |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * Show the calendar. |
@@ -47,12 +48,14 @@ discard block |
||
47 | 48 | 'post' => 'CalendarPost', |
48 | 49 | ); |
49 | 50 | |
50 | - if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) |
|
51 | - return call_helper($subActions[$_GET['sa']]); |
|
51 | + if (isset($_GET['sa']) && isset($subActions[$_GET['sa']])) { |
|
52 | + return call_helper($subActions[$_GET['sa']]); |
|
53 | + } |
|
52 | 54 | |
53 | 55 | // You can't do anything if the calendar is off. |
54 | - if (empty($modSettings['cal_enabled'])) |
|
55 | - fatal_lang_error('calendar_off', false); |
|
56 | + if (empty($modSettings['cal_enabled'])) { |
|
57 | + fatal_lang_error('calendar_off', false); |
|
58 | + } |
|
56 | 59 | |
57 | 60 | // This is gonna be needed... |
58 | 61 | loadTemplate('Calendar'); |
@@ -88,22 +91,25 @@ discard block |
||
88 | 91 | $context['page_title'] = $txt['calendar']; |
89 | 92 | |
90 | 93 | // Ensure a default view is defined |
91 | - if (empty($modSettings['calendar_default_view'])) |
|
92 | - $modSettings['calendar_default_view'] = 'viewlist'; |
|
94 | + if (empty($modSettings['calendar_default_view'])) { |
|
95 | + $modSettings['calendar_default_view'] = 'viewlist'; |
|
96 | + } |
|
93 | 97 | |
94 | 98 | // What view do we want? |
95 | - if (isset($_GET['viewweek'])) |
|
96 | - $context['calendar_view'] = 'viewweek'; |
|
97 | - elseif (isset($_GET['viewmonth'])) |
|
98 | - $context['calendar_view'] = 'viewmonth'; |
|
99 | - elseif (isset($_GET['viewlist'])) |
|
100 | - $context['calendar_view'] = 'viewlist'; |
|
101 | - else |
|
102 | - $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
99 | + if (isset($_GET['viewweek'])) { |
|
100 | + $context['calendar_view'] = 'viewweek'; |
|
101 | + } elseif (isset($_GET['viewmonth'])) { |
|
102 | + $context['calendar_view'] = 'viewmonth'; |
|
103 | + } elseif (isset($_GET['viewlist'])) { |
|
104 | + $context['calendar_view'] = 'viewlist'; |
|
105 | + } else { |
|
106 | + $context['calendar_view'] = $modSettings['calendar_default_view']; |
|
107 | + } |
|
103 | 108 | |
104 | 109 | // Don't let search engines index the non-default calendar pages |
105 | - if ($context['calendar_view'] !== $modSettings['calendar_default_view']) |
|
106 | - $context['robot_no_index'] = true; |
|
110 | + if ($context['calendar_view'] !== $modSettings['calendar_default_view']) { |
|
111 | + $context['robot_no_index'] = true; |
|
112 | + } |
|
107 | 113 | |
108 | 114 | // Get the current day of month... |
109 | 115 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -164,16 +170,19 @@ discard block |
||
164 | 170 | ); |
165 | 171 | |
166 | 172 | // Make sure the year and month are in valid ranges. |
167 | - if ($curPage['month'] < 1 || $curPage['month'] > 12) |
|
168 | - fatal_lang_error('invalid_month', false); |
|
169 | - if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) |
|
170 | - fatal_lang_error('invalid_year', false); |
|
173 | + if ($curPage['month'] < 1 || $curPage['month'] > 12) { |
|
174 | + fatal_lang_error('invalid_month', false); |
|
175 | + } |
|
176 | + if ($curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear']) { |
|
177 | + fatal_lang_error('invalid_year', false); |
|
178 | + } |
|
171 | 179 | // If we have a day clean that too. |
172 | 180 | if ($context['calendar_view'] != 'viewmonth') |
173 | 181 | { |
174 | 182 | $isValid = checkdate($curPage['month'], $curPage['day'], $curPage['year']); |
175 | - if (!$isValid) |
|
176 | - fatal_lang_error('invalid_day', false); |
|
183 | + if (!$isValid) { |
|
184 | + fatal_lang_error('invalid_day', false); |
|
185 | + } |
|
177 | 186 | } |
178 | 187 | |
179 | 188 | // Load all the context information needed to show the calendar grid. |
@@ -195,23 +204,26 @@ discard block |
||
195 | 204 | ); |
196 | 205 | |
197 | 206 | // Load up the main view. |
198 | - if ($context['calendar_view'] == 'viewlist') |
|
199 | - $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
200 | - elseif ($context['calendar_view'] == 'viewweek') |
|
201 | - $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
202 | - else |
|
203 | - $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
207 | + if ($context['calendar_view'] == 'viewlist') { |
|
208 | + $context['calendar_grid_main'] = getCalendarList($curPage['start_date'], $curPage['end_date'], $calendarOptions); |
|
209 | + } elseif ($context['calendar_view'] == 'viewweek') { |
|
210 | + $context['calendar_grid_main'] = getCalendarWeek($curPage['month'], $curPage['year'], $curPage['day'], $calendarOptions); |
|
211 | + } else { |
|
212 | + $context['calendar_grid_main'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
|
213 | + } |
|
204 | 214 | |
205 | 215 | // Load up the previous and next months. |
206 | 216 | $context['calendar_grid_current'] = getCalendarGrid($curPage['month'], $curPage['year'], $calendarOptions); |
207 | 217 | |
208 | 218 | // Only show previous month if it isn't pre-January of the min-year |
209 | - if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) |
|
210 | - $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
219 | + if ($context['calendar_grid_current']['previous_calendar']['year'] > $modSettings['cal_minyear'] || $curPage['month'] != 1) { |
|
220 | + $context['calendar_grid_prev'] = getCalendarGrid($context['calendar_grid_current']['previous_calendar']['month'], $context['calendar_grid_current']['previous_calendar']['year'], $calendarOptions, true); |
|
221 | + } |
|
211 | 222 | |
212 | 223 | // Only show next month if it isn't post-December of the max-year |
213 | - if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) |
|
214 | - $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
224 | + if ($context['calendar_grid_current']['next_calendar']['year'] < $modSettings['cal_maxyear'] || $curPage['month'] != 12) { |
|
225 | + $context['calendar_grid_next'] = getCalendarGrid($context['calendar_grid_current']['next_calendar']['month'], $context['calendar_grid_current']['next_calendar']['year'], $calendarOptions); |
|
226 | + } |
|
215 | 227 | |
216 | 228 | // Basic template stuff. |
217 | 229 | $context['allow_calendar_event'] = allowedTo('calendar_post'); |
@@ -231,8 +243,9 @@ discard block |
||
231 | 243 | $context['blocks_disabled'] = !empty($modSettings['cal_disable_prev_next']) ? 1 : 0; |
232 | 244 | |
233 | 245 | // Set the page title to mention the month or week, too |
234 | - if ($context['calendar_view'] != 'viewlist') |
|
235 | - $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
246 | + if ($context['calendar_view'] != 'viewlist') { |
|
247 | + $context['page_title'] .= ' - ' . ($context['calendar_view'] == 'viewweek' ? $context['calendar_grid_main']['week_title'] : $txt['months'][$context['current_month']] . ' ' . $context['current_year']); |
|
248 | + } |
|
236 | 249 | |
237 | 250 | // Load up the linktree! |
238 | 251 | $context['linktree'][] = array( |
@@ -245,17 +258,19 @@ discard block |
||
245 | 258 | 'name' => $txt['months'][$context['current_month']] . ' ' . $context['current_year'] |
246 | 259 | ); |
247 | 260 | // If applicable, add the current week to the linktree. |
248 | - if ($context['calendar_view'] == 'viewweek') |
|
249 | - $context['linktree'][] = array( |
|
261 | + if ($context['calendar_view'] == 'viewweek') { |
|
262 | + $context['linktree'][] = array( |
|
250 | 263 | 'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'], |
251 | 264 | 'name' => $context['calendar_grid_main']['week_title'], |
252 | 265 | ); |
266 | + } |
|
253 | 267 | |
254 | 268 | // Build the calendar button array. |
255 | 269 | $context['calendar_buttons'] = array(); |
256 | 270 | |
257 | - if ($context['can_post']) |
|
258 | - $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
271 | + if ($context['can_post']) { |
|
272 | + $context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']); |
|
273 | + } |
|
259 | 274 | |
260 | 275 | // Allow mods to add additional buttons here |
261 | 276 | call_integration_hook('integrate_calendar_buttons'); |
@@ -284,14 +299,16 @@ discard block |
||
284 | 299 | require_once($sourcedir . '/Subs.php'); |
285 | 300 | |
286 | 301 | // Cast this for safety... |
287 | - if (isset($_REQUEST['eventid'])) |
|
288 | - $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
302 | + if (isset($_REQUEST['eventid'])) { |
|
303 | + $_REQUEST['eventid'] = (int) $_REQUEST['eventid']; |
|
304 | + } |
|
289 | 305 | |
290 | 306 | // We want a fairly compact version of the time, but as close as possible to the user's settings. |
291 | - if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) |
|
292 | - $time_string = '%k:%M'; |
|
293 | - else |
|
294 | - $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
307 | + if (preg_match('~%[HkIlMpPrRSTX](?:[^%]*%[HkIlMpPrRSTX])*~', $user_info['time_format'], $matches) == 0 || empty($matches[0])) { |
|
308 | + $time_string = '%k:%M'; |
|
309 | + } else { |
|
310 | + $time_string = str_replace(array('%I', '%H', '%S', '%r', '%R', '%T'), array('%l', '%k', '', '%l:%M %p', '%k:%M', '%l:%M'), $matches[0]); |
|
311 | + } |
|
295 | 312 | |
296 | 313 | $js_time_string = str_replace( |
297 | 314 | array('%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X'), |
@@ -305,12 +322,14 @@ discard block |
||
305 | 322 | checkSession(); |
306 | 323 | |
307 | 324 | // Validate the post... |
308 | - if (!isset($_POST['link_to_board'])) |
|
309 | - validateEventPost(); |
|
325 | + if (!isset($_POST['link_to_board'])) { |
|
326 | + validateEventPost(); |
|
327 | + } |
|
310 | 328 | |
311 | 329 | // If you're not allowed to edit any events, you have to be the poster. |
312 | - if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) |
|
313 | - isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
330 | + if ($_REQUEST['eventid'] > 0 && !allowedTo('calendar_edit_any')) { |
|
331 | + isAllowedTo('calendar_edit_' . (!empty($user_info['id']) && getEventPoster($_REQUEST['eventid']) == $user_info['id'] ? 'own' : 'any')); |
|
332 | + } |
|
314 | 333 | |
315 | 334 | // New - and directing? |
316 | 335 | if (isset($_POST['link_to_board']) || empty($modSettings['cal_allow_unlinked'])) |
@@ -333,8 +352,9 @@ discard block |
||
333 | 352 | } |
334 | 353 | |
335 | 354 | // Deleting... |
336 | - elseif (isset($_REQUEST['deleteevent'])) |
|
337 | - removeEvent($_REQUEST['eventid']); |
|
355 | + elseif (isset($_REQUEST['deleteevent'])) { |
|
356 | + removeEvent($_REQUEST['eventid']); |
|
357 | + } |
|
338 | 358 | |
339 | 359 | // ... or just update it? |
340 | 360 | else |
@@ -357,15 +377,13 @@ discard block |
||
357 | 377 | $year = $d['year']; |
358 | 378 | $month = $d['month']; |
359 | 379 | $day = $d['day']; |
360 | - } |
|
361 | - elseif (isset($_POST['start_datetime'])) |
|
380 | + } elseif (isset($_POST['start_datetime'])) |
|
362 | 381 | { |
363 | 382 | $d = date_parse($_POST['start_datetime']); |
364 | 383 | $year = $d['year']; |
365 | 384 | $month = $d['month']; |
366 | 385 | $day = $d['day']; |
367 | - } |
|
368 | - else |
|
386 | + } else |
|
369 | 387 | { |
370 | 388 | $today = getdate(); |
371 | 389 | $year = isset($_POST['year']) ? $_POST['year'] : $today['year']; |
@@ -399,13 +417,13 @@ discard block |
||
399 | 417 | $context['event'] = array_merge($context['event'], $eventDatetimes); |
400 | 418 | |
401 | 419 | $context['event']['last_day'] = (int) strftime('%d', mktime(0, 0, 0, $context['event']['month'] == 12 ? 1 : $context['event']['month'] + 1, 0, $context['event']['month'] == 12 ? $context['event']['year'] + 1 : $context['event']['year'])); |
402 | - } |
|
403 | - else |
|
420 | + } else |
|
404 | 421 | { |
405 | 422 | $context['event'] = getEventProperties($_REQUEST['eventid']); |
406 | 423 | |
407 | - if ($context['event'] === false) |
|
408 | - fatal_lang_error('no_access', false); |
|
424 | + if ($context['event'] === false) { |
|
425 | + fatal_lang_error('no_access', false); |
|
426 | + } |
|
409 | 427 | |
410 | 428 | // If it has a board, then they should be editing it within the topic. |
411 | 429 | if (!empty($context['event']['topic']['id']) && !empty($context['event']['topic']['first_msg'])) |
@@ -416,10 +434,11 @@ discard block |
||
416 | 434 | } |
417 | 435 | |
418 | 436 | // Make sure the user is allowed to edit this event. |
419 | - if ($context['event']['member'] != $user_info['id']) |
|
420 | - isAllowedTo('calendar_edit_any'); |
|
421 | - elseif (!allowedTo('calendar_edit_any')) |
|
422 | - isAllowedTo('calendar_edit_own'); |
|
437 | + if ($context['event']['member'] != $user_info['id']) { |
|
438 | + isAllowedTo('calendar_edit_any'); |
|
439 | + } elseif (!allowedTo('calendar_edit_any')) { |
|
440 | + isAllowedTo('calendar_edit_own'); |
|
441 | + } |
|
423 | 442 | } |
424 | 443 | |
425 | 444 | // An all day event? Set up some nice defaults in case the user wants to change that |
@@ -453,8 +472,7 @@ discard block |
||
453 | 472 | { |
454 | 473 | // You can post new events but can't link them to anything... |
455 | 474 | $context['event']['categories'] = array(); |
456 | - } |
|
457 | - else |
|
475 | + } else |
|
458 | 476 | { |
459 | 477 | // Load the list of boards and categories in the context. |
460 | 478 | require_once($sourcedir . '/Subs-MessageIndex.php'); |
@@ -541,12 +559,14 @@ discard block |
||
541 | 559 | global $smcFunc, $sourcedir, $forum_version, $modSettings, $webmaster_email, $mbname; |
542 | 560 | |
543 | 561 | // You can't export if the calendar export feature is off. |
544 | - if (empty($modSettings['cal_export'])) |
|
545 | - fatal_lang_error('calendar_export_off', false); |
|
562 | + if (empty($modSettings['cal_export'])) { |
|
563 | + fatal_lang_error('calendar_export_off', false); |
|
564 | + } |
|
546 | 565 | |
547 | 566 | // Goes without saying that this is required. |
548 | - if (!isset($_REQUEST['eventid'])) |
|
549 | - fatal_lang_error('no_access', false); |
|
567 | + if (!isset($_REQUEST['eventid'])) { |
|
568 | + fatal_lang_error('no_access', false); |
|
569 | + } |
|
550 | 570 | |
551 | 571 | // This is kinda wanted. |
552 | 572 | require_once($sourcedir . '/Subs-Calendar.php'); |
@@ -554,15 +574,17 @@ discard block |
||
554 | 574 | // Load up the event in question and check it exists. |
555 | 575 | $event = getEventProperties($_REQUEST['eventid']); |
556 | 576 | |
557 | - if ($event === false) |
|
558 | - fatal_lang_error('no_access', false); |
|
577 | + if ($event === false) { |
|
578 | + fatal_lang_error('no_access', false); |
|
579 | + } |
|
559 | 580 | |
560 | 581 | // Check the title isn't too long - iCal requires some formatting if so. |
561 | 582 | $title = str_split($event['title'], 30); |
562 | 583 | foreach ($title as $id => $line) |
563 | 584 | { |
564 | - if ($id != 0) |
|
565 | - $title[$id] = ' ' . $title[$id]; |
|
585 | + if ($id != 0) { |
|
586 | + $title[$id] = ' ' . $title[$id]; |
|
587 | + } |
|
566 | 588 | $title[$id] .= "\n"; |
567 | 589 | } |
568 | 590 | |
@@ -575,8 +597,7 @@ discard block |
||
575 | 597 | { |
576 | 598 | $datestart = date_format($start_date, 'Ymd\THis'); |
577 | 599 | $dateend = date_format($end_date, 'Ymd\THis'); |
578 | - } |
|
579 | - else |
|
600 | + } else |
|
580 | 601 | { |
581 | 602 | $datestart = date_format($start_date, 'Ymd'); |
582 | 603 | |
@@ -597,15 +618,18 @@ discard block |
||
597 | 618 | $filecontents .= 'DTSTART' . (!empty($event['start_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $datestart . "\n"; |
598 | 619 | |
599 | 620 | // event has a duration |
600 | - if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) |
|
601 | - $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
621 | + if ($event['start_iso_gmdate'] != $event['end_iso_gmdate']) { |
|
622 | + $filecontents .= 'DTEND' . (!empty($event['end_time']) ? ';TZID=' . $event['tz'] : ';VALUE=DATE') . ':' . $dateend . "\n"; |
|
623 | + } |
|
602 | 624 | |
603 | 625 | // event has changed? advance the sequence for this UID |
604 | - if ($event['sequence'] > 0) |
|
605 | - $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
626 | + if ($event['sequence'] > 0) { |
|
627 | + $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n"; |
|
628 | + } |
|
606 | 629 | |
607 | - if (!empty($event['location'])) |
|
608 | - $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
630 | + if (!empty($event['location'])) { |
|
631 | + $filecontents .= 'LOCATION:' . str_replace(',', '\,', $event['location']) . "\n"; |
|
632 | + } |
|
609 | 633 | |
610 | 634 | $filecontents .= 'SUMMARY:' . implode('', $title); |
611 | 635 | $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n"; |
@@ -614,23 +638,26 @@ discard block |
||
614 | 638 | |
615 | 639 | // Send some standard headers. |
616 | 640 | ob_end_clean(); |
617 | - if (!empty($modSettings['enableCompressedOutput'])) |
|
618 | - @ob_start('ob_gzhandler'); |
|
619 | - else |
|
620 | - ob_start(); |
|
641 | + if (!empty($modSettings['enableCompressedOutput'])) { |
|
642 | + @ob_start('ob_gzhandler'); |
|
643 | + } else { |
|
644 | + ob_start(); |
|
645 | + } |
|
621 | 646 | |
622 | 647 | // Send the file headers |
623 | 648 | header('pragma: '); |
624 | 649 | header('cache-control: no-cache'); |
625 | - if (!isBrowser('gecko')) |
|
626 | - header('content-transfer-encoding: binary'); |
|
650 | + if (!isBrowser('gecko')) { |
|
651 | + header('content-transfer-encoding: binary'); |
|
652 | + } |
|
627 | 653 | header('expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT'); |
628 | 654 | header('last-modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT'); |
629 | 655 | header('accept-ranges: bytes'); |
630 | 656 | header('connection: close'); |
631 | 657 | header('content-disposition: attachment; filename="' . $event['title'] . '.ics"'); |
632 | - if (empty($modSettings['enableCompressedOutput'])) |
|
633 | - header('content-length: ' . $smcFunc['strlen']($filecontents)); |
|
658 | + if (empty($modSettings['enableCompressedOutput'])) { |
|
659 | + header('content-length: ' . $smcFunc['strlen']($filecontents)); |
|
660 | + } |
|
634 | 661 | |
635 | 662 | // This is a calendar item! |
636 | 663 | header('content-type: text/calendar'); |
@@ -669,20 +696,17 @@ discard block |
||
669 | 696 | $context['sub_template'] = 'bcd'; |
670 | 697 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;bcd', 'name' => 'BCD'); |
671 | 698 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoMSI6WzIsMV0sImgyIjpbOCw0LDIsMV0sIm0xIjpbNCwyLDFdLCJtMiI6WzgsNCwyLDFdLCJzMSI6WzQsMiwxXSwiczIiOls4LDQsMiwxXX0='), true); |
672 | - } |
|
673 | - elseif (!$omfg && !isset($_REQUEST['time'])) |
|
699 | + } elseif (!$omfg && !isset($_REQUEST['time'])) |
|
674 | 700 | { |
675 | 701 | $context['sub_template'] = 'hms'; |
676 | 702 | $context['linktree'][] = array('url' => $scripturl . '?action=clock', 'name' => 'Binary'); |
677 | 703 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJoIjpbMTYsOCw0LDIsMV0sIm0iOlszMiwxNiw4LDQsMiwxXSwicyI6WzMyLDE2LDgsNCwyLDFdfQ'), true); |
678 | - } |
|
679 | - elseif ($omfg) |
|
704 | + } elseif ($omfg) |
|
680 | 705 | { |
681 | 706 | $context['sub_template'] = 'omfg'; |
682 | 707 | $context['linktree'][] = array('url' => $scripturl . '?action=clock;omfg', 'name' => 'OMFG'); |
683 | 708 | $context['clockicons'] = $smcFunc['json_decode'](base64_decode('eyJ5ZWFyIjpbNjQsMzIsMTYsOCw0LDIsMV0sIm1vbnRoIjpbOCw0LDIsMV0sImRheSI6WzE2LDgsNCwyLDFdLCJob3VyIjpbMTYsOCw0LDIsMV0sIm1pbiI6WzMyLDE2LDgsNCwyLDFdLCJzZWMiOlszMiwxNiw4LDQsMiwxXX0='), true); |
684 | - } |
|
685 | - elseif (isset($_REQUEST['time'])) |
|
709 | + } elseif (isset($_REQUEST['time'])) |
|
686 | 710 | { |
687 | 711 | $context['sub_template'] = 'thetime'; |
688 | 712 | $time = getdate($_REQUEST['time'] == 'now' ? time() : (int) $_REQUEST['time']); |
@@ -736,12 +760,13 @@ discard block |
||
736 | 760 | ), |
737 | 761 | ); |
738 | 762 | |
739 | - foreach ($context['clockicons'] as $t => $vs) |
|
740 | - foreach ($vs as $v => $dumb) |
|
763 | + foreach ($context['clockicons'] as $t => $vs) { |
|
764 | + foreach ($vs as $v => $dumb) |
|
741 | 765 | { |
742 | 766 | if ($$t >= $v) |
743 | 767 | { |
744 | 768 | $$t -= $v; |
769 | + } |
|
745 | 770 | $context['clockicons'][$t][$v] = true; |
746 | 771 | } |
747 | 772 | } |