Example #1
0
/**
 *
 * @param $id_node
 * @return
 * @author Christophe Gesché <*****@*****.**>
 *
 */
function delete_node($id_node)
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_course_node = $tbl_mdb_names['category'];
    $cat_data = get_cat_data($id_node);
    if (!$cat_data) {
        return false;
    }
    $sql_Delete = " DELETE FROM `" . $tbl_course_node . "`\n                   WHERE id= " . (int) $cat_data['id'];
    if (!claro_sql_query($sql_Delete)) {
        return false;
    }
    // Update nb_child of the parent
    delete_qty_child_father($cat_data['code_P'], 1);
    // Update treePos of next categories
    $sql_update = " UPDATE `" . $tbl_course_node . "`\n                    SET treePos = treePos - 1\n                    WHERE treePos > " . (int) $cat_data['treePos'];
    claro_sql_query($sql_update);
    return true;
}
Example #2
0
     claro_sql_query($sql_ChangeTree);
     $i++;
 }
 // Change the category edit
 $sql_ChangeInfoFaculty = " UPDATE `" . $tbl_course_node . "`";
 if ($_REQUEST['fatherCat'] == 'NULL') {
     $sql_ChangeInfoFaculty .= "SET code_P = NULL ";
 } else {
     $sql_ChangeInfoFaculty .= "SET code_P = '" . claro_sql_escape($_REQUEST['fatherCat']) . "' ";
 }
 $sql_ChangeInfoFaculty .= " WHERE id='" . (int) $_REQUEST['id'] . "'";
 claro_sql_query($sql_ChangeInfoFaculty);
 $newNbChild = $facultyEdit['nb_childs'] + 1;
 // Change the number of childeren of the father category and his parent
 $fatherChangeChild = $facultyEdit['code_P'];
 delete_qty_child_father($fatherChangeChild, $newNbChild);
 // Change the number of childeren of the new father and his parent
 $fatherChangeChild = $_REQUEST['fatherCat'];
 addNbChildFather($fatherChangeChild, $newNbChild);
 // Search nb_childs of the new father
 $nbChildFather = get_node_descendance_count($_REQUEST['fatherCat'] == 'NULL' ? null : $_REQUEST['fatherCat']);
 // Si le nouveau pere avait des enfants replace celui que l on vient de deplacer comme dernier enfant
 if ($nbChildFather > $facultyEdit['nb_childs'] + 1) {
     // Met des treePos temporaire pour celui qu on vient de deplacer et ses enfants
     $i = 1;
     while ($i <= $facultyEdit['nb_childs'] + 1) {
         $sql_TempTree = " UPDATE `" . $tbl_course_node . "`\n                                              SET treePos=" . $maxTree . "+" . $i . "\n                                              WHERE treePos=" . $newTree . "+" . $i . "-1";
         claro_sql_query($sql_TempTree);
         $i++;
     }
     // Deplace les enfants restant du pere