} else { $sql = sprintf("DELETE FROM project_roles WHERE project_id = '%s' AND role_id = '%s'", $_GET['project_id'], $role); $st = @mysql_query($sql, $indaba_dbh); if (mysql_affected_rows() == 1) { $i++; } } } //indaba_alert( $i . " roles has been removed from project"); } } $sql = sprintf("SELECT * FROM project where id = '%s'", $_GET['project_id']); $st = @mysql_query($sql, $indaba_dbh); $project = @mysql_fetch_assoc($st); if (empty($project['code_name'])) { indaba_alert("Project not found"); header("Location: projects.php"); } $sql = sprintf("SELECT * FROM role where id NOT IN ( SELECT role_id FROM project_roles WHERE project_id = '%s')", $_GET['project_id']); $st = @mysql_query($sql, $indaba_dbh); $avarolesOpt = "<SELECT name=role_id class=sel_list size=25 multiple>"; while ($role = @mysql_fetch_assoc($st)) { $avarolesOpt .= "<option name=a value=" . $role['id'] . ">" . $role['name'] . "</option>"; } $avarolesOpt .= "</SELECT>"; $sql = sprintf("SELECT a.role_id as role_id, b.name as name FROM project_roles a, role b WHERE a.role_id = b.id and a.project_id = '%s'", $_GET['project_id']); $st = @mysql_query($sql, $indaba_dbh); $projectrolesOpt = "<SELECT name=project_role_id class=sel_list size=25 multiple>"; while ($role = @mysql_fetch_assoc($st)) { $projectrolesOpt .= "<option name=a value=" . $role['role_id'] . ">" . $role['name'] . "</option>"; }
} header("Location: manage_teams.php?project_id=" . $_GET['project_id'] . "&team_id=" . $_GET['team_id']); } if ($_GET['func'] == 'removeteam') { $sql = sprintf("DELETE FROM team_user WHERE team_id = '%s'", $_GET['team_id']); $i = mysql_affected_rows(); $sql = sprintf("DELETE FROM team WHERE id = '%s' and project_id = '%s'", $_GET['team_id'], $_GET['project_id']); $j = mysql_affected_rows(); } if ($_GET['func'] == 'addteam') { $sql = sprintf("INSERT INTO team ( project_id, team_name, description ) VALUES ( '%s', '%s', '%s' )", $_GET['project_id'], $_GET['added_team'], $_GET['added_desc']); $st = @mysql_query($sql, $indaba_dbh); if (mysql_affected_rows() == 1) { //header("Location: manage_teams.php?project_id=" . $_GET['project_id'] . "&team_name=" . $_GET['added_team']); } else { indaba_alert("Error adding team: " . mysql_error()); header("Location: manage_teams.php?project_id=" . $_GET['project_id']); } } } // Build team list $sql = "SELECT * FROM team WHERE project_id = '" . $_GET['project_id'] . "'"; $st = @mysql_query($sql, $indaba_dbh); $teamOpt = "<SELECT name=team_id id=team_id onChange='getTeam();' ><option name=a value=''>Select a team to manage</option>"; while ($teams = mysql_fetch_assoc($st)) { $selected = ""; if (isset($_GET['team_id'])) { $selected = $_GET['team_id'] == $teams['id'] ? "selected=selected" : ""; } $teamOpt .= "<option name=a value='" . $teams['id'] . "' " . $selected . ">" . $teams['team_name'] . "</option>"; }