MDL-10109 Only creating new category when at least 2 grade_items (inc. outcome or...
[moodle-pu.git] / iplookup / ipatlas / ip-atlas_prefs.php
blob589ba98c66b22a16ab3ec247289957f54dfeec35
1 <?php
3 include("plotconf.inc");
4 include("plot.inc");
6 if (isset($HTTP_GET_VARS["lastquery"])){
7 $HTTP_GET_VARS["lastquery"] = clean_param($HTTP_GET_VARS["lastquery"], PARAM_HOST);
11 <?php
13 if(shouldrun($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
14 $drawmode = "GD";
15 } else {
16 $drawmode = "CSS";
19 if(isset($HTTP_POST_VARS["button"])) {
21 // cleanup post data
22 $HTTP_POST_VARS["shape"] = clean_param($HTTP_POST_VARS["shape"], PARAM_ALPHA);
23 $HTTP_POST_VARS["color"] = clean_param($HTTP_POST_VARS["color"], PARAM_ALPHA);
24 $HTTP_POST_VARS["color"] = clean_param($HTTP_POST_VARS["size"], PARAM_INT);
25 $HTTP_POST_VARS["earthimage"] = clean_param($HTTP_POST_VARS["earthimage"], PARAM_FILE);
26 $HTTP_POST_VARS["cssdot"] = clean_param($HTTP_POST_VARS["cssdot"], PARAM_FILE);
27 $HTTP_POST_VARS["seldrawmode"] = clean_param($HTTP_POST_VARS["seldrawmode"],PARAM_ALPHA);
28 // unset the earth image if we don't have it in our list
29 if (!in_array($HTTP_POST_VARS["earthimage"],$earthimages)) {
30 unset($HTTP_POST_VARS["earthimage"]);
34 // save data from the POST
35 setcookie ("atlasprefs", "", time() - 36000000);
36 setcookie ("atlasprefs", "$HTTP_POST_VARS[shape]:$HTTP_POST_VARS[color]:$HTTP_POST_VARS[size]:$HTTP_POST_VARS[earthimage]:$HTTP_POST_VARS[cssdot]:$HTTP_POST_VARS[seldrawmode]", time() + 36000000, $cookiepath);
38 $setshape = $HTTP_POST_VARS["shape"];
39 $setcolor = $HTTP_POST_VARS["color"];
40 $setsize = $HTTP_POST_VARS["size"];
41 $setearthimage = $HTTP_POST_VARS["earthimage"];
42 $setcssdot = $HTTP_POST_VARS["cssdot"];
43 $setseldrawmode = $HTTP_POST_VARS["seldrawmode"];
47 if($setseldrawmode == "1") {
48 $drawmode = "GD";
49 } else {
50 $drawmode = "CSS";
53 } elseif(isset($HTTP_COOKIE_VARS["atlasprefs"]) && validcookie($HTTP_COOKIE_VARS["atlasprefs"])) {
54 // get data from the cookie
55 @list($setshape, $setcolor, $setsize, $setearthimage, $setcssdot, $setseldrawmode) = split(":", $HTTP_COOKIE_VARS["atlasprefs"]);
56 } else {
57 $setshape = "Diamond";
58 $setsize = "3";
59 $setcolor = "red";
60 $setearthimage = $earthimages[$defaultimage];
61 $setcssdot = "reddot.gif";
63 if(shouldrun($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
64 $setseldrawmode = 1;
65 } else {
66 $setseldrawmode = 0;
69 // override old cookie if there is post data
71 if(isset($HTTP_POST_VARS["seldrawmode"])) {
72 $setsetdrawmode = $HTTP_POST_VARS["seldrawmode"];
79 <?php # START HTML
82 <html><head><title><?php echo t("IP-Atlas Preferences") ?></title>
84 <!-- your head tags here -->
85 <link rel="Stylesheet" href="ip-atlas.css">
86 </head><body bgcolor="#ffffff">
88 </head><body>
90 <b><?php echo t("IP-Atlas preferences"); ?></b> <?php echo t("(cookie based)"); ?><br /><br />
92 <?php
93 if(isset($HTTP_POST_VARS["button"])) {
94 print t("Your settings have been saved. You can now try"); ?> <a href="plot.php<?php if(isset($HTTP_GET_VARS["lastquery"])) { echo "?address=$HTTP_GET_VARS[lastquery]"; } ?>"><?php print t("plotting something.")."</a>"."<br /><br />";
100 <form action="ip-atlas_prefs.php<?php if(isset($HTTP_GET_VARS["lastquery"])) { echo "?lastquery=$HTTP_GET_VARS[lastquery]"; } ?>" method="POST">
102 <?php if(istheregd()) {
103 echo t("Draw mode (defaults guessed for your browser):");
105 print "<br /><select name=\"seldrawmode\">";
107 if(!isset($setseldrawmode)) {
108 if(shouldrun($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
109 $setseldrawmode = 1;
110 } else {
111 $setseldrawmode = 0;
115 if($setseldrawmode == "1") {
116 echo "<option value=\"1\" selected>GD";
117 echo "<option value=\"0\">CSS";
118 } elseif($setseldrawmode == "0") {
119 echo "<option value=\"1\">GD";
120 echo "<option value=\"0\" selected>CSS";
123 print "</select><br /><br />";
125 } else {
127 print "<input type=\"hidden\" name=\"seldrawmode\" value=\"0\" />";
133 <?php echo t("Pointer Preferences (the dot that marks lat/lon):"); ?><br />
134 <?php
135 if($drawmode == "GD") {
136 print '
137 <input type="hidden" name="cssdot" value="reddot.gif" />
139 <table><tr>
141 <td>'.t("Shape:").'</td><td><select name="shape">
144 $shapes = array("Diamond", "Diamond Outline", "Square", "Square Outline", "Cross");
145 foreach($shapes as $curshape) {
147 if($setshape == $curshape) {
148 print "<option value=\"$curshape\" selected>".t($curshape);
149 } else {
150 print "<option value=\"$curshape\">".t($curshape);
155 print "</select></td></tr><tr><td>".t("Size:")."</td><td><select name=\"size\">";
157 $sizes = array("2", "3", "4", "5", "6", "7", "8");
158 foreach($sizes as $cursize) {
160 if($setsize == $cursize) {
161 print "<option value=\"$cursize\" selected>$cursize";
162 } else {
163 print "<option value=\"$cursize\">$cursize";
168 print "</select></td></tr><tr><td>".t("Color:")."</td><td><select name=\"color\">";
170 $colors = array("red", "white", "yellow", "magenta", "cyan", "green", "violet");
171 foreach($colors as $curcolor) {
173 if($setcolor == $curcolor) {
174 print "<option value=\"$curcolor\" selected>".t($curcolor);
175 } else {
176 print "<option value=\"$curcolor\">".t($curcolor);
181 print "
182 </select></td></tr></table>
185 } elseif($drawmode == "CSS") {
187 print t("Pointer:")." <select name=\"cssdot\">";
189 foreach($cssdots as $curdot) {
191 list($filename, $curdot, , ) = split(":", $curdot);
193 if($setcssdot == $filename) {
194 print "<option value=\"$filename\" selected>$curdot";
195 } else {
196 print "<option value=\"$filename\">$curdot";
201 print "</select><br />";
203 print '
204 <input type="hidden" name="shape" value="Diamond" />
205 <input type="hidden" name="color" value="Red" />
206 <input type="hidden" name="size" value="3" />
213 <br />
217 <?php echo t("Other Preferences:") ?><br />
218 <?php echo t("Earth Image:") ?>&nbsp;
219 <select name="earthimage">
221 <?php
223 foreach($earthimages as $curentry) {
225 list($curfile, $curname, , ) = split(":", $curentry);
227 if($setearthimage == $curfile) {
228 print "<option value=\"$curfile\" selected>$curname";
229 } else {
230 print "<option value=\"$curfile\">$curname";
238 </select>
239 <br /><br />
240 <input type="Submit" name="button" value="<?php echo t("Save") ?>">
242 <div align="right">
243 [ <a href="plot.php<?php if(isset($HTTP_GET_VARS["lastquery"])) { echo "?address=$HTTP_GET_VARS[lastquery]"; } ?>"><?php echo t("main") ?></a> ]<br /><br />
244 </div>
245 <?php include("footer.inc"); ?>
246 </body></html>