-
Notifications
You must be signed in to change notification settings - Fork 8
/
editCat.inc.php
77 lines (74 loc) · 1.76 KB
/
editCat.inc.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
<?php
require_once 'headerDB.inc.php';
$values = array();
$thiscat=array();
$field=$_GET['field'];
if (isset($_GET['id'])) {
$id=(int) $_GET['id'];
$thiscat['id']=$id;
if ($id===0) {
$title="Create $field";
$canDelete=false;
$thiscat['name']='';
$thiscat['description']='';
$thiscat['type']='a';
} else {
$title="Edit $field";
$canDelete=true;
}
} else {
$id=0;
$thiscat['id']=false;
$title="$field List";
$canDelete=false;
}
$keys=array('id','name','description');
switch ($field) {
case 'category':
$query='categoryselectbox';
$showTypes=false;
break;
case 'context':
$query='spacecontextselectbox';
$showTypes=false;
break;
case 'time-context':
$query='timecontextselectbox' ;
$values['timefilterquery'] = '';
$keys[]='type';
$showTypes=$_SESSION['config']['useTypesForTimeContexts'];
break;
default:
$query='';
$showTypes=false;
break;
}
$result = query($query,$values);
$catlist=array();
$count=0;
$thiscat=false;
if ($result) {
$firstcat=0;
$nextcat=-1;
foreach ($result as $checkcat) {
$newcat=array();
$i=0;
foreach ($checkcat as $item)
$newcat[$keys[$i++]]=makeclean($item);
if (!$firstcat) $firstcat=$newcat['id'];
if (!$nextcat) $nextcat=$newcat['id'];
if ($newcat['id']==$id) {
$thiscat=$newcat;
$nextcat=0;
} else $catlist[]=$newcat;
$count++;
}
if (!$nextcat)
$nextcat=$firstcat;
else if ($nextcat===-1)
$nextcat=0;
}
if ($thiscat)
$title.=': '.$thiscat['name'];
else if ($id)
$title=makeclean("Failed to find $field with id=$id");