diff --git a/main/admin/course_category.php b/main/admin/course_category.php index d03192b933..0b2ca4af13 100644 --- a/main/admin/course_category.php +++ b/main/admin/course_category.php @@ -1,4 +1,4 @@ - - -<< - -0){ + $parent_id=Database::fetch_row($result); + } + ?> + + << + + - -<< - -

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
:
:
- /> - /> -
 " />
-
- - + + << + +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
:
:
+ /> + /> +
 " />
+
+ + - -
  • - " alt="" align="absbottom" /> - " alt ="" /> - " alt="" /> - " alt="" /> - - ( - ) -
  • - -0) +{ + foreach($Categories as $enreg) { - echo get_lang("NoCategories"); + ?> +
  • + " alt="" align="absbottom" /> + " alt ="" /> + " alt="" /> + " alt="" /> + + ( - ) +
  • + - - + '$row[tree_pos]'",__FILE__,__LINE__); + api_sql_query("UPDATE $tbl_category SET tree_pos=tree_pos-1 WHERE tree_pos > '".$row['tree_pos']."'",__FILE__,__LINE__); api_sql_query("DELETE FROM $tbl_category WHERE code='$node'",__FILE__,__LINE__); if(!empty($row['parent_id'])) @@ -268,17 +278,20 @@ function addNode($code,$name,$canHaveCourses,$parent_id) global $tbl_category; $canHaveCourses=$canHaveCourses?'TRUE':'FALSE'; + $code = Database::escape_string($code); + $name = Database::escape_string($name); + $parent_id = Database::escape_string($parent_id); $result=api_sql_query("SELECT 1 FROM $tbl_category WHERE code='$code'",__FILE__,__LINE__); - if(mysql_num_rows($result)) + if(Database::num_rows($result)) { return false; } $result=api_sql_query("SELECT MAX(tree_pos) AS maxTreePos FROM $tbl_category",__FILE__,__LINE__); - $row=mysql_fetch_array($result); + $row=Database::fetch_array($result); $tree_pos=$row['maxTreePos']+1; @@ -294,12 +307,15 @@ function editNode($code,$name,$canHaveCourses,$old_code) global $tbl_category; $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) { $result=api_sql_query("SELECT 1 FROM $tbl_category WHERE code='$code'",__FILE__,__LINE__); - if(mysql_num_rows($result)) + if(Database::num_rows($result)) { return false; } @@ -313,14 +329,17 @@ function editNode($code,$name,$canHaveCourses,$old_code) function moveNodeUp($code,$tree_pos,$parent_id) { global $tbl_category; - + $code = Database::escape_string($code); + $tree_pos = Database::escape_string($tree_pos); + $parent_id = Database::escape_string($parent_id); + $result=api_sql_query("SELECT code,tree_pos FROM $tbl_category WHERE parent_id ".(empty($parent_id)?"IS NULL":"='$parent_id'")." AND tree_pos<'$tree_pos' ORDER BY tree_pos DESC LIMIT 0,1",__FILE__,__LINE__); - if(!$row=mysql_fetch_array($result)) + if(!$row=Database::fetch_array($result)) { $result=api_sql_query("SELECT code,tree_pos FROM $tbl_category WHERE parent_id ".(empty($parent_id)?"IS NULL":"='$parent_id'")." AND tree_pos>'$tree_pos' ORDER BY tree_pos DESC LIMIT 0,1",__FILE__,__LINE__); - if(!$row=mysql_fetch_array($result)) + if(!$row=Database::fetch_array($result)) { return false; } @@ -333,10 +352,10 @@ function moveNodeUp($code,$tree_pos,$parent_id) function updateFils($category) { global $tbl_category; - + $category = Database::escape_string($category); $result=api_sql_query("SELECT parent_id FROM $tbl_category WHERE code='$category'",__FILE__,__LINE__); - if($row=mysql_fetch_array($result)) + if($row=Database::fetch_array($result)) { updateFils($row['parent_id']); } @@ -349,14 +368,14 @@ function updateFils($category) function compterFils($pere,$cpt) { global $tbl_category; - + $pere = Database::escape_string($pere); $result=api_sql_query("SELECT code FROM $tbl_category WHERE parent_id='$pere'",__FILE__,__LINE__); - while($row=mysql_fetch_array($result)) + while($row=Database::fetch_array($result)) { $cpt=compterFils($row['code'],$cpt); } return ($cpt+1); } -?> +?> \ No newline at end of file