Skip to content

Commit

Permalink
MDL-20766 message_send() used intead of events, it will enable us to …
Browse files Browse the repository at this point in the history
…improve performance and solve db transactions issues independedntly from events, hopefully this will give us more options in future too because the events are designed specifically for communication "moodle-->external systems"
  • Loading branch information
skodak committed Nov 7, 2009
1 parent c01678b commit 7c7d3af
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 106 deletions.
6 changes: 3 additions & 3 deletions admin/handlevirus.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function notify_user($user,$subject,$a) {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}


Expand All @@ -87,7 +87,7 @@ function notify_admins($user,$subject,$a) {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
}

Expand All @@ -108,7 +108,7 @@ function notify_admins_unknown($file,$a) {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
}

Expand Down
2 changes: 1 addition & 1 deletion backup/backup_scheduled.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function schedule_backup_cron() {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}

//Everything is finished stop backup_sche_running
Expand Down
2 changes: 1 addition & 1 deletion course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -3996,6 +3996,6 @@ protected function notify($touser, $fromuser, $name='courserequested', $subject,
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
}
16 changes: 8 additions & 8 deletions enrol/authorize/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ private function cc_submit($form, $course)
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
}
redirect($CFG->wwwroot, get_string("reviewnotify", "enrol_authorize"), '30');
Expand Down Expand Up @@ -285,7 +285,7 @@ private function cc_submit($form, $course)
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
if (!empty($CFG->enrol_mailadmins)) {
$a = new stdClass;
Expand All @@ -302,7 +302,7 @@ private function cc_submit($form, $course)
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
}
}
Expand Down Expand Up @@ -723,7 +723,7 @@ public function cron()
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
if (!empty($CFG->enrol_mailadmins)) {
$eventdata = new object();
Expand All @@ -735,7 +735,7 @@ public function cron()
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}

// Send emails to students about which courses have enrolled.
Expand Down Expand Up @@ -803,7 +803,7 @@ private function cron_daily()
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
mtrace(" users who have 'enrol/authorize:uploadcsv' were mailed");
}
Expand Down Expand Up @@ -847,7 +847,7 @@ private function cron_daily()
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);

// Email to payment managers
if (empty($CFG->an_emailexpiredteacher)) {
Expand Down Expand Up @@ -895,7 +895,7 @@ private function cron_daily()
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions enrol/authorize/localfuncs.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function message_to_admin($subject, $data)
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}

function send_welcome_messages($orderdata)
Expand Down Expand Up @@ -198,7 +198,7 @@ function send_welcome_messages($orderdata)
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
}
while ($ei);
Expand Down
2 changes: 1 addition & 1 deletion enrol/authorize/uploadcsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function authorize_process_csv($filename)
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}

/// Send welcome messages to users
Expand Down
8 changes: 4 additions & 4 deletions enrol/flatfile/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function cron() {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}

if (!empty($CFG->enrol_mailteachers) && $teachers) {
Expand All @@ -247,7 +247,7 @@ function cron() {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
}
}
Expand All @@ -274,7 +274,7 @@ function cron() {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
$this->log .= "Error unlinking file $filename\n";
}

Expand All @@ -288,7 +288,7 @@ function cron() {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}

} // end of if(file_exists)
Expand Down
2 changes: 1 addition & 1 deletion enrol/imsenterprise/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ function cron() {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);

$this->log_line('Notification email sent to administrator.');

Expand Down
4 changes: 2 additions & 2 deletions enrol/manual/enrol.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ function cron() {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
}
}
Expand All @@ -355,7 +355,7 @@ function cron() {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions enrol/paypal/ipn.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);

message_paypal_error_to_admin("Payment pending", $data);
die;
Expand Down Expand Up @@ -203,7 +203,7 @@
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);

}

Expand All @@ -220,7 +220,7 @@
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}

if (!empty($CFG->enrol_mailadmins)) {
Expand All @@ -237,7 +237,7 @@
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}
}

Expand Down Expand Up @@ -277,7 +277,7 @@ function message_paypal_error_to_admin($subject, $data) {
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);
}


2 changes: 1 addition & 1 deletion error/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
events_trigger('message_send', $eventdata);
message_send($eventdata);

redirect($CFG->wwwroot .'/course/', 'Message sent, thanks', 3);
exit;
Expand Down
1 change: 0 additions & 1 deletion lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
/// Add libraries
require_once($CFG->libdir.'/ddllib.php');
require_once($CFG->libdir.'/xmlize.php');
require_once($CFG->libdir.'/messagelib.php'); // Messagelib functions

define('INSECURE_DATAROOT_WARNING', 1);
define('INSECURE_DATAROOT_ERROR', 2);
Expand Down
17 changes: 0 additions & 17 deletions lib/db/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,6 @@

$handlers = array (

/* Messaging required parameters (object):
* modulename -
* userfrom
* userto
* subject
* fullmessage - the full message in a given format
* fullmessageformat - the format if the full message (FORMAT_MOODLE, FORMAT_HTML, ..)
* fullmessagehtml - the full version (the message processor will choose with one to use)
* smallmessage - the small version of the message
*/

'message_send' => array (
'handlerfile' => '/lib/messagelib.php',
'handlerfunction' => 'message_send_handler',
'schedule' => 'instant'
),

/*
* portfolio queued event - for non interactive file transfers
*/
Expand Down
Loading

0 comments on commit 7c7d3af

Please sign in to comment.