Mercurial > hg > fapweb
annotate admin.inc.php @ 61:e85ed35585fc
Work on attendee editing, etc.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 05 Oct 2013 12:33:59 +0300 |
parents | e5e38ed4e837 |
children | 4684336cec09 |
rev | line source |
---|---|
0 | 1 <? |
32 | 2 $sessionType = "admin"; |
3 | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
4 function stCreateSettingsData() |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
5 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
6 $args = array(); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
7 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
8 if (($res = stExecSQL("SELECT * FROM settings")) !== FALSE) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
9 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
10 foreach ($res as $item) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
11 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
12 switch ($item["vtype"]) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
13 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
14 case VT_STR: |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
15 case VT_TEXT: $type = 0; break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
16 case VT_INT: $type = 4; break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
17 case VT_BOOL: $type = 3; break; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
18 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
19 $args[] = "\"".$item["key"]."\":".$type; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
20 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
21 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
22 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
23 echo |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
24 "\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
25 "function updateSettings()\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
26 "{\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
27 " var args = makePostArgs({".implode(",", $args)."}, \"st\", \"\");\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
28 " sendPOSTRequest(\"action=update&type=settings&\"+args);\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
29 " return false;\n". |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
30 "}\n"; |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
31 } |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
32 |
0 | 33 // Check if sessions are enabled |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
34 if (!stChkSetting("admPassword")) |
0 | 35 { |
36 echo "<h1>Oh noes, admin configuration not done!</h1>\n". | |
37 "<p>Better go and prod that, so you get to use the fine admin interface.</p>\n"; | |
38 $authState = "error"; | |
39 } | |
40 else | |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
41 if (stAdmSessionAuth()) |
0 | 42 { |
43 $authState = "ok"; | |
44 } | |
45 else | |
46 { | |
47 // Perform authentication if we are not in session already | |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
48 echo |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
49 "<h1>Party admin login</h1>\n". |
0 | 50 "<p>Please use illegal telepathy over HTTP to provide a password to enter the party administration systembolaget.</p>\n". |
32 | 51 stGetFormStart("admlogin", "admlogin.php"). |
0 | 52 stGetFormHiddenInput("mode", "check")."\n". |
32 | 53 stGetFormPasswordInput("admpass", "", "")."\n". |
54 stGetFormSubmitInput("submit", "Login"). | |
0 | 55 "</form>\n"; |
56 | |
57 $authState = "login"; | |
58 } | |
59 | |
60 if ($authState == "ok") | |
61 { | |
62 ?> | |
63 <script type="text/javascript"> | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
64 // <? stCreateSettingsData(); ?> |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
65 |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
66 |
0 | 67 function statusMsg(msg) |
68 { | |
69 document.getElementById("nstatus").innerHTML = msg; | |
70 } | |
71 | |
72 | |
73 function strtrim(str) | |
74 { | |
75 if (!str || str == null) | |
76 return ""; | |
77 return str.replace(/^\s+|\s+$/g,'') | |
78 } | |
79 | |
80 | |
81 function strencode(str) | |
82 { | |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
83 return encodeURIComponent(str); |
0 | 84 } |
85 | |
86 | |
87 function createXMLRequest() | |
88 { | |
89 var req; | |
90 if (window.XMLHttpRequest) | |
91 { | |
92 // Modern browsers | |
93 req = new XMLHttpRequest(); | |
94 } | |
95 else | |
96 { | |
97 // Old IE versions | |
98 req = new ActiveXObject("Microsoft.XMLHTTP"); | |
99 } | |
100 return req; | |
101 } | |
102 | |
103 | |
104 function sendPOSTRequest(params, success, failure) | |
105 { | |
106 var req = createXMLRequest(); | |
107 req.open("POST", "ajax.php", true); | |
108 req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); | |
109 req.setRequestHeader("Content-length", params.length); | |
110 req.setRequestHeader("Connection", "close"); | |
111 | |
112 req.onreadystatechange = function() | |
113 { | |
114 if (req.readyState == 4) | |
115 { | |
116 if (req.status == 404) | |
117 { | |
32 | 118 window.location = "admlogout.php"; |
0 | 119 } |
120 else | |
121 if (req.status == 200) | |
122 { | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
123 if (success) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
124 { |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
125 success(req.responseText); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
126 } |
0 | 127 statusMsg(req.statusText); |
128 } | |
129 else | |
130 { | |
131 if (failure) | |
132 { | |
133 failure(req.status, req.statusText, req.responseText); | |
134 } | |
135 else | |
136 { | |
137 statusMsg("["+req.status+" - "+req.statusText+"] "+ req.responseText); | |
138 } | |
139 } | |
140 } | |
141 } | |
142 req.send(params); | |
143 } | |
144 | |
145 | |
146 function makePostArgs(fields, fprefix, fsuffix) | |
147 { | |
148 var res = []; | |
149 for (var id in fields) | |
150 { | |
151 var elem = document.getElementById(fprefix + id + fsuffix); | |
152 if (!elem) | |
153 { | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
154 alert("No such DOM element '"+ fprefix + id + fsuffix +"'."); |
0 | 155 return ""; |
156 } | |
157 | |
158 switch (fields[id]) | |
159 { | |
160 case 0: | |
161 case 1: | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
162 case 4: |
0 | 163 { |
164 var str = strtrim(elem.value); | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
165 if ((fields[id] == 1 || fields[id] == 4) && str == "") |
0 | 166 { |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
167 alert("One or more of the required fields are empty."); |
0 | 168 return ""; |
169 } | |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
170 if (fields[id] == 4) |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
171 res.push(id+"="+parseInt(elem.value)); |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
172 else |
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
10
diff
changeset
|
173 res.push(id+"="+strencode(str)); |
0 | 174 } |
175 break; | |
176 | |
177 case 2: | |
178 res.push(id+"="+parseInt(elem.value)); | |
179 break; | |
180 | |
181 case 3: | |
182 res.push(id+"="+(elem.checked ? "1" : "0")); | |
183 break; | |
184 | |
185 } | |
186 } | |
187 return res.join("&"); | |
188 } | |
189 | |
190 | |
191 function refreshItems(id,name,msgname) | |
192 { | |
193 var msuccess = function(txt) | |
194 { | |
195 var nitem = document.getElementById(id); | |
196 nitem.innerHTML = txt; | |
197 } | |
198 | |
199 sendPOSTRequest("action=get&type="+name, msuccess); | |
200 } | |
201 | |
202 | |
203 function deleteItem(id,prefix,type,func,dsc) | |
204 { | |
205 var msuccess = function(txt) | |
206 { | |
207 var item = document.getElementById(prefix+id); | |
208 item.style.display = "none"; | |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
209 setTimeout(func, 50); |
0 | 210 } |
211 | |
212 if (confirm("Are you sure you want to delete "+dsc+" #"+id+"?")) | |
213 { | |
214 sendPOSTRequest("action=delete&type="+type+"&id="+id, msuccess); | |
215 } | |
216 } | |
217 | |
218 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
219 function refreshSettings() |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
220 { |
10
11816aad6967
Start work on settings interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
221 refreshItems("nsettings", "settings", "General settings"); |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
222 } |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
223 |
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
224 |
0 | 225 function refreshNews() |
226 { | |
227 refreshItems("nnews", "news", "News list"); | |
228 } | |
229 | |
230 | |
231 function refreshAttendees() | |
232 { | |
233 refreshItems("nattendees", "attendees", "Attendees list"); | |
234 } | |
235 | |
236 | |
237 function refreshDump() | |
238 { | |
239 var msuccess = function(txt) | |
240 { | |
241 var nitem = document.getElementById("ndump"); | |
242 nitem.innerHTML = txt; | |
243 } | |
244 | |
245 sendPOSTRequest("action=dump&type=attendees", msuccess); | |
246 } | |
247 | |
248 | |
249 function refreshCompos() | |
250 { | |
251 refreshItems("ncompos", "compos", "Compo list"); | |
252 } | |
253 | |
254 | |
255 function refreshEntries() | |
256 { | |
257 refreshItems("nentries", "entries", "Entry list"); | |
258 } | |
259 | |
260 | |
261 function addNews() | |
262 { | |
263 var args = makePostArgs({"title":1,"text":1,"author":1}, "nn", ""); | |
264 | |
265 var msuccess = function(txt) | |
266 { | |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
267 setTimeout("refreshNews();", 50); |
0 | 268 } |
269 | |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
270 if (args != "") |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
271 sendPOSTRequest("action=add&type=news&"+args, msuccess); |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
272 |
0 | 273 return false; |
274 } | |
275 | |
276 | |
277 function deleteNews(id) | |
278 { | |
279 deleteItem(id, "news", "news", "refreshNews();", "news item"); | |
280 } | |
281 | |
282 | |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
283 function addAttendee() |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
284 { |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
285 var args = makePostArgs({"name":1,"groups":0,"oneliner":0,"email":0}, "ne", "x"); |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
286 |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
287 var msuccess = function(txt) |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
288 { |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
289 setTimeout("refreshAttendees();", 50); |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
290 } |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
291 |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
292 if (args != "") |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
293 sendPOSTRequest("action=add&type=attendees&"+args, msuccess); |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
294 |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
295 return false; |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
296 } |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
297 |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
298 |
0 | 299 function deleteAttendee(id) |
300 { | |
301 deleteItem(id, "attendee", "attendees", "refreshAttendees();", "attendee"); | |
302 } | |
303 | |
304 | |
305 function updateAttendee(id) | |
306 { | |
52
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
307 var args = makePostArgs({"oneliner":0,"email":0,"active":3}, "at", id); |
0 | 308 |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
309 var msuccess = function(txt) |
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 setTimeout("refreshAttendees();", 50); |
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 |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
314 if (args != "") |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
315 sendPOSTRequest("action=update&type=attendees&id="+id+"&"+args, msuccess); |
0 | 316 } |
317 | |
318 | |
52
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
319 function updateAttendee2(id) |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
320 { |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
321 var elem = document.getElementById("atactive"+id); |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
322 if (elem && !elem.checked) |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
323 { |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
324 if (confirm("Are you sure you want deactivate vote ID #"+id+"?")) |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
325 updateAttendee(id); |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
326 else |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
327 setTimeout("refreshAttendees();", 50); |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
328 } |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
329 else |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
330 updateAttendee(id); |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
331 } |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
332 |
cba0b944da79
Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents:
33
diff
changeset
|
333 |
0 | 334 function addCompo() |
335 { | |
336 var args = makePostArgs({"name":1, "description":1}, "nc", ""); | |
337 | |
338 var msuccess = function(txt) | |
339 { | |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
340 setTimeout("refreshCompos();", 50); |
0 | 341 } |
342 | |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
343 if (args != "") |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
344 sendPOSTRequest("action=add&type=compo&"+args, msuccess); |
0 | 345 return false; |
346 } | |
347 | |
348 | |
349 function updateCompo(id) | |
350 { | |
55
4fac95384753
Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
351 var args = makePostArgs({"name":1, "description":1, "visible":3, "voting":3, "showAuthors":3}, "co", id); |
0 | 352 |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
353 if (args != "") |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
354 sendPOSTRequest("action=update&type=compo&id="+id+"&"+args); |
0 | 355 } |
356 | |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
357 |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
358 function addEntry(id) |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
359 { |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
360 var args = makePostArgs({"name":1, "author":1, "filename":0}, "ne", id); |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
361 |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
362 var msuccess = function(txt) |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
363 { |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
364 setTimeout("refreshEntries();", 50); |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
365 } |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
366 |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
367 if (args != "") |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
368 sendPOSTRequest("action=add&type=entry&compo_id="+id+"&"+args, msuccess); |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
369 return false; |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
370 } |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
371 |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
372 |
0 | 373 function updateEntry(id) |
374 { | |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
375 var args = makePostArgs({"name":1, "author":1, "filename":0, "compo_id":2}, "en", id); |
0 | 376 |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
377 var msuccess = function(txt) |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
378 { |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
379 setTimeout("refreshEntries();", 50); |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
380 } |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
381 |
61
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
382 if (args != "") |
e85ed35585fc
Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
59
diff
changeset
|
383 sendPOSTRequest("action=update&type=entry&id="+id+"&"+args, msuccess); |
0 | 384 } |
385 | |
386 | |
387 function deleteEntry(id) | |
388 { | |
389 deleteItem(id, "entry", "entries", "refreshEntries();", "entry"); | |
390 } | |
391 | |
392 | |
393 var registeredTabs = Object(); | |
394 | |
395 | |
396 function updateTabList() | |
397 { | |
398 var item = document.getElementById("pageTabs"); | |
399 var str = ""; | |
400 for (var id in registeredTabs) | |
401 { | |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
402 str += "<a id=\"cc"+id+ |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
403 "\"href=\"#\" onClick=\"switchActiveTab('"+id+ |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
404 "')\">"+registeredTabs[id]+"</a>"; |
0 | 405 } |
406 | |
32 | 407 str += "<a class=\"admin\" href=\"admlogout.php\">Logout</a>"; |
0 | 408 |
409 item.innerHTML = str; | |
410 } | |
411 | |
412 | |
413 function registerTab(id, name) | |
414 { | |
415 registeredTabs[id] = name; | |
416 } | |
417 | |
418 | |
419 function refreshTabs() | |
420 { | |
421 for (var id in registeredTabs) | |
422 { | |
423 setTimeout("refresh"+ registeredTabs[id] +"();", 10); | |
424 } | |
425 } | |
426 | |
427 | |
428 function switchActiveTab(tab) | |
429 { | |
430 for (var id in registeredTabs) | |
431 { | |
432 var ob = document.getElementById(id); | |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
433 var ccob = document.getElementById("cc"+id); |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
434 if (ob && ccob) |
0 | 435 { |
436 ob.style.display = (tab == id) ? "block" : "none"; | |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
437 ccob.style.borderTop = (tab == id) ? "4px solid white" : "none"; |
0 | 438 if (tab == id) |
439 { | |
440 setTimeout("refresh"+ registeredTabs[id] +"();", 10); | |
441 } | |
442 } | |
443 } | |
444 } | |
445 </script> | |
446 | |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
447 <!-- ========================== --> |
0 | 448 |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
449 <div id="nstatus">-</div> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
450 |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
451 <div id="pageTabs"></div> |
0 | 452 |
453 <!-- ========================== --> | |
454 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
455 <div id="tabSettings"> |
10
11816aad6967
Start work on settings interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
456 <form method="post" action="" onsubmit="return updateSettings()"> |
11816aad6967
Start work on settings interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
457 <div id="nsettings"></div> |
11816aad6967
Start work on settings interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
458 </form> |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
459 </div> |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
460 |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
461 <!-- ========================== --> |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
462 |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
463 <div id="tabNews"> |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
464 <form method="post" action="" onsubmit="return addNews()"> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
465 <input id="nntitle" type="text" size="40" /><br /> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
466 <textarea id="nntext" rows="5" cols="60"></textarea><br /> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
467 <input id="nnauthor" type="text" value="orgaz" /> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
468 <input id="nnadd" type="submit" value=" Add post " /> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
469 <input type="button" value=" Clear " onClick="this.form.reset()" /> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
470 </form> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
471 <hr /> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
472 <div id="nnews"></div> |
0 | 473 </div> |
474 | |
475 <!-- ========================== --> | |
476 | |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
477 <div id="tabAttendees"> |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
478 <div id="nattendees"></div> |
0 | 479 </div> |
480 | |
481 <!-- ========================== --> | |
482 | |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
483 <div id="tabDump"> |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
484 <div id="ndump"></div> |
0 | 485 </div> |
486 | |
487 <!-- ========================== --> | |
488 | |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
489 <div id="tabCompos"> |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
490 <form method="post" action="" onsubmit="return addCompo()"> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
491 <input id="ncname" type="text" size="64" /><br /> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
492 <textarea id="ncdescription" rows="5" cols="60"></textarea><br /> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
493 <input id="nccompo" type="submit" value=" Add compo " /> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
494 <input type="button" value=" Clear " onClick="this.form.reset()" /> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
495 </form> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
496 <hr /> |
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
497 <div id="ncompos"></div> |
0 | 498 </div> |
499 | |
500 <!-- ========================== --> | |
501 | |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
502 <div id="tabEntries"> |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
503 <div id="nentries"></div> |
0 | 504 </div> |
505 | |
506 <!-- ========================== --> | |
507 | |
508 <script type="text/javascript"> | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
509 registerTab("tabSettings", "Settings"); |
7
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
510 registerTab("tabNews", "News"); |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
511 registerTab("tabAttendees", "Attendees"); |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
512 registerTab("tabDump", "Dump"); |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
513 registerTab("tabCompos", "Compos"); |
d76020022881
Various fixes, cleanups and improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
514 registerTab("tabEntries", "Entries"); |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
515 updateTabList(); |
17 | 516 switchActiveTab("tabSettings"); |
0 | 517 </script> |
5
76c3b89d7b11
Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
518 <? } ?> |