tag logs MDL-19604 Add logging for tag editing/updates, merged from MOODLE19_STABLE

This commit is contained in:
rwijaya 2009-09-09 02:43:43 +00:00
parent e6728ca7c8
commit b89e4ad8fa
5 changed files with 30 additions and 2 deletions

View File

@ -61,6 +61,9 @@ function make_log_url($module, $url) {
case 'notes':
$url = "/notes/$url";
break;
case 'tag':
$url = "/tag/$url";
break;
default:
$url = "/mod/$module/$url";
break;

View File

@ -127,6 +127,7 @@ function xmldb_main_install() {
update_log_display_entry('message', 'block contact', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('message', 'unblock contact', 'user', 'CONCAT(firstname,\' \',lastname)');
update_log_display_entry('group', 'view', 'groups', 'name');
update_log_display_entry('tag', 'update', 'tag', 'name');
/// Create guest record

View File

@ -2540,6 +2540,20 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
upgrade_main_savepoint($result, 2009090400);
}
if ($result && $oldversion < 2009090800){
//insert new record for log_display table
//used to record tag update.
if (!$DB->record_exists('log_display', array('action'=>'update', 'module'=>'tag'))) {
$log_action = new object();
$log_action->module = 'tag';
$log_action->action = 'update';
$log_action->mtable = 'tag';
$log_action->field = 'name';
$result = $result && $DB->insert_record('log_display', $log_action);
}
upgrade_main_savepoint($result, 2009090800);
}
return $result;
}

View File

@ -99,7 +99,17 @@ if ($tagnew = $tagform->get_data()) {
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)));
//print_object($tagnew); die();

View File

@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
$version = 2009090400; // YYYYMMDD = date of the last version bump
$version = 2009090800; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 dev (Build: 20090909)'; // Human-friendly version name