summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreaChirulescu <andrea.chirulescu@gmail.com>2021-04-13 22:44:02 +0200
committerAndreaChirulescu <andrea.chirulescu@gmail.com>2021-04-13 22:44:02 +0200
commit4f0454005caa787e9fed33ca33671b7f4ada8a31 (patch)
tree450b0d03a7b80416183d028a20d3b10d54946512
parent0c437c746a8f964bf59ae9808a2b990d144bc39e (diff)
downloadgigologadmin-4f0454005caa787e9fed33ca33671b7f4ada8a31.tar.gz
gigologadmin-4f0454005caa787e9fed33ca33671b7f4ada8a31.tar.bz2
gigologadmin-4f0454005caa787e9fed33ca33671b7f4ada8a31.zip
Concert file wizardry to split create/createAndFind,Find functions
Adjustments in admin page and import gigs to use the above adjustments
-rw-r--r--includes/admin/views/giglog_admin_page.php7
-rw-r--r--includes/admin/views/giglog_import_gigs.php32
-rw-r--r--includes/concert.php46
3 files changed, 46 insertions, 39 deletions
diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php
index 3f43873..d3d97c0 100644
--- a/includes/admin/views/giglog_admin_page.php
+++ b/includes/admin/views/giglog_admin_page.php
@@ -137,7 +137,10 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
static function editforms()
{ global $wpdb;
$cid = filter_input(INPUT_POST, "cid");
- $c = GiglogAdmin_Concert::find_or_create($cid,'','','','','');
+ if($_POST['edit']=="EDIT" && !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::find_cid($cid);
+ else
+ $c = GiglogAdmin_Concert::find_cid('');
$content='<form method="POST" action="" class="concedit" > Form to create/edit concerts, bands, venues<br>'
.'<input type="hidden" name="pid" value="' .$c->id(). '" />'
@@ -337,7 +340,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) {
echo '<script language="javascript">alert("You are missing a value, concert was not created"); </script>';
else
{
- GiglogAdmin_Concert::create($_POST['selectband'], $_POST['selectvenueadmin'], $_POST['cdate'], $_POST['ticket'], $_POST['eventurl']);
+ GiglogAdmin_Concert::find_or_create($_POST['selectband'], $_POST['selectvenueadmin'], $_POST['cdate'], $_POST['ticket'], $_POST['eventurl']);
echo '<script language="javascript">alert("Yey, concert created"); </script>';
}
}
diff --git a/includes/admin/views/giglog_import_gigs.php b/includes/admin/views/giglog_import_gigs.php
index ae34c2d..a5fb72e 100644
--- a/includes/admin/views/giglog_import_gigs.php
+++ b/includes/admin/views/giglog_import_gigs.php
@@ -91,42 +91,12 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) {
//not sure how to check dates, hopefully manual verification of files will take care of it
- $cresults = GiglogAdmin_Concert::get($newconcert[0], $newconcert[1], $condate);
- if ($cresults) {
- error_log( 'DUPLICATE ROW detected: '
- . ' BAND ' . $band . ' with band ID ' . $newconcert[0]
- . ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1]
- . ', CONCERTDATE ' . $condate);
- } else {
- $id = GiglogAdmin_Concert::find_or_create(
- '',
+ GiglogAdmin_Concert::find_or_create(
$newconcert[0],
$newconcert[1],
$condate,
$ticketlink,
$eventlink);
-
- error_log( 'NEW CONCERT ADDED: '
- . ' ID: ' . $id->id()
- . ' BAND ' . $band . ' with band ID ' . $newconcert[0]
- . ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1]
- . ', CONCERTDATE ' . $condate
- . ', Ticket LINK ' . $ticketlink
- . ', Event LINK ' . $eventlink);
-
- GiglogAdmin_Concertlogs::add($id->id());
-
- /*the last line can be replaced by a trigger
- CREATE TRIGGER `insertIntoPhotoLogs` AFTER INSERT ON `wpg_concerts`
- FOR EACH ROW INSERT INTO wpg_concertlogs (
- wpg_concertlogs.id,
- wpg_concertlogs.wpgcl_concertid,
- wpg_concertlogs.wpgcl_status)
-
- VALUES
- (null, new.id, 1)
- */
- }
}
}
}
diff --git a/includes/concert.php b/includes/concert.php
index e7165cc..7453319 100644
--- a/includes/concert.php
+++ b/includes/concert.php
@@ -42,20 +42,36 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
$this->eventlink = isset($attrs->wpgconcert_event) ? $attrs->wpgconcert_event : NULL;
}
- static function find_or_create($id,$band, $venue, $cdate, $ticketlink, $eventlink)
+
+ static function find_or_create($band, $venue, $cdate, $ticketlink, $eventlink)
{
global $wpdb;
- if($id)
+ $cresults = GiglogAdmin_Concert::get($band, $venue, $cdate);
+ if ($cresults) {
+ error_log( 'DUPLICATE ROW detected: '
+ . ' BAND ID ' . $band
+ . ', VENUE ID ' . $venue
+ . ', CONCERTDATE ' . $cdate);
+ }
+ else
+ return GiglogAdmin_Concert::create($band, $venue, $cdate, $ticketlink, $eventlink);
+ }
+
+
+ static function find_cid($id)
+ { global $wpdb;
+ if(!empty($id))
{
$csql = 'SELECT * FROM wpg_concerts WHERE id="' . $id . '"';
$results = $wpdb->get_results($csql);
-
if ($results)
+ {
return new GiglogAdmin_Concert($results[0]);
+ }
}
- else {
-
- return GiglogAdmin_Concert::create($band, $venue, $cdate, $ticketlink, $eventlink);
+ else
+ { $arr = array_fill(0, 6, null);
+ return new GiglogAdmin_Concert($arr);
}
}
@@ -71,6 +87,24 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
$cid = new GiglogAdmin_Concert($attrs);
$cid->save();
+ error_log( 'NEW CONCERT ADDED: '
+ . ' ID: ' . $cid -> id()
+ . ' BAND ID ' . $band
+ . ', VENUE ID ' . $venue
+ . ', CONCERTDATE ' . $cdate
+ . ', Ticket LINK ' . $ticketlink
+ . ', Event LINK ' . $eventlink);
+ GiglogAdmin_Concertlogs::add($cid->id());
+ /*the last line can be replaced by a trigger
+ CREATE TRIGGER `insertIntoPhotoLogs` AFTER INSERT ON `wpg_concerts`
+ FOR EACH ROW INSERT INTO wpg_concertlogs (
+ wpg_concertlogs.id,
+ wpg_concertlogs.wpgcl_concertid,
+ wpg_concertlogs.wpgcl_status)
+
+ VALUES
+ (null, new.id, 1)
+ */
return $cid;
}