Beispiel #1
0
function nv_menu_del_sub($id, $parentid)
{
    global $module_data, $module_name, $db, $admin_info;
    $sql = 'SELECT title, subitem FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . $id . ' AND parentid=' . $parentid;
    $row = $db->query($sql)->fetch();
    if (empty($row)) {
        die('NO_' . $id);
    }
    $sql = 'DELETE FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . $id;
    if ($db->exec($sql)) {
        // Cap nhat cho menu cha
        if ($parentid > 0) {
            $sql = 'SELECT subitem FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . $parentid;
            $subitem = $db->query($sql)->fetch();
            if (!empty($subitem)) {
                $subitem = implode(',', array_diff(array_filter(array_unique(explode(',', $subitem['subitem']))), array($id)));
                $stmt = $db->prepare('UPDATE ' . NV_PREFIXLANG . '_' . $module_data . '_rows SET subitem= :subitem WHERE id=' . $parentid);
                $stmt->bindParam(':subitem', $subitem, PDO::PARAM_STR, strlen($subitem));
                $stmt->execute();
            }
        }
        $subitem = !empty($row['subitem']) ? explode(',', $row['subitem']) : array();
        foreach ($subitem as $id) {
            $sql = 'SELECT parentid FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE id=' . $id;
            list($parentid) = $db->query($sql)->fetch(3);
            nv_menu_del_sub($id, $parentid);
            nv_insert_logs(NV_LANG_DATA, $module_name, 'Delete menu item', 'Item ID ' . $id, $admin_info['userid']);
        }
    }
}
Beispiel #2
0
                    }
                    $db->query("UPDATE " . NV_PREFIXLANG . "_" . $module_data . "_rows SET subitem= '" . implode(',', $arr_item_menu) . "' WHERE mid=" . $mid_old . " AND id=" . $pa_old);
                }
                $nv_Cache->delMod($module_name);
                Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&mid=' . $post['mid'] . '&parentid=' . $post['parentid']);
                exit;
            } else {
                $error = $lang_module['errorsave'];
            }
        }
    }
}
if ($nv_Request->get_title('action', 'post') == 'delete' and $nv_Request->isset_request('idcheck', 'post')) {
    $array_id = $nv_Request->get_typed_array('idcheck', 'post', 'int');
    foreach ($array_id as $id) {
        nv_menu_del_sub($id, $post['parentid']);
    }
    menu_fix_order($post['mid']);
    $nv_Cache->delMod($module_name);
}
$sql = 'SELECT * FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE mid = ' . $post['mid'] . ' AND parentid=' . $post['parentid'] . ' ORDER BY weight';
$result = $db->query($sql);
$arr_table = array();
$num = 0;
while ($row = $result->fetch()) {
    ++$num;
    $sql = 'SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $module_data . '_rows WHERE parentid=' . $row['id'];
    $nu = $db->query($sql)->fetchColumn();
    $row['sub'] = sizeof(array_filter(explode(',', $row['subitem'])));
    $groups_view = array();
    $array_groups_view = explode(',', $row['groups_view']);
Beispiel #3
0
<?php

/**
 * @Project NUKEVIET 4.x
 * @Author VINADES.,JSC (contact@vinades.vn)
 * @Copyright (C) 2014 VINADES.,JSC. All rights reserved
 * @License GNU/GPL version 2 or any later version
 * @Createdate 20-03-2011 20:08
 */
if (!defined('NV_IS_FILE_ADMIN')) {
    die('Stop!!!');
}
if (!defined('NV_IS_AJAX')) {
    die('Wrong URL');
}
$id = $nv_Request->get_int('id', 'post', 0);
$mid = $nv_Request->get_int('mid', 'post', 0);
$parentid = $nv_Request->get_int('parentid', 'post', 0);
nv_menu_del_sub($id, $parentid);
menu_fix_order($mid);
nv_del_moduleCache($module_name);
include NV_ROOTDIR . '/includes/header.php';
echo 'OK_' . $id . '_' . $mid . '_' . $parentid;
include NV_ROOTDIR . '/includes/footer.php';