$sql= "SELECT * FROM $tbl_courses_nodes WHERE parent_id ".(empty($category)?"IS NULL":"='".$category."'")." GROUP BY code, parent_id ORDER BY tree_pos ASC";
@ -334,14 +335,15 @@ function browse_course_categories()
echo "<ul>";
while ($row=Database::fetch_array($result))
{
if ($row['children_count'] > 0 OR count_courses_in_category($row['code'])>0)
$sql_find="SELECT * FROM $TABLECOURS WHERE code LIKE '%".$search_term_safe."%' OR title LIKE '%".$search_term_safe."%' OR tutor_name LIKE '%".$search_term_safe."%'";
@ -554,11 +540,11 @@ function store_course_category()
// step 2: we check if there is already a category with this name, if not we store it, else we give an error.
$sql="SELECT * FROM `$TABLE_USER_COURSE_CATEGORY` WHERE user_id='".$_user['user_id']."' AND title='".Database::escape_string($_POST['title_course_category'])."'ORDER BY sort DESC";
$result=api_sql_query($sql);
$result=api_sql_query($sql,__FILE__,__LINE__);
if (Database::num_rows($result) == 0)
{
$sql_insert="INSERT INTO `$TABLE_USER_COURSE_CATEGORY` (user_id, title,sort) VALUES ('".$_user['user_id']."', '".htmlentities($_POST['title_course_category'])."', '".$nextsort."')";
api_sql_query($sql_insert);
$sql_insert="INSERT INTO `$TABLE_USER_COURSE_CATEGORY` (user_id, title,sort) VALUES ('".$_user['user_id']."', '".htmlentities($_POST['title_course_category'])."', '".$nextsort."')";
$sql="UPDATE $TABLECOURSUSER SET user_course_cat='".$newcategory."', sort='".($max_sort_value+1)."' WHERE course_code='".$course_code."' AND user_id='".$_user['user_id']."'";
$result=api_sql_query($sql);
return get_lang("EditCourseCategorySucces");
@ -670,12 +657,12 @@ function move_course($direction, $course2move, $category)
/**
* moves the course one place up or down
* Moves the course one place up or down
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @param string $direction : the direction we are moving the course to (up or down)
* string $course2move : the course we are moving
* @return string a language variable saying that the course was moved.
*/
*/
function move_category($direction, $category2move)
{
global $_user;
@ -683,21 +670,27 @@ function move_category($direction, $category2move)
$sql_update1="UPDATE $table_user_defined_category SET sort='".$target_category['sort']."' WHERE id='".$source_category['id']."' AND user_id='".$_user['user_id']."'";
$sql_update2="UPDATE $table_user_defined_category SET sort='".$source_category['sort']."' WHERE id='".$target_category['id']."' AND user_id='".$_user['user_id']."'";
@ -1088,7 +1081,7 @@ function get_courses_of_user($user_id)
/**
* retrieves the user defined course categories
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @return array containing all the titles of the user defined courses with the id as key of the array
* @return array containing all the IDs of the user defined courses categories, sorted by the "sort" field
*/
function get_user_course_categories()
{
@ -1104,6 +1097,23 @@ function get_user_course_categories()
}
/**
* Retrieves the user defined course categories and all the info that goes with it
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @return array containing all the info of the user defined courses categories with the id as key of the array