MDL-40908 core_tag: replaced 'update' add_to_log calls with an event

This commit is contained in:
Mark Nelson
2014-04-03 18:15:31 -07:00
parent 1a727e121e
commit 09fce43469
5 changed files with 266 additions and 23 deletions
+9 -14
View File
@@ -119,27 +119,22 @@ if ($tagnew = $tagform->get_data()) {
$tagnew = file_postupdate_standard_editor($tagnew, 'description', $editoroptions, $systemcontext, 'tag', 'description', $tag->id);
tag_description_set($tag_id, $tagnew->description, $tagnew->descriptionformat);
if ($tag->description != $tagnew->description) {
tag_description_set($tag_id, $tagnew->description, $tagnew->descriptionformat);
}
$tagnew->timemodified = time();
if (has_capability('moodle/tag:manage', $systemcontext)) {
// rename tag
if(!tag_rename($tag->id, $tagnew->rawname)) {
print_error('errorupdatingrecord', 'tag');
// Check if we need to rename the tag.
if (isset($tagnew->name) && ($tag->name != $tagnew->name)) {
// Rename the tag.
if (!tag_rename($tag->id, $tagnew->rawname)) {
print_error('errorupdatingrecord', 'tag');
}
}
}
//log tag changes activity
//if tag name exist from form, renaming is allow. record log action as rename
//otherwise, record log action as update
if (isset($tagnew->name) && ($tag->name != $tagnew->name)){
add_to_log($COURSE->id, 'tag', 'update', 'index.php?id='. $tag->id, $tag->name . '->'. $tagnew->name);
} elseif ($tag->description != $tagnew->description) {
add_to_log($COURSE->id, 'tag', 'update', 'index.php?id='. $tag->id, $tag->name);
}
//updated related tags
tag_set('tag', $tagnew->id, explode(',', trim($tagnew->relatedtags)), 'core', $systemcontext);
//print_object($tagnew); die();