Skip to content

Commit

Permalink
Merge branch 'MDL-51894-29' of git://github.com/andrewnicols/moodle i…
Browse files Browse the repository at this point in the history
…nto MOODLE_29_STABLE
  • Loading branch information
danpoltawski committed Oct 26, 2015
2 parents bd7583c + bf54c89 commit 0c15e94
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions admin/tool/messageinbound/classes/manager.php
Expand Up @@ -102,6 +102,10 @@ protected function get_imap_client() {
try {
$this->client->login();
mtrace("Connection established.");

// Ensure that mailboxes exist.
$this->ensure_mailboxes_exist();

return true;

} catch (\Horde_Imap_Client_Exception $e) {
Expand Down Expand Up @@ -741,6 +745,27 @@ private function message_has_flag($messageid, $flag) {
return in_array($flag, $flags);
}

/**
* Ensure that all mailboxes exist.
*/
private function ensure_mailboxes_exist() {
$requiredmailboxes = array(
self::MAILBOX,
self::CONFIRMATIONFOLDER,
);

$existingmailboxes = $this->client->listMailboxes($requiredmailboxes);
foreach ($requiredmailboxes as $mailbox) {
if (isset($existingmailboxes[$mailbox])) {
// This mailbox was found.
continue;
}

mtrace("Unable to find the '{$mailbox}' mailbox - creating it.");
$this->client->createMailbox($mailbox);
}
}

/**
* Attempt to determine whether this message is a bulk message (e.g. automated reply).
*
Expand Down

0 comments on commit 0c15e94

Please sign in to comment.