summaryrefslogtreecommitdiffstats
path: root/includes/admin/views/giglog_admin_page.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-09-03 09:15:46 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-09-03 09:15:46 +0200
commit74b06505888d69602b32d792ba4a815cd604ae41 (patch)
treea867e0941ad426c3f84861c2170060c50708491c /includes/admin/views/giglog_admin_page.php
parent742ef8ee58b5b2dd59e17648f31f2f8ed9d4f3d0 (diff)
downloadgigologadmin-74b06505888d69602b32d792ba4a815cd604ae41.tar.gz
gigologadmin-74b06505888d69602b32d792ba4a815cd604ae41.tar.bz2
gigologadmin-74b06505888d69602b32d792ba4a815cd604ae41.zip
Redo concert list to use the Concert class.
Instead of directly accessing the database with a custom query, we now just use the Concert::find_concerts method to fetch the concerts that are to be displayed. This became much easier now that we don't rely on the extra concertlogs table. There's still stuff missing to be functionally equivalent to the old code, but this should be a lot easier to get in place now.
Diffstat (limited to 'includes/admin/views/giglog_admin_page.php')
-rw-r--r--includes/admin/views/giglog_admin_page.php70
1 files changed, 32 insertions, 38 deletions
diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php
index 6c1f059..5a16b66 100644
--- a/includes/admin/views/giglog_admin_page.php
+++ b/includes/admin/views/giglog_admin_page.php
@@ -115,7 +115,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
if ($editing && !empty($cid)) //A bit overdoing with the checks if concert ID is empty both here and in find_cid. But based on that, things are NULL or not. Better ideas?
$c = GiglogAdmin_Concert::get($cid);
else
- $c = new GiglogAdmin_Concert();
+ $c = new GiglogAdmin_Concert((object)[]);
$content='<div><h3>Form to create/edit concerts and venues</h3><br></div><div class="editform"><div class="concertform">';
$content.='<form method="POST" action="" class="concert" >'
@@ -204,63 +204,58 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
$content .= '<th>AdminOptions</th>';
$content .= '</tr>';
+ $filter = [];
+
// Use the submitted "city" if any. Otherwise, use the default/static value.
$cty = filter_input( INPUT_POST, 'selectcity', FILTER_SANITIZE_SPECIAL_CHARS );
- $cty = $cty ? $cty: 'ALL';
+ if ($cty) $filter['city'] = $cty;
$venue = filter_input( INPUT_POST, 'selectvenue', FILTER_SANITIZE_SPECIAL_CHARS );
- $venue = $venue ? $venue : '0';
+ if ($venue) $filter['venue_id'] = $venue;
+ $concerts = GiglogAdmin_Concert::find_concerts($filter);
- $query = "SELECT wpgc.id, wpgconcert_name, wpgv.wpgvenue_name as venue, wpgc.wpgconcert_date, wpgc.wpgconcert_tickets, wpgc.wpgconcert_event, wpgv.wpgvenue_city, wpgv.wpgvenue_webpage, wpgps.wpgs_name
- FROM wpg_concerts wpgc, wpg_venues wpgv, wpg_pressstatus wpgps, wpg_concertlogs wpgcl
- where wpgc.venue = wpgv.id
- and wpgconcert_date >= CURDATE()
- and wpgps.id = wpgcl.wpgcl_status
- and wpgcl.wpgcl_concertid=wpgc.id";
-
- $query .= ($cty == "ALL") ? "" : " and wpgv.wpgvenue_city='" .$cty ."'";
- $query .= ($venue == "0") ? "" : " and wpgv.id='" .$venue ."'";
- $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 = '';
- foreach ( $results AS $row ) {
+ foreach ( $concerts AS $concert ) {
$content .= '<tr class="assignitr">';
- if($lastType != '' && $lastType != $row->wpgvenue_city) {
- $content .= '<td>'.$row->wpgvenue_city.'</td></tr><tr>';
+ if ($lastType != '' && $lastType != $concert->venue()->city()) {
+ $content .= '<td>' . $concert->city() . '</td></tr><tr>';
}
if ($lastType == '' ) {
- $content .= '<td>'.$row->wpgvenue_city.'</td></tr><tr>';
+ $content .= '<td>' . $concert->venue()->city() . '</td></tr><tr>';
}
// Modify these to match the database structure
// $content .= '<td>' . $row->id. '</td>';
$content .= '<td></td>';
- $content .= '<td>' . $row->wpgconcert_name. '</td>';
- $content .= '<td>' . $row->venue. '</td>';
- $fdate = strtotime($row->wpgconcert_date);
+ $content .= '<td>' . $concert->cname() . '</td>';
+ $content .= '<td>' . $concert->venue()->name() . '</td>';
+ $fdate = strtotime($concert->cdate());
$newformat = date('d.M.Y',$fdate);
//$content .= DATE_FORMAT($fdate,'%d.%b.%Y');
- $content .= '<td>' .$newformat. '</td>';
- $content .= '<td>'.$this->getpublishstatus($row->id ).'</td>';
- $content .= '<td>'.$this->returnuser('photo1', $row->id ).'</td>';
- $content .= '<td>'.$this->returnuser('photo2', $row->id ).'</td>';
- $content .= '<td>'.$this->returnuser('rev1', $row->id ).'</td>';
- $content .= '<td>'.$this->returnuser('rev2', $row->id ).'</td>';
- $content .= '<td>'.$row -> wpgs_name.'</td>';
-
- if (current_user_can('administrator')) {
- $content .=
- '<td class="adminbuttons">'
- . $this->adminactions($row->id)
- . '</td>';
- }
+ $content .= '<td>' . $newformat . '</td>';
+ $content .= '<td>' . /* $concert->isnew() */ '' . '</td>';
+
+ $roles = $concert->roles();
+
+ $content .= '<td>' . (array_key_exists('photo1', $roles) ? $roles['photo1'] : '') . '</td>';
+ $content .= '<td>' . (array_key_exists('photo1', $roles) ? $roles['photo2'] : '') . '</td>';
+ $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>';
+
+ // if (current_user_can('administrator')) {
+ // $content .=
+ // '<td class="adminbuttons">'
+ // . $this->adminactions($row->id)
+ // . '</td>';
+ // }
$content .= '</tr>';
- $lastType = $row->wpgvenue_city;
+ $lastType = $concert->venue()->city();
}
$content .= '</table>';
@@ -395,7 +390,6 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
return null;
}
- $cl = GiglogAdmin_Concertlogs::get($c);
$role = $cl->get_assigned_role( $this->username );
$assigned_user = $cl->assigned_user( $p1 );