diff --git a/main/admin/course_add.php b/main/admin/course_add.php index 53df031b0e..69bcda7029 100644 --- a/main/admin/course_add.php +++ b/main/admin/course_add.php @@ -18,7 +18,6 @@ api_protect_admin_script(); require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php'; require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php'; -require_once api_get_path(LIBRARY_PATH).'course.lib.php'; require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'; $table_course = Database::get_main_table(TABLE_MAIN_COURSE); $tool_name = get_lang('AddCourse'); @@ -62,8 +61,7 @@ $form->applyFilter('title', 'html_filter'); $form->applyFilter('title', 'trim'); // Code -$form->add_textfield('visual_code', get_lang('CourseCode'), false, array('size' => '20', 'maxlength' => 20)); -$form->addElement('static', null, null, get_lang('OnlyLettersAndNumbers')); +$form->add_textfield('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers')) , false, array('size' => '20', 'maxlength' => 20)); $form->applyFilter('visual_code', 'api_strtoupper'); $form->applyFilter('visual_code', 'html_filter'); diff --git a/main/admin/course_category.php b/main/admin/course_category.php old mode 100755 new mode 100644 index ee42478343..c636420a06 --- a/main/admin/course_category.php +++ b/main/admin/course_category.php @@ -18,16 +18,17 @@ $this_section=SECTION_PLATFORM_ADMIN; require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); api_protect_admin_script(); -$category=$_GET['category']; -$action=$_GET['action']; +$category = $_GET['category']; +$category = Database::escape_string($category); + +$action = $_GET['action']; $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); $errorMsg=''; -if(!empty($action)) -{ +if(!empty($action)) { if($action == 'delete') { deleteNode($_GET['id']); @@ -91,60 +92,43 @@ $interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin' Display::display_header($tool_name); -//api_display_tool_title($tool_name); - -if(!empty($category)) -{ +if(!empty($category)) { $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"; + $result = Database::query($myquery); $Categories=Database::store_result($result); } - - - -if($action == 'add' || $action == 'edit') -{ +if($action == 'add' || $action == 'edit') { ?>
- - - addElement('header', '', $form_title); $form->display(); - ?> -