IMP_Indices::getSingle PHP Method

getSingle() public method

Returns mailbox/UID information for the first index.
public getSingle ( $all = false ) : array
return array $all If true, returns all UIDs for the first index in an array. If false, returns the first UID for the first index as a string.
    public function getSingle($all = false)
    {
        $val = reset($this->_indices);
        return array(IMP_Mailbox::get(key($this->_indices)), $all ? $val : (is_array($val) ? reset($val) : null));
    }

Usage Example

示例#1
0
文件: Ui.php 项目: DSNS-LAB/Dmail
 /**
  * Check if we need to send a MDN, and send if needed.
  *
  * @param IMP_Indices $indices         Indices object of the message.
  * @param Horde_Mime_Headers $headers  The headers of the message.
  * @param boolean $confirmed           Has the MDN request been confirmed?
  *
  * @return boolean  True if the MDN request needs to be confirmed.
  */
 public function MDNCheck(IMP_Indices $indices, $headers, $confirmed = false)
 {
     global $conf, $injector, $prefs;
     $maillog = $injector->getInstance('IMP_Maillog');
     $pref_val = $prefs->getValue('send_mdn');
     list($mbox, ) = $indices->getSingle();
     if (!$pref_val || $mbox->readonly) {
         return false;
     }
     /* Check to see if an MDN has been requested. */
     $mdn = new Horde_Mime_Mdn($headers);
     if (!($return_addr = $mdn->getMdnReturnAddr())) {
         return false;
     }
     $log_msg = new IMP_Maillog_Message($indices);
     if (count($maillog->getLog($log_msg, array('forward', 'redirect', 'reply_all', 'reply_list', 'reply')))) {
         return false;
     }
     /* See if we need to query the user. */
     if (!$confirmed && (intval($pref_val) == 1 || $mdn->userConfirmationNeeded())) {
         try {
             if ($injector->getInstance('Horde_Core_Hooks')->callHook('mdn_check', 'imp', array($headers))) {
                 return true;
             }
         } catch (Horde_Exception_HookNotSet $e) {
             return true;
         }
     }
     /* Send out the MDN now. */
     $success = false;
     try {
         $mdn->generate(false, $confirmed, 'displayed', $conf['server']['name'], $injector->getInstance('IMP_Mail'), array('charset' => 'UTF-8', 'from_addr' => $injector->getInstance('Horde_Core_Factory_Identity')->create()->getDefaultFromAddress()));
         $maillog->log($log_msg, new IMP_Maillog_Log_Mdn());
         $success = true;
     } catch (Exception $e) {
     }
     $injector->getInstance('IMP_Sentmail')->log(IMP_Sentmail::MDN, '', $return_addr, $success);
     return false;
 }
All Usage Examples Of IMP_Indices::getSingle