Permalink
Browse files

MDL-26674 wiki2.0: Fixed wiki activity log

  • Loading branch information...
1 parent 3c4111e commit f3463229bdc9637cb802dbfdd88ebeeeb7658eb8 @dvillemure dvillemure committed with rajeshtaneja Feb 24, 2012
View
2 mod/wiki/comments.php
@@ -59,7 +59,7 @@
require_login($course->id, true, $cm);
-add_to_log($course->id, 'wiki', 'comments', 'comments.php?id=' . $cm->id, $wiki->id);
+add_to_log($course->id, 'wiki', 'view comments', "comments.php?pageid=$pageid", $page->title, $cm->id);
/// Print the page header
$wikipage = new page_wiki_comments($wiki, $subwiki, $cm);
View
19 mod/wiki/create.php
@@ -66,8 +66,6 @@
require_login($course->id, true, $cm);
-add_to_log($course->id, 'createpage', 'createpage', 'view.php?id=' . $cm->id, $wiki->id);
-
$wikipage = new page_wiki_create($wiki, $subwiki, $cm);
if (!empty($swid)) {
@@ -80,22 +78,27 @@
$wikipage->set_uid($uid);
}
-if (!empty($title)) {
- $wikipage->set_title($title);
-} else {
- $wikipage->set_title(get_string('newpage', 'wiki'));
+if (empty($title)) {
+ $title = get_string('newpage', 'wiki');
}
+$wikipage->set_title($title);
// set page action, and initialise moodle form
$wikipage->set_action($action);
switch ($action) {
case 'create':
- $wikipage->create_page($title);
+ $newpageid = $wikipage->create_page($title);
+ $newtitle = $wikipage->get_title();
+ add_to_log($course->id, 'wiki', 'add page', "view.php?pageid=$newpageid", "$newtitle", $cm->id);
+ redirect($CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $newpageid);
break;
case 'new':
if ((int)$wiki->forceformat == 1 && !empty($title)) {
- $wikipage->create_page($title);
+ $newpageid = $wikipage->create_page($title);
+ $newtitle = $wikipage->get_title();
+ add_to_log($course->id, 'wiki', 'add page', "view.php?pageid=$newpageid", "$newtitle", $cm->id);
+ redirect($CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $newpageid);
} else {
// create link from moodle navigation block without pagetitle
$wikipage->print_header();
View
2 mod/wiki/diff.php
@@ -74,6 +74,8 @@
$wikipage->set_page($page);
$wikipage->set_comparison($compare, $comparewith);
+add_to_log($course->id, "wiki", "view diff", "diff.php?pageid=$pageid&comparewith=$comparewith&compare=$compare", "$page->title", $cm->id);
+
$wikipage->print_header();
$wikipage->print_content();
View
3 mod/wiki/edit.php
@@ -77,8 +77,6 @@
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:editpage', $context);
-add_to_log($course->id, 'wiki', 'edit', "edit.php?id=$cm->id", "$wiki->id");
-
if ($option == get_string('save', 'wiki')) {
if (!confirm_sesskey()) {
print_error(get_string('invalidsesskey', 'wiki'));
@@ -87,6 +85,7 @@
$wikipage->set_page($page);
$wikipage->set_newcontent($newcontent);
$wikipage->set_upload(true);
+ add_to_log($course->id, 'wiki', 'update', "view.php?pageid=$pageid", "$page->title", $cm->id);
} else {
if ($option == get_string('preview')) {
if (!confirm_sesskey()) {
View
2 mod/wiki/history.php
@@ -61,7 +61,7 @@
require_login($course->id, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:viewpage', $context);
-add_to_log($course->id, 'wiki', 'history', 'history.php?id=' . $cm->id, $wiki->id);
+add_to_log($course->id, 'wiki', 'view history', "history.php?pageid=$pageid", "$page->title", $cm->id);
/// Print the page header
$wikipage = new page_wiki_history($wiki, $subwiki, $cm);
View
2 mod/wiki/index.php
@@ -45,7 +45,7 @@
$PAGE->set_pagelayout('incourse');
$context = get_context_instance(CONTEXT_COURSE, $course->id);
-add_to_log($course->id, 'wiki', 'view all', "index.php?id=$course->id", "");
+add_to_log($course->id, 'wiki', 'view all', "index.php?id=$id", "");
/// Get all required stringswiki
$strwikis = get_string("modulenameplural", "wiki");
View
4 mod/wiki/instancecomments.php
@@ -82,6 +82,7 @@
}
if ($action == 'delete') {
+ add_to_log($course->id, 'wiki', 'delete comment', "comments.php?pageid=$pageid", "$page->title", $cm->id);
$comm->set_action($action, $commentid, 0);
} else {
if (empty($newcontent)) {
@@ -93,9 +94,10 @@
}
if ($action == 'edit') {
+ add_to_log($course->id, 'wiki', 'update comment', "comments.php?pageid=$pageid", "$page->title", $cm->id);
$comm->set_action($action, $id, $content);
-
} else {
+ add_to_log($course->id, 'wiki', 'add comment', "comments.php?pageid=$pageid", "$page->title", $cm->id);
$action = 'add';
$comm->set_action($action, 0, $content);
}
View
2 mod/wiki/lock.php
@@ -71,8 +71,6 @@
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:editpage', $context);
-//add_to_log($course->id, "wiki", "lock", "lock.php?id=$cm->id", "$wiki->id");
-
$wikipage = new page_wiki_lock($wiki, $subwiki, $cm);
$wikipage->set_page($page);
View
1 mod/wiki/map.php
@@ -62,6 +62,7 @@
/// Finish the page
$wikipage = new page_wiki_map($wiki, $subwiki, $cm);
+add_to_log($course->id, "wiki", "view map", "map.php?pageid=$pageid", "$page->title", $cm->id);
$wikipage->set_view($option);
$wikipage->set_page($page);
View
3 mod/wiki/overridelocks.php
@@ -67,8 +67,6 @@
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:overridelock', $context);
-add_to_log($course->id, "wiki", "overridelocks", "overridelocks.php?id=$cm->id", "$wiki->id");
-
if (!confirm_sesskey()) {
print_error(get_string('invalidsesskey', 'wiki'));
}
@@ -79,6 +77,7 @@
if (!empty($section)) {
$wikipage->set_section($sectioncontent, $section);
}
+add_to_log($course->id, "wiki", "overridelocks", "view.php?pageid=$pageid", "$page->title", $cm->id);
$wikipage->print_header();
View
13 mod/wiki/pagelib.php
@@ -221,6 +221,14 @@ function set_title($title) {
}
/**
+ * returns title of the wiki page
+ * @return string
+ */
+ function get_title() {
+ return $this->title;
+ }
+
+ /**
* Method to set current group id
* @param int $gid Current group id
*/
@@ -935,11 +943,14 @@ function create_page($pagetitle) {
$this->subwiki = wiki_get_subwiki($swid);
}
if ($data) {
+ $this->set_title($data->pagetitle);
$id = wiki_create_page($this->subwiki->id, $data->pagetitle, $data->pageformat, $USER->id);
} else {
+ $this->set_title($pagetitle);
$id = wiki_create_page($this->subwiki->id, $pagetitle, $PAGE->activityrecord->defaultformat, $USER->id);
}
- redirect($CFG->wwwroot . '/mod/wiki/edit.php?pageid=' . $id);
+ $this->page = $id;
+ return $id;
}
}
View
3 mod/wiki/prettyview.php
@@ -56,11 +56,10 @@
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:viewpage', $context);
-add_to_log($course->id, "wiki", "view", "prettyview.php?pageid=$pageid", "$wiki->id");
-
$wikipage = new page_wiki_prettyview($wiki, $subwiki, $cm);
$wikipage->set_page($page);
+add_to_log($course->id, "wiki", "view pretty", "prettyview.php?pageid=$pageid", "$page->title", $cm->id);
$wikipage->print_header();
$wikipage->print_content();
View
3 mod/wiki/restoreversion.php
@@ -60,8 +60,6 @@
require_login($course->id, true, $cm);
-add_to_log($course->id, "restore", "restore", "view.php?id=$cm->id", "$wiki->id");
-
if ($confirm) {
if (!confirm_sesskey()) {
print_error(get_string('invalidsesskey', 'wiki'));
@@ -77,6 +75,7 @@
$wikipage->set_versionid($versionid);
}
+add_to_log($course->id, "wiki", "restore", "view.php?pageid=$pageid", "$page->title : $versionid", $cm->id);
$wikipage->print_header();
$wikipage->print_content();
View
10 mod/wiki/view.php
@@ -269,8 +269,6 @@
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:viewpage', $context);
-add_to_log($course->id, 'wiki', 'view', 'view.php?id=' . $cm->id, $wiki->id);
-
// Update 'viewed' state if required by completion system
require_once($CFG->libdir . '/completionlib.php');
$completion = new completion_info($course);
@@ -294,6 +292,14 @@
$wikipage->set_gid($currentgroup);
$wikipage->set_page($page);
+if($pageid) {
+ add_to_log($course->id, 'wiki', 'view', "view.php?pageid=$pageid", "$page->title", $cm->id);
+} else if($id) {
+ add_to_log($course->id, 'wiki', 'view', "view.php?id=$id", "$page->title", $cm->id);
+} else if($wid && $title) {
+ add_to_log($course->id, 'wiki', 'view', "view.php?wid=$wid&title=$title", "$page->title", $cm->id);
+}
+
$wikipage->print_header();
$wikipage->print_content();
View
2 mod/wiki/viewversion.php
@@ -67,6 +67,8 @@
$wikipage->set_page($page);
$wikipage->set_versionid($versionid);
+add_to_log($course->id, "wiki", "view version", "viewversion.php?pageid=$pageid&versionid=$versionid", "$page->title", $cm->id);
+
$wikipage->print_header();
$wikipage->print_content();

0 comments on commit f346322

Please sign in to comment.