Ejemplo n.º 1
0
 function settings_table($args)
 {
     if ($args['section'] == 'mailbox') {
         $a_list_cols = rcmail::get_instance()->config->get('list_cols');
         $args['blocks']['roworder']['name'] = Q($this->gettext('roworder', 'msglistcols'));
         for ($i = 0; $i < 9; $i++) {
             $field_id = 'rcmfd_list_col' . $i;
             $select_col = new html_select(array('name' => '_list_cols[]', 'id' => $field_id));
             $select_col->add(rcube_label('skip', 'msglistcols'), '');
             $select_col->add(rcube_label('subject'), 'subject');
             $select_col->add(rcube_label('from'), 'from');
             $select_col->add(rcube_label('to'), 'to');
             $select_col->add(rcube_label('cc'), 'cc');
             $select_col->add(rcube_label('replyto'), 'replyto');
             $select_col->add(rcube_label('date'), 'date');
             $select_col->add(rcube_label('size'), 'size');
             $select_col->add(rcube_label('flagged', 'msglistcols'), 'flag');
             $select_col->add(rcube_label('attachment', 'msglistcols'), 'attachment');
             $args['blocks']['roworder']['options']['listcol_' . $i]['title'] = Q($this->gettext('list_col_' . $i, 'msglistcols'));
             if (!empty($a_list_cols[$i])) {
                 $selected = $a_list_cols[$i];
             } else {
                 $selected = "";
             }
             $args['blocks']['roworder']['options']['listcol_' . $i]['content'] = $select_col->show($selected);
             unset($select_col);
         }
     }
     return $args;
 }
Ejemplo n.º 2
0
 function select_menu()
 {
     $rcmail = rcmail::get_instance();
     $skin = $rcmail->config->get('skin');
     if ($skin == 'classic' or $skin == 'default') {
         $out .= "<div id=\"selectmenu\" class=\"popupmenu\">\n        <ul>\n          <li><a title=\"" . rcube_label('all') . "\" href=\"#\" onclick=\"return rcmail.command('select-all','',this)\" class=\"active\">" . rcube_label('all') . "</a></li>\n          <li><a title=\"" . rcube_label('currpage') . "\" href=\"#\" onclick=\"return rcmail.command('select-all','page',this)\" class=\"active\">" . rcube_label('currpage') . "</a></li>\n          <li><a title=\"" . rcube_label('unread') . "\" href=\"#\" onclick=\"return rcmail.command('select-all','unread',this)\" class=\"active\">" . rcube_label('unread') . "</a></li>\n          <li><a title=\"" . rcube_label('invert') . "\" href=\"#\" onclick=\"return rcmail.command('select-all','invert',this)\" class=\"active\">" . rcube_label('invert') . "</a></li>\n          <li><a title=\"" . rcube_label('none') . "\" href=\"#\" onclick=\"return rcmail.command('select-none','',this)\" class=\"active\">" . rcube_label('none') . "</a></li>\n        </ul>";
     } else {
         $out .= "<div id=\"selectmenu\" class=\"popupmenu dropdown\">\n        <ul>\n          <li title=\"" . rcube_label('all') . "\" onclick=\"return rcmail.command('select-all','',this)\" class=\"active\">" . rcube_label('all') . "</li>\n          <li title=\"" . rcube_label('currpage') . "\" onclick=\"return rcmail.command('select-all','page',this)\" class=\"active\">" . rcube_label('currpage') . "</li>\n          <li title=\"" . rcube_label('unread') . "\" onclick=\"return rcmail.command('select-all','unread',this)\" class=\"active\">" . rcube_label('unread') . "</li>\n          <li title=\"" . rcube_label('invert') . "\" onclick=\"return rcmail.command('select-all','invert',this)\" class=\"active\">" . rcube_label('invert') . "</li>\n          <li title=\"" . rcube_label('none') . "\" onclick=\"return rcmail.command('select-none','',this)\" class=\"active\">" . rcube_label('none') . "</li>\n        </ul>";
     }
     $out .= "</div>";
     $rcmail->output->add_gui_object('selectmenu', 'selectmenu');
     $rcmail->output->add_footer($out);
 }
Ejemplo n.º 3
0
 public function __construct($dbid)
 {
     $dbh = rcmail::get_instance()->db;
     $this->ready = $dbh && !$dbh->is_error();
     $this->groups = true;
     $this->readonly = false;
     $this->id = $dbid;
     $this->config = self::carddavconfig($dbid);
     $prefs = carddav_common::get_adminsettings();
     if ($this->config['presetname']) {
         if ($prefs[$this->config['presetname']]['readonly']) {
             $this->readonly = true;
         }
     }
     $this->coltypes = array('name' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('name'), 'category' => 'main'), 'firstname' => array('type' => 'text', 'size' => 19, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('firstname'), 'category' => 'main'), 'surname' => array('type' => 'text', 'size' => 19, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('surname'), 'category' => 'main'), 'email' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('email'), 'subtypes' => array('home', 'work', 'other', 'internet'), 'category' => 'main'), 'middlename' => array('type' => 'text', 'size' => 19, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('middlename'), 'category' => 'main'), 'prefix' => array('type' => 'text', 'size' => 8, 'maxlength' => 20, 'limit' => 1, 'label' => rcube_label('nameprefix'), 'category' => 'main'), 'suffix' => array('type' => 'text', 'size' => 8, 'maxlength' => 20, 'limit' => 1, 'label' => rcube_label('namesuffix'), 'category' => 'main'), 'nickname' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('nickname'), 'category' => 'main'), 'jobtitle' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('jobtitle'), 'category' => 'main'), 'organization' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('organization'), 'category' => 'main'), 'department' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('department'), 'category' => 'main'), 'gender' => array('type' => 'select', 'limit' => 1, 'label' => rcube_label('gender'), 'options' => array('male' => rcube_label('male'), 'female' => rcube_label('female')), 'category' => 'personal'), 'phone' => array('type' => 'text', 'size' => 40, 'maxlength' => 20, 'label' => rcube_label('phone'), 'subtypes' => array('home', 'home2', 'work', 'work2', 'mobile', 'cell', 'main', 'homefax', 'workfax', 'car', 'pager', 'video', 'assistant', 'other'), 'category' => 'main'), 'address' => array('type' => 'composite', 'label' => rcube_label('address'), 'subtypes' => array('home', 'work', 'other'), 'childs' => array('street' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('street'), 'category' => 'main'), 'locality' => array('type' => 'text', 'size' => 28, 'maxlength' => 50, 'label' => rcube_label('locality'), 'category' => 'main'), 'zipcode' => array('type' => 'text', 'size' => 8, 'maxlength' => 15, 'label' => rcube_label('zipcode'), 'category' => 'main'), 'region' => array('type' => 'text', 'size' => 12, 'maxlength' => 50, 'label' => rcube_label('region'), 'category' => 'main'), 'country' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('country'), 'category' => 'main')), 'category' => 'main'), 'birthday' => array('type' => 'date', 'size' => 12, 'maxlength' => 16, 'label' => rcube_label('birthday'), 'limit' => 1, 'render_func' => 'rcmail_format_date_col', 'category' => 'personal'), 'anniversary' => array('type' => 'date', 'size' => 12, 'maxlength' => 16, 'label' => rcube_label('anniversary'), 'limit' => 1, 'render_func' => 'rcmail_format_date_col', 'category' => 'personal'), 'website' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'label' => rcube_label('website'), 'subtypes' => array('homepage', 'work', 'blog', 'profile', 'other'), 'category' => 'main'), 'notes' => array('type' => 'textarea', 'size' => 40, 'rows' => 15, 'maxlength' => 500, 'label' => rcube_label('notes'), 'limit' => 1), 'photo' => array('type' => 'image', 'limit' => 1, 'category' => 'main'), 'assistant' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('assistant'), 'category' => 'personal'), 'manager' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('manager'), 'category' => 'personal'), 'spouse' => array('type' => 'text', 'size' => 40, 'maxlength' => 50, 'limit' => 1, 'label' => rcube_label('spouse'), 'category' => 'personal'));
     /* }}} */
     $this->addextrasubtypes();
 }
Ejemplo n.º 4
0
 function header_alter_charsets($p)
 {
     if ($msg_uid = get_input_value('_uid', RCUBE_INPUT_GET)) {
         $rcmail = rcmail::get_instance();
         $alter_charset = (array) $rcmail->config->get('alter_charset', array());
         $charset = $this->charset($msg_uid);
         $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         //error_log($charset."\n",3,"/var/log/nginx/checkmail_error.log");
         if ($alias_charset = get_input_value('_alter_charset', RCUBE_INPUT_GET)) {
             $charset = $alter_charset[$alias_charset];
             $url = str_replace('&_alter_charset=' . $alias_charset, '', $url);
         }
         $selector = '';
         foreach ($alter_charset as $key => $value) {
             $selector .= sprintf('<input type="radio" id="r_%s" onclick="window.location.href=\'https://%s&_alter_charset=%s\';" value="%s" %s>', $key, $url, $key, $key, current(array_keys($alter_charset, $charset)) == $key ? 'checked' : '') . html::label($attrib['id'], strtolower($value));
         }
         $p['output']['selectcharset'] = array('title' => rcube_label('charset'), 'value' => strtr($selector, "\r\n", "  "));
     }
     return $p;
 }
Ejemplo n.º 5
0
 function filters_form()
 {
     $this->rc->imap_connect();
     $table = new html_table(array('cols' => 4));
     $table->add('title', Q($this->gettext('whatfilter') . ":"));
     $select = new html_select(array('name' => '_whatfilter', 'id' => 'whatfilter'));
     $select->add($this->gettext('from'), 'from');
     $select->add($this->gettext('to'), 'to');
     $select->add($this->gettext('cc'), 'cc');
     $select->add($this->gettext('subject'), 'subject');
     $table->add('', $select->show($this->gettext('from')));
     $table->add_row();
     $table->add('title', Q($this->gettext('searchstring') . ":"));
     $inputfield = new html_inputfield(array('name' => '_searchstring', 'id' => 'searchstring'));
     $table->add('', $inputfield->show(""));
     $table->add('title', Q($this->gettext('casesensitive') . ":"));
     $checkbox = new html_checkbox(array('name' => '_casesensitive', 'id' => 'casesensitive', 'value' => '1'));
     $casesensitive = $this->rc->config->get('caseInsensitiveSearch', true);
     $table->add('', $checkbox->show($casesensitive ? 1 : 0));
     $table->add_row();
     $table->add('title', Q($this->gettext('moveto') . ":"));
     $select = rcmail_mailbox_select(array('name' => '_folders', 'id' => 'folders'));
     $table->add('title', $select->show());
     $table->add_row();
     # new option: all, read and unread messages
     $table->add('title', Q($this->gettext('messagecount') . ":"));
     $select = new html_select(array('name' => '_messages', 'id' => 'messages'));
     $select->add($this->gettext('all'), 'all');
     $select->add($this->gettext('unread'), 'unread');
     $select->add($this->gettext('markread'), 'markread');
     $table->add('', $select->show($this->gettext('all')));
     // get mailbox list
     $a_folders = $this->rc->imap->list_mailboxes('', '*');
     $delimiter = $this->rc->imap->get_hierarchy_delimiter();
     $a_mailboxes = array();
     foreach ($a_folders as $folder) {
         rcmail_build_folder_tree($a_mailboxes, $folder, $delimiter);
     }
     // load saved filters
     $user = $this->rc->user;
     $arr_prefs = $user->get_prefs();
     $i = 1;
     $flag = false;
     $table2 = new html_table(array('cols' => 2));
     //To prevent PHP Warning when no filter already set
     if (!empty($arr_prefs['filters'])) {
         foreach ($arr_prefs['filters'] as $key => $saved_filter) {
             $flag = true;
             $folder_id = $saved_filter['destfolder'];
             $folder_name = "";
             if (strtoupper($folder_id) == 'INBOX') {
                 $folder_name = rcube_label('inbox');
             } else {
                 foreach ($a_mailboxes as $folder => $vet) {
                     if ($vet['id'] == $folder_id) {
                         $folder_name = $vet['name'];
                         break;
                     }
                 }
             }
             $messages = $saved_filter['messages'];
             $msg = $i . " - " . $this->gettext('msg_if_field') . " <b>" . $this->gettext($saved_filter['whatfilter']) . "</b> " . $this->gettext('msg_contains') . " <b>" . $saved_filter['searchstring'] . "</b> " . ($saved_filter['casesensitive'] == '1' ? $this->gettext('msg_and_is') . " <b>" . $this->gettext('casesensitive') . "</b> " : "") . $this->gettext('msg_move_msg_in') . " <b>" . $folder_name . "</b> " . "(" . $this->gettext('messagecount') . ": " . $this->gettext($saved_filter['messages']) . ")";
             $table2->add('title', $msg);
             $dlink = "<a href='./?_task=settings&_action=plugin.filters-delete&filterid=" . $key . "'>" . $this->gettext('delete') . "</a>";
             $table2->add('title', $dlink);
             $i++;
         }
     }
     if (!$flag) {
         $table2->add('title', Q($this->gettext('msg_no_stored_filters')));
     }
     $out = html::div(array('class' => 'box'), html::div(array('id' => 'prefs-title', 'class' => 'boxtitle'), $this->gettext('filters')) . html::div(array('class' => 'boxcontent'), $table->show() . html::p(null, $this->rc->output->button(array('command' => 'plugin.filters-save', 'type' => 'input', 'class' => 'button mainaction', 'label' => 'save')))));
     $out .= html::div(array('id' => 'prefs-title', 'class' => 'boxtitle'), $this->gettext('storedfilters')) . html::div(array('class' => 'uibox listbox scroller', 'style' => 'margin-top:205px;'), html::div(array('class' => 'boxcontent'), $table2->show()));
     $this->rc->output->add_gui_object('filtersform', 'filters-form');
     return $this->rc->output->form_tag(array('id' => 'filters-form', 'name' => 'filters-form', 'method' => 'post', 'action' => './?_task=settings&_action=plugin.filters-save'), $out);
 }
Ejemplo n.º 6
0
 /**
  * Raad the message structure returend by the IMAP server
  * and build flat lists of content parts and attachments
  *
  * @param object rcube_message_part Message structure node
  * @param bool  True when called recursively
  */
 private function parse_structure($structure, $recursive = false)
 {
     $message_ctype_primary = strtolower($structure->ctype_primary);
     $message_ctype_secondary = strtolower($structure->ctype_secondary);
     // show message headers
     if ($recursive && is_array($structure->headers) && isset($structure->headers['subject'])) {
         $c = new stdClass();
         $c->type = 'headers';
         $c->headers =& $structure->headers;
         $this->parts[] = $c;
     }
     // print body if message doesn't have multiple parts
     if ($message_ctype_primary == 'text' && !$recursive) {
         $structure->type = 'content';
         $this->parts[] =& $structure;
     } else {
         if ($message_ctype_primary == 'application' && $message_ctype_secondary == 'pgp' && !$recursive) {
             $structure->type = 'content';
             $this->parts[] =& $structure;
         } else {
             if ($message_ctype_primary == 'multipart' && $message_ctype_secondary == 'alternative' && is_array($structure->parts)) {
                 // get html/plaintext parts
                 $plain_part = $html_part = $print_part = $related_part = null;
                 foreach ($structure->parts as $p => $sub_part) {
                     $rel_parts = $attachmnts = null;
                     $sub_ctype_primary = strtolower($sub_part->ctype_primary);
                     $sub_ctype_secondary = strtolower($sub_part->ctype_secondary);
                     // check if sub part is
                     if ($sub_ctype_primary == 'text' && $sub_ctype_secondary == 'plain') {
                         $plain_part = $p;
                     } else {
                         if ($sub_ctype_primary == 'text' && $sub_ctype_secondary == 'html') {
                             $html_part = $p;
                         } else {
                             if ($sub_ctype_primary == 'text' && $sub_ctype_secondary == 'enriched') {
                                 $enriched_part = $p;
                             } else {
                                 if ($sub_ctype_primary == 'multipart' && in_array($sub_ctype_secondary, array('related', 'mixed', 'alternative'))) {
                                     $related_part = $p;
                                 }
                             }
                         }
                     }
                 }
                 // parse related part (alternative part could be in here)
                 if ($related_part !== null && !$this->parse_alternative) {
                     $this->parse_alternative = true;
                     $this->parse_structure($structure->parts[$related_part], true);
                     $this->parse_alternative = false;
                     // if plain part was found, we should unset it if html is preferred
                     if ($this->opt['prefer_html'] && count($this->parts)) {
                         $plain_part = null;
                     }
                 }
                 // choose html/plain part to print
                 if ($html_part !== null && $this->opt['prefer_html']) {
                     $print_part =& $structure->parts[$html_part];
                 } else {
                     if ($enriched_part !== null) {
                         $print_part =& $structure->parts[$enriched_part];
                     } else {
                         if ($plain_part !== null) {
                             $print_part =& $structure->parts[$plain_part];
                         }
                     }
                 }
                 // add the right message body
                 if (is_object($print_part)) {
                     $print_part->type = 'content';
                     $this->parts[] = $print_part;
                 } else {
                     if ($html_part !== null && empty($this->parts)) {
                         $c = new stdClass();
                         $c->type = 'content';
                         $c->body = rcube_label('htmlmessage');
                         $c->ctype_primary = 'text';
                         $c->ctype_secondary = 'plain';
                         $this->parts[] = $c;
                     }
                 }
                 // add html part as attachment
                 if ($html_part !== null && $structure->parts[$html_part] !== $print_part) {
                     $html_part =& $structure->parts[$html_part];
                     $html_part->filename = rcube_label('htmlmessage');
                     $html_part->mimetype = 'text/html';
                     $this->attachments[] = $html_part;
                 }
             } else {
                 if ($message_ctype_primary == 'multipart' && $message_ctype_secondary == 'encrypted') {
                     $p = new stdClass();
                     $p->type = 'content';
                     $p->ctype_primary = 'text';
                     $p->ctype_secondary = 'plain';
                     $p->body = rcube_label('encryptedmessage');
                     $this->parts[] = $p;
                 } else {
                     if (is_array($structure->parts) && !empty($structure->parts)) {
                         // iterate over parts
                         for ($i = 0; $i < count($structure->parts); $i++) {
                             $mail_part =& $structure->parts[$i];
                             $primary_type = strtolower($mail_part->ctype_primary);
                             $secondary_type = strtolower($mail_part->ctype_secondary);
                             // multipart/alternative
                             if ($primary_type == 'multipart') {
                                 $this->parse_structure($mail_part, true);
                             } else {
                                 if ($primary_type == 'text' && ($secondary_type == 'plain' || $secondary_type == 'html') && $mail_part->disposition != 'attachment' || $primary_type == 'message' && ($secondary_type == 'delivery-status' || $secondary_type == 'disposition-notification')) {
                                     // add text part if we're not in alternative mode or if it matches the prefs
                                     if (!$this->parse_alternative || $secondary_type == 'html' && $this->opt['prefer_html'] || $secondary_type == 'plain' && !$this->opt['prefer_html']) {
                                         $mail_part->type = 'content';
                                         $this->parts[] = $mail_part;
                                     }
                                     // list as attachment as well
                                     if (!empty($mail_part->filename)) {
                                         $this->attachments[] = $mail_part;
                                     }
                                 } else {
                                     if ($primary_type == 'message') {
                                         $this->parse_structure($mail_part, true);
                                         // list as attachment as well (mostly .eml)
                                         if (!empty($mail_part->filename)) {
                                             $this->attachments[] = $mail_part;
                                         }
                                     } else {
                                         if ($primary_type == 'protocol') {
                                             continue;
                                         } else {
                                             if ($primary_type == 'application' && $secondary_type == 'ms-tnef') {
                                                 foreach ((array) $this->imap->tnef_decode($mail_part, $structure->headers['uid']) as $tnef_part) {
                                                     $this->mime_parts[$tnef_part->mime_id] = $tnef_part;
                                                     $this->attachments[] = $tnef_part;
                                                 }
                                             } else {
                                                 if ($mail_part->disposition == 'attachment' || $mail_part->disposition == 'inline' || $mail_part->headers['content-id'] || empty($mail_part->disposition) && $mail_part->filename) {
                                                     // skip apple resource forks
                                                     if ($message_ctype_secondary == 'appledouble' && $secondary_type == 'applefile') {
                                                         continue;
                                                     }
                                                     // part belongs to a related message
                                                     if ($message_ctype_secondary == 'related') {
                                                         if ($mail_part->headers['content-id']) {
                                                             $mail_part->content_id = preg_replace(array('/^</', '/>$/'), '', $mail_part->headers['content-id']);
                                                         }
                                                         if ($mail_part->headers['content-location']) {
                                                             $mail_part->content_location = $mail_part->headers['content-base'] . $mail_part->headers['content-location'];
                                                         }
                                                         if ($mail_part->content_id || $mail_part->content_location) {
                                                             $this->inline_parts[] = $mail_part;
                                                         }
                                                     } else {
                                                         if (!$mail_part->filename) {
                                                             $mail_part->filename = 'Part ' . $mail_part->mime_id;
                                                         }
                                                         $this->attachments[] = $mail_part;
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         // if this was a related part try to resolve references
                         if ($message_ctype_secondary == 'related' && sizeof($this->inline_parts)) {
                             $a_replaces = array();
                             foreach ($this->inline_parts as $inline_object) {
                                 $part_url = $this->get_part_url($inline_object->mime_id);
                                 if ($inline_object->content_id) {
                                     $a_replaces['cid:' . $inline_object->content_id] = $part_url;
                                 }
                                 if ($inline_object->content_location) {
                                     $a_replaces[$inline_object->content_location] = $part_url;
                                 }
                             }
                             // add replace array to each content part
                             // (will be applied later when part body is available)
                             foreach ($this->parts as $i => $part) {
                                 if ($part->type == 'content') {
                                     $this->parts[$i]->replaces = $a_replaces;
                                 }
                             }
                         }
                     } else {
                         if ($structure->filename) {
                             $this->attachments[] = $structure;
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * Generate the form for event attachments upload
  */
 function attachments_form($attrib = array())
 {
     // add ID if not given
     if (!$attrib['id']) {
         $attrib['id'] = 'rcmUploadForm';
     }
     // Get max filesize, enable upload progress bar
     $max_filesize = rcube_upload_init();
     $button = new html_inputfield(array('type' => 'button'));
     $input = new html_inputfield(array('type' => 'file', 'name' => '_attachments[]', 'multiple' => 'multiple', 'size' => $attrib['attachmentfieldsize']));
     return html::div($attrib, html::div(null, $input->show()) . html::div('formbuttons', $button->show(rcube_label('upload'), array('class' => 'button mainaction', 'onclick' => JS_OBJECT_NAME . ".upload_file(this.form)"))) . html::div('hint', rcube_label(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize)))));
 }
Ejemplo n.º 8
0
 /**
  * GUI object 'charsetselector'
  *
  * @param array Named parameters for the select tag
  * @return string HTML code for the gui object
  */
 function charset_selector($attrib)
 {
     // pass the following attributes to the form class
     $field_attrib = array('name' => '_charset');
     foreach ($attrib as $attr => $value) {
         if (in_array($attr, array('id', 'name', 'class', 'style', 'size', 'tabindex'))) {
             $field_attrib[$attr] = $value;
         }
     }
     $charsets = array('UTF-8' => 'UTF-8 (' . rcube_label('unicode') . ')', 'US-ASCII' => 'ASCII (' . rcube_label('english') . ')', 'ISO-8859-1' => 'ISO-8859-1 (' . rcube_label('westerneuropean') . ')', 'ISO-8859-2' => 'ISO-8859-2 (' . rcube_label('easterneuropean') . ')', 'ISO-8859-4' => 'ISO-8859-4 (' . rcube_label('baltic') . ')', 'ISO-8859-5' => 'ISO-8859-5 (' . rcube_label('cyrillic') . ')', 'ISO-8859-6' => 'ISO-8859-6 (' . rcube_label('arabic') . ')', 'ISO-8859-7' => 'ISO-8859-7 (' . rcube_label('greek') . ')', 'ISO-8859-8' => 'ISO-8859-8 (' . rcube_label('hebrew') . ')', 'ISO-8859-9' => 'ISO-8859-9 (' . rcube_label('turkish') . ')', 'ISO-8859-10' => 'ISO-8859-10 (' . rcube_label('nordic') . ')', 'ISO-8859-11' => 'ISO-8859-11 (' . rcube_label('thai') . ')', 'ISO-8859-13' => 'ISO-8859-13 (' . rcube_label('baltic') . ')', 'ISO-8859-14' => 'ISO-8859-14 (' . rcube_label('celtic') . ')', 'ISO-8859-15' => 'ISO-8859-15 (' . rcube_label('westerneuropean') . ')', 'ISO-8859-16' => 'ISO-8859-16 (' . rcube_label('southeasterneuropean') . ')', 'WINDOWS-1250' => 'Windows-1250 (' . rcube_label('easterneuropean') . ')', 'WINDOWS-1251' => 'Windows-1251 (' . rcube_label('cyrillic') . ')', 'WINDOWS-1252' => 'Windows-1252 (' . rcube_label('westerneuropean') . ')', 'WINDOWS-1253' => 'Windows-1253 (' . rcube_label('greek') . ')', 'WINDOWS-1254' => 'Windows-1254 (' . rcube_label('turkish') . ')', 'WINDOWS-1255' => 'Windows-1255 (' . rcube_label('hebrew') . ')', 'WINDOWS-1256' => 'Windows-1256 (' . rcube_label('arabic') . ')', 'WINDOWS-1257' => 'Windows-1257 (' . rcube_label('baltic') . ')', 'WINDOWS-1258' => 'Windows-1258 (' . rcube_label('vietnamese') . ')', 'ISO-2022-JP' => 'ISO-2022-JP (' . rcube_label('japanese') . ')', 'ISO-2022-KR' => 'ISO-2022-KR (' . rcube_label('korean') . ')', 'ISO-2022-CN' => 'ISO-2022-CN (' . rcube_label('chinese') . ')', 'EUC-JP' => 'EUC-JP (' . rcube_label('japanese') . ')', 'EUC-KR' => 'EUC-KR (' . rcube_label('korean') . ')', 'EUC-CN' => 'EUC-CN (' . rcube_label('chinese') . ')', 'BIG5' => 'BIG5 (' . rcube_label('chinese') . ')', 'GB2312' => 'GB2312 (' . rcube_label('chinese') . ')');
     if (!empty($_POST['_charset'])) {
         $set = $_POST['_charset'];
     } else {
         if (!empty($attrib['selected'])) {
             $set = $attrib['selected'];
         } else {
             $set = $this->get_charset();
         }
     }
     $set = strtoupper($set);
     if (!isset($charsets[$set])) {
         $charsets[$set] = $set;
     }
     $select = new html_select($field_attrib);
     $select->add(array_values($charsets), array_keys($charsets));
     return $select->show($set);
 }
Ejemplo n.º 9
0
 /**
  * Return address books list
  *
  * @param boolean True if the address book needs to be writeable
  * @return array  Address books array
  */
 public function get_address_sources($writeable = false)
 {
     $abook_type = strtolower($this->config->get('address_book_type'));
     $ldap_config = $this->config->get('ldap_public');
     $autocomplete = (array) $this->config->get('autocomplete_addressbooks');
     $list = array();
     // We are using the DB address book
     if ($abook_type != 'ldap') {
         $contacts = new rcube_contacts($this->db, null);
         $list['0'] = array('id' => 0, 'name' => rcube_label('personaladrbook'), 'groups' => $contacts->groups, 'readonly' => false, 'autocomplete' => in_array('sql', $autocomplete));
     }
     if ($ldap_config) {
         $ldap_config = (array) $ldap_config;
         foreach ($ldap_config as $id => $prop) {
             $list[$id] = array('id' => $id, 'name' => $prop['name'], 'groups' => false, 'readonly' => !$prop['writable'], 'autocomplete' => in_array('sql', $autocomplete));
         }
     }
     $plugin = $this->plugins->exec_hook('address_sources', array('sources' => $list));
     $list = $plugin['sources'];
     if ($writeable && !empty($list)) {
         foreach ($list as $idx => $item) {
             if ($item['readonly']) {
                 unset($list[$idx]);
             }
         }
     }
     return $list;
 }
Ejemplo n.º 10
0
 /**
  * Return address books list
  *
  * @param boolean True if the address book needs to be writeable
  *
  * @return array  Address books array
  */
 public function get_address_sources($writeable = false)
 {
     $abook_type = strtolower($this->config->get('address_book_type'));
     $ldap_config = $this->config->get('ldap_public');
     $autocomplete = (array) $this->config->get('autocomplete_addressbooks');
     $list = array();
     // We are using the DB address book
     if ($abook_type != 'ldap') {
         if (!isset($this->address_books['0'])) {
             $this->address_books['0'] = new rcube_contacts($this->db, $this->user->ID);
         }
         $list['0'] = array('id' => '0', 'name' => rcube_label('personaladrbook'), 'groups' => $this->address_books['0']->groups, 'readonly' => $this->address_books['0']->readonly, 'autocomplete' => in_array('sql', $autocomplete), 'undelete' => $this->address_books['0']->undelete && $this->config->get('undo_timeout'));
     }
     if ($ldap_config) {
         $ldap_config = (array) $ldap_config;
         foreach ($ldap_config as $id => $prop) {
             $list[$id] = array('id' => $id, 'name' => $prop['name'], 'groups' => is_array($prop['groups']), 'readonly' => !$prop['writable'], 'hidden' => $prop['hidden'], 'autocomplete' => in_array($id, $autocomplete));
         }
     }
     $plugin = $this->plugins->exec_hook('addressbooks_list', array('sources' => $list));
     $list = $plugin['sources'];
     foreach ($list as $idx => $item) {
         // register source for shutdown function
         if (!is_object($this->address_books[$item['id']])) {
             $this->address_books[$item['id']] = $item;
         }
         // remove from list if not writeable as requested
         if ($writeable && $item['readonly']) {
             unset($list[$idx]);
         }
     }
     return $list;
 }
Ejemplo n.º 11
0
 /**
  * Helper function used in calendar_form_content(). Creates a part of the form.
  */
 private function get_form_part($form)
 {
     $content = '';
     if (is_array($form['content']) && !empty($form['content'])) {
         $table = new html_table(array('cols' => 2));
         foreach ($form['content'] as $col => $colprop) {
             $label = !empty($colprop['label']) ? $colprop['label'] : rcube_label($col);
             $table->add('title', html::label($colprop['id'], Q($label)));
             $table->add(null, $colprop['value']);
         }
         $content = $table->show();
     } else {
         $content = $form['content'];
     }
     return $content;
 }
Ejemplo n.º 12
0
 /**
  * Hook to inject plugin-specific user settings
  */
 function prefs_table($args)
 {
     global $CURR_SECTION;
     if ($args['section'] == 'folders') {
         $this->add_texts('localization');
         $rcmail = rcmail::get_instance();
         // load folders list when needed
         if ($CURR_SECTION) {
             $select = $rcmail->folder_selector(array('noselection' => '---', 'realnames' => true, 'maxlength' => 30, 'exceptions' => array('INBOX'), 'folder_filter' => 'mail', 'folder_rights' => 'w'));
         } else {
             $select = new html_select();
         }
         $args['blocks']['main']['options']['archive_mbox'] = array('title' => $this->gettext('archivefolder'), 'content' => $select->show($rcmail->config->get('archive_mbox'), array('name' => "_archive_mbox")));
         // add option for structuring the archive folder
         $archive_type = new html_select(array('name' => '_archive_type', 'id' => 'ff_archive_type'));
         $archive_type->add($this->gettext('none'), '');
         $archive_type->add($this->gettext('archivetypeyear'), 'year');
         $archive_type->add($this->gettext('archivetypemonth'), 'month');
         $archive_type->add($this->gettext('archivetypesender'), 'sender');
         $archive_type->add($this->gettext('archivetypefolder'), 'folder');
         $args['blocks']['archive'] = array('name' => Q(rcube_label('settingstitle', 'archive')), 'options' => array('archive_type' => array('title' => $this->gettext('archivetype'), 'content' => $archive_type->show($rcmail->config->get('archive_type')))));
     }
     return $args;
 }
 function pfadmin_autoresponder_save()
 {
     $rcmail = rcmail::get_instance();
     $user = $rcmail->user->data['username'];
     $enabled = get_input_value('_autoresponderenabled', RCUBE_INPUT_POST);
     if (!$enabled) {
         $enabled = 0;
     }
     if (isset($_SESSION['dnsblacklisted']) && $_SESSION['dnsblacklisted'] != 'pass') {
         $enabled = 0;
     }
     $subject = get_input_value('_autorespondersubject', RCUBE_INPUT_POST);
     $body = get_input_value('_autoresponderbody', RCUBE_INPUT_POST);
     $date = get_input_value('_autoresponderdate', RCUBE_INPUT_POST);
     $datefrom = get_input_value('_autoresponderdatefrom', RCUBE_INPUT_POST);
     // check $datefrom
     if (preg_match("/^\\s*\$/", $datefrom) or !preg_match($this->date_format_regexp, $datefrom)) {
         $datefrom = "now()";
     }
     if (preg_match("/^\\s*\$/", $date) or !preg_match($this->date_format_regexp, $date)) {
         $date = "NULL";
     }
     if (!$enabled) {
         $date = $datefrom = "NULL";
     }
     if (!($res = $this->_save($user, $enabled, $subject, $body, $date, $datefrom))) {
         if (isset($_SESSION['dnsblacklisted']) && $_SESSION['dnsblacklisted'] != 'pass') {
             $this->add_texts('../dnsbl/localization/');
             $rcmail->output->command('display_message', sprintf(rcube_label('dnsblacklisted', 'pfadmin_autoresponder'), $_SESSION['clientip']), 'error');
         } else {
             $rcmail->output->command('display_message', $this->gettext('successfullysaved'), 'confirmation');
         }
     } else {
         $rcmail->output->command('display_message', "DUPA." . $res, 'error');
     }
     if (!$rcmail->config->get('db_persistent')) {
         if ($dsn = $rcmail->config->get('db_dsnw')) {
             $rcmail->db = rcube_db::factory($dsn, '', false);
         }
     }
     $this->pfadmin_autoresponder_init();
 }
Ejemplo n.º 14
0
 /**
  * Replaces the preference skin selection with a dialog-based selection that allows specifying separate desktop
  * table and phone skins.
  */
 function preferencesList($args)
 {
     // split the skin selection to desktop, tablet and phone
     if ($args['section'] != 'general' || !isset($args['blocks']['skin'])) {
         return $args;
     }
     // get the config settings and skins
     global $RCMAIL;
     // if skins set in config's dont_overwrite, don't do anything
     $no_override = array_flip($RCMAIL->config->get('dont_override', array()));
     if (isset($no_override['skin'])) {
         return $args;
     }
     $config = $RCMAIL->config->all();
     $skins = rcmail_get_skins();
     if (count($skins) <= 1) {
         return $args;
     }
     sort($skins);
     $this->add_texts('localization');
     // remove the interface skin block created by Roundcube
     unset($args['blocks']['skin']);
     // add the current browser type to the "Browser Options" section
     if ($this->phone) {
         $browser = $this->gettext("phone");
     } else {
         if ($this->tablet) {
             $browser = $this->gettext("tablet");
         } else {
             $browser = $this->gettext("desktop");
         }
     }
     $args['blocks']['browser']['options']['currentbrowser'] = array('title' => $this->gettext("current_device"), 'content' => $browser);
     // create skin selection hidden blocks that will be shown in dialogs, if mobile, create the selects
     // since we don't use dialogs in mobile
     if ($this->desktop) {
         $desktopList = "";
         $tabletList = "";
         $phoneList = "";
     } else {
         $desktopSelect = new html_select(array("name" => "_skin", "id" => "rcmfd_skin"));
         $tabletSelect = new html_select(array("name" => "_tablet_skin", "id" => "rcmfd_tablet_skin"));
         $phoneSelect = new html_select(array("name" => "_phone_skin", "id" => "rcmfd_phone_skin"));
     }
     foreach ($skins as $skin) {
         $thumbnail = "./skins/{$skin}/thumbnail.png";
         if (!is_file($thumbnail)) {
             $thumbnail = './program/resources/blank.gif';
         }
         $skinname = ucfirst($skin);
         $author = "";
         $license = "";
         $meta = @json_decode(@file_get_contents("./skins/{$skin}/meta.json"), true);
         if (is_array($meta) && $meta['name']) {
             $skinname = $meta['name'];
             $author = $this->encode($meta['author']);
             // we don't use links since the entire item is a link already
             $license = $this->encode($meta['license']);
         }
         if ($this->desktop) {
             // create the skin display boxes, add them to the appropriate lists for selection and set the
             // selected item
             $selected = $skin == $this->desktopSkin;
             $item = $this->skinItem("desktop", $skin, $skinname, $thumbnail, $author, $license, $selected);
             $desktopList .= $item;
             if ($selected) {
                 $desktopSelect = $item;
             }
             $selected = $skin == $this->tabletSkin;
             $item = $this->skinItem("tablet", $skin, $skinname, $thumbnail, $author, $license, $selected);
             $tabletList .= $item;
             if ($selected) {
                 $tabletSelect = $item;
             }
             $selected = $skin == $this->phoneSkin;
             $item = $this->skinItem("phone", $skin, $skinname, $thumbnail, $author, $license, $selected);
             $phoneList .= $item;
             if ($selected) {
                 $phoneSelect = $item;
             }
         } else {
             $desktopSelect->add($skinname, $skin);
             $tabletSelect->add($skinname, $skin);
             $phoneSelect->add($skinname, $skin);
         }
     }
     if ($this->desktop) {
         if (!$desktopSelect) {
             $desktopSelect = "<a href='javascript:void(0)' onclick='rcs_skins.dialog(\"desktop\", \"\", this)'>" . $this->encode($this->gettext("select")) . "</a>";
         }
         if (!$tabletSelect) {
             $tabletSelect = "<a href='javascript:void(0)' onclick='rcs_skins.dialog(\"tablet\", \"\", this)'>" . $this->encode($this->gettext("select")) . "</a>";
         }
         if (!$phoneSelect) {
             $phoneSelect = "<a href='javascript:void(0)' onclick='rcs_skins.dialog(\"phone\", \"\", this)'>" . $this->encode($this->gettext("select")) . "</a>";
         }
         $desktopSelect = "<div class='skin-select' id='desktop-skin-select'>{$desktopSelect}</div>" . "<div class='skin-list' id='desktop-skin-list' title='" . $this->encode($this->gettext("select_desktop_skin")) . "'>" . $desktopList . "</div>";
         $tabletSelect = "<div class='skin-select' id='tablet-skin-select'>{$tabletSelect}</div>" . "<div class='skin-list' id='tablet-skin-list' title='" . $this->encode($this->gettext("select_tablet_skin")) . "'>" . $tabletList . "</div>";
         $phoneSelect = "<div class='skin-select' id='phone-skin-select'>{$phoneSelect}</div>" . "<div class='skin-list' id='phone-skin-list' title='" . $this->encode($this->gettext("select_phone_skin")) . "'>" . $phoneList . "</div>" . "<div id='skinPost'>" . "<input id='desktop-skin-post' type='hidden' name='_skin' value='{$this->desktopSkin}' />" . "<input id='tablet-skin-post' type='hidden' name='_tablet_skin' value='{$this->tabletSkin}' />" . "<input id='phone-skin-post' type='hidden' name='_phone_skin' value='{$this->phoneSkin}' />" . "</div>";
     } else {
         $desktopSelect = $desktopSelect->show($this->desktopSkin);
         $tabletSelect = $tabletSelect->show($this->tabletSkin);
         $phoneSelect = $phoneSelect->show($this->phoneSkin);
     }
     $args['blocks']['skin']['name'] = $this->encode(rcube_label('skin'));
     $args['blocks']['skin']['options']['desktop_skin'] = array('title' => $this->gettext("desktop_skin"), 'content' => $desktopSelect);
     $args['blocks']['skin']['options']['tablet_skin'] = array('title' => $this->gettext("tablet_skin"), 'content' => $tabletSelect);
     $args['blocks']['skin']['options']['phone_skin'] = array('title' => $this->gettext("phone_skin"), 'content' => $phoneSelect);
     return $args;
 }
Ejemplo n.º 15
0
 /**
  * Fetch groups from server
  */
 private function _fetch_groups($vlv_page = null)
 {
     // special case: list groups from 'group_filters' config
     if ($vlv_page === null && !empty($this->prop['group_filters'])) {
         $groups = array();
         // list regular groups configuration as special filter
         if (!empty($this->prop['groups']['filter'])) {
             $id = '__groups__';
             $groups[$id] = array('ID' => $id, 'name' => rcube_label('groups'), 'virtual' => true) + $this->prop['groups'];
         }
         foreach ($this->prop['group_filters'] as $id => $prop) {
             $groups[$id] = $prop + array('ID' => $id, 'name' => ucfirst($id), 'virtual' => true, 'base_dn' => $this->base_dn);
         }
         return $groups;
     }
     if ($this->cache && $vlv_page === null && ($groups = $this->cache->get('groups')) !== null) {
         return $groups;
     }
     $base_dn = $this->groups_base_dn;
     $filter = $this->prop['groups']['filter'];
     $scope = $this->prop['groups']['scope'];
     $name_attr = $this->prop['groups']['name_attr'];
     $email_attr = $this->prop['groups']['email_attr'] ? $this->prop['groups']['email_attr'] : 'mail';
     $sort_attrs = $this->prop['groups']['sort'] ? (array) $this->prop['groups']['sort'] : array($name_attr);
     $sort_attr = $sort_attrs[0];
     $ldap = $this->ldap;
     // use vlv to list groups
     if ($this->prop['groups']['vlv']) {
         $page_size = 200;
         if (!$this->prop['groups']['sort']) {
             $this->prop['groups']['sort'] = $sort_attrs;
         }
         $ldap = clone $this->ldap;
         $ldap->set_config($this->prop['groups']);
         $ldap->set_vlv_page($vlv_page + 1, $page_size);
     }
     $attrs = array_unique(array('dn', 'objectClass', $name_attr, $email_attr, $sort_attr));
     $ldap_data = $ldap->search($base_dn, $filter, $scope, $attrs, $this->prop['groups']);
     if ($ldap_data === false) {
         return array();
     }
     $groups = array();
     $group_sortnames = array();
     $group_count = $ldap_data->count();
     foreach ($ldap_data as $entry) {
         if (!$entry['dn']) {
             // DN is mandatory
             $entry['dn'] = $ldap_data->get_dn();
         }
         $group_name = is_array($entry[$name_attr]) ? $entry[$name_attr][0] : $entry[$name_attr];
         $group_id = self::dn_encode($entry['dn']);
         $groups[$group_id]['ID'] = $group_id;
         $groups[$group_id]['dn'] = $entry['dn'];
         $groups[$group_id]['name'] = $group_name;
         $groups[$group_id]['member_attr'] = $this->get_group_member_attr($entry['objectclass']);
         // list email attributes of a group
         for ($j = 0; $entry[$email_attr] && $j < $entry[$email_attr]['count']; $j++) {
             if (strpos($entry[$email_attr][$j], '@') > 0) {
                 $groups[$group_id]['email'][] = $entry[$email_attr][$j];
             }
         }
         $group_sortnames[] = mb_strtolower($entry[$sort_attr][0]);
     }
     // recursive call can exit here
     if ($vlv_page > 0) {
         return $groups;
     }
     // call recursively until we have fetched all groups
     while ($this->prop['groups']['vlv'] && $group_count == $page_size) {
         $next_page = $this->_fetch_groups(++$vlv_page);
         $groups = array_merge($groups, $next_page);
         $group_count = count($next_page);
     }
     // when using VLV the list of groups is already sorted
     if (!$this->prop['groups']['vlv']) {
         array_multisort($group_sortnames, SORT_ASC, SORT_STRING, $groups);
     }
     // cache this
     if ($this->cache) {
         $this->cache->set('groups', $groups);
     }
     return $groups;
 }
Ejemplo n.º 16
0
 /**
  * Invoke display_message command
  *
  * @param string  $message  Message to display
  * @param string  $type     Message type [notice|confirm|error]
  * @param array   $vars     Key-value pairs to be replaced in localized text
  * @param boolean $override Override last set message
  * @param int     $timeout  Message displaying time in seconds
  * @uses self::command()
  */
 public function show_message($message, $type = 'notice', $vars = null, $override = true, $timeout = 0)
 {
     if ($override || !$this->message) {
         if (rcube_label_exists($message)) {
             if (!empty($vars)) {
                 $vars = array_map('Q', $vars);
             }
             $msgtext = rcube_label(array('name' => $message, 'vars' => $vars));
         } else {
             $msgtext = $message;
         }
         $this->message = $message;
         $this->command('display_message', $msgtext, $type, $timeout * 1000);
     }
 }
Ejemplo n.º 17
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;
 }
Ejemplo n.º 18
0
 /**
  * Invoke display_message command
  *
  * @param string Message to display
  * @param string Message type [notice|confirm|error]
  * @param array Key-value pairs to be replaced in localized text
  * @uses self::command()
  */
 public function show_message($message, $type = 'notice', $vars = null)
 {
     $this->command('display_message', rcube_label(array('name' => $message, 'vars' => $vars)), $type);
 }
Ejemplo n.º 19
0
 /**
  *
  */
 function import_events($silent = false)
 {
     // Upload progress update
     if (!empty($_GET['_progress'])) {
         rcube_upload_progress();
     }
     @set_time_limit(0);
     // process uploaded file if there is no error
     $err = $_FILES['_data']['error'];
     if (!$err && $_FILES['_data']['tmp_name']) {
         $calendar = get_input_value('calendar', RCUBE_INPUT_GPC);
         $driver = $this->get_driver_by_cal($calendar);
         $rangestart = $_REQUEST['_range'] ? date_create("now -" . intval($_REQUEST['_range']) . " months") : 0;
         $user_email = $this->rc->user->get_username();
         $ical = $this->get_ical();
         $errors = !$ical->fopen($_FILES['_data']['tmp_name']);
         $count = $i = 0;
         foreach ($ical as $event) {
             if (isset($event['recurrence']['EXCEPTIONS'])) {
                 foreach ($event['recurrence']['EXCEPTIONS'] as $idx => $exception) {
                     $event['recurrence']['EXCEPTIONS'][$idx]['uid'] = $event['uid'];
                 }
             }
             // End mod by Rosali
             // keep the browser connection alive on long import jobs
             if (++$i > 100 && $i % 100 == 0) {
                 echo "<!-- -->";
                 ob_flush();
             }
             // TODO: correctly handle recurring events which start before $rangestart
             if ($event['end'] && $event['end'] < $rangestart && (!$event['recurrence'] || $event['recurrence']['until'] && $event['recurrence']['until'] < $rangestart)) {
                 continue;
             }
             $event['_owner'] = $user_email;
             $event['calendar'] = $calendar;
             if ($driver->new_event($event)) {
                 $count++;
             } else {
                 $errors++;
             }
         }
         // Begin mod by Rosali
         if ($silent) {
             return;
         }
         // End mod by Rosali
         if ($count) {
             $this->rc->output->command('display_message', $this->gettext(array('name' => 'importsuccess', 'vars' => array('nr' => $count))), 'confirmation');
             $this->rc->output->command('plugin.import_success', array('source' => $calendar, 'refetch' => true));
         } else {
             if (!$errors) {
                 $this->rc->output->command('display_message', $this->gettext('importnone'), 'notice');
                 $this->rc->output->command('plugin.import_success', array('source' => $calendar));
             } else {
                 $this->rc->output->command('plugin.import_error', array('message' => $this->gettext('importerror') . ($msg ? ': ' . $msg : '')));
             }
         }
     } else {
         if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
             $msg = rcube_label(array('name' => 'filesizeerror', 'vars' => array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize'))))));
         } else {
             $msg = rcube_label('fileuploaderror');
         }
         $this->rc->output->command('plugin.import_error', array('message' => $msg));
         $this->rc->output->command('plugin.unlock_saving', false);
     }
     $this->rc->output->send('iframe');
 }
Ejemplo n.º 20
0
 /**
  * Hook: prepare the new sections HTML for the settings page.
  */
 function user_preferences($args)
 {
     $RCMAIL = rcmail::get_instance();
     if ($args['section'] == 'vacation' && $RCMAIL->config->get('qmailadmin_allow_vacation')) {
         $config = $RCMAIL->config->all();
         $blocks = array('main' => array('name' => Q(rcube_label('mainoptions'))));
         // Vacation enabled?
         $field_id = 'vacation_enabled';
         $input_vacation_enabled = new html_checkbox(array('name' => '_vacation_enabled', 'id' => $field_id, 'value' => 1));
         $blocks['main']['options']['vacation_enabled'] = array('title' => html::label($field_id, rcube::Q($this->gettext('autoresponderenabled'))), 'content' => $input_vacation_enabled->show($config['vacation_enabled'] ? 1 : 0));
         // Vacation message subject
         $field_id = 'vacation_subject';
         $input_vacation_subject = new html_inputfield(array('name' => '_vacation_subject', 'id' => $field_id, 'size' => '80'));
         $blocks['main']['options']['vacation_subject'] = array('title' => html::label($field_id, rcube::Q($this->gettext('subject'))), 'content' => $input_vacation_subject->show($config['vacation_subject']));
         // Vacation message
         $field_id = 'vacation_message';
         $input_vacation_message = new html_textarea(array('name' => '_vacation_message', 'id' => $field_id, 'cols' => 80, 'rows' => 15));
         $blocks['main']['options']['vacation_message'] = array('title' => html::label($field_id, rcube::Q($this->gettext('message'))), 'content' => $input_vacation_message->show($config['vacation_message']));
         $args['blocks'] = $blocks;
     } else {
         if ($args['section'] == 'password' && $RCMAIL->config->get('qmailadmin_allow_password')) {
             $blocks = array('main' => array('name' => Q(rcube_label('mainoptions'))), 'explanation' => array('name' => Q($this->gettext('qmail_password_explanation'))));
             // Old password
             $field_id = 'password_old';
             $input_password_old = new html_passwordfield(array('name' => '_password_old', 'id' => $field_id, 'size' => '20'));
             $blocks['main']['options']['password_old'] = array('title' => html::label($field_id, rcube::Q($this->gettext('oldpassword'))), 'content' => $input_password_old->show());
             // New password 1
             $field_id = 'password_new1';
             $input_password_new1 = new html_passwordfield(array('name' => '_password_new1', 'id' => $field_id, 'size' => '20'));
             $blocks['main']['options']['password_new1'] = array('title' => html::label($field_id, rcube::Q($this->gettext('newpassword'))), 'content' => $input_password_new1->show());
             // New password 2
             $field_id = 'password_new2';
             $input_password_new2 = new html_passwordfield(array('name' => '_password_new2', 'id' => $field_id, 'size' => '20'));
             $blocks['main']['options']['password_new2'] = array('title' => html::label($field_id, rcube::Q($this->gettext('newpassword2'))), 'content' => $input_password_new2->show());
             // Password requisites explanation
             $blocks['explanation']['options']['password_explanation1'] = array('title' => html::label('password_explanation1', rcube::Q($this->gettext('password_explanation1a')) . ' ' . $RCMAIL->config->get('qmailadmin_password_min_length') . ' ' . rcube::Q($this->gettext('password_explanation1b')) . ' ' . $RCMAIL->config->get('qmailadmin_password_max_length') . ' ' . rcube::Q($this->gettext('password_explanation1c') . '. ')), 'content' => '');
             if ($RCMAIL->config->get('qmailadmin_password_lower_need') || $RCMAIL->config->get('qmailadmin_password_upper_need') || $RCMAIL->config->get('qmailadmin_password_number_need') || $RCMAIL->config->get('qmailadmin_password_special_need')) {
                 $blocks['explanation']['options']['password_explanation2'] = array('title' => html::label('password_explanation2', rcube::Q($this->gettext('password_explanation2'))), 'content' => '');
             }
             if (!$RCMAIL->config->get('qmailadmin_password_lower_need') && !$RCMAIL->config->get('qmailadmin_password_upper_need')) {
                 $blocks['explanation']['options']['password_explanation3'] = array('title' => html::label('password_explanation3', '* ' . rcube::Q($this->gettext('password_explanation3')) . '; '), 'content' => '');
             }
             if ($RCMAIL->config->get('qmailadmin_password_lower_need')) {
                 $blocks['explanation']['options']['password_explanation4'] = array('title' => html::label('password_explanation4', '* ' . rcube::Q($this->gettext('password_explanation4')) . '; '), 'content' => '');
             }
             if ($RCMAIL->config->get('qmailadmin_password_upper_need')) {
                 $blocks['explanation']['options']['password_explanation5'] = array('title' => html::label('password_explanation5', '* ' . rcube::Q($this->gettext('password_explanation5')) . '; '), 'content' => '');
             }
             if ($RCMAIL->config->get('qmailadmin_password_number_need')) {
                 $blocks['explanation']['options']['password_explanation6'] = array('title' => html::label('password_explanation6', '* ' . rcube::Q($this->gettext('password_explanation6')) . '; '), 'content' => '');
             }
             if ($RCMAIL->config->get('qmailadmin_password_special_need')) {
                 $blocks['explanation']['options']['password_explanation7'] = array('title' => html::label('password_explanation7', '* ' . rcube::Q($this->gettext('password_explanation7')) . ' "' . $RCMAIL->config->get('qmailadmin_password_special_chars') . '"; '), 'content' => '');
             }
             $args['blocks'] = $blocks;
         }
     }
     return $args;
 }
Ejemplo n.º 21
0
 function rule_div($fid, $id, $div = true)
 {
     $rule = isset($this->form) ? $this->form['tests'][$id] : $this->script[$fid]['tests'][$id];
     $rows_num = isset($this->form) ? sizeof($this->form['tests']) : sizeof($this->script[$fid]['tests']);
     // headers select
     $select_header = new html_select(array('name' => "_header[]", 'id' => 'header' . $id, 'onchange' => 'rule_header_select(' . $id . ')'));
     foreach ($this->headers as $name => $val) {
         $select_header->add(Q($this->gettext($name)), Q($val));
     }
     if (in_array('body', $this->exts)) {
         $select_header->add(Q($this->gettext('body')), 'body');
     }
     $select_header->add(Q($this->gettext('size')), 'size');
     $select_header->add(Q($this->gettext('...')), '...');
     // TODO: list arguments
     $aout = '';
     if (isset($rule['test']) && in_array($rule['test'], array('header', 'address', 'envelope')) && !is_array($rule['arg1']) && in_array($rule['arg1'], $this->headers)) {
         $aout .= $select_header->show($rule['arg1']);
     } else {
         if (isset($rule['test']) && $rule['test'] == 'exists' && !is_array($rule['arg']) && in_array($rule['arg'], $this->headers)) {
             $aout .= $select_header->show($rule['arg']);
         } else {
             if (isset($rule['test']) && $rule['test'] == 'size') {
                 $aout .= $select_header->show('size');
             } else {
                 if (isset($rule['test']) && $rule['test'] == 'body') {
                     $aout .= $select_header->show('body');
                 } else {
                     if (isset($rule['test']) && $rule['test'] != 'true') {
                         $aout .= $select_header->show('...');
                     } else {
                         $aout .= $select_header->show();
                     }
                 }
             }
         }
     }
     if (isset($rule['test']) && in_array($rule['test'], array('header', 'address', 'envelope'))) {
         if (is_array($rule['arg1'])) {
             $custom = implode(', ', $rule['arg1']);
         } else {
             if (!in_array($rule['arg1'], $this->headers)) {
                 $custom = $rule['arg1'];
             }
         }
     } else {
         if (isset($rule['test']) && $rule['test'] == 'exists') {
             if (is_array($rule['arg'])) {
                 $custom = implode(', ', $rule['arg']);
             } else {
                 if (!in_array($rule['arg'], $this->headers)) {
                     $custom = $rule['arg'];
                 }
             }
         }
     }
     $tout = '<div id="custom_header' . $id . '" style="display:' . (isset($custom) ? 'inline' : 'none') . '">
         <input type="text" name="_custom_header[]" id="custom_header_i' . $id . '" ' . $this->error_class($id, 'test', 'header', 'custom_header_i') . ' value="' . Q($custom) . '" size="15" />&nbsp;</div>' . "\n";
     // matching type select (operator)
     $select_op = new html_select(array('name' => "_rule_op[]", 'id' => 'rule_op' . $id, 'style' => 'display:' . ($rule['test'] != 'size' ? 'inline' : 'none'), 'class' => 'operator_selector', 'onchange' => 'rule_op_select(' . $id . ')'));
     $select_op->add(Q($this->gettext('filtercontains')), 'contains');
     $select_op->add(Q($this->gettext('filternotcontains')), 'notcontains');
     $select_op->add(Q($this->gettext('filteris')), 'is');
     $select_op->add(Q($this->gettext('filterisnot')), 'notis');
     $select_op->add(Q($this->gettext('filterexists')), 'exists');
     $select_op->add(Q($this->gettext('filternotexists')), 'notexists');
     $select_op->add(Q($this->gettext('filtermatches')), 'matches');
     $select_op->add(Q($this->gettext('filternotmatches')), 'notmatches');
     if (in_array('regex', $this->exts)) {
         $select_op->add(Q($this->gettext('filterregex')), 'regex');
         $select_op->add(Q($this->gettext('filternotregex')), 'notregex');
     }
     if (in_array('relational', $this->exts)) {
         $select_op->add(Q($this->gettext('countisgreaterthan')), 'count-gt');
         $select_op->add(Q($this->gettext('countisgreaterthanequal')), 'count-ge');
         $select_op->add(Q($this->gettext('countislessthan')), 'count-lt');
         $select_op->add(Q($this->gettext('countislessthanequal')), 'count-le');
         $select_op->add(Q($this->gettext('countequals')), 'count-eq');
         $select_op->add(Q($this->gettext('countnotequals')), 'count-ne');
         $select_op->add(Q($this->gettext('valueisgreaterthan')), 'value-gt');
         $select_op->add(Q($this->gettext('valueisgreaterthanequal')), 'value-ge');
         $select_op->add(Q($this->gettext('valueislessthan')), 'value-lt');
         $select_op->add(Q($this->gettext('valueislessthanequal')), 'value-le');
         $select_op->add(Q($this->gettext('valueequals')), 'value-eq');
         $select_op->add(Q($this->gettext('valuenotequals')), 'value-ne');
     }
     // target input (TODO: lists)
     if (in_array($rule['test'], array('header', 'address', 'envelope'))) {
         $test = ($rule['not'] ? 'not' : '') . ($rule['type'] ? $rule['type'] : 'is');
         $target = $rule['arg2'];
     } else {
         if ($rule['test'] == 'body') {
             $test = ($rule['not'] ? 'not' : '') . ($rule['type'] ? $rule['type'] : 'is');
             $target = $rule['arg'];
         } else {
             if ($rule['test'] == 'size') {
                 $test = '';
                 $target = '';
                 if (preg_match('/^([0-9]+)(K|M|G)?$/', $rule['arg'], $matches)) {
                     $sizetarget = $matches[1];
                     $sizeitem = $matches[2];
                 } else {
                     $sizetarget = $rule['arg'];
                     $sizeitem = $rule['item'];
                 }
             } else {
                 $test = ($rule['not'] ? 'not' : '') . $rule['test'];
                 $target = '';
             }
         }
     }
     $tout .= $select_op->show($test);
     $tout .= '<input type="text" name="_rule_target[]" id="rule_target' . $id . '"
         value="' . Q($target) . '" size="20" ' . $this->error_class($id, 'test', 'target', 'rule_target') . ' style="display:' . ($rule['test'] != 'size' && $rule['test'] != 'exists' ? 'inline' : 'none') . '" />' . "\n";
     $select_size_op = new html_select(array('name' => "_rule_size_op[]", 'id' => 'rule_size_op' . $id));
     $select_size_op->add(Q($this->gettext('filterover')), 'over');
     $select_size_op->add(Q($this->gettext('filterunder')), 'under');
     $tout .= '<div id="rule_size' . $id . '" style="display:' . ($rule['test'] == 'size' ? 'inline' : 'none') . '">';
     $tout .= $select_size_op->show($rule['test'] == 'size' ? $rule['type'] : '');
     $tout .= '<input type="text" name="_rule_size_target[]" id="rule_size_i' . $id . '" value="' . $sizetarget . '" size="10" ' . $this->error_class($id, 'test', 'sizetarget', 'rule_size_i') . ' />
         <input type="radio" name="_rule_size_item[' . $id . ']" value=""' . (!$sizeitem ? ' checked="checked"' : '') . ' class="radio" />' . rcube_label('B') . '
         <input type="radio" name="_rule_size_item[' . $id . ']" value="K"' . ($sizeitem == 'K' ? ' checked="checked"' : '') . ' class="radio" />' . rcube_label('KB') . '
         <input type="radio" name="_rule_size_item[' . $id . ']" value="M"' . ($sizeitem == 'M' ? ' checked="checked"' : '') . ' class="radio" />' . rcube_label('MB') . '
         <input type="radio" name="_rule_size_item[' . $id . ']" value="G"' . ($sizeitem == 'G' ? ' checked="checked"' : '') . ' class="radio" />' . rcube_label('GB');
     $tout .= '</div>';
     // Advanced modifiers (address, envelope)
     $select_mod = new html_select(array('name' => "_rule_mod[]", 'id' => 'rule_mod_op' . $id, 'onchange' => 'rule_mod_select(' . $id . ')'));
     $select_mod->add(Q($this->gettext('none')), '');
     $select_mod->add(Q($this->gettext('address')), 'address');
     if (in_array('envelope', $this->exts)) {
         $select_mod->add(Q($this->gettext('envelope')), 'envelope');
     }
     $select_type = new html_select(array('name' => "_rule_mod_type[]", 'id' => 'rule_mod_type' . $id));
     $select_type->add(Q($this->gettext('allparts')), 'all');
     $select_type->add(Q($this->gettext('domain')), 'domain');
     $select_type->add(Q($this->gettext('localpart')), 'localpart');
     if (in_array('subaddress', $this->exts)) {
         $select_type->add(Q($this->gettext('user')), 'user');
         $select_type->add(Q($this->gettext('detail')), 'detail');
     }
     $need_mod = $rule['test'] != 'size' && $rule['test'] != 'body';
     $mout = '<div id="rule_mod' . $id . '" class="adv" style="display:' . ($need_mod ? 'block' : 'none') . '">';
     $mout .= ' <span>';
     $mout .= Q($this->gettext('modifier')) . ' ';
     $mout .= $select_mod->show($rule['test']);
     $mout .= '</span>';
     $mout .= ' <span id="rule_mod_type' . $id . '"';
     $mout .= ' style="display:' . (in_array($rule['test'], array('address', 'envelope')) ? 'inline' : 'none') . '">';
     $mout .= Q($this->gettext('modtype')) . ' ';
     $mout .= $select_type->show($rule['part']);
     $mout .= '</span>';
     $mout .= '</div>';
     // Advanced modifiers (body transformations)
     $select_mod = new html_select(array('name' => "_rule_trans[]", 'id' => 'rule_trans_op' . $id, 'onchange' => 'rule_trans_select(' . $id . ')'));
     $select_mod->add(Q($this->gettext('text')), 'text');
     $select_mod->add(Q($this->gettext('undecoded')), 'raw');
     $select_mod->add(Q($this->gettext('contenttype')), 'content');
     $mout .= '<div id="rule_trans' . $id . '" class="adv" style="display:' . ($rule['test'] == 'body' ? 'block' : 'none') . '">';
     $mout .= ' <span>';
     $mout .= Q($this->gettext('modifier')) . ' ';
     $mout .= $select_mod->show($rule['part']);
     $mout .= '<input type="text" name="_rule_trans_type[]" id="rule_trans_type' . $id . '" value="' . (is_array($rule['content']) ? implode(',', $rule['content']) : $rule['content']) . '" size="20" style="display:' . ($rule['part'] == 'content' ? 'inline' : 'none') . '"' . $this->error_class($id, 'test', 'part', 'rule_trans_type') . ' />';
     $mout .= '</span>';
     $mout .= '</div>';
     // Advanced modifiers (body transformations)
     $select_comp = new html_select(array('name' => "_rule_comp[]", 'id' => 'rule_comp_op' . $id));
     $select_comp->add(Q($this->gettext('default')), '');
     $select_comp->add(Q($this->gettext('octet')), 'i;octet');
     $select_comp->add(Q($this->gettext('asciicasemap')), 'i;ascii-casemap');
     if (in_array('comparator-i;ascii-numeric', $this->exts)) {
         $select_comp->add(Q($this->gettext('asciinumeric')), 'i;ascii-numeric');
     }
     $mout .= '<div id="rule_comp' . $id . '" class="adv" style="display:' . ($rule['test'] != 'size' ? 'block' : 'none') . '">';
     $mout .= ' <span>';
     $mout .= Q($this->gettext('comparator')) . ' ';
     $mout .= $select_comp->show($rule['comparator']);
     $mout .= '</span>';
     $mout .= '</div>';
     // Build output table
     $out = $div ? '<div class="rulerow" id="rulerow' . $id . '">' . "\n" : '';
     $out .= '<table><tr>';
     $out .= '<td class="advbutton">';
     $out .= '<a href="#" id="ruleadv' . $id . '" title="' . Q($this->gettext('advancedopts')) . '"
         onclick="rule_adv_switch(' . $id . ', this)" class="show">&nbsp;&nbsp;</a>';
     $out .= '</td>';
     $out .= '<td class="rowactions">' . $aout . '</td>';
     $out .= '<td class="rowtargets">' . $tout . "\n";
     $out .= '<div id="rule_advanced' . $id . '" style="display:none">' . $mout . '</div>';
     $out .= '</td>';
     // add/del buttons
     $out .= '<td class="rowbuttons">';
     $out .= '<a href="#" id="ruleadd' . $id . '" title="' . Q($this->gettext('add')) . '"
         onclick="rcmail.managesieve_ruleadd(' . $id . ')" class="button add"></a>';
     $out .= '<a href="#" id="ruledel' . $id . '" title="' . Q($this->gettext('del')) . '"
         onclick="rcmail.managesieve_ruledel(' . $id . ')" class="button del' . ($rows_num < 2 ? ' disabled' : '') . '"></a>';
     $out .= '</td>';
     $out .= '</tr></table>';
     $out .= $div ? "</div>\n" : '';
     return $out;
 }
Ejemplo n.º 22
0
 /**
  * Invoke display_message command
  *
  * @param string Message to display
  * @param string Message type [notice|confirm|error]
  * @param array Key-value pairs to be replaced in localized text
  * @param boolean Override last set message
  * @uses self::command()
  */
 public function show_message($message, $type = 'notice', $vars = null, $override = true)
 {
     if ($override || !$this->message) {
         $this->message = $message;
         $this->command('display_message', rcube_label(array('name' => $message, 'vars' => $vars)), $type);
     }
 }
Ejemplo n.º 23
0
 function render_box($p)
 {
     $this->add_texts('localization');
     $rcmail = rcmail::get_instance();
     if (!$attrib['id']) {
         $attrib['id'] = 'bounce-box';
         $attrib['class'] = 'popupmenu';
     }
     $button = new html_inputfield(array('type' => 'button'));
     $submit = new html_inputfield(array('type' => 'submit'));
     $table = new html_table(array('cols' => 2, 'id' => 'form'));
     $table->add('title', html::label('_to', Q(rcube_label('to'))));
     $table->add('editfield', html::tag('textarea', array('spellcheck' => 'false', 'id' => '_to', 'name' => '_to', 'cols' => '50', 'rows' => '2', 'tabindex' => '2', 'class' => 'editfield', 'onclick' => 'select_field(this)')));
     $table->set_row_attribs(array('id' => 'compose-cc'));
     $table->add('title', html::a(array('href' => '#cc', 'onclick' => 'return rcmail_ui.hide_header_form(\'cc\')'), html::img(array('src' => $rcmail->config->get('skin_path') . '/images/icons/minus.gif', 'title' => rcube_label('delete'), 'alt' => rcube_label('delete')))) . '&nbsp;' . html::label('_cc', Q(rcube_label('cc'))));
     $table->add(null, html::tag('textarea', array('spellcheck' => 'false', 'id' => '_cc', 'name' => '_cc', 'cols' => '50', 'rows' => '2', 'value' => '', 'class' => 'editfield', 'onclick' => 'select_field(this)')));
     $table->set_row_attribs(array('id' => 'compose-bcc'));
     $table->add('title', html::a(array('href' => '#bcc', 'onclick' => 'return rcmail_ui.hide_header_form(\'bcc\')'), html::img(array('src' => $rcmail->config->get('skin_path') . '/images/icons/minus.gif', 'title' => rcube_label('delete'), 'alt' => rcube_label('delete')))) . '&nbsp;' . html::label('_bcc', Q(rcube_label('bcc'))));
     $table->add(null, html::tag('textarea', array('spellcheck' => 'false', 'id' => '_bcc', 'cols' => '50', 'name' => '_bcc', 'rows' => '2', 'value' => '', 'class' => 'editfield', 'onclick' => 'select_field(this)')));
     $table->add(null, null);
     $table->add(formlinks, html::a(array('href' => '#cc', 'onclick' => 'return rcmail_ui.show_header_form(\'cc\')', 'id' => 'cc-link'), Q(rcube_label('addcc'))) . '<span class="separator">|</span>' . html::a(array('href' => '#bcc', 'onclick' => 'return rcmail_ui.show_header_form(\'bcc\')', 'id' => 'bcc-link'), Q(rcube_label('addbcc'))));
     $target_url = $_SERVER['REQUEST_URI'];
     $rcmail->output->add_footer(html::div($attrib, $rcmail->output->form_tag(array('name' => 'bounceform', 'method' => 'post', 'action' => './', 'enctype' => 'multipart/form-data'), html::tag('input', array('type' => "hidden", 'name' => '_action', 'value' => 'bounce')) . html::div('bounce-title', Q($this->gettext('bouncemessage'))) . html::div('bounce-body', $table->show() . html::div('buttons', $button->show(rcube_label('close'), array('class' => 'button', 'onclick' => "\$('#{$attrib['id']}').hide()")) . ' ' . $button->show(Q($this->gettext('bounce')), array('class' => 'button mainaction', 'onclick' => JS_OBJECT_NAME . ".command('plugin.bounce.send', this.bounceform)")))))));
     $rcmail->output->add_label('norecipientwarning');
     $rcmail->output->add_gui_object('bouncebox', $attrib['id']);
     $rcmail->output->add_gui_object('bounceform', 'bounceform');
     $this->include_stylesheet('bounce.css');
     $rcmail->output->set_env('autocomplete_min_length', $rcmail->config->get('autocomplete_min_length'));
     $rcmail->output->add_gui_object('messageform', 'bounceform');
 }
Ejemplo n.º 24
0
 /**
  * Raad the message structure returend by the IMAP server
  * and build flat lists of content parts and attachments
  *
  * @param rcube_message_part $structure Message structure node
  * @param bool               $recursive True when called recursively
  */
 private function parse_structure($structure, $recursive = false)
 {
     // real content-type of message/rfc822 part
     if ($structure->mimetype == 'message/rfc822' && $structure->real_mimetype) {
         $mimetype = $structure->real_mimetype;
     } else {
         $mimetype = $structure->mimetype;
     }
     // show message headers
     if ($recursive && is_array($structure->headers) && isset($structure->headers['subject'])) {
         $c = new stdClass();
         $c->type = 'headers';
         $c->headers =& $structure->headers;
         $this->parts[] = $c;
     }
     // Allow plugins to handle message parts
     $plugin = $this->app->plugins->exec_hook('message_part_structure', array('object' => $this, 'structure' => $structure, 'mimetype' => $mimetype, 'recursive' => $recursive));
     if ($plugin['abort']) {
         return;
     }
     $structure = $plugin['structure'];
     list($message_ctype_primary, $message_ctype_secondary) = explode('/', $plugin['mimetype']);
     // print body if message doesn't have multiple parts
     if ($message_ctype_primary == 'text' && !$recursive) {
         $structure->type = 'content';
         $this->parts[] =& $structure;
         // Parse simple (plain text) message body
         if ($message_ctype_secondary == 'plain') {
             foreach ((array) $this->uu_decode($structure) as $uupart) {
                 $this->mime_parts[$uupart->mime_id] = $uupart;
                 $this->attachments[] = $uupart;
             }
         }
     } else {
         if ($mimetype == 'application/pgp' && !$recursive) {
             $structure->type = 'content';
             $this->parts[] =& $structure;
         } else {
             if ($mimetype == 'multipart/alternative' && is_array($structure->parts)) {
                 // get html/plaintext parts
                 $plain_part = $html_part = $print_part = $related_part = null;
                 foreach ($structure->parts as $p => $sub_part) {
                     $sub_mimetype = $sub_part->mimetype;
                     // check if sub part is
                     if ($sub_mimetype == 'text/plain') {
                         $plain_part = $p;
                     } else {
                         if ($sub_mimetype == 'text/html') {
                             $html_part = $p;
                         } else {
                             if ($sub_mimetype == 'text/enriched') {
                                 $enriched_part = $p;
                             } else {
                                 if (in_array($sub_mimetype, array('multipart/related', 'multipart/mixed', 'multipart/alternative'))) {
                                     $related_part = $p;
                                 }
                             }
                         }
                     }
                 }
                 // parse related part (alternative part could be in here)
                 if ($related_part !== null && !$this->parse_alternative) {
                     $this->parse_alternative = true;
                     $this->parse_structure($structure->parts[$related_part], true);
                     $this->parse_alternative = false;
                     // if plain part was found, we should unset it if html is preferred
                     if ($this->opt['prefer_html'] && count($this->parts)) {
                         $plain_part = null;
                     }
                 }
                 // choose html/plain part to print
                 if ($html_part !== null && $this->opt['prefer_html']) {
                     $print_part =& $structure->parts[$html_part];
                 } else {
                     if ($enriched_part !== null) {
                         $print_part =& $structure->parts[$enriched_part];
                     } else {
                         if ($plain_part !== null) {
                             $print_part =& $structure->parts[$plain_part];
                         }
                     }
                 }
                 // add the right message body
                 if (is_object($print_part)) {
                     $print_part->type = 'content';
                     $this->parts[] = $print_part;
                 } else {
                     if ($html_part !== null && empty($this->parts)) {
                         $c = new stdClass();
                         $c->type = 'content';
                         $c->ctype_primary = 'text';
                         $c->ctype_secondary = 'plain';
                         $c->body = rcube_label('htmlmessage');
                         $this->parts[] = $c;
                     }
                 }
                 // add html part as attachment
                 if ($html_part !== null && $structure->parts[$html_part] !== $print_part) {
                     $html_part =& $structure->parts[$html_part];
                     $html_part->filename = rcube_label('htmlmessage');
                     $html_part->mimetype = 'text/html';
                     $this->attachments[] = $html_part;
                 }
             } else {
                 if ($mimetype == 'multipart/encrypted') {
                     $p = new stdClass();
                     $p->type = 'content';
                     $p->ctype_primary = 'text';
                     $p->ctype_secondary = 'plain';
                     $p->body = rcube_label('encryptedmessage');
                     $p->size = strlen($p->body);
                 } else {
                     if (is_array($structure->parts) && !empty($structure->parts)) {
                         // iterate over parts
                         for ($i = 0; $i < count($structure->parts); $i++) {
                             $mail_part =& $structure->parts[$i];
                             $primary_type = $mail_part->ctype_primary;
                             $secondary_type = $mail_part->ctype_secondary;
                             // real content-type of message/rfc822
                             if ($mail_part->real_mimetype) {
                                 $part_orig_mimetype = $mail_part->mimetype;
                                 $part_mimetype = $mail_part->real_mimetype;
                                 list($primary_type, $secondary_type) = explode('/', $part_mimetype);
                             } else {
                                 $part_mimetype = $mail_part->mimetype;
                             }
                             // multipart/alternative
                             if ($primary_type == 'multipart') {
                                 $this->parse_structure($mail_part, true);
                                 // list message/rfc822 as attachment as well (mostly .eml)
                                 if ($part_orig_mimetype == 'message/rfc822' && !empty($mail_part->filename)) {
                                     $this->attachments[] = $mail_part;
                                 }
                             } else {
                                 if (($part_mimetype == 'text/plain' || $part_mimetype == 'text/html') && $mail_part->disposition != 'attachment' || in_array($part_mimetype, array('message/delivery-status', 'text/rfc822-headers', 'message/disposition-notification'))) {
                                     // Allow plugins to handle also this part
                                     $plugin = $this->app->plugins->exec_hook('message_part_structure', array('object' => $this, 'structure' => $mail_part, 'mimetype' => $part_mimetype, 'recursive' => true));
                                     if ($plugin['abort']) {
                                         continue;
                                     }
                                     if ($part_mimetype == 'text/html') {
                                         $got_html_part = true;
                                     }
                                     $mail_part = $plugin['structure'];
                                     list($primary_type, $secondary_type) = explode('/', $plugin['mimetype']);
                                     // add text part if it matches the prefs
                                     if (!$this->parse_alternative || $secondary_type == 'html' && $this->opt['prefer_html'] || $secondary_type == 'plain' && !$this->opt['prefer_html']) {
                                         $mail_part->type = 'content';
                                         $this->parts[] = $mail_part;
                                     }
                                     // list as attachment as well
                                     if (!empty($mail_part->filename)) {
                                         $this->attachments[] = $mail_part;
                                     }
                                 } else {
                                     if ($primary_type == 'message') {
                                         $this->parse_structure($mail_part, true);
                                         // list as attachment as well (mostly .eml)
                                         if (!empty($mail_part->filename)) {
                                             $this->attachments[] = $mail_part;
                                         }
                                     } else {
                                         if ($primary_type == 'protocol') {
                                             continue;
                                         } else {
                                             if ($part_mimetype == 'application/ms-tnef') {
                                                 foreach ((array) $this->tnef_decode($mail_part) as $tpart) {
                                                     $this->mime_parts[$tpart->mime_id] = $tpart;
                                                     $this->attachments[] = $tpart;
                                                 }
                                             } else {
                                                 if (preg_match('/^(inline|attach)/', $mail_part->disposition) || $mail_part->headers['content-id'] || $mail_part->filename && (empty($mail_part->disposition) || preg_match('/^[a-z0-9!#$&.+^_-]+$/i', $mail_part->disposition))) {
                                                     // skip apple resource forks
                                                     if ($message_ctype_secondary == 'appledouble' && $secondary_type == 'applefile') {
                                                         continue;
                                                     }
                                                     // part belongs to a related message and is linked
                                                     if ($mimetype == 'multipart/related' && ($mail_part->headers['content-id'] || $mail_part->headers['content-location'])) {
                                                         if ($mail_part->headers['content-id']) {
                                                             $mail_part->content_id = preg_replace(array('/^</', '/>$/'), '', $mail_part->headers['content-id']);
                                                         }
                                                         if ($mail_part->headers['content-location']) {
                                                             $mail_part->content_location = $mail_part->headers['content-base'] . $mail_part->headers['content-location'];
                                                         }
                                                         $this->inline_parts[] = $mail_part;
                                                     } else {
                                                         if ($part_orig_mimetype == 'message/rfc822') {
                                                             $this->parse_structure($mail_part, true);
                                                             // list as attachment as well (mostly .eml)
                                                             if (!empty($mail_part->filename)) {
                                                                 $this->attachments[] = $mail_part;
                                                             }
                                                         } else {
                                                             if (preg_match('/^[a-z0-9!#$&.+^_-]+\\/[a-z0-9!#$&.+^_-]+$/i', $part_mimetype)) {
                                                                 if (!$mail_part->filename) {
                                                                     $mail_part->filename = 'Part ' . $mail_part->mime_id;
                                                                 }
                                                                 $this->attachments[] = $mail_part;
                                                             } else {
                                                                 if ($mail_part->filename) {
                                                                     $mail_part->ctype_primary = 'application';
                                                                     $mail_part->ctype_secondary = 'octet-stream';
                                                                     $mail_part->mimetype = 'application/octet-stream';
                                                                     $this->attachments[] = $mail_part;
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                         // if this was a related part try to resolve references
                         if ($mimetype == 'multipart/related' && sizeof($this->inline_parts)) {
                             $a_replaces = array();
                             foreach ($this->inline_parts as $inline_object) {
                                 $part_url = $this->get_part_url($inline_object->mime_id);
                                 if ($inline_object->content_id) {
                                     $a_replaces['cid:' . $inline_object->content_id] = $part_url;
                                 }
                                 if ($inline_object->content_location) {
                                     $a_replaces[$inline_object->content_location] = $part_url;
                                 }
                                 // MS Outlook sends sometimes non-related attachments as related
                                 // In this case multipart/related message has only one text part
                                 // We'll add all such attachments to the attachments list
                                 if (!isset($got_html_part) && empty($inline_object->content_id) && !empty($inline_object->filename)) {
                                     $this->attachments[] = $inline_object;
                                 }
                                 // MS Outlook sometimes also adds non-image attachments as related
                                 // We'll add all such attachments to the attachments list
                                 // Warning: some browsers support pdf in <img/>
                                 // @TODO: we should fetch HTML body and find attachment's content-id
                                 // to handle also image attachments without reference in the body
                                 if (!empty($inline_object->filename) && !preg_match('/^image\\/(gif|jpe?g|png|tiff|bmp|svg)/', $inline_object->mimetype)) {
                                     $this->attachments[] = $inline_object;
                                 }
                             }
                             // add replace array to each content part
                             // (will be applied later when part body is available)
                             foreach ($this->parts as $i => $part) {
                                 if ($part->type == 'content') {
                                     $this->parts[$i]->replaces = $a_replaces;
                                 }
                             }
                         }
                     } else {
                         if ($structure->filename) {
                             $this->attachments[] = $structure;
                         } else {
                             if (preg_match('/application\\//i', $mimetype)) {
                                 $structure->filename = 'Part ' . $structure->mime_id;
                                 $this->attachments[] = $structure;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 25
0
 /**
  *
  */
 function import_events()
 {
     // Upload progress update
     if (!empty($_GET['_progress'])) {
         rcube_upload_progress();
     }
     @set_time_limit(0);
     // process uploaded file if there is no error
     $err = $_FILES['_data']['error'];
     if (!$err && $_FILES['_data']['tmp_name']) {
         $calendar = rcube_utils::get_input_value('calendar', rcube_utils::INPUT_GPC);
         $rangestart = $_REQUEST['_range'] ? date_create("now -" . intval($_REQUEST['_range']) . " months") : 0;
         // extract zip file
         if ($_FILES['_data']['type'] == 'application/zip') {
             $count = 0;
             if (class_exists('ZipArchive', false)) {
                 $zip = new ZipArchive();
                 if ($zip->open($_FILES['_data']['tmp_name'])) {
                     $randname = uniqid('zip-' . session_id(), true);
                     $tmpdir = slashify($this->rc->config->get('temp_dir', sys_get_temp_dir())) . $randname;
                     mkdir($tmpdir, 0700);
                     // extract each ical file from the archive and import it
                     for ($i = 0; $i < $zip->numFiles; $i++) {
                         $filename = $zip->getNameIndex($i);
                         if (preg_match('/\\.ics$/i', $filename)) {
                             $tmpfile = $tmpdir . '/' . basename($filename);
                             if (copy('zip://' . $_FILES['_data']['tmp_name'] . '#' . $filename, $tmpfile)) {
                                 $count += $this->import_from_file($tmpfile, $calendar, $rangestart, $errors);
                                 unlink($tmpfile);
                             }
                         }
                     }
                     rmdir($tmpdir);
                     $zip->close();
                 } else {
                     $errors = 1;
                     $msg = 'Failed to open zip file.';
                 }
             } else {
                 $errors = 1;
                 $msg = 'Zip files are not supported for import.';
             }
         } else {
             // attempt to import teh uploaded file directly
             $count = $this->import_from_file($_FILES['_data']['tmp_name'], $calendar, $rangestart, $errors);
         }
         if ($count) {
             $this->rc->output->command('display_message', $this->gettext(array('name' => 'importsuccess', 'vars' => array('nr' => $count))), 'confirmation');
             $this->rc->output->command('plugin.import_success', array('source' => $calendar, 'refetch' => true));
         } else {
             if (!$errors) {
                 $this->rc->output->command('display_message', $this->gettext('importnone'), 'notice');
                 $this->rc->output->command('plugin.import_success', array('source' => $calendar));
             } else {
                 $this->rc->output->command('plugin.import_error', array('message' => $this->gettext('importerror') . ($msg ? ': ' . $msg : '')));
             }
         }
     } else {
         if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
             $msg = rcube_label(array('name' => 'filesizeerror', 'vars' => array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize'))))));
         } else {
             $msg = rcube_label('fileuploaderror');
         }
         $this->rc->output->command('plugin.import_error', array('message' => $msg));
     }
     $this->rc->output->send('iframe');
 }
Ejemplo n.º 26
0
 /**
  * Handler for 'folder_form' hook
  *
  * @param array $args Hook arguments array (form data)
  *
  * @return array Hook arguments array
  */
 function folder_form($args)
 {
     $mbox_imap = $args['options']['name'];
     $myrights = $args['options']['rights'];
     // Edited folder name (empty in create-folder mode)
     if (!strlen($mbox_imap)) {
         return $args;
     }
     /*
             // Do nothing on protected folders (?)
             if ($args['options']['protected']) {
                 return $args;
             }
     */
     // Get MYRIGHTS
     if (empty($myrights)) {
         return $args;
     }
     // Load localization and include scripts
     $this->load_config();
     $this->add_texts('localization/', array('deleteconfirm', 'norights', 'nouser', 'deleting', 'saving'));
     $this->include_script('acl.js');
     $this->rc->output->include_script('list.js');
     $this->include_stylesheet($this->local_skin_path() . '/acl.css');
     // add Info fieldset if it doesn't exist
     if (!isset($args['form']['props']['fieldsets']['info'])) {
         $args['form']['props']['fieldsets']['info'] = array('name' => rcube_label('info'), 'content' => array());
     }
     // Display folder rights to 'Info' fieldset
     $args['form']['props']['fieldsets']['info']['content']['myrights'] = array('label' => Q($this->gettext('myrights')), 'value' => $this->acl2text($myrights));
     // Return if not folder admin
     if (!in_array('a', $myrights)) {
         return $args;
     }
     // The 'Sharing' tab
     $this->mbox = $mbox_imap;
     $this->rc->output->set_env('acl_users_source', (bool) $this->rc->config->get('acl_users_source'));
     $this->rc->output->set_env('mailbox', $mbox_imap);
     $this->rc->output->add_handlers(array('acltable' => array($this, 'templ_table'), 'acluser' => array($this, 'templ_user'), 'aclrights' => array($this, 'templ_rights')));
     $this->rc->output->set_env('autocomplete_max', (int) $this->rc->config->get('autocomplete_max', 15));
     $this->rc->output->set_env('autocomplete_min_length', $this->rc->config->get('autocomplete_min_length'));
     $this->rc->output->add_label('autocompletechars', 'autocompletemore');
     $args['form']['sharing'] = array('name' => Q($this->gettext('sharing')), 'content' => $this->rc->output->parse('acl.table', false, false));
     return $args;
 }
Ejemplo n.º 27
0
 /**
  * Check the given data before saving.
  * If input isn't valid, the message to display can be fetched using get_error()
  *
  * @param array Assoziative array with data to save
  * @param boolean Attempt to fix/complete record automatically
  * @return boolean True if input is valid, False if not.
  */
 public function validate(&$save_data, $autofix = false)
 {
     // check validity of email addresses
     foreach ($this->get_col_values('email', $save_data, true) as $email) {
         if (strlen($email)) {
             if (!check_email(rcube_idn_to_ascii($email))) {
                 $this->set_error(self::ERROR_VALIDATE, rcube_label(array('name' => 'emailformaterror', 'vars' => array('email' => $email))));
                 return false;
             }
         }
     }
     return true;
 }
Ejemplo n.º 28
0
 function settingsTable($args)
 {
     if ($args['section'] == 'server') {
         $rcmail = rcmail::get_instance();
         $args['blocks']['calendar']['name'] = $this->gettext('calendar');
         $default_view = $rcmail->config->get('default_view', "HH:mm");
         $field_id = 'rcmfd_default_view';
         $select = new html_select(array('name' => '_default_view', 'id' => $field_id));
         $select->add($this->gettext('day'), "agendaDay");
         $select->add($this->gettext('week'), "agendaWeek");
         $select->add($this->gettext('month'), "month");
         $args['blocks']['calendar']['options']['default_view'] = array('title' => html::label($field_id, Q($this->gettext('default_view'))), 'content' => $select->show($rcmail->config->get('default_view')));
         $time_format = $rcmail->config->get('time_format', "HH:mm");
         $field_id = 'rcmfd_time_format';
         $choices = array('HH:mm', 'H:mm', 'h:mmt');
         $select = new html_select(array('name' => '_time_format', 'id' => $field_id));
         $select->add($choices);
         $args['blocks']['calendar']['options']['time_format'] = array('title' => html::label($field_id, Q($this->gettext('time_format'))), 'content' => $select->show($rcmail->config->get('time_format')));
         $timeslots = $rcmail->config->get('timeslots', 2);
         $field_id = 'rcmfd_timeslot';
         $choices = array('1', '2', '3', '4', '6');
         $select = new html_select(array('name' => '_timeslots', 'id' => $field_id));
         $select->add($choices);
         $args['blocks']['calendar']['options']['timeslots'] = array('title' => html::label($field_id, Q($this->gettext('timeslots'))), 'content' => $select->show($rcmail->config->get('timeslots')));
         $first_day = $rcmail->config->get('first_day', 1);
         $field_id = 'rcmfd_timeslot';
         $select = new html_select(array('name' => '_first_day', 'id' => $field_id));
         $select->add(rcube_label('sunday'), '0');
         $select->add(rcube_label('monday'), '1');
         $select->add(rcube_label('tuesday'), '2');
         $select->add(rcube_label('wednesday'), '3');
         $select->add(rcube_label('thursday'), '4');
         $select->add(rcube_label('friday'), '5');
         $select->add(rcube_label('saturday'), '6');
         $args['blocks']['calendar']['options']['first_day'] = array('title' => html::label($field_id, Q($this->gettext('first_day'))), 'content' => $select->show($rcmail->config->get('first_day')));
     }
     return $args;
 }
Ejemplo n.º 29
0
 private function _gen_folder_list($arrFolders, $command, $nestLevel = 0, &$folderTotal = 0)
 {
     $rcmail = rcmail::get_instance();
     $maxlength = 35;
     $realnames = false;
     $out = '';
     foreach ($arrFolders as $key => $folder) {
         $title = null;
         if (($folder_class = rcmail_folder_classname($folder['id'])) && !$realnames) {
             $foldername = rcube_label($folder_class);
         } else {
             $foldername = $folder['name'];
             // shorten the folder name to a given length
             if ($maxlength && $maxlength > 1) {
                 $fname = abbreviate_string($foldername, $maxlength);
                 if ($fname != $foldername) {
                     $title = $foldername;
                 }
                 $foldername = $fname;
             }
         }
         // make folder name safe for ids and class names
         $folder_id = asciiwords($folder['id'], true, '_');
         $classes = array();
         // set special class for Sent, Drafts, Trash and Junk
         if ($folder['id'] == $rcmail->config->get('sent_mbox')) {
             $classes[] = 'sent';
         } else {
             if ($folder['id'] == $rcmail->config->get('drafts_mbox')) {
                 $classes[] = 'drafts';
             } else {
                 if ($folder['id'] == $rcmail->config->get('trash_mbox')) {
                     $classes[] = 'trash';
                 } else {
                     if ($folder['id'] == $rcmail->config->get('junk_mbox')) {
                         $classes[] = 'junk';
                     } else {
                         if ($folder['id'] == 'INBOX') {
                             $classes[] = 'inbox';
                         } else {
                             $classes[] = '_' . asciiwords($folder_class ? $folder_class : strtolower($folder['id']), true);
                         }
                     }
                 }
             }
         }
         if ($folder['virtual']) {
             $classes[] = 'virtual';
         }
         $out .= html::tag('li', array('class' => join(' ', $classes)), html::a(array('href' => $command, 'onclick' => "rcm_set_dest_folder('" . JQ($folder['id']) . "')", 'class' => 'active', 'title' => $title), str_repeat('&nbsp;&nbsp;', $nestLevel) . Q($foldername)));
         if (!empty($folder['folders'])) {
             $out .= $this->_gen_folder_list($folder['folders'], $command, $nestLevel + 1, $folderTotal);
         }
         $folderTotal++;
     }
     if ($nestLevel == 0) {
         if ($folderTotal > 5) {
             $out = html::tag('ul', array('class' => 'toolbarmenu folders scrollable'), $out);
             $out = html::tag('div', array('class' => 'scroll_up_pas'), '') . $out . html::tag('div', array('class' => 'scroll_down_act'), '');
             $out = html::tag('div', array('class' => 'popupmenu'), $out);
         } else {
             $out = html::tag('ul', array('class' => 'popupmenu toolbarmenu folders'), $out);
         }
     }
     return $out;
 }
Ejemplo n.º 30
0
 function rule_div($fid, $id, $div = true)
 {
     $rule = isset($this->form) ? $this->form['tests'][$id] : $this->script[$fid]['tests'][$id];
     $rows_num = isset($this->form) ? sizeof($this->form['tests']) : sizeof($this->script[$fid]['tests']);
     $out = $div ? '<div class="rulerow" id="rulerow' . $id . '">' . "\n" : '';
     $out .= '<table><tr><td class="rowactions">';
     // headers select
     $select_header = new html_select(array('name' => "_header[]", 'id' => 'header' . $id, 'onchange' => 'header_select(' . $id . ')'));
     foreach ($this->headers as $name => $val) {
         $select_header->add(Q($this->gettext($name)), Q($val));
     }
     $select_header->add(Q($this->gettext('size')), 'size');
     $select_header->add(Q($this->gettext('...')), '...');
     // TODO: list arguments
     if (isset($rule['test']) && $rule['test'] == 'header' && !is_array($rule['arg1']) && in_array($rule['arg1'], $this->headers)) {
         $out .= $select_header->show($rule['arg1']);
     } else {
         if (isset($rule['test']) && $rule['test'] == 'exists' && !is_array($rule['arg']) && in_array($rule['arg'], $this->headers)) {
             $out .= $select_header->show($rule['arg']);
         } else {
             if (isset($rule['test']) && $rule['test'] == 'size') {
                 $out .= $select_header->show('size');
             } else {
                 if (isset($rule['test']) && $rule['test'] != 'true') {
                     $out .= $select_header->show('...');
                 } else {
                     $out .= $select_header->show();
                 }
             }
         }
     }
     $out .= '</td><td class="rowtargets">';
     if (isset($rule['test']) && $rule['test'] == 'header' && (is_array($rule['arg1']) || !in_array($rule['arg1'], $this->headers))) {
         $custom = is_array($rule['arg1']) ? implode(', ', $rule['arg1']) : $rule['arg1'];
     } else {
         if (isset($rule['test']) && $rule['test'] == 'exists' && (is_array($rule['arg']) || !in_array($rule['arg'], $this->headers))) {
             $custom = is_array($rule['arg']) ? implode(', ', $rule['arg']) : $rule['arg'];
         }
     }
     $out .= '<div id="custom_header' . $id . '" style="display:' . (isset($custom) ? 'inline' : 'none') . '">
         <input type="text" name="_custom_header[]" id="custom_header_i' . $id . '" ' . $this->error_class($id, 'test', 'header', 'custom_header_i') . ' value="' . Q($custom) . '" size="20" />&nbsp;</div>' . "\n";
     // matching type select (operator)
     $select_op = new html_select(array('name' => "_rule_op[]", 'id' => 'rule_op' . $id, 'style' => 'display:' . ($rule['test'] != 'size' ? 'inline' : 'none'), 'onchange' => 'rule_op_select(' . $id . ')'));
     $select_op->add(Q($this->gettext('filtercontains')), 'contains');
     $select_op->add(Q($this->gettext('filternotcontains')), 'notcontains');
     $select_op->add(Q($this->gettext('filteris')), 'is');
     $select_op->add(Q($this->gettext('filterisnot')), 'notis');
     $select_op->add(Q($this->gettext('filterexists')), 'exists');
     $select_op->add(Q($this->gettext('filternotexists')), 'notexists');
     //      $select_op->add(Q($this->gettext('filtermatches')), 'matches');
     //      $select_op->add(Q($this->gettext('filternotmatches')), 'notmatches');
     if (in_array('relational', $this->exts)) {
         $select_op->add(Q($this->gettext('countisgreaterthan')), 'count-gt');
         $select_op->add(Q($this->gettext('countisgreaterthanequal')), 'count-ge');
         $select_op->add(Q($this->gettext('countislessthan')), 'count-lt');
         $select_op->add(Q($this->gettext('countislessthanequal')), 'count-le');
         $select_op->add(Q($this->gettext('countequals')), 'count-eq');
         $select_op->add(Q($this->gettext('countnotequals')), 'count-ne');
         $select_op->add(Q($this->gettext('valueisgreaterthan')), 'value-gt');
         $select_op->add(Q($this->gettext('valueisgreaterthanequal')), 'value-ge');
         $select_op->add(Q($this->gettext('valueislessthan')), 'value-lt');
         $select_op->add(Q($this->gettext('valueislessthanequal')), 'value-le');
         $select_op->add(Q($this->gettext('valueequals')), 'value-eq');
         $select_op->add(Q($this->gettext('valuenotequals')), 'value-ne');
     }
     // target input (TODO: lists)
     if ($rule['test'] == 'header') {
         $out .= $select_op->show(($rule['not'] ? 'not' : '') . $rule['type']);
         $target = $rule['arg2'];
     } else {
         if ($rule['test'] == 'size') {
             $out .= $select_op->show();
             if (preg_match('/^([0-9]+)(K|M|G)*$/', $rule['arg'], $matches)) {
                 $sizetarget = $matches[1];
                 $sizeitem = $matches[2];
             }
         } else {
             $out .= $select_op->show(($rule['not'] ? 'not' : '') . $rule['test']);
             $target = '';
         }
     }
     $out .= '<input type="text" name="_rule_target[]" id="rule_target' . $id . '"
         value="' . Q($target) . '" size="20" ' . $this->error_class($id, 'test', 'target', 'rule_target') . ' style="display:' . ($rule['test'] != 'size' && $rule['test'] != 'exists' ? 'inline' : 'none') . '" />' . "\n";
     $select_size_op = new html_select(array('name' => "_rule_size_op[]", 'id' => 'rule_size_op' . $id));
     $select_size_op->add(Q($this->gettext('filterunder')), 'under');
     $select_size_op->add(Q($this->gettext('filterover')), 'over');
     $out .= '<div id="rule_size' . $id . '" style="display:' . ($rule['test'] == 'size' ? 'inline' : 'none') . '">';
     $out .= $select_size_op->show($rule['test'] == 'size' ? $rule['type'] : '');
     $out .= '<input type="text" name="_rule_size_target[]" id="rule_size_i' . $id . '" value="' . $sizetarget . '" size="10" ' . $this->error_class($id, 'test', 'sizetarget', 'rule_size_i') . ' />
         <input type="radio" name="_rule_size_item[' . $id . ']" value=""' . (!$sizeitem ? ' checked="checked"' : '') . ' class="radio" />' . rcube_label('B') . '
         <input type="radio" name="_rule_size_item[' . $id . ']" value="K"' . ($sizeitem == 'K' ? ' checked="checked"' : '') . ' class="radio" />' . rcube_label('KB') . '
         <input type="radio" name="_rule_size_item[' . $id . ']" value="M"' . ($sizeitem == 'M' ? ' checked="checked"' : '') . ' class="radio" />' . rcube_label('MB') . '
         <input type="radio" name="_rule_size_item[' . $id . ']" value="G"' . ($sizeitem == 'G' ? ' checked="checked"' : '') . ' class="radio" />' . rcube_label('GB');
     $out .= '</div>';
     $out .= '</td>';
     // add/del buttons
     $out .= '<td class="rowbuttons">';
     $out .= '<input type="button" id="ruleadd' . $id . '" value="' . Q($this->gettext('add')) . '"
         onclick="rcmail.managesieve_ruleadd(' . $id . ')" class="button" /> ';
     $out .= '<input type="button" id="ruledel' . $id . '" value="' . Q($this->gettext('del')) . '"
         onclick="rcmail.managesieve_ruledel(' . $id . ')" class="button' . ($rows_num < 2 ? ' disabled' : '') . '"' . ($rows_num < 2 ? ' disabled="disabled"' : '') . ' />';
     $out .= '</td></tr></table>';
     $out .= $div ? "</div>\n" : '';
     return $out;
 }