2 // Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
11 require_once("$srcdir/formdata.inc.php");
12 require_once("$srcdir/globals.inc.php");
14 // Check authorization.
15 $thisauth = acl_check('admin', 'super');
16 if (!$thisauth) die(xl('Not authorized'));
18 // If we are saving, then save.
20 if ($_POST['form_save']) {
23 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
24 foreach ($grparr as $fldid => $fldarr) {
25 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
26 sqlStatement("DELETE FROM globals WHERE gl_name = '$fldid'");
28 if (substr($fldtype, 0, 2) == 'm_') {
29 if (isset($_POST["form_$i"])) {
31 foreach ($_POST["form_$i"] as $fldvalue) {
32 $fldvalue = formDataCore($fldvalue, true);
33 sqlStatement("INSERT INTO globals ( gl_name, gl_index, gl_value ) " .
34 "VALUES ( '$fldid', '$fldindex', '$fldvalue' )");
40 if (isset($_POST["form_$i"])) {
41 $fldvalue = formData("form_$i", "P", true);
46 sqlStatement("INSERT INTO globals ( gl_name, gl_index, gl_value ) " .
47 "VALUES ( '$fldid', '0', '$fldvalue' )");
59 <?php
html_header_show();?
>
61 <!-- supporting javascript code
-->
62 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
63 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
64 <script type
="text/javascript" src
="../../library/js/common.js"></script
>
65 <script type
="text/javascript" src
="../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
66 <link rel
="stylesheet" type
="text/css" href
="../../library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
68 <link rel
="stylesheet" href
='<?php echo $css_header ?>' type
='text/css'>
69 <title
><?php
xl('Global Settings','e'); ?
></title
>
72 tr
.head
{ font
-size
:10pt
; background
-color
:#cccccc; text-align:center; }
73 tr
.detail
{ font
-size
:10pt
; }
74 td
{ font
-size
:10pt
; }
75 input
{ font
-size
:10pt
; }
78 <script language
="JavaScript">
80 $
(document
).ready(function(){
89 <body
class="body_top">
91 <form method
='post' name
='theform' id
='theform' action
='edit_globals.php' onsubmit
='return top.restoreSession()'>
93 <p
><b
><?php
xl('Edit Global Settings','e'); ?
></b
>
98 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
99 echo " <li" . ($i ?
"" : " class='current'") .
100 "><a href='/play/javascript-tabbed-navigation/'>" .
101 xl($grpname) . "</a></li>\n";
107 <div
class="tabContainer">
110 foreach ($GLOBALS_METADATA as $grpname => $grparr) {
111 echo " <div class='tab" . ($i ?
"" : " current") .
112 "' style='height:auto;width:97%;'>\n";
116 foreach ($grparr as $fldid => $fldarr) {
117 list($fldname, $fldtype, $flddef, $flddesc) = $fldarr;
119 // Most parameters will have a single value, but some will be arrays.
120 // Here we cater to both possibilities.
121 $glres = sqlStatement("SELECT gl_index, gl_value FROM globals WHERE " .
122 "gl_name = '$fldid' ORDER BY gl_index");
124 while ($glrow = sqlFetchArray($glres)) $glarr[] = $glrow;
126 // $fldvalue is meaningful only for the single-value cases.
127 $fldvalue = count($glarr) ?
$glarr[0]['gl_value'] : $flddef;
129 echo " <tr title='$flddesc'><td valign='top'><b>$fldname </b></td><td valign='top'>\n";
131 if (is_array($fldtype)) {
132 echo " <select name='form_$i'>\n";
133 foreach ($fldtype as $key => $value) {
134 echo " <option value='$key'";
135 if ($key == $fldvalue) echo " selected";
143 else if ($fldtype == 'bool') {
144 echo " <input type='checkbox' name='form_$i' value='1'";
145 if ($fldvalue) echo " checked";
149 else if ($fldtype == 'num') {
150 echo " <input type='text' name='form_$i' " .
151 "size='6' maxlength='15' value='$fldvalue' />\n";
154 else if ($fldtype == 'text') {
155 echo " <input type='text' name='form_$i' " .
156 "size='50' maxlength='255' value='$fldvalue' />\n";
159 else if ($fldtype == 'lang') {
160 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
161 echo " <select name='form_$i'>\n";
162 while ($row = sqlFetchArray($res)) {
163 echo " <option value='" . $row['lang_description'] . "'";
164 if ($row['lang_description'] == $fldvalue) echo " selected";
166 echo xl($row['lang_description']);
172 else if ($fldtype == 'm_lang') {
173 $res = sqlStatement("SELECT * FROM lang_languages ORDER BY lang_description");
174 echo " <select multiple name='form_{$i}[]' size='3'>\n";
175 while ($row = sqlFetchArray($res)) {
176 echo " <option value='" . $row['lang_description'] . "'";
177 foreach ($glarr as $glrow) {
178 if ($glrow['gl_value'] == $row['lang_description']) {
184 echo xl($row['lang_description']);
190 else if ($fldtype == 'css') {
191 $themedir = "$webserver_root/interface/themes";
192 $dh = opendir($themedir);
194 echo " <select name='form_$i'>\n";
195 while (false !== ($tfname = readdir($dh))) {
196 // Only show files that contain style_ as options
197 // Skip style_blue.css since this is used for
198 // lone scripts such as setup.php
199 if (!preg_match("/^style_.*\.css$/", $tfname) ||
$tfname == 'style_blue.css') { continue; }
200 echo "<option value='$tfname'";
201 if ($tfname == $fldvalue) echo " selected";
211 else if ($fldtype == 'hour') {
212 echo " <select name='form_$i'>\n";
213 for ($h = 0; $h < 24; ++
$h) {
214 echo "<option value='$h'";
215 if ($h == $fldvalue) echo " selected";
217 if ($h == 0) echo "12 AM";
218 else if ($h < 12) echo "$h AM";
219 else if ($h == 12) echo "12 PM";
220 else echo ($h - 12) . " PM";
226 echo " </td></tr>\n";
236 <input type
='submit' name
='form_save' value
='<?php xl('Save
','e
'); ?>' />