annotate admin.php @ 263:8c3922a65231

Work on entry admin looks.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 24 Nov 2013 03:09:12 +0200
parents 6a1f1f2f2141
children aef6dfcf352c
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 <?
136
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
2 //
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
3 // FAPWeb Simple Demoparty System
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
4 // Party administration page frontend module
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
5 // (C) Copyright 2012-2013 Tecnic Software productions (TNSP)
aeebfedb5709 Add some copyright headers.
Matti Hamalainen <ccr@tnsp.org>
parents: 126
diff changeset
6 //
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
7 $sessionType = "admin";
175
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
8 require_once "mconfig.inc.php";
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
9 require_once "msite.inc.php";
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
10 require_once "msession.inc.php";
8df523e6326a User require_once instead of require.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
11 require_once "majax.php";
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
12
180
a3f0f2a3551a Split stylesheets into separate files for different platforms and also split
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
13 $pageCSS["admin.css"] = "";
a3f0f2a3551a Split stylesheets into separate files for different platforms and also split
Matti Hamalainen <ccr@tnsp.org>
parents: 175
diff changeset
14
174
63c840590476 Move common code from mcommon.inc.php to msitegen module.
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
15 cmLocaleInit();
171
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
16
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
17 // Switch to https first, if needed
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
18 if (!stCheckHTTPS())
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
19 {
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
20 header("Location: https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
21 exit;
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
22 }
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
23
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
24 // Start output
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
25 cmPrintPageHeader("FAPWeb Administration",
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
26 " <meta http-equiv=\"Pragma\" content=\"no-cache\" />",
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
27 FALSE);
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
28
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
29 echo "<div id=\"adminContent\">\n";
171
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
30
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
31 // Initiate SQL database connection
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
32 if (!stConnectSQLDB())
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
33 {
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
34 // Error occured, bail out early
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
35 cmPrintPageFooter();
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
36 exit;
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
37 }
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
38
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
39 // Fetch non-"hardcoded" settings from SQL database
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
40 stReloadSettings();
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
41
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
42 function stCreateSettingsData()
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
43 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
44 $args = array();
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
45
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
46 if (($res = stExecSQL("SELECT * FROM settings")) !== FALSE)
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
47 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
48 foreach ($res as $item)
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
49 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
50 switch ($item["vtype"])
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
51 {
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
52 case VT_STR:
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
53 case VT_TEXT: $type = 0; break;
105
a85f258f6beb Move some things around and modularize the code.
Matti Hamalainen <ccr@tnsp.org>
parents: 86
diff changeset
54 case VT_INT: $type = 4; break;
14
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
55 case VT_BOOL: $type = 3; break;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
56 }
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
57 $args[] = "\"".$item["key"]."\":".$type;
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
58 }
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
59 }
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
60
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
61 echo
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
62 "\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
63 "function updateSettings()\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
64 "{\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
65 " var args = makePostArgs({".implode(",", $args)."}, \"st\", \"\");\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
66 " sendPOSTRequest(\"action=update&type=settings&\"+args);\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
67 " return false;\n".
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
68 "}\n";
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
69 }
e36c4d2b09c4 Fix settings to work, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 10
diff changeset
70
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 // Check if sessions are enabled
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
72 if (!stChkSetting("admPassword"))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 {
171
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
74 echo
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
75 "<h1>Oh noes, admin configuration not done!</h1>\n".
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
76 "<p>Better go and prod that, so you get to use the fine admin interface.</p>\n";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 else
107
6e076b3630a0 Cleanup the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
79 if (!stAdmSessionAuth(FALSE))
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 // Perform authentication if we are not in session already
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
82 echo
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
83 "<h1>Party admin login</h1>\n".
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 "<p>Please use illegal telepathy over HTTP to provide a password to enter the party administration systembolaget.</p>\n".
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
85 stGetFormStart("admlogin", "admlogin.php").
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 stGetFormHiddenInput("mode", "check")."\n".
247
8945b78dd6b6 Use HTML5 form field autofocus.
Matti Hamalainen <ccr@tnsp.org>
parents: 223
diff changeset
87 stGetFormPasswordInput("admpass", "", "", "autofocus=\"autofocus\"")."\n".
32
36392d1d6b5f Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
88 stGetFormSubmitInput("submit", "Login").
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 "</form>\n";
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 }
107
6e076b3630a0 Cleanup the code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 105
diff changeset
91 else
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 ?>
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 <script type="text/javascript">
126
71c35d5302c2 More work on cleanups, and AJAX modularization.
Matti Hamalainen <ccr@tnsp.org>
parents: 124
diff changeset
95 // <? stCreateSettingsData(); stCommonAJAX("admajax.php", "admlogout.php", FALSE); ?>
124
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
96
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
97
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
98 var activeAttendee = -1, prevAttendee = -1;
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
99 var activeTmp = "";
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
100 var registeredTabs = Object();
260
6a1f1f2f2141 Make tab selection in subtabs persistent.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
101 var activeTabs = Object();
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
102
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
103
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
104 function refreshItems(id,name,extra)
124
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
105 {
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
106 var msuccess = function(txt)
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
107 {
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
108 var nitem = document.getElementById(id);
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
109 if (nitem) nitem.innerHTML = txt;
124
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
110 }
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
111
219
ca5ca5cf7901 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 217
diff changeset
112 sendPOSTRequest("action=get&type="+name+extra, msuccess);
124
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
113 }
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
114
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
115
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
116 function deleteItem(id,prefix,type,func,dsc)
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
117 {
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
118 var msuccess = function(txt)
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
119 {
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
120 var item = document.getElementById(prefix+id);
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
121 item.style.display = "none";
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
122 setTimeout(func, 50);
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
123 }
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
124
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
125 // Clearly mark the element when asking confirmation
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
126 var item = document.getElementById(prefix+id);
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
127 var tmp = item.style.background;
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
128 item.style.background = "red";
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
129
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
130 // Ask confirmation for deletion
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
131 if (confirm("Are you sure you want to delete "+dsc+" #"+id+"?"))
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
132 {
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
133 // Okay, delete
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
134 sendPOSTRequest("action=delete&type="+type+"&id="+id, msuccess);
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
135 }
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
136
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
137 // Restore background
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
138 item.style.background = tmp;
986c25c2e2bc Move some relevant javascript code from ajax.js to admin module.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
139 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141
253
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
142 function refreshDispatchCC(id)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 {
253
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
144 switch (id)
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
145 {
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
146 case "Settings": refreshItems("tabContCCSettings", "settings", ""); break;
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
147 case "News": refreshItems("tabContCCNews", "news", ""); break;
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
148 case "Attendees": refreshItems("tabContCCAttendees", "attendees", ""); break;
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
149 case "Voters": refreshItems("tabContCCVoters", "voters", ""); break;
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
150 case "Compos": refreshItems("tabContCCCompos", "compos", ""); break;
253
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
151 case "Entries": refreshCCEntries(); break;
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
152 }
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155
255
16d453f1b23d Simplify refreshing function.
Matti Hamalainen <ccr@tnsp.org>
parents: 254
diff changeset
156 function refreshCCAttendee(id)
209
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
157 {
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
158 refreshItems("attendee"+ id, "attendee", "&id="+ id);
209
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
159 }
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
160
3870601c17c3 More work.
Matti Hamalainen <ccr@tnsp.org>
parents: 206
diff changeset
161
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
162 function refreshCCEntries()
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 {
254
c26167a096bf Rename a callback function.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
164 var msuccess = function(txt)
250
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
165 {
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
166 var nitem = document.getElementById("tabContCCEntries");
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
167 if (nitem)
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
168 {
259
a7aa20dec154 Some more work.
Matti Hamalainen <ccr@tnsp.org>
parents: 258
diff changeset
169 nitem.innerHTML = "<div id=\"tabHeadersCM\" class=\"tabHeadersSub\"></div><div id=\"tabContentsCM\" class=\"tabContentsSub\"></div>";
250
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
170 try {
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
171 var tmp = JSON.parse("{"+ txt +"}");
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
172 registeredTabs["CM"] = tmp;
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
173 updateTabList("CM", "");
260
6a1f1f2f2141 Make tab selection in subtabs persistent.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
174 if (activeTabs["CM"])
6a1f1f2f2141 Make tab selection in subtabs persistent.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
175 switchActiveTab("CM", activeTabs["CM"]);
250
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
176 }
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
177 catch (err) {
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
178 alert("JSON.parse("+ txt +") failure: "+ err);
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
179 }
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
180 }
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
181 }
34f540cea1ff Some work on compo entry listing.
Matti Hamalainen <ccr@tnsp.org>
parents: 247
diff changeset
182
254
c26167a096bf Rename a callback function.
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
183 sendPOSTRequest("action=get&type=compolist", msuccess);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186
256
ed8d8d016420 Add refreshCMEntry(id) function for updating one entry only.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
187 function refreshCMEntry(id)
ed8d8d016420 Add refreshCMEntry(id) function for updating one entry only.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
188 {
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
189 refreshItems("entry"+ id, "entry", "&id="+ id);
256
ed8d8d016420 Add refreshCMEntry(id) function for updating one entry only.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
190 }
ed8d8d016420 Add refreshCMEntry(id) function for updating one entry only.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
191
ed8d8d016420 Add refreshCMEntry(id) function for updating one entry only.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
192
253
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
193 function refreshDispatchCM(id)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 {
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
195 refreshItems("tabContCM"+ id, "entries", "&id="+ id);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 function addNews()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 var args = makePostArgs({"title":1,"text":1,"author":1}, "nn", "");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 var msuccess = function(txt)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 {
253
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
205 setTimeout("refreshDispatchCC('News');", 50);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207
61
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
208 if (args != "")
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
209 sendPOSTRequest("action=add&type=news&"+args, msuccess);
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
210
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 return false;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 function deleteNews(id)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 {
253
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
217 deleteItem(id, "news", "news", "refreshDispatchCC('News');", "news item");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
221
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
222 function updateNews(id)
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
223 {
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
224 var args = makePostArgs({"title":1,"text":1,"author":1}, "ne", id);
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
225
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
226 var msuccess = function(txt)
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
227 {
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
228 refreshItems("news"+id, "newsitem", "&id="+id);
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
229 }
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
230
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
231 if (args != "")
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
232 sendPOSTRequest("action=update&type=news&id="+id+"&"+args, msuccess);
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
233 }
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
234
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
235
61
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
236 function addAttendee()
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
237 {
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
238 var args = makePostArgs({"name":1,"groups":0,"oneliner":0,"email":0}, "ne", "x");
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
239
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
240 var msuccess = function(txt)
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
241 {
253
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
242 setTimeout("refreshDispatchCC('Attendees');", 50);
61
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
243 }
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
244
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
245 if (args != "")
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
246 sendPOSTRequest("action=add&type=attendees&"+args, msuccess);
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
247
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
248 return false;
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
249 }
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
250
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
251
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252 function deleteAttendee(id)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 {
253
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
254 deleteItem(id, "attendee", "attendees", "refreshDispatchCC('Attendees');", "attendee");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 function updateAttendee(id)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
259 {
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
260 var args = makePostArgs({"name":1,"groups":0,"oneliner":0,"email":0}, "at", id);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
261
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
262 var msuccess = function(txt)
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
263 {
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
264 refreshItems("attendee"+id, "attendee", "&id="+id+"&edit=1");
53
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
265 }
71256605546b More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
266
61
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
267 if (args != "")
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
268 sendPOSTRequest("action=update&type=attendees&id="+id+"&"+args, msuccess);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
269 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
272 function activateAttendee(id)
52
cba0b944da79 Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
273 {
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
274 var msuccess1 = function(txt)
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
275 {
217
d313f9907610 Fix active attendee handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 215
diff changeset
276 var nitem = document.getElementById("attendee"+prevAttendee);
206
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
277 if (nitem)
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
278 {
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
279 nitem.innerHTML = txt;
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
280 nitem.style.background = activeTmp;
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
281 }
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
282 }
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
283
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
284 var msuccess2 = function(txt)
52
cba0b944da79 Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
285 {
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
286 var nitem = document.getElementById("attendee"+id);
206
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
287 if (nitem)
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
288 {
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
289 nitem.innerHTML = txt;
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
290 activeTmp = nitem.style.background;
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
291 nitem.style.background = "green";
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
292 activeAttendee = id;
1fa109a0c583 Change active attendee entry's background color as indicator.
Matti Hamalainen <ccr@tnsp.org>
parents: 205
diff changeset
293 }
52
cba0b944da79 Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
294 }
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
295
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
296 if (activeAttendee != id)
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
297 {
217
d313f9907610 Fix active attendee handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 215
diff changeset
298 prevAttendee = activeAttendee;
d313f9907610 Fix active attendee handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 215
diff changeset
299 activeAttendee = id;
d313f9907610 Fix active attendee handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 215
diff changeset
300
d313f9907610 Fix active attendee handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 215
diff changeset
301 if (prevAttendee != -1)
d313f9907610 Fix active attendee handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 215
diff changeset
302 sendPOSTRequest("action=get&type=attendee&id="+prevAttendee+"&edit=0", msuccess1);
205
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
303
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
304 sendPOSTRequest("action=get&type=attendee&id="+id+"&edit=1", msuccess2);
77d33161f8be More work on admin interface.
Matti Hamalainen <ccr@tnsp.org>
parents: 202
diff changeset
305 }
52
cba0b944da79 Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
306 }
cba0b944da79 Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
307
cba0b944da79 Start combining "users" with "attendees".
Matti Hamalainen <ccr@tnsp.org>
parents: 33
diff changeset
308
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309 function addCompo()
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 {
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 var args = makePostArgs({"name":1, "description":1}, "nc", "");
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 var msuccess = function(txt)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 {
253
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
315 setTimeout("refreshDispatchCC('Compos');", 50);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317
61
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
318 if (args != "")
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
319 sendPOSTRequest("action=add&type=compo&"+args, msuccess);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320 return false;
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324 function updateCompo(id)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 {
55
4fac95384753 Make visibility of entry authors per compo.
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
326 var args = makePostArgs({"name":1, "description":1, "visible":3, "voting":3, "showAuthors":3}, "co", id);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
328 var msuccess = function(txt)
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
329 {
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
330 refreshItems("compo"+id, "compo", "&id="+id);
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
331 }
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
332
61
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
333 if (args != "")
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
334 sendPOSTRequest("action=update&type=compo&id="+id+"&"+args, msuccess);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
337
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
338 function addEntry(id)
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
339 {
215
bfd480370a70 More work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 209
diff changeset
340 var args = makePostArgs({"name":1, "author":1, "filename":0, "info":0}, "ne", id);
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
341
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
342 var msuccess = function(txt)
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
343 {
256
ed8d8d016420 Add refreshCMEntry(id) function for updating one entry only.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
344 setTimeout("refreshDispatchCM("+ id +");", 50);
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
345 }
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
346
61
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
347 if (args != "")
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
348 sendPOSTRequest("action=add&type=entry&compo_id="+id+"&"+args, msuccess);
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
349 return false;
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
350 }
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
351
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
352
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353 function updateEntry(id)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 {
215
bfd480370a70 More work on input validation.
Matti Hamalainen <ccr@tnsp.org>
parents: 209
diff changeset
355 var args = makePostArgs({"name":1, "author":1, "filename":0, "info":0, "compo_id":2}, "en", id);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
357 var msuccess = function(txt)
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
358 {
223
532704115290 Make it possible to update news entries.
Matti Hamalainen <ccr@tnsp.org>
parents: 219
diff changeset
359 // Full update needed, because of possibly changed compo_id
256
ed8d8d016420 Add refreshCMEntry(id) function for updating one entry only.
Matti Hamalainen <ccr@tnsp.org>
parents: 255
diff changeset
360 setTimeout("refreshCMEntry("+ id +");", 50);
59
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
361 }
e5e38ed4e837 Work on compo entry addition and editing.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
362
61
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
363 if (args != "")
e85ed35585fc Work on attendee editing, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 59
diff changeset
364 sendPOSTRequest("action=update&type=entry&id="+id+"&"+args, msuccess);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
368 function deleteEntry(cid, id)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 {
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
370 deleteItem(id, "entry", "entries", "refreshDispatchCM("+ cid +");", "entry");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
375 function updateTabList(tabset, extra)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 {
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
377 var tabs = "";
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
378 var content = "";
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
379
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
380 for (var id in registeredTabs[tabset])
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 {
258
08b292dd12ff More work on entry admin.
Matti Hamalainen <ccr@tnsp.org>
parents: 256
diff changeset
382 var thead = registeredTabs[tabset][id];
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
383 tabs += "<a id=\"tabHead"+ tabset + id +
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
384 "\"href=\"#\" onClick=\"switchActiveTab('"+tabset+"', '"+id+
263
8c3922a65231 Work on entry admin looks.
Matti Hamalainen <ccr@tnsp.org>
parents: 260
diff changeset
385 "')\">"+ thead.replace(/\s/g, "&nbsp;") +"</a> ";
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
386
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
387 content += "<div id=\"tabCont"+ tabset + id +"\"></div>";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 }
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
389
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
390 var item = document.getElementById("tabHeaders"+ tabset);
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
391 if (item) item.innerHTML = tabs + extra;
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
392
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
393 item = document.getElementById("tabContents"+ tabset);
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
394 if (item) item.innerHTML = content;
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
398 function registerTab(tabset, id, name)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 {
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
400 if (!registeredTabs[tabset])
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
401 registeredTabs[tabset] = Object();
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
402
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
403 registeredTabs[tabset][id] = name;
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
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
407 function switchActiveTab(tabset, tab)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408 {
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
409 for (var id in registeredTabs[tabset])
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410 {
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
411 var tabContent = document.getElementById("tabCont"+ tabset + id);
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
412 var tabHead = document.getElementById("tabHead"+ tabset + id);
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
413 if (tabContent && tabHead)
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
414 {
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
415 tabContent.style.display = (tab == id) ? "block" : "none";
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
416 tabHead.style.borderTop = (tab == id) ? "4px solid white" : "none";
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
417 if (tab == id)
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
418 {
260
6a1f1f2f2141 Make tab selection in subtabs persistent.
Matti Hamalainen <ccr@tnsp.org>
parents: 259
diff changeset
419 activeTabs[tabset] = id;
253
bbe0d57d6ac9 Use a refresh function dispatcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
420 setTimeout("refreshDispatch"+ tabset +"('"+ id +"');", 10);
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
422 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
423 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
424 }
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
425 </script>
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
426
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
427 <!-- ========================== -->
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
428
5
76c3b89d7b11 Improve voting, clean up the code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
429 <div id="nstatus">-</div>
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
430 <div id="tabHeadersCC" class="tabHeaders"></div>
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
431 <div id="tabContentsCC" class="tabContents"></div>
171
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
432
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
433 <script type="text/javascript">
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
434 registerTab("CC", "Settings", "Settings");
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
435 registerTab("CC", "News", "News");
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
436 registerTab("CC", "Attendees", "Attendees");
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
437 registerTab("CC", "Voters", "Voters");
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
438 registerTab("CC", "Compos", "Compos");
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
439 registerTab("CC", "Entries", "Entries");
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
440 registerTab("CC", "Info", "Party Info");
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
441 updateTabList("CC",
263
8c3922a65231 Work on entry admin looks.
Matti Hamalainen <ccr@tnsp.org>
parents: 260
diff changeset
442 "<a class=\"admin\" href=\"admlogout.php\">Logout</a> " +
201
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
443 "<a class=\"admin\" href=\"about\">Mainpage</a>");
a4be19c4d99d Modularize admin pages tab system.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
444 switchActiveTab("CC", "Settings");
0
8019b357cc03 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445 </script>
171
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
446 <?
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
447 }
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
448
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
449 cmPrintPageFooter();
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
450
705dabdc37d4 Move administration interface page to separate layout, to make things less cramped.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
451 ?>