summaryrefslogtreecommitdiffstats
path: root/includes/concertlogs.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/concertlogs.php')
-rw-r--r--includes/concertlogs.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/includes/concertlogs.php b/includes/concertlogs.php
index 70baf26..8b485ca 100644
--- a/includes/concertlogs.php
+++ b/includes/concertlogs.php
@@ -9,6 +9,16 @@ if ( !class_exists( 'GiglogAdmin_Concertlogs' ) )
{
class GiglogAdmin_Concertlogs
{
+ private array $roles;
+
+ private function __construct( $attr = [] )
+ {
+ $this->roles['photo1'] = $attr->{"wpgcl_photo1"};
+ $this->roles['photo2'] = $attr->{"wpgcl_photo2"};
+ $this->roles['rev1'] = $attr->{"wpgcl_rev1"};
+ $this->roles['rev2'] = $attr->{"wpgcl_rev2"};
+ }
+
/**
* Adds a default entry for the given concert id in the
* concert logs table.
@@ -56,5 +66,28 @@ if ( !class_exists( 'GiglogAdmin_Concertlogs' ) )
return array_shift( $res );
}
+
+ public static function get(int $concert_id) : ?self
+ {
+ global $wpdb;
+
+ $q = $wpdb->prepare(
+ "select * from wpg_concertlogs where id = %d",
+ $concert_id);
+
+ $res = $wpdb->get_row($q);
+
+ return $res ? new self($res) : null;
+ }
+
+ public function get_assigned_role(string $username) : ?string
+ {
+ return array_search( $username, $this->roles );
+ }
+
+ public function assigned_user(string $role) : ?string
+ {
+ return $this->roles[$role];
+ }
}
}