本文整理匯總了PHP中InboundEmail::setCacheValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP InboundEmail::setCacheValue方法的具體用法?PHP InboundEmail::setCacheValue怎麽用?PHP InboundEmail::setCacheValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類InboundEmail
的用法示例。
在下文中一共展示了InboundEmail::setCacheValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSetCacheValue
/**
* @group 49543
*/
public function testSetCacheValue()
{
global $timedate;
$ie_id = '123';
$mailbox = 'trash';
$time = mt_rand();
$subj = 'test ' . $time;
$GLOBALS['db']->query(sprintf("INSERT INTO email_cache (ie_id, mbox, subject, fromaddr, toaddr, imap_uid) \n VALUES ('%s', '%s', '%s', 'from@test.com', 'to@test.com', '11')", $ie_id, $mailbox, $subj));
//deleted item from inbox which will be inserted in trash
$insert[0] = $this->createMail($subj . '_new', 'from@test.com', 'to@test.com', '12', '2012-11-11 11:11:11', '12');
//old trash item which should be updated
$insert[1] = $this->createMail($subj . '_old', 'from@test.com', 'to@test.com', '11', '2011-11-11 11:11:11', '11');
$ie = new InboundEmail();
$ie->id = $ie_id;
$ie->setCacheValue($mailbox, $insert, '', '');
$fr = $GLOBALS['db']->fetchRow($GLOBALS['db']->query("SELECT subject FROM email_cache WHERE imap_uid = '11'"));
//if old trash item was updated successfully then 'subject' has new value
$this->assertTrue($fr['subject'] == $subj . '_old');
$GLOBALS['db']->query(sprintf("DELETE FROM email_cache WHERE mbox = '%s'", $mailbox));
}
示例2: markEmails
/**
* Marks emails with the passed flag type. This will be applied to local
* cache files as well as remote emails.
* @param string $type Flag type
* @param string $ieId
* @param string $folder IMAP folder structure or SugarFolder GUID
* @param string $uids Comma sep list of UIDs or GUIDs
*/
function markEmails($type, $ieId, $folder, $uids)
{
global $app_strings;
$uids = $this->_cleanUIDList($uids);
$exUids = explode($app_strings['LBL_EMAIL_DELIMITER'], $uids);
if (strpos($folder, 'sugar::') !== false) {
// dealing with a sugar email object, uids are GUIDs
foreach ($exUids as $id) {
$email = new Email();
$email->retrieve($id);
// BUG FIX BEGIN
// Bug 50973 - marking unread in group inbox removes message
if (empty($email->assigned_user_id)) {
$email->setFieldNullable('assigned_user_id');
}
// BUG FIX END
switch ($type) {
case "unread":
$email->status = 'unread';
$email->save();
break;
case "read":
$email->status = 'read';
$email->save();
break;
case "deleted":
$email->delete();
break;
case "flagged":
$email->flagged = 1;
$email->save();
break;
case "unflagged":
$email->flagged = 0;
$email->save();
break;
}
// BUG FIX BEGIN
// Bug 50973 - reset assigned_user_id field defs
if (empty($email->assigned_user_id)) {
$email->revertFieldNullable('assigned_user_id');
}
// BUG FIX END
}
} else {
/* dealing with IMAP email, uids are IMAP uids */
global $ie;
// provided by EmailUIAjax.php
if (empty($ie)) {
$ie = new InboundEmail();
}
$ie->retrieve($ieId);
$ie->mailbox = $folder;
$ie->connectMailserver();
// mark cache files
if ($type == 'deleted') {
$ie->deleteMessageOnMailServer($uids);
$ie->deleteMessageFromCache($uids);
} else {
$overviews = $ie->getCacheValueForUIDs($ie->mailbox, $exUids);
$manipulated = array();
foreach ($overviews['retArr'] as $k => $overview) {
if (in_array($overview->uid, $exUids)) {
switch ($type) {
case "unread":
$overview->seen = 0;
break;
case "read":
$overview->seen = 1;
break;
case "flagged":
$overview->flagged = 1;
break;
case "unflagged":
$overview->flagged = 0;
break;
}
$manipulated[] = $overview;
}
}
if (!empty($manipulated)) {
$ie->setCacheValue($ie->mailbox, array(), $manipulated);
/* now mark emails on email server */
$ie->markEmails(implode(",", explode($app_strings['LBL_EMAIL_DELIMITER'], $uids)), $type);
}
}
// end not type == deleted
}
}
示例3: testsetCacheValue
public function testsetCacheValue()
{
$inboundEmail = new InboundEmail();
$inboundEmail->id = 1;
$inserts = array();
$overview = new Overview();
$overview->imap_uid = 1;
$overview->subject = 'subject';
$overview->from = 'from';
$overview->fromaddr = 'from@email.com';
$overview->to = 'to';
$overview->toaddr = 'to@email.com';
$overview->size = 0;
$overview->message_id = 1;
$inserts[] = $overview;
//execute the method to populate email cache
$inboundEmail->setCacheValue('INBOX', $inserts);
$inboundEmail->setCacheValue('INBOX.Trash', $inserts);
//retrieve back to verify the records created
$result = $inboundEmail->getCacheValue('INBOX');
$this->assertGreaterThan(0, count($result['retArr'][0]));
$this->assertEquals(1, $result['retArr'][0]->message_id);
}