Mercurial > hg > fapweb
annotate ajax.php @ 55:4fac95384753
Make visibility of entry authors per compo.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 05 Oct 2013 09:33:06 +0300 |
parents | 71256605546b |
children | 243e9a51920b |
rev | line source |
---|---|
0 | 1 <? |
32 | 2 $sessionType = "admin"; |
0 | 3 require "mconfig.inc.php"; |
4 require "msite.inc.php"; | |
33 | 5 require "msession.inc.php"; |
0 | 6 |
7 // Check if we are allowed to execute | |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
3
diff
changeset
|
8 if (!stCheckHTTPS() || !stAdmSessionAuth()) |
0 | 9 { |
10 header("Status: 404 Not Found"); | |
11 exit; | |
12 } | |
13 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
14 stSetupCacheControl(); |
0 | 15 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
16 // Initiate SQL database connection |
0 | 17 if (!stConnectSQLDB()) |
18 die("Could not connect to SQL database."); | |
19 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
20 // Fetch non-"hardcoded" settings from SQL database |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
21 stReloadSettings(); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
22 |
0 | 23 |
16 | 24 function saveButton() |
25 { | |
26 return "<input type=\"submit\" value=\" Save \" />\n"; | |
27 } | |
28 | |
29 | |
0 | 30 function setStatus($val, $msg) |
31 { | |
32 global $statusSet; | |
33 if (!$statusSet) | |
34 { | |
35 header("Status: ".$val." ".$msg); | |
36 } | |
37 $statusSet = TRUE; | |
38 } | |
39 | |
40 | |
41 function execSQLCond($sql, $okmsg) | |
42 { | |
43 if (($res = stExecSQL($sql)) !== FALSE) | |
44 { | |
45 if ($okmsg != "") | |
46 setStatus(200, $okmsg); | |
47 return $res; | |
48 } | |
49 else | |
50 { | |
51 setStatus(900, "Error in SQL execution."); | |
52 return FALSE; | |
53 } | |
54 } | |
55 | |
56 | |
57 // XMLHttp responses | |
58 $action = "ERROR"; | |
59 if (stChkRequestItem("action") && stChkRequestItem("type")) | |
60 { | |
61 $action = $_REQUEST["action"]; | |
62 $type = $_REQUEST["type"]; | |
63 } | |
64 | |
65 | |
66 switch ($action) | |
67 { | |
68 case "dump": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
69 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
70 // Perform generic data dump |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
71 // |
0 | 72 if (($res = execSQLCond( |
73 "SELECT * FROM attendees WHERE email NOT NULL AND email != '' ORDER BY regtime DESC", | |
74 "Dump OK.")) !== FALSE) | |
75 { | |
76 $out1 = array(); | |
77 $out2 = array(); | |
78 | |
79 foreach ($res as $item) | |
80 { | |
81 $out1[] = $item["name"]." <".$item["email"].">"; | |
82 $out2[] = $item["email"]; | |
83 } | |
84 | |
85 echo "<br /><hr />". | |
86 implode(", ", $out1)."<br /><hr /><br />". | |
87 implode("<br />", $out1)."<br /><hr /><br />". | |
88 implode(", ", $out2)."<br /><hr /><br />". | |
89 implode("<br />", $out2)."<br /><hr />"; | |
90 | |
91 } | |
92 break; | |
93 | |
94 case "get": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
95 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
96 // Get specific data |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
97 // |
0 | 98 switch ($type) |
99 { | |
100 case "news": | |
101 $sql = "SELECT * FROM news ORDER BY utime DESC"; | |
102 break; | |
103 | |
104 case "attendees": | |
105 $sql = "SELECT * FROM attendees ORDER BY regtime DESC"; | |
106 break; | |
107 | |
108 case "compos": | |
109 $sql = "SELECT * FROM compos ORDER BY id DESC"; | |
110 break; | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
111 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
112 case "settings": |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
113 $prefix = "st"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
114 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
115 echo |
16 | 116 "<h1>Site settings</h1>\n". |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
117 "<table>\n"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
118 foreach (stExecSQL("SELECT * FROM settings WHERE vtype<>".VT_TEXT) as $item) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
119 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
120 echo |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
121 " <tr>\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
122 " <td>"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
123 $id = $item["key"]; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
124 switch ($item["vtype"]) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
125 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
126 case VT_INT: |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
127 echo stGetFormTextInput(10, 10, "", $id, $prefix, $item["vint"]); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
128 break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
129 case VT_STR: |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
130 echo stGetFormTextInput(40, 128, "", $id, $prefix, $item["vstr"]); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
131 break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
132 case VT_BOOL: |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
133 echo stGetFormCheckBoxInput("", $id, $prefix, $item["vint"], ""); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
134 break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
135 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
136 echo "</td>\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
137 " <td>".$item["desc"]."</td>\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
138 " </tr>\n"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
139 } |
16 | 140 echo "</table>\n".saveButton(); |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
141 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
142 foreach (stExecSQL("SELECT * FROM settings WHERE vtype=".VT_TEXT) as $item) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
143 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
144 echo "<h2>".chentities($item["desc"])."</h2>\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
145 stGetFormTextArea(10, 60, "", $item["key"], $prefix, $item["vtext"]). |
16 | 146 "\n<br />\n".saveButton(); |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
147 } |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
148 break; |
0 | 149 |
150 case "entries": | |
24
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
151 stGetCompoList(FALSE, FALSE); |
0 | 152 |
153 foreach ($compos as $id => $compo) | |
154 { | |
155 echo | |
156 "<form>\n". | |
157 " <table class=\"misc\">\n". | |
158 " <tr>\n". | |
30
ad25827304b6
Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
159 " <th colspan=\"3\">#".$id." - ".chentities($compo["name"])."</th>\n". |
0 | 160 " </tr>\n". |
161 " <tr>\n". | |
30
ad25827304b6
Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
162 " <th style=\"width:1%;\">Compo</th>\n". |
0 | 163 " <th>Title</th>\n". |
29 | 164 " <th>Author(s)</th>\n". |
0 | 165 " <th>Actions</th>\n". |
166 " </tr>\n"; | |
167 | |
168 $prefix = "en"; | |
169 foreach ($compo["entries"] as $eid => $entry) | |
170 { | |
171 echo | |
172 " <tr id=\"entry".$eid."\">\n". | |
30
ad25827304b6
Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
173 " <td>".stGetFormTextInput(5, 5, "compo_id", $eid, "en", $id)."</td>\n". |
29 | 174 " <td>".stGetFormTextInput(35, 64, "name", $eid, "en", $entry["name"])."</td>\n". |
175 " <td>".stGetFormTextInput(30, 64, "author", $eid, "en", $entry["author"])."</td>\n". | |
0 | 176 " <td>". |
177 stGetFormButtonInput("update", $eid, $prefix, " Update ", "updateEntry(".$eid.")"). | |
178 stGetFormButtonInput("delete", $eid, $prefix, " Delete ", "deleteEntry(".$eid.")"). | |
179 "</td>\n". | |
180 " </tr>\n"; | |
181 } | |
182 echo | |
183 " </table>\n". | |
184 "</form>\n"; | |
185 } | |
186 break; | |
187 } | |
188 | |
189 if (isset($sql) && ($res = execSQLCond($sql, "")) !== FALSE) | |
190 { | |
191 if ($type == "news") | |
192 { | |
193 foreach ($res as $item) | |
194 { | |
195 $id = $item["id"]; | |
196 stPrintNewsItem($item, | |
197 "<br />". | |
198 " <button class=\"button\" id=\"ndel".$id. | |
199 "\" type=\"button\" onclick=\"deleteNews(".$id. | |
200 ")\">Delete</button>\n" | |
201 ); | |
202 } | |
203 } | |
204 else | |
205 if ($type == "attendees") | |
206 { | |
207 echo | |
208 "<table class=\"attendees\">\n". | |
209 " <tr>\n". | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
210 " <th class=\"rname\">Name</th>\n". |
0 | 211 " <th class=\"oneliner\">Oneliner</th>\n". |
212 " <th class=\"email\">E-mail</th>\n". | |
213 " <th>Actions</th>\n". | |
52
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
214 " <th class=\"vkey\">User key</th>\n". |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
215 " <th class=\"vactive\">Active</th>\n". |
0 | 216 " </tr>\n"; |
217 $row = 0; | |
218 foreach ($res as $item) | |
219 stPrintAttendee($item, $row++, TRUE); | |
220 echo "</table>\n"; | |
221 } | |
222 else | |
223 if ($type == "compos") | |
224 { | |
225 foreach ($res as $item) | |
226 { | |
227 $id = $item["id"]; | |
228 $prefix = "co"; | |
229 echo | |
230 "<div id=\"compo".$id."\">\n". | |
231 "<h2>#".$id." - ".chentities($item["name"])."</h2>\n". | |
232 stGetFormTextInput(40, 64, "name", $id, $prefix, $item["name"])."\n". | |
24
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
233 stGetFormCheckBoxInput("visible", $id, $prefix, $item["visible"], "Visible")."\n". |
55
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
234 stGetFormCheckBoxInput("showAuthors", $id, $prefix, $item["showAuthors"], "Show authors")."\n". |
24
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
235 stGetFormCheckBoxInput("voting", $id, $prefix, $item["voting"], "Enable voting")."<br />\n". |
0 | 236 stGetFormTextArea(5, 60, "description", $id, $prefix, $item["description"])."\n<br />\n". |
237 stGetFormButtonInput("update", $id, $prefix, " Update ", "updateCompo(".$id.")")."\n". | |
238 "</div>\n". | |
239 "<hr />\n"; | |
240 } | |
241 } | |
242 } | |
243 break; | |
244 | |
245 case "delete": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
246 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
247 // Delete entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
248 // |
0 | 249 if (stChkRequestItem("id")) |
250 { | |
251 $id = intval(stGetRequestItem("id")); | |
252 | |
253 if ($type == "news") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
254 { |
0 | 255 $sql = stPrepareSQL("DELETE FROM news WHERE id=%d AND persist=0", $id); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
256 execSQLCond($sql, "OK, news item ".$id." deleted."); |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
257 } |
0 | 258 else |
259 if ($type == "attendees") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
260 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
261 // Attendees require some more work |
0 | 262 $sql = stPrepareSQL("DELETE FROM attendees WHERE id=%d", $id); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
263 execSQLCond($sql, "OK, attendee ".$id." deleted."); |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
264 |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
265 $sql = stPrepareSQL("DELETE FROM votes WHERE voter_id=%d", $id); |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
266 execSQLCond($sql, "OK, attendee ".$id." votes deleted."); |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
267 } |
0 | 268 else |
269 if ($type == "entries") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
270 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
271 // .. as do compo entries |
0 | 272 $sql = stPrepareSQL("DELETE FROM entries WHERE id=%d", $id); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
273 execSQLCond($sql, "OK, entry ".$id." deleted."); |
0 | 274 |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
275 $sql = stPrepareSQL("DELETE FROM votes WHERE entry_id=%d", $id); |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
276 execSQLCond($sql, "OK, entry ".$id." votes deleted."); |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
277 } |
0 | 278 } |
279 else | |
280 setStatus(901, "No ID specified."); | |
281 break; | |
282 | |
283 case "add": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
284 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
285 // Add new entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
286 // |
26
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
287 if ($type == "news" && stChkRequestItem("text") && |
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
288 stChkRequestItem("author") && stChkRequestItem("title")) |
0 | 289 { |
290 $sql = stPrepareSQL( | |
291 "INSERT INTO news (utime,title,text,author) VALUES (%d,%S,%Q,%S)", | |
292 time(), "title", "text", "author"); | |
293 | |
294 execSQLCond($sql, "OK, news item added."); | |
295 } | |
296 else | |
26
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
297 if ($type == "compo" && stChkRequestItem("name") && |
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
298 stChkRequestItem("description")) |
0 | 299 { |
300 $sql = stPrepareSQL( | |
55
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
301 "INSERT INTO compos (name,description,visible,voting,showAuthors) VALUES (%S,%Q,0,0,0)", |
26
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
302 "name", "description"); |
0 | 303 |
304 execSQLCond($sql, "OK, compo added."); | |
305 } | |
306 else | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
307 if ($type == "attendees" && stChkRequestItem("name") && |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
308 stChkRequestItem("groups") && stChkRequestItem("email") && |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
309 stChkRequestItem("oneliner")) |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
310 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
311 $sql = stPrepareSQL( |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
312 "INSERT INTO attendees (regtime,name,groups,oneliner,email) VALUES (%d,%S,%S,%S,%S)", |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
313 time(), "name", "groups", "oneliner", "email"); |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
314 |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
315 execSQLCond($sql, "OK, attendee added."); |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
316 } |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
317 else |
0 | 318 setStatus(902, "No data."); |
319 break; | |
320 | |
321 case "update": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
322 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
323 // Update existing entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
324 // |
0 | 325 if ($type == "attendees" && stChkRequestItem("id") && |
52
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
326 stChkRequestItem("email") && stChkRequestItem("oneliner") && |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
327 stChkRequestItem("active")) |
0 | 328 { |
329 $sql = stPrepareSQLUpdate("attendees", | |
330 "WHERE id=".intval(stGetRequestItem("id")), | |
331 array( | |
332 "email" => "S", | |
333 "oneliner" => "S", | |
52
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
334 "active" => "B", |
0 | 335 )); |
336 | |
337 execSQLCond($sql, "OK, attendee updated."); | |
338 } | |
339 else | |
340 if ($type == "news" && stChkRequestItem("id") && | |
341 stChkRequestItem("text") && stChkRequestItem("author") && | |
342 stChkRequestItem("title")) | |
343 { | |
344 $sql = stPrepareSQLUpdate("news", | |
345 "WHERE id=".intval(stGetRequestItem("id")), | |
346 array( | |
347 "title" => "S", | |
348 "text" => "Q", | |
349 "author" => "S" | |
350 )); | |
351 | |
352 execSQLCond($sql, "OK, news item updated."); | |
353 } | |
354 else | |
355 if ($type == "compo" && stChkRequestItem("id") && | |
356 stChkRequestItem("name") && stChkRequestItem("description") && | |
55
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
357 stChkRequestItem("visible") && stChkRequestItem("voting") && |
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
358 stChkRequestItem("showAuthors")) |
0 | 359 { |
360 $sql = stPrepareSQLUpdate("compos", | |
361 "WHERE id=".intval(stGetRequestItem("id")), | |
362 array( | |
363 "name" => "S", | |
364 "description" => "Q", | |
24
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
365 "visible" => "B", |
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
366 "voting" => "B", |
55
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
367 "showAuthors" => "B", |
0 | 368 )); |
369 | |
370 execSQLCond($sql, "OK, compo updated."); | |
371 } | |
372 else | |
373 if ($type == "entry" && stChkRequestItem("id") && | |
30
ad25827304b6
Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
374 stChkRequestItem("name") && stChkRequestItem("author") && |
ad25827304b6
Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
375 stChkRequestItem("compo_id")) |
0 | 376 { |
377 $sql = stPrepareSQLUpdate("entries", | |
30
ad25827304b6
Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
378 "WHERE id=".intval(stGetRequestItem("id")). |
0 | 379 array( |
380 "name" => "S", | |
381 "author" => "S", | |
30
ad25827304b6
Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents:
29
diff
changeset
|
382 "compo_id" => "D", |
0 | 383 )); |
384 | |
20 | 385 execSQLCond($sql, "OK, entry updated."); |
0 | 386 } |
387 else | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
388 if ($type == "settings") |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
389 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
390 foreach (stExecSQL("SELECT * FROM settings") as $item) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
391 if (stChkRequestItem($item["key"])) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
392 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
393 $val = stGetRequestItem($item["key"]); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
394 switch ($item["vtype"]) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
395 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
396 case VT_INT: $vsql = stPrepareSQL("vint=%d", $val); break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
397 case VT_BOOL: $vsql = stPrepareSQL("vint=%d", $val ? 1 : 0); break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
398 case VT_STR: $vsql = stPrepareSQL("vstr=%s", $val); break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
399 case VT_TEXT: $vsql = stPrepareSQL("vtext=%s", $val); break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
400 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
401 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
402 $sql = "UPDATE settings SET ".$vsql." WHERE key=".$db->quote($item["key"]); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
403 execSQLCond($sql, "OK, setting updated."); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
404 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
405 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
406 else |
0 | 407 setStatus(902, "No data."); |
408 break; | |
409 | |
410 default: | |
411 setStatus(404, "Not Found"); | |
412 break; | |
413 } | |
414 | |
415 ?> |