summaryrefslogtreecommitdiffstats
path: root/includes/admin/views/giglog_admin_page.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-09-03 13:12:43 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-09-03 13:12:43 +0200
commitc09de43860ac6d57c6af31c971424e9c957e75c2 (patch)
tree5203ebb6766c8c9f5523214739950397459c4088 /includes/admin/views/giglog_admin_page.php
parent92ee799aab8d9ee41564b346f3a89bb688cf53bd (diff)
downloadgigologadmin-c09de43860ac6d57c6af31c971424e9c957e75c2.tar.gz
gigologadmin-c09de43860ac6d57c6af31c971424e9c957e75c2.tar.bz2
gigologadmin-c09de43860ac6d57c6af31c971424e9c957e75c2.zip
Drop query to press status table in adminactions.
Replace the table with hardcoded strings in the AdminPage class. This makes it a pure presentation issue, while the statuses themselves are just mnemonics. There's one smell here, and that is that the status values and their textual representation is split across two modules. (Values in Concert, and textual representation in AdminPage.) This should probably be addressed later by refactoring both into a separate AccredStatus class or something.
Diffstat (limited to 'includes/admin/views/giglog_admin_page.php')
-rw-r--r--includes/admin/views/giglog_admin_page.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php
index 3fe3237..7490122 100644
--- a/includes/admin/views/giglog_admin_page.php
+++ b/includes/admin/views/giglog_admin_page.php
@@ -11,6 +11,15 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
class GiglogAdmin_AdminPage {
private string $username;
+ const STATUS_LABELS = [
+ '',
+ 'Accred Requested',
+ 'Photo Approved',
+ 'Text Approved',
+ 'Photo and Text Approved',
+ 'Rejected'
+ ];
+
public function __construct()
{
$this->username = wp_get_current_user()->user_login;
@@ -152,16 +161,12 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
private function adminactions( GiglogAdmin_Concert $concert ) : string
{
- global $wpdb;
- $query = "SELECT id,wpgs_name from wpg_pressstatus" ;
- $statuses = $wpdb->get_results($query);
-
return
'<form method="POST" action="">'
. '<input type="hidden" name="cid" value="' . $concert->id() . '" />'
. \EternalTerror\ViewHelpers\select_field(
'selectstatus',
- array_map(fn($status) => [ $status->id, $status->wpgs_name ], $statuses),
+ array_map(fn($i) => [ $i, self::STATUS_LABELS[$i] ], range(1, count(self::STATUS_LABELS) - 1)),
$concert->status())
. '<input type="submit" value="SetStatus">'
. '<input type="submit" name ="edit" value="EDIT">'
@@ -246,7 +251,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
$content .= '<td>' . (array_key_exists('rev1', $roles) ? $roles['rev1'] : '') . '</td>';
$content .= '<td>' . (array_key_exists('rev2', $roles) ? $roles['rev2'] : '') . '</td>';
- $content .= '<td>' . $concert->status() . '</td>';
+ $content .= '<td>' . self::STATUS_LABELS[$concert->status()] . '</td>';
if (current_user_can('administrator')) {
$content .=