Mercurial > hg > rc1
comparison plugins/thunderbird_labels/thunderbird_labels.php @ 2:c828b0fd4a6e
fix missing line to store changed labels
author | Charlie Root |
---|---|
date | Fri, 05 Jan 2018 14:17:23 -0500 |
parents | 5821049f1791 |
children | 7a7f68b4358e |
comparison
equal
deleted
inserted
replaced
1:5821049f1791 | 2:c828b0fd4a6e |
---|---|
205 } | 205 } |
206 | 206 |
207 // save prefs after modified in UI | 207 // save prefs after modified in UI |
208 public function prefs_save($args) | 208 public function prefs_save($args) |
209 { | 209 { |
210 if ($args['section'] != 'thunderbird_labels') | 210 rcube::write_log('lab','saving: '.print_r($args,true)); |
211 if ($args['section'] != 'thunderbird_labels') | |
211 return $args; | 212 return $args; |
212 | 213 |
213 | 214 |
214 $this->load_config(); | 215 $this->load_config(); |
215 $dont_override = (array) $this->rc->config->get('dont_override', array()); | 216 $dont_override = (array) $this->rc->config->get('dont_override', array()); |
230 $tb_lab_prefs = array(); | 231 $tb_lab_prefs = array(); |
231 $tb_lab_prefs[0] = $this->gettext('label0'); | 232 $tb_lab_prefs[0] = $this->gettext('label0'); |
232 for ($i = 1; $i <= $max_id; $i++) { | 233 for ($i = 1; $i <= $max_id; $i++) { |
233 $tb_lab_prefs[$i] = rcube_utils::get_input_value('tb_label_custom_labels'.$i, rcube_utils::INPUT_POST); | 234 $tb_lab_prefs[$i] = rcube_utils::get_input_value('tb_label_custom_labels'.$i, rcube_utils::INPUT_POST); |
234 } | 235 } |
236 $args['prefs']['tb_label_custom_labels'] = $tb_lab_prefs; | |
235 } | 237 } |
236 | 238 |
237 return $args; | 239 return $args; |
238 } | 240 } |
239 | 241 |
265 return $out; | 267 return $out; |
266 } | 268 } |
267 | 269 |
268 public function read_single_flags($args) | 270 public function read_single_flags($args) |
269 { | 271 { |
270 #rcube::write_log($this->name, print_r(($args['object']), true)); | 272 rcube::write_log($this->name, print_r(($args['object']), true)); |
271 if (!isset($args['object'])) { | 273 if (!isset($args['object'])) { |
272 return; | 274 return; |
273 } | 275 } |
274 | 276 |
275 if (is_array($args['object']->headers->flags)) | 277 if (is_array($args['object']->headers->flags)) |
280 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 | 282 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 |
281 $flag = strtolower($flag); | 283 $flag = strtolower($flag); |
282 if (preg_match('/^\$?label/', $flag)) | 284 if (preg_match('/^\$?label/', $flag)) |
283 { | 285 { |
284 $flag_no = preg_replace('/^\$?label/', '', $flag); | 286 $flag_no = preg_replace('/^\$?label/', '', $flag); |
285 #rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no); | 287 rcube::write_log($this->name, "Single message Flag: ".$flag." Flag_no:".$flag_no); |
286 $this->message_tb_labels[] = (int)$flag_no; | 288 $this->message_tb_labels[] = (int)$flag_no; |
287 } | 289 } |
288 } | 290 } |
289 } | 291 } |
290 # -- no return value for this hook | 292 # -- no return value for this hook |
294 * Writes labelnumbers for single message display | 296 * Writes labelnumbers for single message display |
295 * Coloring of Message header table happens via Javascript | 297 * Coloring of Message header table happens via Javascript |
296 */ | 298 */ |
297 public function color_headers($p) | 299 public function color_headers($p) |
298 { | 300 { |
299 #rcube::write_log($this->name, print_r($p, true)); | 301 rcube::write_log($this->name, print_r($p, true)); |
300 # -- always write array, even when empty | 302 # -- always write array, even when empty |
301 $p['content'] .= '<script type="text/javascript"> | 303 $p['content'] .= '<script type="text/javascript"> |
302 var tb_labels_for_message = ['.join(',', $this->message_tb_labels).']; | 304 var tb_labels_for_message = ['.join(',', $this->message_tb_labels).']; |
303 </script>'; | 305 </script>'; |
304 return $p; | 306 return $p; |
305 } | 307 } |
306 | 308 |
307 public function read_flags($args) | 309 public function read_flags($args) |
308 { | 310 { |
309 #rcube::write_log($this->name, print_r($args, true)); | 311 rcube::write_log($this->name, print_r($args, true)); |
310 // add color information for all messages | 312 // add color information for all messages |
311 // dont loop over all messages if we dont have any highlights or no msgs | 313 // dont loop over all messages if we dont have any highlights or no msgs |
312 if (!isset($args['messages']) or !is_array($args['messages'])) { | 314 if (!isset($args['messages']) or !is_array($args['messages'])) { |
313 return $args; | 315 return $args; |
314 } | 316 } |
315 | 317 |
316 // loop over all messages and add $LabelX info to the extra_flags | 318 // loop over all messages and add $LabelX info to the extra_flags |
317 foreach($args['messages'] as $message) | 319 foreach($args['messages'] as $message) |
318 { | 320 { |
319 #rcube::write_log($this->name, print_r($message->flags, true)); | 321 rcube::write_log($this->name, print_r($message->flags, true)); |
320 $message->list_flags['extra_flags']['tb_labels'] = array(); # always set extra_flags, needed for javascript later! | 322 $message->list_flags['extra_flags']['tb_labels'] = array(); # always set extra_flags, needed for javascript later! |
321 if (is_array($message->flags)) | 323 if (is_array($message->flags)) |
322 foreach ($message->flags as $flagname => $flagvalue) | 324 foreach ($message->flags as $flagname => $flagvalue) |
323 { | 325 { |
324 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 | 326 $flag = is_numeric("$flagvalue")? $flagname:$flagvalue;// for compatibility with < 0.5.4 |
325 $flag = strtolower($flag); | 327 $flag = strtolower($flag); |
326 if (preg_match('/^\$?label/', $flag)) | 328 if (preg_match('/^\$?label/', $flag)) |
327 { | 329 { |
328 $flag_no = preg_replace('/^\$?label/', '', $flag); | 330 $flag_no = preg_replace('/^\$?label/', '', $flag); |
329 #rcube::write_log($this->name, "Flag:".$flag." Flag_no:".$flag_no); | 331 rcube::write_log($this->name, "Flag:".$flag." Flag_no:".$flag_no); |
330 $message->list_flags['extra_flags']['tb_labels'][] = (int)$flag_no; | 332 $message->list_flags['extra_flags']['tb_labels'][] = (int)$flag_no; |
331 } | 333 } |
332 } | 334 } |
333 } | 335 } |
334 return($args); | 336 return($args); |
335 } | 337 } |
336 | 338 |
337 // set flags in IMAP server | 339 // set flags in IMAP server |
338 function set_flags() | 340 function set_flags() |
339 { | 341 { |
340 #rcube::write_log($this->name, print_r($_GET, true)); | 342 rcube::write_log($this->name, print_r($_GET, true)); |
341 | 343 |
342 $imap = $this->rc->imap; | 344 $imap = $this->rc->imap; |
343 $cbox = rcube_utils::get_input_value('_cur', rcube_utils::INPUT_GET); | 345 $cbox = rcube_utils::get_input_value('_cur', rcube_utils::INPUT_GET); |
344 $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GET); | 346 $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GET); |
345 $toggle_label = rcube_utils::get_input_value('_toggle_label', rcube_utils::INPUT_GET); | 347 $toggle_label = rcube_utils::get_input_value('_toggle_label', rcube_utils::INPUT_GET); |
348 $unflag_uids = rcube_utils::get_input_value('_unflag_uids', rcube_utils::INPUT_GET); | 350 $unflag_uids = rcube_utils::get_input_value('_unflag_uids', rcube_utils::INPUT_GET); |
349 $unflag_uids = explode(',', $unflag_uids); | 351 $unflag_uids = explode(',', $unflag_uids); |
350 | 352 |
351 $imap->conn->flags = array_merge($imap->conn->flags, $this->add_tb_flags); | 353 $imap->conn->flags = array_merge($imap->conn->flags, $this->add_tb_flags); |
352 | 354 |
353 #rcube::write_log($this->name, print_r($flag_uids, true)); | 355 rcube::write_log($this->name, print_r($flag_uids, true)); |
354 #rcube::write_log($this->name, print_r($unflag_uids, true)); | 356 rcube::write_log($this->name, print_r($unflag_uids, true)); |
355 | 357 |
356 if (!is_array($unflag_uids) | 358 if (!is_array($unflag_uids) |
357 || !is_array($flag_uids)) | 359 || !is_array($flag_uids)) |
358 return false; | 360 return false; |
359 | 361 |