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_once(TR_INCLUDE_PATH.'vitals.inc.php');
15 require_once(TR_INCLUDE_PATH.'classes/DAO/PrimaryResourcesDAO.class.php');
16 require_once(TR_INCLUDE_PATH.'classes/DAO/PrimaryResourcesTypesDAO.class.php');
17 require_once(TR_INCLUDE_PATH.'classes/DAO/SecondaryResourcesDAO.class.php');
18 require_once(TR_INCLUDE_PATH.'classes/DAO/SecondaryResourcesTypesDAO.class.php');
19 require_once(TR_INCLUDE_PATH.'classes/FileUtility.class.php');
22 Utility::authenticate(TR_PRIV_ISAUTHOR_OF_CURRENT_COURSE);
24 $current_path = TR_CONTENT_DIR.$_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'].SEP.'_course_id='.$_course_id);
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 (FileUtility::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 $secondaryResourcesTypesDAO = new SecondaryResourcesTypesDAO();
63 $secondaryResourcesTypesDAO->DeleteByResourceName($filename);
65 // 2. delete secondary resources
66 $secondaryResourcesDAO = new SecondaryResourcesDAO();
67 $secondaryResourcesDAO->DeleteByResourceName($filename);
69 // 3. delete primary resources types
70 $primaryResourcesTypesDAO = new PrimaryResourcesTypesDAO();
71 $primaryResourcesTypesDAO->DeleteByResourceName($filename);
73 // 4. delete primary resources
74 $primaryResourcesDAO = new PrimaryResourcesDAO();
75 $primaryResourcesDAO->DeleteByResourceName($filename);
77 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
80 /* delete directory */
81 if (isset($_POST['listofdirs'])) {
83 $checkbox = explode(',',$_POST['listofdirs']);
84 $count = count($checkbox);
86 for ($i=0; $i<$count; $i++) {
87 $filename=$checkbox[$i];
89 if (strpos($filename, '..') !== false) {
90 $msg->addError('UNKNOWN');
92 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);
94 } else if (!is_dir($current_path.$pathext.$filename)) {
95 $msg->addError(array('DIR_NOT_DELETED',$filename));
97 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);
99 } else if (!($result = FileUtility::clr_dir($current_path.$pathext.$filename))) {
100 $msg->addError('DIR_NO_PERMISSION');
102 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 $msg->addFeedback('DIR_DELETED');
110 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);
114 require(TR_INCLUDE_PATH.'header.inc.php');
115 // find the files and directories to be deleted
116 $total_list = explode(',', $_GET['list']);
117 $pathext = $_GET['pathext'];
118 $popup = $_GET['popup'];
119 $framed = $_GET['framed'];
123 $a_type = $_GET['a_type'];
125 $count = count($total_list);
129 foreach ($total_list as $list_item) {
130 if (is_dir($current_path.$pathext.$list_item)) {
131 $_dirs[$countd] = $list_item;
134 $_files[$countf] = $list_item;
139 $hidden_vars['pathext'] = $pathext;
140 $hidden_vars['popup'] = $popup;
141 $hidden_vars['framed'] = $framed;
142 $hidden_vars['cp'] = $cp;
143 $hidden_vars['cid'] = $cid;
144 $hidden_vars['pid'] = $pid;
145 $hidden_vars['a_type'] = $a_type;
146 $hidden_vars['_course_id'] = $_course_id;
148 if (isset($_files)) {
149 $list_of_files = implode(',', $_files);
150 $hidden_vars['listoffiles'] = $list_of_files;
152 foreach ($_files as $file) {
153 $file_list_to_print .= '<li>'.$file.'</li>';
155 $msg->addConfirm(array('FILE_DELETE', $file_list_to_print), $hidden_vars);
159 $list_of_dirs = implode(',', $_dirs);
160 $hidden_vars['listofdirs'] = $list_of_dirs;
162 foreach ($_dirs as $dir) {
163 $dir_list_to_print .= '<li>'.$dir.'</li>';
166 $msg->addConfirm(array('DIR_DELETE',$dir_list_to_print), $hidden_vars);
169 $msg->printConfirm();
171 require(TR_INCLUDE_PATH.'footer.inc.php');