/** * 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; } }
/** * Entfernt ein Projekt aus der Zuweisung an ein bestimmtes Mitglied * * @param int $user User ID * @param int $id Project ID * @return bool */ function deassign($user, $id) { $user = mysql_real_escape_string($user); $id = mysql_real_escape_string($id); $user = (int) $user; $id = (int) $id; $sql = "DELETE FROM projekte_assigned WHERE user = {$user} AND projekt = {$id}"; $milestone = new milestone(); $donemiles = $milestone->getDoneProjectMilestones($id); if (!empty($donemiles)) { foreach ($donemiles as $dm) { $sql1 = mysql_query("DELETE FROM milestones_assigned WHERE user = {$user} AND milestone = {$dm['ID']}"); } } $openmiles = $milestone->getAllProjectMilestones($id, 100000); if (!empty($openmiles)) { foreach ($openmiles as $om) { $sql2 = mysql_query("DELETE FROM milestones_assigned WHERE user = {$user} AND milestone = {$om['ID']}"); } } $task = new task(); $tasks = $task->getProjectTasks($id); if (!empty($tasks)) { foreach ($tasks as $t) { $sql3 = mysql_query("DELETE FROM tasks_assigned WHERE user = {$user} AND task = {$t['ID']}"); } } $del = mysql_query($sql); if ($del) { $userObj = new user(); $user = $userObj->getProfile($user); $this->mylog->add($user["name"], 'user', 7, $id); return true; } else { return false; } }