summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreaChirulescu <andrea.chirulescu@gmail.com>2021-04-23 21:04:44 +0200
committerAndreaChirulescu <andrea.chirulescu@gmail.com>2021-04-23 21:04:44 +0200
commit283e01a784e566b1c6e44456202699cb127ab9a8 (patch)
tree8197ce9f48b5b1057c7864ba7c3245a90fc81bf3
parent763d6e5c803992bf92c7f95d57dc4c18f8604bad (diff)
parentc4446eb3cbe8f7074d565ad9b68192b2c5d222f4 (diff)
downloadgigologadmin-283e01a784e566b1c6e44456202699cb127ab9a8.tar.gz
gigologadmin-283e01a784e566b1c6e44456202699cb127ab9a8.tar.bz2
gigologadmin-283e01a784e566b1c6e44456202699cb127ab9a8.zip
Merge branch 'dev' of https://code.volse.net/wordpress/plugins/gigologadmin.git into andreaschanges
-rw-r--r--includes/concert.php67
1 files changed, 27 insertions, 40 deletions
diff --git a/includes/concert.php b/includes/concert.php
index 22fc13d..aff41ac 100644
--- a/includes/concert.php
+++ b/includes/concert.php
@@ -51,41 +51,36 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
}
}
- private static function check_duplicate($cname, $venue, $cdate, $ticketlink, $eventlink)
+ public static function create($name, $venue, $date, $ticketlink, $eventlink)
{
- global $wpdb;
-
- $cresults = GiglogAdmin_Concert::get($cname, $venue, $cdate);
- if ($cresults)
- return($cresults);
- else
- return ('new');
+ if ( GiglogAdmin_Concert::find($name, $venue, $date) ) {
+ error_log( 'DUPLICATE ROW detected: '
+ . ' CONCERT NAME ' . $name
+ . ', VENUE ID ' . $venue
+ . ', CONCERTDATE ' . $date);
- }
+ return NULL;
+ }
+ else {
+ $concert = new GiglogAdmin_Concert( (object) [
+ "wpgconcert_name" => $name,
+ "venue" => $venue,
+ "wpgconcert_date" => $date,
+ "wpgconcert_tickets" => $ticketlink,
+ "wpgconcert_event" => $eventlink,
+ ]);
- public static function create($cname, $venue, $cdate, $ticketlink, $eventlink)
- {
- $c = GiglogAdmin_Concert::check_duplicate($cname, $venue, $cdate, $ticketlink, $eventlink);
- if ($c=='new')
- {
- $attrs = new stdClass();
- $attrs->id = '';
- $attrs->wpgconcert_name = $cname;
- $attrs->venue = $venue;
- $attrs->wpgconcert_date = $cdate;
- $attrs->wpgconcert_tickets = $ticketlink;
- $attrs->wpgconcert_event = $eventlink;
- $cid = new GiglogAdmin_Concert($attrs);
- $cid->save();
+ $concert->save();
error_log( 'NEW CONCERT ADDED: '
- . ' ID: ' . $cid -> id()
- . ' CONCERT NAME ' . $cname
- . ', VENUE ID ' . $venue
- . ', CONCERTDATE ' . $cdate
- . ', Ticket LINK ' . $ticketlink
- . ', Event LINK ' . $eventlink);
- GiglogAdmin_Concertlogs::add($cid->id());
+ . ' ID: ' . $concert -> id()
+ . ' CONCERT NAME ' . $name
+ . ', VENUE ID ' . $venue
+ . ', CONCERTDATE ' . $date
+ . ', Ticket LINK ' . $ticketlink
+ . ', Event LINK ' . $eventlink);
+
+ GiglogAdmin_Concertlogs::add( $concert->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 (
@@ -96,15 +91,7 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
VALUES
(null, new.id, 1)
*/
- return $cid;
- }
- else
- {
- error_log( 'DUPLICATE ROW detected: '
- . ' CONCERT NAME ' . $cname
- . ', VENUE ID ' . $venue
- . ', CONCERTDATE ' . $cdate);
- return NULL;
+ return $concert;
}
}
@@ -155,7 +142,7 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
}
- public static function get($cname, $venue, $date)
+ public static function find($cname, $venue, $date)
{
global $wpdb;