annotate ajax.php @ 59:e5e38ed4e837

Work on compo entry addition and editing.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 05 Oct 2013 11:36:09 +0300
parents f9cd2dd42b2e
children e85ed35585fc
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 //
243e9a51920b Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
3 // AJAX request handler backend module
243e9a51920b Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
4 //
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
5 $sessionType = "admin";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 require "mconfig.inc.php";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 require "msite.inc.php";
33
5bf22431176c Modularize.
Matti Hamalainen <ccr@tnsp.org>
parents: 32
diff changeset
8 require "msession.inc.php";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 // Check if we are allowed to execute
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
11 if (!stCheckHTTPS() || !stAdmSessionAuth())
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 {
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
13 stSetupCacheControl();
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
14
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
15 stSessionEnd(SESS_ADMIN);
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
16
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
17 header("Location: news");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 exit;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
21 stSetupCacheControl();
0
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 // Initiate SQL database connection
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 if (!stConnectSQLDB())
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 die("Could not connect to SQL database.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
27 // Fetch non-"hardcoded" settings from SQL database
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
28 stReloadSettings();
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
29
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
31 function saveButton()
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
32 {
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
33 return "<input type=\"submit\" value=\" Save \" />\n";
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
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
36
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 function setStatus($val, $msg)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 global $statusSet;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 if (!$statusSet)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 header("Status: ".$val." ".$msg);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 $statusSet = TRUE;
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 function execSQLCond($sql, $okmsg)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 if (($res = stExecSQL($sql)) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 if ($okmsg != "")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 setStatus(200, $okmsg);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 return $res;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 setStatus(900, "Error in SQL execution.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 return FALSE;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 // XMLHttp responses
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 $action = "ERROR";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 if (stChkRequestItem("action") && stChkRequestItem("type"))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 $action = $_REQUEST["action"];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 $type = $_REQUEST["type"];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 switch ($action)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 case "dump":
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
76 //
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
77 // Perform generic data dump
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
78 //
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 if (($res = execSQLCond(
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 "SELECT * FROM attendees WHERE email NOT NULL AND email != '' ORDER BY regtime DESC",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 "Dump OK.")) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 $out1 = array();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 $out2 = array();
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 foreach ($res as $item)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 $out1[] = $item["name"]." &lt;".$item["email"]."&gt;";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 $out2[] = $item["email"];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 echo "<br /><hr />".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 implode(", ", $out1)."<br /><hr /><br />".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 implode("<br />", $out1)."<br /><hr /><br />".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 implode(", ", $out2)."<br /><hr /><br />".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 implode("<br />", $out2)."<br /><hr />";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 case "get":
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
102 //
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
103 // Get specific data
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
104 //
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 switch ($type)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 case "news":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 $sql = "SELECT * FROM news ORDER BY utime DESC";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 case "attendees":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 $sql = "SELECT * FROM attendees ORDER BY regtime DESC";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 case "compos":
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 $sql = "SELECT * FROM compos ORDER BY id DESC";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 break;
8
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
118
4c5f651aa107 Migrate certain settings to SQL database, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
119 case "settings":
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
120 $prefix = "st";
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
121
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
122 echo
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
123 "<h1>Site settings</h1>\n".
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
124 "<table>\n";
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
125 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
126 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
127 echo
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
128 " <tr>\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
129 " <td>";
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
130 $id = $item["key"];
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
131 switch ($item["vtype"])
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
132 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
133 case VT_INT:
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
134 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
135 break;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
136 case VT_STR:
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
137 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
138 break;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
139 case VT_BOOL:
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
140 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
141 break;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
142 }
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
143 echo "</td>\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
144 " <td>".$item["desc"]."</td>\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
145 " </tr>\n";
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
146 }
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
147 echo "</table>\n".saveButton();
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
148
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
149 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
150 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
151 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
152 stGetFormTextArea(10, 60, "", $item["key"], $prefix, $item["vtext"]).
16
6da681d1f62a Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 14
diff changeset
153 "\n<br />\n".saveButton();
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
154 }
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".
30
ad25827304b6 Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
169 " <th style=\"width:1%;\">Compo</th>\n".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 " <th>Title</th>\n".
29
4b5a176805e2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
171 " <th>Author(s)</th>\n".
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
172 " <th>Filename</th>\n".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 " <th>Actions</th>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 " </tr>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 $prefix = "en";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 foreach ($compo["entries"] as $eid => $entry)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 echo
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 " <tr id=\"entry".$eid."\">\n".
30
ad25827304b6 Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
181 " <td>".stGetFormTextInput(5, 5, "compo_id", $eid, "en", $id)."</td>\n".
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
182 " <td>".stGetFormTextInput(30, 64, "name", $eid, "en", $entry["name"])."</td>\n".
29
4b5a176805e2 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 26
diff changeset
183 " <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
184 " <td>".stGetFormTextInput(20, 64, "filename", $eid, "en", $entry["filename"])."</td>\n".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 " <td>".
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
186 stGetFormButtonInput("update", $eid, $prefix, " Upd ", "updateEntry(".$eid.")").
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
187 stGetFormButtonInput("delete", $eid, $prefix, " Del ", "deleteEntry(".$eid.")").
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 "</td>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 " </tr>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 }
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
191
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
192 $prefix = "ne";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 echo
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
194 " <tr>\n".
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
195 " <td></td>\n".
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
196 " <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
197 " <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
198 " <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
199 " <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
200 " </tr>\n".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 " </table>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 "</form>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206
56
243e9a51920b Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
207 //
243e9a51920b Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
208 // Perform query if we need to, output results
243e9a51920b Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
209 //
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 if (isset($sql) && ($res = execSQLCond($sql, "")) !== FALSE)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 if ($type == "news")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 foreach ($res as $item)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 $id = $item["id"];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 stPrintNewsItem($item,
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 "<br />".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 " <button class=\"button\" id=\"ndel".$id.
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 "\" type=\"button\" onclick=\"deleteNews(".$id.
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 ")\">Delete</button>\n"
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 );
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 if ($type == "attendees")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 echo
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 "<table class=\"attendees\">\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 " <tr>\n".
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
231 " <th class=\"rname\">Name</th>\n".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 " <th class=\"oneliner\">Oneliner</th>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 " <th class=\"email\">E-mail</th>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 " <th>Actions</th>\n".
52
cba0b944da79 Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
235 " <th class=\"vkey\">User key</th>\n".
cba0b944da79 Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
236 " <th class=\"vactive\">Active</th>\n".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 " </tr>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 $row = 0;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 foreach ($res as $item)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 stPrintAttendee($item, $row++, TRUE);
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 echo "</table>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 if ($type == "compos")
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 foreach ($res as $item)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 $id = $item["id"];
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 $prefix = "co";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 echo
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 "<div id=\"compo".$id."\">\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252 "<h2>#".$id." - ".chentities($item["name"])."</h2>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 stGetFormTextInput(40, 64, "name", $id, $prefix, $item["name"])."\n".
24
5bc8bd5c7ecc Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
254 stGetFormCheckBoxInput("visible", $id, $prefix, $item["visible"], "Visible")."\n".
55
4fac95384753 Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
255 stGetFormCheckBoxInput("showAuthors", $id, $prefix, $item["showAuthors"], "Show authors")."\n".
24
5bc8bd5c7ecc Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
256 stGetFormCheckBoxInput("voting", $id, $prefix, $item["voting"], "Enable voting")."<br />\n".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 stGetFormTextArea(5, 60, "description", $id, $prefix, $item["description"])."\n<br />\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 stGetFormButtonInput("update", $id, $prefix, " Update ", "updateCompo(".$id.")")."\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 "</div>\n".
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 "<hr />\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266 case "delete":
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
267 //
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
268 // Delete entry
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
269 //
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270 if (stChkRequestItem("id"))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 $id = intval(stGetRequestItem("id"));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274 if ($type == "news")
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
275 {
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 $sql = stPrepareSQL("DELETE FROM news WHERE id=%d AND persist=0", $id);
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
277 execSQLCond($sql, "OK, news item ".$id." deleted.");
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
278 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 if ($type == "attendees")
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
281 {
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
282 // Attendees require some more work
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 $sql = stPrepareSQL("DELETE FROM attendees WHERE id=%d", $id);
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
284 execSQLCond($sql, "OK, attendee ".$id." deleted.");
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
285
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
286 $sql = stPrepareSQL("DELETE FROM votes WHERE voter_id=%d", $id);
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
287 execSQLCond($sql, "OK, attendee ".$id." votes deleted.");
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
288 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 if ($type == "entries")
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
291 {
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
292 // .. as do compo entries
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 $sql = stPrepareSQL("DELETE FROM entries WHERE id=%d", $id);
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
294 execSQLCond($sql, "OK, entry ".$id." deleted.");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
296 $sql = stPrepareSQL("DELETE FROM votes WHERE entry_id=%d", $id);
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
297 execSQLCond($sql, "OK, entry ".$id." votes deleted.");
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
298 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 setStatus(901, "No ID specified.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 case "add":
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
305 //
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
306 // Add new entry
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
307 //
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
308 if ($type == "news" && stChkRequestItem("text") &&
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
309 stChkRequestItem("author") && stChkRequestItem("title"))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 $sql = stPrepareSQL(
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312 "INSERT INTO news (utime,title,text,author) VALUES (%d,%S,%Q,%S)",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 time(), "title", "text", "author");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 execSQLCond($sql, "OK, news item added.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 else
26
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
318 if ($type == "compo" && stChkRequestItem("name") &&
7be3f8cf1f7a Lots of cleanups, preparing for adding entry submission support.
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
319 stChkRequestItem("description"))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 $sql = stPrepareSQL(
55
4fac95384753 Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
322 "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
323 "name", "description");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 execSQLCond($sql, "OK, compo added.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 else
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
328 if ($type == "attendees" && stChkRequestItem("name") &&
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
329 stChkRequestItem("groups") && stChkRequestItem("email") &&
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
330 stChkRequestItem("oneliner"))
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
331 {
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
332 $sql = stPrepareSQL(
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
333 "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
334 time(), "name", "groups", "oneliner", "email");
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
335
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
336 execSQLCond($sql, "OK, attendee added.");
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
337 }
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
338 else
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
339 if ($type == "entry" && stChkRequestItem("name") &&
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
340 stChkRequestItem("author") && stChkRequestItem("compo_id"))
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
341 {
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
342 $sql = stPrepareSQL(
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
343 "INSERT INTO entries (name,author,compo_id) VALUES (%S,%Q,%D)",
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
344 "name", "author", "compo_id", "filename");
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
345
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
346 execSQLCond($sql, "OK, entry added.");
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
347 }
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
348 else
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 setStatus(902, "No data.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 case "update":
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
353 //
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
354 // Update existing entry
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
355 //
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 if ($type == "attendees" && stChkRequestItem("id") &&
52
cba0b944da79 Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
357 stChkRequestItem("email") && stChkRequestItem("oneliner") &&
cba0b944da79 Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
358 stChkRequestItem("active"))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 $sql = stPrepareSQLUpdate("attendees",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 "WHERE id=".intval(stGetRequestItem("id")),
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362 array(
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 "email" => "S",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 "oneliner" => "S",
52
cba0b944da79 Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
365 "active" => "B",
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 ));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 execSQLCond($sql, "OK, attendee updated.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 if ($type == "news" && stChkRequestItem("id") &&
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 stChkRequestItem("text") && stChkRequestItem("author") &&
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373 stChkRequestItem("title"))
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 $sql = stPrepareSQLUpdate("news",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 "WHERE id=".intval(stGetRequestItem("id")),
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 array(
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378 "title" => "S",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 "text" => "Q",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 "author" => "S"
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 ));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 execSQLCond($sql, "OK, news item updated.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386 if ($type == "compo" && stChkRequestItem("id") &&
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 stChkRequestItem("name") && stChkRequestItem("description") &&
55
4fac95384753 Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
388 stChkRequestItem("visible") && stChkRequestItem("voting") &&
4fac95384753 Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
389 stChkRequestItem("showAuthors"))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 $sql = stPrepareSQLUpdate("compos",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 "WHERE id=".intval(stGetRequestItem("id")),
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 array(
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394 "name" => "S",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 "description" => "Q",
24
5bc8bd5c7ecc Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
396 "visible" => "B",
5bc8bd5c7ecc Make voting toggle for individual compos.
Matti Hamalainen <ccr@tnsp.org>
parents: 20
diff changeset
397 "voting" => "B",
55
4fac95384753 Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
398 "showAuthors" => "B",
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 ));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 execSQLCond($sql, "OK, compo updated.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
403 else
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404 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
405 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
406 stChkRequestItem("compo_id"))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408 $sql = stPrepareSQLUpdate("entries",
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
409 "WHERE id=".intval(stGetRequestItem("id")),
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410 array(
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411 "name" => "S",
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412 "author" => "S",
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 57
diff changeset
413 "filename" => "S",
30
ad25827304b6 Adding entries is now done via the regular entry submission system .. which
Matti Hamalainen <ccr@tnsp.org>
parents: 29
diff changeset
414 "compo_id" => "D",
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
415 ));
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416
20
02ff0c29df8a s/voter/entry/.
Matti Hamalainen <ccr@tnsp.org>
parents: 19
diff changeset
417 execSQLCond($sql, "OK, entry updated.");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
418 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
419 else
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
420 if ($type == "settings")
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
421 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
422 foreach (stExecSQL("SELECT * FROM settings") as $item)
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
423 if (stChkRequestItem($item["key"]))
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
424 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
425 $val = stGetRequestItem($item["key"]);
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
426 switch ($item["vtype"])
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
427 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
428 case VT_INT: $vsql = stPrepareSQL("vint=%d", $val); break;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
429 case VT_BOOL: $vsql = stPrepareSQL("vint=%d", $val ? 1 : 0); break;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
430 case VT_STR: $vsql = stPrepareSQL("vstr=%s", $val); break;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
431 case VT_TEXT: $vsql = stPrepareSQL("vtext=%s", $val); break;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
432 }
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
433
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
434 $sql = "UPDATE settings SET ".$vsql." WHERE key=".$db->quote($item["key"]);
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
435 execSQLCond($sql, "OK, setting updated.");
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
436 }
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
437 }
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
438 else
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
439 setStatus(902, "No data.");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
440 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
442 default:
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443 setStatus(404, "Not Found");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
444 break;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
446
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
447 ?>