Skip to content

Commit

Permalink
MDL-35904 send notifications from main admin and improve coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Oct 13, 2012
1 parent 3ed5751 commit 5507901
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 20 deletions.
4 changes: 1 addition & 3 deletions admin/cli/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,7 @@
upgrade_noncore(true);

// log in as admin - we need doanything permission when applying defaults
$admins = get_admins();
$admin = reset($admins);
session_set_user($admin);
session_set_user(get_admin());

// apply all default settings, just in case do it twice to fill all defaults
admin_apply_default_settings(NULL, false);
Expand Down
4 changes: 2 additions & 2 deletions admin/handlevirus.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function notify_admins($user,$subject,$a) {
foreach ($admins as $admin) {
$eventdata = new stdClass();
$eventdata->modulename = 'moodle';
$eventdata->userfrom = $admin;
$eventdata->userfrom = get_admin();
$eventdata->userto = $admin;
$eventdata->subject = $subject;
$eventdata->fullmessage = $body;
Expand All @@ -107,7 +107,7 @@ function notify_admins_unknown($file,$a) {
foreach ($admins as $admin) {
$eventdata = new stdClass();
$eventdata->modulename = 'moodle';
$eventdata->userfrom = $admin;
$eventdata->userfrom = get_admin();
$eventdata->userto = $admin;
$eventdata->subject = $subject;
$eventdata->fullmessage = $body;
Expand Down
4 changes: 1 addition & 3 deletions lib/installlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,7 @@ function install_cli_database(array $options, $interactive) {
upgrade_finished();

// log in as admin - we need do anything when applying defaults
$admins = get_admins();
$admin = reset($admins);
session_set_user($admin);
session_set_user(get_admin());

// apply all default settings, do it twice to fill all defaults - some settings depend on other setting
admin_apply_default_settings(NULL, true);
Expand Down
4 changes: 1 addition & 3 deletions lib/pluginlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1315,13 +1315,11 @@ protected function cron_notify(array $notifications) {
$html .= html_writer::tag('footer', html_writer::tag('p', get_string('updatenotificationfooter', 'core_admin', $a),
array('style' => 'font-size:smaller; color:#333;')));

$mainadmin = reset($admins);

foreach ($admins as $admin) {
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'availableupdate';
$message->userfrom = $mainadmin;
$message->userfrom = get_admin();
$message->userto = $admin;
$message->subject = get_string('updatenotifications', 'core_admin');
$message->fullmessage = $text;
Expand Down
2 changes: 1 addition & 1 deletion lib/portfoliolib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ function portfolio_insane_notify_admins($insane, $instances=false) {
$eventdata->modulename = 'portfolio';
$eventdata->component = 'portfolio';
$eventdata->name = 'notices';
$eventdata->userfrom = $admin;
$eventdata->userfrom = get_admin();
$eventdata->userto = $admin;
$eventdata->subject = $subject;
$eventdata->fullmessage = $plainbody;
Expand Down
3 changes: 1 addition & 2 deletions portfolio/googledocs/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ function portfolio_googledocs_admin_upgrade_notification() {
if (empty($admins)) {
return;
}
$mainadmin = reset($admins);
$a = new stdClass;
$a->docsurl = get_docs_url('Google_OAuth_2.0_setup');

foreach ($admins as $admin) {
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'notices';
$message->userfrom = $mainadmin;
$message->userfrom = get_admin();
$message->userto = $admin;
$message->smallmessage = get_string('oauth2upgrade_message_small', 'portfolio_googledocs');
$message->subject = get_string('oauth2upgrade_message_subject', 'portfolio_googledocs');
Expand Down
3 changes: 1 addition & 2 deletions portfolio/picasa/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@ function portfolio_picasa_admin_upgrade_notification() {
if (empty($admins)) {
return;
}
$mainadmin = reset($admins);
$a = new stdClass;
$a->docsurl = get_docs_url('Google_OAuth_2.0_setup');

foreach ($admins as $admin) {
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'notices';
$message->userfrom = $mainadmin;
$message->userfrom = get_admin();
$message->userto = $admin;
$message->smallmessage = get_string('oauth2upgrade_message_small', 'portfolio_picasa');
$message->subject = get_string('oauth2upgrade_message_subject', 'portfolio_picasa');
Expand Down
3 changes: 1 addition & 2 deletions repository/googledocs/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@ function repository_googledocs_admin_upgrade_notification() {
if (empty($admins)) {
return;
}
$mainadmin = reset($admins);

$a = new stdClass;
$a->docsurl = get_docs_url('Google_OAuth_2.0_setup');
foreach ($admins as $admin) {
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'notices';
$message->userfrom = $mainadmin;
$message->userfrom = get_admin();
$message->userto = $admin;
$message->smallmessage = get_string('oauth2upgrade_message_small', 'repository_googledocs');
$message->subject = get_string('oauth2upgrade_message_subject', 'repository_googledocs');
Expand Down
3 changes: 1 addition & 2 deletions repository/picasa/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@ function repository_picasa_admin_upgrade_notification() {
if (empty($admins)) {
return;
}
$mainadmin = reset($admins);
$a = new stdClass;
$a->docsurl = get_docs_url('Google_OAuth_2.0_setup');

foreach ($admins as $admin) {
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'notices';
$message->userfrom = $mainadmin;
$message->userfrom = get_admin();
$message->userto = $admin;
$message->smallmessage = get_string('oauth2upgrade_message_small', 'repository_picasa');
$message->subject = get_string('oauth2upgrade_message_subject', 'repository_picasa');
Expand Down

0 comments on commit 5507901

Please sign in to comment.