File/nasmail/functions/imap_mailbox.php

Description

This implements all functions that manipulate mailboxes

  • version: $Id: imap_mailbox.php 1486 2009-11-08 12:52:32Z tokul $
  • copyright: (c) 1999-2006 The SquirrelMail Project Team
  • copyright: (c) 2006-2009 The NaSMail Project
  • license: GNU Public License
Includes
 include_once (SM_PATH.'functions/imap_utf7_local.php') (line 14)

UTF7 support

Functions
check_is_noselect (line 40)

Detects a Noselect mailbox from LSUB|LIST response

  • return: true on noselect mailbox
boolean check_is_noselect (string $lsub_line)
  • string $lsub_line
find_mailbox_name (line 24)

Finds mailbox name in LSUB|LIST response

string find_mailbox_name (string $mailbox)
  • string $mailbox
isBoxBelow (line 74)

Checks if $subbox is below the specified $parentbox

boolean isBoxBelow (string $subbox, string $parentbox)
  • string $subbox: subbox Child mailbox name
  • string $parentbox: parentbox Parent mailbox name
isDraftMailbox (line 159)

Detects if mailbox is a Drafts folder or subfolder of Drafts

  • return: whether this is a Draft folder
bool isDraftMailbox (string $box, [boolean $include_subs = true])
  • string $box: box mailbox name
  • boolean $include_subs: include_subs if true, subfolders of system folders are special. if false, subfolders are not special mailboxes.
isSentMailbox (line 140)

Detects if mailbox is a Sent folder or subfolder of Sent

  • return: whether this is a Sent folder
bool isSentMailbox (string $box, [boolean $include_subs = true])
  • string $box: box mailbox name
  • boolean $include_subs: include_subs if true, subfolders of system folders are special. if false, subfolders are not special mailboxes.
isSpecialMailbox (line 101)

Defines special mailboxes: given a mailbox name, it checks if this is a "special" one: INBOX, Trash, Sent or Draft.

Function includes special_mailbox hook.

boolean isSpecialMailbox (string $box, [boolean $include_subs = true])
  • string $box: box mailbox name
  • boolean $include_subs: include_subs if true, subfolders of system folders are special. if false, subfolders are not special mailboxes unless they are tagged as special in 'special_mailbox' hook.
isTrashMailbox (line 120)

Detects if mailbox is a Trash folder or subfolder of Trash

  • return: whether this is a Trash folder
bool isTrashMailbox (string $box, [boolean $include_subs = true])
  • string $box: box mailbox name
  • boolean $include_subs: include_subs if true, subfolders of system folders are special. if false, subfolders are not special mailboxes.
mailtree_sort (line 658)

Sorts mailboxes in array values

Mailboxes with some chars (like -) can mess up the order, this fixes it test test.a test.b test-again

  • deprecated: 1.3 code uses sqimap_mailtree_ksort()
void mailtree_sort (array &$lsub)
  • array &$lsub: lsub array with full imap folder names in array values
nsm_imap_mailbox_expunge (line 216)

Expunges messages in selected mailbox.

Mailbox must be selected with sqimap_mailbox_select() before issuing the command.

If message UIDs are set and IMAP UIDPLUS extension is supported, function tries to expunge only selected messages.

  • return: Number of expunged messages
  • since: 1.5
integer nsm_imap_mailbox_expunge (stream $imap_stream, [boolean $handle_errors = true], [array $msgs = array()], [boolean $force_expunge = false])
  • stream $imap_stream: IMAP connection resource
  • boolean $handle_errors: Controls internal error handling. Allows to ignore expunge errors, if option is set to false
  • array $msgs: List of message UIDs. Function accepts string values due to sqimap_message_list_squisher() function specifics, but use of strings is deprecated and unsupported.
  • boolean $force_expunge: Force mailbox expunge, if UIDPLUS extension is not supported and code can't expunge only selected message UIDs.
nsm_imap_mailbox_name (line 1035)

Returns human readable mailbox name

Function does utf7-imap decoding and applies all rewrites done in scripts.

  • since: 1.4
string nsm_imap_mailbox_name (string $mailbox, [boolean $html_safe = true])
  • string $mailbox: Full IMAP mailbox name
  • boolean $html_safe: Controls html sanitizing of returned data
readMailboxParent (line 53)

If $haystack is a full mailbox name, and $needle is the mailbox separator character, returns the second last part of the full mailbox name (i.e. the mailbox's parent mailbox)

  • return: Parent mailbox name
string readMailboxParent (string $haystack, string $needle)
  • string $haystack: haystack mailbox name
  • string $needle: needle IMAP delimiter
sqimap_compact_mailboxes_response (line 1007)

Converts multiline imap resposes to one line.

Function is not part of SquirrelMail 1.4 API. It was introduced in SquirrelMail 1.5.0 and used name without sqimap_ prefix. NaSMail uses function with sqimap_ prefix.

array sqimap_compact_mailboxes_response (array $ary)
  • array $ary: ary Array with IMAP responses
sqimap_mailbox_create (line 346)

Creates a folder.

void sqimap_mailbox_create (stream $imap_stream, string $mailbox, string $type)
  • stream $imap_stream: imap_stream IMAP connection resource
  • string $mailbox: mailbox Mailbox name
  • string $type: type 'noselect' for Noselect mailbox
sqimap_mailbox_delete (line 387)

Deletes the given folder

void sqimap_mailbox_delete (stream $imap_stream, string $mailbox)
  • stream $imap_stream: imap_stream IMAP connection resource
  • string $mailbox: mailbox Mailbox name
sqimap_mailbox_exists (line 263)

Checks whether or not the specified mailbox exists

  • return: true if mailbox exists. false, if not.
boolean sqimap_mailbox_exists (stream $imap_stream, string $mailbox)
  • stream $imap_stream: imap_stream IMAP connection resource
  • string $mailbox: mailbox Mailbox name
sqimap_mailbox_expunge (line 183)

Expunges a mailbox

In NaSMail 1.0-1.1 function had fourth argument. Argument was removed because it violated IMAP standards.

  • return: number of expunged messages
  • deprecated: Use nsm_imap_mailbox_expunge() with only first two arguments.
int sqimap_mailbox_expunge (stream $imap_stream, string $mailbox, [boolean $handle_errors = true])
  • stream $imap_stream: imap_stream IMAP connection resource
  • string $mailbox: mailbox Mailbox (argument is unused)
  • boolean $handle_errors: handle_errors Error handling
sqimap_mailbox_is_subscribed (line 411)

Determines if the user is subscribed to the folder or not

  • return: true, if subscribed
boolean sqimap_mailbox_is_subscribed (stream $imap_stream, string $folder)
  • stream $imap_stream: imap_stream IMAP connection resource
  • string $folder: folder Mailbox name
sqimap_mailbox_ksort (line 979)

Sorts mailboxes stored in array keys

Mailboxes with some chars (like -) can mess up the order, this fixes it See sample listing in mailtree_sort() function

void sqimap_mailbox_ksort (array &$lsub)
  • array &$lsub: lsub array with full imap folder names in array keys
sqimap_mailbox_list (line 680)

Returns sorted mailbox lists in several different ways.

See comment on sqimap_mailbox_parse() for info about the returned array.

array sqimap_mailbox_list (stream $imap_stream, [boolean $force = false])
  • stream $imap_stream: imap_stream
  • boolean $force: force Overrides session caching
sqimap_mailbox_list_all (line 850)

Returns a list of all folders, subscribed or not

array sqimap_mailbox_list_all (stream $imap_stream)
  • stream $imap_stream: imap_stream
sqimap_mailbox_option_list (line 592)

Returns list of options (to be echoed into select statement based on available mailboxes and separators Caller should surround options with <select ...> </select> and any formatting.

unknown sqimap_mailbox_option_list (stream $imap_stream, [array $show_selected = 0], [array $folder_skip = 0], [array $boxes = 0], [string $flag = 'noselect'], [boolean $use_long_format = false])
  • stream $imap_stream: imap_stream IMAP connection resource
  • array $show_selected: show_selected array containing list of mailboxes to pre-select (0 if none)
  • array $folder_skip: folder_skip array of folders to keep out of option list. Case sensitivity depends on interface configuration.
  • array $boxes: boxes list of already fetched boxes (for places like folder panel, where you know these options will be shown 3 times in a row.. (most often unset)
  • string $flag: flag flag to check for in mailbox flags, used to filter out mailboxes. 'noselect' by default to remove unselectable mailboxes. 'noinferiors' used to filter out folders that can not contain subfolders. NULL to avoid flag check entirely.
  • boolean $use_long_format: use_long_format override folder display preference and always show full folder name.
sqimap_mailbox_parse (line 498)

Formats a mailbox into parts for the $boxesall array

The parts are:

raw - Raw LIST/LSUB response from the IMAP server formatted - nicely formatted folder name unformatted - unformatted, but with delimiter at end removed unformatted-dm - folder name as it appears in raw response unformatted-disp - unformatted without $folder_prefix

array sqimap_mailbox_parse (string $line, string $line_lsub)
  • string $line
  • string $line_lsub
sqimap_mailbox_rename (line 428)

Renames a mailbox.

void sqimap_mailbox_rename (stream $imap_stream, string $old_name, string $new_name)
  • stream $imap_stream: imap_stream IMAP connection resource
  • string $old_name: old_name Old mailbox name
  • string $new_name: new_name New mailbox name
sqimap_mailbox_select (line 286)

Selects a mailbox

Command blocks mailboxes that start with '/' or contain '../' string. All linefeeds and cariage returns are removed for mailbox name.

Returned array keys depend on IMAP SELECT command response. See RFC 3501 and 2060. Please note that SELECT response requirements are changed in rfc 3501.

  • return: array with IMAP SELECT command info or empty array. Command might stop code execution if invalid mailbox name is used or IMAP SELECT command fails.
array sqimap_mailbox_select (stream $imap_stream, string $mailbox)
  • stream $imap_stream: imap_stream IMAP connection resource
  • string $mailbox: mailbox IMAP mailbox name
sqimap_subscribe (line 365)

Subscribes to an existing folder.

void sqimap_subscribe (stream $imap_stream, string $mailbox)
  • stream $imap_stream: imap_stream IMAP connection resource
  • string $mailbox: mailbox Mailbox name
sqimap_unsubscribe (line 376)

Unsubscribes from an existing folder

void sqimap_unsubscribe (stream $imap_stream, string $mailbox)
  • stream $imap_stream: imap_stream IMAP connection resource
  • string $mailbox: mailbox Mailbox name
user_strcasecmp (line 569)

Callback function used to sort mailboxes

Function was rewritten in SquirrelMail 1.3.x. Older code was dropped. After modifications standard PHP function can be used in callbacks.

  • deprecated: 1.2 - 2007.06.16 - use strnatcasecmp instead. If there are no issues, function will be removed in NaSMail 2.0.
void user_strcasecmp (string $a, string $b)
  • string $a: first mailbox name
  • string $b: second mailbox name

Documentation generated on Sun, 22 Nov 2009 17:36:38 +0200 by phpDocumentor 1.4.3