From: rwijaya Date: Wed, 9 Sep 2009 02:43:43 +0000 (+0000) Subject: tag logs MDL-19604 Add logging for tag editing/updates, merged from MOODLE19_STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b89e4ad8fabe623bf57dc5c3d84d00db5f301340;p=moodle.git tag logs MDL-19604 Add logging for tag editing/updates, merged from MOODLE19_STABLE --- diff --git a/course/lib.php b/course/lib.php index 29af1662b7..e8aa13a4ec 100644 --- a/course/lib.php +++ b/course/lib.php @@ -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; diff --git a/lib/db/install.php b/lib/db/install.php index 7c748b28f4..c1f79c36d8 100644 --- a/lib/db/install.php +++ b/lib/db/install.php @@ -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 diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index bd274cb15e..20504dfc0c 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -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; } diff --git a/tag/edit.php b/tag/edit.php index aa530f35dc..d8261a5013 100644 --- a/tag/edit.php +++ b/tag/edit.php @@ -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(); diff --git a/version.php b/version.php index 96ec4fe378..4cf9c6e627 100644 --- a/version.php +++ b/version.php @@ -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