diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2021-09-03 19:32:28 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2021-09-03 19:32:28 +0200 |
commit | 74d39366640683914ab44db039ab48959c7dc91b (patch) | |
tree | 497a0304d40b4b7d03096b344ddffbffc94d4df8 /includes/admin/views/giglog_admin_page.php | |
parent | c9d80308ccb63a74f7dab723dd4e73a67b7fb597 (diff) | |
download | gigologadmin-74d39366640683914ab44db039ab48959c7dc91b.tar.gz gigologadmin-74d39366640683914ab44db039ab48959c7dc91b.tar.bz2 gigologadmin-74d39366640683914ab44db039ab48959c7dc91b.zip |
Editing concerts now work again.
Diffstat (limited to 'includes/admin/views/giglog_admin_page.php')
-rw-r--r-- | includes/admin/views/giglog_admin_page.php | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 4cb7dad..56376a8 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -331,15 +331,31 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { if(isset($_POST['editconcert'])) { - IF (empty($_POST['cname']) || empty($_POST['selectvenueadmin']) || empty($_POST['cdate']) || empty($_POST['ticket']) || empty($_POST['eventurl'])) - echo '<script language="javascript">alert("You are missing a value, concert was not updated"); </script>'; - else - { - GiglogAdmin_Concert::update_concert($_POST['pid'],$_POST['cname'], $_POST['selectvenueadmin'], $_POST['cdate'], $_POST['ticket'], $_POST['eventurl']); - GiglogAdmin_Concertlogs::update($_POST['pid'],$_POST['photo1'], $_POST['photo2'], $_POST['rev1'], $_POST['rev2']); - echo '<script language="javascript">alert("Yay, concert updated"); </script>'; + $roles = array_reduce( + ['photo1', 'photo1', 'rev1', 'rev2'], + function($roles, $r) { + if (isset($_POST[$r])) { + $roles[$r] = sanitize_user($_POST[$r]); + } + return $roles; + }, + [] + ); + + $attributes = [ + 'wpgconcert_name' => sanitize_text_field($_POST['cname']), + 'venue' => intval($_POST['selectvenueadmin']), + 'wpgconcert_date' => sanitize_text_field($_POST['cdate']), + 'wpgconcert_ticket' => esc_url_raw($_POST['ticket']), + 'wpgconcert_event' => esc_url_raw($_POST['eventurl']), + 'wpgconcert_roles' => $roles, + ]; + + $concert = GiglogAdmin_Concert::get(intval($_POST['pid'])); + if ($concert->update((object) $attributes)) { + // let user know the concert was updated. + // Look into admin_notices } - } |