Fixing function "generate_couser_code" callings

skala
Julio Montoya 12 years ago
parent aa87258f30
commit d76fbf3fe6
  1. 10
      main/admin/course_category.php
  2. 2
      main/survey/survey.lib.php

@ -83,9 +83,9 @@ if (!empty($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'") . "
$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);
@ -265,7 +265,7 @@ function addNode($code, $name, $canHaveCourses, $parent_id) {
$tree_pos = $row['maxTreePos'] + 1;
$code = generate_course_code($code);
$code = CourseManager::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);
@ -287,7 +287,7 @@ function editNode($code, $name, $canHaveCourses, $old_code) {
return false;
}
}
$code = generate_course_code($code);
$code = CourseManager::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);

@ -224,7 +224,7 @@ class survey_manager {
$course_id = api_get_course_int_id();
$sql = "INSERT INTO $table_survey (c_id, code, title, subtitle, author, lang, avail_from, avail_till, is_shared, template, intro, surveythanks, creation_date, anonymous".$additional['columns'].", session_id) VALUES (
$course_id,
'".Database::escape_string(strtolower(generate_course_code(api_substr($values['survey_code'],0))))."',
'".Database::escape_string(strtolower(CourseManager::generate_course_code(api_substr($values['survey_code'],0))))."',
'".Database::escape_string($values['survey_title'])."',
'".Database::escape_string($values['survey_subtitle'])."',
'".Database::escape_string($_user['user_id'])."',

Loading…
Cancel
Save