Changeset 3460 in subversion
- Timestamp:
- Apr 1, 2010 2:59:30 AM (3 years ago)
- Location:
- trunk/plugins/managesieve
- Files:
-
- 9 edited
-
Changelog (modified) (1 diff)
-
lib/rcube_sieve.php (modified) (3 diffs)
-
localization/en_US.inc (modified) (1 diff)
-
localization/pl_PL.inc (modified) (1 diff)
-
managesieve.js (modified) (5 diffs)
-
managesieve.php (modified) (9 diffs)
-
skins/default/managesieve.css (modified) (2 diffs)
-
skins/default/managesieve_toolbar.png (modified) (previous)
-
skins/default/templates/managesieve.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/managesieve/Changelog
r3454 r3460 1 * version 2.4 [2010-04-01] 2 ----------------------------------------------------------- 1 3 - Fixed bug in DIGEST-MD5 authentication (http://pear.php.net/bugs/bug.php?id=17285) 2 4 - Fixed disabling rules with many tests 3 5 - Small css unification with core 6 - Scripts import/export 4 7 5 8 * version 2.3 [2010-03-18] -
trunk/plugins/managesieve/lib/rcube_sieve.php
r3398 r3460 224 224 225 225 // try to parse from Roundcube format 226 $this->script = new rcube_sieve_script($script, $this->disabled); 226 $this->script = $this->_parse($script); 227 228 $this->current = $name; 229 230 return true; 231 } 232 233 /** 234 * Loads script from text content 235 */ 236 public function load_script($script) 237 { 238 if (!$this->sieve) 239 return $this->_set_error(SIEVE_ERROR_INTERNAL); 240 241 // try to parse from Roundcube format 242 $this->script = $this->_parse($script); 243 } 244 245 /** 246 * Creates rcube_sieve_script object from text script 247 */ 248 private function _parse($txt) 249 { 250 // try to parse from Roundcube format 251 $script = new rcube_sieve_script($txt, $this->disabled); 227 252 228 253 // ... else try to import from different formats 229 if (empty($ this->script->content)) {230 $script = $this->_import_rules($ script);231 $ this->script = new rcube_sieve_script($script, $this->disabled);254 if (empty($script->content)) { 255 $script = $this->_import_rules($txt); 256 $script = new rcube_sieve_script($script, $this->disabled); 232 257 } 233 258 234 259 // replace all elsif with if+stop, we support only ifs 235 foreach ($ this->script->content as $idx => $rule) {236 if (!isset($ this->script->content[$idx+1])237 || preg_match('/^else|elsif$/', $ this->script->content[$idx+1]['type'])) {260 foreach ($script->content as $idx => $rule) { 261 if (!isset($script->content[$idx+1]) 262 || preg_match('/^else|elsif$/', $script->content[$idx+1]['type'])) { 238 263 // 'stop' not found? 239 264 if (!preg_match('/^(stop|vacation)$/', $rule['actions'][count($rule['actions'])-1]['type'])) { 240 $ this->script->content[$idx]['actions'][] = array(265 $script->content[$idx]['actions'][] = array( 241 266 'type' => 'stop' 242 267 ); … … 245 270 } 246 271 247 $this->current = $name; 248 249 return true; 272 return $script; 273 } 274 275 /** 276 * Gets specified script as text 277 */ 278 public function get_script($name) 279 { 280 if (!$this->sieve) 281 return $this->_set_error(SIEVE_ERROR_INTERNAL); 282 283 $content = $this->sieve->getScript($name); 284 285 if (PEAR::isError($content)) 286 return $this->_set_error(SIEVE_ERROR_OTHER); 287 288 return $content; 250 289 } 251 290 … … 267 306 return $this->save_script($name, $content); 268 307 } 269 270 308 271 309 private function _import_rules($script) -
trunk/plugins/managesieve/localization/en_US.inc
r3376 r3460 41 41 $labels['filtersetdel'] = 'Delete current filters set'; 42 42 $labels['filtersetact'] = 'Activate current filters set'; 43 $labels['filtersetget'] = 'Download filters set in text format'; 43 44 $labels['filterdef'] = 'Filter definition'; 44 45 $labels['filtersetname'] = 'Filters set name'; 45 46 $labels['newfilterset'] = 'New filters set'; 46 47 $labels['active'] = 'active'; 47 $labels['copyfromset'] = 'Copy filters from set'; 48 $labels['none'] = '- none -'; 48 $labels['none'] = 'none'; 49 $labels['fromset'] = 'from set'; 50 $labels['fromfile'] = 'from file'; 49 51 $labels['filterdisabled'] = 'Filter disabled'; 50 52 -
trunk/plugins/managesieve/localization/pl_PL.inc
r3376 r3460 51 51 $labels['filtersetact'] = 'Aktywuj bierzÄ 52 52 cy zbiór filtrów'; 53 $labels['filtersetget'] = 'Pobierz bierzÄ 54 cy zbiór filtrów w formacie tekstowym'; 53 55 $labels['filterdef'] = 'Definicja filtra'; 54 $labels['filtersetname'] = 'Nazwa zbioru filtrów';56 $labels['filtersetname'] = 'Nazwa zbioru'; 55 57 $labels['newfilterset'] = 'Nowy zbiór filtrów'; 56 58 $labels['active'] = 'aktywny'; 57 $labels['copyfromset'] = 'Skopiuj filtry ze zbioru'; 58 $labels['none'] = '- brak -'; 59 $labels['none'] = 'brak'; 60 $labels['fromset'] = 'ze zbioru'; 61 $labels['fromfile'] = 'z pliku'; 59 62 $labels['filterdisabled'] = 'Filtr wyÅÄ 60 63 czony'; -
trunk/plugins/managesieve/managesieve.js
r3376 r3460 24 24 rcmail.register_command('plugin.managesieve-setdel', function() { rcmail.managesieve_setdel() }, true); 25 25 rcmail.register_command('plugin.managesieve-setact', function() { rcmail.managesieve_setact() }, true); 26 rcmail.register_command('plugin.managesieve-setget', function() { rcmail.managesieve_setget() }, true); 26 27 27 28 if (rcmail.env.action == 'plugin.managesieve') … … 34 35 'plugin.managesieve-down', false); 35 36 rcmail.enable_command('plugin.managesieve-add', 'plugin.managesieve-setadd', !rcmail.env.sieveconnerror); 36 rcmail.enable_command('plugin.managesieve-set', rcmail.gui_objects.filtersetslist != null); 37 rcmail.enable_command('plugin.managesieve-set', 'plugin.managesieve-setget', 38 rcmail.gui_objects.filtersetslist != null); 37 39 rcmail.enable_command('plugin.managesieve-setact', 38 40 (rcmail.gui_objects.filtersetslist && rcmail.gui_objects.filtersetslist.length > 1 … … 411 413 { 412 414 var script = $(this.gui_objects.filtersetslist).val(); 413 location.href = this.env.comm_path+'&_action=plugin.managesieve&_sid='+script; 415 location.href = this.env.comm_path+'&_action=plugin.managesieve&_set='+script; 416 }; 417 418 // Script download 419 rcube_webmail.prototype.managesieve_setget = function() 420 { 421 var script = $(this.gui_objects.filtersetslist).val(); 422 location.href = this.env.comm_path+'&_action=plugin.managesieve&_act=setget&_set='+script; 414 423 }; 415 424 … … 467 476 }; 468 477 469 470 478 rcube_webmail.prototype.managesieve_reload = function(set) 471 479 { … … 473 481 window.setTimeout(function() { 474 482 location.href = rcmail.env.comm_path + '&_action=plugin.managesieve' 475 + (rcmail.env.reload_set ? '&_s id=' + rcmail.env.reload_set : '')483 + (rcmail.env.reload_set ? '&_set=' + rcmail.env.reload_set : '') 476 484 }, 500); 477 485 }; -
trunk/plugins/managesieve/managesieve.php
r3376 r3460 8 8 * with server using managesieve protocol. Adds Filters tab in Settings. 9 9 * 10 * @version 2. 310 * @version 2.4 11 11 * @author Aleksander 'A.L.E.C' Machniak <alec@alec.pl> 12 12 * … … 80 80 $_SESSION['managesieve_active'] = $active; 81 81 82 if (!empty($_GET['_s id'])) {83 $script_name = get_input_value('_s id', RCUBE_INPUT_GET);82 if (!empty($_GET['_set'])) { 83 $script_name = get_input_value('_set', RCUBE_INPUT_GET); 84 84 } else if (!empty($_SESSION['managesieve_current'])) { 85 85 $script_name = $_SESSION['managesieve_current']; … … 225 225 } 226 226 } 227 else if ($action=='setget') 228 { 229 $script_name = get_input_value('_set', RCUBE_INPUT_GPC); 230 $script = $this->sieve->get_script($script_name); 231 232 if (PEAR::isError($script)) 233 exit; 234 235 $browser = new rcube_browser; 236 237 // send download headers 238 header("Content-Type: application/octet-stream"); 239 header("Content-Length: ".strlen($script)); 240 241 if ($browser->ie) 242 header("Content-Type: application/force-download"); 243 if ($browser->ie && $browser->ver < 7) 244 $filename = rawurlencode(abbreviate_string($script_name, 55)); 245 else if ($browser->ie) 246 $filename = rawurlencode($script_name); 247 else 248 $filename = addcslashes($script_name, '\\"'); 249 250 header("Content-Disposition: attachment; filename=\"$filename.txt\""); 251 echo $script; 252 exit; 253 } 227 254 elseif ($action=='ruleadd') 228 255 { … … 256 283 if (!empty($_POST['_newset'])) 257 284 { 258 $name = get_input_value('_name', RCUBE_INPUT_GPC); 259 $copy = get_input_value('_copy', RCUBE_INPUT_GPC); 285 $name = get_input_value('_name', RCUBE_INPUT_POST); 286 $copy = get_input_value('_copy', RCUBE_INPUT_POST); 287 $from = get_input_value('_from', RCUBE_INPUT_POST); 260 288 261 289 if (!$name) … … 263 291 else if (mb_strlen($name)>128) 264 292 $error = 'managesieve.nametoolong'; 265 else if (!$this->sieve->copy($name, $copy)) 293 else if ($from == 'file') { 294 // from file 295 if (is_uploaded_file($_FILES['_file']['tmp_name'])) { 296 $file = file_get_contents($_FILES['_file']['tmp_name']); 297 $file = preg_replace('/\r/', '', $file); 298 // for security don't save script directly 299 // check syntax before, like this... 300 $this->sieve->load_script($file); 301 if (!$this->sieve->save($name)) { 302 $error = 'managesieve.setcreateerror'; 303 } 304 } 305 else { // upload failed 306 $err = $_FILES['_file']['error']; 307 $error = true; 308 if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) { 309 $msg = rcube_label(array('name' => 'filesizeerror', 'vars' => array('size' => 310 show_bytes(parse_bytes(ini_get('upload_max_filesize')))))); 311 } 312 else { 313 $error = 'fileuploaderror'; 314 } 315 } 316 } 317 else if (!$this->sieve->copy($name, $from == 'set' ? $copy : '')) { 266 318 $error = 'managesieve.setcreateerror'; 267 319 } 320 268 321 if (!$error) { 269 322 $this->rc->output->show_message('managesieve.setcreated', 'confirmation'); 270 323 $this->rc->output->command('parent.managesieve_reload', $name); 271 // $this->rc->session->remove('managesieve_current'); 324 } else if ($msg) { 325 $this->rc->output->command('display_message', $msg, 'error'); 272 326 } else { 273 327 $this->rc->output->show_message($error, 'error'); … … 597 651 $attrib['id'] = 'rcmfiltersetform'; 598 652 599 $out = '<form name="filtersetform" action="./" method="post" >'."\n";653 $out = '<form name="filtersetform" action="./" method="post" enctype="multipart/form-data">'."\n"; 600 654 601 655 $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $this->rc->task)); … … 606 660 $out .= $hiddenfields->show(); 607 661 608 $name = get_input_value('_name', RCUBE_INPUT_GPC); 609 $copy = get_input_value('_copy', RCUBE_INPUT_GPC); 662 $name = get_input_value('_name', RCUBE_INPUT_POST); 663 $copy = get_input_value('_copy', RCUBE_INPUT_POST); 664 $selected = get_input_value('_from', RCUBE_INPUT_POST); 610 665 611 666 $table = new html_table(array('cols' => 2)); … … 618 673 $table->add(null, $input_name->show($name)); 619 674 675 $from ='<div class="itemlist">'; 676 $from .= '<input type="radio" id="from_none" name="_from" value="none"' 677 .(!$selected || $selected=='none' ? ' checked="checked"' : '').'></input>'; 678 $from .= sprintf('<label for="%s">%s</label> ', 'from_none', Q($this->gettext('none'))); 679 620 680 // filters set list 621 681 $list = $this->sieve->get_scripts(); … … 626 686 asort($list, SORT_LOCALE_STRING); 627 687 628 $select->add($this->gettext('none'), '');629 688 foreach($list as $set) 630 689 $select->add($set . ($set == $active ? ' ('.$this->gettext('active').')' : ''), $set); 631 690 632 $table->add('title', '<label>'.$this->gettext('copyfromset').':</label>'); 633 $table->add(null, $select->show($copy)); 691 $from .= '<br /><input type="radio" id="from_set" name="_from" value="set"' 692 .($selected=='set' ? ' checked="checked"' : '').'></input>'; 693 $from .= sprintf('<label for="%s">%s:</label> ', 'from_set', Q($this->gettext('fromset'))); 694 $from .= $select->show($copy); 695 696 // script upload box 697 $upload = new html_inputfield(array('name' => '_file', 'id' => '_file', 'size' => 30, 698 'type' => 'file', 'class' => ($this->errors['name'] ? 'error' : ''))); 699 700 $from .= '<br /><input type="radio" id="from_file" name="_from" value="file"' 701 .($selected=='file' ? ' checked="checked"' : '').'></input>'; 702 $from .= sprintf('<label for="%s">%s:</label> ', 'from_file', Q($this->gettext('fromfile'))); 703 $from .= $upload->show(); 704 $from .= '</div>'; 705 706 $table->add('title', '<label>'.$this->gettext('filters').':</label>'); 707 $table->add(null, $from); 634 708 635 709 $out .= $table->show(); -
trunk/plugins/managesieve/skins/default/managesieve.css
r3422 r3460 132 132 } 133 133 134 #filtersetsbuttons a.setget { 135 background-position: -224px 0px; 136 } 137 138 #filtersetsbuttons a.setgetsel { 139 background-position: -224px -32px; 140 } 141 134 142 #filtersetselect 135 143 { 136 144 position: absolute; 137 left: 3 60px;145 left: 375px; 138 146 top: 90px; 139 147 } … … 272 280 float: right; 273 281 } 282 283 div .itemlist 284 { 285 line-height: 25px; 286 } 287 288 div .itemlist input 289 { 290 vertical-align: middle; 291 } -
trunk/plugins/managesieve/skins/default/templates/managesieve.html
r3376 r3460 33 33 <roundcube:button command="plugin.managesieve-setdel" type="link" class="buttonPas setdel" classSel="button setdelsel" classAct="button setdel" title="managesieve.filtersetdel" content=" " /> 34 34 <roundcube:button command="plugin.managesieve-setact" type="link" class="buttonPas setset" classSel="button setsetsel" classAct="button setset" title="managesieve.filtersetact" content=" " /> 35 <roundcube:button command="plugin.managesieve-setget" type="link" class="buttonPas setget" classSel="button setgetsel" classAct="button setget" title="managesieve.filtersetget" content=" " /> 35 36 </div> 36 37 <div id="filtersetselect">
Note: See TracChangeset
for help on using the changeset viewer.
