From c09de43860ac6d57c6af31c971424e9c957e75c2 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Fri, 3 Sep 2021 13:12:43 +0200 Subject: 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. --- includes/admin/views/giglog_admin_page.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'includes/admin/views') 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 '
' . '' . \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()) . '' . '' @@ -246,7 +251,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { $content .= '' . (array_key_exists('rev1', $roles) ? $roles['rev1'] : '') . ''; $content .= '' . (array_key_exists('rev2', $roles) ? $roles['rev2'] : '') . ''; - $content .= '' . $concert->status() . ''; + $content .= '' . self::STATUS_LABELS[$concert->status()] . ''; if (current_user_can('administrator')) { $content .= -- cgit v1.2.3