Fix sub category creation see #7540

1.9.x
Julio Montoya 10 years ago
parent 132919c017
commit 8cbb366115
  1. 7
      main/admin/course_category.php
  2. 6
      main/inc/lib/course_category.lib.php

@ -3,9 +3,7 @@
/**
* @package chamilo.admin
*/
/**
* Code
*/
// name of the language file that needs to be included
$language_file = 'admin';
$cidReset = true;
@ -83,10 +81,11 @@ if ($action == 'add' || $action == 'edit') {
if (!empty($category)) {
$form_title .= ' ' . get_lang('Into') . ' ' . Security::remove_XSS($category);
}
$url = api_get_self().'?action='.Security::remove_XSS($action).'&category='.Security::remove_XSS($category).'&id='.$categoryId;
$url = api_get_self().'?action='.Security::remove_XSS($action).'&category='.Security::remove_XSS($category).'&id='.$category;
$form = new FormValidator('course_category', 'post', $url);
$form->addElement('header', '', $form_title);
$form->addElement('hidden', 'formSent', 1);
$form->addElement('text', 'code', get_lang("CategoryCode"));
$form->addElement('text', 'name', get_lang("CategoryName"));
$form->addRule('name', get_lang('PleaseEnterCategoryInfo'), 'required');

@ -101,7 +101,7 @@ function addNode($code, $name, $canHaveCourses, $parent_id)
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = trim(Database::escape_string($code));
$name = trim(Database::escape_string($name));
$parent_id = intval($parent_id);
$parent_id = trim(Database::escape_string($parent_id));
$canHaveCourses = Database::escape_string($canHaveCourses);
$code = generate_course_code($code);
@ -109,7 +109,6 @@ function addNode($code, $name, $canHaveCourses, $parent_id)
if (Database::num_rows($result)) {
return false;
}
$result = Database::query("SELECT MAX(tree_pos) AS maxTreePos FROM $tbl_category");
$row = Database::fetch_array($result);
$tree_pos = $row['maxTreePos'] + 1;
@ -142,7 +141,8 @@ function updateCategoryChildren($category)
}
$children_count = compterFils($category, 0) - 1;
Database::query("UPDATE $tbl_category SET children_count='$children_count' WHERE code='$category'");
$sql = "UPDATE $tbl_category SET children_count='$children_count' WHERE code='$category'";
Database::query($sql);
}
/**

Loading…
Cancel
Save