/** * Renames the old sent-mail mailboxes. * * Mailbox name: sent-mail-month-year * month = English: 3 letter abbreviation * Other Languages: Month value (01-12) * year = 4 digit year * * The mailbox name needs to be in this specific format (as opposed to a * user-defined one) to ensure that 'delete_sentmail_monthly' processing * can accurately find all the old sent-mail mailboxes. * * @return boolean Whether all sent-mail mailboxes were renamed. */ public function execute() { global $notification; $date_format = substr($GLOBALS['language'], 0, 2) == 'en' ? 'M-Y' : 'm-Y'; $datetime = new DateTime(); $now = $datetime->format($date_format); foreach ($this->_getSentmail() as $sent) { /* Display a message to the user and rename the mailbox. * Only do this if sent-mail mailbox currently exists. */ if ($sent->exists) { $notification->push(sprintf(_("\"%s\" mailbox being renamed at the start of the month."), $sent->display), 'horde.message'); $query = new Horde_Imap_Client_Fetch_Query(); $query->imapDate(); $query->uid(); $imp_imap = $sent->imp_imap; $res = $imp_imap->fetch($sent, $query); $msgs = array(); foreach ($res as $val) { $date_string = $val->getImapDate()->format($date_format); if (!isset($msgs[$date_string])) { $msgs[$date_string] = $imp_imap->getIdsOb(); } $msgs[$date_string]->add($val->getUid()); } unset($msgs[$now]); foreach ($msgs as $key => $val) { $new_mbox = IMP_Mailbox::get(strval($sent) . '-' . Horde_String::lower($key)); $imp_imap->copy($sent, $new_mbox, array('create' => true, 'ids' => $val, 'move' => true)); } } } return true; }
/** * Constructor. * * @param mixed Two possible inputs: * - 1 argument: Horde_Variables object. These GET/POST parameters are * reserved in IMP: * - buid: (string) BUID [Browser UID]. * - mailbox: (string) Base64url encoded mailbox. * - muid: (string) MUID [Mailbox + UID]. * - uid: (string) UID [Actual mail UID]. * - 2 arguments: IMP_Mailbox object, IMP_Indices argument */ public function __construct() { $args = func_get_args(); switch (func_num_args()) { case 1: if ($args[0] instanceof Horde_Variables) { if (isset($args[0]->mailbox) && strlen($args[0]->mailbox)) { $this->mailbox = IMP_Mailbox::formFrom($args[0]->mailbox); if (isset($args[0]->buid)) { $this->buids = new IMP_Indices($this->mailbox, $args[0]->buid); parent::__construct($this->mailbox->fromBuids($this->buids)); } elseif (isset($args[0]->uid)) { parent::__construct($this->mailbox, $args[0]->uid); } } if (isset($args[0]->muid)) { parent::__construct($args[0]->muid); } } break; case 2: if ($args[0] instanceof IMP_Mailbox && $args[1] instanceof IMP_Indices) { $this->mailbox = $args[0]; $this->buids = $args[0]->toBuids($args[1]); parent::__construct($args[1]); } break; } if (!isset($this->buids)) { $this->buids = new IMP_Indices(); } if (!isset($this->mailbox)) { $this->mailbox = IMP_Mailbox::get('INBOX'); } }
/** * Purge the old sent-mail mailboxes. * * @return boolean Whether any mailboxes were deleted. */ public function execute() { global $injector, $notification, $prefs; $iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree')); $iterator->add($iterator::CONTAINERS); $mbox_list = array(); /* Get list of all mailboxes, parse through and get the list of all * old sent-mail mailboxes. Then sort this array according to the * date. */ $sent_mail = $injector->getInstance('IMP_Identity')->getAllSentmail(); foreach (array_map('strval', $iterator) as $k) { foreach ($sent_mail as $mbox) { if (preg_match('/^' . preg_quote($mbox, '/') . '-([^-]+)-([0-9]{4})$/i', $k, $regs)) { $mbox_list[$k] = is_numeric($regs[1]) ? mktime(0, 0, 0, $regs[1], 1, $regs[2]) : strtotime("{$regs['1']} 1, {$regs['2']}"); } } } arsort($mbox_list, SORT_NUMERIC); $return_val = false; /* See if any mailboxes need to be purged. */ $purge = array_slice(array_keys($mbox_list), $prefs->getValue('delete_sentmail_monthly_keep')); if (count($purge)) { $notification->push(_("Old sent-mail mailboxes being purged."), 'horde.message'); /* Delete the old mailboxes now. */ foreach (IMP_Mailbox::get($purge) as $val) { if ($val->delete()) { $return_val = true; } } } return $return_val; }
/** * @param array $opts Options: * - buid: (string) BUID of message. * - full: (boolean) Full URL? * - mailbox: (string) Mailbox of message. */ public static function url(array $opts = array()) { $url = Horde::url('basic.php')->add('page', 'listinfo')->unique()->setRaw(!empty($opts['full'])); if (!empty($opts['mailbox'])) { $url->add(array('buid' => $opts['buid'], 'mailbox' => IMP_Mailbox::get($opts['mailbox'])->form_to)); } return $url; }
/** * Tasks to perform on shutdown. */ public function shutdown() { foreach ($this->_instances as $key => $val) { if ($val->changed) { $this->_getCache(IMP_Mailbox::get($key))->set($key, serialize($val)); } } }
/** */ protected function _init() { global $injector, $notification; if (!$this->indices->mailbox->access_search) { $notification->push(_("Searching is not available."), 'horde.error'); $this->indices->mailbox->url('mailbox')->redirect(); } $imp_flags = $injector->getInstance('IMP_Flags'); $imp_search = $injector->getInstance('IMP_Search'); /* If search_basic is set, we are processing the search query. */ if ($this->vars->search_basic) { $c_list = array(); if ($this->vars->search_criteria_text) { switch ($this->vars->search_criteria) { case 'from': case 'subject': $c_list[] = new IMP_Search_Element_Header($this->vars->search_criteria_text, $this->vars->search_criteria, $this->vars->search_criteria_not); break; case 'recip': $c_list[] = new IMP_Search_Element_Recipient($this->vars->search_criteria_text, $this->vars->search_criteria_not); break; case 'body': case 'text': $c_list[] = new IMP_Search_Element_Text($this->vars->search_criteria_text, $this->vars->search_criteria == 'body', $this->vars->search_criteria_not); break; } } if ($this->vars->search_criteria_flag) { $formdata = $imp_flags->parseFormId($this->vars->search_criteria_flag); $c_list[] = new IMP_Search_Element_Flag($formdata['flag'], $formdata['set'] && !$this->vars->search_criteria_flag_not); } if (empty($c_list)) { $notification->push(_("No search criteria specified."), 'horde.error'); } else { /* Store the search in the session. */ $q_ob = $imp_search->createQuery($c_list, array('id' => IMP_Search::BASIC_SEARCH, 'mboxes' => array($this->indices->mailbox), 'type' => IMP_Search::CREATE_QUERY)); /* Redirect to the mailbox screen. */ IMP_Mailbox::get($q_ob)->url('mailbox')->redirect(); } } $flist = $imp_flags->getList(array('imap' => true, 'mailbox' => $this->indices->mailbox)); $flag_set = array(); foreach ($flist as $val) { $flag_set[] = array('val' => $val->form_set, 'label' => $val->label); } /* Prepare the search template. */ $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/basic/search')); $view->addHelper('FormTag'); $view->addHelper('Tag'); $view->action = self::url(); $view->advsearch = Horde::link($this->indices->mailbox->url(IMP_Basic_Search::url())); $view->mbox = $this->indices->mailbox->form_to; $view->search_title = sprintf(_("Search %s"), $this->indices->mailbox->display_html); $view->flist = $flag_set; $this->title = _("Search"); $this->output = $view->render('search-basic'); }
/** * Returns data needed to output quota. * * @param string $mailbox Mailbox to query. * @param boolean $force If true, ignore 'interval' config option and * force quota display. * * @return array|boolean Array with these keys: class, message, percent. * Returns false if no updated quota information. */ public function quota($mailbox = null, $force = true) { global $injector, $session; $qconfig = $injector->getInstance('IMP_Factory_Imap')->create()->config->quota; if (!$qconfig) { return false; } $qlist = array(); if (!is_null($mailbox)) { $mailbox = IMP_Mailbox::get($mailbox); if ($mailbox->nonimap) { return false; } if (!$force) { $qlist = $session->get('imp', self::SESSION_INTERVAL_KEY, $session::TYPE_ARRAY); if (isset($qlist[strval($mailbox)]) && time() < $qlist[strval($mailbox)]) { return false; } } } try { $quotaDriver = $injector->getInstance('IMP_Quota'); $quota = $quotaDriver->getQuota($mailbox); } catch (IMP_Exception $e) { Horde::log($e, 'ERR'); return false; } $qlist[strval($mailbox)] = $qconfig['params']['interval'] + time(); $session->set('imp', self::SESSION_INTERVAL_KEY, $qlist); if (empty($quota)) { return false; } $strings = $quotaDriver->getMessages(); list($calc, $unit) = $quotaDriver->getUnit(); $ret = array('class' => '', 'percent' => 0); if ($quota['limit'] != 0) { $quota['usage'] = $quota['usage'] / $calc; $quota['limit'] = $quota['limit'] / $calc; $ret['percent'] = $quota['usage'] * 100 / $quota['limit']; if ($ret['percent'] >= 90) { $ret['class'] = 'quotaalert'; } elseif ($ret['percent'] >= 75) { $ret['class'] = 'quotawarn'; } $ret['message'] = sprintf($strings['short'], $ret['percent'], $quota['limit'], $unit); $ret['percent'] = sprintf("%.2f", $ret['percent']); } elseif ($quotaDriver->isHiddenWhenUnlimited()) { return false; } elseif ($quota['usage'] != 0) { $quota['usage'] = $quota['usage'] / $calc; $ret['message'] = sprintf($strings['nolimit_short'], $quota['usage'], $unit); } else { $ret['message'] = _("No limit"); } return $ret; }
/** * Garbage collection. */ public function gc() { foreach (IMP_Mailbox::get(array_keys($this->_sortpref)) as $val) { /* Purge if mailbox doesn't exist or this is a search query (not * a virtual folder). */ if (!$val->exists || $val->query) { unset($this[strval($val)]); } } }
/** * Generates a string that can be saved out to an mbox format mailbox file * for a mailbox (or set of mailboxes), optionally including all * subfolders of the selected mailbox(es) as well. All mailboxes will be * output in the same string. * * @param mixed $mboxes A mailbox name (UTF-8), or list of mailbox names, * to generate a mbox file for. * * @return resource A stream resource containing the text of a mbox * format mailbox file. */ public function generate($mboxes) { $body = fopen('php://temp', 'r+'); if (!is_array($mboxes)) { if (!strlen($mboxes)) { return $body; } $mboxes = array($mboxes); } if (empty($mboxes)) { return $body; } $query = new Horde_Imap_Client_Fetch_Query(); $query->envelope(); $query->imapDate(); $query->headerText(array('peek' => true)); $query->bodyText(array('peek' => true)); foreach (IMP_Mailbox::get($mboxes) as $val) { $imp_imap = $val->imp_imap; $slices = $imp_imap->getSlices($val, $imp_imap->getIdsOb(Horde_Imap_Client_Ids::ALL, true)); foreach ($slices as $slice) { try { $res = $imp_imap->fetch($val, $query, array('ids' => $slice, 'nocache' => true)); } catch (IMP_Imap_Exception $e) { continue; } foreach ($res as $ptr) { $from_env = $ptr->getEnvelope()->from; $from = count($from_env) ? $from_env[0]->bare_address : '<>'; /* We need this long command since some MUAs (e.g. pine) * require a space in front of single digit days. */ $imap_date = $ptr->getImapDate(); $date = sprintf('%s %2s %s', $imap_date->format('D M'), $imap_date->format('j'), $imap_date->format('H:i:s Y')); fwrite($body, 'From ' . $from . ' ' . $date . "\r\n"); /* Remove spurious 'From ' line in headers. */ $stream = $ptr->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_STREAM); while (!feof($stream)) { $line = fgets($stream); if (substr($line, 0, 5) != 'From ') { fwrite($body, $line); } } fwrite($body, "\r\n"); /* Add Body text. */ $stream = $ptr->getBodyText(0, true); while (!feof($stream)) { fwrite($body, fread($stream, 8192)); } fwrite($body, "\r\n"); } } } return $body; }
/** */ public function update(Horde_Core_Prefs_Ui $ui) { global $injector, $prefs; $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create(); if (!$imp_imap->access(IMP_Imap::ACCESS_FOLDERS) || $prefs->isLocked(IMP_Mailbox::MBOX_SENT)) { return false; } if (!$ui->vars->sent_mail && $ui->vars->sent_mail_new) { $sent_mail = IMP_Mailbox::get($ui->vars->sent_mail_new)->namespace_append; } else { $sent_mail = IMP_Mailbox::formFrom($ui->vars->sent_mail); if (strpos($sent_mail, self::PREF_SPECIALUSE) === 0) { $sent_mail = IMP_Mailbox::get(substr($sent_mail, strlen(self::PREF_SPECIALUSE))); } elseif ($sent_mail == self::PREF_DEFAULT && ($sm_default = $prefs->getDefault(IMP_Mailbox::MBOX_SENT))) { $sent_mail = IMP_Mailbox::get($sm_default)->namespace_append; } } if ($sent_mail && !$sent_mail->create()) { return false; } return $injector->getInstance('IMP_Identity')->setValue(IMP_Mailbox::MBOX_SENT, $sent_mail); }
/** * Constructor. * * @param mixed Two possible inputs: * - 1 argument: Horde_Variables object. These GET/POST parameters are * reserved in IMP: * - buid: (string) BUID [Browser UID]. * - mailbox: (string) Base64url encoded mailbox. * - muid: (string) MUID [Mailbox + UID]. * - uid: (string) UID [Actual mail UID]. * - 2 arguments: IMP_Mailbox object, IMP_Indices argument */ public function __construct() { $args = func_get_args(); switch (func_num_args()) { case 1: if ($args[0] instanceof Horde_Variables) { if (isset($args[0]->mailbox) && strlen($args[0]->mailbox)) { $this->mailbox = IMP_Mailbox::formFrom($args[0]->mailbox); if (isset($args[0]->buid)) { /* BUIDs are always integers. Do conversion here since * POP3 won't work otherwise. */ $tmp = new Horde_Imap_Client_Ids($args[0]->buid); $this->buids = new IMP_Indices($this->mailbox, $tmp->ids); parent::__construct($this->mailbox->fromBuids($this->buids)); } elseif (isset($args[0]->uid)) { parent::__construct($this->mailbox, $args[0]->uid); } } if (isset($args[0]->muid)) { parent::__construct($args[0]->muid); } } break; case 2: if ($args[0] instanceof IMP_Mailbox && $args[1] instanceof IMP_Indices) { $this->mailbox = $args[0]; $this->buids = $args[0]->toBuids($args[1]); parent::__construct($args[1]); } break; } if (!isset($this->buids)) { $this->buids = new IMP_Indices($this->_indices); } if (!isset($this->mailbox)) { $this->mailbox = IMP_Mailbox::get('INBOX'); } }
/** */ protected function _content() { $inbox = IMP_Mailbox::get('INBOX'); /* Filter on INBOX display, if requested. */ $inbox->filterOnDisplay(); $query = new Horde_Imap_Client_Search_Query(); $query->flag(Horde_Imap_Client::FLAG_SEEN, false); $ids = $inbox->runSearchQuery($query, Horde_Imap_Client::SORT_SEQUENCE, 1); $indices = $ids['INBOX']; $html = '<table cellspacing="0" width="100%">'; $text = _("Go to your Inbox..."); if (empty($indices)) { $html .= '<tr><td><em>' . _("No unread messages") . '</em></td></tr>'; } else { $imp_ui = new IMP_Mailbox_Ui($inbox); $shown = empty($this->_params['msgs_shown']) ? 3 : $this->_params['msgs_shown']; $query = new Horde_Imap_Client_Fetch_Query(); $query->envelope(); try { $imp_imap = $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create($inbox); $fetch_ret = $imp_imap->fetch($inbox, $query, array('ids' => $imp_imap->getIdsOb(array_slice($indices, 0, $shown)))); } catch (IMP_Imap_Exception $e) { $fetch_ret = new Horde_Imap_Client_Fetch_Results(); } foreach ($fetch_ret as $uid => $ob) { $envelope = $ob->getEnvelope(); $date = $imp_ui->getDate(isset($envelope->date) ? $envelope->date : null); $from = $imp_ui->getFrom($envelope); $subject = $imp_ui->getSubject($envelope->subject, true); $html .= '<tr style="cursor:pointer" class="text"><td>' . $inbox->url('message', $uid)->link() . '<strong>' . htmlspecialchars($from['from'], ENT_QUOTES, 'UTF-8') . '</strong><br />' . $subject . '</a></td>' . '<td>' . htmlspecialchars($date, ENT_QUOTES, 'UTF-8') . '</td></tr>'; } $more_msgs = count($indices) - $shown; if ($more_msgs > 0) { $text = sprintf(ngettext("%d more unseen message...", "%d more unseen messages...", $more_msgs), $more_msgs); } } return $html . '<tr><td colspan="2" style="cursor:pointer" align="right">' . $inbox->url('mailbox')->link() . $text . '</a></td></tr>' . '</table>'; }
/** */ protected function _content() { global $injector; /* Filter on INBOX display. INBOX is always polled. */ IMP_Mailbox::get('INBOX')->filterOnDisplay(); /* Get list of mailboxes to poll. */ $poll = $injector->getInstance('IMP_Ftree')->poll->getPollList(true); $status = $injector->getInstance('IMP_Factory_Imap')->create()->status($poll, Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_RECENT_TOTAL); $anyUnseen = false; $out = ''; foreach ($poll as $mbox) { $mbox_str = strval($mbox); if (isset($status[$mbox_str]) && (empty($this->_params['show_unread']) || !empty($status[$mbox_str]['unseen']))) { $mbox_status = $status[$mbox_str]; $label = $mbox->url('mailbox')->link() . $mbox->display_html . '</a>'; if (!empty($mbox_status['unseen'])) { $label = '<strong>' . $label . '</strong>'; $anyUnseen = true; } $out .= '<tr><td>' . $label . '</td>'; if (empty($mbox_status['unseen'])) { $out .= '<td>-</td>'; } else { $out .= '<td><strong>' . intval($mbox_status['unseen']) . '</strong>'; if (!empty($mbox_status['recent_total'])) { $out .= ' (<span style="color:red">' . sprintf(ngettext("%d new", "%d new", $mbox_status['recent_total']), $mbox_status['recent_total']) . '</span>)'; } $out .= '</td>'; } $out .= '<td>' . intval($mbox_status['messages']) . '</td></tr>'; } } if (!empty($this->_params['show_unread']) && !$anyUnseen) { return '<em>' . _("No mailboxes with unseen messages") . '</em>'; } return '<table class="impBlockSummary"><thead><tr><th>' . _("Mailbox") . '</th><th>' . _("Unseen") . '</th><th>' . _("Total") . '</th></tr></thead><tbody>' . $out . '</tbody></table>'; }
/** */ public function display(Horde_Core_Prefs_Ui $ui) { global $injector, $notification, $page_output; $page_output->addScriptFile('acl.js'); $acl = $injector->getInstance('IMP_Imap_Acl'); $mbox = isset($ui->vars->mbox) ? IMP_Mailbox::formFrom($ui->vars->mbox) : IMP_Mailbox::get('INBOX'); try { $curr_acl = $acl->getACL($mbox); if (!($canEdit = $acl->canEdit($mbox))) { $notification->push(_("You do not have permission to change access to this mailbox."), 'horde.warning'); } } catch (IMP_Exception $e) { $notification->push($e); $canEdit = false; $curr_acl = array(); } $rightslist = $acl->getRights(); $iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree')); $iterator->add($iterator::NONIMAP); $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs')); $view->addHelper('FormTag'); $view->addHelper('Tag'); $view->addHelper('Text'); $view->canedit = $canEdit; $view->current = sprintf(_("Current access to %s"), $mbox->display_html); $view->hasacl = count($curr_acl); $view->mbox = $mbox->form_to; $view->options = new IMP_Ftree_Select(array('basename' => true, 'iterator' => $iterator, 'selected' => $mbox)); if ($view->hasacl) { $cval = array(); foreach ($curr_acl as $index => $rule) { $entry = array('index' => $index, 'rule' => array()); if ($rule instanceof Horde_Imap_Client_Data_AclNegative) { $entry['negative'] = substr($index, 1); } /* Create table of each ACL option for each user granted * permissions; enabled indicates the right has been given to * the user. */ $rightsmbox = $acl->getRightsMbox($mbox, $index); foreach (array_keys($rightslist) as $val) { $entry['rule'][] = array('disable' => !$canEdit || !$rightsmbox[$val], 'on' => $rule[$val], 'val' => $val); } $cval[] = $entry; } $view->curr_acl = $cval; } $current_users = array_keys($curr_acl); $new_user = array(); try { $auth_imap = $injector->getInstance('IMP_AuthImap'); foreach (array('anyone') + $auth_imap->listUsers() as $user) { if (!in_array($user, $current_users)) { $new_user[] = htmlspecialchars($user); } } $view->new_user = $new_user; } catch (IMP_Exception $e) { /* Ignore - admin user is not available. */ } catch (Horde_Exception $e) { $notification->push('Could not authenticate as admin user to obtain ACLs. Perhaps your admin configuration is incorrect in config/backends.local.php?', 'horde.warning'); } $rights = array(); foreach ($rightslist as $key => $val) { $val['val'] = $key; $rights[] = $val; } $view->rights = $rights; $view->width = round(100 / (count($rights) + 2)) . '%'; return $view->render('acl'); }
/** * Empties the entire mailbox. */ public function emptyMailbox() { global $notification, $prefs; if (!$this->access_empty) { $notification->push(sprintf(_("Could not delete messages from %s. This mailbox is read-only."), $this->display), 'horde.error'); return; } if ($this->vtrash) { foreach (IMP_Mailbox::get($this->getSearchOb()->mboxes) as $val) { $val->expunge(); } $notification->push(_("Emptied all messages from Virtual Trash Folder."), 'horde.success'); return; } /* Make sure there is at least 1 message before attempting to * delete. */ try { $imp_imap = $this->imp_imap; $status = $imp_imap->status($this, Horde_Imap_Client::STATUS_MESSAGES); if (empty($status['messages'])) { $notification->push(sprintf(_("The mailbox %s is already empty."), $this->display), 'horde.message'); return; } $trash = $prefs->getValue('use_trash') ? IMP_Mailbox::getPref(IMP_Mailbox::MBOX_TRASH) : null; if (!$trash || $trash == $this) { $imp_imap->store($this, array('add' => array(Horde_Imap_Client::FLAG_DELETED))); $this->expunge(); } else { $ret = $imp_imap->search($this); $this->getIndicesOb($ret['match'])->delete(); } $notification->push(sprintf(_("Emptied all messages from %s."), $this->display), 'horde.success'); } catch (IMP_Imap_Exception $e) { } }
/** * Returns the initial page for IMP. * * @return object Object with the following properties: * <pre> * - mbox (IMP_Mailbox) * - url (Horde_Url) * </pre> */ public static function getInitialPage() { global $injector, $prefs, $registry; $init_url = $prefs->getValue('initial_page'); if (!$init_url || !$injector->getInstance('IMP_Factory_Imap')->create()->access(IMP_Imap::ACCESS_FOLDERS)) { $init_url = 'INBOX'; } if ($init_url == IMP::INITIAL_FOLDERS) { $mbox = null; } else { $mbox = IMP_Mailbox::get($init_url); if (!$mbox->exists) { $mbox = IMP_Mailbox::get('INBOX'); } } $result = new stdClass(); $result->mbox = $mbox; switch ($registry->getView()) { case Horde_Registry::VIEW_BASIC: $result->url = is_null($mbox) ? IMP_Basic_Folders::url() : $mbox->url('mailbox'); break; case Horde_Registry::VIEW_DYNAMIC: $result->url = IMP_Dynamic_Mailbox::url(array('mailbox' => is_null($mbox) ? 'INBOX' : $mbox)); break; case Horde_Registry::VIEW_MINIMAL: $result->url = is_null($mbox) ? IMP_Minimal_Folders::url() : IMP_Minimal_Mailbox::url(array('mailbox' => $mbox)); break; case Horde_Registry::VIEW_SMARTMOBILE: $result->url = is_null($mbox) ? Horde::url('smartmobile.php', true) : $mbox->url('mailbox'); break; } return $result; }
/** * Returns the thread object for a mailbox. * * @param string $mbox The mailbox. * @param array $extra Extra options to pass to IMAP thread() command. * * @return Horde_Imap_Client_Data_Thread Thread object. */ protected function _getThread($mbox, array $extra = array()) { if (!isset($this->_thread[strval($mbox)])) { $imp_imap = IMP_Mailbox::get($mbox)->imp_imap; try { $thread = $imp_imap->thread($mbox, array_merge($extra, array('criteria' => $imp_imap->thread_algo))); } catch (Horde_Imap_Client_Exception $e) { $thread = new Horde_Imap_Client_Data_Thread(array(), 'uid'); } $this->_thread[strval($mbox)] = $thread; } return $this->_thread[strval($mbox)]; }
/** * URL Parameters: * <pre> * - criteria_form: (string) JSON representation of the search query. * - edit_query: (integer) If true, edit a search query (contained in * 'mailbox' parameter). * - edit_query_filter: (string) The name of the filter being edited. * - edit_query_vfolder: (string) The name of the virtual folder being * edited. * - mailbox: (string) Mailbox parameter. * - mailbox_list: (array) A list of mailboxes to process (base64url * encoded) If empty, uses 'mailbox' parameter. * - mboxes_form: (string) JSON representation of the list of mailboxes * for the query. Hash containing 2 keys: mbox & * subfolder. Both values are base64url encoded. * - search_label: (string) The label to use when saving the search. * - search_type: (string) The type of saved search ('filter', * 'vfolder'). If empty, the search should not be saved. * - subfolder: (boolean) If set, search mailbox will default to * subfolder search. * </pre> */ protected function _init() { global $injector, $notification, $page_output, $prefs, $registry; /* Define the criteria list. */ $criteria = array('from' => array('label' => _("From"), 'type' => 'header'), 'recip' => array('label' => _("Recipients (To/Cc/Bcc)"), 'type' => 'header'), 'to' => array('label' => _("To"), 'type' => 'header'), 'cc' => array('label' => _("Cc"), 'type' => 'header'), 'bcc' => array('label' => _("Bcc"), 'type' => 'header'), 'subject' => array('label' => _("Subject"), 'type' => 'header'), 'customhdr' => array('label' => _("Custom Header"), 'type' => 'customhdr'), 'body' => array('label' => _("Body"), 'type' => 'text'), 'text' => array('label' => _("Entire Message"), 'type' => 'text'), 'date_range' => array('label' => _("Date"), 'type' => 'date'), 'older' => array('label' => _("Older Than"), 'type' => 'within'), 'younger' => array('label' => _("Younger Than"), 'type' => 'within'), 'size_smaller' => array('label' => _("Size (KB) <"), 'type' => 'size'), 'size_larger' => array('label' => _("Size (KB) >"), 'type' => 'size')); $filters = array('bulk' => array('label' => _("Bulk Messages"), 'type' => 'filter'), 'attach' => array('label' => _("Contains Attachment(s)"), 'type' => 'filter'), 'mailinglist' => array('label' => _("Mailing List Messages"), 'type' => 'filter'), 'personal' => array('label' => _("Personal Messages"), 'type' => 'filter')); /* Define some constants. */ $constants = array('within' => array('d' => IMP_Search_Element_Within::INTERVAL_DAYS, 'm' => IMP_Search_Element_Within::INTERVAL_MONTHS, 'y' => IMP_Search_Element_Within::INTERVAL_YEARS)); if (isset($this->vars->mailbox_list)) { if (is_array($this->vars->mailbox_list)) { $default_mailbox = IMP_Mailbox::get('INBOX'); $search_mailbox = IMP_Mailbox::formFrom($this->vars->mailbox_list); } else { $default_mailbox = IMP_Mailbox::formFrom($this->vars->mailbox_list); $search_mailbox = array($default_mailbox); } } elseif (isset($this->vars->mailbox)) { $default_mailbox = IMP_Mailbox::formFrom($this->vars->mailbox); $search_mailbox = array($default_mailbox); } else { $default_mailbox = IMP_Mailbox::get('INBOX'); $search_mailbox = array($default_mailbox); } /* Check that searching is allowed. */ if (!$injector->getInstance('IMP_Factory_Imap')->create()->access(IMP_Imap::ACCESS_SEARCH)) { $default_mailbox->url('mailbox')->redirect(); } $imp_flags = $injector->getInstance('IMP_Flags'); $imp_search = $injector->getInstance('IMP_Search'); $dynamic_view = $registry->getView() == Horde_Registry::VIEW_DYNAMIC; $js_vars = array(); /* Generate the search query if 'criteria_form' is present in the form * data. */ if ($this->vars->criteria_form) { $c_list = array(); foreach (json_decode($this->vars->criteria_form) as $val) { switch ($val->t) { case 'from': case 'to': case 'cc': case 'bcc': case 'subject': $c_list[] = new IMP_Search_Element_Header($val->v, $val->t, $val->n); break; case 'recip': $c_list[] = new IMP_Search_Element_Recipient($val->v, $val->n); break; case 'customhdr': $c_list[] = new IMP_Search_Element_Header($val->v->s, $val->v->h, $val->n); break; case 'body': case 'text': $c_list[] = new IMP_Search_Element_Text($val->v, $val->t == 'body', $val->n); break; case 'date_range': $c_list[] = new IMP_Search_Element_Daterange($val->b ? new DateTime($val->b) : 0, $val->e ? new DateTime($val->e) : 0, $val->n); break; case 'older': case 'younger': $c_list[] = new IMP_Search_Element_Within($val->v->v, $constants['within'][$val->v->l], $val->t == 'older'); break; case 'size_smaller': case 'size_larger': $c_list[] = new IMP_Search_Element_Size($val->v, $val->t == 'size_larger'); break; case 'or': $c_list[] = new IMP_Search_Element_Or(); break; case 'bulk': $c_list[] = new IMP_Search_Element_Bulk($val->n); break; case 'attach': $c_list[] = new IMP_Search_Element_Attachment($val->n); break; case 'mailinglist': $c_list[] = new IMP_Search_Element_Mailinglist($val->n); break; case 'personal': $c_list[] = new IMP_Search_Element_Personal($val->n); break; case 'flag': /* Flag search. */ $formdata = $imp_flags->parseFormId(rawurldecode($val->v)); $c_list[] = new IMP_Search_Element_Flag($formdata['flag'], $formdata['set'] && !$val->n); break; } } $redirect_dynamic = true; $redirect_target = false; switch ($this->vars->search_type) { case 'filter': $q_ob = $imp_search->createQuery($c_list, array('id' => IMP_Mailbox::formFrom($this->vars->edit_query_filter), 'label' => $this->vars->search_label, 'type' => IMP_Search::CREATE_FILTER)); if ($this->vars->edit_query_filter) { $notification->push(sprintf(_("Filter \"%s\" edited successfully."), $this->vars->search_label), 'horde.success'); $redirect_dynamic = false; $redirect_target = 'prefs'; } else { $notification->push(sprintf(_("Filter \"%s\" created succesfully."), $this->vars->search_label), 'horde.success'); } break; case 'vfolder': $form = json_decode($this->vars->mboxes_form); $q_ob = $imp_search->createQuery($c_list, array('id' => IMP_Mailbox::formFrom($this->vars->edit_query_vfolder), 'label' => $this->vars->search_label, 'mboxes' => IMP_Mailbox::formFrom($form->mbox), 'subfolders' => IMP_Mailbox::formFrom($form->subfolder), 'type' => IMP_Search::CREATE_VFOLDER)); if ($this->vars->edit_query_vfolder) { $notification->push(sprintf(_("Virtual Folder \"%s\" edited successfully."), $this->vars->search_label), 'horde.success'); $redirect_target = 'prefs'; } else { $notification->push(sprintf(_("Virtual Folder \"%s\" created succesfully."), $this->vars->search_label), 'horde.success'); $redirect_target = 'mailbox'; } break; default: $form = json_decode($this->vars->mboxes_form); $q_ob = $imp_search->createQuery($c_list, array('mboxes' => IMP_Mailbox::formFrom($form->mbox), 'subfolders' => IMP_Mailbox::formFrom($form->subfolder))); $redirect_target = 'mailbox'; break; } /* Redirect to the mailbox page. */ if ($redirect_target) { if ($dynamic_view && $redirect_dynamic) { echo '<html><head>' . Horde::wrapInlineScript(array('window.parent.DimpBase.go("mbox", "' . $q_ob->mbox_ob->form_to . '")')) . '</head></html>'; exit; } switch ($redirect_target) { case 'mailbox': $q_ob->mbox_ob->url('mailbox')->redirect(); break; case 'prefs': $registry->getServiceLink('prefs', 'imp')->add('group', 'searches')->redirect(); break; } exit; } } /* Prepare the search view. */ $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/search')); $view->addHelper('Text'); $view->addHelper('Tag'); $view->addHelper('FormTag'); $view->action = self::url(); /* Determine if we are editing a search query. */ $q_ob = $default_mailbox->getSearchOb(); if ($this->vars->edit_query && $default_mailbox->search) { if ($default_mailbox->vfolder) { if (!$default_mailbox->editvfolder) { $notification->push(_("Built-in Virtual Folders cannot be edited."), 'horde.error'); $registry->getServiceLink('prefs', 'imp')->add('group', 'searches')->redirect(); } $view->edit_query = true; $view->edit_query_vfolder = $default_mailbox->form_to; } elseif ($imp_search->isFilter($q_ob)) { if (!$imp_search->isFilter($q_ob, true)) { $notification->push(_("Built-in Filters cannot be edited."), 'horde.error'); $registry->getServiceLink('prefs', 'imp')->add('group', 'searches')->redirect(); } $view->edit_query = true; $view->edit_query_filter = $default_mailbox->form_to; } if ($view->edit_query) { $view->search_label = $q_ob->label; $js_vars['ImpSearch.prefsurl'] = strval($registry->getServiceLink('prefs', 'imp')->add('group', 'searches')->setRaw(true)); } } else { /* Process list of recent searches. */ $iterator = IMP_Search_IteratorFilter::create(IMP_Search_IteratorFilter::QUERY); $rs = array(); foreach ($iterator as $val) { $rs[$val->formid] = array('c' => $val->criteria, 'f' => array('m' => IMP_Mailbox::formTo($val->all ? array(IMP_Search_Query::ALLSEARCH) : array_map('strval', $val->mbox_list)), 's' => IMP_Mailbox::formTo(array_map('strval', $val->subfolder_list))), 'l' => Horde_String::truncate($val->querytext)); } if (!empty($rs)) { $js_vars['ImpSearch.i_recent'] = $rs; } $s_mboxes = IMP_Mailbox::formTo($search_mailbox); $js_vars['ImpSearch.i_mboxes'] = array('m' => $this->vars->subfolder ? array() : $s_mboxes, 's' => $this->vars->subfolder ? $s_mboxes : array()); } if ($default_mailbox->search) { $js_vars['ImpSearch.i_criteria'] = $q_ob->criteria; $js_vars['ImpSearch.i_mboxes'] = array('m' => IMP_Mailbox::formTo($q_ob->all ? array(IMP_Search_Query::ALLSEARCH) : $q_ob->mbox_list), 's' => IMP_Mailbox::formTo($q_ob->subfolder_list)); } /* Create the criteria list. */ $c_list = $types = array(); foreach ($criteria as $key => $val) { $c_list[] = array('l' => $val['label'], 'v' => $key); $types[$key] = $val['type']; } $view->clist = $c_list; /* Create the filter list. These are all-or-nothing searches. */ $f_list = array(); foreach ($filters as $key => $val) { $f_list[] = array('l' => $val['label'], 'v' => $key); $types[$key] = 'filter'; } $view->filterlist = $f_list; /* Create the flag list. */ $flist = $imp_flags->getList(array('imap' => true, 'mailbox' => $default_mailbox)); $flag_set = array(); foreach ($flist as $val) { $flag_set[] = array('l' => $val->label, 'v' => rawurlencode($val->form_set)); $types[rawurlencode($val->form_set)] = 'flag'; } $view->flist = $flag_set; /* Generate master mailbox list. */ $mbox_list = array(); if (!$view->edit_query_filter) { $js_vars['ImpSearch.allsearch'] = IMP_Mailbox::formTo(IMP_Search_Query::ALLSEARCH); $ob = $injector->getInstance('IMP_Search_Ui')->getSearchMboxList(); $mbox_list = $ob->mbox_list; $view->subscribe = $prefs->getValue('subscribe'); $view->tree = $ob->tree->getTree(); } /* Prepare the topbar. */ if (!$dynamic_view) { $injector->getInstance('Horde_View_Topbar')->subinfo = $injector->getInstance('IMP_View_Subinfo')->render(); } Horde_Core_Ui_JsCalendar::init(); $page_output->addScriptFile('hordecore.js', 'horde'); $page_output->addScriptFile('horde.js', 'horde'); $page_output->addScriptFile('search.js'); $page_output->addInlineJsVars(array_merge($js_vars, array('ImpSearch.data' => array('constants' => $constants, 'dynamic_view' => $dynamic_view, 'inbox' => IMP_Mailbox::get('INBOX')->form_to, 'mbox_list' => $mbox_list, 'months' => Horde_Core_Ui_JsCalendar::months(), 'searchmbox' => $default_mailbox->form_to, 'types' => $types), 'ImpSearch.text' => array('and' => _("and"), 'customhdr' => _("Custom Header:"), 'datereset' => _("Date Reset"), 'dateselection' => _("Date Selection"), 'flag' => _("Flag:"), 'loading' => _("Loading..."), 'need_criteria' => _("Please select at least one search criteria."), 'need_date' => _("Need at least one date in the date range search."), 'need_mbox' => _("Please select at least one mailbox to search."), 'need_label' => _("Saved searches require a label."), 'not_match' => _("Do NOT Match"), 'or' => _("OR"), 'search_all' => _("Search All Mailboxes"), 'search_term' => _("Search Term:"), 'subfolder_search' => _("Search all subfolders?"), 'to' => _("to")))), array('onload' => true)); if ($dynamic_view) { if (!$this->vars->edit_query) { $view->return_mailbox_val = sprintf(_("Return to %s"), $default_mailbox->display_html); } $page_output->topbar = $page_output->sidebar = false; $this->header_params = array('html_id' => 'htmlAllowScroll'); } $this->title = _("Search"); $this->output = $view->render('search'); }
/** * Return whether the mailbox exists. * * @param string $mbox Mailbox. * * @return boolean True if mailbox exists. */ public function exists($mbox) { $s_mbox = strval($mbox); if (!isset($this->_temp[$s_mbox][self::CACHE_EXISTS])) { $mbox = IMP_Mailbox::get($mbox); if ($mbox->search) { $exists = ($ob = $mbox->getSearchOb()) && $ob->enabled; } elseif ($elt = $mbox->tree_elt) { $exists = !$elt->container; } else { try { $mbox_list = $mbox->imp_imap->listMailboxes($mbox->imap_mbox_ob, null, array('attributes' => true)); $exists = isset($mbox_list[strval($mbox)]) && !in_array('\\noselect', $mbox_list[strval($mbox)]['attributes']); } catch (IMP_Imap_Exception $e) { $exists = false; } } $this->_temp[$s_mbox][self::CACHE_EXISTS] = $exists; } return $this->_temp[$s_mbox][self::CACHE_EXISTS]; }
/** * Return the raw list of flags. * * @param array $opts Additional options: * - imap: (boolean) If true, only return IMAP flags that can be set by * the user. * DEFAULT: false * - mailbox: (string) A real (not virtual) IMAP mailbox. If set, will * determine what flags are available in the mailbox. * DEFAULT: '' (no mailbox check) * * @return array An array of IMP_Flag_Base elements. */ public function getList(array $opts = array()) { if (!$GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->access(IMP_Imap::ACCESS_FLAGS)) { return array(); } $ret = array_merge($this->_flags, $this->_userflags); if (!empty($opts['imap'])) { foreach ($ret as $key => $val) { if (!$val instanceof IMP_Flag_Imap) { unset($ret[$key]); } } } if (!isset($opts['mailbox']) || !strlen($opts['mailbox']) || IMP_Mailbox::get($opts['mailbox'])->search) { return array_values($ret); } /* Alter the list of flags for a mailbox depending on the mailbox's * PERMANENTFLAGS status. */ $permflags = IMP_Mailbox::get($opts['mailbox'])->permflags; /* Limited flags allowed in mailbox. */ foreach ($ret as $key => $val) { if ($val instanceof IMP_Flag_Imap && !$permflags->allowed($val->imapflag)) { unset($ret[$key]); } } /* Get list of unknown flags. */ if ($GLOBALS['prefs']->getValue('show_all_flags')) { /* Get list of IMAP flags. */ $imapflags = array(); foreach ($ret as $val) { if ($val instanceof IMP_Flag_Imap) { $imapflags[] = $val->imapflag; } } foreach ($permflags as $val) { if (!in_array($val, $imapflags)) { $ret[] = new IMP_Flag_User($val); } } } return array_values($ret); }
/** * Add poll entry to response queue. * * @param mixed $mboxes A mailbox name or list of mailbox names. * @param boolean $explicit If true, explicitly output poll information. * Otherwise, add only if not disabled. */ public function poll($mboxes, $explicit = false) { if (is_null($this->_poll)) { if (!$explicit) { return; } $this->_poll = array(); } elseif (empty($this->_poll) && is_null($mboxes)) { $this->_poll = null; return; } if (!is_array($mboxes)) { $mboxes = array($mboxes); } foreach (IMP_Mailbox::get($mboxes) as $val) { if ($val->polled) { $this->_poll[] = $val; } } }
/** * As of IMP 6, special mailboxes are stored in UTF-8, not UTF7-IMAP. */ protected function _upgradeMailboxPrefs() { global $injector, $prefs; $special_mboxes = array('drafts_folder', 'spam_folder', 'trash_folder'); foreach ($special_mboxes as $val) { if (!$prefs->isDefault($val)) { $old_pref = strval(IMP_Mailbox::getPref($val)); if (!Horde_Mime::is8bit($old_pref, 'UTF-8')) { $mbox = IMP_Mailbox::get(Horde_String::convertCharset($old_pref, 'UTF7-IMAP', 'UTF-8')); $prefs->setValue($val, $old_pref->{$mbox}->pref_to); } } } $imp_identity = $injector->getInstance('IMP_Identity'); foreach ($imp_identity->getAll('sent_mail_folder') as $key => $val) { if (!is_null($val) && !Horde_Mime::is8bit($val, 'UTF-8')) { $mbox = IMP_Mailbox::get(Horde_String::convertCharset(strval($val), 'UTF7-IMAP', 'UTF-8')); $imp_identity->setValue(IMP_Mailbox::MBOX_SENT, $mbox, $key); } } }
/** */ public function resolveBuid($buid) { if (!isset($this->_buids[$buid])) { return null; } $pos = strrpos($this->_buids[$buid], self::IDX_SEP); return array('m' => IMP_Mailbox::get(substr($this->_buids[$buid], 0, $pos)), 'u' => intval(substr($this->_buids[$buid], $pos + 1))); }
/** * @param array $opts Options: * - buid: (string) BUID of message. * - mailbox: (string) Mailbox of message. */ public static function url(array $opts = array()) { return IMP_Mailbox::get($opts['mailbox'])->url('minimal', $opts['buid'])->add('page', 'message'); }
/** * Returns a property from one of the identities. * * @see getValue() */ public function getValue($key, $identity = null) { $val = parent::getValue($key, $identity); switch ($key) { case IMP_Mailbox::MBOX_SENT: return is_string($val) && strlen($val) ? IMP_Mailbox::get(IMP_Mailbox::prefFrom($val)) : null; default: return $val; } }
/** * @param array $opts Options: * - mailbox: (string) The mailbox to link to. */ public static function url(array $opts = array()) { $opts = array_merge(array('mailbox' => 'INBOX'), $opts); return IMP_Mailbox::get($opts['mailbox'])->url('basic')->add('page', 'mailbox'); }
public function current() { if (!$this->valid()) { return null; } $ret = new stdClass(); $ret->mbox = IMP_Mailbox::get($this->key()); $ret->uids = current($this->_indices); return $ret; }
/** */ protected function _notify(Horde_Notification_Handler $handler, Horde_Notification_Listener $listener) { global $injector, $prefs, $session; if (!$prefs->getValue('newmail_notify') || !$listener instanceof Horde_Notification_Listener_Status) { return; } /* Rate limit. If rate limit is not yet set, this is the initial * login so skip. */ $curr = time(); $ratelimit = $session->get('imp', self::SESS_RATELIMIT); if ($ratelimit && $ratelimit + self::RATELIMIT > $curr) { return; } $session->set('imp', self::SESS_RATELIMIT, $curr); if (!$ratelimit) { return; } $ajax_queue = $injector->getInstance('IMP_Ajax_Queue'); $imp_imap = $injector->getInstance('IMP_Factory_Imap')->create(); $recent = array(); try { foreach ($imp_imap->status($injector->getInstance('IMP_Ftree')->poll->getPollList(), Horde_Imap_Client::STATUS_RECENT_TOTAL, array('sort' => true)) as $key => $val) { if (!empty($val['recent_total'])) { /* Open the mailbox R/W so we ensure the 'recent' flag is * cleared. */ $imp_imap->openMailbox($key, Horde_Imap_Client::OPEN_READWRITE); $mbox = IMP_Mailbox::get($key); $recent[$mbox->display] = $val['recent_total']; $ajax_queue->poll($mbox); } } } catch (Exception $e) { } if (empty($recent)) { return; } $recent_sum = array_sum($recent); reset($recent); switch (count($recent)) { case 1: $mbox_list = key($recent); break; case 2: $mbox_list = implode(_(" and "), array_keys($recent)); break; default: $akeys = array_keys($recent); $mbox_list = $akeys[0] . ', ' . $akeys[1] . ', ' . _("and") . ' ' . $akeys[2]; if ($addl_mbox = count($recent) - 3) { $mbox_list .= ' (' . sprintf(ngettext("and %d more mailbox", "and %d more mailboxes", $addl_mbox), $addl_mbox) . ')'; } break; } $text = sprintf(ngettext("You have %d new mail message in %s.", "You have %d new mail messages in %s.", $recent_sum), $recent_sum, $mbox_list); /* Status notification. */ $handler->push($text, 'horde.message'); /* Web notifications. */ $handler->attach('webnotification', null, 'Horde_Core_Notification_Listener_Webnotification'); $handler->push(Horde_Core_Notification_Event_Webnotification::createEvent($text, array('icon' => strval(Horde_Themes::img('unseen.png')))), 'webnotification'); if ($audio = $prefs->getValue('newmail_audio')) { $handler->attach('audio'); $handler->push(Horde_Themes::sound($audio), 'audio'); } }
/** * Returns the appropriate link to call the message composition script. * * @param string $simplejs Use simple JS (instead of HordePopup JS)? * * @return Horde_Url The link to the message composition script. */ public function link($simplejs = false) { global $browser, $prefs, $registry; $args = $this->args; $callback = $raw = false; $view = $registry->getView(); if ($view == Horde_Registry::VIEW_SMARTMOBILE) { $url = new Horde_Core_Smartmobile_Url(Horde::url('smartmobile.php')); $url->setAnchor('compose'); } elseif ($simplejs || $view == Horde_Registry::VIEW_DYNAMIC) { $args['popup'] = 1; $url = $view == Horde_Registry::VIEW_DYNAMIC ? IMP_Dynamic_Compose::url() : IMP_Basic_Compose::url(); $raw = true; $callback = array($this, 'composeLinkSimpleCallback'); } elseif ($view != Horde_Registry::VIEW_MINIMAL && $prefs->getValue('compose_popup') && $browser->hasFeature('javascript')) { $url = IMP_Basic_Compose::url(); $callback = array($this, 'composeLinkJsCallback'); } else { $url = $view == Horde_Registry::VIEW_MINIMAL ? IMP_Minimal_Compose::url() : IMP_Basic_Compose::url(); } if (isset($args['mailbox'])) { $url = IMP_Mailbox::get($args['mailbox'])->url($url, $args['buid']); unset($args['buid'], $args['mailbox']); } elseif (!$url instanceof Horde_Url) { $url = Horde::url($url); } $url->setRaw($raw)->add($args); if ($callback) { $url->toStringCallback = $callback; } return $url; }
/** */ public function __get($name) { switch ($name) { case 'account': return $this->_tree->getAccount($this->_id); case 'base_elt': return $this->_id == IMP_Ftree::BASE_ELT; case 'child_list': return $this->_tree->getChildren($this->_id); case 'inbox': return $this->_id == 'INBOX'; case 'level': if ($this->base_elt) { return 0; } $i = substr_count($this->_id, $this->namespace_info->delimiter); $elt = $this; while ($elt = $elt->parent) { if ($elt->namespace) { return $i + 1; } elseif ($elt->remote) { if ($this->remote_mbox) { ++$i; } return $i + 1; } } return $i; case 'mbox_ob': return IMP_Mailbox::get($this->_id); case 'namespace': return $this->namespace_other || $this->namespace_shared; case 'namespace_info': return $this->mbox_ob->imp_imap->getNamespace($this->_id); case 'parent': return $this->_tree->getParent($this->_id); default: return $this->_tree->getAttribute($name, $this->_id); } }