@@ -9,34 +9,34 @@ discard block |
||
9 | 9 | * Implements hook_perm(). |
10 | 10 | */ |
11 | 11 | function privatemsg_filter_perm() { |
12 | - return array( |
|
12 | + return array( |
|
13 | 13 | 'filter private messages', |
14 | 14 | 'tag private messages', |
15 | 15 | 'create private message tags', |
16 | - ); |
|
16 | + ); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Implements hook_menu(). |
21 | 21 | */ |
22 | 22 | function privatemsg_filter_menu() { |
23 | - $items['admin/settings/messages/filter'] = array( |
|
23 | + $items['admin/settings/messages/filter'] = array( |
|
24 | 24 | 'title' => 'Filter', |
25 | 25 | 'description' => 'Configure filter settings.', |
26 | 26 | 'page callback' => 'drupal_get_form', |
27 | 27 | 'page arguments' => array('privatemsg_filter_admin'), |
28 | 28 | 'access arguments' => array('administer privatemsg settings'), |
29 | 29 | 'type' => MENU_LOCAL_TASK, |
30 | - ); |
|
31 | - $items['admin/settings/messages/tags'] = array( |
|
30 | + ); |
|
31 | + $items['admin/settings/messages/tags'] = array( |
|
32 | 32 | 'title' => 'Tags', |
33 | 33 | 'description' => 'Configure tags.', |
34 | 34 | 'page callback' => 'privatemsg_tags_admin', |
35 | 35 | 'access arguments' => array('administer privatemsg settings'), |
36 | 36 | 'type' => MENU_LOCAL_TASK, |
37 | 37 | 'file' => 'privatemsg_filter.admin.inc', |
38 | - ); |
|
39 | - $items['admin/settings/messages/tags/list'] = array( |
|
38 | + ); |
|
39 | + $items['admin/settings/messages/tags/list'] = array( |
|
40 | 40 | 'title' => 'List', |
41 | 41 | 'description' => 'Configure tags.', |
42 | 42 | 'page callback' => 'privatemsg_tags_admin', |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
45 | 45 | 'file' => 'privatemsg_filter.admin.inc', |
46 | 46 | 'weight' => -10, |
47 | - ); |
|
48 | - $items['admin/settings/messages/tags/add'] = array( |
|
47 | + ); |
|
48 | + $items['admin/settings/messages/tags/add'] = array( |
|
49 | 49 | 'title' => 'Add', |
50 | 50 | 'description' => 'Configure tags.', |
51 | 51 | 'page callback' => 'drupal_get_form', |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | 'access arguments' => array('administer privatemsg settings'), |
54 | 54 | 'type' => MENU_LOCAL_TASK, |
55 | 55 | 'file' => 'privatemsg_filter.admin.inc', |
56 | - ); |
|
57 | - $items['admin/settings/messages/tags/edit/%'] = array( |
|
56 | + ); |
|
57 | + $items['admin/settings/messages/tags/edit/%'] = array( |
|
58 | 58 | 'title' => 'Add', |
59 | 59 | 'description' => 'Configure tags.', |
60 | 60 | 'page callback' => 'drupal_get_form', |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | 'access arguments' => array('administer privatemsg settings'), |
63 | 63 | 'type' => MENU_CALLBACK, |
64 | 64 | 'file' => 'privatemsg_filter.admin.inc', |
65 | - ); |
|
66 | - $items['admin/settings/messages/tags/delete/%'] = array( |
|
65 | + ); |
|
66 | + $items['admin/settings/messages/tags/delete/%'] = array( |
|
67 | 67 | 'title' => 'Add', |
68 | 68 | 'description' => 'Configure tags.', |
69 | 69 | 'page callback' => 'drupal_get_form', |
@@ -71,62 +71,62 @@ discard block |
||
71 | 71 | 'access arguments' => array('administer privatemsg settings'), |
72 | 72 | 'type' => MENU_CALLBACK, |
73 | 73 | 'file' => 'privatemsg_filter.admin.inc', |
74 | - ); |
|
75 | - $items['messages/inbox'] = array( |
|
74 | + ); |
|
75 | + $items['messages/inbox'] = array( |
|
76 | 76 | 'title' => 'Inbox', |
77 | 77 | 'page callback' => 'drupal_get_form', |
78 | 78 | 'page arguments' => array('privatemsg_list', 'inbox'), |
79 | 79 | 'access callback' => 'privatemsg_user_access', |
80 | 80 | 'type' => variable_get('privatemsg_filter_default_list', 0) ? MENU_LOCAL_TASK : MENU_DEFAULT_LOCAL_TASK, |
81 | 81 | 'weight' => -15, |
82 | - ); |
|
83 | - $items['messages/sent'] = array( |
|
82 | + ); |
|
83 | + $items['messages/sent'] = array( |
|
84 | 84 | 'title' => 'Sent messages', |
85 | 85 | 'page callback' => 'drupal_get_form', |
86 | 86 | 'page arguments' => array('privatemsg_list', 'sent'), |
87 | 87 | 'access callback' => 'privatemsg_user_access', |
88 | 88 | 'type' => MENU_LOCAL_TASK, |
89 | 89 | 'weight' => -12, |
90 | - ); |
|
91 | - $items['messages/filter/user-name-autocomplete'] = array( |
|
90 | + ); |
|
91 | + $items['messages/filter/user-name-autocomplete'] = array( |
|
92 | 92 | 'page callback' => 'privatemsg_user_name_autocomplete', |
93 | 93 | 'access callback' => 'privatemsg_user_access', |
94 | 94 | 'access arguments' => array('write privatemsg'), |
95 | 95 | 'type' => MENU_CALLBACK, |
96 | - ); |
|
97 | - $items['messages/filter/tag-autocomplete'] = array( |
|
96 | + ); |
|
97 | + $items['messages/filter/tag-autocomplete'] = array( |
|
98 | 98 | 'page callback' => 'privatemsg_filter_tags_autocomplete', |
99 | 99 | 'access callback' => 'privatemsg_user_access', |
100 | 100 | 'access arguments' => array('tag private messages'), |
101 | 101 | 'type' => MENU_CALLBACK, |
102 | 102 | 'weight' => -10, |
103 | - ); |
|
104 | - return $items; |
|
103 | + ); |
|
104 | + return $items; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Implements hook_menu_alter(). |
109 | 109 | */ |
110 | 110 | function privatemsg_filter_menu_alter(&$items) { |
111 | - // Rename messages to "All messages". |
|
112 | - $items['messages/list']['title'] = 'All messages'; |
|
111 | + // Rename messages to "All messages". |
|
112 | + $items['messages/list']['title'] = 'All messages'; |
|
113 | 113 | |
114 | - if (variable_get('privatemsg_filter_default_list', 0) == 0) { |
|
114 | + if (variable_get('privatemsg_filter_default_list', 0) == 0) { |
|
115 | 115 | // Change default argument of /messages to inbox. and set the task to MENU_LOCAL_TASK. |
116 | 116 | $items['messages']['page arguments'] = array('privatemsg_list', 'inbox'); |
117 | 117 | $items['messages/list']['type'] = MENU_LOCAL_TASK; |
118 | - } |
|
118 | + } |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | function privatemsg_filter_admin() { |
122 | - $form = array(); |
|
122 | + $form = array(); |
|
123 | 123 | |
124 | - $form['privatemsg_filter_searchbody'] = array( |
|
124 | + $form['privatemsg_filter_searchbody'] = array( |
|
125 | 125 | '#type' => 'checkbox', |
126 | 126 | '#title' => t('Search message body'), |
127 | 127 | '#description' => t('WARNING: turning on this feature will slow down search performance by a large factor. Gets worse as your messages database increases.'), |
128 | 128 | '#default_value' => variable_get('privatemsg_filter_searchbody', FALSE), |
129 | - ); |
|
129 | + ); |
|
130 | 130 | |
131 | 131 | $form['privatemsg_filter_tagfield_weight'] = array( |
132 | 132 | '#type' => 'textfield', |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | '#description' => t('Use higher values to push the form lower down the page, lower or negative values to raise it higher.'), |
135 | 135 | '#size' => 4, |
136 | 136 | '#default_value' => variable_get('privatemsg_filter_tagfield_weight', 10), |
137 | - ); |
|
137 | + ); |
|
138 | 138 | |
139 | - return system_settings_form($form); |
|
139 | + return system_settings_form($form); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -145,26 +145,26 @@ discard block |
||
145 | 145 | * Add a filter widget to the message listing pages. |
146 | 146 | */ |
147 | 147 | function privatemsg_filter_form_private_message_settings_alter(&$form, $form_state) { |
148 | - $form['privatemsg_listing']['privatemsg_filter_default_list'] = array( |
|
148 | + $form['privatemsg_listing']['privatemsg_filter_default_list'] = array( |
|
149 | 149 | '#type' => 'radios', |
150 | 150 | '#default_value' => variable_get('privatemsg_filter_default_list', 0), |
151 | 151 | '#options' => array(t('Inbox'), t('All messages')), |
152 | 152 | '#title' => t('Choose the default list option'), |
153 | 153 | '#description' => t('Choose which of the two lists are shown by default when following the messages link.'), |
154 | - ); |
|
155 | - // Add tags to the list of possible columns. |
|
156 | - $form['privatemsg_listing']['privatemsg_display_fields']['#options']['tags'] = t('Tags'); |
|
154 | + ); |
|
155 | + // Add tags to the list of possible columns. |
|
156 | + $form['privatemsg_listing']['privatemsg_display_fields']['#options']['tags'] = t('Tags'); |
|
157 | 157 | |
158 | - $form['#submit'][] = 'privatemsg_filter_settings_submit'; |
|
158 | + $form['#submit'][] = 'privatemsg_filter_settings_submit'; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
162 | 162 | * Rebuilding the menu if necessary. |
163 | 163 | */ |
164 | 164 | function privatemsg_filter_settings_submit($form, &$form_state) { |
165 | - if ($form['privatemsg_listing']['privatemsg_filter_default_list']['#default_value'] != $form_state['values']['privatemsg_filter_default_list']) { |
|
165 | + if ($form['privatemsg_listing']['privatemsg_filter_default_list']['#default_value'] != $form_state['values']['privatemsg_filter_default_list']) { |
|
166 | 166 | menu_rebuild(); |
167 | - } |
|
167 | + } |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -174,33 +174,33 @@ discard block |
||
174 | 174 | * A single tag or an array of tags. |
175 | 175 | */ |
176 | 176 | function privatemsg_filter_create_tags($tags) { |
177 | - if (!is_array($tags)) { |
|
177 | + if (!is_array($tags)) { |
|
178 | 178 | $tags = array($tags); |
179 | - } |
|
179 | + } |
|
180 | 180 | |
181 | - $tag_ids = array(); |
|
181 | + $tag_ids = array(); |
|
182 | 182 | |
183 | - foreach ($tags as $tag) { |
|
183 | + foreach ($tags as $tag) { |
|
184 | 184 | $tag = trim($tag); |
185 | 185 | if (empty($tag)) { |
186 | - // Do not save a blank tag. |
|
187 | - continue; |
|
186 | + // Do not save a blank tag. |
|
187 | + continue; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | // Check if the tag already exists and only create the tag if it does not. |
191 | 191 | $tag_id = db_result(db_query("SELECT tag_id FROM {pm_tags} WHERE tag = '%s'", $tag)); |
192 | 192 | if (empty($tag_id) && privatemsg_user_access('create private message tags')) { |
193 | - db_query("INSERT INTO {pm_tags} (tag) VALUES ('%s')", $tag); |
|
194 | - $tag_id = db_last_insert_id('pm_tags', 'tag_id'); |
|
193 | + db_query("INSERT INTO {pm_tags} (tag) VALUES ('%s')", $tag); |
|
194 | + $tag_id = db_last_insert_id('pm_tags', 'tag_id'); |
|
195 | 195 | } |
196 | 196 | elseif (empty($tag_id)) { |
197 | - // The user does not have permission to create new tags - disregard this tag and move onto the next. |
|
198 | - drupal_set_message(t('Tag %tag was ignored because you do not have permission to create new tags.', array('%tag' => $tag))); |
|
199 | - continue; |
|
197 | + // The user does not have permission to create new tags - disregard this tag and move onto the next. |
|
198 | + drupal_set_message(t('Tag %tag was ignored because you do not have permission to create new tags.', array('%tag' => $tag))); |
|
199 | + continue; |
|
200 | 200 | } |
201 | 201 | $tag_ids[] = $tag_id; |
202 | - } |
|
203 | - return $tag_ids; |
|
202 | + } |
|
203 | + return $tag_ids; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -212,21 +212,21 @@ discard block |
||
212 | 212 | * Id of the tag. |
213 | 213 | */ |
214 | 214 | function privatemsg_filter_add_tags($threads, $tag_id, $account = NULL) { |
215 | - if (!is_array($threads)) { |
|
215 | + if (!is_array($threads)) { |
|
216 | 216 | $threads = array($threads); |
217 | - } |
|
218 | - if (empty($account)) { |
|
217 | + } |
|
218 | + if (empty($account)) { |
|
219 | 219 | global $user; |
220 | 220 | $account = drupal_clone($user); |
221 | - } |
|
221 | + } |
|
222 | 222 | |
223 | - foreach ($threads as $thread) { |
|
223 | + foreach ($threads as $thread) { |
|
224 | 224 | // Make sure that we don't add a tag to a thread twice, |
225 | 225 | // only insert if there is no such tag yet. |
226 | 226 | if (db_result(db_query('SELECT COUNT(*) FROM {pm_tags_index} WHERE tag_id = %d AND (uid = %d AND thread_id = %d)', $tag_id, $account->uid, $thread)) == 0) { |
227 | - db_query('INSERT INTO {pm_tags_index} (tag_id, uid, thread_id) VALUES (%d, %d, %d)', $tag_id, $account->uid, $thread); |
|
227 | + db_query('INSERT INTO {pm_tags_index} (tag_id, uid, thread_id) VALUES (%d, %d, %d)', $tag_id, $account->uid, $thread); |
|
228 | + } |
|
228 | 229 | } |
229 | - } |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -238,238 +238,238 @@ discard block |
||
238 | 238 | * Id of the tag - set to NULL to remove all tags. |
239 | 239 | */ |
240 | 240 | function privatemsg_filter_remove_tags($threads, $tag_id = NULL, $account = NULL) { |
241 | - if (!is_array($threads)) { |
|
241 | + if (!is_array($threads)) { |
|
242 | 242 | $threads = array($threads); |
243 | - } |
|
244 | - if (empty($account)) { |
|
243 | + } |
|
244 | + if (empty($account)) { |
|
245 | 245 | global $user; |
246 | 246 | $account = drupal_clone($user); |
247 | - } |
|
247 | + } |
|
248 | 248 | |
249 | - if (is_null($tag_id)) { |
|
249 | + if (is_null($tag_id)) { |
|
250 | 250 | // Delete all tag mapping. |
251 | 251 | foreach ($threads as $thread) { |
252 | - db_query('DELETE FROM {pm_tags_index} WHERE uid = %d AND thread_id = %d', $account->uid, $thread); |
|
252 | + db_query('DELETE FROM {pm_tags_index} WHERE uid = %d AND thread_id = %d', $account->uid, $thread); |
|
253 | + } |
|
253 | 254 | } |
254 | - } |
|
255 | - else { |
|
255 | + else { |
|
256 | 256 | // Delete tag mapping for the specified tag. |
257 | 257 | foreach ($threads as $thread) { |
258 | - db_query('DELETE FROM {pm_tags_index} WHERE uid = %d AND thread_id = %d AND tag_id = %d', $account->uid, $thread, $tag_id); |
|
258 | + db_query('DELETE FROM {pm_tags_index} WHERE uid = %d AND thread_id = %d AND tag_id = %d', $account->uid, $thread, $tag_id); |
|
259 | + } |
|
259 | 260 | } |
260 | - } |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | function privatemsg_filter_get_filter($account) { |
264 | - $filter = array(); |
|
265 | - if (isset($_GET['tags'])) { |
|
264 | + $filter = array(); |
|
265 | + if (isset($_GET['tags'])) { |
|
266 | 266 | $_GET['tags'] = urldecode($_GET['tags']); |
267 | 267 | $tag_data = privatemsg_filter_get_tags_data($account); |
268 | 268 | foreach (explode(',', $_GET['tags']) as $tag) { |
269 | - if (isset($tag_data[$tag])) { |
|
269 | + if (isset($tag_data[$tag])) { |
|
270 | 270 | $filter['tags'][$tag] = $tag; |
271 | - } |
|
272 | - elseif (in_array($tag, $tag_data)) { |
|
271 | + } |
|
272 | + elseif (in_array($tag, $tag_data)) { |
|
273 | 273 | $filter['tags'][array_search($tag, $tag_data)] = array_search($tag, $tag_data); |
274 | - } |
|
274 | + } |
|
275 | + } |
|
275 | 276 | } |
276 | - } |
|
277 | 277 | |
278 | - if (isset($_GET['author'])) { |
|
278 | + if (isset($_GET['author'])) { |
|
279 | 279 | list($filter['author']) = _privatemsg_parse_userstring($_GET['author']); |
280 | - } |
|
280 | + } |
|
281 | 281 | |
282 | - if (isset($_GET['search'])) { |
|
282 | + if (isset($_GET['search'])) { |
|
283 | 283 | $filter['search'] = $_GET['search']; |
284 | - } |
|
284 | + } |
|
285 | 285 | |
286 | - if (!empty($filter)) { |
|
286 | + if (!empty($filter)) { |
|
287 | 287 | return $filter; |
288 | - } |
|
288 | + } |
|
289 | 289 | |
290 | - if (!empty($_SESSION['privatemsg_filter'])) { |
|
290 | + if (!empty($_SESSION['privatemsg_filter'])) { |
|
291 | 291 | return $_SESSION['privatemsg_filter']; |
292 | - } |
|
292 | + } |
|
293 | 293 | |
294 | 294 | } |
295 | 295 | |
296 | 296 | function privatemsg_filter_get_tags_data($account) { |
297 | - static $tag_data; |
|
297 | + static $tag_data; |
|
298 | 298 | |
299 | - if (is_array($tag_data)) { |
|
299 | + if (is_array($tag_data)) { |
|
300 | 300 | return $tag_data; |
301 | - } |
|
301 | + } |
|
302 | 302 | |
303 | - // Only show the tags that a user have used. |
|
304 | - $query = _privatemsg_assemble_query(array('tags', 'privatemsg_filter'), $account); |
|
305 | - $results = db_query($query['query']); |
|
303 | + // Only show the tags that a user have used. |
|
304 | + $query = _privatemsg_assemble_query(array('tags', 'privatemsg_filter'), $account); |
|
305 | + $results = db_query($query['query']); |
|
306 | 306 | |
307 | - $tag_data = array(); |
|
308 | - while ($result = db_fetch_object($results)) { |
|
307 | + $tag_data = array(); |
|
308 | + while ($result = db_fetch_object($results)) { |
|
309 | 309 | $tag_data[$result->tag_id] = $result->tag; |
310 | - } |
|
311 | - return $tag_data; |
|
310 | + } |
|
311 | + return $tag_data; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | function privatemsg_filter_dropdown(&$form_state, $account) { |
315 | 315 | |
316 | - drupal_add_css(drupal_get_path('module', 'privatemsg_filter') .'/privatemsg_filter.css'); |
|
316 | + drupal_add_css(drupal_get_path('module', 'privatemsg_filter') .'/privatemsg_filter.css'); |
|
317 | 317 | |
318 | - $form['filter'] = array( |
|
318 | + $form['filter'] = array( |
|
319 | 319 | '#type' => 'fieldset', |
320 | 320 | '#title' => t('Filter messages'), |
321 | 321 | '#collapsible' => TRUE, |
322 | 322 | '#collapsed' => TRUE, |
323 | - ); |
|
324 | - $form['filter']['search'] = array( |
|
323 | + ); |
|
324 | + $form['filter']['search'] = array( |
|
325 | 325 | '#type' => 'textfield', |
326 | 326 | '#title' => variable_get('privatemsg_filter_searchbody', FALSE) ? t('Search messages') : t('Search subjects'), |
327 | 327 | '#weight' => -20 |
328 | - ); |
|
328 | + ); |
|
329 | 329 | |
330 | - $form['filter']['author'] = array( |
|
330 | + $form['filter']['author'] = array( |
|
331 | 331 | '#type' => 'textfield', |
332 | 332 | '#title' => t('Participants'), |
333 | 333 | '#description' => t('Separate multiple names with commas.'), |
334 | 334 | '#weight' => -5, |
335 | 335 | '#size' => 50, |
336 | 336 | '#autocomplete_path' => 'messages/filter/user-name-autocomplete', |
337 | - ); |
|
337 | + ); |
|
338 | 338 | |
339 | - // Only show form if the user has some messages tagged. |
|
340 | - if (count($tag_data = privatemsg_filter_get_tags_data($account))) { |
|
339 | + // Only show form if the user has some messages tagged. |
|
340 | + if (count($tag_data = privatemsg_filter_get_tags_data($account))) { |
|
341 | 341 | $form['filter']['tags'] = array( |
342 | - '#type' => 'select', |
|
343 | - '#title' => t('Tags'), |
|
344 | - '#options' => $tag_data, |
|
345 | - '#multiple' => TRUE, |
|
346 | - '#size' => 5, |
|
347 | - '#weight' => 0 |
|
348 | - ); |
|
349 | - } |
|
342 | + '#type' => 'select', |
|
343 | + '#title' => t('Tags'), |
|
344 | + '#options' => $tag_data, |
|
345 | + '#multiple' => TRUE, |
|
346 | + '#size' => 5, |
|
347 | + '#weight' => 0 |
|
348 | + ); |
|
349 | + } |
|
350 | 350 | $form['filter']['submit'] = array( |
351 | - '#type' => 'submit', |
|
352 | - '#value' => t('Filter'), |
|
353 | - '#prefix' => '<div id="privatemsg-filter-buttons">', |
|
354 | - '#weight' => 10, |
|
355 | - '#submit' => array('privatemsg_filter_dropdown_submit'), |
|
351 | + '#type' => 'submit', |
|
352 | + '#value' => t('Filter'), |
|
353 | + '#prefix' => '<div id="privatemsg-filter-buttons">', |
|
354 | + '#weight' => 10, |
|
355 | + '#submit' => array('privatemsg_filter_dropdown_submit'), |
|
356 | 356 | ); |
357 | 357 | |
358 | 358 | $form['filter']['save'] = array( |
359 | - '#type' => 'submit', |
|
360 | - '#value' => t('Save filter'), |
|
361 | - '#suffix' => '</div>', |
|
362 | - '#weight' => 11, |
|
363 | - '#submit' => array('privatemsg_filter_dropdown_submit'), |
|
359 | + '#type' => 'submit', |
|
360 | + '#value' => t('Save filter'), |
|
361 | + '#suffix' => '</div>', |
|
362 | + '#weight' => 11, |
|
363 | + '#submit' => array('privatemsg_filter_dropdown_submit'), |
|
364 | 364 | ); |
365 | 365 | |
366 | 366 | if ($filter = privatemsg_filter_get_filter($account)) { |
367 | - privatemsg_filter_dropdown_set_active($form, $filter); |
|
367 | + privatemsg_filter_dropdown_set_active($form, $filter); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | return $form; |
371 | 371 | } |
372 | 372 | |
373 | 373 | function privatemsg_filter_dropdown_set_active(&$form, $filter) { |
374 | - $form['filter']['#title'] = t('Filter messages (active)'); |
|
375 | - $form['filter']['#collapsed'] = FALSE; |
|
374 | + $form['filter']['#title'] = t('Filter messages (active)'); |
|
375 | + $form['filter']['#collapsed'] = FALSE; |
|
376 | 376 | |
377 | - if (isset($filter['author'])) { |
|
377 | + if (isset($filter['author'])) { |
|
378 | 378 | $string = ''; |
379 | 379 | foreach ($filter['author'] as $author) { |
380 | - $string .= $author->name . ', '; |
|
380 | + $string .= $author->name . ', '; |
|
381 | 381 | } |
382 | 382 | $form['filter']['author']['#default_value'] = $string; |
383 | - } |
|
384 | - if (isset($filter['tags'])) { |
|
383 | + } |
|
384 | + if (isset($filter['tags'])) { |
|
385 | 385 | $form['filter']['tags']['#default_value'] = $filter['tags']; |
386 | - } |
|
387 | - if (isset($filter['search'])) { |
|
386 | + } |
|
387 | + if (isset($filter['search'])) { |
|
388 | 388 | $form['filter']['search']['#default_value'] = $filter['search']; |
389 | - } |
|
390 | - |
|
391 | - $form['filter']['reset'] = array( |
|
392 | - '#type' => 'submit', |
|
393 | - '#value' => t('Reset'), |
|
394 | - '#suffix' => '</div>', |
|
395 | - '#weight' => 12, |
|
396 | - '#submit' => array('privatemsg_filter_dropdown_submit'), |
|
397 | - ); |
|
398 | - unset($form['filter']['save']['#suffix']); |
|
389 | + } |
|
390 | + |
|
391 | + $form['filter']['reset'] = array( |
|
392 | + '#type' => 'submit', |
|
393 | + '#value' => t('Reset'), |
|
394 | + '#suffix' => '</div>', |
|
395 | + '#weight' => 12, |
|
396 | + '#submit' => array('privatemsg_filter_dropdown_submit'), |
|
397 | + ); |
|
398 | + unset($form['filter']['save']['#suffix']); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | function privatemsg_filter_dropdown_submit($form, &$form_state) { |
402 | 402 | |
403 | - if (!empty($form_state['values']['author'])) { |
|
403 | + if (!empty($form_state['values']['author'])) { |
|
404 | 404 | list($form_state['values']['author']) = _privatemsg_parse_userstring($form_state['values']['author']); |
405 | - } |
|
405 | + } |
|
406 | 406 | |
407 | - switch ($form_state['values']['op']) { |
|
407 | + switch ($form_state['values']['op']) { |
|
408 | 408 | case t('Save filter'): |
409 | 409 | $filter = array(); |
410 | - if (!empty($form_state['values']['tags'])) { |
|
410 | + if (!empty($form_state['values']['tags'])) { |
|
411 | 411 | $filter['tags'] = $form_state['values']['tags']; |
412 | - } |
|
413 | - if (!empty($form_state['values']['author'])) { |
|
412 | + } |
|
413 | + if (!empty($form_state['values']['author'])) { |
|
414 | 414 | $filter['author'] = $form_state['values']['author']; |
415 | - } |
|
416 | - if (!empty($form_state['values']['search'])) { |
|
415 | + } |
|
416 | + if (!empty($form_state['values']['search'])) { |
|
417 | 417 | $filter['search'] = $form_state['values']['search']; |
418 | - } |
|
419 | - $_SESSION['privatemsg_filter'] = $filter; |
|
420 | - break; |
|
418 | + } |
|
419 | + $_SESSION['privatemsg_filter'] = $filter; |
|
420 | + break; |
|
421 | 421 | case t('Filter'): |
422 | 422 | drupal_goto($_GET['q'], privatemsg_filter_create_get_query($form_state['values'])); |
423 | - return; |
|
424 | - break; |
|
423 | + return; |
|
424 | + break; |
|
425 | 425 | case t('Reset'): |
426 | 426 | $_SESSION['privatemsg_filter'] = array(); |
427 | - break; |
|
428 | - } |
|
429 | - $form_state['redirect'] = $_GET['q']; |
|
427 | + break; |
|
428 | + } |
|
429 | + $form_state['redirect'] = $_GET['q']; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | function privatemsg_filter_create_get_query($filter) { |
433 | - $query = array(); |
|
434 | - if (isset($filter['tags']) && !empty($filter['tags'])) { |
|
433 | + $query = array(); |
|
434 | + if (isset($filter['tags']) && !empty($filter['tags'])) { |
|
435 | 435 | $ids = array(); |
436 | 436 | foreach ($filter['tags'] as $tag) { |
437 | - if ((int)$tag > 0) { |
|
437 | + if ((int)$tag > 0) { |
|
438 | 438 | $ids[] = $tag; |
439 | - } |
|
440 | - else { |
|
439 | + } |
|
440 | + else { |
|
441 | 441 | $query['tags'][] = $tag; |
442 | - } |
|
442 | + } |
|
443 | 443 | } |
444 | 444 | $sql = 'SELECT pmt.tag FROM {pm_tags} pmt WHERE pmt.tag_id IN ('. implode(', ', $filter['tags']) .')'; |
445 | 445 | $result = db_query($sql); |
446 | 446 | while ($row = db_fetch_object($result)) { |
447 | - $query['tags'][] = $row->tag; |
|
447 | + $query['tags'][] = $row->tag; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | if (isset($query['tags'])) { |
451 | - $query['tags'] = implode(',', $query['tags']); |
|
451 | + $query['tags'] = implode(',', $query['tags']); |
|
452 | + } |
|
452 | 453 | } |
453 | - } |
|
454 | 454 | |
455 | - if (isset($filter['author']) && !empty($filter['author'])) { |
|
455 | + if (isset($filter['author']) && !empty($filter['author'])) { |
|
456 | 456 | foreach ($filter['author'] as $author) { |
457 | - if (is_object($author) && isset($author->uid) && isset($author->name)) { |
|
457 | + if (is_object($author) && isset($author->uid) && isset($author->name)) { |
|
458 | 458 | $query['author'][] = $author->name; |
459 | - } |
|
460 | - elseif ($author_obj = user_load($author)) { |
|
459 | + } |
|
460 | + elseif ($author_obj = user_load($author)) { |
|
461 | 461 | $query['author'][] = $author_obj->name; |
462 | - } |
|
462 | + } |
|
463 | 463 | } |
464 | 464 | if (isset($query['author'])) { |
465 | - $query['author'] = implode(',', $query['author']); |
|
465 | + $query['author'] = implode(',', $query['author']); |
|
466 | + } |
|
466 | 467 | } |
467 | - } |
|
468 | 468 | |
469 | - if (isset($filter['search']) && !empty($filter['search'])) { |
|
469 | + if (isset($filter['search']) && !empty($filter['search'])) { |
|
470 | 470 | $query['search'] = $filter['search']; |
471 | - } |
|
472 | - return $query; |
|
471 | + } |
|
472 | + return $query; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -478,14 +478,14 @@ discard block |
||
478 | 478 | * Adds a filter widget to the message listing pages. |
479 | 479 | */ |
480 | 480 | function privatemsg_filter_form_privatemsg_list_alter(&$form, $form_state) { |
481 | - global $user; |
|
481 | + global $user; |
|
482 | 482 | |
483 | - if (privatemsg_user_access('filter private messages') && !empty($form['#data'])) { |
|
483 | + if (privatemsg_user_access('filter private messages') && !empty($form['#data'])) { |
|
484 | 484 | $form += privatemsg_filter_dropdown($form_state, $form['#account']); |
485 | - } |
|
485 | + } |
|
486 | 486 | |
487 | - $fields = array_filter(variable_get('privatemsg_display_fields', array('participants'))); |
|
488 | - if (in_array('tags', $fields)) { |
|
487 | + $fields = array_filter(variable_get('privatemsg_display_fields', array('participants'))); |
|
488 | + if (in_array('tags', $fields)) { |
|
489 | 489 | // Load thread id's of the current list. |
490 | 490 | $threads = array_keys($form['#data']); |
491 | 491 | |
@@ -495,21 +495,21 @@ discard block |
||
495 | 495 | // Add them to #data |
496 | 496 | $result = db_query($query['query']); |
497 | 497 | while ($tag = db_fetch_array($result)) { |
498 | - $form['#data'][$tag['thread_id']]['tags'][$tag['tag_id']] = $tag['tag']; |
|
498 | + $form['#data'][$tag['thread_id']]['tags'][$tag['tag_id']] = $tag['tag']; |
|
499 | + } |
|
499 | 500 | } |
500 | - } |
|
501 | 501 | |
502 | - $tags = privatemsg_filter_get_tags_data($user); |
|
503 | - if (privatemsg_user_access('tag private messages') && !empty($tags) && !empty($form['#data'])) { |
|
502 | + $tags = privatemsg_filter_get_tags_data($user); |
|
503 | + if (privatemsg_user_access('tag private messages') && !empty($tags) && !empty($form['#data'])) { |
|
504 | 504 | $options = array(); |
505 | 505 | $options[] = t('Apply tag...'); |
506 | 506 | foreach ($tags as $tag_id => $tag) { |
507 | - $options[$tag_id] = $tag; |
|
507 | + $options[$tag_id] = $tag; |
|
508 | 508 | } |
509 | 509 | $form['actions']['tag-add'] = array( |
510 | - '#type' => 'select', |
|
511 | - '#options' => $options, |
|
512 | - '#default_value' => 0, |
|
510 | + '#type' => 'select', |
|
511 | + '#options' => $options, |
|
512 | + '#default_value' => 0, |
|
513 | 513 | ); |
514 | 514 | $form['actions']['tag-add-submit'] = array( |
515 | 515 | '#prefix' => '<div class="privatemsg-tag-add-submit">', |
@@ -521,9 +521,9 @@ discard block |
||
521 | 521 | ); |
522 | 522 | $options[0] = t('Remove Tag...'); |
523 | 523 | $form['actions']['tag-remove'] = array( |
524 | - '#type' => 'select', |
|
525 | - '#options' => $options, |
|
526 | - '#default_value' => 0, |
|
524 | + '#type' => 'select', |
|
525 | + '#options' => $options, |
|
526 | + '#default_value' => 0, |
|
527 | 527 | ); |
528 | 528 | $form['actions']['tag-remove-submit'] = array( |
529 | 529 | '#prefix' => '<div class="privatemsg-tag-remove-submit">', |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | |
537 | 537 | // JS for hiding the submit buttons. |
538 | 538 | drupal_add_js(drupal_get_path('module', 'privatemsg_filter') .'/privatemsg-filter-list.js'); |
539 | - } |
|
539 | + } |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
@@ -545,12 +545,12 @@ discard block |
||
545 | 545 | * @see theme_privatemsg_list_header() |
546 | 546 | */ |
547 | 547 | function phptemplate_privatemsg_list_header__tags() { |
548 | - return array( |
|
548 | + return array( |
|
549 | 549 | 'data' => t('Tags'), |
550 | 550 | 'key' => 'tags', |
551 | 551 | 'class' => 'privatemsg-header-tags', |
552 | 552 | '#weight' => -42, |
553 | - ); |
|
553 | + ); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | |
@@ -560,48 +560,48 @@ discard block |
||
560 | 560 | * @see theme_privatemsg_list_field() |
561 | 561 | */ |
562 | 562 | function phptemplate_privatemsg_list_field__tags($thread) { |
563 | - if (!empty($thread['tags'])) { |
|
563 | + if (!empty($thread['tags'])) { |
|
564 | 564 | $tags = array(); |
565 | 565 | |
566 | 566 | foreach ($thread['tags'] as $tag_id => $tag) { |
567 | - $tags[] = l(strlen($tag) > 15 ? substr($tag, 0, 13) . '...' : $tag, 'messages', array( |
|
567 | + $tags[] = l(strlen($tag) > 15 ? substr($tag, 0, 13) . '...' : $tag, 'messages', array( |
|
568 | 568 | 'attributes' => array('title' => $tag), |
569 | 569 | 'query' => array('tags' => $tag) |
570 | - )); |
|
570 | + )); |
|
571 | 571 | } |
572 | 572 | return array( |
573 | - 'data' => implode(', ', $tags), |
|
574 | - 'class' => 'privatemsg-list-tags', |
|
573 | + 'data' => implode(', ', $tags), |
|
574 | + 'class' => 'privatemsg-list-tags', |
|
575 | 575 | ); |
576 | - } |
|
576 | + } |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | /** |
580 | 580 | * Form callback for adding a tag to threads. |
581 | 581 | */ |
582 | 582 | function privatemsg_filter_add_tag_submit($form, &$form_state) { |
583 | - $operation = array( |
|
583 | + $operation = array( |
|
584 | 584 | 'callback' => 'privatemsg_filter_add_tags', |
585 | 585 | 'callback arguments' => array('tag_id' => $form_state['values']['tag-add']), |
586 | 586 | 'undo callback' => 'privatemsg_filter_remove_tags', |
587 | 587 | 'undo callback arguments' => array('tag_id' => $form_state['values']['tag-add']), |
588 | - ); |
|
589 | - drupal_set_message(t('The selected conversations have been tagged.')); |
|
590 | - privatemsg_operation_execute($operation, $form_state['values']['threads']); |
|
588 | + ); |
|
589 | + drupal_set_message(t('The selected conversations have been tagged.')); |
|
590 | + privatemsg_operation_execute($operation, $form_state['values']['threads']); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
594 | 594 | * Form callback for removing a tag to threads. |
595 | 595 | */ |
596 | 596 | function privatemsg_filter_remove_tag_submit($form, &$form_state) { |
597 | - $operation = array( |
|
597 | + $operation = array( |
|
598 | 598 | 'callback' => 'privatemsg_filter_remove_tags', |
599 | 599 | 'callback arguments' => array('tag_id' => $form_state['values']['tag-remove']), |
600 | 600 | 'undo callback' => 'privatemsg_filter_add_tags', |
601 | 601 | 'undo callback arguments' => array('tag_id' => $form_state['values']['tag-remove']), |
602 | - ); |
|
603 | - drupal_set_message(t('The tag has been removed from the selected conversations.')); |
|
604 | - privatemsg_operation_execute($operation, $form_state['values']['threads']); |
|
602 | + ); |
|
603 | + drupal_set_message(t('The tag has been removed from the selected conversations.')); |
|
604 | + privatemsg_operation_execute($operation, $form_state['values']['threads']); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -609,114 +609,114 @@ discard block |
||
609 | 609 | */ |
610 | 610 | function privatemsg_filter_privatemsg_sql_list_alter(&$fragments, $account, $argument) { |
611 | 611 | |
612 | - // Check if its a filtered view. |
|
613 | - if ($argument == 'sent') { |
|
612 | + // Check if its a filtered view. |
|
613 | + if ($argument == 'sent') { |
|
614 | 614 | $fragments['where'][] = "pm.author = %d"; |
615 | 615 | $fragments['query_args']['where'][] = $account->uid; |
616 | - } |
|
617 | - if ($argument == 'inbox') { |
|
616 | + } |
|
617 | + if ($argument == 'inbox') { |
|
618 | 618 | $fragments['having'][] = '((SELECT pmf.author FROM {pm_message} pmf WHERE pmf.mid = pmi.thread_id) = %d AND COUNT(pmi.thread_id) > 1) OR (SELECT COUNT(*) FROM {pm_message} pmf INNER JOIN {pm_index} pmif ON (pmf.mid = pmif.mid) WHERE pmif.thread_id = pmi.thread_id AND pmf.author <> %d) > 0'; |
619 | 619 | $fragments['query_args']['having'][] = $account->uid; |
620 | 620 | $fragments['query_args']['having'][] = $account->uid; |
621 | - } |
|
621 | + } |
|
622 | 622 | |
623 | - // Filter the message listing by any set tags. |
|
624 | - if ($filter = privatemsg_filter_get_filter($account)) { |
|
623 | + // Filter the message listing by any set tags. |
|
624 | + if ($filter = privatemsg_filter_get_filter($account)) { |
|
625 | 625 | $count = 0; |
626 | 626 | if (isset($filter['tags']) && !empty($filter['tags'])) { |
627 | - foreach ($filter['tags'] as $tag) { |
|
627 | + foreach ($filter['tags'] as $tag) { |
|
628 | 628 | $fragments['inner_join'][] = "INNER JOIN {pm_tags_index} pmti$count ON (pmti$count.thread_id = pmi.thread_id AND pmti$count.uid = pmi.uid)"; |
629 | 629 | $fragments['where'][] = "pmti$count.tag_id = %d"; |
630 | 630 | $fragments['query_args']['where'][] = $tag; |
631 | 631 | $count++; |
632 | - } |
|
632 | + } |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | if (isset($filter['author']) && !empty($filter['author'])) { |
636 | - foreach ($filter['author'] as $author) { |
|
636 | + foreach ($filter['author'] as $author) { |
|
637 | 637 | $fragments['inner_join'][] = "INNER JOIN {pm_index} pmi$count ON (pmi$count.mid = pm.mid)"; |
638 | 638 | $fragments['where'][] = "pmi$count.uid = %d"; |
639 | 639 | $fragments['query_args']['where'][] = $author->uid; |
640 | 640 | $count++; |
641 | - } |
|
641 | + } |
|
642 | 642 | } |
643 | 643 | |
644 | 644 | if (isset($filter['search']) && !empty($filter['search'])) { |
645 | - if (variable_get('privatemsg_filter_searchbody', FALSE)) { |
|
645 | + if (variable_get('privatemsg_filter_searchbody', FALSE)) { |
|
646 | 646 | $fragments['where'][] = "pm.subject LIKE '%s' OR pm.body LIKE '%s'"; |
647 | 647 | $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
648 | 648 | $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
649 | - } |
|
650 | - else { |
|
649 | + } |
|
650 | + else { |
|
651 | 651 | $fragments['where'][] = "pm.subject LIKE '%s'"; |
652 | 652 | $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
653 | - } |
|
653 | + } |
|
654 | + } |
|
654 | 655 | } |
655 | - } |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | /** |
659 | 659 | * Hook into the view messages page to add a form for tagging purposes. |
660 | 660 | */ |
661 | 661 | function privatemsg_filter_privatemsg_view_messages_alter(&$content, $thread) { |
662 | - if (count($thread['messages']) > 0) { |
|
662 | + if (count($thread['messages']) > 0) { |
|
663 | 663 | $content['tags']['#value'] = drupal_get_form('privatemsg_filter_form'); |
664 | 664 | $content['tags']['#weight'] = variable_get('privatemsg_filter_tagfield_weight', 10); |
665 | - } |
|
665 | + } |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
669 | 669 | * Form to show and allow modification of tagging information of a conversation. |
670 | 670 | */ |
671 | 671 | function privatemsg_filter_form(&$form_state) { |
672 | - global $user; |
|
673 | - $thread_id = arg(2); |
|
674 | - |
|
675 | - // Get a list of current tags for this thread |
|
676 | - $query = _privatemsg_assemble_query(array('tags', 'privatemsg_filter'), $user, array($thread_id)); |
|
677 | - $results = db_query($query['query']); |
|
678 | - $count = db_result(db_query($query['count'])); |
|
679 | - $tags = ''; |
|
680 | - while ($tag = db_fetch_array($results)) { |
|
672 | + global $user; |
|
673 | + $thread_id = arg(2); |
|
674 | + |
|
675 | + // Get a list of current tags for this thread |
|
676 | + $query = _privatemsg_assemble_query(array('tags', 'privatemsg_filter'), $user, array($thread_id)); |
|
677 | + $results = db_query($query['query']); |
|
678 | + $count = db_result(db_query($query['count'])); |
|
679 | + $tags = ''; |
|
680 | + while ($tag = db_fetch_array($results)) { |
|
681 | 681 | $tags .= $tag['tag'] . ', '; |
682 | - } |
|
682 | + } |
|
683 | 683 | |
684 | - $form['tags'] = array( |
|
684 | + $form['tags'] = array( |
|
685 | 685 | '#type' => 'fieldset', |
686 | 686 | '#title' => t('Tags'), |
687 | 687 | '#access' => privatemsg_user_access('tag private messages'), |
688 | 688 | '#collapsible' => TRUE, |
689 | 689 | '#collapsed' => empty($count) ? TRUE : FALSE, |
690 | - ); |
|
691 | - $form['tags']['user_id'] = array( |
|
690 | + ); |
|
691 | + $form['tags']['user_id'] = array( |
|
692 | 692 | '#type' => 'value', |
693 | 693 | '#value' => $user->uid, |
694 | - ); |
|
695 | - $form['tags']['thread_id'] = array( |
|
694 | + ); |
|
695 | + $form['tags']['thread_id'] = array( |
|
696 | 696 | '#type' => 'value', |
697 | 697 | '#value' => $thread_id, |
698 | - ); |
|
698 | + ); |
|
699 | 699 | |
700 | - $form['tags']['tags'] = array( |
|
700 | + $form['tags']['tags'] = array( |
|
701 | 701 | '#type' => 'textfield', |
702 | 702 | '#title' => t('Tags for this conversation'), |
703 | 703 | '#description' => t('Separate multiple tags with commas.'), |
704 | 704 | '#size' => 50, |
705 | 705 | '#default_value' => $tags, |
706 | 706 | '#autocomplete_path' => 'messages/filter/tag-autocomplete', |
707 | - ); |
|
707 | + ); |
|
708 | 708 | |
709 | - $form['tags']['submit'] = array( |
|
709 | + $form['tags']['submit'] = array( |
|
710 | 710 | '#type' => 'submit', |
711 | 711 | '#value' => t('Tag this conversation'), |
712 | 712 | '#submit' => array('privatemsg_filter_form_submit'), |
713 | - ); |
|
713 | + ); |
|
714 | 714 | |
715 | - return $form; |
|
715 | + return $form; |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | function privatemsg_filter_form_submit($form, &$form_state) { |
719 | - if (isset($form_state['values']['submit'])) { |
|
719 | + if (isset($form_state['values']['submit'])) { |
|
720 | 720 | $tags = explode(',', $form_state['values']['tags']); |
721 | 721 | |
722 | 722 | // Step 1 - Delete all tag mapping. I cannot think of a better way to remove tags that are no longer in the textfield, so ideas welcome. |
@@ -727,10 +727,10 @@ discard block |
||
727 | 727 | |
728 | 728 | // Step 3 - Save all the tagging data. |
729 | 729 | foreach ($tag_ids as $tag_id) { |
730 | - privatemsg_filter_add_tags($form_state['values']['thread_id'], $tag_id); |
|
730 | + privatemsg_filter_add_tags($form_state['values']['thread_id'], $tag_id); |
|
731 | 731 | } |
732 | 732 | drupal_set_message(t('Tagging information has been saved.')); |
733 | - } |
|
733 | + } |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | /** |
@@ -741,28 +741,28 @@ discard block |
||
741 | 741 | */ |
742 | 742 | function privatemsg_filter_tags_autocomplete($string) { |
743 | 743 | |
744 | - // 1: Parse $string and build a list of tags. |
|
745 | - $tags = array(); |
|
746 | - $fragments = explode(',', $string); |
|
747 | - foreach ($fragments as $index => $tag) { |
|
744 | + // 1: Parse $string and build a list of tags. |
|
745 | + $tags = array(); |
|
746 | + $fragments = explode(',', $string); |
|
747 | + foreach ($fragments as $index => $tag) { |
|
748 | 748 | $tag = trim($tag); |
749 | 749 | $tags[$tag] = $tag; |
750 | - } |
|
750 | + } |
|
751 | 751 | |
752 | - // 2: Find the next tag suggestion. |
|
753 | - $fragment = array_pop($tags); |
|
754 | - $matches = array(); |
|
755 | - if (!empty($fragment)) { |
|
752 | + // 2: Find the next tag suggestion. |
|
753 | + $fragment = array_pop($tags); |
|
754 | + $matches = array(); |
|
755 | + if (!empty($fragment)) { |
|
756 | 756 | $query = _privatemsg_assemble_query(array('tags_autocomplete', 'privatemsg_filter'), $fragment, $tags); |
757 | 757 | $result = db_query_range($query['query'], $fragment, 0, 10); |
758 | 758 | $prefix = count($tags) ? implode(", ", $tags) .", " : ''; |
759 | 759 | // 3: Build proper suggestions and print. |
760 | 760 | while ($tag = db_fetch_object($result)) { |
761 | - $matches[$prefix . $tag->tag .", "] = $tag->tag; |
|
761 | + $matches[$prefix . $tag->tag .", "] = $tag->tag; |
|
762 | 762 | } |
763 | - } |
|
764 | - // convert to object to prevent drupal bug, see http://drupal.org/node/175361 |
|
765 | - drupal_json((object)$matches); |
|
763 | + } |
|
764 | + // convert to object to prevent drupal bug, see http://drupal.org/node/175361 |
|
765 | + drupal_json((object)$matches); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | /** |
@@ -781,19 +781,19 @@ discard block |
||
781 | 781 | * Array of names that are already part of the autocomplete field. |
782 | 782 | */ |
783 | 783 | function privatemsg_filter_privatemsg_sql_autocomplete_alter(&$fragments, $search, $names) { |
784 | - global $user; |
|
785 | - // arg(1) is an additional URL argument passed to the URL when only |
|
786 | - // users that are listed as recipient for threads of that user should be |
|
787 | - // displayed. |
|
788 | - // @todo: Check if these results can be grouped to avoid unecessary loops. |
|
789 | - if (arg(1) == 'filter') { |
|
784 | + global $user; |
|
785 | + // arg(1) is an additional URL argument passed to the URL when only |
|
786 | + // users that are listed as recipient for threads of that user should be |
|
787 | + // displayed. |
|
788 | + // @todo: Check if these results can be grouped to avoid unecessary loops. |
|
789 | + if (arg(1) == 'filter') { |
|
790 | 790 | // JOIN on index entries where the to be selected user is a recipient. |
791 | 791 | $fragments['inner_join'][] = 'INNER JOIN {pm_index} pip ON pip.uid = u.uid'; |
792 | 792 | // JOIN on rows where the current user is the recipient and that have the |
793 | 793 | // same mid as those above. |
794 | 794 | $fragments['inner_join'][] = 'INNER JOIN {pm_index} piu ON piu.uid = %d AND pip.mid = piu.mid'; |
795 | 795 | $fragments['query_args']['join'][] = $user->uid; |
796 | - } |
|
796 | + } |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | /** |
@@ -809,19 +809,19 @@ discard block |
||
809 | 809 | * Limit the number of tags *per thread*. |
810 | 810 | */ |
811 | 811 | function privatemsg_filter_sql_tags(&$fragments, $user = NULL, $threads = NULL, $limit = NULL) { |
812 | - $fragments['primary_table'] = '{pm_tags} t'; |
|
813 | - $fragments['select'][] = 't.tag'; |
|
814 | - $fragments['select'][] = 't.tag_id'; |
|
815 | - $fragments['select'][] = 't.public'; |
|
812 | + $fragments['primary_table'] = '{pm_tags} t'; |
|
813 | + $fragments['select'][] = 't.tag'; |
|
814 | + $fragments['select'][] = 't.tag_id'; |
|
815 | + $fragments['select'][] = 't.public'; |
|
816 | 816 | |
817 | - if (!empty($threads)) { |
|
817 | + if (!empty($threads)) { |
|
818 | 818 | // If the tag list needs to be for specific threads. |
819 | 819 | $fragments['select'][] = 'ti.thread_id'; |
820 | 820 | $fragments['inner_join'][] = 'INNER JOIN {pm_tags_index} ti on ti.tag_id = t.tag_id'; |
821 | 821 | $fragments['where'][] = 'ti.thread_id IN (' . db_placeholders($threads) . ')'; |
822 | 822 | $fragments['query_args']['where'] += $threads; |
823 | - } |
|
824 | - else { |
|
823 | + } |
|
824 | + else { |
|
825 | 825 | // Tag usage counter is only used when we select all tags. |
826 | 826 | $fragments['select'][] = 'COUNT(ti.thread_id) as count'; |
827 | 827 | // LEFT JOIN so that unused tags are displayed too. |
@@ -829,33 +829,33 @@ discard block |
||
829 | 829 | $fragments['group_by'][] = 't.tag_id'; |
830 | 830 | $fragments['group_by'][] = 't.tag'; |
831 | 831 | $fragments['group_by'][] = 't.public'; |
832 | - } |
|
833 | - if (!empty($user)) { |
|
832 | + } |
|
833 | + if (!empty($user)) { |
|
834 | 834 | $fragments['where'][] = 'ti.uid = %d'; |
835 | 835 | $fragments['query_args']['where'][] = $user->uid; |
836 | - } |
|
837 | - |
|
838 | - // Only select n tags per thread (ordered per tag_id), see |
|
839 | - // http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/. |
|
840 | - // |
|
841 | - // It does select how many tags for that thread/uid combination exist that |
|
842 | - // have a lower tag_id and does only select those that have less than $limit. |
|
843 | - // |
|
844 | - // This should only have a very minor performance impact as most users won't |
|
845 | - // tag a thread with 1000 different tags. |
|
846 | - // |
|
847 | - if ($limit) { |
|
836 | + } |
|
837 | + |
|
838 | + // Only select n tags per thread (ordered per tag_id), see |
|
839 | + // http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/. |
|
840 | + // |
|
841 | + // It does select how many tags for that thread/uid combination exist that |
|
842 | + // have a lower tag_id and does only select those that have less than $limit. |
|
843 | + // |
|
844 | + // This should only have a very minor performance impact as most users won't |
|
845 | + // tag a thread with 1000 different tags. |
|
846 | + // |
|
847 | + if ($limit) { |
|
848 | 848 | $fragments['where'][] = '(SELECT count(*) FROM {pm_tags_index} AS pmtic |
849 | 849 | WHERE pmtic.thread_id = ti.thread_id |
850 | 850 | AND pmtic.uid = ti.uid |
851 | 851 | AND pmtic.tag_id < ti.tag_id) < %d'; |
852 | 852 | $fragments['query_args']['where'][] = $limit; |
853 | - } |
|
854 | - elseif (!empty($threads) || !empty($user)) { |
|
853 | + } |
|
854 | + elseif (!empty($threads) || !empty($user)) { |
|
855 | 855 | // Only add a sort when we are not loading the tags for the admin page. |
856 | 856 | // Sorting is handled through tablesort_sql() then. |
857 | 857 | $fragments['order_by'][] = 't.tag ASC'; |
858 | - } |
|
858 | + } |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | /** |
@@ -869,25 +869,25 @@ discard block |
||
869 | 869 | * Array of tags not to be used as suggestions. |
870 | 870 | */ |
871 | 871 | function privatemsg_filter_sql_tags_autocomplete(&$fragments, $search, $tags) { |
872 | - global $user; |
|
873 | - |
|
874 | - $fragments['primary_table'] = '{pm_tags} pmt'; |
|
875 | - $fragments['select'][] = 'pmt.tag'; |
|
876 | - $fragments['where'][] = "pmt.tag LIKE '%s'"; |
|
877 | - // Escape % to get through the placeholder replacement. |
|
878 | - $fragments['query_args']['where'][] = $search .'%%'; |
|
879 | - if (!empty($tags)) { |
|
872 | + global $user; |
|
873 | + |
|
874 | + $fragments['primary_table'] = '{pm_tags} pmt'; |
|
875 | + $fragments['select'][] = 'pmt.tag'; |
|
876 | + $fragments['where'][] = "pmt.tag LIKE '%s'"; |
|
877 | + // Escape % to get through the placeholder replacement. |
|
878 | + $fragments['query_args']['where'][] = $search .'%%'; |
|
879 | + if (!empty($tags)) { |
|
880 | 880 | // Exclude tags. |
881 | 881 | $fragments['where'][] = "pmt.tag NOT IN (". db_placeholders($tags, 'text') .")"; |
882 | 882 | $fragments['query_args']['where'] += $tags; |
883 | - } |
|
884 | - // LEFT JOIN to be able to load public, unused tags. |
|
885 | - $fragments['inner_join'][] = 'LEFT JOIN {pm_tags_index} pmti ON pmt.tag_id = pmti.tag_id AND pmti.uid = %d'; |
|
886 | - $fragments['query_args']['join'][] = $user->uid; |
|
887 | - // Autocomplete should only display Tags used by that user or public tags. |
|
888 | - // This is done to avoid information disclosure as part of tag names. |
|
889 | - $fragments['where'][] = '(pmti.uid IS NOT NULL OR pmt.public = 1)'; |
|
890 | - $fragments['order_by'][] = 'pmt.tag ASC'; |
|
883 | + } |
|
884 | + // LEFT JOIN to be able to load public, unused tags. |
|
885 | + $fragments['inner_join'][] = 'LEFT JOIN {pm_tags_index} pmti ON pmt.tag_id = pmti.tag_id AND pmti.uid = %d'; |
|
886 | + $fragments['query_args']['join'][] = $user->uid; |
|
887 | + // Autocomplete should only display Tags used by that user or public tags. |
|
888 | + // This is done to avoid information disclosure as part of tag names. |
|
889 | + $fragments['where'][] = '(pmti.uid IS NOT NULL OR pmt.public = 1)'; |
|
890 | + $fragments['order_by'][] = 'pmt.tag ASC'; |
|
891 | 891 | } |
892 | 892 | |
893 | 893 | /** |
@@ -898,10 +898,10 @@ discard block |
||
898 | 898 | * Implement hook_user(). |
899 | 899 | */ |
900 | 900 | function privatemsg_filter_user($op, &$edit, &$account, $category = NULL) { |
901 | - switch ($op) { |
|
902 | - case 'delete': |
|
901 | + switch ($op) { |
|
902 | + case 'delete': |
|
903 | 903 | // Delete tag information of that user. |
904 | 904 | db_query("DELETE FROM {pm_tags_index} WHERE uid = %d", $account->uid, $account->uid); |
905 | - break; |
|
906 | - } |
|
905 | + break; |
|
906 | + } |
|
907 | 907 | } |
@@ -405,26 +405,26 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | switch ($form_state['values']['op']) { |
408 | - case t('Save filter'): |
|
409 | - $filter = array(); |
|
410 | - if (!empty($form_state['values']['tags'])) { |
|
411 | - $filter['tags'] = $form_state['values']['tags']; |
|
412 | - } |
|
413 | - if (!empty($form_state['values']['author'])) { |
|
414 | - $filter['author'] = $form_state['values']['author']; |
|
415 | - } |
|
416 | - if (!empty($form_state['values']['search'])) { |
|
417 | - $filter['search'] = $form_state['values']['search']; |
|
418 | - } |
|
419 | - $_SESSION['privatemsg_filter'] = $filter; |
|
420 | - break; |
|
421 | - case t('Filter'): |
|
422 | - drupal_goto($_GET['q'], privatemsg_filter_create_get_query($form_state['values'])); |
|
423 | - return; |
|
424 | - break; |
|
425 | - case t('Reset'): |
|
426 | - $_SESSION['privatemsg_filter'] = array(); |
|
427 | - break; |
|
408 | + case t('Save filter'): |
|
409 | + $filter = array(); |
|
410 | + if (!empty($form_state['values']['tags'])) { |
|
411 | + $filter['tags'] = $form_state['values']['tags']; |
|
412 | + } |
|
413 | + if (!empty($form_state['values']['author'])) { |
|
414 | + $filter['author'] = $form_state['values']['author']; |
|
415 | + } |
|
416 | + if (!empty($form_state['values']['search'])) { |
|
417 | + $filter['search'] = $form_state['values']['search']; |
|
418 | + } |
|
419 | + $_SESSION['privatemsg_filter'] = $filter; |
|
420 | + break; |
|
421 | + case t('Filter'): |
|
422 | + drupal_goto($_GET['q'], privatemsg_filter_create_get_query($form_state['values'])); |
|
423 | + return; |
|
424 | + break; |
|
425 | + case t('Reset'): |
|
426 | + $_SESSION['privatemsg_filter'] = array(); |
|
427 | + break; |
|
428 | 428 | } |
429 | 429 | $form_state['redirect'] = $_GET['q']; |
430 | 430 | } |
@@ -899,9 +899,9 @@ discard block |
||
899 | 899 | */ |
900 | 900 | function privatemsg_filter_user($op, &$edit, &$account, $category = NULL) { |
901 | 901 | switch ($op) { |
902 | - case 'delete': |
|
903 | - // Delete tag information of that user. |
|
904 | - db_query("DELETE FROM {pm_tags_index} WHERE uid = %d", $account->uid, $account->uid); |
|
905 | - break; |
|
902 | + case 'delete': |
|
903 | + // Delete tag information of that user. |
|
904 | + db_query("DELETE FROM {pm_tags_index} WHERE uid = %d", $account->uid, $account->uid); |
|
905 | + break; |
|
906 | 906 | } |
907 | 907 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | |
314 | 314 | function privatemsg_filter_dropdown(&$form_state, $account) { |
315 | 315 | |
316 | - drupal_add_css(drupal_get_path('module', 'privatemsg_filter') .'/privatemsg_filter.css'); |
|
316 | + drupal_add_css(drupal_get_path('module', 'privatemsg_filter').'/privatemsg_filter.css'); |
|
317 | 317 | |
318 | 318 | $form['filter'] = array( |
319 | 319 | '#type' => 'fieldset', |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | if (isset($filter['author'])) { |
378 | 378 | $string = ''; |
379 | 379 | foreach ($filter['author'] as $author) { |
380 | - $string .= $author->name . ', '; |
|
380 | + $string .= $author->name.', '; |
|
381 | 381 | } |
382 | 382 | $form['filter']['author']['#default_value'] = $string; |
383 | 383 | } |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | $query['tags'][] = $tag; |
442 | 442 | } |
443 | 443 | } |
444 | - $sql = 'SELECT pmt.tag FROM {pm_tags} pmt WHERE pmt.tag_id IN ('. implode(', ', $filter['tags']) .')'; |
|
444 | + $sql = 'SELECT pmt.tag FROM {pm_tags} pmt WHERE pmt.tag_id IN ('.implode(', ', $filter['tags']).')'; |
|
445 | 445 | $result = db_query($sql); |
446 | 446 | while ($row = db_fetch_object($result)) { |
447 | 447 | $query['tags'][] = $row->tag; |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | ); |
536 | 536 | |
537 | 537 | // JS for hiding the submit buttons. |
538 | - drupal_add_js(drupal_get_path('module', 'privatemsg_filter') .'/privatemsg-filter-list.js'); |
|
538 | + drupal_add_js(drupal_get_path('module', 'privatemsg_filter').'/privatemsg-filter-list.js'); |
|
539 | 539 | } |
540 | 540 | } |
541 | 541 | |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | $tags = array(); |
565 | 565 | |
566 | 566 | foreach ($thread['tags'] as $tag_id => $tag) { |
567 | - $tags[] = l(strlen($tag) > 15 ? substr($tag, 0, 13) . '...' : $tag, 'messages', array( |
|
567 | + $tags[] = l(strlen($tag) > 15 ? substr($tag, 0, 13).'...' : $tag, 'messages', array( |
|
568 | 568 | 'attributes' => array('title' => $tag), |
569 | 569 | 'query' => array('tags' => $tag) |
570 | 570 | )); |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | |
612 | 612 | // Check if its a filtered view. |
613 | 613 | if ($argument == 'sent') { |
614 | - $fragments['where'][] = "pm.author = %d"; |
|
615 | - $fragments['query_args']['where'][] = $account->uid; |
|
614 | + $fragments['where'][] = "pm.author = %d"; |
|
615 | + $fragments['query_args']['where'][] = $account->uid; |
|
616 | 616 | } |
617 | 617 | if ($argument == 'inbox') { |
618 | - $fragments['having'][] = '((SELECT pmf.author FROM {pm_message} pmf WHERE pmf.mid = pmi.thread_id) = %d AND COUNT(pmi.thread_id) > 1) OR (SELECT COUNT(*) FROM {pm_message} pmf INNER JOIN {pm_index} pmif ON (pmf.mid = pmif.mid) WHERE pmif.thread_id = pmi.thread_id AND pmf.author <> %d) > 0'; |
|
618 | + $fragments['having'][] = '((SELECT pmf.author FROM {pm_message} pmf WHERE pmf.mid = pmi.thread_id) = %d AND COUNT(pmi.thread_id) > 1) OR (SELECT COUNT(*) FROM {pm_message} pmf INNER JOIN {pm_index} pmif ON (pmf.mid = pmif.mid) WHERE pmif.thread_id = pmi.thread_id AND pmf.author <> %d) > 0'; |
|
619 | 619 | $fragments['query_args']['having'][] = $account->uid; |
620 | 620 | $fragments['query_args']['having'][] = $account->uid; |
621 | 621 | } |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | foreach ($filter['tags'] as $tag) { |
628 | 628 | $fragments['inner_join'][] = "INNER JOIN {pm_tags_index} pmti$count ON (pmti$count.thread_id = pmi.thread_id AND pmti$count.uid = pmi.uid)"; |
629 | 629 | $fragments['where'][] = "pmti$count.tag_id = %d"; |
630 | - $fragments['query_args']['where'][] = $tag; |
|
630 | + $fragments['query_args']['where'][] = $tag; |
|
631 | 631 | $count++; |
632 | 632 | } |
633 | 633 | } |
@@ -636,20 +636,20 @@ discard block |
||
636 | 636 | foreach ($filter['author'] as $author) { |
637 | 637 | $fragments['inner_join'][] = "INNER JOIN {pm_index} pmi$count ON (pmi$count.mid = pm.mid)"; |
638 | 638 | $fragments['where'][] = "pmi$count.uid = %d"; |
639 | - $fragments['query_args']['where'][] = $author->uid; |
|
639 | + $fragments['query_args']['where'][] = $author->uid; |
|
640 | 640 | $count++; |
641 | 641 | } |
642 | 642 | } |
643 | 643 | |
644 | 644 | if (isset($filter['search']) && !empty($filter['search'])) { |
645 | 645 | if (variable_get('privatemsg_filter_searchbody', FALSE)) { |
646 | - $fragments['where'][] = "pm.subject LIKE '%s' OR pm.body LIKE '%s'"; |
|
647 | - $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
|
648 | - $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
|
646 | + $fragments['where'][] = "pm.subject LIKE '%s' OR pm.body LIKE '%s'"; |
|
647 | + $fragments['query_args']['where'][] = '%%'.$filter['search'].'%%'; |
|
648 | + $fragments['query_args']['where'][] = '%%'.$filter['search'].'%%'; |
|
649 | 649 | } |
650 | 650 | else { |
651 | - $fragments['where'][] = "pm.subject LIKE '%s'"; |
|
652 | - $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
|
651 | + $fragments['where'][] = "pm.subject LIKE '%s'"; |
|
652 | + $fragments['query_args']['where'][] = '%%'.$filter['search'].'%%'; |
|
653 | 653 | } |
654 | 654 | } |
655 | 655 | } |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | $count = db_result(db_query($query['count'])); |
679 | 679 | $tags = ''; |
680 | 680 | while ($tag = db_fetch_array($results)) { |
681 | - $tags .= $tag['tag'] . ', '; |
|
681 | + $tags .= $tag['tag'].', '; |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | $form['tags'] = array( |
@@ -755,10 +755,10 @@ discard block |
||
755 | 755 | if (!empty($fragment)) { |
756 | 756 | $query = _privatemsg_assemble_query(array('tags_autocomplete', 'privatemsg_filter'), $fragment, $tags); |
757 | 757 | $result = db_query_range($query['query'], $fragment, 0, 10); |
758 | - $prefix = count($tags) ? implode(", ", $tags) .", " : ''; |
|
758 | + $prefix = count($tags) ? implode(", ", $tags).", " : ''; |
|
759 | 759 | // 3: Build proper suggestions and print. |
760 | 760 | while ($tag = db_fetch_object($result)) { |
761 | - $matches[$prefix . $tag->tag .", "] = $tag->tag; |
|
761 | + $matches[$prefix.$tag->tag.", "] = $tag->tag; |
|
762 | 762 | } |
763 | 763 | } |
764 | 764 | // convert to object to prevent drupal bug, see http://drupal.org/node/175361 |
@@ -817,8 +817,8 @@ discard block |
||
817 | 817 | if (!empty($threads)) { |
818 | 818 | // If the tag list needs to be for specific threads. |
819 | 819 | $fragments['select'][] = 'ti.thread_id'; |
820 | - $fragments['inner_join'][] = 'INNER JOIN {pm_tags_index} ti on ti.tag_id = t.tag_id'; |
|
821 | - $fragments['where'][] = 'ti.thread_id IN (' . db_placeholders($threads) . ')'; |
|
820 | + $fragments['inner_join'][] = 'INNER JOIN {pm_tags_index} ti on ti.tag_id = t.tag_id'; |
|
821 | + $fragments['where'][] = 'ti.thread_id IN ('.db_placeholders($threads).')'; |
|
822 | 822 | $fragments['query_args']['where'] += $threads; |
823 | 823 | } |
824 | 824 | else { |
@@ -875,14 +875,14 @@ discard block |
||
875 | 875 | $fragments['select'][] = 'pmt.tag'; |
876 | 876 | $fragments['where'][] = "pmt.tag LIKE '%s'"; |
877 | 877 | // Escape % to get through the placeholder replacement. |
878 | - $fragments['query_args']['where'][] = $search .'%%'; |
|
878 | + $fragments['query_args']['where'][] = $search.'%%'; |
|
879 | 879 | if (!empty($tags)) { |
880 | 880 | // Exclude tags. |
881 | - $fragments['where'][] = "pmt.tag NOT IN (". db_placeholders($tags, 'text') .")"; |
|
881 | + $fragments['where'][] = "pmt.tag NOT IN (".db_placeholders($tags, 'text').")"; |
|
882 | 882 | $fragments['query_args']['where'] += $tags; |
883 | 883 | } |
884 | 884 | // LEFT JOIN to be able to load public, unused tags. |
885 | - $fragments['inner_join'][] = 'LEFT JOIN {pm_tags_index} pmti ON pmt.tag_id = pmti.tag_id AND pmti.uid = %d'; |
|
885 | + $fragments['inner_join'][] = 'LEFT JOIN {pm_tags_index} pmti ON pmt.tag_id = pmti.tag_id AND pmti.uid = %d'; |
|
886 | 886 | $fragments['query_args']['join'][] = $user->uid; |
887 | 887 | // Autocomplete should only display Tags used by that user or public tags. |
888 | 888 | // This is done to avoid information disclosure as part of tag names. |
@@ -192,8 +192,7 @@ discard block |
||
192 | 192 | if (empty($tag_id) && privatemsg_user_access('create private message tags')) { |
193 | 193 | db_query("INSERT INTO {pm_tags} (tag) VALUES ('%s')", $tag); |
194 | 194 | $tag_id = db_last_insert_id('pm_tags', 'tag_id'); |
195 | - } |
|
196 | - elseif (empty($tag_id)) { |
|
195 | + } elseif (empty($tag_id)) { |
|
197 | 196 | // The user does not have permission to create new tags - disregard this tag and move onto the next. |
198 | 197 | drupal_set_message(t('Tag %tag was ignored because you do not have permission to create new tags.', array('%tag' => $tag))); |
199 | 198 | continue; |
@@ -251,8 +250,7 @@ discard block |
||
251 | 250 | foreach ($threads as $thread) { |
252 | 251 | db_query('DELETE FROM {pm_tags_index} WHERE uid = %d AND thread_id = %d', $account->uid, $thread); |
253 | 252 | } |
254 | - } |
|
255 | - else { |
|
253 | + } else { |
|
256 | 254 | // Delete tag mapping for the specified tag. |
257 | 255 | foreach ($threads as $thread) { |
258 | 256 | db_query('DELETE FROM {pm_tags_index} WHERE uid = %d AND thread_id = %d AND tag_id = %d', $account->uid, $thread, $tag_id); |
@@ -268,8 +266,7 @@ discard block |
||
268 | 266 | foreach (explode(',', $_GET['tags']) as $tag) { |
269 | 267 | if (isset($tag_data[$tag])) { |
270 | 268 | $filter['tags'][$tag] = $tag; |
271 | - } |
|
272 | - elseif (in_array($tag, $tag_data)) { |
|
269 | + } elseif (in_array($tag, $tag_data)) { |
|
273 | 270 | $filter['tags'][array_search($tag, $tag_data)] = array_search($tag, $tag_data); |
274 | 271 | } |
275 | 272 | } |
@@ -436,8 +433,7 @@ discard block |
||
436 | 433 | foreach ($filter['tags'] as $tag) { |
437 | 434 | if ((int)$tag > 0) { |
438 | 435 | $ids[] = $tag; |
439 | - } |
|
440 | - else { |
|
436 | + } else { |
|
441 | 437 | $query['tags'][] = $tag; |
442 | 438 | } |
443 | 439 | } |
@@ -456,8 +452,7 @@ discard block |
||
456 | 452 | foreach ($filter['author'] as $author) { |
457 | 453 | if (is_object($author) && isset($author->uid) && isset($author->name)) { |
458 | 454 | $query['author'][] = $author->name; |
459 | - } |
|
460 | - elseif ($author_obj = user_load($author)) { |
|
455 | + } elseif ($author_obj = user_load($author)) { |
|
461 | 456 | $query['author'][] = $author_obj->name; |
462 | 457 | } |
463 | 458 | } |
@@ -646,8 +641,7 @@ discard block |
||
646 | 641 | $fragments['where'][] = "pm.subject LIKE '%s' OR pm.body LIKE '%s'"; |
647 | 642 | $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
648 | 643 | $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
649 | - } |
|
650 | - else { |
|
644 | + } else { |
|
651 | 645 | $fragments['where'][] = "pm.subject LIKE '%s'"; |
652 | 646 | $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
653 | 647 | } |
@@ -820,8 +814,7 @@ discard block |
||
820 | 814 | $fragments['inner_join'][] = 'INNER JOIN {pm_tags_index} ti on ti.tag_id = t.tag_id'; |
821 | 815 | $fragments['where'][] = 'ti.thread_id IN (' . db_placeholders($threads) . ')'; |
822 | 816 | $fragments['query_args']['where'] += $threads; |
823 | - } |
|
824 | - else { |
|
817 | + } else { |
|
825 | 818 | // Tag usage counter is only used when we select all tags. |
826 | 819 | $fragments['select'][] = 'COUNT(ti.thread_id) as count'; |
827 | 820 | // LEFT JOIN so that unused tags are displayed too. |
@@ -850,8 +843,7 @@ discard block |
||
850 | 843 | AND pmtic.uid = ti.uid |
851 | 844 | AND pmtic.tag_id < ti.tag_id) < %d'; |
852 | 845 | $fragments['query_args']['where'][] = $limit; |
853 | - } |
|
854 | - elseif (!empty($threads) || !empty($user)) { |
|
846 | + } elseif (!empty($threads) || !empty($user)) { |
|
855 | 847 | // Only add a sort when we are not loading the tags for the admin page. |
856 | 848 | // Sorting is handled through tablesort_sql() then. |
857 | 849 | $fragments['order_by'][] = 't.tag ASC'; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | '#type' => 'checkbox', |
126 | 126 | '#title' => t('Search message body'), |
127 | 127 | '#description' => t('WARNING: turning on this feature will slow down search performance by a large factor. Gets worse as your messages database increases.'), |
128 | - '#default_value' => variable_get('privatemsg_filter_searchbody', FALSE), |
|
128 | + '#default_value' => variable_get('privatemsg_filter_searchbody', false), |
|
129 | 129 | ); |
130 | 130 | |
131 | 131 | $form['privatemsg_filter_tagfield_weight'] = array( |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @param $tag_id |
212 | 212 | * Id of the tag. |
213 | 213 | */ |
214 | -function privatemsg_filter_add_tags($threads, $tag_id, $account = NULL) { |
|
214 | +function privatemsg_filter_add_tags($threads, $tag_id, $account = null) { |
|
215 | 215 | if (!is_array($threads)) { |
216 | 216 | $threads = array($threads); |
217 | 217 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param $tag_id |
238 | 238 | * Id of the tag - set to NULL to remove all tags. |
239 | 239 | */ |
240 | -function privatemsg_filter_remove_tags($threads, $tag_id = NULL, $account = NULL) { |
|
240 | +function privatemsg_filter_remove_tags($threads, $tag_id = null, $account = null) { |
|
241 | 241 | if (!is_array($threads)) { |
242 | 242 | $threads = array($threads); |
243 | 243 | } |
@@ -318,12 +318,12 @@ discard block |
||
318 | 318 | $form['filter'] = array( |
319 | 319 | '#type' => 'fieldset', |
320 | 320 | '#title' => t('Filter messages'), |
321 | - '#collapsible' => TRUE, |
|
322 | - '#collapsed' => TRUE, |
|
321 | + '#collapsible' => true, |
|
322 | + '#collapsed' => true, |
|
323 | 323 | ); |
324 | 324 | $form['filter']['search'] = array( |
325 | 325 | '#type' => 'textfield', |
326 | - '#title' => variable_get('privatemsg_filter_searchbody', FALSE) ? t('Search messages') : t('Search subjects'), |
|
326 | + '#title' => variable_get('privatemsg_filter_searchbody', false) ? t('Search messages') : t('Search subjects'), |
|
327 | 327 | '#weight' => -20 |
328 | 328 | ); |
329 | 329 | |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | '#type' => 'select', |
343 | 343 | '#title' => t('Tags'), |
344 | 344 | '#options' => $tag_data, |
345 | - '#multiple' => TRUE, |
|
345 | + '#multiple' => true, |
|
346 | 346 | '#size' => 5, |
347 | 347 | '#weight' => 0 |
348 | 348 | ); |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | |
373 | 373 | function privatemsg_filter_dropdown_set_active(&$form, $filter) { |
374 | 374 | $form['filter']['#title'] = t('Filter messages (active)'); |
375 | - $form['filter']['#collapsed'] = FALSE; |
|
375 | + $form['filter']['#collapsed'] = false; |
|
376 | 376 | |
377 | 377 | if (isset($filter['author'])) { |
378 | 378 | $string = ''; |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | } |
643 | 643 | |
644 | 644 | if (isset($filter['search']) && !empty($filter['search'])) { |
645 | - if (variable_get('privatemsg_filter_searchbody', FALSE)) { |
|
645 | + if (variable_get('privatemsg_filter_searchbody', false)) { |
|
646 | 646 | $fragments['where'][] = "pm.subject LIKE '%s' OR pm.body LIKE '%s'"; |
647 | 647 | $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
648 | 648 | $fragments['query_args']['where'][] = '%%'. $filter['search'] .'%%'; |
@@ -685,8 +685,8 @@ discard block |
||
685 | 685 | '#type' => 'fieldset', |
686 | 686 | '#title' => t('Tags'), |
687 | 687 | '#access' => privatemsg_user_access('tag private messages'), |
688 | - '#collapsible' => TRUE, |
|
689 | - '#collapsed' => empty($count) ? TRUE : FALSE, |
|
688 | + '#collapsible' => true, |
|
689 | + '#collapsed' => empty($count) ? true : false, |
|
690 | 690 | ); |
691 | 691 | $form['tags']['user_id'] = array( |
692 | 692 | '#type' => 'value', |
@@ -808,7 +808,7 @@ discard block |
||
808 | 808 | * @param $limit |
809 | 809 | * Limit the number of tags *per thread*. |
810 | 810 | */ |
811 | -function privatemsg_filter_sql_tags(&$fragments, $user = NULL, $threads = NULL, $limit = NULL) { |
|
811 | +function privatemsg_filter_sql_tags(&$fragments, $user = null, $threads = null, $limit = null) { |
|
812 | 812 | $fragments['primary_table'] = '{pm_tags} t'; |
813 | 813 | $fragments['select'][] = 't.tag'; |
814 | 814 | $fragments['select'][] = 't.tag_id'; |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | /** |
898 | 898 | * Implement hook_user(). |
899 | 899 | */ |
900 | -function privatemsg_filter_user($op, &$edit, &$account, $category = NULL) { |
|
900 | +function privatemsg_filter_user($op, &$edit, &$account, $category = null) { |
|
901 | 901 | switch ($op) { |
902 | 902 | case 'delete': |
903 | 903 | // Delete tag information of that user. |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @see theme_privatemsg_list_field() |
76 | 76 | */ |
77 | 77 | function phptemplate_privatemsg_list_field__participants($thread) { |
78 | - $participants = _privatemsg_generate_user_array($thread['participants'], -4); |
|
79 | - $field = array(); |
|
80 | - $field['data'] = _privatemsg_format_participants($participants, 3, TRUE); |
|
81 | - $field['class'] = 'privatemsg-list-participants'; |
|
82 | - return $field; |
|
78 | + $participants = _privatemsg_generate_user_array($thread['participants'], -4); |
|
79 | + $field = array(); |
|
80 | + $field['data'] = _privatemsg_format_participants($participants, 3, TRUE); |
|
81 | + $field['class'] = 'privatemsg-list-participants'; |
|
82 | + return $field; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | * @see theme_privatemsg_list_field() |
89 | 89 | */ |
90 | 90 | function phptemplate_privatemsg_list_field__subject($thread) { |
91 | - $field = array(); |
|
92 | - $options = array(); |
|
93 | - $is_new = ''; |
|
94 | - if (!empty($thread['is_new'])) { |
|
91 | + $field = array(); |
|
92 | + $options = array(); |
|
93 | + $is_new = ''; |
|
94 | + if (!empty($thread['is_new'])) { |
|
95 | 95 | $is_new = theme_mark(MARK_NEW); |
96 | 96 | $options['fragment'] = 'new'; |
97 | - } |
|
98 | - $field['data'] = l($thread['subject'], 'messages/view/' . $thread['thread_id'], $options) . $is_new; |
|
99 | - $field['class'] = 'privatemsg-list-subject'; |
|
100 | - return $field; |
|
97 | + } |
|
98 | + $field['data'] = l($thread['subject'], 'messages/view/' . $thread['thread_id'], $options) . $is_new; |
|
99 | + $field['class'] = 'privatemsg-list-subject'; |
|
100 | + return $field; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -106,15 +106,15 @@ discard block |
||
106 | 106 | * @see theme_privatemsg_list_field() |
107 | 107 | */ |
108 | 108 | function phptemplate_privatemsg_list_field__count($thread) { |
109 | - $field = array(); |
|
110 | - $field['data'] = $thread['count']; |
|
111 | - $options = array(); |
|
112 | - if (!empty($thread['is_new']) && $thread['is_new'] < $thread['count']) { |
|
109 | + $field = array(); |
|
110 | + $field['data'] = $thread['count']; |
|
111 | + $options = array(); |
|
112 | + if (!empty($thread['is_new']) && $thread['is_new'] < $thread['count']) { |
|
113 | 113 | $options['fragment'] = 'new'; |
114 | 114 | $field['data'] .= '<br />' . l((format_plural($thread['is_new'], '(1 new)', '(@count new)')), 'messages/view/' . $thread['thread_id'], $options); |
115 | - } |
|
116 | - $field['class'] = 'privatemsg-list-count'; |
|
117 | - return $field; |
|
115 | + } |
|
116 | + $field['class'] = 'privatemsg-list-count'; |
|
117 | + return $field; |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | * @see theme_privatemsg_list_field() |
124 | 124 | */ |
125 | 125 | function phptemplate_privatemsg_list_field__last_updated($thread) { |
126 | - $field = array(); |
|
127 | - $field['data'] = format_date($thread['last_updated'], 'small'); |
|
128 | - $field['class'] = 'privatemsg-list-date'; |
|
129 | - return $field; |
|
126 | + $field = array(); |
|
127 | + $field['data'] = format_date($thread['last_updated'], 'small'); |
|
128 | + $field['class'] = 'privatemsg-list-date'; |
|
129 | + return $field; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * @see theme_privatemsg_list_field() |
136 | 136 | */ |
137 | 137 | function phptemplate_privatemsg_list_field__thread_started($thread) { |
138 | - $field = array(); |
|
139 | - $field['data'] = format_date($thread['thread_started'], 'small'); |
|
140 | - $field['class'] = 'privatemsg-list-date-started'; |
|
141 | - return $field; |
|
138 | + $field = array(); |
|
139 | + $field['data'] = format_date($thread['thread_started'], 'small'); |
|
140 | + $field['class'] = 'privatemsg-list-date-started'; |
|
141 | + return $field; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | * @see theme_privatemsg_list_header() |
163 | 163 | */ |
164 | 164 | function phptemplate_privatemsg_list_header__subject() { |
165 | - return array( |
|
165 | + return array( |
|
166 | 166 | 'data' => t('Subject'), |
167 | 167 | 'field' => 'subject', |
168 | 168 | 'key' => 'subject', |
169 | 169 | 'class' => 'privatemsg-header-subject', |
170 | 170 | '#weight' => -40, |
171 | - ); |
|
171 | + ); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | * @see theme_privatemsg_list_header() |
178 | 178 | */ |
179 | 179 | function phptemplate_privatemsg_list_header__count() { |
180 | - return array( |
|
180 | + return array( |
|
181 | 181 | 'data' => t('Messages'), |
182 | 182 | 'key' => 'count', |
183 | 183 | 'class' => 'privatemsg-header-count', |
184 | 184 | '#weight' => -25, |
185 | - ); |
|
185 | + ); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -191,12 +191,12 @@ discard block |
||
191 | 191 | * @see theme_privatemsg_list_header() |
192 | 192 | */ |
193 | 193 | function phptemplate_privatemsg_list_header__participants() { |
194 | - return array( |
|
194 | + return array( |
|
195 | 195 | 'data' => t('Participants'), |
196 | 196 | 'key' => 'participants', |
197 | 197 | 'class' => 'privatemsg-header-participants', |
198 | 198 | '#weight' => -30, |
199 | - ); |
|
199 | + ); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | * @see theme_privatemsg_list_header() |
206 | 206 | */ |
207 | 207 | function phptemplate_privatemsg_list_header__last_updated() { |
208 | - return array( |
|
208 | + return array( |
|
209 | 209 | 'data' => t('Last Updated'), |
210 | 210 | 'field' => 'last_updated', |
211 | 211 | 'key' => 'last_updated', |
212 | 212 | 'sort' => 'desc', |
213 | 213 | 'class' => 'privatemsg-header-lastupdated', |
214 | 214 | '#weight' => -20, |
215 | - ); |
|
215 | + ); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | * @see theme_privatemsg_list_header() |
222 | 222 | */ |
223 | 223 | function phptemplate_privatemsg_list_header__thread_started() { |
224 | - return array( |
|
224 | + return array( |
|
225 | 225 | 'data' => t('Started'), |
226 | 226 | 'field' => 'thread_started', |
227 | 227 | 'key' => 'thread_started', |
228 | 228 | 'class' => 'privatemsg-header-threadstarted', |
229 | 229 | '#weight' => -15, |
230 | - ); |
|
230 | + ); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -237,70 +237,70 @@ discard block |
||
237 | 237 | * by the header and field theme patterns. |
238 | 238 | */ |
239 | 239 | function theme_privatemsg_list($form) { |
240 | - $has_posts = !empty($form['#data']); |
|
240 | + $has_posts = !empty($form['#data']); |
|
241 | 241 | |
242 | - drupal_add_css(drupal_get_path('module', 'privatemsg') .'/styles/privatemsg-list.css'); |
|
242 | + drupal_add_css(drupal_get_path('module', 'privatemsg') .'/styles/privatemsg-list.css'); |
|
243 | 243 | |
244 | - // Load the table columns. |
|
245 | - $columns = array_merge(array('subject', 'last_updated'), array_filter(variable_get('privatemsg_display_fields', array('participants')))); |
|
244 | + // Load the table columns. |
|
245 | + $columns = array_merge(array('subject', 'last_updated'), array_filter(variable_get('privatemsg_display_fields', array('participants')))); |
|
246 | 246 | |
247 | - // Load the themed list headers based on the available data. |
|
248 | - $headers = _privatemsg_list_headers(!empty($form['#data']), $columns); |
|
249 | - // sort the headers array based on the #weight property. |
|
250 | - usort($headers, 'element_sort'); |
|
247 | + // Load the themed list headers based on the available data. |
|
248 | + $headers = _privatemsg_list_headers(!empty($form['#data']), $columns); |
|
249 | + // sort the headers array based on the #weight property. |
|
250 | + usort($headers, 'element_sort'); |
|
251 | 251 | |
252 | - $themed_rows = array(); |
|
253 | - // Check if there is atleast a single thread. |
|
254 | - if ($has_posts) { |
|
252 | + $themed_rows = array(); |
|
253 | + // Check if there is atleast a single thread. |
|
254 | + if ($has_posts) { |
|
255 | 255 | foreach ($form['#data'] as $thread_id => $data) { |
256 | - // Theme the row. |
|
257 | - $row = _privatemsg_list_thread($data); |
|
258 | - $data = array(); |
|
259 | - // Render the checkbox. |
|
260 | - $data[] = array('data' => drupal_render($form['threads'][$thread_id]), 'class' => 'privatemsg-list-select'); |
|
256 | + // Theme the row. |
|
257 | + $row = _privatemsg_list_thread($data); |
|
258 | + $data = array(); |
|
259 | + // Render the checkbox. |
|
260 | + $data[] = array('data' => drupal_render($form['threads'][$thread_id]), 'class' => 'privatemsg-list-select'); |
|
261 | 261 | |
262 | - // Store the #rows data in the same order as the header is, the key property of the header refers to the field that belongs to it. |
|
263 | - foreach ($headers as $header) { |
|
262 | + // Store the #rows data in the same order as the header is, the key property of the header refers to the field that belongs to it. |
|
263 | + foreach ($headers as $header) { |
|
264 | 264 | if (!empty($header['key'])) { |
265 | - if (isset($row['data'][$header['key']])) { |
|
265 | + if (isset($row['data'][$header['key']])) { |
|
266 | 266 | $data[] = $row['data'][$header['key']]; |
267 | - } |
|
268 | - else { |
|
267 | + } |
|
268 | + else { |
|
269 | 269 | // Store a empty value so that the order is still correct. |
270 | 270 | $data[] = ''; |
271 | - } |
|
271 | + } |
|
272 | + } |
|
272 | 273 | } |
273 | - } |
|
274 | - // Replace the data |
|
275 | - $row['data'] = $data; |
|
276 | - $themed_rows[] = $row; |
|
274 | + // Replace the data |
|
275 | + $row['data'] = $data; |
|
276 | + $themed_rows[] = $row; |
|
277 | 277 | } |
278 | - } |
|
279 | - else { |
|
278 | + } |
|
279 | + else { |
|
280 | 280 | // Display a message if now messages are available. |
281 | 281 | $themed_rows[] = array(array('data' => t('No messages available.'), 'colspan' => count($headers))); |
282 | - } |
|
282 | + } |
|
283 | 283 | |
284 | - // Remove any data in header that we don't need anymore. |
|
285 | - foreach ($headers as $id => $header) { |
|
284 | + // Remove any data in header that we don't need anymore. |
|
285 | + foreach ($headers as $id => $header) { |
|
286 | 286 | unset($headers[$id]['key']); |
287 | 287 | unset($headers[$id]['#weight']); |
288 | - } |
|
288 | + } |
|
289 | 289 | |
290 | - // Theme the table, pass all generated information to the table theme function. |
|
291 | - $form['list'] = array('#value' => theme('table', $headers, $themed_rows, array('class' => 'privatemsg-list')), '#weight' => 5); |
|
292 | - return drupal_render($form); |
|
290 | + // Theme the table, pass all generated information to the table theme function. |
|
291 | + $form['list'] = array('#value' => theme('table', $headers, $themed_rows, array('class' => 'privatemsg-list')), '#weight' => 5); |
|
292 | + return drupal_render($form); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
296 | 296 | * Theme a block which displays the number of new messages a user has. |
297 | 297 | */ |
298 | 298 | function theme_privatemsg_new_block($count) { |
299 | - $text = format_plural($count, 'You have a new message, click here to read it', |
|
299 | + $text = format_plural($count, 'You have a new message, click here to read it', |
|
300 | 300 | 'You have @count new messages, click here to read them', |
301 | 301 | array('@count' => $count)); |
302 | 302 | |
303 | - return l($text, 'messages', array('attributes' => array('id' => 'privatemsg-new-link'))); |
|
303 | + return l($text, 'messages', array('attributes' => array('id' => 'privatemsg-new-link'))); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $is_new = theme_mark(MARK_NEW); |
96 | 96 | $options['fragment'] = 'new'; |
97 | 97 | } |
98 | - $field['data'] = l($thread['subject'], 'messages/view/' . $thread['thread_id'], $options) . $is_new; |
|
98 | + $field['data'] = l($thread['subject'], 'messages/view/'.$thread['thread_id'], $options).$is_new; |
|
99 | 99 | $field['class'] = 'privatemsg-list-subject'; |
100 | 100 | return $field; |
101 | 101 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $options = array(); |
112 | 112 | if (!empty($thread['is_new']) && $thread['is_new'] < $thread['count']) { |
113 | 113 | $options['fragment'] = 'new'; |
114 | - $field['data'] .= '<br />' . l((format_plural($thread['is_new'], '(1 new)', '(@count new)')), 'messages/view/' . $thread['thread_id'], $options); |
|
114 | + $field['data'] .= '<br />'.l((format_plural($thread['is_new'], '(1 new)', '(@count new)')), 'messages/view/'.$thread['thread_id'], $options); |
|
115 | 115 | } |
116 | 116 | $field['class'] = 'privatemsg-list-count'; |
117 | 117 | return $field; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | function theme_privatemsg_list($form) { |
240 | 240 | $has_posts = !empty($form['#data']); |
241 | 241 | |
242 | - drupal_add_css(drupal_get_path('module', 'privatemsg') .'/styles/privatemsg-list.css'); |
|
242 | + drupal_add_css(drupal_get_path('module', 'privatemsg').'/styles/privatemsg-list.css'); |
|
243 | 243 | |
244 | 244 | // Load the table columns. |
245 | 245 | $columns = array_merge(array('subject', 'last_updated'), array_filter(variable_get('privatemsg_display_fields', array('participants')))); |
@@ -264,8 +264,7 @@ discard block |
||
264 | 264 | if (!empty($header['key'])) { |
265 | 265 | if (isset($row['data'][$header['key']])) { |
266 | 266 | $data[] = $row['data'][$header['key']]; |
267 | - } |
|
268 | - else { |
|
267 | + } else { |
|
269 | 268 | // Store a empty value so that the order is still correct. |
270 | 269 | $data[] = ''; |
271 | 270 | } |
@@ -275,8 +274,7 @@ discard block |
||
275 | 274 | $row['data'] = $data; |
276 | 275 | $themed_rows[] = $row; |
277 | 276 | } |
278 | - } |
|
279 | - else { |
|
277 | + } else { |
|
280 | 278 | // Display a message if now messages are available. |
281 | 279 | $themed_rows[] = array(array('data' => t('No messages available.'), 'colspan' => count($headers))); |
282 | 280 | } |
@@ -77,7 +77,7 @@ |
||
77 | 77 | function phptemplate_privatemsg_list_field__participants($thread) { |
78 | 78 | $participants = _privatemsg_generate_user_array($thread['participants'], -4); |
79 | 79 | $field = array(); |
80 | - $field['data'] = _privatemsg_format_participants($participants, 3, TRUE); |
|
80 | + $field['data'] = _privatemsg_format_participants($participants, 3, true); |
|
81 | 81 | $field['class'] = 'privatemsg-list-participants'; |
82 | 82 | return $field; |
83 | 83 | } |
@@ -1437,43 +1437,43 @@ discard block |
||
1437 | 1437 | global $user; |
1438 | 1438 | |
1439 | 1439 | switch ($op) { |
1440 | - case 'view': |
|
1441 | - if ($url = privatemsg_get_link(array($account))) { |
|
1442 | - $account->content['privatemsg_send_new_message'] = array( |
|
1443 | - '#type' => 'markup', |
|
1444 | - '#value' => l(t('Send this user a message'), $url, array('query' => drupal_get_destination())), |
|
1445 | - '#weight' => 10, |
|
1446 | - ); |
|
1447 | - } |
|
1448 | - break; |
|
1449 | - case 'login': |
|
1450 | - if (variable_get('privatemsg_display_loginmessage', TRUE) && privatemsg_user_access()) { |
|
1451 | - $count = privatemsg_unread_count(); |
|
1452 | - if ($count) { |
|
1453 | - drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages')))); |
|
1454 | - } |
|
1440 | + case 'view': |
|
1441 | + if ($url = privatemsg_get_link(array($account))) { |
|
1442 | + $account->content['privatemsg_send_new_message'] = array( |
|
1443 | + '#type' => 'markup', |
|
1444 | + '#value' => l(t('Send this user a message'), $url, array('query' => drupal_get_destination())), |
|
1445 | + '#weight' => 10, |
|
1446 | + ); |
|
1447 | + } |
|
1448 | + break; |
|
1449 | + case 'login': |
|
1450 | + if (variable_get('privatemsg_display_loginmessage', TRUE) && privatemsg_user_access()) { |
|
1451 | + $count = privatemsg_unread_count(); |
|
1452 | + if ($count) { |
|
1453 | + drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages')))); |
|
1455 | 1454 | } |
1456 | - break; |
|
1457 | - case 'delete': |
|
1455 | + } |
|
1456 | + break; |
|
1457 | + case 'delete': |
|
1458 | 1458 | |
1459 | - // Load all mids of the messages the user wrote. |
|
1460 | - $result = db_query("SELECT mid FROM {pm_message} WHERE author = %d", $account->uid); |
|
1461 | - $mids = array(); |
|
1462 | - while ($row = db_fetch_array($result)) { |
|
1463 | - $mids[] = $row['mid']; |
|
1464 | - } |
|
1459 | + // Load all mids of the messages the user wrote. |
|
1460 | + $result = db_query("SELECT mid FROM {pm_message} WHERE author = %d", $account->uid); |
|
1461 | + $mids = array(); |
|
1462 | + while ($row = db_fetch_array($result)) { |
|
1463 | + $mids[] = $row['mid']; |
|
1464 | + } |
|
1465 | 1465 | |
1466 | - // Delete messages the user wrote. |
|
1467 | - db_query('DELETE FROM {pm_message} WHERE author = %d', $account->uid); |
|
1466 | + // Delete messages the user wrote. |
|
1467 | + db_query('DELETE FROM {pm_message} WHERE author = %d', $account->uid); |
|
1468 | 1468 | |
1469 | - if (!empty($mids)) { |
|
1470 | - // Delete recipient entries in {pm_index} of the messages the user wrote. |
|
1471 | - db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids); |
|
1472 | - } |
|
1469 | + if (!empty($mids)) { |
|
1470 | + // Delete recipient entries in {pm_index} of the messages the user wrote. |
|
1471 | + db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids); |
|
1472 | + } |
|
1473 | 1473 | |
1474 | - // Delete recipient entries of that user. |
|
1475 | - db_query('DELETE FROM {pm_index} WHERE uid = %d', $account->uid); |
|
1476 | - break; |
|
1474 | + // Delete recipient entries of that user. |
|
1475 | + db_query('DELETE FROM {pm_index} WHERE uid = %d', $account->uid); |
|
1476 | + break; |
|
1477 | 1477 | } |
1478 | 1478 | } |
1479 | 1479 | |
@@ -1494,12 +1494,12 @@ discard block |
||
1494 | 1494 | elseif ('view' == $op) { |
1495 | 1495 | $block = array(); |
1496 | 1496 | switch ($delta) { |
1497 | - case 'privatemsg-menu': |
|
1498 | - $block = _privatemsg_block_menu(); |
|
1499 | - break; |
|
1500 | - case 'privatemsg-new': |
|
1501 | - $block = _privatemsg_block_new(); |
|
1502 | - break; |
|
1497 | + case 'privatemsg-menu': |
|
1498 | + $block = _privatemsg_block_menu(); |
|
1499 | + break; |
|
1500 | + case 'privatemsg-new': |
|
1501 | + $block = _privatemsg_block_new(); |
|
1502 | + break; |
|
1503 | 1503 | } |
1504 | 1504 | return $block; |
1505 | 1505 | } |
@@ -102,10 +102,11 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | $last = array_pop($to); |
105 | - if (count($to) == 0) { // Only one participant |
|
105 | + if (count($to) == 0) { |
|
106 | +// Only one participant |
|
106 | 107 | return t("From !last", array('!last' => $last)); |
107 | - } |
|
108 | - else { // Multipe participants.. |
|
108 | + } else { |
|
109 | +// Multipe participants.. |
|
109 | 110 | $participants = implode(', ', $to); |
110 | 111 | return t('Participants: !participants and !last', array('!participants' => $participants, '!last' => $last)); |
111 | 112 | } |
@@ -224,7 +225,8 @@ discard block |
||
224 | 225 | global $user; |
225 | 226 | $account = $user; |
226 | 227 | } |
227 | - if (!$account->uid) { // Disallow anonymous access, regardless of permissions |
|
228 | + if (!$account->uid) { |
|
229 | +// Disallow anonymous access, regardless of permissions |
|
228 | 230 | return FALSE; |
229 | 231 | } |
230 | 232 | if (!user_access($permission, $account)) { |
@@ -325,11 +327,9 @@ discard block |
||
325 | 327 | if (is_null($start)) { |
326 | 328 | if (isset($_GET['start']) && $_GET['start'] < $thread['message_count']) { |
327 | 329 | $start = $_GET['start']; |
328 | - } |
|
329 | - elseif (!variable_get('privatemsg_view_use_max_as_default', FALSE) && $max_amount == PRIVATEMSG_UNLIMITED) { |
|
330 | + } elseif (!variable_get('privatemsg_view_use_max_as_default', FALSE) && $max_amount == PRIVATEMSG_UNLIMITED) { |
|
330 | 331 | $start = PRIVATEMSG_UNLIMITED; |
331 | - } |
|
332 | - else { |
|
332 | + } else { |
|
333 | 333 | $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', FALSE) ? variable_get('privatemsg_view_default_amount', 10) : $max_amount); |
334 | 334 | } |
335 | 335 | } |
@@ -338,8 +338,7 @@ discard block |
||
338 | 338 | if ($max_amount == PRIVATEMSG_UNLIMITED) { |
339 | 339 | $last_page = 0; |
340 | 340 | $max_amount = $thread['message_count']; |
341 | - } |
|
342 | - else { |
|
341 | + } else { |
|
343 | 342 | // Calculate the number of messages on the "last" page to avoid |
344 | 343 | // message overlap. |
345 | 344 | // Note - the last page lists the earliest messages, not the latest. |
@@ -360,8 +359,7 @@ discard block |
||
360 | 359 | } |
361 | 360 | if ($start - $max_amount >= 0) { |
362 | 361 | $thread['older_start'] = $start - $max_amount; |
363 | - } |
|
364 | - elseif ($start > 0) { |
|
362 | + } elseif ($start > 0) { |
|
365 | 363 | $thread['older_start'] = 0; |
366 | 364 | } |
367 | 365 | |
@@ -377,8 +375,7 @@ discard block |
||
377 | 375 | // Visual counts start from 1 instead of zero, so plus one. |
378 | 376 | $thread['from'] = $start + 1; |
379 | 377 | $conversation = db_query_range($query['query'], $start, $max_amount); |
380 | - } |
|
381 | - else { |
|
378 | + } else { |
|
382 | 379 | $conversation = db_query($query['query']); |
383 | 380 | } |
384 | 381 | $mids = array(); |
@@ -398,12 +395,10 @@ discard block |
||
398 | 395 | // Thread does not exist, display 404. |
399 | 396 | $thread = FALSE; |
400 | 397 | } |
401 | - } |
|
402 | - else { |
|
398 | + } else { |
|
403 | 399 | $thread = FALSE; |
404 | 400 | } |
405 | - } |
|
406 | - else { |
|
401 | + } else { |
|
407 | 402 | // General data, assume subject is the same for all messages of that thread. |
408 | 403 | $thread['user'] = $account; |
409 | 404 | $message = current($thread['messages']); |
@@ -689,8 +684,7 @@ discard block |
||
689 | 684 | // Trying to view someone else's messages... |
690 | 685 | if (!privatemsg_user_access('read all private messages')) { |
691 | 686 | drupal_set_message(t("You do not have sufficient rights to view someone else's messages"), 'warning'); |
692 | - } |
|
693 | - elseif ($account_check = user_load(array('uid' => $uid))) { |
|
687 | + } elseif ($account_check = user_load(array('uid' => $uid))) { |
|
694 | 688 | // Has rights and user_load return an array so user does exist |
695 | 689 | $account = $account_check; |
696 | 690 | } |
@@ -852,11 +846,9 @@ discard block |
||
852 | 846 | // convert recipients to array of user objects |
853 | 847 | if (!empty($recipients) && is_string($recipients) || is_int($recipients)) { |
854 | 848 | $recipients = _privatemsg_generate_user_array($recipients); |
855 | - } |
|
856 | - elseif (is_object($recipients)) { |
|
849 | + } elseif (is_object($recipients)) { |
|
857 | 850 | $recipients = array($recipients); |
858 | - } |
|
859 | - elseif (empty($recipients) && is_string($recipients)) { |
|
851 | + } elseif (empty($recipients) && is_string($recipients)) { |
|
860 | 852 | $recipients = array(); |
861 | 853 | } |
862 | 854 | |
@@ -881,8 +873,7 @@ discard block |
||
881 | 873 | $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name); |
882 | 874 | $to[] = $myname . "_" . $myuser->boincuser_id; |
883 | 875 | $to_themed[$recipient->uid] = $myname; |
884 | - } |
|
885 | - else { |
|
876 | + } else { |
|
886 | 877 | // Recipient list contains blocked users. |
887 | 878 | $blocked = TRUE; |
888 | 879 | } |
@@ -909,8 +900,7 @@ discard block |
||
909 | 900 | } |
910 | 901 | if (!$thread_id && !empty($recipients_string)) { |
911 | 902 | drupal_set_title(t('Write new message to %recipient', array('%recipient' => $recipients_string))); |
912 | - } |
|
913 | - elseif (!$thread_id) { |
|
903 | + } elseif (!$thread_id) { |
|
914 | 904 | drupal_set_title(t('Write new message')); |
915 | 905 | } |
916 | 906 | $form = array(); |
@@ -985,8 +975,7 @@ discard block |
||
985 | 975 | $title = t('Cancel'); |
986 | 976 | if (isset($_REQUEST['destination'])) { |
987 | 977 | $url = $_REQUEST['destination']; |
988 | - } |
|
989 | - elseif (!is_null($thread_id)) { |
|
978 | + } elseif (!is_null($thread_id)) { |
|
990 | 979 | $url = $_GET['q']; |
991 | 980 | $title = t('Clear'); |
992 | 981 | } |
@@ -1037,8 +1026,7 @@ discard block |
||
1037 | 1026 | // Only parse the user string for a new thread. |
1038 | 1027 | if (!isset($message['thread_id'])) { |
1039 | 1028 | list($message['recipients'], $invalid) = _privatemsg_parse_userstring($message['recipient']); |
1040 | - } |
|
1041 | - else { |
|
1029 | + } else { |
|
1042 | 1030 | // Load participants. |
1043 | 1031 | $message['recipients'] = _privatemsg_load_thread_participants($message['thread_id']); |
1044 | 1032 | // Remove author. |
@@ -1096,7 +1084,8 @@ discard block |
||
1096 | 1084 | $recipients = array(); |
1097 | 1085 | foreach ($input as $string) { |
1098 | 1086 | $string = trim($string); |
1099 | - if (!empty($string)) { // We don't care about white space names. |
|
1087 | + if (!empty($string)) { |
|
1088 | +// We don't care about white space names. |
|
1100 | 1089 | |
1101 | 1090 | // First, check if another module is able to resolve the string into an |
1102 | 1091 | // user object. |
@@ -1132,10 +1121,9 @@ discard block |
||
1132 | 1121 | foreach ($form_state['validate_built_message']['recipients'] as $recipient) { |
1133 | 1122 | $recipient_names[] = theme('username', $recipient); |
1134 | 1123 | } |
1135 | - if ($status !== FALSE ) { |
|
1124 | + if ($status !== FALSE ) { |
|
1136 | 1125 | drupal_set_message(t('A message has been sent to !recipients.', array('!recipients' => implode(', ', $recipient_names)))); |
1137 | - } |
|
1138 | - else { |
|
1126 | + } else { |
|
1139 | 1127 | drupal_set_message(t('An attempt to send a message <em>may have failed</em> when sending to !recipients.', array('!recipients' => implode(', ', $recipient_names))), 'error'); |
1140 | 1128 | } |
1141 | 1129 | } |
@@ -1196,8 +1184,7 @@ discard block |
||
1196 | 1184 | $fragments['select'][] = "array_to_string(array(SELECT DISTINCT textin(int4out(pmia.uid)) |
1197 | 1185 | FROM {pm_index} pmia |
1198 | 1186 | WHERE pmia.thread_id = pmi.thread_id), ',') AS participants"; |
1199 | - } |
|
1200 | - else { |
|
1187 | + } else { |
|
1201 | 1188 | $fragments['select'][] = '(SELECT GROUP_CONCAT(DISTINCT pmia.uid SEPARATOR ",") |
1202 | 1189 | FROM {pm_index} pmia |
1203 | 1190 | WHERE pmia.thread_id = pmi.thread_id) AS participants'; |
@@ -1502,8 +1489,7 @@ discard block |
||
1502 | 1489 | ); |
1503 | 1490 | |
1504 | 1491 | return $blocks; |
1505 | - } |
|
1506 | - elseif ('view' == $op) { |
|
1492 | + } elseif ('view' == $op) { |
|
1507 | 1493 | $block = array(); |
1508 | 1494 | switch ($delta) { |
1509 | 1495 | case 'privatemsg-menu': |
@@ -1599,8 +1585,7 @@ discard block |
||
1599 | 1585 | if (isset($form_state['values']['delete_options']) && $form_state['values']['delete_options']) { |
1600 | 1586 | privatemsg_message_change_delete($form_state['values']['pmid'], 1); |
1601 | 1587 | drupal_set_message(t('Message has been deleted for all users.')); |
1602 | - } |
|
1603 | - else { |
|
1588 | + } else { |
|
1604 | 1589 | privatemsg_message_change_delete($form_state['values']['pmid'], 1, $account); |
1605 | 1590 | drupal_set_message(t('Message has been deleted.')); |
1606 | 1591 | } |
@@ -1629,8 +1614,7 @@ discard block |
||
1629 | 1614 | |
1630 | 1615 | if ($account) { |
1631 | 1616 | db_query('UPDATE {pm_index} SET deleted = %d WHERE mid = %d AND uid = %d', $delete_value, $pmid, $account->uid); |
1632 | - } |
|
1633 | - else { |
|
1617 | + } else { |
|
1634 | 1618 | // Mark deleted for all users. |
1635 | 1619 | db_query('UPDATE {pm_index} SET deleted = %d WHERE mid = %d', $delete_value, $pmid); |
1636 | 1620 | } |
@@ -1791,8 +1775,7 @@ discard block |
||
1791 | 1775 | 'success' => FALSE, |
1792 | 1776 | 'messages' => $messages, |
1793 | 1777 | ); |
1794 | - } |
|
1795 | - else { |
|
1778 | + } else { |
|
1796 | 1779 | $messages['error'][] = t('User @user is not allowed to write messages', array('@user' => $message['author']->name)); |
1797 | 1780 | return array( |
1798 | 1781 | 'success' => FALSE, |
@@ -1806,8 +1789,7 @@ discard block |
||
1806 | 1789 | if (empty($message['subject'])) { |
1807 | 1790 | if ($form) { |
1808 | 1791 | form_set_error('subject', t('Disallowed to send a message without subject')); |
1809 | - } |
|
1810 | - else { |
|
1792 | + } else { |
|
1811 | 1793 | $messages['error'][] = t('Disallowed to send a message without subject'); |
1812 | 1794 | } |
1813 | 1795 | } |
@@ -1816,8 +1798,7 @@ discard block |
||
1816 | 1798 | if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '') ) { |
1817 | 1799 | if ($form) { |
1818 | 1800 | form_set_error('body', t('Disallowed to send reply without a message.')); |
1819 | - } |
|
1820 | - else { |
|
1801 | + } else { |
|
1821 | 1802 | $messages['error'][] = t('Disallowed to send reply without a message.'); |
1822 | 1803 | } |
1823 | 1804 | } |
@@ -1831,8 +1812,7 @@ discard block |
||
1831 | 1812 | if (!filter_access($message['format'])) { |
1832 | 1813 | if ($form) { |
1833 | 1814 | form_set_error('format', t('You are not allowed to use the specified input format.')); |
1834 | - } |
|
1835 | - else { |
|
1815 | + } else { |
|
1836 | 1816 | $messages['error'][] = t('User @user is not allowed to use the specified input format.', array('@user' => $message['author']->name)); |
1837 | 1817 | } |
1838 | 1818 | } |
@@ -1843,8 +1823,7 @@ discard block |
||
1843 | 1823 | if (empty($message['recipients']) || !is_array($message['recipients'])) { |
1844 | 1824 | if ($form) { |
1845 | 1825 | form_set_error('to', t('Disallowed to send a message without at least one valid recipient')); |
1846 | - } |
|
1847 | - else { |
|
1826 | + } else { |
|
1848 | 1827 | $messages['error'][] = t('Disallowed to send a message without at least one valid recipient'); |
1849 | 1828 | } |
1850 | 1829 | } |
@@ -1854,8 +1833,7 @@ discard block |
||
1854 | 1833 | unset($message['recipients'][$blocked['uid']]); |
1855 | 1834 | if ($form) { |
1856 | 1835 | drupal_set_message($blocked['message'], 'warning'); |
1857 | - } |
|
1858 | - else { |
|
1836 | + } else { |
|
1859 | 1837 | $messages['warning'][] = $blocked['message']; |
1860 | 1838 | } |
1861 | 1839 | } |
@@ -1865,8 +1843,7 @@ discard block |
||
1865 | 1843 | if (empty($message['recipients'])) { |
1866 | 1844 | if ($form) { |
1867 | 1845 | form_set_error('to', t('Disallowed to send message because all recipients are blocked')); |
1868 | - } |
|
1869 | - else { |
|
1846 | + } else { |
|
1870 | 1847 | $messages['error'][] = t('Disallowed to send message because all recipients are blocked'); |
1871 | 1848 | } |
1872 | 1849 | } |
@@ -2072,8 +2049,7 @@ discard block |
||
2072 | 2049 | if (is_array($query)) { |
2073 | 2050 | $query_id = $query[0]; |
2074 | 2051 | $query_group = $query[1]; |
2075 | - } |
|
2076 | - else { |
|
2052 | + } else { |
|
2077 | 2053 | $query_id = $query; |
2078 | 2054 | $query_group = 'privatemsg'; |
2079 | 2055 | } |
@@ -2153,8 +2129,7 @@ discard block |
||
2153 | 2129 | // Works fine for thread_id/list but may generate an error when a more complex GROUP BY is used. |
2154 | 2130 | $str_group_by_count = current($GROUP_BY); |
2155 | 2131 | $count = "SELECT COUNT(DISTINCT {$str_group_by_count}) FROM ". $primary_table; |
2156 | - } |
|
2157 | - else { |
|
2132 | + } else { |
|
2158 | 2133 | $count = "SELECT COUNT(*) FROM ". $primary_table; |
2159 | 2134 | } |
2160 | 2135 | |
@@ -2275,8 +2250,7 @@ discard block |
||
2275 | 2250 | |
2276 | 2251 | if ($status == PRIVATEMSG_UNREAD) { |
2277 | 2252 | drupal_set_message(format_plural(count($threads), 'Marked 1 thread as unread.', 'Marked @count threads as unread.')); |
2278 | - } |
|
2279 | - else { |
|
2253 | + } else { |
|
2280 | 2254 | drupal_set_message(format_plural(count($threads), 'Marked 1 thread as read.', 'Marked @count threads as read.')); |
2281 | 2255 | } |
2282 | 2256 | } |
@@ -2457,8 +2431,7 @@ discard block |
||
2457 | 2431 | // Add in callback arguments if present. |
2458 | 2432 | if (isset($operation['callback arguments'])) { |
2459 | 2433 | $args = array_merge(array($threads), $operation['callback arguments']); |
2460 | - } |
|
2461 | - else { |
|
2434 | + } else { |
|
2462 | 2435 | $args = array($threads); |
2463 | 2436 | } |
2464 | 2437 | |
@@ -2475,8 +2448,7 @@ discard block |
||
2475 | 2448 | // Add in callback arguments if present. |
2476 | 2449 | if (isset($operation['undo callback arguments'])) { |
2477 | 2450 | $undo_args = array_merge(array($threads), $operation['undo callback arguments']); |
2478 | - } |
|
2479 | - else { |
|
2451 | + } else { |
|
2480 | 2452 | $undo_args = array($threads); |
2481 | 2453 | } |
2482 | 2454 | |
@@ -2528,8 +2500,7 @@ discard block |
||
2528 | 2500 | |
2529 | 2501 | if ($delete) { |
2530 | 2502 | drupal_set_message(format_plural(count($threads), 'Deleted 1 thread.', 'Deleted @count threads.')); |
2531 | - } |
|
2532 | - else { |
|
2503 | + } else { |
|
2533 | 2504 | drupal_set_message(format_plural(count($threads), 'Restored 1 thread.', 'Restored @count threads.')); |
2534 | 2505 | } |
2535 | 2506 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @return |
42 | 42 | * Array with user objects. |
43 | 43 | */ |
44 | -function _privatemsg_generate_user_array($userstring, $slice = NULL) { |
|
44 | +function _privatemsg_generate_user_array($userstring, $slice = null) { |
|
45 | 45 | static $user_cache = array(); |
46 | 46 | |
47 | 47 | // Convert user uid list (uid1,uid2,uid3) into an array. If $slice is not NULL |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | * @return |
80 | 80 | * String with formated user objects, like user1, user2. |
81 | 81 | */ |
82 | -function _privatemsg_format_participants($part_array, $limit = NULL, $no_text = FALSE) { |
|
82 | +function _privatemsg_format_participants($part_array, $limit = null, $no_text = false) { |
|
83 | 83 | if (count($part_array) > 0) { |
84 | 84 | $to = array(); |
85 | - $limited = FALSE; |
|
85 | + $limited = false; |
|
86 | 86 | foreach ($part_array as $account) { |
87 | 87 | if (is_int($limit) && count($to) >= $limit) { |
88 | - $limited = TRUE; |
|
88 | + $limited = true; |
|
89 | 89 | break; |
90 | 90 | } |
91 | 91 | $to[] = theme('username', $account); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'title' => 'Read message', |
138 | 138 | // Set the third argument to TRUE so that we can show access denied instead |
139 | 139 | // of not found. |
140 | - 'load arguments' => array(NULL, NULL, TRUE), |
|
140 | + 'load arguments' => array(null, null, true), |
|
141 | 141 | 'page callback' => 'privatemsg_view', |
142 | 142 | 'page arguments' => array(2), |
143 | 143 | 'access callback' => 'privatemsg_view_access', |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $items['messages/new'] = array( |
157 | 157 | 'title' => 'Write new message', |
158 | 158 | 'page callback' => 'drupal_get_form', |
159 | - 'page arguments' => array('privatemsg_new', 2, 3, NULL), |
|
159 | + 'page arguments' => array('privatemsg_new', 2, 3, null), |
|
160 | 160 | 'access callback' => 'privatemsg_user_access', |
161 | 161 | 'access arguments' => array('write privatemsg'), |
162 | 162 | 'type' => MENU_LOCAL_TASK, |
@@ -219,18 +219,18 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @ingroup api |
221 | 221 | */ |
222 | -function privatemsg_user_access($permission = 'read privatemsg', $account = NULL) { |
|
223 | - if ( $account === NULL ) { |
|
222 | +function privatemsg_user_access($permission = 'read privatemsg', $account = null) { |
|
223 | + if ( $account === null ) { |
|
224 | 224 | global $user; |
225 | 225 | $account = $user; |
226 | 226 | } |
227 | 227 | if (!$account->uid) { // Disallow anonymous access, regardless of permissions |
228 | - return FALSE; |
|
228 | + return false; |
|
229 | 229 | } |
230 | 230 | if (!user_access($permission, $account)) { |
231 | - return FALSE; |
|
231 | + return false; |
|
232 | 232 | } |
233 | - return TRUE; |
|
233 | + return true; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -250,12 +250,12 @@ discard block |
||
250 | 250 | // Do not allow access to threads without messages. |
251 | 251 | if (empty($thread['messages'])) { |
252 | 252 | // Count all messages, if there |
253 | - return FALSE; |
|
253 | + return false; |
|
254 | 254 | } |
255 | 255 | if (privatemsg_user_access('read privatemsg') && arg(1) == 'view') { |
256 | - return TRUE; |
|
256 | + return true; |
|
257 | 257 | } |
258 | - return FALSE; |
|
258 | + return false; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | |
288 | 288 | * @ingroup api |
289 | 289 | */ |
290 | -function privatemsg_thread_load($thread_id, $account = NULL, $start = NULL, $useAccessDenied = FALSE) { |
|
290 | +function privatemsg_thread_load($thread_id, $account = null, $start = null, $useAccessDenied = false) { |
|
291 | 291 | static $threads = array(); |
292 | 292 | if ((int)$thread_id > 0) { |
293 | 293 | $thread = array('thread_id' => $thread_id); |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | while ($participant = db_fetch_object($participants)) { |
310 | 310 | $thread['participants'][$participant->uid] = $participant; |
311 | 311 | } |
312 | - $thread['read_all'] = FALSE; |
|
312 | + $thread['read_all'] = false; |
|
313 | 313 | if (!array_key_exists($account->uid, $thread['participants']) && privatemsg_user_access('read all private messages', $account)) { |
314 | - $thread['read_all'] = TRUE; |
|
314 | + $thread['read_all'] = true; |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | // Load messages returned by the messages query with privatemsg_message_load_multiple(). |
318 | - $query = _privatemsg_assemble_query('messages', array($thread_id), $thread['read_all'] ? NULL : $account); |
|
318 | + $query = _privatemsg_assemble_query('messages', array($thread_id), $thread['read_all'] ? null : $account); |
|
319 | 319 | $thread['message_count'] = $thread['to'] = db_result(db_query($query['count'])); |
320 | 320 | $thread['from'] = 1; |
321 | 321 | // Check if we need to limit the messages. |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | if (isset($_GET['start']) && $_GET['start'] < $thread['message_count']) { |
327 | 327 | $start = $_GET['start']; |
328 | 328 | } |
329 | - elseif (!variable_get('privatemsg_view_use_max_as_default', FALSE) && $max_amount == PRIVATEMSG_UNLIMITED) { |
|
329 | + elseif (!variable_get('privatemsg_view_use_max_as_default', false) && $max_amount == PRIVATEMSG_UNLIMITED) { |
|
330 | 330 | $start = PRIVATEMSG_UNLIMITED; |
331 | 331 | } |
332 | 332 | else { |
333 | - $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', FALSE) ? variable_get('privatemsg_view_default_amount', 10) : $max_amount); |
|
333 | + $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', false) ? variable_get('privatemsg_view_default_amount', 10) : $max_amount); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | // Calculate the number of messages on the "last" page to avoid |
344 | 344 | // message overlap. |
345 | 345 | // Note - the last page lists the earliest messages, not the latest. |
346 | - $paging_count = variable_get('privatemsg_view_use_max_as_default', FALSE) ? $thread['message_count'] - variable_get('privatemsg_view_default_amount', 10) : $thread['message_count']; |
|
346 | + $paging_count = variable_get('privatemsg_view_use_max_as_default', false) ? $thread['message_count'] - variable_get('privatemsg_view_default_amount', 10) : $thread['message_count']; |
|
347 | 347 | $last_page = $paging_count % $max_amount; |
348 | 348 | } |
349 | 349 | |
@@ -386,21 +386,21 @@ discard block |
||
386 | 386 | $mids[] = $result['mid']; |
387 | 387 | } |
388 | 388 | // Load messages returned by the messages query. |
389 | - $thread['messages'] = privatemsg_message_load_multiple($mids, $thread['read_all'] ? NULL : $account); |
|
389 | + $thread['messages'] = privatemsg_message_load_multiple($mids, $thread['read_all'] ? null : $account); |
|
390 | 390 | |
391 | 391 | // If there are no messages, don't allow access to the thread. |
392 | 392 | if (empty($thread['messages'])) { |
393 | 393 | if ($useAccessDenied) { |
394 | 394 | // Generate new query with read all to see if the thread does exist. |
395 | - $query = _privatemsg_assemble_query('messages', array($thread_id), NULL); |
|
395 | + $query = _privatemsg_assemble_query('messages', array($thread_id), null); |
|
396 | 396 | $exists = db_result(db_query($query['count'])); |
397 | 397 | if (!$exists) { |
398 | 398 | // Thread does not exist, display 404. |
399 | - $thread = FALSE; |
|
399 | + $thread = false; |
|
400 | 400 | } |
401 | 401 | } |
402 | 402 | else { |
403 | - $thread = FALSE; |
|
403 | + $thread = false; |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | else { |
@@ -414,7 +414,7 @@ discard block |
||
414 | 414 | |
415 | 415 | return $threads[$account->uid][$thread_id]; |
416 | 416 | } |
417 | - return FALSE; |
|
417 | + return false; |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | function private_message_view_options() { |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | |
446 | 446 | $form['theming_settings'] = array( |
447 | 447 | '#type' => 'fieldset', |
448 | - '#collapsible' => TRUE, |
|
449 | - '#collapsed' => TRUE, |
|
448 | + '#collapsible' => true, |
|
449 | + '#collapsed' => true, |
|
450 | 450 | '#title' => t('Theming settings'), |
451 | 451 | ); |
452 | 452 | $form['theming_settings']['private_message_view_template'] = array( |
@@ -458,14 +458,14 @@ discard block |
||
458 | 458 | $form['privatemsg_display_loginmessage'] = array( |
459 | 459 | '#type' => 'checkbox', |
460 | 460 | '#title' => t('Inform the user about new messages on login'), |
461 | - '#default_value' => variable_get('privatemsg_display_loginmessage', TRUE), |
|
461 | + '#default_value' => variable_get('privatemsg_display_loginmessage', true), |
|
462 | 462 | '#description' => t('This option can safely be disabled if the "New message indication" block is used instead.'), |
463 | 463 | ); |
464 | 464 | |
465 | 465 | $form['flush_deleted'] = array( |
466 | 466 | '#type' => 'fieldset', |
467 | - '#collapsible' => TRUE, |
|
468 | - '#collapsed' => TRUE, |
|
467 | + '#collapsible' => true, |
|
468 | + '#collapsed' => true, |
|
469 | 469 | '#title' => t('Flush deleted messages'), |
470 | 470 | '#description' => t('By default, deleted messages are only hidden from the user but still stored in the database. These settings control if and when messages should be removed.'), |
471 | 471 | ); |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | $form['flush_deleted']['privatemsg_flush_enabled'] = array( |
474 | 474 | '#type' => 'checkbox', |
475 | 475 | '#title' => t('Flush deleted messages'), |
476 | - '#default_value' => variable_get('privatemsg_flush_enabled', FALSE), |
|
476 | + '#default_value' => variable_get('privatemsg_flush_enabled', false), |
|
477 | 477 | '#description' => t('Enable the flushing of deleted messages. Requires that cron is enabled'), |
478 | 478 | ); |
479 | 479 | |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | $form['privatemsg_listing'] = array( |
495 | 495 | '#type' => 'fieldset', |
496 | 496 | '#title' => t('Configure listings'), |
497 | - '#collapsible' => TRUE, |
|
498 | - '#collapsed' => FALSE, |
|
497 | + '#collapsible' => true, |
|
498 | + '#collapsed' => false, |
|
499 | 499 | ); |
500 | 500 | |
501 | 501 | $form['privatemsg_listing']['privatemsg_per_page'] = array( |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | $form['privatemsg_listing']['privatemsg_view_use_max_as_default'] = array( |
532 | 532 | '#type' => 'checkbox', |
533 | 533 | '#title' => t('Display different amount of messages on first thread page'), |
534 | - '#default_value' => variable_get('privatemsg_view_use_max_as_default', FALSE), |
|
534 | + '#default_value' => variable_get('privatemsg_view_use_max_as_default', false), |
|
535 | 535 | '#description' => t('By default, the first thread page shows the maximally allowed amount of messages. Enable this checkbox to set a different value.'), |
536 | 536 | '#weight' => 15, |
537 | 537 | ); |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | * old enough are flushed. |
564 | 564 | */ |
565 | 565 | function privatemsg_cron() { |
566 | - if (variable_get('privatemsg_flush_enabled', FALSE)) { |
|
566 | + if (variable_get('privatemsg_flush_enabled', false)) { |
|
567 | 567 | $query = _privatemsg_assemble_query('deleted', variable_get('privatemsg_flush_days', 30)); |
568 | 568 | $result = db_query($query['query']); |
569 | 569 | |
@@ -584,19 +584,19 @@ discard block |
||
584 | 584 | function privatemsg_theme() { |
585 | 585 | return array( |
586 | 586 | 'privatemsg_view' => array( |
587 | - 'arguments' => array('message' => NULL), |
|
587 | + 'arguments' => array('message' => null), |
|
588 | 588 | 'template' => variable_get('private_message_view_template', 'privatemsg-view'), // 'privatemsg', |
589 | 589 | ), |
590 | 590 | 'privatemsg_from' => array( |
591 | - 'arguments' => array('author' => NULL), |
|
591 | + 'arguments' => array('author' => null), |
|
592 | 592 | 'template' => 'privatemsg-from', |
593 | 593 | ), |
594 | 594 | 'privatemsg_recipients' => array( |
595 | - 'arguments' => array('message' => NULL), |
|
595 | + 'arguments' => array('message' => null), |
|
596 | 596 | 'template' => 'privatemsg-recipients', |
597 | 597 | ), |
598 | 598 | 'privatemsg_between' => array( |
599 | - 'arguments' => array('recipients' => NULL), |
|
599 | + 'arguments' => array('recipients' => null), |
|
600 | 600 | 'template' => 'privatemsg-between', |
601 | 601 | ), |
602 | 602 | 'privatemsg_list' => array( |
@@ -630,15 +630,15 @@ discard block |
||
630 | 630 | // drupal_set_message('<pre>'. print_r($vars,1 ) . '</pre>'); |
631 | 631 | |
632 | 632 | $message = $vars['message']; |
633 | - $vars['mid'] = isset($message['mid']) ? $message['mid'] : NULL; |
|
634 | - $vars['thread_id'] = isset($message['thread_id']) ? $message['thread_id'] : NULL; |
|
633 | + $vars['mid'] = isset($message['mid']) ? $message['mid'] : null; |
|
634 | + $vars['thread_id'] = isset($message['thread_id']) ? $message['thread_id'] : null; |
|
635 | 635 | $vars['author_picture'] = theme('user_picture', $message['author']); |
636 | 636 | $vars['author_name_link'] = theme('username', $message['author']); |
637 | 637 | /** |
638 | 638 | * @todo perhaps make this timestamp configurable via admin UI? |
639 | 639 | */ |
640 | 640 | $vars['message_timestamp'] = format_date($message['timestamp'], 'small'); |
641 | - $vars['message_body'] = check_markup($message['body'], $message['format'], FALSE); |
|
641 | + $vars['message_body'] = check_markup($message['body'], $message['format'], false); |
|
642 | 642 | if (isset($vars['mid']) && isset($vars['thread_id']) && privatemsg_user_access('delete privatemsg')) { |
643 | 643 | $vars['message_actions'][] = array('title' => t('Delete message'), 'href' => 'messages/delete/' . $vars['thread_id'] . '/' . $vars['mid']); |
644 | 644 | } |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | * @return |
680 | 680 | * Form array |
681 | 681 | */ |
682 | -function privatemsg_list(&$form_state, $argument = 'list', $uid = NULL) { |
|
682 | +function privatemsg_list(&$form_state, $argument = 'list', $uid = null) { |
|
683 | 683 | global $user; |
684 | 684 | |
685 | 685 | // Setting default behavior... |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | * @param $account |
736 | 736 | * User object, defaults to the current user |
737 | 737 | */ |
738 | -function privatemsg_message_change_status($pmid, $status, $account = NULL) { |
|
738 | +function privatemsg_message_change_status($pmid, $status, $account = null) { |
|
739 | 739 | if (!$account) { |
740 | 740 | global $user; |
741 | 741 | $account = $user; |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | * |
753 | 753 | * @ingroup api |
754 | 754 | */ |
755 | -function privatemsg_unread_count($account = NULL) { |
|
755 | +function privatemsg_unread_count($account = null) { |
|
756 | 756 | static $counts = array(); |
757 | 757 | if (!$account || $account->uid == 0) { |
758 | 758 | global $user; |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | } |
844 | 844 | |
845 | 845 | |
846 | -function privatemsg_new(&$form_state, $recipients = array(), $subject = '', $thread_id = NULL, $read_all = FALSE) { |
|
846 | +function privatemsg_new(&$form_state, $recipients = array(), $subject = '', $thread_id = null, $read_all = false) { |
|
847 | 847 | global $user; |
848 | 848 | |
849 | 849 | $recipients_string = ''; |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | $usercount = 0; |
864 | 864 | $to = array(); |
865 | 865 | $to_themed = array(); |
866 | - $blocked = FALSE; |
|
866 | + $blocked = false; |
|
867 | 867 | foreach ($recipients as $recipient) { |
868 | 868 | if (in_array($recipient->name, $to)) { |
869 | 869 | // We already added the recipient to the list, skip him. |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | } |
885 | 885 | else { |
886 | 886 | // Recipient list contains blocked users. |
887 | - $blocked = TRUE; |
|
887 | + $blocked = true; |
|
888 | 888 | } |
889 | 889 | } |
890 | 890 | |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | '#title' => t('To'), |
938 | 938 | '#description' => t('Separate multiple names with a comma followed by one space. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'), |
939 | 939 | '#default_value' => $recipients_string, |
940 | - '#required' => TRUE, |
|
940 | + '#required' => true, |
|
941 | 941 | '#weight' => -10, |
942 | 942 | '#size' => 50, |
943 | 943 | '#autocomplete_path' => 'messages/user-name-autocomplete', |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | '#rows' => 6, |
959 | 959 | '#weight' => 0, |
960 | 960 | '#default_value' => $body, |
961 | - '#resizable' => TRUE, |
|
961 | + '#resizable' => true, |
|
962 | 962 | ); |
963 | 963 | $format = FILTER_FORMAT_DEFAULT; |
964 | 964 | // The input filter widget looses the format during preview, specify it |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | ); |
1013 | 1013 | if (empty($recipients_string)) { |
1014 | 1014 | // If there are no valid recipients, unset the message reply form. |
1015 | - $form['privatemsg']['#access'] = FALSE; |
|
1015 | + $form['privatemsg']['#access'] = false; |
|
1016 | 1016 | } |
1017 | 1017 | } |
1018 | 1018 | $form['privatemsg']['read_all'] = array( |
@@ -1030,7 +1030,7 @@ discard block |
||
1030 | 1030 | $message['subject'] = trim($message['subject']); |
1031 | 1031 | |
1032 | 1032 | |
1033 | - $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE)); |
|
1033 | + $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, true, true)); |
|
1034 | 1034 | if (empty($message['subject']) && !empty($trimed_body)) { |
1035 | 1035 | $message['subject'] = $trimed_body; |
1036 | 1036 | } |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | unset($message['recipients'][$message['author']->uid]); |
1047 | 1047 | } |
1048 | 1048 | } |
1049 | - $validated = _privatemsg_validate_message($message, TRUE); |
|
1049 | + $validated = _privatemsg_validate_message($message, true); |
|
1050 | 1050 | foreach ($validated['messages'] as $type => $text) { |
1051 | 1051 | drupal_set_message($text, $type); |
1052 | 1052 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | foreach ($form_state['validate_built_message']['recipients'] as $recipient) { |
1133 | 1133 | $recipient_names[] = theme('username', $recipient); |
1134 | 1134 | } |
1135 | - if ($status !== FALSE ) { |
|
1135 | + if ($status !== false ) { |
|
1136 | 1136 | drupal_set_message(t('A message has been sent to !recipients.', array('!recipients' => implode(', ', $recipient_names)))); |
1137 | 1137 | } |
1138 | 1138 | else { |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | $form_state['privatemsg_preview'] = theme('privatemsg_view', $form_state['validate_built_message']); |
1148 | 1148 | } |
1149 | 1149 | |
1150 | - $form_state['rebuild'] = TRUE; // this forces our form to be rebuilt instead of being submitted. |
|
1150 | + $form_state['rebuild'] = true; // this forces our form to be rebuilt instead of being submitted. |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | /** |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | // tablesort_sql() generates a ORDER BY string. However, the "ORDER BY " part |
1226 | 1226 | // is not needed and added by the query builder. Discard the first 9 |
1227 | 1227 | // characters of the string. |
1228 | - $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers( FALSE, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9); |
|
1228 | + $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers( false, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9); |
|
1229 | 1229 | $fragments['order_by'][] = $order_by; |
1230 | 1230 | } |
1231 | 1231 | |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | * @param $account |
1240 | 1240 | * Account for which the messages should be loaded. |
1241 | 1241 | */ |
1242 | -function privatemsg_sql_load(&$fragments, $pmids, $account = NULL) { |
|
1242 | +function privatemsg_sql_load(&$fragments, $pmids, $account = null) { |
|
1243 | 1243 | $fragments['primary_table'] = '{pm_message} pm'; |
1244 | 1244 | |
1245 | 1245 | $fragments['select'][] = "pm.mid"; |
@@ -1275,7 +1275,7 @@ discard block |
||
1275 | 1275 | * @param $load_all |
1276 | 1276 | * Deleted messages are only loaded if this is set to TRUE. |
1277 | 1277 | */ |
1278 | -function privatemsg_sql_messages(&$fragments, $threads, $account = NULL, $load_all = FALSE) { |
|
1278 | +function privatemsg_sql_messages(&$fragments, $threads, $account = null, $load_all = false) { |
|
1279 | 1279 | $fragments['primary_table'] = '{pm_index} pmi'; |
1280 | 1280 | |
1281 | 1281 | $fragments['select'][] = 'pmi.mid'; |
@@ -1445,7 +1445,7 @@ discard block |
||
1445 | 1445 | drupal_json((object)$matches); |
1446 | 1446 | } |
1447 | 1447 | |
1448 | -function privatemsg_user($op, &$edit, &$account, $category = NULL) { |
|
1448 | +function privatemsg_user($op, &$edit, &$account, $category = null) { |
|
1449 | 1449 | global $user; |
1450 | 1450 | |
1451 | 1451 | switch ($op) { |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | } |
1460 | 1460 | break; |
1461 | 1461 | case 'login': |
1462 | - if (variable_get('privatemsg_display_loginmessage', TRUE) && privatemsg_user_access()) { |
|
1462 | + if (variable_get('privatemsg_display_loginmessage', true) && privatemsg_user_access()) { |
|
1463 | 1463 | $count = privatemsg_unread_count(); |
1464 | 1464 | if ($count) { |
1465 | 1465 | drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages')))); |
@@ -1517,7 +1517,7 @@ discard block |
||
1517 | 1517 | } |
1518 | 1518 | } |
1519 | 1519 | |
1520 | -function privatemsg_title_callback($title = NULL) { |
|
1520 | +function privatemsg_title_callback($title = null) { |
|
1521 | 1521 | $count = privatemsg_unread_count(); |
1522 | 1522 | |
1523 | 1523 | if ($count > 0) { |
@@ -1579,7 +1579,7 @@ discard block |
||
1579 | 1579 | '#type' => 'checkbox', |
1580 | 1580 | '#title' => t('Delete this message for all users?'), |
1581 | 1581 | '#description' => t('Tick the box to delete the message for all users.'), |
1582 | - '#default_value' => FALSE, |
|
1582 | + '#default_value' => false, |
|
1583 | 1583 | ); |
1584 | 1584 | } |
1585 | 1585 | return confirm_form($form, |
@@ -1621,9 +1621,9 @@ discard block |
||
1621 | 1621 | * |
1622 | 1622 | * @ingroup api |
1623 | 1623 | */ |
1624 | -function privatemsg_message_change_delete($pmid, $delete, $account = NULL) { |
|
1624 | +function privatemsg_message_change_delete($pmid, $delete, $account = null) { |
|
1625 | 1625 | $delete_value = 0; |
1626 | - if ($delete == TRUE) { |
|
1626 | + if ($delete == true) { |
|
1627 | 1627 | $delete_value = time(); |
1628 | 1628 | } |
1629 | 1629 | |
@@ -1675,7 +1675,7 @@ discard block |
||
1675 | 1675 | * |
1676 | 1676 | * @ingroup api |
1677 | 1677 | */ |
1678 | -function privatemsg_new_thread($recipients, $subject, $body = NULL, $options = array()) { |
|
1678 | +function privatemsg_new_thread($recipients, $subject, $body = null, $options = array()) { |
|
1679 | 1679 | global $user; |
1680 | 1680 | $author = drupal_clone($user); |
1681 | 1681 | |
@@ -1781,21 +1781,21 @@ discard block |
||
1781 | 1781 | return $validated; |
1782 | 1782 | } |
1783 | 1783 | |
1784 | -function _privatemsg_validate_message(&$message, $form = FALSE) { |
|
1784 | +function _privatemsg_validate_message(&$message, $form = false) { |
|
1785 | 1785 | $messages = array('error' => array(), 'warning' => array()); |
1786 | 1786 | if (!privatemsg_user_access('write privatemsg', $message['author'])) { |
1787 | 1787 | // no need to do further checks in this case... |
1788 | 1788 | if ($form) { |
1789 | 1789 | form_set_error('author', t('User @user is not allowed to write messages', array('@user' => $message['author']->name))); |
1790 | 1790 | return array( |
1791 | - 'success' => FALSE, |
|
1791 | + 'success' => false, |
|
1792 | 1792 | 'messages' => $messages, |
1793 | 1793 | ); |
1794 | 1794 | } |
1795 | 1795 | else { |
1796 | 1796 | $messages['error'][] = t('User @user is not allowed to write messages', array('@user' => $message['author']->name)); |
1797 | 1797 | return array( |
1798 | - 'success' => FALSE, |
|
1798 | + 'success' => false, |
|
1799 | 1799 | 'messages' => $messages, |
1800 | 1800 | ); |
1801 | 1801 | } |
@@ -1813,7 +1813,7 @@ discard block |
||
1813 | 1813 | } |
1814 | 1814 | |
1815 | 1815 | // Don't allow replies without a body. |
1816 | - if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '') ) { |
|
1816 | + if (!empty($message['thread_id']) && ($message['body'] === null || $message['body'] === '') ) { |
|
1817 | 1817 | if ($form) { |
1818 | 1818 | form_set_error('body', t('Disallowed to send reply without a message.')); |
1819 | 1819 | } |
@@ -1825,7 +1825,7 @@ discard block |
||
1825 | 1825 | // it is not possible to do the check for a specific user. |
1826 | 1826 | global $user; |
1827 | 1827 | $original_user = drupal_clone($user); |
1828 | - session_save_session(FALSE); |
|
1828 | + session_save_session(false); |
|
1829 | 1829 | $user = $message['author']; |
1830 | 1830 | |
1831 | 1831 | if (!filter_access($message['format'])) { |
@@ -1838,7 +1838,7 @@ discard block |
||
1838 | 1838 | } |
1839 | 1839 | |
1840 | 1840 | $user = $original_user; |
1841 | - session_save_session(TRUE); |
|
1841 | + session_save_session(true); |
|
1842 | 1842 | |
1843 | 1843 | if (empty($message['recipients']) || !is_array($message['recipients'])) { |
1844 | 1844 | if ($form) { |
@@ -1900,11 +1900,11 @@ discard block |
||
1900 | 1900 | if (isset($message['read_all']) && $message['read_all']) { |
1901 | 1901 | // The message was sent in read all mode, add the author as recipient to all |
1902 | 1902 | // existing messages. |
1903 | - $query_messages = _privatemsg_assemble_query('messages', array($message['thread_id']), NULL); |
|
1903 | + $query_messages = _privatemsg_assemble_query('messages', array($message['thread_id']), null); |
|
1904 | 1904 | $conversation = db_query($query_messages['query']); |
1905 | 1905 | while ($result = db_fetch_array($conversation)) { |
1906 | 1906 | if (!db_query($index_sql, $result['mid'], $message['thread_id'], $message['author']->uid, 0)) { |
1907 | - return FALSE; |
|
1907 | + return false; |
|
1908 | 1908 | } |
1909 | 1909 | } |
1910 | 1910 | } |
@@ -1932,7 +1932,7 @@ discard block |
||
1932 | 1932 | if (!db_query($index_sql, $mid, $message['thread_id'], $recipient->uid, 1) ) { |
1933 | 1933 | // We assume if one insert failed then the rest may fail too against the |
1934 | 1934 | // same table. |
1935 | - return FALSE; |
|
1935 | + return false; |
|
1936 | 1936 | } |
1937 | 1937 | } |
1938 | 1938 | |
@@ -1942,7 +1942,7 @@ discard block |
||
1942 | 1942 | |
1943 | 1943 | // Also add a record for the author to the pm_index table. |
1944 | 1944 | if (!db_query($index_sql, $mid, $message['thread_id'], $message['author']->uid, $is_new)) { |
1945 | - return FALSE; |
|
1945 | + return false; |
|
1946 | 1946 | } |
1947 | 1947 | |
1948 | 1948 | module_invoke_all('privatemsg_message_insert', $message); |
@@ -1967,8 +1967,8 @@ discard block |
||
1967 | 1967 | * |
1968 | 1968 | * @ingroup api |
1969 | 1969 | */ |
1970 | -function privatemsg_get_link($recipients, $account = array(), $subject = NULL) { |
|
1971 | - if ($account == NULL) { |
|
1970 | +function privatemsg_get_link($recipients, $account = array(), $subject = null) { |
|
1971 | + if ($account == null) { |
|
1972 | 1972 | global $user; |
1973 | 1973 | $account = $user; |
1974 | 1974 | } |
@@ -1978,7 +1978,7 @@ discard block |
||
1978 | 1978 | } |
1979 | 1979 | |
1980 | 1980 | if (!privatemsg_user_access('write privatemsg', $account) || $account->uid == 0) { |
1981 | - return FALSE; |
|
1981 | + return false; |
|
1982 | 1982 | } |
1983 | 1983 | |
1984 | 1984 | $validated = array(); |
@@ -1992,7 +1992,7 @@ discard block |
||
1992 | 1992 | $validated[] = $recipient->uid; |
1993 | 1993 | } |
1994 | 1994 | if (empty($validated)) { |
1995 | - return FALSE; |
|
1995 | + return false; |
|
1996 | 1996 | } |
1997 | 1997 | $url = 'messages/new/'. implode(',', $validated); |
1998 | 1998 | if (!is_null($subject)) { |
@@ -2012,7 +2012,7 @@ discard block |
||
2012 | 2012 | * |
2013 | 2013 | * @ingroup api |
2014 | 2014 | */ |
2015 | -function privatemsg_message_load($pmid, $account = NULL) { |
|
2015 | +function privatemsg_message_load($pmid, $account = null) { |
|
2016 | 2016 | $messages = privatemsg_message_load_multiple(array($pmid), $account); |
2017 | 2017 | return current($messages); |
2018 | 2018 | } |
@@ -2028,7 +2028,7 @@ discard block |
||
2028 | 2028 | * |
2029 | 2029 | * @ingroup api |
2030 | 2030 | */ |
2031 | -function privatemsg_message_load_multiple($pmids, $account = NULL) { |
|
2031 | +function privatemsg_message_load_multiple($pmids, $account = null) { |
|
2032 | 2032 | // Avoid SQL error that would happen with an empty pm.mid IN () clause. |
2033 | 2033 | if (empty($pmids)) { |
2034 | 2034 | return array(); |
@@ -2115,7 +2115,7 @@ discard block |
||
2115 | 2115 | */ |
2116 | 2116 | if (!function_exists($query_function)) { |
2117 | 2117 | drupal_set_message(t('Query function %function does not exist', array('%function' => $query_function)), 'error'); |
2118 | - return FALSE; |
|
2118 | + return false; |
|
2119 | 2119 | } |
2120 | 2120 | call_user_func_array($query_function, $alterargs); |
2121 | 2121 | |
@@ -2143,7 +2143,7 @@ discard block |
||
2143 | 2143 | // Perform the whole query assembly only if we have something to select. |
2144 | 2144 | if (!empty($SELECT)) { |
2145 | 2145 | $str_select = implode(", ", $SELECT); |
2146 | - $query = "SELECT {$str_select} FROM ". $primary_table; |
|
2146 | + $query = "select {$str_select} FROM ". $primary_table; |
|
2147 | 2147 | |
2148 | 2148 | // Also build a count query which can be passed to pager_query to get a "page count" as that does not play well with queries including "GROUP BY". |
2149 | 2149 | // In most cases, "COUNT(*)" is enough to get the count query, but in queries involving a GROUP BY, we want a count of the number of groups we have, not the count of elements inside each group. |
@@ -2186,14 +2186,14 @@ discard block |
||
2186 | 2186 | } |
2187 | 2187 | $QUERY_ARGS = array_merge($QUERY_ARGS['select'], $QUERY_ARGS['join'], $QUERY_ARGS['where'], $QUERY_ARGS['having']); |
2188 | 2188 | if (!empty($QUERY_ARGS)) { |
2189 | - _db_query_callback($QUERY_ARGS, TRUE); |
|
2189 | + _db_query_callback($QUERY_ARGS, true); |
|
2190 | 2190 | $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); |
2191 | - _db_query_callback($QUERY_ARGS, TRUE); |
|
2191 | + _db_query_callback($QUERY_ARGS, true); |
|
2192 | 2192 | $count = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $count); |
2193 | 2193 | } |
2194 | 2194 | return array('query' => $query, 'count' => $count); |
2195 | 2195 | } |
2196 | - return FALSE; |
|
2196 | + return false; |
|
2197 | 2197 | } |
2198 | 2198 | |
2199 | 2199 | /** |
@@ -2215,8 +2215,8 @@ discard block |
||
2215 | 2215 | '#title' => t('Actions'), |
2216 | 2216 | '#prefix' => '<div class="container-inline">', |
2217 | 2217 | '#suffix' => '</div>', |
2218 | - '#collapsible' => TRUE, |
|
2219 | - '#collapsed' => FALSE, |
|
2218 | + '#collapsible' => true, |
|
2219 | + '#collapsed' => false, |
|
2220 | 2220 | '#weight' => 15, |
2221 | 2221 | ); |
2222 | 2222 | if (privatemsg_user_access('delete privatemsg')) { |
@@ -2261,7 +2261,7 @@ discard block |
||
2261 | 2261 | * User object for which the threads should be deleted, defaults to the |
2262 | 2262 | * current user. |
2263 | 2263 | */ |
2264 | -function privatemsg_thread_change_status($threads, $status, $account = NULL) { |
|
2264 | +function privatemsg_thread_change_status($threads, $status, $account = null) { |
|
2265 | 2265 | if (!is_array($threads)) { |
2266 | 2266 | $threads = array($threads); |
2267 | 2267 | } |
@@ -2505,7 +2505,7 @@ discard block |
||
2505 | 2505 | * User object for which the threads should be deleted, |
2506 | 2506 | * defaults to the current user. |
2507 | 2507 | */ |
2508 | -function privatemsg_thread_change_delete($threads, $delete, $account = NULL) { |
|
2508 | +function privatemsg_thread_change_delete($threads, $delete, $account = null) { |
|
2509 | 2509 | if (!is_array($threads)) { |
2510 | 2510 | $threads = array($threads); |
2511 | 2511 | } |
@@ -2518,7 +2518,7 @@ discard block |
||
2518 | 2518 | $params = array_merge(array($delete, $account->uid), $threads); |
2519 | 2519 | |
2520 | 2520 | // Load all messages of those threads including the deleted. |
2521 | - $query = _privatemsg_assemble_query('messages', $threads, $account, TRUE); |
|
2521 | + $query = _privatemsg_assemble_query('messages', $threads, $account, true); |
|
2522 | 2522 | $result = db_query($query['query']); |
2523 | 2523 | |
2524 | 2524 | // Delete each message. We need to do that to trigger the delete hook. |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | * Implements hook_perm(). |
23 | 23 | */ |
24 | 24 | function privatemsg_perm() { |
25 | - return array( |
|
25 | + return array( |
|
26 | 26 | 'read privatemsg', |
27 | 27 | 'read all private messages', |
28 | 28 | 'administer privatemsg settings', |
29 | 29 | 'write privatemsg', |
30 | 30 | 'delete privatemsg', |
31 | - ); |
|
31 | + ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -42,27 +42,27 @@ discard block |
||
42 | 42 | * Array with user objects. |
43 | 43 | */ |
44 | 44 | function _privatemsg_generate_user_array($userstring, $slice = NULL) { |
45 | - static $user_cache = array(); |
|
46 | - |
|
47 | - // Convert user uid list (uid1,uid2,uid3) into an array. If $slice is not NULL |
|
48 | - // pass that as argument to array_slice(). For example, -4 will only load the |
|
49 | - // last four users. |
|
50 | - // This is done to avoid loading user objects that are not displayed, for |
|
51 | - // obvious performance reasons. |
|
52 | - $users = explode(',', $userstring); |
|
53 | - if (!is_null($slice)) { |
|
45 | + static $user_cache = array(); |
|
46 | + |
|
47 | + // Convert user uid list (uid1,uid2,uid3) into an array. If $slice is not NULL |
|
48 | + // pass that as argument to array_slice(). For example, -4 will only load the |
|
49 | + // last four users. |
|
50 | + // This is done to avoid loading user objects that are not displayed, for |
|
51 | + // obvious performance reasons. |
|
52 | + $users = explode(',', $userstring); |
|
53 | + if (!is_null($slice)) { |
|
54 | 54 | $users = array_slice($users, $slice); |
55 | - } |
|
56 | - $participants = array(); |
|
57 | - foreach ($users as $uid) { |
|
55 | + } |
|
56 | + $participants = array(); |
|
57 | + foreach ($users as $uid) { |
|
58 | 58 | if (!array_key_exists($uid, $user_cache)) { |
59 | - $user_cache[$uid] = user_load($uid); |
|
59 | + $user_cache[$uid] = user_load($uid); |
|
60 | 60 | } |
61 | 61 | if (is_object($user_cache[$uid])) { |
62 | - $participants[$uid] = $user_cache[$uid]; |
|
62 | + $participants[$uid] = $user_cache[$uid]; |
|
63 | + } |
|
63 | 64 | } |
64 | - } |
|
65 | - return $participants; |
|
65 | + return $participants; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -80,60 +80,60 @@ discard block |
||
80 | 80 | * String with formated user objects, like user1, user2. |
81 | 81 | */ |
82 | 82 | function _privatemsg_format_participants($part_array, $limit = NULL, $no_text = FALSE) { |
83 | - if (count($part_array) > 0) { |
|
83 | + if (count($part_array) > 0) { |
|
84 | 84 | $to = array(); |
85 | 85 | $limited = FALSE; |
86 | 86 | foreach ($part_array as $account) { |
87 | - if (is_int($limit) && count($to) >= $limit) { |
|
87 | + if (is_int($limit) && count($to) >= $limit) { |
|
88 | 88 | $limited = TRUE; |
89 | 89 | break; |
90 | - } |
|
91 | - $to[] = theme('username', $account); |
|
90 | + } |
|
91 | + $to[] = theme('username', $account); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | $limit_string = ''; |
95 | 95 | if ($limited) { |
96 | - $limit_string = t(' and others'); |
|
96 | + $limit_string = t(' and others'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
100 | 100 | if ($no_text) { |
101 | - return implode(', ', $to) . $limit_string; |
|
101 | + return implode(', ', $to) . $limit_string; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $last = array_pop($to); |
105 | 105 | if (count($to) == 0) { // Only one participant |
106 | - return t("From !last", array('!last' => $last)); |
|
106 | + return t("From !last", array('!last' => $last)); |
|
107 | 107 | } |
108 | 108 | else { // Multipe participants.. |
109 | - $participants = implode(', ', $to); |
|
110 | - return t('Participants: !participants and !last', array('!participants' => $participants, '!last' => $last)); |
|
109 | + $participants = implode(', ', $to); |
|
110 | + return t('Participants: !participants and !last', array('!participants' => $participants, '!last' => $last)); |
|
111 | + } |
|
111 | 112 | } |
112 | - } |
|
113 | - return ''; |
|
113 | + return ''; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | 117 | * Implements hook_menu(). |
118 | 118 | */ |
119 | 119 | function privatemsg_menu() { |
120 | - $items['messages'] = array( |
|
120 | + $items['messages'] = array( |
|
121 | 121 | 'title' => 'Messages', |
122 | 122 | 'title callback' => 'privatemsg_title_callback', |
123 | 123 | 'page callback' => 'drupal_get_form', |
124 | 124 | 'page arguments' => array('privatemsg_list', 'list'), |
125 | 125 | 'access callback' => 'privatemsg_user_access', |
126 | 126 | 'type' => MENU_NORMAL_ITEM, |
127 | - ); |
|
128 | - $items['messages/list'] = array( |
|
127 | + ); |
|
128 | + $items['messages/list'] = array( |
|
129 | 129 | 'title' => 'Messages', |
130 | 130 | 'page callback' => 'drupal_get_form', |
131 | 131 | 'page arguments' => array('privatemsg_list', 'list'), |
132 | 132 | 'access callback' => 'privatemsg_user_access', |
133 | 133 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
134 | 134 | 'weight' => -10, |
135 | - ); |
|
136 | - $items['messages/view/%privatemsg_thread'] = array( |
|
135 | + ); |
|
136 | + $items['messages/view/%privatemsg_thread'] = array( |
|
137 | 137 | 'title' => 'Read message', |
138 | 138 | // Set the third argument to TRUE so that we can show access denied instead |
139 | 139 | // of not found. |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | 'access arguments' => array(2), |
145 | 145 | 'type' => MENU_LOCAL_TASK, |
146 | 146 | 'weight' => -5, |
147 | - ); |
|
148 | - $items['messages/delete/%privatemsg_thread/%privatemsg_message'] = array( |
|
147 | + ); |
|
148 | + $items['messages/delete/%privatemsg_thread/%privatemsg_message'] = array( |
|
149 | 149 | 'title' => 'Delete message', |
150 | 150 | 'page callback' => 'drupal_get_form', |
151 | 151 | 'page arguments' => array('privatemsg_delete', 2, 3), |
152 | 152 | 'access callback' => 'privatemsg_user_access', |
153 | 153 | 'access arguments' => array('delete privatemsg'), |
154 | 154 | 'type' => MENU_CALLBACK, |
155 | - ); |
|
156 | - $items['messages/new'] = array( |
|
155 | + ); |
|
156 | + $items['messages/new'] = array( |
|
157 | 157 | 'title' => 'Write new message', |
158 | 158 | 'page callback' => 'drupal_get_form', |
159 | 159 | 'page arguments' => array('privatemsg_new', 2, 3, NULL), |
@@ -161,24 +161,24 @@ discard block |
||
161 | 161 | 'access arguments' => array('write privatemsg'), |
162 | 162 | 'type' => MENU_LOCAL_TASK, |
163 | 163 | 'weight' => -3, |
164 | - ); |
|
165 | - // Auto-completes available user names & removes duplicates. |
|
166 | - $items['messages/user-name-autocomplete'] = array( |
|
164 | + ); |
|
165 | + // Auto-completes available user names & removes duplicates. |
|
166 | + $items['messages/user-name-autocomplete'] = array( |
|
167 | 167 | 'page callback' => 'privatemsg_user_name_autocomplete', |
168 | 168 | 'access callback' => 'privatemsg_user_access', |
169 | 169 | 'access arguments' => array('write privatemsg'), |
170 | 170 | 'type' => MENU_CALLBACK, |
171 | 171 | 'weight' => -10, |
172 | - ); |
|
173 | - $items['admin/settings/messages'] = array( |
|
172 | + ); |
|
173 | + $items['admin/settings/messages'] = array( |
|
174 | 174 | 'title' => 'Private messages', |
175 | 175 | 'description' => 'Configure private messaging settings.', |
176 | 176 | 'page callback' => 'drupal_get_form', |
177 | 177 | 'page arguments' => array('private_message_settings'), |
178 | 178 | 'access arguments' => array('administer privatemsg settings'), |
179 | 179 | 'type' => MENU_NORMAL_ITEM, |
180 | - ); |
|
181 | - $items['admin/settings/messages/default'] = array( |
|
180 | + ); |
|
181 | + $items['admin/settings/messages/default'] = array( |
|
182 | 182 | 'title' => 'Private messages', |
183 | 183 | 'description' => 'Configure private messaging settings.', |
184 | 184 | 'page callback' => 'drupal_get_form', |
@@ -186,24 +186,24 @@ discard block |
||
186 | 186 | 'access arguments' => array('administer privatemsg settings'), |
187 | 187 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
188 | 188 | 'weight' => -10, |
189 | - ); |
|
190 | - $items['messages/undo/action'] = array( |
|
189 | + ); |
|
190 | + $items['messages/undo/action'] = array( |
|
191 | 191 | 'title' => 'Private messages', |
192 | 192 | 'description' => 'Undo last thread action', |
193 | 193 | 'page callback' => 'privatemsg_undo_action', |
194 | 194 | 'access arguments' => array('read privatemsg'), |
195 | 195 | 'type' => MENU_CALLBACK, |
196 | - ); |
|
197 | - $items['user/%/messages'] = array( |
|
196 | + ); |
|
197 | + $items['user/%/messages'] = array( |
|
198 | 198 | 'title' => 'Messages', |
199 | 199 | 'page callback' => 'drupal_get_form', |
200 | 200 | 'page arguments' => array('privatemsg_list', 'list', 1), |
201 | 201 | 'access callback' => 'privatemsg_user_access', |
202 | 202 | 'access arguments' => array('read all private messages'), |
203 | 203 | 'type' => MENU_LOCAL_TASK, |
204 | - ); |
|
204 | + ); |
|
205 | 205 | |
206 | - return $items; |
|
206 | + return $items; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -220,17 +220,17 @@ discard block |
||
220 | 220 | * @ingroup api |
221 | 221 | */ |
222 | 222 | function privatemsg_user_access($permission = 'read privatemsg', $account = NULL) { |
223 | - if ( $account === NULL ) { |
|
223 | + if ( $account === NULL ) { |
|
224 | 224 | global $user; |
225 | 225 | $account = $user; |
226 | - } |
|
227 | - if (!$account->uid) { // Disallow anonymous access, regardless of permissions |
|
226 | + } |
|
227 | + if (!$account->uid) { // Disallow anonymous access, regardless of permissions |
|
228 | 228 | return FALSE; |
229 | - } |
|
230 | - if (!user_access($permission, $account)) { |
|
229 | + } |
|
230 | + if (!user_access($permission, $account)) { |
|
231 | 231 | return FALSE; |
232 | - } |
|
233 | - return TRUE; |
|
232 | + } |
|
233 | + return TRUE; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -247,15 +247,15 @@ discard block |
||
247 | 247 | * @ingroup api |
248 | 248 | */ |
249 | 249 | function privatemsg_view_access($thread = array()) { |
250 | - // Do not allow access to threads without messages. |
|
251 | - if (empty($thread['messages'])) { |
|
250 | + // Do not allow access to threads without messages. |
|
251 | + if (empty($thread['messages'])) { |
|
252 | 252 | // Count all messages, if there |
253 | 253 | return FALSE; |
254 | - } |
|
255 | - if (privatemsg_user_access('read privatemsg') && arg(1) == 'view') { |
|
254 | + } |
|
255 | + if (privatemsg_user_access('read privatemsg') && arg(1) == 'view') { |
|
256 | 256 | return TRUE; |
257 | - } |
|
258 | - return FALSE; |
|
257 | + } |
|
258 | + return FALSE; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -284,142 +284,141 @@ discard block |
||
284 | 284 | * |
285 | 285 | * If no messages are found, or the thread_id is invalid, the function returns |
286 | 286 | * FALSE. |
287 | - |
|
288 | 287 | * @ingroup api |
289 | 288 | */ |
290 | 289 | function privatemsg_thread_load($thread_id, $account = NULL, $start = NULL, $useAccessDenied = FALSE) { |
291 | - static $threads = array(); |
|
292 | - if ((int)$thread_id > 0) { |
|
290 | + static $threads = array(); |
|
291 | + if ((int)$thread_id > 0) { |
|
293 | 292 | $thread = array('thread_id' => $thread_id); |
294 | 293 | |
295 | 294 | if (is_null($account)) { |
296 | - global $user; |
|
297 | - $account = drupal_clone($user); |
|
295 | + global $user; |
|
296 | + $account = drupal_clone($user); |
|
298 | 297 | } |
299 | 298 | |
300 | 299 | if (!isset($threads[$account->uid])) { |
301 | - $threads[$account->uid] = array(); |
|
300 | + $threads[$account->uid] = array(); |
|
302 | 301 | } |
303 | 302 | |
304 | 303 | if (!array_key_exists($thread_id, $threads[$account->uid])) { |
305 | - // Load the list of participants. |
|
306 | - $query = _privatemsg_assemble_query('participants', $thread_id); |
|
307 | - $participants = db_query($query['query']); |
|
308 | - $thread['participants'] = array(); |
|
309 | - while ($participant = db_fetch_object($participants)) { |
|
304 | + // Load the list of participants. |
|
305 | + $query = _privatemsg_assemble_query('participants', $thread_id); |
|
306 | + $participants = db_query($query['query']); |
|
307 | + $thread['participants'] = array(); |
|
308 | + while ($participant = db_fetch_object($participants)) { |
|
310 | 309 | $thread['participants'][$participant->uid] = $participant; |
311 | - } |
|
312 | - $thread['read_all'] = FALSE; |
|
313 | - if (!array_key_exists($account->uid, $thread['participants']) && privatemsg_user_access('read all private messages', $account)) { |
|
310 | + } |
|
311 | + $thread['read_all'] = FALSE; |
|
312 | + if (!array_key_exists($account->uid, $thread['participants']) && privatemsg_user_access('read all private messages', $account)) { |
|
314 | 313 | $thread['read_all'] = TRUE; |
315 | - } |
|
314 | + } |
|
316 | 315 | |
317 | - // Load messages returned by the messages query with privatemsg_message_load_multiple(). |
|
318 | - $query = _privatemsg_assemble_query('messages', array($thread_id), $thread['read_all'] ? NULL : $account); |
|
319 | - $thread['message_count'] = $thread['to'] = db_result(db_query($query['count'])); |
|
320 | - $thread['from'] = 1; |
|
321 | - // Check if we need to limit the messages. |
|
322 | - $max_amount = variable_get('privatemsg_view_max_amount', 20); |
|
316 | + // Load messages returned by the messages query with privatemsg_message_load_multiple(). |
|
317 | + $query = _privatemsg_assemble_query('messages', array($thread_id), $thread['read_all'] ? NULL : $account); |
|
318 | + $thread['message_count'] = $thread['to'] = db_result(db_query($query['count'])); |
|
319 | + $thread['from'] = 1; |
|
320 | + // Check if we need to limit the messages. |
|
321 | + $max_amount = variable_get('privatemsg_view_max_amount', 20); |
|
323 | 322 | |
324 | - // If there is no start value, select based on get params. |
|
325 | - if (is_null($start)) { |
|
323 | + // If there is no start value, select based on get params. |
|
324 | + if (is_null($start)) { |
|
326 | 325 | if (isset($_GET['start']) && $_GET['start'] < $thread['message_count']) { |
327 | - $start = $_GET['start']; |
|
326 | + $start = $_GET['start']; |
|
328 | 327 | } |
329 | 328 | elseif (!variable_get('privatemsg_view_use_max_as_default', FALSE) && $max_amount == PRIVATEMSG_UNLIMITED) { |
330 | - $start = PRIVATEMSG_UNLIMITED; |
|
329 | + $start = PRIVATEMSG_UNLIMITED; |
|
331 | 330 | } |
332 | 331 | else { |
333 | - $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', FALSE) ? variable_get('privatemsg_view_default_amount', 10) : $max_amount); |
|
332 | + $start = $thread['message_count'] - (variable_get('privatemsg_view_use_max_as_default', FALSE) ? variable_get('privatemsg_view_default_amount', 10) : $max_amount); |
|
333 | + } |
|
334 | 334 | } |
335 | - } |
|
336 | 335 | |
337 | - if ($start != PRIVATEMSG_UNLIMITED) { |
|
336 | + if ($start != PRIVATEMSG_UNLIMITED) { |
|
338 | 337 | if ($max_amount == PRIVATEMSG_UNLIMITED) { |
339 | - $last_page = 0; |
|
340 | - $max_amount = $thread['message_count']; |
|
338 | + $last_page = 0; |
|
339 | + $max_amount = $thread['message_count']; |
|
341 | 340 | } |
342 | 341 | else { |
343 | - // Calculate the number of messages on the "last" page to avoid |
|
344 | - // message overlap. |
|
345 | - // Note - the last page lists the earliest messages, not the latest. |
|
346 | - $paging_count = variable_get('privatemsg_view_use_max_as_default', FALSE) ? $thread['message_count'] - variable_get('privatemsg_view_default_amount', 10) : $thread['message_count']; |
|
347 | - $last_page = $paging_count % $max_amount; |
|
342 | + // Calculate the number of messages on the "last" page to avoid |
|
343 | + // message overlap. |
|
344 | + // Note - the last page lists the earliest messages, not the latest. |
|
345 | + $paging_count = variable_get('privatemsg_view_use_max_as_default', FALSE) ? $thread['message_count'] - variable_get('privatemsg_view_default_amount', 10) : $thread['message_count']; |
|
346 | + $last_page = $paging_count % $max_amount; |
|
348 | 347 | } |
349 | 348 | |
350 | 349 | // Sanity check - we cannot start from a negative number. |
351 | 350 | if ($start < 0) { |
352 | - $start = 0; |
|
351 | + $start = 0; |
|
353 | 352 | } |
354 | 353 | $thread['start'] = $start; |
355 | 354 | |
356 | 355 | //If there are newer messages on the page, show pager link allowing to go to the newer messages. |
357 | 356 | if (($start + $max_amount + 1) < $thread['message_count']) { |
358 | - $thread['to'] = $start + $max_amount; |
|
359 | - $thread['newer_start'] = $start + $max_amount; |
|
357 | + $thread['to'] = $start + $max_amount; |
|
358 | + $thread['newer_start'] = $start + $max_amount; |
|
360 | 359 | } |
361 | 360 | if ($start - $max_amount >= 0) { |
362 | - $thread['older_start'] = $start - $max_amount; |
|
361 | + $thread['older_start'] = $start - $max_amount; |
|
363 | 362 | } |
364 | 363 | elseif ($start > 0) { |
365 | - $thread['older_start'] = 0; |
|
364 | + $thread['older_start'] = 0; |
|
366 | 365 | } |
367 | 366 | |
368 | 367 | // Do not show messages on the last page that would show on the page |
369 | 368 | // before. This will only work when using the visual pager. |
370 | 369 | if ($start < $last_page && $max_amount != PRIVATEMSG_UNLIMITED && $max_amount < $thread['message_count']) { |
371 | - unset($thread['older_start']); |
|
372 | - $thread['to'] = $thread['newer_start'] = $max_amount = $last_page; |
|
373 | - // Start from the first message - this is a specific hack to make sure |
|
374 | - // the message display has sane paging on the last page. |
|
375 | - $start = 0; |
|
370 | + unset($thread['older_start']); |
|
371 | + $thread['to'] = $thread['newer_start'] = $max_amount = $last_page; |
|
372 | + // Start from the first message - this is a specific hack to make sure |
|
373 | + // the message display has sane paging on the last page. |
|
374 | + $start = 0; |
|
376 | 375 | } |
377 | 376 | // Visual counts start from 1 instead of zero, so plus one. |
378 | 377 | $thread['from'] = $start + 1; |
379 | 378 | $conversation = db_query_range($query['query'], $start, $max_amount); |
380 | - } |
|
381 | - else { |
|
379 | + } |
|
380 | + else { |
|
382 | 381 | $conversation = db_query($query['query']); |
383 | - } |
|
384 | - $mids = array(); |
|
385 | - while ($result = db_fetch_array($conversation)) { |
|
382 | + } |
|
383 | + $mids = array(); |
|
384 | + while ($result = db_fetch_array($conversation)) { |
|
386 | 385 | $mids[] = $result['mid']; |
387 | - } |
|
388 | - // Load messages returned by the messages query. |
|
389 | - $thread['messages'] = privatemsg_message_load_multiple($mids, $thread['read_all'] ? NULL : $account); |
|
386 | + } |
|
387 | + // Load messages returned by the messages query. |
|
388 | + $thread['messages'] = privatemsg_message_load_multiple($mids, $thread['read_all'] ? NULL : $account); |
|
390 | 389 | |
391 | - // If there are no messages, don't allow access to the thread. |
|
392 | - if (empty($thread['messages'])) { |
|
390 | + // If there are no messages, don't allow access to the thread. |
|
391 | + if (empty($thread['messages'])) { |
|
393 | 392 | if ($useAccessDenied) { |
394 | - // Generate new query with read all to see if the thread does exist. |
|
395 | - $query = _privatemsg_assemble_query('messages', array($thread_id), NULL); |
|
396 | - $exists = db_result(db_query($query['count'])); |
|
397 | - if (!$exists) { |
|
393 | + // Generate new query with read all to see if the thread does exist. |
|
394 | + $query = _privatemsg_assemble_query('messages', array($thread_id), NULL); |
|
395 | + $exists = db_result(db_query($query['count'])); |
|
396 | + if (!$exists) { |
|
398 | 397 | // Thread does not exist, display 404. |
399 | 398 | $thread = FALSE; |
400 | - } |
|
399 | + } |
|
401 | 400 | } |
402 | 401 | else { |
403 | - $thread = FALSE; |
|
402 | + $thread = FALSE; |
|
403 | + } |
|
404 | 404 | } |
405 | - } |
|
406 | - else { |
|
405 | + else { |
|
407 | 406 | // General data, assume subject is the same for all messages of that thread. |
408 | 407 | $thread['user'] = $account; |
409 | 408 | $message = current($thread['messages']); |
410 | 409 | $thread['subject'] = $message['subject']; |
411 | - } |
|
412 | - $threads[$account->uid][$thread_id] = $thread; |
|
410 | + } |
|
411 | + $threads[$account->uid][$thread_id] = $thread; |
|
413 | 412 | } |
414 | 413 | |
415 | 414 | return $threads[$account->uid][$thread_id]; |
416 | - } |
|
417 | - return FALSE; |
|
415 | + } |
|
416 | + return FALSE; |
|
418 | 417 | } |
419 | 418 | |
420 | 419 | function private_message_view_options() { |
421 | - $options = module_invoke_all('privatemsg_view_template'); |
|
422 | - return $options; |
|
420 | + $options = module_invoke_all('privatemsg_view_template'); |
|
421 | + return $options; |
|
423 | 422 | } |
424 | 423 | |
425 | 424 | /** |
@@ -435,108 +434,108 @@ discard block |
||
435 | 434 | * }; |
436 | 435 | */ |
437 | 436 | function privatemsg_privatemsg_view_template() { |
438 | - return array( |
|
437 | + return array( |
|
439 | 438 | 'privatemsg-view' => 'Default view', |
440 | - ); |
|
439 | + ); |
|
441 | 440 | } |
442 | 441 | |
443 | 442 | function private_message_settings() { |
444 | - $form = array(); |
|
443 | + $form = array(); |
|
445 | 444 | |
446 | - $form['theming_settings'] = array( |
|
445 | + $form['theming_settings'] = array( |
|
447 | 446 | '#type' => 'fieldset', |
448 | 447 | '#collapsible' => TRUE, |
449 | 448 | '#collapsed' => TRUE, |
450 | 449 | '#title' => t('Theming settings'), |
451 | - ); |
|
452 | - $form['theming_settings']['private_message_view_template'] = array( |
|
450 | + ); |
|
451 | + $form['theming_settings']['private_message_view_template'] = array( |
|
453 | 452 | '#type' => 'radios', |
454 | 453 | '#title' => t('Private message display template'), |
455 | 454 | '#default_value' => variable_get('private_message_view_template', 'privatemsg-view'), |
456 | 455 | '#options' => private_message_view_options(), |
457 | - ); |
|
458 | - $form['privatemsg_display_loginmessage'] = array( |
|
456 | + ); |
|
457 | + $form['privatemsg_display_loginmessage'] = array( |
|
459 | 458 | '#type' => 'checkbox', |
460 | 459 | '#title' => t('Inform the user about new messages on login'), |
461 | 460 | '#default_value' => variable_get('privatemsg_display_loginmessage', TRUE), |
462 | 461 | '#description' => t('This option can safely be disabled if the "New message indication" block is used instead.'), |
463 | - ); |
|
462 | + ); |
|
464 | 463 | |
465 | - $form['flush_deleted'] = array( |
|
464 | + $form['flush_deleted'] = array( |
|
466 | 465 | '#type' => 'fieldset', |
467 | 466 | '#collapsible' => TRUE, |
468 | 467 | '#collapsed' => TRUE, |
469 | 468 | '#title' => t('Flush deleted messages'), |
470 | 469 | '#description' => t('By default, deleted messages are only hidden from the user but still stored in the database. These settings control if and when messages should be removed.'), |
471 | - ); |
|
470 | + ); |
|
472 | 471 | |
473 | - $form['flush_deleted']['privatemsg_flush_enabled'] = array( |
|
472 | + $form['flush_deleted']['privatemsg_flush_enabled'] = array( |
|
474 | 473 | '#type' => 'checkbox', |
475 | 474 | '#title' => t('Flush deleted messages'), |
476 | 475 | '#default_value' => variable_get('privatemsg_flush_enabled', FALSE), |
477 | 476 | '#description' => t('Enable the flushing of deleted messages. Requires that cron is enabled'), |
478 | - ); |
|
477 | + ); |
|
479 | 478 | |
480 | - $form['flush_deleted']['privatemsg_flush_days'] = array( |
|
479 | + $form['flush_deleted']['privatemsg_flush_days'] = array( |
|
481 | 480 | '#type' => 'select', |
482 | 481 | '#title' => t('Flush messages after they have been deleted for more days than'), |
483 | 482 | '#default_value' => variable_get('privatemsg_flush_days', 30), |
484 | 483 | '#options' => drupal_map_assoc(array(0, 1, 2, 5, 10, 30, 100)), |
485 | - ); |
|
484 | + ); |
|
486 | 485 | |
487 | - $form['flush_deleted']['privatemsg_flush_max'] = array( |
|
486 | + $form['flush_deleted']['privatemsg_flush_max'] = array( |
|
488 | 487 | '#type' => 'select', |
489 | 488 | '#title' => t('Maximum number of messages to flush per cron run'), |
490 | 489 | '#default_value' => variable_get('privatemsg_flush_max', 200), |
491 | 490 | '#options' => drupal_map_assoc(array(50, 100, 200, 500, 1000)), |
492 | - ); |
|
491 | + ); |
|
493 | 492 | |
494 | - $form['privatemsg_listing'] = array( |
|
493 | + $form['privatemsg_listing'] = array( |
|
495 | 494 | '#type' => 'fieldset', |
496 | 495 | '#title' => t('Configure listings'), |
497 | 496 | '#collapsible' => TRUE, |
498 | 497 | '#collapsed' => FALSE, |
499 | - ); |
|
498 | + ); |
|
500 | 499 | |
501 | - $form['privatemsg_listing']['privatemsg_per_page'] = array( |
|
500 | + $form['privatemsg_listing']['privatemsg_per_page'] = array( |
|
502 | 501 | '#type' => 'select', |
503 | 502 | '#title' => t('Threads per page'), |
504 | 503 | '#default_value' => variable_get('privatemsg_per_page', 25), |
505 | 504 | '#options' => drupal_map_assoc(array(10, 25, 50, 75, 100)), |
506 | 505 | '#description' => t('Choose the number of conversations that should be listed per page.'), |
507 | - ); |
|
506 | + ); |
|
508 | 507 | |
509 | - $form['privatemsg_listing']['privatemsg_display_fields'] = array( |
|
508 | + $form['privatemsg_listing']['privatemsg_display_fields'] = array( |
|
510 | 509 | '#type' => 'checkboxes', |
511 | 510 | '#title' => t('Configure fields'), |
512 | 511 | '#description' => t('Select which columns/fields should be displayed in the message listings. Subject and Last updated cannot be disabled.'), |
513 | 512 | '#options' => array( |
514 | - 'participants' => t('Participants'), |
|
515 | - 'thread_started' => t('Started'), |
|
516 | - 'count' => t('Messages'), |
|
513 | + 'participants' => t('Participants'), |
|
514 | + 'thread_started' => t('Started'), |
|
515 | + 'count' => t('Messages'), |
|
517 | 516 | ), |
518 | 517 | '#default_value' => variable_get('privatemsg_display_fields', array('participants')), |
519 | - ); |
|
518 | + ); |
|
520 | 519 | |
521 | - $amounts = drupal_map_assoc(array(5, 10, 20, 30, 50, 70, 90, 150, 200, 250, 300)); |
|
522 | - $form['privatemsg_listing']['privatemsg_view_max_amount'] = array( |
|
520 | + $amounts = drupal_map_assoc(array(5, 10, 20, 30, 50, 70, 90, 150, 200, 250, 300)); |
|
521 | + $form['privatemsg_listing']['privatemsg_view_max_amount'] = array( |
|
523 | 522 | '#type' => 'select', |
524 | 523 | '#title' => t('Number of messages on thread pages'), |
525 | 524 | '#options' => $amounts + array(PRIVATEMSG_UNLIMITED => t('Unlimited')), |
526 | 525 | '#default_value' => variable_get('privatemsg_view_max_amount', 20), |
527 | 526 | '#description' => t('Threads will not show more than this number of messages on a single page.'), |
528 | 527 | '#weight' => 10, |
529 | - ); |
|
528 | + ); |
|
530 | 529 | |
531 | - $form['privatemsg_listing']['privatemsg_view_use_max_as_default'] = array( |
|
530 | + $form['privatemsg_listing']['privatemsg_view_use_max_as_default'] = array( |
|
532 | 531 | '#type' => 'checkbox', |
533 | 532 | '#title' => t('Display different amount of messages on first thread page'), |
534 | 533 | '#default_value' => variable_get('privatemsg_view_use_max_as_default', FALSE), |
535 | 534 | '#description' => t('By default, the first thread page shows the maximally allowed amount of messages. Enable this checkbox to set a different value.'), |
536 | 535 | '#weight' => 15, |
537 | - ); |
|
536 | + ); |
|
538 | 537 | |
539 | - $form['privatemsg_listing']['privatemsg_view_default_amount'] = array( |
|
538 | + $form['privatemsg_listing']['privatemsg_view_default_amount'] = array( |
|
540 | 539 | '#prefix' => '<div id="privatemsg-view-default-button">', |
541 | 540 | '#suffix' => '</div>', |
542 | 541 | '#type' => 'select', |
@@ -545,15 +544,15 @@ discard block |
||
545 | 544 | '#description' => t('The number of messages to be displayed on first thread page. Displays the newest messages.'), |
546 | 545 | '#options' => $amounts, |
547 | 546 | '#weight' => 20, |
548 | - ); |
|
549 | - drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-admin.js'); |
|
547 | + ); |
|
548 | + drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-admin.js'); |
|
550 | 549 | |
551 | - $form['#submit'][] = 'private_message_settings_submit'; |
|
552 | - return system_settings_form($form); |
|
550 | + $form['#submit'][] = 'private_message_settings_submit'; |
|
551 | + return system_settings_form($form); |
|
553 | 552 | } |
554 | 553 | |
555 | 554 | function private_message_settings_submit() { |
556 | - drupal_rebuild_theme_registry(); |
|
555 | + drupal_rebuild_theme_registry(); |
|
557 | 556 | } |
558 | 557 | |
559 | 558 | /** |
@@ -563,107 +562,107 @@ discard block |
||
563 | 562 | * old enough are flushed. |
564 | 563 | */ |
565 | 564 | function privatemsg_cron() { |
566 | - if (variable_get('privatemsg_flush_enabled', FALSE)) { |
|
565 | + if (variable_get('privatemsg_flush_enabled', FALSE)) { |
|
567 | 566 | $query = _privatemsg_assemble_query('deleted', variable_get('privatemsg_flush_days', 30)); |
568 | 567 | $result = db_query($query['query']); |
569 | 568 | |
570 | 569 | $flushed = 0; |
571 | 570 | while (($row = db_fetch_array($result)) && ($flushed < variable_get('privatemsg_flush_max', 200))) { |
572 | - $message = privatemsg_message_load($row['mid']); |
|
573 | - module_invoke_all('privatemsg_message_flush', $message); |
|
571 | + $message = privatemsg_message_load($row['mid']); |
|
572 | + module_invoke_all('privatemsg_message_flush', $message); |
|
574 | 573 | |
575 | - // Delete recipients of the message. |
|
576 | - db_query('DELETE FROM {pm_index} WHERE mid = %d', $row['mid']); |
|
577 | - // Delete message itself. |
|
578 | - db_query('DELETE FROM {pm_message} WHERE mid = %d', $row['mid']); |
|
579 | - $flushed++; |
|
574 | + // Delete recipients of the message. |
|
575 | + db_query('DELETE FROM {pm_index} WHERE mid = %d', $row['mid']); |
|
576 | + // Delete message itself. |
|
577 | + db_query('DELETE FROM {pm_message} WHERE mid = %d', $row['mid']); |
|
578 | + $flushed++; |
|
579 | + } |
|
580 | 580 | } |
581 | - } |
|
582 | 581 | } |
583 | 582 | |
584 | 583 | function privatemsg_theme() { |
585 | - return array( |
|
584 | + return array( |
|
586 | 585 | 'privatemsg_view' => array( |
587 | - 'arguments' => array('message' => NULL), |
|
588 | - 'template' => variable_get('private_message_view_template', 'privatemsg-view'), // 'privatemsg', |
|
586 | + 'arguments' => array('message' => NULL), |
|
587 | + 'template' => variable_get('private_message_view_template', 'privatemsg-view'), // 'privatemsg', |
|
589 | 588 | ), |
590 | 589 | 'privatemsg_from' => array( |
591 | - 'arguments' => array('author' => NULL), |
|
592 | - 'template' => 'privatemsg-from', |
|
590 | + 'arguments' => array('author' => NULL), |
|
591 | + 'template' => 'privatemsg-from', |
|
593 | 592 | ), |
594 | 593 | 'privatemsg_recipients' => array( |
595 | - 'arguments' => array('message' => NULL), |
|
596 | - 'template' => 'privatemsg-recipients', |
|
594 | + 'arguments' => array('message' => NULL), |
|
595 | + 'template' => 'privatemsg-recipients', |
|
597 | 596 | ), |
598 | 597 | 'privatemsg_between' => array( |
599 | - 'arguments' => array('recipients' => NULL), |
|
600 | - 'template' => 'privatemsg-between', |
|
598 | + 'arguments' => array('recipients' => NULL), |
|
599 | + 'template' => 'privatemsg-between', |
|
601 | 600 | ), |
602 | 601 | 'privatemsg_list' => array( |
603 | - 'file' => 'privatemsg.theme.inc', |
|
604 | - 'path' => drupal_get_path('module', 'privatemsg'), |
|
605 | - 'arguments' => array('form'), |
|
602 | + 'file' => 'privatemsg.theme.inc', |
|
603 | + 'path' => drupal_get_path('module', 'privatemsg'), |
|
604 | + 'arguments' => array('form'), |
|
606 | 605 | ), |
607 | 606 | // Define pattern for header/field templates. The theme system will register all |
608 | 607 | // theme functions that start with the defined pattern. |
609 | 608 | 'privatemsg_list_header' => array( |
610 | - 'file' => 'privatemsg.theme.inc', |
|
611 | - 'path' => drupal_get_path('module', 'privatemsg'), |
|
612 | - 'pattern' => 'privatemsg_list_header__', |
|
613 | - 'arguments' => array(), |
|
609 | + 'file' => 'privatemsg.theme.inc', |
|
610 | + 'path' => drupal_get_path('module', 'privatemsg'), |
|
611 | + 'pattern' => 'privatemsg_list_header__', |
|
612 | + 'arguments' => array(), |
|
614 | 613 | ), |
615 | 614 | 'privatemsg_list_field' => array( |
616 | - 'file' => 'privatemsg.theme.inc', |
|
617 | - 'path' => drupal_get_path('module', 'privatemsg'), |
|
618 | - 'pattern' => 'privatemsg_list_field__', |
|
619 | - 'arguments' => array('thread'), |
|
615 | + 'file' => 'privatemsg.theme.inc', |
|
616 | + 'path' => drupal_get_path('module', 'privatemsg'), |
|
617 | + 'pattern' => 'privatemsg_list_field__', |
|
618 | + 'arguments' => array('thread'), |
|
620 | 619 | ), |
621 | 620 | 'privatemsg_new_block' => array( |
622 | - 'file' => 'privatemsg.theme.inc', |
|
623 | - 'path' => drupal_get_path('module', 'privatemsg'), |
|
624 | - 'arguments' => array('count'), |
|
621 | + 'file' => 'privatemsg.theme.inc', |
|
622 | + 'path' => drupal_get_path('module', 'privatemsg'), |
|
623 | + 'arguments' => array('count'), |
|
625 | 624 | ), |
626 | - ); |
|
625 | + ); |
|
627 | 626 | } |
628 | 627 | |
629 | 628 | function template_preprocess_privatemsg_view(&$vars) { |
630 | 629 | // drupal_set_message('<pre>'. print_r($vars,1 ) . '</pre>'); |
631 | 630 | |
632 | - $message = $vars['message']; |
|
633 | - $vars['mid'] = isset($message['mid']) ? $message['mid'] : NULL; |
|
634 | - $vars['thread_id'] = isset($message['thread_id']) ? $message['thread_id'] : NULL; |
|
635 | - $vars['author_picture'] = theme('user_picture', $message['author']); |
|
636 | - $vars['author_name_link'] = theme('username', $message['author']); |
|
637 | - /** |
|
638 | - * @todo perhaps make this timestamp configurable via admin UI? |
|
639 | - */ |
|
640 | - $vars['message_timestamp'] = format_date($message['timestamp'], 'small'); |
|
641 | - $vars['message_body'] = check_markup($message['body'], $message['format'], FALSE); |
|
642 | - if (isset($vars['mid']) && isset($vars['thread_id']) && privatemsg_user_access('delete privatemsg')) { |
|
631 | + $message = $vars['message']; |
|
632 | + $vars['mid'] = isset($message['mid']) ? $message['mid'] : NULL; |
|
633 | + $vars['thread_id'] = isset($message['thread_id']) ? $message['thread_id'] : NULL; |
|
634 | + $vars['author_picture'] = theme('user_picture', $message['author']); |
|
635 | + $vars['author_name_link'] = theme('username', $message['author']); |
|
636 | + /** |
|
637 | + * @todo perhaps make this timestamp configurable via admin UI? |
|
638 | + */ |
|
639 | + $vars['message_timestamp'] = format_date($message['timestamp'], 'small'); |
|
640 | + $vars['message_body'] = check_markup($message['body'], $message['format'], FALSE); |
|
641 | + if (isset($vars['mid']) && isset($vars['thread_id']) && privatemsg_user_access('delete privatemsg')) { |
|
643 | 642 | $vars['message_actions'][] = array('title' => t('Delete message'), 'href' => 'messages/delete/' . $vars['thread_id'] . '/' . $vars['mid']); |
644 | - } |
|
645 | - $vars['message_anchors'][] = 'privatemsg-mid-' . $vars['mid']; |
|
646 | - if (!empty($message['is_new'])) { |
|
643 | + } |
|
644 | + $vars['message_anchors'][] = 'privatemsg-mid-' . $vars['mid']; |
|
645 | + if (!empty($message['is_new'])) { |
|
647 | 646 | $vars['message_anchors'][] = 'new'; |
648 | 647 | $vars['new'] = drupal_ucfirst(t('new')); |
649 | - } |
|
648 | + } |
|
650 | 649 | |
651 | - // call hook_privatemsg_message_view_alter |
|
652 | - drupal_alter('privatemsg_message_view', $vars); |
|
650 | + // call hook_privatemsg_message_view_alter |
|
651 | + drupal_alter('privatemsg_message_view', $vars); |
|
653 | 652 | |
654 | - $vars['message_actions'] = !empty($vars['message_actions']) ? theme('links', $vars['message_actions'], array('class' => 'message-actions')) : ''; |
|
653 | + $vars['message_actions'] = !empty($vars['message_actions']) ? theme('links', $vars['message_actions'], array('class' => 'message-actions')) : ''; |
|
655 | 654 | |
656 | - $vars['anchors'] = ''; |
|
657 | - foreach ($vars['message_anchors'] as $anchor) { |
|
655 | + $vars['anchors'] = ''; |
|
656 | + foreach ($vars['message_anchors'] as $anchor) { |
|
658 | 657 | $vars['anchors'] .= '<a name="' . $anchor . '"></a>'; |
659 | - } |
|
658 | + } |
|
660 | 659 | } |
661 | 660 | |
662 | 661 | function template_preprocess_privatemsg_recipients(&$vars) { |
663 | - $vars['participants'] = ''; // assign a default empty value |
|
664 | - if (isset($vars['message']['participants'])) { |
|
662 | + $vars['participants'] = ''; // assign a default empty value |
|
663 | + if (isset($vars['message']['participants'])) { |
|
665 | 664 | $vars['participants'] = _privatemsg_format_participants($vars['message']['participants']); |
666 | - } |
|
665 | + } |
|
667 | 666 | } |
668 | 667 | |
669 | 668 | /** |
@@ -680,49 +679,49 @@ discard block |
||
680 | 679 | * Form array |
681 | 680 | */ |
682 | 681 | function privatemsg_list(&$form_state, $argument = 'list', $uid = NULL) { |
683 | - global $user; |
|
682 | + global $user; |
|
684 | 683 | |
685 | - // Setting default behavior... |
|
686 | - $account = $user; |
|
687 | - // Because uid is submitted by the menu system, it's a string not a integer. |
|
688 | - if ((int)$uid > 0 && $uid != $user->uid) { |
|
684 | + // Setting default behavior... |
|
685 | + $account = $user; |
|
686 | + // Because uid is submitted by the menu system, it's a string not a integer. |
|
687 | + if ((int)$uid > 0 && $uid != $user->uid) { |
|
689 | 688 | // Trying to view someone else's messages... |
690 | 689 | if (!privatemsg_user_access('read all private messages')) { |
691 | - drupal_set_message(t("You do not have sufficient rights to view someone else's messages"), 'warning'); |
|
690 | + drupal_set_message(t("You do not have sufficient rights to view someone else's messages"), 'warning'); |
|
692 | 691 | } |
693 | 692 | elseif ($account_check = user_load(array('uid' => $uid))) { |
694 | - // Has rights and user_load return an array so user does exist |
|
695 | - $account = $account_check; |
|
693 | + // Has rights and user_load return an array so user does exist |
|
694 | + $account = $account_check; |
|
695 | + } |
|
696 | 696 | } |
697 | - } |
|
698 | - // By this point we have figured out for which user we are listing messages and now it is safe to use $account->uid in the listing query. |
|
697 | + // By this point we have figured out for which user we are listing messages and now it is safe to use $account->uid in the listing query. |
|
699 | 698 | |
700 | - $query = _privatemsg_assemble_query('list', $account, $argument); |
|
701 | - $result = pager_query($query['query'], variable_get('privatemsg_per_page', 25), 0, $query['count']); |
|
699 | + $query = _privatemsg_assemble_query('list', $account, $argument); |
|
700 | + $result = pager_query($query['query'], variable_get('privatemsg_per_page', 25), 0, $query['count']); |
|
702 | 701 | |
703 | - $threads = array(); |
|
704 | - $form['#data'] = array(); |
|
705 | - while ($row = db_fetch_array($result)) { |
|
702 | + $threads = array(); |
|
703 | + $form['#data'] = array(); |
|
704 | + while ($row = db_fetch_array($result)) { |
|
706 | 705 | // Store the raw row data. |
707 | 706 | $form['#data'][$row['thread_id']] = $row; |
708 | 707 | // store thread id for the checkboxes array |
709 | 708 | $threads[$row['thread_id']] = ''; |
710 | - } |
|
711 | - if (!empty($form['#data'])) { |
|
709 | + } |
|
710 | + if (!empty($form['#data'])) { |
|
712 | 711 | $form['actions'] = _privatemsg_action_form(); |
713 | - } |
|
712 | + } |
|
714 | 713 | |
715 | - // Save the currently active account, used for actions. |
|
716 | - $form['account'] = array('#type' => 'value', '#value' => $account); |
|
714 | + // Save the currently active account, used for actions. |
|
715 | + $form['account'] = array('#type' => 'value', '#value' => $account); |
|
717 | 716 | |
718 | - // Define checkboxes, pager and theme |
|
719 | - $form['threads'] = array('#type' => 'checkboxes', '#options' => $threads); |
|
720 | - $form['pager'] = array('#value' => theme('pager'), '#weight' => 20); |
|
721 | - $form['#theme'] = 'privatemsg_list'; |
|
717 | + // Define checkboxes, pager and theme |
|
718 | + $form['threads'] = array('#type' => 'checkboxes', '#options' => $threads); |
|
719 | + $form['pager'] = array('#value' => theme('pager'), '#weight' => 20); |
|
720 | + $form['#theme'] = 'privatemsg_list'; |
|
722 | 721 | |
723 | - // Store the account for which the threads are displayed. |
|
724 | - $form['#account'] = $account; |
|
725 | - return $form; |
|
722 | + // Store the account for which the threads are displayed. |
|
723 | + $form['#account'] = $account; |
|
724 | + return $form; |
|
726 | 725 | } |
727 | 726 | |
728 | 727 | /** |
@@ -736,12 +735,12 @@ discard block |
||
736 | 735 | * User object, defaults to the current user |
737 | 736 | */ |
738 | 737 | function privatemsg_message_change_status($pmid, $status, $account = NULL) { |
739 | - if (!$account) { |
|
738 | + if (!$account) { |
|
740 | 739 | global $user; |
741 | 740 | $account = $user; |
742 | - } |
|
743 | - $query = "UPDATE {pm_index} SET is_new = %d WHERE mid = %d AND uid = %d"; |
|
744 | - db_query($query, $status, $pmid, $account->uid); |
|
741 | + } |
|
742 | + $query = "UPDATE {pm_index} SET is_new = %d WHERE mid = %d AND uid = %d"; |
|
743 | + db_query($query, $status, $pmid, $account->uid); |
|
745 | 744 | } |
746 | 745 | |
747 | 746 | /** |
@@ -753,16 +752,16 @@ discard block |
||
753 | 752 | * @ingroup api |
754 | 753 | */ |
755 | 754 | function privatemsg_unread_count($account = NULL) { |
756 | - static $counts = array(); |
|
757 | - if (!$account || $account->uid == 0) { |
|
755 | + static $counts = array(); |
|
756 | + if (!$account || $account->uid == 0) { |
|
758 | 757 | global $user; |
759 | 758 | $account = $user; |
760 | - } |
|
761 | - if ( !isset($counts[$account->uid])) { |
|
759 | + } |
|
760 | + if ( !isset($counts[$account->uid])) { |
|
762 | 761 | $query = _privatemsg_assemble_query('unread_count', $account); |
763 | 762 | $counts[$account->uid] = db_result(db_query($query['query'])); |
764 | - } |
|
765 | - return $counts[$account->uid]; |
|
763 | + } |
|
764 | + return $counts[$account->uid]; |
|
766 | 765 | } |
767 | 766 | |
768 | 767 | /** |
@@ -776,284 +775,284 @@ discard block |
||
776 | 775 | * @see privatemsg_thread_load() |
777 | 776 | */ |
778 | 777 | function privatemsg_view($thread) { |
779 | - drupal_set_title(check_plain($thread['subject'])); |
|
778 | + drupal_set_title(check_plain($thread['subject'])); |
|
780 | 779 | |
781 | - // Generate paging links. |
|
782 | - $older = ''; |
|
783 | - if (isset($thread['older_start'])) { |
|
780 | + // Generate paging links. |
|
781 | + $older = ''; |
|
782 | + if (isset($thread['older_start'])) { |
|
784 | 783 | $options = array( |
785 | - 'query' => array('start' => $thread['older_start']), |
|
786 | - 'title' => t('Display older messages'), |
|
784 | + 'query' => array('start' => $thread['older_start']), |
|
785 | + 'title' => t('Display older messages'), |
|
787 | 786 | ); |
788 | - $older = l(t('<<'), 'messages/view/' . $thread['thread_id'], $options); |
|
789 | - } |
|
790 | - $newer = ''; |
|
791 | - if (isset($thread['newer_start'])) { |
|
787 | + $older = l(t('<<'), 'messages/view/' . $thread['thread_id'], $options); |
|
788 | + } |
|
789 | + $newer = ''; |
|
790 | + if (isset($thread['newer_start'])) { |
|
792 | 791 | $options = array( |
793 | - 'query' => array('start' => $thread['newer_start']), |
|
794 | - 'title' => t('Display newer messages'), |
|
792 | + 'query' => array('start' => $thread['newer_start']), |
|
793 | + 'title' => t('Display newer messages'), |
|
795 | 794 | ); |
796 | 795 | $newer = l(t('>>'), 'messages/view/' . $thread['thread_id'], $options); |
797 | - } |
|
798 | - $substitutions = array('@from' => $thread['from'], '@to' => $thread['to'], '@total' => $thread['message_count'], '!previous_link' => $older, '!newer_link' => $newer); |
|
799 | - $title = t('!previous_link Displaying messages @from - @to of @total !newer_link', $substitutions); |
|
800 | - $content['pager_top'] = array( |
|
796 | + } |
|
797 | + $substitutions = array('@from' => $thread['from'], '@to' => $thread['to'], '@total' => $thread['message_count'], '!previous_link' => $older, '!newer_link' => $newer); |
|
798 | + $title = t('!previous_link Displaying messages @from - @to of @total !newer_link', $substitutions); |
|
799 | + $content['pager_top'] = array( |
|
801 | 800 | '#value' => trim($title), |
802 | 801 | '#prefix' => '<div class="privatemsg-view-pager">', |
803 | 802 | '#suffix' => '</div>', |
804 | 803 | '#weight' => -10, |
805 | - ); |
|
804 | + ); |
|
806 | 805 | |
807 | - // Display a copy at the end. |
|
808 | - $content['pager_bottom'] = $content['pager_top']; |
|
809 | - $content['pager_bottom']['#weight'] = 3; |
|
806 | + // Display a copy at the end. |
|
807 | + $content['pager_bottom'] = $content['pager_top']; |
|
808 | + $content['pager_bottom']['#weight'] = 3; |
|
810 | 809 | |
811 | - // Render the participants. |
|
812 | - $content['participants']['#value'] = theme('privatemsg_recipients', $thread); |
|
813 | - $content['participants']['#weight'] = -5; |
|
810 | + // Render the participants. |
|
811 | + $content['participants']['#value'] = theme('privatemsg_recipients', $thread); |
|
812 | + $content['participants']['#weight'] = -5; |
|
814 | 813 | |
815 | - // Render the messages. |
|
816 | - $output = ''; |
|
817 | - foreach ($thread['messages'] as $pmid => $message) { |
|
814 | + // Render the messages. |
|
815 | + $output = ''; |
|
816 | + foreach ($thread['messages'] as $pmid => $message) { |
|
818 | 817 | // Set message as read and theme it. |
819 | 818 | if (!empty($message['is_new'])) { |
820 | - privatemsg_message_change_status($pmid, PRIVATEMSG_READ, $thread['user']); |
|
819 | + privatemsg_message_change_status($pmid, PRIVATEMSG_READ, $thread['user']); |
|
821 | 820 | } |
822 | 821 | $output .= theme('privatemsg_view', $message); |
823 | - } |
|
824 | - $content['messages']['#value'] = $output; |
|
825 | - $content['messages']['#weight'] = 0; |
|
822 | + } |
|
823 | + $content['messages']['#value'] = $output; |
|
824 | + $content['messages']['#weight'] = 0; |
|
826 | 825 | |
827 | - // Display the reply form if user is allowed to use it. |
|
828 | - if (privatemsg_user_access('write privatemsg')) { |
|
826 | + // Display the reply form if user is allowed to use it. |
|
827 | + if (privatemsg_user_access('write privatemsg')) { |
|
829 | 828 | $content['reply']['#value'] = drupal_get_form('privatemsg_new', $thread['participants'], $thread['subject'], $thread['thread_id'], $thread['read_all']); |
830 | 829 | $content['reply']['#weight'] = 5; |
831 | - } |
|
830 | + } |
|
832 | 831 | |
833 | - // Check after calling the privatemsg_new form so that this message is only |
|
834 | - // displayed when we are not sending a message. |
|
835 | - if ($thread['read_all']) { |
|
832 | + // Check after calling the privatemsg_new form so that this message is only |
|
833 | + // displayed when we are not sending a message. |
|
834 | + if ($thread['read_all']) { |
|
836 | 835 | // User has permission to read all messages AND is not a participant of the current thread. |
837 | 836 | drupal_set_message(t('This conversation is being viewed with escalated priviledges and may not be the same as shown to normal users.'), 'warning'); |
838 | - } |
|
837 | + } |
|
839 | 838 | |
840 | - // Allow other modules to hook into the $content array and alter it. |
|
841 | - drupal_alter('privatemsg_view_messages', $content, $thread); |
|
842 | - return drupal_render($content); |
|
839 | + // Allow other modules to hook into the $content array and alter it. |
|
840 | + drupal_alter('privatemsg_view_messages', $content, $thread); |
|
841 | + return drupal_render($content); |
|
843 | 842 | } |
844 | 843 | |
845 | 844 | |
846 | 845 | function privatemsg_new(&$form_state, $recipients = array(), $subject = '', $thread_id = NULL, $read_all = FALSE) { |
847 | - global $user; |
|
846 | + global $user; |
|
848 | 847 | |
849 | - $recipients_string = ''; |
|
850 | - $body = ''; |
|
848 | + $recipients_string = ''; |
|
849 | + $body = ''; |
|
851 | 850 | |
852 | - // convert recipients to array of user objects |
|
853 | - if (!empty($recipients) && is_string($recipients) || is_int($recipients)) { |
|
851 | + // convert recipients to array of user objects |
|
852 | + if (!empty($recipients) && is_string($recipients) || is_int($recipients)) { |
|
854 | 853 | $recipients = _privatemsg_generate_user_array($recipients); |
855 | - } |
|
856 | - elseif (is_object($recipients)) { |
|
854 | + } |
|
855 | + elseif (is_object($recipients)) { |
|
857 | 856 | $recipients = array($recipients); |
858 | - } |
|
859 | - elseif (empty($recipients) && is_string($recipients)) { |
|
857 | + } |
|
858 | + elseif (empty($recipients) && is_string($recipients)) { |
|
860 | 859 | $recipients = array(); |
861 | - } |
|
860 | + } |
|
862 | 861 | |
863 | - $usercount = 0; |
|
864 | - $to = array(); |
|
865 | - $to_themed = array(); |
|
866 | - $blocked = FALSE; |
|
867 | - foreach ($recipients as $recipient) { |
|
862 | + $usercount = 0; |
|
863 | + $to = array(); |
|
864 | + $to_themed = array(); |
|
865 | + $blocked = FALSE; |
|
866 | + foreach ($recipients as $recipient) { |
|
868 | 867 | if (in_array($recipient->name, $to)) { |
869 | - // We already added the recipient to the list, skip him. |
|
870 | - continue; |
|
868 | + // We already added the recipient to the list, skip him. |
|
869 | + continue; |
|
871 | 870 | } |
872 | 871 | // Check if another module is blocking the sending of messages to the recipient by current user. |
873 | 872 | $user_blocked = module_invoke_all('privatemsg_block_message', $user, array($recipient->uid => $recipient)); |
874 | 873 | if (!count($user_blocked) <> 0 && $recipient->uid) { |
875 | - if ($recipient->uid == $user->uid) { |
|
874 | + if ($recipient->uid == $user->uid) { |
|
876 | 875 | $usercount++; |
877 | 876 | // Skip putting author in the recipients list for now. |
878 | 877 | continue; |
879 | - } |
|
880 | - $myuser = user_load(array('uid' => $recipient->uid)); |
|
881 | - $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name); |
|
882 | - $to[] = $myname . "_" . $myuser->boincuser_id; |
|
883 | - $to_themed[$recipient->uid] = $myname; |
|
878 | + } |
|
879 | + $myuser = user_load(array('uid' => $recipient->uid)); |
|
880 | + $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name); |
|
881 | + $to[] = $myname . "_" . $myuser->boincuser_id; |
|
882 | + $to_themed[$recipient->uid] = $myname; |
|
884 | 883 | } |
885 | 884 | else { |
886 | - // Recipient list contains blocked users. |
|
887 | - $blocked = TRUE; |
|
885 | + // Recipient list contains blocked users. |
|
886 | + $blocked = TRUE; |
|
887 | + } |
|
888 | 888 | } |
889 | - } |
|
890 | 889 | |
891 | - if (empty($to) && $usercount >= 1 && !$blocked) { |
|
890 | + if (empty($to) && $usercount >= 1 && !$blocked) { |
|
892 | 891 | // Assume the user sent message to own account as if the usercount is one or less, then the user sent a message but not to self. |
893 | 892 | $myuser = user_load(array('uid' => $user->uid)); |
894 | 893 | $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name); |
895 | 894 | $to[] = $myname . "_" . $myuser->boincuser_id; |
896 | 895 | $to_themed[$user->uid] = $myname; |
897 | - } |
|
898 | - if (!empty($to)) { |
|
896 | + } |
|
897 | + if (!empty($to)) { |
|
899 | 898 | $recipients_string = implode(', ', $to); |
900 | 899 | $recipients_string .= ', '; |
901 | - } |
|
902 | - if (isset($form_state['values'])) { |
|
900 | + } |
|
901 | + if (isset($form_state['values'])) { |
|
903 | 902 | if (isset($form_state['values']['recipient'])) { |
904 | - $recipients_string = $form_state['values']['recipient']; |
|
903 | + $recipients_string = $form_state['values']['recipient']; |
|
905 | 904 | |
906 | 905 | } |
907 | 906 | $subject = $form_state['values']['subject']; |
908 | 907 | $body = $form_state['values']['body']; |
909 | - } |
|
910 | - if (!$thread_id && !empty($recipients_string)) { |
|
908 | + } |
|
909 | + if (!$thread_id && !empty($recipients_string)) { |
|
911 | 910 | drupal_set_title(t('Write new message to %recipient', array('%recipient' => $recipients_string))); |
912 | - } |
|
913 | - elseif (!$thread_id) { |
|
911 | + } |
|
912 | + elseif (!$thread_id) { |
|
914 | 913 | drupal_set_title(t('Write new message')); |
915 | - } |
|
916 | - $form = array(); |
|
917 | - if (isset($form_state['privatemsg_preview'])) { |
|
914 | + } |
|
915 | + $form = array(); |
|
916 | + if (isset($form_state['privatemsg_preview'])) { |
|
918 | 917 | $form['message_header'] = array( |
919 | - '#type' => 'fieldset', |
|
920 | - '#attributes' => array('class' => 'preview'), |
|
918 | + '#type' => 'fieldset', |
|
919 | + '#attributes' => array('class' => 'preview'), |
|
921 | 920 | ); |
922 | 921 | $form['message_header']['message_preview'] = array( |
923 | - '#value' => $form_state['privatemsg_preview'], |
|
922 | + '#value' => $form_state['privatemsg_preview'], |
|
924 | 923 | ); |
925 | - } |
|
926 | - $form['privatemsg'] = array( |
|
924 | + } |
|
925 | + $form['privatemsg'] = array( |
|
927 | 926 | '#type' => 'fieldset', |
928 | 927 | '#access' => privatemsg_user_access('write privatemsg'), |
929 | - ); |
|
930 | - $form['privatemsg']['author'] = array( |
|
928 | + ); |
|
929 | + $form['privatemsg']['author'] = array( |
|
931 | 930 | '#type' => 'value', |
932 | 931 | '#value' => $user, |
933 | - ); |
|
934 | - if (is_null($thread_id)) { |
|
932 | + ); |
|
933 | + if (is_null($thread_id)) { |
|
935 | 934 | $form['privatemsg']['recipient'] = array( |
936 | - '#type' => 'textfield', |
|
937 | - '#title' => t('To'), |
|
938 | - '#description' => t('Separate multiple names with a comma followed by one space. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'), |
|
939 | - '#default_value' => $recipients_string, |
|
940 | - '#required' => TRUE, |
|
941 | - '#weight' => -10, |
|
942 | - '#size' => 50, |
|
943 | - '#autocomplete_path' => 'messages/user-name-autocomplete', |
|
944 | - // Do not hardcode #maxlength, make it configurable by number of recipients, not their name length. |
|
935 | + '#type' => 'textfield', |
|
936 | + '#title' => t('To'), |
|
937 | + '#description' => t('Separate multiple names with a comma followed by one space. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'), |
|
938 | + '#default_value' => $recipients_string, |
|
939 | + '#required' => TRUE, |
|
940 | + '#weight' => -10, |
|
941 | + '#size' => 50, |
|
942 | + '#autocomplete_path' => 'messages/user-name-autocomplete', |
|
943 | + // Do not hardcode #maxlength, make it configurable by number of recipients, not their name length. |
|
945 | 944 | ); |
946 | - } |
|
947 | - $form['privatemsg']['subject'] = array( |
|
945 | + } |
|
946 | + $form['privatemsg']['subject'] = array( |
|
948 | 947 | '#type' => 'textfield', |
949 | 948 | '#title' => t('Subject'), |
950 | 949 | '#size' => 50, |
951 | 950 | '#maxlength' => 255, |
952 | 951 | '#default_value' => $subject, |
953 | 952 | '#weight' => -5, |
954 | - ); |
|
955 | - $form['privatemsg']['body'] = array( |
|
953 | + ); |
|
954 | + $form['privatemsg']['body'] = array( |
|
956 | 955 | '#type' => 'textarea', |
957 | 956 | '#title' => t('Message'), |
958 | 957 | '#rows' => 6, |
959 | 958 | '#weight' => 0, |
960 | 959 | '#default_value' => $body, |
961 | 960 | '#resizable' => TRUE, |
962 | - ); |
|
963 | - $format = FILTER_FORMAT_DEFAULT; |
|
964 | - // The input filter widget looses the format during preview, specify it |
|
965 | - // explicitly. |
|
966 | - if (isset($form_state['values']) && array_key_exists('format', $form_state['values'])) { |
|
961 | + ); |
|
962 | + $format = FILTER_FORMAT_DEFAULT; |
|
963 | + // The input filter widget looses the format during preview, specify it |
|
964 | + // explicitly. |
|
965 | + if (isset($form_state['values']) && array_key_exists('format', $form_state['values'])) { |
|
967 | 966 | $format = $form_state['values']['format']; |
968 | - } |
|
969 | - $form['privatemsg']['format'] = filter_form($format); |
|
970 | - $form['privatemsg']['preview'] = array( |
|
967 | + } |
|
968 | + $form['privatemsg']['format'] = filter_form($format); |
|
969 | + $form['privatemsg']['preview'] = array( |
|
971 | 970 | '#type' => 'submit', |
972 | 971 | '#value' => t('Preview message'), |
973 | 972 | '#submit' => array('pm_preview'), |
974 | 973 | '#validate' => array('pm_send_validate'), |
975 | 974 | '#weight' => 10, |
976 | - ); |
|
977 | - $form['privatemsg']['submit'] = array( |
|
975 | + ); |
|
976 | + $form['privatemsg']['submit'] = array( |
|
978 | 977 | '#type' => 'submit', |
979 | 978 | '#value' => t('Send message'), |
980 | 979 | '#submit' => array('pm_send'), |
981 | 980 | '#validate' => array('pm_send_validate'), |
982 | 981 | '#weight' => 15, |
983 | - ); |
|
984 | - $url = 'messages'; |
|
985 | - $title = t('Cancel'); |
|
986 | - if (isset($_REQUEST['destination'])) { |
|
982 | + ); |
|
983 | + $url = 'messages'; |
|
984 | + $title = t('Cancel'); |
|
985 | + if (isset($_REQUEST['destination'])) { |
|
987 | 986 | $url = $_REQUEST['destination']; |
988 | - } |
|
989 | - elseif (!is_null($thread_id)) { |
|
987 | + } |
|
988 | + elseif (!is_null($thread_id)) { |
|
990 | 989 | $url = $_GET['q']; |
991 | 990 | $title = t('Clear'); |
992 | - } |
|
991 | + } |
|
993 | 992 | |
994 | - $form['privatemsg']['cancel'] = array( |
|
993 | + $form['privatemsg']['cancel'] = array( |
|
995 | 994 | '#value' => l($title, $url, array('attributes' => array('id' => 'edit-cancel'))), |
996 | 995 | '#weight' => 20, |
997 | - ); |
|
996 | + ); |
|
998 | 997 | |
999 | - if (!is_null($thread_id)) { |
|
998 | + if (!is_null($thread_id)) { |
|
1000 | 999 | $form['privatemsg']['thread_id'] = array( |
1001 | - '#type' => 'value', |
|
1002 | - '#value' => $thread_id, |
|
1000 | + '#type' => 'value', |
|
1001 | + '#value' => $thread_id, |
|
1003 | 1002 | ); |
1004 | 1003 | $form['privatemsg']['subject'] = array( |
1005 | - '#type' => 'value', |
|
1006 | - '#default_value' => $subject, |
|
1004 | + '#type' => 'value', |
|
1005 | + '#default_value' => $subject, |
|
1007 | 1006 | ); |
1008 | 1007 | $recipients_string_themed = implode(', ', $to_themed); |
1009 | 1008 | $form['privatemsg']['recipient_display'] = array( |
1010 | - '#value' => '<p>'. t('<strong>Reply to thread</strong>:<br /> Recipients: !to', array('!to' => $recipients_string_themed)) .'</p>', |
|
1011 | - '#weight' => -10, |
|
1009 | + '#value' => '<p>'. t('<strong>Reply to thread</strong>:<br /> Recipients: !to', array('!to' => $recipients_string_themed)) .'</p>', |
|
1010 | + '#weight' => -10, |
|
1012 | 1011 | ); |
1013 | 1012 | if (empty($recipients_string)) { |
1014 | - // If there are no valid recipients, unset the message reply form. |
|
1015 | - $form['privatemsg']['#access'] = FALSE; |
|
1013 | + // If there are no valid recipients, unset the message reply form. |
|
1014 | + $form['privatemsg']['#access'] = FALSE; |
|
1015 | + } |
|
1016 | 1016 | } |
1017 | - } |
|
1018 | - $form['privatemsg']['read_all'] = array( |
|
1017 | + $form['privatemsg']['read_all'] = array( |
|
1019 | 1018 | '#type' => 'value', |
1020 | 1019 | '#value' => $read_all, |
1021 | - ); |
|
1022 | - return $form; |
|
1020 | + ); |
|
1021 | + return $form; |
|
1023 | 1022 | } |
1024 | 1023 | |
1025 | 1024 | function pm_send_validate($form, &$form_state) { |
1026 | - // The actual message that is being sent, we create this during validation and pass to submit to send out. |
|
1027 | - $message = $form_state['values']; |
|
1028 | - $message['timestamp'] = time(); |
|
1029 | - // Avoid subjects which only consist of a space as these can not be clicked. |
|
1030 | - $message['subject'] = trim($message['subject']); |
|
1025 | + // The actual message that is being sent, we create this during validation and pass to submit to send out. |
|
1026 | + $message = $form_state['values']; |
|
1027 | + $message['timestamp'] = time(); |
|
1028 | + // Avoid subjects which only consist of a space as these can not be clicked. |
|
1029 | + $message['subject'] = trim($message['subject']); |
|
1031 | 1030 | |
1032 | 1031 | |
1033 | - $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE)); |
|
1034 | - if (empty($message['subject']) && !empty($trimed_body)) { |
|
1032 | + $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE)); |
|
1033 | + if (empty($message['subject']) && !empty($trimed_body)) { |
|
1035 | 1034 | $message['subject'] = $trimed_body; |
1036 | - } |
|
1037 | - // Only parse the user string for a new thread. |
|
1038 | - if (!isset($message['thread_id'])) { |
|
1035 | + } |
|
1036 | + // Only parse the user string for a new thread. |
|
1037 | + if (!isset($message['thread_id'])) { |
|
1039 | 1038 | list($message['recipients'], $invalid) = _privatemsg_parse_userstring($message['recipient']); |
1040 | - } |
|
1041 | - else { |
|
1039 | + } |
|
1040 | + else { |
|
1042 | 1041 | // Load participants. |
1043 | 1042 | $message['recipients'] = _privatemsg_load_thread_participants($message['thread_id']); |
1044 | 1043 | // Remove author. |
1045 | 1044 | if (isset($message['recipients'][$message['author']->uid]) && count($message['recipients']) > 1) { |
1046 | - unset($message['recipients'][$message['author']->uid]); |
|
1045 | + unset($message['recipients'][$message['author']->uid]); |
|
1047 | 1046 | } |
1048 | - } |
|
1049 | - $validated = _privatemsg_validate_message($message, TRUE); |
|
1050 | - foreach ($validated['messages'] as $type => $text) { |
|
1047 | + } |
|
1048 | + $validated = _privatemsg_validate_message($message, TRUE); |
|
1049 | + foreach ($validated['messages'] as $type => $text) { |
|
1051 | 1050 | drupal_set_message($text, $type); |
1052 | - } |
|
1053 | - $form_state['validate_built_message'] = $message; |
|
1054 | - if (!empty($invalid)) { |
|
1051 | + } |
|
1052 | + $form_state['validate_built_message'] = $message; |
|
1053 | + if (!empty($invalid)) { |
|
1055 | 1054 | drupal_set_message(t('The following users will not receive this private message: @invalid', array('@invalid' => implode(", ", $invalid))), 'error'); |
1056 | - } |
|
1055 | + } |
|
1057 | 1056 | } |
1058 | 1057 | |
1059 | 1058 | /** |
@@ -1063,15 +1062,15 @@ discard block |
||
1063 | 1062 | * Thread ID for wich the participants should be loaded. |
1064 | 1063 | */ |
1065 | 1064 | function _privatemsg_load_thread_participants($thread_id) { |
1066 | - $query = _privatemsg_assemble_query('participants', $thread_id); |
|
1067 | - $result = db_query($query['query']); |
|
1068 | - $participants = array(); |
|
1069 | - while ($uid = db_fetch_object($result)) { |
|
1065 | + $query = _privatemsg_assemble_query('participants', $thread_id); |
|
1066 | + $result = db_query($query['query']); |
|
1067 | + $participants = array(); |
|
1068 | + while ($uid = db_fetch_object($result)) { |
|
1070 | 1069 | if (($recipient = user_load($uid->uid))) { |
1071 | - $participants[$recipient->uid] = $recipient; |
|
1070 | + $participants[$recipient->uid] = $recipient; |
|
1071 | + } |
|
1072 | 1072 | } |
1073 | - } |
|
1074 | - return $participants; |
|
1073 | + return $participants; |
|
1075 | 1074 | } |
1076 | 1075 | |
1077 | 1076 | /** |
@@ -1087,67 +1086,67 @@ discard block |
||
1087 | 1086 | * with invalid names. |
1088 | 1087 | */ |
1089 | 1088 | function _privatemsg_parse_userstring($input) { |
1090 | - if (is_string($input)) { |
|
1089 | + if (is_string($input)) { |
|
1091 | 1090 | $input = explode(', ', $input); |
1092 | - } |
|
1091 | + } |
|
1093 | 1092 | |
1094 | - // Start working through the input array. |
|
1095 | - $invalid = array(); |
|
1096 | - $recipients = array(); |
|
1097 | - foreach ($input as $string) { |
|
1093 | + // Start working through the input array. |
|
1094 | + $invalid = array(); |
|
1095 | + $recipients = array(); |
|
1096 | + foreach ($input as $string) { |
|
1098 | 1097 | $string = trim($string); |
1099 | 1098 | if (!empty($string)) { // We don't care about white space names. |
1100 | 1099 | |
1101 | - // First, check if another module is able to resolve the string into an |
|
1102 | - // user object. |
|
1103 | - foreach (module_implements('privatemsg_name_lookup') as $module) { |
|
1100 | + // First, check if another module is able to resolve the string into an |
|
1101 | + // user object. |
|
1102 | + foreach (module_implements('privatemsg_name_lookup') as $module) { |
|
1104 | 1103 | $function = $module . '_privatemsg_name_lookup'; |
1105 | 1104 | if (($recipient = $function($string)) && is_object($recipient)) { |
1106 | - // If there is a match, continue with the next input string. |
|
1107 | - $recipients[$recipient->uid] = $recipient; |
|
1108 | - continue 2; |
|
1105 | + // If there is a match, continue with the next input string. |
|
1106 | + $recipients[$recipient->uid] = $recipient; |
|
1107 | + continue 2; |
|
1109 | 1108 | } |
1110 | - } |
|
1111 | - // Fall back to the default username lookup. |
|
1112 | - if (!$error = module_invoke('user', 'validate_name', $string)) { |
|
1109 | + } |
|
1110 | + // Fall back to the default username lookup. |
|
1111 | + if (!$error = module_invoke('user', 'validate_name', $string)) { |
|
1113 | 1112 | // String is a valid username, look it up. |
1114 | 1113 | if ($recipient = user_load(array('name' => $string))) { |
1115 | - $recipients[$recipient->uid] = $recipient; |
|
1116 | - continue; |
|
1114 | + $recipients[$recipient->uid] = $recipient; |
|
1115 | + continue; |
|
1116 | + } |
|
1117 | 1117 | } |
1118 | - } |
|
1119 | - $invalid[$string] = $string; |
|
1118 | + $invalid[$string] = $string; |
|
1120 | 1119 | } |
1121 | - } |
|
1122 | - return array($recipients, $invalid); |
|
1120 | + } |
|
1121 | + return array($recipients, $invalid); |
|
1123 | 1122 | } |
1124 | 1123 | |
1125 | 1124 | /** |
1126 | 1125 | * Submit callback for the privatemsg_new form. |
1127 | 1126 | */ |
1128 | 1127 | function pm_send($form, &$form_state) { |
1129 | - $status = _privatemsg_send($form_state['validate_built_message']); |
|
1130 | - // Load usernames to which the message was sent to. |
|
1131 | - $recipient_names = array(); |
|
1132 | - foreach ($form_state['validate_built_message']['recipients'] as $recipient) { |
|
1128 | + $status = _privatemsg_send($form_state['validate_built_message']); |
|
1129 | + // Load usernames to which the message was sent to. |
|
1130 | + $recipient_names = array(); |
|
1131 | + foreach ($form_state['validate_built_message']['recipients'] as $recipient) { |
|
1133 | 1132 | $recipient_names[] = theme('username', $recipient); |
1134 | - } |
|
1135 | - if ($status !== FALSE ) { |
|
1133 | + } |
|
1134 | + if ($status !== FALSE ) { |
|
1136 | 1135 | drupal_set_message(t('A message has been sent to !recipients.', array('!recipients' => implode(', ', $recipient_names)))); |
1137 | - } |
|
1138 | - else { |
|
1136 | + } |
|
1137 | + else { |
|
1139 | 1138 | drupal_set_message(t('An attempt to send a message <em>may have failed</em> when sending to !recipients.', array('!recipients' => implode(', ', $recipient_names))), 'error'); |
1140 | - } |
|
1139 | + } |
|
1141 | 1140 | } |
1142 | 1141 | |
1143 | 1142 | function pm_preview($form, &$form_state) { |
1144 | 1143 | |
1145 | 1144 | drupal_validate_form($form['form_id']['#value'], $form, $form_state); |
1146 | 1145 | if (!form_get_errors()) { |
1147 | - $form_state['privatemsg_preview'] = theme('privatemsg_view', $form_state['validate_built_message']); |
|
1146 | + $form_state['privatemsg_preview'] = theme('privatemsg_view', $form_state['validate_built_message']); |
|
1148 | 1147 | } |
1149 | 1148 | |
1150 | - $form_state['rebuild'] = TRUE; // this forces our form to be rebuilt instead of being submitted. |
|
1149 | + $form_state['rebuild'] = TRUE; // this forces our form to be rebuilt instead of being submitted. |
|
1151 | 1150 | } |
1152 | 1151 | |
1153 | 1152 | /** |
@@ -1168,65 +1167,65 @@ discard block |
||
1168 | 1167 | */ |
1169 | 1168 | |
1170 | 1169 | function privatemsg_sql_list(&$fragments, $account, $argument = 'list') { |
1171 | - $fragments['primary_table'] = '{pm_message} pm'; |
|
1172 | - |
|
1173 | - // Load enabled columns. |
|
1174 | - $fields = array_filter(variable_get('privatemsg_display_fields', array('participants'))); |
|
1175 | - |
|
1176 | - // Required columns. |
|
1177 | - $fragments['select'][] = 'pmi.thread_id'; |
|
1178 | - // We have to use MIN as the subject might not be the same in some threads. |
|
1179 | - // MIN() does not have a useful meaning except that it helps to correctly |
|
1180 | - // aggregate the thread on PostgreSQL. |
|
1181 | - $fragments['select'][] = 'MIN(pm.subject) as subject'; |
|
1182 | - $fragments['select'][] = 'MAX(pm.timestamp) as last_updated'; |
|
1183 | - // We use SUM so that we can count the number of unread messages. |
|
1184 | - $fragments['select'][] = 'SUM(pmi.is_new) as is_new'; |
|
1185 | - |
|
1186 | - // Select number of messages in the thread if the count is |
|
1187 | - // set to be displayed. |
|
1188 | - if (in_array('count', $fields)) { |
|
1170 | + $fragments['primary_table'] = '{pm_message} pm'; |
|
1171 | + |
|
1172 | + // Load enabled columns. |
|
1173 | + $fields = array_filter(variable_get('privatemsg_display_fields', array('participants'))); |
|
1174 | + |
|
1175 | + // Required columns. |
|
1176 | + $fragments['select'][] = 'pmi.thread_id'; |
|
1177 | + // We have to use MIN as the subject might not be the same in some threads. |
|
1178 | + // MIN() does not have a useful meaning except that it helps to correctly |
|
1179 | + // aggregate the thread on PostgreSQL. |
|
1180 | + $fragments['select'][] = 'MIN(pm.subject) as subject'; |
|
1181 | + $fragments['select'][] = 'MAX(pm.timestamp) as last_updated'; |
|
1182 | + // We use SUM so that we can count the number of unread messages. |
|
1183 | + $fragments['select'][] = 'SUM(pmi.is_new) as is_new'; |
|
1184 | + |
|
1185 | + // Select number of messages in the thread if the count is |
|
1186 | + // set to be displayed. |
|
1187 | + if (in_array('count', $fields)) { |
|
1189 | 1188 | $fragments['select'][] = 'COUNT(distinct pmi.mid) as count'; |
1190 | - } |
|
1191 | - if (in_array('participants', $fields)) { |
|
1189 | + } |
|
1190 | + if (in_array('participants', $fields)) { |
|
1192 | 1191 | // Query for a string with uid's, for example "1,6,7". |
1193 | 1192 | // @todo: Replace this with a single query similiar to the tag list. |
1194 | 1193 | if ($GLOBALS['db_type'] == 'pgsql') { |
1195 | - // PostgreSQL does not know GROUP_CONCAT, so a subquery is required. |
|
1196 | - $fragments['select'][] = "array_to_string(array(SELECT DISTINCT textin(int4out(pmia.uid)) |
|
1194 | + // PostgreSQL does not know GROUP_CONCAT, so a subquery is required. |
|
1195 | + $fragments['select'][] = "array_to_string(array(SELECT DISTINCT textin(int4out(pmia.uid)) |
|
1197 | 1196 | FROM {pm_index} pmia |
1198 | 1197 | WHERE pmia.thread_id = pmi.thread_id), ',') AS participants"; |
1199 | 1198 | } |
1200 | 1199 | else { |
1201 | - $fragments['select'][] = '(SELECT GROUP_CONCAT(DISTINCT pmia.uid SEPARATOR ",") |
|
1200 | + $fragments['select'][] = '(SELECT GROUP_CONCAT(DISTINCT pmia.uid SEPARATOR ",") |
|
1202 | 1201 | FROM {pm_index} pmia |
1203 | 1202 | WHERE pmia.thread_id = pmi.thread_id) AS participants'; |
1204 | 1203 | } |
1205 | - } |
|
1206 | - if (in_array('thread_started', $fields)) { |
|
1204 | + } |
|
1205 | + if (in_array('thread_started', $fields)) { |
|
1207 | 1206 | $fragments['select'][] = 'MIN(pm.timestamp) as thread_started'; |
1208 | - } |
|
1207 | + } |
|
1209 | 1208 | |
1210 | - $fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid'; |
|
1209 | + $fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid'; |
|
1211 | 1210 | |
1212 | - // Only load undeleted messages of the current user and group by thread. |
|
1213 | - $fragments['where'][] = 'pmi.uid = %d'; |
|
1214 | - $fragments['query_args']['where'][] = $account->uid; |
|
1215 | - $fragments['where'][] = 'pmi.deleted = 0'; |
|
1216 | - $fragments['group_by'][] = 'pmi.thread_id'; |
|
1211 | + // Only load undeleted messages of the current user and group by thread. |
|
1212 | + $fragments['where'][] = 'pmi.uid = %d'; |
|
1213 | + $fragments['query_args']['where'][] = $account->uid; |
|
1214 | + $fragments['where'][] = 'pmi.deleted = 0'; |
|
1215 | + $fragments['group_by'][] = 'pmi.thread_id'; |
|
1217 | 1216 | |
1218 | - $order_by_first = 'MAX(pmi.is_new) DESC, '; |
|
1219 | - // MySQL 4.1 does not allow to order by aggregate functions. MAX() is used |
|
1220 | - // to avoid a ordering bug with multiple new messages. |
|
1221 | - if ($GLOBALS['db_type'] != 'pgsql' && version_compare(db_version(), '5.0.0') < 0) { |
|
1217 | + $order_by_first = 'MAX(pmi.is_new) DESC, '; |
|
1218 | + // MySQL 4.1 does not allow to order by aggregate functions. MAX() is used |
|
1219 | + // to avoid a ordering bug with multiple new messages. |
|
1220 | + if ($GLOBALS['db_type'] != 'pgsql' && version_compare(db_version(), '5.0.0') < 0) { |
|
1222 | 1221 | $order_by_first = 'is_new DESC, '; |
1223 | - } |
|
1222 | + } |
|
1224 | 1223 | |
1225 | - // tablesort_sql() generates a ORDER BY string. However, the "ORDER BY " part |
|
1226 | - // is not needed and added by the query builder. Discard the first 9 |
|
1227 | - // characters of the string. |
|
1228 | - $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers( FALSE, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9); |
|
1229 | - $fragments['order_by'][] = $order_by; |
|
1224 | + // tablesort_sql() generates a ORDER BY string. However, the "ORDER BY " part |
|
1225 | + // is not needed and added by the query builder. Discard the first 9 |
|
1226 | + // characters of the string. |
|
1227 | + $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers( FALSE, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9); |
|
1228 | + $fragments['order_by'][] = $order_by; |
|
1230 | 1229 | } |
1231 | 1230 | |
1232 | 1231 | /** |
@@ -1240,27 +1239,27 @@ discard block |
||
1240 | 1239 | * Account for which the messages should be loaded. |
1241 | 1240 | */ |
1242 | 1241 | function privatemsg_sql_load(&$fragments, $pmids, $account = NULL) { |
1243 | - $fragments['primary_table'] = '{pm_message} pm'; |
|
1244 | - |
|
1245 | - $fragments['select'][] = "pm.mid"; |
|
1246 | - $fragments['select'][] = "pm.author"; |
|
1247 | - $fragments['select'][] = "pm.subject"; |
|
1248 | - $fragments['select'][] = "pm.body"; |
|
1249 | - $fragments['select'][] = "pm.timestamp"; |
|
1250 | - $fragments['select'][] = "pm.format"; |
|
1251 | - $fragments['select'][] = "pmi.is_new"; |
|
1252 | - $fragments['select'][] = "pmi.thread_id"; |
|
1253 | - |
|
1254 | - $fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid'; |
|
1255 | - // Use IN() to load multiple messages at the same time. |
|
1256 | - $fragments['where'][] = 'pmi.mid IN (' . db_placeholders($pmids) . ')'; |
|
1257 | - $fragments['query_args']['where'] += $pmids; |
|
1258 | - if ($account) { |
|
1242 | + $fragments['primary_table'] = '{pm_message} pm'; |
|
1243 | + |
|
1244 | + $fragments['select'][] = "pm.mid"; |
|
1245 | + $fragments['select'][] = "pm.author"; |
|
1246 | + $fragments['select'][] = "pm.subject"; |
|
1247 | + $fragments['select'][] = "pm.body"; |
|
1248 | + $fragments['select'][] = "pm.timestamp"; |
|
1249 | + $fragments['select'][] = "pm.format"; |
|
1250 | + $fragments['select'][] = "pmi.is_new"; |
|
1251 | + $fragments['select'][] = "pmi.thread_id"; |
|
1252 | + |
|
1253 | + $fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid'; |
|
1254 | + // Use IN() to load multiple messages at the same time. |
|
1255 | + $fragments['where'][] = 'pmi.mid IN (' . db_placeholders($pmids) . ')'; |
|
1256 | + $fragments['query_args']['where'] += $pmids; |
|
1257 | + if ($account) { |
|
1259 | 1258 | $fragments['where'][] = 'pmi.uid = %d'; |
1260 | 1259 | $fragments['query_args']['where'][] = $account->uid; |
1261 | - } |
|
1262 | - $fragments['order_by'][] = 'pm.timestamp ASC'; |
|
1263 | - $fragments['order_by'][] = 'pm.mid ASC'; |
|
1260 | + } |
|
1261 | + $fragments['order_by'][] = 'pm.timestamp ASC'; |
|
1262 | + $fragments['order_by'][] = 'pm.mid ASC'; |
|
1264 | 1263 | } |
1265 | 1264 | |
1266 | 1265 | /** |
@@ -1276,30 +1275,30 @@ discard block |
||
1276 | 1275 | * Deleted messages are only loaded if this is set to TRUE. |
1277 | 1276 | */ |
1278 | 1277 | function privatemsg_sql_messages(&$fragments, $threads, $account = NULL, $load_all = FALSE) { |
1279 | - $fragments['primary_table'] = '{pm_index} pmi'; |
|
1278 | + $fragments['primary_table'] = '{pm_index} pmi'; |
|
1280 | 1279 | |
1281 | - $fragments['select'][] = 'pmi.mid'; |
|
1282 | - $fragments['where'][] = 'pmi.thread_id IN ('. db_placeholders($threads) .')'; |
|
1283 | - $fragments['query_args']['where'] += $threads; |
|
1284 | - $fragments['inner_join'][] = 'INNER JOIN {pm_message} pm ON (pm.mid = pmi.mid)'; |
|
1285 | - if ($account) { |
|
1280 | + $fragments['select'][] = 'pmi.mid'; |
|
1281 | + $fragments['where'][] = 'pmi.thread_id IN ('. db_placeholders($threads) .')'; |
|
1282 | + $fragments['query_args']['where'] += $threads; |
|
1283 | + $fragments['inner_join'][] = 'INNER JOIN {pm_message} pm ON (pm.mid = pmi.mid)'; |
|
1284 | + if ($account) { |
|
1286 | 1285 | // Only load the user's messages. |
1287 | 1286 | $fragments['where'][] = 'pmi.uid = %d'; |
1288 | 1287 | $fragments['query_args']['where'][] = $account->uid; |
1289 | - } |
|
1290 | - if (!$load_all) { |
|
1288 | + } |
|
1289 | + if (!$load_all) { |
|
1291 | 1290 | // Also load deleted messages when requested. |
1292 | 1291 | $fragments['where'][] = 'pmi.deleted = 0'; |
1293 | - } |
|
1294 | - // Only load each mid once. |
|
1295 | - $fragments['group_by'][] = 'pmi.mid'; |
|
1296 | - $fragments['group_by'][] = 'pm.timestamp'; |
|
1292 | + } |
|
1293 | + // Only load each mid once. |
|
1294 | + $fragments['group_by'][] = 'pmi.mid'; |
|
1295 | + $fragments['group_by'][] = 'pm.timestamp'; |
|
1297 | 1296 | |
1298 | - // Order by timestamp first. |
|
1299 | - $fragments['order_by'][] = 'pm.timestamp ASC'; |
|
1300 | - // If there are multiple inserts during the same second (tests, for example) |
|
1301 | - // sort by mid second to have them in the same order as they were saved. |
|
1302 | - $fragments['order_by'][] = 'pmi.mid ASC'; |
|
1297 | + // Order by timestamp first. |
|
1298 | + $fragments['order_by'][] = 'pm.timestamp ASC'; |
|
1299 | + // If there are multiple inserts during the same second (tests, for example) |
|
1300 | + // sort by mid second to have them in the same order as they were saved. |
|
1301 | + $fragments['order_by'][] = 'pmi.mid ASC'; |
|
1303 | 1302 | |
1304 | 1303 | } |
1305 | 1304 | |
@@ -1312,16 +1311,16 @@ discard block |
||
1312 | 1311 | * Thread id from which the participants should be loaded. |
1313 | 1312 | */ |
1314 | 1313 | function privatemsg_sql_participants(&$fragments, $thread_id) { |
1315 | - $fragments['primary_table'] = '{pm_index} pmi'; |
|
1314 | + $fragments['primary_table'] = '{pm_index} pmi'; |
|
1316 | 1315 | |
1317 | - // Only load each participant once since they are listed as recipient for |
|
1318 | - // every message of that thread. |
|
1319 | - $fragments['select'][] = 'DISTINCT(pmi.uid) AS uid'; |
|
1320 | - $fragments['select'][] = 'u.name AS name'; |
|
1316 | + // Only load each participant once since they are listed as recipient for |
|
1317 | + // every message of that thread. |
|
1318 | + $fragments['select'][] = 'DISTINCT(pmi.uid) AS uid'; |
|
1319 | + $fragments['select'][] = 'u.name AS name'; |
|
1321 | 1320 | |
1322 | - $fragments['inner_join'][] = 'INNER JOIN {users} u ON (u.uid = pmi.uid)'; |
|
1323 | - $fragments['where'][] = 'pmi.thread_id = %d'; |
|
1324 | - $fragments['query_args']['where'][] = $thread_id; |
|
1321 | + $fragments['inner_join'][] = 'INNER JOIN {users} u ON (u.uid = pmi.uid)'; |
|
1322 | + $fragments['where'][] = 'pmi.thread_id = %d'; |
|
1323 | + $fragments['query_args']['where'][] = $thread_id; |
|
1325 | 1324 | } |
1326 | 1325 | |
1327 | 1326 | /** |
@@ -1333,15 +1332,15 @@ discard block |
||
1333 | 1332 | * User object for which the messages are being counted. |
1334 | 1333 | */ |
1335 | 1334 | function privatemsg_sql_unread_count(&$fragments, $account) { |
1336 | - $fragments['primary_table'] = '{pm_index} pmi'; |
|
1335 | + $fragments['primary_table'] = '{pm_index} pmi'; |
|
1337 | 1336 | |
1338 | - $fragments['select'][] = 'COUNT(DISTINCT thread_id) as unread_count'; |
|
1337 | + $fragments['select'][] = 'COUNT(DISTINCT thread_id) as unread_count'; |
|
1339 | 1338 | |
1340 | - // Only count new messages that have not been deleted. |
|
1341 | - $fragments['where'][] = 'pmi.deleted = 0'; |
|
1342 | - $fragments['where'][] = 'pmi.is_new = 1'; |
|
1343 | - $fragments['where'][] = 'pmi.uid = %d'; |
|
1344 | - $fragments['query_args']['where'][] = $account->uid; |
|
1339 | + // Only count new messages that have not been deleted. |
|
1340 | + $fragments['where'][] = 'pmi.deleted = 0'; |
|
1341 | + $fragments['where'][] = 'pmi.is_new = 1'; |
|
1342 | + $fragments['where'][] = 'pmi.uid = %d'; |
|
1343 | + $fragments['query_args']['where'][] = $account->uid; |
|
1345 | 1344 | } |
1346 | 1345 | |
1347 | 1346 | /** |
@@ -1355,27 +1354,27 @@ discard block |
||
1355 | 1354 | * Array of names not to be used as suggestions. |
1356 | 1355 | */ |
1357 | 1356 | function privatemsg_sql_autocomplete(&$fragments, $search, $names) { |
1358 | - // Select users from BOINC user table by name and id. The id is |
|
1359 | - // unique. |
|
1360 | - $fragments['primary_table'] = '{user} u'; |
|
1361 | - $fragments['select'][] = 'u.name,u.id'; |
|
1362 | - // Escape the % to get it through the placeholder replacement. |
|
1363 | - $fragments['where'][] = "u.name LIKE '%s'"; |
|
1364 | - $fragments['query_args']['where'][] = $search .'%%'; |
|
1365 | - if (!empty($names)) { |
|
1357 | + // Select users from BOINC user table by name and id. The id is |
|
1358 | + // unique. |
|
1359 | + $fragments['primary_table'] = '{user} u'; |
|
1360 | + $fragments['select'][] = 'u.name,u.id'; |
|
1361 | + // Escape the % to get it through the placeholder replacement. |
|
1362 | + $fragments['where'][] = "u.name LIKE '%s'"; |
|
1363 | + $fragments['query_args']['where'][] = $search .'%%'; |
|
1364 | + if (!empty($names)) { |
|
1366 | 1365 | // If there are already names selected, exclude them from the |
1367 | 1366 | // suggestions. Extract the BOINC ids from the names array, and |
1368 | 1367 | // use to remove query results. |
1369 | 1368 | $ids = array(); |
1370 | 1369 | foreach ($names as $name) { |
1371 | - $boincid = substr($name, strrpos($name, '_') + 1); |
|
1372 | - $ids[$boincid] = $boincid; |
|
1370 | + $boincid = substr($name, strrpos($name, '_') + 1); |
|
1371 | + $ids[$boincid] = $boincid; |
|
1373 | 1372 | } |
1374 | 1373 | $fragments['where'][] = "u.id NOT IN (". db_placeholders($ids, 'int') .")"; |
1375 | 1374 | $fragments['query_args']['where'] += $ids; |
1376 | - } |
|
1377 | - // Only load active users and sort them by name. |
|
1378 | - $fragments['order_by'][] = 'u.name ASC'; |
|
1375 | + } |
|
1376 | + // Only load active users and sort them by name. |
|
1377 | + $fragments['order_by'][] = 'u.name ASC'; |
|
1379 | 1378 | } |
1380 | 1379 | |
1381 | 1380 | /** |
@@ -1387,24 +1386,24 @@ discard block |
||
1387 | 1386 | * Select messages older than x days. |
1388 | 1387 | */ |
1389 | 1388 | function privatemsg_sql_deleted(&$fragments, $days) { |
1390 | - $fragments['primary_table'] = '{pm_message} pm'; |
|
1389 | + $fragments['primary_table'] = '{pm_message} pm'; |
|
1391 | 1390 | |
1392 | - $fragments['select'][] = 'pm.mid'; |
|
1393 | - // The lowest value is higher than 0 if all recipients have deleted a message. |
|
1394 | - $fragments['select'][] = 'MIN(pmi.deleted) as is_deleted'; |
|
1395 | - // The time the most recent deletion happened. |
|
1396 | - $fragments['select'][] = 'MAX(pmi.deleted) as last_deleted'; |
|
1391 | + $fragments['select'][] = 'pm.mid'; |
|
1392 | + // The lowest value is higher than 0 if all recipients have deleted a message. |
|
1393 | + $fragments['select'][] = 'MIN(pmi.deleted) as is_deleted'; |
|
1394 | + // The time the most recent deletion happened. |
|
1395 | + $fragments['select'][] = 'MAX(pmi.deleted) as last_deleted'; |
|
1397 | 1396 | |
1398 | - $fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON (pmi.mid = pm.mid)'; |
|
1397 | + $fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON (pmi.mid = pm.mid)'; |
|
1399 | 1398 | |
1400 | - $fragments['group_by'][] = 'pm.mid'; |
|
1399 | + $fragments['group_by'][] = 'pm.mid'; |
|
1401 | 1400 | |
1402 | - // Ignore messages that have not been deleted by all users. |
|
1403 | - $fragments['having'][] = 'MIN(pmi.deleted) > 0'; |
|
1401 | + // Ignore messages that have not been deleted by all users. |
|
1402 | + $fragments['having'][] = 'MIN(pmi.deleted) > 0'; |
|
1404 | 1403 | |
1405 | - // Only select messages that have been deleted more than n days ago. |
|
1406 | - $fragments['having'][] = 'MAX(pmi.deleted) < %d'; |
|
1407 | - $fragments['query_args']['having'][] = time() - $days * 86400; |
|
1404 | + // Only select messages that have been deleted more than n days ago. |
|
1405 | + $fragments['having'][] = 'MAX(pmi.deleted) < %d'; |
|
1406 | + $fragments['query_args']['having'][] = time() - $days * 86400; |
|
1408 | 1407 | } |
1409 | 1408 | |
1410 | 1409 | /** |
@@ -1417,19 +1416,19 @@ discard block |
||
1417 | 1416 | * Prevents usernames from being used and/or suggested twice. |
1418 | 1417 | */ |
1419 | 1418 | function privatemsg_user_name_autocomplete($string) { |
1420 | - $names = array(); |
|
1421 | - // 1: Parse $string and build list of valid user names. |
|
1422 | - $fragments = explode(', ', $string); |
|
1423 | - foreach ($fragments as $index => $name) { |
|
1419 | + $names = array(); |
|
1420 | + // 1: Parse $string and build list of valid user names. |
|
1421 | + $fragments = explode(', ', $string); |
|
1422 | + foreach ($fragments as $index => $name) { |
|
1424 | 1423 | if ($name = trim($name)) { |
1425 | - $names[$name] = $name; |
|
1426 | - } |
|
1427 | - } |
|
1428 | - // By using user_validate_user we can ensure that names included in $names are at least logisticaly possible. |
|
1429 | - // 2: Find the next user name suggestion. |
|
1430 | - $fragment = array_pop($names); |
|
1431 | - $matches = array(); |
|
1432 | - if (!empty($fragment)) { |
|
1424 | + $names[$name] = $name; |
|
1425 | + } |
|
1426 | + } |
|
1427 | + // By using user_validate_user we can ensure that names included in $names are at least logisticaly possible. |
|
1428 | + // 2: Find the next user name suggestion. |
|
1429 | + $fragment = array_pop($names); |
|
1430 | + $matches = array(); |
|
1431 | + if (!empty($fragment)) { |
|
1433 | 1432 | $query = _privatemsg_assemble_query('autocomplete', $fragment, $names); |
1434 | 1433 | db_set_active('boinc_rw'); |
1435 | 1434 | $result = db_query_range($query['query'], $fragment, 0, 10); |
@@ -1437,175 +1436,175 @@ discard block |
||
1437 | 1436 | $prefix = count($names) ? implode(', ', $names) . ', ' : ''; |
1438 | 1437 | // 3: Build proper suggestions and print. |
1439 | 1438 | while ($user = db_fetch_object($result)) { |
1440 | - $myname = preg_replace("/ /", "\xc2\xa0", $user->name); |
|
1441 | - $matches[$prefix . $myname . "_" . $user->id . ', '] = htmlentities($myname) . ' (' . $user->id . ')'; |
|
1439 | + $myname = preg_replace("/ /", "\xc2\xa0", $user->name); |
|
1440 | + $matches[$prefix . $myname . "_" . $user->id . ', '] = htmlentities($myname) . ' (' . $user->id . ')'; |
|
1442 | 1441 | } |
1443 | - } |
|
1444 | - // convert to object to prevent drupal bug, see http://drupal.org/node/175361 |
|
1445 | - drupal_json((object)$matches); |
|
1442 | + } |
|
1443 | + // convert to object to prevent drupal bug, see http://drupal.org/node/175361 |
|
1444 | + drupal_json((object)$matches); |
|
1446 | 1445 | } |
1447 | 1446 | |
1448 | 1447 | function privatemsg_user($op, &$edit, &$account, $category = NULL) { |
1449 | - global $user; |
|
1448 | + global $user; |
|
1450 | 1449 | |
1451 | - switch ($op) { |
|
1450 | + switch ($op) { |
|
1452 | 1451 | case 'view': |
1453 | 1452 | if ($url = privatemsg_get_link(array($account))) { |
1454 | 1453 | $account->content['privatemsg_send_new_message'] = array( |
1455 | - '#type' => 'markup', |
|
1456 | - '#value' => l(t('Send this user a message'), $url, array('query' => drupal_get_destination())), |
|
1457 | - '#weight' => 10, |
|
1454 | + '#type' => 'markup', |
|
1455 | + '#value' => l(t('Send this user a message'), $url, array('query' => drupal_get_destination())), |
|
1456 | + '#weight' => 10, |
|
1458 | 1457 | ); |
1459 | - } |
|
1460 | - break; |
|
1458 | + } |
|
1459 | + break; |
|
1461 | 1460 | case 'login': |
1462 | 1461 | if (variable_get('privatemsg_display_loginmessage', TRUE) && privatemsg_user_access()) { |
1463 | 1462 | $count = privatemsg_unread_count(); |
1464 | 1463 | if ($count) { |
1465 | - drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages')))); |
|
1464 | + drupal_set_message(format_plural($count, 'You have <a href="@messages">1 unread message</a>.', 'You have <a href="@messages">@count unread messages</a>', array('@messages' => url('messages')))); |
|
1466 | 1465 | } |
1467 | - } |
|
1468 | - break; |
|
1466 | + } |
|
1467 | + break; |
|
1469 | 1468 | case 'delete': |
1470 | 1469 | |
1471 | 1470 | // Load all mids of the messages the user wrote. |
1472 | 1471 | $result = db_query("SELECT mid FROM {pm_message} WHERE author = %d", $account->uid); |
1473 | - $mids = array(); |
|
1474 | - while ($row = db_fetch_array($result)) { |
|
1472 | + $mids = array(); |
|
1473 | + while ($row = db_fetch_array($result)) { |
|
1475 | 1474 | $mids[] = $row['mid']; |
1476 | - } |
|
1475 | + } |
|
1477 | 1476 | |
1478 | - // Delete messages the user wrote. |
|
1479 | - db_query('DELETE FROM {pm_message} WHERE author = %d', $account->uid); |
|
1477 | + // Delete messages the user wrote. |
|
1478 | + db_query('DELETE FROM {pm_message} WHERE author = %d', $account->uid); |
|
1480 | 1479 | |
1481 | - if (!empty($mids)) { |
|
1480 | + if (!empty($mids)) { |
|
1482 | 1481 | // Delete recipient entries in {pm_index} of the messages the user wrote. |
1483 | 1482 | db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids); |
1484 | - } |
|
1483 | + } |
|
1485 | 1484 | |
1486 | - // Delete recipient entries of that user. |
|
1487 | - db_query('DELETE FROM {pm_index} WHERE uid = %d', $account->uid); |
|
1488 | - break; |
|
1489 | - } |
|
1485 | + // Delete recipient entries of that user. |
|
1486 | + db_query('DELETE FROM {pm_index} WHERE uid = %d', $account->uid); |
|
1487 | + break; |
|
1488 | + } |
|
1490 | 1489 | } |
1491 | 1490 | |
1492 | 1491 | function privatemsg_block($op = 'list', $delta = 0, $edit = array()) { |
1493 | - if ('list' == $op) { |
|
1492 | + if ('list' == $op) { |
|
1494 | 1493 | $blocks = array(); |
1495 | 1494 | $blocks['privatemsg-menu'] = array( |
1496 | - 'info' => t('Privatemsg links'), |
|
1497 | - 'cache' => BLOCK_NO_CACHE, |
|
1495 | + 'info' => t('Privatemsg links'), |
|
1496 | + 'cache' => BLOCK_NO_CACHE, |
|
1498 | 1497 | ); |
1499 | 1498 | $blocks['privatemsg-new'] = array( |
1500 | - 'info' => t('New message indication'), |
|
1501 | - 'cache' => BLOCK_NO_CACHE, |
|
1499 | + 'info' => t('New message indication'), |
|
1500 | + 'cache' => BLOCK_NO_CACHE, |
|
1502 | 1501 | ); |
1503 | 1502 | |
1504 | 1503 | return $blocks; |
1505 | - } |
|
1506 | - elseif ('view' == $op) { |
|
1504 | + } |
|
1505 | + elseif ('view' == $op) { |
|
1507 | 1506 | $block = array(); |
1508 | 1507 | switch ($delta) { |
1509 | - case 'privatemsg-menu': |
|
1508 | + case 'privatemsg-menu': |
|
1510 | 1509 | $block = _privatemsg_block_menu(); |
1511 | 1510 | break; |
1512 | - case 'privatemsg-new': |
|
1511 | + case 'privatemsg-new': |
|
1513 | 1512 | $block = _privatemsg_block_new(); |
1514 | 1513 | break; |
1515 | 1514 | } |
1516 | 1515 | return $block; |
1517 | - } |
|
1516 | + } |
|
1518 | 1517 | } |
1519 | 1518 | |
1520 | 1519 | function privatemsg_title_callback($title = NULL) { |
1521 | - $count = privatemsg_unread_count(); |
|
1520 | + $count = privatemsg_unread_count(); |
|
1522 | 1521 | |
1523 | - if ($count > 0) { |
|
1522 | + if ($count > 0) { |
|
1524 | 1523 | return format_plural($count, 'Messages (1 new)', 'Messages (@count new)'); |
1525 | - } |
|
1526 | - return t('Messages'); |
|
1524 | + } |
|
1525 | + return t('Messages'); |
|
1527 | 1526 | } |
1528 | 1527 | |
1529 | 1528 | |
1530 | 1529 | function _privatemsg_block_new() { |
1531 | - $block = array(); |
|
1530 | + $block = array(); |
|
1532 | 1531 | |
1533 | - if (!privatemsg_user_access()) { |
|
1532 | + if (!privatemsg_user_access()) { |
|
1534 | 1533 | return $block; |
1535 | - } |
|
1534 | + } |
|
1536 | 1535 | |
1537 | - $count = privatemsg_unread_count(); |
|
1538 | - if ($count) { |
|
1536 | + $count = privatemsg_unread_count(); |
|
1537 | + if ($count) { |
|
1539 | 1538 | $block = array( |
1540 | - 'subject' => format_plural($count, 'New message', 'New messages'), |
|
1541 | - 'content' => theme('privatemsg_new_block', $count), |
|
1539 | + 'subject' => format_plural($count, 'New message', 'New messages'), |
|
1540 | + 'content' => theme('privatemsg_new_block', $count), |
|
1542 | 1541 | ); |
1543 | 1542 | return $block; |
1544 | - } |
|
1545 | - return array(); |
|
1543 | + } |
|
1544 | + return array(); |
|
1546 | 1545 | } |
1547 | 1546 | |
1548 | 1547 | function _privatemsg_block_menu() { |
1549 | - $block = array(); |
|
1548 | + $block = array(); |
|
1550 | 1549 | |
1551 | - $links = array(); |
|
1552 | - if (privatemsg_user_access('write privatemsg')) { |
|
1550 | + $links = array(); |
|
1551 | + if (privatemsg_user_access('write privatemsg')) { |
|
1553 | 1552 | $links[] = l(t('Write new message'), 'messages/new'); |
1554 | - } |
|
1555 | - if (privatemsg_user_access('read privatemsg') || privatemsg_user_access('read all private messages') ) { |
|
1553 | + } |
|
1554 | + if (privatemsg_user_access('read privatemsg') || privatemsg_user_access('read all private messages') ) { |
|
1556 | 1555 | $links[] = l(privatemsg_title_callback(), 'messages'); |
1557 | - } |
|
1558 | - if ( count( $links ) ) { |
|
1556 | + } |
|
1557 | + if ( count( $links ) ) { |
|
1559 | 1558 | $block = array( |
1560 | - 'subject' => t('Private messages'), |
|
1561 | - 'content' => theme('item_list', $links), |
|
1559 | + 'subject' => t('Private messages'), |
|
1560 | + 'content' => theme('item_list', $links), |
|
1562 | 1561 | ); |
1563 | - } |
|
1564 | - return $block; |
|
1562 | + } |
|
1563 | + return $block; |
|
1565 | 1564 | } |
1566 | 1565 | |
1567 | 1566 | function privatemsg_delete($form_state, $thread, $message) { |
1568 | - $form['pmid'] = array( |
|
1567 | + $form['pmid'] = array( |
|
1569 | 1568 | '#type' => 'value', |
1570 | 1569 | '#value' => $message['mid'], |
1571 | - ); |
|
1572 | - $form['delete_destination'] = array( |
|
1570 | + ); |
|
1571 | + $form['delete_destination'] = array( |
|
1573 | 1572 | '#type' => 'value', |
1574 | 1573 | '#value' => count($thread['messages']) > 1 ? 'messages/view/' . $message['thread_id'] : 'messages', |
1575 | - ); |
|
1574 | + ); |
|
1576 | 1575 | |
1577 | - if (privatemsg_user_access('read all private messages')) { |
|
1576 | + if (privatemsg_user_access('read all private messages')) { |
|
1578 | 1577 | $form['delete_options'] = array( |
1579 | - '#type' => 'checkbox', |
|
1580 | - '#title' => t('Delete this message for all users?'), |
|
1581 | - '#description' => t('Tick the box to delete the message for all users.'), |
|
1582 | - '#default_value' => FALSE, |
|
1578 | + '#type' => 'checkbox', |
|
1579 | + '#title' => t('Delete this message for all users?'), |
|
1580 | + '#description' => t('Tick the box to delete the message for all users.'), |
|
1581 | + '#default_value' => FALSE, |
|
1583 | 1582 | ); |
1584 | - } |
|
1585 | - return confirm_form($form, |
|
1583 | + } |
|
1584 | + return confirm_form($form, |
|
1586 | 1585 | t('Are you sure you want to delete this message?'), |
1587 | 1586 | isset($_GET['destination']) ? $_GET['destination'] : 'messages/view/'. $message['thread_id'], |
1588 | 1587 | t('This action cannot be undone.'), |
1589 | 1588 | t('Delete'), |
1590 | 1589 | t('Cancel') |
1591 | - ); |
|
1590 | + ); |
|
1592 | 1591 | } |
1593 | 1592 | |
1594 | 1593 | function privatemsg_delete_submit($form, &$form_state) { |
1595 | - global $user; |
|
1596 | - $account = drupal_clone($user); |
|
1594 | + global $user; |
|
1595 | + $account = drupal_clone($user); |
|
1597 | 1596 | |
1598 | - if ($form_state['values']['confirm']) { |
|
1597 | + if ($form_state['values']['confirm']) { |
|
1599 | 1598 | if (isset($form_state['values']['delete_options']) && $form_state['values']['delete_options']) { |
1600 | - privatemsg_message_change_delete($form_state['values']['pmid'], 1); |
|
1601 | - drupal_set_message(t('Message has been deleted for all users.')); |
|
1599 | + privatemsg_message_change_delete($form_state['values']['pmid'], 1); |
|
1600 | + drupal_set_message(t('Message has been deleted for all users.')); |
|
1602 | 1601 | } |
1603 | 1602 | else { |
1604 | - privatemsg_message_change_delete($form_state['values']['pmid'], 1, $account); |
|
1605 | - drupal_set_message(t('Message has been deleted.')); |
|
1603 | + privatemsg_message_change_delete($form_state['values']['pmid'], 1, $account); |
|
1604 | + drupal_set_message(t('Message has been deleted.')); |
|
1606 | 1605 | } |
1607 | - } |
|
1608 | - $form_state['redirect'] = $form_state['values']['delete_destination']; |
|
1606 | + } |
|
1607 | + $form_state['redirect'] = $form_state['values']['delete_destination']; |
|
1609 | 1608 | } |
1610 | 1609 | |
1611 | 1610 | /** |
@@ -1622,18 +1621,18 @@ discard block |
||
1622 | 1621 | * @ingroup api |
1623 | 1622 | */ |
1624 | 1623 | function privatemsg_message_change_delete($pmid, $delete, $account = NULL) { |
1625 | - $delete_value = 0; |
|
1626 | - if ($delete == TRUE) { |
|
1624 | + $delete_value = 0; |
|
1625 | + if ($delete == TRUE) { |
|
1627 | 1626 | $delete_value = time(); |
1628 | - } |
|
1627 | + } |
|
1629 | 1628 | |
1630 | - if ($account) { |
|
1629 | + if ($account) { |
|
1631 | 1630 | db_query('UPDATE {pm_index} SET deleted = %d WHERE mid = %d AND uid = %d', $delete_value, $pmid, $account->uid); |
1632 | - } |
|
1633 | - else { |
|
1631 | + } |
|
1632 | + else { |
|
1634 | 1633 | // Mark deleted for all users. |
1635 | 1634 | db_query('UPDATE {pm_index} SET deleted = %d WHERE mid = %d', $delete_value, $pmid); |
1636 | - } |
|
1635 | + } |
|
1637 | 1636 | } |
1638 | 1637 | |
1639 | 1638 | /** |
@@ -1676,35 +1675,35 @@ discard block |
||
1676 | 1675 | * @ingroup api |
1677 | 1676 | */ |
1678 | 1677 | function privatemsg_new_thread($recipients, $subject, $body = NULL, $options = array()) { |
1679 | - global $user; |
|
1680 | - $author = drupal_clone($user); |
|
1681 | - |
|
1682 | - $message = array(); |
|
1683 | - $message['subject'] = $subject; |
|
1684 | - $message['body'] = $body; |
|
1685 | - // Make sure that recipients are keyed by user id and are not added |
|
1686 | - // multiple times. |
|
1687 | - foreach ($recipients as $recipient) { |
|
1678 | + global $user; |
|
1679 | + $author = drupal_clone($user); |
|
1680 | + |
|
1681 | + $message = array(); |
|
1682 | + $message['subject'] = $subject; |
|
1683 | + $message['body'] = $body; |
|
1684 | + // Make sure that recipients are keyed by user id and are not added |
|
1685 | + // multiple times. |
|
1686 | + foreach ($recipients as $recipient) { |
|
1688 | 1687 | $message['recipients'][$recipient->uid] = $recipient; |
1689 | - } |
|
1688 | + } |
|
1690 | 1689 | |
1691 | - // Set custom options, if any. |
|
1692 | - if (!empty($options)) { |
|
1690 | + // Set custom options, if any. |
|
1691 | + if (!empty($options)) { |
|
1693 | 1692 | $message += $options; |
1694 | - } |
|
1695 | - // Apply defaults - this will not overwrite existing keys. |
|
1696 | - $message += array( |
|
1693 | + } |
|
1694 | + // Apply defaults - this will not overwrite existing keys. |
|
1695 | + $message += array( |
|
1697 | 1696 | 'author' => $author, |
1698 | 1697 | 'timestamp' => time(), |
1699 | 1698 | 'format' => filter_resolve_format(FILTER_FORMAT_DEFAULT), |
1700 | - ); |
|
1699 | + ); |
|
1701 | 1700 | |
1702 | - $validated = _privatemsg_validate_message($message); |
|
1703 | - if ($validated['success']) { |
|
1701 | + $validated = _privatemsg_validate_message($message); |
|
1702 | + if ($validated['success']) { |
|
1704 | 1703 | $validated['message'] = _privatemsg_send($message); |
1705 | - } |
|
1704 | + } |
|
1706 | 1705 | |
1707 | - return $validated; |
|
1706 | + return $validated; |
|
1708 | 1707 | } |
1709 | 1708 | |
1710 | 1709 | /** |
@@ -1741,144 +1740,144 @@ discard block |
||
1741 | 1740 | * @ingroup api |
1742 | 1741 | */ |
1743 | 1742 | function privatemsg_reply($thread_id, $body, $options = array()) { |
1744 | - global $user; |
|
1745 | - $author = drupal_clone($user); |
|
1743 | + global $user; |
|
1744 | + $author = drupal_clone($user); |
|
1746 | 1745 | |
1747 | - $message = array(); |
|
1748 | - $message['body'] = $body; |
|
1746 | + $message = array(); |
|
1747 | + $message['body'] = $body; |
|
1749 | 1748 | |
1750 | - // set custom options, if any |
|
1751 | - if (!empty($options)) { |
|
1749 | + // set custom options, if any |
|
1750 | + if (!empty($options)) { |
|
1752 | 1751 | $message += $options; |
1753 | - } |
|
1754 | - // apply defaults |
|
1755 | - $message += array( |
|
1752 | + } |
|
1753 | + // apply defaults |
|
1754 | + $message += array( |
|
1756 | 1755 | 'author' => $author, |
1757 | 1756 | 'timestamp' => time(), |
1758 | 1757 | 'format' => filter_resolve_format(FILTER_FORMAT_DEFAULT), |
1759 | - ); |
|
1758 | + ); |
|
1760 | 1759 | |
1761 | - // We don't know the subject and the recipients, so we need to load them.. |
|
1762 | - // thread_id == mid on the first message of the thread |
|
1763 | - $first_message = privatemsg_message_load($thread_id, $message['author']); |
|
1764 | - if (!$first_message) { |
|
1760 | + // We don't know the subject and the recipients, so we need to load them.. |
|
1761 | + // thread_id == mid on the first message of the thread |
|
1762 | + $first_message = privatemsg_message_load($thread_id, $message['author']); |
|
1763 | + if (!$first_message) { |
|
1765 | 1764 | return array(t('Thread %thread_id not found, unable to answer', array('%thread_id' => $thread_id))); |
1766 | - } |
|
1765 | + } |
|
1767 | 1766 | |
1768 | - $message['thread_id'] = $thread_id; |
|
1769 | - // Load participants. |
|
1770 | - $message['recipients'] = _privatemsg_load_thread_participants($thread_id); |
|
1771 | - // Remove author. |
|
1772 | - if (isset($message['recipients'][$message['author']->uid]) && count($message['recipients']) > 1) { |
|
1767 | + $message['thread_id'] = $thread_id; |
|
1768 | + // Load participants. |
|
1769 | + $message['recipients'] = _privatemsg_load_thread_participants($thread_id); |
|
1770 | + // Remove author. |
|
1771 | + if (isset($message['recipients'][$message['author']->uid]) && count($message['recipients']) > 1) { |
|
1773 | 1772 | unset($message['recipients'][$message['author']->uid]); |
1774 | - } |
|
1775 | - $message['subject'] = $first_message['subject']; |
|
1773 | + } |
|
1774 | + $message['subject'] = $first_message['subject']; |
|
1776 | 1775 | |
1777 | - $validated = _privatemsg_validate_message($message); |
|
1778 | - if ($validated['success']) { |
|
1776 | + $validated = _privatemsg_validate_message($message); |
|
1777 | + if ($validated['success']) { |
|
1779 | 1778 | $validated['message'] = _privatemsg_send($message); |
1780 | - } |
|
1781 | - return $validated; |
|
1779 | + } |
|
1780 | + return $validated; |
|
1782 | 1781 | } |
1783 | 1782 | |
1784 | 1783 | function _privatemsg_validate_message(&$message, $form = FALSE) { |
1785 | - $messages = array('error' => array(), 'warning' => array()); |
|
1786 | - if (!privatemsg_user_access('write privatemsg', $message['author'])) { |
|
1784 | + $messages = array('error' => array(), 'warning' => array()); |
|
1785 | + if (!privatemsg_user_access('write privatemsg', $message['author'])) { |
|
1787 | 1786 | // no need to do further checks in this case... |
1788 | 1787 | if ($form) { |
1789 | - form_set_error('author', t('User @user is not allowed to write messages', array('@user' => $message['author']->name))); |
|
1790 | - return array( |
|
1788 | + form_set_error('author', t('User @user is not allowed to write messages', array('@user' => $message['author']->name))); |
|
1789 | + return array( |
|
1791 | 1790 | 'success' => FALSE, |
1792 | 1791 | 'messages' => $messages, |
1793 | - ); |
|
1792 | + ); |
|
1794 | 1793 | } |
1795 | 1794 | else { |
1796 | - $messages['error'][] = t('User @user is not allowed to write messages', array('@user' => $message['author']->name)); |
|
1797 | - return array( |
|
1798 | - 'success' => FALSE, |
|
1799 | - 'messages' => $messages, |
|
1800 | - ); |
|
1795 | + $messages['error'][] = t('User @user is not allowed to write messages', array('@user' => $message['author']->name)); |
|
1796 | + return array( |
|
1797 | + 'success' => FALSE, |
|
1798 | + 'messages' => $messages, |
|
1799 | + ); |
|
1800 | + } |
|
1801 | 1801 | } |
1802 | - } |
|
1803 | 1802 | |
1804 | - // Prevent subjects which only consist of a space as these can not be clicked. |
|
1805 | - $message['subject'] = trim($message['subject']); |
|
1806 | - if (empty($message['subject'])) { |
|
1803 | + // Prevent subjects which only consist of a space as these can not be clicked. |
|
1804 | + $message['subject'] = trim($message['subject']); |
|
1805 | + if (empty($message['subject'])) { |
|
1807 | 1806 | if ($form) { |
1808 | - form_set_error('subject', t('Disallowed to send a message without subject')); |
|
1807 | + form_set_error('subject', t('Disallowed to send a message without subject')); |
|
1809 | 1808 | } |
1810 | 1809 | else { |
1811 | - $messages['error'][] = t('Disallowed to send a message without subject'); |
|
1810 | + $messages['error'][] = t('Disallowed to send a message without subject'); |
|
1811 | + } |
|
1812 | 1812 | } |
1813 | - } |
|
1814 | 1813 | |
1815 | - // Don't allow replies without a body. |
|
1816 | - if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '') ) { |
|
1814 | + // Don't allow replies without a body. |
|
1815 | + if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '') ) { |
|
1817 | 1816 | if ($form) { |
1818 | - form_set_error('body', t('Disallowed to send reply without a message.')); |
|
1817 | + form_set_error('body', t('Disallowed to send reply without a message.')); |
|
1819 | 1818 | } |
1820 | 1819 | else { |
1821 | - $messages['error'][] = t('Disallowed to send reply without a message.'); |
|
1820 | + $messages['error'][] = t('Disallowed to send reply without a message.'); |
|
1821 | + } |
|
1822 | 1822 | } |
1823 | - } |
|
1824 | - // Check if an allowed format is used. global $user needs to be changed since |
|
1825 | - // it is not possible to do the check for a specific user. |
|
1826 | - global $user; |
|
1827 | - $original_user = drupal_clone($user); |
|
1828 | - session_save_session(FALSE); |
|
1829 | - $user = $message['author']; |
|
1823 | + // Check if an allowed format is used. global $user needs to be changed since |
|
1824 | + // it is not possible to do the check for a specific user. |
|
1825 | + global $user; |
|
1826 | + $original_user = drupal_clone($user); |
|
1827 | + session_save_session(FALSE); |
|
1828 | + $user = $message['author']; |
|
1830 | 1829 | |
1831 | - if (!filter_access($message['format'])) { |
|
1830 | + if (!filter_access($message['format'])) { |
|
1832 | 1831 | if ($form) { |
1833 | - form_set_error('format', t('You are not allowed to use the specified input format.')); |
|
1832 | + form_set_error('format', t('You are not allowed to use the specified input format.')); |
|
1834 | 1833 | } |
1835 | 1834 | else { |
1836 | - $messages['error'][] = t('User @user is not allowed to use the specified input format.', array('@user' => $message['author']->name)); |
|
1835 | + $messages['error'][] = t('User @user is not allowed to use the specified input format.', array('@user' => $message['author']->name)); |
|
1836 | + } |
|
1837 | 1837 | } |
1838 | - } |
|
1839 | 1838 | |
1840 | - $user = $original_user; |
|
1841 | - session_save_session(TRUE); |
|
1839 | + $user = $original_user; |
|
1840 | + session_save_session(TRUE); |
|
1842 | 1841 | |
1843 | - if (empty($message['recipients']) || !is_array($message['recipients'])) { |
|
1842 | + if (empty($message['recipients']) || !is_array($message['recipients'])) { |
|
1844 | 1843 | if ($form) { |
1845 | - form_set_error('to', t('Disallowed to send a message without at least one valid recipient')); |
|
1844 | + form_set_error('to', t('Disallowed to send a message without at least one valid recipient')); |
|
1846 | 1845 | } |
1847 | 1846 | else { |
1848 | - $messages['error'][] = t('Disallowed to send a message without at least one valid recipient'); |
|
1847 | + $messages['error'][] = t('Disallowed to send a message without at least one valid recipient'); |
|
1848 | + } |
|
1849 | 1849 | } |
1850 | - } |
|
1851 | 1850 | |
1852 | - if (!empty($message['recipients']) && is_array($message['recipients'])) { |
|
1851 | + if (!empty($message['recipients']) && is_array($message['recipients'])) { |
|
1853 | 1852 | foreach (module_invoke_all('privatemsg_block_message', $message['author'], $message['recipients']) as $blocked) { |
1854 | - unset($message['recipients'][$blocked['uid']]); |
|
1855 | - if ($form) { |
|
1853 | + unset($message['recipients'][$blocked['uid']]); |
|
1854 | + if ($form) { |
|
1856 | 1855 | drupal_set_message($blocked['message'], 'warning'); |
1857 | - } |
|
1858 | - else { |
|
1856 | + } |
|
1857 | + else { |
|
1859 | 1858 | $messages['warning'][] = $blocked['message']; |
1860 | - } |
|
1859 | + } |
|
1860 | + } |
|
1861 | 1861 | } |
1862 | - } |
|
1863 | 1862 | |
1864 | - // Check again, give another error message if all recipients are blocked |
|
1865 | - if (empty($message['recipients'])) { |
|
1863 | + // Check again, give another error message if all recipients are blocked |
|
1864 | + if (empty($message['recipients'])) { |
|
1866 | 1865 | if ($form) { |
1867 | - form_set_error('to', t('Disallowed to send message because all recipients are blocked')); |
|
1866 | + form_set_error('to', t('Disallowed to send message because all recipients are blocked')); |
|
1868 | 1867 | } |
1869 | 1868 | else { |
1870 | - $messages['error'][] = t('Disallowed to send message because all recipients are blocked'); |
|
1869 | + $messages['error'][] = t('Disallowed to send message because all recipients are blocked'); |
|
1870 | + } |
|
1871 | 1871 | } |
1872 | - } |
|
1873 | 1872 | |
1874 | - $messages = array_merge_recursive(module_invoke_all('privatemsg_message_validate', $message, $form), $messages); |
|
1873 | + $messages = array_merge_recursive(module_invoke_all('privatemsg_message_validate', $message, $form), $messages); |
|
1875 | 1874 | |
1876 | - // Check if there are errors in $messages or if $form is TRUE, there are form errors. |
|
1877 | - $success = empty($messages['error']) || ($form && count((array)form_get_errors()) > 0); |
|
1878 | - return array( |
|
1875 | + // Check if there are errors in $messages or if $form is TRUE, there are form errors. |
|
1876 | + $success = empty($messages['error']) || ($form && count((array)form_get_errors()) > 0); |
|
1877 | + return array( |
|
1879 | 1878 | 'success' => $success, |
1880 | 1879 | 'messages' => $messages, |
1881 | - ); |
|
1880 | + ); |
|
1882 | 1881 | } |
1883 | 1882 | |
1884 | 1883 | /** |
@@ -1894,61 +1893,61 @@ discard block |
||
1894 | 1893 | */ |
1895 | 1894 | function _privatemsg_send($message) { |
1896 | 1895 | |
1897 | - drupal_alter('privatemsg_message_presave', $message); |
|
1896 | + drupal_alter('privatemsg_message_presave', $message); |
|
1898 | 1897 | |
1899 | - $index_sql = "INSERT INTO {pm_index} (mid, thread_id, uid, is_new, deleted) VALUES (%d, %d, %d, %d, 0)"; |
|
1900 | - if (isset($message['read_all']) && $message['read_all']) { |
|
1898 | + $index_sql = "INSERT INTO {pm_index} (mid, thread_id, uid, is_new, deleted) VALUES (%d, %d, %d, %d, 0)"; |
|
1899 | + if (isset($message['read_all']) && $message['read_all']) { |
|
1901 | 1900 | // The message was sent in read all mode, add the author as recipient to all |
1902 | 1901 | // existing messages. |
1903 | 1902 | $query_messages = _privatemsg_assemble_query('messages', array($message['thread_id']), NULL); |
1904 | 1903 | $conversation = db_query($query_messages['query']); |
1905 | 1904 | while ($result = db_fetch_array($conversation)) { |
1906 | - if (!db_query($index_sql, $result['mid'], $message['thread_id'], $message['author']->uid, 0)) { |
|
1905 | + if (!db_query($index_sql, $result['mid'], $message['thread_id'], $message['author']->uid, 0)) { |
|
1907 | 1906 | return FALSE; |
1908 | - } |
|
1909 | - } |
|
1910 | - } |
|
1911 | - |
|
1912 | - // 1) Save the message body first. |
|
1913 | - $args = array(); |
|
1914 | - $args[] = $message['subject']; |
|
1915 | - $args[] = $message['author']->uid; |
|
1916 | - $args[] = $message['body']; |
|
1917 | - $args[] = $message['format']; |
|
1918 | - $args[] = $message['timestamp']; |
|
1919 | - $message_sql = "INSERT INTO {pm_message} (subject, author, body, format, timestamp) VALUES ('%s', %d, '%s', %d, %d)"; |
|
1920 | - db_query($message_sql, $args); |
|
1921 | - $mid = db_last_insert_id('pm_message', 'mid'); |
|
1922 | - $message['mid'] = $mid; |
|
1923 | - |
|
1924 | - // Thread ID is the same as the mid if it's the first message in the thread. |
|
1925 | - if (!isset($message['thread_id'])) { |
|
1907 | + } |
|
1908 | + } |
|
1909 | + } |
|
1910 | + |
|
1911 | + // 1) Save the message body first. |
|
1912 | + $args = array(); |
|
1913 | + $args[] = $message['subject']; |
|
1914 | + $args[] = $message['author']->uid; |
|
1915 | + $args[] = $message['body']; |
|
1916 | + $args[] = $message['format']; |
|
1917 | + $args[] = $message['timestamp']; |
|
1918 | + $message_sql = "INSERT INTO {pm_message} (subject, author, body, format, timestamp) VALUES ('%s', %d, '%s', %d, %d)"; |
|
1919 | + db_query($message_sql, $args); |
|
1920 | + $mid = db_last_insert_id('pm_message', 'mid'); |
|
1921 | + $message['mid'] = $mid; |
|
1922 | + |
|
1923 | + // Thread ID is the same as the mid if it's the first message in the thread. |
|
1924 | + if (!isset($message['thread_id'])) { |
|
1926 | 1925 | $message['thread_id'] = $mid; |
1927 | - } |
|
1926 | + } |
|
1928 | 1927 | |
1929 | - // 2) Save message to recipients. |
|
1930 | - // Each recipient gets a record in the pm_index table. |
|
1931 | - foreach ($message['recipients'] as $recipient) { |
|
1928 | + // 2) Save message to recipients. |
|
1929 | + // Each recipient gets a record in the pm_index table. |
|
1930 | + foreach ($message['recipients'] as $recipient) { |
|
1932 | 1931 | if (!db_query($index_sql, $mid, $message['thread_id'], $recipient->uid, 1) ) { |
1933 | - // We assume if one insert failed then the rest may fail too against the |
|
1934 | - // same table. |
|
1935 | - return FALSE; |
|
1932 | + // We assume if one insert failed then the rest may fail too against the |
|
1933 | + // same table. |
|
1934 | + return FALSE; |
|
1935 | + } |
|
1936 | 1936 | } |
1937 | - } |
|
1938 | 1937 | |
1939 | - // When author is also the recipient, we want to set message to UNREAD. |
|
1940 | - // All other times the message is set to READ. |
|
1941 | - $is_new = isset($message['recipients'][$message['author']->uid]) ? 1 : 0; |
|
1938 | + // When author is also the recipient, we want to set message to UNREAD. |
|
1939 | + // All other times the message is set to READ. |
|
1940 | + $is_new = isset($message['recipients'][$message['author']->uid]) ? 1 : 0; |
|
1942 | 1941 | |
1943 | - // Also add a record for the author to the pm_index table. |
|
1944 | - if (!db_query($index_sql, $mid, $message['thread_id'], $message['author']->uid, $is_new)) { |
|
1942 | + // Also add a record for the author to the pm_index table. |
|
1943 | + if (!db_query($index_sql, $mid, $message['thread_id'], $message['author']->uid, $is_new)) { |
|
1945 | 1944 | return FALSE; |
1946 | - } |
|
1945 | + } |
|
1947 | 1946 | |
1948 | - module_invoke_all('privatemsg_message_insert', $message); |
|
1947 | + module_invoke_all('privatemsg_message_insert', $message); |
|
1949 | 1948 | |
1950 | - // If we reached here that means we were successful at writing all messages to db. |
|
1951 | - return $message; |
|
1949 | + // If we reached here that means we were successful at writing all messages to db. |
|
1950 | + return $message; |
|
1952 | 1951 | } |
1953 | 1952 | |
1954 | 1953 | /** |
@@ -1968,37 +1967,37 @@ discard block |
||
1968 | 1967 | * @ingroup api |
1969 | 1968 | */ |
1970 | 1969 | function privatemsg_get_link($recipients, $account = array(), $subject = NULL) { |
1971 | - if ($account == NULL) { |
|
1970 | + if ($account == NULL) { |
|
1972 | 1971 | global $user; |
1973 | 1972 | $account = $user; |
1974 | - } |
|
1973 | + } |
|
1975 | 1974 | |
1976 | - if (!is_array($recipients)) { |
|
1975 | + if (!is_array($recipients)) { |
|
1977 | 1976 | $recipients = array($recipients); |
1978 | - } |
|
1977 | + } |
|
1979 | 1978 | |
1980 | - if (!privatemsg_user_access('write privatemsg', $account) || $account->uid == 0) { |
|
1979 | + if (!privatemsg_user_access('write privatemsg', $account) || $account->uid == 0) { |
|
1981 | 1980 | return FALSE; |
1982 | - } |
|
1981 | + } |
|
1983 | 1982 | |
1984 | - $validated = array(); |
|
1985 | - foreach ($recipients as $recipient) { |
|
1983 | + $validated = array(); |
|
1984 | + foreach ($recipients as $recipient) { |
|
1986 | 1985 | if (!privatemsg_user_access('read privatemsg', $recipient)) { |
1987 | - continue; |
|
1986 | + continue; |
|
1988 | 1987 | } |
1989 | 1988 | if (count(module_invoke_all('privatemsg_block_message', $account, array($recipient->uid => $recipient))) > 0) { |
1990 | - continue; |
|
1989 | + continue; |
|
1991 | 1990 | } |
1992 | 1991 | $validated[] = $recipient->uid; |
1993 | - } |
|
1994 | - if (empty($validated)) { |
|
1992 | + } |
|
1993 | + if (empty($validated)) { |
|
1995 | 1994 | return FALSE; |
1996 | - } |
|
1997 | - $url = 'messages/new/'. implode(',', $validated); |
|
1998 | - if (!is_null($subject)) { |
|
1995 | + } |
|
1996 | + $url = 'messages/new/'. implode(',', $validated); |
|
1997 | + if (!is_null($subject)) { |
|
1999 | 1998 | $url .= '/'. $subject; |
2000 | - } |
|
2001 | - return $url; |
|
1999 | + } |
|
2000 | + return $url; |
|
2002 | 2001 | } |
2003 | 2002 | |
2004 | 2003 | /** |
@@ -2013,8 +2012,8 @@ discard block |
||
2013 | 2012 | * @ingroup api |
2014 | 2013 | */ |
2015 | 2014 | function privatemsg_message_load($pmid, $account = NULL) { |
2016 | - $messages = privatemsg_message_load_multiple(array($pmid), $account); |
|
2017 | - return current($messages); |
|
2015 | + $messages = privatemsg_message_load_multiple(array($pmid), $account); |
|
2016 | + return current($messages); |
|
2018 | 2017 | } |
2019 | 2018 | |
2020 | 2019 | /** |
@@ -2029,27 +2028,27 @@ discard block |
||
2029 | 2028 | * @ingroup api |
2030 | 2029 | */ |
2031 | 2030 | function privatemsg_message_load_multiple($pmids, $account = NULL) { |
2032 | - // Avoid SQL error that would happen with an empty pm.mid IN () clause. |
|
2033 | - if (empty($pmids)) { |
|
2031 | + // Avoid SQL error that would happen with an empty pm.mid IN () clause. |
|
2032 | + if (empty($pmids)) { |
|
2034 | 2033 | return array(); |
2035 | - } |
|
2034 | + } |
|
2036 | 2035 | |
2037 | - $query = _privatemsg_assemble_query('load', $pmids, $account); |
|
2038 | - $result = db_query($query['query']); |
|
2039 | - $messages = array(); |
|
2040 | - while ($message = db_fetch_array($result)) { |
|
2036 | + $query = _privatemsg_assemble_query('load', $pmids, $account); |
|
2037 | + $result = db_query($query['query']); |
|
2038 | + $messages = array(); |
|
2039 | + while ($message = db_fetch_array($result)) { |
|
2041 | 2040 | // Load author of message. |
2042 | 2041 | if (!($message['author'] = user_load($message['author']))) { |
2043 | - // If user does not exist, load anonymous user. |
|
2044 | - $message['author'] = user_load(array('uid' => 0)); |
|
2042 | + // If user does not exist, load anonymous user. |
|
2043 | + $message['author'] = user_load(array('uid' => 0)); |
|
2045 | 2044 | } |
2046 | 2045 | $returned = module_invoke_all('privatemsg_message_load', $message); |
2047 | 2046 | if (!empty($returned)) { |
2048 | - $message = array_merge_recursive($returned, $message); |
|
2047 | + $message = array_merge_recursive($returned, $message); |
|
2049 | 2048 | } |
2050 | 2049 | $messages[$message['mid']] = $message; |
2051 | - } |
|
2052 | - return $messages; |
|
2050 | + } |
|
2051 | + return $messages; |
|
2053 | 2052 | } |
2054 | 2053 | |
2055 | 2054 | /** |
@@ -2068,26 +2067,26 @@ discard block |
||
2068 | 2067 | */ |
2069 | 2068 | function _privatemsg_assemble_query($query) { |
2070 | 2069 | |
2071 | - // Modules will be allowed to choose the prefix for the querybuilder, but if there is not one supplied, 'privatemsg' will be taken by default. |
|
2072 | - if (is_array($query)) { |
|
2070 | + // Modules will be allowed to choose the prefix for the querybuilder, but if there is not one supplied, 'privatemsg' will be taken by default. |
|
2071 | + if (is_array($query)) { |
|
2073 | 2072 | $query_id = $query[0]; |
2074 | 2073 | $query_group = $query[1]; |
2075 | - } |
|
2076 | - else { |
|
2074 | + } |
|
2075 | + else { |
|
2077 | 2076 | $query_id = $query; |
2078 | 2077 | $query_group = 'privatemsg'; |
2079 | - } |
|
2080 | - |
|
2081 | - $SELECT = array(); |
|
2082 | - $INNER_JOIN = array(); |
|
2083 | - $WHERE = array(); |
|
2084 | - $GROUP_BY = array(); |
|
2085 | - $HAVING = array(); |
|
2086 | - $ORDER_BY = array(); |
|
2087 | - $QUERY_ARGS = array('select' => array(), 'where' => array(), 'join' => array(), 'having' => array()); |
|
2088 | - $primary_table = ''; |
|
2089 | - |
|
2090 | - $fragments = array( |
|
2078 | + } |
|
2079 | + |
|
2080 | + $SELECT = array(); |
|
2081 | + $INNER_JOIN = array(); |
|
2082 | + $WHERE = array(); |
|
2083 | + $GROUP_BY = array(); |
|
2084 | + $HAVING = array(); |
|
2085 | + $ORDER_BY = array(); |
|
2086 | + $QUERY_ARGS = array('select' => array(), 'where' => array(), 'join' => array(), 'having' => array()); |
|
2087 | + $primary_table = ''; |
|
2088 | + |
|
2089 | + $fragments = array( |
|
2091 | 2090 | 'select' => $SELECT, |
2092 | 2091 | 'inner_join' => $INNER_JOIN, |
2093 | 2092 | 'where' => $WHERE, |
@@ -2096,52 +2095,52 @@ discard block |
||
2096 | 2095 | 'order_by' => $ORDER_BY, |
2097 | 2096 | 'query_args' => $QUERY_ARGS, |
2098 | 2097 | 'primary_table' => $primary_table, |
2099 | - ); |
|
2100 | - |
|
2101 | - /** |
|
2102 | - * Begin: dynamic arguments |
|
2103 | - */ |
|
2104 | - $args = func_get_args(); |
|
2105 | - unset($args[0]); |
|
2106 | - // we do the merge because we call call_user_func_array and not drupal_alter |
|
2107 | - // this is necessary because otherwise we would not be able to use $args correctly (otherwise it doesnt unfold) |
|
2108 | - $alterargs = array(&$fragments); |
|
2109 | - $query_function = $query_group .'_sql_'. $query_id; |
|
2110 | - if (!empty($args)) { |
|
2098 | + ); |
|
2099 | + |
|
2100 | + /** |
|
2101 | + * Begin: dynamic arguments |
|
2102 | + */ |
|
2103 | + $args = func_get_args(); |
|
2104 | + unset($args[0]); |
|
2105 | + // we do the merge because we call call_user_func_array and not drupal_alter |
|
2106 | + // this is necessary because otherwise we would not be able to use $args correctly (otherwise it doesnt unfold) |
|
2107 | + $alterargs = array(&$fragments); |
|
2108 | + $query_function = $query_group .'_sql_'. $query_id; |
|
2109 | + if (!empty($args)) { |
|
2111 | 2110 | $alterargs = array_merge($alterargs, $args); |
2112 | - } |
|
2113 | - /** |
|
2114 | - * END: Dynamic arguments |
|
2115 | - */ |
|
2116 | - if (!function_exists($query_function)) { |
|
2111 | + } |
|
2112 | + /** |
|
2113 | + * END: Dynamic arguments |
|
2114 | + */ |
|
2115 | + if (!function_exists($query_function)) { |
|
2117 | 2116 | drupal_set_message(t('Query function %function does not exist', array('%function' => $query_function)), 'error'); |
2118 | 2117 | return FALSE; |
2119 | - } |
|
2120 | - call_user_func_array($query_function, $alterargs); |
|
2121 | - |
|
2122 | - array_unshift($alterargs, $query_function); |
|
2123 | - call_user_func_array('drupal_alter', $alterargs); |
|
2124 | - |
|
2125 | - $SELECT = $fragments['select']; |
|
2126 | - $INNER_JOIN = $fragments['inner_join']; |
|
2127 | - $WHERE = $fragments['where']; |
|
2128 | - $GROUP_BY = $fragments['group_by']; |
|
2129 | - $HAVING = $fragments['having']; |
|
2130 | - $ORDER_BY = $fragments['order_by']; |
|
2131 | - $QUERY_ARGS = $fragments['query_args']; |
|
2132 | - $primary_table = $fragments['primary_table']; |
|
2133 | - |
|
2134 | - // pgsql has a case sensitive LIKE - replace it with ILIKE. see http://drupal.org/node/462982 |
|
2135 | - if ($GLOBALS['db_type'] == 'pgsql') { |
|
2118 | + } |
|
2119 | + call_user_func_array($query_function, $alterargs); |
|
2120 | + |
|
2121 | + array_unshift($alterargs, $query_function); |
|
2122 | + call_user_func_array('drupal_alter', $alterargs); |
|
2123 | + |
|
2124 | + $SELECT = $fragments['select']; |
|
2125 | + $INNER_JOIN = $fragments['inner_join']; |
|
2126 | + $WHERE = $fragments['where']; |
|
2127 | + $GROUP_BY = $fragments['group_by']; |
|
2128 | + $HAVING = $fragments['having']; |
|
2129 | + $ORDER_BY = $fragments['order_by']; |
|
2130 | + $QUERY_ARGS = $fragments['query_args']; |
|
2131 | + $primary_table = $fragments['primary_table']; |
|
2132 | + |
|
2133 | + // pgsql has a case sensitive LIKE - replace it with ILIKE. see http://drupal.org/node/462982 |
|
2134 | + if ($GLOBALS['db_type'] == 'pgsql') { |
|
2136 | 2135 | $WHERE = str_replace('LIKE', 'ILIKE', $WHERE); |
2137 | - } |
|
2136 | + } |
|
2138 | 2137 | |
2139 | - if (empty($primary_table)) { |
|
2138 | + if (empty($primary_table)) { |
|
2140 | 2139 | $primary_table = '{privatemsg} pm'; |
2141 | - } |
|
2140 | + } |
|
2142 | 2141 | |
2143 | - // Perform the whole query assembly only if we have something to select. |
|
2144 | - if (!empty($SELECT)) { |
|
2142 | + // Perform the whole query assembly only if we have something to select. |
|
2143 | + if (!empty($SELECT)) { |
|
2145 | 2144 | $str_select = implode(", ", $SELECT); |
2146 | 2145 | $query = "SELECT {$str_select} FROM ". $primary_table; |
2147 | 2146 | |
@@ -2149,51 +2148,51 @@ discard block |
||
2149 | 2148 | // In most cases, "COUNT(*)" is enough to get the count query, but in queries involving a GROUP BY, we want a count of the number of groups we have, not the count of elements inside each group. |
2150 | 2149 | // So we test if there is GROUP BY and if there is, count the number of distinct groups. If not, we go the normal wal and do a plain COUNT(*). |
2151 | 2150 | if (!empty($GROUP_BY)) { |
2152 | - // PostgreSQL does not support COUNT(sometextfield, someintfield), so I'm only using the first one |
|
2153 | - // Works fine for thread_id/list but may generate an error when a more complex GROUP BY is used. |
|
2154 | - $str_group_by_count = current($GROUP_BY); |
|
2155 | - $count = "SELECT COUNT(DISTINCT {$str_group_by_count}) FROM ". $primary_table; |
|
2151 | + // PostgreSQL does not support COUNT(sometextfield, someintfield), so I'm only using the first one |
|
2152 | + // Works fine for thread_id/list but may generate an error when a more complex GROUP BY is used. |
|
2153 | + $str_group_by_count = current($GROUP_BY); |
|
2154 | + $count = "SELECT COUNT(DISTINCT {$str_group_by_count}) FROM ". $primary_table; |
|
2156 | 2155 | } |
2157 | 2156 | else { |
2158 | - $count = "SELECT COUNT(*) FROM ". $primary_table; |
|
2157 | + $count = "SELECT COUNT(*) FROM ". $primary_table; |
|
2159 | 2158 | } |
2160 | 2159 | |
2161 | 2160 | if (!empty($INNER_JOIN)) { |
2162 | - $str_inner_join = implode(' ', $INNER_JOIN); |
|
2163 | - $query .= " {$str_inner_join}"; |
|
2164 | - $count .= " {$str_inner_join}"; |
|
2161 | + $str_inner_join = implode(' ', $INNER_JOIN); |
|
2162 | + $query .= " {$str_inner_join}"; |
|
2163 | + $count .= " {$str_inner_join}"; |
|
2165 | 2164 | } |
2166 | 2165 | if (!empty($WHERE)) { |
2167 | - $str_where = '('. implode(') AND (', $WHERE) .')'; |
|
2168 | - $query .= " WHERE {$str_where}"; |
|
2169 | - $count .= " WHERE {$str_where}"; |
|
2166 | + $str_where = '('. implode(') AND (', $WHERE) .')'; |
|
2167 | + $query .= " WHERE {$str_where}"; |
|
2168 | + $count .= " WHERE {$str_where}"; |
|
2170 | 2169 | } |
2171 | 2170 | if (!empty($GROUP_BY)) { |
2172 | - $str_group_by = ' GROUP BY '. implode(", ", $GROUP_BY) ; |
|
2173 | - $query .= " {$str_group_by}"; |
|
2171 | + $str_group_by = ' GROUP BY '. implode(", ", $GROUP_BY) ; |
|
2172 | + $query .= " {$str_group_by}"; |
|
2174 | 2173 | } |
2175 | 2174 | if (!empty($HAVING)) { |
2176 | - $str_having = '('. implode(') AND (', $HAVING) .')'; |
|
2177 | - $query .= " HAVING {$str_having}"; |
|
2178 | - // queries containing a HAVING break the count query on pgsql. |
|
2179 | - // In this case, use the subquery method as outlined in http://drupal.org/node/303087#comment-1370752 . |
|
2180 | - // The subquery method will work for all COUNT queries, but it is thought to be much slower, so we are only using it where other cross database approaches fail. |
|
2181 | - $count = 'SELECT COUNT(*) FROM ('. $query .') as count'; |
|
2175 | + $str_having = '('. implode(') AND (', $HAVING) .')'; |
|
2176 | + $query .= " HAVING {$str_having}"; |
|
2177 | + // queries containing a HAVING break the count query on pgsql. |
|
2178 | + // In this case, use the subquery method as outlined in http://drupal.org/node/303087#comment-1370752 . |
|
2179 | + // The subquery method will work for all COUNT queries, but it is thought to be much slower, so we are only using it where other cross database approaches fail. |
|
2180 | + $count = 'SELECT COUNT(*) FROM ('. $query .') as count'; |
|
2182 | 2181 | } |
2183 | 2182 | if (!empty($ORDER_BY)) { |
2184 | - $str_order_by = ' ORDER BY '. implode(", ", $ORDER_BY) ; |
|
2185 | - $query .= " {$str_order_by}"; |
|
2183 | + $str_order_by = ' ORDER BY '. implode(", ", $ORDER_BY) ; |
|
2184 | + $query .= " {$str_order_by}"; |
|
2186 | 2185 | } |
2187 | 2186 | $QUERY_ARGS = array_merge($QUERY_ARGS['select'], $QUERY_ARGS['join'], $QUERY_ARGS['where'], $QUERY_ARGS['having']); |
2188 | 2187 | if (!empty($QUERY_ARGS)) { |
2189 | - _db_query_callback($QUERY_ARGS, TRUE); |
|
2190 | - $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); |
|
2191 | - _db_query_callback($QUERY_ARGS, TRUE); |
|
2192 | - $count = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $count); |
|
2188 | + _db_query_callback($QUERY_ARGS, TRUE); |
|
2189 | + $query = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $query); |
|
2190 | + _db_query_callback($QUERY_ARGS, TRUE); |
|
2191 | + $count = preg_replace_callback(DB_QUERY_REGEXP, '_db_query_callback', $count); |
|
2193 | 2192 | } |
2194 | 2193 | return array('query' => $query, 'count' => $count); |
2195 | - } |
|
2196 | - return FALSE; |
|
2194 | + } |
|
2195 | + return FALSE; |
|
2197 | 2196 | } |
2198 | 2197 | |
2199 | 2198 | /** |
@@ -2210,44 +2209,44 @@ discard block |
||
2210 | 2209 | * The FAPI definitions for the thread action form. |
2211 | 2210 | */ |
2212 | 2211 | function _privatemsg_action_form() { |
2213 | - $form = array( |
|
2214 | - '#type' => 'fieldset', |
|
2215 | - '#title' => t('Actions'), |
|
2216 | - '#prefix' => '<div class="container-inline">', |
|
2217 | - '#suffix' => '</div>', |
|
2218 | - '#collapsible' => TRUE, |
|
2219 | - '#collapsed' => FALSE, |
|
2220 | - '#weight' => 15, |
|
2221 | - ); |
|
2222 | - if (privatemsg_user_access('delete privatemsg')) { |
|
2212 | + $form = array( |
|
2213 | + '#type' => 'fieldset', |
|
2214 | + '#title' => t('Actions'), |
|
2215 | + '#prefix' => '<div class="container-inline">', |
|
2216 | + '#suffix' => '</div>', |
|
2217 | + '#collapsible' => TRUE, |
|
2218 | + '#collapsed' => FALSE, |
|
2219 | + '#weight' => 15, |
|
2220 | + ); |
|
2221 | + if (privatemsg_user_access('delete privatemsg')) { |
|
2223 | 2222 | $form['delete'] = array( |
2224 | 2223 | '#type' => 'submit', |
2225 | 2224 | '#value' => t('Delete'), |
2226 | 2225 | ); |
2227 | - } |
|
2228 | - // Display all operations which have a label. |
|
2229 | - $options = array(0 => t('More actions...')); |
|
2230 | - foreach (module_invoke_all('privatemsg_thread_operations') as $operation => $array) { |
|
2226 | + } |
|
2227 | + // Display all operations which have a label. |
|
2228 | + $options = array(0 => t('More actions...')); |
|
2229 | + foreach (module_invoke_all('privatemsg_thread_operations') as $operation => $array) { |
|
2231 | 2230 | if (isset($array['label'])) { |
2232 | - $options[$operation] = $array['label']; |
|
2233 | - } |
|
2234 | - } |
|
2235 | - $form['operation'] = array( |
|
2236 | - '#type' => 'select', |
|
2237 | - '#options' => $options, |
|
2238 | - '#default_value' => 0, |
|
2239 | - ); |
|
2240 | - $form['submit'] = array( |
|
2241 | - '#prefix' => '<div class="privatemsg-op-button">', |
|
2242 | - '#suffix' => '</div>', |
|
2243 | - '#type' => 'submit', |
|
2244 | - '#value' => t('Execute'), |
|
2245 | - '#submit' => array('privatemsg_list_submit'), |
|
2246 | - '#attributes' => array('class' => 'privatemsg-action-button'), |
|
2247 | - ); |
|
2248 | - // JS for hiding the execute button. |
|
2249 | - drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-list.js'); |
|
2250 | - return $form; |
|
2231 | + $options[$operation] = $array['label']; |
|
2232 | + } |
|
2233 | + } |
|
2234 | + $form['operation'] = array( |
|
2235 | + '#type' => 'select', |
|
2236 | + '#options' => $options, |
|
2237 | + '#default_value' => 0, |
|
2238 | + ); |
|
2239 | + $form['submit'] = array( |
|
2240 | + '#prefix' => '<div class="privatemsg-op-button">', |
|
2241 | + '#suffix' => '</div>', |
|
2242 | + '#type' => 'submit', |
|
2243 | + '#value' => t('Execute'), |
|
2244 | + '#submit' => array('privatemsg_list_submit'), |
|
2245 | + '#attributes' => array('class' => 'privatemsg-action-button'), |
|
2246 | + ); |
|
2247 | + // JS for hiding the execute button. |
|
2248 | + drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-list.js'); |
|
2249 | + return $form; |
|
2251 | 2250 | } |
2252 | 2251 | |
2253 | 2252 | /** |
@@ -2262,23 +2261,23 @@ discard block |
||
2262 | 2261 | * current user. |
2263 | 2262 | */ |
2264 | 2263 | function privatemsg_thread_change_status($threads, $status, $account = NULL) { |
2265 | - if (!is_array($threads)) { |
|
2264 | + if (!is_array($threads)) { |
|
2266 | 2265 | $threads = array($threads); |
2267 | - } |
|
2268 | - if (empty($account)) { |
|
2266 | + } |
|
2267 | + if (empty($account)) { |
|
2269 | 2268 | global $user; |
2270 | 2269 | $account = drupal_clone($user); |
2271 | - } |
|
2272 | - // Merge status and uid with the threads list. array_merge() will not overwrite/ignore thread_id 1. |
|
2273 | - $params = array_merge(array($status, $account->uid), $threads); |
|
2274 | - db_query('UPDATE {pm_index} SET is_new = %d WHERE uid = %d AND thread_id IN ('. db_placeholders($threads) .')', $params); |
|
2270 | + } |
|
2271 | + // Merge status and uid with the threads list. array_merge() will not overwrite/ignore thread_id 1. |
|
2272 | + $params = array_merge(array($status, $account->uid), $threads); |
|
2273 | + db_query('UPDATE {pm_index} SET is_new = %d WHERE uid = %d AND thread_id IN ('. db_placeholders($threads) .')', $params); |
|
2275 | 2274 | |
2276 | - if ($status == PRIVATEMSG_UNREAD) { |
|
2275 | + if ($status == PRIVATEMSG_UNREAD) { |
|
2277 | 2276 | drupal_set_message(format_plural(count($threads), 'Marked 1 thread as unread.', 'Marked @count threads as unread.')); |
2278 | - } |
|
2279 | - else { |
|
2277 | + } |
|
2278 | + else { |
|
2280 | 2279 | drupal_set_message(format_plural(count($threads), 'Marked 1 thread as read.', 'Marked @count threads as read.')); |
2281 | - } |
|
2280 | + } |
|
2282 | 2281 | } |
2283 | 2282 | /** |
2284 | 2283 | * Returns a table header definition based on the submitted keys. |
@@ -2294,25 +2293,25 @@ discard block |
||
2294 | 2293 | * Array with header defintions for tablesort_sql and theme('table'). |
2295 | 2294 | */ |
2296 | 2295 | function _privatemsg_list_headers($has_posts, $keys) { |
2297 | - $select_header = $has_posts ? theme('table_select_header_cell') : ''; |
|
2298 | - $select_header['#weight'] = -50; |
|
2296 | + $select_header = $has_posts ? theme('table_select_header_cell') : ''; |
|
2297 | + $select_header['#weight'] = -50; |
|
2299 | 2298 | |
2300 | - // theme() doesn't include the theme file for patterns, we need to do it manually. |
|
2301 | - include_once drupal_get_path('module', 'privatemsg') .'/privatemsg.theme.inc'; |
|
2299 | + // theme() doesn't include the theme file for patterns, we need to do it manually. |
|
2300 | + include_once drupal_get_path('module', 'privatemsg') .'/privatemsg.theme.inc'; |
|
2302 | 2301 | |
2303 | - $header = array($select_header); |
|
2304 | - foreach ($keys as $key) { |
|
2302 | + $header = array($select_header); |
|
2303 | + foreach ($keys as $key) { |
|
2305 | 2304 | // First, try to load a specific theme for that header, if not present, use the default. |
2306 | 2305 | if ($return = theme(array('privatemsg_list_header__'. $key, 'privatemsg_list_header'))) { |
2307 | - // The default theme returns nothing, only store the value if we have something. |
|
2308 | - $header[$key] = $return; |
|
2306 | + // The default theme returns nothing, only store the value if we have something. |
|
2307 | + $header[$key] = $return; |
|
2308 | + } |
|
2309 | 2309 | } |
2310 | - } |
|
2311 | - if (count($header) == 1) { |
|
2310 | + if (count($header) == 1) { |
|
2312 | 2311 | // No header definition returned, fallback to the default. |
2313 | 2312 | $header += _privatemsg_list_headers_fallback($keys); |
2314 | - } |
|
2315 | - return $header; |
|
2313 | + } |
|
2314 | + return $header; |
|
2316 | 2315 | } |
2317 | 2316 | |
2318 | 2317 | /** |
@@ -2322,15 +2321,15 @@ discard block |
||
2322 | 2321 | * Array with the correct headers. |
2323 | 2322 | */ |
2324 | 2323 | function _privatemsg_list_headers_fallback($keys) { |
2325 | - $header = array(); |
|
2326 | - foreach ($keys as $key) { |
|
2324 | + $header = array(); |
|
2325 | + foreach ($keys as $key) { |
|
2327 | 2326 | $theme_function = 'phptemplate_privatemsg_list_header__' . $key; |
2328 | 2327 | if (function_exists($theme_function)) { |
2329 | - $header[$key] = $theme_function(); |
|
2328 | + $header[$key] = $theme_function(); |
|
2329 | + } |
|
2330 | 2330 | } |
2331 | - } |
|
2332 | 2331 | |
2333 | - return $header; |
|
2332 | + return $header; |
|
2334 | 2333 | } |
2335 | 2334 | |
2336 | 2335 | /** |
@@ -2344,23 +2343,23 @@ discard block |
||
2344 | 2343 | * Row definition for use with theme('table') |
2345 | 2344 | */ |
2346 | 2345 | function _privatemsg_list_thread($thread) { |
2347 | - $row = array('data' => array()); |
|
2346 | + $row = array('data' => array()); |
|
2348 | 2347 | |
2349 | - if (!empty($thread['is_new'])) { |
|
2348 | + if (!empty($thread['is_new'])) { |
|
2350 | 2349 | // Set the css class in the tr tag. |
2351 | 2350 | $row['class'] = 'privatemsg-unread'; |
2352 | - } |
|
2353 | - foreach ($thread as $key => $data) { |
|
2351 | + } |
|
2352 | + foreach ($thread as $key => $data) { |
|
2354 | 2353 | // First, try to load a specific theme for that field, if not present, use the default. |
2355 | 2354 | if ($return = theme(array('privatemsg_list_field__'. $key, 'privatemsg_list_field'), $thread)) { |
2356 | - // The default theme returns nothing, only store the value if we have something. |
|
2357 | - $row['data'][$key] = $return; |
|
2355 | + // The default theme returns nothing, only store the value if we have something. |
|
2356 | + $row['data'][$key] = $return; |
|
2357 | + } |
|
2358 | 2358 | } |
2359 | - } |
|
2360 | - if (empty($row['data'])) { |
|
2359 | + if (empty($row['data'])) { |
|
2361 | 2360 | $row['data'] = _privatemsg_list_thread_fallback($thread); |
2362 | - } |
|
2363 | - return $row; |
|
2361 | + } |
|
2362 | + return $row; |
|
2364 | 2363 | } |
2365 | 2364 | |
2366 | 2365 | /** |
@@ -2370,15 +2369,15 @@ discard block |
||
2370 | 2369 | * Array with row data. |
2371 | 2370 | */ |
2372 | 2371 | function _privatemsg_list_thread_fallback($thread) { |
2373 | - $row_data = array(); |
|
2374 | - foreach ($thread as $key => $data) { |
|
2372 | + $row_data = array(); |
|
2373 | + foreach ($thread as $key => $data) { |
|
2375 | 2374 | $theme_function = 'phptemplate_privatemsg_list_field__' . $key; |
2376 | 2375 | if (function_exists($theme_function)) { |
2377 | - $row_data[$key] = $theme_function($thread); |
|
2376 | + $row_data[$key] = $theme_function($thread); |
|
2377 | + } |
|
2378 | 2378 | } |
2379 | - } |
|
2380 | 2379 | |
2381 | - return $row_data; |
|
2380 | + return $row_data; |
|
2382 | 2381 | } |
2383 | 2382 | |
2384 | 2383 | /** |
@@ -2388,20 +2387,20 @@ discard block |
||
2388 | 2387 | * execute it. |
2389 | 2388 | */ |
2390 | 2389 | function privatemsg_undo_action() { |
2391 | - // Check if a undo callback for that user exists. |
|
2392 | - if (isset($_SESSION['privatemsg']['undo callback']) && is_array($_SESSION['privatemsg']['undo callback'])) { |
|
2390 | + // Check if a undo callback for that user exists. |
|
2391 | + if (isset($_SESSION['privatemsg']['undo callback']) && is_array($_SESSION['privatemsg']['undo callback'])) { |
|
2393 | 2392 | $undo = $_SESSION['privatemsg']['undo callback']; |
2394 | 2393 | // If the defined undo callback exists, execute it |
2395 | 2394 | if (isset($undo['function']) && isset($undo['args'])) { |
2396 | - // Load the user object. |
|
2397 | - if (isset($undo['args']['account']) && $undo['args']['account'] > 0) { |
|
2395 | + // Load the user object. |
|
2396 | + if (isset($undo['args']['account']) && $undo['args']['account'] > 0) { |
|
2398 | 2397 | $undo['args']['account'] = user_load((int)$undo['args']['account']); |
2399 | - } |
|
2400 | - call_user_func_array($undo['function'], $undo['args']); |
|
2398 | + } |
|
2399 | + call_user_func_array($undo['function'], $undo['args']); |
|
2401 | 2400 | } |
2402 | 2401 | // Return back to the site defined by the destination GET param. |
2403 | 2402 | drupal_goto(); |
2404 | - } |
|
2403 | + } |
|
2405 | 2404 | } |
2406 | 2405 | |
2407 | 2406 | /** |
@@ -2411,29 +2410,29 @@ discard block |
||
2411 | 2410 | * based on node_admin_nodes_submit(). |
2412 | 2411 | */ |
2413 | 2412 | function privatemsg_list_submit($form, &$form_state) { |
2414 | - // Load all available operation definitions. |
|
2415 | - $operations = module_invoke_all('privatemsg_thread_operations'); |
|
2413 | + // Load all available operation definitions. |
|
2414 | + $operations = module_invoke_all('privatemsg_thread_operations'); |
|
2416 | 2415 | |
2417 | - // Default "default" operation, which won't do anything. |
|
2418 | - $operation = array('callback' => 0); |
|
2416 | + // Default "default" operation, which won't do anything. |
|
2417 | + $operation = array('callback' => 0); |
|
2419 | 2418 | |
2420 | - // Check if a valid operation has been submitted. |
|
2421 | - if (isset($form_state['values']['operation']) && isset($operations[$form_state['values']['operation']])) { |
|
2419 | + // Check if a valid operation has been submitted. |
|
2420 | + if (isset($form_state['values']['operation']) && isset($operations[$form_state['values']['operation']])) { |
|
2422 | 2421 | $operation = $operations[$form_state['values']['operation']]; |
2423 | - } |
|
2422 | + } |
|
2424 | 2423 | |
2425 | - // Load all keys where the value is the current op. |
|
2426 | - $keys = array_keys($form_state['values'], $form_state['values']['op']); |
|
2424 | + // Load all keys where the value is the current op. |
|
2425 | + $keys = array_keys($form_state['values'], $form_state['values']['op']); |
|
2427 | 2426 | |
2428 | - // The first one is op itself, we need to use the second. |
|
2429 | - if (isset($keys[1]) && isset($operations[$keys[1]])) { |
|
2427 | + // The first one is op itself, we need to use the second. |
|
2428 | + if (isset($keys[1]) && isset($operations[$keys[1]])) { |
|
2430 | 2429 | $operation = $operations[$keys[1]]; |
2431 | - } |
|
2430 | + } |
|
2432 | 2431 | |
2433 | - // Only execute something if we have a valid callback and at least one checked thread. |
|
2434 | - if (!empty($operation['callback'])) { |
|
2432 | + // Only execute something if we have a valid callback and at least one checked thread. |
|
2433 | + if (!empty($operation['callback'])) { |
|
2435 | 2434 | privatemsg_operation_execute($operation, $form_state['values']['threads'], $form_state['values']['account']); |
2436 | - } |
|
2435 | + } |
|
2437 | 2436 | } |
2438 | 2437 | |
2439 | 2438 | /** |
@@ -2447,42 +2446,42 @@ discard block |
||
2447 | 2446 | * array can be directly passed to it. |
2448 | 2447 | */ |
2449 | 2448 | function privatemsg_operation_execute($operation, $threads, $account = null) { |
2450 | - // Filter out unchecked threads, this gives us an array of "checked" threads. |
|
2451 | - $threads = array_filter($threads); |
|
2449 | + // Filter out unchecked threads, this gives us an array of "checked" threads. |
|
2450 | + $threads = array_filter($threads); |
|
2452 | 2451 | |
2453 | - if (empty($threads)) { |
|
2452 | + if (empty($threads)) { |
|
2454 | 2453 | // Do not execute anything if there are no checked threads. |
2455 | 2454 | return; |
2456 | - } |
|
2457 | - // Add in callback arguments if present. |
|
2458 | - if (isset($operation['callback arguments'])) { |
|
2455 | + } |
|
2456 | + // Add in callback arguments if present. |
|
2457 | + if (isset($operation['callback arguments'])) { |
|
2459 | 2458 | $args = array_merge(array($threads), $operation['callback arguments']); |
2460 | - } |
|
2461 | - else { |
|
2459 | + } |
|
2460 | + else { |
|
2462 | 2461 | $args = array($threads); |
2463 | - } |
|
2462 | + } |
|
2464 | 2463 | |
2465 | - // Add the user object to the arguments. |
|
2466 | - if ($account) { |
|
2464 | + // Add the user object to the arguments. |
|
2465 | + if ($account) { |
|
2467 | 2466 | $args[] = $account; |
2468 | - } |
|
2467 | + } |
|
2469 | 2468 | |
2470 | - // Execute the chosen action and pass the defined arguments. |
|
2471 | - call_user_func_array($operation['callback'], $args); |
|
2469 | + // Execute the chosen action and pass the defined arguments. |
|
2470 | + call_user_func_array($operation['callback'], $args); |
|
2472 | 2471 | |
2473 | - // Check if that operation has defined an undo callback. |
|
2474 | - if (isset($operation['undo callback']) && $undo_function = $operation['undo callback']) { |
|
2472 | + // Check if that operation has defined an undo callback. |
|
2473 | + if (isset($operation['undo callback']) && $undo_function = $operation['undo callback']) { |
|
2475 | 2474 | // Add in callback arguments if present. |
2476 | 2475 | if (isset($operation['undo callback arguments'])) { |
2477 | - $undo_args = array_merge(array($threads), $operation['undo callback arguments']); |
|
2476 | + $undo_args = array_merge(array($threads), $operation['undo callback arguments']); |
|
2478 | 2477 | } |
2479 | 2478 | else { |
2480 | - $undo_args = array($threads); |
|
2479 | + $undo_args = array($threads); |
|
2481 | 2480 | } |
2482 | 2481 | |
2483 | 2482 | // Avoid saving the complete user object in the session. |
2484 | 2483 | if ($account) { |
2485 | - $undo_args['account'] = $account->uid; |
|
2484 | + $undo_args['account'] = $account->uid; |
|
2486 | 2485 | } |
2487 | 2486 | // Store the undo callback in the session and display a "Undo" link. |
2488 | 2487 | // @todo: Provide a more flexible solution for such an undo action, operation defined string for example. |
@@ -2490,7 +2489,7 @@ discard block |
||
2490 | 2489 | $undo = url('messages/undo/action', array('query' => drupal_get_destination())); |
2491 | 2490 | |
2492 | 2491 | drupal_set_message(t('The previous action can be <a href="!undo">undone</a>.', array('!undo' => $undo))); |
2493 | - } |
|
2492 | + } |
|
2494 | 2493 | } |
2495 | 2494 | |
2496 | 2495 | /** |
@@ -2506,71 +2505,71 @@ discard block |
||
2506 | 2505 | * defaults to the current user. |
2507 | 2506 | */ |
2508 | 2507 | function privatemsg_thread_change_delete($threads, $delete, $account = NULL) { |
2509 | - if (!is_array($threads)) { |
|
2508 | + if (!is_array($threads)) { |
|
2510 | 2509 | $threads = array($threads); |
2511 | - } |
|
2512 | - if (empty($account)) { |
|
2510 | + } |
|
2511 | + if (empty($account)) { |
|
2513 | 2512 | global $user; |
2514 | 2513 | $account = drupal_clone($user); |
2515 | - } |
|
2514 | + } |
|
2516 | 2515 | |
2517 | - // Merge status and uid with the threads list. array_merge() will not overwrite/ignore thread_id 1. |
|
2518 | - $params = array_merge(array($delete, $account->uid), $threads); |
|
2516 | + // Merge status and uid with the threads list. array_merge() will not overwrite/ignore thread_id 1. |
|
2517 | + $params = array_merge(array($delete, $account->uid), $threads); |
|
2519 | 2518 | |
2520 | - // Load all messages of those threads including the deleted. |
|
2521 | - $query = _privatemsg_assemble_query('messages', $threads, $account, TRUE); |
|
2522 | - $result = db_query($query['query']); |
|
2519 | + // Load all messages of those threads including the deleted. |
|
2520 | + $query = _privatemsg_assemble_query('messages', $threads, $account, TRUE); |
|
2521 | + $result = db_query($query['query']); |
|
2523 | 2522 | |
2524 | - // Delete each message. We need to do that to trigger the delete hook. |
|
2525 | - while ($row = db_fetch_array($result)) { |
|
2523 | + // Delete each message. We need to do that to trigger the delete hook. |
|
2524 | + while ($row = db_fetch_array($result)) { |
|
2526 | 2525 | privatemsg_message_change_delete($row['mid'], $delete, $account); |
2527 | - } |
|
2526 | + } |
|
2528 | 2527 | |
2529 | - if ($delete) { |
|
2528 | + if ($delete) { |
|
2530 | 2529 | drupal_set_message(format_plural(count($threads), 'Deleted 1 thread.', 'Deleted @count threads.')); |
2531 | - } |
|
2532 | - else { |
|
2530 | + } |
|
2531 | + else { |
|
2533 | 2532 | drupal_set_message(format_plural(count($threads), 'Restored 1 thread.', 'Restored @count threads.')); |
2534 | - } |
|
2533 | + } |
|
2535 | 2534 | } |
2536 | 2535 | |
2537 | 2536 | /** |
2538 | 2537 | * Implements hook_privatemsg_thread_operations(). |
2539 | 2538 | */ |
2540 | 2539 | function privatemsg_privatemsg_thread_operations() { |
2541 | - $operations = array( |
|
2540 | + $operations = array( |
|
2542 | 2541 | 'mark as read' => array( |
2543 | - 'label' => t('Mark as read'), |
|
2544 | - 'callback' => 'privatemsg_thread_change_status', |
|
2545 | - 'callback arguments' => array('status' => PRIVATEMSG_READ), |
|
2546 | - 'undo callback' => 'privatemsg_thread_change_status', |
|
2547 | - 'undo callback arguments' => array('status' => PRIVATEMSG_UNREAD), |
|
2542 | + 'label' => t('Mark as read'), |
|
2543 | + 'callback' => 'privatemsg_thread_change_status', |
|
2544 | + 'callback arguments' => array('status' => PRIVATEMSG_READ), |
|
2545 | + 'undo callback' => 'privatemsg_thread_change_status', |
|
2546 | + 'undo callback arguments' => array('status' => PRIVATEMSG_UNREAD), |
|
2548 | 2547 | ), |
2549 | 2548 | 'mark as unread' => array( |
2550 | - 'label' => t('Mark as unread'), |
|
2551 | - 'callback' => 'privatemsg_thread_change_status', |
|
2552 | - 'callback arguments' => array('status' => PRIVATEMSG_UNREAD), |
|
2553 | - 'undo callback' => 'privatemsg_thread_change_status', |
|
2554 | - 'undo callback arguments' => array('status' => PRIVATEMSG_READ), |
|
2549 | + 'label' => t('Mark as unread'), |
|
2550 | + 'callback' => 'privatemsg_thread_change_status', |
|
2551 | + 'callback arguments' => array('status' => PRIVATEMSG_UNREAD), |
|
2552 | + 'undo callback' => 'privatemsg_thread_change_status', |
|
2553 | + 'undo callback arguments' => array('status' => PRIVATEMSG_READ), |
|
2555 | 2554 | ), |
2556 | - ); |
|
2557 | - if (privatemsg_user_access('delete privatemsg')) { |
|
2555 | + ); |
|
2556 | + if (privatemsg_user_access('delete privatemsg')) { |
|
2558 | 2557 | $operations['delete'] = array( |
2559 | - 'callback' => 'privatemsg_thread_change_delete', |
|
2560 | - 'callback arguments' => array('delete' => 1), |
|
2561 | - 'undo callback' => 'privatemsg_thread_change_delete', |
|
2562 | - 'undo callback arguments' => array('delete' => 0), |
|
2558 | + 'callback' => 'privatemsg_thread_change_delete', |
|
2559 | + 'callback arguments' => array('delete' => 1), |
|
2560 | + 'undo callback' => 'privatemsg_thread_change_delete', |
|
2561 | + 'undo callback arguments' => array('delete' => 0), |
|
2563 | 2562 | ); |
2564 | - } |
|
2565 | - return $operations; |
|
2563 | + } |
|
2564 | + return $operations; |
|
2566 | 2565 | } |
2567 | 2566 | |
2568 | 2567 | /** |
2569 | 2568 | * Implementation of hook_views_api(). |
2570 | 2569 | */ |
2571 | 2570 | function privatemsg_views_api() { |
2572 | - return array( |
|
2571 | + return array( |
|
2573 | 2572 | 'api' => 2, |
2574 | 2573 | 'path' => drupal_get_path('module', 'privatemsg') . '/views', |
2575 | - ); |
|
2574 | + ); |
|
2576 | 2575 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | |
100 | 100 | if ($no_text) { |
101 | - return implode(', ', $to) . $limit_string; |
|
101 | + return implode(', ', $to).$limit_string; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $last = array_pop($to); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @ingroup api |
221 | 221 | */ |
222 | 222 | function privatemsg_user_access($permission = 'read privatemsg', $account = NULL) { |
223 | - if ( $account === NULL ) { |
|
223 | + if ($account === NULL) { |
|
224 | 224 | global $user; |
225 | 225 | $account = $user; |
226 | 226 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | // message overlap. |
345 | 345 | // Note - the last page lists the earliest messages, not the latest. |
346 | 346 | $paging_count = variable_get('privatemsg_view_use_max_as_default', FALSE) ? $thread['message_count'] - variable_get('privatemsg_view_default_amount', 10) : $thread['message_count']; |
347 | - $last_page = $paging_count % $max_amount; |
|
347 | + $last_page = $paging_count%$max_amount; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | // Sanity check - we cannot start from a negative number. |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | '#options' => $amounts, |
547 | 547 | '#weight' => 20, |
548 | 548 | ); |
549 | - drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-admin.js'); |
|
549 | + drupal_add_js(drupal_get_path('module', 'privatemsg').'/privatemsg-admin.js'); |
|
550 | 550 | |
551 | 551 | $form['#submit'][] = 'private_message_settings_submit'; |
552 | 552 | return system_settings_form($form); |
@@ -640,9 +640,9 @@ discard block |
||
640 | 640 | $vars['message_timestamp'] = format_date($message['timestamp'], 'small'); |
641 | 641 | $vars['message_body'] = check_markup($message['body'], $message['format'], FALSE); |
642 | 642 | if (isset($vars['mid']) && isset($vars['thread_id']) && privatemsg_user_access('delete privatemsg')) { |
643 | - $vars['message_actions'][] = array('title' => t('Delete message'), 'href' => 'messages/delete/' . $vars['thread_id'] . '/' . $vars['mid']); |
|
643 | + $vars['message_actions'][] = array('title' => t('Delete message'), 'href' => 'messages/delete/'.$vars['thread_id'].'/'.$vars['mid']); |
|
644 | 644 | } |
645 | - $vars['message_anchors'][] = 'privatemsg-mid-' . $vars['mid']; |
|
645 | + $vars['message_anchors'][] = 'privatemsg-mid-'.$vars['mid']; |
|
646 | 646 | if (!empty($message['is_new'])) { |
647 | 647 | $vars['message_anchors'][] = 'new'; |
648 | 648 | $vars['new'] = drupal_ucfirst(t('new')); |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | |
656 | 656 | $vars['anchors'] = ''; |
657 | 657 | foreach ($vars['message_anchors'] as $anchor) { |
658 | - $vars['anchors'] .= '<a name="' . $anchor . '"></a>'; |
|
658 | + $vars['anchors'] .= '<a name="'.$anchor.'"></a>'; |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 | |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | global $user; |
759 | 759 | $account = $user; |
760 | 760 | } |
761 | - if ( !isset($counts[$account->uid])) { |
|
761 | + if (!isset($counts[$account->uid])) { |
|
762 | 762 | $query = _privatemsg_assemble_query('unread_count', $account); |
763 | 763 | $counts[$account->uid] = db_result(db_query($query['query'])); |
764 | 764 | } |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | 'query' => array('start' => $thread['older_start']), |
786 | 786 | 'title' => t('Display older messages'), |
787 | 787 | ); |
788 | - $older = l(t('<<'), 'messages/view/' . $thread['thread_id'], $options); |
|
788 | + $older = l(t('<<'), 'messages/view/'.$thread['thread_id'], $options); |
|
789 | 789 | } |
790 | 790 | $newer = ''; |
791 | 791 | if (isset($thread['newer_start'])) { |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | 'query' => array('start' => $thread['newer_start']), |
794 | 794 | 'title' => t('Display newer messages'), |
795 | 795 | ); |
796 | - $newer = l(t('>>'), 'messages/view/' . $thread['thread_id'], $options); |
|
796 | + $newer = l(t('>>'), 'messages/view/'.$thread['thread_id'], $options); |
|
797 | 797 | } |
798 | 798 | $substitutions = array('@from' => $thread['from'], '@to' => $thread['to'], '@total' => $thread['message_count'], '!previous_link' => $older, '!newer_link' => $newer); |
799 | 799 | $title = t('!previous_link Displaying messages @from - @to of @total !newer_link', $substitutions); |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | global $user; |
848 | 848 | |
849 | 849 | $recipients_string = ''; |
850 | - $body = ''; |
|
850 | + $body = ''; |
|
851 | 851 | |
852 | 852 | // convert recipients to array of user objects |
853 | 853 | if (!empty($recipients) && is_string($recipients) || is_int($recipients)) { |
@@ -879,7 +879,7 @@ discard block |
||
879 | 879 | } |
880 | 880 | $myuser = user_load(array('uid' => $recipient->uid)); |
881 | 881 | $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name); |
882 | - $to[] = $myname . "_" . $myuser->boincuser_id; |
|
882 | + $to[] = $myname."_".$myuser->boincuser_id; |
|
883 | 883 | $to_themed[$recipient->uid] = $myname; |
884 | 884 | } |
885 | 885 | else { |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | // Assume the user sent message to own account as if the usercount is one or less, then the user sent a message but not to self. |
893 | 893 | $myuser = user_load(array('uid' => $user->uid)); |
894 | 894 | $myname = preg_replace("/ /", "\xc2\xa0", $myuser->boincuser_name); |
895 | - $to[] = $myname . "_" . $myuser->boincuser_id; |
|
895 | + $to[] = $myname."_".$myuser->boincuser_id; |
|
896 | 896 | $to_themed[$user->uid] = $myname; |
897 | 897 | } |
898 | 898 | if (!empty($to)) { |
@@ -1007,7 +1007,7 @@ discard block |
||
1007 | 1007 | ); |
1008 | 1008 | $recipients_string_themed = implode(', ', $to_themed); |
1009 | 1009 | $form['privatemsg']['recipient_display'] = array( |
1010 | - '#value' => '<p>'. t('<strong>Reply to thread</strong>:<br /> Recipients: !to', array('!to' => $recipients_string_themed)) .'</p>', |
|
1010 | + '#value' => '<p>'.t('<strong>Reply to thread</strong>:<br /> Recipients: !to', array('!to' => $recipients_string_themed)).'</p>', |
|
1011 | 1011 | '#weight' => -10, |
1012 | 1012 | ); |
1013 | 1013 | if (empty($recipients_string)) { |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | // First, check if another module is able to resolve the string into an |
1102 | 1102 | // user object. |
1103 | 1103 | foreach (module_implements('privatemsg_name_lookup') as $module) { |
1104 | - $function = $module . '_privatemsg_name_lookup'; |
|
1104 | + $function = $module.'_privatemsg_name_lookup'; |
|
1105 | 1105 | if (($recipient = $function($string)) && is_object($recipient)) { |
1106 | 1106 | // If there is a match, continue with the next input string. |
1107 | 1107 | $recipients[$recipient->uid] = $recipient; |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | foreach ($form_state['validate_built_message']['recipients'] as $recipient) { |
1133 | 1133 | $recipient_names[] = theme('username', $recipient); |
1134 | 1134 | } |
1135 | - if ($status !== FALSE ) { |
|
1135 | + if ($status !== FALSE) { |
|
1136 | 1136 | drupal_set_message(t('A message has been sent to !recipients.', array('!recipients' => implode(', ', $recipient_names)))); |
1137 | 1137 | } |
1138 | 1138 | else { |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | $fields = array_filter(variable_get('privatemsg_display_fields', array('participants'))); |
1175 | 1175 | |
1176 | 1176 | // Required columns. |
1177 | - $fragments['select'][] = 'pmi.thread_id'; |
|
1177 | + $fragments['select'][] = 'pmi.thread_id'; |
|
1178 | 1178 | // We have to use MIN as the subject might not be the same in some threads. |
1179 | 1179 | // MIN() does not have a useful meaning except that it helps to correctly |
1180 | 1180 | // aggregate the thread on PostgreSQL. |
@@ -1186,32 +1186,32 @@ discard block |
||
1186 | 1186 | // Select number of messages in the thread if the count is |
1187 | 1187 | // set to be displayed. |
1188 | 1188 | if (in_array('count', $fields)) { |
1189 | - $fragments['select'][] = 'COUNT(distinct pmi.mid) as count'; |
|
1189 | + $fragments['select'][] = 'COUNT(distinct pmi.mid) as count'; |
|
1190 | 1190 | } |
1191 | 1191 | if (in_array('participants', $fields)) { |
1192 | 1192 | // Query for a string with uid's, for example "1,6,7". |
1193 | 1193 | // @todo: Replace this with a single query similiar to the tag list. |
1194 | 1194 | if ($GLOBALS['db_type'] == 'pgsql') { |
1195 | 1195 | // PostgreSQL does not know GROUP_CONCAT, so a subquery is required. |
1196 | - $fragments['select'][] = "array_to_string(array(SELECT DISTINCT textin(int4out(pmia.uid)) |
|
1196 | + $fragments['select'][] = "array_to_string(array(SELECT DISTINCT textin(int4out(pmia.uid)) |
|
1197 | 1197 | FROM {pm_index} pmia |
1198 | 1198 | WHERE pmia.thread_id = pmi.thread_id), ',') AS participants"; |
1199 | 1199 | } |
1200 | 1200 | else { |
1201 | - $fragments['select'][] = '(SELECT GROUP_CONCAT(DISTINCT pmia.uid SEPARATOR ",") |
|
1201 | + $fragments['select'][] = '(SELECT GROUP_CONCAT(DISTINCT pmia.uid SEPARATOR ",") |
|
1202 | 1202 | FROM {pm_index} pmia |
1203 | 1203 | WHERE pmia.thread_id = pmi.thread_id) AS participants'; |
1204 | 1204 | } |
1205 | 1205 | } |
1206 | 1206 | if (in_array('thread_started', $fields)) { |
1207 | - $fragments['select'][] = 'MIN(pm.timestamp) as thread_started'; |
|
1207 | + $fragments['select'][] = 'MIN(pm.timestamp) as thread_started'; |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | $fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid'; |
1211 | 1211 | |
1212 | 1212 | // Only load undeleted messages of the current user and group by thread. |
1213 | 1213 | $fragments['where'][] = 'pmi.uid = %d'; |
1214 | - $fragments['query_args']['where'][] = $account->uid; |
|
1214 | + $fragments['query_args']['where'][] = $account->uid; |
|
1215 | 1215 | $fragments['where'][] = 'pmi.deleted = 0'; |
1216 | 1216 | $fragments['group_by'][] = 'pmi.thread_id'; |
1217 | 1217 | |
@@ -1225,8 +1225,8 @@ discard block |
||
1225 | 1225 | // tablesort_sql() generates a ORDER BY string. However, the "ORDER BY " part |
1226 | 1226 | // is not needed and added by the query builder. Discard the first 9 |
1227 | 1227 | // characters of the string. |
1228 | - $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers( FALSE, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9); |
|
1229 | - $fragments['order_by'][] = $order_by; |
|
1228 | + $order_by = drupal_substr(tablesort_sql(_privatemsg_list_headers(FALSE, array_merge(array('subject', 'last_updated'), $fields)), $order_by_first), 9); |
|
1229 | + $fragments['order_by'][] = $order_by; |
|
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | /** |
@@ -1253,11 +1253,11 @@ discard block |
||
1253 | 1253 | |
1254 | 1254 | $fragments['inner_join'][] = 'INNER JOIN {pm_index} pmi ON pm.mid = pmi.mid'; |
1255 | 1255 | // Use IN() to load multiple messages at the same time. |
1256 | - $fragments['where'][] = 'pmi.mid IN (' . db_placeholders($pmids) . ')'; |
|
1257 | - $fragments['query_args']['where'] += $pmids; |
|
1256 | + $fragments['where'][] = 'pmi.mid IN ('.db_placeholders($pmids).')'; |
|
1257 | + $fragments['query_args']['where'] += $pmids; |
|
1258 | 1258 | if ($account) { |
1259 | - $fragments['where'][] = 'pmi.uid = %d'; |
|
1260 | - $fragments['query_args']['where'][] = $account->uid; |
|
1259 | + $fragments['where'][] = 'pmi.uid = %d'; |
|
1260 | + $fragments['query_args']['where'][] = $account->uid; |
|
1261 | 1261 | } |
1262 | 1262 | $fragments['order_by'][] = 'pm.timestamp ASC'; |
1263 | 1263 | $fragments['order_by'][] = 'pm.mid ASC'; |
@@ -1279,13 +1279,13 @@ discard block |
||
1279 | 1279 | $fragments['primary_table'] = '{pm_index} pmi'; |
1280 | 1280 | |
1281 | 1281 | $fragments['select'][] = 'pmi.mid'; |
1282 | - $fragments['where'][] = 'pmi.thread_id IN ('. db_placeholders($threads) .')'; |
|
1283 | - $fragments['query_args']['where'] += $threads; |
|
1282 | + $fragments['where'][] = 'pmi.thread_id IN ('.db_placeholders($threads).')'; |
|
1283 | + $fragments['query_args']['where'] += $threads; |
|
1284 | 1284 | $fragments['inner_join'][] = 'INNER JOIN {pm_message} pm ON (pm.mid = pmi.mid)'; |
1285 | 1285 | if ($account) { |
1286 | 1286 | // Only load the user's messages. |
1287 | 1287 | $fragments['where'][] = 'pmi.uid = %d'; |
1288 | - $fragments['query_args']['where'][] = $account->uid; |
|
1288 | + $fragments['query_args']['where'][] = $account->uid; |
|
1289 | 1289 | } |
1290 | 1290 | if (!$load_all) { |
1291 | 1291 | // Also load deleted messages when requested. |
@@ -1321,7 +1321,7 @@ discard block |
||
1321 | 1321 | |
1322 | 1322 | $fragments['inner_join'][] = 'INNER JOIN {users} u ON (u.uid = pmi.uid)'; |
1323 | 1323 | $fragments['where'][] = 'pmi.thread_id = %d'; |
1324 | - $fragments['query_args']['where'][] = $thread_id; |
|
1324 | + $fragments['query_args']['where'][] = $thread_id; |
|
1325 | 1325 | } |
1326 | 1326 | |
1327 | 1327 | /** |
@@ -1341,7 +1341,7 @@ discard block |
||
1341 | 1341 | $fragments['where'][] = 'pmi.deleted = 0'; |
1342 | 1342 | $fragments['where'][] = 'pmi.is_new = 1'; |
1343 | 1343 | $fragments['where'][] = 'pmi.uid = %d'; |
1344 | - $fragments['query_args']['where'][] = $account->uid; |
|
1344 | + $fragments['query_args']['where'][] = $account->uid; |
|
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | /** |
@@ -1361,7 +1361,7 @@ discard block |
||
1361 | 1361 | $fragments['select'][] = 'u.name,u.id'; |
1362 | 1362 | // Escape the % to get it through the placeholder replacement. |
1363 | 1363 | $fragments['where'][] = "u.name LIKE '%s'"; |
1364 | - $fragments['query_args']['where'][] = $search .'%%'; |
|
1364 | + $fragments['query_args']['where'][] = $search.'%%'; |
|
1365 | 1365 | if (!empty($names)) { |
1366 | 1366 | // If there are already names selected, exclude them from the |
1367 | 1367 | // suggestions. Extract the BOINC ids from the names array, and |
@@ -1371,7 +1371,7 @@ discard block |
||
1371 | 1371 | $boincid = substr($name, strrpos($name, '_') + 1); |
1372 | 1372 | $ids[$boincid] = $boincid; |
1373 | 1373 | } |
1374 | - $fragments['where'][] = "u.id NOT IN (". db_placeholders($ids, 'int') .")"; |
|
1374 | + $fragments['where'][] = "u.id NOT IN (".db_placeholders($ids, 'int').")"; |
|
1375 | 1375 | $fragments['query_args']['where'] += $ids; |
1376 | 1376 | } |
1377 | 1377 | // Only load active users and sort them by name. |
@@ -1404,7 +1404,7 @@ discard block |
||
1404 | 1404 | |
1405 | 1405 | // Only select messages that have been deleted more than n days ago. |
1406 | 1406 | $fragments['having'][] = 'MAX(pmi.deleted) < %d'; |
1407 | - $fragments['query_args']['having'][] = time() - $days * 86400; |
|
1407 | + $fragments['query_args']['having'][] = time() - $days*86400; |
|
1408 | 1408 | } |
1409 | 1409 | |
1410 | 1410 | /** |
@@ -1434,11 +1434,11 @@ discard block |
||
1434 | 1434 | db_set_active('boinc_rw'); |
1435 | 1435 | $result = db_query_range($query['query'], $fragment, 0, 10); |
1436 | 1436 | db_set_active('default'); |
1437 | - $prefix = count($names) ? implode(', ', $names) . ', ' : ''; |
|
1437 | + $prefix = count($names) ? implode(', ', $names).', ' : ''; |
|
1438 | 1438 | // 3: Build proper suggestions and print. |
1439 | 1439 | while ($user = db_fetch_object($result)) { |
1440 | 1440 | $myname = preg_replace("/ /", "\xc2\xa0", $user->name); |
1441 | - $matches[$prefix . $myname . "_" . $user->id . ', '] = htmlentities($myname) . ' (' . $user->id . ')'; |
|
1441 | + $matches[$prefix.$myname."_".$user->id.', '] = htmlentities($myname).' ('.$user->id.')'; |
|
1442 | 1442 | } |
1443 | 1443 | } |
1444 | 1444 | // convert to object to prevent drupal bug, see http://drupal.org/node/175361 |
@@ -1480,7 +1480,7 @@ discard block |
||
1480 | 1480 | |
1481 | 1481 | if (!empty($mids)) { |
1482 | 1482 | // Delete recipient entries in {pm_index} of the messages the user wrote. |
1483 | - db_query('DELETE FROM {pm_index} WHERE mid IN (' . db_placeholders($mids) . ')', $mids); |
|
1483 | + db_query('DELETE FROM {pm_index} WHERE mid IN ('.db_placeholders($mids).')', $mids); |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | // Delete recipient entries of that user. |
@@ -1552,10 +1552,10 @@ discard block |
||
1552 | 1552 | if (privatemsg_user_access('write privatemsg')) { |
1553 | 1553 | $links[] = l(t('Write new message'), 'messages/new'); |
1554 | 1554 | } |
1555 | - if (privatemsg_user_access('read privatemsg') || privatemsg_user_access('read all private messages') ) { |
|
1555 | + if (privatemsg_user_access('read privatemsg') || privatemsg_user_access('read all private messages')) { |
|
1556 | 1556 | $links[] = l(privatemsg_title_callback(), 'messages'); |
1557 | 1557 | } |
1558 | - if ( count( $links ) ) { |
|
1558 | + if (count($links)) { |
|
1559 | 1559 | $block = array( |
1560 | 1560 | 'subject' => t('Private messages'), |
1561 | 1561 | 'content' => theme('item_list', $links), |
@@ -1571,7 +1571,7 @@ discard block |
||
1571 | 1571 | ); |
1572 | 1572 | $form['delete_destination'] = array( |
1573 | 1573 | '#type' => 'value', |
1574 | - '#value' => count($thread['messages']) > 1 ? 'messages/view/' . $message['thread_id'] : 'messages', |
|
1574 | + '#value' => count($thread['messages']) > 1 ? 'messages/view/'.$message['thread_id'] : 'messages', |
|
1575 | 1575 | ); |
1576 | 1576 | |
1577 | 1577 | if (privatemsg_user_access('read all private messages')) { |
@@ -1584,7 +1584,7 @@ discard block |
||
1584 | 1584 | } |
1585 | 1585 | return confirm_form($form, |
1586 | 1586 | t('Are you sure you want to delete this message?'), |
1587 | - isset($_GET['destination']) ? $_GET['destination'] : 'messages/view/'. $message['thread_id'], |
|
1587 | + isset($_GET['destination']) ? $_GET['destination'] : 'messages/view/'.$message['thread_id'], |
|
1588 | 1588 | t('This action cannot be undone.'), |
1589 | 1589 | t('Delete'), |
1590 | 1590 | t('Cancel') |
@@ -1813,7 +1813,7 @@ discard block |
||
1813 | 1813 | } |
1814 | 1814 | |
1815 | 1815 | // Don't allow replies without a body. |
1816 | - if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '') ) { |
|
1816 | + if (!empty($message['thread_id']) && ($message['body'] === NULL || $message['body'] === '')) { |
|
1817 | 1817 | if ($form) { |
1818 | 1818 | form_set_error('body', t('Disallowed to send reply without a message.')); |
1819 | 1819 | } |
@@ -1929,7 +1929,7 @@ discard block |
||
1929 | 1929 | // 2) Save message to recipients. |
1930 | 1930 | // Each recipient gets a record in the pm_index table. |
1931 | 1931 | foreach ($message['recipients'] as $recipient) { |
1932 | - if (!db_query($index_sql, $mid, $message['thread_id'], $recipient->uid, 1) ) { |
|
1932 | + if (!db_query($index_sql, $mid, $message['thread_id'], $recipient->uid, 1)) { |
|
1933 | 1933 | // We assume if one insert failed then the rest may fail too against the |
1934 | 1934 | // same table. |
1935 | 1935 | return FALSE; |
@@ -1994,9 +1994,9 @@ discard block |
||
1994 | 1994 | if (empty($validated)) { |
1995 | 1995 | return FALSE; |
1996 | 1996 | } |
1997 | - $url = 'messages/new/'. implode(',', $validated); |
|
1997 | + $url = 'messages/new/'.implode(',', $validated); |
|
1998 | 1998 | if (!is_null($subject)) { |
1999 | - $url .= '/'. $subject; |
|
1999 | + $url .= '/'.$subject; |
|
2000 | 2000 | } |
2001 | 2001 | return $url; |
2002 | 2002 | } |
@@ -2106,7 +2106,7 @@ discard block |
||
2106 | 2106 | // we do the merge because we call call_user_func_array and not drupal_alter |
2107 | 2107 | // this is necessary because otherwise we would not be able to use $args correctly (otherwise it doesnt unfold) |
2108 | 2108 | $alterargs = array(&$fragments); |
2109 | - $query_function = $query_group .'_sql_'. $query_id; |
|
2109 | + $query_function = $query_group.'_sql_'.$query_id; |
|
2110 | 2110 | if (!empty($args)) { |
2111 | 2111 | $alterargs = array_merge($alterargs, $args); |
2112 | 2112 | } |
@@ -2143,7 +2143,7 @@ discard block |
||
2143 | 2143 | // Perform the whole query assembly only if we have something to select. |
2144 | 2144 | if (!empty($SELECT)) { |
2145 | 2145 | $str_select = implode(", ", $SELECT); |
2146 | - $query = "SELECT {$str_select} FROM ". $primary_table; |
|
2146 | + $query = "SELECT {$str_select} FROM ".$primary_table; |
|
2147 | 2147 | |
2148 | 2148 | // Also build a count query which can be passed to pager_query to get a "page count" as that does not play well with queries including "GROUP BY". |
2149 | 2149 | // In most cases, "COUNT(*)" is enough to get the count query, but in queries involving a GROUP BY, we want a count of the number of groups we have, not the count of elements inside each group. |
@@ -2152,10 +2152,10 @@ discard block |
||
2152 | 2152 | // PostgreSQL does not support COUNT(sometextfield, someintfield), so I'm only using the first one |
2153 | 2153 | // Works fine for thread_id/list but may generate an error when a more complex GROUP BY is used. |
2154 | 2154 | $str_group_by_count = current($GROUP_BY); |
2155 | - $count = "SELECT COUNT(DISTINCT {$str_group_by_count}) FROM ". $primary_table; |
|
2155 | + $count = "SELECT COUNT(DISTINCT {$str_group_by_count}) FROM ".$primary_table; |
|
2156 | 2156 | } |
2157 | 2157 | else { |
2158 | - $count = "SELECT COUNT(*) FROM ". $primary_table; |
|
2158 | + $count = "SELECT COUNT(*) FROM ".$primary_table; |
|
2159 | 2159 | } |
2160 | 2160 | |
2161 | 2161 | if (!empty($INNER_JOIN)) { |
@@ -2164,24 +2164,24 @@ discard block |
||
2164 | 2164 | $count .= " {$str_inner_join}"; |
2165 | 2165 | } |
2166 | 2166 | if (!empty($WHERE)) { |
2167 | - $str_where = '('. implode(') AND (', $WHERE) .')'; |
|
2167 | + $str_where = '('.implode(') AND (', $WHERE).')'; |
|
2168 | 2168 | $query .= " WHERE {$str_where}"; |
2169 | 2169 | $count .= " WHERE {$str_where}"; |
2170 | 2170 | } |
2171 | 2171 | if (!empty($GROUP_BY)) { |
2172 | - $str_group_by = ' GROUP BY '. implode(", ", $GROUP_BY) ; |
|
2172 | + $str_group_by = ' GROUP BY '.implode(", ", $GROUP_BY); |
|
2173 | 2173 | $query .= " {$str_group_by}"; |
2174 | 2174 | } |
2175 | 2175 | if (!empty($HAVING)) { |
2176 | - $str_having = '('. implode(') AND (', $HAVING) .')'; |
|
2176 | + $str_having = '('.implode(') AND (', $HAVING).')'; |
|
2177 | 2177 | $query .= " HAVING {$str_having}"; |
2178 | 2178 | // queries containing a HAVING break the count query on pgsql. |
2179 | 2179 | // In this case, use the subquery method as outlined in http://drupal.org/node/303087#comment-1370752 . |
2180 | 2180 | // The subquery method will work for all COUNT queries, but it is thought to be much slower, so we are only using it where other cross database approaches fail. |
2181 | - $count = 'SELECT COUNT(*) FROM ('. $query .') as count'; |
|
2181 | + $count = 'SELECT COUNT(*) FROM ('.$query.') as count'; |
|
2182 | 2182 | } |
2183 | 2183 | if (!empty($ORDER_BY)) { |
2184 | - $str_order_by = ' ORDER BY '. implode(", ", $ORDER_BY) ; |
|
2184 | + $str_order_by = ' ORDER BY '.implode(", ", $ORDER_BY); |
|
2185 | 2185 | $query .= " {$str_order_by}"; |
2186 | 2186 | } |
2187 | 2187 | $QUERY_ARGS = array_merge($QUERY_ARGS['select'], $QUERY_ARGS['join'], $QUERY_ARGS['where'], $QUERY_ARGS['having']); |
@@ -2246,7 +2246,7 @@ discard block |
||
2246 | 2246 | '#attributes' => array('class' => 'privatemsg-action-button'), |
2247 | 2247 | ); |
2248 | 2248 | // JS for hiding the execute button. |
2249 | - drupal_add_js(drupal_get_path('module', 'privatemsg') .'/privatemsg-list.js'); |
|
2249 | + drupal_add_js(drupal_get_path('module', 'privatemsg').'/privatemsg-list.js'); |
|
2250 | 2250 | return $form; |
2251 | 2251 | } |
2252 | 2252 | |
@@ -2271,7 +2271,7 @@ discard block |
||
2271 | 2271 | } |
2272 | 2272 | // Merge status and uid with the threads list. array_merge() will not overwrite/ignore thread_id 1. |
2273 | 2273 | $params = array_merge(array($status, $account->uid), $threads); |
2274 | - db_query('UPDATE {pm_index} SET is_new = %d WHERE uid = %d AND thread_id IN ('. db_placeholders($threads) .')', $params); |
|
2274 | + db_query('UPDATE {pm_index} SET is_new = %d WHERE uid = %d AND thread_id IN ('.db_placeholders($threads).')', $params); |
|
2275 | 2275 | |
2276 | 2276 | if ($status == PRIVATEMSG_UNREAD) { |
2277 | 2277 | drupal_set_message(format_plural(count($threads), 'Marked 1 thread as unread.', 'Marked @count threads as unread.')); |
@@ -2298,12 +2298,12 @@ discard block |
||
2298 | 2298 | $select_header['#weight'] = -50; |
2299 | 2299 | |
2300 | 2300 | // theme() doesn't include the theme file for patterns, we need to do it manually. |
2301 | - include_once drupal_get_path('module', 'privatemsg') .'/privatemsg.theme.inc'; |
|
2301 | + include_once drupal_get_path('module', 'privatemsg').'/privatemsg.theme.inc'; |
|
2302 | 2302 | |
2303 | 2303 | $header = array($select_header); |
2304 | 2304 | foreach ($keys as $key) { |
2305 | 2305 | // First, try to load a specific theme for that header, if not present, use the default. |
2306 | - if ($return = theme(array('privatemsg_list_header__'. $key, 'privatemsg_list_header'))) { |
|
2306 | + if ($return = theme(array('privatemsg_list_header__'.$key, 'privatemsg_list_header'))) { |
|
2307 | 2307 | // The default theme returns nothing, only store the value if we have something. |
2308 | 2308 | $header[$key] = $return; |
2309 | 2309 | } |
@@ -2324,7 +2324,7 @@ discard block |
||
2324 | 2324 | function _privatemsg_list_headers_fallback($keys) { |
2325 | 2325 | $header = array(); |
2326 | 2326 | foreach ($keys as $key) { |
2327 | - $theme_function = 'phptemplate_privatemsg_list_header__' . $key; |
|
2327 | + $theme_function = 'phptemplate_privatemsg_list_header__'.$key; |
|
2328 | 2328 | if (function_exists($theme_function)) { |
2329 | 2329 | $header[$key] = $theme_function(); |
2330 | 2330 | } |
@@ -2352,7 +2352,7 @@ discard block |
||
2352 | 2352 | } |
2353 | 2353 | foreach ($thread as $key => $data) { |
2354 | 2354 | // First, try to load a specific theme for that field, if not present, use the default. |
2355 | - if ($return = theme(array('privatemsg_list_field__'. $key, 'privatemsg_list_field'), $thread)) { |
|
2355 | + if ($return = theme(array('privatemsg_list_field__'.$key, 'privatemsg_list_field'), $thread)) { |
|
2356 | 2356 | // The default theme returns nothing, only store the value if we have something. |
2357 | 2357 | $row['data'][$key] = $return; |
2358 | 2358 | } |
@@ -2372,7 +2372,7 @@ discard block |
||
2372 | 2372 | function _privatemsg_list_thread_fallback($thread) { |
2373 | 2373 | $row_data = array(); |
2374 | 2374 | foreach ($thread as $key => $data) { |
2375 | - $theme_function = 'phptemplate_privatemsg_list_field__' . $key; |
|
2375 | + $theme_function = 'phptemplate_privatemsg_list_field__'.$key; |
|
2376 | 2376 | if (function_exists($theme_function)) { |
2377 | 2377 | $row_data[$key] = $theme_function($thread); |
2378 | 2378 | } |
@@ -2571,6 +2571,6 @@ discard block |
||
2571 | 2571 | function privatemsg_views_api() { |
2572 | 2572 | return array( |
2573 | 2573 | 'api' => 2, |
2574 | - 'path' => drupal_get_path('module', 'privatemsg') . '/views', |
|
2574 | + 'path' => drupal_get_path('module', 'privatemsg').'/views', |
|
2575 | 2575 | ); |
2576 | 2576 | } |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function pm_block_user_help($path) { |
22 | 22 | switch ($path) { |
23 | - case 'admin/settings/messages/block': |
|
24 | - return '<p>' . t('This area is used to define user blocking rules for the Privatemsg module. Rules allow control of who may block messages from whom. By default all users are allowed to block messages from anyone else. However, a site may have groups of users that need to contact or get information to others, for example: the site may have administrative staff or be a forum with moderators. Groups of users are defined by roles, which can be managed on the <a href="@roles">roles configuration page</a>.', array('@roles' => url('admin/user/roles'))) . '</p>'; |
|
23 | + case 'admin/settings/messages/block': |
|
24 | + return '<p>' . t('This area is used to define user blocking rules for the Privatemsg module. Rules allow control of who may block messages from whom. By default all users are allowed to block messages from anyone else. However, a site may have groups of users that need to contact or get information to others, for example: the site may have administrative staff or be a forum with moderators. Groups of users are defined by roles, which can be managed on the <a href="@roles">roles configuration page</a>.', array('@roles' => url('admin/user/roles'))) . '</p>'; |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
@@ -485,14 +485,14 @@ discard block |
||
485 | 485 | function pm_block_user_form_submit($form, &$form_state) { |
486 | 486 | if ($form_state['values']['confirm']) { |
487 | 487 | switch ($form_state['values']['block_action']) { |
488 | - case 'block_user': |
|
489 | - db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $form_state['values']['author'], $form_state['values']['recipient']); |
|
490 | - drupal_set_message(t('@author has been blocked from sending you any further messages.', array('@author' => $form_state['values']['author_name']))); |
|
491 | - break; |
|
492 | - case 'unblock_user': |
|
493 | - db_query('DELETE FROM {pm_block_user} WHERE author = %d AND recipient = %d', $form_state['values']['author'], $form_state['values']['recipient']); |
|
494 | - drupal_set_message(t('@author is now allowed to send you new messages.', array('@author' => $form_state['values']['author_name']))); |
|
495 | - break; |
|
488 | + case 'block_user': |
|
489 | + db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $form_state['values']['author'], $form_state['values']['recipient']); |
|
490 | + drupal_set_message(t('@author has been blocked from sending you any further messages.', array('@author' => $form_state['values']['author_name']))); |
|
491 | + break; |
|
492 | + case 'unblock_user': |
|
493 | + db_query('DELETE FROM {pm_block_user} WHERE author = %d AND recipient = %d', $form_state['values']['author'], $form_state['values']['recipient']); |
|
494 | + drupal_set_message(t('@author is now allowed to send you new messages.', array('@author' => $form_state['values']['author_name']))); |
|
495 | + break; |
|
496 | 496 | } |
497 | 497 | } |
498 | 498 | $form_state['redirect'] = $form_state['values']['destination']; |
@@ -576,9 +576,9 @@ discard block |
||
576 | 576 | */ |
577 | 577 | function pm_block_user_user($op, &$edit, &$account, $category = NULL) { |
578 | 578 | switch ($op) { |
579 | - case 'delete': |
|
580 | - // Delete blocking rules which involve this user. |
|
581 | - db_query("DELETE FROM {pm_block_user} WHERE author = %d OR recipient = %d", $account->uid, $account->uid); |
|
582 | - break; |
|
579 | + case 'delete': |
|
580 | + // Delete blocking rules which involve this user. |
|
581 | + db_query("DELETE FROM {pm_block_user} WHERE author = %d OR recipient = %d", $account->uid, $account->uid); |
|
582 | + break; |
|
583 | 583 | } |
584 | 584 | } |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | drupal_add_css(drupal_get_path('module', 'pm_block_user') .'/pm_block_user.css'); |
66 | 66 | // Need to cache form for AHAH, so it can be rebuilt from cache later. |
67 | 67 | $form = array( |
68 | - '#cache' => TRUE, |
|
68 | + '#cache' => true, |
|
69 | 69 | ); |
70 | 70 | |
71 | 71 | // Container for just the actions, used for AHAH. |
72 | 72 | $form['block_actions'] = array( |
73 | - '#tree' => TRUE, |
|
73 | + '#tree' => true, |
|
74 | 74 | '#prefix' => '<div id="block-actions">', |
75 | 75 | '#suffix' => '</div>', |
76 | 76 | '#theme' => 'pm_block_user_actions', |
@@ -131,24 +131,24 @@ discard block |
||
131 | 131 | * @return |
132 | 132 | * Part of a form with controls for sending, receiving and actions. |
133 | 133 | */ |
134 | -function _pm_block_user_actions_form($details, $blacklist = TRUE) { |
|
134 | +function _pm_block_user_actions_form($details, $blacklist = true) { |
|
135 | 135 | $form = array( |
136 | - '#tree' => TRUE, |
|
136 | + '#tree' => true, |
|
137 | 137 | ); |
138 | 138 | $delta = $details['delta']; |
139 | 139 | // FALSE by default, or if the user has checked the 'Enabled' check box for |
140 | 140 | // this row. |
141 | - $row_disabled = (isset($details['enabled']) ? !$details['enabled'] : FALSE); |
|
141 | + $row_disabled = (isset($details['enabled']) ? !$details['enabled'] : false); |
|
142 | 142 | |
143 | 143 | $form['author'] = array( |
144 | 144 | '#type' => 'select', |
145 | - '#options' => user_roles(TRUE), |
|
145 | + '#options' => user_roles(true), |
|
146 | 146 | '#default_value' => (isset($details['author']) ? $details['author'] : DRUPAL_AUTHENTICATED_RID), |
147 | 147 | '#disabled' => $row_disabled, |
148 | 148 | ); |
149 | 149 | $form['recipient'] = array( |
150 | 150 | '#type' => 'select', |
151 | - '#options' => user_roles(TRUE), |
|
151 | + '#options' => user_roles(true), |
|
152 | 152 | '#default_value' => (isset($details['recipient']) ? $details['recipient'] : DRUPAL_AUTHENTICATED_RID), |
153 | 153 | '#disabled' => $row_disabled, |
154 | 154 | ); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | |
174 | 174 | $form['enabled'] = array( |
175 | 175 | '#type' => 'checkbox', |
176 | - '#default_value' => (isset($details['enabled']) ? $details['enabled'] : TRUE), |
|
176 | + '#default_value' => (isset($details['enabled']) ? $details['enabled'] : true), |
|
177 | 177 | ); |
178 | 178 | $form['remove'] = array( |
179 | 179 | '#type' => 'submit', |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $form_state['pm_block_user'] = $submitted_values; |
210 | 210 | // Rebuild the form by passing our $form_state through the |
211 | 211 | // pm_block_user_settings() builder function. |
212 | - $form_state['rebuild'] = TRUE; |
|
212 | + $form_state['rebuild'] = true; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $delta = $form_state['clicked_button']['#parents'][1]; |
226 | 226 | unset($submitted_values['block_actions'][$delta]); |
227 | 227 | $form_state['pm_block_user'] = $submitted_values; |
228 | - $form_state['rebuild'] = TRUE; |
|
228 | + $form_state['rebuild'] = true; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -283,14 +283,14 @@ discard block |
||
283 | 283 | */ |
284 | 284 | function pm_block_user_js() { |
285 | 285 | // See: http://drupal.org/node/331941 for the philosophy of Drupal AHAH. |
286 | - $form_state = array('storage' => NULL, 'submitted' => FALSE); |
|
286 | + $form_state = array('storage' => null, 'submitted' => false); |
|
287 | 287 | $form_build_id = $_POST['form_build_id']; |
288 | 288 | $form = form_get_cache($form_build_id, $form_state); |
289 | 289 | $args = $form['#parameters']; |
290 | 290 | $form_id = array_shift($args); |
291 | 291 | $form['#post'] = $_POST; |
292 | - $form['#redirect'] = FALSE; |
|
293 | - $form['#programmed'] = FALSE; |
|
292 | + $form['#redirect'] = false; |
|
293 | + $form['#programmed'] = false; |
|
294 | 294 | $form_state['post'] = $_POST; |
295 | 295 | drupal_process_form($form_id, $form, $form_state); |
296 | 296 | $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | |
301 | 301 | // Hack to make behaviours attach to new HTML controls (delete buttons in |
302 | 302 | // this case). |
303 | - $javascript = drupal_add_js(NULL, NULL, 'header'); |
|
304 | - drupal_json(array('status' => TRUE, 'data' => $output)); |
|
303 | + $javascript = drupal_add_js(null, null, 'header'); |
|
304 | + drupal_json(array('status' => true, 'data' => $output)); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | function pm_block_user_theme() { |
311 | 311 | return array( |
312 | 312 | 'pm_block_user_actions' => array( |
313 | - 'arguments' => array('form' => NULL), |
|
313 | + 'arguments' => array('form' => null), |
|
314 | 314 | ), |
315 | 315 | ); |
316 | 316 | } |
@@ -379,12 +379,12 @@ discard block |
||
379 | 379 | function _pm_block_user_access($account) { |
380 | 380 | global $user; |
381 | 381 | if (!privatemsg_user_access('read privatemsg', $user)) { |
382 | - return FALSE; |
|
382 | + return false; |
|
383 | 383 | } |
384 | 384 | if (_pm_block_user_rule_exists($account, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) { |
385 | - return FALSE; |
|
385 | + return false; |
|
386 | 386 | } |
387 | - return TRUE; |
|
387 | + return true; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
@@ -425,10 +425,10 @@ discard block |
||
425 | 425 | } |
426 | 426 | // The author has a role matching the rule and so does the recipient. |
427 | 427 | if (isset($author->roles[$details['author']]) && isset($recipient->roles[$details['recipient']])) { |
428 | - return TRUE; |
|
428 | + return true; |
|
429 | 429 | } |
430 | 430 | } |
431 | - return FALSE; |
|
431 | + return false; |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | function pm_block_user_form($form_state, $author) { |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | /** |
575 | 575 | * Implement hook_user(). |
576 | 576 | */ |
577 | -function pm_block_user_user($op, &$edit, &$account, $category = NULL) { |
|
577 | +function pm_block_user_user($op, &$edit, &$account, $category = null) { |
|
578 | 578 | switch ($op) { |
579 | 579 | case 'delete': |
580 | 580 | // Delete blocking rules which involve this user. |
@@ -19,17 +19,17 @@ discard block |
||
19 | 19 | * Implements hook_help(). |
20 | 20 | */ |
21 | 21 | function pm_block_user_help($path) { |
22 | - switch ($path) { |
|
22 | + switch ($path) { |
|
23 | 23 | case 'admin/settings/messages/block': |
24 | 24 | return '<p>' . t('This area is used to define user blocking rules for the Privatemsg module. Rules allow control of who may block messages from whom. By default all users are allowed to block messages from anyone else. However, a site may have groups of users that need to contact or get information to others, for example: the site may have administrative staff or be a forum with moderators. Groups of users are defined by roles, which can be managed on the <a href="@roles">roles configuration page</a>.', array('@roles' => url('admin/user/roles'))) . '</p>'; |
25 | - } |
|
25 | + } |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Implements hook_menu(). |
30 | 30 | */ |
31 | 31 | function pm_block_user_menu() { |
32 | - $items['messages/block/%user'] = array( |
|
32 | + $items['messages/block/%user'] = array( |
|
33 | 33 | 'title' => 'Block user messages', |
34 | 34 | 'page callback' => 'drupal_get_form', |
35 | 35 | 'page arguments' => array('pm_block_user_form', 2), |
@@ -37,61 +37,61 @@ discard block |
||
37 | 37 | 'access arguments' => array(2), |
38 | 38 | 'type' => MENU_CALLBACK, |
39 | 39 | 'weight' => -10, |
40 | - ); |
|
40 | + ); |
|
41 | 41 | |
42 | - $items['admin/settings/messages/block'] = array( |
|
42 | + $items['admin/settings/messages/block'] = array( |
|
43 | 43 | 'title' => 'User blocking rules', |
44 | 44 | 'description' => 'Configure rules for which users may block each other.', |
45 | 45 | 'page callback' => 'drupal_get_form', |
46 | 46 | 'page arguments' => array('pm_block_user_settings'), |
47 | 47 | 'access arguments' => array('administer privatemsg settings'), |
48 | 48 | 'type' => MENU_LOCAL_TASK, |
49 | - ); |
|
49 | + ); |
|
50 | 50 | |
51 | - $items['messages/block/js'] = array( |
|
51 | + $items['messages/block/js'] = array( |
|
52 | 52 | 'title' => 'Javascript block actions form', |
53 | 53 | 'page callback' => 'pm_block_user_js', |
54 | 54 | 'access arguments' => array('administer privatemsg settings'), |
55 | 55 | 'type' => MENU_CALLBACK, |
56 | - ); |
|
56 | + ); |
|
57 | 57 | |
58 | - return $items; |
|
58 | + return $items; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Menu callback for blocked user settings. |
63 | 63 | */ |
64 | 64 | function pm_block_user_settings(&$form_state) { |
65 | - drupal_add_css(drupal_get_path('module', 'pm_block_user') .'/pm_block_user.css'); |
|
66 | - // Need to cache form for AHAH, so it can be rebuilt from cache later. |
|
67 | - $form = array( |
|
65 | + drupal_add_css(drupal_get_path('module', 'pm_block_user') .'/pm_block_user.css'); |
|
66 | + // Need to cache form for AHAH, so it can be rebuilt from cache later. |
|
67 | + $form = array( |
|
68 | 68 | '#cache' => TRUE, |
69 | - ); |
|
69 | + ); |
|
70 | 70 | |
71 | - // Container for just the actions, used for AHAH. |
|
72 | - $form['block_actions'] = array( |
|
71 | + // Container for just the actions, used for AHAH. |
|
72 | + $form['block_actions'] = array( |
|
73 | 73 | '#tree' => TRUE, |
74 | 74 | '#prefix' => '<div id="block-actions">', |
75 | 75 | '#suffix' => '</div>', |
76 | 76 | '#theme' => 'pm_block_user_actions', |
77 | - ); |
|
77 | + ); |
|
78 | 78 | |
79 | - // Should we populate the form with data from $form_state or the database? |
|
80 | - if (!isset($form_state['pm_block_user']['block_actions'])) { |
|
79 | + // Should we populate the form with data from $form_state or the database? |
|
80 | + if (!isset($form_state['pm_block_user']['block_actions'])) { |
|
81 | 81 | $block_actions = variable_get('pm_block_user_actions', array()); |
82 | - } |
|
83 | - else { |
|
82 | + } |
|
83 | + else { |
|
84 | 84 | $block_actions = $form_state['pm_block_user']['block_actions']; |
85 | - } |
|
86 | - // Work through each rule, adding it as a new element in |
|
87 | - // $form['block_actions'] ready to be themed later. |
|
88 | - foreach ($block_actions as $delta => $details) { |
|
85 | + } |
|
86 | + // Work through each rule, adding it as a new element in |
|
87 | + // $form['block_actions'] ready to be themed later. |
|
88 | + foreach ($block_actions as $delta => $details) { |
|
89 | 89 | $details['delta'] = $delta; |
90 | 90 | $form['block_actions'][$delta] = _pm_block_user_actions_form($details); |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | - // The magic AHAH callback button that adds more rows. |
|
94 | - $form['pm_block_actions_more'] = array( |
|
93 | + // The magic AHAH callback button that adds more rows. |
|
94 | + $form['pm_block_actions_more'] = array( |
|
95 | 95 | '#type' => 'submit', |
96 | 96 | '#value' => t('More'), |
97 | 97 | '#weight' => 1, |
@@ -99,20 +99,20 @@ discard block |
||
99 | 99 | '#suffix' => '<label for="edit-pm-block-actions-more">' . t('Add new rule') . '</label></div>', |
100 | 100 | '#submit' => array('pm_block_user_more_submit'), |
101 | 101 | '#ahah' => array( |
102 | - 'path' => 'messages/block/js', |
|
103 | - 'wrapper' => 'block-actions', |
|
104 | - 'method' => 'replace', |
|
105 | - 'effect' => 'fade', |
|
102 | + 'path' => 'messages/block/js', |
|
103 | + 'wrapper' => 'block-actions', |
|
104 | + 'method' => 'replace', |
|
105 | + 'effect' => 'fade', |
|
106 | 106 | ), |
107 | - ); |
|
107 | + ); |
|
108 | 108 | |
109 | - $form['submit_form'] = array( |
|
109 | + $form['submit_form'] = array( |
|
110 | 110 | '#type' => 'submit', |
111 | 111 | '#weight' => 10, |
112 | 112 | '#value' => t('Save configuration'), |
113 | - ); |
|
113 | + ); |
|
114 | 114 | |
115 | - return $form; |
|
115 | + return $form; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -132,50 +132,50 @@ discard block |
||
132 | 132 | * Part of a form with controls for sending, receiving and actions. |
133 | 133 | */ |
134 | 134 | function _pm_block_user_actions_form($details, $blacklist = TRUE) { |
135 | - $form = array( |
|
135 | + $form = array( |
|
136 | 136 | '#tree' => TRUE, |
137 | - ); |
|
138 | - $delta = $details['delta']; |
|
139 | - // FALSE by default, or if the user has checked the 'Enabled' check box for |
|
140 | - // this row. |
|
141 | - $row_disabled = (isset($details['enabled']) ? !$details['enabled'] : FALSE); |
|
137 | + ); |
|
138 | + $delta = $details['delta']; |
|
139 | + // FALSE by default, or if the user has checked the 'Enabled' check box for |
|
140 | + // this row. |
|
141 | + $row_disabled = (isset($details['enabled']) ? !$details['enabled'] : FALSE); |
|
142 | 142 | |
143 | - $form['author'] = array( |
|
143 | + $form['author'] = array( |
|
144 | 144 | '#type' => 'select', |
145 | 145 | '#options' => user_roles(TRUE), |
146 | 146 | '#default_value' => (isset($details['author']) ? $details['author'] : DRUPAL_AUTHENTICATED_RID), |
147 | 147 | '#disabled' => $row_disabled, |
148 | - ); |
|
149 | - $form['recipient'] = array( |
|
148 | + ); |
|
149 | + $form['recipient'] = array( |
|
150 | 150 | '#type' => 'select', |
151 | 151 | '#options' => user_roles(TRUE), |
152 | 152 | '#default_value' => (isset($details['recipient']) ? $details['recipient'] : DRUPAL_AUTHENTICATED_RID), |
153 | 153 | '#disabled' => $row_disabled, |
154 | - ); |
|
154 | + ); |
|
155 | 155 | |
156 | - // Provide different action radios if we're using a whitelist or a blacklist. |
|
157 | - if ($blacklist) { |
|
156 | + // Provide different action radios if we're using a whitelist or a blacklist. |
|
157 | + if ($blacklist) { |
|
158 | 158 | $options = array( |
159 | - PM_BLOCK_USER_DISALLOW_BLOCKING => t('Disallow blocking author'), |
|
160 | - PM_BLOCK_USER_DISALLOW_SENDING => t('Disallow sending message'), |
|
159 | + PM_BLOCK_USER_DISALLOW_BLOCKING => t('Disallow blocking author'), |
|
160 | + PM_BLOCK_USER_DISALLOW_SENDING => t('Disallow sending message'), |
|
161 | 161 | ); |
162 | 162 | $default_value = (isset($details['action']) ? $details['action'] : PM_BLOCK_USER_DISALLOW_BLOCKING); |
163 | - } |
|
164 | - else { |
|
163 | + } |
|
164 | + else { |
|
165 | 165 | // @todo: add whitelist options/default_value here. |
166 | - } |
|
167 | - $form['action'] = array( |
|
166 | + } |
|
167 | + $form['action'] = array( |
|
168 | 168 | '#type' => 'radios', |
169 | 169 | '#options' => $options, |
170 | 170 | '#disabled' => $row_disabled, |
171 | 171 | '#default_value' => $default_value, |
172 | - ); |
|
172 | + ); |
|
173 | 173 | |
174 | - $form['enabled'] = array( |
|
174 | + $form['enabled'] = array( |
|
175 | 175 | '#type' => 'checkbox', |
176 | 176 | '#default_value' => (isset($details['enabled']) ? $details['enabled'] : TRUE), |
177 | - ); |
|
178 | - $form['remove'] = array( |
|
177 | + ); |
|
178 | + $form['remove'] = array( |
|
179 | 179 | '#type' => 'submit', |
180 | 180 | '#submit' => array('pm_block_user_remove_submit'), |
181 | 181 | '#value' => t('Remove'), |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | '#prefix' => '<div id="remove-rule-button">', |
184 | 184 | '#suffix' => '<label for="edit-remove">' . t('Remove rule') . '</label></div>', |
185 | 185 | '#ahah' => array( |
186 | - 'path' => 'messages/block/js', |
|
187 | - 'wrapper' => 'block-actions', |
|
188 | - 'method' => 'replace', |
|
189 | - 'effect' => 'fade', |
|
186 | + 'path' => 'messages/block/js', |
|
187 | + 'wrapper' => 'block-actions', |
|
188 | + 'method' => 'replace', |
|
189 | + 'effect' => 'fade', |
|
190 | 190 | ), |
191 | - ); |
|
191 | + ); |
|
192 | 192 | |
193 | - return $form; |
|
193 | + return $form; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | * @see pm_block_user_remove_submit() |
200 | 200 | */ |
201 | 201 | function pm_block_user_more_submit($form, &$form_state) { |
202 | - unset($form_state['submit_handlers']); |
|
203 | - form_execute_handlers('submit', $form, $form_state); |
|
204 | - // Get the submitted actions, then put them into a special area of |
|
205 | - // the $form_state. |
|
206 | - $submitted_values = $form_state['values']; |
|
207 | - // Add an empty action. |
|
208 | - $submitted_values['block_actions'][] = array(); |
|
209 | - $form_state['pm_block_user'] = $submitted_values; |
|
210 | - // Rebuild the form by passing our $form_state through the |
|
211 | - // pm_block_user_settings() builder function. |
|
212 | - $form_state['rebuild'] = TRUE; |
|
202 | + unset($form_state['submit_handlers']); |
|
203 | + form_execute_handlers('submit', $form, $form_state); |
|
204 | + // Get the submitted actions, then put them into a special area of |
|
205 | + // the $form_state. |
|
206 | + $submitted_values = $form_state['values']; |
|
207 | + // Add an empty action. |
|
208 | + $submitted_values['block_actions'][] = array(); |
|
209 | + $form_state['pm_block_user'] = $submitted_values; |
|
210 | + // Rebuild the form by passing our $form_state through the |
|
211 | + // pm_block_user_settings() builder function. |
|
212 | + $form_state['rebuild'] = TRUE; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -218,33 +218,33 @@ discard block |
||
218 | 218 | * @see pm_block_user_more_submit() |
219 | 219 | */ |
220 | 220 | function pm_block_user_remove_submit($form, &$form_state) { |
221 | - unset($form_state['submit_handlers']); |
|
222 | - form_execute_handlers('submit', $form, $form_state); |
|
223 | - $submitted_values = $form_state['values']; |
|
224 | - // Remove the requested action. |
|
225 | - $delta = $form_state['clicked_button']['#parents'][1]; |
|
226 | - unset($submitted_values['block_actions'][$delta]); |
|
227 | - $form_state['pm_block_user'] = $submitted_values; |
|
228 | - $form_state['rebuild'] = TRUE; |
|
221 | + unset($form_state['submit_handlers']); |
|
222 | + form_execute_handlers('submit', $form, $form_state); |
|
223 | + $submitted_values = $form_state['values']; |
|
224 | + // Remove the requested action. |
|
225 | + $delta = $form_state['clicked_button']['#parents'][1]; |
|
226 | + unset($submitted_values['block_actions'][$delta]); |
|
227 | + $form_state['pm_block_user'] = $submitted_values; |
|
228 | + $form_state['rebuild'] = TRUE; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
232 | 232 | * Submit handler for admin form. |
233 | 233 | */ |
234 | 234 | function pm_block_user_settings_submit($form, &$form_state) { |
235 | - // We don't want it to submit when we're adding/removing actions. |
|
236 | - if ($form_state['clicked_button']['#id'] == 'edit-submit-form') { |
|
235 | + // We don't want it to submit when we're adding/removing actions. |
|
236 | + if ($form_state['clicked_button']['#id'] == 'edit-submit-form') { |
|
237 | 237 | // If the form's 'block_actions' aren't set, the user has deleted all the |
238 | 238 | // rows in the table, so we save an empty array to stop errors in the form |
239 | 239 | // builder. |
240 | 240 | if (isset($form_state['values']['block_actions'])) { |
241 | - variable_set('pm_block_user_actions', _pm_block_user_settings_filter($form_state['values']['block_actions'])); |
|
241 | + variable_set('pm_block_user_actions', _pm_block_user_settings_filter($form_state['values']['block_actions'])); |
|
242 | 242 | } |
243 | 243 | else { |
244 | - variable_set('pm_block_user_actions', array()); |
|
244 | + variable_set('pm_block_user_actions', array()); |
|
245 | 245 | } |
246 | 246 | drupal_set_message(t('The configuration options have been saved.')); |
247 | - } |
|
247 | + } |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -259,60 +259,60 @@ discard block |
||
259 | 259 | * @see pm_block_user_settings_submit() |
260 | 260 | */ |
261 | 261 | function _pm_block_user_settings_filter($settings) { |
262 | - // Add-in the names of any settings to be saved into the array below. |
|
263 | - $save_keys = array('author', 'recipient', 'action', 'enabled'); |
|
264 | - $matching = array(); |
|
265 | - // Run through each of the keys we want to save, creating a new array. |
|
266 | - // It's not possible to simply check for unwanted values and unset() them as |
|
267 | - // the array is multi-dimensional. |
|
268 | - foreach ($save_keys as $save_key) { |
|
262 | + // Add-in the names of any settings to be saved into the array below. |
|
263 | + $save_keys = array('author', 'recipient', 'action', 'enabled'); |
|
264 | + $matching = array(); |
|
265 | + // Run through each of the keys we want to save, creating a new array. |
|
266 | + // It's not possible to simply check for unwanted values and unset() them as |
|
267 | + // the array is multi-dimensional. |
|
268 | + foreach ($save_keys as $save_key) { |
|
269 | 269 | if (isset($settings[$save_key])) { |
270 | - $matching[$save_key] = $settings[$save_key]; |
|
270 | + $matching[$save_key] = $settings[$save_key]; |
|
271 | + } |
|
271 | 272 | } |
272 | - } |
|
273 | - if (count($matching) > 0) { |
|
273 | + if (count($matching) > 0) { |
|
274 | 274 | return $matching; |
275 | - } |
|
276 | - else { |
|
275 | + } |
|
276 | + else { |
|
277 | 277 | return array_map('_pm_block_user_settings_filter', $settings); |
278 | - } |
|
278 | + } |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
282 | 282 | * Menu callback for AHAH handling. |
283 | 283 | */ |
284 | 284 | function pm_block_user_js() { |
285 | - // See: http://drupal.org/node/331941 for the philosophy of Drupal AHAH. |
|
286 | - $form_state = array('storage' => NULL, 'submitted' => FALSE); |
|
287 | - $form_build_id = $_POST['form_build_id']; |
|
288 | - $form = form_get_cache($form_build_id, $form_state); |
|
289 | - $args = $form['#parameters']; |
|
290 | - $form_id = array_shift($args); |
|
291 | - $form['#post'] = $_POST; |
|
292 | - $form['#redirect'] = FALSE; |
|
293 | - $form['#programmed'] = FALSE; |
|
294 | - $form_state['post'] = $_POST; |
|
295 | - drupal_process_form($form_id, $form, $form_state); |
|
296 | - $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); |
|
297 | - $output_form = $form['block_actions']; |
|
298 | - unset($output_form['#prefix'], $output_form['#suffix']); // Prevent duplicate wrappers. |
|
299 | - $output = theme('status_messages') . drupal_render($output_form); |
|
300 | - |
|
301 | - // Hack to make behaviours attach to new HTML controls (delete buttons in |
|
302 | - // this case). |
|
303 | - $javascript = drupal_add_js(NULL, NULL, 'header'); |
|
304 | - drupal_json(array('status' => TRUE, 'data' => $output)); |
|
285 | + // See: http://drupal.org/node/331941 for the philosophy of Drupal AHAH. |
|
286 | + $form_state = array('storage' => NULL, 'submitted' => FALSE); |
|
287 | + $form_build_id = $_POST['form_build_id']; |
|
288 | + $form = form_get_cache($form_build_id, $form_state); |
|
289 | + $args = $form['#parameters']; |
|
290 | + $form_id = array_shift($args); |
|
291 | + $form['#post'] = $_POST; |
|
292 | + $form['#redirect'] = FALSE; |
|
293 | + $form['#programmed'] = FALSE; |
|
294 | + $form_state['post'] = $_POST; |
|
295 | + drupal_process_form($form_id, $form, $form_state); |
|
296 | + $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); |
|
297 | + $output_form = $form['block_actions']; |
|
298 | + unset($output_form['#prefix'], $output_form['#suffix']); // Prevent duplicate wrappers. |
|
299 | + $output = theme('status_messages') . drupal_render($output_form); |
|
300 | + |
|
301 | + // Hack to make behaviours attach to new HTML controls (delete buttons in |
|
302 | + // this case). |
|
303 | + $javascript = drupal_add_js(NULL, NULL, 'header'); |
|
304 | + drupal_json(array('status' => TRUE, 'data' => $output)); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
308 | 308 | * Implements hook_theme(). |
309 | 309 | */ |
310 | 310 | function pm_block_user_theme() { |
311 | - return array( |
|
311 | + return array( |
|
312 | 312 | 'pm_block_user_actions' => array( |
313 | - 'arguments' => array('form' => NULL), |
|
313 | + 'arguments' => array('form' => NULL), |
|
314 | 314 | ), |
315 | - ); |
|
315 | + ); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -321,49 +321,49 @@ discard block |
||
321 | 321 | * @ingroup themeable |
322 | 322 | */ |
323 | 323 | function theme_pm_block_user_actions($form) { |
324 | - $rows = array(); |
|
325 | - $headers = array( |
|
324 | + $rows = array(); |
|
325 | + $headers = array( |
|
326 | 326 | t('If the author has the role'), |
327 | 327 | t('And the recipient has the role'), |
328 | 328 | t('Action'), |
329 | 329 | t('Enabled'), |
330 | 330 | '', |
331 | - ); |
|
332 | - $form_data = element_children($form); |
|
331 | + ); |
|
332 | + $form_data = element_children($form); |
|
333 | 333 | |
334 | - foreach ($form_data as $key) { |
|
334 | + foreach ($form_data as $key) { |
|
335 | 335 | // Build the table row. |
336 | 336 | $row = array( |
337 | - 'data' => array( |
|
337 | + 'data' => array( |
|
338 | 338 | array('data' => drupal_render($form[$key]['author'])), |
339 | 339 | array('data' => drupal_render($form[$key]['recipient'])), |
340 | 340 | array('data' => drupal_render($form[$key]['action'])), |
341 | 341 | array('data' => drupal_render($form[$key]['enabled'])), |
342 | 342 | array('data' => drupal_render($form[$key]['remove'])), |
343 | - ), |
|
343 | + ), |
|
344 | 344 | ); |
345 | 345 | |
346 | 346 | // Add additional attributes to the row, such as a class for this row. |
347 | 347 | if (isset($form[$key]['#attributes'])) { |
348 | - $row = array_merge($row, $form[$key]['#attributes']); |
|
348 | + $row = array_merge($row, $form[$key]['#attributes']); |
|
349 | 349 | } |
350 | 350 | $rows[] = $row; |
351 | - } |
|
351 | + } |
|
352 | 352 | |
353 | - // If there are no rows, output some instructions for the user. |
|
354 | - if (empty($form_data)) { |
|
353 | + // If there are no rows, output some instructions for the user. |
|
354 | + if (empty($form_data)) { |
|
355 | 355 | $rows[] = array( |
356 | - array( |
|
356 | + array( |
|
357 | 357 | 'data' => t("No rules have been added. All users may block private messages from each other. To limit which users may be blocked, click 'Add new rule'."), |
358 | 358 | 'colspan' => '5', |
359 | - ), |
|
359 | + ), |
|
360 | 360 | ); |
361 | - } |
|
361 | + } |
|
362 | 362 | |
363 | - $output = theme('table', $headers, $rows); |
|
364 | - $output .= drupal_render($form); |
|
363 | + $output = theme('table', $headers, $rows); |
|
364 | + $output .= drupal_render($form); |
|
365 | 365 | |
366 | - return $output; |
|
366 | + return $output; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -377,14 +377,14 @@ discard block |
||
377 | 377 | * TRUE if the user is allowed to block $account, or FALSE if not. |
378 | 378 | */ |
379 | 379 | function _pm_block_user_access($account) { |
380 | - global $user; |
|
381 | - if (!privatemsg_user_access('read privatemsg', $user)) { |
|
380 | + global $user; |
|
381 | + if (!privatemsg_user_access('read privatemsg', $user)) { |
|
382 | 382 | return FALSE; |
383 | - } |
|
384 | - if (_pm_block_user_rule_exists($account, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) { |
|
383 | + } |
|
384 | + if (_pm_block_user_rule_exists($account, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) { |
|
385 | 385 | return FALSE; |
386 | - } |
|
387 | - return TRUE; |
|
386 | + } |
|
387 | + return TRUE; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
@@ -406,143 +406,143 @@ discard block |
||
406 | 406 | * TRUE if a rule exists for the combination of author recipient and action. |
407 | 407 | */ |
408 | 408 | function _pm_block_user_rule_exists($author, $recipient, $action = PM_BLOCK_USER_DISALLOW_BLOCKING) { |
409 | - $block_actions = variable_get('pm_block_user_actions', array()); |
|
410 | - foreach ($block_actions as $delta => $details) { |
|
409 | + $block_actions = variable_get('pm_block_user_actions', array()); |
|
410 | + foreach ($block_actions as $delta => $details) { |
|
411 | 411 | // If this rule doesn't relate to $action, or it's disabled |
412 | 412 | // ignore it and go to next loop iteration. |
413 | 413 | if ($details['action'] != $action || !$details['enabled']) { |
414 | - continue; |
|
414 | + continue; |
|
415 | 415 | } |
416 | 416 | // There are no rules governing user one, but user one may have roles that |
417 | 417 | // affect other users, so these exceptions are narrow in scope. |
418 | 418 | // Disallow sending affects private message authors. |
419 | 419 | if ($author->uid == 1 && $action == PM_BLOCK_USER_DISALLOW_SENDING) { |
420 | - continue; |
|
420 | + continue; |
|
421 | 421 | } |
422 | 422 | // Disallow blocking affects private message recipients. |
423 | 423 | if ($recipient->uid == 1 && $action == PM_BLOCK_USER_DISALLOW_BLOCKING) { |
424 | - continue; |
|
424 | + continue; |
|
425 | 425 | } |
426 | 426 | // The author has a role matching the rule and so does the recipient. |
427 | 427 | if (isset($author->roles[$details['author']]) && isset($recipient->roles[$details['recipient']])) { |
428 | - return TRUE; |
|
428 | + return TRUE; |
|
429 | + } |
|
429 | 430 | } |
430 | - } |
|
431 | - return FALSE; |
|
431 | + return FALSE; |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | function pm_block_user_form($form_state, $author) { |
435 | - global $user; |
|
435 | + global $user; |
|
436 | 436 | |
437 | - $form['author'] = array( |
|
437 | + $form['author'] = array( |
|
438 | 438 | '#type' => 'value', |
439 | 439 | '#value' => $author->uid, |
440 | - ); |
|
440 | + ); |
|
441 | 441 | $form['recipient'] = array( |
442 | 442 | '#type' => 'value', |
443 | 443 | '#value' => $user->uid, |
444 | - ); |
|
445 | - $form['author_name'] = array( |
|
444 | + ); |
|
445 | + $form['author_name'] = array( |
|
446 | 446 | '#type' => 'value', |
447 | 447 | '#value' => $author->name, |
448 | - ); |
|
449 | - $form['destination'] = array( |
|
448 | + ); |
|
449 | + $form['destination'] = array( |
|
450 | 450 | '#type' => 'value', |
451 | 451 | '#value' => isset($_GET['destination']) ? $_GET['destination'] : 'messages/', |
452 | - ); |
|
452 | + ); |
|
453 | 453 | |
454 | - if (db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $author->uid, $user->uid))) { |
|
454 | + if (db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $author->uid, $user->uid))) { |
|
455 | 455 | $form['block_action'] = array( |
456 | - '#type' => 'value', |
|
457 | - '#value' => 'unblock_user', |
|
456 | + '#type' => 'value', |
|
457 | + '#value' => 'unblock_user', |
|
458 | 458 | ); |
459 | 459 | return confirm_form($form, |
460 | - t('You have previously blocked "@author" from sending you any more messages. Are you sure you want to unblock this user?', array('@author' => $author->name)), |
|
461 | - isset($_GET['destination']) ? $_GET['destination'] : 'messages/', |
|
462 | - t('This action cannot be undone.'), |
|
463 | - t('Unblock @author', array('@author' => $author->name)), |
|
464 | - t('Cancel') |
|
460 | + t('You have previously blocked "@author" from sending you any more messages. Are you sure you want to unblock this user?', array('@author' => $author->name)), |
|
461 | + isset($_GET['destination']) ? $_GET['destination'] : 'messages/', |
|
462 | + t('This action cannot be undone.'), |
|
463 | + t('Unblock @author', array('@author' => $author->name)), |
|
464 | + t('Cancel') |
|
465 | 465 | ); |
466 | - } |
|
467 | - else { |
|
466 | + } |
|
467 | + else { |
|
468 | 468 | $form['block_action'] = array( |
469 | - '#type' => 'value', |
|
470 | - '#value' => 'block_user', |
|
469 | + '#type' => 'value', |
|
470 | + '#value' => 'block_user', |
|
471 | 471 | ); |
472 | 472 | return confirm_form($form, |
473 | - t('Are you sure you want to block "@author" from sending you any more messages?', array('@author' => $author->name)), |
|
474 | - isset($_GET['destination']) ? $_GET['destination'] : 'messages/', |
|
475 | - '', |
|
476 | - t('Block @author', array('@author' => $author->name)), |
|
477 | - t('Cancel') |
|
473 | + t('Are you sure you want to block "@author" from sending you any more messages?', array('@author' => $author->name)), |
|
474 | + isset($_GET['destination']) ? $_GET['destination'] : 'messages/', |
|
475 | + '', |
|
476 | + t('Block @author', array('@author' => $author->name)), |
|
477 | + t('Cancel') |
|
478 | 478 | ); |
479 | - } |
|
479 | + } |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | /** |
483 | 483 | * Implements hook_form_submit(). |
484 | 484 | */ |
485 | 485 | function pm_block_user_form_submit($form, &$form_state) { |
486 | - if ($form_state['values']['confirm']) { |
|
486 | + if ($form_state['values']['confirm']) { |
|
487 | 487 | switch ($form_state['values']['block_action']) { |
488 | - case 'block_user': |
|
488 | + case 'block_user': |
|
489 | 489 | db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $form_state['values']['author'], $form_state['values']['recipient']); |
490 | 490 | drupal_set_message(t('@author has been blocked from sending you any further messages.', array('@author' => $form_state['values']['author_name']))); |
491 | - break; |
|
492 | - case 'unblock_user': |
|
491 | + break; |
|
492 | + case 'unblock_user': |
|
493 | 493 | db_query('DELETE FROM {pm_block_user} WHERE author = %d AND recipient = %d', $form_state['values']['author'], $form_state['values']['recipient']); |
494 | 494 | drupal_set_message(t('@author is now allowed to send you new messages.', array('@author' => $form_state['values']['author_name']))); |
495 | - break; |
|
495 | + break; |
|
496 | + } |
|
496 | 497 | } |
497 | - } |
|
498 | - $form_state['redirect'] = $form_state['values']['destination']; |
|
498 | + $form_state['redirect'] = $form_state['values']['destination']; |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
502 | 502 | * Implements hook_privatemsg_block_message(). |
503 | 503 | */ |
504 | 504 | function pm_block_user_privatemsg_block_message($author, $recipients) { |
505 | - $blocked = array(); |
|
506 | - // Loop through each recipient and ensure there is no rule blocking this |
|
507 | - // author from sending them private messages. Use a reference, so when |
|
508 | - // user_load() is needed here the array is updated, negating the need for |
|
509 | - // further calls to user_load() later in the code. |
|
510 | - foreach (array_keys($recipients) as $uid) { |
|
505 | + $blocked = array(); |
|
506 | + // Loop through each recipient and ensure there is no rule blocking this |
|
507 | + // author from sending them private messages. Use a reference, so when |
|
508 | + // user_load() is needed here the array is updated, negating the need for |
|
509 | + // further calls to user_load() later in the code. |
|
510 | + foreach (array_keys($recipients) as $uid) { |
|
511 | 511 | |
512 | 512 | // Ensure we have a recipient user object which includes roles. |
513 | 513 | if (!isset($recipients[$uid]->roles)) { |
514 | - $recipients[$uid] = user_load($uid); |
|
514 | + $recipients[$uid] = user_load($uid); |
|
515 | 515 | } |
516 | 516 | // Note: this is checks whether the author may send the message (see third |
517 | 517 | // parameter). Further below is a check whether the recipient may block it. |
518 | 518 | if (_pm_block_user_rule_exists($author, $recipients[$uid], PM_BLOCK_USER_DISALLOW_SENDING)) { |
519 | - $blocked[] = array( |
|
519 | + $blocked[] = array( |
|
520 | 520 | 'uid' => $uid, |
521 | 521 | 'message' => t('Sorry, private messaging rules forbid sending messages to !name.', array('!name' => $recipients[$uid]->name)), |
522 | - ); |
|
522 | + ); |
|
523 | + } |
|
523 | 524 | } |
524 | - } |
|
525 | 525 | |
526 | - $args = array_merge(array($author->uid), array_keys($recipients)); |
|
527 | - $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('. db_placeholders($recipients) .') GROUP BY recipient', $args); |
|
528 | - while ($row = db_fetch_array($result)) { |
|
526 | + $args = array_merge(array($author->uid), array_keys($recipients)); |
|
527 | + $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('. db_placeholders($recipients) .') GROUP BY recipient', $args); |
|
528 | + while ($row = db_fetch_array($result)) { |
|
529 | 529 | $recipient = $recipients[$row['recipient']]; |
530 | 530 | // If there's a rule disallowing blocking of this message, send it anyway. |
531 | 531 | if (_pm_block_user_rule_exists($author, $recipient, PM_BLOCK_USER_DISALLOW_BLOCKING)) { |
532 | - continue; |
|
532 | + continue; |
|
533 | 533 | } |
534 | 534 | $blocked[] = array( |
535 | - 'uid' => $row['recipient'], |
|
536 | - 'message' => t('%name has chosen to not recieve any more messages from you.', array('%name' => $recipients[$row['recipient']]->name)) |
|
535 | + 'uid' => $row['recipient'], |
|
536 | + 'message' => t('%name has chosen to not recieve any more messages from you.', array('%name' => $recipients[$row['recipient']]->name)) |
|
537 | 537 | ); |
538 | - } |
|
539 | - return $blocked; |
|
538 | + } |
|
539 | + return $blocked; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | function pm_block_user_privatemsg_sql_load_alter(&$fragments, $pmid, $uid) { |
543 | - $fragments['select'][] = 'pmbu.recipient AS is_blocked'; |
|
543 | + $fragments['select'][] = 'pmbu.recipient AS is_blocked'; |
|
544 | 544 | |
545 | - $fragments['inner_join'][] = 'LEFT JOIN {pm_block_user} pmbu ON (pm.author = pmbu.author AND pmi.uid = pmbu.recipient)'; |
|
545 | + $fragments['inner_join'][] = 'LEFT JOIN {pm_block_user} pmbu ON (pm.author = pmbu.author AND pmi.uid = pmbu.recipient)'; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -558,10 +558,10 @@ discard block |
||
558 | 558 | * Implement hook_user(). |
559 | 559 | */ |
560 | 560 | function pm_block_user_user($op, &$edit, &$account, $category = NULL) { |
561 | - switch ($op) { |
|
562 | - case 'delete': |
|
561 | + switch ($op) { |
|
562 | + case 'delete': |
|
563 | 563 | // Delete blocking rules which involve this user. |
564 | 564 | db_query("DELETE FROM {pm_block_user} WHERE author = %d OR recipient = %d", $account->uid, $account->uid); |
565 | - break; |
|
566 | - } |
|
565 | + break; |
|
566 | + } |
|
567 | 567 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | function pm_block_user_help($path) { |
22 | 22 | switch ($path) { |
23 | 23 | case 'admin/settings/messages/block': |
24 | - return '<p>' . t('This area is used to define user blocking rules for the Privatemsg module. Rules allow control of who may block messages from whom. By default all users are allowed to block messages from anyone else. However, a site may have groups of users that need to contact or get information to others, for example: the site may have administrative staff or be a forum with moderators. Groups of users are defined by roles, which can be managed on the <a href="@roles">roles configuration page</a>.', array('@roles' => url('admin/user/roles'))) . '</p>'; |
|
24 | + return '<p>'.t('This area is used to define user blocking rules for the Privatemsg module. Rules allow control of who may block messages from whom. By default all users are allowed to block messages from anyone else. However, a site may have groups of users that need to contact or get information to others, for example: the site may have administrative staff or be a forum with moderators. Groups of users are defined by roles, which can be managed on the <a href="@roles">roles configuration page</a>.', array('@roles' => url('admin/user/roles'))).'</p>'; |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * Menu callback for blocked user settings. |
63 | 63 | */ |
64 | 64 | function pm_block_user_settings(&$form_state) { |
65 | - drupal_add_css(drupal_get_path('module', 'pm_block_user') .'/pm_block_user.css'); |
|
65 | + drupal_add_css(drupal_get_path('module', 'pm_block_user').'/pm_block_user.css'); |
|
66 | 66 | // Need to cache form for AHAH, so it can be rebuilt from cache later. |
67 | 67 | $form = array( |
68 | 68 | '#cache' => TRUE, |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | '#value' => t('More'), |
97 | 97 | '#weight' => 1, |
98 | 98 | '#prefix' => '<div id="add-rule-button">', |
99 | - '#suffix' => '<label for="edit-pm-block-actions-more">' . t('Add new rule') . '</label></div>', |
|
99 | + '#suffix' => '<label for="edit-pm-block-actions-more">'.t('Add new rule').'</label></div>', |
|
100 | 100 | '#submit' => array('pm_block_user_more_submit'), |
101 | 101 | '#ahah' => array( |
102 | 102 | 'path' => 'messages/block/js', |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | else { |
165 | 165 | // @todo: add whitelist options/default_value here. |
166 | 166 | } |
167 | - $form['action'] = array( |
|
167 | + $form['action'] = array( |
|
168 | 168 | '#type' => 'radios', |
169 | 169 | '#options' => $options, |
170 | 170 | '#disabled' => $row_disabled, |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | '#value' => t('Remove'), |
182 | 182 | '#attributes' => array('class' => 'remove-action'), |
183 | 183 | '#prefix' => '<div id="remove-rule-button">', |
184 | - '#suffix' => '<label for="edit-remove">' . t('Remove rule') . '</label></div>', |
|
184 | + '#suffix' => '<label for="edit-remove">'.t('Remove rule').'</label></div>', |
|
185 | 185 | '#ahah' => array( |
186 | 186 | 'path' => 'messages/block/js', |
187 | 187 | 'wrapper' => 'block-actions', |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); |
297 | 297 | $output_form = $form['block_actions']; |
298 | 298 | unset($output_form['#prefix'], $output_form['#suffix']); // Prevent duplicate wrappers. |
299 | - $output = theme('status_messages') . drupal_render($output_form); |
|
299 | + $output = theme('status_messages').drupal_render($output_form); |
|
300 | 300 | |
301 | 301 | // Hack to make behaviours attach to new HTML controls (delete buttons in |
302 | 302 | // this case). |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | } |
525 | 525 | |
526 | 526 | $args = array_merge(array($author->uid), array_keys($recipients)); |
527 | - $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('. db_placeholders($recipients) .') GROUP BY recipient', $args); |
|
527 | + $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('.db_placeholders($recipients).') GROUP BY recipient', $args); |
|
528 | 528 | while ($row = db_fetch_array($result)) { |
529 | 529 | $recipient = $recipients[$row['recipient']]; |
530 | 530 | // If there's a rule disallowing blocking of this message, send it anyway. |
@@ -79,8 +79,7 @@ discard block |
||
79 | 79 | // Should we populate the form with data from $form_state or the database? |
80 | 80 | if (!isset($form_state['pm_block_user']['block_actions'])) { |
81 | 81 | $block_actions = variable_get('pm_block_user_actions', array()); |
82 | - } |
|
83 | - else { |
|
82 | + } else { |
|
84 | 83 | $block_actions = $form_state['pm_block_user']['block_actions']; |
85 | 84 | } |
86 | 85 | // Work through each rule, adding it as a new element in |
@@ -160,8 +159,7 @@ discard block |
||
160 | 159 | PM_BLOCK_USER_DISALLOW_SENDING => t('Disallow sending message'), |
161 | 160 | ); |
162 | 161 | $default_value = (isset($details['action']) ? $details['action'] : PM_BLOCK_USER_DISALLOW_BLOCKING); |
163 | - } |
|
164 | - else { |
|
162 | + } else { |
|
165 | 163 | // @todo: add whitelist options/default_value here. |
166 | 164 | } |
167 | 165 | $form['action'] = array( |
@@ -239,8 +237,7 @@ discard block |
||
239 | 237 | // builder. |
240 | 238 | if (isset($form_state['values']['block_actions'])) { |
241 | 239 | variable_set('pm_block_user_actions', _pm_block_user_settings_filter($form_state['values']['block_actions'])); |
242 | - } |
|
243 | - else { |
|
240 | + } else { |
|
244 | 241 | variable_set('pm_block_user_actions', array()); |
245 | 242 | } |
246 | 243 | drupal_set_message(t('The configuration options have been saved.')); |
@@ -272,8 +269,7 @@ discard block |
||
272 | 269 | } |
273 | 270 | if (count($matching) > 0) { |
274 | 271 | return $matching; |
275 | - } |
|
276 | - else { |
|
272 | + } else { |
|
277 | 273 | return array_map('_pm_block_user_settings_filter', $settings); |
278 | 274 | } |
279 | 275 | } |
@@ -463,8 +459,7 @@ discard block |
||
463 | 459 | t('Unblock @author', array('@author' => $author->name)), |
464 | 460 | t('Cancel') |
465 | 461 | ); |
466 | - } |
|
467 | - else { |
|
462 | + } else { |
|
468 | 463 | $form['block_action'] = array( |
469 | 464 | '#type' => 'value', |
470 | 465 | '#value' => 'block_user', |
@@ -9,45 +9,45 @@ discard block |
||
9 | 9 | * Implements hook_block() for Drupal 6 compatibility |
10 | 10 | */ |
11 | 11 | function node_comment_block_block($op = 'list', $delta = 0, $edit = array()) { |
12 | - switch ($op) { |
|
13 | - case 'view': |
|
12 | + switch ($op) { |
|
13 | + case 'view': |
|
14 | 14 | //$block = node_comment_block_block_view($delta); |
15 | 15 | $block = array(); |
16 | 16 | if ($delta == 'node_comments') { |
17 | - if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { |
|
17 | + if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { |
|
18 | 18 | $node = node_load($nid); |
19 | 19 | if ($node->comment !== 0) { |
20 | - $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. |
|
21 | - $block['content'] = ''; |
|
22 | - if ($node->comment) { |
|
20 | + $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. |
|
21 | + $block['content'] = ''; |
|
22 | + if ($node->comment) { |
|
23 | 23 | $block['content'] .= comment_render($node); |
24 | - } |
|
24 | + } |
|
25 | + } |
|
25 | 26 | } |
26 | - } |
|
27 | 27 | } |
28 | 28 | break; |
29 | - case 'list': |
|
29 | + case 'list': |
|
30 | 30 | $blocks = node_comment_block_block_info(); |
31 | 31 | return $blocks; |
32 | 32 | break; |
33 | - default: |
|
33 | + default: |
|
34 | 34 | } |
35 | - return $block; |
|
35 | + return $block; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Port Drupal 7 render() function to Drupal 6 |
40 | 40 | */ |
41 | 41 | function render(&$element) { |
42 | - if (is_array($element)) { |
|
42 | + if (is_array($element)) { |
|
43 | 43 | show($element); |
44 | 44 | return drupal_render($element); |
45 | - } |
|
46 | - else { |
|
45 | + } |
|
46 | + else { |
|
47 | 47 | // Safe-guard for inappropriate use of render() on flat variables: return |
48 | 48 | // the variable as-is. |
49 | 49 | return $element; |
50 | - } |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -56,50 +56,50 @@ discard block |
||
56 | 56 | * Implements hook_block_info(). |
57 | 57 | */ |
58 | 58 | function node_comment_block_block_info() { |
59 | - $blocks['node_comments'] = array( |
|
59 | + $blocks['node_comments'] = array( |
|
60 | 60 | 'info' => t('Node comments'), |
61 | - ); |
|
61 | + ); |
|
62 | 62 | |
63 | - return $blocks; |
|
63 | + return $blocks; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Implements hook_block_view(). |
68 | 68 | */ |
69 | 69 | function node_comment_block_block_view($delta = '') { |
70 | - $block = array(); |
|
70 | + $block = array(); |
|
71 | 71 | |
72 | - if ($delta == 'node_comments') { |
|
72 | + if ($delta == 'node_comments') { |
|
73 | 73 | if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { |
74 | - $node = node_load($nid); |
|
74 | + $node = node_load($nid); |
|
75 | 75 | |
76 | - if ($node->comment !== 0) { |
|
76 | + if ($node->comment !== 0) { |
|
77 | 77 | $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. |
78 | 78 | $block['content'] = ''; |
79 | 79 | |
80 | 80 | $node = node_view($node); |
81 | 81 | |
82 | 82 | if ($node['comments']) { |
83 | - $block['content'] .= render($node['comments']); |
|
83 | + $block['content'] .= render($node['comments']); |
|
84 | + } |
|
84 | 85 | } |
85 | - } |
|
86 | 86 | } |
87 | - } |
|
87 | + } |
|
88 | 88 | |
89 | - return $block; |
|
89 | + return $block; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * Implements hook_preprocess_HOOK() for nodes. |
94 | 94 | */ |
95 | 95 | function node_comment_block_preprocess_node(&$variables) { |
96 | - $node = $variables['node']; |
|
97 | - // Only hide standard comments for news content |
|
98 | - if ($variables['type'] == 'news') { |
|
96 | + $node = $variables['node']; |
|
97 | + // Only hide standard comments for news content |
|
98 | + if ($variables['type'] == 'news') { |
|
99 | 99 | $variables['node']->comment = 0; |
100 | - } |
|
100 | + } |
|
101 | 101 | |
102 | - /* Drupal 7... |
|
102 | + /* Drupal 7... |
|
103 | 103 | if ($node->comment !== 0 && $variables['view_mode'] == 'full') { |
104 | 104 | if (isset($variables['content']['comments'])) { |
105 | 105 | unset($variables['content']['comments']); |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | * Implements hook_form_FORM_ID_alter() for block_admin_configure. |
114 | 114 | */ |
115 | 115 | function node_comment_block_form_block_admin_configure_alter(&$form, &$form_state) { |
116 | - if (isset($form['delta'])) { |
|
116 | + if (isset($form['delta'])) { |
|
117 | 117 | if ($form['delta']['#value'] == 'node_comments') { |
118 | - $form['settings']['title']['#disabled'] = TRUE; |
|
119 | - $form['settings']['title']['#description'] = t('The title for this block cannot be overridden.'); |
|
118 | + $form['settings']['title']['#disabled'] = TRUE; |
|
119 | + $form['settings']['title']['#description'] = t('The title for this block cannot be overridden.'); |
|
120 | + } |
|
120 | 121 | } |
121 | - } |
|
122 | 122 | } |
@@ -42,8 +42,7 @@ |
||
42 | 42 | if (is_array($element)) { |
43 | 43 | show($element); |
44 | 44 | return drupal_render($element); |
45 | - } |
|
46 | - else { |
|
45 | + } else { |
|
47 | 46 | // Safe-guard for inappropriate use of render() on flat variables: return |
48 | 47 | // the variable as-is. |
49 | 48 | return $element; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { |
18 | 18 | $node = node_load($nid); |
19 | 19 | if ($node->comment !== 0) { |
20 | - $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. |
|
20 | + $block['subject'] = null; // This should be NULL otherwise there will be duplicate h2 elements. |
|
21 | 21 | $block['content'] = ''; |
22 | 22 | if ($node->comment) { |
23 | 23 | $block['content'] .= comment_render($node); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $node = node_load($nid); |
75 | 75 | |
76 | 76 | if ($node->comment !== 0) { |
77 | - $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. |
|
77 | + $block['subject'] = null; // This should be NULL otherwise there will be duplicate h2 elements. |
|
78 | 78 | $block['content'] = ''; |
79 | 79 | |
80 | 80 | $node = node_view($node); |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | function node_comment_block_form_block_admin_configure_alter(&$form, &$form_state) { |
116 | 116 | if (isset($form['delta'])) { |
117 | 117 | if ($form['delta']['#value'] == 'node_comments') { |
118 | - $form['settings']['title']['#disabled'] = TRUE; |
|
118 | + $form['settings']['title']['#disabled'] = true; |
|
119 | 119 | $form['settings']['title']['#description'] = t('The title for this block cannot be overridden.'); |
120 | 120 | } |
121 | 121 | } |
@@ -9,29 +9,29 @@ |
||
9 | 9 | * Implements hook_block() for Drupal 6 compatibility |
10 | 10 | */ |
11 | 11 | function node_comment_block_block($op = 'list', $delta = 0, $edit = array()) { |
12 | - switch ($op) { |
|
13 | - case 'view': |
|
14 | - //$block = node_comment_block_block_view($delta); |
|
15 | - $block = array(); |
|
16 | - if ($delta == 'node_comments') { |
|
17 | - if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { |
|
18 | - $node = node_load($nid); |
|
19 | - if ($node->comment !== 0) { |
|
20 | - $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. |
|
21 | - $block['content'] = ''; |
|
22 | - if ($node->comment) { |
|
23 | - $block['content'] .= comment_render($node); |
|
24 | - } |
|
25 | - } |
|
26 | - } |
|
27 | - } |
|
28 | - break; |
|
29 | - case 'list': |
|
30 | - $blocks = node_comment_block_block_info(); |
|
31 | - return $blocks; |
|
32 | - break; |
|
33 | - default: |
|
34 | - } |
|
12 | +switch ($op) { |
|
13 | +case 'view': |
|
14 | +//$block = node_comment_block_block_view($delta); |
|
15 | +$block = array(); |
|
16 | +if ($delta == 'node_comments') { |
|
17 | +if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) { |
|
18 | +$node = node_load($nid); |
|
19 | +if ($node->comment !== 0) { |
|
20 | +$block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements. |
|
21 | +$block['content'] = ''; |
|
22 | +if ($node->comment) { |
|
23 | + $block['content'] .= comment_render($node); |
|
24 | +} |
|
25 | +} |
|
26 | +} |
|
27 | +} |
|
28 | +break; |
|
29 | +case 'list': |
|
30 | +$blocks = node_comment_block_block_info(); |
|
31 | +return $blocks; |
|
32 | +break; |
|
33 | +default: |
|
34 | +} |
|
35 | 35 | return $block; |
36 | 36 | } |
37 | 37 |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | switch ($op) { |
283 | - case 'delete': |
|
284 | - // Only call delete function on certain node types |
|
285 | - if (in_array( $node->type, $node_types)) { |
|
286 | - boinc_solr_comments_delete($node); |
|
287 | - } |
|
288 | - break; |
|
283 | + case 'delete': |
|
284 | + // Only call delete function on certain node types |
|
285 | + if (in_array( $node->type, $node_types)) { |
|
286 | + boinc_solr_comments_delete($node); |
|
287 | + } |
|
288 | + break; |
|
289 | 289 | } //switch |
290 | 290 | } |
291 | 291 | |
@@ -335,13 +335,13 @@ discard block |
||
335 | 335 | */ |
336 | 336 | function boinc_solr_comments_comment(&$a1, $op) { |
337 | 337 | switch ($op) { |
338 | - case 'view': |
|
339 | - case 'update': |
|
340 | - break; |
|
341 | - case 'delete': |
|
342 | - // $a1 should be a comment object |
|
343 | - boinc_solr_comments_deletecomment($a1); |
|
344 | - break; |
|
338 | + case 'view': |
|
339 | + case 'update': |
|
340 | + break; |
|
341 | + case 'delete': |
|
342 | + // $a1 should be a comment object |
|
343 | + boinc_solr_comments_deletecomment($a1); |
|
344 | + break; |
|
345 | 345 | }// switch |
346 | 346 | } |
347 | 347 |
@@ -131,8 +131,7 @@ discard block |
||
131 | 131 | if ($comment->uid == 0 || strlen($comment->name) == 0) { |
132 | 132 | // @see user_validate_name(). !'0' === TRUE. |
133 | 133 | $comment_document->ss_name = '0'; |
134 | - } |
|
135 | - else { |
|
134 | + } else { |
|
136 | 135 | $comment_document->ss_name = $comment->name; |
137 | 136 | // We want the name to be searchable for keywords. |
138 | 137 | $comment_document->tos_name = $comment->name; |
@@ -318,8 +317,7 @@ discard block |
||
318 | 317 | $solr->deleteByQuery($query); |
319 | 318 | // Log the query used for deletion. |
320 | 319 | watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); |
321 | - } |
|
322 | - catch (Exception $e) { |
|
320 | + } catch (Exception $e) { |
|
323 | 321 | watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
324 | 322 | return FALSE; |
325 | 323 | }// try |
@@ -376,8 +374,7 @@ discard block |
||
376 | 374 | $solr->deleteByQuery($query); |
377 | 375 | // Log the query used for deletion. |
378 | 376 | watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); |
379 | - } |
|
380 | - catch (Exception $e) { |
|
377 | + } catch (Exception $e) { |
|
381 | 378 | watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
382 | 379 | return FALSE; |
383 | 380 | }// try |
@@ -14,19 +14,19 @@ discard block |
||
14 | 14 | * Implementation of hook_menu() |
15 | 15 | */ |
16 | 16 | function boinc_solr_comments_menu() { |
17 | - $items = array(); |
|
18 | - $base_path = 'admin/settings/apachesolr/indexcomments'; |
|
19 | - $items[$base_path] = array( |
|
20 | - 'title' => 'Index Comments', |
|
21 | - 'description' => 'Administer Indexing of Comments', |
|
22 | - 'page callback' => 'drupal_get_form', |
|
23 | - 'page arguments' => array('boinc_solr_comments_form'), |
|
24 | - 'access arguments' => array('administer search'), |
|
25 | - 'file' => 'boinc_solr_comments.admin.inc', |
|
26 | - 'weight' => '10', |
|
27 | - ); |
|
28 | - |
|
29 | - return $items; |
|
17 | + $items = array(); |
|
18 | + $base_path = 'admin/settings/apachesolr/indexcomments'; |
|
19 | + $items[$base_path] = array( |
|
20 | + 'title' => 'Index Comments', |
|
21 | + 'description' => 'Administer Indexing of Comments', |
|
22 | + 'page callback' => 'drupal_get_form', |
|
23 | + 'page arguments' => array('boinc_solr_comments_form'), |
|
24 | + 'access arguments' => array('administer search'), |
|
25 | + 'file' => 'boinc_solr_comments.admin.inc', |
|
26 | + 'weight' => '10', |
|
27 | + ); |
|
28 | + |
|
29 | + return $items; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | * Environment ID for apache solr. |
59 | 59 | */ |
60 | 60 | function boinc_solr_comments_apachesolr_index_documents_alter(array &$documents, $entity, $entity_type, $env_id) { |
61 | - $comdocs = array(); |
|
61 | + $comdocs = array(); |
|
62 | 62 | |
63 | - // Array of node types that will have comments indexed. |
|
64 | - $node_types = variable_get('boinc_solr_comments_nodetypes', ''); |
|
65 | - if (empty($node_types)) { |
|
63 | + // Array of node types that will have comments indexed. |
|
64 | + $node_types = variable_get('boinc_solr_comments_nodetypes', ''); |
|
65 | + if (empty($node_types)) { |
|
66 | 66 | // If the variable has not been set, then by default index |
67 | 67 | // comments for all known node types. |
68 | 68 | $node_types = array( |
@@ -72,28 +72,28 @@ discard block |
||
72 | 72 | 'story' => 'story', |
73 | 73 | 'team_forum' => 'team_forum', |
74 | 74 | ); |
75 | - } |
|
75 | + } |
|
76 | 76 | |
77 | - // Loop over all documents and alter: |
|
78 | - foreach ($documents as $document) { |
|
77 | + // Loop over all documents and alter: |
|
78 | + foreach ($documents as $document) { |
|
79 | 79 | //dd($document, "index documents alter - document"); |
80 | 80 | |
81 | 81 | $to_process = ( array_key_exists($document->bundle, $node_types) AND $node_types[$document->bundle] ); |
82 | 82 | if ( $document->entity_type=='node' AND $to_process) { |
83 | 83 | |
84 | - // Remove ts_comments if present. |
|
85 | - if (isset($document->ts_comments)) { |
|
84 | + // Remove ts_comments if present. |
|
85 | + if (isset($document->ts_comments)) { |
|
86 | 86 | unset($document->ts_comments); |
87 | - } |
|
88 | - // Node information. |
|
89 | - $nid = $document->entity_id; |
|
90 | - $node = node_load($nid); |
|
87 | + } |
|
88 | + // Node information. |
|
89 | + $nid = $document->entity_id; |
|
90 | + $node = node_load($nid); |
|
91 | 91 | |
92 | - // Query database for comments of node. Only return comments |
|
93 | - // with status 0 (0 is published for comments). |
|
94 | - $sql = 'SELECT cid from {comments} WHERE nid = %d AND status = 0 ORDER by timestamp DESC'; |
|
95 | - $resource = db_query($sql, $nid); |
|
96 | - while ($row = db_fetch_array($resource)) { |
|
92 | + // Query database for comments of node. Only return comments |
|
93 | + // with status 0 (0 is published for comments). |
|
94 | + $sql = 'SELECT cid from {comments} WHERE nid = %d AND status = 0 ORDER by timestamp DESC'; |
|
95 | + $resource = db_query($sql, $nid); |
|
96 | + while ($row = db_fetch_array($resource)) { |
|
97 | 97 | // Load the comment from cid. |
98 | 98 | $comment = _comment_load($row['cid']); |
99 | 99 | |
@@ -116,10 +116,10 @@ discard block |
||
116 | 116 | // Comment object has no language |
117 | 117 | $comment_document->ss_language = 'und'; |
118 | 118 | if (function_exists('drupal_get_path_alias')) { |
119 | - $output = drupal_get_path_alias($comment_document->path, NULL); |
|
120 | - if ($output && $output != $document->path) { |
|
119 | + $output = drupal_get_path_alias($comment_document->path, NULL); |
|
120 | + if ($output && $output != $document->path) { |
|
121 | 121 | $comment_document->path_alias = $output; |
122 | - } |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | // Code derived from apachesolr_index_node_solr_document |
@@ -129,13 +129,13 @@ discard block |
||
129 | 129 | |
130 | 130 | // Author information |
131 | 131 | if ($comment->uid == 0 || strlen($comment->name) == 0) { |
132 | - // @see user_validate_name(). !'0' === TRUE. |
|
133 | - $comment_document->ss_name = '0'; |
|
132 | + // @see user_validate_name(). !'0' === TRUE. |
|
133 | + $comment_document->ss_name = '0'; |
|
134 | 134 | } |
135 | 135 | else { |
136 | - $comment_document->ss_name = $comment->name; |
|
137 | - // We want the name to be searchable for keywords. |
|
138 | - $comment_document->tos_name = $comment->name; |
|
136 | + $comment_document->ss_name = $comment->name; |
|
137 | + // We want the name to be searchable for keywords. |
|
138 | + $comment_document->tos_name = $comment->name; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // Index formatted username so it can be searched and sorted |
@@ -157,59 +157,59 @@ discard block |
||
157 | 157 | // Unset the following fields (if set) that don't make sense |
158 | 158 | // for a comment. |
159 | 159 | if (isset($comment_document->bs_sticky)) { |
160 | - unset($comment_document->bs_sticky); |
|
160 | + unset($comment_document->bs_sticky); |
|
161 | 161 | } |
162 | 162 | if (isset($comment_document->bs_promote)) { |
163 | - unset($comment_document->bs_promote); |
|
163 | + unset($comment_document->bs_promote); |
|
164 | 164 | } |
165 | 165 | if (isset($comment_document->is_tnid)) { |
166 | - unset($comment_document->is_tnid); |
|
166 | + unset($comment_document->is_tnid); |
|
167 | 167 | } |
168 | 168 | if (isset($comment_document->bs_translate)) { |
169 | - unset($comment_document->bs_translate); |
|
169 | + unset($comment_document->bs_translate); |
|
170 | 170 | } |
171 | 171 | if (isset($comment_document->ts_last_comment_timestamp)) { |
172 | - unset($comment_document->ts_last_comment_timestamp); |
|
172 | + unset($comment_document->ts_last_comment_timestamp); |
|
173 | 173 | } |
174 | 174 | if (isset($comment_document->ds_last_comment_or_change)) { |
175 | - unset($comment_document->ds_last_comment_or_change); |
|
175 | + unset($comment_document->ds_last_comment_or_change); |
|
176 | 176 | } |
177 | 177 | if (isset($comment_document->is_comment_count)) { |
178 | - unset($comment_document->is_comment_count); |
|
178 | + unset($comment_document->is_comment_count); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | // Loop over fields in document and copy relevant values into |
182 | 182 | // comment_document. |
183 | 183 | foreach ($document as $fieldName => $fieldValue) { |
184 | 184 | |
185 | - // Copy over fields [im_taxonomy_vid_1], [tid], [im_vid_1], |
|
186 | - // [im_vid_Forums], [tm_vid_1_names] |
|
187 | - if ( ( preg_match('/tid/', $fieldName) OR preg_match('/vid/', $fieldName) ) AND is_array($fieldValue) ) { |
|
185 | + // Copy over fields [im_taxonomy_vid_1], [tid], [im_vid_1], |
|
186 | + // [im_vid_Forums], [tm_vid_1_names] |
|
187 | + if ( ( preg_match('/tid/', $fieldName) OR preg_match('/vid/', $fieldName) ) AND is_array($fieldValue) ) { |
|
188 | 188 | foreach ($fieldValue as $subkey => $subvalue) { |
189 | - $comment_document->addField($fieldName, $subvalue); |
|
189 | + $comment_document->addField($fieldName, $subvalue); |
|
190 | 190 | } |
191 | - }// if preg_match |
|
191 | + }// if preg_match |
|
192 | 192 | |
193 | - // Set the access keys so this module will work with |
|
194 | - // apachesolr_access. |
|
195 | - if (module_exists('apachesolr_access')) { |
|
193 | + // Set the access keys so this module will work with |
|
194 | + // apachesolr_access. |
|
195 | + if (module_exists('apachesolr_access')) { |
|
196 | 196 | if (preg_match('/^access/', $fieldName) AND is_array($fieldValue)) { |
197 | - foreach ($fieldValue as $subkey => $subvalue) { |
|
197 | + foreach ($fieldValue as $subkey => $subvalue) { |
|
198 | 198 | $comment_document->addField($fieldName, $subvalue); |
199 | - } |
|
199 | + } |
|
200 | 200 | }// if preg_match |
201 | - }// if module_exist |
|
201 | + }// if module_exist |
|
202 | 202 | |
203 | 203 | }// foreach document |
204 | 204 | |
205 | 205 | $comdocs[] = $comment_document; |
206 | - }// while |
|
206 | + }// while |
|
207 | 207 | }// if entity_type=node |
208 | - }// documents |
|
208 | + }// documents |
|
209 | 209 | |
210 | - // Merge the comment documents with the input documents array. These |
|
211 | - // documents will now be added to the Solr search index. |
|
212 | - $documents = array_merge($documents, $comdocs); |
|
210 | + // Merge the comment documents with the input documents array. These |
|
211 | + // documents will now be added to the Solr search index. |
|
212 | + $documents = array_merge($documents, $comdocs); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -225,19 +225,19 @@ discard block |
||
225 | 225 | * The Solr query used for the search. |
226 | 226 | */ |
227 | 227 | function boinc_solr_comments_apachesolr_process_results(&$results, DrupalSolrQueryInterface $query) { |
228 | - //dpm($query->getSolrParams(), "process_results query getSolrParams"); |
|
229 | - foreach($results as $id => $result) { |
|
228 | + //dpm($query->getSolrParams(), "process_results query getSolrParams"); |
|
229 | + foreach($results as $id => $result) { |
|
230 | 230 | if ($result['entity_type']=='comment') { |
231 | 231 | $results[$id]['type'] = 'Comment'; |
232 | 232 | $results[$id]['date'] = $result['fields']['changed']; |
233 | 233 | if (isset($result['fields']['is_uid'])) { |
234 | - $uid = $result['fields']['is_uid']; |
|
235 | - $results[$id]['uid'] = $uid; |
|
236 | - $results[$id]['user'] = theme('username', user_load($uid)); |
|
234 | + $uid = $result['fields']['is_uid']; |
|
235 | + $results[$id]['uid'] = $uid; |
|
236 | + $results[$id]['user'] = theme('username', user_load($uid)); |
|
237 | 237 | } |
238 | 238 | } //if result entity_type == comment |
239 | - }// foreach $result |
|
240 | - //dpm($results, "process_results array_results"); |
|
239 | + }// foreach $result |
|
240 | + //dpm($results, "process_results array_results"); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -251,8 +251,8 @@ discard block |
||
251 | 251 | * The Solr query used for the search. |
252 | 252 | */ |
253 | 253 | function boinc_solr_comments_apachesolr_query_alter($query) { |
254 | - // Add custom field to query results |
|
255 | - $query->addParam('fl','tos_content_extra'); |
|
254 | + // Add custom field to query results |
|
255 | + $query->addParam('fl','tos_content_extra'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | * |
266 | 266 | */ |
267 | 267 | function boinc_solr_comments_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { |
268 | - // Array of node types that will have comments indexed. |
|
269 | - $node_types = variable_get('boinc_solr_comments_nodetypes', ''); |
|
270 | - if (empty($node_types)) { |
|
268 | + // Array of node types that will have comments indexed. |
|
269 | + $node_types = variable_get('boinc_solr_comments_nodetypes', ''); |
|
270 | + if (empty($node_types)) { |
|
271 | 271 | // If the variable has not been set, then by default index |
272 | 272 | // comments for all known node types. |
273 | 273 | $node_types = array( |
@@ -277,16 +277,16 @@ discard block |
||
277 | 277 | 'story' => 'story', |
278 | 278 | 'team_forum' => 'team_forum', |
279 | 279 | ); |
280 | - } |
|
280 | + } |
|
281 | 281 | |
282 | - switch ($op) { |
|
282 | + switch ($op) { |
|
283 | 283 | case 'delete': |
284 | 284 | // Only call delete function on certain node types |
285 | 285 | if (in_array( $node->type, $node_types)) { |
286 | 286 | boinc_solr_comments_delete($node); |
287 | - } |
|
288 | - break; |
|
289 | - } //switch |
|
287 | + } |
|
288 | + break; |
|
289 | + } //switch |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -303,30 +303,30 @@ discard block |
||
303 | 303 | * Returns TRUE if the comment was deleted, otherwise return FALSE. |
304 | 304 | */ |
305 | 305 | function boinc_solr_comments_delete($node) { |
306 | - // Load the Solr environment. |
|
307 | - $env_id = apachesolr_default_environment(); |
|
308 | - // Check to see if Solr is read-only. |
|
309 | - if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { |
|
306 | + // Load the Solr environment. |
|
307 | + $env_id = apachesolr_default_environment(); |
|
308 | + // Check to see if Solr is read-only. |
|
309 | + if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { |
|
310 | 310 | return FALSE; |
311 | - } |
|
311 | + } |
|
312 | 312 | |
313 | - // Code derived from apachesolr_index_delete_entity_from_index |
|
314 | - try { |
|
313 | + // Code derived from apachesolr_index_delete_entity_from_index |
|
314 | + try { |
|
315 | 315 | $solr = apachesolr_get_solr($env_id); |
316 | 316 | // Custom query to find all comments with parent nid of the node bing deleted. |
317 | 317 | $query = "entity_type:comment AND tos_content_extra:" . $node->nid; |
318 | 318 | $solr->deleteByQuery($query); |
319 | 319 | // Log the query used for deletion. |
320 | 320 | watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); |
321 | - } |
|
322 | - catch (Exception $e) { |
|
323 | - watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
|
324 | - return FALSE; |
|
325 | - }// try |
|
326 | - |
|
327 | - // all deletions sucessful |
|
328 | - apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); |
|
329 | - return TRUE; |
|
321 | + } |
|
322 | + catch (Exception $e) { |
|
323 | + watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
|
324 | + return FALSE; |
|
325 | + }// try |
|
326 | + |
|
327 | + // all deletions sucessful |
|
328 | + apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); |
|
329 | + return TRUE; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -334,15 +334,15 @@ discard block |
||
334 | 334 | * |
335 | 335 | */ |
336 | 336 | function boinc_solr_comments_comment(&$a1, $op) { |
337 | - switch ($op) { |
|
337 | + switch ($op) { |
|
338 | 338 | case 'view': |
339 | 339 | case 'update': |
340 | 340 | break; |
341 | 341 | case 'delete': |
342 | 342 | // $a1 should be a comment object |
343 | 343 | boinc_solr_comments_deletecomment($a1); |
344 | - break; |
|
345 | - }// switch |
|
344 | + break; |
|
345 | + }// switch |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -358,16 +358,16 @@ discard block |
||
358 | 358 | * Returns TRUE if the comment was deleted, otherwise return FALSE. |
359 | 359 | */ |
360 | 360 | function boinc_solr_comments_deletecomment($comment) { |
361 | - // Load the Solr environment. |
|
362 | - $env_id = apachesolr_default_environment(); |
|
363 | - // Check to see if Solr is read-only. |
|
364 | - if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { |
|
361 | + // Load the Solr environment. |
|
362 | + $env_id = apachesolr_default_environment(); |
|
363 | + // Check to see if Solr is read-only. |
|
364 | + if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { |
|
365 | 365 | return FALSE; |
366 | - } |
|
367 | - //dd($comment->cid, "delete - nid begin"); |
|
366 | + } |
|
367 | + //dd($comment->cid, "delete - nid begin"); |
|
368 | 368 | |
369 | - // Code derived from apachesolr_index_delete_entity_from_index. |
|
370 | - try { |
|
369 | + // Code derived from apachesolr_index_delete_entity_from_index. |
|
370 | + try { |
|
371 | 371 | $solr = apachesolr_get_solr($env_id); |
372 | 372 | $entity_id = $comment->cid; |
373 | 373 | $entity_type = 'comment'; |
@@ -377,14 +377,14 @@ discard block |
||
377 | 377 | // Log the query used for deletion. |
378 | 378 | watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); |
379 | 379 | } |
380 | - catch (Exception $e) { |
|
380 | + catch (Exception $e) { |
|
381 | 381 | watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
382 | 382 | return FALSE; |
383 | - }// try |
|
383 | + }// try |
|
384 | 384 | |
385 | - // deletion sucessful |
|
386 | - apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); |
|
387 | - return TRUE; |
|
385 | + // deletion sucessful |
|
386 | + apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); |
|
387 | + return TRUE; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | */ |
400 | 400 | |
401 | 401 | function boinc_solr_comments_enable() { |
402 | - drupal_set_message( bts('Warning: Your content <a href="@url">must be re-indexed</a> before Apache Solr will search comments.', array('@url' => url('admin/settings/apachesolr/index')), NULL, 'boinc:admin-solr-index-comments-message'), 'warning'); |
|
402 | + drupal_set_message( bts('Warning: Your content <a href="@url">must be re-indexed</a> before Apache Solr will search comments.', array('@url' => url('admin/settings/apachesolr/index')), NULL, 'boinc:admin-solr-index-comments-message'), 'warning'); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -410,12 +410,12 @@ discard block |
||
410 | 410 | * The comment to be published (unhidden). |
411 | 411 | */ |
412 | 412 | function boinc_solr_comments_publish($comment) { |
413 | - if ( ($comment->cid) AND ($comment->nid) ) { |
|
413 | + if ( ($comment->cid) AND ($comment->nid) ) { |
|
414 | 414 | $node = node_load($comment->nid); |
415 | 415 | // Tell Solr that the node has been updated, so the comment can be |
416 | 416 | // indexed. |
417 | 417 | apachesolr_entity_update($node, 'node'); |
418 | - } |
|
418 | + } |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -426,9 +426,9 @@ discard block |
||
426 | 426 | * The comment to be unpublished (hidden). |
427 | 427 | */ |
428 | 428 | function boinc_solr_comments_unpublish($comment) { |
429 | - if ( ($comment->cid) ) { |
|
429 | + if ( ($comment->cid) ) { |
|
430 | 430 | // Call the deletecomment function for hook comment. |
431 | 431 | boinc_solr_comments_deletecomment($comment); |
432 | - } |
|
432 | + } |
|
433 | 433 | } |
434 | 434 |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | foreach ($documents as $document) { |
79 | 79 | //dd($document, "index documents alter - document"); |
80 | 80 | |
81 | - $to_process = ( array_key_exists($document->bundle, $node_types) AND $node_types[$document->bundle] ); |
|
82 | - if ( $document->entity_type=='node' AND $to_process) { |
|
81 | + $to_process = (array_key_exists($document->bundle, $node_types) AND $node_types[$document->bundle]); |
|
82 | + if ($document->entity_type == 'node' AND $to_process) { |
|
83 | 83 | |
84 | 84 | // Remove ts_comments if present. |
85 | 85 | if (isset($document->ts_comments)) { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $comment_document->bundle = 'Comment'; |
111 | 111 | $comment_document->bundle_name = 'Comment'; |
112 | 112 | |
113 | - $comment_document->path = 'goto/comment/' . $comment->cid; |
|
113 | + $comment_document->path = 'goto/comment/'.$comment->cid; |
|
114 | 114 | $comment_document->url = url($comment_document->path, $url_options); |
115 | 115 | |
116 | 116 | // Comment object has no language |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | // Index formatted username so it can be searched and sorted |
142 | 142 | // on. |
143 | - $account = (object) array('uid' => $comment->uid, 'name' => $comment->name); |
|
143 | + $account = (object)array('uid' => $comment->uid, 'name' => $comment->name); |
|
144 | 144 | $username = check_plain($account->name); |
145 | 145 | $comment_document->ss_name_formatted = $username; |
146 | 146 | $comment_document->tos_name_formatted = $username; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | // Copy over fields [im_taxonomy_vid_1], [tid], [im_vid_1], |
186 | 186 | // [im_vid_Forums], [tm_vid_1_names] |
187 | - if ( ( preg_match('/tid/', $fieldName) OR preg_match('/vid/', $fieldName) ) AND is_array($fieldValue) ) { |
|
187 | + if ((preg_match('/tid/', $fieldName) OR preg_match('/vid/', $fieldName)) AND is_array($fieldValue)) { |
|
188 | 188 | foreach ($fieldValue as $subkey => $subvalue) { |
189 | 189 | $comment_document->addField($fieldName, $subvalue); |
190 | 190 | } |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | */ |
227 | 227 | function boinc_solr_comments_apachesolr_process_results(&$results, DrupalSolrQueryInterface $query) { |
228 | 228 | //dpm($query->getSolrParams(), "process_results query getSolrParams"); |
229 | - foreach($results as $id => $result) { |
|
230 | - if ($result['entity_type']=='comment') { |
|
229 | + foreach ($results as $id => $result) { |
|
230 | + if ($result['entity_type'] == 'comment') { |
|
231 | 231 | $results[$id]['type'] = 'Comment'; |
232 | 232 | $results[$id]['date'] = $result['fields']['changed']; |
233 | 233 | if (isset($result['fields']['is_uid'])) { |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | */ |
253 | 253 | function boinc_solr_comments_apachesolr_query_alter($query) { |
254 | 254 | // Add custom field to query results |
255 | - $query->addParam('fl','tos_content_extra'); |
|
255 | + $query->addParam('fl', 'tos_content_extra'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | switch ($op) { |
283 | 283 | case 'delete': |
284 | 284 | // Only call delete function on certain node types |
285 | - if (in_array( $node->type, $node_types)) { |
|
285 | + if (in_array($node->type, $node_types)) { |
|
286 | 286 | boinc_solr_comments_delete($node); |
287 | 287 | } |
288 | 288 | break; |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | try { |
315 | 315 | $solr = apachesolr_get_solr($env_id); |
316 | 316 | // Custom query to find all comments with parent nid of the node bing deleted. |
317 | - $query = "entity_type:comment AND tos_content_extra:" . $node->nid; |
|
317 | + $query = "entity_type:comment AND tos_content_extra:".$node->nid; |
|
318 | 318 | $solr->deleteByQuery($query); |
319 | 319 | // Log the query used for deletion. |
320 | 320 | watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | */ |
400 | 400 | |
401 | 401 | function boinc_solr_comments_enable() { |
402 | - drupal_set_message( bts('Warning: Your content <a href="@url">must be re-indexed</a> before Apache Solr will search comments.', array('@url' => url('admin/settings/apachesolr/index')), NULL, 'boinc:admin-solr-index-comments-message'), 'warning'); |
|
402 | + drupal_set_message(bts('Warning: Your content <a href="@url">must be re-indexed</a> before Apache Solr will search comments.', array('@url' => url('admin/settings/apachesolr/index')), NULL, 'boinc:admin-solr-index-comments-message'), 'warning'); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * The comment to be published (unhidden). |
411 | 411 | */ |
412 | 412 | function boinc_solr_comments_publish($comment) { |
413 | - if ( ($comment->cid) AND ($comment->nid) ) { |
|
413 | + if (($comment->cid) AND ($comment->nid)) { |
|
414 | 414 | $node = node_load($comment->nid); |
415 | 415 | // Tell Solr that the node has been updated, so the comment can be |
416 | 416 | // indexed. |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * The comment to be unpublished (hidden). |
427 | 427 | */ |
428 | 428 | function boinc_solr_comments_unpublish($comment) { |
429 | - if ( ($comment->cid) ) { |
|
429 | + if (($comment->cid)) { |
|
430 | 430 | // Call the deletecomment function for hook comment. |
431 | 431 | boinc_solr_comments_deletecomment($comment); |
432 | 432 | } |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | foreach ($documents as $document) { |
79 | 79 | //dd($document, "index documents alter - document"); |
80 | 80 | |
81 | - $to_process = ( array_key_exists($document->bundle, $node_types) AND $node_types[$document->bundle] ); |
|
82 | - if ( $document->entity_type=='node' AND $to_process) { |
|
81 | + $to_process = ( array_key_exists($document->bundle, $node_types) and $node_types[$document->bundle] ); |
|
82 | + if ( $document->entity_type=='node' and $to_process) { |
|
83 | 83 | |
84 | 84 | // Remove ts_comments if present. |
85 | 85 | if (isset($document->ts_comments)) { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $comment = _comment_load($row['cid']); |
99 | 99 | |
100 | 100 | // Code derived from _apachesolr_index_process_entity_get_document |
101 | - $url_options = array('absolute' => TRUE); |
|
101 | + $url_options = array('absolute' => true); |
|
102 | 102 | $comment_document = new ApacheSolrdocument(); |
103 | 103 | |
104 | 104 | $comment_document->id = apachesolr_document_id($comment->cid, 'comment'); |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | // Comment object has no language |
117 | 117 | $comment_document->ss_language = 'und'; |
118 | 118 | if (function_exists('drupal_get_path_alias')) { |
119 | - $output = drupal_get_path_alias($comment_document->path, NULL); |
|
119 | + $output = drupal_get_path_alias($comment_document->path, null); |
|
120 | 120 | if ($output && $output != $document->path) { |
121 | 121 | $comment_document->path_alias = $output; |
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
125 | 125 | // Code derived from apachesolr_index_node_solr_document |
126 | - $comment_document->label = truncate_utf8(apachesolr_clean_text($comment->comment), 32, TRUE); |
|
126 | + $comment_document->label = truncate_utf8(apachesolr_clean_text($comment->comment), 32, true); |
|
127 | 127 | $comment_document->content = apachesolr_clean_text($comment->comment); |
128 | - $comment_document->teaser = truncate_utf8($document->content, 300, TRUE); |
|
128 | + $comment_document->teaser = truncate_utf8($document->content, 300, true); |
|
129 | 129 | |
130 | 130 | // Author information |
131 | 131 | if ($comment->uid == 0 || strlen($comment->name) == 0) { |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | // Copy over fields [im_taxonomy_vid_1], [tid], [im_vid_1], |
186 | 186 | // [im_vid_Forums], [tm_vid_1_names] |
187 | - if ( ( preg_match('/tid/', $fieldName) OR preg_match('/vid/', $fieldName) ) AND is_array($fieldValue) ) { |
|
187 | + if ( ( preg_match('/tid/', $fieldName) or preg_match('/vid/', $fieldName) ) and is_array($fieldValue) ) { |
|
188 | 188 | foreach ($fieldValue as $subkey => $subvalue) { |
189 | 189 | $comment_document->addField($fieldName, $subvalue); |
190 | 190 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | // Set the access keys so this module will work with |
194 | 194 | // apachesolr_access. |
195 | 195 | if (module_exists('apachesolr_access')) { |
196 | - if (preg_match('/^access/', $fieldName) AND is_array($fieldValue)) { |
|
196 | + if (preg_match('/^access/', $fieldName) and is_array($fieldValue)) { |
|
197 | 197 | foreach ($fieldValue as $subkey => $subvalue) { |
198 | 198 | $comment_document->addField($fieldName, $subvalue); |
199 | 199 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * Implementation of hook_nodeapi() |
265 | 265 | * |
266 | 266 | */ |
267 | -function boinc_solr_comments_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { |
|
267 | +function boinc_solr_comments_nodeapi(&$node, $op, $a3 = null, $a4 = null) { |
|
268 | 268 | // Array of node types that will have comments indexed. |
269 | 269 | $node_types = variable_get('boinc_solr_comments_nodetypes', ''); |
270 | 270 | if (empty($node_types)) { |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $env_id = apachesolr_default_environment(); |
308 | 308 | // Check to see if Solr is read-only. |
309 | 309 | if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { |
310 | - return FALSE; |
|
310 | + return false; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | // Code derived from apachesolr_index_delete_entity_from_index |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); |
321 | 321 | } |
322 | 322 | catch (Exception $e) { |
323 | - watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
|
324 | - return FALSE; |
|
323 | + watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), null, WATCHDOG_ERROR); |
|
324 | + return false; |
|
325 | 325 | }// try |
326 | 326 | |
327 | 327 | // all deletions sucessful |
328 | 328 | apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); |
329 | - return TRUE; |
|
329 | + return true; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $env_id = apachesolr_default_environment(); |
363 | 363 | // Check to see if Solr is read-only. |
364 | 364 | if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) { |
365 | - return FALSE; |
|
365 | + return false; |
|
366 | 366 | } |
367 | 367 | //dd($comment->cid, "delete - nid begin"); |
368 | 368 | |
@@ -378,13 +378,13 @@ discard block |
||
378 | 378 | watchdog('Apache Solr', 'Deleted documents from index with query @query', array('@query' => $query), WATCHDOG_INFO); |
379 | 379 | } |
380 | 380 | catch (Exception $e) { |
381 | - watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR); |
|
382 | - return FALSE; |
|
381 | + watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), null, WATCHDOG_ERROR); |
|
382 | + return false; |
|
383 | 383 | }// try |
384 | 384 | |
385 | 385 | // deletion sucessful |
386 | 386 | apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME); |
387 | - return TRUE; |
|
387 | + return true; |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | */ |
400 | 400 | |
401 | 401 | function boinc_solr_comments_enable() { |
402 | - drupal_set_message( bts('Warning: Your content <a href="@url">must be re-indexed</a> before Apache Solr will search comments.', array('@url' => url('admin/settings/apachesolr/index')), NULL, 'boinc:admin-solr-index-comments-message'), 'warning'); |
|
402 | + drupal_set_message( bts('Warning: Your content <a href="@url">must be re-indexed</a> before Apache Solr will search comments.', array('@url' => url('admin/settings/apachesolr/index')), null, 'boinc:admin-solr-index-comments-message'), 'warning'); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * The comment to be published (unhidden). |
411 | 411 | */ |
412 | 412 | function boinc_solr_comments_publish($comment) { |
413 | - if ( ($comment->cid) AND ($comment->nid) ) { |
|
413 | + if ( ($comment->cid) and ($comment->nid) ) { |
|
414 | 414 | $node = node_load($comment->nid); |
415 | 415 | // Tell Solr that the node has been updated, so the comment can be |
416 | 416 | // indexed. |
@@ -19,10 +19,10 @@ |
||
19 | 19 | foreach (content_types() as $key => $info) { |
20 | 20 | // Exclude node types profile, team, and panel |
21 | 21 | switch ($key) { |
22 | - case 'profile': |
|
23 | - case 'team': |
|
24 | - case 'panel': |
|
25 | - continue 2; |
|
22 | + case 'profile': |
|
23 | + case 'team': |
|
24 | + case 'panel': |
|
25 | + continue 2; |
|
26 | 26 | }// switch key |
27 | 27 | $options[$key] = $info['name']; |
28 | 28 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | 'boinc_solr_comments_nodetypes' => variable_get('boinc_solr_comments_nodetypes', ''), |
34 | 34 | ); |
35 | 35 | if (empty($default['boinc_solr_comments_nodetypes'])) { |
36 | - $default['boinc_solr_comments_nodetypes'] = array('forum','team_forum','news','page','story'); |
|
36 | + $default['boinc_solr_comments_nodetypes'] = array('forum', 'team_forum', 'news', 'page', 'story'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // Define the form |
@@ -7,48 +7,48 @@ |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | function boinc_solr_comments_form(&$form_state) { |
10 | - $form = array(); |
|
10 | + $form = array(); |
|
11 | 11 | |
12 | - $form['config'] = array( |
|
12 | + $form['config'] = array( |
|
13 | 13 | '#type' => 'fieldset', |
14 | 14 | '#title' => t('Configuration'), |
15 | 15 | '#collapsible' => TRUE, |
16 | - ); |
|
16 | + ); |
|
17 | 17 | |
18 | - $options = array(); |
|
19 | - foreach (content_types() as $key => $info) { |
|
18 | + $options = array(); |
|
19 | + foreach (content_types() as $key => $info) { |
|
20 | 20 | // Exclude node types profile, team, and panel |
21 | 21 | switch ($key) { |
22 | - case 'profile': |
|
22 | + case 'profile': |
|
23 | 23 | case 'team': |
24 | 24 | case 'panel': |
25 | 25 | continue 2; |
26 | 26 | }// switch key |
27 | 27 | $options[$key] = $info['name']; |
28 | - } |
|
29 | - asort($options); |
|
28 | + } |
|
29 | + asort($options); |
|
30 | 30 | |
31 | - // Form defaults |
|
32 | - $default = array( |
|
31 | + // Form defaults |
|
32 | + $default = array( |
|
33 | 33 | 'boinc_solr_comments_nodetypes' => variable_get('boinc_solr_comments_nodetypes', ''), |
34 | - ); |
|
35 | - if (empty($default['boinc_solr_comments_nodetypes'])) { |
|
34 | + ); |
|
35 | + if (empty($default['boinc_solr_comments_nodetypes'])) { |
|
36 | 36 | $default['boinc_solr_comments_nodetypes'] = array('forum','team_forum','news','page','story'); |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | - // Define the form |
|
40 | - $form['config']['nodes'] = array( |
|
39 | + // Define the form |
|
40 | + $form['config']['nodes'] = array( |
|
41 | 41 | '#type' => 'markup', |
42 | 42 | '#value' => bts('Select the content types where the comments are indexed by Apace Solr. Your content must be re-indexed after changing this configuration.', array(), NULL, 'boinc:admin-solr-search-comments-option'), |
43 | - ); |
|
43 | + ); |
|
44 | 44 | |
45 | - $form['config']['boinc_solr_comments_nodetypes'] = array( |
|
45 | + $form['config']['boinc_solr_comments_nodetypes'] = array( |
|
46 | 46 | '#type' => 'checkboxes', |
47 | 47 | '#title' => 'node', |
48 | 48 | '#options' => $options, |
49 | 49 | '#default_value' => $default['boinc_solr_comments_nodetypes'], |
50 | - ); |
|
50 | + ); |
|
51 | 51 | |
52 | - return system_settings_form($form); |
|
52 | + return system_settings_form($form); |
|
53 | 53 | } |
54 | 54 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | $form['config'] = array( |
13 | 13 | '#type' => 'fieldset', |
14 | 14 | '#title' => t('Configuration'), |
15 | - '#collapsible' => TRUE, |
|
15 | + '#collapsible' => true, |
|
16 | 16 | ); |
17 | 17 | |
18 | 18 | $options = array(); |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | // Define the form |
40 | 40 | $form['config']['nodes'] = array( |
41 | 41 | '#type' => 'markup', |
42 | - '#value' => bts('Select the content types where the comments are indexed by Apace Solr. Your content must be re-indexed after changing this configuration.', array(), NULL, 'boinc:admin-solr-search-comments-option'), |
|
42 | + '#value' => bts('Select the content types where the comments are indexed by Apace Solr. Your content must be re-indexed after changing this configuration.', array(), null, 'boinc:admin-solr-search-comments-option'), |
|
43 | 43 | ); |
44 | 44 | |
45 | 45 | $form['config']['boinc_solr_comments_nodetypes'] = array( |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /* |
|
2 | + /* |
|
3 | 3 | pBarcode39 - class to create barcodes (39B) |
4 | 4 | |
5 | 5 | Version : 2.1.3 |
@@ -13,188 +13,188 @@ discard block |
||
13 | 13 | You can find the whole class documentation on the pChart web site. |
14 | 14 | */ |
15 | 15 | |
16 | - /* pData class definition */ |
|
17 | - class pBarcode39 |
|
18 | - { |
|
19 | - var $Codes; |
|
20 | - var $Reverse; |
|
21 | - var $Result; |
|
22 | - var $pChartObject; |
|
23 | - var $CRC; |
|
24 | - var $MOD43; |
|
25 | - |
|
26 | - /* Class creator */ |
|
27 | - function pBarcode39($BasePath="",$EnableMOD43=FALSE) |
|
16 | + /* pData class definition */ |
|
17 | + class pBarcode39 |
|
28 | 18 | { |
29 | - $this->MOD43 = $EnableMOD43; |
|
30 | - $this->Codes = ""; |
|
31 | - $this->Reverse = ""; |
|
19 | + var $Codes; |
|
20 | + var $Reverse; |
|
21 | + var $Result; |
|
22 | + var $pChartObject; |
|
23 | + var $CRC; |
|
24 | + var $MOD43; |
|
25 | + |
|
26 | + /* Class creator */ |
|
27 | + function pBarcode39($BasePath="",$EnableMOD43=FALSE) |
|
28 | + { |
|
29 | + $this->MOD43 = $EnableMOD43; |
|
30 | + $this->Codes = ""; |
|
31 | + $this->Reverse = ""; |
|
32 | 32 | |
33 | - $FileHandle = @fopen($BasePath."data/39.db", "r"); |
|
33 | + $FileHandle = @fopen($BasePath."data/39.db", "r"); |
|
34 | 34 | |
35 | - if (!$FileHandle) { die("Cannot find barcode database (".$BasePath."data/39.db)."); } |
|
35 | + if (!$FileHandle) { die("Cannot find barcode database (".$BasePath."data/39.db)."); } |
|
36 | 36 | |
37 | - while (!feof($FileHandle)) |
|
38 | - { |
|
39 | - $Buffer = fgets($FileHandle,4096); |
|
40 | - $Buffer = str_replace(chr(10),"",$Buffer); |
|
41 | - $Buffer = str_replace(chr(13),"",$Buffer); |
|
42 | - $Values = preg_split("/;/",$Buffer); |
|
37 | + while (!feof($FileHandle)) |
|
38 | + { |
|
39 | + $Buffer = fgets($FileHandle,4096); |
|
40 | + $Buffer = str_replace(chr(10),"",$Buffer); |
|
41 | + $Buffer = str_replace(chr(13),"",$Buffer); |
|
42 | + $Values = preg_split("/;/",$Buffer); |
|
43 | 43 | |
44 | - $this->Codes[$Values[0]] = $Values[1]; |
|
45 | - } |
|
46 | - fclose($FileHandle); |
|
44 | + $this->Codes[$Values[0]] = $Values[1]; |
|
45 | + } |
|
46 | + fclose($FileHandle); |
|
47 | 47 | } |
48 | 48 | |
49 | - /* Return the projected size of a barcode */ |
|
50 | - function getSize($TextString,$Format="") |
|
49 | + /* Return the projected size of a barcode */ |
|
50 | + function getSize($TextString,$Format="") |
|
51 | 51 | { |
52 | - $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
53 | - $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
54 | - $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
55 | - $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
|
56 | - $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : 12; |
|
57 | - $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
52 | + $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
53 | + $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
54 | + $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
55 | + $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
|
56 | + $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : 12; |
|
57 | + $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
58 | 58 | |
59 | - $TextString = $this->encode39($TextString); |
|
60 | - $BarcodeLength = strlen($this->Result); |
|
59 | + $TextString = $this->encode39($TextString); |
|
60 | + $BarcodeLength = strlen($this->Result); |
|
61 | 61 | |
62 | - if ( $DrawArea ) { $WOffset = 20; } else { $WOffset = 0; } |
|
63 | - if ( $ShowLegend ) { $HOffset = $FontSize+$LegendOffset+$WOffset; } else { $HOffset = 0; } |
|
62 | + if ( $DrawArea ) { $WOffset = 20; } else { $WOffset = 0; } |
|
63 | + if ( $ShowLegend ) { $HOffset = $FontSize+$LegendOffset+$WOffset; } else { $HOffset = 0; } |
|
64 | 64 | |
65 | - $X1 = cos($Angle * PI / 180) * ($WOffset+$BarcodeLength); |
|
66 | - $Y1 = sin($Angle * PI / 180) * ($WOffset+$BarcodeLength); |
|
65 | + $X1 = cos($Angle * PI / 180) * ($WOffset+$BarcodeLength); |
|
66 | + $Y1 = sin($Angle * PI / 180) * ($WOffset+$BarcodeLength); |
|
67 | 67 | |
68 | - $X2 = $X1 + cos(($Angle+90) * PI / 180) * ($HOffset+$Height); |
|
69 | - $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * ($HOffset+$Height); |
|
68 | + $X2 = $X1 + cos(($Angle+90) * PI / 180) * ($HOffset+$Height); |
|
69 | + $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * ($HOffset+$Height); |
|
70 | 70 | |
71 | 71 | |
72 | - $AreaWidth = max(abs($X1),abs($X2)); |
|
73 | - $AreaHeight = max(abs($Y1),abs($Y2)); |
|
72 | + $AreaWidth = max(abs($X1),abs($X2)); |
|
73 | + $AreaHeight = max(abs($Y1),abs($Y2)); |
|
74 | 74 | |
75 | - return(array("Width"=>$AreaWidth,"Height"=>$AreaHeight)); |
|
75 | + return(array("Width"=>$AreaWidth,"Height"=>$AreaHeight)); |
|
76 | 76 | } |
77 | 77 | |
78 | - /* Create the encoded string */ |
|
79 | - function encode39($Value) |
|
78 | + /* Create the encoded string */ |
|
79 | + function encode39($Value) |
|
80 | 80 | { |
81 | - $this->Result = "100101101101"."0"; |
|
82 | - $TextString = ""; |
|
83 | - for($i=1;$i<=strlen($Value);$i++) |
|
84 | - { |
|
85 | - $CharCode = ord($this->mid($Value,$i,1)); |
|
86 | - if ( $CharCode >= 97 && $CharCode <= 122 ) { $CharCode = $CharCode - 32; } |
|
87 | - |
|
88 | - if ( isset($this->Codes[chr($CharCode)]) ) |
|
81 | + $this->Result = "100101101101"."0"; |
|
82 | + $TextString = ""; |
|
83 | + for($i=1;$i<=strlen($Value);$i++) |
|
84 | + { |
|
85 | + $CharCode = ord($this->mid($Value,$i,1)); |
|
86 | + if ( $CharCode >= 97 && $CharCode <= 122 ) { $CharCode = $CharCode - 32; } |
|
87 | + |
|
88 | + if ( isset($this->Codes[chr($CharCode)]) ) |
|
89 | 89 | { |
90 | - $this->Result = $this->Result.$this->Codes[chr($CharCode)]."0"; |
|
91 | - $TextString = $TextString.chr($CharCode); |
|
90 | + $this->Result = $this->Result.$this->Codes[chr($CharCode)]."0"; |
|
91 | + $TextString = $TextString.chr($CharCode); |
|
92 | + } |
|
92 | 93 | } |
93 | - } |
|
94 | 94 | |
95 | - if ( $this->MOD43 ) |
|
96 | - { |
|
97 | - $Checksum = $this->checksum($TextString); |
|
98 | - $this->Result = $this->Result.$this->Codes[$Checksum]."0"; |
|
99 | - } |
|
95 | + if ( $this->MOD43 ) |
|
96 | + { |
|
97 | + $Checksum = $this->checksum($TextString); |
|
98 | + $this->Result = $this->Result.$this->Codes[$Checksum]."0"; |
|
99 | + } |
|
100 | 100 | |
101 | - $this->Result = $this->Result."100101101101"; |
|
102 | - $TextString = "*".$TextString."*"; |
|
101 | + $this->Result = $this->Result."100101101101"; |
|
102 | + $TextString = "*".$TextString."*"; |
|
103 | 103 | |
104 | - return($TextString); |
|
104 | + return($TextString); |
|
105 | 105 | } |
106 | 106 | |
107 | - /* Create the encoded string */ |
|
108 | - function draw($Object,$Value,$X,$Y,$Format="") |
|
107 | + /* Create the encoded string */ |
|
108 | + function draw($Object,$Value,$X,$Y,$Format="") |
|
109 | 109 | { |
110 | - $this->pChartObject = $Object; |
|
111 | - |
|
112 | - $R = isset($Format["R"]) ? $Format["R"] : 0; |
|
113 | - $G = isset($Format["G"]) ? $Format["G"] : 0; |
|
114 | - $B = isset($Format["B"]) ? $Format["B"] : 0; |
|
115 | - $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; |
|
116 | - $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
117 | - $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
118 | - $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
119 | - $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
120 | - $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
|
121 | - $AreaR = isset($Format["AreaR"]) ? $Format["AreaR"] : 255; |
|
122 | - $AreaG = isset($Format["AreaG"]) ? $Format["AreaG"] : 255; |
|
123 | - $AreaB = isset($Format["AreaB"]) ? $Format["AreaB"] : 255; |
|
124 | - $AreaBorderR = isset($Format["AreaBorderR"]) ? $Format["AreaBorderR"] : $AreaR; |
|
125 | - $AreaBorderG = isset($Format["AreaBorderG"]) ? $Format["AreaBorderG"] : $AreaG; |
|
126 | - $AreaBorderB = isset($Format["AreaBorderB"]) ? $Format["AreaBorderB"] : $AreaB; |
|
127 | - |
|
128 | - $TextString = $this->encode39($Value); |
|
129 | - |
|
130 | - if ( $DrawArea ) |
|
131 | - { |
|
132 | - $X1 = $X + cos(($Angle-135) * PI / 180) * 10; |
|
133 | - $Y1 = $Y + sin(($Angle-135) * PI / 180) * 10; |
|
134 | - |
|
135 | - $X2 = $X1 + cos($Angle * PI / 180) * (strlen($this->Result)+20); |
|
136 | - $Y2 = $Y1 + sin($Angle * PI / 180) * (strlen($this->Result)+20); |
|
137 | - |
|
138 | - if ( $ShowLegend ) |
|
110 | + $this->pChartObject = $Object; |
|
111 | + |
|
112 | + $R = isset($Format["R"]) ? $Format["R"] : 0; |
|
113 | + $G = isset($Format["G"]) ? $Format["G"] : 0; |
|
114 | + $B = isset($Format["B"]) ? $Format["B"] : 0; |
|
115 | + $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; |
|
116 | + $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
117 | + $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
118 | + $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
119 | + $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
120 | + $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
|
121 | + $AreaR = isset($Format["AreaR"]) ? $Format["AreaR"] : 255; |
|
122 | + $AreaG = isset($Format["AreaG"]) ? $Format["AreaG"] : 255; |
|
123 | + $AreaB = isset($Format["AreaB"]) ? $Format["AreaB"] : 255; |
|
124 | + $AreaBorderR = isset($Format["AreaBorderR"]) ? $Format["AreaBorderR"] : $AreaR; |
|
125 | + $AreaBorderG = isset($Format["AreaBorderG"]) ? $Format["AreaBorderG"] : $AreaG; |
|
126 | + $AreaBorderB = isset($Format["AreaBorderB"]) ? $Format["AreaBorderB"] : $AreaB; |
|
127 | + |
|
128 | + $TextString = $this->encode39($Value); |
|
129 | + |
|
130 | + if ( $DrawArea ) |
|
139 | 131 | { |
140 | - $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
|
141 | - $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
|
132 | + $X1 = $X + cos(($Angle-135) * PI / 180) * 10; |
|
133 | + $Y1 = $Y + sin(($Angle-135) * PI / 180) * 10; |
|
134 | + |
|
135 | + $X2 = $X1 + cos($Angle * PI / 180) * (strlen($this->Result)+20); |
|
136 | + $Y2 = $Y1 + sin($Angle * PI / 180) * (strlen($this->Result)+20); |
|
137 | + |
|
138 | + if ( $ShowLegend ) |
|
139 | + { |
|
140 | + $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
|
141 | + $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
|
142 | 142 | } |
143 | - else |
|
143 | + else |
|
144 | 144 | { |
145 | - $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+20); |
|
146 | - $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+20); |
|
145 | + $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+20); |
|
146 | + $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+20); |
|
147 | 147 | } |
148 | 148 | |
149 | - $X4 = $X3 + cos(($Angle+180) * PI / 180) * (strlen($this->Result)+20); |
|
150 | - $Y4 = $Y3 + sin(($Angle+180) * PI / 180) * (strlen($this->Result)+20); |
|
149 | + $X4 = $X3 + cos(($Angle+180) * PI / 180) * (strlen($this->Result)+20); |
|
150 | + $Y4 = $Y3 + sin(($Angle+180) * PI / 180) * (strlen($this->Result)+20); |
|
151 | 151 | |
152 | - $Polygon = array($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4); |
|
153 | - $Settings = array("R"=>$AreaR,"G"=>$AreaG,"B"=>$AreaB,"BorderR"=>$AreaBorderR,"BorderG"=>$AreaBorderG,"BorderB"=>$AreaBorderB); |
|
154 | - $this->pChartObject->drawPolygon($Polygon,$Settings); |
|
155 | - } |
|
152 | + $Polygon = array($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4); |
|
153 | + $Settings = array("R"=>$AreaR,"G"=>$AreaG,"B"=>$AreaB,"BorderR"=>$AreaBorderR,"BorderG"=>$AreaBorderG,"BorderB"=>$AreaBorderB); |
|
154 | + $this->pChartObject->drawPolygon($Polygon,$Settings); |
|
155 | + } |
|
156 | 156 | |
157 | - for($i=1;$i<=strlen($this->Result);$i++) |
|
158 | - { |
|
159 | - if ( $this->mid($this->Result,$i,1) == 1 ) |
|
157 | + for($i=1;$i<=strlen($this->Result);$i++) |
|
158 | + { |
|
159 | + if ( $this->mid($this->Result,$i,1) == 1 ) |
|
160 | 160 | { |
161 | - $X1 = $X + cos($Angle * PI / 180) * $i; |
|
162 | - $Y1 = $Y + sin($Angle * PI / 180) * $i; |
|
163 | - $X2 = $X1 + cos(($Angle+90) * PI / 180) * $Height; |
|
164 | - $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * $Height; |
|
161 | + $X1 = $X + cos($Angle * PI / 180) * $i; |
|
162 | + $Y1 = $Y + sin($Angle * PI / 180) * $i; |
|
163 | + $X2 = $X1 + cos(($Angle+90) * PI / 180) * $Height; |
|
164 | + $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * $Height; |
|
165 | 165 | |
166 | - $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
167 | - $this->pChartObject->drawLine($X1,$Y1,$X2,$Y2,$Settings); |
|
166 | + $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
167 | + $this->pChartObject->drawLine($X1,$Y1,$X2,$Y2,$Settings); |
|
168 | + } |
|
168 | 169 | } |
169 | - } |
|
170 | 170 | |
171 | - if ( $ShowLegend ) |
|
172 | - { |
|
173 | - $X1 = $X + cos($Angle * PI / 180) * (strlen($this->Result)/2); |
|
174 | - $Y1 = $Y + sin($Angle * PI / 180) * (strlen($this->Result)/2); |
|
171 | + if ( $ShowLegend ) |
|
172 | + { |
|
173 | + $X1 = $X + cos($Angle * PI / 180) * (strlen($this->Result)/2); |
|
174 | + $Y1 = $Y + sin($Angle * PI / 180) * (strlen($this->Result)/2); |
|
175 | 175 | |
176 | - $LegendX = $X1 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset); |
|
177 | - $LegendY = $Y1 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset); |
|
176 | + $LegendX = $X1 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset); |
|
177 | + $LegendY = $Y1 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset); |
|
178 | 178 | |
179 | - $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Angle"=>-$Angle,"Align"=>TEXT_ALIGN_TOPMIDDLE); |
|
180 | - $this->pChartObject->drawText($LegendX,$LegendY,$TextString,$Settings); |
|
181 | - } |
|
179 | + $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Angle"=>-$Angle,"Align"=>TEXT_ALIGN_TOPMIDDLE); |
|
180 | + $this->pChartObject->drawText($LegendX,$LegendY,$TextString,$Settings); |
|
181 | + } |
|
182 | 182 | } |
183 | 183 | |
184 | - function checksum( $string ) |
|
184 | + function checksum( $string ) |
|
185 | 185 | { |
186 | - $checksum = 0; |
|
187 | - $length = strlen( $string ); |
|
188 | - $charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%'; |
|
186 | + $checksum = 0; |
|
187 | + $length = strlen( $string ); |
|
188 | + $charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%'; |
|
189 | 189 | |
190 | - for( $i=0; $i < $length; ++$i ) |
|
191 | - $checksum += strpos( $charset, $string[$i] ); |
|
190 | + for( $i=0; $i < $length; ++$i ) |
|
191 | + $checksum += strpos( $charset, $string[$i] ); |
|
192 | 192 | |
193 | - return substr( $charset, ($checksum % 43), 1 ); |
|
193 | + return substr( $charset, ($checksum % 43), 1 ); |
|
194 | 194 | } |
195 | 195 | |
196 | - function left($value,$NbChar) { return substr($value,0,$NbChar); } |
|
197 | - function right($value,$NbChar) { return substr($value,strlen($value)-$NbChar,$NbChar); } |
|
198 | - function mid($value,$Depart,$NbChar) { return substr($value,$Depart-1,$NbChar); } |
|
199 | - } |
|
196 | + function left($value,$NbChar) { return substr($value,0,$NbChar); } |
|
197 | + function right($value,$NbChar) { return substr($value,strlen($value)-$NbChar,$NbChar); } |
|
198 | + function mid($value,$Depart,$NbChar) { return substr($value,$Depart-1,$NbChar); } |
|
199 | + } |
|
200 | 200 | ?> |
201 | 201 | \ No newline at end of file |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | var $MOD43; |
25 | 25 | |
26 | 26 | /* Class creator */ |
27 | - function pBarcode39($BasePath="",$EnableMOD43=FALSE) |
|
27 | + function pBarcode39($BasePath = "", $EnableMOD43 = FALSE) |
|
28 | 28 | { |
29 | - $this->MOD43 = $EnableMOD43; |
|
29 | + $this->MOD43 = $EnableMOD43; |
|
30 | 30 | $this->Codes = ""; |
31 | 31 | $this->Reverse = ""; |
32 | 32 | |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | |
37 | 37 | while (!feof($FileHandle)) |
38 | 38 | { |
39 | - $Buffer = fgets($FileHandle,4096); |
|
40 | - $Buffer = str_replace(chr(10),"",$Buffer); |
|
41 | - $Buffer = str_replace(chr(13),"",$Buffer); |
|
42 | - $Values = preg_split("/;/",$Buffer); |
|
39 | + $Buffer = fgets($FileHandle, 4096); |
|
40 | + $Buffer = str_replace(chr(10), "", $Buffer); |
|
41 | + $Buffer = str_replace(chr(13), "", $Buffer); |
|
42 | + $Values = preg_split("/;/", $Buffer); |
|
43 | 43 | |
44 | 44 | $this->Codes[$Values[0]] = $Values[1]; |
45 | 45 | } |
@@ -47,32 +47,32 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | /* Return the projected size of a barcode */ |
50 | - function getSize($TextString,$Format="") |
|
50 | + function getSize($TextString, $Format = "") |
|
51 | 51 | { |
52 | - $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
53 | - $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
54 | - $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
52 | + $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
|
53 | + $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
54 | + $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
55 | 55 | $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
56 | 56 | $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : 12; |
57 | - $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
57 | + $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
58 | 58 | |
59 | 59 | $TextString = $this->encode39($TextString); |
60 | 60 | $BarcodeLength = strlen($this->Result); |
61 | 61 | |
62 | - if ( $DrawArea ) { $WOffset = 20; } else { $WOffset = 0; } |
|
63 | - if ( $ShowLegend ) { $HOffset = $FontSize+$LegendOffset+$WOffset; } else { $HOffset = 0; } |
|
62 | + if ($DrawArea) { $WOffset = 20; } else { $WOffset = 0; } |
|
63 | + if ($ShowLegend) { $HOffset = $FontSize + $LegendOffset + $WOffset; } else { $HOffset = 0; } |
|
64 | 64 | |
65 | - $X1 = cos($Angle * PI / 180) * ($WOffset+$BarcodeLength); |
|
66 | - $Y1 = sin($Angle * PI / 180) * ($WOffset+$BarcodeLength); |
|
65 | + $X1 = cos($Angle*PI/180)*($WOffset + $BarcodeLength); |
|
66 | + $Y1 = sin($Angle*PI/180)*($WOffset + $BarcodeLength); |
|
67 | 67 | |
68 | - $X2 = $X1 + cos(($Angle+90) * PI / 180) * ($HOffset+$Height); |
|
69 | - $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * ($HOffset+$Height); |
|
68 | + $X2 = $X1 + cos(($Angle + 90)*PI/180)*($HOffset + $Height); |
|
69 | + $Y2 = $Y1 + sin(($Angle + 90)*PI/180)*($HOffset + $Height); |
|
70 | 70 | |
71 | 71 | |
72 | - $AreaWidth = max(abs($X1),abs($X2)); |
|
73 | - $AreaHeight = max(abs($Y1),abs($Y2)); |
|
72 | + $AreaWidth = max(abs($X1), abs($X2)); |
|
73 | + $AreaHeight = max(abs($Y1), abs($Y2)); |
|
74 | 74 | |
75 | - return(array("Width"=>$AreaWidth,"Height"=>$AreaHeight)); |
|
75 | + return(array("Width"=>$AreaWidth, "Height"=>$AreaHeight)); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /* Create the encoded string */ |
@@ -80,19 +80,19 @@ discard block |
||
80 | 80 | { |
81 | 81 | $this->Result = "100101101101"."0"; |
82 | 82 | $TextString = ""; |
83 | - for($i=1;$i<=strlen($Value);$i++) |
|
83 | + for ($i = 1; $i <= strlen($Value); $i++) |
|
84 | 84 | { |
85 | - $CharCode = ord($this->mid($Value,$i,1)); |
|
86 | - if ( $CharCode >= 97 && $CharCode <= 122 ) { $CharCode = $CharCode - 32; } |
|
85 | + $CharCode = ord($this->mid($Value, $i, 1)); |
|
86 | + if ($CharCode >= 97 && $CharCode <= 122) { $CharCode = $CharCode - 32; } |
|
87 | 87 | |
88 | - if ( isset($this->Codes[chr($CharCode)]) ) |
|
88 | + if (isset($this->Codes[chr($CharCode)])) |
|
89 | 89 | { |
90 | 90 | $this->Result = $this->Result.$this->Codes[chr($CharCode)]."0"; |
91 | 91 | $TextString = $TextString.chr($CharCode); |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - if ( $this->MOD43 ) |
|
95 | + if ($this->MOD43) |
|
96 | 96 | { |
97 | 97 | $Checksum = $this->checksum($TextString); |
98 | 98 | $this->Result = $this->Result.$this->Codes[$Checksum]."0"; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | |
107 | 107 | /* Create the encoded string */ |
108 | - function draw($Object,$Value,$X,$Y,$Format="") |
|
108 | + function draw($Object, $Value, $X, $Y, $Format = "") |
|
109 | 109 | { |
110 | 110 | $this->pChartObject = $Object; |
111 | 111 | |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | $G = isset($Format["G"]) ? $Format["G"] : 0; |
114 | 114 | $B = isset($Format["B"]) ? $Format["B"] : 0; |
115 | 115 | $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; |
116 | - $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
116 | + $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
|
117 | 117 | $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
118 | - $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
119 | - $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
120 | - $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
|
118 | + $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
119 | + $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
|
120 | + $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
|
121 | 121 | $AreaR = isset($Format["AreaR"]) ? $Format["AreaR"] : 255; |
122 | 122 | $AreaG = isset($Format["AreaG"]) ? $Format["AreaG"] : 255; |
123 | 123 | $AreaB = isset($Format["AreaB"]) ? $Format["AreaB"] : 255; |
@@ -125,76 +125,76 @@ discard block |
||
125 | 125 | $AreaBorderG = isset($Format["AreaBorderG"]) ? $Format["AreaBorderG"] : $AreaG; |
126 | 126 | $AreaBorderB = isset($Format["AreaBorderB"]) ? $Format["AreaBorderB"] : $AreaB; |
127 | 127 | |
128 | - $TextString = $this->encode39($Value); |
|
128 | + $TextString = $this->encode39($Value); |
|
129 | 129 | |
130 | - if ( $DrawArea ) |
|
130 | + if ($DrawArea) |
|
131 | 131 | { |
132 | - $X1 = $X + cos(($Angle-135) * PI / 180) * 10; |
|
133 | - $Y1 = $Y + sin(($Angle-135) * PI / 180) * 10; |
|
132 | + $X1 = $X + cos(($Angle - 135)*PI/180)*10; |
|
133 | + $Y1 = $Y + sin(($Angle - 135)*PI/180)*10; |
|
134 | 134 | |
135 | - $X2 = $X1 + cos($Angle * PI / 180) * (strlen($this->Result)+20); |
|
136 | - $Y2 = $Y1 + sin($Angle * PI / 180) * (strlen($this->Result)+20); |
|
135 | + $X2 = $X1 + cos($Angle*PI/180)*(strlen($this->Result) + 20); |
|
136 | + $Y2 = $Y1 + sin($Angle*PI/180)*(strlen($this->Result) + 20); |
|
137 | 137 | |
138 | - if ( $ShowLegend ) |
|
138 | + if ($ShowLegend) |
|
139 | 139 | { |
140 | - $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
|
141 | - $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
|
140 | + $X3 = $X2 + cos(($Angle + 90)*PI/180)*($Height + $LegendOffset + $this->pChartObject->FontSize + 10); |
|
141 | + $Y3 = $Y2 + sin(($Angle + 90)*PI/180)*($Height + $LegendOffset + $this->pChartObject->FontSize + 10); |
|
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
145 | - $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+20); |
|
146 | - $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+20); |
|
145 | + $X3 = $X2 + cos(($Angle + 90)*PI/180)*($Height + 20); |
|
146 | + $Y3 = $Y2 + sin(($Angle + 90)*PI/180)*($Height + 20); |
|
147 | 147 | } |
148 | 148 | |
149 | - $X4 = $X3 + cos(($Angle+180) * PI / 180) * (strlen($this->Result)+20); |
|
150 | - $Y4 = $Y3 + sin(($Angle+180) * PI / 180) * (strlen($this->Result)+20); |
|
149 | + $X4 = $X3 + cos(($Angle + 180)*PI/180)*(strlen($this->Result) + 20); |
|
150 | + $Y4 = $Y3 + sin(($Angle + 180)*PI/180)*(strlen($this->Result) + 20); |
|
151 | 151 | |
152 | - $Polygon = array($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4); |
|
153 | - $Settings = array("R"=>$AreaR,"G"=>$AreaG,"B"=>$AreaB,"BorderR"=>$AreaBorderR,"BorderG"=>$AreaBorderG,"BorderB"=>$AreaBorderB); |
|
154 | - $this->pChartObject->drawPolygon($Polygon,$Settings); |
|
152 | + $Polygon = array($X1, $Y1, $X2, $Y2, $X3, $Y3, $X4, $Y4); |
|
153 | + $Settings = array("R"=>$AreaR, "G"=>$AreaG, "B"=>$AreaB, "BorderR"=>$AreaBorderR, "BorderG"=>$AreaBorderG, "BorderB"=>$AreaBorderB); |
|
154 | + $this->pChartObject->drawPolygon($Polygon, $Settings); |
|
155 | 155 | } |
156 | 156 | |
157 | - for($i=1;$i<=strlen($this->Result);$i++) |
|
157 | + for ($i = 1; $i <= strlen($this->Result); $i++) |
|
158 | 158 | { |
159 | - if ( $this->mid($this->Result,$i,1) == 1 ) |
|
159 | + if ($this->mid($this->Result, $i, 1) == 1) |
|
160 | 160 | { |
161 | - $X1 = $X + cos($Angle * PI / 180) * $i; |
|
162 | - $Y1 = $Y + sin($Angle * PI / 180) * $i; |
|
163 | - $X2 = $X1 + cos(($Angle+90) * PI / 180) * $Height; |
|
164 | - $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * $Height; |
|
161 | + $X1 = $X + cos($Angle*PI/180)*$i; |
|
162 | + $Y1 = $Y + sin($Angle*PI/180)*$i; |
|
163 | + $X2 = $X1 + cos(($Angle + 90)*PI/180)*$Height; |
|
164 | + $Y2 = $Y1 + sin(($Angle + 90)*PI/180)*$Height; |
|
165 | 165 | |
166 | - $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha); |
|
167 | - $this->pChartObject->drawLine($X1,$Y1,$X2,$Y2,$Settings); |
|
166 | + $Settings = array("R"=>$R, "G"=>$G, "B"=>$B, "Alpha"=>$Alpha); |
|
167 | + $this->pChartObject->drawLine($X1, $Y1, $X2, $Y2, $Settings); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | - if ( $ShowLegend ) |
|
171 | + if ($ShowLegend) |
|
172 | 172 | { |
173 | - $X1 = $X + cos($Angle * PI / 180) * (strlen($this->Result)/2); |
|
174 | - $Y1 = $Y + sin($Angle * PI / 180) * (strlen($this->Result)/2); |
|
173 | + $X1 = $X + cos($Angle*PI/180)*(strlen($this->Result)/2); |
|
174 | + $Y1 = $Y + sin($Angle*PI/180)*(strlen($this->Result)/2); |
|
175 | 175 | |
176 | - $LegendX = $X1 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset); |
|
177 | - $LegendY = $Y1 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset); |
|
176 | + $LegendX = $X1 + cos(($Angle + 90)*PI/180)*($Height + $LegendOffset); |
|
177 | + $LegendY = $Y1 + sin(($Angle + 90)*PI/180)*($Height + $LegendOffset); |
|
178 | 178 | |
179 | - $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Angle"=>-$Angle,"Align"=>TEXT_ALIGN_TOPMIDDLE); |
|
180 | - $this->pChartObject->drawText($LegendX,$LegendY,$TextString,$Settings); |
|
179 | + $Settings = array("R"=>$R, "G"=>$G, "B"=>$B, "Alpha"=>$Alpha, "Angle"=>-$Angle, "Align"=>TEXT_ALIGN_TOPMIDDLE); |
|
180 | + $this->pChartObject->drawText($LegendX, $LegendY, $TextString, $Settings); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - function checksum( $string ) |
|
184 | + function checksum($string) |
|
185 | 185 | { |
186 | 186 | $checksum = 0; |
187 | - $length = strlen( $string ); |
|
187 | + $length = strlen($string); |
|
188 | 188 | $charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%'; |
189 | 189 | |
190 | - for( $i=0; $i < $length; ++$i ) |
|
191 | - $checksum += strpos( $charset, $string[$i] ); |
|
190 | + for ($i = 0; $i < $length; ++$i) |
|
191 | + $checksum += strpos($charset, $string[$i]); |
|
192 | 192 | |
193 | - return substr( $charset, ($checksum % 43), 1 ); |
|
193 | + return substr($charset, ($checksum%43), 1); |
|
194 | 194 | } |
195 | 195 | |
196 | - function left($value,$NbChar) { return substr($value,0,$NbChar); } |
|
197 | - function right($value,$NbChar) { return substr($value,strlen($value)-$NbChar,$NbChar); } |
|
198 | - function mid($value,$Depart,$NbChar) { return substr($value,$Depart-1,$NbChar); } |
|
196 | + function left($value, $NbChar) { return substr($value, 0, $NbChar); } |
|
197 | + function right($value, $NbChar) { return substr($value, strlen($value) - $NbChar, $NbChar); } |
|
198 | + function mid($value, $Depart, $NbChar) { return substr($value, $Depart - 1, $NbChar); } |
|
199 | 199 | } |
200 | 200 | ?> |
201 | 201 | \ No newline at end of file |
@@ -14,8 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | |
16 | 16 | /* pData class definition */ |
17 | - class pBarcode39 |
|
18 | - { |
|
17 | + class pBarcode39 { |
|
19 | 18 | var $Codes; |
20 | 19 | var $Reverse; |
21 | 20 | var $Result; |
@@ -24,8 +23,7 @@ discard block |
||
24 | 23 | var $MOD43; |
25 | 24 | |
26 | 25 | /* Class creator */ |
27 | - function pBarcode39($BasePath="",$EnableMOD43=FALSE) |
|
28 | - { |
|
26 | + function pBarcode39($BasePath="",$EnableMOD43=FALSE) { |
|
29 | 27 | $this->MOD43 = $EnableMOD43; |
30 | 28 | $this->Codes = ""; |
31 | 29 | $this->Reverse = ""; |
@@ -34,8 +32,7 @@ discard block |
||
34 | 32 | |
35 | 33 | if (!$FileHandle) { die("Cannot find barcode database (".$BasePath."data/39.db)."); } |
36 | 34 | |
37 | - while (!feof($FileHandle)) |
|
38 | - { |
|
35 | + while (!feof($FileHandle)) { |
|
39 | 36 | $Buffer = fgets($FileHandle,4096); |
40 | 37 | $Buffer = str_replace(chr(10),"",$Buffer); |
41 | 38 | $Buffer = str_replace(chr(13),"",$Buffer); |
@@ -47,8 +44,7 @@ discard block |
||
47 | 44 | } |
48 | 45 | |
49 | 46 | /* Return the projected size of a barcode */ |
50 | - function getSize($TextString,$Format="") |
|
51 | - { |
|
47 | + function getSize($TextString,$Format="") { |
|
52 | 48 | $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
53 | 49 | $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
54 | 50 | $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
@@ -76,24 +72,20 @@ discard block |
||
76 | 72 | } |
77 | 73 | |
78 | 74 | /* Create the encoded string */ |
79 | - function encode39($Value) |
|
80 | - { |
|
75 | + function encode39($Value) { |
|
81 | 76 | $this->Result = "100101101101"."0"; |
82 | 77 | $TextString = ""; |
83 | - for($i=1;$i<=strlen($Value);$i++) |
|
84 | - { |
|
78 | + for($i=1;$i<=strlen($Value);$i++) { |
|
85 | 79 | $CharCode = ord($this->mid($Value,$i,1)); |
86 | 80 | if ( $CharCode >= 97 && $CharCode <= 122 ) { $CharCode = $CharCode - 32; } |
87 | 81 | |
88 | - if ( isset($this->Codes[chr($CharCode)]) ) |
|
89 | - { |
|
82 | + if ( isset($this->Codes[chr($CharCode)]) ) { |
|
90 | 83 | $this->Result = $this->Result.$this->Codes[chr($CharCode)]."0"; |
91 | 84 | $TextString = $TextString.chr($CharCode); |
92 | 85 | } |
93 | 86 | } |
94 | 87 | |
95 | - if ( $this->MOD43 ) |
|
96 | - { |
|
88 | + if ( $this->MOD43 ) { |
|
97 | 89 | $Checksum = $this->checksum($TextString); |
98 | 90 | $this->Result = $this->Result.$this->Codes[$Checksum]."0"; |
99 | 91 | } |
@@ -105,8 +97,7 @@ discard block |
||
105 | 97 | } |
106 | 98 | |
107 | 99 | /* Create the encoded string */ |
108 | - function draw($Object,$Value,$X,$Y,$Format="") |
|
109 | - { |
|
100 | + function draw($Object,$Value,$X,$Y,$Format="") { |
|
110 | 101 | $this->pChartObject = $Object; |
111 | 102 | |
112 | 103 | $R = isset($Format["R"]) ? $Format["R"] : 0; |
@@ -127,21 +118,17 @@ discard block |
||
127 | 118 | |
128 | 119 | $TextString = $this->encode39($Value); |
129 | 120 | |
130 | - if ( $DrawArea ) |
|
131 | - { |
|
121 | + if ( $DrawArea ) { |
|
132 | 122 | $X1 = $X + cos(($Angle-135) * PI / 180) * 10; |
133 | 123 | $Y1 = $Y + sin(($Angle-135) * PI / 180) * 10; |
134 | 124 | |
135 | 125 | $X2 = $X1 + cos($Angle * PI / 180) * (strlen($this->Result)+20); |
136 | 126 | $Y2 = $Y1 + sin($Angle * PI / 180) * (strlen($this->Result)+20); |
137 | 127 | |
138 | - if ( $ShowLegend ) |
|
139 | - { |
|
128 | + if ( $ShowLegend ) { |
|
140 | 129 | $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
141 | 130 | $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10); |
142 | - } |
|
143 | - else |
|
144 | - { |
|
131 | + } else { |
|
145 | 132 | $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+20); |
146 | 133 | $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+20); |
147 | 134 | } |
@@ -154,10 +141,8 @@ discard block |
||
154 | 141 | $this->pChartObject->drawPolygon($Polygon,$Settings); |
155 | 142 | } |
156 | 143 | |
157 | - for($i=1;$i<=strlen($this->Result);$i++) |
|
158 | - { |
|
159 | - if ( $this->mid($this->Result,$i,1) == 1 ) |
|
160 | - { |
|
144 | + for($i=1;$i<=strlen($this->Result);$i++) { |
|
145 | + if ( $this->mid($this->Result,$i,1) == 1 ) { |
|
161 | 146 | $X1 = $X + cos($Angle * PI / 180) * $i; |
162 | 147 | $Y1 = $Y + sin($Angle * PI / 180) * $i; |
163 | 148 | $X2 = $X1 + cos(($Angle+90) * PI / 180) * $Height; |
@@ -168,8 +153,7 @@ discard block |
||
168 | 153 | } |
169 | 154 | } |
170 | 155 | |
171 | - if ( $ShowLegend ) |
|
172 | - { |
|
156 | + if ( $ShowLegend ) { |
|
173 | 157 | $X1 = $X + cos($Angle * PI / 180) * (strlen($this->Result)/2); |
174 | 158 | $Y1 = $Y + sin($Angle * PI / 180) * (strlen($this->Result)/2); |
175 | 159 | |
@@ -181,14 +165,14 @@ discard block |
||
181 | 165 | } |
182 | 166 | } |
183 | 167 | |
184 | - function checksum( $string ) |
|
185 | - { |
|
168 | + function checksum( $string ) { |
|
186 | 169 | $checksum = 0; |
187 | 170 | $length = strlen( $string ); |
188 | 171 | $charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%'; |
189 | 172 | |
190 | - for( $i=0; $i < $length; ++$i ) |
|
191 | - $checksum += strpos( $charset, $string[$i] ); |
|
173 | + for( $i=0; $i < $length; ++$i ) { |
|
174 | + $checksum += strpos( $charset, $string[$i] ); |
|
175 | + } |
|
192 | 176 | |
193 | 177 | return substr( $charset, ($checksum % 43), 1 ); |
194 | 178 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | var $MOD43; |
25 | 25 | |
26 | 26 | /* Class creator */ |
27 | - function pBarcode39($BasePath="",$EnableMOD43=FALSE) |
|
27 | + function pBarcode39($BasePath="",$EnableMOD43=false) |
|
28 | 28 | { |
29 | 29 | $this->MOD43 = $EnableMOD43; |
30 | 30 | $this->Codes = ""; |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | function getSize($TextString,$Format="") |
51 | 51 | { |
52 | 52 | $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
53 | - $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
53 | + $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : false; |
|
54 | 54 | $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
55 | - $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
|
55 | + $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : false; |
|
56 | 56 | $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : 12; |
57 | 57 | $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
58 | 58 | |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100; |
116 | 116 | $Height = isset($Format["Height"]) ? $Format["Height"] : 30; |
117 | 117 | $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0; |
118 | - $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE; |
|
118 | + $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : false; |
|
119 | 119 | $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5; |
120 | - $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE; |
|
120 | + $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : false; |
|
121 | 121 | $AreaR = isset($Format["AreaR"]) ? $Format["AreaR"] : 255; |
122 | 122 | $AreaG = isset($Format["AreaG"]) ? $Format["AreaG"] : 255; |
123 | 123 | $AreaB = isset($Format["AreaB"]) ? $Format["AreaB"] : 255; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | - /* |
|
2 | + /* |
|
3 | 3 | pIndicator - class to draw indicators |
4 | 4 | |
5 | 5 | Version : 2.1.3 |
@@ -13,229 +13,229 @@ discard block |
||
13 | 13 | You can find the whole class documentation on the pChart web site. |
14 | 14 | */ |
15 | 15 | |
16 | - define("INDICATOR_CAPTION_DEFAULT" , 700001); |
|
17 | - define("INDICATOR_CAPTION_EXTENDED" , 700002); |
|
16 | + define("INDICATOR_CAPTION_DEFAULT" , 700001); |
|
17 | + define("INDICATOR_CAPTION_EXTENDED" , 700002); |
|
18 | 18 | |
19 | - define("INDICATOR_CAPTION_INSIDE" , 700011); |
|
20 | - define("INDICATOR_CAPTION_BOTTOM" , 700012); |
|
19 | + define("INDICATOR_CAPTION_INSIDE" , 700011); |
|
20 | + define("INDICATOR_CAPTION_BOTTOM" , 700012); |
|
21 | 21 | |
22 | - define("INDICATOR_VALUE_BUBBLE" , 700021); |
|
23 | - define("INDICATOR_VALUE_LABEL" , 700022); |
|
22 | + define("INDICATOR_VALUE_BUBBLE" , 700021); |
|
23 | + define("INDICATOR_VALUE_LABEL" , 700022); |
|
24 | 24 | |
25 | - /* pIndicator class definition */ |
|
26 | - class pIndicator |
|
27 | - { |
|
28 | - var $pChartObject; |
|
25 | + /* pIndicator class definition */ |
|
26 | + class pIndicator |
|
27 | + { |
|
28 | + var $pChartObject; |
|
29 | 29 | |
30 | - /* Class creator */ |
|
31 | - function pIndicator($pChartObject) |
|
30 | + /* Class creator */ |
|
31 | + function pIndicator($pChartObject) |
|
32 | 32 | { |
33 | - $this->pChartObject = $pChartObject; |
|
33 | + $this->pChartObject = $pChartObject; |
|
34 | 34 | } |
35 | 35 | |
36 | - /* Draw an indicator */ |
|
37 | - function draw($X,$Y,$Width,$Height,$Format="") |
|
36 | + /* Draw an indicator */ |
|
37 | + function draw($X,$Y,$Width,$Height,$Format="") |
|
38 | 38 | { |
39 | - $Values = isset($Format["Values"]) ? $Format["Values"] : VOID; |
|
40 | - $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : NULL; |
|
41 | - $ValueDisplay = isset($Format["ValueDisplay"]) ? $Format["ValueDisplay"] : INDICATOR_VALUE_BUBBLE; |
|
42 | - $SectionsMargin = isset($Format["SectionsMargin"]) ? $Format["SectionsMargin"] : 4; |
|
43 | - $DrawLeftHead = isset($Format["DrawLeftHead"]) ? $Format["DrawLeftHead"] : TRUE; |
|
44 | - $DrawRightHead = isset($Format["DrawRightHead"]) ? $Format["DrawRightHead"] : TRUE; |
|
45 | - $HeadSize = isset($Format["HeadSize"]) ? $Format["HeadSize"] : floor($Height/4); |
|
46 | - $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 4; |
|
47 | - $CaptionLayout = isset($Format["CaptionLayout"]) ? $Format["CaptionLayout"] : INDICATOR_CAPTION_EXTENDED; |
|
48 | - $CaptionPosition = isset($Format["CaptionPosition"]) ? $Format["CaptionPosition"] : INDICATOR_CAPTION_INSIDE; |
|
49 | - $CaptionColorFactor = isset($Format["CaptionColorFactor"]) ? $Format["CaptionColorFactor"] : NULL; |
|
50 | - $CaptionR = isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255; |
|
51 | - $CaptionG = isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255; |
|
52 | - $CaptionB = isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255; |
|
53 | - $CaptionAlpha = isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100; |
|
54 | - $SubCaptionColorFactor = isset($Format["SubCaptionColorFactor"]) ? $Format["SubCaptionColorFactor"] : NULL; |
|
55 | - $SubCaptionR = isset($Format["SubCaptionR"]) ? $Format["SubCaptionR"] : 50; |
|
56 | - $SubCaptionG = isset($Format["SubCaptionG"]) ? $Format["SubCaptionG"] : 50; |
|
57 | - $SubCaptionB = isset($Format["SubCaptionB"]) ? $Format["SubCaptionB"] : 50; |
|
58 | - $SubCaptionAlpha = isset($Format["SubCaptionAlpha"]) ? $Format["SubCaptionAlpha"] : 100; |
|
59 | - $ValueFontName = isset($Format["ValueFontName"]) ? $Format["ValueFontName"] : $this->pChartObject->FontName; |
|
60 | - $ValueFontSize = isset($Format["ValueFontSize"]) ? $Format["ValueFontSize"] : $this->pChartObject->FontSize; |
|
61 | - $CaptionFontName = isset($Format["CaptionFontName"]) ? $Format["CaptionFontName"] : $this->pChartObject->FontName; |
|
62 | - $CaptionFontSize = isset($Format["CaptionFontSize"]) ? $Format["CaptionFontSize"] : $this->pChartObject->FontSize; |
|
63 | - $Unit = isset($Format["Unit"]) ? $Format["Unit"] : ""; |
|
64 | - |
|
65 | - /* Convert the Values to display to an array if needed */ |
|
66 | - if ( !is_array($Values) ) { $Value = $Values; $Values = ""; $Values[] = $Value; } |
|
67 | - |
|
68 | - /* No section, let's die */ |
|
69 | - if ( $IndicatorSections == NULL ) { return(0); } |
|
70 | - |
|
71 | - /* Determine indicator visual configuration */ |
|
72 | - $OverallMin = $IndicatorSections[0]["End"]; $OverallMax = $IndicatorSections[0]["Start"]; |
|
73 | - foreach ($IndicatorSections as $Key => $Settings) |
|
74 | - { |
|
75 | - if ( $Settings["End"] > $OverallMax ) { $OverallMax = $Settings["End"]; } |
|
76 | - if ( $Settings["Start"] < $OverallMin ) { $OverallMin = $Settings["Start"]; } |
|
77 | - } |
|
78 | - $RealWidth = $Width - (count($IndicatorSections)-1)*$SectionsMargin; |
|
79 | - $XScale = $RealWidth / ($OverallMax-$OverallMin); |
|
80 | - |
|
81 | - $X1 = $X; $ValuesPos = ""; |
|
82 | - foreach ($IndicatorSections as $Key => $Settings) |
|
83 | - { |
|
84 | - $Color = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"]); |
|
85 | - $Caption = $Settings["Caption"]; |
|
86 | - $SubCaption = $Settings["Start"]." - ".$Settings["End"]; |
|
87 | - |
|
88 | - $X2 = $X1 + ($Settings["End"] - $Settings["Start"]) * $XScale; |
|
89 | - |
|
90 | - if ( $Key == 0 && $DrawLeftHead ) |
|
39 | + $Values = isset($Format["Values"]) ? $Format["Values"] : VOID; |
|
40 | + $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : NULL; |
|
41 | + $ValueDisplay = isset($Format["ValueDisplay"]) ? $Format["ValueDisplay"] : INDICATOR_VALUE_BUBBLE; |
|
42 | + $SectionsMargin = isset($Format["SectionsMargin"]) ? $Format["SectionsMargin"] : 4; |
|
43 | + $DrawLeftHead = isset($Format["DrawLeftHead"]) ? $Format["DrawLeftHead"] : TRUE; |
|
44 | + $DrawRightHead = isset($Format["DrawRightHead"]) ? $Format["DrawRightHead"] : TRUE; |
|
45 | + $HeadSize = isset($Format["HeadSize"]) ? $Format["HeadSize"] : floor($Height/4); |
|
46 | + $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 4; |
|
47 | + $CaptionLayout = isset($Format["CaptionLayout"]) ? $Format["CaptionLayout"] : INDICATOR_CAPTION_EXTENDED; |
|
48 | + $CaptionPosition = isset($Format["CaptionPosition"]) ? $Format["CaptionPosition"] : INDICATOR_CAPTION_INSIDE; |
|
49 | + $CaptionColorFactor = isset($Format["CaptionColorFactor"]) ? $Format["CaptionColorFactor"] : NULL; |
|
50 | + $CaptionR = isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255; |
|
51 | + $CaptionG = isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255; |
|
52 | + $CaptionB = isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255; |
|
53 | + $CaptionAlpha = isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100; |
|
54 | + $SubCaptionColorFactor = isset($Format["SubCaptionColorFactor"]) ? $Format["SubCaptionColorFactor"] : NULL; |
|
55 | + $SubCaptionR = isset($Format["SubCaptionR"]) ? $Format["SubCaptionR"] : 50; |
|
56 | + $SubCaptionG = isset($Format["SubCaptionG"]) ? $Format["SubCaptionG"] : 50; |
|
57 | + $SubCaptionB = isset($Format["SubCaptionB"]) ? $Format["SubCaptionB"] : 50; |
|
58 | + $SubCaptionAlpha = isset($Format["SubCaptionAlpha"]) ? $Format["SubCaptionAlpha"] : 100; |
|
59 | + $ValueFontName = isset($Format["ValueFontName"]) ? $Format["ValueFontName"] : $this->pChartObject->FontName; |
|
60 | + $ValueFontSize = isset($Format["ValueFontSize"]) ? $Format["ValueFontSize"] : $this->pChartObject->FontSize; |
|
61 | + $CaptionFontName = isset($Format["CaptionFontName"]) ? $Format["CaptionFontName"] : $this->pChartObject->FontName; |
|
62 | + $CaptionFontSize = isset($Format["CaptionFontSize"]) ? $Format["CaptionFontSize"] : $this->pChartObject->FontSize; |
|
63 | + $Unit = isset($Format["Unit"]) ? $Format["Unit"] : ""; |
|
64 | + |
|
65 | + /* Convert the Values to display to an array if needed */ |
|
66 | + if ( !is_array($Values) ) { $Value = $Values; $Values = ""; $Values[] = $Value; } |
|
67 | + |
|
68 | + /* No section, let's die */ |
|
69 | + if ( $IndicatorSections == NULL ) { return(0); } |
|
70 | + |
|
71 | + /* Determine indicator visual configuration */ |
|
72 | + $OverallMin = $IndicatorSections[0]["End"]; $OverallMax = $IndicatorSections[0]["Start"]; |
|
73 | + foreach ($IndicatorSections as $Key => $Settings) |
|
74 | + { |
|
75 | + if ( $Settings["End"] > $OverallMax ) { $OverallMax = $Settings["End"]; } |
|
76 | + if ( $Settings["Start"] < $OverallMin ) { $OverallMin = $Settings["Start"]; } |
|
77 | + } |
|
78 | + $RealWidth = $Width - (count($IndicatorSections)-1)*$SectionsMargin; |
|
79 | + $XScale = $RealWidth / ($OverallMax-$OverallMin); |
|
80 | + |
|
81 | + $X1 = $X; $ValuesPos = ""; |
|
82 | + foreach ($IndicatorSections as $Key => $Settings) |
|
83 | + { |
|
84 | + $Color = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"]); |
|
85 | + $Caption = $Settings["Caption"]; |
|
86 | + $SubCaption = $Settings["Start"]." - ".$Settings["End"]; |
|
87 | + |
|
88 | + $X2 = $X1 + ($Settings["End"] - $Settings["Start"]) * $XScale; |
|
89 | + |
|
90 | + if ( $Key == 0 && $DrawLeftHead ) |
|
91 | 91 | { |
92 | - $Poly = ""; $Poly[] = $X1-1; $Poly[] = $Y; $Poly[] = $X1-1; $Poly[] = $Y+$Height; $Poly[] = $X1-1-$HeadSize; $Poly[] = $Y+($Height/2); |
|
93 | - $this->pChartObject->drawPolygon($Poly,$Color); |
|
94 | - $this->pChartObject->drawLine($X1-2,$Y,$X1-2-$HeadSize,$Y+($Height/2),$Color); |
|
95 | - $this->pChartObject->drawLine($X1-2,$Y+$Height,$X1-2-$HeadSize,$Y+($Height/2),$Color); |
|
92 | + $Poly = ""; $Poly[] = $X1-1; $Poly[] = $Y; $Poly[] = $X1-1; $Poly[] = $Y+$Height; $Poly[] = $X1-1-$HeadSize; $Poly[] = $Y+($Height/2); |
|
93 | + $this->pChartObject->drawPolygon($Poly,$Color); |
|
94 | + $this->pChartObject->drawLine($X1-2,$Y,$X1-2-$HeadSize,$Y+($Height/2),$Color); |
|
95 | + $this->pChartObject->drawLine($X1-2,$Y+$Height,$X1-2-$HeadSize,$Y+($Height/2),$Color); |
|
96 | 96 | } |
97 | 97 | |
98 | - /* Determine the position of the breaks */ |
|
99 | - $Break = ""; |
|
100 | - foreach($Values as $iKey => $Value) |
|
98 | + /* Determine the position of the breaks */ |
|
99 | + $Break = ""; |
|
100 | + foreach($Values as $iKey => $Value) |
|
101 | 101 | { |
102 | - if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
103 | - { |
|
104 | - $XBreak = $X1 + ($Value - $Settings["Start"]) * $XScale; |
|
105 | - $ValuesPos[$Value] = $XBreak; |
|
106 | - $Break[] = floor($XBreak); |
|
107 | - } |
|
102 | + if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
103 | + { |
|
104 | + $XBreak = $X1 + ($Value - $Settings["Start"]) * $XScale; |
|
105 | + $ValuesPos[$Value] = $XBreak; |
|
106 | + $Break[] = floor($XBreak); |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | |
110 | - if ( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
110 | + if ( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
111 | 111 | { |
112 | - if ( $Break == "" ) |
|
113 | - $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color); |
|
114 | - else |
|
115 | - { |
|
116 | - sort($Break); |
|
117 | - $Poly = ""; $Poly[] = $X1; $Poly[] = $Y; $LastPointWritten = FALSE; |
|
118 | - foreach($Break as $iKey => $Value) |
|
112 | + if ( $Break == "" ) |
|
113 | + $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color); |
|
114 | + else |
|
115 | + { |
|
116 | + sort($Break); |
|
117 | + $Poly = ""; $Poly[] = $X1; $Poly[] = $Y; $LastPointWritten = FALSE; |
|
118 | + foreach($Break as $iKey => $Value) |
|
119 | 119 | { |
120 | - if ( $Value-5 >= $X1 ) |
|
121 | - { $Poly[] = $Value-5; $Poly[] = $Y; } |
|
122 | - elseif ($X1 - ($Value-5) > 0 ) |
|
123 | - { |
|
124 | - $Offset = $X1 - ($Value-5); |
|
125 | - $Poly = ""; $Poly[] = $X1; $Poly[] = $Y + $Offset; |
|
126 | - } |
|
127 | - |
|
128 | - $Poly[] = $Value; $Poly[] = $Y+5; |
|
129 | - |
|
130 | - if ( $Value+5 <= $X2 ) |
|
131 | - { $Poly[] = $Value+5; $Poly[] = $Y; } |
|
132 | - elseif (($Value+5) > $X2 ) |
|
133 | - { |
|
134 | - $Offset = ($Value+5) - $X2; |
|
135 | - $Poly[] = $X2; $Poly[] = $Y + $Offset; |
|
136 | - $LastPointWritten = TRUE; |
|
137 | - } |
|
120 | + if ( $Value-5 >= $X1 ) |
|
121 | + { $Poly[] = $Value-5; $Poly[] = $Y; } |
|
122 | + elseif ($X1 - ($Value-5) > 0 ) |
|
123 | + { |
|
124 | + $Offset = $X1 - ($Value-5); |
|
125 | + $Poly = ""; $Poly[] = $X1; $Poly[] = $Y + $Offset; |
|
126 | + } |
|
127 | + |
|
128 | + $Poly[] = $Value; $Poly[] = $Y+5; |
|
129 | + |
|
130 | + if ( $Value+5 <= $X2 ) |
|
131 | + { $Poly[] = $Value+5; $Poly[] = $Y; } |
|
132 | + elseif (($Value+5) > $X2 ) |
|
133 | + { |
|
134 | + $Offset = ($Value+5) - $X2; |
|
135 | + $Poly[] = $X2; $Poly[] = $Y + $Offset; |
|
136 | + $LastPointWritten = TRUE; |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
140 | - if ( !$LastPointWritten ) { $Poly[] = $X2; $Poly[] = $Y; } |
|
141 | - $Poly[] = $X2; $Poly[] = $Y+$Height; |
|
142 | - $Poly[] = $X1; $Poly[] = $Y+$Height; |
|
140 | + if ( !$LastPointWritten ) { $Poly[] = $X2; $Poly[] = $Y; } |
|
141 | + $Poly[] = $X2; $Poly[] = $Y+$Height; |
|
142 | + $Poly[] = $X1; $Poly[] = $Y+$Height; |
|
143 | 143 | |
144 | - $this->pChartObject->drawPolygon($Poly,$Color); |
|
145 | - } |
|
144 | + $this->pChartObject->drawPolygon($Poly,$Color); |
|
145 | + } |
|
146 | 146 | } |
147 | - else |
|
147 | + else |
|
148 | 148 | $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color); |
149 | 149 | |
150 | - if ( $Key == count($IndicatorSections)-1 && $DrawRightHead ) |
|
150 | + if ( $Key == count($IndicatorSections)-1 && $DrawRightHead ) |
|
151 | 151 | { |
152 | - $Poly = ""; $Poly[] = $X2+1; $Poly[] = $Y; $Poly[] = $X2+1; $Poly[] = $Y+$Height; $Poly[] = $X2+1+$HeadSize; $Poly[] = $Y+($Height/2); |
|
153 | - $this->pChartObject->drawPolygon($Poly,$Color); |
|
154 | - $this->pChartObject->drawLine($X2+1,$Y,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
|
155 | - $this->pChartObject->drawLine($X2+1,$Y+$Height,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
|
152 | + $Poly = ""; $Poly[] = $X2+1; $Poly[] = $Y; $Poly[] = $X2+1; $Poly[] = $Y+$Height; $Poly[] = $X2+1+$HeadSize; $Poly[] = $Y+($Height/2); |
|
153 | + $this->pChartObject->drawPolygon($Poly,$Color); |
|
154 | + $this->pChartObject->drawLine($X2+1,$Y,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
|
155 | + $this->pChartObject->drawLine($X2+1,$Y+$Height,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
|
156 | 156 | } |
157 | 157 | |
158 | - if ( $CaptionPosition == INDICATOR_CAPTION_INSIDE ) |
|
158 | + if ( $CaptionPosition == INDICATOR_CAPTION_INSIDE ) |
|
159 | 159 | { |
160 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
|
161 | - $YOffset = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding; |
|
160 | + $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
|
161 | + $YOffset = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding; |
|
162 | 162 | |
163 | - if ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
164 | - { |
|
165 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$SubCaption); |
|
166 | - $YOffset = $YOffset + ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding*2; |
|
167 | - } |
|
163 | + if ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
164 | + { |
|
165 | + $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$SubCaption); |
|
166 | + $YOffset = $YOffset + ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding*2; |
|
167 | + } |
|
168 | 168 | |
169 | - $XOffset = $TextPadding; |
|
169 | + $XOffset = $TextPadding; |
|
170 | 170 | } |
171 | - else |
|
171 | + else |
|
172 | 172 | { $YOffset = 0; $XOffset = 0; } |
173 | 173 | |
174 | - if ( $CaptionColorFactor == NULL ) |
|
174 | + if ( $CaptionColorFactor == NULL ) |
|
175 | 175 | { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha); } |
176 | - else |
|
176 | + else |
|
177 | 177 | { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$CaptionColorFactor,"G"=>$Settings["G"]+$CaptionColorFactor,"B"=>$Settings["B"]+$CaptionColorFactor); } |
178 | 178 | |
179 | - if ( $SubCaptionColorFactor == NULL ) |
|
179 | + if ( $SubCaptionColorFactor == NULL ) |
|
180 | 180 | $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$SubCaptionR,"G"=>$SubCaptionG,"B"=>$SubCaptionB,"Alpha"=>$SubCaptionAlpha); |
181 | - else |
|
181 | + else |
|
182 | 182 | $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$SubCaptionColorFactor,"G"=>$Settings["G"]+$SubCaptionColorFactor,"B"=>$Settings["B"]+$SubCaptionColorFactor); |
183 | 183 | |
184 | - $RestoreShadow = $this->pChartObject->Shadow; |
|
185 | - $this->pChartObject->Shadow = FALSE; |
|
184 | + $RestoreShadow = $this->pChartObject->Shadow; |
|
185 | + $this->pChartObject->Shadow = FALSE; |
|
186 | 186 | |
187 | - if ( $CaptionLayout == INDICATOR_CAPTION_DEFAULT ) |
|
187 | + if ( $CaptionLayout == INDICATOR_CAPTION_DEFAULT ) |
|
188 | 188 | $this->pChartObject->drawText($X1,$Y+$Height+$TextPadding,$Caption,$CaptionColor); |
189 | - elseif ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
189 | + elseif ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
190 | 190 | { |
191 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
|
192 | - $CaptionHeight = $TxtPos[0]["Y"] - $TxtPos[2]["Y"]; |
|
191 | + $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
|
192 | + $CaptionHeight = $TxtPos[0]["Y"] - $TxtPos[2]["Y"]; |
|
193 | 193 | |
194 | - $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$TextPadding,$Caption,$CaptionColor); |
|
195 | - $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$CaptionHeight+$TextPadding*2,$SubCaption,$SubCaptionColor); |
|
194 | + $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$TextPadding,$Caption,$CaptionColor); |
|
195 | + $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$CaptionHeight+$TextPadding*2,$SubCaption,$SubCaptionColor); |
|
196 | 196 | } |
197 | 197 | |
198 | - $this->pChartObject->Shadow = $RestoreShadow; |
|
198 | + $this->pChartObject->Shadow = $RestoreShadow; |
|
199 | 199 | |
200 | - $X1 = $X2 + $SectionsMargin; |
|
201 | - } |
|
200 | + $X1 = $X2 + $SectionsMargin; |
|
201 | + } |
|
202 | 202 | |
203 | - $RestoreShadow = $this->pChartObject->Shadow; |
|
204 | - $this->pChartObject->Shadow = FALSE; |
|
203 | + $RestoreShadow = $this->pChartObject->Shadow; |
|
204 | + $this->pChartObject->Shadow = FALSE; |
|
205 | 205 | |
206 | - foreach($Values as $Key => $Value) |
|
207 | - { |
|
208 | - if ( $Value >= $OverallMin && $Value <= $OverallMax ) |
|
206 | + foreach($Values as $Key => $Value) |
|
207 | + { |
|
208 | + if ( $Value >= $OverallMin && $Value <= $OverallMax ) |
|
209 | 209 | { |
210 | - foreach ($IndicatorSections as $Key => $Settings) |
|
211 | - { |
|
212 | - if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
210 | + foreach ($IndicatorSections as $Key => $Settings) |
|
213 | 211 | { |
214 | - $X1 = $ValuesPos[$Value]; //$X + $Key*$SectionsMargin + ($Value - $OverallMin) * $XScale; |
|
215 | - |
|
216 | - if ( $ValueDisplay == INDICATOR_VALUE_BUBBLE ) |
|
217 | - { |
|
218 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y,$ValueFontName,$ValueFontSize,0,$Value.$Unit); |
|
219 | - $Radius = floor(($TxtPos[1]["X"] - $TxtPos[0]["X"] + $TextPadding*4)/2); |
|
220 | - |
|
221 | - $this->pChartObject->drawFilledCircle($X1,$Y,$Radius+4,array("R"=>$Settings["R"]+20,"G"=>$Settings["G"]+20,"B"=>$Settings["B"]+20)); |
|
222 | - $this->pChartObject->drawFilledCircle($X1,$Y,$Radius,array("R"=>255,"G"=>255,"B"=>255)); |
|
223 | - |
|
224 | - $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontName"=>$ValueFontName,"FontSize"=>$ValueFontSize); |
|
225 | - $this->pChartObject->drawText($X1-1,$Y-1,$Value.$Unit,$TextSettings); |
|
226 | - } |
|
227 | - elseif( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
228 | - { |
|
229 | - $Caption = ""; |
|
230 | - $Caption[] = array("Format"=>array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>100),"Caption"=>$Value.$Unit); |
|
231 | - $this->pChartObject->drawLabelBox(floor($X1),floor($Y)+2,"Value - ".$Settings["Caption"],$Caption); |
|
232 | - } |
|
212 | + if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
213 | + { |
|
214 | + $X1 = $ValuesPos[$Value]; //$X + $Key*$SectionsMargin + ($Value - $OverallMin) * $XScale; |
|
215 | + |
|
216 | + if ( $ValueDisplay == INDICATOR_VALUE_BUBBLE ) |
|
217 | + { |
|
218 | + $TxtPos = $this->pChartObject->getTextBox($X1,$Y,$ValueFontName,$ValueFontSize,0,$Value.$Unit); |
|
219 | + $Radius = floor(($TxtPos[1]["X"] - $TxtPos[0]["X"] + $TextPadding*4)/2); |
|
220 | + |
|
221 | + $this->pChartObject->drawFilledCircle($X1,$Y,$Radius+4,array("R"=>$Settings["R"]+20,"G"=>$Settings["G"]+20,"B"=>$Settings["B"]+20)); |
|
222 | + $this->pChartObject->drawFilledCircle($X1,$Y,$Radius,array("R"=>255,"G"=>255,"B"=>255)); |
|
223 | + |
|
224 | + $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontName"=>$ValueFontName,"FontSize"=>$ValueFontSize); |
|
225 | + $this->pChartObject->drawText($X1-1,$Y-1,$Value.$Unit,$TextSettings); |
|
226 | + } |
|
227 | + elseif( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
228 | + { |
|
229 | + $Caption = ""; |
|
230 | + $Caption[] = array("Format"=>array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>100),"Caption"=>$Value.$Unit); |
|
231 | + $this->pChartObject->drawLabelBox(floor($X1),floor($Y)+2,"Value - ".$Settings["Caption"],$Caption); |
|
232 | + } |
|
233 | + } |
|
234 | + $X1 = $X2 + $SectionsMargin; |
|
233 | 235 | } |
234 | - $X1 = $X2 + $SectionsMargin; |
|
235 | - } |
|
236 | 236 | } |
237 | - } |
|
238 | - $this->pChartObject->Shadow = $RestoreShadow; |
|
237 | + } |
|
238 | + $this->pChartObject->Shadow = $RestoreShadow; |
|
239 | + } |
|
239 | 240 | } |
240 | - } |
|
241 | 241 | ?> |
242 | 242 | \ No newline at end of file |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | You can find the whole class documentation on the pChart web site. |
14 | 14 | */ |
15 | 15 | |
16 | - define("INDICATOR_CAPTION_DEFAULT" , 700001); |
|
17 | - define("INDICATOR_CAPTION_EXTENDED" , 700002); |
|
16 | + define("INDICATOR_CAPTION_DEFAULT", 700001); |
|
17 | + define("INDICATOR_CAPTION_EXTENDED", 700002); |
|
18 | 18 | |
19 | - define("INDICATOR_CAPTION_INSIDE" , 700011); |
|
20 | - define("INDICATOR_CAPTION_BOTTOM" , 700012); |
|
19 | + define("INDICATOR_CAPTION_INSIDE", 700011); |
|
20 | + define("INDICATOR_CAPTION_BOTTOM", 700012); |
|
21 | 21 | |
22 | - define("INDICATOR_VALUE_BUBBLE" , 700021); |
|
23 | - define("INDICATOR_VALUE_LABEL" , 700022); |
|
22 | + define("INDICATOR_VALUE_BUBBLE", 700021); |
|
23 | + define("INDICATOR_VALUE_LABEL", 700022); |
|
24 | 24 | |
25 | 25 | /* pIndicator class definition */ |
26 | 26 | class pIndicator |
@@ -34,24 +34,24 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | /* Draw an indicator */ |
37 | - function draw($X,$Y,$Width,$Height,$Format="") |
|
37 | + function draw($X, $Y, $Width, $Height, $Format = "") |
|
38 | 38 | { |
39 | - $Values = isset($Format["Values"]) ? $Format["Values"] : VOID; |
|
40 | - $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : NULL; |
|
39 | + $Values = isset($Format["Values"]) ? $Format["Values"] : VOID; |
|
40 | + $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : NULL; |
|
41 | 41 | $ValueDisplay = isset($Format["ValueDisplay"]) ? $Format["ValueDisplay"] : INDICATOR_VALUE_BUBBLE; |
42 | - $SectionsMargin = isset($Format["SectionsMargin"]) ? $Format["SectionsMargin"] : 4; |
|
42 | + $SectionsMargin = isset($Format["SectionsMargin"]) ? $Format["SectionsMargin"] : 4; |
|
43 | 43 | $DrawLeftHead = isset($Format["DrawLeftHead"]) ? $Format["DrawLeftHead"] : TRUE; |
44 | 44 | $DrawRightHead = isset($Format["DrawRightHead"]) ? $Format["DrawRightHead"] : TRUE; |
45 | - $HeadSize = isset($Format["HeadSize"]) ? $Format["HeadSize"] : floor($Height/4); |
|
46 | - $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 4; |
|
45 | + $HeadSize = isset($Format["HeadSize"]) ? $Format["HeadSize"] : floor($Height/4); |
|
46 | + $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 4; |
|
47 | 47 | $CaptionLayout = isset($Format["CaptionLayout"]) ? $Format["CaptionLayout"] : INDICATOR_CAPTION_EXTENDED; |
48 | - $CaptionPosition = isset($Format["CaptionPosition"]) ? $Format["CaptionPosition"] : INDICATOR_CAPTION_INSIDE; |
|
49 | - $CaptionColorFactor = isset($Format["CaptionColorFactor"]) ? $Format["CaptionColorFactor"] : NULL; |
|
48 | + $CaptionPosition = isset($Format["CaptionPosition"]) ? $Format["CaptionPosition"] : INDICATOR_CAPTION_INSIDE; |
|
49 | + $CaptionColorFactor = isset($Format["CaptionColorFactor"]) ? $Format["CaptionColorFactor"] : NULL; |
|
50 | 50 | $CaptionR = isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255; |
51 | 51 | $CaptionG = isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255; |
52 | 52 | $CaptionB = isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255; |
53 | - $CaptionAlpha = isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100; |
|
54 | - $SubCaptionColorFactor = isset($Format["SubCaptionColorFactor"]) ? $Format["SubCaptionColorFactor"] : NULL; |
|
53 | + $CaptionAlpha = isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100; |
|
54 | + $SubCaptionColorFactor = isset($Format["SubCaptionColorFactor"]) ? $Format["SubCaptionColorFactor"] : NULL; |
|
55 | 55 | $SubCaptionR = isset($Format["SubCaptionR"]) ? $Format["SubCaptionR"] : 50; |
56 | 56 | $SubCaptionG = isset($Format["SubCaptionG"]) ? $Format["SubCaptionG"] : 50; |
57 | 57 | $SubCaptionB = isset($Format["SubCaptionB"]) ? $Format["SubCaptionB"] : 50; |
@@ -60,109 +60,109 @@ discard block |
||
60 | 60 | $ValueFontSize = isset($Format["ValueFontSize"]) ? $Format["ValueFontSize"] : $this->pChartObject->FontSize; |
61 | 61 | $CaptionFontName = isset($Format["CaptionFontName"]) ? $Format["CaptionFontName"] : $this->pChartObject->FontName; |
62 | 62 | $CaptionFontSize = isset($Format["CaptionFontSize"]) ? $Format["CaptionFontSize"] : $this->pChartObject->FontSize; |
63 | - $Unit = isset($Format["Unit"]) ? $Format["Unit"] : ""; |
|
63 | + $Unit = isset($Format["Unit"]) ? $Format["Unit"] : ""; |
|
64 | 64 | |
65 | 65 | /* Convert the Values to display to an array if needed */ |
66 | - if ( !is_array($Values) ) { $Value = $Values; $Values = ""; $Values[] = $Value; } |
|
66 | + if (!is_array($Values)) { $Value = $Values; $Values = ""; $Values[] = $Value; } |
|
67 | 67 | |
68 | 68 | /* No section, let's die */ |
69 | - if ( $IndicatorSections == NULL ) { return(0); } |
|
69 | + if ($IndicatorSections == NULL) { return(0); } |
|
70 | 70 | |
71 | 71 | /* Determine indicator visual configuration */ |
72 | 72 | $OverallMin = $IndicatorSections[0]["End"]; $OverallMax = $IndicatorSections[0]["Start"]; |
73 | 73 | foreach ($IndicatorSections as $Key => $Settings) |
74 | 74 | { |
75 | - if ( $Settings["End"] > $OverallMax ) { $OverallMax = $Settings["End"]; } |
|
76 | - if ( $Settings["Start"] < $OverallMin ) { $OverallMin = $Settings["Start"]; } |
|
75 | + if ($Settings["End"] > $OverallMax) { $OverallMax = $Settings["End"]; } |
|
76 | + if ($Settings["Start"] < $OverallMin) { $OverallMin = $Settings["Start"]; } |
|
77 | 77 | } |
78 | - $RealWidth = $Width - (count($IndicatorSections)-1)*$SectionsMargin; |
|
79 | - $XScale = $RealWidth / ($OverallMax-$OverallMin); |
|
78 | + $RealWidth = $Width - (count($IndicatorSections) - 1)*$SectionsMargin; |
|
79 | + $XScale = $RealWidth/($OverallMax - $OverallMin); |
|
80 | 80 | |
81 | 81 | $X1 = $X; $ValuesPos = ""; |
82 | 82 | foreach ($IndicatorSections as $Key => $Settings) |
83 | 83 | { |
84 | - $Color = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"]); |
|
84 | + $Color = array("R"=>$Settings["R"], "G"=>$Settings["G"], "B"=>$Settings["B"]); |
|
85 | 85 | $Caption = $Settings["Caption"]; |
86 | 86 | $SubCaption = $Settings["Start"]." - ".$Settings["End"]; |
87 | 87 | |
88 | - $X2 = $X1 + ($Settings["End"] - $Settings["Start"]) * $XScale; |
|
88 | + $X2 = $X1 + ($Settings["End"] - $Settings["Start"])*$XScale; |
|
89 | 89 | |
90 | - if ( $Key == 0 && $DrawLeftHead ) |
|
90 | + if ($Key == 0 && $DrawLeftHead) |
|
91 | 91 | { |
92 | - $Poly = ""; $Poly[] = $X1-1; $Poly[] = $Y; $Poly[] = $X1-1; $Poly[] = $Y+$Height; $Poly[] = $X1-1-$HeadSize; $Poly[] = $Y+($Height/2); |
|
93 | - $this->pChartObject->drawPolygon($Poly,$Color); |
|
94 | - $this->pChartObject->drawLine($X1-2,$Y,$X1-2-$HeadSize,$Y+($Height/2),$Color); |
|
95 | - $this->pChartObject->drawLine($X1-2,$Y+$Height,$X1-2-$HeadSize,$Y+($Height/2),$Color); |
|
92 | + $Poly = ""; $Poly[] = $X1 - 1; $Poly[] = $Y; $Poly[] = $X1 - 1; $Poly[] = $Y + $Height; $Poly[] = $X1 - 1 - $HeadSize; $Poly[] = $Y + ($Height/2); |
|
93 | + $this->pChartObject->drawPolygon($Poly, $Color); |
|
94 | + $this->pChartObject->drawLine($X1 - 2, $Y, $X1 - 2 - $HeadSize, $Y + ($Height/2), $Color); |
|
95 | + $this->pChartObject->drawLine($X1 - 2, $Y + $Height, $X1 - 2 - $HeadSize, $Y + ($Height/2), $Color); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /* Determine the position of the breaks */ |
99 | 99 | $Break = ""; |
100 | - foreach($Values as $iKey => $Value) |
|
100 | + foreach ($Values as $iKey => $Value) |
|
101 | 101 | { |
102 | - if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
102 | + if ($Value >= $Settings["Start"] && $Value <= $Settings["End"]) |
|
103 | 103 | { |
104 | - $XBreak = $X1 + ($Value - $Settings["Start"]) * $XScale; |
|
104 | + $XBreak = $X1 + ($Value - $Settings["Start"])*$XScale; |
|
105 | 105 | $ValuesPos[$Value] = $XBreak; |
106 | 106 | $Break[] = floor($XBreak); |
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | - if ( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
110 | + if ($ValueDisplay == INDICATOR_VALUE_LABEL) |
|
111 | 111 | { |
112 | - if ( $Break == "" ) |
|
113 | - $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color); |
|
112 | + if ($Break == "") |
|
113 | + $this->pChartObject->drawFilledRectangle($X1, $Y, $X2, $Y + $Height, $Color); |
|
114 | 114 | else |
115 | 115 | { |
116 | 116 | sort($Break); |
117 | 117 | $Poly = ""; $Poly[] = $X1; $Poly[] = $Y; $LastPointWritten = FALSE; |
118 | - foreach($Break as $iKey => $Value) |
|
118 | + foreach ($Break as $iKey => $Value) |
|
119 | 119 | { |
120 | - if ( $Value-5 >= $X1 ) |
|
121 | - { $Poly[] = $Value-5; $Poly[] = $Y; } |
|
122 | - elseif ($X1 - ($Value-5) > 0 ) |
|
120 | + if ($Value - 5 >= $X1) |
|
121 | + { $Poly[] = $Value - 5; $Poly[] = $Y; } |
|
122 | + elseif ($X1 - ($Value - 5) > 0) |
|
123 | 123 | { |
124 | - $Offset = $X1 - ($Value-5); |
|
124 | + $Offset = $X1 - ($Value - 5); |
|
125 | 125 | $Poly = ""; $Poly[] = $X1; $Poly[] = $Y + $Offset; |
126 | 126 | } |
127 | 127 | |
128 | - $Poly[] = $Value; $Poly[] = $Y+5; |
|
128 | + $Poly[] = $Value; $Poly[] = $Y + 5; |
|
129 | 129 | |
130 | - if ( $Value+5 <= $X2 ) |
|
131 | - { $Poly[] = $Value+5; $Poly[] = $Y; } |
|
132 | - elseif (($Value+5) > $X2 ) |
|
130 | + if ($Value + 5 <= $X2) |
|
131 | + { $Poly[] = $Value + 5; $Poly[] = $Y; } |
|
132 | + elseif (($Value + 5) > $X2) |
|
133 | 133 | { |
134 | - $Offset = ($Value+5) - $X2; |
|
134 | + $Offset = ($Value + 5) - $X2; |
|
135 | 135 | $Poly[] = $X2; $Poly[] = $Y + $Offset; |
136 | 136 | $LastPointWritten = TRUE; |
137 | 137 | } |
138 | 138 | |
139 | 139 | } |
140 | - if ( !$LastPointWritten ) { $Poly[] = $X2; $Poly[] = $Y; } |
|
141 | - $Poly[] = $X2; $Poly[] = $Y+$Height; |
|
142 | - $Poly[] = $X1; $Poly[] = $Y+$Height; |
|
140 | + if (!$LastPointWritten) { $Poly[] = $X2; $Poly[] = $Y; } |
|
141 | + $Poly[] = $X2; $Poly[] = $Y + $Height; |
|
142 | + $Poly[] = $X1; $Poly[] = $Y + $Height; |
|
143 | 143 | |
144 | - $this->pChartObject->drawPolygon($Poly,$Color); |
|
144 | + $this->pChartObject->drawPolygon($Poly, $Color); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | else |
148 | - $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color); |
|
148 | + $this->pChartObject->drawFilledRectangle($X1, $Y, $X2, $Y + $Height, $Color); |
|
149 | 149 | |
150 | - if ( $Key == count($IndicatorSections)-1 && $DrawRightHead ) |
|
150 | + if ($Key == count($IndicatorSections) - 1 && $DrawRightHead) |
|
151 | 151 | { |
152 | - $Poly = ""; $Poly[] = $X2+1; $Poly[] = $Y; $Poly[] = $X2+1; $Poly[] = $Y+$Height; $Poly[] = $X2+1+$HeadSize; $Poly[] = $Y+($Height/2); |
|
153 | - $this->pChartObject->drawPolygon($Poly,$Color); |
|
154 | - $this->pChartObject->drawLine($X2+1,$Y,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
|
155 | - $this->pChartObject->drawLine($X2+1,$Y+$Height,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
|
152 | + $Poly = ""; $Poly[] = $X2 + 1; $Poly[] = $Y; $Poly[] = $X2 + 1; $Poly[] = $Y + $Height; $Poly[] = $X2 + 1 + $HeadSize; $Poly[] = $Y + ($Height/2); |
|
153 | + $this->pChartObject->drawPolygon($Poly, $Color); |
|
154 | + $this->pChartObject->drawLine($X2 + 1, $Y, $X2 + 1 + $HeadSize, $Y + ($Height/2), $Color); |
|
155 | + $this->pChartObject->drawLine($X2 + 1, $Y + $Height, $X2 + 1 + $HeadSize, $Y + ($Height/2), $Color); |
|
156 | 156 | } |
157 | 157 | |
158 | - if ( $CaptionPosition == INDICATOR_CAPTION_INSIDE ) |
|
158 | + if ($CaptionPosition == INDICATOR_CAPTION_INSIDE) |
|
159 | 159 | { |
160 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
|
160 | + $TxtPos = $this->pChartObject->getTextBox($X1, $Y + $Height + $TextPadding, $CaptionFontName, $CaptionFontSize, 0, $Caption); |
|
161 | 161 | $YOffset = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding; |
162 | 162 | |
163 | - if ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
163 | + if ($CaptionLayout == INDICATOR_CAPTION_EXTENDED) |
|
164 | 164 | { |
165 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$SubCaption); |
|
165 | + $TxtPos = $this->pChartObject->getTextBox($X1, $Y + $Height + $TextPadding, $CaptionFontName, $CaptionFontSize, 0, $SubCaption); |
|
166 | 166 | $YOffset = $YOffset + ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding*2; |
167 | 167 | } |
168 | 168 | |
@@ -171,28 +171,28 @@ discard block |
||
171 | 171 | else |
172 | 172 | { $YOffset = 0; $XOffset = 0; } |
173 | 173 | |
174 | - if ( $CaptionColorFactor == NULL ) |
|
175 | - { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha); } |
|
174 | + if ($CaptionColorFactor == NULL) |
|
175 | + { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT, "FontName"=>$CaptionFontName, "FontSize"=>$CaptionFontSize, "R"=>$CaptionR, "G"=>$CaptionG, "B"=>$CaptionB, "Alpha"=>$CaptionAlpha); } |
|
176 | 176 | else |
177 | - { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$CaptionColorFactor,"G"=>$Settings["G"]+$CaptionColorFactor,"B"=>$Settings["B"]+$CaptionColorFactor); } |
|
177 | + { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT, "FontName"=>$CaptionFontName, "FontSize"=>$CaptionFontSize, "R"=>$Settings["R"] + $CaptionColorFactor, "G"=>$Settings["G"] + $CaptionColorFactor, "B"=>$Settings["B"] + $CaptionColorFactor); } |
|
178 | 178 | |
179 | - if ( $SubCaptionColorFactor == NULL ) |
|
180 | - $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$SubCaptionR,"G"=>$SubCaptionG,"B"=>$SubCaptionB,"Alpha"=>$SubCaptionAlpha); |
|
179 | + if ($SubCaptionColorFactor == NULL) |
|
180 | + $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT, "FontName"=>$CaptionFontName, "FontSize"=>$CaptionFontSize, "R"=>$SubCaptionR, "G"=>$SubCaptionG, "B"=>$SubCaptionB, "Alpha"=>$SubCaptionAlpha); |
|
181 | 181 | else |
182 | - $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$SubCaptionColorFactor,"G"=>$Settings["G"]+$SubCaptionColorFactor,"B"=>$Settings["B"]+$SubCaptionColorFactor); |
|
182 | + $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT, "FontName"=>$CaptionFontName, "FontSize"=>$CaptionFontSize, "R"=>$Settings["R"] + $SubCaptionColorFactor, "G"=>$Settings["G"] + $SubCaptionColorFactor, "B"=>$Settings["B"] + $SubCaptionColorFactor); |
|
183 | 183 | |
184 | 184 | $RestoreShadow = $this->pChartObject->Shadow; |
185 | 185 | $this->pChartObject->Shadow = FALSE; |
186 | 186 | |
187 | - if ( $CaptionLayout == INDICATOR_CAPTION_DEFAULT ) |
|
188 | - $this->pChartObject->drawText($X1,$Y+$Height+$TextPadding,$Caption,$CaptionColor); |
|
189 | - elseif ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
187 | + if ($CaptionLayout == INDICATOR_CAPTION_DEFAULT) |
|
188 | + $this->pChartObject->drawText($X1, $Y + $Height + $TextPadding, $Caption, $CaptionColor); |
|
189 | + elseif ($CaptionLayout == INDICATOR_CAPTION_EXTENDED) |
|
190 | 190 | { |
191 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
|
191 | + $TxtPos = $this->pChartObject->getTextBox($X1, $Y + $Height + $TextPadding, $CaptionFontName, $CaptionFontSize, 0, $Caption); |
|
192 | 192 | $CaptionHeight = $TxtPos[0]["Y"] - $TxtPos[2]["Y"]; |
193 | 193 | |
194 | - $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$TextPadding,$Caption,$CaptionColor); |
|
195 | - $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$CaptionHeight+$TextPadding*2,$SubCaption,$SubCaptionColor); |
|
194 | + $this->pChartObject->drawText($X1 + $XOffset, $Y + $Height - $YOffset + $TextPadding, $Caption, $CaptionColor); |
|
195 | + $this->pChartObject->drawText($X1 + $XOffset, $Y + $Height - $YOffset + $CaptionHeight + $TextPadding*2, $SubCaption, $SubCaptionColor); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $this->pChartObject->Shadow = $RestoreShadow; |
@@ -203,32 +203,32 @@ discard block |
||
203 | 203 | $RestoreShadow = $this->pChartObject->Shadow; |
204 | 204 | $this->pChartObject->Shadow = FALSE; |
205 | 205 | |
206 | - foreach($Values as $Key => $Value) |
|
206 | + foreach ($Values as $Key => $Value) |
|
207 | 207 | { |
208 | - if ( $Value >= $OverallMin && $Value <= $OverallMax ) |
|
208 | + if ($Value >= $OverallMin && $Value <= $OverallMax) |
|
209 | 209 | { |
210 | 210 | foreach ($IndicatorSections as $Key => $Settings) |
211 | 211 | { |
212 | - if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
212 | + if ($Value >= $Settings["Start"] && $Value <= $Settings["End"]) |
|
213 | 213 | { |
214 | 214 | $X1 = $ValuesPos[$Value]; //$X + $Key*$SectionsMargin + ($Value - $OverallMin) * $XScale; |
215 | 215 | |
216 | - if ( $ValueDisplay == INDICATOR_VALUE_BUBBLE ) |
|
216 | + if ($ValueDisplay == INDICATOR_VALUE_BUBBLE) |
|
217 | 217 | { |
218 | - $TxtPos = $this->pChartObject->getTextBox($X1,$Y,$ValueFontName,$ValueFontSize,0,$Value.$Unit); |
|
218 | + $TxtPos = $this->pChartObject->getTextBox($X1, $Y, $ValueFontName, $ValueFontSize, 0, $Value.$Unit); |
|
219 | 219 | $Radius = floor(($TxtPos[1]["X"] - $TxtPos[0]["X"] + $TextPadding*4)/2); |
220 | 220 | |
221 | - $this->pChartObject->drawFilledCircle($X1,$Y,$Radius+4,array("R"=>$Settings["R"]+20,"G"=>$Settings["G"]+20,"B"=>$Settings["B"]+20)); |
|
222 | - $this->pChartObject->drawFilledCircle($X1,$Y,$Radius,array("R"=>255,"G"=>255,"B"=>255)); |
|
221 | + $this->pChartObject->drawFilledCircle($X1, $Y, $Radius + 4, array("R"=>$Settings["R"] + 20, "G"=>$Settings["G"] + 20, "B"=>$Settings["B"] + 20)); |
|
222 | + $this->pChartObject->drawFilledCircle($X1, $Y, $Radius, array("R"=>255, "G"=>255, "B"=>255)); |
|
223 | 223 | |
224 | - $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontName"=>$ValueFontName,"FontSize"=>$ValueFontSize); |
|
225 | - $this->pChartObject->drawText($X1-1,$Y-1,$Value.$Unit,$TextSettings); |
|
224 | + $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE, "FontName"=>$ValueFontName, "FontSize"=>$ValueFontSize); |
|
225 | + $this->pChartObject->drawText($X1 - 1, $Y - 1, $Value.$Unit, $TextSettings); |
|
226 | 226 | } |
227 | - elseif( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
227 | + elseif ($ValueDisplay == INDICATOR_VALUE_LABEL) |
|
228 | 228 | { |
229 | 229 | $Caption = ""; |
230 | - $Caption[] = array("Format"=>array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>100),"Caption"=>$Value.$Unit); |
|
231 | - $this->pChartObject->drawLabelBox(floor($X1),floor($Y)+2,"Value - ".$Settings["Caption"],$Caption); |
|
230 | + $Caption[] = array("Format"=>array("R"=>$Settings["R"], "G"=>$Settings["G"], "B"=>$Settings["B"], "Alpha"=>100), "Caption"=>$Value.$Unit); |
|
231 | + $this->pChartObject->drawLabelBox(floor($X1), floor($Y) + 2, "Value - ".$Settings["Caption"], $Caption); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | $X1 = $X2 + $SectionsMargin; |
@@ -23,19 +23,16 @@ discard block |
||
23 | 23 | define("INDICATOR_VALUE_LABEL" , 700022); |
24 | 24 | |
25 | 25 | /* pIndicator class definition */ |
26 | - class pIndicator |
|
27 | - { |
|
26 | + class pIndicator { |
|
28 | 27 | var $pChartObject; |
29 | 28 | |
30 | 29 | /* Class creator */ |
31 | - function pIndicator($pChartObject) |
|
32 | - { |
|
30 | + function pIndicator($pChartObject) { |
|
33 | 31 | $this->pChartObject = $pChartObject; |
34 | 32 | } |
35 | 33 | |
36 | 34 | /* Draw an indicator */ |
37 | - function draw($X,$Y,$Width,$Height,$Format="") |
|
38 | - { |
|
35 | + function draw($X,$Y,$Width,$Height,$Format="") { |
|
39 | 36 | $Values = isset($Format["Values"]) ? $Format["Values"] : VOID; |
40 | 37 | $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : NULL; |
41 | 38 | $ValueDisplay = isset($Format["ValueDisplay"]) ? $Format["ValueDisplay"] : INDICATOR_VALUE_BUBBLE; |
@@ -70,8 +67,7 @@ discard block |
||
70 | 67 | |
71 | 68 | /* Determine indicator visual configuration */ |
72 | 69 | $OverallMin = $IndicatorSections[0]["End"]; $OverallMax = $IndicatorSections[0]["Start"]; |
73 | - foreach ($IndicatorSections as $Key => $Settings) |
|
74 | - { |
|
70 | + foreach ($IndicatorSections as $Key => $Settings) { |
|
75 | 71 | if ( $Settings["End"] > $OverallMax ) { $OverallMax = $Settings["End"]; } |
76 | 72 | if ( $Settings["Start"] < $OverallMin ) { $OverallMin = $Settings["Start"]; } |
77 | 73 | } |
@@ -79,16 +75,14 @@ discard block |
||
79 | 75 | $XScale = $RealWidth / ($OverallMax-$OverallMin); |
80 | 76 | |
81 | 77 | $X1 = $X; $ValuesPos = ""; |
82 | - foreach ($IndicatorSections as $Key => $Settings) |
|
83 | - { |
|
78 | + foreach ($IndicatorSections as $Key => $Settings) { |
|
84 | 79 | $Color = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"]); |
85 | 80 | $Caption = $Settings["Caption"]; |
86 | 81 | $SubCaption = $Settings["Start"]." - ".$Settings["End"]; |
87 | 82 | |
88 | 83 | $X2 = $X1 + ($Settings["End"] - $Settings["Start"]) * $XScale; |
89 | 84 | |
90 | - if ( $Key == 0 && $DrawLeftHead ) |
|
91 | - { |
|
85 | + if ( $Key == 0 && $DrawLeftHead ) { |
|
92 | 86 | $Poly = ""; $Poly[] = $X1-1; $Poly[] = $Y; $Poly[] = $X1-1; $Poly[] = $Y+$Height; $Poly[] = $X1-1-$HeadSize; $Poly[] = $Y+($Height/2); |
93 | 87 | $this->pChartObject->drawPolygon($Poly,$Color); |
94 | 88 | $this->pChartObject->drawLine($X1-2,$Y,$X1-2-$HeadSize,$Y+($Height/2),$Color); |
@@ -97,30 +91,23 @@ discard block |
||
97 | 91 | |
98 | 92 | /* Determine the position of the breaks */ |
99 | 93 | $Break = ""; |
100 | - foreach($Values as $iKey => $Value) |
|
101 | - { |
|
102 | - if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
103 | - { |
|
94 | + foreach($Values as $iKey => $Value) { |
|
95 | + if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) { |
|
104 | 96 | $XBreak = $X1 + ($Value - $Settings["Start"]) * $XScale; |
105 | 97 | $ValuesPos[$Value] = $XBreak; |
106 | 98 | $Break[] = floor($XBreak); |
107 | 99 | } |
108 | 100 | } |
109 | 101 | |
110 | - if ( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
111 | - { |
|
102 | + if ( $ValueDisplay == INDICATOR_VALUE_LABEL ) { |
|
112 | 103 | if ( $Break == "" ) |
113 | 104 | $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color); |
114 | - else |
|
115 | - { |
|
105 | + else { |
|
116 | 106 | sort($Break); |
117 | 107 | $Poly = ""; $Poly[] = $X1; $Poly[] = $Y; $LastPointWritten = FALSE; |
118 | - foreach($Break as $iKey => $Value) |
|
119 | - { |
|
108 | + foreach($Break as $iKey => $Value) { |
|
120 | 109 | if ( $Value-5 >= $X1 ) |
121 | - { $Poly[] = $Value-5; $Poly[] = $Y; } |
|
122 | - elseif ($X1 - ($Value-5) > 0 ) |
|
123 | - { |
|
110 | + { $Poly[] = $Value-5; $Poly[] = $Y; } elseif ($X1 - ($Value-5) > 0 ) { |
|
124 | 111 | $Offset = $X1 - ($Value-5); |
125 | 112 | $Poly = ""; $Poly[] = $X1; $Poly[] = $Y + $Offset; |
126 | 113 | } |
@@ -128,9 +115,7 @@ discard block |
||
128 | 115 | $Poly[] = $Value; $Poly[] = $Y+5; |
129 | 116 | |
130 | 117 | if ( $Value+5 <= $X2 ) |
131 | - { $Poly[] = $Value+5; $Poly[] = $Y; } |
|
132 | - elseif (($Value+5) > $X2 ) |
|
133 | - { |
|
118 | + { $Poly[] = $Value+5; $Poly[] = $Y; } elseif (($Value+5) > $X2 ) { |
|
134 | 119 | $Offset = ($Value+5) - $X2; |
135 | 120 | $Poly[] = $X2; $Poly[] = $Y + $Offset; |
136 | 121 | $LastPointWritten = TRUE; |
@@ -143,37 +128,31 @@ discard block |
||
143 | 128 | |
144 | 129 | $this->pChartObject->drawPolygon($Poly,$Color); |
145 | 130 | } |
146 | - } |
|
147 | - else |
|
131 | + } else |
|
148 | 132 | $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color); |
149 | 133 | |
150 | - if ( $Key == count($IndicatorSections)-1 && $DrawRightHead ) |
|
151 | - { |
|
134 | + if ( $Key == count($IndicatorSections)-1 && $DrawRightHead ) { |
|
152 | 135 | $Poly = ""; $Poly[] = $X2+1; $Poly[] = $Y; $Poly[] = $X2+1; $Poly[] = $Y+$Height; $Poly[] = $X2+1+$HeadSize; $Poly[] = $Y+($Height/2); |
153 | 136 | $this->pChartObject->drawPolygon($Poly,$Color); |
154 | 137 | $this->pChartObject->drawLine($X2+1,$Y,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
155 | 138 | $this->pChartObject->drawLine($X2+1,$Y+$Height,$X2+1+$HeadSize,$Y+($Height/2),$Color); |
156 | 139 | } |
157 | 140 | |
158 | - if ( $CaptionPosition == INDICATOR_CAPTION_INSIDE ) |
|
159 | - { |
|
141 | + if ( $CaptionPosition == INDICATOR_CAPTION_INSIDE ) { |
|
160 | 142 | $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
161 | 143 | $YOffset = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding; |
162 | 144 | |
163 | - if ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
164 | - { |
|
145 | + if ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) { |
|
165 | 146 | $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$SubCaption); |
166 | 147 | $YOffset = $YOffset + ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding*2; |
167 | 148 | } |
168 | 149 | |
169 | 150 | $XOffset = $TextPadding; |
170 | - } |
|
171 | - else |
|
151 | + } else |
|
172 | 152 | { $YOffset = 0; $XOffset = 0; } |
173 | 153 | |
174 | 154 | if ( $CaptionColorFactor == NULL ) |
175 | - { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha); } |
|
176 | - else |
|
155 | + { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha); } else |
|
177 | 156 | { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$CaptionColorFactor,"G"=>$Settings["G"]+$CaptionColorFactor,"B"=>$Settings["B"]+$CaptionColorFactor); } |
178 | 157 | |
179 | 158 | if ( $SubCaptionColorFactor == NULL ) |
@@ -186,8 +165,7 @@ discard block |
||
186 | 165 | |
187 | 166 | if ( $CaptionLayout == INDICATOR_CAPTION_DEFAULT ) |
188 | 167 | $this->pChartObject->drawText($X1,$Y+$Height+$TextPadding,$Caption,$CaptionColor); |
189 | - elseif ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) |
|
190 | - { |
|
168 | + elseif ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED ) { |
|
191 | 169 | $TxtPos = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption); |
192 | 170 | $CaptionHeight = $TxtPos[0]["Y"] - $TxtPos[2]["Y"]; |
193 | 171 | |
@@ -203,18 +181,13 @@ discard block |
||
203 | 181 | $RestoreShadow = $this->pChartObject->Shadow; |
204 | 182 | $this->pChartObject->Shadow = FALSE; |
205 | 183 | |
206 | - foreach($Values as $Key => $Value) |
|
207 | - { |
|
208 | - if ( $Value >= $OverallMin && $Value <= $OverallMax ) |
|
209 | - { |
|
210 | - foreach ($IndicatorSections as $Key => $Settings) |
|
211 | - { |
|
212 | - if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) |
|
213 | - { |
|
184 | + foreach($Values as $Key => $Value) { |
|
185 | + if ( $Value >= $OverallMin && $Value <= $OverallMax ) { |
|
186 | + foreach ($IndicatorSections as $Key => $Settings) { |
|
187 | + if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] ) { |
|
214 | 188 | $X1 = $ValuesPos[$Value]; //$X + $Key*$SectionsMargin + ($Value - $OverallMin) * $XScale; |
215 | 189 | |
216 | - if ( $ValueDisplay == INDICATOR_VALUE_BUBBLE ) |
|
217 | - { |
|
190 | + if ( $ValueDisplay == INDICATOR_VALUE_BUBBLE ) { |
|
218 | 191 | $TxtPos = $this->pChartObject->getTextBox($X1,$Y,$ValueFontName,$ValueFontSize,0,$Value.$Unit); |
219 | 192 | $Radius = floor(($TxtPos[1]["X"] - $TxtPos[0]["X"] + $TextPadding*4)/2); |
220 | 193 | |
@@ -223,9 +196,7 @@ discard block |
||
223 | 196 | |
224 | 197 | $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontName"=>$ValueFontName,"FontSize"=>$ValueFontSize); |
225 | 198 | $this->pChartObject->drawText($X1-1,$Y-1,$Value.$Unit,$TextSettings); |
226 | - } |
|
227 | - elseif( $ValueDisplay == INDICATOR_VALUE_LABEL ) |
|
228 | - { |
|
199 | + } elseif( $ValueDisplay == INDICATOR_VALUE_LABEL ) { |
|
229 | 200 | $Caption = ""; |
230 | 201 | $Caption[] = array("Format"=>array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>100),"Caption"=>$Value.$Unit); |
231 | 202 | $this->pChartObject->drawLabelBox(floor($X1),floor($Y)+2,"Value - ".$Settings["Caption"],$Caption); |
@@ -37,21 +37,21 @@ discard block |
||
37 | 37 | function draw($X,$Y,$Width,$Height,$Format="") |
38 | 38 | { |
39 | 39 | $Values = isset($Format["Values"]) ? $Format["Values"] : VOID; |
40 | - $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : NULL; |
|
40 | + $IndicatorSections = isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : null; |
|
41 | 41 | $ValueDisplay = isset($Format["ValueDisplay"]) ? $Format["ValueDisplay"] : INDICATOR_VALUE_BUBBLE; |
42 | 42 | $SectionsMargin = isset($Format["SectionsMargin"]) ? $Format["SectionsMargin"] : 4; |
43 | - $DrawLeftHead = isset($Format["DrawLeftHead"]) ? $Format["DrawLeftHead"] : TRUE; |
|
44 | - $DrawRightHead = isset($Format["DrawRightHead"]) ? $Format["DrawRightHead"] : TRUE; |
|
43 | + $DrawLeftHead = isset($Format["DrawLeftHead"]) ? $Format["DrawLeftHead"] : true; |
|
44 | + $DrawRightHead = isset($Format["DrawRightHead"]) ? $Format["DrawRightHead"] : true; |
|
45 | 45 | $HeadSize = isset($Format["HeadSize"]) ? $Format["HeadSize"] : floor($Height/4); |
46 | 46 | $TextPadding = isset($Format["TextPadding"]) ? $Format["TextPadding"] : 4; |
47 | 47 | $CaptionLayout = isset($Format["CaptionLayout"]) ? $Format["CaptionLayout"] : INDICATOR_CAPTION_EXTENDED; |
48 | 48 | $CaptionPosition = isset($Format["CaptionPosition"]) ? $Format["CaptionPosition"] : INDICATOR_CAPTION_INSIDE; |
49 | - $CaptionColorFactor = isset($Format["CaptionColorFactor"]) ? $Format["CaptionColorFactor"] : NULL; |
|
49 | + $CaptionColorFactor = isset($Format["CaptionColorFactor"]) ? $Format["CaptionColorFactor"] : null; |
|
50 | 50 | $CaptionR = isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255; |
51 | 51 | $CaptionG = isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255; |
52 | 52 | $CaptionB = isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255; |
53 | 53 | $CaptionAlpha = isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100; |
54 | - $SubCaptionColorFactor = isset($Format["SubCaptionColorFactor"]) ? $Format["SubCaptionColorFactor"] : NULL; |
|
54 | + $SubCaptionColorFactor = isset($Format["SubCaptionColorFactor"]) ? $Format["SubCaptionColorFactor"] : null; |
|
55 | 55 | $SubCaptionR = isset($Format["SubCaptionR"]) ? $Format["SubCaptionR"] : 50; |
56 | 56 | $SubCaptionG = isset($Format["SubCaptionG"]) ? $Format["SubCaptionG"] : 50; |
57 | 57 | $SubCaptionB = isset($Format["SubCaptionB"]) ? $Format["SubCaptionB"] : 50; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | if ( !is_array($Values) ) { $Value = $Values; $Values = ""; $Values[] = $Value; } |
67 | 67 | |
68 | 68 | /* No section, let's die */ |
69 | - if ( $IndicatorSections == NULL ) { return(0); } |
|
69 | + if ( $IndicatorSections == null ) { return(0); } |
|
70 | 70 | |
71 | 71 | /* Determine indicator visual configuration */ |
72 | 72 | $OverallMin = $IndicatorSections[0]["End"]; $OverallMax = $IndicatorSections[0]["Start"]; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | else |
115 | 115 | { |
116 | 116 | sort($Break); |
117 | - $Poly = ""; $Poly[] = $X1; $Poly[] = $Y; $LastPointWritten = FALSE; |
|
117 | + $Poly = ""; $Poly[] = $X1; $Poly[] = $Y; $LastPointWritten = false; |
|
118 | 118 | foreach($Break as $iKey => $Value) |
119 | 119 | { |
120 | 120 | if ( $Value-5 >= $X1 ) |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | $Offset = ($Value+5) - $X2; |
135 | 135 | $Poly[] = $X2; $Poly[] = $Y + $Offset; |
136 | - $LastPointWritten = TRUE; |
|
136 | + $LastPointWritten = true; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | } |
@@ -171,18 +171,18 @@ discard block |
||
171 | 171 | else |
172 | 172 | { $YOffset = 0; $XOffset = 0; } |
173 | 173 | |
174 | - if ( $CaptionColorFactor == NULL ) |
|
174 | + if ( $CaptionColorFactor == null ) |
|
175 | 175 | { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha); } |
176 | 176 | else |
177 | 177 | { $CaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$CaptionColorFactor,"G"=>$Settings["G"]+$CaptionColorFactor,"B"=>$Settings["B"]+$CaptionColorFactor); } |
178 | 178 | |
179 | - if ( $SubCaptionColorFactor == NULL ) |
|
179 | + if ( $SubCaptionColorFactor == null ) |
|
180 | 180 | $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$SubCaptionR,"G"=>$SubCaptionG,"B"=>$SubCaptionB,"Alpha"=>$SubCaptionAlpha); |
181 | 181 | else |
182 | 182 | $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$SubCaptionColorFactor,"G"=>$Settings["G"]+$SubCaptionColorFactor,"B"=>$Settings["B"]+$SubCaptionColorFactor); |
183 | 183 | |
184 | 184 | $RestoreShadow = $this->pChartObject->Shadow; |
185 | - $this->pChartObject->Shadow = FALSE; |
|
185 | + $this->pChartObject->Shadow = false; |
|
186 | 186 | |
187 | 187 | if ( $CaptionLayout == INDICATOR_CAPTION_DEFAULT ) |
188 | 188 | $this->pChartObject->drawText($X1,$Y+$Height+$TextPadding,$Caption,$CaptionColor); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | $RestoreShadow = $this->pChartObject->Shadow; |
204 | - $this->pChartObject->Shadow = FALSE; |
|
204 | + $this->pChartObject->Shadow = false; |
|
205 | 205 | |
206 | 206 | foreach($Values as $Key => $Value) |
207 | 207 | { |