Overview

Namespaces

  • Cron
  • None

Classes

  • _HtmlGrid_TableOut
  • _TransactionModel_RawSaveOperation
  • AccessControlComponent
  • AccessControlHelper
  • ActionListHelper
  • ActiveDirectoryUtils
  • AddCurrentPidToSchedulingShellCallLogs
  • AnonymousFunctionOperation
  • ArrayUtil
  • AssociationIntegrityBehavior
  • AtomicOperation
  • AuthenticationComponent
  • AuthenticationController
  • AuthenticationUser
  • AutocompleteDatasourceComponent
  • BaseModelComponent
  • Basics
  • CakeLayersHelper
  • CheckAndRunShell
  • ClassSearcher
  • CommandLineUtil
  • CommonValidationBehavior
  • ConfigurableShellCallsSchedulingTask
  • ConfigurationKey
  • ConfigurationKeys
  • ConfigurationKeysController
  • Context
  • ContextComponent
  • ContextHelper
  • Contexts
  • ControllerInspector
  • ControllerMenuHelper
  • CreateJournalingTables
  • CreateTableConfigurationKeys
  • CreateTableSchedulingConfigurableShellCalls
  • CreateTableSchedulingShellCallLogs
  • CreateTableSettedConfigurationKeys
  • CreateTableUserResetPasswordRequests
  • CreateTableUsers
  • CronSchedulingInstaller
  • CronValidationBehavior
  • CssBox
  • CssController
  • CssProperties
  • CssShell
  • CsvUtil
  • CustomDataModel
  • DatasourceDumperManager
  • DateTimeInput
  • DependencyShell
  • DetailHelper
  • DumperShell
  • ExtendedFieldsAccessControl
  • ExtendedFieldSet
  • ExtendedFieldSetHelper
  • ExtendedFieldsParser
  • ExtendedFormHelper
  • ExtendedHasManyAppModel
  • ExtendedOperationsBehavior
  • FieldDefinition
  • FieldRowDefinition
  • FieldSetDefinition
  • FieldSetLayoutHelper
  • FileOperations
  • FileOperations_Rename
  • FileOperations_SymLink
  • FileOperations_Touch
  • FileOperations_Unlink
  • FileSystem
  • FixConfigurationKeysPrimaryKey
  • FixSettedConfigurationKeysPrimaryKey
  • HasManyUtilsBehavior
  • HtmlDocument
  • HtmlGrid
  • HtmlGrid_Cell
  • HttpClient
  • HttpResponse
  • ImapClient
  • ImapMailBox
  • ImapParserShell
  • IncludePath
  • InputMasked
  • InputSearchable
  • InputsOnSubmit
  • InstallShell
  • JenkinsBuildShell
  • Journal
  • JournalDetail
  • JournalizedBehavior
  • JsonResponseComponent
  • LayoutsHelper
  • Ldap
  • LdapUtils
  • ListFieldSet
  • ListFieldSetHelper
  • ListsHelper
  • MailParser
  • Make
  • MenuHelper
  • MigrationAllPluginsShell
  • ModelOperations
  • ModelOperations_Delete
  • ModelOperations_Save
  • ModelTraverser
  • MysqlDumper
  • OpenLdapUtils
  • PaginatorUtilComponent
  • PaginatorUtilComponentFilter
  • PaginatorUtilHelper
  • Plugin
  • PluginManager
  • Reflections
  • RenameEnabledToActiveFromUsersTable
  • RunShellCallShell
  • ScaffoldUtilComponent
  • ScaffoldUtilHelper
  • Scheduling
  • SchedulingConfigurableShellCall
  • SchedulingConfigurableShellCallsController
  • SchedulingShellCallLog
  • SchedulingShellCallLogsController
  • SettedConfigurationKey
  • StuffreposPluginsRename
  • TimeZoneBehavior
  • TransactionModel
  • TransactionOperation
  • Translator
  • TranslatorShell
  • User
  • UserAuthenticationComponent
  • UserChangePassword
  • UserResetPassword
  • UserResetPasswordRequest
  • UserResetPasswordRequestSubmission
  • UsersController
  • ViewUtilHelper

Interfaces

  • AccessControlFilter
  • CommitableOperation
  • DatasourceDumper
  • MakeListener
  • SchedulingInstaller
  • TasksObject
  • UndoableOperation

Exceptions

  • LdapObjectNotWritableException
  • ModelTraverserException
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: class ImapMailBox {
  4: 
  5:     /**
  6:      *
  7:      * @var ImapClient
  8:      */
  9:     private $client;
 10: 
 11:     /**
 12:      *
 13:      * @var string 
 14:      */
 15:     private $mailBoxName;
 16: 
 17:     public function __construct(ImapClient $client, $mailBoxName) {
 18:         $this->client = $client;
 19:         $this->mailBoxName = $mailBoxName;
 20:     }
 21: 
 22:     public function queryUnseenIds($sender = null) {
 23:         $query = new Horde_Imap_Client_Search_Query();
 24:         $query->flag(Horde_Imap_Client::FLAG_SEEN, false);
 25:         if ($sender) {
 26:             $query->headerText('From', $sender);
 27:         }
 28:         $results = $this->client->getHordeImapClient()->search($this->mailBoxName, $query);
 29:         $ids = array();
 30:         foreach ($results['match'] as $id) {
 31:             $ids[] = $id;
 32:         }
 33:         return $ids;
 34:     }
 35: 
 36:     public function fetchMessage($messageId) {
 37:         $structure = $this->_getStructure($messageId);
 38:         $query = new Horde_Imap_Client_Fetch_Query();
 39:         $query->envelope();
 40:         foreach (array_keys($structure->contentTypeMap()) as $typeIndex) {
 41:             $query->bodyPart($typeIndex, array(
 42:                 'peek' => true
 43:             ));
 44:         }
 45:         $results = $this->client->getHordeImapClient()->fetch($this->mailBoxName, $query, array(
 46:             'ids' => new Horde_Imap_Client_Ids($messageId)
 47:         ));
 48:         return $this->_parseFetchData($results[$messageId], $structure);
 49:     }
 50: 
 51:     public function setAsSeen($messageId) {
 52:         $query = new Horde_Imap_Client_Fetch_Query();
 53:         $query->headerText(array(
 54:             'peek' => false
 55:         ));
 56:         $results = $this->client->getHordeImapClient()->fetch($this->mailBoxName, $query, array(
 57:             'ids' => new Horde_Imap_Client_Ids($messageId)
 58:         ));
 59:         if (!($results instanceof Horde_Imap_Client_Fetch_Results)) {
 60:             throw new Exception("Failed to set message (ID=$messageId) as seen");
 61:         }
 62:     }
 63: 
 64:     /**
 65:      * 
 66:      * @param Horde_Imap_Client_Socket $client
 67:      * @param type $messageId
 68:      * @return Horde_Mime_Part
 69:      */
 70:     private function _getStructure($messageId) {
 71:         $query = new Horde_Imap_Client_Fetch_Query();
 72:         $query->structure();
 73:         $results = $this->client->getHordeImapClient()->fetch($this->mailBoxName, $query, array(
 74:             'ids' => new Horde_Imap_Client_Ids($messageId)
 75:         ));
 76:         return $results[$messageId]->getStructure();
 77:     }
 78: 
 79:     private function _parseFetchData(Horde_Imap_Client_Data_Fetch $fetchData, Horde_Mime_Part $structure) {
 80:         $data = $this->_parseFetchDataHeaders($fetchData);
 81:         $data['bodies'] = array();
 82:         foreach ($structure->contentTypeMap() as $typeIndex => $typeMime) {
 83:             $data['bodies'][$typeMime] = $this->_parseFetchDataContents($fetchData, $structure, $typeIndex);
 84:         }
 85:         return $data;
 86:     }
 87: 
 88:     private function _parseFetchDataHeaders(Horde_Imap_Client_Data_Fetch $fetchData) {
 89:         $properties = array(
 90:             'bcc', 'cc', 'date', 'from', 'in_reply_to', 'message_id',
 91:             'reply_to', 'sender', 'subject', 'to'
 92:         );
 93:         $headers = array();
 94:         foreach ($properties as $property) {
 95:             $value = $fetchData->getEnvelope()->{$property};
 96:             if ($value instanceof Horde_Mail_Rfc822_List) {
 97:                 $headers[$property] = $value->bare_addresses;
 98:             } else if ($value instanceof Horde_Imap_Client_DateTime ||
 99:                     is_string($value)) {
100:                 $headers[$property] = $value;
101:             } else {
102:                 throw new Exception('Class "' . gettype($value) . '" not mapped for property "' . $property . '"');
103:             }
104:         }
105:         return $headers;
106:     }
107: 
108:     private function _parseFetchDataContents(Horde_Imap_Client_Data_Fetch $fetchData, $structure, $contentsBodyPartIndex) {
109:         $stream = $fetchData->getBodyPart($contentsBodyPartIndex, true);
110:         $part = $structure[$contentsBodyPartIndex];
111:         $part->setContents($stream, array(
112:             'usestream' => true
113:         ));
114:         return $part->getContents();
115:     }
116: 
117: }
118: 
API documentation generated by ApiGen 2.8.0