Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-34435 reports: Log category actions

  • Loading branch information...
commit 95d1d0373b9ad95da517722580d3dd87df74e04e 1 parent 9da506c
@FMCorz FMCorz authored
View
2  course/category.php
@@ -144,6 +144,7 @@
require_capability('moodle/course:visibility', $coursecontext);
// Set the visibility of the course. we set the old flag when user manually changes visibility of course.
$DB->update_record('course', array('id' => $course->id, 'visible' => $visible, 'visibleold' => $visible, 'timemodified' => time()));
+ add_to_log($course->id, "course", ($visible ? 'show' : 'hide'), "edit.php?id=$course->id", $course->id);
}
}
@@ -172,6 +173,7 @@
}
$DB->set_field('course', 'sortorder', $swapcourse->sortorder, array('id' => $movecourse->id));
$DB->set_field('course', 'sortorder', $movecourse->sortorder, array('id' => $swapcourse->id));
+ add_to_log($movecourse->id, "course", "move", "edit.php?id=$movecourse->id", $movecourse->id);
}
}
View
3  course/editcategory.php
@@ -102,6 +102,7 @@
$newcategory->theme = $data->theme;
}
+ $logaction = 'update';
if ($id) {
// Update an existing category.
$newcategory->id = $category->id;
@@ -119,10 +120,12 @@
$category = create_course_category($newcategory);
$newcategory->id = $category->id;
$categorycontext = $category->context;
+ $logaction = 'add';
}
$newcategory = file_postupdate_standard_editor($newcategory, 'description', $editoroptions, $categorycontext, 'coursecat', 'description', 0);
$DB->update_record('course_categories', $newcategory);
+ add_to_log(SITEID, "category", $logaction, "editcategory.php?id=$newcategory->id", $newcategory->id);
fix_course_sortorder();
redirect('category.php?id='.$newcategory->id.'&categoryedit=on');
View
1  course/index.php
@@ -232,6 +232,7 @@
if ($swapcategory and $movecategory) {
$DB->set_field('course_categories', 'sortorder', $swapcategory->sortorder, array('id'=>$movecategory->id));
$DB->set_field('course_categories', 'sortorder', $movecategory->sortorder, array('id'=>$swapcategory->id));
+ add_to_log(SITEID, "category", "move", "editcategory.php?id=$movecategory->id", $movecategory->id);
}
// finally reorder courses
View
15 course/lib.php
@@ -68,6 +68,7 @@ function make_log_url($module, $url) {
case 'lib':
case 'admin':
case 'calendar':
+ case 'category':
case 'mnet course':
if (strpos($url, '../') === 0) {
$url = ltrim($url, '.');
@@ -3472,6 +3473,7 @@ function category_delete_full($category, $showfeedback=true) {
// finally delete the category and it's context
$DB->delete_records('course_categories', array('id'=>$category->id));
delete_context(CONTEXT_COURSECAT, $category->id);
+ add_to_log(SITEID, "category", "delete", "index.php", "$category->name (ID $category->id)");
events_trigger('course_category_deleted', $category);
@@ -3527,6 +3529,7 @@ function category_delete_move($category, $newparentid, $showfeedback=true) {
// finally delete the category and it's context
$DB->delete_records('course_categories', array('id'=>$category->id));
delete_context(CONTEXT_COURSECAT, $category->id);
+ add_to_log(SITEID, "category", "delete", "index.php", "$category->name (ID $category->id)");
events_trigger('course_category_deleted', $category);
@@ -3573,6 +3576,7 @@ function move_courses($courseids, $categoryid) {
}
$DB->update_record('course', $course);
+ add_to_log($course->id, "course", "move", "edit.php?id=$course->id", $course->id);
$context = context_course::instance($course->id);
context_moved($context, $newparent);
@@ -3605,6 +3609,7 @@ function course_category_hide($category) {
$DB->set_field('course', 'visible', 0, array('category' => $cat->id));
}
}
+ add_to_log(SITEID, "category", "hide", "editcategory.php?id=$category->id", $category->id);
}
/**
@@ -3628,6 +3633,7 @@ function course_category_show($category) {
$DB->execute("UPDATE {course} SET visible = visibleold WHERE category = ?", array($cat->id));
}
}
+ add_to_log(SITEID, "category", "show", "editcategory.php?id=$category->id", $category->id);
}
/**
@@ -3641,12 +3647,10 @@ function move_category($category, $newparentcat) {
$hidecat = false;
if (empty($newparentcat->id)) {
- $DB->set_field('course_categories', 'parent', 0, array('id'=>$category->id));
-
+ $DB->set_field('course_categories', 'parent', 0, array('id' => $category->id));
$newparent = context_system::instance();
-
} else {
- $DB->set_field('course_categories', 'parent', $newparentcat->id, array('id'=>$category->id));
+ $DB->set_field('course_categories', 'parent', $newparentcat->id, array('id' => $category->id));
$newparent = context_coursecat::instance($newparentcat->id);
if (!$newparentcat->visible and $category->visible) {
@@ -3660,6 +3664,9 @@ function move_category($category, $newparentcat) {
// now make it last in new category
$DB->set_field('course_categories', 'sortorder', MAX_COURSES_IN_CATEGORY*MAX_COURSE_CATEGORIES, array('id'=>$category->id));
+ // Log action.
+ add_to_log(SITEID, "category", "move", "editcategory.php?id=$category->id", $category->id);
+
// and fix the sortorders
fix_course_sortorder();
View
8 lib/db/log.php
@@ -40,6 +40,9 @@
array('module'=>'course', 'action'=>'view', 'mtable'=>'course', 'field'=>'fullname'),
array('module'=>'course', 'action'=>'view section', 'mtable'=>'course_sections', 'field'=>'name'),
array('module'=>'course', 'action'=>'update', 'mtable'=>'course', 'field'=>'fullname'),
+ array('module'=>'course', 'action'=>'hide', 'mtable'=>'course', 'field'=>'fullname'),
+ array('module'=>'course', 'action'=>'show', 'mtable'=>'course', 'field'=>'fullname'),
+ array('module'=>'course', 'action'=>'move', 'mtable'=>'course', 'field'=>'fullname'),
array('module'=>'course', 'action'=>'enrol', 'mtable'=>'course', 'field'=>'fullname'), // there should be some way to store user id of the enrolled user!
array('module'=>'course', 'action'=>'unenrol', 'mtable'=>'course', 'field'=>'fullname'), // there should be some way to store user id of the enrolled user!
array('module'=>'course', 'action'=>'report log', 'mtable'=>'course', 'field'=>'fullname'),
@@ -47,6 +50,11 @@
array('module'=>'course', 'action'=>'report outline', 'mtable'=>'course', 'field'=>'fullname'),
array('module'=>'course', 'action'=>'report participation', 'mtable'=>'course', 'field'=>'fullname'),
array('module'=>'course', 'action'=>'report stats', 'mtable'=>'course', 'field'=>'fullname'),
+ array('module'=>'category', 'action'=>'add', 'mtable'=>'course_categories', 'field'=>'name'),
+ array('module'=>'category', 'action'=>'hide', 'mtable'=>'course_categories', 'field'=>'name'),
+ array('module'=>'category', 'action'=>'move', 'mtable'=>'course_categories', 'field'=>'name'),
+ array('module'=>'category', 'action'=>'show', 'mtable'=>'course_categories', 'field'=>'name'),
+ array('module'=>'category', 'action'=>'update', 'mtable'=>'course_categories', 'field'=>'name'),
array('module'=>'message', 'action'=>'write', 'mtable'=>'user', 'field'=>$DB->sql_concat('firstname', "' '" , 'lastname')),
array('module'=>'message', 'action'=>'read', 'mtable'=>'user', 'field'=>$DB->sql_concat('firstname', "' '" , 'lastname')),
array('module'=>'message', 'action'=>'add contact', 'mtable'=>'user', 'field'=>$DB->sql_concat('firstname', "' '" , 'lastname')),
View
2  version.php
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2012120300.06; // YYYYMMDD = weekly release date of this DEV branch
+$version = 2012120300.09; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes
Please sign in to comment.
Something went wrong with that request. Please try again.