public function __construct($timezone = NULL)
 {
     $this->_tables = array('Person_CPT' => new EE_Primary_Table('posts', 'ID'), 'Person_Meta' => new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID'));
     $this->_fields = array('Person_CPT' => array('PER_ID' => new EE_Primary_Key_Int_Field('ID', __("Person ID", 'event_espresso')), 'PER_full_name' => new EE_Plain_Text_Field('post_title', __("Person's Full Name", "event_espresso"), false, __("Unknown", "event_espresso")), 'PER_bio' => new EE_Post_Content_Field('post_content', __("Person's Biography", "event_espresso"), false, __("No Biography Provided", "event_espresso")), 'PER_slug' => new EE_Slug_Field('post_name', __("Person's URL Slug", "event_espresso"), false), 'PER_created' => new EE_Datetime_Field('post_date', __("Time Person Created", "event_espresso"), false, current_time('timestamp')), 'PER_short_bio' => new EE_Simple_HTML_Field('post_excerpt', __("Person's Short Biography", "event_espresso"), true, __("No Biography Provided", "event_espresso")), 'PER_modified' => new EE_Datetime_Field('post_modified', __("Time Person Last Modified", "event_espresso"), true, current_time('timestamp')), 'PER_wp_user' => new EE_Integer_Field('post_author', __("WP User that Created this Person", "event_espresso"), false, get_current_user_id()), 'PER_parent' => new EE_Integer_Field('post_parent', __("Parent Person", "event_espresso"), true), 'post_type' => new EE_WP_Post_Type_Field('espresso_people'), 'status' => new EE_WP_Post_Status_Field('post_status', __('Person\'s Status', 'event_espresso'), false, 'publish')), 'Person_Meta' => array('PERM_ID' => new EE_DB_Only_Int_Field('ATTM_ID', __('Person Meta Row ID', 'event_espresso'), false), 'PER_ID_fk' => new EE_DB_Only_Int_Field('ATT_ID', __("Foreign Key to People in Post Table", "event_espresso"), false), 'PER_fname' => new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''), 'PER_lname' => new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''), 'PER_address' => new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true, ''), 'PER_address2' => new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true, ''), 'PER_city' => new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''), 'STA_ID' => new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0, 'State'), 'CNT_ISO' => new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '', 'Country'), 'PER_zip' => new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''), 'PER_email' => new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''), 'PER_phone' => new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, '')));
     $this->_model_relations = array('Event' => new EE_HABTM_Relation('Person_Post'), 'Person_Post' => new EE_Has_Many_Relation(), 'State' => new EE_Belongs_To_Relation(), 'Country' => new EE_Belongs_To_Relation());
     $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_people', 'PERM_ID');
     parent::__construct($timezone);
 }
 protected function __construct($timezone = NULL)
 {
     $this->singular_item = __('Venue', 'event_espresso');
     $this->plural_item = __('Venues', 'event_espresso');
     $this->_tables = array('Venue_CPT' => new EE_Primary_Table('posts', 'ID'), 'Venue_Meta' => new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID'));
     $this->_fields = array('Venue_CPT' => array('VNU_ID' => new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")), 'VNU_name' => new EE_Plain_Text_Field('post_title', __("Venue Name", "event_espresso"), false, ''), 'VNU_desc' => new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false, ''), 'VNU_identifier' => new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''), 'VNU_created' => new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE, time()), 'VNU_short_desc' => new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true, ''), 'VNU_modified' => new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE, time()), 'VNU_wp_user' => new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false), 'parent' => new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false, 0), 'VNU_order' => new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1), 'post_type' => new EE_WP_Post_Type_Field('espresso_venues')), 'Venue_Meta' => array('VNUM_ID' => new EE_DB_Only_Int_Field('VNUM_ID', __("ID of Venue Meta Row", "event_espresso"), false), 'VNU_ID_fk' => new EE_DB_Only_Int_Field('VNU_ID', __("Foreign Key to Venue Post ", "event_espresso"), false), 'VNU_address' => new EE_Plain_Text_Field('VNU_address', __("Venue Address line 1", "event_espresso"), true, ''), 'VNU_address2' => new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true, ''), 'VNU_city' => new EE_Plain_Text_Field('VNU_city', __("Venue City", "event_espresso"), true, ''), 'STA_ID' => new EE_Foreign_Key_Int_Field('STA_ID', __("State ID", "event_espresso"), true, null, 'State'), 'CNT_ISO' => new EE_Foreign_Key_String_Field('CNT_ISO', __("Country Code", "event_espresso"), true, null, 'Country'), 'VNU_zip' => new EE_Plain_Text_Field('VNU_zip', __("Venue Zip/Postal Code", "event_espresso"), true), 'VNU_phone' => new EE_Plain_Text_Field('VNU_phone', __("Venue Phone", "event_espresso"), true), 'VNU_capacity' => new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true, EE_INF), 'VNU_url' => new EE_Plain_Text_Field('VNU_url', __('Venue Website', 'event_espresso'), true), 'VNU_virtual_phone' => new EE_Plain_Text_Field('VNU_virtual_phone', __('Call in Number', 'event_espresso'), true), 'VNU_virtual_url' => new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true), 'VNU_google_map_link' => new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true), 'VNU_enable_for_gmap' => new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false)));
     $this->_model_relations = array('Event' => new EE_HABTM_Relation('Event_Venue'), 'State' => new EE_Belongs_To_Relation(), 'Country' => new EE_Belongs_To_Relation(), 'Event_Venue' => new EE_Has_Many_Relation(), 'WP_User' => new EE_Belongs_To_Relation());
     //this model is generally available for reading
     $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
     parent::__construct($timezone);
 }
 /**
  *		private constructor to prevent direct creation
  *		@Constructor
  *		@access protected
  *		@return void
  */
 protected function __construct()
 {
     $this->singular_item = __('Attendee', 'event_espresso');
     $this->plural_item = __('Attendees', 'event_espresso');
     $this->_tables = array('Attendee_CPT' => new EE_Primary_Table('posts', 'ID'), 'Attendee_Meta' => new EE_Secondary_Table('esp_attendee_meta', 'ATTM_ID', 'ATT_ID'));
     $this->_fields = array('Attendee_CPT' => array('ATT_ID' => new EE_Primary_Key_Int_Field('ID', __("Attendee ID", "event_espresso")), 'ATT_full_name' => new EE_Plain_Text_Field('post_title', __("Attendee Full Name", "event_espresso"), false, __("Unknown", "event_espresso")), 'ATT_bio' => new EE_Post_Content_Field('post_content', __("Attendee Biography", "event_espresso"), false, __("No Biography Provided", "event_espresso")), 'ATT_slug' => new EE_Slug_Field('post_name', __("Attendee URL Slug", "event_espresso"), false), 'ATT_created' => new EE_Datetime_Field('post_date', __("Time Attendee Created", "event_espresso"), false, current_time('timestamp')), 'ATT_short_bio' => new EE_Simple_HTML_Field('post_excerpt', __("Attendee Short Biography", "event_espresso"), true, __("No Biography Provided", "event_espresso")), 'ATT_modified' => new EE_Datetime_Field('post_modified', __("Time Attendee Last Modified", "event_espresso"), true, current_time('timestamp')), 'ATT_author' => new EE_Integer_Field('post_author', __("WP User that Created Attendee", "event_espresso"), false, 0), 'ATT_parent' => new EE_DB_Only_Int_Field('post_parent', __("Parent Attendee (unused)", "event_espresso"), true), 'post_type' => new EE_WP_Post_Type_Field('espresso_attendees'), 'status' => new EE_WP_Post_Status_Field('post_status', __('Attendee Status', 'event_espresso'), false, 'publish')), 'Attendee_Meta' => array('ATTM_ID' => new EE_DB_Only_Int_Field('ATTM_ID', __('Attendee Meta Row ID', 'event_espresso'), false), 'ATT_ID_fk' => new EE_DB_Only_Int_Field('ATT_ID', __("Foreign Key to Attendee in Post Table", "event_espresso"), false), 'ATT_fname' => new EE_Plain_Text_Field('ATT_fname', __('First Name', 'event_espresso'), true, ''), 'ATT_lname' => new EE_Plain_Text_Field('ATT_lname', __('Last Name', 'event_espresso'), true, ''), 'ATT_address' => new EE_Plain_Text_Field('ATT_address', __('Address Part 1', 'event_espresso'), true, ''), 'ATT_address2' => new EE_Plain_Text_Field('ATT_address2', __('Address Part 2', 'event_espresso'), true, ''), 'ATT_city' => new EE_Plain_Text_Field('ATT_city', __('City', 'event_espresso'), true, ''), 'STA_ID' => new EE_Foreign_Key_Int_Field('STA_ID', __('State', 'event_espresso'), true, 0, 'State'), 'CNT_ISO' => new EE_Foreign_Key_String_Field('CNT_ISO', __('Country', 'event_espresso'), true, '', 'Country'), 'ATT_zip' => new EE_Plain_Text_Field('ATT_zip', __('ZIP/Postal Code', 'event_espresso'), true, ''), 'ATT_email' => new EE_Email_Field('ATT_email', __('Email Address', 'event_espresso'), true, ''), 'ATT_phone' => new EE_Plain_Text_Field('ATT_phone', __('Phone', 'event_espresso'), true, '')));
     $this->_model_relations = array('Registration' => new EE_Has_Many_Relation(), 'State' => new EE_Belongs_To_Relation(), 'Country' => new EE_Belongs_To_Relation(), 'Event' => new EE_HABTM_Relation('Registration'));
     require_once 'strategies/EE_CPT_Where_Conditions.strategy.php';
     $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_attendees', 'ATTM_ID');
     parent::__construct();
 }
 protected function __construct()
 {
     $this->singular_item = __('Venue', 'event_espresso');
     $this->plural_item = __('Venues', 'event_espresso');
     $this->_tables = array('Venue_CPT' => new EE_Primary_Table('posts', 'ID'), 'Venue_Meta' => new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID'));
     $this->_fields = array('Venue_CPT' => array('VNU_ID' => new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")), 'VNU_name' => new EE_Plain_Text_Field('post_title', __("Venue Name", "event_espresso"), false, ''), 'VNU_desc' => new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false, ''), 'VNU_identifier' => new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''), 'VNU_created' => new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), true, current_time('timestamp')), 'VNU_short_desc' => new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true, ''), 'VNU_modified' => new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), true, current_time('timestamp')), 'VNU_wp_user' => new EE_Integer_Field('post_author', __("Venue Creator", "event_espresso"), false, 1), 'parent' => new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false, 0), 'VNU_order' => new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1), 'post_type' => new EE_WP_Post_Type_Field('espresso_venues')), 'Venue_Meta' => array('VNUM_ID' => new EE_DB_Only_Int_Field('VNUM_ID', __("ID of Venue Meta Row", "event_espresso"), false), 'VNU_ID_fk' => new EE_DB_Only_Int_Field('VNU_ID', __("Foreign Key to Venue Post ", "event_espresso"), false), 'VNU_address' => new EE_Plain_Text_Field('VNU_address', __("Venue Address line 1", "event_espresso"), true, ''), 'VNU_address2' => new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true, ''), 'VNU_city' => new EE_Plain_Text_Field('VNU_city', __("Venue City", "event_espresso"), true, ''), 'STA_ID' => new EE_Foreign_Key_Int_Field('STA_ID', __("State ID", "event_espresso"), true, null, 'State'), 'CNT_ISO' => new EE_Foreign_Key_String_Field('CNT_ISO', __("Country Code", "event_espresso"), true, null, 'Country'), 'VNU_zip' => new EE_Plain_Text_Field('VNU_zip', __("Venue Zip/Postal Code", "event_espresso"), true), 'VNU_phone' => new EE_Plain_Text_Field('VNU_phone', __("Venue Phone", "event_espresso"), true), 'VNU_capacity' => new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true, INF), 'VNU_url' => new EE_Plain_Text_Field('VNU_url', __('Venue Website', 'event_espresso'), true), 'VNU_virtual_phone' => new EE_Plain_Text_Field('VNU_virtual_phone', __('Call in Number', 'event_espresso'), true), 'VNU_virtual_url' => new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true), 'VNU_google_map_link' => new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true), 'VNU_enable_for_gmap' => new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false)));
     $this->_model_relations = array('Event' => new EE_HABTM_Relation('Event_Venue'), 'State' => new EE_Belongs_To_Relation(), 'Country' => new EE_Belongs_To_Relation(), 'Event_Venue' => new EE_Has_Many_Relation());
     require_once EE_CLASSES . 'EE_Venue.class.php';
     require_once EE_MODELS . 'strategies/EE_CPT_Where_Conditions.strategy.php';
     $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_venues', 'VNUM_ID');
     parent::__construct();
 }
 /**
  * This is just injecting into the parent add_relationship_to so we do special handling on price relationships because we don't want to override any existing global default prices but instead insert NEW prices that get attached to the event.
  * See parent for param descriptions
  */
 public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array())
 {
     if ($relationName == 'Price') {
         //let's get the PRC object for the given ID to make sure that we aren't dealing with a default
         $prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
         //if EVT_ID = 0, then this is a default
         if ($prc_chk->get('EVT_ID') == 0) {
             //let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
             $prc_chk->set('PRC_ID', 0);
         }
         //run parent
         return parent::add_relationship_to($id_or_obj, $prc_chk, $relationName, $where_query);
     }
     //otherwise carry on as normal
     return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
 }