From 0d3a225b3203b8a8fe0ad24138c09a4f1f738f54 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 24 May 2021 21:09:34 +0200 Subject: Use select_field for venue selector in new/edit form --- includes/admin/views/giglog_admin_page.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 9d9d759..7de52ce 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -38,19 +38,10 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { static function get_venue_selector( ?GiglogAdmin_Venue $invenue ): string { - $select = ''; - return($select); + return \EternalTerror\ViewHelpers\select_field( + "selectvenueadmin", + array_map(fn($venue) => [$venue->id(), $venue->name()], GiglogAdmin_Venue::all_venues()), + $invenue ? $invenue->id() : null); } -- cgit v1.2.3 From 543bddc03fbf9dc90429d4d77dd11affaea4f356 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 25 May 2021 09:13:28 +0200 Subject: Use select_field helper for city/venue filter. --- includes/admin/views/giglog_admin_page.php | 49 ++++++++++-------------------- 1 file changed, 16 insertions(+), 33 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 7de52ce..8ae30c3 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -70,45 +70,28 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } - static function get_filters(): string + static function get_filters() : string { - $cities = array_merge(["ALL"], GiglogAdmin_Venue::all_cities()); - $cty = filter_input( INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS ); - $selected_city = - filter_input(INPUT_POST, "selectcity", FILTER_SANITIZE_SPECIAL_CHARS) - || $cities[0]; - - $select = '
FILTER DATA: '; + $select = 'FILTER DATA:'; + $select .= \EternalTerror\ViewHelpers\select_field( + "selectcity", + array_map(fn($city) => [$city, $city], GiglogAdmin_Venue::all_cities()), + $cty, + "Select city..."); - if ( $cty && $cty!= "ALL" ) { + if ( !empty($cty) ) { //second drop down for venue - $venues = GiglogAdmin_Venue::venues_in_city($cty); - - $venue_list = array_merge( - [0, "ALL"], + $select .= \EternalTerror\ViewHelpers\select_field( + "selectvenue", array_map( - function($v) { return [$v->id(), $v->name()]; }, - $venues)); - - $selected_venue = filter_input(INPUT_POST, "selectvenue", FILTER_SANITIZE_SPECIAL_CHARS) - || $venue_list[0]; - - $select .= ''; - + fn($venue) => [$venue->id(), $venue->name()], + GiglogAdmin_Venue::venues_in_city($cty) + ), + filter_input(INPUT_POST, 'selectvenue', FILTER_SANITIZE_SPECIAL_CHARS), + "Select venue..."); } //option to select own concerts only $select .= ' Date: Tue, 25 May 2021 16:43:05 +0200 Subject: Use select_field in adminactions form. Also add a `get_status` method to the Concertlogs class, returning the press status for a given concert_id. --- includes/admin/views/giglog_admin_page.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 8ae30c3..f84b497 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -152,22 +152,16 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { $query = "SELECT id,wpgs_name from wpg_pressstatus" ; $statuses = $wpdb->get_results($query); - $select = + return '' . '' - . '' + . \EternalTerror\ViewHelpers\select_field( + 'selectstatus', + array_map(fn($status) => [ $status->id, $status->wpgs_name ], $statuses), + GiglogAdmin_Concertlogs::get_status($concert_id)) . '' . '' . '
'; - - return $select; } //function to calculate if the concert has been added in the past 10 days or before that and show a green NEW for the newest rows -- cgit v1.2.3 From 40fd00f9b5988690d09fb4f760577e54b51a9c5b Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 25 May 2021 20:23:54 +0200 Subject: Refactor the AdminPage::get_user method. No functional change, just trying to make sense of it. --- includes/admin/views/giglog_admin_page.php | 34 ++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index f84b497..7ae7628 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -49,21 +49,33 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { { $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; + $users = array_map( + fn($usr) => $usr->user_login, + get_users( array( 'fields' => array( 'user_login' ) ) ) ); + + // This renders a user form, which we don't really use for anything + // other than to check which user (if any) the form was made for. + // Seems this could be done a bit simpler... + $userform = GiglogAdmin_AdminPage::returnuser($ctype, $cid); + $select = ''; return($select); -- cgit v1.2.3 From aaa154aec8b446fb7123f0dd7a37bdd18490248e Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 25 May 2021 21:03:24 +0200 Subject: Simplify AdminPage::get_user Now queries the user from the concertlogs table instead of going by generating a form that is thrown away. --- includes/admin/views/giglog_admin_page.php | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 7ae7628..4f211fc 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -53,29 +53,20 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { fn($usr) => $usr->user_login, get_users( array( 'fields' => array( 'user_login' ) ) ) ); - // This renders a user form, which we don't really use for anything - // other than to check which user (if any) the form was made for. - // Seems this could be done a bit simpler... - $userform = GiglogAdmin_AdminPage::returnuser($ctype, $cid); + $current_user = $cid ? GiglogAdmin_Concertlogs::get_assigned_user( $cid, $ctype ) : null; $select = ''; return($select); -- cgit v1.2.3 From 72a0df55f1a5858ac088cfce34183c740c544663 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 25 May 2021 21:15:09 +0200 Subject: Use select_field in AdminPage::get_user --- includes/admin/views/giglog_admin_page.php | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 4f211fc..bb42aa7 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -55,21 +55,10 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { $current_user = $cid ? GiglogAdmin_Concertlogs::get_assigned_user( $cid, $ctype ) : null; - $select = ''; - return($select); + return \EternalTerror\ViewHelpers\select_field( + $ctype, + array_map( fn($user) => [ $user, $user ], $users ), + $current_user); } -- cgit v1.2.3 From b3c2e40c2ebfbfc6098495293c322140fd48250c Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 26 May 2021 21:35:28 +0200 Subject: Refactor and reformat AdminPage::returnuser. Now use a Concertlog object to render the correct subform instead of messing with the db directly. --- includes/admin/views/giglog_admin_page.php | 49 +++++++++++++++++++----------- 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index bb42aa7..c1887dc 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -384,31 +384,44 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { wp_mail( $to, $subject, $body, $headers ); } - static function returnuser(string $p1, ?int $c): string + static function returnuser(string $p1, ?int $c) : ?string { - global $wpdb; $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; + if (!$c) { + return null; + } - if (!empty($c)) - { - $sql = "select * from wpg_concertlogs where wpgcl_concertid=".$c; - $crow = $wpdb->get_results($sql); - $array = array('photo1' => $crow[0]->wpgcl_photo1, 'photo2'=> $crow[0]->wpgcl_photo2, 'rev1' => $crow[0]->wpgcl_rev1, 'rev2'=> $crow[0]->wpgcl_rev2); - - //first check if current slot is taken by current user - if ($array[$p1] == $hf_username) return ('
'); - else //check if slot is taken by another user - if (!empty($array[$p1])) return ('Taken
Taken by '.$array[$p1].'
'); - else //check if other slots for this concert are taken by user - if (in_array($hf_username,$array)) return ('-'); - else //not taken by anyone - return ('
-
'); + $cl = GiglogAdmin_Concertlogs::get($c); + $role = $cl->get_assigned_role( $hf_username ); + $assigned_user = $cl->assigned_user( $p1 ); + + //first check if current slot is taken by current user + if ( $role == $p1 ) { + $f = '
' + . ' ' + . ' ' + . ' ' + . '
'; + } + elseif ( $assigned_user ) { //check if slot is taken by another user + $f = 'Taken' + . '
Taken by ' . $assigned_user . '
'; + } + elseif ( $role ) { + // other slots for this concert are taken by user + $f = '-'; + } + else { //not taken by anyone + $f = '
' + . ' ' + . ' ' + . ' ' + . '
'; } - else return ('no concert selected'); + return $f; } } } -- cgit v1.2.3 From 1c8667a1d6e56ac359b18b4b364296d12b2e41a0 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 29 May 2021 13:59:03 +0200 Subject: Make AdminPage a proper object. --- includes/admin/views/giglog_admin_page.php | 57 ++++++++++++++++++------------ 1 file changed, 34 insertions(+), 23 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index c1887dc..c2c84e9 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -9,7 +9,18 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { require_once __DIR__ . '/../../venue.php'; class GiglogAdmin_AdminPage { - static function render_html(): void { + public function __construct() + { + } + + public static function render_html() : void + { + $page = new self(); + $page->render_page(); + } + + public function render_page() : void + { ?>

Giglog Admin

@@ -28,15 +39,15 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { what the accreditation status is. You will get personal message if this is really close to the concert date.

-

-

+

get_filters() ?>

+

get_concerts() ?>

user_login; @@ -62,7 +73,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } - static function get_filters() : string + private function get_filters() : string { $cty = filter_input(INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS); @@ -95,7 +106,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { return $select; } - static function editforms(): string + private function editforms(): string { $cid = filter_input(INPUT_POST, "cid"); $editing = filter_input(INPUT_POST, "edit") == "EDIT"; @@ -110,7 +121,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { .'
CONCERT DETAILS

' .'' .'
' - .'' . GiglogAdmin_AdminPage::get_venue_selector($c->venue()) . '
' + .'' . $this->get_venue_selector($c->venue()) . '
' .'
' .'
' .'
' @@ -123,10 +134,10 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { $content.='
'; $content.='
ASSIGNMENT DETAILS

' - .''.GiglogAdmin_AdminPage::get_user($c->id(),'photo1').'
' - .''.GiglogAdmin_AdminPage::get_user($c->id(),'photo2').'
' - .''.GiglogAdmin_AdminPage::get_user($c->id(),'rev1').'
' - .''.GiglogAdmin_AdminPage::get_user($c->id(),'rev2').'
'; + .''.$this->get_user($c->id(),'photo1').'
' + .''.$this->get_user($c->id(),'photo2').'
' + .''.$this->get_user($c->id(),'rev1').'
' + .''.$this->get_user($c->id(),'rev2').'
'; $content.='
'; $content.='
VENUE DETAILS

' @@ -138,7 +149,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { return $content; } - static function adminactions( int $concert_id ) : string + private function adminactions( int $concert_id ) : string { global $wpdb; $query = "SELECT id,wpgs_name from wpg_pressstatus" ; @@ -160,7 +171,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { /** * @return null|string */ - static function getpublishstatus(int $concert_id) + private function getpublishstatus(int $concert_id) { global $wpdb; $date1 = new DateTime("now"); @@ -177,7 +188,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } - static function get_concerts(): string + private function get_concerts(): string { $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; @@ -237,17 +248,17 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { //$content .= DATE_FORMAT($fdate,'%d.%b.%Y'); $content .= '' .$newformat. ''; - $content .= ''.GiglogAdmin_AdminPage::getpublishstatus($row->id ).''; - $content .= ''.GiglogAdmin_AdminPage::returnuser('photo1', $row->id ).''; - $content .= ''.GiglogAdmin_AdminPage::returnuser('photo2', $row->id ).''; - $content .= ''.GiglogAdmin_AdminPage::returnuser('rev1', $row->id ).''; - $content .= ''.GiglogAdmin_AdminPage::returnuser('rev2', $row->id ).''; + $content .= ''.$this->getpublishstatus($row->id ).''; + $content .= ''.$this->returnuser('photo1', $row->id ).''; + $content .= ''.$this->returnuser('photo2', $row->id ).''; + $content .= ''.$this->returnuser('rev1', $row->id ).''; + $content .= ''.$this->returnuser('rev2', $row->id ).''; $content .= ''.$row -> wpgs_name.''; if (current_user_can('administrator')) { $content .= '' - . GiglogAdmin_AdminPage::adminactions($row->id) + . $this->adminactions($row->id) . ''; } $content .= ''; @@ -294,7 +305,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } //handling the admin drop down menu - if(isset($_POST['selectstatus']) && $_POST['edit']!="EDIT" && !empty($_POST['cid'])) + if(isset($_POST['selectstatus']) && (isset($_POST['edit']) && $_POST['edit']!="EDIT") && !empty($_POST['cid'])) { $usql = "UPDATE wpg_concertlogs SET wpgcl_status=".$_POST['selectstatus']." WHERE wpgcl_concertid=".$_POST['cid']; $uresults = $wpdb->get_results($usql); @@ -384,7 +395,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { wp_mail( $to, $subject, $body, $headers ); } - static function returnuser(string $p1, ?int $c) : ?string + private function returnuser(string $p1, ?int $c) : ?string { $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; -- cgit v1.2.3 From ca846023ab96299d53c7f806810f1b09bc45c5bb Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 29 May 2021 14:07:19 +0200 Subject: Get current users username in AdminPage constructor. --- includes/admin/views/giglog_admin_page.php | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index c2c84e9..4a0e348 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -11,6 +11,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { class GiglogAdmin_AdminPage { public function __construct() { + $this->username = wp_get_current_user()->user_login; } public static function render_html() : void @@ -58,8 +59,6 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { private function get_user( ?int $cid, string $ctype): string { - $hf_user = wp_get_current_user(); - $hf_username = $hf_user->user_login; $users = array_map( fn($usr) => $usr->user_login, get_users( array( 'fields' => array( 'user_login' ) ) ) ); @@ -190,8 +189,6 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { private function get_concerts(): string { - $hf_user = wp_get_current_user(); - $hf_username = $hf_user->user_login; $roles = $hf_user->roles; global $wpdb; @@ -202,7 +199,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { CITYNAMEVENUEDATE PHOTO1PHOTO2TEXT1TEXT2 STATUS'; - if (current_user_can('administrator')) //($hf_username == 'etadmin') + if (current_user_can('administrator')) $content .= 'AdminOptions'; $content .= ''; @@ -223,7 +220,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { $query .= ($cty == "ALL") ? "" : " and wpgv.wpgvenue_city='" .$cty ."'"; $query .= ($venue == "0") ? "" : " and wpgv.id='" .$venue ."'"; - $query.= (empty($_POST['my_checkbox'])) ? "": " and (wpgcl_photo1 ='".$hf_username."' or wpgcl_photo2 ='".$hf_username."' or wpgcl_rev1 ='".$hf_username."' or wpgcl_rev2 ='".$hf_username."')"; + $query.= (empty($_POST['my_checkbox'])) ? "": " and (wpgcl_photo1 ='".$this->username."' or wpgcl_photo2 ='".$this->username."' or wpgcl_rev1 ='".$this->username."' or wpgcl_rev2 ='".$this->username."')"; $query .=" order by wpgv.wpgvenue_city, wpgconcert_date, wpgc.id" ; $results = $wpdb->get_results($query); $lastType = ''; @@ -357,17 +354,15 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { { global $wpdb; - $hf_user = wp_get_current_user(); - $hf_username = $hf_user->user_login; $to = 'live@eternal-terror.com'; - $subject = $hf_username.' has taken '.$p1. 'for a concert with id '.$c; + $subject = $this->username.' has taken '.$p1. 'for a concert with id '.$c; $body = 'The email body content'; $headers = array('Content-Type: text/html; charset=UTF-8'); - $usql = "UPDATE wpg_concertlogs SET wpgcl_".$p1."='".$hf_username."' WHERE wpgcl_concertid=".$c; + $usql = "UPDATE wpg_concertlogs SET wpgcl_".$p1."='".$this->username."' WHERE wpgcl_concertid=".$c; $uresults = $wpdb->get_results($usql); $wpdb->insert( 'wpg_logchanges', array ( 'id' => '', - 'userid' => $hf_username, + 'userid' => $this->username, 'action' => 'assigned '.$p1, 'concertid' => $c)); echo ($wpdb->last_error ); @@ -378,17 +373,15 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { { global $wpdb; - $hf_user = wp_get_current_user(); - $hf_username = $hf_user->user_login; $to = 'live@eternal-terror.com'; - $subject = $hf_username.' has UNASSINED '.$p1. 'for a concert with id '.$c; + $subject = $this->username.' has UNASSINED '.$p1. 'for a concert with id '.$c; $body = 'The email body content'; $headers = array('Content-Type: text/html; charset=UTF-8'); $usql = "UPDATE wpg_concertlogs SET wpgcl_".$p1."='' WHERE wpgcl_concertid=".$c; $uresults = $wpdb->get_results($usql); $wpdb->insert( 'wpg_logchanges', array ( 'id' => '', - 'userid' => $hf_username, + 'userid' => $this->username, 'action' => 'unassigned '.$p1, 'concertid' => $c)); echo ($wpdb->last_error ); @@ -397,15 +390,12 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { private function returnuser(string $p1, ?int $c) : ?string { - $hf_user = wp_get_current_user(); - $hf_username = $hf_user->user_login; - if (!$c) { return null; } $cl = GiglogAdmin_Concertlogs::get($c); - $role = $cl->get_assigned_role( $hf_username ); + $role = $cl->get_assigned_role( $this->username ); $assigned_user = $cl->assigned_user( $p1 ); //first check if current slot is taken by current user -- cgit v1.2.3 From b5c2165f0369391bd2367f2df4a3ee9a903b7eb9 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 12 Jun 2021 18:11:06 +0200 Subject: Drop obsolete line from AdminPage::get_concerts. This must have been forgotten in the previous commit. --- includes/admin/views/giglog_admin_page.php | 1 - 1 file changed, 1 deletion(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 4a0e348..6f0b2ba 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -189,7 +189,6 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { private function get_concerts(): string { - $roles = $hf_user->roles; global $wpdb; $content = ''; -- cgit v1.2.3 From 5af89bca3bd17777fae94e681882d6eabf152303 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 12 Jun 2021 18:24:01 +0200 Subject: Fix misc Psalm issues. --- includes/admin/views/giglog_admin_page.php | 2 ++ includes/admin/views/giglog_import_gigs.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 6f0b2ba..ab71270 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -9,6 +9,8 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { require_once __DIR__ . '/../../venue.php'; class GiglogAdmin_AdminPage { + private string $username; + public function __construct() { $this->username = wp_get_current_user()->user_login; diff --git a/includes/admin/views/giglog_import_gigs.php b/includes/admin/views/giglog_import_gigs.php index a8daa3f..aeaf974 100644 --- a/includes/admin/views/giglog_import_gigs.php +++ b/includes/admin/views/giglog_import_gigs.php @@ -51,7 +51,7 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) { * * @return void * - * @param ArrayAccess|array $file + * @param array */ static function process_upload(array $file): void { $newconcert= []; -- cgit v1.2.3 From bb353e8e61156b0c9fdab673e2485502a01b8434 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 13 Jun 2021 16:05:48 +0200 Subject: Move method to update Concertlogs to Concertlogs class. --- includes/admin/views/giglog_admin_page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index ab71270..6c1f059 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -332,7 +332,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { else { GiglogAdmin_Concert::update_concert($_POST['pid'],$_POST['cname'], $_POST['selectvenueadmin'], $_POST['cdate'], $_POST['ticket'], $_POST['eventurl']); - GiglogAdmin_Concert::update_concertlog($_POST['pid'],$_POST['photo1'], $_POST['photo2'], $_POST['rev1'], $_POST['rev2']); + GiglogAdmin_Concertlogs::update($_POST['pid'],$_POST['photo1'], $_POST['photo2'], $_POST['rev1'], $_POST['rev2']); echo ''; } -- cgit v1.2.3 From 82c4a8f2c4e5acd80b813829cecc40f621da3b21 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 14 Jun 2021 10:07:55 +0200 Subject: Begin move roles and status field to concerts table. There's no need to have a separate table (concertlogs) for these fields. --- includes/admin/register_db_tables.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/register_db_tables.php b/includes/admin/register_db_tables.php index 11223b3..64123d9 100644 --- a/includes/admin/register_db_tables.php +++ b/includes/admin/register_db_tables.php @@ -260,7 +260,7 @@ if ( !function_exists( "giglog_register_db_tables") ) function giglog_register_db_tables() { $db_version = get_option('giglogadmin_db_version'); - if ($db_version == 5) { + if ($db_version == 6) { return; } @@ -445,7 +445,21 @@ if ( !function_exists( "giglog_register_db_tables") ) "ALTER TABLE `wpg_concerts` DROP FOREIGN KEY `wpgconcert_band`;"); } - update_option("giglogadmin_db_version", 5); + if ($db_version == NULL || $db_version < 6) + { + /* + * Move status and roles from concertlogs to main concerts table + * Don't really see the value in a separate table for these items + * Also make the roles fiels a JSON field instead of separate + * fields for each role. + */ + $wpdb->query( + "ALTER TABLE `wpg_concerts` ADD COLUMN IF NOT EXISTS ( + wpgconcert_status INT DEFAULT 1, + wpgconcert_roles JSON CHECK (JSON_VALID(wpgconcert_roles)))"); + } + + update_option("giglogadmin_db_version", 6); } giglog_register_db_tables(); -- cgit v1.2.3