Exemplo n.º 1
0
 /**
  * Create a HTML table based on the given data
  *
  * @param  array  Named table attributes
  * @param  mixed  Table row data. Either a two-dimensional array or a valid SQL result set
  * @param  array  List of cols to show
  * @param  string Name of the identifier col
  *
  * @return string HTML table code
  */
 public function table_output($attrib, $table_data, $a_show_cols, $id_col)
 {
     $table = new html_table($attrib);
     // add table header
     if (!$attrib['noheader']) {
         foreach ($a_show_cols as $col) {
             $table->add_header($col, $this->Q($this->gettext($col)));
         }
     }
     if (!is_array($table_data)) {
         $db = $this->get_dbh();
         while ($table_data && ($sql_arr = $db->fetch_assoc($table_data))) {
             $table->add_row(array('id' => 'rcmrow' . rcube_utils::html_identifier($sql_arr[$id_col])));
             // format each col
             foreach ($a_show_cols as $col) {
                 $table->add($col, $this->Q($sql_arr[$col]));
             }
         }
     } else {
         foreach ($table_data as $row_data) {
             $class = !empty($row_data['class']) ? $row_data['class'] : null;
             if (!empty($attrib['rowclass'])) {
                 $class = trim($class . ' ' . $attrib['rowclass']);
             }
             $rowid = 'rcmrow' . rcube_utils::html_identifier($row_data[$id_col]);
             $table->add_row(array('id' => $rowid, 'class' => $class));
             // format each col
             foreach ($a_show_cols as $col) {
                 $val = is_array($row_data[$col]) ? $row_data[$col][0] : $row_data[$col];
                 $table->add($col, empty($attrib['ishtml']) ? $this->Q($val) : $val);
             }
         }
     }
     return $table->show($attrib);
 }
 function veximaccountadmin_form()
 {
     $rcmail = rcmail::get_instance();
     $this->_load_config();
     // add labels to client - to be used in JS alerts
     $rcmail->output->add_label('veximaccountadmin.enterallpassfields', 'veximaccountadmin.passwordinconsistency', 'veximaccountadmin.autoresponderlong', 'veximaccountadmin.autoresponderlongnum', 'veximaccountadmin.autoresponderlongmax', 'veximaccountadmin.headerblockdelete', 'veximaccountadmin.headerblockdeleteall', 'veximaccountadmin.headerblockexists', 'veximaccountadmin.headerblockentervalue');
     $rcmail->output->set_env('product_name', $rcmail->config->get('product_name'));
     $settings = $this->_get_configuration();
     $on_avscan = $settings['on_avscan'];
     $on_spamassassin = $settings['on_spamassassin'];
     $sa_tag = $settings['sa_tag'];
     $sa_refuse = $settings['sa_refuse'];
     $spam_drop = $settings['spam_drop'];
     $on_vacation = $settings['on_vacation'];
     $vacation = $settings['vacation'];
     $on_forward = $settings['on_forward'];
     $forward = $settings['forward'];
     $unseen = $settings['unseen'];
     $maxmsgsize = $settings['maxmsgsize'];
     $user_id = $settings['user_id'];
     $domain_id = $settings['domain_id'];
     $domain_settings = $this->_get_domain_configuration($domain_id);
     $default_sa_tag = $domain_settings['sa_tag'];
     $default_sa_refuse = $domain_settings['sa_refuse'];
     $default_maxmsgsize = $domain_settings['maxmsgsize'];
     $active_domain = $domain_settings['domain'];
     $rcmail->output->set_env('vacation_maxlength', $this->config['vexim_vacation_maxlength']);
     $out .= '<p class="introtext">' . $this->gettext('introtext') . '</p>' . "\n";
     if ($this->config['show_admin_link'] == true and $settings['admin'] == true) {
         $out .= '<p class="adminlink">';
         $out .= sprintf($this->gettext('adminlinktext'), '<a href="' . $this->config['vexim_url'] . '" target="_blank">', '</a>');
         $out .= "</p>\n";
     }
     // =====================================================================================================
     // Password
     $out .= '<fieldset><legend>' . $this->gettext('password') . '</legend>' . "\n";
     $out .= '<div class="fieldset-content">';
     $out .= '<p>' . $this->gettext('passwordcurrentexplanation') . '</p>';
     $out .= '<table class="vexim-settings" cellpadding="0" cellspacing="0">';
     $field_id = 'curpasswd';
     $input_passwordcurrent = new html_passwordfield(array('name' => '_curpasswd', 'id' => $field_id, 'class' => 'text-long', 'autocomplete' => 'off'));
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('passwordcurrent')), $input_passwordcurrent->show(), '');
     $field_id = 'newpasswd';
     $input_passwordnew = new html_passwordfield(array('name' => '_newpasswd', 'id' => $field_id, 'class' => 'text-long', 'autocomplete' => 'off'));
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('passwordnew')), $input_passwordnew->show(), '');
     $field_id = 'confpasswd';
     $input_passwordconf = new html_passwordfield(array('name' => '_confpasswd', 'id' => $field_id, 'class' => 'text-long', 'autocomplete' => 'off'));
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('passwordconfirm')), $input_passwordconf->show(), '');
     $out .= '</table>';
     $out .= '</div></fieldset>' . "\n\n";
     // =====================================================================================================
     // Spam/Virus
     $out .= '<fieldset><legend>' . $this->gettext('spamvirus') . '</legend>' . "\n";
     $out .= '<div class="fieldset-content">';
     $out .= '<table class="vexim-settings" cellpadding="0" cellspacing="0">';
     $field_id = 'on_avscan';
     $input_virusenabled = new html_checkbox(array('name' => 'on_avscan', 'id' => $field_id, 'value' => 1));
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('virusenabled')), $input_virusenabled->show($on_avscan ? 1 : 0), '<br /><span class="vexim-explanation">' . $this->gettext('virusenabledexplanation') . '</span>');
     $field_id = 'on_spamassassin';
     $input_spamenabled = new html_checkbox(array('name' => 'on_spamassassin', 'id' => $field_id, 'value' => 1));
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('spamenabled')), $input_spamenabled->show($on_spamassassin ? 1 : 0), '<br /><span class="vexim-explanation">' . $this->gettext('spamenabledexplanation') . '</span>');
     $field_id = 'sa_tag';
     $input_spamscoretag = new html_select(array('name' => 'sa_tag', 'id' => $field_id, 'class' => 'select'));
     $decPlaces = 0;
     $found_number = false;
     for ($i = 1; $i <= 20; $i = $i + 1) {
         $i = number_format($i, $decPlaces);
         $input_spamscoretag->add($i, $i);
         if ($sa_tag == $i) {
             $found_number = true;
         }
     }
     for ($i = 25; $i <= 100; $i = $i + 5) {
         $i = number_format($i, $decPlaces);
         $input_spamscoretag->add($i, $i);
         if ($sa_tag == $i) {
             $found_number = true;
         }
     }
     // If the value from database cannot be choosed among the list we present,
     // add it to the end of the list. This may happen because Vexim lets the
     // user write in a number in a textbox.
     if (!$found_number) {
         $input_spamscoretag->add($sa_tag, $sa_tag);
     }
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('spamscoretag')), $input_spamscoretag->show($sa_tag), '<br /><span class="vexim-explanation">' . $this->gettext('spamscoretagexplanation') . '. <span class="sameline">' . $this->gettext('domaindefault') . ': ' . $default_sa_tag . '.</span></span>');
     $field_id = 'sa_refuse';
     $input_spamscorerefuse = new html_select(array('name' => 'sa_refuse', 'id' => $field_id, 'class' => 'select'));
     $found_number = false;
     for ($i = 1; $i <= 20; $i = $i + 1) {
         $i = number_format($i, $decPlaces);
         $input_spamscorerefuse->add($i, $i);
         if ($sa_refuse == $i) {
             $found_number = true;
         }
     }
     for ($i = 25; $i <= 200; $i = $i + 5) {
         $i = number_format($i, $decPlaces);
         $input_spamscorerefuse->add($i, $i);
         if ($sa_refuse == $i) {
             $found_number = true;
         }
     }
     for ($i = 300; $i <= 900; $i = $i + 100) {
         $i = number_format($i, $decPlaces);
         $input_spamscorerefuse->add($i, $i);
         if ($sa_refuse == $i) {
             $found_number = true;
         }
     }
     $i = number_format(999, $decPlaces);
     $input_spamscorerefuse->add($i, $i);
     if ($sa_refuse == $i) {
         $found_number = true;
     }
     // If the value from database cannot be choosed among the list we present,
     // add it to the end of the list. This may happen because Vexim lets the
     // user write in a number in a textbox.
     if (!$found_number) {
         $input_spamscorerefuse->add($sa_refuse, $sa_refuse);
     }
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('spamscorerefuse')), $input_spamscorerefuse->show($sa_refuse), '<br /><span class="vexim-explanation">' . $this->gettext('spamscorerefuseexplanation') . '. <span class="sameline">' . $this->gettext('domaindefault') . ': ' . $default_sa_refuse . '.</span></span>');
     $spammoveexplanation = '<br /><span class="vexim-explanation">' . str_replace("%italicstart", "<i>", str_replace("%italicend", "</i>", $this->gettext('spammoveexplanation_part1')));
     if ($this->config['parsefolders_script']) {
         $spammoveexplanation .= ' ' . $this->gettext('spammoveexplanation_part2');
     }
     $spammoveexplanation .= ' ' . $this->gettext('spammoveexplanation_part3');
     $field_id = 'spam_drop';
     $input_spammove = new html_checkbox(array('name' => 'spam_drop', 'id' => $field_id, 'value' => 1));
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('spammove')), $input_spammove->show($spam_drop ? 1 : 0), $spammoveexplanation);
     $out .= '</table>';
     if ($this->config['parsefolders_script'] and $this->config['parsefolders_script_show_tip']) {
         $out .= '<p class="vexim-explanation">' . str_replace('%italicstart', '<i>', str_replace('%italicend', '</i>', $this->gettext('spamtip'))) . '</p>';
     }
     $out .= '</div></fieldset>' . "\n\n";
     // =====================================================================================================
     // Autoresponder
     $out .= '<fieldset><legend>' . $this->gettext('autoresponder') . '</legend>' . "\n";
     $out .= '<div class="fieldset-content">';
     $out .= '<table class="vexim-settings" cellpadding="0" cellspacing="0">';
     $field_id = 'on_vacation';
     $input_autoresponderenabled = new html_checkbox(array('name' => 'on_vacation', 'id' => $field_id, 'value' => 1));
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('autoresponderenabled')), $input_autoresponderenabled->show($on_vacation ? 1 : 0), '');
     $field_id = 'vacation';
     $input_autorespondermessage = new html_textarea(array('name' => 'vacation', 'id' => $field_id, 'class' => 'textarea'));
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('autorespondermessage')), $input_autorespondermessage->show($vacation), '<br /><span class="vexim-explanation">' . $this->gettext('autorespondermessageexplanation') . '</span>');
     $out .= '</table>';
     $out .= '</div></fieldset>' . "\n\n";
     // =====================================================================================================
     // Forward
     $out .= '<fieldset><legend>' . $this->gettext('forwarding') . '</legend>' . "\n";
     $out .= '<div class="fieldset-content">';
     $out .= '<table class="vexim-settings" cellpadding="0" cellspacing="0">';
     $field_id = 'on_forward';
     $input_forwardingenabled = new html_checkbox(array('name' => 'on_forward', 'id' => $field_id, 'value' => 1));
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('forwardingenabled')), $input_forwardingenabled->show($on_forward ? 1 : 0));
     $field_id = 'forward';
     $input_forwardingaddress = new html_inputfield(array('name' => 'forward', 'id' => $field_id, 'maxlength' => 255, 'class' => 'text-long'));
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('forwardingaddress')), $input_forwardingaddress->show($forward));
     $field_id = 'unseen';
     $input_forwardinglocal = new html_checkbox(array('name' => 'unseen', 'id' => $field_id, 'value' => 1));
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('forwardinglocal')), $input_forwardinglocal->show($unseen ? 1 : 0));
     $out .= '</table>';
     $out .= '</div></fieldset>' . "\n\n";
     // =====================================================================================================
     // Header blocks (based on code from Philip Weir's sauserprefs plugin
     //                http://roundcube.net/plugins/sauserprefs)
     $out .= '<fieldset><legend>' . $this->gettext('blockbyheader') . '</legend>' . "\n";
     $out .= '<div class="fieldset-content">';
     $out .= '<p>' . $this->gettext('blockbyheaderexplanation') . '</p>';
     $table = new html_table(array('class' => 'headerblockprefstable', 'cols' => 3));
     $field_id = 'rcmfd_headerblockrule';
     $input_headerblockrule = new html_select(array('name' => '_headerblockrule', 'id' => $field_id));
     $input_headerblockrule->add($this->gettext('headerfrom'), 'From');
     $input_headerblockrule->add($this->gettext('headerto'), 'To');
     $input_headerblockrule->add($this->gettext('headersubject'), 'Subject');
     $input_headerblockrule->add($this->gettext('headerxmailer'), 'X-Mailer');
     $field_id = 'rcmfd_headerblockvalue';
     $input_headerblockvalue = new html_inputfield(array('name' => '_headerblockvalue', 'id' => $field_id, 'style' => 'width:270px;'));
     $field_id = 'rcmbtn_add_address';
     $button_addaddress = $this->api->output->button(array('command' => 'plugin.veximaccountadmin.headerblock_add', 'type' => 'input', 'class' => 'button', 'label' => 'veximaccountadmin.addrule', 'style' => 'width: 130px;'));
     $table->add(null, $input_headerblockrule->show());
     $table->add(null, $input_headerblockvalue->show());
     $table->add(array('align' => 'right'), $button_addaddress);
     $delete_all = $this->api->output->button(array('command' => 'plugin.veximaccountadmin.headerblock_delete_all', 'type' => 'link', 'label' => 'veximaccountadmin.deleteall'));
     $table->add(array('colspan' => 3, 'id' => 'listcontrols'), $delete_all);
     $table->add_row();
     $address_table = new html_table(array('id' => 'headerblock-rules-table', 'class' => 'records-table', 'cellspacing' => '0', 'cols' => 3));
     $address_table->add_header(array('width' => '120px'), $this->gettext('field'));
     $address_table->add_header(null, $this->gettext('value'));
     $address_table->add_header(array('width' => '40px'), '&nbsp;');
     $this->_address_row($address_table, null, null, $attrib);
     // Get the header rules from DB. Should probably be put in a function.
     $this->_load_config();
     $this->_db_connect('r');
     $sql_result = $this->db->query("SELECT blockhdr, blockval \r\n\t\t   FROM   blocklists\r\n\t\t   WHERE  user_id = '{$user_id}'\r\n\t\t   AND    domain_id = '{$domain_id}'\r\n\t\t   ORDER BY block_id;");
     if ($sql_result && $this->db->num_rows($sql_result) > 0) {
         $norules = 'display: none;';
     }
     $address_table->set_row_attribs(array('style' => $norules));
     $address_table->add(array('colspan' => '3'), rep_specialchars_output($this->gettext('noaddressrules')));
     $address_table->add_row();
     $this->api->output->set_env('address_rule_count', $this->db->num_rows());
     while ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) {
         $field = $sql_arr['blockhdr'];
         $value = $sql_arr['blockval'];
         $this->_address_row($address_table, $field, $value, $attrib);
     }
     $table->add(array('colspan' => 3), html::div(array('id' => 'headerblock-rules-cont'), $address_table->show()));
     $table->add_row();
     if ($table->size()) {
         $out .= $table->show();
     }
     $out .= '</div></fieldset>' . "\n\n";
     // =====================================================================================================
     // Parameters
     $out .= '<fieldset><legend>' . $this->gettext('parameters') . '</legend>' . "\n";
     $out .= '<div class="fieldset-content">';
     $out .= '<table class="vexim-settings" cellpadding="0" cellspacing="0">';
     $field_id = 'maxmsgsize';
     $input_messagesize = new html_inputfield(array('name' => 'maxmsgsize', 'id' => $field_id, 'maxlength' => 3, 'size' => 4));
     if ($default_maxmsgsize == 0) {
         $default_maxmsgsize = $this->gettext('unlimited');
     } else {
         $default_maxmsgsize = $default_maxmsgsize . ' kb';
     }
     $out .= sprintf("<tr><th><label for=\"%s\">%s</label>:</th><td>%s%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('messagesize')), $input_messagesize->show($maxmsgsize), '<br /><span class="vexim-explanation">' . str_replace('%d', $active_domain, str_replace('%m', $default_maxmsgsize, $this->gettext('messagesizeexplanation'))) . '</span>');
     $out .= '</table>';
     $out .= '</div></fieldset>' . "\n\n";
     // =====================================================================================================
     $out .= html::p(null, $rcmail->output->button(array('command' => 'plugin.veximaccountadmin-save', 'type' => 'input', 'class' => 'button mainaction', 'label' => 'save')));
     $rcmail->output->add_gui_object('veximform', 'veximaccountadminform');
     $out = $rcmail->output->form_tag(array('id' => 'veximaccountadminform', 'name' => 'veximaccountadminform', 'method' => 'post', 'action' => './?_task=settings&_action=plugin.veximaccountadmin-save'), $out);
     $out = html::div(array('class' => 'settingsbox', 'style' => 'margin:0 0 15px 0;'), html::div(array('class' => 'boxtitle'), $this->gettext('accountadministration')) . html::div(array('style' => 'padding:15px'), $outtop . "\n" . $out . "\n" . $outbottom));
     return $out;
 }
Exemplo n.º 3
0
 /**
  * Creates ACL rights table
  *
  * @param array $attrib Template object attributes
  *
  * @return string HTML Content
  */
 private function list_rights($attrib = array())
 {
     // Get ACL for the folder
     $acl = $this->rc->storage->get_acl($this->mbox);
     if (!is_array($acl)) {
         $acl = array();
     }
     // Keep special entries (anyone/anonymous) on top of the list
     if (!empty($this->specials) && !empty($acl)) {
         foreach ($this->specials as $key) {
             if (isset($acl[$key])) {
                 $acl_special[$key] = $acl[$key];
                 unset($acl[$key]);
             }
         }
     }
     // Sort the list by username
     uksort($acl, 'strnatcasecmp');
     if (!empty($acl_special)) {
         $acl = array_merge($acl_special, $acl);
     }
     // Get supported rights and build column names
     $supported = $this->rights_supported();
     // depending on server capability either use 'te' or 'd' for deleting msgs
     $deleteright = implode(array_intersect(str_split('ted'), $supported));
     // Use advanced or simple (grouped) rights
     $advanced = $this->rc->config->get('acl_advanced_mode');
     if ($advanced) {
         $items = array();
         foreach ($supported as $sup) {
             $items[$sup] = $sup;
         }
     } else {
         $items = array('read' => 'lrs', 'write' => 'wi', 'delete' => $deleteright, 'other' => preg_replace('/[lrswi' . $deleteright . ']/', '', implode($supported)));
     }
     // Create the table
     $attrib['noheader'] = true;
     $table = new html_table($attrib);
     // Create table header
     $table->add_header('user', $this->gettext('identifier'));
     foreach (array_keys($items) as $key) {
         $label = $this->gettext('shortacl' . $key);
         $table->add_header(array('class' => 'acl' . $key, 'title' => $label), $label);
     }
     $js_table = array();
     foreach ($acl as $user => $rights) {
         if ($this->rc->storage->conn->user == $user) {
             continue;
         }
         // filter out virtual rights (c or d) the server may return
         $userrights = array_intersect($rights, $supported);
         $userid = rcube_utils::html_identifier($user);
         if (!empty($this->specials) && in_array($user, $this->specials)) {
             $user = $this->gettext($user);
         }
         $table->add_row(array('id' => 'rcmrow' . $userid));
         $table->add('user', rcube::Q($user));
         foreach ($items as $key => $right) {
             $in = $this->acl_compare($userrights, $right);
             switch ($in) {
                 case 2:
                     $class = 'enabled';
                     break;
                 case 1:
                     $class = 'partial';
                     break;
                 default:
                     $class = 'disabled';
                     break;
             }
             $table->add('acl' . $key . ' ' . $class, '');
         }
         $js_table[$userid] = implode($userrights);
     }
     $this->rc->output->set_env('acl', $js_table);
     $this->rc->output->set_env('acl_advanced', $advanced);
     $out = $table->show();
     return $out;
 }
Exemplo n.º 4
0
 public function vacation_sieve_form()
 {
     try {
         $table = new html_table(array('cols' => 2, 'class' => 'propform'));
         $format = $this->app->config->get('date_format');
         # Options
         $table->add(array('colspan' => 2, 'class' => 'section-first'), Q($this->gettext('options')));
         $table->add_row();
         $field_id = 'vacation_enable';
         $input_vacationenable = new html_checkbox(array('name' => '_vacation_enable', 'id' => $field_id, 'value' => 1));
         $table->add('title', html::label($field_id, Q($this->gettext('vacationenable'))));
         $table->add(null, $input_vacationenable->show($this->obj->is_vacation_enable() ? 1 : 0));
         $field_id = 'vacation_start';
         $input_vacationstart = new html_inputfield(array('name' => '_vacation_start', 'id' => $field_id, 'size' => 10));
         $table->add('title', html::label($field_id, Q($this->gettext('period'))));
         $vacStart = $this->obj->get_vacation_start();
         $hour_text = array();
         $hour_value = array();
         $wholeDay = Q($this->gettext('wholeday'));
         $hour_value[$wholeDay] = '';
         $hour_text[$wholeDay] = $wholeDay;
         $minHour = $this->config['working_hours'][0];
         $maxHour = $this->config['working_hours'][1];
         foreach (range($minHour, $maxHour) as $tmp_hour) {
             $hour_text[$tmp_hour] = sprintf("%02d:00", $tmp_hour);
             $hour_value[$tmp_hour] = $tmp_hour;
         }
         unset($tmp_hour);
         $field_id = 'vacation_starttime';
         $input_vacationstarttime = new html_select(array('name' => '_vacation_starttime'));
         $input_vacationstarttime->add($hour_text, $hour_value);
         $field_id = 'vacation_endtime';
         $input_vacationendtime = new html_select(array('name' => '_vacation_endtime'));
         $input_vacationendtime->add($hour_text, $hour_value);
         $field_id = 'vacation_end';
         $input_vacationend = new html_inputfield(array('name' => '_vacation_end', 'id' => $field_id, 'size' => 10));
         $vacEnd = $this->obj->get_vacation_end();
         $periodFields = $this->gettext('vacationfrom') . ' ' . $input_vacationstart->show(date($format, $vacStart)) . ' ' . $input_vacationstarttime->show($hour_text[$this->obj->get_vacation_starttime()]) . ' ' . $this->gettext('vacationto') . ' ' . $input_vacationend->show(date($format, $vacEnd)) . ' ' . $input_vacationendtime->show($hour_text[$this->obj->get_vacation_endtime()]);
         $table->add(null, $periodFields);
         $table->add_row();
         $field_id = 'every';
         $input_every = new html_inputfield(array('name' => '_every', 'id' => $field_id, 'size' => 5));
         $table->add('title', html::label($field_id, Q($this->gettext('frequency'))));
         $table->add(null, $this->gettext('answer_no_more_than_every') . ' ' . $input_every->show($this->obj->get_every()) . ' ' . $this->gettext('vacationdays'));
         $table->add_row();
         $identities = $this->get_identities();
         $default_identity = key($identities);
         $field_id = 'addressed_to';
         $input_addressed_to = new html_select(array('name' => '_addressed_to[]', 'id' => $field_id, 'multiple' => true));
         $input_addressed_to->add($identities);
         $addressedTo = $this->obj->get_addressed_to();
         $table->add('title', html::label($field_id, Q($this->gettext('addressed_to'))));
         $table->add(null, $input_addressed_to->show($addressedTo ? $addressedTo : $default_identity));
         # Subject field
         $table->add(array('colspan' => 2, 'class' => 'section'), Q($this->gettext('subject')));
         $table->add_row();
         $field_id = 'vacation_subject';
         $input_vacationsubject = new html_inputfield(array('name' => '_vacation_subject', 'id' => $field_id, 'size' => 40));
         $table->add('title', html::label($field_id, Q($this->gettext('vacationsubject'))));
         $table->add(null, $input_vacationsubject->show($this->obj->get_vacation_subject()));
         $table->add_row();
         $field_id = '_append_subject';
         $input_appendsubject = new html_checkbox(array('name' => '_append_subject', 'id' => $field_id, 'value' => 1));
         $table->add('title', html::label($field_id, Q($this->gettext('append_subject'))));
         $table->add(null, $input_appendsubject->show($this->obj->get_append_subject() ? 1 : 0));
         # Message
         $table->add(array('colspan' => 2, 'class' => 'section'), Q($this->gettext('vacationmessage')));
         $table->add_row();
         $field_id = 'send_from';
         $input_sendfrom = new html_select(array('name' => '_send_from', 'id' => $field_id));
         $input_sendfrom->add($identities);
         $sendFrom = $this->obj->get_send_from();
         $table->add('title', html::label($field_id, Q($this->gettext('send_from'))));
         $table->add(null, $input_sendfrom->show($sendFrom ? $sendFrom : $default_identity));
         # Add the HTML Row
         $table->add_row();
         $field_id = 'vacation_message';
         if ($this->config['msg_format'] == 'html') {
             $this->app->output->add_label('converting', 'editorwarning');
             rcube_html_editor('identity');
             $text_vacationmessage = new html_textarea(array('name' => '_vacation_message', 'id' => $field_id, 'spellcheck' => 1, 'rows' => 6, 'cols' => 40, 'class' => 'mce_editor'));
         } else {
             $text_vacationmessage = new html_textarea(array('name' => '_vacation_message', 'id' => $field_id, 'spellcheck' => 1, 'rows' => 6, 'cols' => 40));
         }
         #
         $table->add('top title', html::label($field_id, Q($this->gettext('vacationmessage'))));
         $table->add(null, $text_vacationmessage->show($this->obj->get_vacation_message()));
         # Get the HTML
         $tableHtml = $table->show();
         $submitLine = html::p(null, $this->app->output->button(array('command' => 'plugin.vacation_sieve-save', 'type' => 'input', 'class' => 'button mainaction', 'label' => 'save')));
         # First line
         $boxTitle = html::div(array('id' => "prefs-title", 'class' => 'boxtitle'), $this->gettext('vacation'));
         $out = html::div(array('class' => 'box'), $boxTitle . html::div(array('class' => "boxcontent"), $tableHtml . $submitLine));
         $this->app->output->add_gui_object('vacationsieveform', 'vacation_sieve_form');
         return $this->app->output->form_tag(array('id' => 'vacation_sieve_form', 'name' => 'vacation_sieve_form', 'method' => 'post', 'action' => './?_task=settings&_action=plugin.vacation_sieve-save'), $out);
     } catch (Exception $exc) {
         $this->log_error('Fail to build form: ' . $exc->getMessage());
     }
 }
 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;
 }
Exemplo n.º 6
0
 private function _prefs_block($part, $attrib)
 {
     $rcmail = rcmail::get_instance();
     $no_override = array_flip($rcmail->config->get('sauserprefs_dont_override'));
     $locale_info = localeconv();
     switch ($part) {
         // General tests
         case 'general':
             $out = '';
             $data = '';
             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 = new html_table(array('class' => 'generalprefstable', 'cols' => 2));
                 $table->add('title', html::label($field_id, Q($this->gettext('spamthres'))));
                 $table->add(null, $input_spamthres->show(number_format($this->user_prefs['required_hits'], $decPlaces, '.', '')));
                 $data = $table->show() . Q($this->gettext('spamthresexp')) . '<br /><br />';
             }
             if (!isset($no_override['rewrite_header Subject'])) {
                 $table = new html_table(array('class' => 'generalprefstable', 'cols' => 2));
                 $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, Q($this->gettext('spamsubject'))));
                 $table->add(null, $input_spamsubject->show());
                 $table->add(null, "&nbsp;");
                 $table->add(null, Q($this->gettext('spamsubjectblank')));
                 $data .= $table->show();
             }
             if (!empty($data)) {
                 $out .= html::tag('fieldset', null, html::tag('legend', null, Q($this->gettext('mainoptions'))) . $data);
             }
             if (!isset($no_override['ok_languages']) || !isset($no_override['ok_locales'])) {
                 $data = html::p(null, Q($this->gettext('spamlangexp')));
                 $table = new html_table(array('class' => 'langprefstable', 'cols' => 2));
                 $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('colspan' => 2, 'id' => 'listcontrols'), $this->gettext('select') . ":&nbsp;&nbsp;" . $select_all . "&nbsp;&nbsp;" . $select_invert . "&nbsp;&nbsp;" . $select_none);
                 $table->add_row();
                 $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(array('colspan' => 2), html::div(array('id' => 'spam-langs-cont'), $lang_table->show()));
                 $table->add_row();
                 $out .= html::tag('fieldset', null, html::tag('legend', null, Q($this->gettext('langoptions'))) . $data . $table->show());
             }
             break;
             // Header settings
         // Header settings
         case 'headers':
             $data = html::p(null, Q($this->gettext('headersexp')));
             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 ' . 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'));
                 $data .= $input_spamreport->show($this->user_prefs['fold_headers']) . "&nbsp;" . html::label($field_id, Q($this->gettext('foldheaders'))) . $help_button . "<br />";
                 $data .= html::p(array('id' => 'fold_help', 'style' => 'display: none;'), 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 ' . 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' => JS_OBJECT_NAME . '.sauserprefs_toggle_level_char(this)'));
                 $data .= $input_spamreport->show($enabled) . "&nbsp;" . html::label($field_id, Q($this->gettext('spamlevelstars'))) . $help_button . "<br />";
                 $field_id = 'rcmfd_spamlevelchar';
                 $input_spamsubject = new html_inputfield(array('name' => '_spamlevelchar', 'id' => $field_id, 'value' => $char, 'style' => 'width:20px;', 'disabled' => $enabled ? 0 : 1));
                 $data .= html::span(array('style' => 'padding-left: 30px;'), $input_spamsubject->show() . "&nbsp;" . html::label($field_id, Q($this->gettext('spamlevelchar'))));
                 $data .= html::p(array('id' => 'level_help', 'style' => 'display: none;'), Q($this->gettext('levelhelp')));
             }
             $out = html::tag('fieldset', null, html::tag('legend', null, Q($this->gettext('mainoptions'))) . $data);
             break;
             // Test settings
         // Test settings
         case 'tests':
             $data = html::p(null, Q($this->gettext('spamtestssexp')));
             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 ' . 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'));
                 $data .= $input_spamtest->show($this->user_prefs['use_razor1']) . "&nbsp;" . html::label($field_id, Q($this->gettext('userazor1'))) . $help_button . "<br />";
                 $data .= html::p(array('id' => 'raz1_help', 'style' => 'display: none;'), 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 ' . 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'));
                 $data .= $input_spamtest->show($this->user_prefs['use_razor2']) . "&nbsp;" . html::label($field_id, Q($this->gettext('userazor2'))) . $help_button . "<br />";
                 $data .= html::p(array('id' => 'raz2_help', 'style' => 'display: none;'), 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 ' . 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'));
                 $data .= $input_spamtest->show($this->user_prefs['use_pyzor']) . "&nbsp;" . html::label($field_id, Q($this->gettext('usepyzor'))) . $help_button . "<br />";
                 $data .= html::p(array('id' => 'pyz_help', 'style' => 'display: none;'), 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 ' . 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'));
                 $data .= $input_spamtest->show($this->user_prefs['use_dcc']) . "&nbsp;" . html::label($field_id, Q($this->gettext('usedcc'))) . $help_button . "<br />";
                 $data .= html::p(array('id' => 'dcc_help', 'style' => 'display: none;'), 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 ' . 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'));
                 $data .= $input_spamtest->show($enabled) . "&nbsp;" . html::label($field_id, Q($this->gettext('skiprblchecks'))) . $help_button . "<br />";
                 $data .= html::p(array('id' => 'rbl_help', 'style' => 'display: none;'), Q($this->gettext('rblhelp')));
             }
             $out = html::tag('fieldset', null, html::tag('legend', null, Q($this->gettext('mainoptions'))) . $data);
             break;
             // Bayes settings
         // Bayes settings
         case 'bayes':
             $data = html::p(null, Q($this->gettext('bayeshelp')));
             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 '. 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' => JS_OBJECT_NAME . '.sauserprefs_toggle_bayes(this)'));
                 $data .= $input_spamtest->show($this->user_prefs['use_bayes']) . "&nbsp;" . html::label($field_id, Q($this->gettext('usebayes')));
                 if (strlen($rcmail->config->get('sauserprefs_bayes_delete_query')) > 0) {
                     $data .= "&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')));
                 }
                 $data .= "<br />";
                 //$data .= html::p(array('id' => 'bayes_help', 'style' => 'display: none;'), 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 ' . 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));
                 $data .= $input_spamtest->show($this->user_prefs['use_bayes_rules']) . "&nbsp;" . html::label($field_id, Q($this->gettext('bayesrules'))) . $help_button . "<br />";
                 $data .= html::p(array('id' => 'bayesrules_help', 'style' => 'display: none;'), 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 ' . 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' => JS_OBJECT_NAME . '.sauserprefs_toggle_bayes_auto(this)', 'disabled' => $this->user_prefs['use_bayes'] ? 0 : 1));
                 $data .= $input_spamtest->show($this->user_prefs['bayes_auto_learn']) . "&nbsp;" . html::label($field_id, Q($this->gettext('bayesautolearn'))) . $help_button . "<br />";
                 $data .= html::p(array('id' => 'bayesauto_help', 'style' => 'display: none;'), Q($this->gettext('bayesautohelp')));
             }
             $out = html::tag('fieldset', null, html::tag('legend', null, Q($this->gettext('mainoptions'))) . $data);
             $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 = new html_table(array('class' => 'generalprefstable', 'cols' => 2));
                 $table->add('title', html::label($field_id, Q($this->gettext('bayesnonspam'))));
                 $table->add(null, $input_bayesnthres->show(number_format($this->user_prefs['bayes_auto_learn_threshold_nonspam'], $decPlaces, '.', '')));
                 $data .= $table->show() . Q($this->gettext('bayesnonspamexp')) . '<br /><br />';
             }
             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 = new html_table(array('class' => 'generalprefstable', 'cols' => 2));
                 $table->add('title', html::label($field_id, Q($this->gettext('bayesspam'))));
                 $table->add(null, $input_bayesthres->show(number_format($this->user_prefs['bayes_auto_learn_threshold_spam'], $decPlaces, '.', '')));
                 $data .= $table->show() . Q($this->gettext('bayesspamexp')) . '<br />';
             }
             $out .= html::tag('fieldset', null, html::tag('legend', null, Q($this->gettext('bayesautooptions'))) . $data);
             break;
             // Report settings
         // Report settings
         case 'report':
             $data = html::p(null, Q($this->gettext('spamreport')));
             if (!isset($no_override['report_safe'])) {
                 $field_id = 'rcmfd_spamreport';
                 $input_spamreport0 = new html_radiobutton(array('name' => '_spamreport', 'id' => $field_id . '_0', 'value' => '0'));
                 $data .= $input_spamreport0->show($this->user_prefs['report_safe']) . "&nbsp;" . html::label($field_id . '_0', Q($this->gettext('spamreport0'))) . "<br />";
                 $input_spamreport1 = new html_radiobutton(array('name' => '_spamreport', 'id' => $field_id . '_1', 'value' => '1'));
                 $data .= $input_spamreport1->show($this->user_prefs['report_safe']) . "&nbsp;" . html::label($field_id . '_1', Q($this->gettext('spamreport1'))) . "<br />";
                 $input_spamreport2 = new html_radiobutton(array('name' => '_spamreport', 'id' => $field_id . '_2', 'value' => '2'));
                 $data .= $input_spamreport2->show($this->user_prefs['report_safe']) . "&nbsp;" . html::label($field_id . '_2', Q($this->gettext('spamreport2'))) . "<br />";
             }
             $out = html::tag('fieldset', null, html::tag('legend', null, Q($this->gettext('mainoptions'))) . $data);
             break;
             // Address settings
         // Address settings
         case 'addresses':
             $data = html::p(null, Q($this->gettext('whitelistexp')));
             if ($rcmail->config->get('sauserprefs_whitelist_sync')) {
                 $data .= Q($this->gettext('autowhitelist')) . "<br /><br />";
             }
             $table = new html_table(array('class' => 'addressprefstable', 'cols' => 3));
             $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', 'style' => 'width: 75px;'));
             $table->add(null, $input_spamaddressrule->show());
             $table->add(null, $input_spamaddress->show());
             $table->add(array('align' => 'right'), $button_addaddress);
             $table->add(array('colspan' => 3), "&nbsp;");
             $table->add_row();
             $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' => 3, 'id' => 'listcontrols'), $import . "&nbsp;&nbsp;" . $delete_all);
             $table->add_row();
             $address_table = new html_table(array('id' => 'address-rules-table', 'class' => 'records-table', 'cellspacing' => '0', 'cols' => 3));
             $address_table->add_header(array('width' => '180px'), $this->gettext('rule'));
             $address_table->add_header(null, $this->gettext('email'));
             $address_table->add_header(array('width' => '40px'), '&nbsp;');
             $this->_address_row($address_table, null, null, $attrib);
             $sql_result = $this->db->query("SELECT " . $rcmail->config->get('sauserprefs_sql_preference_field') . ", " . $rcmail->config->get('sauserprefs_sql_value_field') . "\n\t\t\t\tFROM   " . $rcmail->config->get('sauserprefs_sql_table_name') . "\n\t\t\t\tWHERE  " . $rcmail->config->get('sauserprefs_sql_username_field') . " = '" . $_SESSION['username'] . "'\n\t\t\t\tAND   (" . $rcmail->config->get('sauserprefs_sql_preference_field') . " = 'whitelist_from'\n\t\t\t\tOR     " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = 'blacklist_from'\n\t\t\t\tOR     " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = 'whitelist_to')\n\t\t\t\tORDER BY " . $rcmail->config->get('sauserprefs_sql_value_field') . ";");
             if ($sql_result && $this->db->num_rows($sql_result) > 0) {
                 $norules = 'display: none;';
             }
             $address_table->set_row_attribs(array('style' => $norules));
             $address_table->add(array('colspan' => '3'), rep_specialchars_output($this->gettext('noaddressrules')));
             $address_table->add_row();
             $this->api->output->set_env('address_rule_count', $this->db->num_rows());
             while ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) {
                 $field = $sql_arr[$rcmail->config->get('sauserprefs_sql_preference_field')];
                 $value = $sql_arr[$rcmail->config->get('sauserprefs_sql_value_field')];
                 $this->_address_row($address_table, $field, $value, $attrib);
             }
             $table->add(array('colspan' => 3), html::div(array('id' => 'address-rules-cont'), $address_table->show()));
             $table->add_row();
             if ($table->size()) {
                 $out = html::tag('fieldset', null, html::tag('legend', null, Q($this->gettext('mainoptions'))) . $data . $table->show());
             }
             break;
         default:
             $out = '';
     }
     return $out;
 }
Exemplo n.º 7
0
 /**
  * Label list to folder list menu and set flags in imap conn
  *
  * @access  public
  */
 function folder_list_label($args)
 {
     $args['content'] .= html::div(array('id' => 'labels-title', 'class' => 'boxtitle label_header_menu'), $this->gettext('label_title') . html::tag('span', array('class' => 'drop_arrow'), ''));
     $prefs = $this->rc->config->get('message_label', array());
     if (!strlen($attrib['id'])) {
         $attrib['id'] = 'labellist';
     }
     $display_label = $this->rc->config->get('message_label_display');
     if ($display_label == 'false') {
         $style = 'display: none;';
     }
     if (count($prefs) > 0) {
         $table = new html_table($attrib);
         foreach ($prefs as $p) {
             $table->add_row(array('id' => 'rcmrow' . $p['id'], 'class' => 'labels_row'));
             $table->add(array('class' => 'labels_color'), html::tag('span', array('class' => 'lmessage', 'style' => 'background-color:' . $p['color']), ''));
             $table->add(array('class' => 'labels_name'), $p['text']);
         }
         $args['content'] .= html::div(array('class' => 'lmenu', 'id' => 'drop_labels', 'style' => $style), $table->show($attrib));
     } else {
         $args['content'] .= html::div('lmenu', html::a(array('href' => '#', 'onclick' => 'return rcmail.command(\'plugin.label_redirect\',\'true\',true)'), $this->gettext('label_create')));
     }
     $flags = array();
     foreach ($prefs as $prefs_val) {
         $flags += array(strtoupper($prefs_val['id']) => '$labels_' . $prefs_val['id']);
     }
     $this->rc->imap->conn->flags = array_merge($this->rc->imap->conn->flags, $flags);
     //write_log('debug', preg_replace('/\r\n$/', '', print_r($this->rc->imap->conn->flags,true)));
     // add id to message label table if not specified
     $this->rc->output->add_gui_object('labellist', $attrib['id']);
     return $args;
 }
Exemplo n.º 8
0
 function filters_form()
 {
     $this->rc->imap_connect();
     $table = new html_table(array('cols' => 4));
     $table->add('title', Q($this->gettext('whatfilter') . ":"));
     $select = new html_select(array('name' => '_whatfilter', 'id' => 'whatfilter'));
     $select->add($this->gettext('from'), 'from');
     $select->add($this->gettext('to'), 'to');
     $select->add($this->gettext('cc'), 'cc');
     $select->add($this->gettext('subject'), 'subject');
     $table->add('', $select->show($this->gettext('from')));
     $table->add_row();
     $table->add('title', Q($this->gettext('searchstring') . ":"));
     $inputfield = new html_inputfield(array('name' => '_searchstring', 'id' => 'searchstring'));
     $table->add('', $inputfield->show(""));
     $table->add('title', Q($this->gettext('casesensitive') . ":"));
     $checkbox = new html_checkbox(array('name' => '_casesensitive', 'id' => 'casesensitive', 'value' => '1'));
     $casesensitive = $this->rc->config->get('caseInsensitiveSearch', true);
     $table->add('', $checkbox->show($casesensitive ? 1 : 0));
     $table->add_row();
     $table->add('title', Q($this->gettext('moveto') . ":"));
     $select = rcmail_mailbox_select(array('name' => '_folders', 'id' => 'folders'));
     $table->add('title', $select->show());
     $table->add_row();
     # new option: all, read and unread messages
     $table->add('title', Q($this->gettext('messagecount') . ":"));
     $select = new html_select(array('name' => '_messages', 'id' => 'messages'));
     $select->add($this->gettext('all'), 'all');
     $select->add($this->gettext('unread'), 'unread');
     $select->add($this->gettext('markread'), 'markread');
     $table->add('', $select->show($this->gettext('all')));
     // get mailbox list
     $a_folders = $this->rc->imap->list_mailboxes('', '*');
     $delimiter = $this->rc->imap->get_hierarchy_delimiter();
     $a_mailboxes = array();
     foreach ($a_folders as $folder) {
         rcmail_build_folder_tree($a_mailboxes, $folder, $delimiter);
     }
     // load saved filters
     $user = $this->rc->user;
     $arr_prefs = $user->get_prefs();
     $i = 1;
     $flag = false;
     $table2 = new html_table(array('cols' => 2));
     //To prevent PHP Warning when no filter already set
     if (!empty($arr_prefs['filters'])) {
         foreach ($arr_prefs['filters'] as $key => $saved_filter) {
             $flag = true;
             $folder_id = $saved_filter['destfolder'];
             $folder_name = "";
             if (strtoupper($folder_id) == 'INBOX') {
                 $folder_name = rcube_label('inbox');
             } else {
                 foreach ($a_mailboxes as $folder => $vet) {
                     if ($vet['id'] == $folder_id) {
                         $folder_name = $vet['name'];
                         break;
                     }
                 }
             }
             $messages = $saved_filter['messages'];
             $msg = $i . " - " . $this->gettext('msg_if_field') . " <b>" . $this->gettext($saved_filter['whatfilter']) . "</b> " . $this->gettext('msg_contains') . " <b>" . $saved_filter['searchstring'] . "</b> " . ($saved_filter['casesensitive'] == '1' ? $this->gettext('msg_and_is') . " <b>" . $this->gettext('casesensitive') . "</b> " : "") . $this->gettext('msg_move_msg_in') . " <b>" . $folder_name . "</b> " . "(" . $this->gettext('messagecount') . ": " . $this->gettext($saved_filter['messages']) . ")";
             $table2->add('title', $msg);
             $dlink = "<a href='./?_task=settings&_action=plugin.filters-delete&filterid=" . $key . "'>" . $this->gettext('delete') . "</a>";
             $table2->add('title', $dlink);
             $i++;
         }
     }
     if (!$flag) {
         $table2->add('title', Q($this->gettext('msg_no_stored_filters')));
     }
     $out = html::div(array('class' => 'box'), html::div(array('id' => 'prefs-title', 'class' => 'boxtitle'), $this->gettext('filters')) . html::div(array('class' => 'boxcontent'), $table->show() . html::p(null, $this->rc->output->button(array('command' => 'plugin.filters-save', 'type' => 'input', 'class' => 'button mainaction', 'label' => 'save')))));
     $out .= html::div(array('id' => 'prefs-title', 'class' => 'boxtitle'), $this->gettext('storedfilters')) . html::div(array('class' => 'uibox listbox scroller', 'style' => 'margin-top:205px;'), html::div(array('class' => 'boxcontent'), $table2->show()));
     $this->rc->output->add_gui_object('filtersform', 'filters-form');
     return $this->rc->output->form_tag(array('id' => 'filters-form', 'name' => 'filters-form', 'method' => 'post', 'action' => './?_task=settings&_action=plugin.filters-save'), $out);
 }