# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/mod/wiki/lang/en/wiki.php
--- moodle/mod/wiki/lang/en/wiki.php Base (1.12)
+++ moodle/mod/wiki/lang/en/wiki.php Locally Modified (Based On 1.12)
@@ -135,6 +135,7 @@
 $string['reparsetimeout'] = 'Reparsing default timeout';
 $string['repeatedsection'] = 'Wiki error: Section name cannot be repeated \'{$a}\'';
 $string['restore'] = 'Restore';
+$string['removeallwikitags'] = 'Remove all wiki tags';
 $string['restoreconfirm'] = 'Are you sure you want to restore version #{$a}?';
 $string['restoreerror'] = 'Version #{$a} could not be restored';
 $string['restorethis'] = 'Restore this version';
@@ -148,6 +149,7 @@
 $string['searchresult'] = 'Search results:';
 $string['searchwikis'] = 'Search wikis';
 $string['special'] = 'Special';
+$string['tagsdeleted'] = 'Wiki tags have been deleted';
 $string['teacherrating'] = 'Teacher rating';
 $string['timesrating']='This page has been rated  {$a->c} times with an average of: {$a->s}';
 $string['updatedpages'] = "Updated pages";
Index: moodle/mod/wiki/lib.php
--- moodle/mod/wiki/lib.php Base (1.91)
+++ moodle/mod/wiki/lib.php Locally Modified (Based On 1.91)
@@ -141,6 +141,46 @@
     return $result;
 }
 
+function wiki_reset_userdata($data) {
+    global $CFG,$DB;
+    require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
+
+    $componentstr = get_string('modulenameplural', 'wiki');
+    $status = array();
+
+    //get the wiki(s) in this course.
+    if (!$wikis = $DB->get_records('wiki', array('course' => $data->courseid))) {
+        return false;
+    }
+    $errors = false;
+    foreach ($wikis as $wiki) {
+        # Get subwiki information #
+        $subwikis = $DB->get_records('wiki_subwikis', array('wikiid' => $wiki->id));
+
+        foreach ($subwikis as $subwiki) {
+            if ($pages = $DB->get_records('wiki_pages', array('subwikiid' => $subwiki->id))) {
+                foreach ($pages as $page) {
+                    $tags = tag_get_tags_array('wiki_page', $page->id);
+                    foreach ($tags as $tagid => $tagname) {
+                        // Delete the related tag_instances related to the wiki page.
+                        if (!$DB->delete_records('tag_instance', array('tagid' => $tagid, 'itemtype' => 'wiki_page', 'itemid' => $page->id), IGNORE_MISSING)) {
+                            $errors = true;
+                        }
+                        $status[] = array('component' => $componentstr, 'item' => get_string('tagsdeleted', 'wiki'), 'error' => $errors);
+                    }
+                }
+            }
+        }
+    }
+    return $status;
+}
+
+
+function wiki_reset_course_form_definition(&$mform) {
+    $mform->addElement('header', 'wikiheader', get_string('modulenameplural', 'wiki'));
+    $mform->addElement('advcheckbox', 'reset_wiki_tags', get_string('removeallwikitags','wiki'));
+}
+
 /**
  * Return a small object with summary information about what a
  * user has done with a given particular instance of this module
