コード例 #1
0
 /**
  * This verifies the can_checkin() method in EE_registration
  *
  * @since 4.5.0
  *
  * @return void
  */
 function test_can_checkin()
 {
     //setup a registration
     $r = $this->new_model_obj_with_dependencies('Registration');
     $t = $this->new_ticket();
     //let's assign the above ticket to our registration
     $r->_add_relation_to($t, 'Ticket');
     $r->save();
     $d = EEM_Datetime_Ticket::instance()->get_one(array(array('TKT_ID' => $r->get('TKT_ID'))));
     $this->assertInstanceOf('EE_Datetime_Ticket', $d);
     $valid_DTT_ID = $d->get('DTT_ID');
     $invalid_DTT_ID = 99999;
     //k let's test the possible expected responses of can_checkin;
     //IGNORING status
     //test one: valid DTT and unapproved reg
     $r->set_status(EEM_Registration::status_id_not_approved);
     $this->assertTrue($r->can_checkin($valid_DTT_ID, false));
     //test two: invalid DTT and approved reg
     $r->set_status(EEM_Registration::status_id_approved);
     $this->assertFalse($r->can_checkin($invalid_DTT_ID, false));
     //including status
     //test one: valid DTT and approved reg
     $this->assertTrue($r->can_checkin($valid_DTT_ID));
     //test two: invalid DTT and approved reg
     $this->assertFalse($r->can_checkin($invalid_DTT_ID));
     //test three: valid DTT and not approved reg
     $r->set_status(EEM_Registration::status_id_not_approved);
     $this->assertFalse($r->can_checkin($valid_DTT_ID));
     //test four: valid DTT and incomplete reg
     $r->set_status(EEM_Registration::status_id_incomplete);
     $this->assertFalse($r->can_checkin($valid_DTT_ID));
     //test five: invalid DTT and incomplete reg
     $this->assertFalse($r->can_checkin($invalid_DTT_ID));
 }
コード例 #2
0
 /**
  *		This function is a singleton method used to instantiate the Espresso_model object
  *
  *		@access public
  *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
  *		@return EEM_Datetime_Ticket instance
  */
 public static function instance($timezone = NULL)
 {
     // check if instance of Espresso_model already exists
     if (self::$_instance === NULL) {
         // instantiate Espresso_model
         self::$_instance = new self($timezone);
     }
     //set timezone if we have in incoming string
     if (!empty($timezone)) {
         self::$_instance->set_timezone($timezone);
     }
     // Espresso_model object
     return self::$_instance;
 }
コード例 #3
0
 /**
  * The purpose of this method is simply to check whether this registration can checkin to the given datetime.
  *
  * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against
  * @param bool   $check_approved   This is used to indicate whether the caller wants can_checkin to also consider registration status as well as datetime access.
  *
  * @return bool
  */
 public function can_checkin($DTT_OR_ID, $check_approved = TRUE)
 {
     $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID);
     //first check registration status
     if ($check_approved && !$this->is_approved() || !$DTT_ID) {
         return false;
     }
     //is there a datetime ticket that matches this dtt_ID?
     if (!EEM_Datetime_Ticket::instance()->exists(array(array('TKT_ID' => $this->get('TKT_ID'), 'DTT_ID' => $DTT_ID)))) {
         return false;
     }
     //final check is against TKT_uses
     return $this->verify_can_checkin_against_TKT_uses($DTT_ID);
 }
コード例 #4
0
 /**
  *    posts_join_for_orderby
  *    usage:  $SQL .= EEH_Event_Query::posts_join_for_orderby( $orderby_params );
  *
  * @access    public
  * @param    array $orderby_params
  * @return    string
  */
 public static function posts_join_for_orderby($orderby_params = array())
 {
     $SQL = '';
     global $wpdb;
     foreach ((array) $orderby_params as $orderby) {
         switch ($orderby) {
             case 'ticket_start':
             case 'ticket_end':
                 $SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON (' . EEM_Datetime::instance()->table() . '.DTT_ID = ' . EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )';
                 $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = ' . EEM_Ticket::instance()->table() . '.TKT_ID )';
                 break;
             case 'venue_title':
             case 'city':
                 $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = ' . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
                 $SQL .= ' LEFT JOIN ' . EEM_Venue::instance()->table() . ' ON (' . EEM_Event_Venue::instance()->table() . '.VNU_ID = ' . EEM_Venue::instance()->table() . '.VNU_ID )';
                 break;
             case 'state':
                 $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = ' . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
                 $SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->second_table() . ' ON (' . EEM_Event_Venue::instance()->table() . '.VNU_ID = ' . EEM_Event_Venue::instance()->second_table() . '.VNU_ID )';
                 break;
                 break;
         }
     }
     return $SQL;
 }
コード例 #5
0
 /**
  * test verifies that if importing from site A to B, is the exported data from A
  * coincidentally has the same IDs as data in site B, that it DOES NOT overwrite it
  */
 public function test_save_data_array_to_db__from_other_site__data_with_same_ids()
 {
     //add some stuff to the db, but just keep references to their clones (which won't be affected by the entity mapper)
     $original_event1 = clone $this->new_model_obj_with_dependencies('Event');
     $original_datetime1 = clone $this->new_model_obj_with_dependencies('Datetime', array('EVT_ID' => $original_event1->ID()));
     $original_ticket1 = clone $this->new_model_obj_with_dependencies('Ticket');
     $original_datetime_ticket = clone $this->new_model_obj_with_dependencies('Datetime_Ticket', array('DTT_ID' => $original_datetime1->ID(), 'TKT_ID' => $original_ticket1->ID()));
     //now let's make some model objects that AREN'T in this database
     //that could confuse the importer
     $other_db_event = $this->new_model_obj_with_dependencies('Event', array(), false);
     $other_db_event_props = $other_db_event->model_field_array();
     $other_db_event_props['EVT_ID'] = $original_event1->ID();
     $other_db_event2 = $this->new_model_obj_with_dependencies('Event', array(), false);
     $other_db_event2_props = $other_db_event2->model_field_array();
     $other_db_event2_props['EVT_ID'] = 1000;
     $other_db_datetime = $this->new_model_obj_with_dependencies('Datetime', array('EVT_ID' => $original_event1->ID()), false);
     $other_db_datetime_props = $other_db_datetime->model_field_array();
     $other_db_datetime_props['DTT_ID'] = $original_datetime1->ID();
     $other_db_ticket = $this->new_model_obj_with_dependencies('Ticket', array('TKT_ID' => $original_ticket1->ID()), false);
     $other_db_ticket_props = $other_db_ticket->model_field_array();
     $other_db_ticket_props['TKT_ID'] = $original_ticket1->ID();
     $other_db_datetime_ticket = EE_Datetime_Ticket::new_instance(array('DTT_ID' => $original_datetime1->ID(), 'TKT_ID' => $original_ticket1->ID()), false);
     $other_db_datetime_ticket_props = $other_db_datetime_ticket->model_field_array();
     $other_db_datetime_ticket_props['DTK_ID'] = $original_datetime_ticket->ID();
     $event_count = EEM_Event::instance()->count();
     $datetime_count = EEM_Datetime::instance()->count();
     $ticket_count = EEM_Ticket::instance()->count();
     $datetime_ticket_count = EEM_Datetime_Ticket::instance()->count();
     $csv_data_rows = array('Event' => array($other_db_event_props, $other_db_event2_props), 'Datetime' => array($other_db_datetime_props), 'Ticket' => array($other_db_ticket_props), 'Datetime_Ticket' => array($other_db_datetime_ticket_props));
     //ok give it a whirl...
     $new_mappings = EE_Import::instance()->save_data_rows_to_db($csv_data_rows, true, array());
     //what should have happened:
     //we should have a mapping for each newly-inserted
     //events...
     $this->assertNotEmpty($new_mappings);
     $this->assertArrayHasKey('Event', $new_mappings);
     $event1_mapping = $new_mappings['Event'][$original_event1->ID()];
     $this->assertNotEmpty($event1_mapping);
     $this->assertNotEquals($original_event1->ID(), $event1_mapping);
     $event2_mapping = $new_mappings['Event'][1000];
     $this->assertNotEmpty($event2_mapping);
     $this->assertNotEquals(1000, $event1_mapping);
     //newly inerted datetime...
     $this->assertNotEmpty($new_mappings);
     $this->assertArrayHasKey('Datetime', $new_mappings);
     $datetime1_mapping = $new_mappings['Datetime'][$original_datetime1->ID()];
     $this->assertNotEmpty($datetime1_mapping);
     $this->assertNotEquals($original_datetime1->ID(), $datetime1_mapping);
     //newly inserted ticket
     $this->assertNotEmpty($new_mappings);
     $this->assertArrayHasKey('Ticket', $new_mappings);
     $ticket1_mapping = $new_mappings['Ticket'][$original_ticket1->ID()];
     $this->assertNotEmpty($ticket1_mapping);
     $this->assertNotEquals($original_ticket1->ID(), $ticket1_mapping);
     //and newly inserted datetime-ticke...
     $this->assertNotEmpty($new_mappings);
     $this->assertArrayHasKey('Datetime_Ticket', $new_mappings);
     $datetime_ticket_mapping = $new_mappings['Datetime_Ticket'][$original_datetime_ticket->ID()];
     $this->assertNotEmpty($datetime_ticket_mapping);
     $this->assertNotEquals($original_datetime_ticket->ID(), $datetime_ticket_mapping);
     //we should have inserted 2 new events, 1 new datetime, 1 new ticket and 1 new relation
     $this->assertEquals($event_count + 2, EEM_Event::instance()->count());
     $this->assertEquals($datetime_count + 1, EEM_Datetime::instance()->count());
     $this->assertEquals($ticket_count + 1, EEM_Ticket::instance()->count());
     $this->assertEquals($datetime_ticket_count + 1, EEM_Datetime_Ticket::instance()->count());
     //the newly inserted datetime shoudl have bene associated to the new event for $other_db_event_props
     $inserted_datetime_from_other_db = EEM_Datetime::instance()->get_one_by_ID($datetime1_mapping);
     $this->assertEquals($event1_mapping, $inserted_datetime_from_other_db->get('EVT_ID'));
     //there shoudl be a newly inserted ticket
     $inserted_ticket_from_other_db = EEM_Ticket::instance()->get_one_by_ID($ticket1_mapping);
     $this->assertNotNull($inserted_ticket_from_other_db);
     //the newly inserted datetime-ticket should hae been associated with the newly inserted datetime and ticket
     $inserted_datetime_ticket_from_other_db = EEM_Datetime_Ticket::instance()->get_one_by_ID($datetime_ticket_mapping);
     $this->assertEquals($ticket1_mapping, $inserted_datetime_ticket_from_other_db->get('TKT_ID'));
     $this->assertEquals($datetime1_mapping, $inserted_datetime_ticket_from_other_db->get('DTT_ID'));
     //the original event shouldn't be affected, nor should it have more than the original datetime on it
     $updated_event1 = EEM_Event::instance()->refresh_entity_map_from_db($original_event1->ID());
     $this->assertEEModelObjectsEquals($original_event1, $updated_event1);
     //the original datetime shoudln't be affected, nor shoudl it have more than the original ticket associagted with it
     $updated_datetime1 = EEM_Datetime::instance()->refresh_entity_map_from_db($original_datetime1->ID());
     $this->assertEEModelObjectsEquals($original_datetime1, $updated_datetime1);
 }
コード例 #6
0
 /**
  *    posts_join_for_orderby
  *    usage:  $SQL .= EEH_Event_Query::posts_join_for_orderby( $orderby_params );
  *
  * @access 	public
  * @param 	string   $SQL
  * @param 	array $orderby_params
  * @return 	string
  */
 public static function posts_join_for_orderby($SQL = '', $orderby_params = array())
 {
     foreach ((array) $orderby_params as $orderby) {
         switch ($orderby) {
             case 'ticket_start':
             case 'ticket_end':
                 $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name());
                 $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' = ' . EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' )';
                 break;
             case 'venue_title':
             case 'city':
                 $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
                 break;
             case 'state':
                 $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL);
                 $SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL);
                 break;
             case 'start_date':
             default:
                 $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table() . '.ID');
                 break;
         }
     }
     return $SQL;
 }