Mercurial > hg > fapweb
annotate admajax.php @ 636:4ea7a88cdb2f
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 03 Nov 2014 00:00:20 +0200 |
parents | 59d14c0825cd |
children | c78e11aa3162 |
rev | line source |
---|---|
0 | 1 <? |
56 | 2 // |
571
ce11ea112a65
Change the header blurb a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
565
diff
changeset
|
3 // FAPWeb - Simple Web-based Demoparty Management System |
136
aeebfedb5709
Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents:
133
diff
changeset
|
4 // Party administration page AJAX backend module |
565 | 5 // (C) Copyright 2012-2014 Tecnic Software productions (TNSP) |
56 | 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 | 11 |
214 | 12 |
228 | 13 function stValidateRequestCompoData($full) |
214 | 14 { |
15 if (!stChkRequestItem("name", $fake, | |
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 | 18 !stChkRequestItem("description", $fake, |
19 array(CHK_ISGT, VT_STR, 10, "Compo description too short"), | |
635
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
20 array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_DESC, "Compo description too long.")) || |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
21 !stChkRequestItem("path", $fake, |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
22 array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_PATH, "Compo file path too long.")) || |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
23 !stChkRequestItem("type", $fake, |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
24 array(CHK_RANGE, VT_INT, array(COMPO_NORMAL, COMPO_ASSIGN), "Invalid compo type."))) |
214 | 25 return FALSE; |
26 | |
27 if (!$full) | |
28 return TRUE; | |
29 | |
30 return | |
31 stChkRequestItem("visible", $fake, | |
32 array(CHK_TYPE, VT_BOOL, "Invalid data.") | |
33 ) && | |
34 stChkRequestItem("voting", $fake, | |
35 array(CHK_TYPE, VT_BOOL, "Invalid data.") | |
36 ) && | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
37 stChkRequestItem("show_authors", $fake, |
214 | 38 array(CHK_TYPE, VT_BOOL, "Invalid data.") |
39 ); | |
40 } | |
41 | |
42 | |
228 | 43 function stValidateRequestEntryData(&$compo_id) |
214 | 44 { |
45 return | |
46 stChkRequestItem("name", $fake, | |
47 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
|
48 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NAME, "Entry name too long.") |
214 | 49 ) && |
50 stChkRequestItem("author", $fake, | |
51 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
|
52 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_AUTHOR, "Entry author too long.") |
214 | 53 ) && |
54 stChkRequestItem("filename", $fake, | |
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_FILENAME, "Entry filename too long.") |
214 | 57 ) && |
58 stChkRequestItem("info", $fake, | |
59 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
|
60 array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_INFO, "Entry info too long.") |
214 | 61 ) && |
62 stChkRequestItem("compo_id", $compo_id, | |
63 array(CHK_TYPE, VT_INT, "Invalid compo ID.") | |
64 ); | |
65 } | |
66 | |
67 | |
228 | 68 function stValidateRequestNewsData() |
214 | 69 { |
70 return | |
71 stChkRequestItem("text", $fake, | |
72 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
|
73 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TEXT, "News text too long.") |
214 | 74 ) && |
75 stChkRequestItem("author", $fake, | |
76 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
|
77 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_AUTHOR, "News author name too long.") |
214 | 78 ) && |
79 stChkRequestItem("title", $fake, | |
80 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
|
81 array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TITLE, "News title too long.") |
214 | 82 ); |
83 } | |
84 | |
85 | |
223
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
86 function stGetCompoData($id, $item, $prefix) |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
87 { |
635
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
88 switch ($item["type"]) |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
89 { |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
90 case COMPO_NORMAL: |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
91 $str = " ". |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
92 stGetFormCheckBoxInput("voting", $id, $prefix, $item["voting"], "Enable voting", "onChange=\"setCompoData(".$id.",'voting')\"")."<br />\n"; |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
93 break; |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
94 |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
95 default: |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
96 $str = " ". |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
97 stGetFormHiddenInput("voting", $id, $prefix, $item["voting"]); |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
98 break; |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
99 } |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
100 |
223
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
101 return |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
102 " <h2>#".$id." - ".chentities($item["name"])."</h2>\n". |
635
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
103 " Name: ".stGetFormTextInput(40, SET_LEN_COMPO_NAME, "name", $id, $prefix, $item["name"])."<br />\n". |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
104 " File path: ".stGetFormTextInput(40, SET_LEN_COMPO_PATH, "path", $id, $prefix, $item["path"])."<br />\n". |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
105 " ".stGetFormTextArea(8, 60, "description", $id, $prefix, $item["description"])."<br />\n". |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
106 " ".stGetFormButtonInput("update", $id, $prefix, "Update", "updateCompo(".$id.")")."\n". |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
107 " ".stGetFormButtonInput("delete", $id, $prefix, "Delete", "deleteCompo(".$id.")")."\n". |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
108 " ".stGetFormCheckBoxInput("visible", $id, $prefix, $item["visible"], "Visible", "onChange=\"setCompoData(".$id.",'visible')\"")."\n". |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
109 " ".stGetFormCheckBoxInput("show_authors", $id, $prefix, $item["show_authors"], "Show authors", "onChange=\"setCompoData(".$id.",'show_authors')\"")."\n". |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
110 $str; |
223
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
111 } |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
112 |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
113 |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
114 function stGetNewsItemData($id, $item, $prefix) |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
115 { |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
116 return |
227
44081a2066f5
Cosmetic improvements in news editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
223
diff
changeset
|
117 " <h2>".chentities($item["title"])."</h2>\n". |
223
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
118 " ".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
|
119 " - 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
|
120 " ".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
|
121 " ".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
|
122 " ".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
|
123 " ".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
|
124 } |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
125 |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
126 |
257
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
127 function stGetEntryItemData($eid, $item, $prefix) |
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
128 { |
259 | 129 return |
257
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
130 " <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
|
131 " <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
|
132 " <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
|
133 " <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
|
134 " <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
|
135 " <td>". |
258 | 136 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
|
137 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
|
138 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
|
139 "</td>\n"; |
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
140 } |
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
141 |
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
142 |
321
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
143 function stGetVoteKeyClass($item) |
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 global $voteKeyMode; |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
146 |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
147 switch ($voteKeyMode) |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
148 { |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
149 case VOTE_FREELY: |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
150 $cond = 0; |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
151 break; |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
152 |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
153 case VOTE_ACTIVATE: |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
154 $cond = $item["active"]; |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
155 break; |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
156 |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
157 case VOTE_ASSIGN: |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
158 $cond = $item["key_id"] > 0; |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
159 break; |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
160 } |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
161 |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
162 return "votekey ".($cond ? "vkeyActive" : "vkeyInactive"); |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
163 } |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
164 |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
165 |
312 | 166 function stGetVoteKeyItemData($id, $item, $prefix) |
167 { | |
168 global $voteKeyMode, $voteKeyLen; | |
169 | |
170 switch ($voteKeyMode) | |
171 { | |
172 case VOTE_FREELY: | |
173 case VOTE_ACTIVATE: | |
174 $str = sprintf( | |
175 "<span class=\"keyid\">%03d</span> : ". | |
176 "<span class=\"keycode\">%s</span>", | |
177 $id, | |
178 str_repeat(" ", $voteKeyLen - strlen($item["key"])).$item["key"]); | |
179 | |
180 if ($voteKeyMode == VOTE_ACTIVATE) | |
181 { | |
319
623acd958944
Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents:
318
diff
changeset
|
182 $str .= stGetFormCheckBoxInput("active", $id, $prefix, $item["active"], FALSE, |
534
067bef3846aa
Use onChange instead of onClick.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
183 "class=\"keyactive\" onChange=\"voteKeySetActive(".$id.")\"", ""); |
312 | 184 } |
185 | |
186 return $str; | |
187 | |
188 case VOTE_ASSIGN: | |
319
623acd958944
Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents:
318
diff
changeset
|
189 $str = |
312 | 190 " <td class=\"name\">".chentities($item["name"])."</td>\n". |
191 " <td class=\"groups\">".chentities($item["groups"])."</td>\n". | |
192 " <td class=\"vkeynum\">". | |
193 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
|
194 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
|
195 |
623acd958944
Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents:
318
diff
changeset
|
196 if ($item["key_id"] != 0) |
623acd958944
Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents:
318
diff
changeset
|
197 $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
|
198 |
623acd958944
Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents:
318
diff
changeset
|
199 $str .= |
623acd958944
Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents:
318
diff
changeset
|
200 "</td>\n". |
324
f3dfdb4fb221
Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
201 " <td class=\"vkey\">"; |
312 | 202 |
324
f3dfdb4fb221
Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
203 if ($item["key_id"] > 0) |
f3dfdb4fb221
Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
204 $str .= sprintf("<span class=\"keyid\">%03d</span>". |
f3dfdb4fb221
Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
205 " : <span class=\"keycode\">%s</span>", |
f3dfdb4fb221
Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
206 $item["key_id"], chentities($item["key"])); |
f3dfdb4fb221
Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
207 |
f3dfdb4fb221
Improve vkey admin visual usability.
Matti Hamalainen <ccr@tnsp.org>
parents:
321
diff
changeset
|
208 $str .= "</td>\n"; |
319
623acd958944
Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents:
318
diff
changeset
|
209 return $str; |
312 | 210 } |
211 } | |
212 | |
213 | |
398 | 214 function stGetInfoOneEntryData($show_id, $compo_id) |
215 { | |
411
2aa58de08d6d
If show_id for entry is 0, ignore it.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
216 if ($show_id > 0) |
2aa58de08d6d
If show_id for entry is 0, ignore it.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
217 { |
2aa58de08d6d
If show_id for entry is 0, ignore it.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
218 $sql = stPrepareSQL("SELECT * FROM entries WHERE show_id=%d AND compo_id=%d", |
2aa58de08d6d
If show_id for entry is 0, ignore it.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
219 $show_id, $compo_id); |
398 | 220 |
411
2aa58de08d6d
If show_id for entry is 0, ignore it.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
221 if (($entry = stFetchSQL($sql)) !== false) |
468
bc1755a9f89f
Add filenames to be shown in current/prev entry in compo control.
Matti Hamalainen <ccr@tnsp.org>
parents:
467
diff
changeset
|
222 { |
bc1755a9f89f
Add filenames to be shown in current/prev entry in compo control.
Matti Hamalainen <ccr@tnsp.org>
parents:
467
diff
changeset
|
223 return |
bc1755a9f89f
Add filenames to be shown in current/prev entry in compo control.
Matti Hamalainen <ccr@tnsp.org>
parents:
467
diff
changeset
|
224 "<b>#".$entry["show_id"]." - ".chentities($entry["name"]). |
bc1755a9f89f
Add filenames to be shown in current/prev entry in compo control.
Matti Hamalainen <ccr@tnsp.org>
parents:
467
diff
changeset
|
225 " by ".chentities($entry["author"])."</b><br />". |
470 | 226 "<i>".chentities(substr($entry["filename"], 0, 40))."</i>"; |
468
bc1755a9f89f
Add filenames to be shown in current/prev entry in compo control.
Matti Hamalainen <ccr@tnsp.org>
parents:
467
diff
changeset
|
227 } |
411
2aa58de08d6d
If show_id for entry is 0, ignore it.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
228 } |
2aa58de08d6d
If show_id for entry is 0, ignore it.
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
229 return "-"; |
398 | 230 } |
231 | |
232 | |
417 | 233 function stGetInfoCurrEntryData($indent) |
398 | 234 { |
235 $compoID = stGetDisplayVar("compoID"); | |
236 if ($compoID > 0) | |
237 { | |
238 $sql = stPrepareSQL("SELECT * FROM compos WHERE id=%d", $compoID); | |
239 if (($entry = stFetchSQL($sql)) !== false) | |
240 $strCompo = $entry["id"]." - ".chentities($entry["name"]); | |
241 | |
242 $strCurrEntry = stGetInfoOneEntryData(stGetDisplayVar("compoCurrEntry"), $compoID); | |
243 $strPrevEntry = stGetInfoOneEntryData(stGetDisplayVar("compoPrevEntry"), $compoID); | |
244 } | |
245 else | |
468
bc1755a9f89f
Add filenames to be shown in current/prev entry in compo control.
Matti Hamalainen <ccr@tnsp.org>
parents:
467
diff
changeset
|
246 $strCompo = $strCurrEntry = $strCurrEntryFile = $strPrevEntry = "-"; |
398 | 247 |
248 return | |
470 | 249 $indent."<div><b>".$strCompo."</b></div>\n". |
468
bc1755a9f89f
Add filenames to be shown in current/prev entry in compo control.
Matti Hamalainen <ccr@tnsp.org>
parents:
467
diff
changeset
|
250 $indent."<div>Current entry:<br />".$strCurrEntry."</div>\n". |
bc1755a9f89f
Add filenames to be shown in current/prev entry in compo control.
Matti Hamalainen <ccr@tnsp.org>
parents:
467
diff
changeset
|
251 $indent."<div>Previous entry:<br />".$strPrevEntry."</div>\n"; |
398 | 252 } |
253 | |
254 | |
417 | 255 function stGetInfoCurrEntryList($indent, $outer) |
398 | 256 { |
404 | 257 $sql = stPrepareSQL( |
258 "SELECT * FROM entries WHERE compo_id=%d ORDER BY show_id ASC", | |
259 stGetDisplayVar("compoID")); | |
260 | |
261 $currShowID = stGetDisplayVar("compoCurrEntry"); | |
413
9eb46567f0aa
If shown entry ID is undefined, don't select anything.
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
262 if ($currShowID <= 0) |
9eb46567f0aa
If shown entry ID is undefined, don't select anything.
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
263 $currShowID = -1; |
9eb46567f0aa
If shown entry ID is undefined, don't select anything.
Matti Hamalainen <ccr@tnsp.org>
parents:
412
diff
changeset
|
264 |
417 | 265 $str = stGetOptionListStart("ctrlEntryList", $indent, $outer); |
407 | 266 |
404 | 267 if (($res = stExecSQL($sql)) !== false) |
268 { | |
269 foreach ($res as $item) | |
270 { | |
417 | 271 $str .= $indent." ". |
272 stGetOptionListItem($item["show_id"], | |
404 | 273 ($item["show_id"] == $currShowID), |
469 | 274 sprintf("%3d. %-25s by %-15s", |
275 $item["show_id"], | |
276 substr($item["name"], 0, 25), | |
277 substr($item["author"], 0, 15))); | |
404 | 278 } |
279 } | |
417 | 280 |
636 | 281 return $str.stGetOptionListEnd($indent, $outer); |
417 | 282 } |
283 | |
284 | |
285 function stGetInfoRotationLists($indent, $outer) | |
286 { | |
287 $sql = | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
288 "SELECT rot_list_data.*, ". |
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
289 "(SELECT COUNT(*) FROM rot_list_slides WHERE list_id=rot_list_data.id) AS nslides ". |
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
290 "FROM rot_list_data ". |
417 | 291 "ORDER BY id DESC"; |
292 | |
293 $str = stGetOptionListStart("ctrlRotationLists", $indent, $outer); | |
453 | 294 $currListID = stGetDisplayVar("rotateList"); |
417 | 295 |
296 if (($res = stExecSQL($sql)) !== false) | |
297 { | |
298 foreach ($res as $item) | |
299 { | |
300 $str .= $indent." ". | |
301 stGetOptionListItem($item["id"], | |
302 ($currListID == $item["id"]), | |
303 $item["name"]." (".$item["nslides"]." slides)"); | |
304 } | |
305 } | |
306 | |
636 | 307 return $str.stGetOptionListEnd($indent, $outer); |
398 | 308 } |
309 | |
310 | |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
311 function stGetInfoDisplaySlides($indent, $outer) |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
312 { |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
313 $str = stGetOptionListStart("ctrlDisplaySlides", $indent, $outer); |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
314 |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
315 $sql = "SELECT * FROM display_slides ORDER BY id DESC"; |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
316 if (($res = stExecSQL($sql)) !== false) |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
317 { |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
318 foreach ($res as $item) |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
319 $str .= $indent." ".stGetOptionListItem($item["id"], FALSE, $item["title"]); |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
320 } |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
321 |
636 | 322 return $str.stGetOptionListEnd($indent, $outer); |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
323 } |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
324 |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
325 |
423 | 326 function stGetInfoRotationListEditFull($indent, $outer, $list_id) |
327 { | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
328 $sql = stPrepareSQL("SELECT * FROM rot_list_data WHERE id=%d", $list_id); |
449 | 329 if (($data = stFetchSQL($sql)) === false) |
330 return ""; | |
331 | |
423 | 332 $str = |
333 ($outer ? $indent."<div class=\"ctrlBox\" id=\"ctrlRotationListEdit\">\n" : ""). | |
334 $indent." <div class=\"ctrlTitle\">Edit rotation list</div>\n". | |
453 | 335 $indent." ".stGetFormTextInput(30, SET_LEN_ROT_LIST_NAME, "", "ctrlEDRotationListName", "", $data["name"])."\n". |
336 $indent." ".stGetFormButtonInput("updname", "", "", "Save", "updateRotationList(".$list_id.")")."\n". | |
450 | 337 "<div>Available slides:</div>\n". |
423 | 338 stGetOptionListStart("ctrlEDDisplaySlides", $indent." ", TRUE); |
339 | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
340 $sql = "SELECT * FROM display_slides"; |
423 | 341 if (($res = stExecSQL($sql)) !== false) |
342 { | |
343 foreach ($res as $item) | |
344 $str .= $indent." ".stGetOptionListItem($item["id"], FALSE, $item["title"]); | |
345 } | |
346 | |
347 $str .= | |
348 stGetOptionListEnd($indent." ", TRUE). | |
450 | 349 "<div>List content:</div>\n". |
423 | 350 stGetInfoRotationListEditData($indent." ", TRUE, $list_id). |
351 $indent." <div class=\"ctrlButtons\">\n". | |
464 | 352 // $indent." ".stGetFormButtonInput("moveslideup", "", "", "Move Up", "moveRotationListSlide(".$list_id.", -1)")."\n". |
353 // $indent." ".stGetFormButtonInput("moveslidedn", "", "", "Move Down", "moveRotationListSlide(".$list_id.", 1)")."\n". | |
453 | 354 $indent." ".stGetFormButtonInput("addslide", "", "", "Add slide", "addRotationListSlide(".$list_id.")")."\n". |
355 $indent." ".stGetFormButtonInput("delslide", "", "", "Remove slide", "removeRotationListSlide(".$list_id.")")."\n". | |
450 | 356 $indent." ".stGetFormButtonInput("closeedit", "", "", "Close", "jsCloseAdminPopup()")."\n". |
423 | 357 $indent." </div>\n". |
358 ($outer ? $indent."</div>\n" : ""); | |
359 | |
360 return $str; | |
361 } | |
362 | |
363 | |
364 function stGetInfoRotationListEditData($indent, $outer, $list_id) | |
365 { | |
366 $sql = stPrepareSQL( | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
367 "SELECT display_slides.*,rot_list_slides.order_num FROM display_slides ". |
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
368 "LEFT JOIN rot_list_slides ON display_slides.id=rot_list_slides.slide_id ". |
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
369 "WHERE rot_list_slides.list_id=%d ". |
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
370 "ORDER BY rot_list_slides.order_num DESC", |
423 | 371 $list_id); |
372 | |
373 $str = stGetOptionListStart("ctrlEDRotationList", $indent, $outer); | |
374 | |
375 if (($res = stExecSQL($sql)) !== false) | |
376 { | |
377 foreach ($res as $item) | |
449 | 378 { |
461 | 379 $str .= $indent." ". |
380 stGetOptionListItem($item["id"]."_".$item["order_num"], FALSE, $item["title"]); | |
449 | 381 } |
423 | 382 } |
383 | |
636 | 384 return $str.stGetOptionListEnd($indent, $outer); |
423 | 385 } |
386 | |
387 | |
455 | 388 function stGetInfoActiveRotationList($indent, $outer) |
389 { | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
390 $sql = stPrepareSQL("SELECT * FROM rot_list_data WHERE id=%d", |
455 | 391 stGetDisplayVar("rotateList")); |
392 | |
393 $str = $indent.($outer ? "<div id=\"ctrlActiveRotationList\">" : ""). | |
394 "<b>Active list:</b> "; | |
395 | |
396 if (($slist = stFetchSQL($sql)) === false) | |
397 $str .= "-"; | |
398 else | |
466 | 399 $str .= chentities(substr($slist["name"], 0, 40)); |
455 | 400 |
401 return $str.($outer ? "</div>\n" : ""); | |
402 } | |
403 | |
404 | |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
405 function stGetInfoDisplaySlideEdit($indent, $outer, $slide_id) |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
406 { |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
407 $prefix = "ctrlDisplaySlide"; |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
408 |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
409 $str = |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
410 ($outer ? "<div class=\"ctrlBox\" id=\"".$prefix."Edit\">\n" : ""). |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
411 $indent." <form method=\"post\" action=\"\" onsubmit=\"return updateDisplaySlide(".$slide_id.")\">\n". |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
412 $indent." <div class=\"ctrlTitle\">Edit display slide</div>\n"; |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
413 |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
414 $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", $slide_id); |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
415 if (($slide = stFetchSQL($sql)) !== false) |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
416 { |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
417 $str .= |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
418 " ".stGetFormTextInput(40, SET_LEN_DISP_SLIDE_TITLE, "", "Title", $prefix, $slide["title"])."<br />\n". |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
419 " ".stGetFormTextArea(5, 40, "", "Text", $prefix, $slide["text"])."<br />\n"; |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
420 } |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
421 |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
422 $str .= |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
423 " <div class=\"ctrlButtons\">\n". |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
424 " ".stGetFormSubmitInput("createslide", "Save slide")."\n". |
442
dfe1e94d6f17
Make close/cancel button bigger.
Matti Hamalainen <ccr@tnsp.org>
parents:
441
diff
changeset
|
425 " ".stGetFormButtonInput("cancelslide", "", "", "Close / Cancel", "jsCloseAdminPopup()")."\n". |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
426 " </div>\n". |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
427 " </form>\n". |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
428 ($outer ? "</div>\n" : ""); |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
429 |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
430 return $str; |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
431 } |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
432 |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
433 |
214 | 434 function stGetSaveButton() |
435 { | |
436 return "<input type=\"submit\" value=\" Save \" />\n"; | |
437 } | |
438 | |
439 | |
374 | 440 function stGetShowModeButton($mode, $name, $cmode) |
441 { | |
396 | 442 return |
443 "<input type=\"radio\" id=\"showMode".$mode. | |
444 "\" name=\"showMode\" value=\"".$mode."\" ". | |
534
067bef3846aa
Use onChange instead of onClick.
Matti Hamalainen <ccr@tnsp.org>
parents:
519
diff
changeset
|
445 "onChange=\"setShowMode(".$mode.")\" ". |
396 | 446 ($cmode == $mode ? "checked=\"checked\" ": "")."/>". |
447 "<label for=\"showMode".$mode."\">".chentities($name)."</label>"; | |
374 | 448 } |
449 | |
450 | |
373 | 451 function stRandomizeCompoShowOrder($compo_id, $patch) |
452 { | |
453 $entries = stExecSQL("SELECT id,show_id FROM entries WHERE compo_id=".$compo_id); | |
371 | 454 if ($entries !== FALSE) |
455 { | |
376
55007fe09371
And some more work on the backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
375
diff
changeset
|
456 $ncount = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo_id." AND show_id<>0"); |
371 | 457 $final = array(); |
373 | 458 |
376
55007fe09371
And some more work on the backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
375
diff
changeset
|
459 if ($patch && $ncount > 0) |
373 | 460 { |
376
55007fe09371
And some more work on the backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
375
diff
changeset
|
461 $index = -1; |
373 | 462 foreach ($entries as $entry) |
463 { | |
464 if ($entry["show_id"] == 0) | |
465 $final[] = $entry["id"]; | |
372 | 466 |
373 | 467 if ($entry["show_id"] > $index) |
468 $index = $entry["show_id"]; | |
469 } | |
376
55007fe09371
And some more work on the backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
375
diff
changeset
|
470 |
373 | 471 $index++; |
472 } | |
473 else | |
474 { | |
475 foreach ($entries as $entry) | |
476 $final[] = $entry["id"]; | |
372 | 477 |
373 | 478 shuffle($final); |
479 $index = 1; | |
480 } | |
481 | |
371 | 482 foreach ($final as $entry) |
483 { | |
484 $sql = stPrepareSQL("UPDATE entries SET show_id=%d WHERE id=%d", $index, $entry); | |
485 if (stExecSQL($sql) === false) | |
486 { | |
487 stError("Error updating entry show positions."); | |
488 break; | |
489 } | |
490 $index++; | |
491 } | |
492 } | |
493 } | |
494 | |
495 | |
214 | 496 // |
0 | 497 // Check if we are allowed to execute |
214 | 498 // |
360
2af8458058ab
Implement CSRF token checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
352
diff
changeset
|
499 if (!stCheckHTTPS() || !stAdmSessionAuth() || !stCSRFCheck()) |
0 | 500 { |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
501 stSetupCacheControl(); |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
502 |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
503 stSessionEnd(SESS_ADMIN); |
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
504 |
613
6fc379f4033d
Session expiration handling made different.
Matti Hamalainen <ccr@tnsp.org>
parents:
609
diff
changeset
|
505 echo |
6fc379f4033d
Session expiration handling made different.
Matti Hamalainen <ccr@tnsp.org>
parents:
609
diff
changeset
|
506 "<h1>Session expired</h1>". |
6fc379f4033d
Session expiration handling made different.
Matti Hamalainen <ccr@tnsp.org>
parents:
609
diff
changeset
|
507 "<div><a href=\"admin.php\">Click here to relogin</a>.</div>\n"; |
6fc379f4033d
Session expiration handling made different.
Matti Hamalainen <ccr@tnsp.org>
parents:
609
diff
changeset
|
508 |
0 | 509 exit; |
510 } | |
511 | |
214 | 512 |
513 // | |
514 // Initialize | |
515 // | |
544 | 516 ob_start(); |
517 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
518 stSetupCacheControl(); |
0 | 519 |
520 if (!stConnectSQLDB()) | |
521 die("Could not connect to SQL database."); | |
522 | |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
523 stReloadSettings(); |
378 | 524 stReloadDisplayVars(); |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
525 |
0 | 526 |
305
b96c41bd9dd6
More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
527 $voteKeyMode = stGetSetting("voteKeyMode"); |
312 | 528 $voteKeyLen = stGetSetting("userKeyLength"); |
208
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
529 $type = stGetRequestItem("type", ""); |
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
530 switch (stGetRequestItem("action", "")) |
0 | 531 { |
370
d65f28bf1080
Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents:
366
diff
changeset
|
532 case "randomize": |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
533 // |
370
d65f28bf1080
Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents:
366
diff
changeset
|
534 // Randomize entries display order |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
535 // |
373 | 536 $patch = intval(stGetRequestItem("patch", 1)); |
371 | 537 if ($type == "all") |
0 | 538 { |
371 | 539 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
|
540 stError("Eh? SQL error occured."); |
d65f28bf1080
Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents:
366
diff
changeset
|
541 else |
d65f28bf1080
Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents:
366
diff
changeset
|
542 foreach ($compos as $compo) |
373 | 543 stRandomizeCompoShowOrder($compo["id"], $patch); |
371 | 544 } |
545 else | |
546 if ($type == "compo") | |
547 { | |
548 if (stChkRequestItem("id", $compo_id, array(CHK_TYPE, VT_INT, "Invalid data."))) | |
373 | 549 stRandomizeCompoShowOrder($compo_id, $patch); |
370
d65f28bf1080
Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents:
366
diff
changeset
|
550 } |
375 | 551 break; |
552 | |
553 case "check": | |
554 // | |
555 // Perform systems check | |
556 // | |
377
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
557 $errors = 0; |
375 | 558 echo |
559 "<h1>Competitions / voting</h1>\n". | |
560 "<ul>\n"; | |
561 | |
562 echo "<li>".(stGetSetting("allowVoting") ? "Voting <b>IS ENABLED</b>." : "Voting is NOT enabled!")."</li>\n"; | |
563 | |
564 if (($compos = stExecSQL("SELECT * FROM compos")) === FALSE) | |
565 stError("Eh? SQL error occured."); | |
370
d65f28bf1080
Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents:
366
diff
changeset
|
566 else |
d65f28bf1080
Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents:
366
diff
changeset
|
567 { |
d65f28bf1080
Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents:
366
diff
changeset
|
568 foreach ($compos as $compo) |
d65f28bf1080
Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents:
366
diff
changeset
|
569 { |
373 | 570 $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
|
571 if ($nentries > 0) |
377
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
572 { |
375 | 573 echo "<li>Compo <b>#".$compo["id"]." - ".$compo["name"]."</b> has NO show order set for some entries.</li>\n"; |
377
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
574 $errors++; |
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
575 } |
370
d65f28bf1080
Add backend code for generating entry show positions.
Matti Hamalainen <ccr@tnsp.org>
parents:
366
diff
changeset
|
576 } |
0 | 577 } |
377
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
578 |
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
579 $nenabled = stFetchSQLColumn("SELECT COUNT(*) FROM compos WHERE visible<>0 AND voting<>0"); |
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
580 if ($nenabled == 0) |
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
581 echo "<li>No competitions that are visible and enabled for voting.</li>\n"; |
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
582 |
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
583 $nenabled = stFetchSQLColumn("SELECT COUNT(*) FROM compos WHERE visible=0 AND voting<>0"); |
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
584 if ($nenabled > 0) |
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
585 echo "<li>".$nenabled." competitions that are NOT visible, but are enabled for voting?</li>\n"; |
381 | 586 |
587 $entries = stFetchSQL("SELECT COUNT(*) AS nentries, COUNT(DISTINCT compo_id) AS ncompos FROM entries"); | |
588 if ($entries !== FALSE) | |
589 echo "<li><b>".$entries["nentries"]."</b> compo entries in system in <b>".$entries["ncompos"]."</b> compos.</li>\n"; | |
377
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
590 |
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
591 if ($errors == 0) |
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
592 echo "<li>No errors/warnings detected.</li>\n"; |
f7b53225d315
Add some more sanity checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
376
diff
changeset
|
593 |
375 | 594 echo "</ul>\n"; |
595 | |
0 | 596 break; |
597 | |
390
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
598 case "ctrl": |
392 | 599 // |
600 // Party information system control | |
601 // | |
390
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
602 switch ($type) |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
603 { |
450 | 604 case "setRotateDuration": |
605 if (stChkRequestItem("duration", $duration, | |
606 array(CHK_TYPE, VT_INT, "Invalid data."), | |
607 array(CHK_RANGE, VT_INT, array(5, 60), "Invalid slide time value, must be 5 - 60 seconds."))) | |
608 { | |
454 | 609 stSetDisplayVarUpd("rotateDuration", $duration); |
610 } | |
611 break; | |
612 | |
455 | 613 case "setActiveRotationList": |
454 | 614 if (stChkRequestItem("id", $list_id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
615 { | |
616 stSetDisplayVarUpd("rotateList", $list_id); | |
450 | 617 } |
618 break; | |
619 | |
390
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
620 case "setShowMode": |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
621 if (stChkRequestItem("mode", $mode, |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
622 array(CHK_TYPE, VT_INT, "Invalid data."), |
391 | 623 array(CHK_RANGE, VT_INT, array(SMODE_DISABLED, SMODE_COMPO), "Invalid mode value."))) |
390
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
624 { |
454 | 625 stSetDisplayVarUpd("showMode", $mode); |
390
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
626 } |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
627 break; |
450 | 628 |
390
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
629 case "setCompoID": |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
630 if (stChkRequestItem("id", $compo_id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
631 { |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
632 if (stFetchSQL("SELECT id FROM compos WHERE id=".$compo_id) === false) |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
633 stError("Invalid compo ID ".$compo_id); |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
634 else |
395 | 635 { |
546
f1f55db4228f
Always update current info display compo id if requested.
Matti Hamalainen <ccr@tnsp.org>
parents:
545
diff
changeset
|
636 stSetDisplayVarUpd("compoID", $compo_id); |
454 | 637 stSetDisplayVar("compoCurrEntry", 0); |
638 stSetDisplayVar("compoPrevEntry", 0); | |
395 | 639 } |
390
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
640 } |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
641 break; |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
642 |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
643 case "setEntry": |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
644 case "nextEntry": |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
645 case "prevEntry": |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
646 if (($compo_id = stGetDisplayVar("compoID")) > 0) |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
647 { |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
648 $prev = $curr = stGetDisplayVar("compoCurrEntry"); |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
649 $nentries = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo_id); |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
650 switch ($type) |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
651 { |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
652 case "setEntry": |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
653 if (stChkRequestItem("index", $tmp, array(CHK_TYPE, VT_INT, "Invalid index."))) |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
654 $curr = $tmp; |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
655 break; |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
656 |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
657 case "nextEntry": |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
658 if ($curr < $nentries) |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
659 $curr++; |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
660 break; |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
661 |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
662 case "prevEntry": |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
663 if ($curr > 1) |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
664 $curr--; |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
665 break; |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
666 } |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
667 |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
668 if (!$errorSet) |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
669 { |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
670 stSetDisplayVar("compoCurrEntry", $curr); |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
671 stSetDisplayVar("compoPrevEntry", $prev); |
407 | 672 stDisplayUpdated(); |
390
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
673 } |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
674 } |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
675 else |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
676 stError("No valid competition set."); |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
677 break; |
421 | 678 |
679 case "setTempSlide": | |
429 | 680 if (stChkRequestItem("id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && |
681 stChkRequestItem("duration", $slide_dur, array(CHK_RANGE, VT_INT, array(1, 60), "Invalid duration range, should be 1-60 min."))) | |
682 { | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
683 $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", $slide_id); |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
684 if (($slide = stFetchSQL($sql)) !== false) |
429 | 685 { |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
686 stSetDisplayVar("tempDuration", $slide_dur); |
429 | 687 stSetDisplayVar("tempSlide", $slide["id"]); |
688 stSetDisplayVar("tempSlideSet", TRUE); | |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
689 echo "Temporary slide '".chentities($slide["title"])."' set for <b>".$slide_dur."</b> minutes."; |
441 | 690 stDisplayUpdated(); |
429 | 691 } |
692 else | |
693 stError("No such slide ID #".$slide_id); | |
694 } | |
421 | 695 break; |
696 | |
472 | 697 case "skipToNextSlide": |
698 if (stGetDisplayVar("activeSlideMode") == SMODE_ROTATE) | |
699 { | |
700 stSetDisplayVar("activeSlideExpire", 0); | |
701 stDisplayUpdated(); | |
702 } | |
703 break; | |
704 | |
457
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
705 case "copyDisplaySlide": |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
706 if (stChkRequestItem("id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
707 { |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
708 $sql = stPrepareSQL("SELECT * FROM display_slides WHERE id=%d", $slide_id); |
457
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
709 if (($slide = stFetchSQL($sql)) !== false) |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
710 { |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
711 $sql = stPrepareSQL("INSERT INTO display_slides (title,text) VALUES (%s,%s)", |
457
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
712 $slide["title"]." (copy)", $slide["text"]); |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
713 |
548
b3e9c3eedc23
Use the helper functions for insertion.
Matti Hamalainen <ccr@tnsp.org>
parents:
546
diff
changeset
|
714 if (($new_id = stExecSQLInsert($sql)) !== false) |
457
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
715 echo stGetInfoDisplaySlideEdit("", TRUE, $new_id); |
548
b3e9c3eedc23
Use the helper functions for insertion.
Matti Hamalainen <ccr@tnsp.org>
parents:
546
diff
changeset
|
716 else |
b3e9c3eedc23
Use the helper functions for insertion.
Matti Hamalainen <ccr@tnsp.org>
parents:
546
diff
changeset
|
717 stError("Could not insert slide."); |
457
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
718 } |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
719 else |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
720 stError("No such slide ID #".$slide_id); |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
721 } |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
722 break; |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
723 |
433 | 724 case "newDisplaySlide": |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
725 $sql = stPrepareSQL("INSERT INTO display_slides (title) VALUES (%s)", "New slide"); |
548
b3e9c3eedc23
Use the helper functions for insertion.
Matti Hamalainen <ccr@tnsp.org>
parents:
546
diff
changeset
|
726 if (($slide_id = stExecSQLInsert($sql)) !== false) |
434 | 727 echo stGetInfoDisplaySlideEdit("", TRUE, $slide_id); |
421 | 728 break; |
729 | |
433 | 730 case "updateDisplaySlide": |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
731 if (stChkRequestItem("id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && |
451 | 732 stChkRequestItem("title", $fake, |
733 array(CHK_GTEQ, VT_STR, 1, "Slide title too short."), | |
734 array(CHK_LTEQ, VT_STR, SET_LEN_DISP_SLIDE_TITLE, "Slide title too long.") | |
735 ) && | |
736 stChkRequestItem("text", $fake, | |
737 array(CHK_LTEQ, VT_STR, SET_LEN_DISP_SLIDE_TEXT, "Slide content too long.") | |
738 )) | |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
739 { |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
740 $sql = stPrepareSQLUpdate("display_slides", |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
741 "WHERE id=".$slide_id, |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
742 array( |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
743 "title" => "S", |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
744 "text" => "S", |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
745 )); |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
746 |
548
b3e9c3eedc23
Use the helper functions for insertion.
Matti Hamalainen <ccr@tnsp.org>
parents:
546
diff
changeset
|
747 if (stExecSQL($sql) !== false) |
b3e9c3eedc23
Use the helper functions for insertion.
Matti Hamalainen <ccr@tnsp.org>
parents:
546
diff
changeset
|
748 { |
b3e9c3eedc23
Use the helper functions for insertion.
Matti Hamalainen <ccr@tnsp.org>
parents:
546
diff
changeset
|
749 stSetStatus(200, "Slide updated."); |
b3e9c3eedc23
Use the helper functions for insertion.
Matti Hamalainen <ccr@tnsp.org>
parents:
546
diff
changeset
|
750 stDisplayUpdated(); |
b3e9c3eedc23
Use the helper functions for insertion.
Matti Hamalainen <ccr@tnsp.org>
parents:
546
diff
changeset
|
751 } |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
752 } |
421 | 753 break; |
754 | |
433 | 755 case "deleteDisplaySlide": |
421 | 756 if (stChkRequestItem("id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
757 { | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
758 $sql = stPrepareSQL("DELETE FROM display_slides WHERE id=%d", $slide_id); |
421 | 759 stExecSQLCond($sql, "Slide deleted."); |
760 | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
761 $sql = stPrepareSQL("DELETE FROM rot_list_slides WHERE slide_id=%d", $slide_id); |
421 | 762 stExecSQLCond($sql, "Slide list refs deleted."); |
441 | 763 stDisplayUpdated(); |
421 | 764 } |
765 break; | |
766 | |
422 | 767 case "newRotationList": |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
768 $sql = stPrepareSQL("INSERT INTO rot_list_data (name) VALUES (%s)", "New list #"); |
548
b3e9c3eedc23
Use the helper functions for insertion.
Matti Hamalainen <ccr@tnsp.org>
parents:
546
diff
changeset
|
769 if (($list_id = stExecSQLInsert($sql)) !== false) |
427 | 770 { |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
771 $sql = stPrepareSQL("UPDATE rot_list_data SET name=%s WHERE id=%d", |
431 | 772 "New list #".$list_id, $list_id); |
427 | 773 |
774 if (stExecSQLCond($sql, "OK!") !== false) | |
775 echo stGetInfoRotationListEditFull("", TRUE, $list_id); | |
776 } | |
422 | 777 break; |
778 | |
779 case "updateRotationList": | |
453 | 780 if (stChkRequestItem("id", $list_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && |
781 stChkRequestItem("name", $fake, | |
782 array(CHK_GTEQ, VT_STR, 3, "Rotation list name too short."), | |
783 array(CHK_LTEQ, VT_STR, SET_LEN_ROT_LIST_NAME, "Rotation list name too long."))) | |
784 { | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
785 $sql = stPrepareSQLUpdate("rot_list_data", |
453 | 786 "WHERE id=".$list_id, |
787 array( | |
788 "name" => "S", | |
789 )); | |
790 | |
791 stExecSQLCond($sql, "OK, list updated."); | |
792 stDisplayUpdated(); | |
793 } | |
441 | 794 stDisplayUpdated(); |
421 | 795 break; |
796 | |
422 | 797 case "deleteRotationList": |
798 if (stChkRequestItem("id", $list_id, array(CHK_TYPE, VT_INT, "Invalid data."))) | |
799 { | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
800 $sql = stPrepareSQL("DELETE FROM rot_list_data WHERE id=%d", $list_id); |
422 | 801 stExecSQLCond($sql, "List data deleted."); |
802 | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
803 $sql = stPrepareSQL("DELETE FROM rot_list_slides WHERE list_id=%d", $list_id); |
422 | 804 stExecSQLCond($sql, "List slide refs deleted."); |
441 | 805 stDisplayUpdated(); |
422 | 806 } |
421 | 807 break; |
808 | |
422 | 809 case "moveRotationListSlide": |
421 | 810 if (stChkRequestItem("list_id", $list_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && |
811 stChkRequestItem("slide_id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && | |
461 | 812 stChkRequestItem("order_num", $order_num, array(CHK_TYPE, VT_INT, "Invalid data.")) && |
421 | 813 stChkRequestItem("dir", $dir, array(CHK_TYPE, VT_INT, "Invalid data."))) |
814 { | |
815 } | |
816 break; | |
817 | |
422 | 818 case "addRotationListSlide": |
421 | 819 if (stChkRequestItem("list_id", $list_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && |
820 stChkRequestItem("slide_id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data."))) | |
821 { | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
822 $nslides = stFetchSQLColumn(stPrepareSQL("SELECT COUNT(*) FROM rot_list_slides WHERE list_id=%d", $list_id)); |
459 | 823 $sql = stPrepareSQL( |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
824 "INSERT INTO rot_list_slides (list_id,slide_id,order_num) VALUES (%d,%d,%d)", |
421 | 825 $list_id, $slide_id, $nslides+1); |
826 | |
459 | 827 if (stExecSQLCond($sql, "Slide added to list.")) |
828 { | |
829 stNormalizeListSlideOrder($list_id); | |
830 stDisplayUpdated(); | |
831 } | |
421 | 832 } |
833 break; | |
834 | |
450 | 835 case "removeRotationListSlide": |
421 | 836 if (stChkRequestItem("list_id", $list_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && |
461 | 837 stChkRequestItem("slide_id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data.")) && |
838 stChkRequestItem("order_num", $order_num, array(CHK_TYPE, VT_INT, "Invalid data."))) | |
421 | 839 { |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
840 $sql = stPrepareSQL("DELETE FROM rot_list_slides WHERE list_id=%d AND slide_id=%d AND order_num=%d", |
461 | 841 $list_id, $slide_id, $order_num); |
459 | 842 |
843 if (stExecSQLCond($sql, "List slide refs deleted.")) | |
844 { | |
845 stNormalizeListSlideOrder($list_id); | |
846 stDisplayUpdated(); | |
847 } | |
421 | 848 } |
849 break; | |
390
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
850 } |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
851 break; |
3257ae94ba1c
Work on show display backend logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
385
diff
changeset
|
852 |
0 | 853 case "get": |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
854 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
855 // Get specific data |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
856 // |
0 | 857 switch ($type) |
858 { | |
398 | 859 case "infoCurrEntryData": |
417 | 860 echo stGetInfoCurrEntryData("", FALSE); |
398 | 861 break; |
404 | 862 |
863 case "infoCurrEntryList": | |
417 | 864 echo stGetInfoCurrEntryList("", FALSE); |
865 break; | |
866 | |
867 case "infoRotationLists": | |
868 echo stGetInfoRotationLists("", FALSE); | |
404 | 869 break; |
398 | 870 |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
871 case "infoDisplaySlides": |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
872 echo stGetInfoDisplaySlides("", FALSE); |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
873 break; |
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
874 |
422 | 875 case "infoRotationListEdit": |
427 | 876 if (stChkRequestItem("id", $list_id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
459 | 877 echo stGetInfoRotationListEditFull("", stGetRequestItem("full", TRUE), $list_id); |
423 | 878 break; |
398 | 879 |
423 | 880 case "infoRotationListEditData": |
427 | 881 if (stChkRequestItem("id", $list_id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
882 echo stGetInfoRotationListEditData("", FALSE, $list_id); | |
393 | 883 break; |
884 | |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
885 case "infoDisplaySlideEdit": |
421 | 886 if (stChkRequestItem("id", $slide_id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
467
9e987c975dca
Default to full html of the slide edit.
Matti Hamalainen <ccr@tnsp.org>
parents:
466
diff
changeset
|
887 echo stGetInfoDisplaySlideEdit("", TRUE, $slide_id); |
393 | 888 break; |
889 | |
455 | 890 case "infoActiveRotationList": |
891 echo stGetInfoActiveRotationList("", FALSE); | |
892 break; | |
893 | |
419 | 894 case "infoMain": |
449 | 895 // |
896 // Main information control screen | |
897 // | |
378 | 898 $showMode = stGetDisplayVar("showMode"); |
899 echo | |
396 | 900 "<div id=\"ctrlModeControls\">\n". |
378 | 901 "Active mode:\n". |
391 | 902 stGetShowModeButton(SMODE_DISABLED, "Off/disabled", $showMode)."\n". |
378 | 903 stGetShowModeButton(SMODE_ROTATE, "Slide rotation", $showMode)."\n". |
904 stGetShowModeButton(SMODE_COMPO, "Compo mode", $showMode)."\n". | |
418
0688a1d2122e
Add link for opening the info view window.
Matti Hamalainen <ccr@tnsp.org>
parents:
417
diff
changeset
|
905 "<a href=\"show.php\" target=\"_blank\">Open info window</a>\n". |
512
998a09b332f1
Add plain text printable results visible for admins.
Matti Hamalainen <ccr@tnsp.org>
parents:
480
diff
changeset
|
906 "<a href=\"print.php?type=results\" target=\"_blank\">Printable results list</a>\n". |
392 | 907 "</div>\n". |
396 | 908 "<div id=\"ctrlSystemControls\">\n". |
909 stGetFormButtonInput("syscheck", "", "", "Perform system check", "performSystemCheck()")."\n". | |
476 | 910 stGetFormButtonInput("generate", "", "", "Add missing show positions", "generateEntryPositions(0, 1)")."\n". |
396 | 911 stGetFormButtonInput("regenerate", "", "", "ReGenerate ALL show positions", "generateEntryPositions(0, 0)")."\n". |
378 | 912 "</div>\n"; |
393 | 913 |
914 echo | |
915 "<div class=\"ctrlBox\" id=\"ctrlListRotationLists\">\n". | |
916 " <div class=\"ctrlTitle\">Rotation lists:</div>\n". | |
450 | 917 " <div class=\"ctrlInfo\">Lists of slides, that are shown for X seconds and 'rotated' to next one.</div>\n". |
417 | 918 stGetInfoRotationLists(" ", TRUE). |
393 | 919 " <div class=\"ctrlButtons\">\n". |
450 | 920 " ".stGetFormButtonInput("setdur", "", "", "Set", "setRotateDuration()")."\n". |
921 " ".stGetFormTextInput(3, 5, "", "ctrlRotSlideDuration", "", stGetDisplayVar("rotateDuration"))." sec\n". | |
922 " - ". | |
454 | 923 " ".stGetFormButtonInput("actlist", "", "", "Set Active", "setActiveRotationList()")."\n". |
416
876846d8ed5b
Rename some database things.
Matti Hamalainen <ccr@tnsp.org>
parents:
415
diff
changeset
|
924 " ".stGetFormButtonInput("editlist", "", "", "Edit", "editRotationList()")."\n". |
393 | 925 " ".stGetFormButtonInput("newlist", "", "", "New", "newRotationList()")."\n". |
926 " ".stGetFormButtonInput("dellist", "", "", "Delete", "deleteRotationList()")."\n". | |
927 " </div>\n". | |
455 | 928 stGetInfoActiveRotationList(" ", TRUE). |
393 | 929 "</div>\n"; |
930 | |
931 echo | |
932 "<div class=\"ctrlBox\" id=\"ctrlListDisplaySlides\">\n". | |
933 "<div class=\"ctrlTitle\">Display slides:</div>\n". | |
443
2a4d5ded6c79
Add helpful information popups.
Matti Hamalainen <ccr@tnsp.org>
parents:
442
diff
changeset
|
934 " <div class=\"ctrlInfo\">Editable slides (think 'powerpoint') for information/announcements. ". |
2a4d5ded6c79
Add helpful information popups.
Matti Hamalainen <ccr@tnsp.org>
parents:
442
diff
changeset
|
935 "Can be collected into slide rotations or set to display as 'temp slide' at any given time.</div>\n". |
438
48903fd966cd
Things are starting to work.
Matti Hamalainen <ccr@tnsp.org>
parents:
437
diff
changeset
|
936 stGetInfoDisplaySlides(" ", TRUE). |
393 | 937 " <div class=\"ctrlButtons\">\n". |
457
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
938 " ".stGetFormButtonInput("editslide", "", "", "Edit", "editDisplaySlide()")."\n". |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
939 " ".stGetFormButtonInput("copyslide", "", "", "Copy", "copyDisplaySlide()")."\n". |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
940 " ".stGetFormButtonInput("newslide", "", "", "New", "newDisplaySlide()")."\n". |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
941 " ".stGetFormButtonInput("delslide", "", "", "Delete", "deleteDisplaySlide()")."\n". |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
942 " </div>\n". |
3b5184c6b36f
Add slide copying function.
Matti Hamalainen <ccr@tnsp.org>
parents:
455
diff
changeset
|
943 " <div class=\"ctrlButtons\">\n". |
429 | 944 " ".stGetFormTextInput(3, 5, "", "ctrlTempSlideDuration", "", stGetDisplayVar("tempDuration"))." min\n". |
393 | 945 " ".stGetFormButtonInput("setslide", "", "", "Set Temp", "activateTempSlide()")."\n". |
472 | 946 " ".stGetFormButtonInput("nextslide", "", "", "Skip to next", "skipToNextSlide()")."\n". |
393 | 947 " </div>\n". |
427 | 948 "</div>\n". |
393 | 949 "<div class=\"ctrlBox\" id=\"ctrlCompoControl\">\n". |
398 | 950 " <div class=\"ctrlTitle\">Competition control:</div>\n". |
443
2a4d5ded6c79
Add helpful information popups.
Matti Hamalainen <ccr@tnsp.org>
parents:
442
diff
changeset
|
951 " <div class=\"ctrlInfo\">Controls for competition showing mode. Select and activate desired compo, then ". |
2a4d5ded6c79
Add helpful information popups.
Matti Hamalainen <ccr@tnsp.org>
parents:
442
diff
changeset
|
952 "hit 'Next entry' to activate the first entry to show. <b>Notice! You need to have generated 'show positions' ". |
2a4d5ded6c79
Add helpful information popups.
Matti Hamalainen <ccr@tnsp.org>
parents:
442
diff
changeset
|
953 "before starting compos!</b></div>\n". |
398 | 954 " <div class=\"ctrlDBox1\">\n". |
417 | 955 stGetOptionListStart("ctrlCompoList", " ", TRUE); |
398 | 956 |
957 $sql = | |
958 "SELECT compos.*, ". | |
545
d5ac0521ca16
Possibly fix a query to work with Postgresql.
Matti Hamalainen <ccr@tnsp.org>
parents:
544
diff
changeset
|
959 "COUNT(DISTINCT entries.id) AS nentries ". |
d5ac0521ca16
Possibly fix a query to work with Postgresql.
Matti Hamalainen <ccr@tnsp.org>
parents:
544
diff
changeset
|
960 "FROM compos LEFT JOIN entries ON compos.id=entries.compo_id ". |
d5ac0521ca16
Possibly fix a query to work with Postgresql.
Matti Hamalainen <ccr@tnsp.org>
parents:
544
diff
changeset
|
961 "GROUP BY compos.id HAVING COUNT(DISTINCT entries.id) > 0 ORDER BY compos.id DESC"; |
398 | 962 |
963 $currCompoID = stGetDisplayVar("compoID"); | |
964 if (($res = stExecSQL($sql)) !== false) | |
965 { | |
966 foreach ($res as $item) | |
967 { | |
407 | 968 echo " ".stGetOptionListItem($item["id"], |
398 | 969 ($item["id"] == $currCompoID), |
469 | 970 sprintf("%-20s (%d entries)", substr($item["name"], 0, 20), $item["nentries"])); |
398 | 971 } |
972 } | |
973 | |
974 echo | |
417 | 975 stGetOptionListEnd(" ", TRUE). |
407 | 976 " <div class=\"ctrlButtons\">\n". |
977 " ".stGetFormButtonInput("setcompo", "", "", "Change compo", "activateCompo()")."\n". | |
978 " </div>\n". | |
427 | 979 " </div>\n". |
407 | 980 " <div class=\"ctrlDBox1\">\n". |
417 | 981 stGetInfoCurrEntryList(" ", TRUE). |
407 | 982 " <div class=\"ctrlButtons\">\n". |
983 " ".stGetFormButtonInput("setentry", "", "", "Set selected entry", "setSelectedEntry()")."\n". | |
984 " ".stGetFormButtonInput("preventry", "", "", "Prev entry", "switchEntry(-1)")."\n". | |
985 " ".stGetFormButtonInput("nextentry", "", "", "Next entry", "switchEntry(1)")."\n". | |
986 " </div>\n". | |
393 | 987 " </div>\n". |
407 | 988 " <div class=\"ctrlDBox2\" id=\"ctrlCurrEntryData\">\n". |
417 | 989 stGetInfoCurrEntryData(" "). |
407 | 990 " </div>\n". |
424
8258b5ddcd7f
Temporarily comment out stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
423
diff
changeset
|
991 "</div>\n"; |
427 | 992 stGetInfoRotationListEditFull("", TRUE, 0); |
378 | 993 break; |
994 | |
0 | 995 case "news": |
265 | 996 echo |
997 "<form method=\"post\" action=\"\" onsubmit=\"return addNews()\">\n". | |
998 " ".stGetFormTextInput(40, SET_LEN_NEWS_TITLE, "", "nntitle", "", "")."<br />\n". | |
999 " ".stGetFormTextArea(5, 60, "", "nntext", "", "")."<br />\n". | |
1000 " ".stGetFormTextInput(20, SET_LEN_NEWS_AUTHOR, "", "nnauthor", "", "orgaz")."\n". | |
1001 " ".stGetFormSubmitInput("nnadd", "Add post")."\n". | |
1002 " ".stGetFormButtonInput("", "", "", "Clear", "this.form.reset()")."\n". | |
1003 "</form>\n". | |
1004 "<hr />\n"; | |
1005 | |
0 | 1006 $sql = "SELECT * FROM news ORDER BY utime DESC"; |
265 | 1007 foreach (stExecSQL($sql) as $item) |
1008 { | |
1009 echo | |
1010 "<div id=\"news".$item["id"]."\">\n". | |
1011 stGetNewsItemData($item["id"], $item, "ne"). | |
634 | 1012 "</div>\n"; |
265 | 1013 } |
0 | 1014 break; |
1015 | |
223
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1016 case "newsitem": |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1017 $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
|
1018 if ($res !== FALSE) |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1019 echo stGetNewsItemData($res["id"], $res, "ne"); |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1020 break; |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1021 |
0 | 1022 case "attendees": |
272
cd3283333ec1
Add link for printing out email addresses of participants.
Matti Hamalainen <ccr@tnsp.org>
parents:
270
diff
changeset
|
1023 echo |
273
39c247babc0c
Make the print links look a bit nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
272
diff
changeset
|
1024 "<div class=\"tabHeadersSub\">\n". |
275 | 1025 "<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
|
1026 "</div>\n"; |
cd3283333ec1
Add link for printing out email addresses of participants.
Matti Hamalainen <ccr@tnsp.org>
parents:
270
diff
changeset
|
1027 |
265 | 1028 // For adding a new one |
1029 $prefix = "ne"; | |
1030 echo | |
1031 "<table>\n". | |
1032 " <tr>\n". | |
1033 " <th>Name</th>\n". | |
1034 " <th>Groups</th>\n". | |
1035 " <th>Oneliner</th>\n". | |
1036 " <th>E-mail</th>\n". | |
1037 " <th>Actions</th>\n". | |
1038 " </tr>\n". | |
1039 " <tr>\n". | |
1040 " <td>".stGetFormTextInput(20, SET_LEN_USERNAME, "name", "x", $prefix, "")."</td>\n". | |
1041 " <td>".stGetFormTextInput(20, SET_LEN_GROUPS, "groups", "x", $prefix, "")."</td>\n". | |
1042 " <td>".stGetFormTextInput(30, SET_LEN_ONELINER, "oneliner", "x", $prefix, "")."</td>\n". | |
1043 " <td>".stGetFormTextInput(20, SET_LEN_EMAIL, "email", "x", $prefix, "")."</td>\n". | |
1044 " <td>".stGetFormButtonInput("add", "", $prefix, " Add new ", "addAttendee()")."</td>\n". | |
1045 " </tr>\n". | |
1046 "</table>\n". | |
1047 "<hr />\n"; | |
1048 | |
1049 // List of attendees | |
1050 echo | |
1051 "<table class=\"attendees\">\n". | |
1052 " <tr>\n". | |
1053 " <th class=\"name\">Name</th>\n". | |
1054 " <th class=\"groups\">Groups</th>\n". | |
1055 " <th class=\"regtime\">Registered</th>\n". | |
1056 " <th class=\"oneliner\">Oneliner</th>\n". | |
1057 " <th class=\"email\">E-mail</th>\n". | |
1058 " <th>Actions</th>\n". | |
1059 " </tr>\n"; | |
1060 | |
0 | 1061 $sql = "SELECT * FROM attendees ORDER BY regtime DESC"; |
265 | 1062 $row = 0; |
1063 foreach (stExecSQL($sql) as $item) | |
1064 stPrintAttendee($item, $row++, TRUE, TRUE, FALSE); | |
1065 | |
1066 echo | |
1067 "</table>\n"; | |
0 | 1068 break; |
1069 | |
205
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
1070 case "attendee": |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
1071 $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
|
1072 if ($res !== FALSE) |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
1073 stPrintAttendee($res, -1, FALSE, TRUE, stGetRequestItem("edit", FALSE)); |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
1074 break; |
77d33161f8be
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
204
diff
changeset
|
1075 |
312 | 1076 case "votekey": |
321
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
1077 case "votekeyclass": |
312 | 1078 switch ($voteKeyMode) |
1079 { | |
1080 case VOTE_FREELY: | |
1081 case VOTE_ACTIVATE: | |
1082 $sql = stPrepareSQL("SELECT * FROM votekeys WHERE id=%D", "id"); | |
1083 break; | |
1084 | |
1085 case VOTE_ASSIGN: | |
1086 $sql = stPrepareSQL("SELECT votekeys.key,attendees.* FROM attendees ". | |
1087 "LEFT JOIN votekeys ON votekeys.id=attendees.key_id ". | |
1088 "WHERE attendees.id=%D", "id"); | |
1089 break; | |
1090 } | |
1091 if (($res = stFetchSQL($sql)) !== FALSE) | |
321
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
1092 { |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
1093 if ($type == "votekeyclass") |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
1094 echo stGetVoteKeyClass($res); |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
1095 else |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
1096 echo stGetVoteKeyItemData($res["id"], $res, "vk"); |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
1097 } |
312 | 1098 break; |
1099 | |
105
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
1100 case "voters": |
270
589b44acb74a
More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
1101 // Generate vote keys, if needed |
589b44acb74a
More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
1102 $numVKeys = stFetchSQLColumn("SELECT COUNT(*) FROM votekeys"); |
478
8dde27202989
And fix the previous commit ..
Matti Hamalainen <ccr@tnsp.org>
parents:
477
diff
changeset
|
1103 $numUsers = stFetchSQLColumn("SELECT COUNT(*) FROM attendees"); |
8dde27202989
And fix the previous commit ..
Matti Hamalainen <ccr@tnsp.org>
parents:
477
diff
changeset
|
1104 if (($tmp = stGetSetting("maxAttendeesHard")) > $numUsers) |
8dde27202989
And fix the previous commit ..
Matti Hamalainen <ccr@tnsp.org>
parents:
477
diff
changeset
|
1105 $numUsers = $tmp; |
8dde27202989
And fix the previous commit ..
Matti Hamalainen <ccr@tnsp.org>
parents:
477
diff
changeset
|
1106 else |
8dde27202989
And fix the previous commit ..
Matti Hamalainen <ccr@tnsp.org>
parents:
477
diff
changeset
|
1107 if (($tmp = stGetSetting("maxAttendeesSoft")) > $numUsers) |
8dde27202989
And fix the previous commit ..
Matti Hamalainen <ccr@tnsp.org>
parents:
477
diff
changeset
|
1108 $numUsers = $tmp; |
8dde27202989
And fix the previous commit ..
Matti Hamalainen <ccr@tnsp.org>
parents:
477
diff
changeset
|
1109 |
480
26033a4b754a
Oops, fix a silly off-by-one in votekey generation (1 less than wanted keys
Matti Hamalainen <ccr@tnsp.org>
parents:
478
diff
changeset
|
1110 while ($numVKeys <= $numUsers) |
270
589b44acb74a
More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
1111 { |
589b44acb74a
More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
1112 if (($key = stGenerateUserKey()) !== false) |
589b44acb74a
More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
1113 { |
589b44acb74a
More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
1114 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
|
1115 $numVKeys++; |
589b44acb74a
More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
1116 } |
589b44acb74a
More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
1117 } |
589b44acb74a
More work on votekey admin.
Matti Hamalainen <ccr@tnsp.org>
parents:
269
diff
changeset
|
1118 |
269
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1119 // List of votekeys |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1120 echo |
597
6de22c51c49b
Add warning about unconfigured voting mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
1121 "<div class=\"info\"><b>Voting mode: "; |
6de22c51c49b
Add warning about unconfigured voting mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
1122 |
6de22c51c49b
Add warning about unconfigured voting mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
1123 if (isset($voteModeData[$voteKeyMode])) |
6de22c51c49b
Add warning about unconfigured voting mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
1124 echo $voteModeData[$voteKeyMode][0]."</b>. ".$voteModeData[$voteKeyMode][1]; |
6de22c51c49b
Add warning about unconfigured voting mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
1125 else |
6de22c51c49b
Add warning about unconfigured voting mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
1126 echo "VOTE MODE NOT SET! CHECK CONFIGURATION!</b>"; |
6de22c51c49b
Add warning about unconfigured voting mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
1127 |
6de22c51c49b
Add warning about unconfigured voting mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
1128 echo |
6de22c51c49b
Add warning about unconfigured voting mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
571
diff
changeset
|
1129 "</div>\n". |
273
39c247babc0c
Make the print links look a bit nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
272
diff
changeset
|
1130 "<div class=\"tabHeadersSub\">\n". |
275 | 1131 "<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
|
1132 "</div>\n"; |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1133 |
305
b96c41bd9dd6
More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
1134 switch ($voteKeyMode) |
116
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
1135 { |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
1136 case VOTE_FREELY: |
269
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1137 case VOTE_ACTIVATE: |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1138 $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
|
1139 |
269
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1140 foreach (stExecSQL($sql) as $item) |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1141 { |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1142 // This funny code is to ensure that the cells are of uniform width |
312 | 1143 echo |
321
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
1144 "<div class=\"".stGetVoteKeyClass($item). |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
1145 "\" id=\"vkey".$item["id"]."\">". |
312 | 1146 stGetVoteKeyItemData($item["id"], $item, "vk"). |
320 | 1147 "</div>\n"; |
269
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1148 } |
116
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
1149 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
1150 |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
1151 case VOTE_ASSIGN: |
308
3cfd95758377
A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
305
diff
changeset
|
1152 $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
|
1153 "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
|
1154 "ORDER BY attendees.regtime DESC"; |
269
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1155 |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1156 echo |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1157 "<table class=\"attendees\">\n". |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1158 " <tr>\n". |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1159 " <th class=\"name\">Name</th>\n". |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1160 " <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
|
1161 " <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
|
1162 " <th class=\"vkey\">Votekey</th>\n". |
269
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1163 " </tr>\n"; |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1164 |
312 | 1165 $index = 0; |
269
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1166 foreach (stExecSQL($sql) as $item) |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1167 { |
308
3cfd95758377
A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
305
diff
changeset
|
1168 echo |
321
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
1169 " <tr class=\"".stGetVoteKeyClass($item). |
9462a59d3ab3
Votekey activation usability improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
320
diff
changeset
|
1170 "\" id=\"vkey".$item["id"]."\">\n". |
312 | 1171 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
|
1172 " </tr>\n"; |
269
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1173 } |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1174 |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1175 echo |
46138f8478e5
Work on votekey management.
Matti Hamalainen <ccr@tnsp.org>
parents:
266
diff
changeset
|
1176 "</table>\n"; |
116
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
1177 break; |
a95facb41c86
Some preliminary work on the votekey administration backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
1178 } |
105
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
1179 break; |
a85f258f6beb
Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
1180 |
0 | 1181 case "compos": |
265 | 1182 echo |
1183 "<form method=\"post\" action=\"\" onsubmit=\"return addCompo()\">\n". | |
1184 " ".stGetFormTextInput(64, SET_LEN_COMPO_NAME, "", "ncname", "", "")."<br />\n". | |
1185 " ".stGetFormTextArea(5, 60, "", "ncdescription", "", "")."<br />\n". | |
1186 " ".stGetFormSubmitInput("nccompo", "Add compo")."\n". | |
1187 " ".stGetFormButtonInput("", "", "", "Clear", "this.form.reset()")."\n". | |
1188 "</form>\n". | |
1189 "<hr />\n"; | |
1190 | |
0 | 1191 $sql = "SELECT * FROM compos ORDER BY id DESC"; |
265 | 1192 foreach (stExecSQL($sql) as $item) |
1193 { | |
1194 echo | |
1195 "<div id=\"compo".$item["id"]."\">\n". | |
1196 stGetCompoData($item["id"], $item, "co"). | |
634 | 1197 "</div>\n"; |
265 | 1198 } |
0 | 1199 break; |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
1200 |
223
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1201 case "compo": |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1202 $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
|
1203 if ($res !== FALSE) |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1204 echo stGetCompoData($res["id"], $res, "co"); |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1205 break; |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1206 |
624
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1207 case "settingslist": |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1208 $index = 0; |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1209 foreach (stExecSQL("SELECT * FROM settings_groups") as $group) |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1210 { |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1211 if ($index++ > 0) echo ","; |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1212 echo "\"".$group["id"]."\":\"".chentities($group["name"])."\""; |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1213 } |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1214 break; |
352 | 1215 |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
1216 case "settings": |
543 | 1217 |
624
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1218 $group = stFetchSQL(stPrepareSQL("SELECT * FROM settings_groups WHERE id=%D", "id")); |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1219 if ($group !== FALSE) |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
1220 { |
624
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1221 $prefix = "st"; |
626
abda11cd3259
Make the settings panels slightly nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
624
diff
changeset
|
1222 $first = TRUE; |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
1223 echo |
624
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1224 "<h1>".chentities($group["description"])."</h1>\n". |
626
abda11cd3259
Make the settings panels slightly nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
624
diff
changeset
|
1225 "<form method=\"post\" action=\"\" onsubmit=\"return jsUpdateSettings(".$group["id"].")\">\n"; |
624
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1226 |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1227 foreach (stExecSQL("SELECT * FROM settings WHERE vtype<>".VT_TEXT." AND vgroup=".$group["id"]." ORDER BY vtype ASC") as $item) |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
1228 { |
626
abda11cd3259
Make the settings panels slightly nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
624
diff
changeset
|
1229 if ($first) |
abda11cd3259
Make the settings panels slightly nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
624
diff
changeset
|
1230 { |
abda11cd3259
Make the settings panels slightly nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
624
diff
changeset
|
1231 echo "<table>\n"; |
abda11cd3259
Make the settings panels slightly nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
624
diff
changeset
|
1232 $first = FALSE; |
abda11cd3259
Make the settings panels slightly nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
624
diff
changeset
|
1233 } |
abda11cd3259
Make the settings panels slightly nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
624
diff
changeset
|
1234 |
624
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1235 echo |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1236 " <tr>\n". |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1237 " <td>"; |
626
abda11cd3259
Make the settings panels slightly nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
624
diff
changeset
|
1238 |
624
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1239 $id = $item["key"]; |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1240 switch ($item["vtype"]) |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1241 { |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1242 case VT_INT: |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1243 echo stGetFormTextInput(10, 10, "", $id, $prefix, $item["vint"]); |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1244 break; |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1245 case VT_STR: |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1246 echo stGetFormTextInput(40, 128, "", $id, $prefix, $item["vstr"]); |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1247 break; |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1248 case VT_BOOL: |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1249 echo stGetFormCheckBoxInput("", $id, $prefix, $item["vint"], ""); |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1250 break; |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1251 } |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1252 echo |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1253 "</td>\n". |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1254 " <td><label for=\"".$prefix.$id."\">".chentities($item["sdesc"])."</label></td>\n". |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1255 " </tr>\n"; |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
1256 } |
626
abda11cd3259
Make the settings panels slightly nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
624
diff
changeset
|
1257 if (!$first) |
abda11cd3259
Make the settings panels slightly nicer.
Matti Hamalainen <ccr@tnsp.org>
parents:
624
diff
changeset
|
1258 echo "</table>\n".stGetSaveButton(); |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
1259 |
624
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1260 foreach (stExecSQL("SELECT * FROM settings WHERE vtype=".VT_TEXT." AND vgroup=".$group["id"]." ORDER BY key DESC") as $item) |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1261 { |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1262 echo |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1263 "<h2>".chentities($item["sdesc"])."</h2>\n". |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1264 stGetFormTextArea(10, 60, "", $item["key"], $prefix, $item["vtext"]). |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1265 "\n<br />\n". |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1266 stGetSaveButton(); |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1267 } |
aad32d21091f
Some work on settings groups.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
1268 echo "</form>\n"; |
14
e36c4d2b09c4
Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
1269 } |
8
4c5f651aa107
Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
5
diff
changeset
|
1270 break; |
0 | 1271 |
250
34f540cea1ff
Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents:
249
diff
changeset
|
1272 case "compolist": |
249
6927edc7e266
Get compo name list as JSON.
Matti Hamalainen <ccr@tnsp.org>
parents:
228
diff
changeset
|
1273 $index = 0; |
223
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1274 foreach (stExecSQL("SELECT * FROM compos") as $compo) |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1275 { |
249
6927edc7e266
Get compo name list as JSON.
Matti Hamalainen <ccr@tnsp.org>
parents:
228
diff
changeset
|
1276 if ($index++ > 0) echo ","; |
251
1953d5025531
Alter the JSON format of the compo data list.
Matti Hamalainen <ccr@tnsp.org>
parents:
250
diff
changeset
|
1277 echo "\"".$compo["id"]."\":\"".chentities($compo["name"])."\""; |
223
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1278 } |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1279 break; |
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1280 |
257
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
1281 case "entry": |
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
1282 $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
|
1283 if ($res !== FALSE) |
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
1284 echo stGetEntryItemData($res["id"], $res, "en"); |
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
1285 break; |
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
1286 |
250
34f540cea1ff
Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents:
249
diff
changeset
|
1287 case "entries": |
223
532704115290
Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents:
216
diff
changeset
|
1288 $id = intval(stGetRequestItem("id", 0)); |
250
34f540cea1ff
Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents:
249
diff
changeset
|
1289 if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== false) |
0 | 1290 { |
381 | 1291 $nentries = stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$id); |
1292 $prefix = "ne"; | |
0 | 1293 echo |
381 | 1294 "<h1 style=\"margin-bottom: 0px;\">#".$id." - ".chentities($compo["name"]). |
385
8b8b0a83233b
Add compo entry show position buttons to individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
382
diff
changeset
|
1295 " (".$nentries." entries)</h1>\n"; |
8b8b0a83233b
Add compo entry show position buttons to individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
382
diff
changeset
|
1296 |
8b8b0a83233b
Add compo entry show position buttons to individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
382
diff
changeset
|
1297 if ($nentries > 0) |
8b8b0a83233b
Add compo entry show position buttons to individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
382
diff
changeset
|
1298 { |
8b8b0a83233b
Add compo entry show position buttons to individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
382
diff
changeset
|
1299 echo |
8b8b0a83233b
Add compo entry show position buttons to individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
382
diff
changeset
|
1300 stGetFormButtonInput("generate", "", "", " Add missing show positions ", "generateEntryPositions(".$id.", 1)")."\n". |
8b8b0a83233b
Add compo entry show position buttons to individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
382
diff
changeset
|
1301 stGetFormButtonInput("regenerate", "", "", " ReGenerate show positions ", "generateEntryPositions(".$id.", 0)")."\n"; |
8b8b0a83233b
Add compo entry show position buttons to individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
382
diff
changeset
|
1302 } |
8b8b0a83233b
Add compo entry show position buttons to individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
382
diff
changeset
|
1303 |
8b8b0a83233b
Add compo entry show position buttons to individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents:
382
diff
changeset
|
1304 echo |
0 | 1305 "<form>\n". |
1306 " <table class=\"misc\">\n". | |
1307 " <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
|
1308 " <th style=\"width:4%;\">S#</th>\n". |
264 | 1309 " <th>Name</th>\n". |
29 | 1310 " <th>Author(s)</th>\n". |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
1311 " <th>Filename</th>\n". |
215
bfd480370a70
More work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents:
214
diff
changeset
|
1312 " <th>Info</th>\n". |
0 | 1313 " <th>Actions</th>\n". |
381 | 1314 " </tr>\n". |
1315 " <tr>\n". | |
1316 " <td></td>\n". | |
1317 " <td>".stGetFormTextInput(20, SET_LEN_ENTRY_NAME, "name", $id, $prefix, "")."</td>\n". | |
1318 " <td>".stGetFormTextInput(15, SET_LEN_ENTRY_AUTHOR, "author", $id, $prefix, "")."</td>\n". | |
1319 " <td>".stGetFormTextInput(20, SET_LEN_ENTRY_FILENAME, "filename", $id, $prefix, "")."</td>\n". | |
1320 // " <td>".stGetFormTextInput(20, SET_LEN_ENTRY_INFO, "info", $id, $prefix, "")."</td>\n". | |
1321 " <td>".stGetFormTextArea(2, 30, "info", $id, $prefix, "")."</td>\n". | |
1322 " <td>".stGetFormButtonInput("add", $id, $prefix, "Add new", "addEntry(".$id.")")."</td>\n". | |
1323 " </tr>\n". | |
1324 " <tr><td colspan=\"6\"><hr /></td></tr>\n"; | |
0 | 1325 |
543 | 1326 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$id." ORDER BY id ASC") as $entry) |
0 | 1327 { |
1328 echo | |
257
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
1329 " <tr id=\"entry".$entry["id"]."\">\n". |
ef9a007c0876
Modularize and add methods for getting single entry.
Matti Hamalainen <ccr@tnsp.org>
parents:
252
diff
changeset
|
1330 stGetEntryItemData($entry["id"], $entry, "en"). |
0 | 1331 " </tr>\n"; |
1332 } | |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
1333 |
0 | 1334 echo |
1335 " </table>\n". | |
1336 "</form>\n"; | |
1337 } | |
1338 break; | |
1339 } | |
1340 break; | |
1341 | |
1342 case "delete": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1343 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1344 // Delete entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1345 // |
208
8985d2bdb29b
More work on error handling etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
1346 if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
0 | 1347 { |
1348 if ($type == "news") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1349 { |
0 | 1350 $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
|
1351 stExecSQLCond($sql, "OK, news item ".$id." deleted."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1352 } |
0 | 1353 else |
1354 if ($type == "attendees") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1355 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1356 // Attendees require some more work |
302
828fc30e3c94
Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
1357 $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
|
1358 if (($attn = stFetchSQL($sql)) !== false) |
828fc30e3c94
Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
1359 { |
828fc30e3c94
Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
1360 $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
|
1361 stExecSQLCond($sql, "OK, attendee ".$id." deleted."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1362 |
305
b96c41bd9dd6
More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
1363 // 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
|
1364 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
|
1365 { |
828fc30e3c94
Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
1366 $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
|
1367 stExecSQLCond($sql, "OK, attendee ".$id." votekey deleted."); |
828fc30e3c94
Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
1368 |
828fc30e3c94
Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
1369 $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
|
1370 stExecSQLCond($sql, "OK, attendee ".$id." votes deleted."); |
828fc30e3c94
Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
1371 } |
828fc30e3c94
Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
1372 } |
828fc30e3c94
Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
1373 else |
828fc30e3c94
Some work on vote backend stuff.
Matti Hamalainen <ccr@tnsp.org>
parents:
296
diff
changeset
|
1374 stError("No such attendee ID #".$id); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1375 } |
0 | 1376 else |
1377 if ($type == "entries") | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1378 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1379 // .. as do compo entries |
0 | 1380 $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
|
1381 stExecSQLCond($sql, "OK, entry ".$id." deleted."); |
0 | 1382 |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1383 $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
|
1384 stExecSQLCond($sql, "OK, entry ".$id." votes deleted."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1385 } |
608
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1386 else |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1387 if ($type == "compo") |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1388 { |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1389 stDBBeginTransaction(); |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1390 |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1391 // Delete votes for compo entry |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1392 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$id) as $sentry) |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1393 { |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1394 stExecSQLCond( |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1395 "DELETE FROM votes WHERE entry_id=".$sentry["id"], |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1396 "OK, entry ".$sentry["id"]." votes deleted."); |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1397 } |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1398 |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1399 // Delete entries for the compo |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1400 stExecSQLCond( |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1401 "DELETE FROM entries WHERE compo_id=".$id, |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1402 "OK, compo entries for compo ".$id." deleted."); |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1403 |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1404 // Delete the compo itself |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1405 stExecSQLCond( |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1406 "DELETE FROM compos WHERE id=".$id, |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1407 "OK, compo ".$id." deleted."); |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1408 |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1409 stDBCommitTransaction(); |
7d676c77e3f8
Add functionality for deleting a compo.
Matti Hamalainen <ccr@tnsp.org>
parents:
601
diff
changeset
|
1410 } |
0 | 1411 } |
305
b96c41bd9dd6
More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
1412 else |
b96c41bd9dd6
More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
1413 if ($type == "votekeys") |
b96c41bd9dd6
More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
1414 { |
b96c41bd9dd6
More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
1415 $sql = stPrepareSQL("DELETE FROM votekeys"); |
b96c41bd9dd6
More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
1416 stExecSQLCond($sql, "OK, all votekeys purged"); |
b96c41bd9dd6
More work on admin backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
1417 } |
0 | 1418 break; |
1419 | |
1420 case "add": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1421 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1422 // Add new entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1423 // |
228 | 1424 if ($type == "news" && stValidateRequestNewsData()) |
0 | 1425 { |
1426 $sql = stPrepareSQL( | |
1427 "INSERT INTO news (utime,title,text,author) VALUES (%d,%S,%Q,%S)", | |
1428 time(), "title", "text", "author"); | |
1429 | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
1430 stExecSQLCond($sql, "OK, news item added."); |
0 | 1431 } |
1432 else | |
228 | 1433 if ($type == "compo" && stValidateRequestCompoData(FALSE)) |
0 | 1434 { |
1435 $sql = stPrepareSQL( | |
635
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
1436 "INSERT INTO compos (name,description,visible,voting,show_authors,path,type) VALUES (%S,%Q,%D,0,0,0,%S,%D)", |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
1437 "name", "description", "path", "type"); |
0 | 1438 |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
1439 stExecSQLCond($sql, "OK, compo added."); |
0 | 1440 } |
1441 else | |
228 | 1442 if ($type == "attendees" && stValidateRequestUserData(TRUE)) |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1443 { |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1444 $sql = stPrepareSQL( |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1445 "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
|
1446 time(), "name", "groups", "oneliner", "email"); |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1447 |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
1448 stExecSQLCond($sql, "OK, attendee added."); |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1449 } |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1450 else |
228 | 1451 if ($type == "entry" && stValidateRequestEntryData($fake)) |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
1452 { |
296
bbdf1b9c5a07
Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
1453 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
|
1454 { |
bbdf1b9c5a07
Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
1455 stError("No such compo ID."); |
bbdf1b9c5a07
Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
1456 } |
bbdf1b9c5a07
Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
1457 else |
bbdf1b9c5a07
Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
1458 { |
bbdf1b9c5a07
Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
1459 $sql = stPrepareSQL( |
bbdf1b9c5a07
Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
1460 "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
|
1461 "name", "author", "compo_id", "filename", "info"); |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
1462 |
296
bbdf1b9c5a07
Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
1463 stExecSQLCond($sql, "OK, entry added."); |
bbdf1b9c5a07
Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
1464 } |
59
e5e38ed4e837
Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents:
57
diff
changeset
|
1465 } |
0 | 1466 break; |
1467 | |
1468 case "update": | |
53
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1469 // |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1470 // Update existing entry |
71256605546b
More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents:
52
diff
changeset
|
1471 // |
209 | 1472 if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data."))) |
1473 { | |
627
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1474 if ($type == "settings") |
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1475 { |
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1476 stDBBeginTransaction(); |
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1477 foreach (stExecSQL("SELECT * FROM settings WHERE vgroup=".$id) as $item) |
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1478 if (($val = stGetRequestItem($item["key"], FALSE)) !== FALSE) |
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1479 { |
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1480 $sql = "UPDATE settings SET ".stGetSettingSQL($item, $val)." WHERE key=".$db->quote($item["key"]); |
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1481 stExecSQLCond($sql, "OK, setting updated."); |
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1482 } |
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1483 stDBCommitTransaction(); |
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1484 } |
18f52c7daf77
Make group-specific settings updates possible.
Matti Hamalainen <ccr@tnsp.org>
parents:
626
diff
changeset
|
1485 else |
228 | 1486 if ($type == "attendees" && stValidateRequestUserData(TRUE)) |
209 | 1487 { |
1488 $sql = stPrepareSQLUpdate("attendees", | |
435 | 1489 "WHERE id=".$id, |
209 | 1490 array( |
1491 "name" => "S", | |
1492 "groups" => "S", | |
1493 "email" => "S", | |
1494 "oneliner" => "S", | |
1495 )); | |
1496 | |
1497 stExecSQLCond($sql, "OK, attendee updated."); | |
1498 } | |
1499 else | |
228 | 1500 if ($type == "news" && stValidateRequestNewsData()) |
209 | 1501 { |
1502 $sql = stPrepareSQLUpdate("news", | |
435 | 1503 "WHERE id=".$id, |
209 | 1504 array( |
1505 "title" => "S", | |
1506 "text" => "Q", | |
1507 "author" => "S" | |
1508 )); | |
1509 | |
1510 stExecSQLCond($sql, "OK, news item updated."); | |
1511 } | |
1512 else | |
228 | 1513 if ($type == "compo" && stValidateRequestCompoData(TRUE)) |
209 | 1514 { |
1515 $sql = stPrepareSQLUpdate("compos", | |
435 | 1516 "WHERE id=".$id, |
209 | 1517 array( |
1518 "name" => "S", | |
1519 "description" => "Q", | |
1520 "visible" => "B", | |
1521 "voting" => "B", | |
542
8c1a53532be0
Rename various database tables and column names for better SQL compatibility.
Matti Hamalainen <ccr@tnsp.org>
parents:
534
diff
changeset
|
1522 "show_authors" => "B", |
635
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
1523 "path" => "S", |
59d14c0825cd
Somewhat fix compo data updating. Work is still needed to have the planned
Matti Hamalainen <ccr@tnsp.org>
parents:
634
diff
changeset
|
1524 "type" => "D", |
209 | 1525 )); |
1526 | |
1527 stExecSQLCond($sql, "OK, compo updated."); | |
1528 } | |
1529 else | |
228 | 1530 if ($type == "entry" && stValidateRequestEntryData($compo_id)) |
209 | 1531 { |
214 | 1532 if (stFetchSQLColumn("SELECT id FROM compos WHERE id=".$compo_id) === FALSE) |
209 | 1533 { |
214 | 1534 stError("No such compo ID."); |
209 | 1535 } |
1536 else | |
1537 { | |
1538 $sql = stPrepareSQLUpdate("entries", | |
435 | 1539 "WHERE id=".$id, |
209 | 1540 array( |
1541 "name" => "S", | |
1542 "author" => "S", | |
1543 "filename" => "S", | |
296
bbdf1b9c5a07
Check compo_id in compo entry addition.
Matti Hamalainen <ccr@tnsp.org>
parents:
289
diff
changeset
|
1544 "info" => "Q", |
209 | 1545 "compo_id" => "D", |
1546 )); | |
1547 | |
1548 stExecSQLCond($sql, "OK, entry updated."); | |
1549 } | |
1550 } | |
435 | 1551 } |
1552 break; | |
1553 | |
1554 case "votekey": | |
1555 if (stChkRequestItem("id", $id, array(CHK_TYPE, VT_INT, "Invalid data."))) | |
1556 { | |
1557 switch ($type) | |
308
3cfd95758377
A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
305
diff
changeset
|
1558 { |
435 | 1559 case "assign": |
1560 // Check if already assigned to someone .. | |
1561 $key_id = intval(stGetRequestItem("key_id", 0)); | |
1562 $sql = stPrepareSQL("SELECT * FROM votekeys WHERE id=%d", $key_id); | |
1563 if (stFetchSQL($sql) === false) | |
1564 stError("Invalid key ID #."); | |
1565 else | |
1566 { | |
1567 $sql = stPrepareSQL("SELECT * FROM attendees WHERE key_id=%d", $key_id); | |
1568 if (($attn = stFetchSQL($sql)) !== false && $attn["id"] != $id) | |
1569 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
|
1570 else |
312 | 1571 { |
435 | 1572 // Assign .. |
1573 $sql = stPrepareSQL("UPDATE attendees SET key_id=%d WHERE id=%d", $key_id, $id); | |
1574 stExecSQLCond($sql, "Assigned key updated."); | |
312 | 1575 } |
435 | 1576 } |
1577 break; | |
319
623acd958944
Simplify things, add clear button to vote key assignation.
Matti Hamalainen <ccr@tnsp.org>
parents:
318
diff
changeset
|
1578 |
435 | 1579 case "clear": |
1580 $sql = stPrepareSQL("UPDATE attendees SET key_id=NULL WHERE id=%d", $id); | |
1581 stExecSQLCond($sql, "Assigned key cleared."); | |
1582 break; | |
1583 | |
1584 case "active": | |
1585 // Autobots activate! | |
1586 $sql = stPrepareSQL("UPDATE votekeys SET active=%B WHERE id=%d", "active", $id); | |
1587 stExecSQLCond($sql, "Votekey status changed."); | |
1588 break; | |
308
3cfd95758377
A bit of work on vote key management backend.
Matti Hamalainen <ccr@tnsp.org>
parents:
305
diff
changeset
|
1589 } |
209 | 1590 } |
0 | 1591 break; |
1592 | |
1593 default: | |
66
230aacc22cb4
Move some functions to site lib.
Matti Hamalainen <ccr@tnsp.org>
parents:
61
diff
changeset
|
1594 stSetStatus(404, "Not Found"); |
0 | 1595 break; |
1596 } | |
1597 | |
378 | 1598 if (!$errorSet) |
1599 stSaveDisplayVars(); | |
1600 | |
544 | 1601 |
1602 if ($errorSet) | |
1603 { | |
1604 ob_clean(); | |
1605 stDumpAJAXStatusErrors(); | |
1606 } | |
1607 | |
1608 ob_end_flush(); | |
0 | 1609 ?> |