Skip to content
Snippets Groups Projects
Unverified Commit 74e7627f authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

Email step now creates database entries for every mail to be sent

parent 2a3c0e71
Branches
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="admin/tool/cleanupcourses/step/email/db" VERSION="2017052300" COMMENT="XMLDB file for Moodle cleanupcourses_step/email"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd">
<TABLES>
<TABLE NAME="cleanupcoursesstep_email" COMMENT="table containing all mails which still have to be sent">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="20" NOTNULL="true" SEQUENCE="true" COMMENT="id of the mail"/>
<FIELD NAME="touser" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="user id to which the email should go to"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="course the user should be informed about"/>
<FIELD NAME="instanceid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="id of the step instance responsible"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
\ No newline at end of file
......@@ -45,6 +45,16 @@ class email extends base {
* @return step_response
*/
public function process_course($instanceid, $course) {
global $DB;
$coursecontext = \context_course::instance($course->id);
$userstobeinformed = get_users_by_capability($coursecontext, 'cleanupcoursesstep/email:preventdeletion');
foreach ($userstobeinformed as $user) {
$record = new \stdClass();
$record->touser = $user->id;
$record->courseid = $course->id;
$record->instanceid = $instanceid;
$DB->insert_record('cleanupcoursesstep_email', $record);
}
return step_response::waiting();
}
......
......@@ -25,5 +25,5 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2017052203;
$plugin->version = 2017052302;
$plugin->component = 'cleanupcoursesstep_email';
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment