Exemplo n.º 1
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('  ', $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;
 }
Exemplo n.º 2
0
    function action_div($fid, $id, $div = true)
    {
        $action = isset($this->form) ? $this->form['actions'][$id] : $this->script[$fid]['actions'][$id];
        $rows_num = isset($this->form) ? sizeof($this->form['actions']) : sizeof($this->script[$fid]['actions']);
        $out = $div ? '<div class="actionrow" id="actionrow' . $id . '">' . "\n" : '';
        $out .= '<table><tr><td class="rowactions">';
        // action select
        $select_action = new html_select(array('name' => "_action_type[]", 'id' => 'action_type' . $id, 'onchange' => 'action_type_select(' . $id . ')'));
        if (in_array('fileinto', $this->exts)) {
            $select_action->add(Q($this->gettext('messagemoveto')), 'fileinto');
        }
        $select_action->add(Q($this->gettext('messageredirect')), 'redirect');
        if (in_array('reject', $this->exts)) {
            $select_action->add(Q($this->gettext('messagediscard')), 'reject');
        } elseif (in_array('ereject', $this->exts)) {
            $select_action->add(Q($this->gettext('messagediscard')), 'ereject');
        }
        if (in_array('vacation', $this->exts)) {
            $select_action->add(Q($this->gettext('messagereply')), 'vacation');
        }
        $select_action->add(Q($this->gettext('messagedelete')), 'discard');
        $select_action->add(Q($this->gettext('rulestop')), 'stop');
        $out .= $select_action->show($action['type']);
        $out .= '</td>';
        // actions target inputs
        $out .= '<td class="rowtargets">';
        // shared targets
        $out .= '<input type="text" name="_action_target[]" id="action_target' . $id . '" ' . 'value="' . ($action['type'] == 'redirect' ? Q($action['target'], 'strict', false) : '') . '" size="40" ' . 'style="display:' . ($action['type'] == 'redirect' ? 'inline' : 'none') . '" ' . $this->error_class($id, 'action', 'target') . ' />';
        $out .= '<textarea name="_action_target_area[]" id="action_target_area' . $id . '" ' . 'rows="3" cols="40" ' . $this->error_class($id, 'action', 'targetarea') . 'style="display:' . (in_array($action['type'], array('reject', 'ereject')) ? 'inline' : 'none') . '">' . (in_array($action['type'], array('reject', 'ereject')) ? Q($action['target'], 'strict', false) : '') . "</textarea>\n";
        // vacation
        $out .= '<div id="action_vacation' . $id . '" style="display:' . ($action['type'] == 'vacation' ? 'inline' : 'none') . '">';
        $out .= '<span class="label">' . Q($this->gettext('vacationreason')) . '</span><br />' . '<textarea name="_action_reason[]" id="action_reason' . $id . '" ' . 'rows="3" cols="40" ' . $this->error_class($id, 'action', 'reason') . '>' . Q($action['reason'], 'strict', false) . "</textarea>\n";
        $out .= '<br /><span class="label">' . Q($this->gettext('vacationaddresses')) . '</span><br />' . '<input type="text" name="_action_addresses[]" ' . 'value="' . (is_array($action['addresses']) ? Q(implode(', ', $action['addresses']), 'strict', false) : $action['addresses']) . '" size="40" ' . $this->error_class($id, 'action', 'addresses') . ' />';
        $out .= '<br /><span class="label">' . Q($this->gettext('vacationdays')) . '</span><br />' . '<input type="text" name="_action_days[]" ' . 'value="' . Q($action['days'], 'strict', false) . '" size="2" ' . $this->error_class($id, 'action', 'days') . ' />';
        $out .= '</div>';
        // mailbox select
        $out .= '<select id="action_mailbox' . $id . '" name="_action_mailbox[]" style="display:' . (!isset($action) || $action['type'] == 'fileinto' ? 'inline' : 'none') . '">';
        $this->rc->imap_init(true);
        $a_folders = $this->rc->imap->list_mailboxes();
        $delimiter = $this->rc->imap->get_hierarchy_delimiter();
        // set mbox encoding
        $mbox_encoding = $this->rc->config->get('managesieve_mbox_encoding', 'UTF7-IMAP');
        if ($action['type'] == 'fileinto') {
            $mailbox = $action['target'];
        } else {
            $mailbox = '';
        }
        foreach ($a_folders as $folder) {
            $utf7folder = $this->rc->imap->mod_mailbox($folder);
            $names = explode($delimiter, rcube_charset_convert($folder, 'UTF7-IMAP'));
            $name = $names[sizeof($names) - 1];
            if ($replace_delimiter = $this->rc->config->get('managesieve_replace_delimiter')) {
                $utf7folder = str_replace($delimiter, $replace_delimiter, $utf7folder);
            }
            // convert to Sieve implementation encoding
            $utf7folder = $this->mbox_encode($utf7folder, $mbox_encoding);
            if ($folder_class = rcmail_folder_classname($name)) {
                $foldername = $this->gettext($folder_class);
            } else {
                $foldername = $name;
            }
            $out .= sprintf('<option value="%s"%s>%s%s</option>' . "\n", htmlspecialchars($utf7folder), $mailbox == $utf7folder ? ' selected="selected"' : '', str_repeat('&nbsp;', 4 * (sizeof($names) - 1)), Q(abbreviate_string($foldername, 40 - (2 * sizeof($names) - 1))));
        }
        $out .= '</select>';
        $out .= '</td>';
        // add/del buttons
        $out .= '<td class="rowbuttons">';
        $out .= '<input type="button" id="actionadd' . $id . '" value="' . Q($this->gettext('add')) . '" 
	onclick="rcmail.managesieve_actionadd(' . $id . ')" class="button" /> ';
        $out .= '<input type="button" id="actiondel' . $id . '" value="' . Q($this->gettext('del')) . '"
        onclick="rcmail.managesieve_actiondel(' . $id . ')" class="button' . ($rows_num < 2 ? ' disabled' : '') . '"' . ($rows_num < 2 ? ' disabled="disabled"' : '') . ' />';
        $out .= '</td>';
        $out .= '</tr></table>';
        $out .= $div ? "</div>\n" : '';
        return $out;
    }