Changeset 82a1417 in github


Ignore:
Timestamp:
May 23, 2012 2:06:57 PM (12 months ago)
Author:
Aleksander Machniak <alec@…>
Branches:
release-0.8
Children:
8b31d99
Parents:
da19e0e
git-author:
Aleksander Machniak <alec@…> (05/23/12 03:19:51)
git-committer:
Aleksander Machniak <alec@…> (05/23/12 14:06:57)
Message:

Improved PERMANENTFLAGS checking code, added code for flags caching (currently commented out)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_imap.php

    r3f9d175 r82a1417  
    405405    public function check_permflag($flag) 
    406406    { 
    407         $flag = strtoupper($flag); 
    408         $imap_flag = $this->conn->flags[$flag]; 
    409  
    410         if ($this->folder !== null) { 
    411             $this->check_connection(); 
    412         } 
    413         // @TODO: cache permanent flags (?) 
    414  
    415         return (in_array_nocase($imap_flag, $this->conn->data['PERMANENTFLAGS'])); 
     407        $flag       = strtoupper($flag); 
     408        $imap_flag  = $this->conn->flags[$flag]; 
     409        $perm_flags = $this->get_permflags($this->folder); 
     410 
     411        return in_array_nocase($imap_flag, $perm_flags); 
     412    } 
     413 
     414 
     415    /** 
     416     * Returns PERMANENTFLAGS of the specified folder 
     417     * 
     418     * @param  string $folder Folder name 
     419     * 
     420     * @return array Flags 
     421     */ 
     422    public function get_permflags($folder) 
     423    { 
     424        if (!strlen($folder)) { 
     425            return array(); 
     426        } 
     427/* 
     428        Checking PERMANENTFLAGS is rather rare, so we disable caching of it 
     429        Re-think when we'll use it for more than only MDNSENT flag 
     430 
     431        $cache_key = 'mailboxes.permanentflags.' . $folder; 
     432        $permflags = $this->get_cache($cache_key); 
     433 
     434        if ($permflags !== null) { 
     435            return explode(' ', $permflags); 
     436        } 
     437*/ 
     438        if (!$this->check_connection()) { 
     439            return array(); 
     440        } 
     441 
     442        if ($this->conn->select($folder)) { 
     443            $permflags = $this->conn->data['PERMANENTFLAGS']; 
     444        } 
     445        else { 
     446            return array(); 
     447        } 
     448 
     449        if (!is_array($permflags)) { 
     450            $permflags = array(); 
     451        } 
     452/* 
     453        // Store permflags as string to limit cached object size 
     454        $this->update_cache($cache_key, implode(' ', $permflags)); 
     455*/ 
     456        return $permflags; 
    416457    } 
    417458 
Note: See TracChangeset for help on using the changeset viewer.