private function _address_row($address_table, $field, $value, $attrib)
 {
     if (!isset($field)) {
         $address_table->set_row_attribs(array('style' => 'display: none;'));
     }
     $hidden_action = new html_hiddenfield(array('name' => '_address_rule_act[]', 'value' => ''));
     $hidden_field = new html_hiddenfield(array('name' => '_address_rule_field[]', 'value' => $field));
     $hidden_text = new html_hiddenfield(array('name' => '_address_rule_value[]', 'value' => $value));
     switch ($field) {
         case "whitelist_from":
             $fieldtxt = rcube_utils::rep_specialchars_output($this->gettext('whitelist_from'));
             break;
         case "blacklist_from":
             $fieldtxt = rcube_utils::rep_specialchars_output($this->gettext('blacklist_from'));
             break;
         case "whitelist_to":
             $fieldtxt = rcube_utils::rep_specialchars_output($this->gettext('whitelist_to'));
             break;
     }
     $address_table->add(array('class' => $field), $fieldtxt);
     $address_table->add(array('class' => 'email'), $value);
     $del_button = $this->api->output->button(array('command' => 'plugin.sauserprefs.addressrule_del', 'type' => 'link', 'class' => 'delete', 'label' => 'delete', 'content' => ' '));
     $address_table->add('control', $del_button . $hidden_action->show() . $hidden_field->show() . $hidden_text->show());
     return $address_table;
 }
Beispiel #2
0
 /**
  * Callback function to produce driver-specific calendar create/edit form
  *
  * @param string Request action 'form-edit|form-new'
  * @param array  Calendar properties (e.g. id, color)
  * @param array  Edit form fields
  *
  * @return string HTML content of the form
  */
 public function calendar_form($action, $calendar, $formfields)
 {
     // show default dialog for birthday calendar
     if (in_array($calendar['id'], array(self::BIRTHDAY_CALENDAR_ID, self::INVITATIONS_CALENDAR_PENDING, self::INVITATIONS_CALENDAR_DECLINED))) {
         if ($calendar['id'] != self::BIRTHDAY_CALENDAR_ID) {
             unset($formfields['showalarms']);
         }
         return parent::calendar_form($action, $calendar, $formfields);
     }
     if ($calendar['id'] && ($cal = $this->calendars[$calendar['id']])) {
         $folder = $cal->get_realname();
         // UTF7
         $color = $cal->get_color();
     } else {
         $folder = '';
         $color = '';
     }
     $hidden_fields[] = array('name' => 'oldname', 'value' => $folder);
     $storage = $this->rc->get_storage();
     $delim = $storage->get_hierarchy_delimiter();
     $form = array();
     if (strlen($folder)) {
         $path_imap = explode($delim, $folder);
         array_pop($path_imap);
         // pop off name part
         $path_imap = implode($path_imap, $delim);
         $options = $storage->folder_info($folder);
     } else {
         $path_imap = '';
     }
     // General tab
     $form['props'] = array('name' => $this->rc->gettext('properties'));
     // Disable folder name input
     if (!empty($options) && ($options['norename'] || $options['protected'])) {
         $input_name = new html_hiddenfield(array('name' => 'name', 'id' => 'calendar-name'));
         $formfields['name']['value'] = kolab_storage::object_name($folder) . $input_name->show($folder);
     }
     // calendar name (default field)
     $form['props']['fieldsets']['location'] = array('name' => $this->rc->gettext('location'), 'content' => array('name' => $formfields['name']));
     if (!empty($options) && ($options['norename'] || $options['protected'])) {
         // prevent user from moving folder
         $hidden_fields[] = array('name' => 'parent', 'value' => $path_imap);
     } else {
         $select = kolab_storage::folder_selector('event', array('name' => 'parent', 'id' => 'calendar-parent'), $folder);
         $form['props']['fieldsets']['location']['content']['path'] = array('id' => 'calendar-parent', 'label' => $this->cal->gettext('parentcalendar'), 'value' => $select->show(strlen($folder) ? $path_imap : ''));
     }
     // calendar color (default field)
     $form['props']['fieldsets']['settings'] = array('name' => $this->rc->gettext('settings'), 'content' => array('color' => $formfields['color'], 'showalarms' => $formfields['showalarms']));
     if ($action != 'form-new') {
         $form['sharing'] = array('name' => rcube::Q($this->cal->gettext('tabsharing')), 'content' => html::tag('iframe', array('src' => $this->cal->rc->url(array('_action' => 'calendar-acl', 'id' => $calendar['id'], 'framed' => 1)), 'width' => '100%', 'height' => 350, 'border' => 0, 'style' => 'border:0'), ''));
     }
     $this->form_html = '';
     if (is_array($hidden_fields)) {
         foreach ($hidden_fields as $field) {
             $hiddenfield = new html_hiddenfield($field);
             $this->form_html .= $hiddenfield->show() . "\n";
         }
     }
     // Create form output
     foreach ($form as $tab) {
         if (!empty($tab['fieldsets']) && is_array($tab['fieldsets'])) {
             $content = '';
             foreach ($tab['fieldsets'] as $fieldset) {
                 $subcontent = $this->get_form_part($fieldset);
                 if ($subcontent) {
                     $content .= html::tag('fieldset', null, html::tag('legend', null, rcube::Q($fieldset['name'])) . $subcontent) . "\n";
                 }
             }
         } else {
             $content = $this->get_form_part($tab);
         }
         if ($content) {
             $this->form_html .= html::tag('fieldset', null, html::tag('legend', null, rcube::Q($tab['name'])) . $content) . "\n";
         }
     }
     // Parse form template for skin-dependent stuff
     $this->rc->output->add_handler('calendarform', array($this, 'calendar_form_html'));
     return $this->rc->output->parse('calendar.kolabform', false, false);
 }
Beispiel #3
0
 /**
  * Add UI element to copy event invitations or updates to the calendar
  */
 public function mail_messagebody_html($p)
 {
     // load iCalendar functions (if necessary)
     if (!empty($this->ics_parts)) {
         $this->get_ical();
     }
     $html = '';
     foreach ($this->ics_parts as $mime_id) {
         $part = $this->message->mime_parts[$mime_id];
         $charset = $part->ctype_parameters['charset'] ? $part->ctype_parameters['charset'] : RCMAIL_CHARSET;
         $events = $this->ical->import($this->message->get_part_content($mime_id), $charset);
         $title = $this->gettext('title');
         $date = rcube_utils::anytodatetime($this->message->headers->date);
         // successfully parsed events?
         if (empty($events)) {
             continue;
         }
         // show a box for every event in the file
         foreach ($events as $idx => $event) {
             // Begin mod by Rosali (Google sends the ics inline and attached -> avoid duplicates with same UID - https://issues.kolab.org/show_bug.cgi?id=3585)
             $uid = $event['uid'] ? $event['uid'] : md5(serialize($event));
             if (isset($this->ics_parts_filtered[$uid])) {
                 continue;
             }
             $this->ics_parts_filtered[$uid] = 1;
             // End mod by Rosali
             if ($event['_type'] != 'event' && $event['_type'] != 'task') {
                 // skip non-event objects (#2928) // Mod by Rosali (don't skip tasks)
                 continue;
             }
             // define buttons according to method
             if ($this->ical->method == 'REPLY') {
                 $driver = $this->get_default_driver();
                 $existing = $driver->get_event($event['uid']);
                 $calendar_saveto = new html_hiddenfield(array('class' => 'calendar-saveto', 'value' => $existing['calendar']));
                 // Mod by Rosali (always pass calendar to GUI)
                 if ($calendar_saveto) {
                     $title = $this->gettext('itipreply');
                     $buttons = html::tag('input', array('type' => 'button', 'class' => 'button', 'onclick' => "rcube_calendar.add_event_from_mail('" . JQ($mime_id . ':' . $idx) . "', this)", 'value' => $this->gettext('updateattendeestatus'))) . $calendar_saveto->show();
                 }
             } else {
                 if ($this->ical->method == 'REQUEST') {
                     $emails = $this->get_user_emails();
                     $title = $event['sequence'] > 0 ? $this->gettext('itipupdate') : $this->gettext('itipinvitation');
                     // add (hidden) buttons and activate them from asyncronous request
                     foreach (array('accepted', 'tentative', 'declined') as $method) {
                         $rsvp_buttons .= html::tag('input', array('type' => 'button', 'class' => "button {$method}", 'onclick' => "rcube_calendar.add_event_from_mail('" . JQ($mime_id . ':' . $idx) . "', this, '{$method}')", 'value' => $this->gettext('itip' . $method)));
                     }
                     $import_button = html::tag('input', array('type' => 'button', 'class' => 'button', 'onclick' => "rcube_calendar.add_event_from_mail('" . JQ($mime_id . ':' . $idx) . "', this)", 'value' => $this->gettext('importtocalendar')));
                     // check my status
                     $status = 'unknown';
                     foreach ($event['attendees'] as $attendee) {
                         if ($attendee['email'] && in_array(strtolower($attendee['email']), $emails)) {
                             $status = !empty($attendee['status']) ? strtoupper($attendee['status']) : 'NEEDS-ACTION';
                             break;
                         }
                     }
                     $dom_id = asciiwords($event['uid'], true);
                     $buttons = html::div(array('id' => 'rsvp-' . $dom_id, 'style' => 'display:none'), $rsvp_buttons);
                     $buttons .= html::div(array('id' => 'import-' . $dom_id, 'style' => 'display:none'), $import_button);
                     $buttons_pre = html::div(array('id' => 'loading-' . $dom_id, 'class' => 'rsvp-status loading'), $this->gettext('loading'));
                     $changed = is_object($event['changed']) ? $event['changed'] : $date;
                     $script = json_serialize(array('uid' => $event['uid'], 'changed' => $changed ? $changed->format('U') : 0, 'sequence' => intval($event['sequence']), 'fallback' => $status));
                     $this->rc->output->add_script("rcube_calendar.fetch_event_rsvp_status({$script})", 'docready');
                 } else {
                     if ($this->ical->method == 'CANCEL') {
                         $title = $this->gettext('itipcancellation');
                         // create buttons to be activated from async request checking existence of this event in local calendars
                         $button_import = html::tag('input', array('type' => 'button', 'class' => 'button', 'onclick' => "rcube_calendar.add_event_from_mail('" . JQ($mime_id . ':' . $idx) . "', this)", 'value' => $this->gettext('importtocalendar')));
                         $button_remove = html::tag('input', array('type' => 'button', 'class' => 'button', 'onclick' => "rcube_calendar.remove_event_from_mail('" . JQ($event['uid']) . "', '" . JQ($event['title']) . "')", 'value' => $this->gettext('removefromcalendar')));
                         $dom_id = asciiwords($event['uid'], true);
                         $buttons = html::div(array('id' => 'rsvp-' . $dom_id, 'style' => 'display:none'), $button_remove);
                         $buttons .= html::div(array('id' => 'import-' . $dom_id, 'style' => 'display:none'), $button_import);
                         $buttons_pre = html::div(array('id' => 'loading-' . $dom_id, 'class' => 'rsvp-status loading'), $this->gettext('loading'));
                         $changed = is_object($event['changed']) ? $event['changed'] : $date;
                         $script = json_serialize(array('uid' => $event['uid'], 'changed' => $changed ? $changed->format('U') : 0, 'sequence' => intval($event['sequence']), 'fallback' => 'CANCELLED'));
                         $this->rc->output->add_script("rcube_calendar.fetch_event_rsvp_status({$script})", 'docready');
                     } else {
                         // get a list of writeable calendars
                         // Begin mod by Rosali (https://gitlab.awesome-it.de/kolab/roundcube-plugins/issues/33)
                         $driver = $this->get_default_driver();
                         $calendars = $driver->list_calendars(false, true);
                         $calendar_select = new html_select(array('name' => 'calendar', 'class' => 'calendar-saveto', 'is_escaped' => true));
                         // Mod by Rosali (calendar selector can exist multiple times - can't be referenced by ID)
                         $numcals = 0;
                         foreach ($calendars as $calendar) {
                             $driver = $this->get_driver_by_cal($calendar['calendar_id']);
                             if ($driver->readonly !== true) {
                                 $calendar_select->add($calendar['name'], $calendar['id']);
                                 $numcals++;
                             }
                         }
                     }
                 }
             }
             if ($numcals > 0) {
                 $buttons = html::tag('input', array('type' => 'button', 'class' => 'button', 'onclick' => "rcube_calendar.add_event_from_mail('" . JQ($mime_id . ':' . $idx) . "', this)", 'value' => $this->gettext('importtocalendar'))) . $calendar_select->show($this->rc->config->get('calendar_default_calendar'));
             }
             // show event details with buttons
             if ($buttons) {
                 $html .= html::div('calendar-invitebox', $this->ui->event_details_table($event, $title) . $buttons_pre . html::div('rsvp-buttons', $buttons));
             }
             // Emd mod by Rosli
             // limit listing
             if ($idx >= 3) {
                 break;
             }
         }
     }
     // prepend event boxes to message body
     if ($html) {
         $this->ui->init();
         $p['content'] = $html . $p['content'];
         $this->rc->output->add_label('calendar.savingdata', 'calendar.deleteventconfirm', 'calendar.declinedeleteconfirm');
     }
     return $p;
 }
 function gen_form()
 {
     $id = get_input_value('_id', RCUBE_INPUT_GET);
     $this->rcmail_inst->output->add_label('ispconfig3_wblist.wblistdelconfirm');
     if ($id != '' || $id != 0) {
         try {
             $session_id = $this->soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass'));
             $mail_user = $this->soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username']));
             $spam_user = $this->soap->mail_spamfilter_user_get($session_id, array('email' => $mail_user[0]['email']));
             if (get_input_value('_type', RCUBE_INPUT_GET) == "W") {
                 $wblist = $this->soap->mail_spamfilter_whitelist_get($session_id, array('wblist_id' => $id));
                 $type = "W";
             } else {
                 $wblist = $this->soap->mail_spamfilter_blacklist_get($session_id, array('wblist_id' => $id));
                 $type = "B";
             }
             $this->soap->logout($session_id);
         } catch (SoapFault $e) {
             $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error');
         }
         $enabled = $wblist[0]['active'];
         if ($wblist[0]['rid'] != $spam_user[0]['id']) {
             $this->rcmail_inst->output->command('display_message', 'Error: ' . $this->gettext('opnotpermitted'), 'error');
             $enabled = 'n';
             $wblist[0]['email'] = '';
             $wblist[0]['priority'] = '';
         }
     } else {
         $wblist[0]['priority'] = '5';
     }
     if ($enabled == 'y') {
         $enabled = 1;
     } else {
         $enabled = 0;
     }
     $this->rcmail_inst->output->set_env('framed', TRUE);
     $out .= '<fieldset><legend>' . $this->gettext('acc_wblist') . '</legend>' . "\n";
     $hidden_id = new html_hiddenfield(array('name' => '_id', 'value' => $wblist[0]['wblist_id']));
     $out .= $hidden_id->show();
     $table = new html_table(array('cols' => 2, 'class' => 'propform'));
     $input_wblistemail = new html_inputfield(array('name' => '_wblistemail', 'id' => 'wblistaddress', 'size' => 70));
     $table->add('title', rep_specialchars_output($this->gettext('email')));
     $table->add('', $input_wblistemail->show($wblist[0]['email']));
     $input_wblistwb = new html_select(array('name' => '_wblistwb', 'id' => 'wblistwb'));
     $input_wblistwb->add(array($this->gettext('wblistwhitelist'), $this->gettext('wblistblacklist')), array('W', 'B'));
     $table->add('title', rep_specialchars_output($this->gettext('wblisttype')));
     $table->add('', $input_wblistwb->show($type));
     $input_wblistpriority = new html_select(array('name' => '_wblistpriority', 'id' => 'wblistpriority'));
     $input_wblistpriority->add(array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"));
     $table->add('title', rep_specialchars_output($this->gettext('wblistpriority')));
     $table->add('', $input_wblistpriority->show($wblist[0]['priority']));
     $input_wblistenabled = new html_checkbox(array('name' => '_wblistenabled', 'id' => 'wblistenabled', 'value' => '1'));
     $table->add('title', rep_specialchars_output($this->gettext('wblistenabled')));
     $table->add('', $input_wblistenabled->show($enabled));
     $out .= $table->show();
     $out .= "</fieldset>\n";
     return $out;
 }
 /**
  * Generate the add / edit account form
  * @param type $attrib
  * @return string html of the form
  */
 function gen_form($attrib)
 {
     require_once dirname(__FILE__) . '/includes/fetchMailRc.php';
     $fetchmail_rc_id = get_input_value('_fetchmail_rc_id', RCUBE_INPUT_GET);
     $fetchmailDatas = new fetchMailRc($fetchmail_rc_id);
     // Show hidden input with the id
     $hidden_id = new html_hiddenfield(array("id" => "_fetchmail_rc_id", "name" => "_fetchmail_rc_id", "value" => $fetchmail_rc_id));
     $formToReturn .= '<form action="" id="fetchmail_rc_form" class="propform"><fieldset><legend>' . $this->gettext("configuration") . '</legend>' . ($formToReturn .= $hidden_id->show());
     $formToReturn .= '<table class="propform">';
     // Mail host
     $field_name = "_mail_host";
     $formToReturn .= '<tr><td class="title">' . html::label($field_name, Q($this->gettext('mail_host'))) . ' <span class="required">*</span></td><td>';
     $input_name = new html_inputfield(array('name' => $field_name, 'id' => $field_name, 'value' => $fetchmailDatas->get_mail_host()));
     $formToReturn .= $input_name->show() . "</td></tr>";
     // Mail host
     $field_name = "_mail_ssl";
     $formToReturn .= '<tr><td class="title">' . html::label($field_name, Q($this->gettext('mail_ssl'))) . '</td><td>';
     $input_ssl = new html_checkbox(array('name' => $field_name, 'id' => $field_name, "value" => 1));
     $formToReturn .= $input_ssl->show($fetchmailDatas->get_mail_ssl()) . "</td></tr>";
     // Mail Login
     $field_name = "_mail_username";
     $formToReturn .= '<tr><td class="title">' . html::label($field_name, Q($this->gettext('mail_username'))) . ' <span class="required">*</span></td><td>';
     $input_username = new html_inputfield(array('name' => $field_name, 'id' => $field_name, 'value' => $fetchmailDatas->get_mail_username()));
     $formToReturn .= $input_username->show() . "</td></tr>";
     // Mail password
     $field_name = "_mail_password";
     $formToReturn .= '<tr><td class="title">' . html::label($field_name, Q($this->gettext('mail_password'))) . ' <span class="required">*</span></td><td>';
     $input_password = new html_passwordfield(array('name' => $field_name, 'id' => $field_name));
     $formToReturn .= $input_password->show() . "</td></tr>";
     // Mail arguments
     $field_name = "_mail_arguments";
     $formToReturn .= '<tr><td class="title">' . html::label($field_name, Q($this->gettext('mail_arguments'))) . '</td><td>';
     $input_arguments = new html_inputfield(array('name' => $field_name, 'id' => $field_name, 'value' => $fetchmailDatas->get_mail_arguments()));
     $formToReturn .= $input_arguments->show() . "</td></tr>";
     // Mail protocol
     $field_name = "_mail_protocol";
     $formToReturn .= '<tr><td class="title">' . html::label($field_name, Q($this->gettext('mail_protocol'))) . ' <span class="required">*</span></td><td>';
     $input_protocol = new html_select(array('name' => $field_name, 'id' => $field_name));
     $input_protocol->add(fetchMailRc::PROTOCOL_AUTO, fetchMailRc::PROTOCOL_AUTO);
     $input_protocol->add(fetchMailRc::PROTOCOL_IMAP, fetchMailRc::PROTOCOL_IMAP);
     $input_protocol->add(fetchMailRc::PROTOCOL_POP2, fetchMailRc::PROTOCOL_POP2);
     $input_protocol->add(fetchMailRc::PROTOCOL_POP3, fetchMailRc::PROTOCOL_POP3);
     $formToReturn .= $input_protocol->show($fetchmailDatas->get_mail_protocol()) . "</td></tr>";
     // Mail disabled
     $field_name = "_mail_disabled";
     $formToReturn .= '<tr><td class="title">' . html::label($field_name, Q($this->gettext('mail_disabled'))) . '</td><td>';
     $input_enabled = new html_checkbox(array('name' => $field_name, 'id' => $field_name, "value" => 1));
     if ($fetchmail_rc_id) {
         $formToReturn .= $input_enabled->show(!$fetchmailDatas->get_enabled()) . "</td></tr>";
     } else {
         $formToReturn .= $input_enabled->show(0) . "</td></tr>";
     }
     $formToReturn .= "</table></fieldset>";
     // Show the test and debug block
     $formToReturn .= "<fieldset>";
     $formToReturn .= "<legend>" . $this->gettext("accountstatus") . "</legend>";
     $formToReturn .= '<table class="propform">';
     $formToReturn .= '<tr>';
     $formToReturn .= '<td class="title">' . $this->gettext("lastimport") . "</td>";
     $formToReturn .= "<td>" . $fetchmailDatas->get_date_last_retrieve() . "</td>";
     $formToReturn .= "</tr>";
     $formToReturn .= '<tr>';
     $formToReturn .= '<td class="title">' . $this->gettext("status") . "</td>";
     $statusMessage = $this->gettext("status_successful");
     if ($fetchmailDatas->get_count_errors() > 0) {
         $statusMessage = "<b>" . $this->gettext("errorlabel") . "</b> : " . $fetchmailDatas->get_last_error() . "<br />";
         $statusMessage .= "<b>" . $this->gettext("nbconsecutiveserrors") . "</b> : " . $fetchmailDatas->get_count_errors();
     }
     $formToReturn .= "<td>" . ($fetchmailDatas->get_date_last_retrieve() == "0000-00-00 00:00:00" ? $this->gettext("notalreadyautoimported") : $statusMessage) . "</td>";
     $formToReturn .= "</tr>";
     $formToReturn .= '<tr>';
     $formToReturn .= '<td class="title">' . $this->gettext("testaccount") . '</td>';
     $formToReturn .= '<td><a href="javascript:;" onclick="return rcmail.command(\'plugin.fetchmail_rc.test_account\',\'\',this)">' . $this->gettext("testaccount") . '</a></td>';
     $formToReturn .= '</tr>';
     $formToReturn .= '<tr>';
     $formToReturn .= '<td class="title">' . $this->gettext("forceretrieve") . '</td>';
     $formToReturn .= '<td><a href="javascript:;" onclick="return rcmail.command(\'plugin.fetchmail_rc.forceretrieve\',\'\',this)">' . $this->gettext("forceretrieve") . '</a></td>';
     $formToReturn .= '</tr>';
     $formToReturn .= "</table>";
     $formToReturn .= "</fieldset>";
     $formToReturn .= "</form>";
     return $formToReturn;
 }
 protected function _vacation_table($ext, $rowid, $defaults, $display, $help_icon)
 {
     $rcmail = rcube::get_instance();
     // begin vacation action
     $vacs_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 3, 'style' => $defaults['method'] == 'vacation' ? '' : 'display: none;'));
     $to_addresses = "";
     $vacto_arr = explode(",", $defaults['vacto']);
     $field_id_vacfrom = 'rcmfd_sievevacfrom_' . $rowid;
     $field_id_vacto = 'rcmfd_sievevacto_' . $rowid;
     if (count($this->identities)) {
         $select_id = new html_select(array('id' => $field_id_vacfrom, 'name' => "_vacfrom[]", 'class' => 'short', 'onchange' => rcmail_output::JS_OBJECT_NAME . '.enable_sig(this);'));
         if ($this->show_vacfrom && in_array('variables', $ext)) {
             $select_id->add($this->gettext('autodetect'), "auto");
         } elseif (!$this->show_vacfrom) {
             $select_id->add($this->gettext('autodetect'), "");
         }
         foreach ($this->identities as $sql_arr) {
             // find currently selected from address
             if ($defaults['vacfrom'] != '' && $defaults['vacfrom'] == rcmail::Q($sql_arr['from']['string'])) {
                 $defaults['vacfrom'] = $sql_arr['identity_id'];
             } elseif ($defaults['vacfrom'] != '' && $defaults['vacfrom'] == $sql_arr['from']['mailto']) {
                 $defaults['vacfrom'] = $sql_arr['identity_id'];
             }
             $select_id->add($sql_arr['from']['disp_string'], $sql_arr['identity_id']);
             $ffield_id = 'rcmfd_vac_' . $rowid . '_' . $sql_arr['identity_id'];
             if ($this->force_vacto) {
                 $curaddress = $sql_arr['email'];
                 $defaults['vacto'] .= (!empty($defaults['vacto']) ? ',' : '') . $sql_arr['email'];
             } else {
                 $curaddress = in_array($sql_arr['email'], $vacto_arr) ? $sql_arr['email'] : "";
             }
             $input_address = new html_checkbox(array('id' => $ffield_id, 'name' => '_vacto_check_' . $rowid . '[]', 'value' => $sql_arr['email'], 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_to(this, ' . $rowid . ')', 'class' => 'checkbox'));
             $to_addresses .= $input_address->show($curaddress) . "&nbsp;" . html::label($ffield_id, rcmail::Q($sql_arr['email'])) . "<br />";
         }
     }
     // deduplicate vacto list
     $tmparr = explode(",", $defaults['vacto']);
     $tmparr = array_unique($tmparr);
     $defaults['vacto'] = implode(",", $tmparr);
     if ($rcmail->config->get('sieverules_limit_vacto', true) && strlen($to_addresses) > 0) {
         $vacfrom_input = $select_id->show($defaults['vacfrom']);
         $input_vacto = new html_hiddenfield(array('id' => $field_id_vacto, 'name' => '_vacto[]', 'value' => $defaults['vacto']));
         $vacto_input = $to_addresses . $input_vacto->show();
         $vac_help = $this->gettext('vactoexp');
     } else {
         $input_vacfrom = new html_inputfield(array('id' => $field_id_vacfrom, 'name' => '_vacfrom[]'));
         $vacfrom_input = $input_vacfrom->show($defaults['vacfrom']);
         $input_vacto = new html_inputfield(array('id' => $field_id_vacto, 'name' => '_vacto[]', 'class' => 'short'));
         $vacto_input = $input_vacto->show($defaults['vacto']);
         $vac_help = $this->gettext('vactoexp') . '<br /><br />' . $this->gettext('vactoexp_adv');
     }
     // from param
     $vacs_table->set_row_attribs(array('class' => $this->show_vacfrom ? 'advanced' : 'disabled', 'style' => $display['vacfrom']));
     $vacs_table->add(null, html::label($field_id_vacfrom, rcmail::Q($this->gettext('from'))));
     $vacs_table->add(null, $vacfrom_input);
     $sig_button = $this->api->output->button(array('command' => 'plugin.sieverules.vacation_sig', 'prop' => $rowid, 'type' => 'link', 'class' => 'vacsig', 'classact' => 'vacsig_act', 'title' => 'insertsignature', 'content' => ' '));
     $vacs_table->add(null, $sig_button);
     // to param
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(array('style' => 'vertical-align: top;'), html::label($field_id_vacto, rcmail::Q($this->gettext('sieveto'))));
     $vacs_table->add(null, $vacto_input);
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(array('style' => 'vertical-align: top;'), $help_button);
     $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $vac_help);
     $field_id = 'rcmfd_sievevacperiod_' . $rowid;
     $input_period = new html_inputfield(array('id' => $field_id, 'name' => '_period[]', 'class' => 'short'));
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('period'))));
     $vacs_table->add(null, $input_period->show($defaults['period']));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . (in_array('vacation-seconds', $ext) ? $vacs_table->size() + 1 : $vacs_table->size()) . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     if (in_array('vacation-seconds', $ext)) {
         $input_periodtype = new html_radiobutton(array('id' => $field_id . '_days', 'name' => '_period_radio_' . $rowid, 'value' => 'days', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_period_type(this, ' . $rowid . ')', 'class' => 'radio'));
         $period_type_show = $input_periodtype->show($defaults['periodtype']) . "&nbsp;" . html::label($field_id . '_days', rcmail::Q($this->gettext('days')));
         $input_periodtype = new html_radiobutton(array('id' => $field_id . '_seconds', 'name' => '_period_radio_' . $rowid, 'value' => 'seconds', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_period_type(this, ' . $rowid . ')', 'class' => 'radio'));
         $period_type_show .= '&nbsp;&nbsp;' . $input_periodtype->show($defaults['periodtype']) . "&nbsp;" . html::label($field_id . '_seconds', rcmail::Q($this->gettext('seconds')));
         $input_periodtype = new html_hiddenfield(array('id' => 'rcmfd_sievevacperiodtype_' . $rowid, 'name' => '_periodtype[]'));
         $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
         $vacs_table->add(null, '&nbsp;');
         $vacs_table->add(null, $period_type_show . $input_periodtype->show($defaults['periodtype']));
         $vacs_table->add(null, '&nbsp;');
     }
     $vacs_table->set_row_attribs(array('style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $this->gettext('vacperiodexp'));
     $field_id = 'rcmfd_sievevachandle_' . $rowid;
     $input_handle = new html_inputfield(array('id' => $field_id, 'name' => '_handle[]', 'class' => 'short'));
     $vacs_table->set_row_attribs(array('class' => $this->show_vachandle ? 'advanced' : 'disabled', 'style' => $display['vachandle']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('sievevachandle'))));
     $vacs_table->add(null, $input_handle->show($defaults['handle']));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $this->gettext('vachandleexp'));
     $field_id = 'rcmfd_sievevacsubject_' . $rowid;
     $input_subject = new html_inputfield(array('id' => $field_id, 'name' => '_subject[]'));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('subject'))));
     $vacs_table->add(array('colspan' => 2), $input_subject->show($defaults['subject']));
     if (in_array('variables', $ext)) {
         $field_id = 'rcmfd_sievevacsubject_orig_' . $rowid;
         $input_origsubject = new html_checkbox(array('id' => $field_id, 'value' => '1', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_osubj(this, ' . $rowid . ')', 'class' => 'checkbox'));
         $input_vacosubj = new html_hiddenfield(array('id' => 'rcmfd_sievevactoh_' . $rowid, 'name' => '_orig_subject[]', 'value' => $defaults['origsubject']));
         $vacs_table->add(null, '&nbsp;');
         $vacs_table->add(array('colspan' => 2), $input_origsubject->show($defaults['origsubject']) . "&nbsp;" . html::label($field_id, rcmail::Q($this->gettext('sieveorigsubj'))) . $input_vacosubj->show());
     }
     $field_id = 'rcmfd_sievevacmag_' . $rowid;
     $input_msg = new html_textarea(array('id' => $field_id, 'name' => '_msg[]', 'rows' => '8', 'cols' => '40', 'class' => $defaults['htmlmsg'] == 1 ? 'mce_editor' : '', 'is_escaped' => $defaults['htmlmsg'] == 1 ? true : null));
     $input_html = new html_checkbox(array('id' => 'rcmfd_sievevachtmlcb_' . $rowid, 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_html(this, ' . $rowid . ', \'' . $field_id . '\');', 'value' => '1', 'class' => 'checkbox'));
     $input_htmlhd = new html_hiddenfield(array('id' => 'rcmfd_sievevachtmlhd_' . $rowid, 'name' => '_htmlmsg[]', 'value' => $defaults['htmlmsg']));
     $vacs_table->add('msg', html::label($field_id, rcmail::Q($this->gettext('message'))));
     $vacs_table->add(array('colspan' => 2), $input_msg->show($defaults['msg']) . html::tag('div', in_array('htmleditor', $rcmail->config->get('dont_override')) ? array('style' => 'display: none;') : null, $input_html->show($defaults['htmlmsg']) . "&nbsp;" . html::label('rcmfd_sievevachtmlcb_' . $rowid, rcmail::Q($this->gettext('htmlmessage')))) . $input_htmlhd->show());
     $field_id = 'rcmfd_sievecharset_' . $rowid;
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('charset'))));
     $vacs_table->add(array('colspan' => 2), $rcmail->output->charset_selector(array('id' => $field_id, 'name' => '_vaccharset[]', 'selected' => $defaults['charset'])));
     $input_advopts = new html_checkbox(array('id' => 'vadvopts' . $rowid, 'name' => '_vadv_opts[]', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'class' => 'checkbox'));
     $vacs_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('vadvopts' . $rowid, rcmail::Q($this->gettext('advancedoptions'))) . $input_advopts->show($display['vacadv'] == '' ? 1 : 0));
     return $vacs_table;
 }
Beispiel #7
0
 /**
  * GUI object 'loginform'
  * Returns code for the webmail login form
  *
  * @param array Named parameters
  * @return string HTML code for the gui object
  */
 private function login_form($attrib)
 {
     $default_host = $this->config['default_host'];
     $_SESSION['temp'] = true;
     // save original url
     $url = get_input_value('_url', RCUBE_INPUT_POST);
     if (empty($url) && !preg_match('/_(task|action)=logout/', $_SERVER['QUERY_STRING'])) {
         $url = $_SERVER['QUERY_STRING'];
     }
     $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser') + $attrib);
     $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd') + $attrib);
     $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login'));
     $input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_'));
     $input_url = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url));
     $input_host = null;
     if (is_array($default_host)) {
         $input_host = new html_select(array('name' => '_host', 'id' => 'rcmloginhost'));
         foreach ($default_host as $key => $value) {
             if (!is_array($value)) {
                 $input_host->add($value, is_numeric($key) ? $value : $key);
             } else {
                 $input_host = null;
                 break;
             }
         }
     } else {
         if (empty($default_host)) {
             $input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost') + $attrib);
         }
     }
     $form_name = !empty($attrib['form']) ? $attrib['form'] : 'form';
     $this->add_gui_object('loginform', $form_name);
     // create HTML table with two cols
     $table = new html_table(array('cols' => 2));
     $table->add('title', html::label('rcmloginuser', Q(rcube_label('username'))));
     $table->add(null, $input_user->show(get_input_value('_user', RCUBE_INPUT_POST)));
     $table->add('title', html::label('rcmloginpwd', Q(rcube_label('password'))));
     $table->add(null, $input_pass->show());
     // add host selection row
     if (is_object($input_host)) {
         $table->add('title', html::label('rcmloginhost', Q(rcube_label('server'))));
         $table->add(null, $input_host->show(get_input_value('_host', RCUBE_INPUT_POST)));
     }
     $out = $input_action->show();
     $out .= $input_tzone->show();
     $out .= $input_url->show();
     $out .= $table->show();
     // surround html output with a form tag
     if (empty($attrib['form'])) {
         $out = $this->form_tag(array('name' => $form_name, 'method' => "post"), $out);
     }
     return $out;
 }
 function filter_form($attrib)
 {
     if (!$attrib['id']) {
         $attrib['id'] = 'rcmfilterform';
     }
     $fid = rcube_utils::get_input_value('_fid', rcube_utils::INPUT_GPC);
     $scr = isset($this->form) ? $this->form : $this->script[$fid];
     $hiddenfields = new html_hiddenfield(array('name' => '_task', 'value' => $this->rc->task));
     $hiddenfields->add(array('name' => '_action', 'value' => 'plugin.managesieve-save'));
     $hiddenfields->add(array('name' => '_framed', 'value' => $_POST['_framed'] || $_GET['_framed'] ? 1 : 0));
     $hiddenfields->add(array('name' => '_fid', 'value' => $fid));
     $out = '<form name="filterform" action="./" method="post">' . "\n";
     $out .= $hiddenfields->show();
     // 'any' flag
     if (sizeof($scr['tests']) == 1 && $scr['tests'][0]['test'] == 'true' && !$scr['tests'][0]['not']) {
         $any = true;
     }
     // filter name input
     $field_id = '_name';
     $input_name = new html_inputfield(array('name' => '_name', 'id' => $field_id, 'size' => 30, 'class' => $this->errors['name'] ? 'error' : ''));
     if ($this->errors['name']) {
         $this->add_tip($field_id, $this->errors['name'], true);
     }
     if (isset($scr)) {
         $input_name = $input_name->show($scr['name']);
     } else {
         $input_name = $input_name->show();
     }
     $out .= sprintf("\n<label for=\"%s\"><b>%s:</b></label> %s\n", $field_id, rcube::Q($this->plugin->gettext('filtername')), $input_name);
     // filter set selector
     if ($this->rc->task == 'mail') {
         $out .= sprintf("\n&nbsp;<label for=\"%s\"><b>%s:</b></label> %s\n", $field_id, rcube::Q($this->plugin->gettext('filterset')), $this->filtersets_list(array('id' => 'sievescriptname'), true));
     }
     $out .= '<br /><br /><fieldset><legend>' . rcube::Q($this->plugin->gettext('messagesrules')) . "</legend>\n";
     // any, allof, anyof radio buttons
     $field_id = '_allof';
     $input_join = new html_radiobutton(array('name' => '_join', 'id' => $field_id, 'value' => 'allof', 'onclick' => 'rule_join_radio(\'allof\')', 'class' => 'radio'));
     if (isset($scr) && !$any) {
         $input_join = $input_join->show($scr['join'] ? 'allof' : '');
     } else {
         $input_join = $input_join->show();
     }
     $out .= sprintf("%s<label for=\"%s\">%s</label>&nbsp;\n", $input_join, $field_id, rcube::Q($this->plugin->gettext('filterallof')));
     $field_id = '_anyof';
     $input_join = new html_radiobutton(array('name' => '_join', 'id' => $field_id, 'value' => 'anyof', 'onclick' => 'rule_join_radio(\'anyof\')', 'class' => 'radio'));
     if (isset($scr) && !$any) {
         $input_join = $input_join->show($scr['join'] ? '' : 'anyof');
     } else {
         $input_join = $input_join->show('anyof');
     }
     // default
     $out .= sprintf("%s<label for=\"%s\">%s</label>\n", $input_join, $field_id, rcube::Q($this->plugin->gettext('filteranyof')));
     $field_id = '_any';
     $input_join = new html_radiobutton(array('name' => '_join', 'id' => $field_id, 'value' => 'any', 'onclick' => 'rule_join_radio(\'any\')', 'class' => 'radio'));
     $input_join = $input_join->show($any ? 'any' : '');
     $out .= sprintf("%s<label for=\"%s\">%s</label>\n", $input_join, $field_id, rcube::Q($this->plugin->gettext('filterany')));
     $rows_num = isset($scr) ? sizeof($scr['tests']) : 1;
     $out .= '<div id="rules"' . ($any ? ' style="display: none"' : '') . '>';
     for ($x = 0; $x < $rows_num; $x++) {
         $out .= $this->rule_div($fid, $x);
     }
     $out .= "</div>\n";
     $out .= "</fieldset>\n";
     // actions
     $out .= '<fieldset><legend>' . rcube::Q($this->plugin->gettext('messagesactions')) . "</legend>\n";
     $rows_num = isset($scr) ? sizeof($scr['actions']) : 1;
     $out .= '<div id="actions">';
     for ($x = 0; $x < $rows_num; $x++) {
         $out .= $this->action_div($fid, $x);
     }
     $out .= "</div>\n";
     $out .= "</fieldset>\n";
     $this->print_tips();
     if ($scr['disabled']) {
         $this->rc->output->set_env('rule_disabled', true);
     }
     $this->rc->output->add_label('managesieve.ruledeleteconfirm', 'managesieve.actiondeleteconfirm');
     $this->rc->output->add_gui_object('sieveform', 'filterform');
     return $out;
 }
 /**
  * create title field for preferences row
  * @param  int  $id
  * @param  string  $section
  * @param  string|boolean $command
  * @return string
  */
 private function create_title($action, $commands, $command = false)
 {
     if ($command !== false) {
         // label should always be set
         $label = isset($commands[$action]['commands'][$command]['label']) ? $commands[$action]['commands'][$command]['label'] : Q($this->gettext($command));
         // command
         $hidden_command = new html_hiddenfield(array('name' => "_ks_command[{$action}][]", 'value' => $command));
         $content = $label . $hidden_command->show();
     } else {
         // create a select box of the available commands in this action
         $select = new html_select(array('name' => "_ks_command[{$action}][]"));
         foreach ($commands[$action]['commands'] as $command => $options) {
             $label = isset($options['label']) ? $options['label'] : Q($this->gettext($command));
             $select->add($label, $command);
         }
         $content = $select->show();
     }
     return $content;
 }
 private function _action_row($ext, $actions_table, $rowid, $action, $attrib, $example)
 {
     $rcmail = rcube::get_instance();
     $help_icon = html::img(array('src' => $attrib['helpicon'], 'alt' => $this->gettext('messagehelp'), 'border' => 0));
     // set default field display
     $display = array('vacadv' => $action['type'] != 'vacation' && $this->force_vacto ? '' : 'display: none;', 'vacfrom' => $this->show_vacfrom ? $display['vacadv'] : 'display: none;', 'vachandle' => $this->show_vachandle ? $display['vacadv'] : 'display: none;', 'noteadv' => 'display: none;', 'eheadadv' => 'display: none;');
     // setup allowed actions
     $allowed_actions = array();
     $config_actions = $rcmail->config->get('sieverules_allowed_actions', array());
     if (in_array('fileinto', $ext) && ($config_actions['fileinto'] || $action['type'] == 'fileinto')) {
         $allowed_actions['fileinto'] = $this->gettext('messagemoveto');
     }
     if (in_array('fileinto', $ext) && in_array('copy', $ext) && ($config_actions['fileinto'] || $action['type'] == 'fileinto')) {
         $allowed_actions['fileinto_copy'] = $this->gettext('messagecopyto');
     }
     if (in_array('vacation', $ext) && ($config_actions['vacation'] || $action['type'] == 'vacation')) {
         $allowed_actions['vacation'] = $this->gettext('messagevacation');
     }
     if (in_array('reject', $ext) && ($config_actions['reject'] || $action['type'] == 'reject')) {
         $allowed_actions['reject'] = $this->gettext('messagereject');
     } elseif (in_array('ereject', $ext) && ($config_actions['reject'] || $action['type'] == 'ereject')) {
         $allowed_actions['ereject'] = $this->gettext('messagereject');
     }
     if (in_array('imap4flags', $ext) && ($config_actions['imapflags'] || $action['type'] == 'imap4flags')) {
         $allowed_actions['imap4flags'] = $this->gettext('messageimapflags');
     } elseif (in_array('imapflags', $ext) && ($config_actions['imapflags'] || $action['type'] == 'imapflags')) {
         $allowed_actions['imapflags'] = $this->gettext('messageimapflags');
     }
     if (in_array('notify', $ext) && ($config_actions['notify'] || $action['type'] == 'notify')) {
         $allowed_actions['notify'] = $this->gettext('messagenotify');
     } elseif (in_array('enotify', $ext) && ($config_actions['notify'] || $action['type'] == 'enotify')) {
         $allowed_actions['enotify'] = $this->gettext('messagenotify');
     }
     if (in_array('editheader', $ext) && ($config_actions['editheaderadd'] || $action['type'] == 'editheaderadd')) {
         $allowed_actions['editheaderadd'] = $this->gettext('addheader');
     }
     if (in_array('editheader', $ext) && ($config_actions['editheaderrem'] || $action['type'] == 'editheaderrem')) {
         $allowed_actions['editheaderrem'] = $this->gettext('removeheader');
     }
     if ($config_actions['redirect'] || $action['type'] == 'redirect') {
         $allowed_actions['redirect'] = $this->gettext('messageredirect');
     }
     if (in_array('copy', $ext) && ($config_actions['redirect'] || $action['type'] == 'redirect_copy')) {
         $allowed_actions['redirect_copy'] = $this->gettext('messageredirectcopy');
     }
     if ($config_actions['keep'] || $action['type'] == 'keep') {
         $allowed_actions['keep'] = $this->gettext('messagekeep');
     }
     if ($config_actions['discard'] || $action['type'] == 'discard') {
         $allowed_actions['discard'] = $this->gettext('messagediscard');
     }
     if ($config_actions['stop'] || $action['type'] == 'stop') {
         $allowed_actions['stop'] = $this->gettext('messagestop');
     }
     // set the default values
     reset($allowed_actions);
     $defaults = array('method' => key($allowed_actions), 'folder' => 'INBOX', 'reject' => '', 'vacto' => null, 'address' => '', 'period' => '', 'periodtype' => '', 'handle' => '', 'subject' => '', 'origsubject' => '', 'msg' => '', 'charset' => RCUBE_CHARSET, 'flags' => '', 'nfrom' => '', 'nimpt' => '', 'nmethod' => '', 'noptions' => '', 'nmsg' => '');
     // set default identity for use in vacation action
     $identity = $rcmail->user->get_identity();
     if ($this->show_vacfrom) {
         $defaults['vacfrom'] = in_array('variables', $ext) ? 'auto' : $identity['email'];
     } else {
         $defaults['vacfrom'] = null;
     }
     // apply current action values
     if ($action['type'] == 'fileinto' || $action['type'] == 'fileinto_copy') {
         $defaults['method'] = $action['type'];
         $defaults['folder'] = $action['target'];
         if ($rcmail->config->get('sieverules_folder_encoding')) {
             $defaults['folder'] = rcube_charset::convert($defaults['folder'], $rcmail->config->get('sieverules_folder_encoding'), 'UTF7-IMAP');
         }
         if ($rcmail->config->get('sieverules_folder_delimiter')) {
             $defaults['folder'] = str_replace($rcmail->config->get('sieverules_folder_delimiter'), $rcmail->storage->get_hierarchy_delimiter(), $defaults['folder']);
         }
         $defaults['folder'] = $rcmail->config->get('sieverules_include_imap_root', true) ? $defaults['folder'] : $rcmail->storage->mod_folder($defaults['folder'], 'IN');
     } elseif ($action['type'] == 'reject' || $action['type'] == 'ereject') {
         $defaults['method'] = $action['type'];
         $defaults['reject'] = $action['target'];
     } elseif ($action['type'] == 'vacation') {
         $defaults['method'] = 'vacation';
         if (isset($action['seconds'])) {
             $defaults['period'] = $action['seconds'];
             $defaults['periodtype'] = 'seconds';
         } else {
             $defaults['period'] = $action['days'];
             $defaults['periodtype'] = 'days';
         }
         $defaults['vacfromdefault'] = $defaults['vacfrom'];
         $defaults['vacfrom'] = $action['from'];
         $defaults['vacto'] = $action['addresses'];
         $defaults['handle'] = $action['handle'];
         $defaults['subject'] = $action['subject'];
         $defaults['origsubject'] = $action['origsubject'];
         $defaults['msg'] = $action['msg'];
         $defaults['htmlmsg'] = $action['htmlmsg'] ? '1' : '';
         $defaults['charset'] = $action['charset'];
         if ($defaults['htmlmsg'] == '1' && $rcmail->config->get('htmleditor') == '0') {
             $h2t = new rcube_html2text($defaults['msg'], false, true, 0);
             $defaults['msg'] = $h2t->get_text();
             $defaults['htmlmsg'] = '';
         } elseif ($defaults['htmlmsg'] == '' && $rcmail->config->get('htmleditor') == '1') {
             $defaults['msg'] = $defaults['msg'];
             $defaults['msg'] = nl2br($defaults['msg']);
             $defaults['htmlmsg'] = '1';
         }
         if (!$example) {
             $this->force_vacto = false;
         }
         // check advanced enabled
         if (!empty($defaults['vacfrom']) && $defaults['vacfrom'] != $defaults['vacfromdefault'] || !empty($defaults['vacto']) || !empty($defaults['handle']) || !empty($defaults['period']) || $defaults['charset'] != RCUBE_CHARSET || $this->force_vacto) {
             $display['vacadv'] = '';
             $display['vacfrom'] = $this->show_vacfrom ? '' : 'display: none;';
             $display['vachandle'] = $this->show_vachandle ? '' : 'display: none;';
         }
     } elseif ($action['type'] == 'redirect' || $action['type'] == 'redirect_copy') {
         $defaults['method'] = $action['type'];
         $defaults['address'] = $action['target'];
     } elseif ($action['type'] == 'imapflags' || $action['type'] == 'imap4flags') {
         $defaults['method'] = $action['type'];
         $defaults['flags'] = $action['target'];
     } elseif ($action['type'] == 'notify' || $action['type'] == 'enotify') {
         $defaults['method'] = $action['type'];
         $defaults['nfrom'] = $action['from'];
         $defaults['nimpt'] = $action['importance'];
         $defaults['nmethod'] = $action['method'];
         $defaults['noptions'] = $action['options'];
         $defaults['nmsg'] = $action['msg'];
         // check advanced enabled
         if (!empty($defaults['nfrom']) || !empty($defaults['nimpt'])) {
             $display['noteadv'] = '';
         }
     } elseif ($action['type'] == 'editheaderadd' || $action['type'] == 'editheaderrem') {
         $defaults['method'] = $action['type'];
         $defaults['headername'] = $action['name'];
         $defaults['headerval'] = $action['value'];
         $defaults['headerindex'] = $action['index'];
         $defaults['headerop'] = $action['operator'];
         if ($action['type'] == 'editheaderrem' && (!empty($defaults['headerindex']) || !empty($defaults['headerval']))) {
             $display['eheadadv'] = '';
         }
     } elseif ($action['type'] == 'discard' || $action['type'] == 'keep' || $action['type'] == 'stop') {
         $defaults['method'] = $action['type'];
     }
     // hide the "template" row
     if (!isset($action)) {
         $actions_table->set_row_attribs(array('style' => 'display: none;'));
     }
     // action type select box
     $select_action = new html_select(array('name' => "_act[]", 'onchange' => rcmail_output::JS_OBJECT_NAME . '.sieverules_action_select(this)'));
     foreach ($allowed_actions as $value => $text) {
         $select_action->add($text, $value);
     }
     // add action type to UI
     $actions_table->add('action', $select_action->show($defaults['method']));
     // begin vacation action
     $vacs_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 3, 'style' => $defaults['method'] == 'vacation' ? '' : 'display: none;'));
     $to_addresses = "";
     $vacto_arr = explode(",", $defaults['vacto']);
     $field_id_vacfrom = 'rcmfd_sievevacfrom_' . $rowid;
     $field_id_vacto = 'rcmfd_sievevacto_' . $rowid;
     if (count($this->identities)) {
         $select_id = new html_select(array('id' => $field_id_vacfrom, 'name' => "_vacfrom[]", 'class' => 'short', 'onchange' => rcmail_output::JS_OBJECT_NAME . '.enable_sig(this);'));
         if ($this->show_vacfrom && in_array('variables', $ext)) {
             $select_id->add($this->gettext('autodetect'), "auto");
         } elseif (!$this->show_vacfrom) {
             $select_id->add($this->gettext('autodetect'), "");
         }
         foreach ($this->identities as $sql_arr) {
             // find currently selected from address
             if ($defaults['vacfrom'] != '' && $defaults['vacfrom'] == rcmail::Q($sql_arr['from']['string'])) {
                 $defaults['vacfrom'] = $sql_arr['identity_id'];
             } elseif ($defaults['vacfrom'] != '' && $defaults['vacfrom'] == $sql_arr['from']['mailto']) {
                 $defaults['vacfrom'] = $sql_arr['identity_id'];
             }
             $select_id->add($sql_arr['from']['disp_string'], $sql_arr['identity_id']);
             $ffield_id = 'rcmfd_vac_' . $rowid . '_' . $sql_arr['identity_id'];
             if ($this->force_vacto) {
                 $curaddress = $sql_arr['email'];
                 $defaults['vacto'] .= (!empty($defaults['vacto']) ? ',' : '') . $sql_arr['email'];
             } else {
                 $curaddress = in_array($sql_arr['email'], $vacto_arr) ? $sql_arr['email'] : "";
             }
             $input_address = new html_checkbox(array('id' => $ffield_id, 'name' => '_vacto_check_' . $rowid . '[]', 'value' => $sql_arr['email'], 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_to(this, ' . $rowid . ')', 'class' => 'checkbox'));
             $to_addresses .= $input_address->show($curaddress) . "&nbsp;" . html::label($ffield_id, rcmail::Q($sql_arr['email'])) . "<br />";
         }
     }
     // deduplicate vacto list
     $tmparr = explode(",", $defaults['vacto']);
     $tmparr = array_unique($tmparr);
     $defaults['vacto'] = implode(",", $tmparr);
     if ($rcmail->config->get('sieverules_limit_vacto', true) && strlen($to_addresses) > 0) {
         $vacfrom_input = $select_id->show($defaults['vacfrom']);
         $input_vacto = new html_hiddenfield(array('id' => $field_id_vacto, 'name' => '_vacto[]', 'value' => $defaults['vacto']));
         $vacto_input = $to_addresses . $input_vacto->show();
         $vac_help = $this->gettext('vactoexp');
     } else {
         $input_vacfrom = new html_inputfield(array('id' => $field_id_vacfrom, 'name' => '_vacfrom[]'));
         $vacfrom_input = $input_vacfrom->show($defaults['vacfrom']);
         $input_vacto = new html_inputfield(array('id' => $field_id_vacto, 'name' => '_vacto[]', 'class' => 'short'));
         $vacto_input = $input_vacto->show($defaults['vacto']);
         $vac_help = $this->gettext('vactoexp') . '<br /><br />' . $this->gettext('vactoexp_adv');
     }
     // from param
     $vacs_table->set_row_attribs(array('class' => $this->show_vacfrom ? 'advanced' : 'disabled', 'style' => $display['vacfrom']));
     $vacs_table->add(null, html::label($field_id_vacfrom, rcmail::Q($this->gettext('from'))));
     $vacs_table->add(null, $vacfrom_input);
     $sig_button = $this->api->output->button(array('command' => 'plugin.sieverules.vacation_sig', 'prop' => $rowid, 'type' => 'link', 'class' => 'vacsig', 'classact' => 'vacsig_act', 'title' => 'insertsignature', 'content' => ' '));
     $vacs_table->add(null, $sig_button);
     // to param
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(array('style' => 'vertical-align: top;'), html::label($field_id_vacto, rcmail::Q($this->gettext('sieveto'))));
     $vacs_table->add(null, $vacto_input);
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(array('style' => 'vertical-align: top;'), $help_button);
     $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $vac_help);
     $field_id = 'rcmfd_sievevacperiod_' . $rowid;
     $input_period = new html_inputfield(array('id' => $field_id, 'name' => '_period[]', 'class' => 'short'));
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('period'))));
     $vacs_table->add(null, $input_period->show($defaults['period']));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . (in_array('vacation-seconds', $ext) ? $vacs_table->size() + 1 : $vacs_table->size()) . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     if (in_array('vacation-seconds', $ext)) {
         $input_periodtype = new html_radiobutton(array('id' => $field_id . '_days', 'name' => '_period_radio_' . $rowid, 'value' => 'days', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_period_type(this, ' . $rowid . ')', 'class' => 'radio'));
         $period_type_show = $input_periodtype->show($defaults['periodtype']) . "&nbsp;" . html::label($field_id . '_days', rcmail::Q($this->gettext('days')));
         $input_periodtype = new html_radiobutton(array('id' => $field_id . '_seconds', 'name' => '_period_radio_' . $rowid, 'value' => 'seconds', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_period_type(this, ' . $rowid . ')', 'class' => 'radio'));
         $period_type_show .= '&nbsp;&nbsp;' . $input_periodtype->show($defaults['periodtype']) . "&nbsp;" . html::label($field_id . '_seconds', rcmail::Q($this->gettext('seconds')));
         $input_periodtype = new html_hiddenfield(array('id' => 'rcmfd_sievevacperiodtype_' . $rowid, 'name' => '_periodtype[]'));
         $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
         $vacs_table->add(null, '&nbsp;');
         $vacs_table->add(null, $period_type_show . $input_periodtype->show($defaults['periodtype']));
         $vacs_table->add(null, '&nbsp;');
     }
     $vacs_table->set_row_attribs(array('style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $this->gettext('vacperiodexp'));
     $field_id = 'rcmfd_sievevachandle_' . $rowid;
     $input_handle = new html_inputfield(array('id' => $field_id, 'name' => '_handle[]', 'class' => 'short'));
     $vacs_table->set_row_attribs(array('class' => $this->show_vachandle ? 'advanced' : 'disabled', 'style' => $display['vachandle']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('sievevachandle'))));
     $vacs_table->add(null, $input_handle->show($defaults['handle']));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . rcmail_output::JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $this->gettext('vachandleexp'));
     $field_id = 'rcmfd_sievevacsubject_' . $rowid;
     $input_subject = new html_inputfield(array('id' => $field_id, 'name' => '_subject[]'));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('subject'))));
     $vacs_table->add(array('colspan' => 2), $input_subject->show($defaults['subject']));
     if (in_array('variables', $ext)) {
         $field_id = 'rcmfd_sievevacsubject_orig_' . $rowid;
         $input_origsubject = new html_checkbox(array('id' => $field_id, 'value' => '1', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_osubj(this, ' . $rowid . ')', 'class' => 'checkbox'));
         $input_vacosubj = new html_hiddenfield(array('id' => 'rcmfd_sievevactoh_' . $rowid, 'name' => '_orig_subject[]', 'value' => $defaults['origsubject']));
         $vacs_table->add(null, '&nbsp;');
         $vacs_table->add(array('colspan' => 2), $input_origsubject->show($defaults['origsubject']) . "&nbsp;" . html::label($field_id, rcmail::Q($this->gettext('sieveorigsubj'))) . $input_vacosubj->show());
     }
     $field_id = 'rcmfd_sievevacmag_' . $rowid;
     $input_msg = new html_textarea(array('id' => $field_id, 'name' => '_msg[]', 'rows' => '8', 'cols' => '40', 'class' => $defaults['htmlmsg'] == 1 ? 'mce_editor' : '', 'is_escaped' => $defaults['htmlmsg'] == 1 ? true : null));
     $input_html = new html_checkbox(array('id' => 'rcmfd_sievevachtmlcb_' . $rowid, 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_vac_html(this, ' . $rowid . ', \'' . $field_id . '\');', 'value' => '1', 'class' => 'checkbox'));
     $input_htmlhd = new html_hiddenfield(array('id' => 'rcmfd_sievevachtmlhd_' . $rowid, 'name' => '_htmlmsg[]', 'value' => $defaults['htmlmsg']));
     $vacs_table->add('msg', html::label($field_id, rcmail::Q($this->gettext('message'))));
     $vacs_table->add(array('colspan' => 2), $input_msg->show($defaults['msg']) . html::tag('div', in_array('htmleditor', $rcmail->config->get('dont_override')) ? array('style' => 'display: none;') : null, $input_html->show($defaults['htmlmsg']) . "&nbsp;" . html::label('rcmfd_sievevachtml_' . $rowid, rcmail::Q($this->gettext('htmlmessage')))) . $input_htmlhd->show());
     $field_id = 'rcmfd_sievecharset_' . $rowid;
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['vacadv']));
     $vacs_table->add(null, html::label($field_id, rcmail::Q($this->gettext('charset'))));
     $vacs_table->add(array('colspan' => 2), $rcmail->output->charset_selector(array('id' => $field_id, 'name' => '_vaccharset[]', 'selected' => $defaults['charset'])));
     $input_advopts = new html_checkbox(array('id' => 'vadvopts' . $rowid, 'name' => '_vadv_opts[]', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'class' => 'checkbox'));
     $vacs_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('vadvopts' . $rowid, rcmail::Q($this->gettext('advancedoptions'))) . $input_advopts->show($display['vacadv'] == '' ? 1 : 0));
     // begin notify action
     $notify_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 3, 'style' => $defaults['method'] == 'notify' || $defaults['method'] == 'enotify' ? '' : 'display: none;'));
     if (count($this->identities)) {
         $field_id = 'rcmfd_sievenotifyfrom_' . $rowid;
         $select_id = new html_select(array('id' => $field_id, 'name' => "_nfrom[]"));
         $select_id->add($this->gettext('autodetect'), "");
         foreach ($this->identities as $sql_arr) {
             // find currently selected from address
             if ($defaults['nfrom'] != '' && $defaults['nfrom'] == rcmail::Q($sql_arr['from']['string'])) {
                 $defaults['nfrom'] = $sql_arr['identity_id'];
             } elseif ($defaults['nfrom'] != '' && $defaults['nfrom'] == $sql_arr['from']['mailto']) {
                 $defaults['nfrom'] = $sql_arr['identity_id'];
             }
             $select_id->add($sql_arr['from']['disp_string'], $sql_arr['identity_id']);
         }
         $notify_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['noteadv']));
         $notify_table->add(null, html::label($field_id, rcmail::Q($this->gettext('sievefrom'))));
         $notify_table->add(array('colspan' => 2), $select_id->show($defaults['nfrom']));
     }
     $field_id = 'rcmfd_nmethod_' . $rowid;
     $input_method = new html_inputfield(array('id' => $field_id, 'name' => '_nmethod[]'));
     $notify_table->add(null, html::label($field_id, rcmail::Q($this->gettext('method'))));
     $notify_table->add(array('colspan' => 2), $input_method->show($defaults['nmethod']));
     $field_id = 'rcmfd_noption_' . $rowid;
     $input_method = new html_inputfield(array('id' => $field_id, 'name' => '_noption[]'));
     $notify_table->add(null, html::label($field_id, rcmail::Q($this->gettext('options'))));
     $notify_table->add(array('colspan' => 2), $input_method->show($defaults['noptions']));
     $notify_table->set_row_attribs(array('style' => 'display: none;'));
     $notify_table->add(array('colspan' => 3, 'class' => 'helpmsg'), $this->gettext('nmethodexp'));
     $field_id = 'rcmfd_nimpt_' . $rowid;
     $input_importance = new html_radiobutton(array('id' => $field_id . '_none', 'name' => '_notify_radio_' . $rowid, 'value' => 'none', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'class' => 'radio'));
     $importance_show = $input_importance->show($defaults['nimpt']) . "&nbsp;" . html::label($field_id . '_none', rcmail::Q($this->gettext('importancen')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_1', 'name' => '_notify_radio_' . $rowid, 'value' => '1', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'class' => 'radio'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($defaults['nimpt']) . "&nbsp;" . html::label($field_id . '_1', rcmail::Q($this->gettext('importance1')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_2', 'name' => '_notify_radio_' . $rowid, 'value' => '2', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'class' => 'radio'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($defaults['nimpt']) . "&nbsp;" . html::label($field_id . '_2', rcmail::Q($this->gettext('importance2')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_3', 'name' => '_notify_radio_' . $rowid, 'value' => '3', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'class' => 'radio'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($defaults['nimpt']) . "&nbsp;" . html::label($field_id . '_3', rcmail::Q($this->gettext('importance3')));
     $input_importance = new html_hiddenfield(array('id' => 'rcmfd_sievenimpt_' . $rowid, 'name' => '_nimpt[]'));
     $notify_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['noteadv']));
     $notify_table->add(null, rcmail::Q($this->gettext('flag')));
     $notify_table->add(array('colspan' => 2), $importance_show . $input_importance->show($defaults['nimpt']));
     $field_id = 'rcmfd_nmsg_' . $rowid;
     $input_msg = new html_inputfield(array('id' => $field_id, 'name' => '_nmsg[]'));
     $notify_table->add(null, html::label($field_id, rcmail::Q($this->gettext('message'))));
     $notify_table->add(array('colspan' => 2), $input_msg->show($defaults['nmsg']));
     if (in_array('enotify', $ext)) {
         $input_advopts = new html_checkbox(array('id' => 'nadvopts' . $rowid, 'name' => '_nadv_opts[]', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'class' => 'checkbox'));
         $notify_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('nadvopts' . $rowid, rcmail::Q($this->gettext('advancedoptions'))) . $input_advopts->show($display['noteadv'] == '' ? 1 : 0));
     }
     // begin editheader action
     $headers_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 2, 'style' => $defaults['method'] == 'editheaderadd' || $defaults['method'] == 'editheaderrem' ? '' : 'display: none;'));
     $field_id = 'rcmfd_eheadname_' . $rowid;
     $input_header = new html_inputfield(array('id' => $field_id, 'name' => '_eheadname[]'));
     $headers_table->add(null, html::label($field_id, rcmail::Q($this->gettext('headername'))));
     $headers_table->add(null, $input_header->show($defaults['headername']));
     $field_id = 'rcmfd_eheadindex_' . $rowid;
     $select_index = new html_select(array('id' => $field_id, 'name' => "_eheadindex[]"));
     $select_index->add($this->gettext('headerdelall'), "");
     $select_index->add("1", "1");
     $select_index->add("2", "2");
     $select_index->add("3", "3");
     $select_index->add("4", "4");
     $select_index->add("5", "5");
     $select_index->add($this->gettext('last'), "last");
     $headers_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['eheadadv']));
     $headers_table->add(null, html::label($field_id, rcmail::Q($this->gettext('headerindex'))));
     $headers_table->add(null, $select_index->show($defaults['headerindex']));
     $field_id = 'rcmfd_eheadopp_' . $rowid;
     $select_match = new html_select(array('id' => $field_id, 'name' => "_eheadopp[]"));
     $select_match->add($this->gettext('filteris'), "");
     $select_match->add($this->gettext('filtercontains'), "contains");
     $headers_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['eheadadv']));
     $headers_table->add(null, html::label($field_id, rcmail::Q($this->gettext('operator'))));
     $headers_table->add(null, $select_match->show($defaults['headerop']));
     $field_id = 'rcmfd_eheadval_' . $rowid;
     $input_header = new html_inputfield(array('id' => $field_id, 'name' => '_eheadval[]'));
     if ($defaults['method'] == 'editheaderrem') {
         $headers_table->set_row_attribs(array('class' => 'advanced', 'style' => $display['eheadadv']));
     }
     $headers_table->add(null, html::label($field_id, rcmail::Q($this->gettext('headervalue'))));
     $headers_table->add(null, $input_header->show($defaults['headerval']));
     if ($defaults['method'] == 'editheaderrem') {
         $headers_table->set_row_attribs(array('style' => 'display: none;'));
     }
     $field_id = 'rcmfd_eheadaddlast_' . $rowid;
     $input_index = new html_checkbox(array('id' => $field_id, 'value' => 'last', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_toggle_eheadlast(this);', 'name' => '_eheadaddlast[]', 'class' => 'checkbox'));
     $headers_table->add(null, '&nbsp;');
     $headers_table->add(null, $input_index->show($defaults['headerindex']) . "&nbsp;" . html::label($field_id, rcmail::Q($this->gettext('headerappend'))));
     if ($defaults['method'] == 'editheaderadd') {
         $headers_table->set_row_attribs(array('style' => 'display: none;'));
     }
     $input_advopts = new html_checkbox(array('id' => 'hadvopts' . $rowid, 'name' => '_hadv_opts[]', 'onclick' => rcmail_output::JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'class' => 'checkbox'));
     $headers_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('nadvopts' . $rowid, rcmail::Q($this->gettext('advancedoptions'))) . $input_advopts->show($display['eheadadv'] == '' ? 1 : 0));
     // begin fileinto action
     $mbox_name = $rcmail->storage->get_folder();
     $input_folderlist = new html_select(array('name' => '_folder[]', 'onchange' => rcmail_output::JS_OBJECT_NAME . '.sieverules_select_folder(this);', 'style' => $defaults['method'] == 'fileinto' || $defaults['method'] == 'fileinto_copy' ? '' : 'display: none;', 'is_escaped' => true));
     $rcmail->render_folder_tree_select($this->mailboxes, $mbox_name, 100, $input_folderlist, false);
     $show_customfolder = 'display: none;';
     if ($rcmail->config->get('sieverules_fileinto_options', 0) == 2 && !$rcmail->storage->folder_exists($defaults['folder'])) {
         $customfolder = rcube_charset::convert($rcmail->storage->mod_folder($defaults['folder']), 'UTF7-IMAP');
         $defaults['folder'] = '@@newfolder';
         $show_customfolder = '';
     }
     $input_customfolder = new html_inputfield(array('name' => '_customfolder[]'));
     $otherfolders = html::span(array('id' => 'customfolder_rowid', 'style' => $show_customfolder), '<br />' . $input_customfolder->show($customfolder));
     // begin redirect action
     $input_address = new html_inputfield(array('name' => '_redirect[]', 'style' => $defaults['method'] == 'redirect' || $defaults['method'] == 'redirect_copy' ? '' : 'display: none;'));
     // begin reject action
     $input_reject = new html_textarea(array('name' => '_reject[]', 'rows' => '5', 'cols' => '40', 'style' => $defaults['method'] == 'reject' || $defaults['method'] == 'ereject' ? '' : 'display: none;'));
     // begin imapflags action
     $input_imapflags = new html_select(array('name' => '_imapflags[]', 'style' => $defaults['method'] == 'imapflags' || $defaults['method'] == 'imap4flags' ? '' : 'display: none;'));
     foreach ($this->flags as $name => $val) {
         $input_imapflags->add($this->gettext($name), $val);
     }
     // add actions to UI
     $actions_table->add('folder', $input_folderlist->show($defaults['folder']) . $otherfolders . $input_address->show($defaults['address']) . $vacs_table->show() . $notify_table->show() . $input_imapflags->show($defaults['flags']) . $input_reject->show($defaults['reject']) . $headers_table->show());
     // add add/delete buttons to UI (if enabled)
     $add_button = $this->api->output->button(array('command' => 'plugin.sieverules.add_action', 'type' => 'link', 'class' => 'add', 'title' => 'sieverules.addsieveact', 'content' => ' '));
     $delete_button = $this->api->output->button(array('command' => 'plugin.sieverules.del_action', 'type' => 'link', 'class' => 'delete', 'classact' => 'delete_act', 'title' => 'sieverules.deletesieveact', 'content' => ' '));
     if ($rcmail->config->get('sieverules_multiple_actions')) {
         $actions_table->add('control', $add_button . $delete_button);
     } else {
         $actions_table->add('control', "&nbsp;");
     }
     return $actions_table;
 }
 private function _action_row($ext, $actions_table, $rowid, $action, $attrib, $example)
 {
     $rcmail = rcmail::get_instance();
     static $a_mailboxes;
     $imgclass = null;
     if (!isset($action)) {
         $actions_table->set_row_attribs(array('style' => 'display: none;'));
         $imgclass = 'nohtc';
     }
     $help_icon = html::img(array('src' => $attrib['helpicon'], 'alt' => $this->gettext('messagehelp'), 'border' => 0));
     $vacadvstyle = $action['type'] != 'vacation' && $this->force_vacto ? '' : 'display: none;';
     $vacadvstyle_from = $this->show_vacfrom ? $vacadvstyle : 'display: none;';
     $vacadvstyle_handle = $this->show_vachandle ? $vacadvstyle : 'display: none;';
     $vacadvclass_from = $this->show_vacfrom ? 'advanced' : 'disabled';
     $vacadvclass_handle = $this->show_vachandle ? 'advanced' : 'disabled';
     $vacshowadv = $action['type'] != 'vacation' && $this->force_vacto ? '1' : '';
     $noteadvstyle = 'display: none;';
     $noteshowadv = '';
     // setup allowed actions
     $allowed_actions = array();
     $config_actions = $rcmail->config->get('sieverules_allowed_actions', array());
     if (in_array('fileinto', $ext) && ($config_actions['fileinto'] || $action['type'] == 'fileinto')) {
         $allowed_actions['fileinto'] = $this->gettext('messagemoveto');
     }
     if (in_array('fileinto', $ext) && in_array('copy', $ext) && ($config_actions['fileinto'] || $action['type'] == 'fileinto')) {
         $allowed_actions['fileinto_copy'] = $this->gettext('messagecopyto');
     }
     if (in_array('vacation', $ext) && ($config_actions['vacation'] || $action['type'] == 'vacation')) {
         $allowed_actions['vacation'] = $this->gettext('messagevacation');
     }
     if (in_array('reject', $ext) && ($config_actions['reject'] || $action['type'] == 'reject')) {
         $allowed_actions['reject'] = $this->gettext('messagereject');
     } elseif (in_array('ereject', $ext) && ($config_actions['reject'] || $action['type'] == 'ereject')) {
         $allowed_actions['ereject'] = $this->gettext('messagereject');
     }
     if (in_array('imapflags', $ext) && ($config_actions['imapflags'] || $action['type'] == 'imapflags')) {
         $allowed_actions['imapflags'] = $this->gettext('messageimapflags');
     } elseif (in_array('imap4flags', $ext) && ($config_actions['imapflags'] || $action['type'] == 'imap4flags')) {
         $allowed_actions['imap4flags'] = $this->gettext('messageimapflags');
     }
     if (in_array('notify', $ext) && ($config_actions['notify'] || $action['type'] == 'notify')) {
         $allowed_actions['notify'] = $this->gettext('messagenotify');
     } elseif (in_array('enotify', $ext) && ($config_actions['notify'] || $action['type'] == 'enotify')) {
         $allowed_actions['enotify'] = $this->gettext('messagenotify');
     }
     if ($config_actions['redirect'] || $action['type'] == 'redirect') {
         $allowed_actions['redirect'] = $this->gettext('messageredirect');
     }
     if (in_array('copy', $ext) && ($config_actions['redirect'] || $action['type'] == 'redirect_copy')) {
         $allowed_actions['redirect_copy'] = $this->gettext('messageredirectcopy');
     }
     if ($config_actions['keep'] || $action['type'] == 'keep') {
         $allowed_actions['keep'] = $this->gettext('messagekeep');
     }
     if ($config_actions['discard'] || $action['type'] == 'discard') {
         $allowed_actions['discard'] = $this->gettext('messagediscard');
     }
     if ($config_actions['stop'] || $action['type'] == 'stop') {
         $allowed_actions['stop'] = $this->gettext('messagestop');
     }
     // set the default action
     reset($allowed_actions);
     $method = key($allowed_actions);
     $folder = 'INBOX';
     $reject = '';
     $identity = $rcmail->user->get_identity();
     if ($this->show_vacfrom) {
         $vacfrom = in_array('variables', $ext) ? 'auto' : $identity['email'];
     } else {
         $vacfrom = null;
     }
     $vacto = null;
     $address = '';
     $days = '';
     $handle = '';
     $subject = '';
     $origsubject = '';
     $msg = '';
     $charset = RCMAIL_CHARSET;
     $flags = '';
     $nfrom = '';
     $nimpt = '';
     $nmethod = '';
     $noptions = '';
     $nmsg = '';
     if ($action['type'] == 'fileinto' || $action['type'] == 'fileinto_copy') {
         $method = $action['type'];
         $folder = $rcmail->config->get('sieverules_include_imap_root', true) ? $action['target'] : $rcmail->imap->mod_mailbox($action['target']);
         if ($rcmail->config->get('sieverules_folder_delimiter', false)) {
             $folder = str_replace($rcmail->imap->get_hierarchy_delimiter(), $rcmail->config->get('sieverules_folder_delimiter'), $folder);
         }
     } elseif ($action['type'] == 'reject' || $action['type'] == 'ereject') {
         $method = $action['type'];
         $reject = htmlspecialchars($action['target']);
     } elseif ($action['type'] == 'vacation') {
         $method = 'vacation';
         $days = $action['days'];
         $vacfrom_default = $vacfrom;
         $vacfrom = $action['from'];
         $vacto = $action['addresses'];
         $handle = htmlspecialchars($action['handle']);
         $subject = htmlspecialchars($action['subject']);
         $origsubject = $action['origsubject'];
         $msg = $action['msg'];
         $htmlmsg = $action['htmlmsg'] ? '1' : '';
         $charset = $action['charset'];
         if (!$example) {
             $this->force_vacto = false;
         }
         // check advanced enabled
         if (!empty($vacfrom) && $vacfrom != $vacfrom_default || !empty($vacto) || !empty($handle) || $charset != RCMAIL_CHARSET || $this->force_vacto) {
             $vacadvstyle = '';
             $vacadvstyle_from = $this->show_vacfrom ? '' : 'display: none;';
             $vacadvstyle_handle = $this->show_vachandle ? '' : 'display: none;';
             $vacshowadv = '1';
         }
     } elseif ($action['type'] == 'redirect' || $action['type'] == 'redirect_copy') {
         $method = $action['type'];
         $address = $action['target'];
     } elseif ($action['type'] == 'imapflags' || $action['type'] == 'imap4flags') {
         $method = $action['type'];
         $flags = $action['target'];
     } elseif ($action['type'] == 'notify' || $action['type'] == 'enotify') {
         $method = $action['type'];
         $nfrom = htmlspecialchars($action['from']);
         $nimpt = htmlspecialchars($action['importance']);
         $nmethod = $action['method'];
         $noptions = $action['options'];
         $nmsg = $action['msg'];
         // check advanced enabled
         if (!empty($nfrom) || !empty($nimpt)) {
             $noteadvstyle = '';
             $noteshowadv = '1';
         }
     } elseif ($action['type'] == 'discard' || $action['type'] == 'keep' || $action['type'] == 'stop') {
         $method = $action['type'];
     }
     $select_action = new html_select(array('name' => "_act[]", 'onchange' => JS_OBJECT_NAME . '.sieverules_action_select(this)'));
     foreach ($allowed_actions as $value => $text) {
         $select_action->add(Q($text), $value);
     }
     $actions_table->add('action', $select_action->show($method));
     $vacs_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 3, 'style' => $method == 'vacation' ? '' : 'display: none;'));
     $to_addresses = "";
     $vacto_arr = explode(",", $vacto);
     $user_identities = $rcmail->user->list_identities();
     if (count($user_identities)) {
         $field_id = 'rcmfd_sievevacfrom_' . $rowid;
         $select_id = new html_select(array('id' => $field_id, 'name' => "_vacfrom[]", 'class' => 'short', 'onchange' => JS_OBJECT_NAME . '.enable_sig(this);'));
         if ($this->show_vacfrom && in_array('variables', $ext)) {
             $select_id->add(Q($this->gettext('autodetect')), "auto");
         } elseif (!$this->show_vacfrom) {
             $select_id->add(Q($this->gettext('autodetect')), "");
         }
         foreach ($user_identities as $sql_arr) {
             $select_id->add($sql_arr['email'], $sql_arr['email']);
             $ffield_id = 'rcmfd_vac_' . $rowid . '_' . $sql_arr['identity_id'];
             if ($this->force_vacto) {
                 $curaddress = $sql_arr['email'];
                 $vacto .= (!empty($vacto) ? ',' : '') . $sql_arr['email'];
             } else {
                 $curaddress = in_array($sql_arr['email'], $vacto_arr) ? $sql_arr['email'] : "";
             }
             $input_address = new html_checkbox(array('id' => $ffield_id, 'name' => '_vacto_check_' . $rowid . '[]', 'value' => $sql_arr['email'], 'onclick' => JS_OBJECT_NAME . '.sieverules_toggle_vac_to(this, ' . $rowid . ')', 'class' => 'checkbox'));
             $to_addresses .= $input_address->show($curaddress) . "&nbsp;" . html::label($ffield_id, Q($sql_arr['email'])) . "<br />";
         }
     }
     if ($rcmail->config->get('sieverules_limit_vacto', true) && strlen($to_addresses) > 0) {
         $vacs_table->set_row_attribs(array('class' => $vacadvclass_from, 'style' => $vacadvstyle_from));
         $vacs_table->add(null, html::label($field_id, Q($this->gettext('from'))));
         $vacs_table->add(null, $select_id->show($vacfrom));
         $sig_button = $this->api->output->button(array('command' => 'plugin.sieverules.vacation_sig', 'prop' => $rowid, 'type' => 'link', 'class' => 'vacsig', 'classact' => 'vacsig_act', 'title' => 'insertsignature', 'content' => ' '));
         $vacs_table->add(null, $sig_button);
         $field_id = 'rcmfd_sievevacto_' . $rowid;
         $input_vacto = new html_hiddenfield(array('id' => $field_id, 'name' => '_vacto[]', 'value' => $vacto));
         $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $vacadvstyle));
         $vacs_table->add(array('style' => 'vertical-align: top;'), Q($this->gettext('sieveto')));
         $vacs_table->add(null, $to_addresses . $input_vacto->show());
         $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
         $vacs_table->add(array('style' => 'vertical-align: top;'), $help_button);
         $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
         $vacs_table->add(array('colspan' => 3, 'class' => 'vacdaysexp'), $this->gettext('vactoexp'));
         $vacs_table->add_row();
     } else {
         $field_id = 'rcmfd_sievevacfrom_' . $rowid;
         $input_vacfrom = new html_inputfield(array('id' => $field_id, 'name' => '_vacfrom[]'));
         $vacs_table->set_row_attribs(array('class' => $vacadvclass_from, 'style' => $vacadvstyle_from));
         $vacs_table->add(null, html::label($field_id, Q($this->gettext('from'))));
         $vacs_table->add(null, $input_vacfrom->show($vacfrom));
         $sig_button = $this->api->output->button(array('command' => 'plugin.sieverules.vacation_sig', 'prop' => $rowid, 'type' => 'link', 'class' => 'vacsig', 'classact' => 'vacsig_act', 'title' => 'insertsignature', 'content' => ' '));
         $vacs_table->add(null, $sig_button);
         $field_id = 'rcmfd_sievevacto_' . $rowid;
         $input_vacto = new html_inputfield(array('id' => $field_id, 'name' => '_vacto[]', 'class' => 'short'));
         $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $vacadvstyle));
         $vacs_table->add(null, html::label($field_id, Q($this->gettext('sieveto'))));
         $vacs_table->add(null, $input_vacto->show($vacto));
         $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
         $vacs_table->add(null, $help_button);
         $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
         $vacs_table->add(array('colspan' => 3, 'class' => 'vacdaysexp'), $this->gettext('vactoexp') . '<br /><br />' . $this->gettext('vactoexp_adv'));
         $vacs_table->add_row();
     }
     $field_id = 'rcmfd_sievevacdays_' . $rowid;
     $input_day = new html_inputfield(array('id' => $field_id, 'name' => '_day[]', 'class' => 'short'));
     $vacs_table->add(null, html::label($field_id, Q($this->gettext('days'))));
     $vacs_table->add(null, $input_day->show($days));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     $vacs_table->set_row_attribs(array('style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'vacdaysexp'), $this->gettext('vacdaysexp'));
     $vacs_table->add_row();
     $field_id = 'rcmfd_sievevachandle_' . $rowid;
     $input_handle = new html_inputfield(array('id' => $field_id, 'name' => '_handle[]', 'class' => 'short'));
     $vacs_table->set_row_attribs(array('class' => $vacadvclass_handle, 'style' => $vacadvstyle_handle));
     $vacs_table->add(null, html::label($field_id, Q($this->gettext('sievevachandle'))));
     $vacs_table->add(null, $input_handle->show($handle));
     $help_button = html::a(array('href' => "#", 'onclick' => 'return ' . JS_OBJECT_NAME . '.sieverules_help(this, ' . $vacs_table->size() . ');', 'title' => $this->gettext('messagehelp')), $help_icon);
     $vacs_table->add(null, $help_button);
     $vacs_table->set_row_attribs(array('class' => 'advhelp', 'style' => 'display: none;'));
     $vacs_table->add(array('colspan' => 3, 'class' => 'vacdaysexp'), $this->gettext('vachandleexp'));
     $vacs_table->add_row();
     $field_id = 'rcmfd_sievevacsubject_' . $rowid;
     $input_subject = new html_inputfield(array('id' => $field_id, 'name' => '_subject[]'));
     $vacs_table->add(null, html::label($field_id, Q($this->gettext('subject'))));
     $vacs_table->add(array('colspan' => 2), $input_subject->show($subject));
     $vacs_table->add_row();
     if (in_array('variables', $ext)) {
         $field_id = 'rcmfd_sievevacsubject_orig_' . $rowid;
         $input_origsubject = new html_checkbox(array('id' => $field_id, 'value' => '1', 'onclick' => JS_OBJECT_NAME . '.sieverules_toggle_vac_osubj(this, ' . $rowid . ')', 'class' => 'checkbox'));
         $input_vacosubj = new html_hiddenfield(array('id' => 'rcmfd_sievevactoh_' . $rowid, 'name' => '_orig_subject[]', 'value' => $origsubject));
         $vacs_table->add(null, '&nbsp;');
         $vacs_table->add(array('colspan' => 2), $input_origsubject->show($origsubject) . "&nbsp;" . html::label($field_id, Q($this->gettext('sieveorigsubj'))) . $input_vacosubj->show());
         $vacs_table->add_row();
     }
     $field_id = 'rcmfd_sievevacmag_' . $rowid;
     $input_msg = new html_textarea(array('id' => $field_id, 'name' => '_msg[]', 'rows' => '8', 'cols' => '40', 'class' => $htmlmsg == 1 ? 'mce_editor' : ''));
     $input_html = new html_checkbox(array('onclick' => JS_OBJECT_NAME . '.sieverules_toggle_vac_html(this, ' . $rowid . ', \'' . $field_id . '\');', 'value' => '1', 'class' => 'checkbox'));
     $input_htmlhd = new html_hiddenfield(array('id' => 'rcmfd_sievevachtmlhd_' . $rowid, 'name' => '_htmlmsg[]', 'value' => $htmlmsg));
     $vacs_table->add('msg', html::label($field_id, Q($this->gettext('message'))));
     $vacs_table->add(array('colspan' => 2), $input_msg->show($msg) . html::tag('div', null, $input_html->show($htmlmsg) . "&nbsp;" . html::label('rcmfd_sievevachtml_' . $rowid, Q($this->gettext('htmlmessage'))) . $input_htmlhd->show()));
     $vacs_table->add_row();
     $field_id = 'rcmfd_sievecharset_' . $rowid;
     $vacs_table->set_row_attribs(array('class' => 'advanced', 'style' => $vacadvstyle));
     $vacs_table->add(null, html::label($field_id, Q($this->gettext('charset'))));
     $vacs_table->add(array('colspan' => 2), $this->_charset_selector(array('id' => $field_id, 'name' => '_charset[]'), $charset));
     $vacs_table->add_row();
     $input_advopts = new html_checkbox(array('id' => 'vadvopts' . $rowid, 'name' => '_vadv_opts[]', 'onclick' => JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'class' => 'checkbox'));
     $vacs_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('vadvopts' . $rowid, Q($this->gettext('advancedoptions'))) . $input_advopts->show($vacshowadv));
     $notify_table = new html_table(array('class' => 'records-table', 'cellspacing' => '0', 'cols' => 3, 'style' => $method == 'notify' || $method == 'enotify' ? '' : 'display: none;'));
     $user_identities = $rcmail->user->list_identities();
     if (count($user_identities)) {
         $field_id = 'rcmfd_sievenotifyfrom_' . $rowid;
         $select_id = new html_select(array('id' => $field_id, 'name' => "_nfrom[]"));
         $select_id->add(Q($this->gettext('autodetect')), "");
         foreach ($user_identities as $sql_arr) {
             $select_id->add($sql_arr['email'], $sql_arr['email']);
         }
         $notify_table->set_row_attribs(array('class' => 'advanced', 'style' => $noteadvstyle));
         $notify_table->add(null, html::label($field_id, Q($this->gettext('sievefrom'))));
         $notify_table->add(array('colspan' => 2), $select_id->show($nfrom));
         $notify_table->add_row();
     }
     $field_id = 'rcmfd_nmethod_' . $rowid;
     $input_method = new html_inputfield(array('id' => $field_id, 'name' => '_nmethod[]'));
     $notify_table->add(null, html::label($field_id, Q($this->gettext('method'))));
     $notify_table->add(array('colspan' => 2), $input_method->show($nmethod));
     $notify_table->add_row();
     $field_id = 'rcmfd_noption_' . $rowid;
     $input_method = new html_inputfield(array('id' => $field_id, 'name' => '_noption[]'));
     $notify_table->add(null, html::label($field_id, Q($this->gettext('options'))));
     $notify_table->add(array('colspan' => 2), $input_method->show($noptions));
     $notify_table->add_row();
     $notify_table->set_row_attribs(array('style' => 'display: none;'));
     $notify_table->add(array('colspan' => 3, 'class' => 'vacdaysexp'), $this->gettext('nmethodexp'));
     $notify_table->add_row();
     $field_id = 'rcmfd_nimpt_' . $rowid;
     $input_importance = new html_radiobutton(array('id' => $field_id . '_none', 'name' => '_notify_radio_' . $rowid, 'value' => 'none', 'onclick' => JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'style' => 'width:15px;'));
     $importance_show = $input_importance->show($nimpt) . "&nbsp;" . html::label($field_id . '_none', Q($this->gettext('importancen')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_1', 'name' => '_notify_radio_' . $rowid, 'value' => '1', 'onclick' => JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'style' => 'width:15px;'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($nimpt) . "&nbsp;" . html::label($field_id . '_1', Q($this->gettext('importance1')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_2', 'name' => '_notify_radio_' . $rowid, 'value' => '2', 'onclick' => JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'style' => 'width:15px;'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($nimpt) . "&nbsp;" . html::label($field_id . '_2', Q($this->gettext('importance2')));
     $input_importance = new html_radiobutton(array('id' => $field_id . '_3', 'name' => '_notify_radio_' . $rowid, 'value' => '3', 'onclick' => JS_OBJECT_NAME . '.sieverules_notify_impt(this, ' . $rowid . ')', 'style' => 'width:15px;'));
     $importance_show .= '&nbsp;&nbsp;' . $input_importance->show($nimpt) . "&nbsp;" . html::label($field_id . '_3', Q($this->gettext('importance3')));
     $input_importance = new html_hiddenfield(array('id' => 'rcmfd_sievenimpt_' . $rowid, 'name' => '_nimpt[]'));
     $notify_table->set_row_attribs(array('class' => 'advanced', 'style' => $noteadvstyle));
     $notify_table->add(null, Q($this->gettext('flag')));
     $notify_table->add(array('colspan' => 2), $importance_show . $input_importance->show($nimpt));
     $notify_table->add_row();
     $field_id = 'rcmfd_nmsg_' . $rowid;
     $input_msg = new html_inputfield(array('id' => $field_id, 'name' => '_nmsg[]'));
     $notify_table->add(null, html::label($field_id, Q($this->gettext('message'))));
     $notify_table->add(array('colspan' => 2), $input_msg->show($nmsg));
     $notify_table->add_row();
     if (in_array('enotify', $ext)) {
         $input_advopts = new html_checkbox(array('id' => 'nadvopts' . $rowid, 'name' => '_nadv_opts[]', 'onclick' => JS_OBJECT_NAME . '.sieverules_show_adv(this);', 'value' => '1', 'style' => 'width:15px;'));
         $notify_table->add(array('colspan' => '3', 'style' => 'text-align: right'), html::label('nadvopts' . $rowid, Q($this->gettext('advancedoptions'))) . $input_advopts->show($noteshowadv));
     }
     // get mailbox list
     $mbox_name = $rcmail->imap->get_mailbox_name();
     // build the folders tree
     if (empty($a_mailboxes)) {
         // get mailbox list
         if ($rcmail->config->get('sieverules_fileinto_options', 0) > 0) {
             $a_folders = $rcmail->imap->list_unsubscribed();
         } else {
             $a_folders = $rcmail->imap->list_mailboxes();
         }
         $delimiter = $rcmail->imap->get_hierarchy_delimiter();
         $a_mailboxes = array();
         foreach ($a_folders as $ifolder) {
             if ($rcmail->config->get('sieverules_folder_encoding')) {
                 $ifolder = $this->_mbox_encode($ifolder, $rcmail->config->get('sieverules_folder_encoding'));
             }
             if ($rcmail->config->get('sieverules_folder_delimiter', false)) {
                 rcmail_build_folder_tree($a_mailboxes, str_replace($delimiter, $rcmail->config->get('sieverules_folder_delimiter'), $ifolder), $rcmail->config->get('sieverules_folder_delimiter'));
             } else {
                 rcmail_build_folder_tree($a_mailboxes, $ifolder, $delimiter);
             }
         }
         if ($rcmail->config->get('sieverules_fileinto_options', 0) == 2 && in_array('mailbox', $ext)) {
             array_push($a_mailboxes, array('id' => '@@newfolder', 'name' => $this->gettext('createfolder'), 'virtual' => '', 'folders' => array()));
         }
     }
     $input_folderlist = new html_select(array('name' => '_folder[]', 'onchange' => JS_OBJECT_NAME . '.sieverules_select_folder(this);', 'style' => $method == 'fileinto' || $method == 'fileinto_copy' ? '' : 'display: none;'));
     rcmail_render_folder_tree_select($a_mailboxes, $mbox_name, 100, $input_folderlist, false);
     $show_customfolder = 'display: none;';
     if ($rcmail->config->get('sieverules_fileinto_options', 0) == 2 && !$rcmail->imap->mailbox_exists($folder)) {
         $customfolder = $rcmail->imap->mod_mailbox($folder);
         $folder = '@@newfolder';
         $show_customfolder = '';
     }
     $input_customfolder = new html_inputfield(array('name' => '_customfolder[]'));
     $otherfolders = html::span(array('id' => 'customfolder_rowid', 'style' => $show_customfolder), '<br />' . $input_customfolder->show($customfolder));
     $input_address = new html_inputfield(array('name' => '_redirect[]', 'style' => $method == 'redirect' || $method == 'redirect_copy' ? '' : 'display: none;'));
     $input_reject = new html_textarea(array('name' => '_reject[]', 'rows' => '5', 'cols' => '40', 'style' => $method == 'reject' || $method == 'ereject' ? '' : 'display: none;'));
     $input_imapflags = new html_select(array('name' => '_imapflags[]', 'style' => $method == 'imapflags' || $method == 'imap4flags' ? '' : 'display: none;'));
     foreach ($this->flags as $name => $val) {
         $input_imapflags->add(Q($this->gettext($name)), Q($val));
     }
     $actions_table->add('folder', $input_folderlist->show($folder) . $otherfolders . $input_address->show($address) . $vacs_table->show() . $notify_table->show() . $input_imapflags->show($flags) . $input_reject->show($reject));
     $add_button = $this->api->output->button(array('command' => 'plugin.sieverules.add_action', 'type' => 'link', 'class' => 'add', 'title' => 'sieverules.addsieveact', 'content' => ' '));
     $delete_button = $this->api->output->button(array('command' => 'plugin.sieverules.del_action', 'type' => 'link', 'class' => 'delete', 'classact' => 'delete_act', 'title' => 'sieverules.deletesieveact', 'content' => ' '));
     if ($rcmail->config->get('sieverules_multiple_actions')) {
         $actions_table->add('control', $delete_button . $add_button);
     } else {
         $actions_table->add('control', "&nbsp;");
     }
     return $actions_table;
 }
 function gen_form()
 {
     $this->rcmail_inst->imap_connect(TRUE);
     $id = get_input_value('_id', RCUBE_INPUT_GET);
     $this->rcmail_inst->output->add_label('ispconfig3_filter.filterdelconfirm');
     if ($id != '' || $id != 0) {
         try {
             $session_id = $this->soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass'));
             $mail_user = $this->soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username']));
             $filter = $this->soap->mail_user_filter_get($session_id, array('filter_id' => $id));
             $mail_server = $this->soap->server_get($session_id, $mail_user[0]['server_id'], 'mail');
             $this->soap->logout($session_id);
         } catch (SoapFault $e) {
             $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error');
         }
         $enabled = $filter[0]['active'];
         if ($filter[0]['mailuser_id'] != $mail_user[0]['mailuser_id']) {
             $this->rcmail_inst->output->command('display_message', 'Error: ' . $this->gettext('opnotpermitted'), 'error');
             $enabled = 'n';
             $mail_fetchmail['rulename'] = '';
             $mail_fetchmail['source'] = '';
             $mail_fetchmail['searchterm'] = '';
             $mail_fetchmail['op'] = '';
             $mail_fetchmail['action'] = '';
             $mail_fetchmail['target'] = '';
         }
         if ($mail_server['mail_filter_syntax'] == 'maildrop') {
             $filter[0]['target'] = "INBOX." . $filter[0]['target'];
         }
     }
     if ($enabled == 'y') {
         $enabled = 1;
     } else {
         $enabled = 0;
     }
     $this->rcmail_inst->output->set_env('framed', TRUE);
     $out .= '<fieldset><legend>' . $this->gettext('acc_filter') . '</legend>' . "\n";
     $table = new html_table(array('cols' => 2, 'class' => 'propform'));
     $hidden_id = new html_hiddenfield(array('name' => '_id', 'value' => $filter[0]['filter_id']));
     $out .= $hidden_id->show();
     $input_filtername = new html_inputfield(array('name' => '_filtername', 'id' => 'filtername', 'size' => 70));
     $table->add('title', rep_specialchars_output($this->gettext('filtername')));
     $table->add('', $input_filtername->show($filter[0]['rulename']));
     $input_filtersource = new html_select(array('name' => '_filtersource', 'id' => 'filtersource'));
     $input_filtersource->add(array($this->gettext('filtersubject'), $this->gettext('filterfrom'), $this->gettext('filterto')), array('Subject', 'From', 'To'));
     $input_filterop = new html_select(array('name' => '_filterop', 'id' => 'filterop'));
     $input_filterop->add(array($this->gettext('filtercontains'), $this->gettext('filteris'), $this->gettext('filterbegins'), $this->gettext('filterends')), array('contains', 'is', 'begins', 'ends'));
     $input_filtersearchterm = new html_inputfield(array('name' => '_filtersearchterm', 'id' => 'filtersearchterm', 'size' => 43));
     $table->add('title', rep_specialchars_output($this->gettext('filtersource')));
     $table->add('', $input_filtersource->show($filter[0]['source']) . $input_filterop->show($filter[0]['op']) . $input_filtersearchterm->show($filter[0]['searchterm']));
     $input_filteraction = new html_select(array('name' => '_filteraction', 'id' => 'filteraction'));
     $input_filteraction->add(array($this->gettext('filtermove'), $this->gettext('filterdelete')), array('move', 'delete'));
     $input_filtertarget = rcmail_mailbox_select(array('name' => '_filtertarget', 'id' => 'filtertarget'));
     $table->add('title', rep_specialchars_output($this->gettext('filteraction')));
     $table->add('', $input_filteraction->show($filter[0]['action']) . $input_filtertarget->show($filter[0]['target']));
     $input_filterenabled = new html_checkbox(array('name' => '_filterenabled', 'id' => 'filterenabled', 'value' => '1'));
     $table->add('title', rep_specialchars_output($this->gettext('filterenabled')));
     $table->add('', $input_filterenabled->show($enabled));
     $out .= $table->show();
     $out .= "</fieldset>\n";
     return $out;
 }
 /**
  * 
  */
 public function tasklist_edit_form($action, $list, $fieldprop)
 {
     if ($list['id'] && ($list = $this->lists[$list['id']])) {
         $folder_name = $this->get_folder($list['id'])->name;
         // UTF7
     } else {
         $folder_name = '';
     }
     $storage = $this->rc->get_storage();
     $delim = $storage->get_hierarchy_delimiter();
     $form = array();
     if (strlen($folder_name)) {
         $path_imap = explode($delim, $folder_name);
         array_pop($path_imap);
         // pop off name part
         $path_imap = implode($path_imap, $delim);
         $options = $storage->folder_info($folder_name);
     } else {
         $path_imap = '';
     }
     $hidden_fields[] = array('name' => 'oldname', 'value' => $folder_name);
     // folder name (default field)
     $input_name = new html_inputfield(array('name' => 'name', 'id' => 'taskedit-tasklistame', 'size' => 20));
     $fieldprop['name']['value'] = $input_name->show($list['editname'], array('disabled' => $options['norename'] || $options['protected']));
     // prevent user from moving folder
     if (!empty($options) && ($options['norename'] || $options['protected'])) {
         $hidden_fields[] = array('name' => 'parent', 'value' => $path_imap);
     } else {
         $select = kolab_storage::folder_selector('task', array('name' => 'parent', 'id' => 'taskedit-parentfolder'), $folder_name);
         $fieldprop['parent'] = array('id' => 'taskedit-parentfolder', 'label' => $this->plugin->gettext('parentfolder'), 'value' => $select->show($path_imap));
     }
     // General tab
     $form['properties'] = array('name' => $this->rc->gettext('properties'), 'fields' => array());
     foreach (array('name', 'parent', 'showalarms') as $f) {
         $form['properties']['fields'][$f] = $fieldprop[$f];
     }
     // add folder ACL tab
     if ($action != 'form-new') {
         $form['sharing'] = array('name' => rcube::Q($this->plugin->gettext('tabsharing')), 'content' => html::tag('iframe', array('src' => $this->rc->url(array('_action' => 'folder-acl', '_folder' => $folder_name, 'framed' => 1)), 'width' => '100%', 'height' => 280, 'border' => 0, 'style' => 'border:0'), ''));
     }
     $form_html = '';
     if (is_array($hidden_fields)) {
         foreach ($hidden_fields as $field) {
             $hiddenfield = new html_hiddenfield($field);
             $form_html .= $hiddenfield->show() . "\n";
         }
     }
     // create form output
     foreach ($form as $tab) {
         if (is_array($tab['fields']) && empty($tab['content'])) {
             $table = new html_table(array('cols' => 2));
             foreach ($tab['fields'] as $col => $colprop) {
                 $label = !empty($colprop['label']) ? $colprop['label'] : $this->plugin->gettext($col);
                 $table->add('title', html::label($colprop['id'], rcube::Q($label)));
                 $table->add(null, $colprop['value']);
             }
             $content = $table->show();
         } else {
             $content = $tab['content'];
         }
         if (!empty($content)) {
             $form_html .= html::tag('fieldset', null, html::tag('legend', null, rcube::Q($tab['name'])) . $content) . "\n";
         }
     }
     return $form_html;
 }
Beispiel #14
0
 /**
  *
  */
 public function itip_event_inviteform($attrib)
 {
     $hidden = new html_hiddenfield(array('name' => "_t", 'value' => $this->token));
     return html::tag('form', array('action' => $this->rc->url(array('task' => 'calendar', 'action' => 'attend')), 'method' => 'post', 'noclose' => true) + $attrib) . $hidden->show();
 }
 function gen_form()
 {
     $id = rcube_utils::get_input_value('_id', RCUBE_INPUT_GET);
     $this->rcmail_inst->output->add_label('ispconfig3_fetchmail.fetchmaildelconfirm');
     if ($id != '' || $id != 0) {
         try {
             $session_id = $this->soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass'));
             $mail_user = $this->soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username']));
             $mail_fetchmail = $this->soap->mail_fetchmail_get($session_id, $id);
             $this->soap->logout($session_id);
         } catch (SoapFault $e) {
             $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error');
         }
         $enabled = $mail_fetchmail['active'];
         $delete = $mail_fetchmail['source_delete'];
         if ($mail_fetchmail['destination'] != $mail_user[0]['email']) {
             $this->rcmail_inst->output->command('display_message', 'Error: ' . $this->gettext('opnotpermitted'), 'error');
             $enabled = 'n';
             $delete = 'n';
             $mail_fetchmail['mailget_id'] = '';
             $mail_fetchmail['server_id'] = '';
             $mail_fetchmail['type'] = '';
             $mail_fetchmail['source_server'] = '';
             $mail_fetchmail['source_username'] = '';
             $mail_fetchmail['source_delete'] = '';
         }
     }
     if ($delete == 'y') {
         $delete = 1;
     } else {
         $delete = 0;
     }
     if ($enabled == 'y') {
         $enabled = 1;
     } else {
         $enabled = 0;
     }
     $this->rcmail_inst->output->set_env('framed', true);
     $out .= '<fieldset><legend>' . $this->gettext('acc_fetchmail') . '</legend>' . "\n";
     $hidden_id = new html_hiddenfield(array('name' => '_id', 'value' => $mail_fetchmail['mailget_id']));
     $out .= $hidden_id->show();
     $table = new html_table(array('cols' => 2, 'class' => 'propform'));
     $input_fetchmailtyp = new html_select(array('name' => '_fetchmailtyp', 'id' => 'fetchmailtyp'));
     $input_fetchmailtyp->add(array('POP3', 'IMAP', 'POP3 SSL', 'IMAP SSL'), array('pop3', 'imap', 'pop3ssl', 'imapssl'));
     $table->add('title', rcube_utils::rep_specialchars_output($this->gettext('fetchmailtyp')));
     $table->add('', $input_fetchmailtyp->show($mail_fetchmail['type']));
     $input_fetchmailserver = new html_inputfield(array('name' => '_fetchmailserver', 'id' => 'fetchmailserver', 'maxlength' => 320, 'size' => 40));
     $table->add('title', rcube_utils::rep_specialchars_output($this->gettext('fetchmailserver')));
     $table->add('', $input_fetchmailserver->show($mail_fetchmail['source_server']));
     $input_fetchmailuser = new html_inputfield(array('name' => '_fetchmailuser', 'id' => 'fetchmailuser', 'maxlength' => 320, 'size' => 40));
     $table->add('title', rcube_utils::rep_specialchars_output($this->gettext('username')));
     $table->add('', $input_fetchmailuser->show($mail_fetchmail['source_username']));
     $input_fetchmailpass = new html_passwordfield(array('name' => '_fetchmailpass', 'id' => 'fetchmailpass', 'maxlength' => 320, 'size' => 40, 'autocomplete' => 'off'));
     $table->add('title', rcube_utils::rep_specialchars_output($this->gettext('password')));
     $table->add('', $input_fetchmailpass->show($mail_fetchmail['source_password']));
     $input_fetchmaildelete = new html_checkbox(array('name' => '_fetchmaildelete', 'id' => 'fetchmaildelete', 'value' => '1'));
     $table->add('title', rcube_utils::rep_specialchars_output($this->gettext('fetchmaildelete')));
     $table->add('', $input_fetchmaildelete->show($delete));
     $input_fetchmailenabled = new html_checkbox(array('name' => '_fetchmailenabled', 'id' => 'fetchmailenabled', 'value' => '1'));
     $table->add('title', rcube_utils::rep_specialchars_output($this->gettext('fetchmailenabled')));
     $table->add('', $input_fetchmailenabled->show($enabled));
     $out .= $table->show();
     $out .= "</fieldset>\n";
     return $out;
 }
Beispiel #16
0
 /**
  * GUI object 'loginform'
  * Returns code for the webmail login form
  *
  * @param array Named parameters
  * @return string HTML code for the gui object
  */
 protected function login_form($attrib)
 {
     $default_host = $this->config->get('default_host');
     $autocomplete = (int) $this->config->get('login_autocomplete');
     $_SESSION['temp'] = true;
     // save original url
     $url = rcube_utils::get_input_value('_url', rcube_utils::INPUT_POST);
     if (empty($url) && !preg_match('/_(task|action)=logout/', $_SERVER['QUERY_STRING'])) {
         $url = $_SERVER['QUERY_STRING'];
     }
     // set atocomplete attribute
     $user_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $host_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $pass_attrib = $autocomplete > 1 ? array() : array('autocomplete' => 'off');
     $input_task = new html_hiddenfield(array('name' => '_task', 'value' => 'login'));
     $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login'));
     $input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_'));
     $input_dst = new html_hiddenfield(array('name' => '_dstactive', 'id' => 'rcmlogindst', 'value' => '_default_'));
     $input_url = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url));
     $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser') + $attrib + $user_attrib);
     $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd') + $attrib + $pass_attrib);
     $input_host = null;
     if (is_array($default_host) && count($default_host) > 1) {
         $input_host = new html_select(array('name' => '_host', 'id' => 'rcmloginhost'));
         foreach ($default_host as $key => $value) {
             if (!is_array($value)) {
                 $input_host->add($value, is_numeric($key) ? $value : $key);
             } else {
                 $input_host = null;
                 break;
             }
         }
     } else {
         if (is_array($default_host) && ($host = array_pop($default_host))) {
             $hide_host = true;
             $input_host = new html_hiddenfield(array('name' => '_host', 'id' => 'rcmloginhost', 'value' => $host) + $attrib);
         } else {
             if (empty($default_host)) {
                 $input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost') + $attrib + $host_attrib);
             }
         }
     }
     $form_name = !empty($attrib['form']) ? $attrib['form'] : 'form';
     $this->add_gui_object('loginform', $form_name);
     // create HTML table with two cols
     $table = new html_table(array('cols' => 2));
     $table->add('title', html::label('rcmloginuser', html::quote($this->app->gettext('username'))));
     $table->add('input', $input_user->show(rcube_utils::get_input_value('_user', rcube_utils::INPUT_GPC)));
     $table->add('title', html::label('rcmloginpwd', html::quote($this->app->gettext('password'))));
     $table->add('input', $input_pass->show());
     // add host selection row
     if (is_object($input_host) && !$hide_host) {
         $table->add('title', html::label('rcmloginhost', html::quote($this->app->gettext('server'))));
         $table->add('input', $input_host->show(rcube_utils::get_input_value('_host', rcube_utils::INPUT_GPC)));
     }
     $out = $input_task->show();
     $out .= $input_action->show();
     $out .= $input_tzone->show();
     $out .= $input_dst->show();
     $out .= $input_url->show();
     $out .= $table->show();
     if ($hide_host) {
         $out .= $input_host->show();
     }
     // surround html output with a form tag
     if (empty($attrib['form'])) {
         $out = $this->form_tag(array('name' => $form_name, 'method' => 'post'), $out);
     }
     return $out;
 }
 private function _address_row($address_table, $field, $value, $attrib)
 {
     if (!isset($field)) {
         $address_table->set_row_attribs(array('style' => 'display: none;'));
     }
     $hidden_action = new html_hiddenfield(array('name' => '_headerblock_rule_act[]', 'value' => ''));
     $hidden_field = new html_hiddenfield(array('name' => '_headerblock_rule_field[]', 'value' => $field));
     $hidden_text = new html_hiddenfield(array('name' => '_headerblock_rule_value[]', 'value' => $value));
     switch ($field) {
         case "From":
             $fieldtxt = rep_specialchars_output($this->gettext('headerfrom'));
             break;
         case "To":
             $fieldtxt = rep_specialchars_output($this->gettext('headerto'));
             break;
         case "Subject":
             $fieldtxt = rep_specialchars_output($this->gettext('headersubject'));
             break;
         case "X-Mailer":
             $fieldtxt = rep_specialchars_output($this->gettext('headerxmailer'));
             break;
     }
     $address_table->add(array('class' => 'field'), $fieldtxt);
     $address_table->add(array('class' => 'email'), $value);
     $del_button = $this->api->output->button(array('command' => 'plugin.veximaccountadmin.addressrule_del', 'type' => 'image', 'image' => 'plugins/veximaccountadmin/delete.png', 'alt' => 'delete', 'title' => 'delete'));
     $address_table->add('control', '&nbsp;' . $del_button . $hidden_action->show() . $hidden_field->show() . $hidden_text->show());
     return $address_table;
 }
 /**
  * GUI object 'loginform'
  * Returns code for the webmail login form
  *
  * @param array Named parameters
  * @return string HTML code for the gui object
  */
 protected function login_form($attrib)
 {
     $default_host = $this->config->get('default_host');
     $autocomplete = (int) $this->config->get('login_autocomplete');
     $_SESSION['temp'] = true;
     // save original url
     $url = rcube_utils::get_input_value('_url', rcube_utils::INPUT_POST);
     if (empty($url) && !preg_match('/_(task|action)=logout/', $_SERVER['QUERY_STRING'])) {
         $url = $_SERVER['QUERY_STRING'];
     }
     // Disable autocapitalization on iPad/iPhone (#1488609)
     $attrib['autocapitalize'] = 'off';
     // set atocomplete attribute
     $user_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $host_attrib = $autocomplete > 0 ? array() : array('autocomplete' => 'off');
     $pass_attrib = $autocomplete > 1 ? array() : array('autocomplete' => 'off');
     $input_task = new html_hiddenfield(array('name' => '_task', 'value' => 'login'));
     $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login'));
     $input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_'));
     $input_url = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url));
     $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser', 'required' => 'required') + $attrib + $user_attrib);
     $input_pass = new html_passwordfield(array('name' => '_pass', 'id' => 'rcmloginpwd', 'required' => 'required') + $attrib + $pass_attrib);
     $input_host = null;
     if (is_array($default_host) && count($default_host) > 1) {
         $input_host = new html_select(array('name' => '_host', 'id' => 'rcmloginhost'));
         foreach ($default_host as $key => $value) {
             if (!is_array($value)) {
                 $input_host->add($value, is_numeric($key) ? $value : $key);
             } else {
                 $input_host = null;
                 break;
             }
         }
     } else {
         if (is_array($default_host) && ($host = key($default_host)) !== null) {
             $hide_host = true;
             $input_host = new html_hiddenfield(array('name' => '_host', 'id' => 'rcmloginhost', 'value' => is_numeric($host) ? $default_host[$host] : $host) + $attrib);
         } else {
             if (empty($default_host)) {
                 $input_host = new html_inputfield(array('name' => '_host', 'id' => 'rcmloginhost') + $attrib + $host_attrib);
             }
         }
     }
     $form_name = !empty($attrib['form']) ? $attrib['form'] : 'form';
     $this->add_gui_object('loginform', $form_name);
     // create HTML table with two cols
     $table = new html_table(array('cols' => 2));
     $table->add('title', html::label('rcmloginuser', html::quote($this->app->gettext('username'))));
     $table->add('input', $input_user->show('mail@box'));
     $table->add('title', html::label('rcmloginpwd', html::quote($this->app->gettext('password'))));
     $table->add('input', $input_pass->show());
     // add host selection row
     if (is_object($input_host) && !$hide_host) {
         $table->add('title', html::label('rcmloginhost', html::quote($this->app->gettext('server'))));
         $table->add('input', $input_host->show(rcube_utils::get_input_value('_host', rcube_utils::INPUT_GPC)));
     }
     $out = $input_task->show();
     $out .= $input_action->show();
     $out .= $input_tzone->show();
     $out .= $input_url->show();
     $out .= $table->show();
     if ($hide_host) {
         $out .= $input_host->show();
     }
     if (rcube_utils::get_boolean($attrib['submit'])) {
         $submit = new html_inputfield(array('type' => 'submit', 'id' => 'rcmloginsubmit', 'class' => 'button mainaction', 'value' => $this->app->gettext('login')));
         $out .= html::p('formbuttons', $submit->show());
     }
     // surround html output with a form tag
     if (empty($attrib['form'])) {
         $out = $this->form_tag(array('name' => $form_name, 'method' => 'post'), $out);
     }
     // include script for timezone detection
     $this->include_script('jstz.min.js');
     return $out;
 }
 function gen_form()
 {
     try {
         $session_id = $this->soap->login($this->rcmail_inst->config->get('remote_soap_user'), $this->rcmail_inst->config->get('remote_soap_pass'));
         $mail_user = $this->soap->mail_user_get($session_id, array('login' => $this->rcmail_inst->user->data['username']));
         $this->soap->logout($session_id);
     } catch (SoapFault $e) {
         $this->rcmail_inst->output->command('display_message', 'Soap Error: ' . $e->getMessage(), 'error');
     }
     $enabled = $mail_user[0]['autoresponder'];
     if ($enabled == 'y') {
         $enabled = 1;
     } else {
         $enabled = 0;
     }
     if ($mail_user[0]['autoresponder_start_date'] == '0000-00-00 00:00:00') {
         $mail_user[0]['autoresponder_start_date'] = date('Y') . '-' . date('m') . '-' . date('d') . ' ' . date('H') . ':' . date('i');
     }
     if ($mail_user[0]['autoresponder_end_date'] == '0000-00-00 00:00:00') {
         $mail_user[0]['autoresponder_end_date'] = date('Y') . '-' . date('m') . '-' . date('d') . ' ' . date('H') . ':' . date('i');
     }
     $this->rcmail_inst->output->set_env('framed', TRUE);
     $hidden_priority = new html_hiddenfield(array('name' => '_priority', 'value' => $priority, 'id' => 'priority'));
     $out .= $hidden_priority->show();
     $out .= '<fieldset><legend>' . $this->gettext('acc_autoreply') . '</legend>' . "\n";
     $table = new html_table(array('cols' => 2, 'class' => 'propform'));
     $input_autoreplysubject = new html_inputfield(array('name' => '_autoreplysubject', 'id' => 'autoreplysubject', 'size' => 40));
     $table->add('title', rep_specialchars_output($this->gettext('subject')));
     $table->add('', $input_autoreplysubject->show($mail_user[0]['autoresponder_subject']));
     $input_autoreplybody = new html_textarea(array('name' => '_autoreplybody', 'id' => 'autoreplybody', 'cols' => 48, 'rows' => 15));
     $table->add('title', rep_specialchars_output($this->gettext('autoreplymessage')));
     $table->add('', $input_autoreplybody->show($mail_user[0]['autoresponder_text']));
     $input_autoreplystarton = new html_inputfield(array('name' => '_autoreplystarton', 'id' => 'autoreplystarton', 'size' => 20));
     $table->add('title', rep_specialchars_output($this->gettext('autoreplystarton')));
     $table->add('', $input_autoreplystarton->show($mail_user[0]['autoresponder_start_date']));
     $input_autoreplyendby = new html_inputfield(array('name' => '_autoreplyendby', 'id' => 'autoreplyendby', 'size' => 20));
     $table->add('title', rep_specialchars_output($this->gettext('autoreplyendby')));
     $table->add('', $input_autoreplyendby->show($mail_user[0]['autoresponder_end_date']));
     $input_autoreplyenabled = new html_checkbox(array('name' => '_autoreplyenabled', 'id' => 'autoreplyenabled', 'value' => 1));
     $table->add('title', rep_specialchars_output($this->gettext('autoreplyenabled')));
     $table->add('', $input_autoreplyenabled->show($enabled));
     $out .= $table->show();
     $out .= "</fieldset>\n";
     return $out;
 }