2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
13 define('TR_INCLUDE_PATH', '../include/');
14 require(TR_INCLUDE_PATH.'vitals.inc.php');
15 require(TR_INCLUDE_PATH.'classes/FileUtility.class.php');
18 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
20 $current_path = TR_CONTENT_DIR.$_course_id.'/';
22 $popup = $_REQUEST['popup'];
23 $framed = $_REQUEST['framed'];
25 if (isset($_POST['submit_no'])) {
26 $msg->addFeedback('CANCELLED');
27 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup'].SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
31 if (isset($_POST['cancel'])) {
32 $msg->addFeedback('CANCELLED');
33 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_REQUEST['framed'].SEP.'popup='.$_REQUEST['popup'].SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
37 if (isset($_POST['submit_yes'])) {
38 $dest = $_POST['dest'] .'/';
39 $pathext = $_POST['pathext'];
41 if (isset($_POST['listofdirs'])) {
43 $_dirs = explode(',',$_POST['listofdirs']);
44 $count = count($_dirs);
46 for ($i = 0; $i < $count; $i++) {
49 if (FileUtility::course_realpath($current_path . $pathext . $source) == FALSE) {
50 // error: File does not exist
51 $msg->addError('DIR_NOT_EXIST');
52 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
55 else if (FileUtility::course_realpath($current_path . $dest) == FALSE) {
56 // error: File does not exist
57 $msg->addError('UNKNOWN');
58 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
61 else if (strpos($source, '..') !== false) {
62 $msg->addError('UNKNOWN');
63 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
67 @rename($current_path.$pathext.$source, $current_path.$dest.$source);
70 $msg->addFeedback('DIRS_MOVED');
72 if (isset($_POST['listoffiles'])) {
74 $_files = explode(',',$_POST['listoffiles']);
75 $count = count($_files);
77 for ($i = 0; $i < $count; $i++) {
78 $source = $_files[$i];
80 if (FileUtility::course_realpath($current_path . $pathext . $source) == FALSE) {
81 // error: File does not exist
82 $msg->addError('FILE_NOT_EXIST');
83 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
86 else if (FileUtility::course_realpath($current_path . $dest) == FALSE) {
87 // error: File does not exist
88 $msg->addError('UNKNOWN');
89 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
92 else if (strpos($source, '..') !== false) {
93 $msg->addError('UNKNOWN');
94 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup.SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
98 @rename($current_path.$pathext.$source, $current_path.$dest.$source);
101 $msg->addFeedback('MOVED_FILES');
103 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup'].SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type'].SEP.'_course_id='.$_course_id);
107 if (isset($_POST['dir_chosen'])) {
108 $hidden_vars['framed'] = $_REQUEST['framed'];
109 $hidden_vars['popup'] = $_REQUEST['popup'];
110 $hidden_vars['pathext'] = $_REQUEST['pathext'];
111 $hidden_vars['dest'] = $_REQUEST['dir_name'];
112 $hidden_vars['cp'] = $_REQUEST['cp'];
113 $hidden_vars['cid'] = $_REQUEST['cid'];
114 $hidden_vars['pid'] = $_REQUEST['pid'];
115 $hidden_vars['a_type'] = $_REQUEST['a_type'];
116 $hidden_vars['_course_id'] = $_course_id;
118 if (isset($_POST['files'])) {
119 $list_of_files = implode(',', $_POST['files']);
120 $hidden_vars['listoffiles'] = $list_of_files;
121 $msg->addConfirm(array('FILE_MOVE', $list_of_files, $_POST['dir_name']), $hidden_vars);
123 if (isset($_POST['dirs'])) {
124 $list_of_dirs = implode(',', $_POST['dirs']);
125 $hidden_vars['listoffiles'] = $list_of_dirs;
126 $msg->addConfirm(array('DIR_MOVE', $list_of_dirs, $_POST['dir_name']), $hidden_vars);
128 require(TR_INCLUDE_PATH.'header.inc.php');
129 $msg->printConfirm();
130 require(TR_INCLUDE_PATH.'footer.inc.php');
133 require(TR_INCLUDE_PATH.'header.inc.php');
135 $tree = TR_CONTENT_DIR.$_course_id.'/';
136 $file = $_GET['file'];
137 $pathext = $_GET['pathext'];
138 $popup = $_GET['popup'];
139 $framed = $_GET['framed'];
143 $a_type = $_GET['a_type'];
145 /* find the files and directories to be copied */
146 $total_list = explode(',', $_GET['list']);
148 $count = count($total_list);
151 for ($i=0; $i<$count; $i++) {
152 if (is_dir($current_path.$pathext.$total_list[$i])) {
153 $_dirs[$countd] = $total_list[$i];
154 $hidden_dirs .= '<input type="hidden" name="dirs['.$countd.']" value="'.$_dirs[$countd].'" />';
157 $_files[$countf] = $total_list[$i];
158 $hidden_files .= '<input type="hidden" name="files['.$countf.']" value="'.$_files[$countf].'" />';
164 <form name="move_form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
165 <div class="input-form">
167 <p><?php echo _AT('select_directory'); ?></p>
172 <li class="folders"><label><input type="radio" name="dir_name" value=""<?php
173 if ($pathext == '') {
174 echo ' checked="checked"';
175 $here = ' ' . _AT('current_location');
177 echo '/>Home ' .$here.'</label>';
179 echo FileUtility::display_tree($current_path, '', $pathext);
184 <div class="row buttons">
185 <input type="submit" name="dir_chosen" value="<?php echo _AT('move'); ?>" accesskey="s" />
186 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
190 <input type="hidden" name="pathext" value="<?php echo AT_print($pathext, 'input.hidden'); ?>" />
191 <input type="hidden" name="framed" value="<?php echo AT_print($framed, 'input.hidden'); ?>" />
192 <input type="hidden" name="popup" value="<?php echo AT_print($popup, 'input.hidden'); ?>" />
193 <input type="hidden" name="cp" value="<?php echo AT_print($cp, 'input.hidden'); ?>" />
194 <input type="hidden" name="cid" value="<?php echo AT_print($cid, 'input.hidden'); ?>" />
195 <input type="hidden" name="pid" value="<?php echo AT_print($pid, 'input.hidden'); ?>" />
196 <input type="hidden" name="a_type" value="<?php echo AT_print($a_type, 'input.hidden'); ?>" />
197 <input type="hidden" name="_course_id" value="<?php echo AT_print($_course_id, 'input.hidden'); ?>" />
204 <?php require(TR_INCLUDE_PATH.'footer.inc.php');