diff --git a/README.md b/README.md deleted file mode 100644 index b2b0c0e..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -moodle-local_configlogemailer -============================= - -Moodle local plugin to email config log updates diff --git a/lang/en/local_configlogemailer.php b/lang/en/local_configlogemailer.php new file mode 100644 index 0000000..e8f7984 --- /dev/null +++ b/lang/en/local_configlogemailer.php @@ -0,0 +1,33 @@ +email = get_config('local_configlogemailer','to_email'); + // Check when the last cron was run, if it was the first time, then make it the current time + $lastcron = get_config('local_configlogemailer','lastcron'); + if (empty($lastcron)) { + $lastcron = time(); + } + + $from->email = get_config('local_configlogemailer','from_email'); + $from->firstname = get_config('local_configlogemailer','from_firstname'); + $from->lastname = get_config('local_configlogemailer','from_lastname'); + + $subject = get_string('subject', 'local_configlogemailer'); + $messagetext = get_string('messagetext', 'local_configlogemailer',$CFG->wwwroot) + + $sql = "SELECT u.firstname, u.lastname, cl.timemodified, cl.plugin, cl.name, cl.value, cl.oldvalue + FROM {config_log} cl + JOIN {user} u ON u.id = cl.userid + WHERE cl.timemodified >= $lastcron + ORDER BY cl.timemodified DESC"; + $rs = $DB->get_recordset_sql($sql); + if ($rs->valid()) { + foreach ($rs as $log) { + $messagetext .= date('Y-m-d H:i:s', $log->timemodified) . ' | '; + $messagetext .= $log->firstname . ' ' . $log->lastname . ' | '; + if (is_null($log->plugin)) { + $plugin = 'core'; + } else { + $plugin = $log->plugin; + } + $messagetext .= $plugin . ' | '; + $messagetext .= $log->name . ' | '; + $messagetext .= $log->value . ' | '; + $messagetext .= $log->oldvalue . ' +'; + } + $rs->close(); + email_to_user($to, $from, $subject, $messagetext); + } +} \ No newline at end of file diff --git a/pix/icon.gif b/pix/icon.gif new file mode 100644 index 0000000..48c7bde Binary files /dev/null and b/pix/icon.gif differ diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..e19e51a --- /dev/null +++ b/readme.txt @@ -0,0 +1,20 @@ +moodle-local_configlogemailer + +Moodle local plugin to email config log updates + +This plugin sends an email to a specified user after +it has detected a config setting was changed when +running cron. The to and from email addresses can +be changed in the settings page. + + @package local + @subpackage configlogemailer + @copyright 2013 Alex Rowe - Study Group + @author Alex Rowe arowe@studygroup.com + @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + +Install into /local/ + +Version 1.0 (2013072200) + +Required Moodle 2.4 diff --git a/settings.php b/settings.php new file mode 100644 index 0000000..5f7721c --- /dev/null +++ b/settings.php @@ -0,0 +1,38 @@ +add('localplugins', $settings); + + $name = 'local_configlogemailer/to_email'; + $title = get_string('to_email_title','local_configlogemailer'); + $description = get_string('to_email_description','local_configlogemailer'); + $default = get_string('to_email_default','local_configlogemailer'); + $setting = new admin_setting_configtext($name, $title, $description, $default); + $settings->add($setting); + + $name = 'local_configlogemailer/from_email'; + $title = get_string('from_email_title','local_configlogemailer'); + $description = get_string('from_email_description','local_configlogemailer'); + $default = get_string('from_email_default','local_configlogemailer',$from->email); + $setting = new admin_setting_configtext($name, $title, $description, $default); + $settings->add($setting); + + $name = 'local_configlogemailer/from_firstname'; + $title = get_string('from_firstname_title','local_configlogemailer'); + $description = get_string('from_firstname_description','local_configlogemailer'); + $default = get_string('from_firstname_default','local_configlogemailer',$from->firstname); + $setting = new admin_setting_configtext($name, $title, $description, $default); + $settings->add($setting); + + $name = 'local_configlogemailer/from_lastname'; + $title = get_string('from_lastname_title','local_configlogemailer'); + $description = get_string('from_lastname_description','local_configlogemailer'); + $default = get_string('from_lastname_default','local_configlogemailer',$from->lastname); + $setting = new admin_setting_configtext($name, $title, $description, $default); + $settings->add($setting); +} \ No newline at end of file diff --git a/version.php b/version.php new file mode 100644 index 0000000..f44cd27 --- /dev/null +++ b/version.php @@ -0,0 +1,17 @@ +version = 2013072200; // The (date) version of this plugin +$plugin->requires = 2012120300; // Requires this Moodle version