本文整理汇总了PHP中Horde_Imap_Client_Fetch_Query::structure方法的典型用法代码示例。如果您正苦于以下问题:PHP Horde_Imap_Client_Fetch_Query::structure方法的具体用法?PHP Horde_Imap_Client_Fetch_Query::structure怎么用?PHP Horde_Imap_Client_Fetch_Query::structure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Horde_Imap_Client_Fetch_Query
的用法示例。
在下文中一共展示了Horde_Imap_Client_Fetch_Query::structure方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchCallback
/**
*/
public function searchCallback(IMP_Mailbox $mbox, array $ids)
{
$fetch_query = new Horde_Imap_Client_Fetch_Query();
$fetch_query->structure();
$fetch_res = $mbox->imp_imap->fetch($mbox, $fetch_query, array('ids' => $mbox->imp_imap->getIdsOb($ids)));
$out = array();
foreach ($ids as $v) {
if (isset($fetch_res[$v])) {
$atc = false;
foreach ($fetch_res[$v]->getStructure()->partIterator() as $val) {
if ($val->isAttachment()) {
$atc = true;
break;
}
}
if ($this->_data && $atc || !$this->_data && !$atc) {
continue;
}
}
$out[] = $v;
}
return $out;
}
示例2: _getMailMessages
/**
*
* @param Horde_Imap_Client_Mailbox $mbox The mailbox
* @param array $uids An array of message uids
* @param array $options An options array
* - headers: (boolean) Fetch header text if true.
* DEFAULT: false (Do not fetch header text).
* - structure: (boolean) Fetch message structure.
* DEFAULT: true (Fetch message structure).
* - flags: (boolean) Fetch messagge flags.
* DEFAULT: true (Fetch message flags).
* - envelope: (boolen) Fetch the envelope data.
* DEFAULT: false (Do not fetch envelope). @since 2.4.0
*
* @return Horde_Imap_Fetch_Results The results.
* @throws Horde_ActiveSync_Exception
*/
protected function _getMailMessages(Horde_Imap_Client_Mailbox $mbox, array $uids, array $options = array())
{
$options = array_merge(array('headers' => false, 'structure' => true, 'flags' => true, 'envelope' => false), $options);
$query = new Horde_Imap_Client_Fetch_Query();
if ($options['structure']) {
$query->structure();
}
if ($options['flags']) {
$query->flags();
}
if ($options['envelope']) {
$query->envelope();
}
if (!empty($options['headers'])) {
$query->headerText(array('peek' => true));
}
try {
return $this->_getImapOb()->fetch($mbox, $query, array('ids' => new Horde_Imap_Client_Ids($uids), 'exists' => true));
} catch (Horde_Imap_Client_Exception $e) {
$this->_logger->err(sprintf('[%s] Unable to fetch message: %s', $this->_procid, $e->getMessage()));
throw new Horde_ActiveSync_Exception($e);
}
}
示例3: __construct
/**
* Constructor.
*
* @param mixed $in An IMP_Indices_Mailbox or Horde_Mime_Part object.
*
* @throws IMP_Exception
*/
public function __construct($in)
{
if ($in instanceof Horde_Mime_Part) {
$this->_message = $in;
} else {
$this->_indices = $in;
/* Get the Horde_Mime_Part object for the given UID. */
$query = new Horde_Imap_Client_Fetch_Query();
$query->structure();
if (!($ret = $this->_fetchData($query))) {
$e = new IMP_Exception(_("Error displaying message: message does not exist on server."));
$e->setLogLevel('NOTICE');
throw $e;
}
$this->_message = $ret->getStructure();
}
}
示例4: fetchBodypart
/**
* Retrieves a bodypart for the given message ID and mime part ID.
*
* @param string $folder The folder to fetch the messages from.
* @param array $uid The message UID.
* @param array $id The mime part ID.
*
* @return resource The body part, as a stream resource.
*/
public function fetchBodypart($folder, $uid, $id)
{
$query = new Horde_Imap_Client_Fetch_Query();
$query->structure();
$query->bodyPart($id, array('decode' => true));
try {
$ret = $this->getBackend()->fetch($folder, $query, array('ids' => new Horde_Imap_Client_Ids($uid)));
$part = $ret[$uid]->getStructure()->getPart($id);
$part->setContents($ret[$uid]->getBodyPart($id, true), array('encoding' => $ret[$uid]->getBodyPartDecode($id), 'usestream' => true));
return $part->getContents(array('stream' => true));
} catch (Horde_Imap_Client_Exception_ServerResponse $e) {
throw new Horde_Kolab_Storage_Exception($e->details);
} catch (Horde_Imap_Client_Exception $e) {
throw new Horde_Kolab_Storage_Exception($e);
}
}
示例5: message_has_flag
/**
* Check whether the message has the specified flag
*
* @param mixed $messageid
* @param string $flag The flag to check
* @return bool
*/
private function message_has_flag($messageid, $flag)
{
// Get the current mailbox.
$mailbox = $this->get_mailbox();
// Grab messagedata including flags.
$query = new \Horde_Imap_Client_Fetch_Query();
$query->flags();
$query->structure();
$messagedata = $this->client->fetch($mailbox, $query, array('ids' => $messageid))->first();
$flags = $messagedata->getFlags();
return in_array($flag, $flags);
}
示例6: getMessages
public function getMessages($from = 0, $count = 2, $filter = '')
{
if ($filter instanceof Horde_Imap_Client_Search_Query) {
$query = $filter;
} else {
$query = new Horde_Imap_Client_Search_Query();
if ($filter) {
$query->text($filter, false);
}
}
if ($this->getSpecialRole() !== 'trash') {
$query->flag(Horde_Imap_Client::FLAG_DELETED, false);
}
$result = $this->conn->search($this->mailBox, $query, ['sort' => [Horde_Imap_Client::SORT_DATE]]);
$ids = array_reverse($result['match']->ids);
if ($from >= 0 && $count >= 0) {
$ids = array_slice($ids, $from, $count);
}
$ids = new \Horde_Imap_Client_Ids($ids, false);
$headers = [];
$fetch_query = new \Horde_Imap_Client_Fetch_Query();
$fetch_query->envelope();
$fetch_query->flags();
$fetch_query->size();
$fetch_query->uid();
$fetch_query->imapDate();
$fetch_query->structure();
$headers = array_merge($headers, ['importance', 'list-post', 'x-priority']);
$headers[] = 'content-type';
$fetch_query->headers('imp', $headers, ['cache' => true, 'peek' => true]);
$options = ['ids' => $ids];
// $list is an array of Horde_Imap_Client_Data_Fetch objects.
$headers = $this->conn->fetch($this->mailBox, $fetch_query, $options);
ob_start();
// fix for Horde warnings
$messages = [];
foreach ($headers->ids() as $message_id) {
$header = $headers[$message_id];
$message = new Message($this->conn, $this->mailBox, $message_id, $header);
$messages[] = $message->getListArray();
}
ob_get_clean();
// sort by time
usort($messages, function ($a, $b) {
return $a['dateInt'] < $b['dateInt'];
});
return $messages;
}
示例7: fetchbody
public function fetchbody($message_no, $partno)
{
$file = $this->getCacheFileName(__FUNCTION__, $message_no, $partno);
if ($this->cacheEnabled && file_exists($file)) {
return json_decode(file_get_contents($file));
} else {
$oQuery = new Horde_Imap_Client_Fetch_Query();
$oQuery->structure();
$oQuery->bodyPart($partno, array('decode' => true, 'peek' => true));
$oQuery->fullText(array('peek' => true));
$message = $this->imap_imp->fetch($this->currentFolder, $oQuery, array('ids' => new Horde_Imap_Client_Ids($message_no)));
$message = $message[$message_no];
$part = $message->getStructure();
$body = $part->getPart($partno);
$tmp = $message->getBodyPart($partno);
if (!$message->getBodyPartDecode($partno)) {
$body->setContents($tmp);
$tmp = $body->getContents();
}
if ($tmp) {
file_put_contents($file, json_encode($tmp));
}
return $tmp;
}
}
示例8: loadMessageBodies
private function loadMessageBodies()
{
$headers = array();
$fetch_query = new \Horde_Imap_Client_Fetch_Query();
$fetch_query->envelope();
$fetch_query->structure();
$fetch_query->flags();
$fetch_query->seq();
$fetch_query->size();
$fetch_query->uid();
$fetch_query->imapDate();
$headers = array_merge($headers, array('importance', 'list-post', 'x-priority'));
$headers[] = 'content-type';
$fetch_query->headers('imp', $headers, array('cache' => true, 'peek' => true));
// $list is an array of Horde_Imap_Client_Data_Fetch objects.
$ids = new \Horde_Imap_Client_Ids($this->message_id);
$headers = $this->conn->fetch($this->folder_id, $fetch_query, array('ids' => $ids));
$fetch = $headers[$this->message_id];
// set $this->fetch to get to, from ...
$this->fetch = $fetch;
// analyse the body part
$structure = $fetch->getStructure();
// debugging below
$structure_type = $structure->getPrimaryType();
if ($structure_type == 'multipart') {
$i = 1;
foreach ($structure->getParts() as $p) {
$this->getpart($p, $i++);
}
} else {
if ($structure->findBody() != null) {
// get the body from the server
$partId = $structure->findBody();
$this->queryBodyPart($partId);
}
}
}
示例9: testComplexFetch
/**
* @depends testOptimizedSearches
*/
public function testComplexFetch()
{
// Fetching message information from complex MIME message.
$complex_fetch = new Horde_Imap_Client_Fetch_Query();
$complex_fetch->fullText(array('length' => 100, 'peek' => true));
// Header of entire message
$complex_fetch->headerText(array('length' => 100, 'peek' => true));
// Header of message/rfc822 part
$complex_fetch->headerText(array('id' => 2, 'length' => 100, 'peek' => true));
// Body text of entire message
$complex_fetch->bodyText(array('length' => 100, 'peek' => true));
// Body text of message/rfc822 part
$complex_fetch->bodyText(array('id' => 2, 'length' => 100, 'peek' => true));
// MIME Header of multipart/alternative part
$complex_fetch->mimeHeader('1', array('length' => 100, 'peek' => true));
// MIME Header of text/plain part embedded in message/rfc822 part
$complex_fetch->mimeHeader('2.1', array('length' => 100, 'peek' => true));
// Body text of multipart/alternative part
$complex_fetch->bodyPart('1', array('length' => 100, 'peek' => true));
// Body text of image/png part embedded in message/rfc822 part
// Try to do server-side decoding, if available
$complex_fetch->mimeHeader('2.2', array('decode' => true, 'length' => 100, 'peek' => true));
// If supported, return decoded body part size
$complex_fetch->bodyPartSize('2.2');
// Select message-id header from base message header
$complex_fetch->headers('headersearch1', array('message-id'), array('length' => 100, 'peek' => true));
// Select everything but message-id header from message/rfc822 header
$complex_fetch->headers('headersearch2', array('message-id'), array('id' => '2', 'length' => 100, 'notsearch' => true, 'peek' => true));
$complex_fetch->structure();
$complex_fetch->flags();
$complex_fetch->imapDate();
$complex_fetch->size();
$complex_fetch->uid();
if (self::$live->capability->query('CONDSTORE')) {
$complex_fetch->modseq();
}
try {
$res = self::$live->fetch(self::$test_mbox, $complex_fetch, array('ids' => new Horde_Imap_Client_Ids(3, true)));
} catch (Horde_Imap_Client_Exception $e) {
if ($e->getCode() === $e::MBOXNOMODSEQ) {
$this->markTestSkipped('Mailbox does not support MODSEQ.');
}
throw $e;
}
$this->assertInstanceOf('Horde_Imap_Client_Fetch_Results', $res);
$this->assertEquals(1, count($res));
$this->assertEquals('Message-ID: <2008yhnujm@foo.example.com>', trim($res[3]->getHeaders('headersearch1')));
/* Return stream instead. */
$this->assertInternalType('resource', $res[3]->getHeaders('headersearch1', Horde_Imap_Client_Data_Fetch::HEADER_STREAM));
/* Parse headers instead. */
$this->assertInstanceOf('Horde_Mime_Headers', $res[3]->getHeaders('headersearch1', Horde_Imap_Client_Data_Fetch::HEADER_PARSE));
}
示例10: loadMessageBodies
private function loadMessageBodies()
{
$headers = [];
$fetch_query = new \Horde_Imap_Client_Fetch_Query();
$fetch_query->envelope();
$fetch_query->structure();
$fetch_query->flags();
$fetch_query->size();
$fetch_query->imapDate();
$headers = array_merge($headers, ['importance', 'list-post', 'x-priority']);
$headers[] = 'content-type';
$fetch_query->headers('imp', $headers, ['cache' => true, 'peek' => true]);
// $list is an array of Horde_Imap_Client_Data_Fetch objects.
$ids = new \Horde_Imap_Client_Ids($this->messageId);
$headers = $this->conn->fetch($this->mailBox, $fetch_query, ['ids' => $ids]);
/** @var $fetch \Horde_Imap_Client_Data_Fetch */
$fetch = $headers[$this->messageId];
if (is_null($fetch)) {
throw new DoesNotExistException("This email ({$this->messageId}) can't be found. Probably it was deleted from the server recently. Please reload.");
}
// set $this->fetch to get to, from ...
$this->fetch = $fetch;
// analyse the body part
$structure = $fetch->getStructure();
// debugging below
$structure_type = $structure->getPrimaryType();
if ($structure_type == 'multipart') {
$i = 1;
foreach ($structure->getParts() as $p) {
$this->getPart($p, $i++);
}
} else {
if ($structure->findBody() != null) {
// get the body from the server
$partId = $structure->findBody();
$this->getPart($structure->getPart($partId), $partId);
}
}
}
示例11: Execute
function Execute($aparams)
{
require_once JPATH_SITE . DS . "Horde" . DS . "Autoloader.php";
require_once JPATH_SITE . DS . "Horde" . DS . "Autoloader" . DS . "ClassPathMapper.php";
require_once JPATH_SITE . DS . "Horde" . DS . "Autoloader" . DS . "ClassPathMapper" . DS . "Default.php";
require_once JPATH_SITE . DS . "Horde" . DS . "Autoloader" . DS . "Default.php";
$this->Log("Checking email account - {$aparams['name']}");
/*if (JRequest::getVar('email') != 1)
return;*/
if (!$aparams['server']) {
return $this->Log("No server specified");
}
if (!$aparams['port']) {
return $this->Log("No port specified");
}
if (!$aparams['username']) {
return $this->Log("No username specified");
}
if (!$aparams['password']) {
return $this->Log("No password specified");
}
$this->params = $aparams;
$this->connect();
if (!$this->conn) {
return $this->Log("Unable to connect to server");
}
// check if we have any messages at all
$messages = $this->conn->search("INBOX");
$ids = $messages['match'];
$ids->reverse();
$msgcount = $ids->count();
if ($msgcount == 0) {
$this->Log("No messages");
$this->disconnect();
return;
} else {
$this->Log("{$msgcount} messaeges");
}
// only get the first 20 messages to make sure web page response is quicker
$maxmsgcount = 50;
if ($msgcount < $maxmsgcount) {
$maxmsgcount = $msgcount;
}
$query = new Horde_Imap_Client_Fetch_Query();
$query->flags();
$query->structure();
$query->headerText(array('peek' => 1));
$uid = new Horde_Imap_Client_Ids();
for ($i = 0; $i < $maxmsgcount; $i++) {
$uid->add($ids->ids[$i]);
}
$messages = $this->conn->fetch('INBOX', $query, array('ids' => $uid));
// for the most recent xx messages
for ($i = 0; $i < $maxmsgcount; $i++) {
$mapped = $ids->ids[$i];
$message = $messages->get($mapped);
$this->Log("---------------------");
$this->Log("Processing message {$i} / {$mapped}");
// get headres of message
if (!$this->GetHeaders($message)) {
$this->Log("Error getting headers");
continue;
}
$subject = $this->headers->getValue("subject");
$this->Log("Subject : " . $subject);
$this->from = $this->parse_addys($this->headers->getValue("from"));
$this->to = $this->parse_addys($this->headers->getValue("to"));
$this->Log("From : {$this->from[0]->mailbox}@{$this->from[0]->host} ({$this->from[0]->personal})");
if ($this->from[0]->mailbox == "no-reply") {
// no-reply from form builder, attempt to find address in name
$text = $this->from[0]->personal;
//$text = str_replace("\"","",$text);
$matches = array();
$pattern = "/(?:[a-z0-9!#\$%&'*+=?^_`{|}~-]+(?:\\.[a-z0-9!#\$%&'*+=?^_`{|}~-]+)*|\"(?:[-\v\f-!#-[]-]|\\[-\t\v\f-])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[-\v\f-!-ZS-]|\\[-\t\v\f-])+)\\])/";
preg_match_all($pattern, $text, $matches);
//print_p($matches);
if (count($matches[0]) > 0) {
// new email found
$newemail = $matches[0][0];
list($name, $host) = explode("@", $newemail);
$this->Log("No Reply message, New From address : {$name}@{$host}");
$this->from[0]->mailbox = $name;
$this->from[0]->host = $host;
$this->from[0]->personal = trim(str_replace("{$name}@{$host}", "", $this->from[0]->personal));
}
}
// skip if already read
if ($aparams['type'] == "imap" && $this->IsMessageRead($message)) {
$this->Log("Skipping read message");
continue;
}
// validate to address is required
if (!$this->ValidateToAddress()) {
$this->Log("Skipping invalid to address");
continue;
}
if (!$this->ValidateFromAddress()) {
$this->Log("Skipping due to from address");
continue;
}
//.........这里部分代码省略.........