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(); - ?> -
- -
@@ -191,14 +175,11 @@ if($action == 'add' || $action == 'edit')
+} \ No newline at end of file diff --git a/main/admin/course_edit.php b/main/admin/course_edit.php index 7e663dacc6..91c62a6ee4 100644 --- a/main/admin/course_edit.php +++ b/main/admin/course_edit.php @@ -95,13 +95,12 @@ $form->add_textfield( 'title', get_lang('Title'),true, array ('size' => '60')); $form->applyFilter('title','html_filter'); $form->applyFilter('title','trim'); // code -$form->add_textfield('visual_code', get_lang('CourseCode')); -$form->addElement('static', null, null, get_lang('OnlyLettersAndNumbers')); +$form->add_textfield('visual_code', array(get_lang('CourseCode'), get_lang('OnlyLettersAndNumbers'))); $form->applyFilter('visual_code','strtoupper'); $form->applyFilter('visual_code','html_filter'); //$form->add_textfield('tutor_name', get_lang('CourseTitular')); -$form->addElement('select', 'tutor_name', get_lang('CourseTitular'), $platform_teachers, array('style'=>'width:350px')); +$form->addElement('select', 'tutor_name', get_lang('CourseTitular'), $platform_teachers, array('style'=>'width:350px','id'=>'tutor_name_id', 'class'=>'chzn-select')); $form->applyFilter('tutor_name','html_filter'); //$form->addElement('select', 'course_teachers', get_lang('CourseTeachers'), $teachers, 'multiple=multiple size="4" style="width: 150px;"'); @@ -115,7 +114,7 @@ $element_template = << * {label}
-
+
{error}
@@ -132,7 +131,7 @@ $form -> addGroup($group,'group',get_lang('CourseTeachers'),'
{element}'); -$categories_select = $form->addElement('select', 'category_code', get_lang('CourseFaculty'), $categories , array('style'=>'width:350px')); +$categories_select = $form->addElement('select', 'category_code', get_lang('CourseFaculty'), $categories , array('style'=>'width:350px','id'=>'category_code_id', 'class'=>'chzn-select')); CourseManager::select_and_sort_categories($categories_select); $form->add_textfield( 'department_name', get_lang('CourseDepartment'), false,array ('size' => '60')); diff --git a/main/admin/course_list.php b/main/admin/course_list.php index 61a004ad9f..45710537bf 100644 --- a/main/admin/course_list.php +++ b/main/admin/course_list.php @@ -66,7 +66,8 @@ function get_course_data($from, $number_of_items, $column, $direction) { $course_table = Database :: get_main_table(TABLE_MAIN_COURSE); $users_table = Database :: get_main_table(TABLE_MAIN_USER); $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER); - $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) { $course[1] = ''.get_course_visibility_icon($course[9]).''.$course[1].''; $course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No'); $course[6] = $course[6] == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No'); - //$course[7] = CourseManager :: is_virtual_course_from_system_code($course[7]) ? get_lang('Yes') : get_lang('No'); - //$course_rem = array($course[0], $course[1], $course[2], $course[3], $course[4], $course[5], $course[6], $course[7], $course[8], $course[9]); + $course_rem = array($course[0], $course[1], $course[2], $course[3], $course[4], $course[5], $course[6], $course[7], $course[8]); $courses[] = $course_rem; }