forked from Bonsaif/new-nconf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_class.php
86 lines (67 loc) · 3.15 KB
/
delete_class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
require_once 'include/head.php';
//set_page();
echo NConf_HTML::page_title('', 'Delete class');
if( ( ( isset($_POST["delete"]) ) AND ($_POST["delete"] == "yes") ) AND
( ( isset($_POST["id"]) ) AND ($_POST["id"] != "") )
){
# Delete entry
$query = 'DELETE FROM ConfigClasses
WHERE id_class='.$_POST["id"];
$result = db_handler($query, "result", "Delete Class");
if ($result) {
echo TXT_DELETED;
history_add("removed", "Class", $_POST["class_name"]);
# set url for redirect
$url = $_SESSION["go_back_page"];
echo '<meta http-equiv="refresh" content="'.REDIRECTING_DELAY.'; url='.$url.'">';
message($info, '<b>redirecting to:</b> <a href="'.$url.'"> [ this page ] (in '.REDIRECTING_DELAY.' seconds)</a>');
}else{
message ($error, 'Error deleting class '.$_POST["id"].':'.$query);
}
}else{
if ( !empty($_SERVER["HTTP_REFERER"]) ){
$_SESSION["after_delete_page"] = $_SERVER["HTTP_REFERER"];
}
# class name
$query = 'SELECT config_class FROM ConfigClasses where id_class='.$_GET["id"];
$class_name = db_handler($query, 'getOne', "get class name");
// Fetch attr name
$query = 'SELECT attr_name FROM ConfigAttrs, ConfigClasses WHERE id_class='.$_GET["id"].' AND fk_id_class=ConfigClasses.id_class';
$attr = db_handler($query, "array", "Get Attrs of this Class");
if ( isset($attr[0]["attr_name"]) ){
// warning message
$content = 'The class you chose to delete contains one or more attributes.
<br>If you proceed, all items belonging to this class, all attributes and
<br>any asscociated data will be lost!
<br><br>Are you <b>ABSOLUTELY SURE</b> you want to proceed?
<br><br>List of attributes defined for this class:<br>(items using these attributes are not listed here explicitly)
<br>
';
$content .= '<ul>';
foreach($attr as $item){
$content .= '<li>'.$item["attr_name"].'</li>';
}
$content .= '</ul>';
}else{
$content = 'No attributes defined for this class.<br>You may safely delete the "<b>'.$class_name.'</b>" class.';
}
// Buttons
$content_button = '
<form name="delete_class" action="delete_class.php" method="post">
<input type="hidden" name="id" value="'.$_GET["id"].'">
<input type="hidden" name="class_name" value="'.$class_name.'">
<input type="hidden" name="delete" value="yes">
';
if ( !empty($_GET["from"]) ) $content_button .= '<input type="hidden" name="from" value="'.$_GET["from"].'">';
$content_button .= '<br><div id=buttons>';
$content_button .= '<input type="Submit" value="Delete" name="submit" align="middle"> ';
$content_button .= '<input type=button onClick="window.location.href=\''.$_SESSION["go_back_page"].'\'" value="Back">';
$content_button .= '</form>';
echo NConf_HTML::limit_space(
NConf_HTML::show_highlight('WARNING', $content.$content_button)
);
}
mysqli_close($dbh);
require_once 'include/foot.php';
?>