]> git.mjollnir.org Git - moodle.git/commitdiff
tag logs MDL-19604 Add logging for tag editing/updates, merged from MOODLE19_STABLE
authorrwijaya <rwijaya>
Wed, 9 Sep 2009 02:43:43 +0000 (02:43 +0000)
committerrwijaya <rwijaya>
Wed, 9 Sep 2009 02:43:43 +0000 (02:43 +0000)
course/lib.php
lib/db/install.php
lib/db/upgrade.php
tag/edit.php
version.php

index 29af1662b752de5b1106a711997ce36d971bd901..e8aa13a4ecb734751240f322c9cab862bd62ccde 100644 (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;
index 7c748b28f4180ec1b90aed364ce782ca07a2b56f..c1f79c36d865fa44c9063a4013bffd086d178e9c 100644 (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
index bd274cb15ef413c1279820c5179b13d733966a91..20504dfc0c00f070819cb1acd83211b87cd5f8d2 100644 (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;
 }
 
index aa530f35dc764569423e88bf5d9c77291e603006..d8261a5013c4cbf623f9d459a18b4e2b4ec6f986 100644 (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();
index 96ec4fe378b232c44b4c6c412e13aa9d73abec5f..4cf9c6e627cab5ccce3d032119bcf32659d87bff 100644 (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