Permalink
Browse files

Make it impossible to create a category in one course as the child of…

… a category in another course, fixing bug 2940
  • Loading branch information...
1 parent e303a82 commit ab4f562bb2522a5f70cb7283be6ab99a24d5035b gustav_delius committed May 6, 2005
Showing with 10 additions and 5 deletions.
  1. +10 −5 mod/quiz/category.php
View
@@ -725,14 +725,19 @@ function publish_category($publish, $categoryid) {
/**
* Creates a new category with given params
*
-* @param int newparent
-* @param string newcategory the name
-* @param string newinfo
-* @param int newpublish
-* @param int newcourse the id of the associated course
+* @param int $newparent id of the parent category
+* @param string $newcategory the name for the new category
+* @param string $newinfo the info field for the new category
+* @param int $newpublish whether to publish the category
+* @param int $newcourse the id of the associated course
*/
function add_category($newparent, $newcategory, $newinfo, $newpublish, $newcourse) {
+ // first check that the parent category is in the correct course
+ if(!(get_field('quiz_categories', 'course', 'id', $newparent) == $newcourse)) {
+ return false;
+ }
+
$cat = NULL;
$cat->parent = $newparent;
$cat->name = $newcategory;

0 comments on commit ab4f562

Please sign in to comment.