Changeset 5155 in subversion
- Timestamp:
- Sep 4, 2011 2:44:18 AM (22 months ago)
- Location:
- trunk/plugins/managesieve
- Files:
-
- 2 added
- 7 edited
-
Changelog (modified) (1 diff)
-
localization/en_US.inc (modified) (2 diffs)
-
localization/pl_PL.inc (modified) (2 diffs)
-
managesieve.js (modified) (5 diffs)
-
managesieve.php (modified) (8 diffs)
-
skins/default/filter.png (added)
-
skins/default/managesieve.css (modified) (3 diffs)
-
skins/default/managesieve_mail.css (added)
-
skins/default/templates/filteredit.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/managesieve/Changelog
r4983 r5155 1 - Added possibility to create a filter based on selected message "in-place" 2 1 3 * version 4.3 [2011-07-28] 2 4 ----------------------------------------------------------- -
trunk/plugins/managesieve/localization/en_US.inc
r4523 r5155 78 78 $labels['flagflagged'] = 'Flagged'; 79 79 $labels['flagdraft'] = 'Draft'; 80 $labels['filtercreate'] = 'Create filter'; 81 $labels['usedata'] = 'Use following data in the filter:'; 82 $labels['nextstep'] = 'Next Step'; 80 83 81 84 $messages = array(); … … 101 104 $messages['setcreated'] = 'Filters set created successfully'; 102 105 $messages['emptyname'] = 'Unable to create filters set. Empty set name'; 103 $messages['nametoolong'] = 'Unable to create filters set. Name too long' 106 $messages['nametoolong'] = 'Unable to create filters set. Name too long'; 107 $messages['nodata'] = 'At least one position must be selected!'; 104 108 105 109 ?> -
trunk/plugins/managesieve/localization/pl_PL.inc
r4629 r5155 92 92 $labels['flagflagged'] = 'Oflagowana'; 93 93 $labels['flagdraft'] = 'Szkic'; 94 $labels['filtercreate'] = 'UtwóŌ filtr'; 95 $labels['usedata'] = 'UÅŒyj nastÄpujÄ 96 cych danych do utworzenia filtra:'; 97 $labels['nextstep'] = 'NastÄpny krok'; 94 98 95 99 $messages = array(); … … 135 139 $messages['emptyname'] = 'Nie moÅŒna utworzyÄ zbioru filtrów. Pusta nazwa zbioru'; 136 140 $messages['nametoolong'] = 'Nie moÅŒna utworzyÄ zbioru filtrów. Nazwa zbyt dÅuga' 141 $messages['nodata'] = 'NaleÅŒy wybraÄ co najmniej jednÄ 142 pozycjÄ!'; 137 143 138 144 ?> -
trunk/plugins/managesieve/managesieve.js
r4865 r5155 1 /* Sieve Filters (tab)*/1 /* (Manage)Sieve Filters */ 2 2 3 3 if (window.rcmail) { 4 4 rcmail.addEventListener('init', function(evt) { 5 6 var tab = $('<span>').attr('id', 'settingstabpluginmanagesieve').addClass('tablink'); 7 var button = $('<a>').attr('href', rcmail.env.comm_path+'&_action=plugin.managesieve') 8 .attr('title', rcmail.gettext('managesieve.managefilters')) 9 .html(rcmail.gettext('managesieve.filters')) 10 .appendTo(tab); 11 12 // add button and register commands 13 rcmail.add_element(tab, 'tabs'); 14 rcmail.register_command('plugin.managesieve-save', function() { rcmail.managesieve_save() }, true); 15 rcmail.register_command('plugin.managesieve-add', function() { rcmail.managesieve_add() }, true); 16 rcmail.register_command('plugin.managesieve-del', function() { rcmail.managesieve_del() }, true); 17 rcmail.register_command('plugin.managesieve-up', function() { rcmail.managesieve_up() }, true); 18 rcmail.register_command('plugin.managesieve-down', function() { rcmail.managesieve_down() }, true); 19 rcmail.register_command('plugin.managesieve-set', function() { rcmail.managesieve_set() }, true); 20 rcmail.register_command('plugin.managesieve-setadd', function() { rcmail.managesieve_setadd() }, true); 21 rcmail.register_command('plugin.managesieve-setdel', function() { rcmail.managesieve_setdel() }, true); 22 rcmail.register_command('plugin.managesieve-setact', function() { rcmail.managesieve_setact() }, true); 23 rcmail.register_command('plugin.managesieve-setget', function() { rcmail.managesieve_setget() }, true); 24 25 if (rcmail.env.action == 'plugin.managesieve') { 26 if (rcmail.gui_objects.sieveform) { 27 rcmail.enable_command('plugin.managesieve-save', true); 28 } 29 else { 30 rcmail.enable_command('plugin.managesieve-del', 'plugin.managesieve-up', 31 'plugin.managesieve-down', false); 32 rcmail.enable_command('plugin.managesieve-add', 'plugin.managesieve-setadd', !rcmail.env.sieveconnerror); 33 } 34 5 // add managesieve-create command to message_commands array, 6 // so it's state will be updated on message selection/unselection 7 if (rcmail.env.task == 'mail') { 8 if (rcmail.env.action != 'show') 9 rcmail.env.message_commands.push('managesieve-create'); 10 else 11 rcmail.enable_command('managesieve-create', true); 12 } 13 else { 14 var tab = $('<span>').attr('id', 'settingstabpluginmanagesieve').addClass('tablink'), 15 button = $('<a>').attr('href', rcmail.env.comm_path+'&_action=plugin.managesieve') 16 .attr('title', rcmail.gettext('managesieve.managefilters')) 17 .html(rcmail.gettext('managesieve.filters')) 18 .appendTo(tab); 19 20 // add tab 21 rcmail.add_element(tab, 'tabs'); 22 } 23 24 if (rcmail.env.task == 'mail' || rcmail.env.action.indexOf('plugin.managesieve') != -1) { 35 25 // Create layer for form tips 36 26 if (!rcmail.env.framed) { 37 27 rcmail.env.ms_tip_layer = $('<div id="managesieve-tip" class="popupmenu"></div>'); 38 28 rcmail.env.ms_tip_layer.appendTo(document.body); 29 } 30 } 31 32 // register commands 33 rcmail.register_command('plugin.managesieve-save', function() { rcmail.managesieve_save() }); 34 rcmail.register_command('plugin.managesieve-add', function() { rcmail.managesieve_add() }); 35 rcmail.register_command('plugin.managesieve-del', function() { rcmail.managesieve_del() }); 36 rcmail.register_command('plugin.managesieve-up', function() { rcmail.managesieve_up() }); 37 rcmail.register_command('plugin.managesieve-down', function() { rcmail.managesieve_down() }); 38 rcmail.register_command('plugin.managesieve-set', function() { rcmail.managesieve_set() }); 39 rcmail.register_command('plugin.managesieve-setadd', function() { rcmail.managesieve_setadd() }); 40 rcmail.register_command('plugin.managesieve-setdel', function() { rcmail.managesieve_setdel() }); 41 rcmail.register_command('plugin.managesieve-setact', function() { rcmail.managesieve_setact() }); 42 rcmail.register_command('plugin.managesieve-setget', function() { rcmail.managesieve_setget() }); 43 44 if (rcmail.env.action == 'plugin.managesieve' || rcmail.env.action == 'plugin.managesieve-save') { 45 if (rcmail.gui_objects.sieveform) { 46 rcmail.enable_command('plugin.managesieve-save', true); 47 // resize dialog window 48 if (rcmail.env.action == 'plugin.managesieve' && rcmail.env.task == 'mail') { 49 parent.rcmail.managesieve_dialog_resize(rcmail.gui_objects.sieveform); 50 } 51 $('input[type="text"]:first', rcmail.gui_objects.sieveform).focus(); 52 } 53 else { 54 rcmail.enable_command('plugin.managesieve-add', 'plugin.managesieve-setadd', !rcmail.env.sieveconnerror); 39 55 } 40 56 … … 480 496 rcube_webmail.prototype.managesieve_tip_register = function(tips) 481 497 { 498 var n, framed = parent.rcmail, 499 tip = framed ? parent.rcmail.env.ms_tip_layer : rcmail.env.ms_tip_layer; 500 482 501 for (var n in tips) { 483 502 $('#'+tips[n][0]) … … 485 504 function(e) { 486 505 var offset = $(this).offset(), 487 tip = rcmail.env.framed ? parent.rcmail.env.ms_tip_layer : rcmail.env.ms_tip_layer,488 506 left = offset.left, 489 507 top = offset.top - 12; 490 508 491 if ( rcmail.env.framed) {492 offset = $( parent.document.getElementById('filter-box')).offset();509 if (framed) { 510 offset = $((rcmail.env.task == 'mail' ? '#sievefilterform > iframe' : '#filter-box'), parent.document).offset(); 493 511 top += offset.top; 494 512 left += offset.left; … … 500 518 tip.css({left: left, top: top}).show(); 501 519 }) 502 .bind('mouseleave', 503 function(e) { 504 var tip = parent.rcmail && parent.rcmail.env.ms_tip_layer ? 505 parent.rcmail.env.ms_tip_layer : rcmail.env.ms_tip_layer; 506 tip.hide(); 507 }); 520 .bind('mouseleave', function(e) { tip.hide(); }); 508 521 } 509 522 }; … … 580 593 } 581 594 }; 595 596 /*********************************************************/ 597 /********* Mail UI methods *********/ 598 /*********************************************************/ 599 600 rcube_webmail.prototype.managesieve_create = function() 601 { 602 if (!rcmail.env.sieve_headers || !rcmail.env.sieve_headers.length) 603 return; 604 605 var i, html, buttons = {}, dialog = $("#sievefilterform"); 606 607 // create dialog window 608 if (!dialog.length) { 609 dialog = $('<div id="sievefilterform"></div>'); 610 $('body').append(dialog); 611 } 612 613 // build dialog window content 614 html = '<fieldset><legend>'+this.gettext('managesieve.usedata')+'</legend><ul>'; 615 for (i in rcmail.env.sieve_headers) 616 html += '<li><input type="checkbox" name="headers[]" id="sievehdr'+i+'" value="'+i+'" checked="checked" />' 617 +'<label for="sievehdr'+i+'">'+rcmail.env.sieve_headers[i][0]+':</label> '+rcmail.env.sieve_headers[i][1]+'</li>'; 618 html += '</ul></fieldset>'; 619 620 dialog.html(html); 621 622 // [Next Step] button action 623 buttons[this.gettext('managesieve.nextstep')] = function () { 624 // check if there's at least one checkbox checked 625 var hdrs = $('input[name="headers[]"]:checked', dialog); 626 if (!hdrs.length) { 627 alert(rcmail.gettext('managesieve.nodata')); 628 return; 629 } 630 631 // build frame URL 632 var url = rcmail.get_task_url('mail'); 633 url = rcmail.add_url(url, '_action', 'plugin.managesieve'); 634 url = rcmail.add_url(url, '_framed', 1); 635 636 hdrs.map(function() { 637 var val = rcmail.env.sieve_headers[this.value]; 638 url = rcmail.add_url(url, 'r['+this.value+']', val[0]+':'+val[1]); 639 }); 640 641 // load form in the iframe 642 var frame = $('<iframe>').attr({src: url, frameborder: 0}) 643 frame.height(dialog.height()); // temp. 644 dialog.empty().append(frame); 645 dialog.dialog('dialog').resize(); 646 647 // Change [Next Step] button with [Save] button 648 buttons = {}; 649 buttons[rcmail.gettext('save')] = function() { 650 var win = $('iframe', dialog).get(0).contentWindow; 651 win.rcmail.managesieve_save(); 652 }; 653 dialog.dialog('option', 'buttons', buttons); 654 }; 655 656 // show dialog window 657 dialog.dialog({ 658 modal: false, 659 resizable: !bw.ie6, 660 closeOnEscape: (!bw.ie6 && !bw.ie7), // disable for performance reasons 661 title: this.gettext('managesieve.newfilter'), 662 close: function() { rcmail.managesieve_dialog_close(); }, 663 buttons: buttons, 664 minWidth: 600, 665 minHeight: 300 666 }).show(); 667 668 this.env.managesieve_dialog = dialog; 669 } 670 671 rcube_webmail.prototype.managesieve_dialog_close = function() 672 { 673 var dialog = this.env.managesieve_dialog; 674 675 // BUG(?): if we don't remove the iframe first, it will be reloaded 676 dialog.html(''); 677 dialog.dialog('destroy').hide(); 678 } 679 680 rcube_webmail.prototype.managesieve_dialog_resize = function(o) 681 { 682 var dialog = this.env.managesieve_dialog, 683 win = $(window), form = $(o); 684 width = form.width(), height = form.height(), 685 w = win.width(), h = win.height(); 686 687 dialog.dialog('option', { height: Math.min(h-20, height+120), width: Math.min(w-20, width+65) }) 688 .dialog('option', 'position', ['center', 'center']); // only works in a separate call (!?) 689 } -
trunk/plugins/managesieve/managesieve.php
r4983 r5155 14 14 * 15 15 * Copyright (C) 2008-2011, The Roundcube Dev Team 16 * Copyright (C) 2011, Kolab Systems AG 16 17 * 17 18 * This program is free software; you can redistribute it and/or modify … … 33 34 class managesieve extends rcube_plugin 34 35 { 35 public $task = ' settings';36 public $task = 'mail|settings'; 36 37 37 38 private $rc; … … 51 52 function init() 52 53 { 53 // add Tab label/title 54 $this->add_texts('localization/', array('filters','managefilters')); 54 $this->rc = rcmail::get_instance(); 55 55 56 56 // register actions … … 58 58 $this->register_action('plugin.managesieve-save', array($this, 'managesieve_save')); 59 59 60 if ($this->rc->task == 'settings') { 61 // load localization 62 $this->add_texts('localization/', array('filters','managefilters')); 63 64 $this->include_script('managesieve.js'); 65 } 66 else if ($this->rc->task == 'mail') { 67 // register message hook 68 $this->add_hook('message_headers_output', array($this, 'mail_headers')); 69 70 // inject Create Filter popup stuff 71 if (empty($this->rc->action) || $this->rc->action == 'show') { 72 $this->mail_task_handler(); 73 } 74 } 75 } 76 77 /** 78 * Add UI elements to the 'mailbox view' and 'show message' UI. 79 */ 80 function mail_task_handler() 81 { 82 // load localization 83 $this->add_texts('localization/'); 84 85 // use jQuery for popup window 86 $this->require_plugin('jqueryui'); 87 60 88 // include main js script 61 89 $this->include_script('managesieve.js'); 62 } 63 90 91 // include styles 92 $skin = $this->rc->config->get('skin'); 93 if (!file_exists($this->home."/skins/$skin/managesieve_mail.css")) 94 $skin = 'default'; 95 $this->include_stylesheet("skins/$skin/managesieve_mail.css"); 96 97 // add 'Create filter' item to message menu 98 $this->api->add_content(html::tag('li', null, 99 $this->api->output->button(array( 100 'command' => 'managesieve-create', 101 'label' => 'managesieve.filtercreate', 102 'type' => 'link', 103 'classact' => 'filterlink active', 104 'class' => 'filterlink', 105 ))), 'messagemenu'); 106 107 // register some labels/messages 108 $this->rc->output->add_label('managesieve.newfilter', 'managesieve.usedata', 109 'managesieve.nodata', 'managesieve.nextstep', 'save'); 110 } 111 112 /** 113 * Get message headers for popup window 114 */ 115 function mail_headers($args) 116 { 117 $headers = $args['headers']; 118 $ret = array(); 119 120 if ($headers->subject) 121 $ret[] = array('Subject', $headers->subject); 122 123 // @TODO: List-Id, others? 124 foreach (array('From', 'To') as $h) { 125 $hl = strtolower($h); 126 if ($headers->$hl) { 127 $list = $this->rc->imap->decode_address_list($headers->$hl); 128 foreach ($list as $item) { 129 if ($item['mailto']) { 130 $ret[] = array($h, $item['mailto']); 131 } 132 } 133 } 134 } 135 136 if ($this->rc->action == 'preview') 137 $this->rc->output->command('parent.set_env', array('sieve_headers' => $ret)); 138 else 139 $this->rc->output->set_env('sieve_headers', $ret); 140 141 142 return $args; 143 } 144 145 /** 146 * Loads configuration, initializes plugin (including sieve connection) 147 */ 64 148 function managesieve_start() 65 149 { 66 $this->rc = rcmail::get_instance();67 150 $this->load_config(); 68 151 … … 170 253 function managesieve_actions() 171 254 { 255 // load localization 256 $this->add_texts('localization/', array('filters','managefilters')); 257 258 // include main js script 259 if ($this->api->output->type == 'html') { 260 $this->include_script('managesieve.js'); 261 } 262 172 263 // Init plugin and handle managesieve connection 173 264 $error = $this->managesieve_start(); … … 299 390 $this->rc->output->send(); 300 391 } 392 else if ($this->rc->task == 'mail') { 393 // Initialize the form 394 $rules = get_input_value('r', RCUBE_INPUT_GET); 395 if (!empty($rules)) { 396 $i = 0; 397 foreach ($rules as $rule) { 398 list($header, $value) = explode(':', $rule, 2); 399 $tests[$i] = array( 400 'type' => 'contains', 401 'test' => 'header', 402 'arg1' => $header, 403 'arg2' => $value, 404 ); 405 $i++; 406 } 407 408 $this->form = array( 409 'join' => count($tests) > 1 ? 'allof' : 'anyof', 410 'name' => '', 411 'tests' => $tests, 412 'actions' => array( 413 0 => array('type' => 'fileinto'), 414 1 => array('type' => 'stop'), 415 ), 416 ); 417 } 418 } 301 419 302 420 $this->managesieve_send(); … … 305 423 function managesieve_save() 306 424 { 425 // load localization 426 $this->add_texts('localization/', array('filters','managefilters')); 427 428 // include main js script 429 if ($this->api->output->type == 'html') { 430 $this->include_script('managesieve.js'); 431 } 432 307 433 // Init plugin and handle managesieve connection 308 434 $error = $this->managesieve_start(); … … 597 723 if ($save && $fid !== false) { 598 724 $this->rc->output->show_message('managesieve.filtersaved', 'confirmation'); 599 $this->rc->output->add_script( 600 sprintf("rcmail.managesieve_updatelist('%s', '%s', %d, %d);", 601 isset($new) ? 'add' : 'update', Q($this->form['name']), 602 $fid, $this->form['disabled']), 603 'foot'); 725 if ($this->rc->task != 'mail') { 726 $this->rc->output->add_script( 727 sprintf("rcmail.managesieve_updatelist('%s', '%s', %d, %d);", 728 isset($new) ? 'add' : 'update', Q($this->form['name']), 729 $fid, $this->form['disabled']), 730 'foot'); 731 } 732 else { 733 $this->rc->output->command('managesieve_dialog_close'); 734 $this->rc->output->send('iframe'); 735 } 604 736 } 605 737 else { -
trunk/plugins/managesieve/skins/default/managesieve.css
r4241 r5155 1 /***** Roundcube|Filters styles *****/2 3 4 1 #filterslist 5 2 { … … 169 166 min-width: 740px; 170 167 width: expression(Math.max(740, document.documentElement.clientWidth)+'px'); 168 background-color: #F2F2F2; 171 169 } 172 170 … … 295 293 width: 200px; 296 294 } 295 296 /* fixes for popup window */ 297 298 body.iframe.mail 299 { 300 margin: 0; 301 padding: 0; 302 } 303 304 body.iframe.mail #filter-form 305 { 306 padding: 10px 5px 5px 5px; 307 } -
trunk/plugins/managesieve/skins/default/templates/filteredit.html
r4525 r5155 6 6 <link rel="stylesheet" type="text/css" href="/this/managesieve.css" /> 7 7 </head> 8 <body class="iframe ">8 <body class="iframe<roundcube:exp expression="env:task != 'mail' ? '' : ' mail'" />"> 9 9 10 <roundcube:if condition="env:task != 'mail'" /> 10 11 <div id="filter-title" class="boxtitle"><roundcube:label name="managesieve.filterdef" /></div> 12 <roundcube:endif /> 11 13 12 14 <div id="filter-form" class="boxcontent"> 13 15 <roundcube:object name="filterform" /> 14 16 17 <roundcube:if condition="env:task != 'mail'" /> 15 18 <div id="footer"> 16 19 <div class="footerleft"> … … 22 25 </div> 23 26 </div> 27 <roundcube:endif /> 24 28 25 29 </form> 26 30 </div> 27 31 28 29 32 </body> 30 33 </html>
Note: See TracChangeset
for help on using the changeset viewer.
