$stmt->bindParam(':gift_content', $rowcontent['gift_content'], PDO::PARAM_STR); $stmt->bindParam(':allowed_comm', $rowcontent['allowed_comm'], PDO::PARAM_STR); if ($stmt->execute()) { // Cap nhat lai group neu co thay doi if ($group_id_old != $rowcontent['group_id']) { $sql = 'DELETE FROM ' . $db_config['prefix'] . '_' . $module_data . '_group_items WHERE pro_id = ' . $rowcontent['id']; $db->query($sql); if (!empty($rowcontent['group_id'])) { $stmt = $db->prepare('INSERT INTO ' . $db_config['prefix'] . '_' . $module_data . '_group_items(pro_id, group_id) VALUES(' . $rowcontent['id'] . ', :group_id)'); foreach ($rowcontent['group_id'] as $group_id_i) { $stmt->bindParam(':group_id', $group_id_i, PDO::PARAM_STR); $stmt->execute(); } } nv_fix_group_count($rowcontent['group_id']); nv_fix_group_count($group_id_old); } // Cap nhat lai files neu co thay doi if ($pro_config['download_active']) { $rowcontent['files'] = array_map('intval', $rowcontent['files']); if ($rowcontent['files'] != $rowcontent['files_old']) { foreach ($rowcontent['files'] as $id_files) { if (!in_array($id_files, $rowcontent['files_old'])) { $db->query('INSERT INTO ' . $db_config['prefix'] . '_' . $module_data . '_files_rows (id_rows, id_files) VALUES (' . $rowcontent['id'] . ', ' . $id_files . ')'); } } foreach ($rowcontent['files_old'] as $id_files_old) { if (!in_array($id_files_old, $rowcontent['files'])) { $db->query('DELETE FROM ' . $db_config['prefix'] . '_' . $module_data . '_files_rows WHERE id_files = ' . $id_files_old); } }
/** * nv_del_group() * * @param mixed $groupid * @return */ function nv_del_group($groupid) { global $db, $module_data, $db_config; $allgroupid = GetGroupID($groupid); if ($db->query("DELETE FROM " . $db_config['prefix'] . "_" . $module_data . "_group WHERE groupid=" . $groupid)) { // Loai bo san pham ra khoi nhom $db->query('DELETE FROM ' . $db_config['prefix'] . '_' . $module_data . '_group_items WHERE group_id = ' . $groupid); // Xoa cateid $db->query('DELETE FROM ' . $db_config['prefix'] . '_' . $module_data . '_group_cateid WHERE groupid = ' . $groupid); // Xoa chi tiet nhap kho, neu nhu chi tiet nhap kho co nhom nay, thi xoa luon chi tiet nhap kho $result = $db->query('SELECT * FROM ' . $db_config['prefix'] . '_' . $module_data . '_group_quantity'); while ($row = $result->fetch()) { if (in_array($groupid, explode(',', $listgroup))) { $db->query('DELETE FROM ' . $db_config['prefix'] . '_' . $module_data . '_group_quantity WHERE pro_id = ' . $row['pro_id'] . ' AND listgroup=' . $db->quote($row['listgroup'])); } } nv_fix_group_count($allgroupid); } }
$groupidnews = $db->query("SELECT groupid FROM " . $db_config['prefix'] . "_" . $module_data . "_group WHERE groupid=" . $groupidnews)->fetchColumn(); if ($groupidnews > 0) { $result = $db->query("SELECT pro_id FROM " . $db_config['prefix'] . "_" . $module_data . "_group_items WHERE group_id='" . $groupid . "'"); while ($row = $result->fetch()) { $count = $db->query('SELECT COUNT(*) FROM ' . $db_config['prefix'] . '_' . $module_data . '_group_items WHERE group_id=' . $groupidnews . ' AND pro_id=' . $row['pro_id'])->fetchColumn(); if ($count == 0) { $stmt = $db->prepare("UPDATE " . $db_config['prefix'] . "_" . $module_data . "_group_items SET group_id=:group_id WHERE pro_id=" . $row['pro_id'] . ' AND group_id=' . $groupid); $stmt->bindParam(':group_id', $groupidnews, PDO::PARAM_STR); $stmt->execute(); } else { $db->query("DELETE FROM " . $db_config['prefix'] . "_" . $module_data . "_group_items WHERE pro_id=" . $row['pro_id'] . ' AND group_id=' . $groupid); } } nv_del_group($groupid); nv_fix_group_order(); nv_fix_group_count($groupidnews); $nv_Cache->delMod($module_name); Header("Location: " . NV_BASE_ADMINURL . "index.php?" . NV_NAME_VARIABLE . "=" . $module_name . "&" . NV_OP_VARIABLE . "=group&parentid=" . $parentid); die; } } } else { $contents = "ERR_ROWS_" . $groupid . "_" . md5($groupid . session_id() . $global_config['sitekey']) . "_" . sprintf($lang_module['delgroup_msg_rows'], $check_rows); } } } if ($contents == "NO_" . $groupid) { $sql = "DELETE FROM " . $db_config['prefix'] . "_" . $module_data . "_group_items WHERE group_id=" . $groupid; $db->exec($sql); $sql = "DELETE FROM " . $db_config['prefix'] . "_" . $module_data . "_group WHERE groupid=" . $groupid; $db->query("DELETE FROM " . $db_config['prefix'] . "_" . $module_data . "_group_cateid WHERE groupid=" . $groupid);
/** * nv_del_content_module() * * @param mixed $id * @return */ function nv_del_content_module($id) { global $db, $module_name, $module_data, $title, $db_config; $content_del = 'NO_' . $id; $title = ''; list($id, $listcatid, $title) = $db->query('SELECT id, listcatid, ' . NV_LANG_DATA . '_title FROM ' . $db_config['prefix'] . '_' . $module_data . '_rows WHERE id=' . intval($id))->fetch(3); if ($id > 0) { $number_no_del = 0; $array_catid = explode(',', $listcatid); if ($number_no_del == 0) { $sql = 'DELETE FROM ' . $db_config['prefix'] . '_' . $module_data . '_rows WHERE id=' . $id; if (!$db->exec($sql)) { ++$number_no_del; } } if ($number_no_del == 0) { // Xoa binh luan $db->query('DELETE FROM ' . NV_PREFIXLANG . '_comment WHERE module=' . $db->quote($module_name) . ' AND id = ' . $id); // Xoa block san pham $db->query('DELETE FROM ' . $db_config['prefix'] . '_' . $module_data . '_block WHERE id = ' . $id); // Xoa du lieu nhom san pham $groupid = GetGroupID($id); if ($db->query('DELETE FROM ' . $db_config['prefix'] . '_' . $module_data . '_group_items WHERE pro_id = ' . $id)) { nv_fix_group_count($groupid); } // Xoa tai lieu $db->query('DELETE FROM ' . $db_config['prefix'] . '_' . $module_data . '_files_rows WHERE id_rows=' . $id); $content_del = 'OK_' . $id; } else { $content_del = 'ERR_' . $lang_module['error_del_content']; } } return $content_del; }