Changeset 94bdcce in github


Ignore:
Timestamp:
May 6, 2011 4:14:48 AM (2 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
091b028
Parents:
de0a3f9
Message:
  • Add possibility (for plugins) to filter folders lists by some additional criteria (e.g. folder type)
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • program/include/main.inc

    rd08333e r94bdcce  
    11711171    $attrib['id'] = 'rcmboxlist'; 
    11721172 
     1173  if (empty($attrib['folder_name'])) 
     1174    $attrib['folder_name'] = '*'; 
     1175 
    11731176  // get mailbox list 
    11741177  $mbox_name = $RCMAIL->imap->get_mailbox_name(); 
     
    11771180  if (empty($a_mailboxes)) { 
    11781181    // get mailbox list 
    1179     $a_folders = $RCMAIL->imap->list_mailboxes(); 
     1182    $a_folders = $RCMAIL->imap->list_mailboxes('', $attrib['folder_name'], $attrib['folder_filter']); 
    11801183    $delimiter = $RCMAIL->imap->get_hierarchy_delimiter(); 
    11811184    $a_mailboxes = array(); 
     
    12241227  $a_mailboxes = array(); 
    12251228 
     1229  if (empty($p['folder_name'])) 
     1230    $p['folder_name'] = '*'; 
     1231 
    12261232  if ($p['unsubscribed']) 
    1227     $list = $RCMAIL->imap->list_unsubscribed(); 
     1233    $list = $RCMAIL->imap->list_unsubscribed('', $p['folder_name'], $p['folder_filter']); 
    12281234  else 
    1229     $list = $RCMAIL->imap->list_mailboxes(); 
     1235    $list = $RCMAIL->imap->list_mailboxes('', $p['folder_name'], $p['folder_filter']); 
    12301236 
    12311237  $delimiter = $RCMAIL->imap->get_hierarchy_delimiter(); 
  • program/include/rcube_imap.php

    rd08333e r94bdcce  
    30153015     * 
    30163016     * @param   string  $root   Optional root folder 
    3017      * @param   string  $filter Optional filter for mailbox listing 
     3017     * @param   string  $name   Optional name pattern 
     3018     * @param   string  $filter Optional filter 
    30183019     * 
    30193020     * @return  array   List of mailboxes/folders 
    30203021     * @access  public 
    30213022     */ 
    3022     function list_mailboxes($root='', $filter='*') 
    3023     { 
    3024         $a_mboxes = $this->_list_mailboxes($root, $filter); 
     3023    function list_mailboxes($root='', $name='*', $filter=null) 
     3024    { 
     3025        $a_mboxes = $this->_list_mailboxes($root, $name, $filter); 
    30253026 
    30263027        // INBOX should always be available 
    3027         if (!in_array('INBOX', $a_mboxes)) 
     3028        if ((!$filter || $filter == 'mail') && !in_array('INBOX', $a_mboxes)) { 
    30283029            array_unshift($a_mboxes, 'INBOX'); 
     3030        } 
    30293031 
    30303032        // sort mailboxes 
     
    30393041     * 
    30403042     * @param   string  $root   Optional root folder 
    3041      * @param   string  $filter Optional filter for mailbox listing 
     3043     * @param   string  $name   Optional name pattern 
     3044     * @param   mixed   $filter Optional filter 
     3045     * 
    30423046     * @return  array   List of mailboxes/folders 
    30433047     * @see     rcube_imap::list_mailboxes() 
    30443048     * @access  private 
    30453049     */ 
    3046     private function _list_mailboxes($root='', $filter='*') 
    3047     { 
     3050    private function _list_mailboxes($root='', $name='*', $filter=null) 
     3051    { 
     3052        $cache_key = 'mailboxes'; 
     3053        if (!empty($filter)) { 
     3054            $cache_key .= ':'.substr((is_string($filter) ? $filter : serialize($filter)), 0, 90); 
     3055        } 
     3056 
    30483057        // get cached folder list 
    3049         $a_mboxes = $this->get_cache('mailboxes'); 
    3050         if (is_array($a_mboxes)) 
     3058        $a_mboxes = $this->get_cache($cache_key); 
     3059        if (is_array($a_mboxes)) { 
    30513060            return $a_mboxes; 
     3061        } 
    30523062 
    30533063        $a_defaults = $a_out = array(); 
     
    30553065        // Give plugins a chance to provide a list of mailboxes 
    30563066        $data = rcmail::get_instance()->plugins->exec_hook('mailboxes_list', 
    3057             array('root' => $root, 'filter' => $filter, 'mode' => 'LSUB')); 
     3067            array('root' => $root, 'name' => $name, 'filter' => $filter, 'mode' => 'LSUB')); 
    30583068 
    30593069        if (isset($data['folders'])) { 
     
    30663076            if (!$config->get('imap_force_lsub') && $this->get_capability('LIST-EXTENDED')) { 
    30673077                // This will also set mailbox options, LSUB doesn't do that 
    3068                 $a_folders = $this->conn->listMailboxes($root, $filter, 
     3078                $a_folders = $this->conn->listMailboxes($root, $name, 
    30693079                    NULL, array('SUBSCRIBED')); 
    30703080 
     
    30823092            // retrieve list of folders from IMAP server using LSUB 
    30833093            else { 
    3084                 $a_folders = $this->conn->listSubscribed($root, $filter); 
    3085             } 
    3086         } 
    3087  
    3088         if (!is_array($a_folders) || !sizeof($a_folders)) 
     3094                $a_folders = $this->conn->listSubscribed($root, $name); 
     3095            } 
     3096        } 
     3097 
     3098        if (!is_array($a_folders) || !sizeof($a_folders)) { 
    30893099            $a_folders = array(); 
     3100        } 
    30903101 
    30913102        // write mailboxlist to cache 
    3092         $this->update_cache('mailboxes', $a_folders); 
     3103        $this->update_cache($cache_key, $a_folders); 
    30933104 
    30943105        return $a_folders; 
     
    31003111     * 
    31013112     * @param string $root   IMAP root dir 
    3102      * @param string $filter Optional filter for mailbox listing 
     3113     * @param string  $name   Optional name pattern 
     3114     * @param mixed   $filter Optional filter 
     3115     * 
    31033116     * @return array Indexed array with folder names 
    31043117     */ 
    3105     function list_unsubscribed($root='', $filter='*') 
    3106     { 
     3118    function list_unsubscribed($root='', $name='*', $filter=null) 
     3119    { 
     3120        // @TODO: caching 
    31073121        // Give plugins a chance to provide a list of mailboxes 
    31083122        $data = rcmail::get_instance()->plugins->exec_hook('mailboxes_list', 
    3109             array('root' => $root, 'filter' => $filter, 'mode' => 'LIST')); 
     3123            array('root' => $root, 'name' => $name, 'filter' => $filter, 'mode' => 'LIST')); 
    31103124 
    31113125        if (isset($data['folders'])) { 
     
    31143128        else { 
    31153129            // retrieve list of folders from IMAP server 
    3116             $a_mboxes = $this->conn->listMailboxes($root, $filter); 
     3130            $a_mboxes = $this->conn->listMailboxes($root, $name); 
    31173131        } 
    31183132 
     
    31223136 
    31233137        // INBOX should always be available 
    3124         if (!in_array('INBOX', $a_mboxes)) 
     3138        if ((!$filter || $filter == 'mail') && !in_array('INBOX', $a_mboxes)) { 
    31253139            array_unshift($a_mboxes, 'INBOX'); 
     3140        } 
    31263141 
    31273142        // filter folders and sort them 
     
    32643279            // clear cache 
    32653280            $this->clear_message_cache($mailbox.'.msg'); 
    3266             $this->clear_cache('mailboxes'); 
     3281            $this->clear_cache('/^mailboxes.*/', true); 
    32673282        } 
    32683283 
     
    33063321            // clear mailbox-related cache 
    33073322            $this->clear_message_cache($mailbox.'.msg'); 
    3308             $this->clear_cache('mailboxes'); 
     3323            $this->clear_cache('/^mailboxes.*/', true); 
    33093324        } 
    33103325 
     
    37783793     * Clears the cache. 
    37793794     * 
    3780      * @param string $key Cache key 
     3795     * @param string  $key          Cache key name or pattern 
     3796     * @param boolean $pattern_mode Enable it to clear all keys with name 
     3797     *                              matching PREG pattern in $key 
    37813798     * @access public 
    37823799     */ 
    3783     function clear_cache($key=NULL) 
     3800    function clear_cache($key=null, $pattern_mode=false) 
    37843801    { 
    37853802        if (!$this->caching_enabled) 
    37863803            return; 
    37873804 
    3788         if ($key===NULL) { 
    3789             foreach ($this->cache as $key => $data) 
     3805        if ($key === null) { 
     3806            foreach (array_keys($this->cache) as $key) 
    37903807                $this->_clear_cache_record($key); 
    37913808 
     
    37933810            $this->cache_changed = false; 
    37943811            $this->cache_changes = array(); 
     3812        } 
     3813        else if ($pattern_mode) { 
     3814            foreach (array_keys($this->cache) as $k) { 
     3815                if (preg_match($key, $k)) { 
     3816                    $this->_clear_cache_record($k); 
     3817                    $this->cache_changes[$k] = false; 
     3818                    unset($this->cache[$key]); 
     3819                } 
     3820            } 
     3821            if (!count($this->cache)) { 
     3822                $this->cache_changed = false; 
     3823            } 
    37953824        } 
    37963825        else { 
  • program/steps/mail/check_recent.inc

    rf5e7b353 r94bdcce  
    2525// list of folders to check 
    2626if ($check_all) { 
    27     $a_mailboxes = $IMAP->list_mailboxes(); 
     27    $a_mailboxes = $IMAP->list_mailboxes('', '*', 'mail'); 
    2828} 
    2929else { 
  • program/steps/mail/compose.inc

    r1abb97f r94bdcce  
    12981298{ 
    12991299  $attrib['name'] = '_store_target'; 
    1300   $select = rcmail_mailbox_select(array_merge($attrib, array('noselection' => '- '.rcube_label('dontsave').' -'))); 
     1300  $select = rcmail_mailbox_select(array_merge($attrib, array( 
     1301    'noselection' => '- '.rcube_label('dontsave').' -', 
     1302    'folder_filter' => 'mail' 
     1303  ))); 
    13011304  return $select->show($_SESSION['compose']['param']['sent_mbox'], $attrib); 
    13021305} 
  • program/steps/mail/getunread.inc

    rf5e7b353 r94bdcce  
    2020*/ 
    2121 
    22 $a_folders = $IMAP->list_mailboxes(); 
     22$a_folders = $IMAP->list_mailboxes('', '*', 'mail'); 
    2323 
    2424if (!empty($a_folders)) 
  • skins/default/templates/mail.html

    r9e1daa4 r94bdcce  
    2929<div id="mailboxlist-title" class="boxtitle"><roundcube:label name="mailboxlist" /></div> 
    3030<div class="boxlistcontent"> 
    31 <roundcube:object name="mailboxlist" id="mailboxlist" /> 
     31<roundcube:object name="mailboxlist" id="mailboxlist" folder_filter="mail" /> 
    3232</div> 
    3333<div class="boxfooter"> 
  • skins/default/templates/message.html

    rc6be456 r94bdcce  
    2929<roundcube:container name="toolbar" id="messagetoolbar" /> 
    3030<roundcube:button name="messagemenulink" id="messagemenulink" type="link" class="button messagemenu" title="messageactions" onclick="rcmail_ui.show_popup('messagemenu');return false" content=" " /> 
    31 <roundcube:object name="mailboxlist" type="select" noSelection="moveto" maxlength="25" onchange="rcmail.command('moveto', this.options[this.selectedIndex].value)" class="mboxlist" /> 
     31<roundcube:object name="mailboxlist" type="select" noSelection="moveto" maxlength="25" onchange="rcmail.command('moveto', this.options[this.selectedIndex].value)" class="mboxlist" folder_filter="mail" /> 
    3232</div> 
    3333 
  • skins/default/templates/messageerror.html

    r9e55503 r94bdcce  
    4343<div class="boxtitle"><roundcube:label name="mailboxlist" /></div> 
    4444<div class="boxlistcontent"> 
    45 <roundcube:object name="mailboxlist" id="mailboxlist" maxlength="25" /> 
     45<roundcube:object name="mailboxlist" id="mailboxlist" folder_filter="mail" /> 
    4646</div> 
    4747<div class="boxfooter"> 
Note: See TracChangeset for help on using the changeset viewer.