Mercurial > hg > fapweb
annotate admajax.php @ 120:2c594958050e
Make test vote keys "testN" where N >= 1
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 22 Oct 2013 14:22:26 +0300 |
parents | a95facb41c86 |
children | 5837b9333964 |
rev | line source |
---|---|
0 | 1 <? |
56 | 2 // |
3 // AJAX request handler backend module | |
4 // | |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
5 $sessionType = "admin"; |
0 | 6 require "mconfig.inc.php"; |
7 require "msite.inc.php"; | |
33 | 8 require "msession.inc.php"; |
0 | 9 |
10 // 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
|
11 if (!stCheckHTTPS() || !stAdmSessionAuth()) |
0 | 12 { |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
13 stSetupCacheControl(); |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
14 |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
15 stSessionEnd(SESS_ADMIN); |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
16 |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
17 header("Location: news"); |
0 | 18 exit; |
19 } | |
20 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
21 stSetupCacheControl(); |
0 | 22 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
23 // Initiate SQL database connection |
0 | 24 if (!stConnectSQLDB()) |
25 die("Could not connect to SQL database."); | |
26 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
27 // 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
|
28 stReloadSettings(); |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
29 |
0 | 30 |
16 | 31 function saveButton() |
32 { | |
33 return "<input type=\"submit\" value=\" Save \" />\n"; | |
34 } | |
35 | |
36 | |
0 | 37 // XMLHttp responses |
38 $action = "ERROR"; | |
39 if (stChkRequestItem("action") && stChkRequestItem("type")) | |
40 { | |
41 $action = $_REQUEST["action"]; | |
42 $type = $_REQUEST["type"]; | |
43 } | |
44 | |
45 | |
46 switch ($action) | |
47 { | |
48 case "dump": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
49 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
50 // Perform generic data dump |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
51 // |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
52 if (($res = stExecSQLCond( |
0 | 53 "SELECT * FROM attendees WHERE email NOT NULL AND email != '' ORDER BY regtime DESC", |
54 "Dump OK.")) !== FALSE) | |
55 { | |
56 $out1 = array(); | |
57 $out2 = array(); | |
58 | |
59 foreach ($res as $item) | |
60 { | |
61 $out1[] = $item["name"]." <".$item["email"].">"; | |
62 $out2[] = $item["email"]; | |
63 } | |
64 | |
65 echo "<br /><hr />". | |
66 implode(", ", $out1)."<br /><hr /><br />". | |
67 implode("<br />", $out1)."<br /><hr /><br />". | |
68 implode(", ", $out2)."<br /><hr /><br />". | |
69 implode("<br />", $out2)."<br /><hr />"; | |
70 | |
71 } | |
72 break; | |
73 | |
74 case "get": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
75 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
76 // Get specific data |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
77 // |
0 | 78 switch ($type) |
79 { | |
80 case "news": | |
81 $sql = "SELECT * FROM news ORDER BY utime DESC"; | |
82 break; | |
83 | |
84 case "attendees": | |
85 $sql = "SELECT * FROM attendees ORDER BY regtime DESC"; | |
86 break; | |
87 | |
105
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
88 case "voters": |
116
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
89 $sqlJoins = ""; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
90 switch (stGetSetting("voteKeyMode")) |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
91 { |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
92 case VOTE_FREELY: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
93 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
94 |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
95 case VOTE_ACTIVATE: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
96 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
97 |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
98 case VOTE_ASSIGN: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
99 $sqlJoins = "LEFT JOIN attendees ON votekeys.voter_id=attendees.id "; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
100 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
101 } |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
102 $sql = "SELECT * FROM votekeys ".$sqlJoins."ORDER BY votekeys.id ASC"; |
105
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
103 break; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
104 |
0 | 105 case "compos": |
106 $sql = "SELECT * FROM compos ORDER BY id DESC"; | |
107 break; | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
108 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
109 case "settings": |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
110 $prefix = "st"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
111 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
112 echo |
16 | 113 "<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
|
114 "<table>\n"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
115 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
|
116 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
117 echo |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
118 " <tr>\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
119 " <td>"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
120 $id = $item["key"]; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
121 switch ($item["vtype"]) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
122 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
123 case VT_INT: |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
124 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
|
125 break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
126 case VT_STR: |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
127 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
|
128 break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
129 case VT_BOOL: |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
130 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
|
131 break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
132 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
133 echo "</td>\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
134 " <td>".$item["desc"]."</td>\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
135 " </tr>\n"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
136 } |
16 | 137 echo "</table>\n".saveButton(); |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
138 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
139 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
|
140 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
141 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
|
142 stGetFormTextArea(10, 60, "", $item["key"], $prefix, $item["vtext"]). |
16 | 143 "\n<br />\n".saveButton(); |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
144 } |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
145 break; |
0 | 146 |
147 case "entries": | |
24
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
148 stGetCompoList(FALSE, FALSE); |
0 | 149 |
150 foreach ($compos as $id => $compo) | |
151 { | |
152 echo | |
153 "<form>\n". | |
154 " <table class=\"misc\">\n". | |
155 " <tr>\n". | |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
156 " <th colspan=\"5\">#".$id." - ".chentities($compo["name"])."</th>\n". |
0 | 157 " </tr>\n". |
158 " <tr>\n". | |
113
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
159 " <th style=\"width:4%;\">ID#</th>\n". |
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
160 " <th style=\"width:4%;\">S#</th>\n". |
0 | 161 " <th>Title</th>\n". |
29 | 162 " <th>Author(s)</th>\n". |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
163 " <th>Filename</th>\n". |
0 | 164 " <th>Actions</th>\n". |
165 " </tr>\n"; | |
166 | |
167 $prefix = "en"; | |
168 foreach ($compo["entries"] as $eid => $entry) | |
169 { | |
170 echo | |
171 " <tr id=\"entry".$eid."\">\n". | |
113
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
172 " <td>".$eid."</td>\n". |
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
173 " <td>".($entry["show_id"] > 0 ? $entry["show_id"] : "-")."</td>\n". |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
174 " <td>".stGetFormTextInput(30, 64, "name", $eid, "en", $entry["name"])."</td>\n". |
29 | 175 " <td>".stGetFormTextInput(30, 64, "author", $eid, "en", $entry["author"])."</td>\n". |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
176 " <td>".stGetFormTextInput(20, 64, "filename", $eid, "en", $entry["filename"])."</td>\n". |
0 | 177 " <td>". |
113
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
178 stGetFormButtonInput("delete", $eid, $prefix, " Del ", "deleteEntry(".$eid.")"). |
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
179 stGetFormTextInput(3, 3, "compo_id", $eid, "en", $id). |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
180 stGetFormButtonInput("update", $eid, $prefix, " Upd ", "updateEntry(".$eid.")"). |
0 | 181 "</td>\n". |
182 " </tr>\n"; | |
111 | 183 $index++; |
0 | 184 } |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
185 |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
186 $prefix = "ne"; |
0 | 187 echo |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
188 " <tr>\n". |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
189 " <td></td>\n". |
113
671330b7f5d1
Add "show_id" to compo entries, to designate the position they were shown at
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
190 " <td></td>\n". |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
191 " <td>".stGetFormTextInput(30, 64, "name", $id, "ne", "")."</td>\n". |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
192 " <td>".stGetFormTextInput(30, 64, "author", $id, "ne", "")."</td>\n". |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
193 " <td>".stGetFormTextInput(20, 64, "filename", $id, "ne", "")."</td>\n". |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
194 " <td>".stGetFormButtonInput("add", $id, $prefix, " Add new ", "addEntry(".$id.")")."</td>\n". |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
195 " </tr>\n". |
0 | 196 " </table>\n". |
197 "</form>\n"; | |
198 } | |
199 break; | |
200 } | |
201 | |
56 | 202 // |
203 // Perform query if we need to, output results | |
204 // | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
205 if (isset($sql) && ($res = stExecSQLCond($sql, "")) !== FALSE) |
0 | 206 { |
207 if ($type == "news") | |
208 { | |
209 foreach ($res as $item) | |
210 { | |
211 $id = $item["id"]; | |
212 stPrintNewsItem($item, | |
213 "<br />". | |
214 " <button class=\"button\" id=\"ndel".$id. | |
215 "\" type=\"button\" onclick=\"deleteNews(".$id. | |
216 ")\">Delete</button>\n" | |
217 ); | |
218 } | |
219 } | |
220 else | |
221 if ($type == "attendees") | |
222 { | |
90 | 223 // List of attendees |
0 | 224 echo |
225 "<table class=\"attendees\">\n". | |
226 " <tr>\n". | |
83 | 227 " <th class=\"name\">Name</th>\n". |
228 " <th class=\"groups\">Groups</th>\n". | |
229 " <th class=\"regtime\">Registered</th>\n". | |
0 | 230 " <th class=\"oneliner\">Oneliner</th>\n". |
231 " <th class=\"email\">E-mail</th>\n". | |
232 " <th>Actions</th>\n". | |
233 " </tr>\n"; | |
234 $row = 0; | |
235 foreach ($res as $item) | |
236 stPrintAttendee($item, $row++, TRUE); | |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
237 |
90 | 238 // For adding a new one |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
239 $prefix = "ne"; |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
240 echo |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
241 "</table>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
242 "<hr />\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
243 "<table>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
244 " <tr>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
245 " <th>Name</th>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
246 " <th>Groups</th>\n". |
82
a071dacdcfc5
Change order of table fields.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
247 " <th>Oneliner</th>\n". |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
248 " <th>E-mail</th>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
249 " <th>Actions</th>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
250 " </tr>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
251 " <tr>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
252 " <td>".stGetFormTextInput(20, 64, "name", "x", $prefix, "")."</td>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
253 " <td>".stGetFormTextInput(20, 64, "groups", "x", $prefix, "")."</td>\n". |
82
a071dacdcfc5
Change order of table fields.
Matti Hamalainen <ccr@tnsp.org>
parents:
75
diff
changeset
|
254 " <td>".stGetFormTextInput(30, 64, "oneliner", "x", $prefix, "")."</td>\n". |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
255 " <td>".stGetFormTextInput(20, 64, "email", "x", $prefix, "")."</td>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
256 " <td>".stGetFormButtonInput("add", "", $prefix, " Add new ", "addAttendee()")."</td>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
257 " </tr>\n". |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
258 "</table>\n"; |
0 | 259 } |
260 else | |
116
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
261 if ($type == "voters") |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
262 { |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
263 switch (stGetSetting("voteKeyMode")) |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
264 { |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
265 case VOTE_FREELY: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
266 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
267 |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
268 case VOTE_ACTIVATE: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
269 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
270 |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
271 case VOTE_ASSIGN: |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
272 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
273 } |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
274 // List of votekeys |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
275 echo |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
276 "<table class=\"attendees\">\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
277 " <tr>\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
278 " <th class=\"name\">Name</th>\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
279 " <th class=\"groups\">Groups</th>\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
280 " <th class=\"email\">E-mail</th>\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
281 " <th class=\"\">Key</th>\n". |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
282 " </tr>\n"; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
283 $row = 0; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
284 |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
285 echo |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
286 "</table>\n"; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
287 } |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
288 else |
0 | 289 if ($type == "compos") |
290 { | |
291 foreach ($res as $item) | |
292 { | |
293 $id = $item["id"]; | |
294 $prefix = "co"; | |
295 echo | |
296 "<div id=\"compo".$id."\">\n". | |
297 "<h2>#".$id." - ".chentities($item["name"])."</h2>\n". | |
298 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
|
299 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
|
300 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
|
301 stGetFormCheckBoxInput("voting", $id, $prefix, $item["voting"], "Enable voting")."<br />\n". |
0 | 302 stGetFormTextArea(5, 60, "description", $id, $prefix, $item["description"])."\n<br />\n". |
303 stGetFormButtonInput("update", $id, $prefix, " Update ", "updateCompo(".$id.")")."\n". | |
304 "</div>\n". | |
305 "<hr />\n"; | |
306 } | |
307 } | |
308 } | |
309 break; | |
310 | |
311 case "delete": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
312 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
313 // Delete entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
314 // |
0 | 315 if (stChkRequestItem("id")) |
316 { | |
317 $id = intval(stGetRequestItem("id")); | |
318 | |
319 if ($type == "news") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
320 { |
0 | 321 $sql = stPrepareSQL("DELETE FROM news WHERE id=%d AND persist=0", $id); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
322 stExecSQLCond($sql, "OK, news item ".$id." deleted."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
323 } |
0 | 324 else |
325 if ($type == "attendees") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
326 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
327 // Attendees require some more work |
0 | 328 $sql = stPrepareSQL("DELETE FROM attendees WHERE id=%d", $id); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
329 stExecSQLCond($sql, "OK, attendee ".$id." deleted."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
330 |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
331 $sql = stPrepareSQL("DELETE FROM votes WHERE voter_id=%d", $id); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
332 stExecSQLCond($sql, "OK, attendee ".$id." votes deleted."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
333 } |
0 | 334 else |
335 if ($type == "entries") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
336 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
337 // .. as do compo entries |
0 | 338 $sql = stPrepareSQL("DELETE FROM entries WHERE id=%d", $id); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
339 stExecSQLCond($sql, "OK, entry ".$id." deleted."); |
0 | 340 |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
341 $sql = stPrepareSQL("DELETE FROM votes WHERE entry_id=%d", $id); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
342 stExecSQLCond($sql, "OK, entry ".$id." votes deleted."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
343 } |
0 | 344 } |
345 else | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
346 stSetStatus(901, "No ID specified."); |
0 | 347 break; |
348 | |
349 case "add": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
350 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
351 // Add new entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
352 // |
26
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
353 if ($type == "news" && stChkRequestItem("text") && |
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
354 stChkRequestItem("author") && stChkRequestItem("title")) |
0 | 355 { |
356 $sql = stPrepareSQL( | |
357 "INSERT INTO news (utime,title,text,author) VALUES (%d,%S,%Q,%S)", | |
358 time(), "title", "text", "author"); | |
359 | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
360 stExecSQLCond($sql, "OK, news item added."); |
0 | 361 } |
362 else | |
26
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
363 if ($type == "compo" && stChkRequestItem("name") && |
7be3f8cf1f7a
Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
364 stChkRequestItem("description")) |
0 | 365 { |
366 $sql = stPrepareSQL( | |
55
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
367 "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
|
368 "name", "description"); |
0 | 369 |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
370 stExecSQLCond($sql, "OK, compo added."); |
0 | 371 } |
372 else | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
373 if ($type == "attendees" && stChkRequestItem("name") && |
75 | 374 stChkRequestItem("groups") && stChkRequestItem("oneliner") && |
375 stChkRequestItem("email")) | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
376 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
377 $sql = stPrepareSQL( |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
378 "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
|
379 time(), "name", "groups", "oneliner", "email"); |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
380 |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
381 stExecSQLCond($sql, "OK, attendee added."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
382 } |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
383 else |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
384 if ($type == "entry" && stChkRequestItem("name") && |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
385 stChkRequestItem("author") && stChkRequestItem("compo_id")) |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
386 { |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
387 $sql = stPrepareSQL( |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
388 "INSERT INTO entries (name,author,compo_id,filename) VALUES (%S,%S,%D,%S)", |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
389 "name", "author", "compo_id", "filename"); |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
390 |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
391 stExecSQLCond($sql, "OK, entry added."); |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
392 } |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
393 else |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
394 stSetStatus(902, "No data."); |
0 | 395 break; |
396 | |
397 case "update": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
398 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
399 // Update existing entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
400 // |
0 | 401 if ($type == "attendees" && stChkRequestItem("id") && |
52
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
402 stChkRequestItem("email") && stChkRequestItem("oneliner") && |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
403 stChkRequestItem("active")) |
0 | 404 { |
405 $sql = stPrepareSQLUpdate("attendees", | |
406 "WHERE id=".intval(stGetRequestItem("id")), | |
407 array( | |
408 "email" => "S", | |
409 "oneliner" => "S", | |
52
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
410 "active" => "B", |
0 | 411 )); |
412 | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
413 stExecSQLCond($sql, "OK, attendee updated."); |
0 | 414 } |
415 else | |
416 if ($type == "news" && stChkRequestItem("id") && | |
417 stChkRequestItem("text") && stChkRequestItem("author") && | |
418 stChkRequestItem("title")) | |
419 { | |
420 $sql = stPrepareSQLUpdate("news", | |
421 "WHERE id=".intval(stGetRequestItem("id")), | |
422 array( | |
423 "title" => "S", | |
424 "text" => "Q", | |
425 "author" => "S" | |
426 )); | |
427 | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
428 stExecSQLCond($sql, "OK, news item updated."); |
0 | 429 } |
430 else | |
431 if ($type == "compo" && stChkRequestItem("id") && | |
432 stChkRequestItem("name") && stChkRequestItem("description") && | |
55
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
433 stChkRequestItem("visible") && stChkRequestItem("voting") && |
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
434 stChkRequestItem("showAuthors")) |
0 | 435 { |
436 $sql = stPrepareSQLUpdate("compos", | |
437 "WHERE id=".intval(stGetRequestItem("id")), | |
438 array( | |
439 "name" => "S", | |
440 "description" => "Q", | |
24
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
441 "visible" => "B", |
5bc8bd5c7ecc
Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
442 "voting" => "B", |
55
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
443 "showAuthors" => "B", |
0 | 444 )); |
445 | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
446 stExecSQLCond($sql, "OK, compo updated."); |
0 | 447 } |
448 else | |
449 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
|
450 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
|
451 stChkRequestItem("compo_id")) |
0 | 452 { |
112
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
453 $cid = stGetRequestItem("compo_id"); |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
454 if (stFetchSQLColumn("SELECT id FROM compos WHERE id=".$cid) === FALSE) |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
455 { |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
456 stSetStatus(903, "No such compo id."); |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
457 } |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
458 else |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
459 { |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
460 $sql = stPrepareSQLUpdate("entries", |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
461 "WHERE id=".intval(stGetRequestItem("id")), |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
462 array( |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
463 "name" => "S", |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
464 "author" => "S", |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
465 "filename" => "S", |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
466 "compo_id" => "D", |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
467 )); |
0 | 468 |
112
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
469 stExecSQLCond($sql, "OK, entry updated."); |
91660a9d50f0
Add some error checking to compo id updating vs. compo entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
111
diff
changeset
|
470 } |
0 | 471 } |
472 else | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
473 if ($type == "settings") |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
474 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
475 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
|
476 if (stChkRequestItem($item["key"])) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
477 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
478 $val = stGetRequestItem($item["key"]); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
479 switch ($item["vtype"]) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
480 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
481 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
|
482 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
|
483 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
|
484 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
|
485 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
486 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
487 $sql = "UPDATE settings SET ".$vsql." WHERE key=".$db->quote($item["key"]); |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
488 stExecSQLCond($sql, "OK, setting updated."); |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
489 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
490 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
491 else |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
492 stSetStatus(902, "No data."); |
0 | 493 break; |
494 | |
495 default: | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
496 stSetStatus(404, "Not Found"); |
0 | 497 break; |
498 } | |
499 | |
500 ?> |