changed git call from https to git readonly
[atutor.git] / mods / scorm_packages / import.php
1 <?php
2 /*
3  * mods/scorm_packages/import.php
4  *
5  * This file is part of ATutor, see http://www.atutor.ca
6  * 
7  * Copyright (C) 2005  Matthai Kurian 
8  * 
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  * 
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  */
23
24 define('AT_INCLUDE_PATH', '../../include/');
25 require_once(AT_INCLUDE_PATH.'vitals.inc.php');
26
27 authenticate(AT_PRIV_PACKAGES);
28 define ('PACKAGE_TYPES', 'scorm-1.2');
29
30 if (isset ($_POST['type'])){
31         $_POST['type'] = $addslashes($_POST['type']);
32
33         if($_POST['type']!= PACKAGE_TYPES){
34                 $error = 'IMPORT_FAILED';
35         $msg->addError($error);
36         }
37         
38         if(!$msg->containsErrors()){
39                 if (isset ($_POST['type']) ) {
40                         require ($_POST['type'] . '/import.php');
41                 }
42         }
43 }
44 require(AT_INCLUDE_PATH.'header.inc.php');
45
46 $msg->printErrors();
47
48 ?>
49
50 <div class="input-form">
51         <fieldset class="group_form"><legend class="group_form"><?php echo _AT('import_package'); ?></legend>
52 <form name="form1" method="post"
53       action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data"
54       onsubmit="openWindow('<?php echo AT_BASE_HREF; ?>tools/prog.php');">
55
56         <?php echo _AT('package_type_info')?>
57         <div class="row">
58         <label for="type"><?php echo _AT('package_type')?></label>
59         <br />
60         <select name="type">
61
62         <?php
63         $ptypes = explode (',', PACKAGE_TYPES);
64         foreach ($ptypes as $type) {
65                 echo '<option value="' . $type . '">' . $type . '</option>';
66         }
67         ?>
68         </select>
69         </div>
70
71         <?php echo _AT('package_upload_file_info')?>
72         <div class="row">
73         <label for="to_file"><?php echo _AT('package_upload_file'); ?></label>
74         <br />
75         <input type="file" name="file" id="to_file" />
76         </div>
77
78         <?php echo _AT('package_upload_url_info')?>
79         <div class="row">
80         <label for="to_url">
81         <?php echo _AT('package_upload_url'); ?>
82         </label><br />
83         <input type="text" name="url" value="http://" size="40" id="to_url" />
84         </div>
85
86         <div class="row buttons">
87         <input type="submit" name="submit" onClick="setClickSource('submit');" value="<?php echo _AT('import'); ?>" />
88         <input type="submit" name="cancel" onClick="setClickSource('cancel');" value="<?php echo _AT('cancel'); ?>" />
89         </div>
90
91 </fieldset>
92 </form>
93 </div>
94 <script language="javascript" type="text/javascript">
95
96 var but_src;
97 function setClickSource(name) {
98         but_src = name;
99 }
100
101 function openWindow(page) {
102         if (but_src != "cancel") {
103                 newWindow = window.open(page, "progWin",
104                         "width=400,height=200,toolbar=no,location=no"
105                 );
106                 newWindow.focus();
107         }
108 }
109 </script>
110
111 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>