function pages_find_subcats(&$array, $id_cat) { global $_PAGES_CATS; foreach ($_PAGES_CATS as $key => $value) { if ($value['id_parent'] == $id_cat) { $array[] = $key; pages_find_subcats($array, $key); } } }
redirect(HOST . DIR . '/pages/pages.php?error=e_auth'); } if ($page_infos['redirect'] > 0) { $Sql->query_inject("DELETE FROM " . PREFIX . "pages WHERE id = '" . $del_redirection . "' AND redirect > 0", __LINE__, __FILE__); } redirect(HOST . DIR . url('/pages/action.php?id=' . $page_infos['redirect'], '', '&')); } elseif ($del_cat_post > 0 && $report_cat >= 0) { $remove_action = $remove_action == 'move_all' ? 'move_all' : 'remove_all'; $page_infos = $Sql->query_array(PREFIX . "pages", "encoded_title", "id_cat", "auth", "WHERE id = '" . $del_cat_post . "'", __LINE__, __FILE__); $general_auth = empty($page_infos['auth']) ? true : false; $array_auth = !empty($page_infos['auth']) ? unserialize($page_infos['auth']) : array(); if (!((!$general_auth || $User->check_auth($_PAGES_CONFIG['auth'], EDIT_PAGE)) && ($general_auth || $User->check_auth($array_auth, EDIT_PAGE)))) { $Errorh->handler('e_auth', E_USER_REDIRECT); } $sub_cats = array(); pages_find_subcats($sub_cats, $page_infos['id_cat']); $sub_cats[] = $page_infos['id_cat']; $id_to_delete = implode($sub_cats, ', '); if ($remove_action == 'move_all') { if ($report_cat > 0 && in_array($report_cat, $sub_cats) || $report_cat == $page_infos['id_cat']) { redirect(HOST . DIR . '/pages/' . url('action.php?del_cat=' . $del_cat_post . '&error=e_cat_contains_cat#errorh', '', '&')); } } if ($remove_action == 'remove_all') { $Sql->query_inject("DELETE FROM " . PREFIX . "pages WHERE id_cat IN (" . $id_to_delete . ")", __LINE__, __FILE__); $Sql->query_inject("DELETE FROM " . PREFIX . "pages_cats WHERE id IN (" . $id_to_delete . ")", __LINE__, __FILE__); $Sql->query_inject("DELETE FROM " . DB_TABLE_COM . " WHERE script = 'pages' AND idprov IN (" . $id_to_delete . ")", __LINE__); $Cache->Generate_module_file('pages'); if (array_key_exists($page_infos['id_cat'], $_PAGES_CATS) && $_PAGES_CATS[$page_infos['id_cat']]['id_parent'] > 0) { $title = $_PAGES_CATS[$_PAGES_CATS[$page_infos['id_cat']]['id_parent']]['name']; redirect(HOST . DIR . '/pages/' . url('pages.php?title=' . url_encode_rewrite($title), url_encode_rewrite($title), '&'));
function pages_find_subcats(&$array, $id_cat) { //On parcourt les catégories et on détermine les catégories filles foreach (PagesCategoriesCache::load()->get_categories() as $key => $cat) { if ($value['id_parent'] == $id_cat) { $array[] = $key; //On rappelle la fonction pour la catégorie fille pages_find_subcats($array, $key); } } }