Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 6b966ac672e5b8cf9ed0a01a851f9ea419d07802 1 parent 6683493
rwijaya authored
3  course/lib.php
@@ -59,6 +59,9 @@ function make_log_url($module, $url) {
59 59 case 'notes':
60 60 $url = "/notes/$url";
61 61 break;
  62 + case 'tag':
  63 + $url = "/tag/$url";
  64 + break;
62 65 default:
63 66 $url = "/mod/$module/$url";
64 67 break;
3  lib/db/install.xml
... ... @@ -1,5 +1,5 @@
1 1 <?xml version="1.0" encoding="UTF-8" ?>
2   -<XMLDB PATH="lib/db" VERSION="20081010" COMMENT="XMLDB file for core Moodle tables"
  2 +<XMLDB PATH="lib/db" VERSION="20090904" COMMENT="XMLDB file for core Moodle tables"
3 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 4 xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
5 5 >
@@ -1702,6 +1702,7 @@
1702 1702 <SENTENCE TEXT="(module, action, mtable, field) VALUES ('message', 'block contact', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)')" />
1703 1703 <SENTENCE TEXT="(module, action, mtable, field) VALUES ('message', 'unblock contact', 'user', 'CONCAT(firstname,&quot; &quot;,lastname)')" />
1704 1704 <SENTENCE TEXT="(module, action, mtable, field) VALUES ('group', 'view', 'groups', 'name')" />
  1705 + <SENTENCE TEXT="(module, action, mtable, field) VALUES ('tag', 'update', 'tag', 'name')" />
1705 1706 </SENTENCES>
1706 1707 </STATEMENT>
1707 1708 </STATEMENTS>
15 lib/db/upgrade.php
@@ -3169,6 +3169,21 @@ function xmldb_main_upgrade($oldversion=0) {
3169 3169 upgrade_main_savepoint($result, 2007101547);
3170 3170 }
3171 3171
  3172 + if ($result && $oldversion < 2007101551){
  3173 + //insert new record for log_display table
  3174 + //used to record tag update.
  3175 + if (!record_exists("log_display", "action", "update",
  3176 + "module", "tag")){
  3177 + $log_action = new stdClass();
  3178 + $log_action->module = 'tag';
  3179 + $log_action->action = 'update';
  3180 + $log_action->mtable = 'tag';
  3181 + $log_action->field = 'name';
  3182 +
  3183 + $result = $result && insert_record('log_display', $log_action);
  3184 + }
  3185 + upgrade_main_savepoint($result, 2007101551);
  3186 + }
3172 3187 return $result;
3173 3188 }
3174 3189
14 tag/edit.php
... ... @@ -1,4 +1,4 @@
1   -<?php // $Id$
  1 + <?php // $Id$
2 2
3 3 require_once('../config.php');
4 4 require_once('lib.php');
@@ -92,7 +92,17 @@
92 92 error('Error updating tag record');
93 93 }
94 94 }
95   -
  95 +
  96 + //log tag changes activity
  97 + //if tag name exist from form, renaming is allow. record log action as rename
  98 + //otherwise, record log action as update
  99 + if (isset($tagnew->name) && ($tag->name != $tagnew->name)){
  100 + add_to_log($COURSE->id, 'tag', 'update', 'index.php?id='. $tag->id, $tag->name . '->'. $tagnew->name);
  101 +
  102 + } elseif ($tag->description != $tagnew->description) {
  103 + add_to_log($COURSE->id, 'tag', 'update', 'index.php?id='. $tag->id, $tag->name);
  104 + }
  105 +
96 106 //updated related tags
97 107 tag_set('tag', $tagnew->id, explode(',', trim($tagnew->relatedtags)));
98 108 //print_object($tagnew); die();
2  version.php
@@ -6,7 +6,7 @@
6 6 // This is compared against the values stored in the database to determine
7 7 // whether upgrades should be performed (see lib/db/*.php)
8 8
9   - $version = 2007101550; // YYYYMMDD = date of the 1.9 branch (don't change)
  9 + $version = 2007101551; // YYYYMMDD = date of the 1.9 branch (don't change)
10 10 // X = release number 1.9.[0,1,2,3,4,5...]
11 11 // Y.YY = micro-increments between releases
12 12

0 comments on commit 6b966ac

Please sign in to comment.
Something went wrong with that request. Please try again.