2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
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 /****************************************************************/
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
20 if (!authenticate(AT_PRIV_FILES,AT_PRIV_RETURN)) {
21 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'].SEP.'cp='.$_POST['cp'].SEP.'cid='.$_POST['cid'].SEP.'pid='.$_POST['pid'].SEP.'a_type='.$_POST['a_type']);
35 if (isset($_POST['submit_yes'])) {
36 /* delete files and directories */
38 $pathext = $_POST['pathext'];
39 if (isset($_POST['listoffiles'])) {
40 $checkbox = explode(',',$_POST['listoffiles']);
41 $count = count($checkbox);
43 for ($i=0; $i<$count; $i++) {
44 $filename=$checkbox[$i];
46 if (course_realpath($current_path . $pathext . $filename) == FALSE) {
47 $msg->addError('FILE_NOT_DELETED');
50 } else if (!(@unlink($current_path.$pathext.$filename))) {
51 $msg->addError('FILE_NOT_DELETED');
58 // delete according definition of primary resources and alternatives for adapted content
59 $filename = '../'.$pathext.$filename;
61 // 1. delete secondary resources types
62 $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources_types
63 WHERE secondary_resource_id in (SELECT secondary_resource_id
64 FROM ".TABLE_PREFIX."secondary_resources
65 WHERE secondary_resource = '".$filename."'
66 OR primary_resource_id in (SELECT primary_resource_id
67 FROM ".TABLE_PREFIX."primary_resources
68 WHERE resource='".$filename."'))";
69 $result = mysql_query($sql, $db);
71 // 2. delete secondary resources
72 $sql = "DELETE FROM ".TABLE_PREFIX."secondary_resources
73 WHERE secondary_resource = '".$filename."'
74 OR primary_resource_id in (SELECT primary_resource_id
75 FROM ".TABLE_PREFIX."primary_resources
76 WHERE resource='".$filename."')";
77 $result = mysql_query($sql, $db);
79 // 3. delete primary resources types
80 $sql = "DELETE FROM ".TABLE_PREFIX."primary_resources_types
81 WHERE primary_resource_id in (SELECT primary_resource_id
82 FROM ".TABLE_PREFIX."primary_resources
83 WHERE resource = '".$filename."')";
84 $result = mysql_query($sql, $db);
86 // 4. delete primary resources
87 $sql = "DELETE FROM ".TABLE_PREFIX."primary_resources
88 WHERE resource = '".$filename."'";
89 $result = mysql_query($sql, $db);
91 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
94 /* delete directory */
95 if (isset($_POST['listofdirs'])) {
97 $checkbox = explode(',',$_POST['listofdirs']);
98 $count = count($checkbox);
100 for ($i=0; $i<$count; $i++) {
101 $filename=$checkbox[$i];
103 if (strpos($filename, '..') !== false) {
104 $msg->addError('UNKNOWN');
106 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']);
108 } else if (!is_dir($current_path.$pathext.$filename)) {
109 $msg->addError(array('DIR_NOT_DELETED',$filename));
111 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']);
113 } else if (!($result = clr_dir($current_path.$pathext.$filename))) {
114 $msg->addError('DIR_NO_PERMISSION');
116 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']);
121 $msg->addFeedback('DIR_DELETED');
124 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']);
128 require(AT_INCLUDE_PATH.'header.inc.php');
129 // find the files and directories to be deleted
130 $total_list = explode(',', $_GET['list']);
131 $pathext = $_GET['pathext'];
132 $popup = $_GET['popup'];
133 $framed = $_GET['framed'];
137 $a_type = $_GET['a_type'];
139 $count = count($total_list);
143 foreach ($total_list as $list_item) {
144 if (is_dir($current_path.$pathext.$list_item)) {
145 $_dirs[$countd] = $list_item;
148 $_files[$countf] = $list_item;
153 $hidden_vars['pathext'] = $pathext;
154 $hidden_vars['popup'] = $popup;
155 $hidden_vars['framed'] = $framed;
156 $hidden_vars['cp'] = $cp;
157 $hidden_vars['cid'] = $cid;
158 $hidden_vars['pid'] = $pid;
159 $hidden_vars['a_type'] = $a_type;
161 if (isset($_files)) {
162 $list_of_files = implode(',', $_files);
163 $hidden_vars['listoffiles'] = $list_of_files;
165 foreach ($_files as $file) {
166 $file_list_to_print .= '<li>'.$file.'</li>';
168 $msg->addConfirm(array('FILE_DELETE', $file_list_to_print), $hidden_vars);
172 $list_of_dirs = implode(',', $_dirs);
173 $hidden_vars['listofdirs'] = $list_of_dirs;
175 foreach ($_dirs as $dir) {
176 $dir_list_to_print .= '<li>'.$dir.'</li>';
179 $msg->addConfirm(array('DIR_DELETE',$dir_list_to_print), $hidden_vars);
182 $msg->printConfirm();
184 require(AT_INCLUDE_PATH.'footer.inc.php');