Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / mod / resource / type / file / localfile.php
blobbf5232d7e80982f80de091d5b9ab384f845b28df
1 <?php // $Id$
3 require('../../../../config.php');
4 require('../../lib.php');
6 $choose = required_param('choose', PARAM_FILE);
8 require_login();
10 if (!$CFG->resource_allowlocalfiles) {
11 error('You cannot access this script');
14 print_header(get_string('localfilechoose', 'resource'));
16 print_simple_box(get_string('localfileinfo', 'resource'), 'center');
19 <script type="text/javascript">
20 //<![CDATA[
21 function set_value(txt) {
22 if (txt.indexOf('/') > -1) {
23 path = txt.substring(txt.indexOf('/'),txt.length);
24 } else if (txt.indexOf('\\') > -1) {
25 path = txt.substring(txt.indexOf('\\'),txt.length);
26 } else {
27 window.close();
29 opener.document.getElementById('<?php echo $choose ?>').value = '<?php p(RESOURCE_LOCALPATH) ?>'+path;
30 window.close();
32 //]]>
33 </script>
35 <br />
36 <div align="center" class="form">
37 <form id="myform">
38 <fieldset class="invisiblefieldset">
39 <input type="file" size="60" name="myfile" /><br />
40 <input type="button" value="<?php print_string('localfileselect','resource') ?>"
41 onClick="return set_value(getElementById('myform').myfile.value)">
42 <input type="button" value="<?php print_string('cancel') ?>"
43 onClick="window.close()">
44 </fieldset>
45 </form>
46 </div>
48 <?php
49 print_footer('empty');