/**
  * @param string $validation_error_message
  * @param string $model_name  name of an EEM_Base model
  * @param array  $query_params     @see EEM_Base::get_all()
  * @param string $input_field_name the input will be treated as this field's value
  * @throws \EE_Error
  */
 public function __construct($validation_error_message = NULL, $model_name = '', $query_params = array(), $input_field_name = '')
 {
     if (!EE_Registry::instance()->is_model_name($model_name)) {
         throw new EE_Error(sprintf(__('You must provide a valid model object ', 'event_espresso'), $model_name));
     }
     $this->_model = EE_Registry::instance()->load_model($model_name);
     $this->_query_params = $query_params;
     if (empty($input_field_name)) {
         $input_field_name = $this->_model->primary_key_name();
     }
     $this->_input_field_name = $input_field_name;
     parent::__construct($validation_error_message);
 }
 /**
  * Automatically finds the related model info from the form, if present, and
  * save the relations indicated
  * @type string $relation_name
  * @return bool
  * @throws EE_Error
  */
 protected function _save_related_info($relation_name)
 {
     $relation_obj = $this->_model->related_settings_for($relation_name);
     if ($relation_obj instanceof EE_Belongs_To_Relation) {
         //there is just a foreign key on this model pointing to that one
         $this->_model_object->_add_relation_to($this->get_input_value($relation_name), $relation_name);
     } elseif ($relation_obj instanceof EE_Has_Many_Relation) {
         //then we want to consider all of its currently-related things.
         //if they're in this list, keep them
         //if they're not in this list, remove them
         //and lastly add all the new items
         throw new EE_Error(sprintf(__('Automatic saving of related info across a "has many" relation is not yet supported', "event_espresso")));
     } elseif ($relation_obj instanceof EE_HABTM_Relation) {
         //delete everything NOT in this list
         $normalized_input_value = $this->get_input_value($relation_name);
         if ($normalized_input_value && is_array($normalized_input_value)) {
             $where_query_params = array($relation_obj->get_other_model()->primary_key_name() => array('NOT_IN', $normalized_input_value));
         } else {
             $where_query_params = array();
         }
         $this->_model_object->_remove_relations($relation_name, $where_query_params);
         foreach ($normalized_input_value as $id) {
             $this->_model_object->_add_relation_to($id, $relation_name);
         }
     }
     return TRUE;
 }
 protected function __construct($timezone = NULL)
 {
     $this->singular_item = __('Term Taxonomy', 'event_espresso');
     $this->plural_item = __('Term Taxonomy', 'event_espresso');
     $this->_tables = array('Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'));
     $this->_fields = array('Term_Taxonomy' => array('term_taxonomy_id' => new EE_Primary_Key_Int_Field('term_taxonomy_id', __('Term-Taxonomy ID', 'event_espresso')), 'term_id' => new EE_Foreign_Key_Int_Field('term_id', __("Term Id", "event_espresso"), false, 0, 'Term'), 'taxonomy' => new EE_Plain_Text_Field('taxonomy', __('Taxonomy Name', 'event_espresso'), false, 'category'), 'description' => new EE_Post_Content_Field('description', __("Description of Term", "event_espresso"), false, ''), 'parent' => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0), 'term_count' => new EE_Integer_Field('count', __("Count of Objects attached", 'event_espresso'), false, 0)));
     $this->_model_relations = array('Term_Relationship' => new EE_Has_Many_Relation(), 'Term' => new EE_Belongs_To_Relation());
     $cpt_models = array_keys(EE_Registry::instance()->cpt_models());
     foreach ($cpt_models as $model_name) {
         $this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship');
     }
     $this->_indexes = array('term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')));
     $path_to_tax_model = '';
     $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
     $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected($path_to_tax_model);
     $this->_cap_restriction_generators[EEM_Base::caps_edit] = false;
     $this->_cap_restriction_generators[EEM_Base::caps_delete] = false;
     //add cap restrictions for editing relating to the "ee_edit_*"
     $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories')));
     $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories')));
     $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type')));
     //add cap restrictions for deleting relating to the "ee_deleting_*"
     $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories')));
     $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories')));
     $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions(array($path_to_tax_model . 'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type')));
     parent::__construct($timezone);
 }
 /**
  * Takes the default query parameters, and traverses them, adding the model relation chain
  * onto them (intelligently doesn't do that to logic query params like NOT, OR, and AND)
  * @param array $where_conditions
  * @param string $model_relation_chain
  * @return array
  * @throws \EE_Error
  */
 public function prepare_where_conditions_for_querying($where_conditions, $model_relation_chain)
 {
     $where_conditions_with_model_relation_chain_prefixes = array();
     if (!is_array($where_conditions)) {
         $where_conditions = array();
     }
     foreach ($where_conditions as $key => $value) {
         if (in_array($key, array('OR', 'AND', 'NOT')) || strpos($key, 'OR*') !== false || strpos($key, 'AND*') !== false || strpos($key, 'NOT*') !== false) {
             $where_conditions_with_model_relation_chain_prefixes[$key] = $this->prepare_where_conditions_for_querying($value, $model_relation_chain);
         } else {
             if ($model_relation_chain != '' && $model_relation_chain[strlen($model_relation_chain) - 1] != '.') {
                 $model_relation_chain = $model_relation_chain . ".";
             }
             //check for the current user id place holder, and if present change it
             if ($value === self::current_user_placeholder) {
                 $value = get_current_user_id();
             }
             //check for user field placeholder
             if ($key == self::user_field_name_placeholder) {
                 if (!$this->_model->wp_user_field_name()) {
                     throw new EE_Error(sprintf(__('There is no foreign key to the WP_User model on model %s. Please either modify your default where conditions, add a _model_chain_to_wp_user onto the model, or a proper EE_WP_User_Field onto the model', 'event_espresso'), $this->_model->get_this_model_name()));
                 }
                 $key = $this->_model->wp_user_field_name();
             }
             $where_conditions_with_model_relation_chain_prefixes[$model_relation_chain . $key] = $value;
         }
     }
     return $where_conditions_with_model_relation_chain_prefixes;
 }
 protected function __construct($timezone = null)
 {
     $this->_tables = array('New_Addon_Thing' => new EE_Primary_Table('esp_new_addon_thing', 'NEW_ID'));
     $this->_fields = array('New_Addon_Thing' => array('NEW_ID' => new EE_Primary_Key_Int_Field('NEW_ID', __("New Addon Thing ID", 'event_espresso')), 'NEW_name' => new EE_Plain_Text_Field('NEW_name', __('Name', 'event_espresso'), false), 'NEW_wp_user' => new EE_WP_User_Field('NEW_wp_user', __('Things Creator', 'event_espresso'), false)));
     $this->_model_relations = array('Attendee' => new EE_Has_Many_Relation(), 'WP_User' => new EE_Belongs_To_Relation());
     parent::__construct($timezone);
 }
 public function __construct($timezone = NULL)
 {
     $this->_tables = array('Person_Post' => new EE_Primary_Table('esp_people_to_post', 'PTP_ID'));
     $this->_fields = array('Person_Post' => array('PTP_ID' => new EE_Primary_Key_Int_Field('PTP_ID', __('Person to Event Link ID', 'event_espresso')), 'PER_ID' => new EE_Foreign_Key_Int_Field('PER_ID', __('Person Primary ID', 'event_espresso'), false, 0, 'Person'), 'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', __('Event ID', 'event_espresso'), false, 0, array('Event')), 'OBJ_type' => new EE_Any_Foreign_Model_Name_Field('OBJ_type', __('Model Person Related to', 'event_espresso'), false, 'Event', array('Event')), 'PER_OBJ_order' => new EE_Integer_Field('P2P_Order', __('Person to Event Order', 'event_Espresso'), false, 0), 'PT_ID' => new EE_Foreign_Key_Int_Field('PT_ID', __('People Type ID', 'event_espresso'), false, 0, 'Term_Taxonomy')));
     $this->_model_relations = array('Person' => new EE_Belongs_To_Relation(), 'Event' => new EE_Belongs_To_Any_Relation(), 'Term_Taxonomy' => new EE_Belongs_to_Relation());
     parent::__construct();
 }
 protected function __construct($timezone = NULL)
 {
     $this->singular_item = __('Registration Payment', 'event_espresso');
     $this->plural_item = __('Registration Payments', 'event_espresso');
     $this->_tables = array('Registration_Payment' => new EE_Primary_Table('esp_registration_payment', 'RPY_ID'));
     $this->_fields = array('Registration_Payment' => array('RPY_ID' => new EE_Primary_Key_Int_Field('RPY_ID', __('Registration Payment ID', 'event_espresso')), 'REG_ID' => new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'), 'PAY_ID' => new EE_Foreign_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso'), true, null, 'Payment'), 'RPY_amount' => new EE_Money_Field('RPY_amount', __('Amount attributed to the registration', 'event_espresso'), false, 0)));
     $this->_model_relations = array('Registration' => new EE_Belongs_To_Relation(), 'Payment' => new EE_Belongs_To_Relation());
     parent::__construct($timezone);
 }
 /**
  * private constructor to prevent direct creation
  * @Constructor
  * @access private
  * @return void
  */
 protected function __construct()
 {
     $this->singlular_item = __('Event Message Template', 'event_espresso');
     $this->plural_item = __('Event Message Templates', 'event_espresso');
     $this->_tables = array('Event_Message_Template' => new EE_Primary_Table('esp_event_message_template', 'EMT_ID'));
     $this->_fields = array('Event_Message_Template' => array('EMT_ID' => new EE_Primary_Key_Int_Field('EMT_ID', __('Event Message Template ID', 'event_espresso')), 'EVT_ID' => new EE_Foreign_Key_Int_Field('EVT_ID', __('The ID to the Event', 'event_espresso'), false, 0, 'Event'), 'GRP_ID' => new EE_Foreign_Key_Int_Field('GRP_ID', __('The ID to the Message Template Group', 'event_espresso'), false, 0, 'Message_Template_Group')));
     $this->_model_relations = array('Event' => new EE_Belongs_To_Relation(), 'Message_Template_Group' => new EE_Belongs_To_Relation());
     parent::__construct();
 }
 /**
  * 	constructor
  */
 protected function __construct()
 {
     $this->singular_item = __('Answer', 'event_espresso');
     $this->plural_item = __('Answers', 'event_espresso');
     $this->_tables = array('Answer' => new EE_Primary_Table('esp_answer', 'ANS_ID'));
     $this->_fields = array('Answer' => array('ANS_ID' => new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')), 'REG_ID' => new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'), 'QST_ID' => new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'), 'ANS_value' => new EE_Maybe_Serialized_Text_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '')));
     $this->_model_relations = array('Registration' => new EE_Belongs_To_Relation(), 'Question' => new EE_Belongs_To_Relation());
     parent::__construct();
 }
 /**
  * 		private constructor to prevent direct creation
  * 		@Constructor
  * 		@access protected
  * 		@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 void
  */
 protected function __construct($timezone)
 {
     $this->singular_item = __('Check-In', 'event_espresso');
     $this->plural_item = __('Check-Ins', 'event_espresso');
     $this->_tables = array('Checkin' => new EE_Primary_Table('esp_checkin', 'CHK_ID'));
     $this->_fields = array('Checkin' => array('CHK_ID' => new EE_Primary_Key_Int_Field('CHK_ID', 'Check-in ID'), 'REG_ID' => new EE_Foreign_Key_Int_Field('REG_ID', 'Registration Id', false, 0, 'Registration'), 'DTT_ID' => new EE_Foreign_Key_Int_Field('DTT_ID', 'Datetime Id', false, 0, 'Datetime'), 'CHK_in' => new EE_Boolean_Field('CHK_in', 'Whether a person has checked in or checked out', false, true), 'CHK_timestamp' => new EE_Datetime_Field('CHK_timestamp', __('When the row was modified', 'event_espresso'), false, current_time('timestamp'), $timezone)));
     $this->_model_relations = array('Registration' => new EE_Belongs_To_Relation(), 'Datetime' => new EE_Belongs_To_Relation());
     parent::__construct($timezone);
 }
 protected function __construct()
 {
     $this->singular_item = __('Question Group to Question Link', 'event_espresso');
     $this->plural_item = __('Question Group to Question Links', 'event_espresso');
     $this->_tables = array('Question_Group_Question' => new EE_Primary_Table('esp_question_group_question', 'QGQ_ID'));
     $this->_fields = array('Question_Group_Question' => array('QGQ_ID' => new EE_Primary_Key_Int_Field('QGQ_ID', __('Question Group to Question Link ID', 'event_espresso')), 'QSG_ID' => new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group ID', 'event_espresso'), false, 0, 'Question_Group'), 'QST_ID' => new EE_Foreign_Key_Int_Field('QST_ID', __('Question Id', 'event_espresso'), false, 0, 'Question'), 'QGQ_order' => new EE_Integer_Field('QGQ_order', __('Question Group Question Order', 'event_espresso'), false, 0)));
     $this->_model_relations = array('Question_Group' => new EE_Belongs_To_Relation(), 'Question' => new EE_Belongs_To_Relation());
     parent::__construct();
 }
 /**
  * @return EEM_Status
  */
 protected function __construct()
 {
     $this->singular_item = __('Status', 'event_espresso');
     $this->plural_item = __('Stati', 'event_espresso');
     $this->_tables = array('Status' => new EE_Primary_Table('esp_status', 'STS_ID'));
     $this->_fields = array('Status' => array('STS_ID' => new EE_Primary_Key_String_Field('STS_ID', __('Status ID', 'event_espresso')), 'STS_code' => new EE_Plain_Text_Field('STS_code', __('Status Code', 'event_espresso'), false, ''), 'STS_type' => new EE_Enum_Text_Field('STS_type', __("Type", "event_espresso"), false, 'event', array('event' => __("Event", "event_espresso"), 'registration' => __("Registration", "event_espresso"), 'transaction' => __("Transaction", "event_espresso"), 'payment' => __("Payment", "event_espresso"), 'email' => __("Email", "event_espresso"))), 'STS_can_edit' => new EE_Boolean_Field('STS_can_edit', __('Editable?', 'event_espresso'), false), 'STS_desc' => new EE_Simple_HTML_Field('STS_desc', __("Description", "event_espresso"), false, ''), 'STS_open' => new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false, false)));
     $this->_model_relations = array('Registration' => new EE_Has_Many_Relation(), 'Transaction' => new EE_Has_Many_Relation(), 'Payment' => new EE_Has_Many_Relation());
     parent::__construct();
 }
 protected function __construct()
 {
     $this->singular_item = __('Country', 'event_espresso');
     $this->plural_item = __('Countries', 'event_espresso');
     $this->_tables = array('Country' => new EE_Primary_Table('esp_country', 'CNT_ISO'));
     $this->_fields = array('Country' => array('CNT_active' => new EE_Boolean_Field('CNT_active', __('Country Appears in Dropdown Select Lists', 'event_espresso'), false, true), 'CNT_ISO' => new EE_Primary_Key_String_Field('CNT_ISO', __('Country ISO Code', 'event_espresso')), 'CNT_ISO3' => new EE_All_Caps_Text_Field('CNT_ISO3', __('Country ISO3 Code', 'event_espresso'), false, ''), 'RGN_ID' => new EE_All_Caps_Text_Field('RGN_ID', __('Region ID', 'event_espresso'), false, 0), 'CNT_name' => new EE_Plain_Text_Field('CNT_name', __('Country Name', 'event_espresso'), false, ''), 'CNT_cur_code' => new EE_All_Caps_Text_Field('CNT_cur_code', __('Country Currency Code', 'event_espresso'), false), 'CNT_cur_single' => new EE_Plain_Text_Field('CNT_cur_single', __('Currency Name Singular', 'event_espresso'), false), 'CNT_cur_plural' => new EE_Plain_Text_Field('CNT_cur_plural', __('Currency Name Plural', 'event_espresso'), false), 'CNT_cur_sign' => new EE_Plain_Text_Field('CNT_cur_sign', __('Currency Sign', 'event_espresso'), false), 'CNT_cur_sign_b4' => new EE_Boolean_Field('CNT_cur_sign_b4', __('Currency Sign Before Number', 'event_espresso'), false, true), 'CNT_cur_dec_plc' => new EE_Integer_Field('CNT_cur_dec_plc', __('Currency Decimal Places', 'event_espresso'), false, 2), 'CNT_cur_dec_mrk' => new EE_Plain_Text_Field('CNT_cur_dec_mrk', __('Currency Decimal Mark', 'event_espresso'), false, '.'), 'CNT_cur_thsnds' => new EE_Plain_Text_Field('CNT_cur_thsnds', __('Currency Thousands Seperator', 'event_espresso'), false, ','), 'CNT_tel_code' => new EE_Plain_Text_Field('CNT_tel_code', __('Country Telephone Code', 'event_espresso'), false, ''), 'CNT_is_EU' => new EE_Boolean_Field('CNT_is_EU', __('Country is Member of EU', 'event_espresso'), false, false)));
     $this->_model_relations = array('Attendee' => new EE_Has_Many_Relation(), 'State' => new EE_Has_Many_Relation(), 'Venue' => new EE_Has_Many_Relation());
     parent::__construct();
 }
 /**
  *		private constructor to prevent direct creation
  *		@Constructor
  *		@access protected
  *		@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 void
  */
 protected function __construct($timezone)
 {
     $this->singular_item = __('Transaction', 'event_espresso');
     $this->plural_item = __('Transactions', 'event_espresso');
     $this->_tables = array('Transaction' => new EE_Primary_Table('esp_transaction', 'TXN_ID'));
     $this->_fields = array('Transaction' => array('TXN_ID' => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), 'TXN_timestamp' => new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created', 'event_espresso'), false, current_time('timestamp'), $timezone), 'TXN_total' => new EE_Money_Field('TXN_total', __('Total value of Transaction', 'event_espresso'), false, 0), 'TXN_paid' => new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date', 'event_espresso'), false, 0), 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Transaction::incomplete_status_code, 'Status'), 'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data', 'event_espresso'), true, ''), 'TXN_hash_salt' => new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt', 'event_espresso'), true, '')));
     $this->_model_relations = array('Registration' => new EE_Has_Many_Relation(), 'Payment' => new EE_Has_Many_Relation(), 'Status' => new EE_Belongs_To_Relation(), 'Line_Item' => new EE_Has_Many_Relation(false));
     parent::__construct($timezone);
 }
 protected function __construct()
 {
     $this->singular_item = __('State/Province', 'event_espresso');
     $this->plural_item = __('States/Provinces', 'event_espresso');
     $this->_tables = array('State' => new EE_Primary_Table('esp_state', 'STA_ID'));
     $this->_fields = array('State' => array('STA_ID' => new EE_Primary_Key_Int_Field('STA_ID', __('State ID', 'event_espresso')), 'CNT_ISO' => new EE_Foreign_Key_String_Field('CNT_ISO', __('Country ISO Code', 'event_espresso'), false, NULL, 'Country'), 'STA_abbrev' => new EE_Plain_Text_Field('STA_abbrev', __('State Abbreviation', 'event_espresso'), false, ''), 'STA_name' => new EE_Plain_Text_Field('STA_name', __('State Name', 'event_espresso'), false, ''), 'STA_active' => new EE_Boolean_Field('STA_active', __("State Active Flag", "event_espresso"), false, false)));
     $this->_model_relations = array('Attendee' => new EE_Has_Many_Relation(), 'Country' => new EE_Belongs_To_Relation(), 'Venue' => new EE_Has_Many_Relation());
     parent::__construct();
 }
 protected function __construct()
 {
     $this->singular_item = __('Event to Question Group Link', 'event_espresso');
     $this->plural_item = __('Event to Question Group Links', 'event_espresso');
     $this->_tables = array('Event_Venue' => new EE_Primary_Table('esp_event_venue', 'EVV_ID'));
     $this->_fields = array('Event_Venue' => array('EVV_ID' => new EE_Primary_Key_Int_Field('EVV_ID', __('Event to Venue Link ID', 'event_espresso')), 'EVT_ID' => new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), 'VNU_ID' => new EE_Foreign_Key_Int_Field('VNU_ID', __('Venue ID', 'event_espresso'), false, 0, 'Venue'), 'EVV_primary' => new EE_Boolean_Field('EVV_primary', __("Flag indicating venue is primary one for event", "event_espresso"), false, true)));
     $this->_model_relations = array('Event' => new EE_Belongs_To_Relation(), 'Venue' => new EE_Belongs_To_Relation());
     parent::__construct();
 }
 /**
  *		private constructor to prevent direct creation
  *		@Constructor
  *		@access private
  *		@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 void
  */
 protected function __construct($timezone)
 {
     $this->singular_item = __('Ticket Template', 'event_espresso');
     $this->plural_item = __('Ticket Templates', 'event_espresso');
     $this->_tables = array('Ticket_Template' => new EE_Primary_Table('esp_ticket_template', 'TTM_ID'));
     $this->_fields = array('Ticket_Template' => array('TTM_ID' => new EE_Primary_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso')), 'TTM_name' => new EE_Plain_Text_Field('TTM_name', __('The name of the ticket template', 'event_espresso'), false, ''), 'TTM_description' => new EE_Plain_Text_Field('TTM_description', __('The description for the ticket template', 'event_espresso'), true, ''), 'TTM_file' => new EE_Plain_Text_Field('TTM_file', __('The file name for the actual template file saved on disk', 'event_espresso'), true, '')));
     $this->_model_relations = array('Ticket' => new EE_Has_Many_Relation());
     parent::__construct($timezone);
 }
 /**
  *		private constructor to prevent direct creation
  *		@Constructor
  *		@access private
  *		@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 void
  */
 protected function __construct($timezone)
 {
     $this->singular_item = __('Datetime Ticket', 'event_espresso');
     $this->plural_item = __('Datetime Tickets', 'event_espresso');
     $this->_tables = array('Datetime_Ticket' => new EE_Primary_Table('esp_datetime_ticket', 'DTK_ID'));
     $this->_fields = array('Datetime_Ticket' => array('DTK_ID' => new EE_Primary_Key_Int_Field('DTK_ID', __('Datetime Ticket ID', 'event_espresso')), 'DTT_ID' => new EE_Foreign_Key_Int_Field('DTT_ID', __('The ID to the Datetime', 'event_espresso'), false, 0, 'Datetime'), 'TKT_ID' => new EE_Foreign_Key_Int_Field('TKT_ID', __('The ID to the Ticket', 'event_espresso'), false, 0, 'Ticket')));
     $this->_model_relations = array('Ticket' => new EE_Belongs_To_Relation(), 'Datetime' => new EE_Belongs_To_Relation());
     parent::__construct($timezone);
 }
 protected function __construct()
 {
     $this->singular_item = __('Event to Question Group Link', 'event_espresso');
     $this->plural_item = __('Event to Question Group Links', 'event_espresso');
     $this->_tables = array('Event_Question_Group' => new EE_Primary_Table('esp_event_question_group', 'EQG_ID'));
     $this->_fields = array('Event_Question_Group' => array('EQG_ID' => new EE_Primary_Key_Int_Field('EQG_ID', __('Event to Question Group Link ID', 'event_espresso')), 'EVT_ID' => new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), 'QSG_ID' => new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'), 'EQG_primary' => new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees', 'event_espresso'), false, false)));
     $this->_model_relations = array('Event' => new EE_Belongs_To_Relation(), 'Question_Group' => new EE_Belongs_To_Relation());
     parent::__construct();
 }
 /**
  * 		private constructor to prevent direct creation
  * 		@Constructor
  * 		@access protected
  * 		@return void
  */
 protected function __construct()
 {
     $this->singular_item = __('Message Template', 'event_espresso');
     $this->plural_item = __('Message Templates', 'event_espresso');
     $this->_tables = array('Message_Template' => new EE_Primary_Table('esp_message_template', 'MTP_ID'));
     $this->_fields = array('Message_Template' => array('MTP_ID' => new EE_Primary_Key_Int_Field('MTP_ID', __('Message Template ID', 'event_espresso')), 'GRP_ID' => new EE_Foreign_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso'), FALSE, 0, 'Message_Template_Group'), 'MTP_template_field' => new EE_Plain_Text_Field('MTP_template_field', __('Field Name for this Template', 'event_espresso'), false, 'default'), 'MTP_context' => new EE_Plain_Text_Field('MTP_context', __('Message Type Context for this field', 'event_espresso'), false, 'admin'), 'MTP_content' => new EE_Serialized_Text_Field('MTP_content', __('The field content for the template', 'event_espresso'), false, '')));
     $this->_model_relations = array('Message_Template_Group' => new EE_Belongs_To_Relation());
     parent::__construct();
 }
 /**
  * 		private constructor to prevent direct creation
  * 		@Constructor
  * 		@access protected
  * 		@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 void
  */
 protected function __construct($timezone)
 {
     $this->singular_item = __('Ticket Price', 'event_espresso');
     $this->plural_item = __('Ticket Prices', 'event_espresso');
     $this->_tables = array('Ticket_Price' => new EE_Primary_Table('esp_ticket_price', 'TKP_ID'));
     $this->_fields = array('Ticket_Price' => array('TKP_ID' => new EE_Primary_Key_Int_Field('TKP_ID', 'Ticket Price ID'), 'TKT_ID' => new EE_Foreign_Key_Int_Field('TKT_ID', 'Ticket Id', false, 0, 'Ticket'), 'PRC_ID' => new EE_Foreign_Key_Int_Field('PRC_ID', 'Price ID', false, 0, 'Price')));
     $this->_model_relations = array('Ticket' => new EE_Belongs_To_Relation(), 'Price' => new EE_Belongs_To_Relation());
     parent::__construct($timezone);
 }
 /**
  * Retrieves the value for this calculation
  *
  * @param \EEM_Base                                               type $model
  * @param string                                                  $field_name
  * @param array                                                   $wpdb_row
  * @param \WP_REST_Request
  * @param \EventEspresso\core\libraries\rest_api\controllers\Base $controller
  * @return mixed|null
  * @throws \EE_Error
  */
 public function retrieve_calculated_field_value(\EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller)
 {
     $mapping = $this->mapping();
     if (isset($mapping[$model->get_this_model_name()]) && isset($mapping[$model->get_this_model_name()][$field_name])) {
         $classname = $mapping[$model->get_this_model_name()][$field_name];
         return call_user_func(array($classname, $field_name), $wpdb_row, $rest_request, $controller);
     }
     throw new Rest_Exception('calculated_field_does_not_exist', sprintf(__('There is no calculated field %1$s on resource %2$s', 'event_espresso'), $field_name, $model->get_this_model_name()));
 }
 /**
  *__construct
  */
 protected function __construct()
 {
     $this->singular_item = __('Term', 'event_espresso');
     $this->plural_item = __('Terms', 'event_espresso');
     $this->_tables = array('Term' => new EE_Primary_Table('terms', 'term_id'));
     $this->_fields = array('Term' => array('term_id' => new EE_Primary_Key_Int_Field('term_id', __('Term ID', 'event_espresso')), 'name' => new EE_Plain_Text_Field('name', __('Term Name', 'event_espresso'), false, ''), 'slug' => new EE_Slug_Field('slug', __('Term Slug', 'event_espresso'), false), 'term_group' => new EE_Integer_Field('term_group', __("Term Group", "event_espresso"), false, 0)));
     $this->_model_relations = array('Term_Taxonomy' => new EE_Has_Many_Relation());
     $this->_indexes = array('slug' => new EE_Unique_Index(array('slug')));
     parent::__construct();
 }
 /**
  * This returns the table prefix for the current model state.
  *
  * @global wpdb     $wpdb
  * @return string
  */
 public function get_table_prefix()
 {
     global $wpdb;
     if ($this->_global) {
         $prefix = $wpdb->base_prefix;
     } else {
         $prefix = $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id());
     }
     return $prefix;
 }
 protected function __construct()
 {
     $this->singular_item = __('Term Taxonomy', 'event_espresso');
     $this->plural_item = __('Term Taxonomy', 'event_espresso');
     $this->_tables = array('Term_Taxonomy' => new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id'));
     $this->_fields = array('Term_Taxonomy' => array('term_taxonomy_id' => new EE_Primary_Key_Int_Field('term_taxonomy_id', __('Term-Taxonomy ID', 'event_espresso')), 'term_id' => new EE_Foreign_Key_Int_Field('term_id', __("Term Id", "event_espresso"), false, 0, 'Term'), 'taxonomy' => new EE_Plain_Text_Field('taxonomy', __('Taxonomy Name', 'event_espresso'), false, 'category'), 'description' => new EE_Simple_HTML_Field('description', __("Description of Term", "event_espresso"), false, ''), 'parent' => new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0), 'term_count' => new EE_Integer_Field('count', __("Count of Objects attached", 'event_espresso'), false, 0)));
     $this->_model_relations = array('Term_Relationship' => new EE_Has_Many_Relation(), 'Term' => new EE_Belongs_To_Relation(), 'Event' => new EE_HABTM_Relation('Term_Relationship'), 'Venue' => new EE_HABTM_Relation('Term_Relationship'), 'Attendee' => new EE_HABTM_Relation('Term_Relationship'));
     $this->_indexes = array('term_id_taxonomy' => new EE_Unique_Index(array('term_id', 'taxonomy')));
     parent::__construct();
 }
 /**
  * 	constructor
  * @return EEM_Promotion_Object
  */
 protected function __construct()
 {
     $this->singular_item = __('Status', 'event_espresso');
     $this->plural_item = __('Stati', 'event_espresso');
     $this->_tables = array('Promotion_Object' => new EE_Primary_Table('esp_promotion_object', 'POB_ID'));
     $relations = array('Event', 'Venue', 'Datetime', 'Ticket', 'Transaction');
     $this->_fields = array('Promotion_Object' => array('POB_ID' => new EE_Primary_Key_Int_Field('POB_ID', __("Price-to-Object ID", "event_espresso")), 'PRO_ID' => new EE_Foreign_Key_Int_Field('PRO_ID', __("Promotion Object", "event_espresso"), false, 0, 'Promotion'), 'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', __("ID of the Related Object", "event_espresso"), false, 0, $relations), 'POB_type' => new EE_Any_Foreign_Model_Name_Field('POB_type', __("Model of Related Object", "event_espresso"), false, 'Event', $relations), 'POB_used' => new EE_Integer_Field('POB_used', __("Times the promotion has been used for this object", "event_espresso"), false, 0)));
     $this->_model_relations = array('Event' => new EE_Belongs_To_Any_Relation(), 'Venue' => new EE_Belongs_To_Any_Relation(), 'Datetime' => new EE_Belongs_To_Any_Relation(), 'Ticket' => new EE_Belongs_To_Any_Relation(), 'Transaction' => new EE_Belongs_To_Any_Relation(), 'Promotion' => new EE_Belongs_To_Relation());
     parent::__construct();
 }
 /**
  *    private constructor to prevent direct creation
  *
  * @Constructor
  * @access protected
  * @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_Transaction
  * @throws \EE_Error
  */
 protected function __construct($timezone)
 {
     $this->singular_item = __('Transaction', 'event_espresso');
     $this->plural_item = __('Transactions', 'event_espresso');
     $this->_tables = array('TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID'));
     $this->_fields = array('TransactionTable' => array('TXN_ID' => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), 'TXN_timestamp' => new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created', 'event_espresso'), false, time(), $timezone), 'TXN_total' => new EE_Money_Field('TXN_total', __('Total value of Transaction', 'event_espresso'), false, 0), 'TXN_paid' => new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date', 'event_espresso'), false, 0), 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'), 'TXN_session_data' => new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data', 'event_espresso'), true, ''), 'TXN_hash_salt' => new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt', 'event_espresso'), true, ''), 'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', __("Last Used Payment Method", 'event_espresso'), true, NULL, 'Payment_Method'), 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', __('Registration Steps', 'event_espresso'), FALSE, array())));
     $this->_model_relations = array('Registration' => new EE_Has_Many_Relation(), 'Payment' => new EE_Has_Many_Relation(), 'Status' => new EE_Belongs_To_Relation(), 'Line_Item' => new EE_Has_Many_Relation(false), 'Payment_Method' => new EE_Belongs_To_Relation(), 'Message' => new EE_Has_Many_Relation());
     $this->_model_chain_to_wp_user = '******';
     parent::__construct($timezone);
 }
 /**
  * 	constructor
  */
 protected function __construct($timezone = NULL)
 {
     $this->singular_item = __('Answer', 'event_espresso');
     $this->plural_item = __('Answers', 'event_espresso');
     $this->_tables = array('Answer' => new EE_Primary_Table('esp_answer', 'ANS_ID'));
     $this->_fields = array('Answer' => array('ANS_ID' => new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')), 'REG_ID' => new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'), 'QST_ID' => new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'), 'ANS_value' => new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '')));
     $this->_model_relations = array('Registration' => new EE_Belongs_To_Relation(), 'Question' => new EE_Belongs_To_Relation());
     $this->_model_chain_to_wp_user = '******';
     $this->_caps_slug = 'registrations';
     parent::__construct($timezone);
 }
 /**
  *		private constructor to prevent direct creation
  *		@Constructor
  *		@access protected
  *		@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_Payment
  */
 protected function __construct($timezone)
 {
     $this->singular_item = __('Payment', 'event_espresso');
     $this->plural_item = __('Payments', 'event_espresso');
     $this->_tables = array('Payment' => new EE_Primary_Table('esp_payment', 'PAY_ID'));
     $this->_fields = array('Payment' => array('PAY_ID' => new EE_Primary_Key_Int_Field('PAY_ID', __('Payment ID', 'event_espresso')), 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Payment::status_id_failed, 'Status'), 'PAY_timestamp' => new EE_Datetime_Field('PAY_timestamp', __('Timestamp of when payment was attempted', 'event_espresso'), false, current_time('timestamp'), $timezone), 'PAY_source' => new EE_All_Caps_Text_Field('PAY_source', __('User-friendly description of payment', 'event_espresso'), false, 'CART'), 'PAY_amount' => new EE_Money_Field('PAY_amount', __('Amount Payment should be for', 'event_espresso'), false, 0), 'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', __("Payment Method ID", 'event_espresso'), false, NULL, 'Payment_Method'), 'PAY_gateway_response' => new EE_Plain_Text_Field('PAY_gateway_response', __('Response from Gateway about the payment', 'event_espresso'), false, ''), 'PAY_txn_id_chq_nmbr' => new EE_Plain_Text_Field('PAY_txn_id_chq_nmbr', __('Gateway Transaction ID or Cheque Number', 'event_espresso'), true, ''), 'PAY_po_number' => new EE_Plain_Text_Field('PAY_po_number', __('Purchase or Sales Number', 'event_espresso'), true, ''), 'PAY_extra_accntng' => new EE_Simple_HTML_Field('PAY_extra_accntng', __('Extra Account Info', 'event_espresso'), true, ''), 'PAY_details' => new EE_Serialized_Text_Field('PAY_details', __('Full Gateway response about payment', 'event_espresso'), true, ''), 'PAY_redirect_url' => new EE_Plain_Text_Field('PAY_redirect_url', __("Redirect URL", 'event_espresso'), true), 'PAY_redirect_args' => new EE_Serialized_Text_Field('PAY_redirect_args', __("Key-Value POST vars to send along with redirect", 'event_espresso'), true)));
     $this->_model_relations = array('Transaction' => new EE_Belongs_To_Relation(), 'Status' => new EE_Belongs_To_Relation(), 'Payment_Method' => new EE_Belongs_To_Relation(), 'Registration' => new EE_HABTM_Relation('Registration_Payment'));
     $this->_model_chain_to_wp_user = '******';
     $this->_caps_slug = 'transactions';
     parent::__construct($timezone);
 }
 /**
  * @return EEM_Status
  */
 protected function __construct($timezone = NULL)
 {
     $this->singular_item = __('Status', 'event_espresso');
     $this->plural_item = __('Stati', 'event_espresso');
     $this->_tables = array('StatusTable' => new EE_Primary_Table('esp_status', 'STS_ID'));
     $this->_fields = array('StatusTable' => array('STS_ID' => new EE_Primary_Key_String_Field('STS_ID', __('Status ID', 'event_espresso')), 'STS_code' => new EE_Plain_Text_Field('STS_code', __('Status Code', 'event_espresso'), false, ''), 'STS_type' => new EE_Enum_Text_Field('STS_type', __("Type", "event_espresso"), false, 'event', array('event' => __("Event", "event_espresso"), 'registration' => __("Registration", "event_espresso"), 'transaction' => __("Transaction", "event_espresso"), 'payment' => __("Payment", "event_espresso"), 'email' => __("Email", "event_espresso"), 'message' => __("Message", "event_espresso"))), 'STS_can_edit' => new EE_Boolean_Field('STS_can_edit', __('Editable?', 'event_espresso'), false), 'STS_desc' => new EE_Simple_HTML_Field('STS_desc', __("Description", "event_espresso"), false, ''), 'STS_open' => new EE_Boolean_Field('STS_open', __("Open?", "event_espresso"), false, false)));
     $this->_model_relations = array('Registration' => new EE_Has_Many_Relation(), 'Transaction' => new EE_Has_Many_Relation(), 'Payment' => new EE_Has_Many_Relation());
     //this model is generally available for reading
     $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
     parent::__construct($timezone);
 }