Improved wording and links for all 3 outage events

This commit is contained in:
Brendan Heywood
2020-02-13 09:39:15 +11:00
parent b428805c0e
commit b435a3f0a7
4 changed files with 36 additions and 17 deletions

View File

@@ -117,19 +117,32 @@ class outagedb {
$outage->createdby = $USER->id;
// Then create it, log it and adjust its id.
$outage->id = $DB->insert_record('auth_outage', $outage, true);
outage_created::create(
['objectid' => $outage->id, 'other' => (array)$outage]
)->trigger();
$other = (array) $outage;
$other['title'] = $outage->get_title();
$event = outage_created::create([
'objectid' => $outage->id,
'other' => $other,
]);
$event->add_record_snapshot('auth_outage', (object)(array) $outage);
$event->trigger();
// Create calendar entry.
calendar::create($outage);
} else {
// Remove the createdby field so it does not get updated.
unset($outage->createdby);
$DB->update_record('auth_outage', $outage);
// Log it.
outage_updated::create(
['objectid' => $outage->id, 'other' => (array)$outage]
)->trigger();
$other = (array) $outage;
$other['title'] = $outage->get_title();
$event = outage_updated::create([
'objectid' => $outage->id,
'other' => $other,
]);
$event->add_record_snapshot('auth_outage', (object)(array) $outage);
$event->trigger();
// Update calendar entry.
calendar::update($outage);
}
@@ -156,7 +169,16 @@ class outagedb {
// Log it.
$previous = $DB->get_record('auth_outage', ['id' => $id], '*', MUST_EXIST);
$event = outage_deleted::create(['objectid' => $id, 'other' => (array)$previous]);
$outage = new outage($previous);
$other = (array) $outage;
$other['title'] = $outage->get_title();
$event = outage_deleted::create([
'objectid' => $id,
'other' => $other,
]);
$event->add_record_snapshot('auth_outage', $previous);
$event->trigger();

View File

@@ -45,8 +45,7 @@ class outage_created extends base {
* @return string
*/
public function get_description() {
return "The user with the id '{$this->userid}' created a new outage title '{$this->other['title']}' ".
" with id '{$this->other['id']}'.";
return "The user with the id '{$this->userid}' created outage {$this->other['id']} '{$this->other['title']}'";
}
/**
@@ -54,7 +53,7 @@ class outage_created extends base {
* @return moodle_url
*/
public function get_url() {
return new moodle_url('/auth/outage/list.php#auth_outage_id_'.$this->other['id']);
return new moodle_url('/auth/outage/edit.php', ['edit' => $this->other['id']]);
}
/**

View File

@@ -44,8 +44,7 @@ class outage_deleted extends base {
* @return string
*/
public function get_description() {
return "The user with the id '{$this->userid}' deleted the outage titled '{$this->other['title']}' ".
"with id '{$this->other['id']}'.";
return "The user with the id '{$this->userid}' deleted outage {$this->other['id']} '{$this->other['title']}'";
}
/**
@@ -53,7 +52,7 @@ class outage_deleted extends base {
* @return moodle_url
*/
public function get_url() {
return new moodle_url('/auth/outage/list.php#auth_outage_id_'.$this->other['id']);
return new moodle_url('/auth/outage/manage.php');
}
/**

View File

@@ -45,8 +45,7 @@ class outage_updated extends base {
* @return string
*/
public function get_description() {
return "The user with the id '{$this->userid}' updated the outage title '{$this->other['title']}' ".
"with id '{$this->other['id']}'.";
return "The user with the id '{$this->userid}' updated outage {$this->other['id']} '{$this->other['title']}'";
}
/**
@@ -54,7 +53,7 @@ class outage_updated extends base {
* @return moodle_url
*/
public function get_url() {
return new moodle_url('/auth/outage/list.php');
return new moodle_url('/auth/outage/edit.php', ['edit' => $this->other['id']]);
}
/**