class IMP_Message
{
/**
+ */
+ protected static $_instance = null;
+
+ /**
* Using POP to access mailboxes?
*
* @var boolean
protected $_usepop = false;
/**
- * Returns a reference to the global IMP_Message object, only creating it
- * if it doesn't already exist. This ensures that only one IMP_Message
- * instance is instantiated for any given session.
- *
- * This method must be invoked as:<code>
- * $imp_message = &IMP_Message::singleton();
- * </code>
+ * Returns a reference to the global IMP_Message object, only creating it if
+ * it doesn't already exist. This ensures that only one IMP_Message instance
+ * is instantiated for any given session.
*
* @return IMP_Message The IMP_Message instance.
*/
- static final public function &singleton()
+ public static function singleton()
{
- static $message;
-
- if (!isset($message)) {
- $message = new IMP_Message();
+ if (!self::$_instance) {
+ self::$_instance = new IMP_Message();
}
- return $message;
+ return self::$_instance;
}
/**
* Constructor.
*/
- function __construct()
+ private function __construct()
{
if ($_SESSION['imp']['protocol'] == 'pop') {
$this->_usepop = true;
}
if ($new) {
- $imp_folder = &IMP_Folder::singleton();
+ $imp_folder = IMP_Folder::singleton();
if (!$imp_folder->exists($targetMbox) &&
!$imp_folder->create($targetMbox, $prefs->getValue('subscribe'))) {
return false;
try {
$imp_imap->ob->copy($mbox, $targetMbox, array('ids' => $msgIndices, 'move' => $imap_move));
- $imp_mailbox = &IMP_Mailbox::singleton($mbox);
+ $imp_mailbox = IMP_Mailbox::singleton($mbox);
if ($imp_mailbox->isBuilt()) {
$imp_mailbox->removeMsgs(array($mbox => $msgIndices));
}
$use_trash_folder = !$this->_usepop && !$nuke && !$use_vtrash && $use_trash;
if ($use_trash_folder) {
include_once IMP_BASE . '/lib/Folder.php';
- $imp_folder = &IMP_Folder::singleton();
+ $imp_folder = IMP_Folder::singleton();
if (!$imp_folder->exists($trash) &&
!$imp_folder->create($trash, $prefs->getValue('subscribe'))) {
try {
$imp_imap->ob->copy($mbox, $trash, array('ids' => $msgIndices, 'move' => true));
- $imp_mailbox = &IMP_Mailbox::singleton($mbox);
+ $imp_mailbox = IMP_Mailbox::singleton($mbox);
if ($imp_mailbox->isBuilt()) {
$imp_mailbox->removeMsgs(array($mbox => $msgIndices));
}
return false;
}
} else {
- /* Get the list of Message-IDs for the deleted messages if
- * using maillogging. */
+ /* Get the list of Message-IDs for the deleted messages if using
+ * maillogging. */
$fetch = null;
if ($maillog_update) {
try {
$expunge_now = true;
} else {
/* If we are using virtual trash, we must mark the message
- * as seen or else it will appear as an 'unseen' message
- * for purposes of new message counts. */
+ * as seen or else it will appear as an 'unseen' message for
+ * purposes of new message counts. */
if ($use_vtrash) {
$del_flags[] = '\\seen';
}
}
} catch (Horde_Imap_Client_Exception $e) {}
- /* Get the list of Message-IDs deleted, and remove
- * the information from the mail log. */
+ /* Get the list of Message-IDs deleted, and remove the
+ * information from the mail log. */
if (!is_null($fetch)) {
$msg_ids = array();
reset($fetch);
foreach ($msgList as $folder => $msgIndices) {
foreach ($msgIndices as $index) {
/* Fetch the message contents. */
- $imp_contents = &IMP_Contents::singleton($index . IMP::IDX_SEP . $folder);
+ $imp_contents = IMP_Contents::singleton($index . IMP::IDX_SEP . $folder);
$imp_contents->buildMessage();
/* Fetch the message headers. */
- $imp_headers = &$imp_contents->getHeaderOb();
+ $imp_headers = $imp_contents->getHeaderOb();
$subject = $imp_headers->getValue('subject');
/* Extract the message body. */
- $imp_compose = &IMP_Compose::singleton();
+ $imp_compose = IMP_Compose::singleton();
$mime_message = $imp_contents->getMIMEMessage();
$body_id = $imp_compose->getBodyId($imp_contents);
$body = $imp_compose->findBody($imp_contents);
case 'task':
/* Create a new vTodo object using this message's
* contents. */
- $vTodo = &Horde_iCalendar::newComponent('vtodo', $vCal);
+ $vTodo = Horde_iCalendar::newComponent('vtodo', $vCal);
$vTodo->setAttribute('SUMMARY', $subject);
$vTodo->setAttribute('DESCRIPTION', $body);
$vTodo->setAttribute('PRIORITY', '3');
case 'note':
/* Create a new vNote object using this message's
* contents. */
- $vNote = &Horde_iCalendar::newComponent('vnote', $vCal);
+ $vNote = Horde_iCalendar::newComponent('vnote', $vCal);
$vNote->setAttribute('BODY', $subject . "\n". $body);
/* Get the list of editable notepads. */
}
/* Get a local copy of the message. */
- $contents = &IMP_Contents::singleton($index . IMP::IDX_SEP . $mbox);
+ $contents = IMP_Contents::singleton($index . IMP::IDX_SEP . $mbox);
/* Loop through all to-be-stripped mime parts. */
if (is_null($partid)) {
$this->delete($indices, true, true);
- $imp_mailbox = &IMP_Mailbox::singleton($mbox);
+ $imp_mailbox = IMP_Mailbox::singleton($mbox);
$imp_mailbox->setIndex(reset($uid));
/* We need to replace the old index in the query string with the
try {
$imp_imap->ob->expunge($key, array('ids' => is_array($val) ? $val : array()));
- $imp_mailbox = &IMP_Mailbox::singleton($key);
+ $imp_mailbox = IMP_Mailbox::singleton($key);
if ($imp_mailbox->isBuilt()) {
$imp_mailbox->removeMsgs(is_array($val) ? array($key => $val) : true);
}