public function deleteAction(Player $me, Team $team) { $members = $team->getMembers(); return $this->delete($team, $me, function () use($team, $me, $members) { $event = new Event\TeamDeleteEvent($team, $me, $members); Service::getDispatcher()->dispatch(Events::TEAM_DELETE, $event); }); }
public function testMembers() { $this->team = Team::createTeam("Sample Team", $this->player->getId(), "Avatar", "Description"); $extraMember = $this->getNewPlayer(); $otherPlayer = $this->getNewPlayer(); $this->team->addMember($otherPlayer->getId()); $this->team->addMember($extraMember->getId()); $this->team->removeMember($otherPlayer->getId()); $team = new Team($this->team->getId()); $members = $team->getMembers('id'); $expectedMembers = array($this->player, $extraMember); $this->assertEquals(2, $team->getNumMembers()); $this->assertArraysHaveEqualValues($expectedMembers, $members); $this->wipe($extraMember, $otherPlayer); }
/** * Add a member to the discussion * * @param Player|Team $member The member to add * @param bool $distinct Whether to add the member as a distinct * player (ignored for teams) * @return void */ public function addMember($member, $distinct = true) { if ($member instanceof Player) { // Mark individual players as distinct by creating or updating the // entry on the table if ($distinct) { $query = "INSERT INTO `player_conversations` (`conversation`, `player`, `distinct`) VALUES (?, ?, 1)\n ON DUPLICATE KEY UPDATE `distinct` = 1"; } else { $query = "INSERT IGNORE INTO `player_conversations` (`conversation`, `player`, `distinct`, `read`) VALUES (?, ?, 0, 1)"; } $this->db->execute($query, array($this->getId(), $member->getId())); } elseif ($member instanceof Team) { // Add the team to the team_conversations table... $this->db->execute("INSERT IGNORE INTO `team_conversations` (`conversation`, `team`) VALUES (?, ?)", array($this->getId(), $member->getId())); // ...and each of its members in the player_conversations table as // non-distinct (unless they were already there) foreach ($member->getMembers() as $player) { $this->db->execute("INSERT IGNORE INTO `player_conversations` (`conversation`, `player`, `distinct`) VALUES (?, ?, 0)", array($this->getId(), $player->getId())); } } }
/** * Add a member to the discussion * * @param Player|Team $member The member to add * @return void */ public function addMember($member) { if ($member instanceof Player) { // Mark individual players as distinct by creating or updating the // entry on the table $this->db->query("INSERT INTO `player_groups` (`group`, `player`, `distinct`) VALUES (?, ?, 1)\n ON DUPLICATE KEY UPDATE `distinct` = 1", "ii", array($this->getId(), $member->getId())); } elseif ($member instanceof Team) { // Add the team to the team_groups table... $this->db->query("INSERT INTO `team_groups` (`group`, `team`) VALUES (?, ?)", "ii", array($this->getId(), $member->getId())); // ...and each of its members in the player_groups table as // non-distinct (unless they were already there) foreach ($member->getMembers() as $player) { $this->db->query("INSERT IGNORE INTO `player_groups` (`group`, `player`, `distinct`) VALUES (?, ?, 0)", "ii", array($this->getId(), $player->getId())); } } }
echo 'Enter Delegate number<form method="POST">'; echo '<input type="input" name="delno" /><br>'; echo '<input type="hidden" name="event" value="', $_POST['event'], '"/>'; echo '<input type="submit" name="regind" value="Register"/><input type="submit" value="Cancel" />'; echo '</form>'; } } else { if (isset($_POST['regteam']) and isset($_POST['teamno'])) { // when team number is posted $e = new Event(); $eventInfo = $e->getInfo($_POST['event']); //display event name echo '<h3>', ucwords($eventInfo['name']), ' Regestration</h3>'; $t = new Team(); // get list of members in the team $members = $t->getMembers($_POST['teamno']); if ($members) { // if there are members in the team echo '<center><table><tr><td>Team No.</td><td>Del No.</td><td>Reg No.</td><td>Name</td><td>Sem</td><td>College</td><td>Phone</td></tr>'; $num = 1; foreach ($members as $mem) { // to change the color if ($num % 2 == 1) { $class = 'odd'; } else { $class = 'even'; } echo "<tr id ='{$class}'><td> {$_POST['teamno']} </td><td> {$mem['delno']} </td><td> {$mem['regno']} </td><td> {$mem['name']} </td><td> {$mem['sem']} </td><td> {$mem['cllg']} </td><td> {$mem['phone']} </td></tr>"; $num += 1; } // asking user to confirm
echo '</table></center><br><br><br><br>'; } else { $t = new Team(); $teams = $t->assignedToEvent($_GET['eid']); if ($teams) { echo '<h3>', ucwords($eventInfo['name']), ' Registeration Details</h3>'; echo '<center><table>'; echo "<tr><td>Sr No.</td><td>Team No.</td><td>Del No.</td><td>Reg No.</td><td>Name</td><td>Sem</td><td>College</td><td>Phone</td></tr>"; $num = 1; foreach ($teams as $team) { if ($num % 2 == 1) { $class = 'odd'; } else { $class = 'even'; } foreach ($t->getMembers($team) as $reg) { echo "<tr id ='{$class}' ><td> {$num} </td><td> {$team} </td><td> {$reg['delno']} </td><td> {$reg['regno']} </td><td> {$reg['name']} </td><td> {$reg['sem']} </td><td> {$reg['cllg']} </td><td> {$reg['phone']} </td></tr>"; } $num += 1; } echo '</table></center><br><br><br><br>'; } } } else { echo 'Sorry wrong event'; } } } } } else { $c = new Catagory();
function team_members($position, Team $team) { $members = $team->getMembers(); if (count($members) == 0 && $position >= POSITION_ACCOUNT) { return 'No team members'; } $text = ''; foreach ($members as $member) { switch ($position) { case POSITION_NONE: return ''; case POSITION_ACCOUNT: $text .= $member->getDisplayName() . ' '; case POSITION_PLAYER: case POSITION_ADMIN: $text .= $member->getDisplayName() . ' (<i>'; $text .= $member->getPhoneNumber() . '</i>) '; $text .= '<br />'; } } return $text; }
</div> <div id="sidebaar"> <?php include_once 'sidebar.php'; ?> </div> <div id="content"> <?php $type = $_GET['type']; $t = new Team(); if (isset($_POST['submit'])) { if ($type == "ce") { echo $t->createTeam($_POST['delNo']); } else { if ($type == "se") { $res = $t->getMembers($_POST['teamNo']); echo "<table border='1'>\n\t\t\t\t <tr>\n\t\t\t\t\t <td>Del No </td>\n\t\t\t\t </tr>\n\t\t\t\n\t\t\t "; foreach ($res as $r) { echo "<tr><td>" . $r . "</td></tr>"; } } else { if ($type == "ae") { echo $t->addToTeam($_POST['delNo'], $_POST['teamNo']); } } } } else { if ($type == "ce") { $str = <<<display <fieldset> <legend>Create Team</legend>