Exemplo n.º 1
0
 function accounts_form_content($email = "", $username = "", $password = "", $server = "", $port = "", $useSSL = 'none', $leave_a_copy = true, $provider = "", $default_folder = "", $show_import_old_messages_option = true)
 {
     $rcmail = rcmail::get_instance();
     $this->include_script('pop3fetcher_providers.js');
     // allow the following attributes to be added to the <table> tag
     $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary'));
     // return the complete edit form as table
     $user = $rcmail->user->data['username'];
     if ($_SESSION['global_alias']) {
         $user = $_SESSION['global_alias'];
     }
     if ($email != "") {
         $out .= '<fieldset><legend>' . $email . ' ::: ' . $user . '</legend>' . "\n";
     } else {
         $out .= '<fieldset>' . "\n";
     }
     $out .= '<br />' . "\n";
     $out .= '<table' . $attrib_str . ">\n";
     //<script type=\"text/javascript\">console.log(providers['gmail.com']);</script>
     $field_id = 'pop3fetcher_email';
     $input_pop3fetcher_email = new html_inputfield(array('autocomplete' => 'off', 'name' => '_pop3fetcher_email', 'id' => $field_id, 'size' => 30));
     $out .= sprintf("<tr><td valign=\"middle\" class=\"title\"><label for=\"%s\">%s</label>:</td><td colspan=\"3\">%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('account_email')), $input_pop3fetcher_email->show($email));
     $field_id = 'pop3fetcher_username';
     $input_pop3fetcher_username = new html_inputfield(array('autocomplete' => 'off', 'name' => '_pop3fetcher_username', 'id' => $field_id, 'size' => 30));
     $out .= sprintf("<tr><td valign=\"middle\" class=\"title\"><label for=\"%s\">%s</label>:</td><td colspan=\"3\">%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('account_username')), $input_pop3fetcher_username->show($username));
     $field_id = 'pop3fetcher_password';
     $input_pop3fetcher_password = new html_passwordfield(array('autocomplete' => 'off', 'name' => '_pop3fetcher_password', 'id' => $field_id, 'size' => 30));
     $out .= sprintf("<tr><td valign=\"middle\" class=\"title\"><label for=\"%s\">%s</label>:</td><td colspan=\"3\">%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('account_password')), $input_pop3fetcher_password->show($password));
     $field_id = 'pop3fetcher_provider';
     $input_pop3fetcher_provider = new html_select(array('name' => '_pop3fetcher_provider', 'id' => $field_id));
     $out .= sprintf("<tr><td valign=\"middle\" class=\"title\"><label for=\"%s\">%s</label>:</td><td colspan=\"3\">%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('account_provider')), $input_pop3fetcher_provider->show());
     $field_id = 'pop3fetcher_serveraddress';
     $input_pop3fetcher_serveraddress = new html_inputfield(array('autocomplete' => 'off', 'name' => '_pop3fetcher_serveraddress', 'id' => $field_id, 'size' => 30));
     $out .= sprintf("<tr><td valign=\"middle\" class=\"title\"><label for=\"%s\">%s</label>:</td><td colspan=\"3\">%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('account_serveraddress')), $input_pop3fetcher_serveraddress->show($server));
     $field_id = 'pop3fetcher_serverport';
     $input_pop3fetcher_serverport = new html_inputfield(array('autocomplete' => 'off', 'name' => '_pop3fetcher_serverport', 'id' => $field_id, 'size' => 10));
     $field_id2 = 'pop3fetcher_ssl';
     $input_pop3fetcher_ssl = new html_select(array('name' => '_pop3fetcher_ssl', 'id' => $field_id2));
     $input_pop3fetcher_ssl->add('none', '');
     $input_pop3fetcher_ssl->add('tls', 'tls');
     $input_pop3fetcher_ssl->add('ssl', 'ssl');
     $input_pop3fetcher_ssl->add('sslv2', 'sslv2');
     $input_pop3fetcher_ssl->add('sslv3', 'sslv3');
     $out .= sprintf("<tr><td valign=\"middle\" class=\"title\"><label for=\"%s\">%s</label>:</td><td>%s</td><td valign=\"middle\" class=\"title\"><label for=\"%s\">%s</label>:</td><td>%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('account_serverport')), $input_pop3fetcher_serverport->show($port), $field_id2, rep_specialchars_output($this->gettext('account_usessl')), $input_pop3fetcher_ssl->show($useSSL));
     $field_id = 'pop3fetcher_leaveacopy';
     $input_pop3fetcher_leaveacopy = new html_checkbox(array('name' => '_pop3fetcher_leaveacopy', 'id' => $field_id));
     $out .= sprintf("<tr><td valign=\"middle\" colspan=\"3\" class=\"title\"><label for=\"%s\">%s</label>:</td><td>%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('account_leaveacopy')), $input_pop3fetcher_leaveacopy->show($leave_a_copy ? false : true));
     // QUESTA COSA E' STRANA MA FUNZIONA...
     // SET TARGET DEFAULT FOLDER
     $field_id = 'pop3fetcher_defaultfolder';
     $this->rcmail->imap_connect();
     // get mailbox list
     $a_folders = $rcmail->imap->list_folders();
     $delimiter = $rcmail->imap->get_hierarchy_delimiter();
     $a_mailboxes = array();
     $custom_folder_name = $this->config["root_folder_path"] . $delimiter . str_replace($delimiter, "_", $email);
     $found = false;
     foreach ($a_folders as $ifolder) {
         if ($ifolder == $custom_folder_name) {
             $found = true;
         }
         rcmail_build_folder_tree($a_mailboxes, $ifolder, $delimiter);
     }
     $input_folderlist = new html_select(array('name' => '_pop3fetcher_defaultfolder', 'id' => $field_id));
     rcmail_render_folder_tree_select($a_mailboxes, $field_id, 100, $input_folderlist, false);
     if (!$found && $default_folder != "" && $default_folder != $custom_folder_name) {
         $input_folderlist->add(str_replace($delimiter, "_", $email), "#AUTO_FOLDER#");
     }
     //$input_folderlist->add('create new folder', 'create_new_folder');
     $out .= sprintf("<tr><td valign=\"middle\" class=\"title\"><label for=\"%s\">%s</label>:</td><td colspan=\"3\">%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('account_default_folder')), $input_folderlist->show($default_folder));
     $field_id = 'pop3fetcher_testconnection';
     $input_pop3fetcher_testconnection = new html_checkbox(array('name' => '_pop3fetcher_testconnection', 'id' => $field_id));
     $out .= sprintf("<tr><td valign=\"middle\" colspan=\"3\" class=\"title\"><label for=\"%s\">%s</label>:</td><td>%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('test_connection_on_save')), $input_pop3fetcher_testconnection->show(false));
     // QUESTA COSA E' STRANA MA FUNZIONA...
     if ($show_import_old_messages_option) {
         $field_id = 'pop3fetcher_import_old_messages';
         $input_pop3fetcher_import_old_messages = new html_checkbox(array('name' => '_pop3fetcher_import_old_messages', 'id' => $field_id));
         $out .= sprintf("<tr><td valign=\"middle\" colspan=\"3\" class=\"title\"><label for=\"%s\">%s</label>:</td><td>%s</td></tr>\n", $field_id, rep_specialchars_output($this->gettext('account_import_old_messages')), $input_pop3fetcher_import_old_messages->show(true));
         // QUESTA COSA E' STRANA MA FUNZIONA...
     }
     $out .= "\n</table>";
     $out .= '<br />' . "\n";
     $out .= "</fieldset>\n";
     $out .= "<script type='text/javascript'>\n\t\t\t\tvar delimiter = '" . $delimiter . "';\n\t\t\t\tvar root_folder_path = '" . $this->config["root_folder_path"] . "';\n\t\t\t\tload_pop3_providers('" . $provider . "');\n\t\t\t\t\$('#pop3fetcher_email').keyup(\n\t\t\t\t\tfunction(){update_default_folder_name(\$(this).val());}\n\t\t\t\t);\n\t\t\t</script>";
     return $out;
 }
Exemplo n.º 2
0
 /**
  * Create row label
  *
  * @access  private
  */
 private function get_form_row($id = '', $header = 'from', $folder = 'all', $input = '', $color = '#000000', $text = '', $delete = false)
 {
     $this->add_texts('localization');
     if (!$text) {
         $text = Q($this->gettext('label_name'));
     }
     //if (!$input) $input = Q($this->gettext('label_matches'));
     if (!$id) {
         $id = uniqid();
     }
     if (!$folder) {
         $folder = 'all';
     }
     // header select box
     $header_select = new html_select(array('name' => '_label_header[]', 'class' => 'label_header'));
     $header_select->add(Q($this->gettext('subject')), 'subject');
     $header_select->add(Q($this->gettext('from')), 'from');
     $header_select->add(Q($this->gettext('to')), 'to');
     $header_select->add(Q($this->gettext('cc')), 'cc');
     // folder search select
     $folder_search = new html_select(array('name' => '_folder_search[]', 'class' => 'folder_search'));
     $p = array('maxlength' => 100, 'realnames' => false);
     // get mailbox list
     $a_folders = $this->rc->storage->list_folders_subscribed();
     $delimiter = $this->rc->storage->get_hierarchy_delimiter();
     $a_mailboxes = array();
     foreach ($a_folders as $folder_list) {
         rcmail_build_folder_tree($a_mailboxes, $folder_list, $delimiter);
     }
     $folder_search->add(Q($this->gettext('label_all')), 'all');
     rcmail_render_folder_tree_select($a_mailboxes, $mbox, $p['maxlength'], $folder_search, $p['realnames']);
     // input field
     $search_info_text = $this->gettext('search_info');
     $input = new html_inputfield(array('name' => '_label_input[]', 'type' => 'text', 'autocomplete' => 'off', 'class' => 'watermark linput', 'value' => $input));
     $text = html::tag('input', array('name' => '_label_text[]', 'type' => 'text', 'title' => $search_info_text, 'class' => 'watermark linput', 'value' => $text));
     $select_color = html::tag('input', array('id' => $id, 'name' => '_label_color[]', 'type' => 'hidden', 'text' => 'hidden', 'class' => 'label_color_input', 'value' => $color));
     $id_field = html::tag('input', array('name' => '_label_id[]', 'type' => 'hidden', 'value' => $id));
     if (!$delete) {
         $button = html::a(array('href' => '#cc', 'class' => 'lhref', 'onclick' => 'return rcmail.command(\'save\',\'\',this)'), $this->gettext('add_row'));
     } else {
         $button = html::a(array('href' => '#cc', 'class' => 'lhref', 'onclick' => 'return rcmail.command(\'plugin.label_delete_row\',\'' . $id . '\')'), $this->gettext('delete_row'));
     }
     $content = $select_color . "&nbsp;" . $text . "&nbsp;" . $header_select->show($header) . "&nbsp;" . $this->gettext('label_matches') . "&nbsp;" . $input->show() . "&nbsp;" . $id_field . "&nbsp;" . $this->gettext('label_folder') . "&nbsp;" . $folder_search->show($folder) . "&nbsp;" . $button;
     return $content;
 }
 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.º 4
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);
 }