annotate admajax.php @ 374:9c4accca7bf8

Add some helper functions.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 03 Dec 2013 15:52:08 +0200
parents ff8462a80cf2
children 028daa721ee2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 <?
56
243e9a51920b Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
2 //
136
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
3 // FAPWeb Simple Demoparty System
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
4 // Party administration page AJAX backend module
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
56
243e9a51920b Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
6 //
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
7 $sessionType = "admin";
175
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
8 require_once "mconfig.inc.php";
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
9 require_once "msite.inc.php";
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
10 require_once "msession.inc.php";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
12
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 227
diff changeset
13 function stValidateRequestCompoData($full)
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
14 {
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
15 if (!stChkRequestItem("name", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
16 array(CHK_ISGT, VT_STR, 0, "Compo name too short"),
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
17 array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_NAME, "Compo name too long.")) ||
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
18 !stChkRequestItem("description", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
19 array(CHK_ISGT, VT_STR, 10, "Compo description too short"),
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
20 array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_DESC, "Compo description too long.")))
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
21 return FALSE;
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
22
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
23 if (!$full)
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
24 return TRUE;
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
25
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
26 return
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
27 stChkRequestItem("visible", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
28 array(CHK_TYPE, VT_BOOL, "Invalid data.")
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
29 ) &&
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
30 stChkRequestItem("voting", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
31 array(CHK_TYPE, VT_BOOL, "Invalid data.")
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
32 ) &&
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
33 stChkRequestItem("showAuthors", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
34 array(CHK_TYPE, VT_BOOL, "Invalid data.")
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
35 );
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
36 }
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
37
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
38
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 227
diff changeset
39 function stValidateRequestEntryData(&$compo_id)
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
40 {
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
41 return
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
42 stChkRequestItem("name", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
43 array(CHK_ISGT, VT_STR, 0, "Entry name too short."),
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
44 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NAME, "Entry name too long.")
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
45 ) &&
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
46 stChkRequestItem("author", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
47 array(CHK_ISGT, VT_STR, 0, "Author name not set."),
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
48 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_AUTHOR, "Entry author too long.")
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
49 ) &&
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
50 stChkRequestItem("filename", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
51 array(CHK_TYPE, VT_TEXT, "Invalid data."),
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
52 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_FILENAME, "Entry filename too long.")
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
53 ) &&
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
54 stChkRequestItem("info", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
55 array(CHK_TYPE, VT_TEXT, "Invalid data."),
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
56 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_INFO, "Entry info too long.")
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
57 ) &&
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
58 stChkRequestItem("compo_id", $compo_id,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
59 array(CHK_TYPE, VT_INT, "Invalid compo ID.")
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
60 );
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
61 }
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
62
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
63
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 227
diff changeset
64 function stValidateRequestNewsData()
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
65 {
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
66 return
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
67 stChkRequestItem("text", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
68 array(CHK_ISGT, VT_STR, 0, "News text too short."),
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
69 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TEXT, "News text too long.")
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
70 ) &&
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
71 stChkRequestItem("author", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
72 array(CHK_ISGT, VT_STR, 0, "News author name too short."),
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
73 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_AUTHOR, "News author name too long.")
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
74 ) &&
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
75 stChkRequestItem("title", $fake,
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
76 array(CHK_ISGT, VT_STR, 0, "News title too short."),
261
b9a40d930bb6 Use CHK_LTEQ instead of CHK_ISLT.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
77 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TITLE, "News title too long.")
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
78 );
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
79 }
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
80
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
81
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
82 function stGetCompoData($id, $item, $prefix)
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
83 {
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
84 return
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
85 " <h2>#".$id." - ".chentities($item["name"])."</h2>\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
86 " ".stGetFormTextInput(40, SET_LEN_COMPO_NAME, "name", $id, $prefix, $item["name"])."\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
87 " ".stGetFormCheckBoxInput("visible", $id, $prefix, $item["visible"], "Visible")."\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
88 " ".stGetFormCheckBoxInput("showAuthors", $id, $prefix, $item["showAuthors"], "Show authors")."\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
89 " ".stGetFormCheckBoxInput("voting", $id, $prefix, $item["voting"], "Enable voting")."<br />\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
90 " ".stGetFormTextArea(5, 60, "description", $id, $prefix, $item["description"])."\n<br />\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
91 " ".stGetFormButtonInput("update", $id, $prefix, "Update", "updateCompo(".$id.")")."\n";
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
92 }
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
93
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
94
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
95 function stGetNewsItemData($id, $item, $prefix)
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
96 {
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
97 return
227
44081a2066f5 Cosmetic improvements in news editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
98 " <h2>".chentities($item["title"])."</h2>\n".
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
99 " ".stGetFormTextInput(40, SET_LEN_NEWS_TITLE, "title", $id, $prefix, $item["title"]).
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
100 " - posted ".date("d M Y / H:i", $item["utime"])."<br />\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
101 " ".stGetFormTextArea(5, 60, "text", $id, $prefix, $item["text"])."<br />\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
102 " ".stGetFormTextInput(20, SET_LEN_NEWS_AUTHOR, "author", $id, $prefix, $item["author"])."\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
103 " ".stGetFormButtonInput("", "upd".$id, $prefix, "Update", "updateNews(".$id.")")."\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
104 " ".stGetFormButtonInput("", "del".$id, $prefix, "Delete", "deleteNews(".$id.")")."\n";
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
105 }
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
106
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
107
257
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
108 function stGetEntryItemData($eid, $item, $prefix)
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
109 {
259
a7aa20dec154 Some more work.
Matti Hamalainen <ccr@tnsp.org>
parents: 258
diff changeset
110 return
257
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
111 " <td>".($item["show_id"] > 0 ? $item["show_id"] : "-")."</td>\n".
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
112 " <td>".stGetFormTextInput(20, SET_LEN_ENTRY_NAME, "name", $eid, $prefix, $item["name"])."</td>\n".
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
113 " <td>".stGetFormTextInput(15, SET_LEN_ENTRY_AUTHOR, "author", $eid, $prefix, $item["author"])."</td>\n".
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
114 " <td>".stGetFormTextInput(20, SET_LEN_ENTRY_FILENAME, "filename", $eid, $prefix, $item["filename"])."</td>\n".
266
c535c5a8a36d Use HTML textarea entry for compoentry information field.
Matti Hamalainen <ccr@tnsp.org>
parents: 265
diff changeset
115 " <td>".stGetFormTextArea(2, 30, "info", $eid, $prefix, $item["info"])."</td>\n".
257
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
116 " <td>".
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 257
diff changeset
117 stGetFormButtonInput("delete", $eid, $prefix, "Del", "deleteEntry(".$item["compo_id"].",".$eid.")").
257
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
118 stGetFormTextInput(3, 3, "compo_id", $eid, $prefix, $item["compo_id"]).
289
b91e92f18cac Make changing of entry's compo_id to work in a somewhat more userfriendly manner.
Matti Hamalainen <ccr@tnsp.org>
parents: 288
diff changeset
119 stGetFormButtonInput("update", $eid, $prefix, "Upd", "updateEntry(".$item["compo_id"].",".$eid.")").
257
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
120 "</td>\n";
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
121 }
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
122
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
123
321
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
124 function stGetVoteKeyClass($item)
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
125 {
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
126 global $voteKeyMode;
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
127
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
128 switch ($voteKeyMode)
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
129 {
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
130 case VOTE_FREELY:
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
131 $cond = 0;
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
132 break;
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
133
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
134 case VOTE_ACTIVATE:
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
135 $cond = $item["active"];
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
136 break;
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
137
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
138 case VOTE_ASSIGN:
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
139 $cond = $item["key_id"] > 0;
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
140 break;
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
141 }
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
142
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
143 return "votekey ".($cond ? "vkeyActive" : "vkeyInactive");
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
144 }
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
145
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
146
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
147 function stGetVoteKeyItemData($id, $item, $prefix)
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
148 {
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
149 global $voteKeyMode, $voteKeyLen;
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
150
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
151 switch ($voteKeyMode)
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
152 {
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
153 case VOTE_FREELY:
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
154 case VOTE_ACTIVATE:
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
155 $str = sprintf(
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
156 "<span class=\"keyid\">%03d</span>&nbsp;:&nbsp;".
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
157 "<span class=\"keycode\">%s</span>",
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
158 $id,
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
159 str_repeat("&nbsp;", $voteKeyLen - strlen($item["key"])).$item["key"]);
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
160
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
161 if ($voteKeyMode == VOTE_ACTIVATE)
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
162 {
319
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
163 $str .= stGetFormCheckBoxInput("active", $id, $prefix, $item["active"], FALSE,
320
a0a6131c37b4 Vote key activation.
Matti Hamalainen <ccr@tnsp.org>
parents: 319
diff changeset
164 "class=\"keyactive\" onClick=\"voteKeySetActive(".$id.")\"", "");
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
165 }
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
166
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
167 return $str;
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
168
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
169 case VOTE_ASSIGN:
319
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
170 $str =
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
171 " <td class=\"name\">".chentities($item["name"])."</td>\n".
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
172 " <td class=\"groups\">".chentities($item["groups"])."</td>\n".
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
173 " <td class=\"vkeynum\">".
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
174 stGetFormTextInput(5, 5, "key_id", $id, $prefix, $item["key_id"]).
319
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
175 stGetFormButtonInput("assign", $id, $prefix, "Set", "voteKeyAssign(".$id.",1)");
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
176
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
177 if ($item["key_id"] != 0)
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
178 $str .= stGetFormButtonInput("clear", $id, $prefix, "Clear", "voteKeyAssign(".$id.",0)");
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
179
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
180 $str .=
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
181 "</td>\n".
324
f3dfdb4fb221 Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents: 321
diff changeset
182 " <td class=\"vkey\">";
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
183
324
f3dfdb4fb221 Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents: 321
diff changeset
184 if ($item["key_id"] > 0)
f3dfdb4fb221 Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents: 321
diff changeset
185 $str .= sprintf("<span class=\"keyid\">%03d</span>".
f3dfdb4fb221 Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents: 321
diff changeset
186 "&nbsp;:&nbsp;<span class=\"keycode\">%s</span>",
f3dfdb4fb221 Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents: 321
diff changeset
187 $item["key_id"], chentities($item["key"]));
f3dfdb4fb221 Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents: 321
diff changeset
188
f3dfdb4fb221 Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents: 321
diff changeset
189 $str .= "</td>\n";
319
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
190 return $str;
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
191 }
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
192 }
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
193
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
194
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
195 function stGetSaveButton()
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
196 {
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
197 return "<input type=\"submit\" value=\" Save \" />\n";
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
198 }
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
199
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
200
374
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
201 function stGetOptionList($id, $sql, $iname, $active, $onChange = "")
371
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
202 {
374
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
203 $str =
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
204 "<select class=\"selectBox\" id=\"".$id."\" size=\"10\"".
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
205 ($onChange != "" ? " onChange=\"".$onChange."\"" : "").">\n";
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
206
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
207 if (($res = stExecSQL($sql)) !== false)
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
208 {
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
209 foreach ($res as $item)
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
210 {
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
211 $str .= "<option value=\"".$item["id"]."\"".
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
212 ($active == $item["id"] ? " selected=\"selected\"" : "").
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
213 ">".chentities($item[$iname])."</option>\n";
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
214 }
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
215 }
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
216
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
217 return $str."</select>\n";
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
218 }
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
219
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
220
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
221 function stGetShowModeButton($mode, $name, $cmode)
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
222 {
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
223 return stGetFormRadioButtonInput(
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
224 "showMode", "", "", $mode,
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
225 $cmode == $mode,
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
226 $name,
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
227 "onClick=\"setDisplayVar('showMode',".$mode.")\"");
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
228 }
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
229
9c4accca7bf8 Add some helper functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 373
diff changeset
230
373
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
231 function stRandomizeCompoShowOrder($compo_id, $patch)
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
232 {
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
233 $entries = stExecSQL("SELECT id,show_id FROM entries WHERE compo_id=".$compo_id);
371
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
234 if ($entries !== FALSE)
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
235 {
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
236 $final = array();
373
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
237
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
238 if ($patch)
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
239 {
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
240 $iindex = -1;
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
241 foreach ($entries as $entry)
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
242 {
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
243 if ($entry["show_id"] == 0)
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
244 $final[] = $entry["id"];
372
f09b4c08a920 Actually shuffle .. oops.
Matti Hamalainen <ccr@tnsp.org>
parents: 371
diff changeset
245
373
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
246 if ($entry["show_id"] > $index)
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
247 $index = $entry["show_id"];
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
248 }
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
249
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
250 $index++;
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
251 }
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
252 else
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
253 {
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
254 foreach ($entries as $entry)
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
255 $final[] = $entry["id"];
372
f09b4c08a920 Actually shuffle .. oops.
Matti Hamalainen <ccr@tnsp.org>
parents: 371
diff changeset
256
373
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
257 shuffle($final);
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
258 $index = 1;
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
259 }
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
260
371
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
261 foreach ($final as $entry)
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
262 {
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
263 $sql = stPrepareSQL("UPDATE entries SET show_id=%d WHERE id=%d", $index, $entry);
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
264 if (stExecSQL($sql) === false)
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
265 {
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
266 stError("Error updating entry show positions.");
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
267 break;
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
268 }
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
269 $index++;
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
270 }
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
271 }
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
272 }
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
273
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
274
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
275 //
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 // Check if we are allowed to execute
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
277 //
360
2af8458058ab Implement CSRF token checks.
Matti Hamalainen <ccr@tnsp.org>
parents: 352
diff changeset
278 if (!stCheckHTTPS() || !stAdmSessionAuth() || !stCSRFCheck())
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 {
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
280 stSetupCacheControl();
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
281
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
282 stSessionEnd(SESS_ADMIN);
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
283
123
5837b9333964 Add new "about" page, and setting for default page.
Matti Hamalainen <ccr@tnsp.org>
parents: 116
diff changeset
284 header("Location: ".stGetSetting("defaultPage"));
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285 exit;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
288
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
289 //
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
290 // Initialize
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
291 //
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
292 stSetupCacheControl();
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294 if (!stConnectSQLDB())
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295 die("Could not connect to SQL database.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
297 stReloadSettings();
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
298
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299
305
b96c41bd9dd6 More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
300 $voteKeyMode = stGetSetting("voteKeyMode");
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
301 $voteKeyLen = stGetSetting("userKeyLength");
208
8985d2bdb29b More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 207
diff changeset
302 $type = stGetRequestItem("type", "");
8985d2bdb29b More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 207
diff changeset
303 switch (stGetRequestItem("action", ""))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 {
370
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
305 case "randomize":
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
306 //
370
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
307 // Randomize entries display order
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
308 //
373
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
309 $patch = intval(stGetRequestItem("patch", 1));
371
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
310 if ($type == "all")
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 {
371
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
312 if (($compos = stExecSQL("SELECT id FROM compos")) === FALSE)
370
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
313 stError("Eh? SQL error occured.");
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
314 else
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
315 foreach ($compos as $compo)
373
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
316 stRandomizeCompoShowOrder($compo["id"], $patch);
371
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
317 }
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
318 else
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
319 if ($type == "compo")
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
320 {
1a7f97a36047 Modularize some more.
Matti Hamalainen <ccr@tnsp.org>
parents: 370
diff changeset
321 if (stChkRequestItem("id", $compo_id, array(CHK_TYPE, VT_INT, "Invalid data.")))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 {
373
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
323 stRandomizeCompoShowOrder($compo_id, $patch);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324 }
370
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
325 }
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
326 else
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
327 if ($type == "check")
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
328 {
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
329 if (($compos = stExecSQL("SELECT * FROM compos")) === FALSE)
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
330 stError("Eh? SQL error occured.");
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
331 else
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
332 foreach ($compos as $compo)
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
333 {
373
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
334 $nentries = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE show_id=0 AND compo_id=".$compo["id"]);
370
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
335 if ($nentries > 0)
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
336 {
373
ff8462a80cf2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 372
diff changeset
337 stError("Compo #".$compo["id"]." - ".$compo["name"]." has NO show order set for some entries.");
370
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
338 }
d65f28bf1080 Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents: 366
diff changeset
339 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 case "get":
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
344 //
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
345 // Get specific data
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
346 //
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347 switch ($type)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 case "news":
265
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
350 echo
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
351 "<form method=\"post\" action=\"\" onsubmit=\"return addNews()\">\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
352 " ".stGetFormTextInput(40, SET_LEN_NEWS_TITLE, "", "nntitle", "", "")."<br />\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
353 " ".stGetFormTextArea(5, 60, "", "nntext", "", "")."<br />\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
354 " ".stGetFormTextInput(20, SET_LEN_NEWS_AUTHOR, "", "nnauthor", "", "orgaz")."\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
355 " ".stGetFormSubmitInput("nnadd", "Add post")."\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
356 " ".stGetFormButtonInput("", "", "", "Clear", "this.form.reset()")."\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
357 "</form>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
358 "<hr />\n";
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
359
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 $sql = "SELECT * FROM news ORDER BY utime DESC";
265
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
361 foreach (stExecSQL($sql) as $item)
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
362 {
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
363 echo
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
364 "<div id=\"news".$item["id"]."\">\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
365 stGetNewsItemData($item["id"], $item, "ne").
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
366 "</div>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
367 "<hr />\n";
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
368 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
371 case "newsitem":
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
372 $res = stFetchSQL(stPrepareSQL("SELECT * FROM news WHERE id=%D", "id"));
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
373 if ($res !== FALSE)
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
374 echo stGetNewsItemData($res["id"], $res, "ne");
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
375 break;
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
376
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 case "attendees":
272
cd3283333ec1 Add link for printing out email addresses of participants.
Matti Hamalainen <ccr@tnsp.org>
parents: 270
diff changeset
378 echo
273
39c247babc0c Make the print links look a bit nicer.
Matti Hamalainen <ccr@tnsp.org>
parents: 272
diff changeset
379 "<div class=\"tabHeadersSub\">\n".
275
11cd85bdfac7 Clarify some links.
Matti Hamalainen <ccr@tnsp.org>
parents: 274
diff changeset
380 "<a href=\"print.php?type=emails\" target=\"_blank\">Show plain list of e-mails</a>\n".
272
cd3283333ec1 Add link for printing out email addresses of participants.
Matti Hamalainen <ccr@tnsp.org>
parents: 270
diff changeset
381 "</div>\n";
cd3283333ec1 Add link for printing out email addresses of participants.
Matti Hamalainen <ccr@tnsp.org>
parents: 270
diff changeset
382
265
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
383 // For adding a new one
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
384 $prefix = "ne";
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
385 echo
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
386 "<table>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
387 " <tr>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
388 " <th>Name</th>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
389 " <th>Groups</th>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
390 " <th>Oneliner</th>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
391 " <th>E-mail</th>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
392 " <th>Actions</th>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
393 " </tr>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
394 " <tr>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
395 " <td>".stGetFormTextInput(20, SET_LEN_USERNAME, "name", "x", $prefix, "")."</td>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
396 " <td>".stGetFormTextInput(20, SET_LEN_GROUPS, "groups", "x", $prefix, "")."</td>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
397 " <td>".stGetFormTextInput(30, SET_LEN_ONELINER, "oneliner", "x", $prefix, "")."</td>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
398 " <td>".stGetFormTextInput(20, SET_LEN_EMAIL, "email", "x", $prefix, "")."</td>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
399 " <td>".stGetFormButtonInput("add", "", $prefix, " Add new ", "addAttendee()")."</td>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
400 " </tr>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
401 "</table>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
402 "<hr />\n";
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
403
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
404 // List of attendees
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
405 echo
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
406 "<table class=\"attendees\">\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
407 " <tr>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
408 " <th class=\"name\">Name</th>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
409 " <th class=\"groups\">Groups</th>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
410 " <th class=\"regtime\">Registered</th>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
411 " <th class=\"oneliner\">Oneliner</th>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
412 " <th class=\"email\">E-mail</th>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
413 " <th>Actions</th>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
414 " </tr>\n";
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
415
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416 $sql = "SELECT * FROM attendees ORDER BY regtime DESC";
265
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
417 $row = 0;
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
418 foreach (stExecSQL($sql) as $item)
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
419 stPrintAttendee($item, $row++, TRUE, TRUE, FALSE);
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
420
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
421 echo
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
422 "</table>\n";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
423 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
424
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
425 case "attendee":
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
426 $res = stFetchSQL(stPrepareSQL("SELECT * FROM attendees WHERE id=%D", "id"));
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
427 if ($res !== FALSE)
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
428 stPrintAttendee($res, -1, FALSE, TRUE, stGetRequestItem("edit", FALSE));
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
429 break;
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 204
diff changeset
430
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
431 case "votekey":
321
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
432 case "votekeyclass":
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
433 switch ($voteKeyMode)
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
434 {
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
435 case VOTE_FREELY:
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
436 case VOTE_ACTIVATE:
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
437 $sql = stPrepareSQL("SELECT * FROM votekeys WHERE id=%D", "id");
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
438 break;
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
439
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
440 case VOTE_ASSIGN:
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
441 $sql = stPrepareSQL("SELECT votekeys.key,attendees.* FROM attendees ".
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
442 "LEFT JOIN votekeys ON votekeys.id=attendees.key_id ".
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
443 "WHERE attendees.id=%D", "id");
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
444 break;
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
445 }
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
446 if (($res = stFetchSQL($sql)) !== FALSE)
321
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
447 {
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
448 if ($type == "votekeyclass")
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
449 echo stGetVoteKeyClass($res);
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
450 else
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
451 echo stGetVoteKeyItemData($res["id"], $res, "vk");
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
452 }
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
453 break;
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
454
105
a85f258f6beb Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
455 case "voters":
270
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
456 // Generate vote keys, if needed
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
457 $numVKeys = stFetchSQLColumn("SELECT COUNT(*) FROM votekeys");
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
458 $numUsers = stFetchSQLColumn("SELECT COUNT(*) FROM attendees");
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
459 while ($numVKeys < $numUsers)
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
460 {
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
461 if (($key = stGenerateUserKey()) !== false)
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
462 {
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
463 if (stExecSQL(stPrepareSQL("INSERT INTO votekeys (key) VALUES (%s)", $key)) !== false)
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
464 $numVKeys++;
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
465 }
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
466 }
589b44acb74a More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 269
diff changeset
467
269
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
468 // List of votekeys
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
469 echo
305
b96c41bd9dd6 More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
470 "<div class=\"info\"><b>Voting mode: ".$voteModeData[$voteKeyMode][0]."</b>. ".$voteModeData[$voteKeyMode][1]."</div>\n".
273
39c247babc0c Make the print links look a bit nicer.
Matti Hamalainen <ccr@tnsp.org>
parents: 272
diff changeset
471 "<div class=\"tabHeadersSub\">\n".
275
11cd85bdfac7 Clarify some links.
Matti Hamalainen <ccr@tnsp.org>
parents: 274
diff changeset
472 "<a href=\"print.php?type=votekeys\" target=\"_blank\">Show printable key list</a>\n".
269
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
473 "</div>\n";
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
474
305
b96c41bd9dd6 More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
475 switch ($voteKeyMode)
116
a95facb41c86 Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
476 {
a95facb41c86 Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
477 case VOTE_FREELY:
269
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
478 case VOTE_ACTIVATE:
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
479 $sql = "SELECT * FROM votekeys ORDER BY votekeys.id ASC";
116
a95facb41c86 Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
480
269
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
481 foreach (stExecSQL($sql) as $item)
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
482 {
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
483 // This funny code is to ensure that the cells are of uniform width
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
484 echo
321
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
485 "<div class=\"".stGetVoteKeyClass($item).
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
486 "\" id=\"vkey".$item["id"]."\">".
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
487 stGetVoteKeyItemData($item["id"], $item, "vk").
320
a0a6131c37b4 Vote key activation.
Matti Hamalainen <ccr@tnsp.org>
parents: 319
diff changeset
488 "</div>\n";
269
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
489 }
116
a95facb41c86 Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
490 break;
a95facb41c86 Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
491
a95facb41c86 Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
492 case VOTE_ASSIGN:
308
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
493 $sql = "SELECT votekeys.key,attendees.* FROM attendees ".
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
494 "LEFT JOIN votekeys ON votekeys.id=attendees.key_id ".
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
495 "ORDER BY attendees.regtime DESC";
269
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
496
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
497 echo
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
498 "<table class=\"attendees\">\n".
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
499 " <tr>\n".
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
500 " <th class=\"name\">Name</th>\n".
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
501 " <th class=\"groups\">Groups</th>\n".
308
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
502 " <th class=\"vkeynum\">Key #</th>\n".
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
503 " <th class=\"vkey\">Votekey</th>\n".
269
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
504 " </tr>\n";
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
505
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
506 $index = 0;
269
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
507 foreach (stExecSQL($sql) as $item)
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
508 {
308
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
509 echo
321
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
510 " <tr class=\"".stGetVoteKeyClass($item).
9462a59d3ab3 Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 320
diff changeset
511 "\" id=\"vkey".$item["id"]."\">\n".
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
512 stGetVoteKeyItemData($item["id"], $item, "vk").
308
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
513 " </tr>\n";
269
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
514 }
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
515
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
516 echo
46138f8478e5 Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents: 266
diff changeset
517 "</table>\n";
116
a95facb41c86 Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
518 break;
a95facb41c86 Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
519 }
105
a85f258f6beb Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
520 break;
a85f258f6beb Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
521
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
522 case "compos":
265
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
523 echo
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
524 "<form method=\"post\" action=\"\" onsubmit=\"return addCompo()\">\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
525 " ".stGetFormTextInput(64, SET_LEN_COMPO_NAME, "", "ncname", "", "")."<br />\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
526 " ".stGetFormTextArea(5, 60, "", "ncdescription", "", "")."<br />\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
527 " ".stGetFormSubmitInput("nccompo", "Add compo")."\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
528 " ".stGetFormButtonInput("", "", "", "Clear", "this.form.reset()")."\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
529 "</form>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
530 "<hr />\n";
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
531
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
532 $sql = "SELECT * FROM compos ORDER BY id DESC";
265
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
533 foreach (stExecSQL($sql) as $item)
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
534 {
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
535 echo
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
536 "<div id=\"compo".$item["id"]."\">\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
537 stGetCompoData($item["id"], $item, "co").
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
538 "</div>\n".
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
539 "<hr />\n";
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
540 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
541 break;
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
542
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
543 case "compo":
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
544 $res = stFetchSQL(stPrepareSQL("SELECT * FROM compos WHERE id=%D", "id"));
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
545 if ($res !== FALSE)
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
546 echo stGetCompoData($res["id"], $res, "co");
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
547 break;
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
548
352
7944ad74b31c Remove dead code.
Matti Hamalainen <ccr@tnsp.org>
parents: 324
diff changeset
549
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
550 case "settings":
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
551 $prefix = "st";
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
552
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
553 echo
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
554 "<h1>Site settings</h1>\n".
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 198
diff changeset
555 "<form method=\"post\" action=\"\" onsubmit=\"return updateSettings()\">\n".
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
556 "<table>\n";
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
557 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
558 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
559 echo
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
560 " <tr>\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
561 " <td>";
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
562 $id = $item["key"];
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
563 switch ($item["vtype"])
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
564 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
565 case VT_INT:
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
566 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
567 break;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
568 case VT_STR:
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
569 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
570 break;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
571 case VT_BOOL:
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
572 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
573 break;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
574 }
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
575 echo "</td>\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
576 " <td>".$item["desc"]."</td>\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
577 " </tr>\n";
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
578 }
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
579 echo "</table>\n".stGetSaveButton();
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
580
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
581 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
582 {
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
583 echo
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
584 "<h2>".chentities($item["desc"])."</h2>\n".
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
585 stGetFormTextArea(10, 60, "", $item["key"], $prefix, $item["vtext"]).
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
586 "\n<br />\n".
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
587 stGetSaveButton();
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
588 }
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 198
diff changeset
589 echo "</form>\n";
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
590 break;
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
591
250
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 249
diff changeset
592 case "compolist":
249
6927edc7e266 Get compo name list as JSON.
Matti Hamalainen <ccr@tnsp.org>
parents: 228
diff changeset
593 $index = 0;
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
594 foreach (stExecSQL("SELECT * FROM compos") as $compo)
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
595 {
249
6927edc7e266 Get compo name list as JSON.
Matti Hamalainen <ccr@tnsp.org>
parents: 228
diff changeset
596 if ($index++ > 0) echo ",";
251
1953d5025531 Alter the JSON format of the compo data list.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
597 echo "\"".$compo["id"]."\":\"".chentities($compo["name"])."\"";
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
598 }
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
599 break;
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
600
257
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
601 case "entry":
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
602 $res = stFetchSQL(stPrepareSQL("SELECT * FROM entries WHERE id=%D", "id"));
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
603 if ($res !== FALSE)
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
604 echo stGetEntryItemData($res["id"], $res, "en");
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
605 break;
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
606
250
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 249
diff changeset
607 case "entries":
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
608 $id = intval(stGetRequestItem("id", 0));
250
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 249
diff changeset
609 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== false)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
610 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
611 echo
265
d1f99f239046 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 264
diff changeset
612 "<h1 style=\"margin-bottom: 0px;\">#".$id." - ".chentities($compo["name"])."</h1>\n".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
613 "<form>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
614 " <table class=\"misc\">\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
615 " <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
616 " <th style=\"width:4%;\">S#</th>\n".
264
fb9bf61c9918 s/Title/Name/
Matti Hamalainen <ccr@tnsp.org>
parents: 262
diff changeset
617 " <th>Name</th>\n".
29
4b5a176805e2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
618 " <th>Author(s)</th>\n".
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
619 " <th>Filename</th>\n".
215
bfd480370a70 More work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 214
diff changeset
620 " <th>Info</th>\n".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
621 " <th>Actions</th>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
622 " </tr>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
623
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
624 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$id) as $entry)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
625 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
626 echo
257
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
627 " <tr id=\"entry".$entry["id"]."\">\n".
ef9a007c0876 Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
628 stGetEntryItemData($entry["id"], $entry, "en").
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
629 " </tr>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
630 }
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
631
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
632 $prefix = "ne";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
633 echo
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
634 " <tr>\n".
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
635 " <td></td>\n".
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
636 " <td>".stGetFormTextInput(20, SET_LEN_ENTRY_NAME, "name", $id, $prefix, "")."</td>\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
637 " <td>".stGetFormTextInput(15, SET_LEN_ENTRY_AUTHOR, "author", $id, $prefix, "")."</td>\n".
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
638 " <td>".stGetFormTextInput(20, SET_LEN_ENTRY_FILENAME, "filename", $id, $prefix, "")."</td>\n".
266
c535c5a8a36d Use HTML textarea entry for compoentry information field.
Matti Hamalainen <ccr@tnsp.org>
parents: 265
diff changeset
639 // " <td>".stGetFormTextInput(20, SET_LEN_ENTRY_INFO, "info", $id, $prefix, "")."</td>\n".
c535c5a8a36d Use HTML textarea entry for compoentry information field.
Matti Hamalainen <ccr@tnsp.org>
parents: 265
diff changeset
640 " <td>".stGetFormTextArea(2, 30, "info", $id, $prefix, "")."</td>\n".
215
bfd480370a70 More work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 214
diff changeset
641 " <td>".stGetFormButtonInput("add", $id, $prefix, "Add new", "addEntry(".$id.")")."</td>\n".
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
642 " </tr>\n".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
643 " </table>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
644 "</form>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
645 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
646 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
647 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
648 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
649
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
650 case "delete":
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
651 //
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
652 // Delete entry
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
653 //
208
8985d2bdb29b More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 207
diff changeset
654 if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data.")))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
655 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
656 if ($type == "news")
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
657 {
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
658 $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
659 stExecSQLCond($sql, "OK, news item ".$id." deleted.");
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
660 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
661 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
662 if ($type == "attendees")
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
663 {
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
664 // Attendees require some more work
302
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
665 $sql = stPrepareSQL("SELECT * FROM attendees WHERE id=%d", $id);
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
666 if (($attn = stFetchSQL($sql)) !== false)
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
667 {
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
668 $sql = stPrepareSQL("DELETE FROM attendees WHERE id=%d", $id);
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
669 stExecSQLCond($sql, "OK, attendee ".$id." deleted.");
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
670
305
b96c41bd9dd6 More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
671 // If assigned votekey mode, delete the key and votes as well
b96c41bd9dd6 More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
672 if ($voteKeyMode == VOTE_ASSIGN && $attn["key_id"] != 0)
302
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
673 {
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
674 $sql = stPrepareSQL("DELETE FROM votekeys WHERE id=%d", $attn["key_id"]);
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
675 stExecSQLCond($sql, "OK, attendee ".$id." votekey deleted.");
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
676
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
677 $sql = stPrepareSQL("DELETE FROM votes WHERE key_id=%d", $attn["key_id"]);
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
678 stExecSQLCond($sql, "OK, attendee ".$id." votes deleted.");
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
679 }
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
680 }
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
681 else
828fc30e3c94 Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
682 stError("No such attendee ID #".$id);
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
683 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
684 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
685 if ($type == "entries")
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
686 {
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
687 // .. as do compo entries
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
688 $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
689 stExecSQLCond($sql, "OK, entry ".$id." deleted.");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
690
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
691 $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
692 stExecSQLCond($sql, "OK, entry ".$id." votes deleted.");
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
693 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
694 }
305
b96c41bd9dd6 More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
695 else
b96c41bd9dd6 More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
696 if ($type == "votekeys")
b96c41bd9dd6 More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
697 {
b96c41bd9dd6 More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
698 $sql = stPrepareSQL("DELETE FROM votekeys");
b96c41bd9dd6 More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
699 stExecSQLCond($sql, "OK, all votekeys purged");
b96c41bd9dd6 More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 302
diff changeset
700 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
701 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
702
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
703 case "add":
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
704 //
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
705 // Add new entry
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
706 //
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 227
diff changeset
707 if ($type == "news" && stValidateRequestNewsData())
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
708 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
709 $sql = stPrepareSQL(
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
710 "INSERT INTO news (utime,title,text,author) VALUES (%d,%S,%Q,%S)",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
711 time(), "title", "text", "author");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
712
66
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 61
diff changeset
713 stExecSQLCond($sql, "OK, news item added.");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
714 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
715 else
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 227
diff changeset
716 if ($type == "compo" && stValidateRequestCompoData(FALSE))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
717 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
718 $sql = stPrepareSQL(
55
4fac95384753 Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
719 "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
720 "name", "description");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
721
66
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 61
diff changeset
722 stExecSQLCond($sql, "OK, compo added.");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
723 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
724 else
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 227
diff changeset
725 if ($type == "attendees" && stValidateRequestUserData(TRUE))
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
726 {
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
727 $sql = stPrepareSQL(
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
728 "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
729 time(), "name", "groups", "oneliner", "email");
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
730
66
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 61
diff changeset
731 stExecSQLCond($sql, "OK, attendee added.");
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
732 }
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
733 else
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 227
diff changeset
734 if ($type == "entry" && stValidateRequestEntryData($fake))
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
735 {
296
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
736 if (stFetchSQLColumn(stPrepareSQL("SELECT id FROM compos WHERE id=%D", "compo_id")) === FALSE)
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
737 {
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
738 stError("No such compo ID.");
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
739 }
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
740 else
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
741 {
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
742 $sql = stPrepareSQL(
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
743 "INSERT INTO entries (name,author,compo_id,filename,info) VALUES (%S,%S,%D,%S,%Q)",
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
744 "name", "author", "compo_id", "filename", "info");
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
745
296
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
746 stExecSQLCond($sql, "OK, entry added.");
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
747 }
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
748 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
749 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
750
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
751 case "update":
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
752 //
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
753 // Update existing entry
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
754 //
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
755 if ($type == "settings")
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
756 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
757 foreach (stExecSQL("SELECT * FROM settings") as $item)
198
96ab189e5c03 Add some new helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
758 if (($val = stGetRequestItem($item["key"], FALSE)) !== FALSE)
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
759 {
198
96ab189e5c03 Add some new helper functions and use them.
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
760 $sql = "UPDATE settings SET ".stGetSettingSQL($item, $val)." WHERE key=".$db->quote($item["key"]);
66
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 61
diff changeset
761 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
762 }
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
763 }
366
9b266dcd1064 Oops, 10L for a missing else.
Matti Hamalainen <ccr@tnsp.org>
parents: 360
diff changeset
764 else
209
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
765 if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data.")))
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
766 {
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 227
diff changeset
767 if ($type == "attendees" && stValidateRequestUserData(TRUE))
209
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
768 {
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
769 $sql = stPrepareSQLUpdate("attendees",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
770 "WHERE id=".intval(stGetRequestItem("id")),
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
771 array(
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
772 "name" => "S",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
773 "groups" => "S",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
774 "email" => "S",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
775 "oneliner" => "S",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
776 ));
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
777
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
778 stExecSQLCond($sql, "OK, attendee updated.");
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
779 }
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
780 else
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 227
diff changeset
781 if ($type == "news" && stValidateRequestNewsData())
209
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
782 {
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
783 $sql = stPrepareSQLUpdate("news",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
784 "WHERE id=".intval(stGetRequestItem("id")),
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
785 array(
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
786 "title" => "S",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
787 "text" => "Q",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
788 "author" => "S"
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
789 ));
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
790
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
791 stExecSQLCond($sql, "OK, news item updated.");
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
792 }
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
793 else
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 227
diff changeset
794 if ($type == "compo" && stValidateRequestCompoData(TRUE))
209
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
795 {
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
796 $sql = stPrepareSQLUpdate("compos",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
797 "WHERE id=".intval(stGetRequestItem("id")),
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
798 array(
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
799 "name" => "S",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
800 "description" => "Q",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
801 "visible" => "B",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
802 "voting" => "B",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
803 "showAuthors" => "B",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
804 ));
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
805
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
806 stExecSQLCond($sql, "OK, compo updated.");
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
807 }
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
808 else
228
e3dd18b58e6c Rename some functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 227
diff changeset
809 if ($type == "entry" && stValidateRequestEntryData($compo_id))
209
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
810 {
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
811 if (stFetchSQLColumn("SELECT id FROM compos WHERE id=".$compo_id) === FALSE)
209
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
812 {
214
36423e8ab765 Improve input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 212
diff changeset
813 stError("No such compo ID.");
209
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
814 }
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
815 else
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
816 {
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
817 $sql = stPrepareSQLUpdate("entries",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
818 "WHERE id=".intval(stGetRequestItem("id")),
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
819 array(
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
820 "name" => "S",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
821 "author" => "S",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
822 "filename" => "S",
296
bbdf1b9c5a07 Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents: 289
diff changeset
823 "info" => "Q",
209
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
824 "compo_id" => "D",
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
825 ));
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
826
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
827 stExecSQLCond($sql, "OK, entry updated.");
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
828 }
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
829 }
308
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
830 else
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
831 if ($type == "votekey")
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
832 {
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
833 switch (stGetRequestItem("mode"))
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
834 {
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
835 case "assign":
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
836 // Check if already assigned to someone ..
318
008406f27395 Allow clearing of key id.
Matti Hamalainen <ccr@tnsp.org>
parents: 314
diff changeset
837 $key_id = intval(stGetRequestItem("key_id", 0));
319
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
838 $sql = stPrepareSQL("SELECT * FROM votekeys WHERE id=%d", $key_id);
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
839 if (stFetchSQL($sql) === false)
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
840 stError("Invalid key ID #.");
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
841 else
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
842 {
319
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
843 $sql = stPrepareSQL("SELECT * FROM attendees WHERE key_id=%d", $key_id);
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
844 if (($attn = stFetchSQL($sql)) !== false && $attn["id"] != $id)
314
50527339b615 Make sure that the key ID # is valid.
Matti Hamalainen <ccr@tnsp.org>
parents: 313
diff changeset
845 stError("That key has already been assigned to another attendee!");
319
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
846 else
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
847 {
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
848 // Assign ..
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
849 $sql = stPrepareSQL("UPDATE attendees SET key_id=%d WHERE id=%d", $key_id, $id);
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
850 stExecSQLCond($sql, "Assigned key updated.");
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
851 }
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
852 }
319
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
853 break;
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
854
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
855 case "clear":
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
856 $sql = stPrepareSQL("UPDATE attendees SET key_id=NULL WHERE id=%D", "id");
623acd958944 Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents: 318
diff changeset
857 stExecSQLCond($sql, "Assigned key cleared.");
308
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
858 break;
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
859
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
860 case "active":
312
9340eb112ccc Work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 309
diff changeset
861 // Autobots activate!
320
a0a6131c37b4 Vote key activation.
Matti Hamalainen <ccr@tnsp.org>
parents: 319
diff changeset
862 $sql = stPrepareSQL("UPDATE votekeys SET active=%B WHERE id=%D", "active", "id");
a0a6131c37b4 Vote key activation.
Matti Hamalainen <ccr@tnsp.org>
parents: 319
diff changeset
863 stExecSQLCond($sql, "Votekey status changed.");
308
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
864 break;
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
865 }
3cfd95758377 A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents: 305
diff changeset
866 }
209
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
867 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
868 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
869
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
870 default:
66
230aacc22cb4 Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents: 61
diff changeset
871 stSetStatus(404, "Not Found");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
872 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
873 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
874
211
5bae42020034 Factorize some code into msitegen.
Matti Hamalainen <ccr@tnsp.org>
parents: 210
diff changeset
875 stDumpAJAXStatusErrors();
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
876 ?>