/** * This function deletes a dropbox category * * @todo give the user the possibility what needs to be done with the files in this category: move them to the root, download them as a zip, delete them * * @author Patrick Cool <*****@*****.**>, Ghent University * @version march 2006 */ function delete_category($action, $id, $user_id = null) { $course_id = api_get_course_int_id(); $is_courseAdmin = api_is_course_admin(); $is_courseTutor = api_is_course_tutor(); $dropbox_cnf = getDropboxConf(); if (empty($user_id)) { $user_id = api_get_user_id(); } $cat = get_dropbox_category($id); if (count($cat) == 0) { return false; } if ($cat['user_id'] != $user_id && !api_is_platform_admin($user_id)) { return false; } // an additional check that might not be necessary if ($action == 'deletereceivedcategory') { $sentreceived = 'received'; $entries_table = $dropbox_cnf['tbl_post']; $id_field = 'file_id'; $return_message = get_lang('ReceivedCatgoryDeleted'); } elseif ($action == 'deletesentcategory') { $sentreceived = 'sent'; $entries_table = $dropbox_cnf['tbl_file']; $id_field = 'id'; $return_message = get_lang('SentCatgoryDeleted'); } else { return get_lang('Error'); } // step 1: delete the category $sql = "DELETE FROM " . $dropbox_cnf['tbl_category'] . " WHERE c_id = {$course_id} AND cat_id='" . intval($id) . "' AND {$sentreceived}='1'"; Database::query($sql); // step 2: delete all the documents in this category $sql = "SELECT * FROM " . $entries_table . " WHERE c_id = {$course_id} AND cat_id='" . intval($id) . "'"; $result = Database::query($sql); while ($row = Database::fetch_array($result)) { $dropboxfile = new Dropbox_Person($user_id, $is_courseAdmin, $is_courseTutor); if ($action == 'deletereceivedcategory') { $dropboxfile->deleteReceivedWork($row[$id_field]); } if ($action == 'deletesentcategory') { $dropboxfile->deleteSentWork($row[$id_field]); } } return $return_message; }
// Move a File if (($action == 'movesent' or $action == 'movereceived') and isset($_GET['move_id'])) { if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } display_move_form(str_replace('move', '', $action), $_GET['move_id'], get_dropbox_categories(str_replace('move', '', $action)), $sort_params, $viewReceivedCategory, $viewSentCategory, $view); } if (isset($_POST['do_move'])) { Display::display_confirmation_message(store_move($_POST['id'], $_POST['move_target'], $_POST['part'])); } // Delete a file if (($action == 'deletereceivedfile' or $action == 'deletesentfile') and isset($_GET['id']) and is_numeric($_GET['id'])) { if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); } $dropboxfile = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); if ($action == 'deletereceivedfile') { $dropboxfile->deleteReceivedWork($_GET['id']); $message = get_lang('ReceivedFileDeleted'); } if ($action == 'deletesentfile') { $dropboxfile->deleteSentWork($_GET['id']); $message = get_lang('SentFileDeleted'); } Display::display_confirmation_message($message); } // Delete a category if (($action == 'deletereceivedcategory' or $action == 'deletesentcategory') and isset($_GET['id']) and is_numeric($_GET['id'])) { if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) { api_not_allowed(); }
} } /** * DELETE RECEIVED OR SENT FILES - EDIT FEEDBACK * - DELETE ALL RECEIVED FILES * - DELETE 1 RECEIVED FILE * - DELETE ALL SENT FILES * - DELETE 1 SENT FILE * - EDIT FEEDBACK */ if (isset($_GET['deleteReceived']) || isset($_GET['deleteSent']) || isset($_GET['showFeedback']) || isset($_GET['editFeedback'])) { if ($_GET['mailing']) { getUserOwningThisMailing($_GET['mailing'], $_user['user_id'], '408'); $dropbox_person = new Dropbox_Person($_GET['mailing'], $is_courseAdmin, $is_courseTutor); } else { $dropbox_person = new Dropbox_Person($_user['user_id'], $is_courseAdmin, $is_courseTutor); } if (isset($_SESSION['sentOrder'])) { $dropbox_person->orderSentWork($_SESSION['sentOrder']); } if (isset($_SESSION['receivedOrder'])) { $dropbox_person->orderReceivedWork($_SESSION['receivedOrder']); } /*if (!$dropbox_person->isCourseAdmin || ! $dropbox_person->isCourseTutor) { die(get_lang('GeneralError').' (code 408)'); }*/ $tellUser = get_lang('FileDeleted'); if (isset($_GET['deleteReceived'])) { if ($_GET['deleteReceived'] == 'all') { $dropbox_person->deleteAllReceivedWork(); } elseif (is_numeric($_GET['deleteReceived'])) {