Skip to content

Commit

Permalink
Series improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
silasary committed Aug 2, 2023
1 parent 94bdd5e commit c3beb98
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions gatherling/admin/db-upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,12 @@ function redirect_deck_update($latest_id = 0)
do_query('ALTER TABLE `players`
CHANGE COLUMN `discord_id` `discord_id` VARCHAR(20) NULL DEFAULT NULL AFTER `theme`;');
});
upgrade_db(50, 'Fix series discord fields', function () {
do_query('ALTER TABLE `series`
CHANGE COLUMN `discord_guild_id` `discord_guild_id` VARCHAR(20) NULL DEFAULT NULL AFTER `mtgo_room`,
ADD COLUMN `discord_channel_id` VARCHAR(20) NULL DEFAULT NULL AFTER `discord_guild_id`,
CHANGE COLUMN `discord_require_membership` `discord_require_membership` INT NULL DEFAULT NULL AFTER `discord_guild_invite`;');
});
$db->autocommit(true);

info('DB is up to date!');
6 changes: 4 additions & 2 deletions gatherling/api_lib.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

require_once 'lib.php';

//## Helper Functions

use Gatherling\Event;
Expand Down Expand Up @@ -193,12 +195,12 @@ function repr_json_deck($deck)
}

/**
* @param string $series
* @param Gatherling\Series $series
* @return mixed
*/
function repr_json_series($series)
{
$json = populate([], $series, ['name', 'active', 'start_day', 'start_time', 'organizers', 'mtgo_room', 'this_season_format', 'this_season_master_link', 'this_season_season']);
$json = populate([], $series, ['name', 'active', 'start_day', 'start_time', 'organizers', 'mtgo_room', 'this_season_format', 'this_season_master_link', 'this_season_season', 'discord_guild_id', 'discord_channel_id', 'discord_channel_name', 'discord_guild_name']);

return $json;
}
Expand Down
4 changes: 3 additions & 1 deletion gatherling/models/Series.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Series
public $prereg_default;

public $discord_guild_id;
public $discord_channel_id;
public $discord_channel_name;
public $discord_guild_name;
public $discord_guild_invite;
Expand All @@ -46,7 +47,7 @@ public function __construct($name)
}

$db = Database::getConnection();
$sql = 'SELECT isactive, day, normalstart, prereg_default, mtgo_room, discord_guild_id, discord_channel_name, discord_guild_name, discord_guild_invite, discord_require_membership FROM series WHERE name = ?';
$sql = 'SELECT isactive, day, normalstart, prereg_default, mtgo_room, discord_guild_id, discord_channel_id, discord_channel_name, discord_guild_name, discord_guild_invite, discord_require_membership FROM series WHERE name = ?';
$stmt = $db->prepare($sql);
$stmt or exit($db->error);
$stmt->bind_param('s', $name);
Expand All @@ -58,6 +59,7 @@ public function __construct($name)
$this->prereg_default,
$this->mtgo_room,
$this->discord_guild_id,
$this->discord_channel_id,
$this->discord_channel_name,
$this->discord_guild_name,
$this->discord_guild_invite,
Expand Down

0 comments on commit c3beb98

Please sign in to comment.