Example #1
0
 /**
  * Get mailbox size (size of all messages in a mailbox)
  *
  * @param string $mailbox Mailbox name
  *
  * @return int Mailbox size in bytes, False on error
  */
 function get_mailbox_size($mailbox)
 {
     // @TODO: could we try to use QUOTA here?
     $result = $this->conn->fetchHeaderIndex($mailbox, '1:*', 'SIZE', false);
     if (is_array($result)) {
         $result = array_sum($result);
     }
     return $result;
 }
Example #2
0
 /**
  * Get folder size (size of all messages in a folder)
  *
  * @param string $folder Folder name
  *
  * @return int Folder size in bytes, False on error
  */
 public function folder_size($folder)
 {
     if (!$this->check_connection()) {
         return 0;
     }
     // @TODO: could we try to use QUOTA here?
     $result = $this->conn->fetchHeaderIndex($folder, '1:*', 'SIZE', false);
     if (is_array($result)) {
         $result = array_sum($result);
     }
     return $result;
 }
Example #3
0
 /**
  * Get folder size (size of all messages in a folder)
  *
  * @param string $folder Folder name
  *
  * @return int Folder size in bytes, False on error
  */
 public function folder_size($folder)
 {
     if (!strlen($folder)) {
         return false;
     }
     if (!$this->check_connection()) {
         return 0;
     }
     // On Cyrus we can use special folder annotation, which should be much faster
     if ($this->get_vendor() == 'cyrus') {
         $idx = '/shared/vendor/cmu/cyrus-imapd/size';
         $result = $this->get_metadata($folder, $idx, array(), true);
         if (!empty($result) && is_numeric($result[$folder][$idx])) {
             return $result[$folder][$idx];
         }
     }
     // @TODO: could we try to use QUOTA here?
     $result = $this->conn->fetchHeaderIndex($folder, '1:*', 'SIZE', false);
     if (is_array($result)) {
         $result = array_sum($result);
     }
     return $result;
 }