$errtxt = $langfile["notyourproject"]; $noperm = $langfile["accessdenied"]; $template->assign("errortext", "{$errtxt}<br>{$noperm}"); $template->display("error.tpl"); die; } $tasklist = new tasklist(); $myproject = new project(); $milestone = new milestone(); // Get open and closed tasklists $lists = $tasklist->getProjectTasklists($id); $oldlists = $tasklist->getProjectTasklists($id, 0); // Get number of assignable users $project_members = $myproject->getProjectMembers($id, $myproject->countMembers($id)); // Get all the milestones in the project $milestones = $milestone->getAllProjectMilestones($id); //get the current project $pro = $myproject->getProject($id); $projectname = $pro["name"]; $title = $langfile['tasks']; $template->assign("title", $title); $template->assign("milestones", $milestones); $template->assign("projectname", $projectname); $template->assign("assignable_users", $project_members); $template->assign("lists", $lists); $template->assign("oldlists", $oldlists); $template->display("projecttasks.tpl"); } elseif ($action == "showtask") { if (!$userpermissions["tasks"]["view"]) { $errtxt = $langfile["nopermission"]; $noperm = $langfile["accessdenied"];
/** * Removes a user from a project * * @param int $user User ID of user to remove * @param int $id Project ID of project to remove from * @return bool */ function deassign($user, $id) { global $conn; $sqlStmt = $conn->prepare("DELETE FROM projekte_assigned WHERE user = ? AND projekt = ?"); $milestone = new milestone(); // Delete the users assignments to closed milestones $donemiles = $milestone->getDoneProjectMilestones($id); if (!empty($donemiles)) { $sql1Stmt = $conn->prepare("DELETE FROM milestones_assigned WHERE user = ? AND milestone = ?"); foreach ($donemiles as $dm) { $sql1 = $sql1Stmt->execute(array((int) $user, $dm['ID'])); } } // Delete the users assignments to open milestones $openmiles = $milestone->getAllProjectMilestones($id, 100000); if (!empty($openmiles)) { $sql2Stmt = $conn->prepare("DELETE FROM milestones_assigned WHERE user = ? AND milestone = ?"); foreach ($openmiles as $om) { $sql2 = $sql2Stmt->execute(array((int) $user, $om['ID'])); } } $task = new task(); $tasks = $task->getProjectTasks($id); // Delete tasks assignments of the user if (!empty($tasks)) { $sql3Stmt = $conn->prepare("DELETE FROM tasks_assigned WHERE user = ? AND task = ?"); foreach ($tasks as $t) { $sql3 = $sql3Stmt->execute(array((int) $user, $t['ID'])); } } // Finally remove the user from the project $del = $sqlStmt->execute(array((int) $user, (int) $id)); if ($del) { $userObj = new user(); $user = $userObj->getProfile($user); $this->mylog->add($user["name"], 'user', 7, $id); return true; } else { return false; } }
/** * Copy a project * by: Daniel Tlach <*****@*****.**>, * Philipp Kiszka <*****@*****.**> * * @param int $id ID of project to copy * @return int $insid New project's ID */ function makecopy($id) { // copy project $q = mysql_query("INSERT INTO projekte (`name`, `desc`, `end`, `start`, `status`, `budget`) SELECT `name`, `desc`, `end`, `start`, `status`, `budget` FROM projekte WHERE ID = " . (int) $id); $insid = mysql_insert_id(); $uid = $_SESSION['userid']; $this->assign($uid, $insid); $milesobj = new milestone(); $objtasklist = new tasklist(); $objtask = new task(); if ($q) { $pname = $this->getProject($insid); $name = $pname["name"] . " Copy"; mysql_query("UPDATE projekte SET `name` = '{$name}' WHERE ID = " . $insid . " LIMIT 1"); // now copy the milestones $miles = $milesobj->getAllProjectMilestones($id); if (!empty($miles)) { // go through the milestones foreach ($miles as $ms) { // copy milestone $msid = $milesobj->add($insid, $ms["name"], $ms["desc"], $ms["end"], 1); // get all tasklists for milestone $qb = mysql_query("SELECT * FROM tasklist WHERE project = {$id} AND milestone = {$ms['ID']}"); if ($qb) { // go through the tasklists while ($tl = mysql_fetch_array($qb)) { // copy tasklist $tlid = $objtasklist->add_liste($insid, $tl["name"], $tl["desc"], 0, $msid); // get tasks for the tasklist $tasks = $objtasklist->getTasksFromList($tl["ID"]); if (!empty($tasks)) { foreach ($tasks as $task) { $taskobj->add($task["end"], $task["title"], $task["text"], $tlid, $uid, $insid); } // tasks END } } // tasklists END } } // milestones END } // get all tasklists and tasks that do not belong to a milestone $qb = mysql_query("SELECT * FROM tasklist WHERE project = {$id} AND milestone = 0"); if ($qb) { // go through the tasklists while ($tl = mysql_fetch_array($qb)) { // copy tasklist $tlid = $objtasklist->add_liste($insid, $tl["name"], $tl["desc"], 0, $msid); // get tasks for the tasklist $tasks = $objtasklist->getTasksFromList($tl["ID"]); if (!empty($tasks)) { foreach ($tasks as $task) { $taskobj->add($task["end"], $task["title"], $task["text"], $tlid, $uid, $insid); } // tasks END } } // tasklists END } mkdir(CL_ROOT . "/files/" . CL_CONFIG . "/{$insid}/", 0777); $this->mylog->add($name, 'projekt', 1, $insid); return $insid; } else { return false; } }