*
* This implements all functions that manipulate mailboxes
*
- * @copyright © 1999-2005 The SquirrelMail Project Team
+ * @copyright © 1999-2006 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
var $mailboxname_full = '', $mailboxname_sub= '', $is_noselect = false, $is_noinferiors = false,
$is_special = false, $is_root = false, $is_inbox = false, $is_sent = false,
$is_trash = false, $is_draft = false, $mbxs = array(),
- $unseen = false, $total = false;
+ $unseen = false, $total = false, $recent = false;
function addMbx($mbx, $delimiter, $start, $specialfirst) {
$ary = explode($delimiter, $mbx->mailboxname_full);
*
* @param stream $imap_stream imap connection resource
* @param string $mailbox mailbox name
- * @param array $mailboxlist (since 1.5.1) optional array of mailboxes from
+ * @param array $mailboxlist (since 1.5.1) optional array of mailboxes from
* sqimap_get_mailboxes() (to avoid having to talk to imap server)
* @return boolean
* @since 1.0 or older
* @since 1.0 or older
*/
function sqimap_mailbox_select ($imap_stream, $mailbox) {
+ // FIX ME: WHAAAA DO NOT USE "None" for something that does not exist. Use false or NULL instead
if ($mailbox == 'None') {
return;
}
-
+ // cleanup $mailbox in order to prevent IMAP injection attacks
+ $mailbox = str_replace(array("\r","\n"), array("",""),$mailbox);
$read = sqimap_run_command($imap_stream, 'SELECT ' . sqimap_encode_mailbox_name($mailbox),
true, $response, $message);
$result = array();
* Before 1.2.0 used third argument for delimiter.
*
* Before 1.5.1 used second argument for lsub line. Argument was removed in order to use
- * find_mailbox_name() on the raw input. Since 1.5.1 includes RFC3501 names in flags
+ * find_mailbox_name() on the raw input. Since 1.5.1 includes RFC3501 names in flags
* array (for example, "\NoSelect" in addition to "noselect")
* @param array $line
* @return array
* There are three main listing commands we can use in IMAP:
* LSUB shows just the list of subscribed folders
* may include flags, but these are not necessarily accurate or authoratative
- * \NoSelect has special meaning: the folder does not exist -OR- it means this
+ * \NoSelect has special meaning: the folder does not exist -OR- it means this
* folder is not subscribed but children may be
* [RFC-2060]
* LIST this shows every mailbox on the system
sqgetGlobalVar($sub_cache_name,$lsub_cache,SQ_SESSION);
}
+ $lsub_assoc_ary=array();
if (!empty($lsub_cache)) {
$lsub_assoc_ary=$lsub_cache;
} else {
// and NOT a LSUB, so no need to do it again
$list_assoc_ary = $lsub_assoc_ary;
} else {
- // we did a LSUB so now we need to do a LIST
+ // we did a LSUB so now we need to do a LIST
// first see if it is in cache
$list_cache_name='list_cache';
if (!$force) {
break;
}
}
-
+
if ($has_inbox == false) {
// do a list request for inbox because we should always show
// inbox even if the user isn't subscribed to it.
if (in_array('\HasNoChildren',$flags)) { $noinferiors=1; }
$noselect=0;
- if (in_array('\NoSelect',$flags)) { $noselect=1; }
+ if (in_array('\NoSelect',$flags)) { $noselect=1; }
/**
* LIST (SUBSCRIBED) has two new flags, \NonExistent which means the mailbox is subscribed to
* but doesn't exist, and \PlaceHolder which is similar (but not the same) as \NoSelect
* For right now, we'll treat these the same as \NoSelect and this behavior can be changed
* later if needed
*/
- if (in_array('\NonExistent',$flags)) { $noselect=1; }
+ if (in_array('\NonExistent',$flags)) { $noselect=1; }
if (in_array('\PlaceHolder',$flags)) { $noselect=1; }
$sorted_lsub_ary[] = array ('mbx' => $mbx, 'noselect' => $noselect, 'noinferiors' => $noinferiors);
}
$trail_del = false;
$start = 0;
-
if (isset($folder_prefix) && ($folder_prefix != '')) {
$start = substr_count($folder_prefix,$delimiter);
if (strrpos($folder_prefix, $delimiter) == (strlen($folder_prefix)-1)) {
$mbx = $oMbx->mailboxname_full;
if ($unseen_type == 2 ||
($move_to_trash && $oMbx->mailboxname_full == $trash_folder)) {
- $query = 'STATUS ' . sqimap_encode_mailbox_name($mbx) . ' (MESSAGES UNSEEN)';
+ $query = 'STATUS ' . sqimap_encode_mailbox_name($mbx) . ' (MESSAGES UNSEEN RECENT)';
} else {
- $query = 'STATUS ' . sqimap_encode_mailbox_name($mbx) . ' (UNSEEN)';
+ $query = 'STATUS ' . sqimap_encode_mailbox_name($mbx) . ' (UNSEEN RECENT)';
}
sqimap_prepare_pipelined_query($query,$tag,$aQuery,false);
} else {
- $oMbx->unseen = $oMbx->total = false;
+ $oMbx->unseen = $oMbx->total = $oMbx->recent = false;
$tag = false;
}
$oMbx->tag = $tag;
if (preg_match('/MESSAGES\s+([0-9]+)/i', $sResponse, $regs)) {
$oMbx->total = $regs[1];
}
+ if (preg_match('/RECENT\s+([0-9]+)/i', $sResponse, $regs)) {
+ $oMbx->recent = $regs[1];
+ }
+
}
unset($oMbx->tag);
}
$aStatus = sqimap_status_messages($imap_stream,$oMbx->mailboxname_full);
$oMbx->unseen = $aStatus['UNSEEN'];
$oMbx->total = $aStatus['MESSAGES'];
+ $oMbx->recent = $aStatus['RECENT'];
} else {
$oMbx->unseen = sqimap_unseen_messages($imap_stream,$oMbx->mailboxname_full);
}
}
}
}
+
+ $cnt = count($aMbxs);
+ for($i=0;$i<$cnt;++$i) {
+ $oMbx =& $aMbxs[$i];
+ unset($hook_status);
+ if (!empty($oMbx->unseen)) { $hook_status['UNSEEN']=$oMbx->unseen; }
+ if (!empty($oMbx->total)) { $hook_status['MESSAGES']=$oMbx->total; }
+ if (!empty($oMbx->recent)) { $hook_status['RECENT']=$oMbx->recent; }
+ if (!empty($hook_status))
+ {
+ $hook_status['MAILBOX']=$oMbx->mailboxname_full;
+ $hook_status['CALLER']='sqimap_get_status_mbx_tree'; // helps w/ debugging
+ do_hook_function('folder_status',$hook_status);
+ }
+ }
}
/**
return false;
}
-?>
\ No newline at end of file
+?>