-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaxonomy-editinplace.php
165 lines (124 loc) · 3.24 KB
/
taxonomy-editinplace.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php
// class loader
require_once 'lib/init.php';
if (isset($_REQUEST['action'])){
// This bit is just for managing the checkboxes...
$action=$_REQUEST['action'];
$termid=$_REQUEST['termid'];
$property=$_REQUEST['property'];
$value=$_REQUEST['value'];
if ($value=="on"){$value=1;} else {$value=0;}
//error_log("I want to $action with term $termid - setting $property to $value");
} else {
if (isset($_REQUEST['editorId'])){
$editorid=$_REQUEST['editorId'];
$editorid=explode("-",$editorid);
// print_r ($editorid);
} else {
echo ("What is going on? Nothing was asked for...");
exit();
}
if (isset($editorid[0])){
if ($editorid[0]=="term"){
//we are assuming
$action='edit_term';
$property='name';
}
}
if (isset($editorid[0])){
if ($editorid[0]=="scale"){
//we are assuming
$action='edit_term';
$property='scale';
}
}
if (isset($editorid[0])){
if ($editorid[0]=="agent"){
//we are assuming
$action='edit_term';
$property='agent';
}
}
if (isset($editorid[1])){
if (is_numeric($editorid[1])){
$termid=$editorid[1];
}
}
if (isset($editorid[2])){
if ($editorid[2]=="class"){
$property='class';
}
}
if (isset($editorid[2])){
if ($editorid[2]=="classag"){
$property='classag';
}
}
if (isset($_REQUEST['value'])){
$value=$_REQUEST['value'];
} else {
echo "Error: No value given";
exit;
}
}
switch ($action){
case "edit_term":
switch ($property){
case 'class':
$sql="SELECT id FROM term_classes WHERE name='$value'";
$ourid=$db->queryarray($sql);
if (isset($ourid[0]['id'])){
$classid=$ourid[0]['id'];
} else {
echo "Error: term not found";
}
$sql="UPDATE terms SET term_class_id='$classid' WHERE id='$termid' LIMIT 1";
$db->query($sql);
echo ($value);
break;
case 'classag':
$sql="SELECT id FROM terms WHERE term='$value'";
$ourid=$db->queryarray($sql);
if (isset($ourid[0]['id'])){
$classid=$ourid[0]['id'];
} else {
echo "Error: term not found";
}
$sql="INSERT INTO properties (term_id, agent_id) VALUES ('$classid', '$termid')";
$db->query($sql);
echo ($value);
break;
case 'name':
$sql="UPDATE terms SET term='$value' WHERE id='$termid' LIMIT 1";
$db->query($sql);
echo ($value);
break;
case 'scale':
$sql="UPDATE terms SET scale='$value' WHERE id='$termid' LIMIT 1";
$db->query($sql);
echo ($value);
break;
case 'multiple':
$sql="UPDATE terms SET multiple='$value' WHERE id='$termid' LIMIT 1";
error_log($db->query($sql));
echo ($value);
break;
case 'necessary':
$sql="UPDATE terms SET necessary='$value' WHERE id='$termid' LIMIT 1";
$db->query($sql);
echo ($value);
break;
case 'scalable':
$sql="UPDATE terms SET scalable='$value' WHERE id='$termid' LIMIT 1";
$db->query($sql);
echo ($value);
break;
case 'agent':
$sql="UPDATE agents SET name='$value' WHERE id='$termid' LIMIT 1";
$db->query($sql);
echo ($value);
break;
}
break;
}
?>