$myquery = "SELECT * FROM $tbl_category WHERE code ='$category'";
$result = Database::query($myquery);
if(Database::num_rows($result)==0)
{
if(Database::num_rows($result)==0) {
$category = '';
}
}
if(empty($action))
{
$myquery="SELECT t1.name,t1.code,t1.parent_id,t1.tree_pos,t1.children_count,COUNT(DISTINCT t3.code) AS nbr_courses FROM $tbl_category t1 LEFT JOIN $tbl_category t2 ON t1.code=t2.parent_id LEFT JOIN $tbl_course t3 ON t3.category_code=t1.code WHERE t1.parent_id ".(empty($category)?"IS NULL":"='$category'")." GROUP BY t1.name,t1.code,t1.parent_id,t1.tree_pos,t1.children_count ORDER BY t1.tree_pos";
$result=Database::query($myquery);
if(empty($action)) {
$myquery = "SELECT t1.name,t1.code,t1.parent_id,t1.tree_pos,t1.children_count,COUNT(DISTINCT t3.code) AS nbr_courses
FROM $tbl_category t1 LEFT JOIN $tbl_category t2 ON t1.code=t2.parent_id LEFT JOIN $tbl_course t3 ON t3.category_code=t1.code
WHERE t1.parent_id ".(empty($category)?"IS NULL":"='$category'")."
GROUP BY t1.name,t1.code,t1.parent_id,t1.tree_pos,t1.children_count ORDER BY t1.tree_pos";
@ -306,8 +282,7 @@ function addNode($code,$name,$canHaveCourses,$parent_id)
$result=Database::query("SELECT 1 FROM $tbl_category WHERE code='$code'");
if(Database::num_rows($result))
{
if (Database::num_rows($result)) {
return false;
}
@ -316,7 +291,8 @@ function addNode($code,$name,$canHaveCourses,$parent_id)
$row=Database::fetch_array($result);
$tree_pos=$row['maxTreePos']+1;
$code = generate_course_code($code);
Database::query("INSERT INTO $tbl_category(name,code,parent_id,tree_pos,children_count,auth_course_child) VALUES('$name','$code',".(empty($parent_id)?"NULL":"'$parent_id'").",'$tree_pos','0','$canHaveCourses')");
updateFils($parent_id);
@ -326,24 +302,23 @@ function addNode($code,$name,$canHaveCourses,$parent_id)
function editNode($code,$name,$canHaveCourses,$old_code)
{
global $tbl_category;
global $tbl_category, $tbl_course;
$canHaveCourses=$canHaveCourses?'TRUE':'FALSE';
$code = Database::escape_string($code);
$name = Database::escape_string($name);
$old_code = Database::escape_string($old_code);
if($code != $old_code)
{
if($code != $old_code) {
$result=Database::query("SELECT 1 FROM $tbl_category WHERE code='$code'");
if(Database::num_rows($result))
{
if(Database::num_rows($result)) {
return false;
}
}
Database::query("UPDATE $tbl_category SET name='$name',code='$code',auth_course_child='$canHaveCourses' WHERE code='$old_code'");
$code = generate_course_code($code);
Database::query("UPDATE $tbl_category SET name='$name', code='$code',auth_course_child='$canHaveCourses' WHERE code='$old_code'");
$sql = "UPDATE $tbl_course SET category_code = '$code' WHERE category_code = '$old_code' ";
Database::query($sql);
return true;
}
@ -399,5 +374,4 @@ function compterFils($pere,$cpt)
$sql = "SELECT code AS col0, visual_code AS col1, title AS col2, course_language AS col3, category_code AS col4, subscribe AS col5, unsubscribe AS col6, tutor_name as col7, code AS col8, visibility AS col9,directory as col10 FROM $course_table";
$sql = "SELECT code AS col0, visual_code AS col1, title AS col2, course_language AS col3, category_code AS col4, subscribe AS col5, unsubscribe AS col6, tutor_name as col7, code AS col8, visibility AS col9,directory as col10
FROM $course_table";
//$sql = "SELECT code AS col0, visual_code AS col1, title AS col2, course_language AS col3, category_code AS col4, subscribe AS col5, unsubscribe AS col6, code AS col7, tutor_name as col8, code AS col9, visibility AS col10,directory as col11 FROM $course_table";
global $_configuration;
@ -105,8 +106,7 @@ function get_course_data($from, $number_of_items, $column, $direction) {