2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg */
6 /* Adaptive Technology Resource Centre / University of Toronto */
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. */
12 /****************************************************************/
15 define('AT_INCLUDE_PATH', '../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 require(AT_INCLUDE_PATH.'lib/filemanager.inc.php');
19 if (!authenticate(AT_PRIV_FILES,AT_PRIV_RETURN)) {
20 authenticate(AT_PRIV_CONTENT);
24 $current_path = AT_CONTENT_DIR.$_SESSION['course_id'].'/';
26 $popup = $_REQUEST['popup'];
27 $framed = $_REQUEST['framed'];
29 if (isset($_POST['submit_no'])) {
30 $msg->addFeedback('CANCELLED');
31 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup']);
35 if (isset($_POST['cancel'])) {
36 $msg->addFeedback('CANCELLED');
37 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_REQUEST['framed'].SEP.'popup='.$_REQUEST['popup']);
41 if (isset($_POST['submit_yes'])) {
42 $dest = $_POST['dest'] .'/';
43 $pathext = $_POST['pathext'];
45 if (isset($_POST['listofdirs'])) {
47 $_dirs = explode(',',$_POST['listofdirs']);
48 $count = count($_dirs);
50 for ($i = 0; $i < $count; $i++) {
53 if (course_realpath($current_path . $pathext . $source) == FALSE) {
54 // error: File does not exist
55 $msg->addError('DIR_NOT_EXIST');
56 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup);
59 else if (course_realpath($current_path . $dest) == FALSE) {
60 // error: File does not exist
61 $msg->addError('UNKNOWN');
62 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup);
65 else if (strpos($source, '..') !== false) {
66 $msg->addError('UNKNOWN');
67 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup);
71 @rename($current_path.$pathext.$source, $current_path.$dest.$source);
74 $msg->addFeedback('DIRS_MOVED');
76 if (isset($_POST['listoffiles'])) {
78 $_files = explode(',',$_POST['listoffiles']);
79 $count = count($_files);
81 for ($i = 0; $i < $count; $i++) {
82 $source = $_files[$i];
84 if (course_realpath($current_path . $pathext . $source) == FALSE) {
85 // error: File does not exist
86 $msg->addError('FILE_NOT_EXIST');
87 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup);
90 else if (course_realpath($current_path . $dest) == FALSE) {
91 // error: File does not exist
92 $msg->addError('UNKNOWN');
93 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup);
96 else if (strpos($source, '..') !== false) {
97 $msg->addError('UNKNOWN');
98 header('Location: index.php?pathext='.$pathext.SEP.'framed='.$framed.SEP.'popup='.$popup);
102 @rename($current_path.$pathext.$source, $current_path.$dest.$source);
105 $msg->addFeedback('MOVED_FILES');
107 header('Location: index.php?pathext='.$_POST['pathext'].SEP.'framed='.$_POST['framed'].SEP.'popup='.$_POST['popup']);
111 if (isset($_POST['dir_chosen'])) {
112 $hidden_vars['framed'] = $_POST['framed'];
113 $hidden_vars['popup'] = $_POST['popup'];
114 $hidden_vars['pathext'] = $_POST['pathext'];
115 $hidden_vars['dest'] = $_POST['dir_name'];
117 if (isset($_POST['files'])) {
118 $list_of_files = implode(',', $_POST['files']);
119 $hidden_vars['listoffiles'] = $list_of_files;
120 $msg->addConfirm(array('FILE_MOVE', $list_of_files, $_POST['dir_name']), $hidden_vars);
122 if (isset($_POST['dirs'])) {
123 $list_of_dirs = implode(',', $_POST['dirs']);
124 $hidden_vars['listoffiles'] = $list_of_dirs;
125 $msg->addConfirm(array('DIR_MOVE', $list_of_dirs, $_POST['dir_name']), $hidden_vars);
127 require(AT_INCLUDE_PATH.'header.inc.php');
128 $msg->printConfirm();
129 require(AT_INCLUDE_PATH.'footer.inc.php');
132 require(AT_INCLUDE_PATH.'header.inc.php');
134 $tree = AT_CONTENT_DIR.$_SESSION['course_id'].'/';
135 $file = $_GET['file'];
136 $pathext = $_GET['pathext'];
137 $popup = $_GET['popup'];
138 $framed = $_GET['framed'];
140 /* find the files and directories to be copied */
141 $total_list = explode(',', $_GET['list']);
143 $count = count($total_list);
146 for ($i=0; $i<$count; $i++) {
147 if (is_dir($current_path.$pathext.$total_list[$i])) {
148 $_dirs[$countd] = $total_list[$i];
149 $hidden_dirs .= '<input type="hidden" name="dirs['.$countd.']" value="'.$_dirs[$countd].'" />';
152 $_files[$countf] = $total_list[$i];
153 $hidden_files .= '<input type="hidden" name="files['.$countf.']" value="'.$_files[$countf].'" />';
159 <form name="move_form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
160 <div class="input-form">
162 <p><?php echo _AT('select_directory'); ?></p>
167 <li class="folders"><label><input type="radio" name="dir_name" value=""<?php
168 if ($pathext == '') {
169 echo ' checked="checked"';
170 $here = ' ' . _AT('current_location');
172 echo '/>Home ' .$here.'</label>';
174 echo display_tree($current_path, '', $pathext);
179 <div class="row buttons">
180 <input type="submit" name="dir_chosen" value="<?php echo _AT('move'); ?>" accesskey="s" />
181 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
185 <input type="hidden" name="pathext" value="<?php echo $pathext; ?>" />
186 <input type="hidden" name="framed" value="<?php echo $framed; ?>" />
187 <input type="hidden" name="popup" value="<?php echo $popup; ?>" />
194 <?php require(AT_INCLUDE_PATH.'footer.inc.php');