Ejemplo n.º 1
0
 /**
  * Generate the form for recurrence settings
  */
 public function recurrence_form($attrib = array())
 {
     switch ($attrib['part']) {
         // frequency selector
         case 'frequency':
             $select = new html_select(array('name' => 'frequency', 'id' => 'edit-recurrence-frequency'));
             $select->add($this->gettext('never'), '');
             $select->add($this->gettext('daily'), 'DAILY');
             $select->add($this->gettext('weekly'), 'WEEKLY');
             $select->add($this->gettext('monthly'), 'MONTHLY');
             $select->add($this->gettext('yearly'), 'YEARLY');
             $select->add($this->gettext('rdate'), 'RDATE');
             $html = html::label('edit-recurrence-frequency', $this->gettext('frequency')) . $select->show('');
             break;
             // daily recurrence
         // daily recurrence
         case 'daily':
             $select = $this->interval_selector(array('name' => 'interval', 'class' => 'edit-recurrence-interval', 'id' => 'edit-recurrence-interval-daily'));
             $html = html::div($attrib, html::label('edit-recurrence-interval-daily', $this->gettext('every')) . $select->show(1) . html::span('label-after', $this->gettext('days')));
             break;
             // weekly recurrence form
         // weekly recurrence form
         case 'weekly':
             $select = $this->interval_selector(array('name' => 'interval', 'class' => 'edit-recurrence-interval', 'id' => 'edit-recurrence-interval-weekly'));
             $html = html::div($attrib, html::label('edit-recurrence-interval-weekly', $this->gettext('every')) . $select->show(1) . html::span('label-after', $this->gettext('weeks')));
             // weekday selection
             $daymap = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
             $checkbox = new html_checkbox(array('name' => 'byday', 'class' => 'edit-recurrence-weekly-byday'));
             $first = $this->rc->config->get('calendar_first_day', 1);
             for ($weekdays = '', $j = $first; $j <= $first + 6; $j++) {
                 $d = $j % 7;
                 $weekdays .= html::label(array('class' => 'weekday'), $checkbox->show('', array('value' => strtoupper(substr($daymap[$d], 0, 2)))) . $this->gettext($daymap[$d])) . ' ';
             }
             $html .= html::div($attrib, html::label(null, $this->gettext('bydays')) . $weekdays);
             break;
             // monthly recurrence form
         // monthly recurrence form
         case 'monthly':
             $select = $this->interval_selector(array('name' => 'interval', 'class' => 'edit-recurrence-interval', 'id' => 'edit-recurrence-interval-monthly'));
             $html = html::div($attrib, html::label('edit-recurrence-interval-monthly', $this->gettext('every')) . $select->show(1) . html::span('label-after', $this->gettext('months')));
             $checkbox = new html_checkbox(array('name' => 'bymonthday', 'class' => 'edit-recurrence-monthly-bymonthday'));
             for ($monthdays = '', $d = 1; $d <= 31; $d++) {
                 $monthdays .= html::label(array('class' => 'monthday'), $checkbox->show('', array('value' => $d)) . $d);
                 $monthdays .= $d % 7 ? ' ' : html::br();
             }
             // rule selectors
             $radio = new html_radiobutton(array('name' => 'repeatmode', 'class' => 'edit-recurrence-monthly-mode'));
             $table = new html_table(array('cols' => 2, 'border' => 0, 'cellpadding' => 0, 'class' => 'formtable'));
             $table->add('label', html::label(null, $radio->show('BYMONTHDAY', array('value' => 'BYMONTHDAY')) . ' ' . $this->gettext('each')));
             $table->add(null, $monthdays);
             $table->add('label', html::label(null, $radio->show('', array('value' => 'BYDAY')) . ' ' . $this->gettext('onevery')));
             $table->add(null, $this->rrule_selectors($attrib['part']));
             $html .= html::div($attrib, $table->show());
             break;
             // annually recurrence form
         // annually recurrence form
         case 'yearly':
             $select = $this->interval_selector(array('name' => 'interval', 'class' => 'edit-recurrence-interval', 'id' => 'edit-recurrence-interval-yearly'));
             $html = html::div($attrib, html::label('edit-recurrence-interval-yearly', $this->gettext('every')) . $select->show(1) . html::span('label-after', $this->gettext('years')));
             // month selector
             $monthmap = array('', 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec');
             $checkbox = new html_checkbox(array('name' => 'bymonth', 'class' => 'edit-recurrence-yearly-bymonth'));
             for ($months = '', $m = 1; $m <= 12; $m++) {
                 $months .= html::label(array('class' => 'month'), $checkbox->show(null, array('value' => $m)) . $this->gettext($monthmap[$m]));
                 $months .= $m % 4 ? ' ' : html::br();
             }
             $html .= html::div($attrib + array('id' => 'edit-recurrence-yearly-bymonthblock'), $months);
             // day rule selection
             $html .= html::div($attrib, html::label(null, $this->gettext('onevery')) . $this->rrule_selectors($attrib['part'], '---'));
             break;
             // end of recurrence form
         // end of recurrence form
         case 'until':
             $radio = new html_radiobutton(array('name' => 'repeat', 'class' => 'edit-recurrence-until'));
             $select = $this->interval_selector(array('name' => 'times', 'id' => 'edit-recurrence-repeat-times'));
             $input = new html_inputfield(array('name' => 'untildate', 'id' => 'edit-recurrence-enddate', 'size' => "10"));
             $html = html::div('line first', html::label(null, $radio->show('', array('value' => '', 'id' => 'edit-recurrence-repeat-forever')) . ' ' . $this->gettext('forever')));
             $forntimes = $this->gettext(array('name' => 'forntimes', 'vars' => array('nr' => '%s')));
             $html .= html::div('line', $radio->show('', array('value' => 'count', 'id' => 'edit-recurrence-repeat-count', 'aria-label' => sprintf($forntimes, 'N'))) . ' ' . sprintf($forntimes, $select->show(1)));
             $html .= html::div('line', $radio->show('', array('value' => 'until', 'id' => 'edit-recurrence-repeat-until', 'aria-label' => $this->gettext('untilenddate'))) . ' ' . $this->gettext('untildate') . ' ' . $input->show('', array('aria-label' => $this->gettext('untilenddate'))));
             $html = html::div($attrib, html::label(null, ucfirst($this->gettext('recurrencend'))) . $html);
             break;
         case 'rdate':
             $ul = html::tag('ul', array('id' => 'edit-recurrence-rdates'), '');
             $input = new html_inputfield(array('name' => 'rdate', 'id' => 'edit-recurrence-rdate-input', 'size' => "10"));
             $button = new html_inputfield(array('type' => 'button', 'class' => 'button add', 'value' => $this->gettext('addrdate')));
             $html .= html::div($attrib, $ul . html::div('inputform', $input->show() . $button->show()));
             break;
     }
     return $html;
 }
Ejemplo n.º 2
0
 /**
  * Generate the form for recurrence settings
  */
 function recurring_event_warning($attrib = array())
 {
     $attrib['id'] = 'edit-recurring-warning';
     $radio = new html_radiobutton(array('name' => '_savemode', 'class' => 'edit-recurring-savemode'));
     $form = html::label(null, $radio->show('', array('value' => 'current')) . $this->cal->gettext('currentevent')) . ' ' . html::label(null, $radio->show('', array('value' => 'future')) . $this->cal->gettext('futurevents')) . ' ' . html::label(null, $radio->show('all', array('value' => 'all')) . $this->cal->gettext('allevents')) . ' ' . html::label(null, $radio->show('', array('value' => 'new')) . $this->cal->gettext('saveasnew'));
     return html::div($attrib, html::div('message', html::span('ui-icon ui-icon-alert', '') . $this->cal->gettext('changerecurringeventwarning')) . html::div('savemode', $form));
 }
Ejemplo n.º 3
0
 /**
  * Creates ACL rights form (user part)
  *
  * @param array $attrib Template object attributes
  *
  * @return string HTML Content
  */
 function templ_user($attrib)
 {
     // Create username input
     $attrib['name'] = 'acluser';
     $textfield = new html_inputfield($attrib);
     $fields['user'] = html::label(array('for' => 'iduser'), $this->gettext('username')) . ' ' . $textfield->show();
     // Add special entries
     if (!empty($this->specials)) {
         foreach ($this->specials as $key) {
             $fields[$key] = html::label(array('for' => 'id' . $key), $this->gettext($key));
         }
     }
     $this->rc->output->set_env('acl_specials', $this->specials);
     // Create list with radio buttons
     if (count($fields) > 1) {
         $ul = '';
         $radio = new html_radiobutton(array('name' => 'usertype'));
         foreach ($fields as $key => $val) {
             $ul .= html::tag('li', null, $radio->show($key == 'user' ? 'user' : '', array('value' => $key, 'id' => 'id' . $key)) . $val);
         }
         $out = html::tag('ul', array('id' => 'usertype', 'class' => $attrib['class']), $ul, html::$common_attrib);
     } else {
         $out = $fields['user'];
     }
     return $out;
 }
Ejemplo n.º 4
0
 private function _prefs_block($part, $attrib)
 {
     $rcmail = rcube::get_instance();
     $no_override = array_flip($rcmail->config->get('sauserprefs_dont_override'));
     $locale_info = localeconv();
     switch ($part) {
         // General tests
         case 'general':
             $out = '';
             $data = '';
             $table = new html_table(array('class' => 'generalprefstable', 'cols' => 2));
             if (!isset($no_override['required_hits'])) {
                 $field_id = 'rcmfd_spamthres';
                 $input_spamthres = new html_select(array('name' => '_spamthres', 'id' => $field_id));
                 $input_spamthres->add($this->gettext('defaultscore'), '');
                 $decPlaces = 0;
                 if ($rcmail->config->get('sauserprefs_score_inc') - (int) $rcmail->config->get('sauserprefs_score_inc') > 0) {
                     $decPlaces = strlen($rcmail->config->get('sauserprefs_score_inc') - (int) $rcmail->config->get('sauserprefs_score_inc')) - 2;
                 }
                 $score_found = false;
                 for ($i = 1; $i <= 10; $i = $i + $rcmail->config->get('sauserprefs_score_inc')) {
                     $input_spamthres->add(number_format($i, $decPlaces, $locale_info['decimal_point'], ''), number_format($i, $decPlaces, '.', ''));
                     if (!$score_found && $this->user_prefs['required_hits'] && (double) $this->user_prefs['required_hits'] == (double) $i) {
                         $score_found = true;
                     }
                 }
                 if (!$score_found && $this->user_prefs['required_hits']) {
                     $input_spamthres->add(str_replace('%s', $this->user_prefs['required_hits'], $this->gettext('otherscore')), (double) $this->user_prefs['required_hits']);
                 }
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('spamthres'))));
                 $table->add(null, $input_spamthres->show(number_format($this->user_prefs['required_hits'], $decPlaces, '.', '')));
                 $table->add(array('colspan' => 2), rcmail::Q($this->gettext('spamthresexp')));
             }
             if (!isset($no_override['rewrite_header Subject'])) {
                 $field_id = 'rcmfd_spamsubject';
                 $input_spamsubject = new html_inputfield(array('name' => '_spamsubject', 'id' => $field_id, 'value' => $this->user_prefs['rewrite_header Subject'], 'style' => 'width:200px;'));
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('spamsubject'))));
                 $table->add(null, $input_spamsubject->show());
                 $table->add('title', "&nbsp;");
                 $table->add(null, rcmail::Q($this->gettext('spamsubjectblank')));
             }
             if ($table->size() > 0) {
                 $out .= html::tag('fieldset', null, html::tag('legend', null, rcmail::Q($this->gettext('mainoptions'))) . $table->show());
             }
             if (!isset($no_override['ok_languages']) || !isset($no_override['ok_locales'])) {
                 $data = html::p(null, rcmail::Q($this->gettext('spamlangexp')));
                 $table = new html_table(array('class' => 'langprefstable', 'cols' => 1));
                 $select_all = $this->api->output->button(array('command' => 'plugin.sauserprefs.select_all_langs', 'type' => 'link', 'label' => 'all'));
                 $select_none = $this->api->output->button(array('command' => 'plugin.sauserprefs.select_no_langs', 'type' => 'link', 'label' => 'none'));
                 $select_invert = $this->api->output->button(array('command' => 'plugin.sauserprefs.select_invert_langs', 'type' => 'link', 'label' => 'invert'));
                 $table->add(array('id' => 'listcontrols'), $this->gettext('select') . ":&nbsp;&nbsp;" . $select_all . "&nbsp;&nbsp;" . $select_invert . "&nbsp;&nbsp;" . $select_none);
                 $lang_table = new html_table(array('id' => 'spam-langs-table', 'class' => 'records-table', 'cellspacing' => '0', 'cols' => 2));
                 $lang_table->add_header(array('colspan' => 2), $this->gettext('language'));
                 if (!isset($no_override['ok_locales'])) {
                     if ($this->user_prefs['ok_locales'] == "all") {
                         $ok_locales = $this->sa_locales;
                     } else {
                         $ok_locales = explode(" ", $this->user_prefs['ok_locales']);
                     }
                 } else {
                     $ok_locales = array();
                 }
                 if (!isset($no_override['ok_languages'])) {
                     if ($this->user_prefs['ok_languages'] == "all") {
                         $ok_languages = array_keys($rcmail->config->get('sauserprefs_languages'));
                     } else {
                         $ok_languages = explode(" ", $this->user_prefs['ok_languages']);
                     }
                 } else {
                     $tmp_array = $rcmail->config->get('sauserprefs_languages');
                     $rcmail->config->set('sauserprefs_languages', array_intersect_key($tmp_array, array_flip($this->sa_locales)));
                     $ok_languages = array();
                 }
                 $i = 0;
                 $locales_langs = array_merge($ok_locales, $ok_languages);
                 foreach ($rcmail->config->get('sauserprefs_languages') as $lang_code => $name) {
                     if (in_array($lang_code, $locales_langs)) {
                         $button = $this->api->output->button(array('command' => 'plugin.sauserprefs.message_lang', 'prop' => $lang_code, 'type' => 'link', 'class' => 'enabled', 'id' => 'spam_lang_' . $i, 'title' => 'sauserprefs.enabled', 'content' => ' '));
                     } else {
                         $button = $this->api->output->button(array('command' => 'plugin.sauserprefs.message_lang', 'prop' => $lang_code, 'type' => 'link', 'class' => 'disabled', 'id' => 'spam_lang_' . $i, 'title' => 'sauserprefs.disabled', 'content' => ' '));
                     }
                     $input_spamlang = new html_checkbox(array('style' => 'display: none;', 'name' => '_spamlang[]', 'value' => $lang_code));
                     $lang_table->add('lang', $name);
                     $lang_table->add('tick', $button . $input_spamlang->show(in_array($lang_code, $locales_langs) ? $lang_code : ''));
                     $i++;
                 }
                 $table->add('scroller', html::div(array('id' => 'spam-langs-cont'), $lang_table->show()));
                 $out .= html::tag('fieldset', null, html::tag('legend', null, rcmail::Q($this->gettext('langoptions'))) . $data . $table->show());
             }
             break;
             // Header settings
         // Header settings
         case 'headers':
             $data = html::p(null, rcmail::Q($this->gettext('headersexp')));
             $table = new html_table(array('class' => 'headersprefstable', 'cols' => 3));
             if (!isset($no_override['fold_headers'])) {
                 $help_button = html::img(array('class' => $imgclass, 'src' => $attrib['helpicon'], 'alt' => $this->gettext('sieveruleheaders'), 'border' => 0, 'style' => 'margin-left: 4px;'));
                 $help_button = html::a(array('name' => '_headerhlp', 'href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sauserprefs_help("fold_help");', 'title' => $this->gettext('help')), $help_button);
                 $field_id = 'rcmfd_spamfoldheaders';
                 $input_spamreport = new html_checkbox(array('name' => '_spamfoldheaders', 'id' => $field_id, 'value' => '1'));
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('foldheaders'))));
                 $table->add(null, $input_spamreport->show($this->user_prefs['fold_headers']));
                 $table->add('help', $help_button);
                 $table->set_row_attribs(array('id' => 'fold_help', 'style' => 'display: none;'));
                 $table->add(array('colspan' => '3'), rcmail::Q($this->gettext('foldhelp')));
             }
             if (!isset($no_override['add_header all Level'])) {
                 $help_button = html::img(array('class' => $imgclass, 'src' => $attrib['helpicon'], 'alt' => $this->gettext('sieveruleheaders'), 'border' => 0, 'style' => 'margin-left: 4px;'));
                 $help_button = html::a(array('name' => '_headerhlp', 'href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sauserprefs_help("level_help");', 'title' => $this->gettext('help')), $help_button);
                 if ($this->user_prefs['remove_header all'] != 'Level') {
                     $enabled = "1";
                     $char = $this->user_prefs['add_header all Level'];
                     $char = substr($char, 7, 1);
                 } else {
                     $enabled = "0";
                     $char = "*";
                 }
                 $field_id = 'rcmfd_spamlevelstars';
                 $input_spamreport = new html_checkbox(array('name' => '_spamlevelstars', 'id' => $field_id, 'value' => '1', 'onchange' => rcmail_output::JS_OBJECT_NAME . '.sauserprefs_toggle_level_char(this)'));
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('spamlevelstars'))));
                 $table->add(null, $input_spamreport->show($enabled));
                 $table->add('help', $help_button);
                 $table->set_row_attribs(array('id' => 'level_help', 'style' => 'display: none;'));
                 $table->add(array('colspan' => '3'), rcmail::Q($this->gettext('levelhelp')));
                 $field_id = 'rcmfd_spamlevelchar';
                 $input_spamsubject = new html_inputfield(array('name' => '_spamlevelchar', 'id' => $field_id, 'value' => $char, 'style' => 'width:20px;', 'disabled' => $enabled ? 0 : 1));
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('spamlevelchar'))));
                 $table->add(null, $input_spamsubject->show());
                 $table->add('help', '&nbsp;');
             }
             $out = html::tag('fieldset', null, html::tag('legend', null, rcmail::Q($this->gettext('mainoptions'))) . $data . $table->show());
             break;
             // Test settings
         // Test settings
         case 'tests':
             $data = html::p(null, rcmail::Q($this->gettext('spamtestssexp')));
             $table = new html_table(array('class' => 'testsprefstable', 'cols' => 3));
             if (!isset($no_override['use_razor1'])) {
                 $help_button = html::img(array('class' => $imgclass, 'src' => $attrib['helpicon'], 'alt' => $this->gettext('sieveruleheaders'), 'border' => 0, 'style' => 'margin-left: 4px;'));
                 $help_button = html::a(array('name' => '_headerhlp', 'href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sauserprefs_help("raz1_help");', 'title' => $this->gettext('help')), $help_button);
                 $field_id = 'rcmfd_spamuserazor1';
                 $input_spamtest = new html_checkbox(array('name' => '_spamuserazor1', 'id' => $field_id, 'value' => '1'));
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('userazor1'))));
                 $table->add(null, $input_spamtest->show($this->user_prefs['use_razor1']));
                 $table->add('help', $help_button);
                 $table->set_row_attribs(array('id' => 'raz1_help', 'style' => 'display: none;'));
                 $table->add(array('colspan' => '3'), rcmail::Q($this->gettext('raz1help')));
             }
             if (!isset($no_override['use_razor2'])) {
                 $help_button = html::img(array('class' => $imgclass, 'src' => $attrib['helpicon'], 'alt' => $this->gettext('sieveruleheaders'), 'border' => 0, 'style' => 'margin-left: 4px;'));
                 $help_button = html::a(array('name' => '_headerhlp', 'href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sauserprefs_help("raz2_help");', 'title' => $this->gettext('help')), $help_button);
                 $field_id = 'rcmfd_spamuserazor2';
                 $input_spamtest = new html_checkbox(array('name' => '_spamuserazor2', 'id' => $field_id, 'value' => '1'));
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('userazor2'))));
                 $table->add(null, $input_spamtest->show($this->user_prefs['use_razor2']));
                 $table->add('help', $help_button);
                 $table->set_row_attribs(array('id' => 'raz2_help', 'style' => 'display: none;'));
                 $table->add(array('colspan' => '3'), rcmail::Q($this->gettext('raz2help')));
             }
             if (!isset($no_override['use_pyzor'])) {
                 $help_button = html::img(array('class' => $imgclass, 'src' => $attrib['helpicon'], 'alt' => $this->gettext('sieveruleheaders'), 'border' => 0, 'style' => 'margin-left: 4px;'));
                 $help_button = html::a(array('name' => '_headerhlp', 'href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sauserprefs_help("pyz_help");', 'title' => $this->gettext('help')), $help_button);
                 $field_id = 'rcmfd_spamusepyzor';
                 $input_spamtest = new html_checkbox(array('name' => '_spamusepyzor', 'id' => $field_id, 'value' => '1'));
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('usepyzor'))));
                 $table->add(null, $input_spamtest->show($this->user_prefs['use_pyzor']));
                 $table->add('help', $help_button);
                 $table->set_row_attribs(array('id' => 'pyz_help', 'style' => 'display: none;'));
                 $table->add(array('colspan' => '3'), rcmail::Q($this->gettext('pyzhelp')));
             }
             if (!isset($no_override['use_dcc'])) {
                 $help_button = html::img(array('class' => $imgclass, 'src' => $attrib['helpicon'], 'alt' => $this->gettext('sieveruleheaders'), 'border' => 0, 'style' => 'margin-left: 4px;'));
                 $help_button = html::a(array('name' => '_headerhlp', 'href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sauserprefs_help("dcc_help");', 'title' => $this->gettext('help')), $help_button);
                 $field_id = 'rcmfd_spamusedcc';
                 $input_spamtest = new html_checkbox(array('name' => '_spamusedcc', 'id' => $field_id, 'value' => '1'));
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('usedcc'))));
                 $table->add(null, $input_spamtest->show($this->user_prefs['use_dcc']));
                 $table->add('help', $help_button);
                 $table->set_row_attribs(array('id' => 'dcc_help', 'style' => 'display: none;'));
                 $table->add(array('colspan' => '3'), rcmail::Q($this->gettext('dcchelp')));
             }
             if (!isset($no_override['skip_rbl_checks'])) {
                 $help_button = html::img(array('class' => $imgclass, 'src' => $attrib['helpicon'], 'alt' => $this->gettext('sieveruleheaders'), 'border' => 0, 'style' => 'margin-left: 4px;'));
                 $help_button = html::a(array('name' => '_headerhlp', 'href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sauserprefs_help("rbl_help");', 'title' => $this->gettext('help')), $help_button);
                 $field_id = 'rcmfd_spamskiprblchecks';
                 $enabled = $this->user_prefs['skip_rbl_checks'] == "1" ? "0" : "1";
                 $input_spamtest = new html_checkbox(array('name' => '_spamskiprblchecks', 'id' => $field_id, 'value' => '1'));
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('skiprblchecks'))));
                 $table->add(null, $input_spamtest->show($enabled));
                 $table->add('help', $help_button);
                 $table->set_row_attribs(array('id' => 'rbl_help', 'style' => 'display: none;'));
                 $table->add(array('colspan' => '3'), rcmail::Q($this->gettext('rblhelp')));
             }
             $out = html::tag('fieldset', null, html::tag('legend', null, rcmail::Q($this->gettext('mainoptions'))) . $data . $table->show());
             break;
             // Bayes settings
         // Bayes settings
         case 'bayes':
             $data = html::p(null, rcmail::Q($this->gettext('bayeshelp')));
             $table = new html_table(array('class' => 'bayesprefstable', 'cols' => 3));
             if (!isset($no_override['use_bayes'])) {
                 $help_button = html::img(array('class' => $imgclass, 'src' => $attrib['helpicon'], 'alt' => $this->gettext('sieveruleheaders'), 'border' => 0, 'style' => 'margin-left: 4px;'));
                 $help_button = html::a(array('name' => '_headerhlp', 'href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sauserprefs_help("bayes_help");', 'title' => $this->gettext('help')), $help_button);
                 $field_id = 'rcmfd_spamusebayes';
                 $input_spamtest = new html_checkbox(array('name' => '_spamusebayes', 'id' => $field_id, 'value' => '1', 'onchange' => rcmail_output::JS_OBJECT_NAME . '.sauserprefs_toggle_bayes(this)'));
                 if ($rcmail->config->get('sauserprefs_bayes_delete', false)) {
                     $delete_link = "&nbsp;&nbsp;&nbsp;" . html::span(array('id' => 'listcontrols'), $this->api->output->button(array('command' => 'plugin.sauserprefs.purge_bayes', 'type' => 'link', 'label' => 'sauserprefs.purgebayes', 'title' => 'sauserprefs.purgebayesexp')));
                 }
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('usebayes'))));
                 $table->add(null, $input_spamtest->show($this->user_prefs['use_bayes']) . $delete_link);
                 $table->add('help', '&nbsp;');
                 $table->set_row_attribs(array('id' => 'bayes_help', 'style' => 'display: none;'));
                 $table->add(array('colspan' => '3'), rcmail::Q($this->gettext('bayeshelp')));
             }
             if (!isset($no_override['use_bayes_rules'])) {
                 $help_button = html::img(array('class' => $imgclass, 'src' => $attrib['helpicon'], 'alt' => $this->gettext('sieveruleheaders'), 'border' => 0, 'style' => 'margin-left: 4px;'));
                 $help_button = html::a(array('name' => '_headerhlp', 'href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sauserprefs_help("bayesrules_help");', 'title' => $this->gettext('help')), $help_button);
                 $field_id = 'rcmfd_spambayesrules';
                 $input_spamtest = new html_checkbox(array('name' => '_spambayesrules', 'id' => $field_id, 'value' => '1', 'disabled' => $this->user_prefs['use_bayes'] ? 0 : 1));
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('bayesrules'))));
                 $table->add(null, $input_spamtest->show($this->user_prefs['use_bayes_rules']));
                 $table->add('help', $help_button);
                 $table->set_row_attribs(array('id' => 'bayesrules_help', 'style' => 'display: none;'));
                 $table->add(array('colspan' => '3'), rcmail::Q($this->gettext('bayesruleshlp')));
             }
             if (!isset($no_override['bayes_auto_learn'])) {
                 $help_button = html::img(array('class' => $imgclass, 'src' => $attrib['helpicon'], 'alt' => $this->gettext('sieveruleheaders'), 'border' => 0, 'style' => 'margin-left: 4px;'));
                 $help_button = html::a(array('name' => '_headerhlp', 'href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sauserprefs_help("bayesauto_help");', 'title' => $this->gettext('help')), $help_button);
                 $field_id = 'rcmfd_spambayesautolearn';
                 $input_spamtest = new html_checkbox(array('name' => '_spambayesautolearn', 'id' => $field_id, 'value' => '1', 'onchange' => rcmail_output::JS_OBJECT_NAME . '.sauserprefs_toggle_bayes_auto(this)', 'disabled' => $this->user_prefs['use_bayes'] ? 0 : 1));
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('bayesautolearn'))));
                 $table->add(null, $input_spamtest->show($this->user_prefs['bayes_auto_learn']));
                 $table->add('help', $help_button);
                 $table->set_row_attribs(array('id' => 'bayesauto_help', 'style' => 'display: none;'));
                 $table->add(array('colspan' => '3'), rcmail::Q($this->gettext('bayesautohelp')));
             }
             if ($table->size() > 0) {
                 $out = html::tag('fieldset', null, html::tag('legend', null, rcmail::Q($this->gettext('mainoptions'))) . $table->show());
             }
             $table = new html_table(array('class' => 'bayesprefstable', 'cols' => 2));
             $data = "";
             if (!isset($no_override['bayes_auto_learn_threshold_nonspam'])) {
                 $field_id = 'rcmfd_bayesnonspam';
                 $input_bayesnthres = new html_select(array('name' => '_bayesnonspam', 'id' => $field_id, 'disabled' => !$this->user_prefs['bayes_auto_learn'] || !$this->user_prefs['use_bayes'] ? 1 : 0));
                 $input_bayesnthres->add($this->gettext('defaultscore'), '');
                 $decPlaces = 1;
                 //if ($rcmail->config->get('sauserprefs_score_inc') - (int)$rcmail->config->get('sauserprefs_score_inc') > 0)
                 //	$decPlaces = strlen($rcmail->config->get('sauserprefs_score_inc') - (int)$rcmail->config->get('sauserprefs_score_inc')) - 2;
                 $score_found = false;
                 for ($i = -1; $i <= 1; $i = $i + 0.1) {
                     $input_bayesnthres->add(number_format($i, $decPlaces, $locale_info['decimal_point'], ''), number_format($i, $decPlaces, '.', ''));
                     if (!$score_found && $this->user_prefs['bayes_auto_learn_threshold_nonspam'] && (double) $this->user_prefs['bayes_auto_learn_threshold_nonspam'] == (double) $i) {
                         $score_found = true;
                     }
                 }
                 if (!$score_found && $this->user_prefs['bayes_auto_learn_threshold_nonspam']) {
                     $input_bayesnthres->add(str_replace('%s', $this->user_prefs['bayes_auto_learn_threshold_nonspam'], $this->gettext('otherscore')), (double) $this->user_prefs['bayes_auto_learn_threshold_nonspam']);
                 }
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('bayesnonspam'))));
                 $table->add(null, $input_bayesnthres->show(number_format($this->user_prefs['bayes_auto_learn_threshold_nonspam'], $decPlaces, '.', '')));
                 $table->add(array('colspan' => '2'), rcmail::Q($this->gettext('bayesnonspamexp')));
             }
             if (!isset($no_override['bayes_auto_learn_threshold_spam'])) {
                 $field_id = 'rcmfd_bayesspam';
                 $input_bayesthres = new html_select(array('name' => '_bayesspam', 'id' => $field_id, 'disabled' => !$this->user_prefs['bayes_auto_learn'] || !$this->user_prefs['use_bayes'] ? 1 : 0));
                 $input_bayesthres->add($this->gettext('defaultscore'), '');
                 $decPlaces = 0;
                 if ($rcmail->config->get('sauserprefs_score_inc') - (int) $rcmail->config->get('sauserprefs_score_inc') > 0) {
                     $decPlaces = strlen($rcmail->config->get('sauserprefs_score_inc') - (int) $rcmail->config->get('sauserprefs_score_inc')) - 2;
                 }
                 $score_found = false;
                 for ($i = 1; $i <= 20; $i = $i + $rcmail->config->get('sauserprefs_score_inc')) {
                     $input_bayesthres->add(number_format($i, $decPlaces, $locale_info['decimal_point'], ''), number_format($i, $decPlaces, '.', ''));
                     if (!$score_found && $this->user_prefs['bayes_auto_learn_threshold_spam'] && (double) $this->user_prefs['bayes_auto_learn_threshold_spam'] == (double) $i) {
                         $score_found = true;
                     }
                 }
                 if (!$score_found && $this->user_prefs['required_hits']) {
                     $input_bayesthres->add(str_replace('%s', $this->user_prefs['bayes_auto_learn_threshold_spam'], $this->gettext('otherscore')), (double) $this->user_prefs['bayes_auto_learn_threshold_spam']);
                 }
                 $table->add('title', html::label($field_id, rcmail::Q($this->gettext('bayesspam'))));
                 $table->add(null, $input_bayesthres->show(number_format($this->user_prefs['bayes_auto_learn_threshold_spam'], $decPlaces, '.', '')));
                 $table->add(array('colspan' => '2'), rcmail::Q($this->gettext('bayesspamexp')));
             }
             if ($table->size() > 0) {
                 $out .= html::tag('fieldset', null, html::tag('legend', null, rcmail::Q($this->gettext('bayesautooptions'))) . $table->show());
             }
             break;
             // Report settings
         // Report settings
         case 'report':
             $data = html::p(null, rcmail::Q($this->gettext('spamreport')));
             $table = new html_table(array('class' => 'reportprefstable', 'cols' => 2));
             if (!isset($no_override['report_safe'])) {
                 $field_id = 'rcmfd_spamreport';
                 $input_spamreport0 = new html_radiobutton(array('name' => '_spamreport', 'id' => $field_id . '_0', 'value' => '0'));
                 $table->add('title', html::label($field_id . '_0', rcmail::Q($this->gettext('spamreport0'))));
                 $table->add(null, $input_spamreport0->show($this->user_prefs['report_safe']));
                 $input_spamreport1 = new html_radiobutton(array('name' => '_spamreport', 'id' => $field_id . '_1', 'value' => '1'));
                 $table->add('title', html::label($field_id . '_1', rcmail::Q($this->gettext('spamreport1'))));
                 $table->add(null, $input_spamreport1->show($this->user_prefs['report_safe']));
                 $data .= $input_spamreport1->show($this->user_prefs['report_safe']) . "&nbsp;" . html::label($field_id . '_1', rcmail::Q($this->gettext('spamreport1'))) . "<br />";
                 $input_spamreport2 = new html_radiobutton(array('name' => '_spamreport', 'id' => $field_id . '_2', 'value' => '2'));
                 $table->add('title', html::label($field_id . '_2', rcmail::Q($this->gettext('spamreport2'))));
                 $table->add(null, $input_spamreport2->show($this->user_prefs['report_safe']));
             }
             $out = html::tag('fieldset', null, html::tag('legend', null, rcmail::Q($this->gettext('mainoptions'))) . $table->show());
             break;
             // Address settings
         // Address settings
         case 'addresses':
             $data = html::p(null, rcmail::Q($this->gettext('whitelistexp')));
             if ($rcmail->config->get('sauserprefs_whitelist_sync')) {
                 $data .= rcmail::Q($this->gettext('autowhitelist')) . "<br /><br />";
             }
             $table = new html_table(array('class' => 'addressprefstable', 'cols' => 4));
             $field_id = 'rcmfd_spamaddressrule';
             $input_spamaddressrule = new html_select(array('name' => '_spamaddressrule', 'id' => $field_id));
             $input_spamaddressrule->add($this->gettext('whitelist_from'), 'whitelist_from');
             $input_spamaddressrule->add($this->gettext('blacklist_from'), 'blacklist_from');
             $input_spamaddressrule->add($this->gettext('whitelist_to'), 'whitelist_to');
             $field_id = 'rcmfd_spamaddress';
             $input_spamaddress = new html_inputfield(array('name' => '_spamaddress', 'id' => $field_id, 'style' => 'width:200px;'));
             $field_id = 'rcmbtn_add_address';
             $button_addaddress = $this->api->output->button(array('command' => 'plugin.sauserprefs.addressrule_add', 'type' => 'input', 'class' => 'button', 'label' => 'sauserprefs.addrule'));
             $table->add('ruletype', $input_spamaddressrule->show());
             $table->add('address', $input_spamaddress->show());
             $table->add('action', $button_addaddress);
             $table->add(null, "&nbsp;");
             $import = $this->api->output->button(array('command' => 'plugin.sauserprefs.import_whitelist', 'type' => 'link', 'label' => 'import', 'title' => 'sauserprefs.importfromaddressbook'));
             $delete_all = $this->api->output->button(array('command' => 'plugin.sauserprefs.whitelist_delete_all', 'type' => 'link', 'label' => 'sauserprefs.deleteall'));
             $table->add(array('colspan' => 4, 'id' => 'listcontrols'), $import . "&nbsp;&nbsp;" . $delete_all);
             $address_table = new html_table(array('id' => 'address-rules-table', 'class' => 'records-table', 'cellspacing' => '0', 'cols' => 3));
             $address_table->add_header('rule', $this->gettext('rule'));
             $address_table->add_header('email', $this->gettext('email'));
             $address_table->add_header('control', '&nbsp;');
             $this->_address_row($address_table, null, null, $attrib);
             if (sizeof($this->user_prefs['addresses']) > 0) {
                 $norules = 'display: none;';
             }
             $address_table->set_row_attribs(array('style' => $norules));
             $address_table->add(array('colspan' => '3'), rcube_utils::rep_specialchars_output($this->gettext('noaddressrules')));
             $this->api->output->set_env('address_rule_count', sizeof($this->user_prefs['addresses']));
             foreach ($this->user_prefs['addresses'] as $address) {
                 $this->_address_row($address_table, $address['field'], $address['value'], $attrib);
             }
             $table->add(array('colspan' => 4, 'class' => 'scroller'), html::div(array('id' => 'address-rules-cont'), $address_table->show()));
             if ($table->size()) {
                 $out = html::tag('fieldset', null, html::tag('legend', null, rcmail::Q($this->gettext('mainoptions'))) . $data . $table->show());
             }
             break;
         default:
             $out = '';
     }
     return $out;
 }
 protected function _vacation_table($ext, $rowid, $defaults, $display, $help_icon)
 {
     $rcmail = rcube::get_instance();
     // begin vacation action
     $vacs_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 3, 'style' => $defaults['method'] == 'vacation' ? '' : 'display: none;'));
     $to_addresses = "";
     $vacto_arr = explode(",", $defaults['vacto']);
     $field_id_vacfrom = 'rcmfd_sievevacfrom_' . $rowid;
     $field_id_vacto = 'rcmfd_sievevacto_' . $rowid;
     if (count($this->identities)) {
         $select_id = new html_select(array('id' => $field_id_vacfrom, 'name' => "_vacfrom[]", 'class' => 'short', 'onchange' => rcmail_output::JS_OBJECT_NAME . '.enable_sig(this);'));
         if ($this->show_vacfrom && in_array('variables', $ext)) {
             $select_id->add($this->gettext('autodetect'), "auto");
         } elseif (!$this->show_vacfrom) {
             $select_id->add($this->gettext('autodetect'), "");
         }
         foreach ($this->identities as $sql_arr) {
             // find currently selected from address
             if ($defaults['vacfrom'] != '' && $defaults['vacfrom'] == rcmail::Q($sql_arr['from']['string'])) {
                 $defaults['vacfrom'] = $sql_arr['identity_id'];
             } elseif ($defaults['vacfrom'] != '' && $defaults['vacfrom'] == $sql_arr['from']['mailto']) {
                 $defaults['vacfrom'] = $sql_arr['identity_id'];
             }
             $select_id->add($sql_arr['from']['disp_string'], $sql_arr['identity_id']);
             $ffield_id = 'rcmfd_vac_' . $rowid . '_' . $sql_arr['identity_id'];
             if ($this->force_vacto) {
                 $curaddress = $sql_arr['email'];
                 $defaults['vacto'] .= (!empty($defaults['vacto']) ? ',' : '') . $sql_arr['email'];
             } else {
                 $curaddress = in_array($sql_arr['email'], $vacto_arr) ? $sql_arr['email'] : "";
             }
             $input_address = new html_checkbox(array('id' => $ffield_id, 'name' => '_vacto_check_' . $rowid . '[]', 'value' => $sql_arr['email'], 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_to(this, ' . $rowid . ')', 'class' => 'checkbox'));
             $to_addresses .= $input_address->show($curaddress) . "&nbsp;" . html::label($ffield_id, rcmail::Q($sql_arr['email'])) . "<br />";
         }
     }
     // deduplicate vacto list
     $tmparr = explode(",", $defaults['vacto']);
     $tmparr = array_unique($tmparr);
     $defaults['vacto'] = implode(",", $tmparr);
     if ($rcmail->config->get('sieverules_limit_vacto', true) && strlen($to_addresses) > 0) {
         $vacfrom_input = $select_id->show($defaults['vacfrom']);
         $input_vacto = new html_hiddenfield(array('id' => $field_id_vacto, 'name' => '_vacto[]', 'value' => $defaults['vacto']));
         $vacto_input = $to_addresses . $input_vacto->show();
         $vac_help = $this->gettext('vactoexp');
     } else {
         $input_vacfrom = new html_inputfield(array('id' => $field_id_vacfrom, 'name' => '_vacfrom[]'));
         $vacfrom_input = $input_vacfrom->show($defaults['vacfrom']);
         $input_vacto = new html_inputfield(array('id' => $field_id_vacto, 'name' => '_vacto[]', 'class' => 'short'));
         $vacto_input = $input_vacto->show($defaults['vacto']);
         $vac_help = $this->gettext('vactoexp') . '<br /><br />' . $this->gettext('vactoexp_adv');
     }
     // from param
     $vacs_table->set_row_attribs(array('class' => $this->show_vacfrom ? 'advanced' : 'disabled', 'style' => $display['vacfrom']));
     $vacs_table->add(null, html::label($field_id_vacfrom, rcmail::Q($this->gettext('from'))));
     $vacs_table->add(null, $vacfrom_input);
     $sig_button = $this->api->output->button(array('command' => 'plugin.sieverules.vacation_sig', 'prop' => $rowid, 'type' => 'link', 'class' => 'vacsig', 'classact' => 'vacsig_act', 'title' => 'insertsignature', 'content' => ' '));
     $vacs_table->add(null, $sig_button);
     // to param
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(array('style' => 'vertical-align: top;'), html::label($field_id_vacto, rcmail::Q($this->gettext('sieveto'))));
     $vacs_table->add(null, $vacto_input);
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(array('style' => 'vertical-align: top;'), $help_button);
     $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $vac_help);
     $field_id = 'rcmfd_sievevacperiod_' . $rowid;
     $input_period = new html_inputfield(array('id' => $field_id, 'name' => '_period[]', 'class' => 'short'));
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('period'))));
     $vacs_table->add(null, $input_period->show($defaults['period']));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . (in_array('vacation-seconds', $ext) ? $vacs_table->size() + 1 : $vacs_table->size()) . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     if (in_array('vacation-seconds', $ext)) {
         $input_periodtype = new html_radiobutton(array('id' => $field_id . '_days', 'name' => '_period_radio_' . $rowid, 'value' => 'days', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_period_type(this, ' . $rowid . ')', 'class' => 'radio'));
         $period_type_show = $input_periodtype->show($defaults['periodtype']) . "&nbsp;" . html::label($field_id . '_days', rcmail::Q($this->gettext('days')));
         $input_periodtype = new html_radiobutton(array('id' => $field_id . '_seconds', 'name' => '_period_radio_' . $rowid, 'value' => 'seconds', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_period_type(this, ' . $rowid . ')', 'class' => 'radio'));
         $period_type_show .= '&nbsp;&nbsp;' . $input_periodtype->show($defaults['periodtype']) . "&nbsp;" . html::label($field_id . '_seconds', rcmail::Q($this->gettext('seconds')));
         $input_periodtype = new html_hiddenfield(array('id' => 'rcmfd_sievevacperiodtype_' . $rowid, 'name' => '_periodtype[]'));
         $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
         $vacs_table->add(null, '&nbsp;');
         $vacs_table->add(null, $period_type_show . $input_periodtype->show($defaults['periodtype']));
         $vacs_table->add(null, '&nbsp;');
     }
     $vacs_table->set_row_attribs(array('style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $this->gettext('vacperiodexp'));
     $field_id = 'rcmfd_sievevachandle_' . $rowid;
     $input_handle = new html_inputfield(array('id' => $field_id, 'name' => '_handle[]', 'class' => 'short'));
     $vacs_table->set_row_attribs(array('class' => $this->show_vachandle ? 'advanced' : 'disabled', 'style' => $display['vachandle']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('sievevachandle'))));
     $vacs_table->add(null, $input_handle->show($defaults['handle']));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $this->gettext('vachandleexp'));
     $field_id = 'rcmfd_sievevacsubject_' . $rowid;
     $input_subject = new html_inputfield(array('id' => $field_id, 'name' => '_subject[]'));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('subject'))));
     $vacs_table->add(array('colspan' => 2), $input_subject->show($defaults['subject']));
     if (in_array('variables', $ext)) {
         $field_id = 'rcmfd_sievevacsubject_orig_' . $rowid;
         $input_origsubject = new html_checkbox(array('id' => $field_id, 'value' => '1', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_osubj(this, ' . $rowid . ')', 'class' => 'checkbox'));
         $input_vacosubj = new html_hiddenfield(array('id' => 'rcmfd_sievevactoh_' . $rowid, 'name' => '_orig_subject[]', 'value' => $defaults['origsubject']));
         $vacs_table->add(null, '&nbsp;');
         $vacs_table->add(array('colspan' => 2), $input_origsubject->show($defaults['origsubject']) . "&nbsp;" . html::label($field_id, rcmail::Q($this->gettext('sieveorigsubj'))) . $input_vacosubj->show());
     }
     $field_id = 'rcmfd_sievevacmag_' . $rowid;
     $input_msg = new html_textarea(array('id' => $field_id, 'name' => '_msg[]', 'rows' => '8', 'cols' => '40', 'class' => $defaults['htmlmsg'] == 1 ? 'mce_editor' : '', 'is_escaped' => $defaults['htmlmsg'] == 1 ? true : null));
     $input_html = new html_checkbox(array('id' => 'rcmfd_sievevachtmlcb_' . $rowid, 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_html(this, ' . $rowid . ', \'' . $field_id . '\');', 'value' => '1', 'class' => 'checkbox'));
     $input_htmlhd = new html_hiddenfield(array('id' => 'rcmfd_sievevachtmlhd_' . $rowid, 'name' => '_htmlmsg[]', 'value' => $defaults['htmlmsg']));
     $vacs_table->add('msg', html::label($field_id, rcmail::Q($this->gettext('message'))));
     $vacs_table->add(array('colspan' => 2), $input_msg->show($defaults['msg']) . html::tag('div', in_array('htmleditor', $rcmail->config->get('dont_override')) ? array('style' => 'display: none;') : null, $input_html->show($defaults['htmlmsg']) . "&nbsp;" . html::label('rcmfd_sievevachtmlcb_' . $rowid, rcmail::Q($this->gettext('htmlmessage')))) . $input_htmlhd->show());
     $field_id = 'rcmfd_sievecharset_' . $rowid;
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('charset'))));
     $vacs_table->add(array('colspan' => 2), $rcmail->output->charset_selector(array('id' => $field_id, 'name' => '_vaccharset[]', 'selected' => $defaults['charset'])));
     $input_advopts = new html_checkbox(array('id' => 'vadvopts' . $rowid, 'name' => '_vadv_opts[]', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'class' => 'checkbox'));
     $vacs_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('vadvopts' . $rowid, rcmail::Q($this->gettext('advancedoptions'))) . $input_advopts->show($display['vacadv'] == '' ? 1 : 0));
     return $vacs_table;
 }
 private function _action_row($ext, $actions_table, $rowid, $action, $attrib, $example)
 {
     $rcmail = rcube::get_instance();
     $help_icon = html::img(array('src' => $attrib['helpicon'], 'alt' => $this->gettext('messagehelp'), 'border' => 0));
     // set default field display
     $display = array('vacadv' => $action['type'] != 'vacation' && $this->force_vacto ? '' : 'display: none;', 'vacfrom' => $this->show_vacfrom ? $display['vacadv'] : 'display: none;', 'vachandle' => $this->show_vachandle ? $display['vacadv'] : 'display: none;', 'noteadv' => 'display: none;', 'eheadadv' => 'display: none;');
     // setup allowed actions
     $allowed_actions = array();
     $config_actions = $rcmail->config->get('sieverules_allowed_actions', array());
     if (in_array('fileinto', $ext) && ($config_actions['fileinto'] || $action['type'] == 'fileinto')) {
         $allowed_actions['fileinto'] = $this->gettext('messagemoveto');
     }
     if (in_array('fileinto', $ext) && in_array('copy', $ext) && ($config_actions['fileinto'] || $action['type'] == 'fileinto')) {
         $allowed_actions['fileinto_copy'] = $this->gettext('messagecopyto');
     }
     if (in_array('vacation', $ext) && ($config_actions['vacation'] || $action['type'] == 'vacation')) {
         $allowed_actions['vacation'] = $this->gettext('messagevacation');
     }
     if (in_array('reject', $ext) && ($config_actions['reject'] || $action['type'] == 'reject')) {
         $allowed_actions['reject'] = $this->gettext('messagereject');
     } elseif (in_array('ereject', $ext) && ($config_actions['reject'] || $action['type'] == 'ereject')) {
         $allowed_actions['ereject'] = $this->gettext('messagereject');
     }
     if (in_array('imap4flags', $ext) && ($config_actions['imapflags'] || $action['type'] == 'imap4flags')) {
         $allowed_actions['imap4flags'] = $this->gettext('messageimapflags');
     } elseif (in_array('imapflags', $ext) && ($config_actions['imapflags'] || $action['type'] == 'imapflags')) {
         $allowed_actions['imapflags'] = $this->gettext('messageimapflags');
     }
     if (in_array('notify', $ext) && ($config_actions['notify'] || $action['type'] == 'notify')) {
         $allowed_actions['notify'] = $this->gettext('messagenotify');
     } elseif (in_array('enotify', $ext) && ($config_actions['notify'] || $action['type'] == 'enotify')) {
         $allowed_actions['enotify'] = $this->gettext('messagenotify');
     }
     if (in_array('editheader', $ext) && ($config_actions['editheaderadd'] || $action['type'] == 'editheaderadd')) {
         $allowed_actions['editheaderadd'] = $this->gettext('addheader');
     }
     if (in_array('editheader', $ext) && ($config_actions['editheaderrem'] || $action['type'] == 'editheaderrem')) {
         $allowed_actions['editheaderrem'] = $this->gettext('removeheader');
     }
     if ($config_actions['redirect'] || $action['type'] == 'redirect') {
         $allowed_actions['redirect'] = $this->gettext('messageredirect');
     }
     if (in_array('copy', $ext) && ($config_actions['redirect'] || $action['type'] == 'redirect_copy')) {
         $allowed_actions['redirect_copy'] = $this->gettext('messageredirectcopy');
     }
     if ($config_actions['keep'] || $action['type'] == 'keep') {
         $allowed_actions['keep'] = $this->gettext('messagekeep');
     }
     if ($config_actions['discard'] || $action['type'] == 'discard') {
         $allowed_actions['discard'] = $this->gettext('messagediscard');
     }
     if ($config_actions['stop'] || $action['type'] == 'stop') {
         $allowed_actions['stop'] = $this->gettext('messagestop');
     }
     // set the default values
     reset($allowed_actions);
     $defaults = array('method' => key($allowed_actions), 'folder' => 'INBOX', 'reject' => '', 'vacto' => null, 'address' => '', 'period' => '', 'periodtype' => '', 'handle' => '', 'subject' => '', 'origsubject' => '', 'msg' => '', 'charset' => RCUBE_CHARSET, 'flags' => '', 'nfrom' => '', 'nimpt' => '', 'nmethod' => '', 'noptions' => '', 'nmsg' => '');
     // set default identity for use in vacation action
     $identity = $rcmail->user->get_identity();
     if ($this->show_vacfrom) {
         $defaults['vacfrom'] = in_array('variables', $ext) ? 'auto' : $identity['email'];
     } else {
         $defaults['vacfrom'] = null;
     }
     // apply current action values
     if ($action['type'] == 'fileinto' || $action['type'] == 'fileinto_copy') {
         $defaults['method'] = $action['type'];
         $defaults['folder'] = $action['target'];
         if ($rcmail->config->get('sieverules_folder_encoding')) {
             $defaults['folder'] = rcube_charset::convert($defaults['folder'], $rcmail->config->get('sieverules_folder_encoding'), 'UTF7-IMAP');
         }
         if ($rcmail->config->get('sieverules_folder_delimiter')) {
             $defaults['folder'] = str_replace($rcmail->config->get('sieverules_folder_delimiter'), $rcmail->storage->get_hierarchy_delimiter(), $defaults['folder']);
         }
         $defaults['folder'] = $rcmail->config->get('sieverules_include_imap_root', true) ? $defaults['folder'] : $rcmail->storage->mod_folder($defaults['folder'], 'IN');
     } elseif ($action['type'] == 'reject' || $action['type'] == 'ereject') {
         $defaults['method'] = $action['type'];
         $defaults['reject'] = $action['target'];
     } elseif ($action['type'] == 'vacation') {
         $defaults['method'] = 'vacation';
         if (isset($action['seconds'])) {
             $defaults['period'] = $action['seconds'];
             $defaults['periodtype'] = 'seconds';
         } else {
             $defaults['period'] = $action['days'];
             $defaults['periodtype'] = 'days';
         }
         $defaults['vacfromdefault'] = $defaults['vacfrom'];
         $defaults['vacfrom'] = $action['from'];
         $defaults['vacto'] = $action['addresses'];
         $defaults['handle'] = $action['handle'];
         $defaults['subject'] = $action['subject'];
         $defaults['origsubject'] = $action['origsubject'];
         $defaults['msg'] = $action['msg'];
         $defaults['htmlmsg'] = $action['htmlmsg'] ? '1' : '';
         $defaults['charset'] = $action['charset'];
         if ($defaults['htmlmsg'] == '1' && $rcmail->config->get('htmleditor') == '0') {
             $h2t = new rcube_html2text($defaults['msg'], false, true, 0);
             $defaults['msg'] = $h2t->get_text();
             $defaults['htmlmsg'] = '';
         } elseif ($defaults['htmlmsg'] == '' && $rcmail->config->get('htmleditor') == '1') {
             $defaults['msg'] = $defaults['msg'];
             $defaults['msg'] = nl2br($defaults['msg']);
             $defaults['htmlmsg'] = '1';
         }
         if (!$example) {
             $this->force_vacto = false;
         }
         // check advanced enabled
         if (!empty($defaults['vacfrom']) && $defaults['vacfrom'] != $defaults['vacfromdefault'] || !empty($defaults['vacto']) || !empty($defaults['handle']) || !empty($defaults['period']) || $defaults['charset'] != RCUBE_CHARSET || $this->force_vacto) {
             $display['vacadv'] = '';
             $display['vacfrom'] = $this->show_vacfrom ? '' : 'display: none;';
             $display['vachandle'] = $this->show_vachandle ? '' : 'display: none;';
         }
     } elseif ($action['type'] == 'redirect' || $action['type'] == 'redirect_copy') {
         $defaults['method'] = $action['type'];
         $defaults['address'] = $action['target'];
     } elseif ($action['type'] == 'imapflags' || $action['type'] == 'imap4flags') {
         $defaults['method'] = $action['type'];
         $defaults['flags'] = $action['target'];
     } elseif ($action['type'] == 'notify' || $action['type'] == 'enotify') {
         $defaults['method'] = $action['type'];
         $defaults['nfrom'] = $action['from'];
         $defaults['nimpt'] = $action['importance'];
         $defaults['nmethod'] = $action['method'];
         $defaults['noptions'] = $action['options'];
         $defaults['nmsg'] = $action['msg'];
         // check advanced enabled
         if (!empty($defaults['nfrom']) || !empty($defaults['nimpt'])) {
             $display['noteadv'] = '';
         }
     } elseif ($action['type'] == 'editheaderadd' || $action['type'] == 'editheaderrem') {
         $defaults['method'] = $action['type'];
         $defaults['headername'] = $action['name'];
         $defaults['headerval'] = $action['value'];
         $defaults['headerindex'] = $action['index'];
         $defaults['headerop'] = $action['operator'];
         if ($action['type'] == 'editheaderrem' && (!empty($defaults['headerindex']) || !empty($defaults['headerval']))) {
             $display['eheadadv'] = '';
         }
     } elseif ($action['type'] == 'discard' || $action['type'] == 'keep' || $action['type'] == 'stop') {
         $defaults['method'] = $action['type'];
     }
     // hide the "template" row
     if (!isset($action)) {
         $actions_table->set_row_attribs(array('style' => 'display: none;'));
     }
     // action type select box
     $select_action = new html_select(array('name' => "_act[]", 'onchange' => rcmail_output::JS_OBJECT_NAME . '.sieverules_action_select(this)'));
     foreach ($allowed_actions as $value => $text) {
         $select_action->add($text, $value);
     }
     // add action type to UI
     $actions_table->add('action', $select_action->show($defaults['method']));
     // begin vacation action
     $vacs_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 3, 'style' => $defaults['method'] == 'vacation' ? '' : 'display: none;'));
     $to_addresses = "";
     $vacto_arr = explode(",", $defaults['vacto']);
     $field_id_vacfrom = 'rcmfd_sievevacfrom_' . $rowid;
     $field_id_vacto = 'rcmfd_sievevacto_' . $rowid;
     if (count($this->identities)) {
         $select_id = new html_select(array('id' => $field_id_vacfrom, 'name' => "_vacfrom[]", 'class' => 'short', 'onchange' => rcmail_output::JS_OBJECT_NAME . '.enable_sig(this);'));
         if ($this->show_vacfrom && in_array('variables', $ext)) {
             $select_id->add($this->gettext('autodetect'), "auto");
         } elseif (!$this->show_vacfrom) {
             $select_id->add($this->gettext('autodetect'), "");
         }
         foreach ($this->identities as $sql_arr) {
             // find currently selected from address
             if ($defaults['vacfrom'] != '' && $defaults['vacfrom'] == rcmail::Q($sql_arr['from']['string'])) {
                 $defaults['vacfrom'] = $sql_arr['identity_id'];
             } elseif ($defaults['vacfrom'] != '' && $defaults['vacfrom'] == $sql_arr['from']['mailto']) {
                 $defaults['vacfrom'] = $sql_arr['identity_id'];
             }
             $select_id->add($sql_arr['from']['disp_string'], $sql_arr['identity_id']);
             $ffield_id = 'rcmfd_vac_' . $rowid . '_' . $sql_arr['identity_id'];
             if ($this->force_vacto) {
                 $curaddress = $sql_arr['email'];
                 $defaults['vacto'] .= (!empty($defaults['vacto']) ? ',' : '') . $sql_arr['email'];
             } else {
                 $curaddress = in_array($sql_arr['email'], $vacto_arr) ? $sql_arr['email'] : "";
             }
             $input_address = new html_checkbox(array('id' => $ffield_id, 'name' => '_vacto_check_' . $rowid . '[]', 'value' => $sql_arr['email'], 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_to(this, ' . $rowid . ')', 'class' => 'checkbox'));
             $to_addresses .= $input_address->show($curaddress) . "&nbsp;" . html::label($ffield_id, rcmail::Q($sql_arr['email'])) . "<br />";
         }
     }
     // deduplicate vacto list
     $tmparr = explode(",", $defaults['vacto']);
     $tmparr = array_unique($tmparr);
     $defaults['vacto'] = implode(",", $tmparr);
     if ($rcmail->config->get('sieverules_limit_vacto', true) && strlen($to_addresses) > 0) {
         $vacfrom_input = $select_id->show($defaults['vacfrom']);
         $input_vacto = new html_hiddenfield(array('id' => $field_id_vacto, 'name' => '_vacto[]', 'value' => $defaults['vacto']));
         $vacto_input = $to_addresses . $input_vacto->show();
         $vac_help = $this->gettext('vactoexp');
     } else {
         $input_vacfrom = new html_inputfield(array('id' => $field_id_vacfrom, 'name' => '_vacfrom[]'));
         $vacfrom_input = $input_vacfrom->show($defaults['vacfrom']);
         $input_vacto = new html_inputfield(array('id' => $field_id_vacto, 'name' => '_vacto[]', 'class' => 'short'));
         $vacto_input = $input_vacto->show($defaults['vacto']);
         $vac_help = $this->gettext('vactoexp') . '<br /><br />' . $this->gettext('vactoexp_adv');
     }
     // from param
     $vacs_table->set_row_attribs(array('class' => $this->show_vacfrom ? 'advanced' : 'disabled', 'style' => $display['vacfrom']));
     $vacs_table->add(null, html::label($field_id_vacfrom, rcmail::Q($this->gettext('from'))));
     $vacs_table->add(null, $vacfrom_input);
     $sig_button = $this->api->output->button(array('command' => 'plugin.sieverules.vacation_sig', 'prop' => $rowid, 'type' => 'link', 'class' => 'vacsig', 'classact' => 'vacsig_act', 'title' => 'insertsignature', 'content' => ' '));
     $vacs_table->add(null, $sig_button);
     // to param
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(array('style' => 'vertical-align: top;'), html::label($field_id_vacto, rcmail::Q($this->gettext('sieveto'))));
     $vacs_table->add(null, $vacto_input);
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(array('style' => 'vertical-align: top;'), $help_button);
     $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $vac_help);
     $field_id = 'rcmfd_sievevacperiod_' . $rowid;
     $input_period = new html_inputfield(array('id' => $field_id, 'name' => '_period[]', 'class' => 'short'));
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('period'))));
     $vacs_table->add(null, $input_period->show($defaults['period']));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . (in_array('vacation-seconds', $ext) ? $vacs_table->size() + 1 : $vacs_table->size()) . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     if (in_array('vacation-seconds', $ext)) {
         $input_periodtype = new html_radiobutton(array('id' => $field_id . '_days', 'name' => '_period_radio_' . $rowid, 'value' => 'days', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_period_type(this, ' . $rowid . ')', 'class' => 'radio'));
         $period_type_show = $input_periodtype->show($defaults['periodtype']) . "&nbsp;" . html::label($field_id . '_days', rcmail::Q($this->gettext('days')));
         $input_periodtype = new html_radiobutton(array('id' => $field_id . '_seconds', 'name' => '_period_radio_' . $rowid, 'value' => 'seconds', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_period_type(this, ' . $rowid . ')', 'class' => 'radio'));
         $period_type_show .= '&nbsp;&nbsp;' . $input_periodtype->show($defaults['periodtype']) . "&nbsp;" . html::label($field_id . '_seconds', rcmail::Q($this->gettext('seconds')));
         $input_periodtype = new html_hiddenfield(array('id' => 'rcmfd_sievevacperiodtype_' . $rowid, 'name' => '_periodtype[]'));
         $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
         $vacs_table->add(null, '&nbsp;');
         $vacs_table->add(null, $period_type_show . $input_periodtype->show($defaults['periodtype']));
         $vacs_table->add(null, '&nbsp;');
     }
     $vacs_table->set_row_attribs(array('style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $this->gettext('vacperiodexp'));
     $field_id = 'rcmfd_sievevachandle_' . $rowid;
     $input_handle = new html_inputfield(array('id' => $field_id, 'name' => '_handle[]', 'class' => 'short'));
     $vacs_table->set_row_attribs(array('class' => $this->show_vachandle ? 'advanced' : 'disabled', 'style' => $display['vachandle']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('sievevachandle'))));
     $vacs_table->add(null, $input_handle->show($defaults['handle']));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $this->gettext('vachandleexp'));
     $field_id = 'rcmfd_sievevacsubject_' . $rowid;
     $input_subject = new html_inputfield(array('id' => $field_id, 'name' => '_subject[]'));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('subject'))));
     $vacs_table->add(array('colspan' => 2), $input_subject->show($defaults['subject']));
     if (in_array('variables', $ext)) {
         $field_id = 'rcmfd_sievevacsubject_orig_' . $rowid;
         $input_origsubject = new html_checkbox(array('id' => $field_id, 'value' => '1', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_osubj(this, ' . $rowid . ')', 'class' => 'checkbox'));
         $input_vacosubj = new html_hiddenfield(array('id' => 'rcmfd_sievevactoh_' . $rowid, 'name' => '_orig_subject[]', 'value' => $defaults['origsubject']));
         $vacs_table->add(null, '&nbsp;');
         $vacs_table->add(array('colspan' => 2), $input_origsubject->show($defaults['origsubject']) . "&nbsp;" . html::label($field_id, rcmail::Q($this->gettext('sieveorigsubj'))) . $input_vacosubj->show());
     }
     $field_id = 'rcmfd_sievevacmag_' . $rowid;
     $input_msg = new html_textarea(array('id' => $field_id, 'name' => '_msg[]', 'rows' => '8', 'cols' => '40', 'class' => $defaults['htmlmsg'] == 1 ? 'mce_editor' : '', 'is_escaped' => $defaults['htmlmsg'] == 1 ? true : null));
     $input_html = new html_checkbox(array('id' => 'rcmfd_sievevachtmlcb_' . $rowid, 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_html(this, ' . $rowid . ', \'' . $field_id . '\');', 'value' => '1', 'class' => 'checkbox'));
     $input_htmlhd = new html_hiddenfield(array('id' => 'rcmfd_sievevachtmlhd_' . $rowid, 'name' => '_htmlmsg[]', 'value' => $defaults['htmlmsg']));
     $vacs_table->add('msg', html::label($field_id, rcmail::Q($this->gettext('message'))));
     $vacs_table->add(array('colspan' => 2), $input_msg->show($defaults['msg']) . html::tag('div', in_array('htmleditor', $rcmail->config->get('dont_override')) ? array('style' => 'display: none;') : null, $input_html->show($defaults['htmlmsg']) . "&nbsp;" . html::label('rcmfd_sievevachtml_' . $rowid, rcmail::Q($this->gettext('htmlmessage')))) . $input_htmlhd->show());
     $field_id = 'rcmfd_sievecharset_' . $rowid;
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('charset'))));
     $vacs_table->add(array('colspan' => 2), $rcmail->output->charset_selector(array('id' => $field_id, 'name' => '_vaccharset[]', 'selected' => $defaults['charset'])));
     $input_advopts = new html_checkbox(array('id' => 'vadvopts' . $rowid, 'name' => '_vadv_opts[]', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'class' => 'checkbox'));
     $vacs_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('vadvopts' . $rowid, rcmail::Q($this->gettext('advancedoptions'))) . $input_advopts->show($display['vacadv'] == '' ? 1 : 0));
     // begin notify action
     $notify_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 3, 'style' => $defaults['method'] == 'notify' || $defaults['method'] == 'enotify' ? '' : 'display: none;'));
     if (count($this->identities)) {
         $field_id = 'rcmfd_sievenotifyfrom_' . $rowid;
         $select_id = new html_select(array('id' => $field_id, 'name' => "_nfrom[]"));
         $select_id->add($this->gettext('autodetect'), "");
         foreach ($this->identities as $sql_arr) {
             // find currently selected from address
             if ($defaults['nfrom'] != '' && $defaults['nfrom'] == rcmail::Q($sql_arr['from']['string'])) {
                 $defaults['nfrom'] = $sql_arr['identity_id'];
             } elseif ($defaults['nfrom'] != '' && $defaults['nfrom'] == $sql_arr['from']['mailto']) {
                 $defaults['nfrom'] = $sql_arr['identity_id'];
             }
             $select_id->add($sql_arr['from']['disp_string'], $sql_arr['identity_id']);
         }
         $notify_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['noteadv']));
         $notify_table->add(null, html::label($field_id, rcmail::Q($this->gettext('sievefrom'))));
         $notify_table->add(array('colspan' => 2), $select_id->show($defaults['nfrom']));
     }
     $field_id = 'rcmfd_nmethod_' . $rowid;
     $input_method = new html_inputfield(array('id' => $field_id, 'name' => '_nmethod[]'));
     $notify_table->add(null, html::label($field_id, rcmail::Q($this->gettext('method'))));
     $notify_table->add(array('colspan' => 2), $input_method->show($defaults['nmethod']));
     $field_id = 'rcmfd_noption_' . $rowid;
     $input_method = new html_inputfield(array('id' => $field_id, 'name' => '_noption[]'));
     $notify_table->add(null, html::label($field_id, rcmail::Q($this->gettext('options'))));
     $notify_table->add(array('colspan' => 2), $input_method->show($defaults['noptions']));
     $notify_table->set_row_attribs(array('style' => 'display: none;'));
     $notify_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $this->gettext('nmethodexp'));
     $field_id = 'rcmfd_nimpt_' . $rowid;
     $input_importance = new html_radiobutton(array('id' => $field_id . '_none', 'name' => '_notify_radio_' . $rowid, 'value' => 'none', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'class' => 'radio'));
     $importance_show = $input_importance->show($defaults['nimpt']) . "&nbsp;" . html::label($field_id . '_none', rcmail::Q($this->gettext('importancen')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_1', 'name' => '_notify_radio_' . $rowid, 'value' => '1', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'class' => 'radio'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($defaults['nimpt']) . "&nbsp;" . html::label($field_id . '_1', rcmail::Q($this->gettext('importance1')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_2', 'name' => '_notify_radio_' . $rowid, 'value' => '2', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'class' => 'radio'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($defaults['nimpt']) . "&nbsp;" . html::label($field_id . '_2', rcmail::Q($this->gettext('importance2')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_3', 'name' => '_notify_radio_' . $rowid, 'value' => '3', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'class' => 'radio'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($defaults['nimpt']) . "&nbsp;" . html::label($field_id . '_3', rcmail::Q($this->gettext('importance3')));
     $input_importance = new html_hiddenfield(array('id' => 'rcmfd_sievenimpt_' . $rowid, 'name' => '_nimpt[]'));
     $notify_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['noteadv']));
     $notify_table->add(null, rcmail::Q($this->gettext('flag')));
     $notify_table->add(array('colspan' => 2), $importance_show . $input_importance->show($defaults['nimpt']));
     $field_id = 'rcmfd_nmsg_' . $rowid;
     $input_msg = new html_inputfield(array('id' => $field_id, 'name' => '_nmsg[]'));
     $notify_table->add(null, html::label($field_id, rcmail::Q($this->gettext('message'))));
     $notify_table->add(array('colspan' => 2), $input_msg->show($defaults['nmsg']));
     if (in_array('enotify', $ext)) {
         $input_advopts = new html_checkbox(array('id' => 'nadvopts' . $rowid, 'name' => '_nadv_opts[]', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'class' => 'checkbox'));
         $notify_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('nadvopts' . $rowid, rcmail::Q($this->gettext('advancedoptions'))) . $input_advopts->show($display['noteadv'] == '' ? 1 : 0));
     }
     // begin editheader action
     $headers_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 2, 'style' => $defaults['method'] == 'editheaderadd' || $defaults['method'] == 'editheaderrem' ? '' : 'display: none;'));
     $field_id = 'rcmfd_eheadname_' . $rowid;
     $input_header = new html_inputfield(array('id' => $field_id, 'name' => '_eheadname[]'));
     $headers_table->add(null, html::label($field_id, rcmail::Q($this->gettext('headername'))));
     $headers_table->add(null, $input_header->show($defaults['headername']));
     $field_id = 'rcmfd_eheadindex_' . $rowid;
     $select_index = new html_select(array('id' => $field_id, 'name' => "_eheadindex[]"));
     $select_index->add($this->gettext('headerdelall'), "");
     $select_index->add("1", "1");
     $select_index->add("2", "2");
     $select_index->add("3", "3");
     $select_index->add("4", "4");
     $select_index->add("5", "5");
     $select_index->add($this->gettext('last'), "last");
     $headers_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['eheadadv']));
     $headers_table->add(null, html::label($field_id, rcmail::Q($this->gettext('headerindex'))));
     $headers_table->add(null, $select_index->show($defaults['headerindex']));
     $field_id = 'rcmfd_eheadopp_' . $rowid;
     $select_match = new html_select(array('id' => $field_id, 'name' => "_eheadopp[]"));
     $select_match->add($this->gettext('filteris'), "");
     $select_match->add($this->gettext('filtercontains'), "contains");
     $headers_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['eheadadv']));
     $headers_table->add(null, html::label($field_id, rcmail::Q($this->gettext('operator'))));
     $headers_table->add(null, $select_match->show($defaults['headerop']));
     $field_id = 'rcmfd_eheadval_' . $rowid;
     $input_header = new html_inputfield(array('id' => $field_id, 'name' => '_eheadval[]'));
     if ($defaults['method'] == 'editheaderrem') {
         $headers_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['eheadadv']));
     }
     $headers_table->add(null, html::label($field_id, rcmail::Q($this->gettext('headervalue'))));
     $headers_table->add(null, $input_header->show($defaults['headerval']));
     if ($defaults['method'] == 'editheaderrem') {
         $headers_table->set_row_attribs(array('style' => 'display: none;'));
     }
     $field_id = 'rcmfd_eheadaddlast_' . $rowid;
     $input_index = new html_checkbox(array('id' => $field_id, 'value' => 'last', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_eheadlast(this);', 'name' => '_eheadaddlast[]', 'class' => 'checkbox'));
     $headers_table->add(null, '&nbsp;');
     $headers_table->add(null, $input_index->show($defaults['headerindex']) . "&nbsp;" . html::label($field_id, rcmail::Q($this->gettext('headerappend'))));
     if ($defaults['method'] == 'editheaderadd') {
         $headers_table->set_row_attribs(array('style' => 'display: none;'));
     }
     $input_advopts = new html_checkbox(array('id' => 'hadvopts' . $rowid, 'name' => '_hadv_opts[]', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'class' => 'checkbox'));
     $headers_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('nadvopts' . $rowid, rcmail::Q($this->gettext('advancedoptions'))) . $input_advopts->show($display['eheadadv'] == '' ? 1 : 0));
     // begin fileinto action
     $mbox_name = $rcmail->storage->get_folder();
     $input_folderlist = new html_select(array('name' => '_folder[]', 'onchange' => rcmail_output::JS_OBJECT_NAME . '.sieverules_select_folder(this);', 'style' => $defaults['method'] == 'fileinto' || $defaults['method'] == 'fileinto_copy' ? '' : 'display: none;', 'is_escaped' => true));
     $rcmail->render_folder_tree_select($this->mailboxes, $mbox_name, 100, $input_folderlist, false);
     $show_customfolder = 'display: none;';
     if ($rcmail->config->get('sieverules_fileinto_options', 0) == 2 && !$rcmail->storage->folder_exists($defaults['folder'])) {
         $customfolder = rcube_charset::convert($rcmail->storage->mod_folder($defaults['folder']), 'UTF7-IMAP');
         $defaults['folder'] = '@@newfolder';
         $show_customfolder = '';
     }
     $input_customfolder = new html_inputfield(array('name' => '_customfolder[]'));
     $otherfolders = html::span(array('id' => 'customfolder_rowid', 'style' => $show_customfolder), '<br />' . $input_customfolder->show($customfolder));
     // begin redirect action
     $input_address = new html_inputfield(array('name' => '_redirect[]', 'style' => $defaults['method'] == 'redirect' || $defaults['method'] == 'redirect_copy' ? '' : 'display: none;'));
     // begin reject action
     $input_reject = new html_textarea(array('name' => '_reject[]', 'rows' => '5', 'cols' => '40', 'style' => $defaults['method'] == 'reject' || $defaults['method'] == 'ereject' ? '' : 'display: none;'));
     // begin imapflags action
     $input_imapflags = new html_select(array('name' => '_imapflags[]', 'style' => $defaults['method'] == 'imapflags' || $defaults['method'] == 'imap4flags' ? '' : 'display: none;'));
     foreach ($this->flags as $name => $val) {
         $input_imapflags->add($this->gettext($name), $val);
     }
     // add actions to UI
     $actions_table->add('folder', $input_folderlist->show($defaults['folder']) . $otherfolders . $input_address->show($defaults['address']) . $vacs_table->show() . $notify_table->show() . $input_imapflags->show($defaults['flags']) . $input_reject->show($defaults['reject']) . $headers_table->show());
     // add add/delete buttons to UI (if enabled)
     $add_button = $this->api->output->button(array('command' => 'plugin.sieverules.add_action', 'type' => 'link', 'class' => 'add', 'title' => 'sieverules.addsieveact', 'content' => ' '));
     $delete_button = $this->api->output->button(array('command' => 'plugin.sieverules.del_action', 'type' => 'link', 'class' => 'delete', 'classact' => 'delete_act', 'title' => 'sieverules.deletesieveact', 'content' => ' '));
     if ($rcmail->config->get('sieverules_multiple_actions')) {
         $actions_table->add('control', $add_button . $delete_button);
     } else {
         $actions_table->add('control', "&nbsp;");
     }
     return $actions_table;
 }
 private function _action_row($ext, $actions_table, $rowid, $action, $attrib, $example)
 {
     $rcmail = rcmail::get_instance();
     static $a_mailboxes;
     $imgclass = null;
     if (!isset($action)) {
         $actions_table->set_row_attribs(array('style' => 'display: none;'));
         $imgclass = 'nohtc';
     }
     $help_icon = html::img(array('src' => $attrib['helpicon'], 'alt' => $this->gettext('messagehelp'), 'border' => 0));
     $vacadvstyle = $action['type'] != 'vacation' && $this->force_vacto ? '' : 'display: none;';
     $vacadvstyle_from = $this->show_vacfrom ? $vacadvstyle : 'display: none;';
     $vacadvstyle_handle = $this->show_vachandle ? $vacadvstyle : 'display: none;';
     $vacadvclass_from = $this->show_vacfrom ? 'advanced' : 'disabled';
     $vacadvclass_handle = $this->show_vachandle ? 'advanced' : 'disabled';
     $vacshowadv = $action['type'] != 'vacation' && $this->force_vacto ? '1' : '';
     $noteadvstyle = 'display: none;';
     $noteshowadv = '';
     // setup allowed actions
     $allowed_actions = array();
     $config_actions = $rcmail->config->get('sieverules_allowed_actions', array());
     if (in_array('fileinto', $ext) && ($config_actions['fileinto'] || $action['type'] == 'fileinto')) {
         $allowed_actions['fileinto'] = $this->gettext('messagemoveto');
     }
     if (in_array('fileinto', $ext) && in_array('copy', $ext) && ($config_actions['fileinto'] || $action['type'] == 'fileinto')) {
         $allowed_actions['fileinto_copy'] = $this->gettext('messagecopyto');
     }
     if (in_array('vacation', $ext) && ($config_actions['vacation'] || $action['type'] == 'vacation')) {
         $allowed_actions['vacation'] = $this->gettext('messagevacation');
     }
     if (in_array('reject', $ext) && ($config_actions['reject'] || $action['type'] == 'reject')) {
         $allowed_actions['reject'] = $this->gettext('messagereject');
     } elseif (in_array('ereject', $ext) && ($config_actions['reject'] || $action['type'] == 'ereject')) {
         $allowed_actions['ereject'] = $this->gettext('messagereject');
     }
     if (in_array('imapflags', $ext) && ($config_actions['imapflags'] || $action['type'] == 'imapflags')) {
         $allowed_actions['imapflags'] = $this->gettext('messageimapflags');
     } elseif (in_array('imap4flags', $ext) && ($config_actions['imapflags'] || $action['type'] == 'imap4flags')) {
         $allowed_actions['imap4flags'] = $this->gettext('messageimapflags');
     }
     if (in_array('notify', $ext) && ($config_actions['notify'] || $action['type'] == 'notify')) {
         $allowed_actions['notify'] = $this->gettext('messagenotify');
     } elseif (in_array('enotify', $ext) && ($config_actions['notify'] || $action['type'] == 'enotify')) {
         $allowed_actions['enotify'] = $this->gettext('messagenotify');
     }
     if ($config_actions['redirect'] || $action['type'] == 'redirect') {
         $allowed_actions['redirect'] = $this->gettext('messageredirect');
     }
     if (in_array('copy', $ext) && ($config_actions['redirect'] || $action['type'] == 'redirect_copy')) {
         $allowed_actions['redirect_copy'] = $this->gettext('messageredirectcopy');
     }
     if ($config_actions['keep'] || $action['type'] == 'keep') {
         $allowed_actions['keep'] = $this->gettext('messagekeep');
     }
     if ($config_actions['discard'] || $action['type'] == 'discard') {
         $allowed_actions['discard'] = $this->gettext('messagediscard');
     }
     if ($config_actions['stop'] || $action['type'] == 'stop') {
         $allowed_actions['stop'] = $this->gettext('messagestop');
     }
     // set the default action
     reset($allowed_actions);
     $method = key($allowed_actions);
     $folder = 'INBOX';
     $reject = '';
     $identity = $rcmail->user->get_identity();
     if ($this->show_vacfrom) {
         $vacfrom = in_array('variables', $ext) ? 'auto' : $identity['email'];
     } else {
         $vacfrom = null;
     }
     $vacto = null;
     $address = '';
     $days = '';
     $handle = '';
     $subject = '';
     $origsubject = '';
     $msg = '';
     $charset = RCMAIL_CHARSET;
     $flags = '';
     $nfrom = '';
     $nimpt = '';
     $nmethod = '';
     $noptions = '';
     $nmsg = '';
     if ($action['type'] == 'fileinto' || $action['type'] == 'fileinto_copy') {
         $method = $action['type'];
         $folder = $rcmail->config->get('sieverules_include_imap_root', true) ? $action['target'] : $rcmail->imap->mod_mailbox($action['target']);
         if ($rcmail->config->get('sieverules_folder_delimiter', false)) {
             $folder = str_replace($rcmail->imap->get_hierarchy_delimiter(), $rcmail->config->get('sieverules_folder_delimiter'), $folder);
         }
     } elseif ($action['type'] == 'reject' || $action['type'] == 'ereject') {
         $method = $action['type'];
         $reject = htmlspecialchars($action['target']);
     } elseif ($action['type'] == 'vacation') {
         $method = 'vacation';
         $days = $action['days'];
         $vacfrom_default = $vacfrom;
         $vacfrom = $action['from'];
         $vacto = $action['addresses'];
         $handle = htmlspecialchars($action['handle']);
         $subject = htmlspecialchars($action['subject']);
         $origsubject = $action['origsubject'];
         $msg = $action['msg'];
         $htmlmsg = $action['htmlmsg'] ? '1' : '';
         $charset = $action['charset'];
         if (!$example) {
             $this->force_vacto = false;
         }
         // check advanced enabled
         if (!empty($vacfrom) && $vacfrom != $vacfrom_default || !empty($vacto) || !empty($handle) || $charset != RCMAIL_CHARSET || $this->force_vacto) {
             $vacadvstyle = '';
             $vacadvstyle_from = $this->show_vacfrom ? '' : 'display: none;';
             $vacadvstyle_handle = $this->show_vachandle ? '' : 'display: none;';
             $vacshowadv = '1';
         }
     } elseif ($action['type'] == 'redirect' || $action['type'] == 'redirect_copy') {
         $method = $action['type'];
         $address = $action['target'];
     } elseif ($action['type'] == 'imapflags' || $action['type'] == 'imap4flags') {
         $method = $action['type'];
         $flags = $action['target'];
     } elseif ($action['type'] == 'notify' || $action['type'] == 'enotify') {
         $method = $action['type'];
         $nfrom = htmlspecialchars($action['from']);
         $nimpt = htmlspecialchars($action['importance']);
         $nmethod = $action['method'];
         $noptions = $action['options'];
         $nmsg = $action['msg'];
         // check advanced enabled
         if (!empty($nfrom) || !empty($nimpt)) {
             $noteadvstyle = '';
             $noteshowadv = '1';
         }
     } elseif ($action['type'] == 'discard' || $action['type'] == 'keep' || $action['type'] == 'stop') {
         $method = $action['type'];
     }
     $select_action = new html_select(array('name' => "_act[]", 'onchange' => JS_OBJECT_NAME . '.sieverules_action_select(this)'));
     foreach ($allowed_actions as $value => $text) {
         $select_action->add(Q($text), $value);
     }
     $actions_table->add('action', $select_action->show($method));
     $vacs_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 3, 'style' => $method == 'vacation' ? '' : 'display: none;'));
     $to_addresses = "";
     $vacto_arr = explode(",", $vacto);
     $user_identities = $rcmail->user->list_identities();
     if (count($user_identities)) {
         $field_id = 'rcmfd_sievevacfrom_' . $rowid;
         $select_id = new html_select(array('id' => $field_id, 'name' => "_vacfrom[]", 'class' => 'short', 'onchange' => JS_OBJECT_NAME . '.enable_sig(this);'));
         if ($this->show_vacfrom && in_array('variables', $ext)) {
             $select_id->add(Q($this->gettext('autodetect')), "auto");
         } elseif (!$this->show_vacfrom) {
             $select_id->add(Q($this->gettext('autodetect')), "");
         }
         foreach ($user_identities as $sql_arr) {
             $select_id->add($sql_arr['email'], $sql_arr['email']);
             $ffield_id = 'rcmfd_vac_' . $rowid . '_' . $sql_arr['identity_id'];
             if ($this->force_vacto) {
                 $curaddress = $sql_arr['email'];
                 $vacto .= (!empty($vacto) ? ',' : '') . $sql_arr['email'];
             } else {
                 $curaddress = in_array($sql_arr['email'], $vacto_arr) ? $sql_arr['email'] : "";
             }
             $input_address = new html_checkbox(array('id' => $ffield_id, 'name' => '_vacto_check_' . $rowid . '[]', 'value' => $sql_arr['email'], 'onclick' => JS_OBJECT_NAME . '.sieverules_toggle_vac_to(this, ' . $rowid . ')', 'class' => 'checkbox'));
             $to_addresses .= $input_address->show($curaddress) . "&nbsp;" . html::label($ffield_id, Q($sql_arr['email'])) . "<br />";
         }
     }
     if ($rcmail->config->get('sieverules_limit_vacto', true) && strlen($to_addresses) > 0) {
         $vacs_table->set_row_attribs(array('class' => $vacadvclass_from, 'style' => $vacadvstyle_from));
         $vacs_table->add(null, html::label($field_id, Q($this->gettext('from'))));
         $vacs_table->add(null, $select_id->show($vacfrom));
         $sig_button = $this->api->output->button(array('command' => 'plugin.sieverules.vacation_sig', 'prop' => $rowid, 'type' => 'link', 'class' => 'vacsig', 'classact' => 'vacsig_act', 'title' => 'insertsignature', 'content' => ' '));
         $vacs_table->add(null, $sig_button);
         $field_id = 'rcmfd_sievevacto_' . $rowid;
         $input_vacto = new html_hiddenfield(array('id' => $field_id, 'name' => '_vacto[]', 'value' => $vacto));
         $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $vacadvstyle));
         $vacs_table->add(array('style' => 'vertical-align: top;'), Q($this->gettext('sieveto')));
         $vacs_table->add(null, $to_addresses . $input_vacto->show());
         $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
         $vacs_table->add(array('style' => 'vertical-align: top;'), $help_button);
         $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
         $vacs_table->add(array('colspan' => 3, 'class' => 'vacdaysexp'), $this->gettext('vactoexp'));
         $vacs_table->add_row();
     } else {
         $field_id = 'rcmfd_sievevacfrom_' . $rowid;
         $input_vacfrom = new html_inputfield(array('id' => $field_id, 'name' => '_vacfrom[]'));
         $vacs_table->set_row_attribs(array('class' => $vacadvclass_from, 'style' => $vacadvstyle_from));
         $vacs_table->add(null, html::label($field_id, Q($this->gettext('from'))));
         $vacs_table->add(null, $input_vacfrom->show($vacfrom));
         $sig_button = $this->api->output->button(array('command' => 'plugin.sieverules.vacation_sig', 'prop' => $rowid, 'type' => 'link', 'class' => 'vacsig', 'classact' => 'vacsig_act', 'title' => 'insertsignature', 'content' => ' '));
         $vacs_table->add(null, $sig_button);
         $field_id = 'rcmfd_sievevacto_' . $rowid;
         $input_vacto = new html_inputfield(array('id' => $field_id, 'name' => '_vacto[]', 'class' => 'short'));
         $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $vacadvstyle));
         $vacs_table->add(null, html::label($field_id, Q($this->gettext('sieveto'))));
         $vacs_table->add(null, $input_vacto->show($vacto));
         $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
         $vacs_table->add(null, $help_button);
         $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
         $vacs_table->add(array('colspan' => 3, 'class' => 'vacdaysexp'), $this->gettext('vactoexp') . '<br /><br />' . $this->gettext('vactoexp_adv'));
         $vacs_table->add_row();
     }
     $field_id = 'rcmfd_sievevacdays_' . $rowid;
     $input_day = new html_inputfield(array('id' => $field_id, 'name' => '_day[]', 'class' => 'short'));
     $vacs_table->add(null, html::label($field_id, Q($this->gettext('days'))));
     $vacs_table->add(null, $input_day->show($days));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     $vacs_table->set_row_attribs(array('style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'vacdaysexp'), $this->gettext('vacdaysexp'));
     $vacs_table->add_row();
     $field_id = 'rcmfd_sievevachandle_' . $rowid;
     $input_handle = new html_inputfield(array('id' => $field_id, 'name' => '_handle[]', 'class' => 'short'));
     $vacs_table->set_row_attribs(array('class' => $vacadvclass_handle, 'style' => $vacadvstyle_handle));
     $vacs_table->add(null, html::label($field_id, Q($this->gettext('sievevachandle'))));
     $vacs_table->add(null, $input_handle->show($handle));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'vacdaysexp'), $this->gettext('vachandleexp'));
     $vacs_table->add_row();
     $field_id = 'rcmfd_sievevacsubject_' . $rowid;
     $input_subject = new html_inputfield(array('id' => $field_id, 'name' => '_subject[]'));
     $vacs_table->add(null, html::label($field_id, Q($this->gettext('subject'))));
     $vacs_table->add(array('colspan' => 2), $input_subject->show($subject));
     $vacs_table->add_row();
     if (in_array('variables', $ext)) {
         $field_id = 'rcmfd_sievevacsubject_orig_' . $rowid;
         $input_origsubject = new html_checkbox(array('id' => $field_id, 'value' => '1', 'onclick' => JS_OBJECT_NAME . '.sieverules_toggle_vac_osubj(this, ' . $rowid . ')', 'class' => 'checkbox'));
         $input_vacosubj = new html_hiddenfield(array('id' => 'rcmfd_sievevactoh_' . $rowid, 'name' => '_orig_subject[]', 'value' => $origsubject));
         $vacs_table->add(null, '&nbsp;');
         $vacs_table->add(array('colspan' => 2), $input_origsubject->show($origsubject) . "&nbsp;" . html::label($field_id, Q($this->gettext('sieveorigsubj'))) . $input_vacosubj->show());
         $vacs_table->add_row();
     }
     $field_id = 'rcmfd_sievevacmag_' . $rowid;
     $input_msg = new html_textarea(array('id' => $field_id, 'name' => '_msg[]', 'rows' => '8', 'cols' => '40', 'class' => $htmlmsg == 1 ? 'mce_editor' : ''));
     $input_html = new html_checkbox(array('onclick' => JS_OBJECT_NAME . '.sieverules_toggle_vac_html(this, ' . $rowid . ', \'' . $field_id . '\');', 'value' => '1', 'class' => 'checkbox'));
     $input_htmlhd = new html_hiddenfield(array('id' => 'rcmfd_sievevachtmlhd_' . $rowid, 'name' => '_htmlmsg[]', 'value' => $htmlmsg));
     $vacs_table->add('msg', html::label($field_id, Q($this->gettext('message'))));
     $vacs_table->add(array('colspan' => 2), $input_msg->show($msg) . html::tag('div', null, $input_html->show($htmlmsg) . "&nbsp;" . html::label('rcmfd_sievevachtml_' . $rowid, Q($this->gettext('htmlmessage'))) . $input_htmlhd->show()));
     $vacs_table->add_row();
     $field_id = 'rcmfd_sievecharset_' . $rowid;
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $vacadvstyle));
     $vacs_table->add(null, html::label($field_id, Q($this->gettext('charset'))));
     $vacs_table->add(array('colspan' => 2), $this->_charset_selector(array('id' => $field_id, 'name' => '_charset[]'), $charset));
     $vacs_table->add_row();
     $input_advopts = new html_checkbox(array('id' => 'vadvopts' . $rowid, 'name' => '_vadv_opts[]', 'onclick' => JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'class' => 'checkbox'));
     $vacs_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('vadvopts' . $rowid, Q($this->gettext('advancedoptions'))) . $input_advopts->show($vacshowadv));
     $notify_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 3, 'style' => $method == 'notify' || $method == 'enotify' ? '' : 'display: none;'));
     $user_identities = $rcmail->user->list_identities();
     if (count($user_identities)) {
         $field_id = 'rcmfd_sievenotifyfrom_' . $rowid;
         $select_id = new html_select(array('id' => $field_id, 'name' => "_nfrom[]"));
         $select_id->add(Q($this->gettext('autodetect')), "");
         foreach ($user_identities as $sql_arr) {
             $select_id->add($sql_arr['email'], $sql_arr['email']);
         }
         $notify_table->set_row_attribs(array('class' => 'advanced', 'style' => $noteadvstyle));
         $notify_table->add(null, html::label($field_id, Q($this->gettext('sievefrom'))));
         $notify_table->add(array('colspan' => 2), $select_id->show($nfrom));
         $notify_table->add_row();
     }
     $field_id = 'rcmfd_nmethod_' . $rowid;
     $input_method = new html_inputfield(array('id' => $field_id, 'name' => '_nmethod[]'));
     $notify_table->add(null, html::label($field_id, Q($this->gettext('method'))));
     $notify_table->add(array('colspan' => 2), $input_method->show($nmethod));
     $notify_table->add_row();
     $field_id = 'rcmfd_noption_' . $rowid;
     $input_method = new html_inputfield(array('id' => $field_id, 'name' => '_noption[]'));
     $notify_table->add(null, html::label($field_id, Q($this->gettext('options'))));
     $notify_table->add(array('colspan' => 2), $input_method->show($noptions));
     $notify_table->add_row();
     $notify_table->set_row_attribs(array('style' => 'display: none;'));
     $notify_table->add(array('colspan' => 3, 'class' => 'vacdaysexp'), $this->gettext('nmethodexp'));
     $notify_table->add_row();
     $field_id = 'rcmfd_nimpt_' . $rowid;
     $input_importance = new html_radiobutton(array('id' => $field_id . '_none', 'name' => '_notify_radio_' . $rowid, 'value' => 'none', 'onclick' => JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'style' => 'width:15px;'));
     $importance_show = $input_importance->show($nimpt) . "&nbsp;" . html::label($field_id . '_none', Q($this->gettext('importancen')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_1', 'name' => '_notify_radio_' . $rowid, 'value' => '1', 'onclick' => JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'style' => 'width:15px;'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($nimpt) . "&nbsp;" . html::label($field_id . '_1', Q($this->gettext('importance1')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_2', 'name' => '_notify_radio_' . $rowid, 'value' => '2', 'onclick' => JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'style' => 'width:15px;'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($nimpt) . "&nbsp;" . html::label($field_id . '_2', Q($this->gettext('importance2')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_3', 'name' => '_notify_radio_' . $rowid, 'value' => '3', 'onclick' => JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'style' => 'width:15px;'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($nimpt) . "&nbsp;" . html::label($field_id . '_3', Q($this->gettext('importance3')));
     $input_importance = new html_hiddenfield(array('id' => 'rcmfd_sievenimpt_' . $rowid, 'name' => '_nimpt[]'));
     $notify_table->set_row_attribs(array('class' => 'advanced', 'style' => $noteadvstyle));
     $notify_table->add(null, Q($this->gettext('flag')));
     $notify_table->add(array('colspan' => 2), $importance_show . $input_importance->show($nimpt));
     $notify_table->add_row();
     $field_id = 'rcmfd_nmsg_' . $rowid;
     $input_msg = new html_inputfield(array('id' => $field_id, 'name' => '_nmsg[]'));
     $notify_table->add(null, html::label($field_id, Q($this->gettext('message'))));
     $notify_table->add(array('colspan' => 2), $input_msg->show($nmsg));
     $notify_table->add_row();
     if (in_array('enotify', $ext)) {
         $input_advopts = new html_checkbox(array('id' => 'nadvopts' . $rowid, 'name' => '_nadv_opts[]', 'onclick' => JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'style' => 'width:15px;'));
         $notify_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('nadvopts' . $rowid, Q($this->gettext('advancedoptions'))) . $input_advopts->show($noteshowadv));
     }
     // get mailbox list
     $mbox_name = $rcmail->imap->get_mailbox_name();
     // build the folders tree
     if (empty($a_mailboxes)) {
         // get mailbox list
         if ($rcmail->config->get('sieverules_fileinto_options', 0) > 0) {
             $a_folders = $rcmail->imap->list_unsubscribed();
         } else {
             $a_folders = $rcmail->imap->list_mailboxes();
         }
         $delimiter = $rcmail->imap->get_hierarchy_delimiter();
         $a_mailboxes = array();
         foreach ($a_folders as $ifolder) {
             if ($rcmail->config->get('sieverules_folder_encoding')) {
                 $ifolder = $this->_mbox_encode($ifolder, $rcmail->config->get('sieverules_folder_encoding'));
             }
             if ($rcmail->config->get('sieverules_folder_delimiter', false)) {
                 rcmail_build_folder_tree($a_mailboxes, str_replace($delimiter, $rcmail->config->get('sieverules_folder_delimiter'), $ifolder), $rcmail->config->get('sieverules_folder_delimiter'));
             } else {
                 rcmail_build_folder_tree($a_mailboxes, $ifolder, $delimiter);
             }
         }
         if ($rcmail->config->get('sieverules_fileinto_options', 0) == 2 && in_array('mailbox', $ext)) {
             array_push($a_mailboxes, array('id' => '@@newfolder', 'name' => $this->gettext('createfolder'), 'virtual' => '', 'folders' => array()));
         }
     }
     $input_folderlist = new html_select(array('name' => '_folder[]', 'onchange' => JS_OBJECT_NAME . '.sieverules_select_folder(this);', 'style' => $method == 'fileinto' || $method == 'fileinto_copy' ? '' : 'display: none;'));
     rcmail_render_folder_tree_select($a_mailboxes, $mbox_name, 100, $input_folderlist, false);
     $show_customfolder = 'display: none;';
     if ($rcmail->config->get('sieverules_fileinto_options', 0) == 2 && !$rcmail->imap->mailbox_exists($folder)) {
         $customfolder = $rcmail->imap->mod_mailbox($folder);
         $folder = '@@newfolder';
         $show_customfolder = '';
     }
     $input_customfolder = new html_inputfield(array('name' => '_customfolder[]'));
     $otherfolders = html::span(array('id' => 'customfolder_rowid', 'style' => $show_customfolder), '<br />' . $input_customfolder->show($customfolder));
     $input_address = new html_inputfield(array('name' => '_redirect[]', 'style' => $method == 'redirect' || $method == 'redirect_copy' ? '' : 'display: none;'));
     $input_reject = new html_textarea(array('name' => '_reject[]', 'rows' => '5', 'cols' => '40', 'style' => $method == 'reject' || $method == 'ereject' ? '' : 'display: none;'));
     $input_imapflags = new html_select(array('name' => '_imapflags[]', 'style' => $method == 'imapflags' || $method == 'imap4flags' ? '' : 'display: none;'));
     foreach ($this->flags as $name => $val) {
         $input_imapflags->add(Q($this->gettext($name)), Q($val));
     }
     $actions_table->add('folder', $input_folderlist->show($folder) . $otherfolders . $input_address->show($address) . $vacs_table->show() . $notify_table->show() . $input_imapflags->show($flags) . $input_reject->show($reject));
     $add_button = $this->api->output->button(array('command' => 'plugin.sieverules.add_action', 'type' => 'link', 'class' => 'add', 'title' => 'sieverules.addsieveact', 'content' => ' '));
     $delete_button = $this->api->output->button(array('command' => 'plugin.sieverules.del_action', 'type' => 'link', 'class' => 'delete', 'classact' => 'delete_act', 'title' => 'sieverules.deletesieveact', 'content' => ' '));
     if ($rcmail->config->get('sieverules_multiple_actions')) {
         $actions_table->add('control', $delete_button . $add_button);
     } else {
         $actions_table->add('control', "&nbsp;");
     }
     return $actions_table;
 }
Ejemplo n.º 8
0
 /**
  * Generate the form for recurrence warning
  */
 public function recurrence_warning($attrib = array())
 {
     $attrib['id'] = 'edit-recurring-warning';
     $object = $this->gettext($attrib['object']);
     $radio = new html_radiobutton(array('name' => '_savemode', 'class' => 'edit-recurring-savemode'));
     $form = html::label(null, $radio->show('', array('value' => 'current')) . $this->gettext('currentobject')) . ' ' . html::label(null, $radio->show('', array('value' => 'future')) . $this->gettext('futureobjects')) . ' ' . html::label(null, $radio->show('all', array('value' => 'all')) . $this->gettext('allobjects')) . ' ' . html::label(null, $radio->show('', array('value' => 'new')) . $this->gettext('saveasnew'));
     return html::div($attrib, html::div('message', html::span('ui-icon ui-icon-alert', '') . str_replace('%s', $object, $this->gettext('changerecurringobjectwarning'))) . html::div('savemode', $form));
 }