X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FMailing%2FMailStore.php;h=f11c413f224aad4c0ffe3d13ecd1c537cdc0df6e;hb=f41a7de74d7f30125ad93e4b80561ac17038c002;hp=c7f2ce5a0cfc9723a28a4b868e5218dc6b0f29a1;hpb=58a50b22e20f112fdbfc7e50f18353c311ceb1ae;p=civicrm-core.git diff --git a/CRM/Mailing/MailStore.php b/CRM/Mailing/MailStore.php index c7f2ce5a0c..f11c413f22 100644 --- a/CRM/Mailing/MailStore.php +++ b/CRM/Mailing/MailStore.php @@ -1,7 +1,7 @@ domain_id = CRM_Core_Config::domainID(); + public static function getStore($name = NULL) { + $dao = new CRM_Core_DAO_MailSettings; + $dao->domain_id = CRM_Core_Config::domainID(); $name ? $dao->name = $name : $dao->is_default = 1; if (!$dao->find(TRUE)) { throw new Exception("Could not find entry named $name in civicrm_mail_settings"); } $protocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'); + if (empty($protocols[$dao->protocol])) { + throw new Exception("Empty mail protocol"); + } switch ($protocols[$dao->protocol]) { case 'IMAP': @@ -81,25 +86,29 @@ class CRM_Mailing_MailStore { /** * Return all emails in the mail store * - * @return array array of ezcMail objects + * @return array + * array of ezcMail objects */ - function allMails() { + public function allMails() { return $this->fetchNext(0); } /** * Expunge the messages marked for deletion; stub function to be redefined by IMAP store */ - function expunge() {} + public function expunge() { + } /** * Return the next X messages from the mail store * - * @param int $count number of messages to fetch (0 to fetch all) + * @param int $count + * Number of messages to fetch (0 to fetch all). * - * @return array array of ezcMail objects + * @return array + * array of ezcMail objects */ - function fetchNext($count = 1) { + public function fetchNext($count = 1) { if (isset($this->_transport->options->uidReferencing) and $this->_transport->options->uidReferencing) { $offset = array_shift($this->_transport->listUniqueIdentifiers()); } @@ -112,7 +121,7 @@ class CRM_Mailing_MailStore { print "fetching $count messages\n"; } } - catch(ezcMailOffsetOutOfRangeException$e) { + catch (ezcMailOffsetOutOfRangeException$e) { if ($this->_debug) { print "got to the end of the mailbox\n"; } @@ -136,16 +145,21 @@ class CRM_Mailing_MailStore { /** * Point to (and create if needed) a local Maildir for storing retrieved mail * - * @param string $name name of the Maildir + * @param string $name + * Name of the Maildir. * * @throws Exception - * @return string path to the Maildir's cur directory + * @return string + * path to the Maildir's cur directory */ - function maildir($name) { + public function maildir($name) { $config = CRM_Core_Config::singleton(); $dir = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $name; foreach (array( - 'cur', 'new', 'tmp') as $sub) { + 'cur', + 'new', + 'tmp' + ) as $sub) { if (!file_exists($dir . DIRECTORY_SEPARATOR . $sub)) { if ($this->_debug) { print "creating $dir/$sub\n"; @@ -158,4 +172,3 @@ class CRM_Mailing_MailStore { return $dir . DIRECTORY_SEPARATOR . 'cur'; } } -