-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathprocessCat.php
62 lines (57 loc) · 1.86 KB
/
processCat.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
<?php
require_once 'headerDB.inc.php';
ignore_user_abort(true);
if ($_SESSION['debug']['debug']) {
$html=true;
include_once 'headerHtml.inc.php';
echo "</head><body>";
log_array('$_POST');
} else {
$html=false;
}
$values=array();
$field=$_POST['field'];
if (isset($_POST['id'])) {
$values['id']=(int) $_POST['id'];
$values['name']=$_POST['name'];
$values['description']=$_POST['description'];
switch ($field) {
case 'category':
$query='category';
$getId='category';
break;
case 'context':
$query='spacecontext';
$getId='context';
break;
case 'time-context':
$query='timecontext';
$getId='timecontext';
if ($_SESSION['config']['useTypesForTimeContexts'] && isset($_POST['type']) && $_POST['type']!='')
$values['type']=$_POST['type'];
else
$values['type']='a';
break;
default:
break;
}
if ($values['id']==0) {
$result = query("new$query",$values);
$msg='Created';
} elseif (isset($_POST['delete']) && $_POST['delete']==="y") {
$values['newId']=(int) $_POST['replacewith'];
$result=query("reassign$query",$values);
if ($result!==false) $result=query("delete$query",$values); // don't delete if reassign fails
$msg='Deleted';
} else {
$result=query("update$query",$values);
$msg='Updated';
}
} // end of: if (isset($_POST['id']))
if ($result) $_SESSION['message'][]="$msg $field '{$values['name']}'";
$nexturl="editCat.php?field=$field";
if (isset($_POST['next']))
$nexturl.='&id='.$_POST['next'];
nextScreen($nexturl);
if ($html) include_once 'footer.inc.php';
// php closing tag has been omitted deliberately, to avoid unwanted blank lines being sent to the browser