Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8a457ce
Add Pixie QueryBuilder as a depenedency
allejo Feb 2, 2018
b05225c
Create QueryBuilderFlex, the new QueryBuilder
allejo Feb 2, 2018
fb930c2
Drop 'status' column from Ban + deprecate its use
allejo Feb 2, 2018
96b0654
Move Ban model to QueryBuilderFlex :tada:
allejo Feb 2, 2018
50fa34e
Set PDO::FETCH_ASSOC in QueryBuilder's constructor
allejo Feb 2, 2018
38782ae
Add support for "named" columns for Named models
allejo Feb 2, 2018
4364991
Port Country model to new Query Builder
allejo Feb 2, 2018
acb39a4
Link QueryBuilderFlex with our query profiler
allejo Feb 3, 2018
068405e
Move soft-delete flag to BaseModel + update delete()
allejo Feb 3, 2018
cd611f6
Port News model to new QueryBuilder
allejo Feb 3, 2018
2fc2450
Fix deprecation warnings to show the called class
allejo Feb 5, 2018
fef36e1
Move model tracking to base test class
allejo Feb 6, 2018
23d5a1f
Migrate NewsCategory to new QueryBuilder
allejo Feb 6, 2018
8a99605
Correct phpDoc for AliasModel + Model base methods
allejo Feb 9, 2018
95deae7
Update core lazy loading fxns for query builder
allejo Feb 9, 2018
be035a6
Update Page model to use new query builder
allejo Feb 9, 2018
22da646
Add Twig breakpoint extension
allejo Feb 10, 2018
2624bcd
QB where() clauses now support Model objects
allejo Feb 10, 2018
5ef318d
Allow AdvancedModelType to handle option overrides
allejo Feb 10, 2018
e6d46fe
Overhaul invitation database + model structure
allejo Feb 10, 2018
298d1e2
Fix UTF-8 support in our new Query Builder
allejo Feb 10, 2018
a5b080d
Use brand new __::merge() function
allejo Feb 10, 2018
3cee91d
Update Map model to use new QB
allejo Feb 10, 2018
892dcd7
Feed QB::getNames() calls to our query manager
allejo Feb 10, 2018
d753aa9
Create "System Models" maintained by BZiON
allejo Feb 10, 2018
753a34c
Port Permission model to new QueryBuilder
allejo Feb 10, 2018
248aa4b
Add findModel() to QB to create a single Model
allejo Feb 11, 2018
9233e3c
Update Server model to new Query Builder
allejo Feb 11, 2018
2383cb7
Cast db results directly to models is now default
allejo Feb 11, 2018
e6b03de
Port Visit model to new Query Builder
allejo Feb 11, 2018
ae076a4
Bump minimum PHP version to 7 in Composer + Travis
allejo Feb 12, 2018
aa89d45
Swap Pixie to an active and compatible fork
allejo Feb 12, 2018
8e34294
Cast showDeleted query param to bool
allejo Feb 13, 2018
91700e1
Port Team and Player models to new QueryBuilder
allejo Feb 13, 2018
49fcb8c
Fix lazy loading for new modals; break old models
allejo Feb 14, 2018
afbe708
Move query tracking to overriden get() in QBF
allejo Feb 15, 2018
328c3a2
Allow QBF to inject arbitrary values to db results
allejo Feb 15, 2018
c4a054b
Allow where() and friends to handle DateTime objects
allejo Feb 16, 2018
0f24bc0
Have Season page use QBF instead of raw queries
allejo Feb 16, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
language: php
php:
- 5.6
- 7
- 7.1
- 7.2
- nightly

matrix:
include:
- php: "hhvm"
env:
- NO_COVERAGE=1
- BZION_HHVM=1
allow_failures:
- php: hhvm
- php: nightly
fast_finish: true

Expand Down
7 changes: 6 additions & 1 deletion app/Resource/symfony_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ services:
bzion.command.log_command:
class: BZIon\Command\LogCommand
tags:

- { name: console.command }
bzion.twig_debug_extension:
class: Ajgl\Twig\Extension\BreakpointExtension
public: false
tags:
- { name: twig.extension }

framework:
router:
resource: "%kernel.root_dir%/Resource/routes_dev.yml"
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-3.0-only",

"require": {
"php": ">=5.6",
"php": ">=7.0.9",
"ext-PDO": "*",
"ext-gd": "*",
"ext-pdo_mysql": "*",
Expand All @@ -18,6 +18,7 @@
"maciejczyzewski/bottomline": "dev-master",
"nelmio/api-doc-bundle": "~2.7",
"nesbot/carbon": "~1.14",
"pecee/pixie": "~4.2.5",
"robmorgan/phinx": "~0.8",
"sensio/framework-extra-bundle": "~3.0",
"swiftmailer/swiftmailer": ">=5.2.0",
Expand All @@ -29,17 +30,18 @@
"yzalis/identicon": "~1.2.0"
},
"require-dev": {
"ajgl/breakpoint-twig-extension": "^0.3.1",
"behat/behat": "~3.0",
"behat/mink": "~1.6",
"behat/mink-extension": "~2.0",
"behat/mink-browserkit-driver": "~1.2",
"behat/mink-extension": "~2.0",
"behat/symfony2-extension": "~2.1.1",
"composer/composer": "~1.5",
"fzaninotto/faker": "^1.7",
"jdorn/sql-formatter": "~1.2",
"phpunit/phpunit": "~5.7",
"sensio/distribution-bundle": "~3.0",
"sensiolabs/security-checker": "~4.1",
"fzaninotto/faker": "^1.7"
"sensiolabs/security-checker": "~4.1"
},

"scripts": {
Expand Down Expand Up @@ -110,7 +112,7 @@
},
"config": {
"platform": {
"php": "5.6.0"
"php": "7.0.9"
},
"sort-packages": true
},
Expand Down
138 changes: 131 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions controllers/BanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ public function listAction(Request $request)
$currentPage = $this->getCurrentPage();

$qb = $this->getQueryBuilder()
->sortBy('updated')->reverse()
->limit(16)->fromPage($currentPage);
->orderBy('updated', 'DESC')
->limit(16)
->fromPage($currentPage)
;

return array(
'bans' => $qb->getModels(),
'bans' => $qb->getModels(true),
'currentPage' => $currentPage,
'totalPages' => $qb->countPages()
);
Expand Down
48 changes: 34 additions & 14 deletions controllers/InvitationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
use BZIon\Event\Events;
use BZIon\Event\TeamInviteEvent;
use BZIon\Event\TeamJoinEvent;
use BZIon\Form\Creator\InvitationFormCreator;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;

class InvitationController extends CRUDController
{
public function acceptAction(Invitation $invitation, Player $me)
public function acceptAction(Player $me, Invitation $invitation)
{
if (!$me->isTeamless()) {
throw new ForbiddenException("You can't join a new team until you leave your current one.");
Expand All @@ -22,7 +24,7 @@ public function acceptAction(Invitation $invitation, Player $me)
}

if ($invitation->getTeam()->isDeleted()) {
$invitation->updateExpiration();
$invitation->setExpired();

throw new ForbiddenException("This invitation is for a team which has been deleted.");
}
Expand All @@ -32,30 +34,48 @@ public function acceptAction(Invitation $invitation, Player $me)

return $this->showConfirmationForm(function () use ($invitation, $team, $me) {
$team->addMember($me->getId());
$invitation->updateExpiration();
$invitation->setStatus(Invitation::STATUS_ACCEPTED);
$invitation->setExpired();
Service::getDispatcher()->dispatch(Events::TEAM_JOIN, new TeamJoinEvent($team, $me));

return new RedirectResponse($team->getUrl());
}, "Are you sure you want to accept the invitation from $inviter to join {$team->getEscapedName()}?",
"You are now a member of {$team->getName()}");
}

public function inviteAction(Team $team, Player $player, Player $me)
public function inviteAction(Player $me, Team $team, Player $player)
{
if (!$me->canEdit($team)) {
throw new ForbiddenException("You are not allowed to invite a player to that team!");
} elseif ($team->isMember($player->getId())) {
throw new ForbiddenException("The specified player is already a member of that team.");
} elseif (Invitation::hasOpenInvitation($player->getId(), $team->getId())) {
throw new ForbiddenException("This player has already been invited to join the team.");
}

return $this->showConfirmationForm(function () use ($team, $player, $me) {
$invite = Invitation::sendInvite($player->getId(), $team->getId(), $me->getId());
Service::getDispatcher()->dispatch(Events::TEAM_INVITE, new TeamInviteEvent($invite));
$creator = new InvitationFormCreator($team, $me, $this);
$form = $creator->create()->handleRequest(self::getRequest());

return new RedirectResponse($team->getUrl());
}, "Are you sure you want to invite {$player->getEscapedUsername()} to {$team->getEscapedName()}?",
"Player {$player->getUsername()} has been invited to {$team->getName()}");
if ($form->isSubmitted()) {
$this->validate($form);

if ($form->isValid()) {
$clickedButton = $form->getClickedButton()->getName();

if ($clickedButton === 'submit') {
$invitation = $creator->enter($form);

self::getFlashBag()->add('success', sprintf('"%s" has been invited to "%s."', $invitation->getInvitedPlayer()->getName(), $team->getName()));

return $this->redirectTo($team);
}

return (new RedirectResponse($this->getPreviousURL()));
}
} else {
$form->get('invited_player')->setData($player);
}

return [
'form' => $form->createView(),
'team' => $team,
'player' => $player,
];
}
}
17 changes: 9 additions & 8 deletions controllers/MapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ class MapController extends CRUDController
public function listAction(Map $map = null)
{
if ($map === null) {
$qb = $this->getQueryBuilder();

$maps = $qb->sortBy('name')
->getModels();
$maps = $this->getQueryBuilder()
->active()
->orderBy('name')
->getModels()
;
} else {
$maps = array($map);
$maps = [$map];
}

return array(
"maps" => $maps
);
return [
'maps' => $maps
];
}

public function createAction(Player $me)
Expand Down
Loading