MDL-46284 core: Add e-mail fetcher from IMAP

This issue is a part of the MDL-47194 Task.
This issue is a part of the MDL-39707 Epic.
This commit is contained in:
Andrew Nicols 2014-07-16 14:51:19 +08:00
parent 6597413d41
commit 776b4acc81
21 changed files with 1909 additions and 3 deletions

View file

@ -33,6 +33,7 @@ namespace core\message\inbound;
* @property-read string $component The component of this handler
* @property-read int $defaultexpiration Default expiration of new addresses for this handler
* @property-read string $description The description of this handler
* @property-read string $name The name of this handler
* @property-read bool $validateaddress Whether the address validation is a requiredment
* @property-read bool $enabled Whether this handler is currently enabled
* @property-read string $classname The name of handler class
@ -193,6 +194,14 @@ abstract class handler {
*/
protected abstract function get_description();
/**
* Return a name for the current handler.
* This appears in the admin pages as a human-readable name.
*
* @return string
*/
protected abstract function get_name();
/**
* Process the message against the current handler.
*

View file

@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Variable Envelope Return Path message processing failure exception.
*
* @package core_message
* @copyright 2014 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\message\inbound;
defined('MOODLE_INTERNAL') || die();
/**
* Variable Envelope Return Path message processing failure exception.
*
* @copyright 2014 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class processing_failed_exception extends \moodle_exception {
/**
* Constructor
*
* @param string $identifier The string identifier to use when displaying this exception.
* @param string $component The string component
* @param stdClass $data The data to pass to get_string
*/
public function __construct($identifier, $component, \stdClass $data = null) {
return parent::__construct($identifier, $component, '', $data);
}
}

View file

@ -1137,7 +1137,7 @@ class core_plugin_manager {
'tool' => array(
'assignmentupgrade', 'availabilityconditions', 'behat', 'capability', 'customlang',
'dbtransfer', 'generator', 'health', 'innodb', 'installaddon',
'langimport', 'log', 'multilangupgrade', 'phpunit', 'profiling',
'langimport', 'log', 'messageinbound', 'multilangupgrade', 'phpunit', 'profiling',
'replace', 'spamcleaner', 'task', 'timezoneimport',
'unittest', 'uploadcourse', 'uploaduser', 'unsuproles', 'xmldb'
),

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20140918" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20141002" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
@ -3061,5 +3061,18 @@
<KEY NAME="handler" TYPE="foreign" FIELDS="handler" REFTABLE="messageinbound_handlers" REFFIELDS="id" COMMENT="The handler must point to a valid record in the messageinbound_handlers table."/>
</KEYS>
</TABLE>
<TABLE NAME="messageinbound_messagelist" COMMENT="A list of message IDs for existing replies">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="messageid" TYPE="text" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="address" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="The Inbound Message address that the message was originally sent to"/>
<FIELD NAME="timecreated" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="user" REFFIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>

View file

@ -3837,5 +3837,30 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2014100100.00);
}
if ($oldversion < 2014100200.01) {
// Define table messageinbound_messagelist to be created.
$table = new xmldb_table('messageinbound_messagelist');
// Adding fields to table messageinbound_messagelist.
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('messageid', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
$table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
$table->add_field('address', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
// Adding keys to table messageinbound_messagelist.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('userid', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
// Conditionally launch create table for messageinbound_messagelist.
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2014100200.01);
}
return true;
}