/** * Displays the Project Details Meta Box. * * @param \WP_Post $post The post currently being edited. */ function display_project_meta_box($post) { wp_nonce_field('fz_project_meta', 'fz_project_nonce'); \FZ_Projects\Core\display_text_meta_field(get_project_tagline_meta_key(), __('Project Tagline', 'fzp'), $post->ID); \FZ_Projects\Core\display_text_meta_field(get_project_github_meta_key(), __('Github URL', 'fzp'), $post->ID); $team_members = get_team_members(); \FZ_Projects\Core\display_dropdown_meta_field(get_project_lead_meta_key(), __('Project Lead', 'fzp'), $team_members, $post->ID); }
function draw_page() { ?> <div class="container"> <?php open_panel("teamlist", "Teams", false) ?> <div class="row"> <!-- LIST OF TEAMS AND MEMBERS --> <?php /* Walkthrough of the code: -Ask mysql for a list of all team leaders (anybody who is an app_supervisor). -Step through each tl -Draw a new table for each tl -Ask mysql for a list of all team members of that particular team leader -Step through each team member and draw a <td> for each one */ $team_leaders = get_team_leaders(); ?> <?php while ($tl = $team_leaders->fetch_array()) { $team_members = get_team_members($tl['user_id']); ?> <div class="col-md-3"> <table class="table table-condensed" id="teams_table"> <tr> <th><?php echo $tl['lname'].', '.$tl['fname']; ?></th> <th></th> </tr> <?php while ($tm = $team_members->fetch_array()) { ?> <tr> <td> <?php echo $tm['lname'].', '.$tm['fname']; ?></td> <td><?php draw_remove_from_team_form($tm['user_id']); ?></td> </tr> <? } ?> </table> </div> <?php } ?> <div class="col-md-12"> <?php $orphans = get_orphans(); echo '<table class="table table-condensed" id="orphans_table">'; while ($orphan = $orphans->fetch_array()) { echo '<tr><td>'.$orphan['lname'].','.$orphan['fname'].'</td></tr>'; } echo '</table>'; ?> </div> </div> <?php close_panel(); ?> <!-- END LIST OF TEAMS AND MEMBERS --> <?php open_panel("add-to-team-form", "Add to Team", false) ?> <?php draw_add_to_team_form(); ?> <div class="col-md-6"> </div> <?php close_panel() ?> </div> <?php }
function handle_team_registration($bid, $pin, $extra_args = array()) { $team_registration = sanitized_team_registration(); $user = get_user($bid); $tid = $user["tid"]; $team = get_team($tid); $team_members = get_team_members($tid); // Choose appropriate action to perform. if (strcmp($team_registration["teamRegistrationAction"], "remove") == 0) { $userToRemove = get_user($team_registration["teamRegistrationBid"]); if ($userToRemove != null && $userToRemove["tid"] == $tid) { assign_user_to_team($userToRemove["bid"], PASSPORT_NO_TEAM_TID); log_entry(LOG_MODE_USER, LOG_USER_ACTION_REMOVE_TEAM_MEMBER, array("actorUid" => $user["uid"], "actorBid" => $user["bid"], "targetUid" => $user_to_add["uid"], "targetBid" => $user_to_add["bid"], "targetTid" => PASSPORT_NO_TEAM_TID, comment => addslashes(serialize($team_registration)))); $team = get_team($tid); $team_members = get_team_members($tid); return array("view" => "team_registration_add", "args" => array("bid" => $bid, "pin" => $pin, "teamMemberJustRemoved" => $user_to_remove, "teamMembers" => $team_members, "team" => $team) + $extra_args); } } else { if (strcmp($team_registration["teamRegistrationAction"], "create") == 0) { if (valid_team_name($team_registration["teamName"])) { $tid = register_team($team_registration["teamName"], $user["uid"]); log_entry(LOG_MODE_USER, LOG_USER_ACTION_CREATE_TEAM, array("actorUid" => $user["uid"], "actorBid" => $user["bid"], "targetTid" => $tid, comment => addslashes(serialize($team_registration)))); if ($tid == PASSPORT_NO_TEAM_TID) { return array("view" => "team_registration_create", "args" => array("bid" => $bid, "pin" => $pin) + $extra_args); } assign_user_to_team($bid, $tid); log_entry(LOG_MODE_USER, LOG_USER_ACTION_ADD_TEAM_MEMBER, array("actorUid" => $user["uid"], "actorBid" => $user["bid"], "targetUid" => $user["uid"], "targetBid" => $user["bid"], "targetTid" => $tid, comment => addslashes(serialize($team_registration)))); $team_members = get_team_members($tid); $team = get_team($tid); return array("view" => "team_registration_add", "args" => array("bid" => $bid, "pin" => $pin, "teamJustCreated" => true, "teamMembers" => $team_members, "team" => $team) + $extra_args); } else { return array("view" => "team_registration_create", "args" => array("bid" => $bid, "pin" => $pin, "teamNameInvalid" => true) + $extra_args); } } else { if (strcmp($team_registration["teamRegistrationAction"], "add") == 0) { $user = get_user($bid); $team = get_team($user["tid"]); $team_members = get_team_members($user["tid"]); if (count($team_members) < MAX_TEAM_MEMBERS) { if (validate_login($team_registration["teamRegistrationBid"], $team_registration["teamRegistrationPin"])) { $user_to_add = get_user($team_registration["teamRegistrationBid"]); if ($user_to_add["tid"] == PASSPORT_NO_TEAM_TID) { assign_user_to_team($user_to_add["bid"], $tid); log_entry(LOG_MODE_USER, LOG_USER_ACTION_ADD_TEAM_MEMBER, array("actorUid" => $user["uid"], "actorBid" => $user["bid"], "targetUid" => $user_to_add["uid"], "targetBid" => $user_to_add["bid"], "targetTid" => $tid, comment => addslashes(serialize($team_registration)))); $team_members = get_team_members($user["tid"]); return array("view" => "team_registration_add", "args" => array("bid" => $bid, "pin" => $pin, "teamMemberJustAdded" => $user_to_add, "teamMembers" => $team_members, "team" => $team) + $extra_args); } else { return array("view" => "team_registration_add", "args" => array("bid" => $bid, "pin" => $pin, "alreadyOnTeam" => true, "teamMembers" => $team_members, "team" => $team) + $extra_args); } } else { return array("view" => "team_registration_add", "args" => array("bid" => $bid, "pin" => $pin, "teamMemberBad" => true, "teamMembers" => $team_members, "team" => $team) + $extra_args); } } else { return array("view" => "team_registration_add", "args" => array("bid" => $bid, "pin" => $pin, "teamFull" => true, "teamMembers" => $team_members, "team" => $team) + $extra_args); } } } } // No action specified, just need to show the user the current members. return array("view" => "team_registration_add", "args" => array("bid" => $bid, "pin" => $pin, "teamMembers" => $team_members, "team" => $team) + $extra_args); }