Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

A few fixes for the dropdown menus.

  • Loading branch information...
commit 72184a52b8da2f1719e36c17a86339733fbbacdb 1 parent 82b7ceb
tomflannaghan authored

Showing 1 changed file with 260 additions and 256 deletions. Show diff stats Hide diff stats

  1. +260 256 mod/data/preset.php
516 mod/data/preset.php
@@ -105,257 +105,257 @@
105 105 echo "<center>";
106 106 switch ($action) {
107 107 /* Main selection menu - default mode also. */
108   - default:
109   - case 'base':
110   - $strimport = get_string('import');
111   - $strfromfile = get_string('fromfile', 'data');
112   - $strchooseorupload = get_string('chooseorupload', 'data');
113   - $strok = get_string('ok');
114   - $strusestandard = get_string('usestandard', 'data');
115   - $strchoose = get_string('choose');
116   - $strexport = get_string('export', 'data');
117   - $strexportaszip = get_string('exportaszip', 'data');
118   - $strsaveaspreset = get_string('saveaspreset', 'data');
119   - $strdelete = get_string('delete');
120   -
121   - echo "<table cellpadding=7>";
122   - echo "<tr><td><h3>$strimport</h3></td>";
123   - echo "<td><form name='form' method='POST' action='?d=$data->id&action=importzip&sesskey=$sesskey' enctype='multipart/form-data'>";
124   - helpbutton('importfromfile', '', 'data');
125   - echo " $strfromfile:</td><td><input name=\"file\" size=\"20\" value=\"\" alt=\"file\" type=\"text\"><input name=\"coursefiles\" title=\"Choose or upload a file\" value=\"$strchooseorupload\" onclick=\"return openpopup('/files/index.php?id=2&choose=form.file', 'coursefiles', 'menubar=0,location=0,scrollbars,resizable,width=750,height=500', 0);\" type=\"button\">";
126   - echo "<input type=\"submit\" value=\"$strok\"/>";
127   - echo "</form></td></tr>";
128   -
129   - echo "<tr valign=top><td></td><td>";
130   - helpbutton('usepreset', '', 'data');
131   - echo " $strusestandard: </td><td>";
132   - echo "<table width=100%>";
133   - foreach ($presets as $id => $preset) {
134   - echo "<tr><form action='' method='POST'>";
135   - echo "<input type='hidden' name='file' value=\"$preset->path\">";
136   - echo "<input type='hidden' name='action' value='beginimport'>";
137   - echo "<input type='hidden' name='d' value='$data->id'>";
138   - echo "<input type='hidden' name='sesskey' value='$sesskey'>";
139   - echo "<td>";
140   - if ($preset->screenshot) {
141   - echo "<img src='$preset->screenshot' alt='$preset->screenshot' />";
142   - }
143   - echo "</td><td>$preset->name";
144   - if ($preset->user) {
145   - $user = get_record('user', 'id', $preset->user);
146   - echo " by $user->firstname $user->lastname";
147   - }
148   - echo "</td><td><input type='submit' value='$strchoose'></td></form>";
149   - echo "<td>";
150   - if ($preset->user == $USER->id || isadmin()) {
151   - echo "<form action='' method='POST'>";
152   - echo "<input type='hidden' name='d' value='$data->id' />";
153   - echo "<input type='hidden' name='action' value='confirmdelete' />";
154   - echo "<input type='hidden' name='sesskey' value='$sesskey' />";
155   - echo "<input type='hidden' name='deleteid' value='$id' />";
156   - echo "<input type='hidden' name='deletename' value=\"$preset->name\" />";
157   - echo "<input type='submit' value='$strdelete' /></form>";
158   - }
159   - echo "</td></tr>";
160   - }
161   - echo "</table></td></tr>";
162   -
163   - echo "<tr><td valign=top><h3>$strexport</h3></td>";
164   - echo "<td><form action='' method='POST'>";
165   - helpbutton('exportzip', '', 'data');
166   - echo " <input type='hidden' name='action' value='export' />";
167   - echo "<input type='hidden' name='d' value='$data->id' />";
168   - echo "<input type='submit' value='$strexportaszip' />";
169   - echo "</form>";
170   -
171   - echo "<form action='' method='POST'>";
172   - helpbutton('savepreset', '', 'data');
173   - echo " <input type='hidden' name='action' value='save1' />";
174   - echo "<input type='hidden' name='d' value='$data->id' />";
175   - echo "<input type='hidden' name='sesskey' value='$sesskey' />";
176   - echo "<input type='submit' value='$strsaveaspreset' />";
177   - echo "</form>";
178   -
179   - echo "</table>";
180   - break;
181   -
  108 + default:
  109 + case 'base':
  110 + $strimport = get_string('import');
  111 + $strfromfile = get_string('fromfile', 'data');
  112 + $strchooseorupload = get_string('chooseorupload', 'data');
  113 + $strok = get_string('ok');
  114 + $strusestandard = get_string('usestandard', 'data');
  115 + $strchoose = get_string('choose');
  116 + $strexport = get_string('export', 'data');
  117 + $strexportaszip = get_string('exportaszip', 'data');
  118 + $strsaveaspreset = get_string('saveaspreset', 'data');
  119 + $strdelete = get_string('delete');
  120 +
  121 + echo "<table cellpadding=7>";
  122 + echo "<tr><td><h3>$strimport</h3></td>";
  123 + echo "<td><form name='form' method='POST' action='?d=$data->id&action=importzip&sesskey=$sesskey' enctype='multipart/form-data'>";
  124 + helpbutton('importfromfile', '', 'data');
  125 + echo " $strfromfile:</td><td><input name=\"file\" size=\"20\" value=\"\" alt=\"file\" type=\"text\"><input name=\"coursefiles\" title=\"Choose or upload a file\" value=\"$strchooseorupload\" onclick=\"return openpopup('/files/index.php?id=2&choose=form.file', 'coursefiles', 'menubar=0,location=0,scrollbars,resizable,width=750,height=500', 0);\" type=\"button\">";
  126 + echo "<input type=\"submit\" value=\"$strok\"/>";
  127 + echo "</form></td></tr>";
  128 +
  129 + echo "<tr valign=top><td></td><td>";
  130 + helpbutton('usepreset', '', 'data');
  131 + echo " $strusestandard: </td><td>";
  132 + echo "<table width=100%>";
  133 + foreach ($presets as $id => $preset) {
  134 + echo "<tr><form action='' method='POST'>";
  135 + echo "<input type='hidden' name='file' value=\"$preset->path\">";
  136 + echo "<input type='hidden' name='action' value='beginimport'>";
  137 + echo "<input type='hidden' name='d' value='$data->id'>";
  138 + echo "<input type='hidden' name='sesskey' value='$sesskey'>";
  139 + echo "<td>";
  140 + if ($preset->screenshot) {
  141 + echo "<img src='$preset->screenshot' alt='$preset->screenshot' />";
  142 + }
  143 + echo "</td><td>$preset->name";
  144 + if ($preset->user) {
  145 + $user = get_record('user', 'id', $preset->user);
  146 + echo " by $user->firstname $user->lastname";
  147 + }
  148 + echo "</td><td><input type='submit' value='$strchoose'></td></form>";
  149 + echo "<td>";
  150 + if ($preset->user == $USER->id || isadmin()) {
  151 + echo "<form action='' method='POST'>";
  152 + echo "<input type='hidden' name='d' value='$data->id' />";
  153 + echo "<input type='hidden' name='action' value='confirmdelete' />";
  154 + echo "<input type='hidden' name='sesskey' value='$sesskey' />";
  155 + echo "<input type='hidden' name='deleteid' value='$id' />";
  156 + echo "<input type='hidden' name='deletename' value=\"$preset->name\" />";
  157 + echo "<input type='submit' value='$strdelete' /></form>";
  158 + }
  159 + echo "</td></tr>";
  160 + }
  161 + echo "</table></td></tr>";
182 162
  163 + echo "<tr><td valign=top><h3>$strexport</h3></td>";
  164 + echo "<td><form action='' method='POST'>";
  165 + helpbutton('exportzip', '', 'data');
  166 + echo " <input type='hidden' name='action' value='export' />";
  167 + echo "<input type='hidden' name='d' value='$data->id' />";
  168 + echo "<input type='submit' value='$strexportaszip' />";
  169 + echo "</form>";
183 170
184   - /***************** Deleting *****************/
185   - case 'confirmdelete' :
186   - if (!confirm_sesskey()) {
187   - error("Sesskey Invalid");
188   - }
  171 + echo "<form action='' method='POST'>";
  172 + helpbutton('savepreset', '', 'data');
  173 + echo " <input type='hidden' name='action' value='save1' />";
  174 + echo "<input type='hidden' name='d' value='$data->id' />";
  175 + echo "<input type='hidden' name='sesskey' value='$sesskey' />";
  176 + echo "<input type='submit' value='$strsaveaspreset' />";
  177 + echo "</form>";
189 178
190   - $deletename = required_param('deletename', PARAM_RAW);
191   - $deleteid = required_param('deleteid', PARAM_INT);
  179 + echo "</table>";
  180 + break;
192 181
193   - $strwarning = get_string('deletewarning', 'data');
194   - $strdelete = get_string('delete');
195   - notify($strwarning);
196   - echo "<form action='' method='POST'>";
197   - echo "<input type='hidden' name='d' value='$data->id' />";
198   - echo "<input type='hidden' name='action' value='delete' />";
199   - echo "<input type='hidden' name='sesskey' value='$sesskey' />";
200   - echo "<input type='hidden' name='deleteid' value='$deleteid' />";
201   - echo "<input type='hidden' name='deletename' value=\"$deletename\" />";
202   - echo "<input type='submit' value='$strdelete' /></form>";
203   - break;
204 182
205   - case 'delete' :
206   - if (!confirm_sesskey()) {
207   - error('Sesskey Invalid');
208   - }
209 183
210   - $deletename = required_param('deletename', PARAM_RAW);
211   - $deleteid = required_param('deleteid', PARAM_INT);
  184 + /***************** Deleting *****************/
  185 + case 'confirmdelete' :
  186 + if (!confirm_sesskey()) {
  187 + error("Sesskey Invalid");
  188 + }
212 189
213   - if (!empty($presets[$deleteid])) {
214   - if ($presets[$deleteid]->name == $deletename) {
215   - if (!clean_preset($CFG->dirroot.$presets[$deleteid]->path)) error("Error deleting");
216   - }
217   - rmdir($CFG->dirroot.$presets[$deleteid]->path);
218   - }
219   - else {
220   - error('Invalid delete');
221   - }
  190 + $deletename = required_param('deletename', PARAM_RAW);
  191 + $deleteid = required_param('deleteid', PARAM_INT);
  192 +
  193 + $strwarning = get_string('deletewarning', 'data');
  194 + $strdelete = get_string('delete');
  195 + notify($strwarning);
  196 + echo "<form action='' method='POST'>";
  197 + echo "<input type='hidden' name='d' value='$data->id' />";
  198 + echo "<input type='hidden' name='action' value='delete' />";
  199 + echo "<input type='hidden' name='sesskey' value='$sesskey' />";
  200 + echo "<input type='hidden' name='deleteid' value='$deleteid' />";
  201 + echo "<input type='hidden' name='deletename' value=\"$deletename\" />";
  202 + echo "<input type='submit' value='$strdelete' /></form>";
  203 + break;
  204 +
  205 + case 'delete' :
  206 + if (!confirm_sesskey()) {
  207 + error('Sesskey Invalid');
  208 + }
222 209
223   - $strdelete = get_string('deleted', 'data');
224   - notify("$deletename $strdeleted");
  210 + $deletename = required_param('deletename', PARAM_RAW);
  211 + $deleteid = required_param('deleteid', PARAM_INT);
225 212
226   - break;
  213 + if (!empty($presets[$deleteid])) {
  214 + if ($presets[$deleteid]->name == $deletename) {
  215 + if (!clean_preset($CFG->dirroot.$presets[$deleteid]->path)) error("Error deleting");
  216 + }
  217 + rmdir($CFG->dirroot.$presets[$deleteid]->path);
  218 + }
  219 + else {
  220 + error('Invalid delete');
  221 + }
227 222
  223 + $strdelete = get_string('deleted', 'data');
  224 + notify("$deletename $strdeleted");
228 225
  226 + break;
229 227
230   - /***************** Importing *****************/
231   - case 'beginimport' :
232   - if (!confirm_sesskey()) {
233   - error("Sesskey Invalid");
234   - }
235 228
236   - $pimporter = new PresetImporter($course, $cm, $data, $file);
237   - $pimporter->import_options();
238   - break;
239 229
240   - /* Imports a zip file. */
241   - case 'importzip' :
242   - if (!confirm_sesskey()) {
243   - error("Sesskey Invalid");
244   - }
  230 + /***************** Importing *****************/
  231 + case 'beginimport' :
  232 + if (!confirm_sesskey()) {
  233 + error("Sesskey Invalid");
  234 + }
245 235
246   - if (!unzip_file($CFG->dataroot."/$course->id/$file", $CFG->dataroot."/temp/data/".$USER->id, false))
247   - error("Can't unzip file");
248   - $presetfile = $CFG->dataroot."/temp/data/".$USER->id;
  236 + $pimporter = new PresetImporter($course, $cm, $data, $file);
  237 + $pimporter->import_options();
  238 + break;
249 239
250   - $pimporter = new PresetImporter($course, $cm, $data, $presetfile);
251   - $pimporter->import_options();
252   - break;
  240 + /* Imports a zip file. */
  241 + case 'importzip' :
  242 + if (!confirm_sesskey()) {
  243 + error("Sesskey Invalid");
  244 + }
253 245
254   - case 'finishimport':
255   - if (!confirm_sesskey()) {
256   - error('Sesskey Invalid');
257   - }
  246 + if (!unzip_file($CFG->dataroot."/$course->id/$file", $CFG->dataroot."/temp/data/".$USER->id, false))
  247 + error("Can't unzip file");
  248 + $presetfile = $CFG->dataroot."/temp/data/".$USER->id;
258 249
259   - $pimporter = new PresetImporter($course, $cm, $data, $file);
260   - $pimporter->import();
  250 + $pimporter = new PresetImporter($course, $cm, $data, $presetfile);
  251 + $pimporter->import_options();
  252 + break;
261 253
262   - $strimportsuccess = get_string('importsuccess', 'data');
263   - $straddentries = get_string('addentries', 'data');
264   - $strtodatabase = get_string('todatabase', 'data');
265   - if (!get_records('data_records', 'dataid', $data->id)) {
266   - notify("$strimportsuccess <a href='edit.php?d=$data->id'>$straddentries</a> $strtodatabase", 'notifysuccess');
267   - }
268   - else {
269   - notify("$strimportsuccess", 'notifysuccess');
270   - }
271   - break;
  254 + case 'finishimport':
  255 + if (!confirm_sesskey()) {
  256 + error('Sesskey Invalid');
  257 + }
272 258
273   - /* Exports as a zip file ready for download. */
274   - case 'export':
275   - $file = data_presets_export($course, $cm, $data);
276   - echo get_string('exportedtozip', 'data')."<br>";
277   - $perminantfile = $CFG->dataroot."/$course->id/moddata/data/$data->id/preset.zip";
278   - @unlink($perminantfile);
279   - /* is this created elsewhere? sometimes its not present... */
280   - make_upload_directory("$course->id/moddata/data/$data->id");
  259 + $pimporter = new PresetImporter($course, $cm, $data, $file);
  260 + $pimporter->import();
281 261
282   - /* now just move the zip into this folder to allow a nice download */
283   - if (!rename($file, $perminantfile)) error("Can't move zip");
284   - echo "<a href='$CFG->wwwroot/file.php/$course->id/moddata/data/$data->id/preset.zip'>".get_string('download', 'data')."</a>";
285   - break;
  262 + $strimportsuccess = get_string('importsuccess', 'data');
  263 + $straddentries = get_string('addentries', 'data');
  264 + $strtodatabase = get_string('todatabase', 'data');
  265 + if (!get_records('data_records', 'dataid', $data->id)) {
  266 + notify("$strimportsuccess <a href='edit.php?d=$data->id'>$straddentries</a> $strtodatabase", 'notifysuccess');
  267 + }
  268 + else {
  269 + notify("$strimportsuccess", 'notifysuccess');
  270 + }
  271 + break;
286 272
  273 + /* Exports as a zip file ready for download. */
  274 + case 'export':
  275 + $file = data_presets_export($course, $cm, $data);
  276 + echo get_string('exportedtozip', 'data')."<br>";
  277 + $perminantfile = $CFG->dataroot."/$course->id/moddata/data/$data->id/preset.zip";
  278 + @unlink($perminantfile);
  279 + /* is this created elsewhere? sometimes its not present... */
  280 + make_upload_directory("$course->id/moddata/data/$data->id");
287 281
  282 + /* now just move the zip into this folder to allow a nice download */
  283 + if (!rename($file, $perminantfile)) error("Can't move zip");
  284 + echo "<a href='$CFG->wwwroot/file.php/$course->id/moddata/data/$data->id/preset.zip'>".get_string('download', 'data')."</a>";
  285 + break;
288 286
289   - /***************** Exporting *****************/
290   - case 'save1':
291   - if (!confirm_sesskey()) {
292   - error("Sesskey Invalid");
293   - }
294 287
295   - $strcontinue = get_string('continue');
296   - $strwarning = get_string('presetwarning', 'data');
297 288
298   - echo "<div align=center>";
299   - echo "<p>$strwarning</p>";
300   - echo "<form action='' method='POST'>";
301   - echo "Name: <input type='textbox' name='name' value=\"$data->name\" />";
302   - echo "<input type='hidden' name='action' value='save2' />";
303   - echo "<input type='hidden' name='d' value='$data->id' />";
304   - echo "<input type='hidden' name='sesskey' value='$sesskey' />";
305   - echo "<input type='submit' value='$strcontinue' /></form></div>";
306   - break;
  289 + /***************** Exporting *****************/
  290 + case 'save1':
  291 + if (!confirm_sesskey()) {
  292 + error("Sesskey Invalid");
  293 + }
307 294
308   - case 'save2':
309   - if (!confirm_sesskey()) {
310   - error("Sesskey Invalid");
311   - }
  295 + $strcontinue = get_string('continue');
  296 + $strwarning = get_string('presetwarning', 'data');
  297 +
  298 + echo "<div align=center>";
  299 + echo "<p>$strwarning</p>";
  300 + echo "<form action='' method='POST'>";
  301 + echo "Name: <input type='textbox' name='name' value=\"$data->name\" />";
  302 + echo "<input type='hidden' name='action' value='save2' />";
  303 + echo "<input type='hidden' name='d' value='$data->id' />";
  304 + echo "<input type='hidden' name='sesskey' value='$sesskey' />";
  305 + echo "<input type='submit' value='$strcontinue' /></form></div>";
  306 + break;
  307 +
  308 + case 'save2':
  309 + if (!confirm_sesskey()) {
  310 + error("Sesskey Invalid");
  311 + }
312 312
313   - $strcontinue = get_string('continue');
314   - $stroverwrite = get_string('overwrite');
315   -
316   - $name = optional_param('name', $data->name, PARAM_FILE);
317   -
318   - if (is_directory_a_preset("$CFG->dirroot/mod/data/preset/$USER->id/$name")) {
319   - notify("Preset already exists: Pick another name or overwrite");
320   -
321   - echo "<div align=center>";
322   - echo "<form action='' method='POST'>";
323   - echo "New name: <input type='textbox' name='name' value=\"$name\" />";
324   - echo "<input type='hidden' name='action' value='save2' />";
325   - echo "<input type='hidden' name='d' value='$data->id' />";
326   - echo "<input type='hidden' name='sesskey' value='$sesskey' />";
327   - echo "<input type='submit' value='$strcontinue' /></form>";
328   -
329   - echo "<form action='' method='POST'>";
330   - echo "<input type='hidden' name='name' value=\"$name\" />";
331   - echo "<input type='hidden' name='action' value='save3' />";
332   - echo "<input type='hidden' name='d' value='$data->id' />";
333   - echo "<input type='hidden' name='sesskey' value='$sesskey' />";
334   - echo "<input type='submit' value='$stroverwrite' /></form>";
335   - echo "</div>";
336   - break;
337   - }
  313 + $strcontinue = get_string('continue');
  314 + $stroverwrite = get_string('overwrite');
  315 +
  316 + $name = optional_param('name', $data->name, PARAM_FILE);
  317 +
  318 + if (is_directory_a_preset("$CFG->dirroot/mod/data/preset/$USER->id/$name")) {
  319 + notify("Preset already exists: Pick another name or overwrite");
  320 +
  321 + echo "<div align=center>";
  322 + echo "<form action='' method='POST'>";
  323 + echo "New name: <input type='textbox' name='name' value=\"$name\" />";
  324 + echo "<input type='hidden' name='action' value='save2' />";
  325 + echo "<input type='hidden' name='d' value='$data->id' />";
  326 + echo "<input type='hidden' name='sesskey' value='$sesskey' />";
  327 + echo "<input type='submit' value='$strcontinue' /></form>";
  328 +
  329 + echo "<form action='' method='POST'>";
  330 + echo "<input type='hidden' name='name' value=\"$name\" />";
  331 + echo "<input type='hidden' name='action' value='save3' />";
  332 + echo "<input type='hidden' name='d' value='$data->id' />";
  333 + echo "<input type='hidden' name='sesskey' value='$sesskey' />";
  334 + echo "<input type='submit' value='$stroverwrite' /></form>";
  335 + echo "</div>";
  336 + break;
  337 + }
338 338
339   - case 'save3':
340   - if (!confirm_sesskey()) {
341   - error("Sesskey Invalid");
342   - }
  339 + case 'save3':
  340 + if (!confirm_sesskey()) {
  341 + error("Sesskey Invalid");
  342 + }
343 343
344   - $name = optional_param('name', $data->name, PARAM_FILE);
345   - $presetdirectory = "$CFG->dirroot/mod/data/preset/$USER->id/$name";
  344 + $name = optional_param('name', $data->name, PARAM_FILE);
  345 + $presetdirectory = "$CFG->dirroot/mod/data/preset/$USER->id/$name";
346 346
347   - if (!is_dir($presetdirectory)) {
348   - @mkdir("$CFG->dirroot/mod/data/preset/$USER->id");
349   - mkdir($presetdirectory);
350   - }
351   - else {
352   - clean_preset($presetdirectory);
353   - }
  347 + if (!is_dir($presetdirectory)) {
  348 + @mkdir("$CFG->dirroot/mod/data/preset/$USER->id");
  349 + mkdir($presetdirectory);
  350 + }
  351 + else {
  352 + clean_preset($presetdirectory);
  353 + }
354 354
355   - $file = data_presets_export($course, $cm, $data);
356   - if (!unzip_file($file, $presetdirectory, false)) error("Can't unzip to the preset directory");
357   - notify(get_string('savesuccess', 'data'), 'notifysuccess');
358   - break;
  355 + $file = data_presets_export($course, $cm, $data);
  356 + if (!unzip_file($file, $presetdirectory, false)) error("Can't unzip to the preset directory");
  357 + notify(get_string('savesuccess', 'data'), 'notifysuccess');
  358 + break;
359 359
360 360 }
361 361 echo "</center>";
@@ -365,14 +365,14 @@
365 365 function is_directory_a_preset($directory) {
366 366 $directory = rtrim($directory, '/\\') . '/';
367 367 if (file_exists($directory.'singletemplate.html') &&
368   - file_exists($directory.'listtemplate.html') &&
369   - file_exists($directory.'listtemplateheader.html') &&
370   - file_exists($directory.'listtemplatefooter.html') &&
371   - file_exists($directory.'addtemplate.html') &&
372   - file_exists($directory.'rsstemplate.html') &&
373   - file_exists($directory.'rsstitletemplate.html') &&
374   - file_exists($directory.'csstemplate.css') &&
375   - file_exists($directory.'preset.xml')) return true;
  368 + file_exists($directory.'listtemplate.html') &&
  369 + file_exists($directory.'listtemplateheader.html') &&
  370 + file_exists($directory.'listtemplatefooter.html') &&
  371 + file_exists($directory.'addtemplate.html') &&
  372 + file_exists($directory.'rsstemplate.html') &&
  373 + file_exists($directory.'rsstitletemplate.html') &&
  374 + file_exists($directory.'csstemplate.css') &&
  375 + file_exists($directory.'preset.xml')) return true;
376 376 else return false;
377 377 }
378 378
@@ -383,7 +383,7 @@ function data_presets_print_header($course, $cm, $data, $showtabs=true) {
383 383 $strdata = get_string('modulenameplural','data');
384 384
385 385 print_header_simple($data->name, '', "<a href='index.php?id=$course->id'>$strdata</a> -> $data->name",
386   - '', '', true, '', navmenu($course, $cm));
  386 + '', '', true, '', navmenu($course, $cm));
387 387
388 388 print_heading(format_string($data->name));
389 389
@@ -406,14 +406,14 @@ function data_presets_print_header($course, $cm, $data, $showtabs=true) {
406 406
407 407 function clean_preset($folder) {
408 408 if (unlink($folder.'/singletemplate.html') &&
409   - unlink($folder.'/listtemplate.html') &&
410   - unlink($folder.'/listtemplateheader.html') &&
411   - unlink($folder.'/listtemplatefooter.html') &&
412   - unlink($folder.'/addtemplate.html') &&
413   - unlink($folder.'/rsstemplate.html') &&
414   - unlink($folder.'/rsstitletemplate.html') &&
415   - unlink($folder.'/csstemplate.css') &&
416   - unlink($folder.'/preset.xml')) return true;
  409 + unlink($folder.'/listtemplate.html') &&
  410 + unlink($folder.'/listtemplateheader.html') &&
  411 + unlink($folder.'/listtemplatefooter.html') &&
  412 + unlink($folder.'/addtemplate.html') &&
  413 + unlink($folder.'/rsstemplate.html') &&
  414 + unlink($folder.'/rsstitletemplate.html') &&
  415 + unlink($folder.'/csstemplate.css') &&
  416 + unlink($folder.'/preset.xml')) return true;
417 417 else return false;
418 418 }
419 419
@@ -454,27 +454,29 @@ function data_presets_export($course, $cm, $data) {
454 454 $presetfile = fopen($tempfolder.'/preset.xml', 'w');
455 455 $presetxml = "<preset>\n\n";
456 456
457   - /* Database settings first. Name not included? */
458   - $settingssaved = array('intro', 'comments', 'ratings', 'participants',
459   - 'requiredentries', 'requiredentriestoview', 'maxentries',
460   - 'rssarticles', 'approval', 'scale', 'assessed', 'assessedpublic',
461   - 'defaultsort', 'defaultsortdir', 'editany');
  457 + /* Database settings first. Name not included? */
  458 + $settingssaved = array('intro', 'comments', 'ratings', 'participants',
  459 + 'requiredentries', 'requiredentriestoview', 'maxentries',
  460 + 'rssarticles', 'approval', 'scale', 'assessed', 'assessedpublic',
  461 + 'defaultsort', 'defaultsortdir', 'editany');
462 462
463   - $presetxml .= "<settings>\n";
464   - foreach ($settingssaved as $setting) {
465   - $presetxml .= "<$setting>{$data->$setting}</$setting>\n";
466   - }
467   - $presetxml .= "</settings>\n\n";
  463 + $presetxml .= "<settings>\n";
  464 + foreach ($settingssaved as $setting) {
  465 + $presetxml .= "<$setting>{$data->$setting}</$setting>\n";
  466 + }
  467 + $presetxml .= "</settings>\n\n";
468 468
469 469 /* Now for the fields. Grabs all settings that are non-empty */
470   - foreach ($fields as $field) {
471   - $presetxml .= "<field>\n";
472   - foreach ($field as $key => $value) {
473   - if ($value != '' && $key != 'id' && $key != 'dataid') {
474   - $presetxml .= "<$key>$value</$key>\n";
475   - }
476   - }
477   - $presetxml .= "</field>\n\n";
  470 + if (!empty($fields)) {
  471 + foreach ($fields as $field) {
  472 + $presetxml .= "<field>\n";
  473 + foreach ($field as $key => $value) {
  474 + if ($value != '' && $key != 'id' && $key != 'dataid') {
  475 + $presetxml .= "<$key>$value</$key>\n";
  476 + }
  477 + }
  478 + $presetxml .= "</field>\n\n";
  479 + }
478 480 }
479 481
480 482 $presetxml .= "</preset>";
@@ -637,8 +639,10 @@ function import_options() {
637 639 echo "<option value='$cid' selected='true'>$currentfield->name</option>";
638 640 $selected=true;
639 641 }
640   - echo "<option value='$cid'>$currentfield->name</option>";
641   - }
  642 + else {
  643 + echo "<option value='$cid'>$currentfield->name</option>";
  644 + }
  645 + }
642 646 }
643 647
644 648 if ($selected)

0 comments on commit 72184a5

Please sign in to comment.
Something went wrong with that request. Please try again.