$template->display("error.tpl"); die; } if ($myfile->edit($thisfile, $title, $desc, "")) { $loc = $url .= "managefile.php?action=showproject&id={$id}&mode=edited"; header("Location: {$loc}"); } } elseif ($action == "delete") { if (!$userpermissions["files"]["del"]) { $errtxt = $langfile["nopermission"]; $noperm = $langfile["accessdenied"]; $template->assign("errortext", "<h2>{$errtxt}</h2><br>{$noperm}"); $template->display("error.tpl"); die; } if ($myfile->loeschen($thisfile)) { echo "ok"; } } elseif ($action == "zipexport") { $topfad = CL_ROOT . "/files/" . CL_CONFIG . "/{$id}" . "/projectfiles" . $id . ".zip"; $zip = new PclZip($topfad); if (file_exists($topfad)) { if (unlink($topfad)) { $create = $zip->create(CL_ROOT . "/files/" . CL_CONFIG . "/{$id}/", PCLZIP_OPT_REMOVE_ALL_PATH); } } else { $create = $zip->create(CL_ROOT . "/files/" . CL_CONFIG . "/{$id}/", PCLZIP_OPT_REMOVE_ALL_PATH); } if ($create != 0) { $loc = $url . "files/" . CL_CONFIG . "/{$id}" . "/projectfiles" . $id . ".zip"; header("Location: {$loc}");
/** * Deletes a project including everything else that was assigned to it (e.g. Milestones, tasks, timetracker entries) * * @param int $id Project ID * @return bool */ function del($id) { global $conn; $userid = $_SESSION["userid"]; $id = (int) $id; // Delete assignments of tasks of this project to users $task = new task(); $tasks = $task->getProjectTasks($id); if (!empty($tasks)) { foreach ($tasks as $tas) { $del_taskassign = $conn->query("DELETE FROM tasks_assigned WHERE task = {$tas['ID']}"); } } // Delete files and the assignments of these files to the messages they were attached to $fil = new datei(); $files = $fil->getProjectFiles($id, 1000000); if (!empty($files)) { foreach ($files as $file) { $del_files = $fil->loeschen($file[ID]); } } $del_messages = $conn->query("DELETE FROM messages WHERE project = {$id}"); $del_milestones = $conn->query("DELETE FROM milestones WHERE project = {$id}"); $del_projectassignments = $conn->query("DELETE FROM projekte_assigned WHERE projekt = {$id}"); $del_tasklists = $conn->query("DELETE FROM tasklist WHERE project = {$id}"); $del_tasks = $conn->query("DELETE FROM tasks WHERE project = {$id}"); $del_timetracker = $conn->query("DELETE FROM timetracker WHERE project = {$id}"); $del_customer = $conn->query("DELETE FROM customers_assigned WHERE project = {$id}"); $del_logentries = $conn->query("DELETE FROM log WHERE project = {$id}"); $del = $conn->query("DELETE FROM projekte WHERE ID = {$id}"); delete_directory(CL_ROOT . "/files/" . CL_CONFIG . "/{$id}"); if ($del) { $this->mylog->add($userid, 'projekt', 3, $id); return true; } else { return false; } }