当前位置: 首页>>代码示例>>PHP>>正文


PHP EmailUI::preflightEmailCache方法代码示例

本文整理汇总了PHP中EmailUI::preflightEmailCache方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailUI::preflightEmailCache方法的具体用法?PHP EmailUI::preflightEmailCache怎么用?PHP EmailUI::preflightEmailCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EmailUI的用法示例。


在下文中一共展示了EmailUI::preflightEmailCache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pop3_checkPartialEmail

 /**
  * Special handler for POP3 boxes.  Standard IMAP commands are useless.
  * This will fetch only partial emails for POP3 and hence needs to be call again and again based on status it returns
  */
 function pop3_checkPartialEmail($synch = false)
 {
     require_once 'include/utils/array_utils.php';
     global $current_user;
     global $sugar_config;
     $cacheDataExists = false;
     $diff = array();
     $results = array();
     $cacheFilePath = clean_path("{$this->EmailCachePath}/{$this->id}/folders/MsgNOToUIDLData.php");
     if (file_exists($cacheFilePath)) {
         $cacheDataExists = true;
         if ($fh = @fopen($cacheFilePath, "rb")) {
             $data = "";
             $chunksize = 1 * (1024 * 1024);
             // how many bytes per chunk
             while (!feof($fh)) {
                 $buf = fgets($fh, $chunksize);
                 // 8kb max buffer - shouldn't be more than 80 chars via pop3...
                 $data = $data . $buf;
                 flush();
             }
             // while
             fclose($fh);
             $diff = unserialize($data);
             if (!empty($diff)) {
                 if (count($diff) > 50) {
                     $newDiff = array_slice($diff, 50, count($diff), true);
                 } else {
                     $newDiff = array();
                 }
                 $results = array_slice(array_keys($diff), 0, 50);
                 $data = serialize($newDiff);
                 if ($fh = @fopen($cacheFilePath, "w")) {
                     fputs($fh, $data);
                     fclose($fh);
                 }
                 // if
             }
         }
         // if
     }
     // if
     if (!$cacheDataExists) {
         if ($synch) {
             $this->deletePop3Cache();
         }
         $UIDLs = $this->pop3_getUIDL();
         if (count($UIDLs) > 0) {
             // get cached UIDLs
             $cacheUIDLs = $this->pop3_getCacheUidls();
             // new email cache values we should deal with
             $diff = array_diff_assoc($UIDLs, $cacheUIDLs);
             $diff = $this->pop3_shiftCache($diff, $cacheUIDLs);
             require_once 'modules/Emails/EmailUI.php';
             EmailUI::preflightEmailCache("{$this->EmailCachePath}/{$this->id}");
             if (count($diff) > 50) {
                 $newDiff = array_slice($diff, 50, count($diff), true);
             } else {
                 $newDiff = array();
             }
             $results = array_slice(array_keys($diff), 0, 50);
             $data = serialize($newDiff);
             if ($fh = @fopen($cacheFilePath, "w")) {
                 fputs($fh, $data);
                 fclose($fh);
             }
             // if
         } else {
             $GLOBALS['log']->debug("*** INBOUNDEMAIL: could not open socket connection to POP3 server");
             return "could not open socket connection to POP3 server";
         }
         // else
     }
     // if
     // build up msgNo request
     if (count($diff) > 0) {
         // remove dirty cache entries
         $startingNo = 0;
         if (isset($_REQUEST['currentCount']) && $_REQUEST['currentCount'] > -1) {
             $startingNo = $_REQUEST['currentCount'];
         }
         $this->mailbox = 'INBOX';
         $this->connectMailserver();
         //$searchResults = array_keys($diff);
         //$fetchedOverviews = array();
         //$chunkArraySerachResults = array_chunk($searchResults, 50);
         $concatResults = implode(",", $results);
         $GLOBALS['log']->info('$$$$ ' . $concatResults);
         $GLOBALS['log']->info("[EMAIL] Start POP3 fetch overview on mailbox [{$this->mailbox}] for user [{$current_user->user_name}] on 50 data");
         $fetchedOverviews = imap_fetch_overview($this->conn, $concatResults);
         $GLOBALS['log']->info("[EMAIL] End POP3 fetch overview on mailbox [{$this->mailbox}] for user [{$current_user->user_name}] on " . sizeof($fetchedOverviews) . " data");
         // clean up cache entry
         foreach ($fetchedOverviews as $k => $overview) {
             $overview->message_id = trim($diff[$overview->msgno]);
             $fetchedOverviews[$k] = $overview;
         }
//.........这里部分代码省略.........
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:101,代码来源:InboundEmail.php


注:本文中的EmailUI::preflightEmailCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。