$sql_find="SELECT * FROM $TABLECOURS WHERE code LIKE '%".$search_term_safe."%' OR title LIKE '%".$search_term_safe."%' OR tutor_name LIKE '%".$search_term_safe."%'";
$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.
// 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";
$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)
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."')";
$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']."'";
$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);
$result=api_sql_query($sql);
return get_lang("EditCourseCategorySucces");
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
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @param string $direction : the direction we are moving the course to (up or down)
* @param string $direction : the direction we are moving the course to (up or down)
* string $course2move : the course we are moving
* string $course2move : the course we are moving
* @return string a language variable saying that the course was moved.
* @return string a language variable saying that the course was moved.
*/
*/
function move_category($direction, $category2move)
function move_category($direction, $category2move)
{
{
global $_user;
global $_user;
@ -683,19 +670,25 @@ function move_category($direction, $category2move)