annotate admajax.php @ 205:77d33161f8be

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