Ejemplo n.º 1
0
 public function testBadNicknameReturnsEmptyRoster()
 {
     // Create a mock of the response from $db->newSelect()
     $new_select = $this->createMockNewSelect();
     // Create our mock DB connection
     $db = $this->getMockBuilder('stdClass')->setMethods(['newSelect', 'fetchAll'])->getMock();
     $db->expects($this->once())->method('newSelect')->will($this->returnValue($new_select));
     $db->expects($this->once())->method('fetchAll')->will($this->returnValue(null));
     $roster = new Roster($db);
     $test_roster = $roster->getByNickname('BAD NICKNAME');
     $this->assertEquals([], $test_roster, 'Bad nickname did not return empty roster');
 }
Ejemplo n.º 2
0
<?php

// Controller for "Make a Trade" page
include 'DB.php';
include 'db_config.php';
$db = DB::connect(DSN);
// Grab all our models
include './models/franchises.php';
include './models/rosters.php';
$franchiseModel = new Franchise($db);
$rosterModel = new Roster($db);
$franchises = $franchiseModel->getAll();
// We need to grab the data that's come in via $_POST and build our rosters
$team1 = filter_input(INPUT_POST, 'team1', FILTER_SANITIZE_ENCODED);
$team2 = filter_input(INPUT_POST, 'team2', FILTER_SANITIZE_ENCODED);
$team1Roster = $rosterModel->getByNickname($team1);
$team2Roster = $rosterModel->getByNickname($team2);
include './templates/make_trade.php';
Ejemplo n.º 3
0
        $tig_name = $_POST["tig_name"];
    }
    // Sanity checks for the data
    if ($id == 0 || $ibl_team == 'FA' || $round == "Undrafted") {
        print "You must submit the correct data to draft someone!";
        $task == "list";
    } else {
        $comments = "{$round} Round (" . YEAR . ")";
        $result = $roster->updatePlayerTeam($ibl_team, $id, $comments);
        if ($result) {
            print "<div align='center'>Assigned {$tig_name} to <b>{$ibl_team}</b></div><br><br>";
            // Add an entry to the transaction log
            transaction_log($ibl_team, "Drafts {$tig_name} {$comments}", $db);
            $task = "list";
        } else {
            print "<div align='center'>Couldn't update record for {$tig_name}.  Please try again later</div><br><br>";
            $task = "list";
        }
    }
}
if ($task == "list") {
    // Show a list of free agents to draft
    $tig_name = array();
    $tig_name = $roster->getByNickname('FA');
    // Now, let's display the list of people to draft
    require 'templates/draft/list.php';
}
?>
<hr>
<div align="center"><a href=free_agents.php>Return to Manage Free Agents</a></div>
Ejemplo n.º 4
0
    // and then allow them to be assigned to a team
    $sql = "SELECT DISTINCT(ibl_team) FROM teams WHERE ibl_team!='FA' ORDER BY ibl_team";
    $select = $db->newSelect();
    $select->distinct()->cols(['ibl_team'])->from('teams')->where("ibl_team != 'FA'")->orderBy(['ibl_team']);
    $sth = $pdo->prepare($select->getStatement());
    $sth->execute($select->getBindValues());
    $results = $sth->fetchAll(PDO::FETCH_ASSOC);
    $ibl_team_dropdown = "<select name=ibl_team[]>";
    $ibl_team_dropdown .= "<option value='FA' selected >Free Agent</option>";
    foreach ($results as $row) {
        $ibl_team = $row['ibl_team'];
        $ibl_team_dropdown .= "<option value='" . $ibl_team . "'>" . $ibl_team . "</option>";
    }
    $ibl_team_dropdown .= "</select>";
    // Now, get a list of all the players who are free agents
    $results = $roster->getByNickname('FA');
    ?>
    <div align=center>
    <form action="<?php 
    print $_SERVER["PHP_SELF"];
    ?>
" method="post">
    <input type="hidden" name="task" value="do_signing">
    <table>
<?php 
    foreach ($results as $row) {
        $tig_name = trim($row['tig_name']);
        $id = $row['id'];
        ?>
        <tr>
        <td><?php