Permalink
Browse files

tag logs MDL-19604 Add logging for tag editing/updates

  • Loading branch information...
1 parent 6683493 commit 6b966ac672e5b8cf9ed0a01a851f9ea419d07802 rwijaya committed Sep 8, 2009
Showing with 33 additions and 4 deletions.
  1. +3 −0 course/lib.php
  2. +2 −1 lib/db/install.xml
  3. +15 −0 lib/db/upgrade.php
  4. +12 −2 tag/edit.php
  5. +1 −1 version.php
View
3 course/lib.php
@@ -59,6 +59,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
3 lib/db/install.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="lib/db" VERSION="20081010" COMMENT="XMLDB file for core Moodle tables"
+<XMLDB PATH="lib/db" VERSION="20090904" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
@@ -1702,6 +1702,7 @@
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('message', 'block contact', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('message', 'unblock contact', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)')" />
<SENTENCE TEXT="(module, action, mtable, field) VALUES ('group', 'view', 'groups', 'name')" />
+ <SENTENCE TEXT="(module, action, mtable, field) VALUES ('tag', 'update', 'tag', 'name')" />
</SENTENCES>
</STATEMENT>
</STATEMENTS>
View
15 lib/db/upgrade.php
@@ -3169,6 +3169,21 @@ function xmldb_main_upgrade($oldversion=0) {
upgrade_main_savepoint($result, 2007101547);
}
+ if ($result && $oldversion < 2007101551){
+ //insert new record for log_display table
+ //used to record tag update.
+ if (!record_exists("log_display", "action", "update",
+ "module", "tag")){
+ $log_action = new stdClass();
+ $log_action->module = 'tag';
+ $log_action->action = 'update';
+ $log_action->mtable = 'tag';
+ $log_action->field = 'name';
+
+ $result = $result && insert_record('log_display', $log_action);
+ }
+ upgrade_main_savepoint($result, 2007101551);
+ }
return $result;
}
View
14 tag/edit.php
@@ -1,4 +1,4 @@
-<?php // $Id$
+ <?php // $Id$
require_once('../config.php');
require_once('lib.php');
@@ -92,7 +92,17 @@
error('Error updating tag record');
}
}
-
+
+ //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
2 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 = 2007101550; // YYYYMMDD = date of the 1.9 branch (don't change)
+ $version = 2007101551; // YYYYMMDD = date of the 1.9 branch (don't change)
// X = release number 1.9.[0,1,2,3,4,5...]
// Y.YY = micro-increments between releases

0 comments on commit 6b966ac

Please sign in to comment.