Completed
Branch BUG/3575-event-deletion-previe... (bbeda1)
by
unknown
06:40 queued 04:49
created
core/db_models/EEM_Currency.model.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
             'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
35 35
         );
36 36
         // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
37
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
38 38
 
39 39
         parent::__construct($timezone);
40 40
     }
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
     public function get_all_active($query_params = array())
49 49
     {
50 50
         $query_params[0]['CUR_active'] = true;
51
-        if (! isset($query_params['order_by'])) {
52
-            $query_params['order_by'] = array('CUR_code' => 'ASC','CUR_single' => 'ASC');
51
+        if ( ! isset($query_params['order_by'])) {
52
+            $query_params['order_by'] = array('CUR_code' => 'ASC', 'CUR_single' => 'ASC');
53 53
         }
54 54
         return $this->get_all($query_params);
55 55
     }
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
72 72
             $currencies = $this->get_all_active();
73 73
         } else {
74
-            $currencies = $this->get_all_active(array(array('CUR_code' => array('IN',$currencies_supported))));
74
+            $currencies = $this->get_all_active(array(array('CUR_code' => array('IN', $currencies_supported))));
75 75
         }
76 76
         return $currencies;
77 77
     }
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -11,68 +11,68 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_Currency extends EEM_Base
13 13
 {
14
-        // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+		// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17
-    protected function __construct($timezone = null)
18
-    {
19
-        $this->singular_item = esc_html__('Currency', 'event_espresso');
20
-        $this->plural_item = esc_html__('Currencies', 'event_espresso');
21
-        $this->_tables = array(
22
-            'Currency' => new EE_Primary_Table('esp_currency', 'CUR_code')
23
-        );
24
-        $this->_fields = array(
25
-            'Currency' => array(
26
-                'CUR_code' => new EE_Primary_Key_String_Field('CUR_code', esc_html__('Currency Code', 'event_espresso')),
27
-                'CUR_single' => new EE_Plain_Text_Field('CUR_single', esc_html__('Currency Name Singular', 'event_espresso'), false),
28
-                'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', esc_html__('Currency Name Plural', 'event_espresso'), false),
29
-                'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', esc_html__('Currency Sign', 'event_espresso'), false),
30
-                'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', esc_html__('Currency Decimal Places', 'event_espresso'), false, 2),
31
-                'CUR_active' => new EE_Boolean_Field('CUR_active', esc_html__('Active?', 'event_espresso'), false, true),
32
-            ));
33
-        $this->_model_relations = array(
34
-            'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
35
-        );
36
-        // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
17
+	protected function __construct($timezone = null)
18
+	{
19
+		$this->singular_item = esc_html__('Currency', 'event_espresso');
20
+		$this->plural_item = esc_html__('Currencies', 'event_espresso');
21
+		$this->_tables = array(
22
+			'Currency' => new EE_Primary_Table('esp_currency', 'CUR_code')
23
+		);
24
+		$this->_fields = array(
25
+			'Currency' => array(
26
+				'CUR_code' => new EE_Primary_Key_String_Field('CUR_code', esc_html__('Currency Code', 'event_espresso')),
27
+				'CUR_single' => new EE_Plain_Text_Field('CUR_single', esc_html__('Currency Name Singular', 'event_espresso'), false),
28
+				'CUR_plural' => new EE_Plain_Text_Field('CUR_plural', esc_html__('Currency Name Plural', 'event_espresso'), false),
29
+				'CUR_sign' => new EE_Plain_Text_Field('CUR_sign', esc_html__('Currency Sign', 'event_espresso'), false),
30
+				'CUR_dec_plc' => new EE_Integer_Field('CUR_dec_plc', esc_html__('Currency Decimal Places', 'event_espresso'), false, 2),
31
+				'CUR_active' => new EE_Boolean_Field('CUR_active', esc_html__('Active?', 'event_espresso'), false, true),
32
+			));
33
+		$this->_model_relations = array(
34
+			'Payment_Method' => new EE_HABTM_Relation('Currency_Payment_Method'),
35
+		);
36
+		// this model is generally available for reading
37
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38 38
 
39
-        parent::__construct($timezone);
40
-    }
39
+		parent::__construct($timezone);
40
+	}
41 41
 
42
-    /**
43
-     * Gets all thea ctive currencies, and orders them by their singular name, and then their code
44
-     * (may be overridden)
45
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
46
-     * @return EE_Currency[]
47
-     */
48
-    public function get_all_active($query_params = array())
49
-    {
50
-        $query_params[0]['CUR_active'] = true;
51
-        if (! isset($query_params['order_by'])) {
52
-            $query_params['order_by'] = array('CUR_code' => 'ASC','CUR_single' => 'ASC');
53
-        }
54
-        return $this->get_all($query_params);
55
-    }
56
-    /**
57
-     * Gets all the currencies which can be used by that payment method type
58
-     * @param EE_PMT_Base $payment_method_type
59
-     * @return EE_Currency[]
60
-     */
61
-    public function get_all_currencies_usable_by($payment_method_type)
62
-    {
63
-        if (
64
-            $payment_method_type instanceof EE_PMT_Base &&
65
-                $payment_method_type->get_gateway()
66
-        ) {
67
-            $currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
68
-        } else {
69
-            $currencies_supported = EE_Gateway::all_currencies_supported;
70
-        }
71
-        if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
72
-            $currencies = $this->get_all_active();
73
-        } else {
74
-            $currencies = $this->get_all_active(array(array('CUR_code' => array('IN',$currencies_supported))));
75
-        }
76
-        return $currencies;
77
-    }
42
+	/**
43
+	 * Gets all thea ctive currencies, and orders them by their singular name, and then their code
44
+	 * (may be overridden)
45
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
46
+	 * @return EE_Currency[]
47
+	 */
48
+	public function get_all_active($query_params = array())
49
+	{
50
+		$query_params[0]['CUR_active'] = true;
51
+		if (! isset($query_params['order_by'])) {
52
+			$query_params['order_by'] = array('CUR_code' => 'ASC','CUR_single' => 'ASC');
53
+		}
54
+		return $this->get_all($query_params);
55
+	}
56
+	/**
57
+	 * Gets all the currencies which can be used by that payment method type
58
+	 * @param EE_PMT_Base $payment_method_type
59
+	 * @return EE_Currency[]
60
+	 */
61
+	public function get_all_currencies_usable_by($payment_method_type)
62
+	{
63
+		if (
64
+			$payment_method_type instanceof EE_PMT_Base &&
65
+				$payment_method_type->get_gateway()
66
+		) {
67
+			$currencies_supported = $payment_method_type->get_gateway()->currencies_supported();
68
+		} else {
69
+			$currencies_supported = EE_Gateway::all_currencies_supported;
70
+		}
71
+		if ($currencies_supported == EE_Gateway::all_currencies_supported || empty($currencies_supported)) {
72
+			$currencies = $this->get_all_active();
73
+		} else {
74
+			$currencies = $this->get_all_active(array(array('CUR_code' => array('IN',$currencies_supported))));
75
+		}
76
+		return $currencies;
77
+	}
78 78
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Currency_Payment_Method.model.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
             'Payment_Method' => new EE_Belongs_To_Relation()
35 35
         );
36 36
         // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
37
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
38 38
         $this->_caps_slug = 'payment_methods';
39 39
         parent::__construct($timezone);
40 40
     }
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,31 +11,31 @@
 block discarded – undo
11 11
  */
12 12
 class EEM_Currency_Payment_Method extends EEM_Base
13 13
 {
14
-    // private instance of the Attendee object
15
-    protected static $_instance = null;
14
+	// private instance of the Attendee object
15
+	protected static $_instance = null;
16 16
 
17 17
 
18
-    protected function __construct($timezone = null)
19
-    {
20
-        $this->singular_item = esc_html__('Currency Usable by Payment Method', 'event_espresso');
21
-        $this->plural_item = esc_html__('Currencies Usable by Payment Methods', 'event_espresso');
22
-        $this->_tables = array(
23
-            'Currency_Payment_Method' => new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID')
24
-        );
25
-        $this->_fields = array(
26
-            'Currency_Payment_Method' => array(
27
-                'CPM_ID' => new EE_Primary_Key_Int_Field('CPM_ID', esc_html__('Currency to Payment Method LInk ID', 'event_espresso')),
28
-                'CUR_code' => new EE_Foreign_Key_String_Field('CUR_code', esc_html__('Currency Code', 'event_espresso'), false, '', 'Currency'),
29
-                'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', esc_html__('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method')
30
-            )
31
-        );
32
-        $this->_model_relations = array(
33
-            'Currency' => new EE_Belongs_To_Relation(),
34
-            'Payment_Method' => new EE_Belongs_To_Relation()
35
-        );
36
-        // this model is generally available for reading
37
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38
-        $this->_caps_slug = 'payment_methods';
39
-        parent::__construct($timezone);
40
-    }
18
+	protected function __construct($timezone = null)
19
+	{
20
+		$this->singular_item = esc_html__('Currency Usable by Payment Method', 'event_espresso');
21
+		$this->plural_item = esc_html__('Currencies Usable by Payment Methods', 'event_espresso');
22
+		$this->_tables = array(
23
+			'Currency_Payment_Method' => new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID')
24
+		);
25
+		$this->_fields = array(
26
+			'Currency_Payment_Method' => array(
27
+				'CPM_ID' => new EE_Primary_Key_Int_Field('CPM_ID', esc_html__('Currency to Payment Method LInk ID', 'event_espresso')),
28
+				'CUR_code' => new EE_Foreign_Key_String_Field('CUR_code', esc_html__('Currency Code', 'event_espresso'), false, '', 'Currency'),
29
+				'PMD_ID' => new EE_Foreign_Key_Int_Field('PMD_ID', esc_html__('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method')
30
+			)
31
+		);
32
+		$this->_model_relations = array(
33
+			'Currency' => new EE_Belongs_To_Relation(),
34
+			'Payment_Method' => new EE_Belongs_To_Relation()
35
+		);
36
+		// this model is generally available for reading
37
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
38
+		$this->_caps_slug = 'payment_methods';
39
+		parent::__construct($timezone);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Model_Parser.php 2 patches
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -9,153 +9,153 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Model_Parser
11 11
 {
12
-    const table_alias_model_relation_chain_separator = '__';
13
-    const table_alias_model_relation_chain_prefix_end = '___';
14
-    /**
15
-     * Adds a period onto the front and end of the string. This often helps in searching.
16
-     * For example, if we want to find the model name "Event", it can be tricky when the following are possible
17
-     * "","Event.EVT_ID","Event","Event_Venue.Venue.VNU_ID",etc. It's easier to look for ".Event." in
18
-     * "..",".Event.EVT_ID.", ".Event.", and ".Event_Venue.Venue.VNU_ID", especially when the last example should NOT
19
-     * be found because the "Event" model isn't mentioned- it's just a string that has a model name that coincidentally
20
-     * has it as a substring
21
-     * @param string $string_to_pad
22
-     * @return string
23
-     */
24
-    public static function pad_with_periods($string_to_pad)
25
-    {
26
-        return "." . $string_to_pad . ".";
27
-    }
28
-    /**
29
-     * Basically undoes _pad_with_periods
30
-     * @param string $string_to_trim
31
-     * @return string
32
-     */
33
-    public static function trim_periods($string_to_trim)
34
-    {
35
-        return trim($string_to_trim, '.');
36
-    }
12
+	const table_alias_model_relation_chain_separator = '__';
13
+	const table_alias_model_relation_chain_prefix_end = '___';
14
+	/**
15
+	 * Adds a period onto the front and end of the string. This often helps in searching.
16
+	 * For example, if we want to find the model name "Event", it can be tricky when the following are possible
17
+	 * "","Event.EVT_ID","Event","Event_Venue.Venue.VNU_ID",etc. It's easier to look for ".Event." in
18
+	 * "..",".Event.EVT_ID.", ".Event.", and ".Event_Venue.Venue.VNU_ID", especially when the last example should NOT
19
+	 * be found because the "Event" model isn't mentioned- it's just a string that has a model name that coincidentally
20
+	 * has it as a substring
21
+	 * @param string $string_to_pad
22
+	 * @return string
23
+	 */
24
+	public static function pad_with_periods($string_to_pad)
25
+	{
26
+		return "." . $string_to_pad . ".";
27
+	}
28
+	/**
29
+	 * Basically undoes _pad_with_periods
30
+	 * @param string $string_to_trim
31
+	 * @return string
32
+	 */
33
+	public static function trim_periods($string_to_trim)
34
+	{
35
+		return trim($string_to_trim, '.');
36
+	}
37 37
 
38 38
 
39 39
 
40
-    /**
41
-     * Gets the calculated table's alias
42
-     * @param string $model_relation_chain or query param
43
-     * @param        $this_model_name
44
-     * @return string which can be added onto table aliases to make them unique
45
-     */
46
-    public static function extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this_model_name)
47
-    {
48
-        // eg $model_relation_chain = 'Venue.Event_Venue.Event.Registration", and $this_model_name = 'Event'
49
-        $model_relation_chain = self::pad_with_periods($model_relation_chain);
50
-        $this_model_name = self::pad_with_periods($this_model_name);
51
-        // eg '.Venue.Event_Venue.Event.Registration." and '.Event.'
52
-        // remove this model name and everything afterwards
53
-        $pos_of_model_name = strpos($model_relation_chain, $this_model_name);
54
-        $model_relation_chain = substr($model_relation_chain, 0, $pos_of_model_name);
55
-        // eg '.Venue.Event_Venue.'
56
-        // trim periods
57
-        $model_relation_chain = self::trim_periods($model_relation_chain);
58
-        // eg 'Venue.Event_Venue'
59
-        // replace periods with double-underscores
60
-        $model_relation_chain = str_replace(".", self::table_alias_model_relation_chain_separator, $model_relation_chain);
61
-        // eg 'Venue__Event_Venue'
62
-        if ($model_relation_chain != '') {
63
-            $model_relation_chain = $model_relation_chain . self::table_alias_model_relation_chain_prefix_end;
64
-        }
65
-        // eg 'Venue_Event_Venue___'
66
-        return $model_relation_chain;
67
-    }
68
-    /**
69
-     * Gets the table's alias (without prefix or anything)
70
-     * @param string $table_alias_with_model_relation_chain_prefix which CAN have a table alias model relation chain prefix (or not)
71
-     * @return string
72
-     */
73
-    public static function remove_table_alias_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix)
74
-    {
75
-        // does this actually have a table alias model relation chain prefix?
76
-        $pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end);
77
-        if ($pos !== false) {
78
-            // yes
79
-            // find that triple underscore and remove it and everything before it
80
-            $table_alias = substr($table_alias_with_model_relation_chain_prefix, $pos + strlen(self::table_alias_model_relation_chain_prefix_end));
81
-        } else {
82
-            $table_alias = $table_alias_with_model_relation_chain_prefix;
83
-        }
84
-        return $table_alias;
85
-    }
86
-    /**
87
-     * Gets the table alias model relation chain prefix from the table alias already containing it
88
-     * @param string $table_alias_with_model_relation_chain_prefix
89
-     * @return string
90
-     */
91
-    public static function get_prefix_from_table_alias_with_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix)
92
-    {
93
-        // does this actually have a table alias model relation chain prefix?
94
-        $pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end);
95
-        if ($pos !== false) {
96
-            // yes
97
-            // find that triple underscore and remove it and everything before it
98
-            $prefix = substr($table_alias_with_model_relation_chain_prefix, 0, $pos + strlen(self::table_alias_model_relation_chain_prefix_end));
99
-        } else {
100
-            $prefix = '';
101
-        }
102
-        return $prefix;
103
-    }
40
+	/**
41
+	 * Gets the calculated table's alias
42
+	 * @param string $model_relation_chain or query param
43
+	 * @param        $this_model_name
44
+	 * @return string which can be added onto table aliases to make them unique
45
+	 */
46
+	public static function extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this_model_name)
47
+	{
48
+		// eg $model_relation_chain = 'Venue.Event_Venue.Event.Registration", and $this_model_name = 'Event'
49
+		$model_relation_chain = self::pad_with_periods($model_relation_chain);
50
+		$this_model_name = self::pad_with_periods($this_model_name);
51
+		// eg '.Venue.Event_Venue.Event.Registration." and '.Event.'
52
+		// remove this model name and everything afterwards
53
+		$pos_of_model_name = strpos($model_relation_chain, $this_model_name);
54
+		$model_relation_chain = substr($model_relation_chain, 0, $pos_of_model_name);
55
+		// eg '.Venue.Event_Venue.'
56
+		// trim periods
57
+		$model_relation_chain = self::trim_periods($model_relation_chain);
58
+		// eg 'Venue.Event_Venue'
59
+		// replace periods with double-underscores
60
+		$model_relation_chain = str_replace(".", self::table_alias_model_relation_chain_separator, $model_relation_chain);
61
+		// eg 'Venue__Event_Venue'
62
+		if ($model_relation_chain != '') {
63
+			$model_relation_chain = $model_relation_chain . self::table_alias_model_relation_chain_prefix_end;
64
+		}
65
+		// eg 'Venue_Event_Venue___'
66
+		return $model_relation_chain;
67
+	}
68
+	/**
69
+	 * Gets the table's alias (without prefix or anything)
70
+	 * @param string $table_alias_with_model_relation_chain_prefix which CAN have a table alias model relation chain prefix (or not)
71
+	 * @return string
72
+	 */
73
+	public static function remove_table_alias_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix)
74
+	{
75
+		// does this actually have a table alias model relation chain prefix?
76
+		$pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end);
77
+		if ($pos !== false) {
78
+			// yes
79
+			// find that triple underscore and remove it and everything before it
80
+			$table_alias = substr($table_alias_with_model_relation_chain_prefix, $pos + strlen(self::table_alias_model_relation_chain_prefix_end));
81
+		} else {
82
+			$table_alias = $table_alias_with_model_relation_chain_prefix;
83
+		}
84
+		return $table_alias;
85
+	}
86
+	/**
87
+	 * Gets the table alias model relation chain prefix from the table alias already containing it
88
+	 * @param string $table_alias_with_model_relation_chain_prefix
89
+	 * @return string
90
+	 */
91
+	public static function get_prefix_from_table_alias_with_model_relation_chain_prefix($table_alias_with_model_relation_chain_prefix)
92
+	{
93
+		// does this actually have a table alias model relation chain prefix?
94
+		$pos = strpos($table_alias_with_model_relation_chain_prefix, self::table_alias_model_relation_chain_prefix_end);
95
+		if ($pos !== false) {
96
+			// yes
97
+			// find that triple underscore and remove it and everything before it
98
+			$prefix = substr($table_alias_with_model_relation_chain_prefix, 0, $pos + strlen(self::table_alias_model_relation_chain_prefix_end));
99
+		} else {
100
+			$prefix = '';
101
+		}
102
+		return $prefix;
103
+	}
104 104
 
105
-    /**
106
-     * Gets the table alias model relation chain prefix (ie, what can be prepended onto
107
-     * EE_Model_Field::get_qualified_column() to get the proper column name for that field
108
-     * in a specific query) from teh query param (eg 'Registration.Event.EVT_ID').
109
-     *
110
-     * @param string $model_name of the model on which the related query param was found to be belong
111
-     * @param string $original_query_param
112
-     * @return string
113
-     */
114
-    public static function extract_table_alias_model_relation_chain_from_query_param($model_name, $original_query_param)
115
-    {
116
-        $relation_chain = self::extract_model_relation_chain($model_name, $original_query_param);
117
-        $table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($relation_chain, $model_name);
118
-        return $table_alias_with_model_relation_chain_prefix;
119
-    }
120
-    /**
121
-     * Gets the model relation chain to $model_name from the $original_query_param.
122
-     * Eg, if $model_name were 'Payment', and $original_query_param were 'Registration.Transaction.Payment.PAY_ID',
123
-     * this would return 'Registration.Transaction.Payment'. Also if the query param were 'Registration.Transaction.Payment'
124
-     * and $model_name were 'Payment', it should return 'Registration.Transaction.Payment'
125
-     * @param string $model_name
126
-     * @param string $original_query_param
127
-     * @return string
128
-     */
129
-    public static function extract_model_relation_chain($model_name, $original_query_param)
130
-    {
131
-        // prefix and postfix both with a period, as this facilitates searching
132
-        $model_name = EE_Model_Parser::pad_with_periods($model_name);
133
-        $original_query_param = EE_Model_Parser::pad_with_periods($original_query_param);
134
-        $pos_of_model_string = strpos($original_query_param, $model_name);
135
-        // eg, if we're looking for the model relation chain from Event to Payment, the original query param is probably something like
136
-        // "Registration.Transaction.Payment.PAY_ID", $pos_of_model_string points to the 'P' or Payment. We want the string
137
-        // "Registration.Transaction.Payment"
138
-        $model_relation_chain = substr($original_query_param, 0, $pos_of_model_string + strlen($model_name));
139
-        return EE_Model_Parser::trim_periods($model_relation_chain);
140
-    }
105
+	/**
106
+	 * Gets the table alias model relation chain prefix (ie, what can be prepended onto
107
+	 * EE_Model_Field::get_qualified_column() to get the proper column name for that field
108
+	 * in a specific query) from teh query param (eg 'Registration.Event.EVT_ID').
109
+	 *
110
+	 * @param string $model_name of the model on which the related query param was found to be belong
111
+	 * @param string $original_query_param
112
+	 * @return string
113
+	 */
114
+	public static function extract_table_alias_model_relation_chain_from_query_param($model_name, $original_query_param)
115
+	{
116
+		$relation_chain = self::extract_model_relation_chain($model_name, $original_query_param);
117
+		$table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($relation_chain, $model_name);
118
+		return $table_alias_with_model_relation_chain_prefix;
119
+	}
120
+	/**
121
+	 * Gets the model relation chain to $model_name from the $original_query_param.
122
+	 * Eg, if $model_name were 'Payment', and $original_query_param were 'Registration.Transaction.Payment.PAY_ID',
123
+	 * this would return 'Registration.Transaction.Payment'. Also if the query param were 'Registration.Transaction.Payment'
124
+	 * and $model_name were 'Payment', it should return 'Registration.Transaction.Payment'
125
+	 * @param string $model_name
126
+	 * @param string $original_query_param
127
+	 * @return string
128
+	 */
129
+	public static function extract_model_relation_chain($model_name, $original_query_param)
130
+	{
131
+		// prefix and postfix both with a period, as this facilitates searching
132
+		$model_name = EE_Model_Parser::pad_with_periods($model_name);
133
+		$original_query_param = EE_Model_Parser::pad_with_periods($original_query_param);
134
+		$pos_of_model_string = strpos($original_query_param, $model_name);
135
+		// eg, if we're looking for the model relation chain from Event to Payment, the original query param is probably something like
136
+		// "Registration.Transaction.Payment.PAY_ID", $pos_of_model_string points to the 'P' or Payment. We want the string
137
+		// "Registration.Transaction.Payment"
138
+		$model_relation_chain = substr($original_query_param, 0, $pos_of_model_string + strlen($model_name));
139
+		return EE_Model_Parser::trim_periods($model_relation_chain);
140
+	}
141 141
 
142
-    /**
143
-     * Replaces the specified model in teh model relation chain with teh join model.
144
-     * Eg EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain(
145
-     * "Ticket", "Datetime_Ticket", "Datetime.Ticket" ) will return
146
-     * "Datetime.Datetime_Ticket" which can be used to find the table alias model relation chain prefix
147
-     * using EE_Model_Parser::extract_table_alias_model_relation_chain_prefix
148
-     * @param string $model_name
149
-     * @param string $join_model_name
150
-     * @param string $model_relation_chain
151
-     * @return string
152
-     */
153
-    public static function replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_name, $model_relation_chain)
154
-    {
155
-        $model_name = EE_Model_Parser::pad_with_periods($model_name);
156
-        $join_model_name = EE_Model_Parser::pad_with_periods($join_model_name);
157
-        $model_relation_chain = EE_Model_Parser::pad_with_periods($model_relation_chain);
158
-        $replaced_with_periods = str_replace($model_name, $join_model_name, $model_relation_chain);
159
-        return EE_Model_Parser::trim_periods($replaced_with_periods);
160
-    }
142
+	/**
143
+	 * Replaces the specified model in teh model relation chain with teh join model.
144
+	 * Eg EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain(
145
+	 * "Ticket", "Datetime_Ticket", "Datetime.Ticket" ) will return
146
+	 * "Datetime.Datetime_Ticket" which can be used to find the table alias model relation chain prefix
147
+	 * using EE_Model_Parser::extract_table_alias_model_relation_chain_prefix
148
+	 * @param string $model_name
149
+	 * @param string $join_model_name
150
+	 * @param string $model_relation_chain
151
+	 * @return string
152
+	 */
153
+	public static function replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_name, $model_relation_chain)
154
+	{
155
+		$model_name = EE_Model_Parser::pad_with_periods($model_name);
156
+		$join_model_name = EE_Model_Parser::pad_with_periods($join_model_name);
157
+		$model_relation_chain = EE_Model_Parser::pad_with_periods($model_relation_chain);
158
+		$replaced_with_periods = str_replace($model_name, $join_model_name, $model_relation_chain);
159
+		return EE_Model_Parser::trim_periods($replaced_with_periods);
160
+	}
161 161
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public static function pad_with_periods($string_to_pad)
25 25
     {
26
-        return "." . $string_to_pad . ".";
26
+        return ".".$string_to_pad.".";
27 27
     }
28 28
     /**
29 29
      * Basically undoes _pad_with_periods
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $model_relation_chain = str_replace(".", self::table_alias_model_relation_chain_separator, $model_relation_chain);
61 61
         // eg 'Venue__Event_Venue'
62 62
         if ($model_relation_chain != '') {
63
-            $model_relation_chain = $model_relation_chain . self::table_alias_model_relation_chain_prefix_end;
63
+            $model_relation_chain = $model_relation_chain.self::table_alias_model_relation_chain_prefix_end;
64 64
         }
65 65
         // eg 'Venue_Event_Venue___'
66 66
         return $model_relation_chain;
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Secondary_Table.php 2 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -8,118 +8,118 @@
 block discarded – undo
8 8
  */
9 9
 class EE_Secondary_Table extends EE_Table_Base
10 10
 {
11
-    protected $_extra_join_conditions;
11
+	protected $_extra_join_conditions;
12 12
 
13
-    /**
14
-     *
15
-     * @global type $wpdb
16
-     * @param string $table_name with or without wpdb prefix
17
-     * @param string $pk_column name of primary key column on THIS table
18
-     * @param string $fk_column the name of the COLUMN that is a foreign key to the primary table's primary key
19
-     * @param string $extra_join_conditions string for additional SQL to add onto the join statement's ON condition
20
-     * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install,
21
-     *                  or whether each site on a multisite install has a copy of this table
22
-     */
23
-    public function __construct($table_name, $pk_column, $fk_column = null, $extra_join_conditions = null, $global = false)
24
-    {
25
-        $this->_fk_on_table = $fk_column;
26
-        $this->_extra_join_conditions = $extra_join_conditions;
27
-        parent::__construct($table_name, $pk_column, $global);
28
-    }
29
-    public function get_fk_on_table()
30
-    {
31
-        return $this->_fk_on_table;
32
-    }
33
-    public function _construct_finalize_set_table_to_join_with(EE_Table_Base $table)
34
-    {
35
-        $this->_table_to_join_with = $table;
36
-    }
37
-    /**
38
-     *
39
-     * @return string of sql like "Event.post_type = 'event'", which gets added to
40
-     * the end of the join statement with the primary table
41
-     */
42
-    public function get_extra_join_conditions()
43
-    {
44
-        return $this->_extra_join_conditions;
45
-    }
46
-    /**
47
-     *
48
-     * @return EE_Primary_Table
49
-     */
50
-    public function get_table_to_join_with()
51
-    {
52
-        return $this->_table_to_join_with;
53
-    }
54
-    /**
55
-     * creates join statement FROM primary table
56
-     * gets SQL like "LEFT JOIN table_name AS table_alias ON other_table_alias.pk = table_alias.fk
57
-     *
58
-     * @param string $table allows us to set special conditions on the $table_name portion of the join query (i.e. doing a subquery)
59
-     * @return string of SQL
60
-     */
61
-    public function get_join_sql($primary_table_alias_with_model_chain_prefix)
62
-    {
13
+	/**
14
+	 *
15
+	 * @global type $wpdb
16
+	 * @param string $table_name with or without wpdb prefix
17
+	 * @param string $pk_column name of primary key column on THIS table
18
+	 * @param string $fk_column the name of the COLUMN that is a foreign key to the primary table's primary key
19
+	 * @param string $extra_join_conditions string for additional SQL to add onto the join statement's ON condition
20
+	 * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install,
21
+	 *                  or whether each site on a multisite install has a copy of this table
22
+	 */
23
+	public function __construct($table_name, $pk_column, $fk_column = null, $extra_join_conditions = null, $global = false)
24
+	{
25
+		$this->_fk_on_table = $fk_column;
26
+		$this->_extra_join_conditions = $extra_join_conditions;
27
+		parent::__construct($table_name, $pk_column, $global);
28
+	}
29
+	public function get_fk_on_table()
30
+	{
31
+		return $this->_fk_on_table;
32
+	}
33
+	public function _construct_finalize_set_table_to_join_with(EE_Table_Base $table)
34
+	{
35
+		$this->_table_to_join_with = $table;
36
+	}
37
+	/**
38
+	 *
39
+	 * @return string of sql like "Event.post_type = 'event'", which gets added to
40
+	 * the end of the join statement with the primary table
41
+	 */
42
+	public function get_extra_join_conditions()
43
+	{
44
+		return $this->_extra_join_conditions;
45
+	}
46
+	/**
47
+	 *
48
+	 * @return EE_Primary_Table
49
+	 */
50
+	public function get_table_to_join_with()
51
+	{
52
+		return $this->_table_to_join_with;
53
+	}
54
+	/**
55
+	 * creates join statement FROM primary table
56
+	 * gets SQL like "LEFT JOIN table_name AS table_alias ON other_table_alias.pk = table_alias.fk
57
+	 *
58
+	 * @param string $table allows us to set special conditions on the $table_name portion of the join query (i.e. doing a subquery)
59
+	 * @return string of SQL
60
+	 */
61
+	public function get_join_sql($primary_table_alias_with_model_chain_prefix)
62
+	{
63 63
 
64
-        $table_name = $this->get_table_name();
65
-        $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix) . $this->get_table_alias();
66
-        $other_table_pk = $this->get_table_to_join_with()->get_pk_column();
67
-        $fk = $this->get_fk_on_table();
68
-        $join_sql = " LEFT JOIN $table_name AS $secondary_table_alias ON $primary_table_alias_with_model_chain_prefix.$other_table_pk = $secondary_table_alias.$fk ";
69
-        if ($this->get_extra_join_conditions()) {
70
-            $join_sql .= "AND " . $this->get_extra_join_conditions();
71
-        }
72
-        return $join_sql;
73
-    }
64
+		$table_name = $this->get_table_name();
65
+		$secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix) . $this->get_table_alias();
66
+		$other_table_pk = $this->get_table_to_join_with()->get_pk_column();
67
+		$fk = $this->get_fk_on_table();
68
+		$join_sql = " LEFT JOIN $table_name AS $secondary_table_alias ON $primary_table_alias_with_model_chain_prefix.$other_table_pk = $secondary_table_alias.$fk ";
69
+		if ($this->get_extra_join_conditions()) {
70
+			$join_sql .= "AND " . $this->get_extra_join_conditions();
71
+		}
72
+		return $join_sql;
73
+	}
74 74
 
75 75
 
76
-    /**
77
-     * Produces join SQL like get_join_sql, except instead of joining the primary table to the
78
-     * secondary table, does the inverse: joins the secondary table to the primary one. (Eg, isntead of
79
-     * " LEFT JOIN secondary_table_table AS Secondary ON ..." like get_join_sql, this function returns
80
-     * " LEFT JOIN primary_table AS Primary ON ...".
81
-     * This is useful if the secondary table is already included in the SQL, but the primary table is not yet.
82
-     * @return string
83
-     */
84
-    public function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix)
85
-    {
86
-        $primary_table_name = $this->get_table_to_join_with()->get_table_name();
87
-        $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix) . $this->get_table_to_join_with()->get_table_alias();
88
-        $primary_table_pk = $this->get_table_to_join_with()->get_pk_column();// $this->get_pk_column();
89
-        $fk = $this->get_fk_on_table();
90
-        $join_sql = " LEFT JOIN $primary_table_name AS $primary_table_alias ON $primary_table_alias.$primary_table_pk = $secondary_table_alias_with_model_chain_prefix.$fk ";
91
-        if ($this->get_extra_join_conditions()) {
92
-            $join_sql .= "AND " . $this->get_extra_join_conditions();
93
-        }
94
-        return $join_sql;
95
-    }
76
+	/**
77
+	 * Produces join SQL like get_join_sql, except instead of joining the primary table to the
78
+	 * secondary table, does the inverse: joins the secondary table to the primary one. (Eg, isntead of
79
+	 * " LEFT JOIN secondary_table_table AS Secondary ON ..." like get_join_sql, this function returns
80
+	 * " LEFT JOIN primary_table AS Primary ON ...".
81
+	 * This is useful if the secondary table is already included in the SQL, but the primary table is not yet.
82
+	 * @return string
83
+	 */
84
+	public function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix)
85
+	{
86
+		$primary_table_name = $this->get_table_to_join_with()->get_table_name();
87
+		$primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix) . $this->get_table_to_join_with()->get_table_alias();
88
+		$primary_table_pk = $this->get_table_to_join_with()->get_pk_column();// $this->get_pk_column();
89
+		$fk = $this->get_fk_on_table();
90
+		$join_sql = " LEFT JOIN $primary_table_name AS $primary_table_alias ON $primary_table_alias.$primary_table_pk = $secondary_table_alias_with_model_chain_prefix.$fk ";
91
+		if ($this->get_extra_join_conditions()) {
92
+			$join_sql .= "AND " . $this->get_extra_join_conditions();
93
+		}
94
+		return $join_sql;
95
+	}
96 96
 
97
-    /**
98
-     * This prepares the join on the other table using a select with a internal limit.
99
-     * @param  mixed (array|string) $limit limit
100
-     * @return string                       SQL to return
101
-     */
102
-    public function get_select_join_limit_join($limit)
103
-    {
104
-        // first get the select
105
-        $select = $this->get_select_join_limit($limit);
106
-        $join_sql = $this->get_join_sql($select);
107
-        return $join_sql;
108
-    }
97
+	/**
98
+	 * This prepares the join on the other table using a select with a internal limit.
99
+	 * @param  mixed (array|string) $limit limit
100
+	 * @return string                       SQL to return
101
+	 */
102
+	public function get_select_join_limit_join($limit)
103
+	{
104
+		// first get the select
105
+		$select = $this->get_select_join_limit($limit);
106
+		$join_sql = $this->get_join_sql($select);
107
+		return $join_sql;
108
+	}
109 109
 
110 110
 
111 111
 
112
-    public function get_fully_qualified_fk_column()
113
-    {
114
-        $table_alias = $this->get_table_alias();
115
-        $fk = $this->get_fk_on_table();
116
-        return $table_alias . '.' . $fk;
117
-    }
112
+	public function get_fully_qualified_fk_column()
113
+	{
114
+		$table_alias = $this->get_table_alias();
115
+		$fk = $this->get_fk_on_table();
116
+		return $table_alias . '.' . $fk;
117
+	}
118 118
 
119
-    public function get_fully_qualified_pk_on_fk_table()
120
-    {
121
-        $table_alias = $this->get_table_to_join_with()->get_table_alias();
122
-        $pk = $this->get_table_to_join_with()->get_pk_column();
123
-        return $table_alias . '.' . $pk;
124
-    }
119
+	public function get_fully_qualified_pk_on_fk_table()
120
+	{
121
+		$table_alias = $this->get_table_to_join_with()->get_table_alias();
122
+		$pk = $this->get_table_to_join_with()->get_pk_column();
123
+		return $table_alias . '.' . $pk;
124
+	}
125 125
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -62,12 +62,12 @@  discard block
 block discarded – undo
62 62
     {
63 63
 
64 64
         $table_name = $this->get_table_name();
65
-        $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix) . $this->get_table_alias();
65
+        $secondary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($primary_table_alias_with_model_chain_prefix).$this->get_table_alias();
66 66
         $other_table_pk = $this->get_table_to_join_with()->get_pk_column();
67 67
         $fk = $this->get_fk_on_table();
68 68
         $join_sql = " LEFT JOIN $table_name AS $secondary_table_alias ON $primary_table_alias_with_model_chain_prefix.$other_table_pk = $secondary_table_alias.$fk ";
69 69
         if ($this->get_extra_join_conditions()) {
70
-            $join_sql .= "AND " . $this->get_extra_join_conditions();
70
+            $join_sql .= "AND ".$this->get_extra_join_conditions();
71 71
         }
72 72
         return $join_sql;
73 73
     }
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
     public function get_inverse_join_sql($secondary_table_alias_with_model_chain_prefix)
85 85
     {
86 86
         $primary_table_name = $this->get_table_to_join_with()->get_table_name();
87
-        $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix) . $this->get_table_to_join_with()->get_table_alias();
88
-        $primary_table_pk = $this->get_table_to_join_with()->get_pk_column();// $this->get_pk_column();
87
+        $primary_table_alias = EE_Model_Parser::get_prefix_from_table_alias_with_model_relation_chain_prefix($secondary_table_alias_with_model_chain_prefix).$this->get_table_to_join_with()->get_table_alias();
88
+        $primary_table_pk = $this->get_table_to_join_with()->get_pk_column(); // $this->get_pk_column();
89 89
         $fk = $this->get_fk_on_table();
90 90
         $join_sql = " LEFT JOIN $primary_table_name AS $primary_table_alias ON $primary_table_alias.$primary_table_pk = $secondary_table_alias_with_model_chain_prefix.$fk ";
91 91
         if ($this->get_extra_join_conditions()) {
92
-            $join_sql .= "AND " . $this->get_extra_join_conditions();
92
+            $join_sql .= "AND ".$this->get_extra_join_conditions();
93 93
         }
94 94
         return $join_sql;
95 95
     }
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
     {
114 114
         $table_alias = $this->get_table_alias();
115 115
         $fk = $this->get_fk_on_table();
116
-        return $table_alias . '.' . $fk;
116
+        return $table_alias.'.'.$fk;
117 117
     }
118 118
 
119 119
     public function get_fully_qualified_pk_on_fk_table()
120 120
     {
121 121
         $table_alias = $this->get_table_to_join_with()->get_table_alias();
122 122
         $pk = $this->get_table_to_join_with()->get_pk_column();
123
-        return $table_alias . '.' . $pk;
123
+        return $table_alias.'.'.$pk;
124 124
     }
125 125
 }
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Index.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -6,45 +6,45 @@
 block discarded – undo
6 6
  */
7 7
 class EE_Index
8 8
 {
9
-    protected $_name;
10
-    protected $_field_names;
11
-    protected $_model_name;
12
-    public function __construct($fields)
13
-    {
14
-        $this->_field_names = $fields;
15
-    }
16
-    public function _construct_finalize($name, $model_name)
17
-    {
18
-        $this->_name = $name;
19
-        $this->_model_name = $model_name;
20
-    }
21
-    public function field_names()
22
-    {
23
-        return $this->_field_names;
24
-    }
25
-    /**
26
-     * Internally used by get_this_model() and get_other_model()
27
-     * @param string $model_name like Event, Question_Group, etc. omit the EEM_
28
-     * @return EEM_Base
29
-     */
30
-    protected function _get_model($model_name)
31
-    {
32
-        $modelInstance = call_user_func("EEM_" . $model_name . "::instance");
33
-        return $modelInstance;
34
-    }
35
-    /**
36
-     * Gets all the fields for this index
37
-     * @return EE_Model_Field_Base[]
38
-     */
39
-    public function fields()
40
-    {
41
-        $fields = array();
42
-        $model = $this->_get_model($this->_model_name);
43
-        foreach ($model->field_settings() as $field_name => $field_obj) {
44
-            if (in_array($field_name, $this->field_names())) {
45
-                $fields[ $field_name ] = $field_obj;
46
-            }
47
-        }
48
-        return $fields;
49
-    }
9
+	protected $_name;
10
+	protected $_field_names;
11
+	protected $_model_name;
12
+	public function __construct($fields)
13
+	{
14
+		$this->_field_names = $fields;
15
+	}
16
+	public function _construct_finalize($name, $model_name)
17
+	{
18
+		$this->_name = $name;
19
+		$this->_model_name = $model_name;
20
+	}
21
+	public function field_names()
22
+	{
23
+		return $this->_field_names;
24
+	}
25
+	/**
26
+	 * Internally used by get_this_model() and get_other_model()
27
+	 * @param string $model_name like Event, Question_Group, etc. omit the EEM_
28
+	 * @return EEM_Base
29
+	 */
30
+	protected function _get_model($model_name)
31
+	{
32
+		$modelInstance = call_user_func("EEM_" . $model_name . "::instance");
33
+		return $modelInstance;
34
+	}
35
+	/**
36
+	 * Gets all the fields for this index
37
+	 * @return EE_Model_Field_Base[]
38
+	 */
39
+	public function fields()
40
+	{
41
+		$fields = array();
42
+		$model = $this->_get_model($this->_model_name);
43
+		foreach ($model->field_settings() as $field_name => $field_obj) {
44
+			if (in_array($field_name, $this->field_names())) {
45
+				$fields[ $field_name ] = $field_obj;
46
+			}
47
+		}
48
+		return $fields;
49
+	}
50 50
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     protected function _get_model($model_name)
31 31
     {
32
-        $modelInstance = call_user_func("EEM_" . $model_name . "::instance");
32
+        $modelInstance = call_user_func("EEM_".$model_name."::instance");
33 33
         return $modelInstance;
34 34
     }
35 35
     /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $model = $this->_get_model($this->_model_name);
43 43
         foreach ($model->field_settings() as $field_name => $field_obj) {
44 44
             if (in_array($field_name, $this->field_names())) {
45
-                $fields[ $field_name ] = $field_obj;
45
+                $fields[$field_name] = $field_obj;
46 46
             }
47 47
         }
48 48
         return $fields;
Please login to merge, or discard this patch.
core/db_models/helpers/EE_Primary_Table.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -7,24 +7,24 @@
 block discarded – undo
7 7
 class EE_Primary_Table extends EE_Table_Base
8 8
 {
9 9
 
10
-    /**
11
-     *
12
-     * @global type $wpdb
13
-     * @param string $table_name with or without wpdb prefix
14
-     * @param string $pk_column name of primary key column
15
-     * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install,
16
-     *                  or whether each site on a multisite install has a copy of this table
17
-     */
18
-    public function __construct($table_name, $pk_column = null, $global = false)
19
-    {
20
-        parent::__construct($table_name, $pk_column, $global);
21
-    }
22
-    /**
23
-     * Gets SQL for this table and assigning it an alias. Eg " wp_esp_attendee AS Attendee "
24
-     * @return string
25
-     */
26
-    public function get_table_sql()
27
-    {
28
-        return " " . $this->get_table_name() . " AS " . $this->get_table_alias() . " ";
29
-    }
10
+	/**
11
+	 *
12
+	 * @global type $wpdb
13
+	 * @param string $table_name with or without wpdb prefix
14
+	 * @param string $pk_column name of primary key column
15
+	 * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite install,
16
+	 *                  or whether each site on a multisite install has a copy of this table
17
+	 */
18
+	public function __construct($table_name, $pk_column = null, $global = false)
19
+	{
20
+		parent::__construct($table_name, $pk_column, $global);
21
+	}
22
+	/**
23
+	 * Gets SQL for this table and assigning it an alias. Eg " wp_esp_attendee AS Attendee "
24
+	 * @return string
25
+	 */
26
+	public function get_table_sql()
27
+	{
28
+		return " " . $this->get_table_name() . " AS " . $this->get_table_alias() . " ";
29
+	}
30 30
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,6 +25,6 @@
 block discarded – undo
25 25
      */
26 26
     public function get_table_sql()
27 27
     {
28
-        return " " . $this->get_table_name() . " AS " . $this->get_table_alias() . " ";
28
+        return " ".$this->get_table_name()." AS ".$this->get_table_alias()." ";
29 29
     }
30 30
 }
Please login to merge, or discard this patch.
core/db_models/EEM_State.model.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             'Venue' => new EE_Has_Many_Relation(),
43 43
         );
44 44
         // this model is generally available for reading
45
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
45
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
46 46
         // @todo: only show STA_active
47 47
         parent::__construct($timezone);
48 48
     }
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
     */
74 74
     public function get_all_states()
75 75
     {
76
-        if (! self::$_all_states) {
77
-            self::$_all_states = $this->get_all(array( 'order_by' => array( 'STA_name' => 'ASC' ), 'limit' => array( 0, 99999 )));
76
+        if ( ! self::$_all_states) {
77
+            self::$_all_states = $this->get_all(array('order_by' => array('STA_name' => 'ASC'), 'limit' => array(0, 99999)));
78 78
         }
79 79
         return self::$_all_states;
80 80
     }
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function get_all_active_states($countries = array(), $flush_cache = false)
93 93
     {
94
-        if (! self::$_active_states || $flush_cache) {
94
+        if ( ! self::$_active_states || $flush_cache) {
95 95
             $countries = is_array($countries) && ! empty($countries) ? $countries : EEM_Country::instance()->get_all_active_countries();
96
-            self::$_active_states =  $this->get_all(array(
97
-                array( 'STA_active' => true, 'CNT_ISO' => array( 'IN', array_keys($countries))),
98
-                'order_by' => array( 'STA_name' => 'ASC' ),
99
-                'limit' => array( 0, 99999 ),
100
-                'force_join' => array( 'Country' )
96
+            self::$_active_states = $this->get_all(array(
97
+                array('STA_active' => true, 'CNT_ISO' => array('IN', array_keys($countries))),
98
+                'order_by' => array('STA_name' => 'ASC'),
99
+                'limit' => array(0, 99999),
100
+                'force_join' => array('Country')
101 101
             ));
102 102
         }
103 103
         return self::$_active_states;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function get_all_states_of_active_countries()
113 113
     {
114
-        if ($states = $this->get_all(array( array( 'Country.CNT_active' => true, 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
114
+        if ($states = $this->get_all(array(array('Country.CNT_active' => true, 'STA_active' => true), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) {
115 115
             return $states;
116 116
         }
117 117
         return false;
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public function get_all_active_states_for_these_countries($countries)
127 127
     {
128
-        if (! $countries) {
128
+        if ( ! $countries) {
129 129
             return false;
130 130
         }
131
-        if ($states = $this->get_all(array(  array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries)), 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
131
+        if ($states = $this->get_all(array(array('Country.CNT_ISO' => array('IN', array_keys($countries)), 'STA_active' => true), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) {
132 132
             return $states;
133 133
         }
134 134
         return false;
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public function get_all_states_for_these_countries($countries)
144 144
     {
145
-        if (! $countries) {
145
+        if ( ! $countries) {
146 146
             return false;
147 147
         }
148
-        if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries))),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
148
+        if ($states = $this->get_all(array(array('Country.CNT_ISO' => array('IN', array_keys($countries))), 'order_by' => array('Country.CNT_name' => 'ASC', 'STA_name' => 'ASC')))) {
149 149
             return $states;
150 150
         }
151 151
         return false;
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
     public function get_state_name_by_ID($state_ID)
160 160
     {
161 161
         if (
162
-            isset(self::$_all_states[ $state_ID ]) &&
163
-                self::$_all_states[ $state_ID ] instanceof EE_State
162
+            isset(self::$_all_states[$state_ID]) &&
163
+                self::$_all_states[$state_ID] instanceof EE_State
164 164
         ) {
165
-            return self::$_all_states[ $state_ID ]->name();
165
+            return self::$_all_states[$state_ID]->name();
166 166
         }
167
-        $names = $this->get_col(array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name');
167
+        $names = $this->get_col(array(array('STA_ID' => $state_ID), 'limit' => 1), 'STA_name');
168 168
         if (is_array($names) && ! empty($names)) {
169 169
             return reset($names);
170 170
         } else {
Please login to merge, or discard this patch.
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -12,163 +12,163 @@
 block discarded – undo
12 12
 class EEM_State extends EEM_Base
13 13
 {
14 14
 
15
-    // private instance of the Attendee object
16
-    protected static $_instance = null;
17
-    // array of all states
18
-    private static $_all_states = false;
19
-    // array of all active states
20
-    private static $_active_states = false;
21
-
22
-    protected function __construct($timezone = null)
23
-    {
24
-        $this->singular_item = esc_html__('State/Province', 'event_espresso');
25
-        $this->plural_item = esc_html__('States/Provinces', 'event_espresso');
26
-
27
-        $this->_tables = array(
28
-            'State' => new EE_Primary_Table('esp_state', 'STA_ID')
29
-        );
30
-
31
-        $this->_fields = array(
32
-            'State' => array(
33
-                'STA_ID' => new EE_Primary_Key_Int_Field('STA_ID', esc_html__('State ID', 'event_espresso')),
34
-                'CNT_ISO' => new EE_Foreign_Key_String_Field('CNT_ISO', esc_html__('Country ISO Code', 'event_espresso'), false, null, 'Country'),
35
-                'STA_abbrev' => new EE_Plain_Text_Field('STA_abbrev', esc_html__('State Abbreviation', 'event_espresso'), false, ''),
36
-                'STA_name' => new EE_Plain_Text_Field('STA_name', esc_html__('State Name', 'event_espresso'), false, ''),
37
-                'STA_active' => new EE_Boolean_Field('STA_active', esc_html__('State Active Flag', 'event_espresso'), false, false)
38
-                ));
39
-        $this->_model_relations = array(
40
-            'Attendee' => new EE_Has_Many_Relation(),
41
-            'Country' => new EE_Belongs_To_Relation(),
42
-            'Venue' => new EE_Has_Many_Relation(),
43
-        );
44
-        // this model is generally available for reading
45
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
46
-        // @todo: only show STA_active
47
-        parent::__construct($timezone);
48
-    }
49
-
50
-
51
-
52
-
53
-    /**
54
-    *   reset_cached_states
55
-    *
56
-    *   @access     private
57
-    *   @return         void
58
-    */
59
-    public function reset_cached_states()
60
-    {
61
-        EEM_State::$_active_states = array();
62
-        EEM_State::$_all_states = array();
63
-    }
64
-
65
-
66
-
67
-
68
-    /**
69
-    *       _get_states
70
-    *
71
-    *       @access     private
72
-    *       @return         array
73
-    */
74
-    public function get_all_states()
75
-    {
76
-        if (! self::$_all_states) {
77
-            self::$_all_states = $this->get_all(array( 'order_by' => array( 'STA_name' => 'ASC' ), 'limit' => array( 0, 99999 )));
78
-        }
79
-        return self::$_all_states;
80
-    }
81
-
82
-
83
-
84
-    /**
85
-     *        _get_states
86
-     *
87
-     * @access        public
88
-     * @param array $countries
89
-     * @param bool  $flush_cache
90
-     * @return        array
91
-     */
92
-    public function get_all_active_states($countries = array(), $flush_cache = false)
93
-    {
94
-        if (! self::$_active_states || $flush_cache) {
95
-            $countries = is_array($countries) && ! empty($countries) ? $countries : EEM_Country::instance()->get_all_active_countries();
96
-            self::$_active_states =  $this->get_all(array(
97
-                array( 'STA_active' => true, 'CNT_ISO' => array( 'IN', array_keys($countries))),
98
-                'order_by' => array( 'STA_name' => 'ASC' ),
99
-                'limit' => array( 0, 99999 ),
100
-                'force_join' => array( 'Country' )
101
-            ));
102
-        }
103
-        return self::$_active_states;
104
-    }
105
-
106
-
107
-
108
-    /**
109
-     *  get_all_states_of_active_countries
110
-     * @return array
111
-     */
112
-    public function get_all_states_of_active_countries()
113
-    {
114
-        if ($states = $this->get_all(array( array( 'Country.CNT_active' => true, 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
115
-            return $states;
116
-        }
117
-        return false;
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     *  get_all_states_of_active_countries
124
-     * @return array
125
-     */
126
-    public function get_all_active_states_for_these_countries($countries)
127
-    {
128
-        if (! $countries) {
129
-            return false;
130
-        }
131
-        if ($states = $this->get_all(array(  array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries)), 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
132
-            return $states;
133
-        }
134
-        return false;
135
-    }
136
-
137
-
138
-
139
-    /**
140
-     *  get_all_states_of_active_countries
141
-     * @return array
142
-     */
143
-    public function get_all_states_for_these_countries($countries)
144
-    {
145
-        if (! $countries) {
146
-            return false;
147
-        }
148
-        if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries))),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
149
-            return $states;
150
-        }
151
-        return false;
152
-    }
153
-
154
-    /**
155
-     * Gets the state's name by its ID
156
-     * @param string $state_ID
157
-     * @return string
158
-     */
159
-    public function get_state_name_by_ID($state_ID)
160
-    {
161
-        if (
162
-            isset(self::$_all_states[ $state_ID ]) &&
163
-                self::$_all_states[ $state_ID ] instanceof EE_State
164
-        ) {
165
-            return self::$_all_states[ $state_ID ]->name();
166
-        }
167
-        $names = $this->get_col(array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name');
168
-        if (is_array($names) && ! empty($names)) {
169
-            return reset($names);
170
-        } else {
171
-            return '';
172
-        }
173
-    }
15
+	// private instance of the Attendee object
16
+	protected static $_instance = null;
17
+	// array of all states
18
+	private static $_all_states = false;
19
+	// array of all active states
20
+	private static $_active_states = false;
21
+
22
+	protected function __construct($timezone = null)
23
+	{
24
+		$this->singular_item = esc_html__('State/Province', 'event_espresso');
25
+		$this->plural_item = esc_html__('States/Provinces', 'event_espresso');
26
+
27
+		$this->_tables = array(
28
+			'State' => new EE_Primary_Table('esp_state', 'STA_ID')
29
+		);
30
+
31
+		$this->_fields = array(
32
+			'State' => array(
33
+				'STA_ID' => new EE_Primary_Key_Int_Field('STA_ID', esc_html__('State ID', 'event_espresso')),
34
+				'CNT_ISO' => new EE_Foreign_Key_String_Field('CNT_ISO', esc_html__('Country ISO Code', 'event_espresso'), false, null, 'Country'),
35
+				'STA_abbrev' => new EE_Plain_Text_Field('STA_abbrev', esc_html__('State Abbreviation', 'event_espresso'), false, ''),
36
+				'STA_name' => new EE_Plain_Text_Field('STA_name', esc_html__('State Name', 'event_espresso'), false, ''),
37
+				'STA_active' => new EE_Boolean_Field('STA_active', esc_html__('State Active Flag', 'event_espresso'), false, false)
38
+				));
39
+		$this->_model_relations = array(
40
+			'Attendee' => new EE_Has_Many_Relation(),
41
+			'Country' => new EE_Belongs_To_Relation(),
42
+			'Venue' => new EE_Has_Many_Relation(),
43
+		);
44
+		// this model is generally available for reading
45
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
46
+		// @todo: only show STA_active
47
+		parent::__construct($timezone);
48
+	}
49
+
50
+
51
+
52
+
53
+	/**
54
+	 *   reset_cached_states
55
+	 *
56
+	 *   @access     private
57
+	 *   @return         void
58
+	 */
59
+	public function reset_cached_states()
60
+	{
61
+		EEM_State::$_active_states = array();
62
+		EEM_State::$_all_states = array();
63
+	}
64
+
65
+
66
+
67
+
68
+	/**
69
+	 *       _get_states
70
+	 *
71
+	 *       @access     private
72
+	 *       @return         array
73
+	 */
74
+	public function get_all_states()
75
+	{
76
+		if (! self::$_all_states) {
77
+			self::$_all_states = $this->get_all(array( 'order_by' => array( 'STA_name' => 'ASC' ), 'limit' => array( 0, 99999 )));
78
+		}
79
+		return self::$_all_states;
80
+	}
81
+
82
+
83
+
84
+	/**
85
+	 *        _get_states
86
+	 *
87
+	 * @access        public
88
+	 * @param array $countries
89
+	 * @param bool  $flush_cache
90
+	 * @return        array
91
+	 */
92
+	public function get_all_active_states($countries = array(), $flush_cache = false)
93
+	{
94
+		if (! self::$_active_states || $flush_cache) {
95
+			$countries = is_array($countries) && ! empty($countries) ? $countries : EEM_Country::instance()->get_all_active_countries();
96
+			self::$_active_states =  $this->get_all(array(
97
+				array( 'STA_active' => true, 'CNT_ISO' => array( 'IN', array_keys($countries))),
98
+				'order_by' => array( 'STA_name' => 'ASC' ),
99
+				'limit' => array( 0, 99999 ),
100
+				'force_join' => array( 'Country' )
101
+			));
102
+		}
103
+		return self::$_active_states;
104
+	}
105
+
106
+
107
+
108
+	/**
109
+	 *  get_all_states_of_active_countries
110
+	 * @return array
111
+	 */
112
+	public function get_all_states_of_active_countries()
113
+	{
114
+		if ($states = $this->get_all(array( array( 'Country.CNT_active' => true, 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
115
+			return $states;
116
+		}
117
+		return false;
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 *  get_all_states_of_active_countries
124
+	 * @return array
125
+	 */
126
+	public function get_all_active_states_for_these_countries($countries)
127
+	{
128
+		if (! $countries) {
129
+			return false;
130
+		}
131
+		if ($states = $this->get_all(array(  array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries)), 'STA_active' => true ),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
132
+			return $states;
133
+		}
134
+		return false;
135
+	}
136
+
137
+
138
+
139
+	/**
140
+	 *  get_all_states_of_active_countries
141
+	 * @return array
142
+	 */
143
+	public function get_all_states_for_these_countries($countries)
144
+	{
145
+		if (! $countries) {
146
+			return false;
147
+		}
148
+		if ($states = $this->get_all(array( array( 'Country.CNT_ISO' => array( 'IN', array_keys($countries))),  'order_by' => array( 'Country.CNT_name' => 'ASC', 'STA_name' => 'ASC' )))) {
149
+			return $states;
150
+		}
151
+		return false;
152
+	}
153
+
154
+	/**
155
+	 * Gets the state's name by its ID
156
+	 * @param string $state_ID
157
+	 * @return string
158
+	 */
159
+	public function get_state_name_by_ID($state_ID)
160
+	{
161
+		if (
162
+			isset(self::$_all_states[ $state_ID ]) &&
163
+				self::$_all_states[ $state_ID ] instanceof EE_State
164
+		) {
165
+			return self::$_all_states[ $state_ID ]->name();
166
+		}
167
+		$names = $this->get_col(array( array( 'STA_ID' => $state_ID ), 'limit' => 1), 'STA_name');
168
+		if (is_array($names) && ! empty($names)) {
169
+			return reset($names);
170
+		} else {
171
+			return '';
172
+		}
173
+	}
174 174
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Ticket_Template.model.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,11 +43,11 @@
 block discarded – undo
43 43
             'Ticket' => new EE_Has_Many_Relation()
44 44
         );
45 45
         $this->_model_chain_to_wp_user = 'Ticket';
46
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
46
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
47 47
         // account for default tickets in the caps
48
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
49
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
50
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
48
+        $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
49
+        $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
50
+        $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
51 51
         parent::__construct($timezone);
52 52
     }
53 53
 }
Please login to merge, or discard this patch.
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -14,40 +14,40 @@
 block discarded – undo
14 14
 
15 15
 
16 16
 
17
-    // private instance of the EEM_Ticket_Template object
18
-    protected static $_instance = null;
17
+	// private instance of the EEM_Ticket_Template object
18
+	protected static $_instance = null;
19 19
 
20
-    /**
21
-     *      private constructor to prevent direct creation
22
-     *      @Constructor
23
-     *      @access private
24
-     *      @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)
25
-     *      @return void
26
-     */
27
-    protected function __construct($timezone)
28
-    {
29
-        $this->singular_item = esc_html__('Ticket Template', 'event_espresso');
30
-        $this->plural_item = esc_html__('Ticket Templates', 'event_espresso');
20
+	/**
21
+	 *      private constructor to prevent direct creation
22
+	 *      @Constructor
23
+	 *      @access private
24
+	 *      @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)
25
+	 *      @return void
26
+	 */
27
+	protected function __construct($timezone)
28
+	{
29
+		$this->singular_item = esc_html__('Ticket Template', 'event_espresso');
30
+		$this->plural_item = esc_html__('Ticket Templates', 'event_espresso');
31 31
 
32
-        $this->_tables = array(
33
-            'Ticket_Template' => new EE_Primary_Table('esp_ticket_template', 'TTM_ID')
34
-        );
35
-        $this->_fields = array(
36
-            'Ticket_Template' => array(
37
-                'TTM_ID' => new EE_Primary_Key_Int_Field('TTM_ID', esc_html__('Ticket Template ID', 'event_espresso')),
38
-                'TTM_name' => new EE_Plain_Text_Field('TTM_name', esc_html__('The name of the ticket template', 'event_espresso'), false, ''),
39
-                'TTM_description' => new EE_Plain_Text_Field('TTM_description', esc_html__('The description for the ticket template', 'event_espresso'), true, ''),
40
-                'TTM_file' => new EE_Plain_Text_Field('TTM_file', esc_html__('The file name for the actual template file saved on disk', 'event_espresso'), true, ''),
41
-            ));
42
-        $this->_model_relations = array(
43
-            'Ticket' => new EE_Has_Many_Relation()
44
-        );
45
-        $this->_model_chain_to_wp_user = 'Ticket';
46
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
47
-        // account for default tickets in the caps
48
-        $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
49
-        $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
50
-        $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
51
-        parent::__construct($timezone);
52
-    }
32
+		$this->_tables = array(
33
+			'Ticket_Template' => new EE_Primary_Table('esp_ticket_template', 'TTM_ID')
34
+		);
35
+		$this->_fields = array(
36
+			'Ticket_Template' => array(
37
+				'TTM_ID' => new EE_Primary_Key_Int_Field('TTM_ID', esc_html__('Ticket Template ID', 'event_espresso')),
38
+				'TTM_name' => new EE_Plain_Text_Field('TTM_name', esc_html__('The name of the ticket template', 'event_espresso'), false, ''),
39
+				'TTM_description' => new EE_Plain_Text_Field('TTM_description', esc_html__('The description for the ticket template', 'event_espresso'), true, ''),
40
+				'TTM_file' => new EE_Plain_Text_Field('TTM_file', esc_html__('The file name for the actual template file saved on disk', 'event_espresso'), true, ''),
41
+			));
42
+		$this->_model_relations = array(
43
+			'Ticket' => new EE_Has_Many_Relation()
44
+		);
45
+		$this->_model_chain_to_wp_user = 'Ticket';
46
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
47
+		// account for default tickets in the caps
48
+		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
49
+		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
50
+		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected('Ticket.TKT_is_default', 'Ticket.Datetime.Event');
51
+		parent::__construct($timezone);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Country.model.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -12,114 +12,114 @@
 block discarded – undo
12 12
 class EEM_Country extends EEM_Base
13 13
 {
14 14
 
15
-    // private instance of the Attendee object
16
-    protected static $_instance = null;
17
-    // array of all countries
18
-    private static $_all_countries = false;
19
-    // array of all active countries
20
-    private static $_active_countries = false;
15
+	// private instance of the Attendee object
16
+	protected static $_instance = null;
17
+	// array of all countries
18
+	private static $_all_countries = false;
19
+	// array of all active countries
20
+	private static $_active_countries = false;
21 21
 
22 22
 
23 23
 
24
-    /**
25
-     * Resets the country
26
-     * @return EEM_Country
27
-     */
28
-    public static function reset($timezone = null)
29
-    {
30
-        self::$_active_countries = null;
31
-        self::$_all_countries = null;
32
-        return parent::reset($timezone);
33
-    }
24
+	/**
25
+	 * Resets the country
26
+	 * @return EEM_Country
27
+	 */
28
+	public static function reset($timezone = null)
29
+	{
30
+		self::$_active_countries = null;
31
+		self::$_all_countries = null;
32
+		return parent::reset($timezone);
33
+	}
34 34
 
35
-    protected function __construct($timezone = null)
36
-    {
37
-        $this->singular_item = esc_html__('Country', 'event_espresso');
38
-        $this->plural_item = esc_html__('Countries', 'event_espresso');
35
+	protected function __construct($timezone = null)
36
+	{
37
+		$this->singular_item = esc_html__('Country', 'event_espresso');
38
+		$this->plural_item = esc_html__('Countries', 'event_espresso');
39 39
 
40 40
 
41
-        $this->_tables = array(
42
-            'Country' => new EE_Primary_Table('esp_country', 'CNT_ISO')
43
-        );
44
-        $this->_fields = array(
45
-            'Country' => array(
46
-                'CNT_active' => new EE_Boolean_Field('CNT_active', esc_html__('Country Appears in Dropdown Select Lists', 'event_espresso'), false, true),
47
-                'CNT_ISO' => new EE_Primary_Key_String_Field('CNT_ISO', esc_html__('Country ISO Code', 'event_espresso')),
48
-                'CNT_ISO3' => new EE_All_Caps_Text_Field('CNT_ISO3', esc_html__('Country ISO3 Code', 'event_espresso'), false, ''),
49
-                'RGN_ID' => new EE_Integer_Field('RGN_ID', esc_html__('Region ID', 'event_espresso'), false, 0),// should be a foreign key, but no region table exists yet
50
-                'CNT_name' => new EE_Plain_Text_Field('CNT_name', esc_html__('Country Name', 'event_espresso'), false, ''),
51
-                'CNT_cur_code' => new EE_All_Caps_Text_Field('CNT_cur_code', esc_html__('Country Currency Code', 'event_espresso'), false),
52
-                'CNT_cur_single' => new EE_Plain_Text_Field('CNT_cur_single', esc_html__('Currency Name Singular', 'event_espresso'), false),
53
-                'CNT_cur_plural' => new EE_Plain_Text_Field('CNT_cur_plural', esc_html__('Currency Name Plural', 'event_espresso'), false),
54
-                'CNT_cur_sign' => new EE_Plain_Text_Field('CNT_cur_sign', esc_html__('Currency Sign', 'event_espresso'), false),
55
-                'CNT_cur_sign_b4' => new EE_Boolean_Field('CNT_cur_sign_b4', esc_html__('Currency Sign Before Number', 'event_espresso'), false, true),
56
-                'CNT_cur_dec_plc' => new EE_Integer_Field('CNT_cur_dec_plc', esc_html__('Currency Decimal Places', 'event_espresso'), false, 2),
57
-                'CNT_cur_dec_mrk' => new EE_Plain_Text_Field('CNT_cur_dec_mrk', esc_html__('Currency Decimal Mark', 'event_espresso'), false, '.'),
58
-                'CNT_cur_thsnds' => new EE_Plain_Text_Field('CNT_cur_thsnds', esc_html__('Currency Thousands Separator', 'event_espresso'), false, ','),
59
-                'CNT_tel_code' => new EE_Plain_Text_Field('CNT_tel_code', esc_html__('Country Telephone Code', 'event_espresso'), false, ''),
60
-                'CNT_is_EU' => new EE_Boolean_Field('CNT_is_EU', esc_html__('Country is Member of EU', 'event_espresso'), false, false)
61
-            ));
62
-        $this->_model_relations = array(
63
-            'Attendee' => new EE_Has_Many_Relation(),
64
-            'State' => new EE_Has_Many_Relation(),
65
-            'Venue' => new EE_Has_Many_Relation(),
66
-        );
67
-        // only anyone to view, but only those with the default role can do anything
68
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
41
+		$this->_tables = array(
42
+			'Country' => new EE_Primary_Table('esp_country', 'CNT_ISO')
43
+		);
44
+		$this->_fields = array(
45
+			'Country' => array(
46
+				'CNT_active' => new EE_Boolean_Field('CNT_active', esc_html__('Country Appears in Dropdown Select Lists', 'event_espresso'), false, true),
47
+				'CNT_ISO' => new EE_Primary_Key_String_Field('CNT_ISO', esc_html__('Country ISO Code', 'event_espresso')),
48
+				'CNT_ISO3' => new EE_All_Caps_Text_Field('CNT_ISO3', esc_html__('Country ISO3 Code', 'event_espresso'), false, ''),
49
+				'RGN_ID' => new EE_Integer_Field('RGN_ID', esc_html__('Region ID', 'event_espresso'), false, 0),// should be a foreign key, but no region table exists yet
50
+				'CNT_name' => new EE_Plain_Text_Field('CNT_name', esc_html__('Country Name', 'event_espresso'), false, ''),
51
+				'CNT_cur_code' => new EE_All_Caps_Text_Field('CNT_cur_code', esc_html__('Country Currency Code', 'event_espresso'), false),
52
+				'CNT_cur_single' => new EE_Plain_Text_Field('CNT_cur_single', esc_html__('Currency Name Singular', 'event_espresso'), false),
53
+				'CNT_cur_plural' => new EE_Plain_Text_Field('CNT_cur_plural', esc_html__('Currency Name Plural', 'event_espresso'), false),
54
+				'CNT_cur_sign' => new EE_Plain_Text_Field('CNT_cur_sign', esc_html__('Currency Sign', 'event_espresso'), false),
55
+				'CNT_cur_sign_b4' => new EE_Boolean_Field('CNT_cur_sign_b4', esc_html__('Currency Sign Before Number', 'event_espresso'), false, true),
56
+				'CNT_cur_dec_plc' => new EE_Integer_Field('CNT_cur_dec_plc', esc_html__('Currency Decimal Places', 'event_espresso'), false, 2),
57
+				'CNT_cur_dec_mrk' => new EE_Plain_Text_Field('CNT_cur_dec_mrk', esc_html__('Currency Decimal Mark', 'event_espresso'), false, '.'),
58
+				'CNT_cur_thsnds' => new EE_Plain_Text_Field('CNT_cur_thsnds', esc_html__('Currency Thousands Separator', 'event_espresso'), false, ','),
59
+				'CNT_tel_code' => new EE_Plain_Text_Field('CNT_tel_code', esc_html__('Country Telephone Code', 'event_espresso'), false, ''),
60
+				'CNT_is_EU' => new EE_Boolean_Field('CNT_is_EU', esc_html__('Country is Member of EU', 'event_espresso'), false, false)
61
+			));
62
+		$this->_model_relations = array(
63
+			'Attendee' => new EE_Has_Many_Relation(),
64
+			'State' => new EE_Has_Many_Relation(),
65
+			'Venue' => new EE_Has_Many_Relation(),
66
+		);
67
+		// only anyone to view, but only those with the default role can do anything
68
+		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
69 69
 
70
-        parent::__construct($timezone);
71
-    }
70
+		parent::__construct($timezone);
71
+	}
72 72
 
73 73
 
74 74
 
75 75
 
76
-    /**
77
-    *       _get_countries
78
-    *
79
-    *       @access     public
80
-    *       @return         array
81
-    */
82
-    public function get_all_countries()
83
-    {
84
-        if (! self::$_all_countries) {
85
-            self::$_all_countries = $this->get_all(array( 'order_by' => array('CNT_name' => 'ASC'), 'limit' => array( 0,99999 )));
86
-        }
87
-        return self::$_all_countries;
88
-    }
76
+	/**
77
+	 *       _get_countries
78
+	 *
79
+	 *       @access     public
80
+	 *       @return         array
81
+	 */
82
+	public function get_all_countries()
83
+	{
84
+		if (! self::$_all_countries) {
85
+			self::$_all_countries = $this->get_all(array( 'order_by' => array('CNT_name' => 'ASC'), 'limit' => array( 0,99999 )));
86
+		}
87
+		return self::$_all_countries;
88
+	}
89 89
 
90
-    /**
91
-    *       _get_countries
92
-    *       Gets and caches the list of active countries. If you know the list of active countries
93
-    *       has changed during this request, first use EEM_Country::reset() to flush the cache
94
-    *       @access     public
95
-    *       @return         array
96
-    */
97
-    public function get_all_active_countries()
98
-    {
99
-        if (! self::$_active_countries) {
100
-            self::$_active_countries =  $this->get_all(array( array( 'CNT_active' => true ), 'order_by' => array('CNT_name' => 'ASC'), 'limit' => array( 0, 99999 )));
101
-        }
102
-        return self::$_active_countries;
103
-    }
90
+	/**
91
+	 *       _get_countries
92
+	 *       Gets and caches the list of active countries. If you know the list of active countries
93
+	 *       has changed during this request, first use EEM_Country::reset() to flush the cache
94
+	 *       @access     public
95
+	 *       @return         array
96
+	 */
97
+	public function get_all_active_countries()
98
+	{
99
+		if (! self::$_active_countries) {
100
+			self::$_active_countries =  $this->get_all(array( array( 'CNT_active' => true ), 'order_by' => array('CNT_name' => 'ASC'), 'limit' => array( 0, 99999 )));
101
+		}
102
+		return self::$_active_countries;
103
+	}
104 104
 
105
-    /**
106
-     * Gets the country's name by its ISO
107
-     * @param string $country_ISO
108
-     * @return string
109
-     */
110
-    public function get_country_name_by_ISO($country_ISO)
111
-    {
112
-        if (
113
-            isset(self::$_all_countries[ $country_ISO ]) &&
114
-                self::$_all_countries[ $country_ISO ] instanceof EE_Country
115
-        ) {
116
-            return self::$_all_countries[ $country_ISO ]->name();
117
-        }
118
-        $names = $this->get_col(array( array( 'CNT_ISO' => $country_ISO ), 'limit' => 1), 'CNT_name');
119
-        if (is_array($names) && ! empty($names)) {
120
-            return reset($names);
121
-        } else {
122
-            return '';
123
-        }
124
-    }
105
+	/**
106
+	 * Gets the country's name by its ISO
107
+	 * @param string $country_ISO
108
+	 * @return string
109
+	 */
110
+	public function get_country_name_by_ISO($country_ISO)
111
+	{
112
+		if (
113
+			isset(self::$_all_countries[ $country_ISO ]) &&
114
+				self::$_all_countries[ $country_ISO ] instanceof EE_Country
115
+		) {
116
+			return self::$_all_countries[ $country_ISO ]->name();
117
+		}
118
+		$names = $this->get_col(array( array( 'CNT_ISO' => $country_ISO ), 'limit' => 1), 'CNT_name');
119
+		if (is_array($names) && ! empty($names)) {
120
+			return reset($names);
121
+		} else {
122
+			return '';
123
+		}
124
+	}
125 125
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
                 'CNT_active' => new EE_Boolean_Field('CNT_active', esc_html__('Country Appears in Dropdown Select Lists', 'event_espresso'), false, true),
47 47
                 'CNT_ISO' => new EE_Primary_Key_String_Field('CNT_ISO', esc_html__('Country ISO Code', 'event_espresso')),
48 48
                 'CNT_ISO3' => new EE_All_Caps_Text_Field('CNT_ISO3', esc_html__('Country ISO3 Code', 'event_espresso'), false, ''),
49
-                'RGN_ID' => new EE_Integer_Field('RGN_ID', esc_html__('Region ID', 'event_espresso'), false, 0),// should be a foreign key, but no region table exists yet
49
+                'RGN_ID' => new EE_Integer_Field('RGN_ID', esc_html__('Region ID', 'event_espresso'), false, 0), // should be a foreign key, but no region table exists yet
50 50
                 'CNT_name' => new EE_Plain_Text_Field('CNT_name', esc_html__('Country Name', 'event_espresso'), false, ''),
51 51
                 'CNT_cur_code' => new EE_All_Caps_Text_Field('CNT_cur_code', esc_html__('Country Currency Code', 'event_espresso'), false),
52 52
                 'CNT_cur_single' => new EE_Plain_Text_Field('CNT_cur_single', esc_html__('Currency Name Singular', 'event_espresso'), false),
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             'Venue' => new EE_Has_Many_Relation(),
66 66
         );
67 67
         // only anyone to view, but only those with the default role can do anything
68
-        $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
68
+        $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
69 69
 
70 70
         parent::__construct($timezone);
71 71
     }
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     */
82 82
     public function get_all_countries()
83 83
     {
84
-        if (! self::$_all_countries) {
85
-            self::$_all_countries = $this->get_all(array( 'order_by' => array('CNT_name' => 'ASC'), 'limit' => array( 0,99999 )));
84
+        if ( ! self::$_all_countries) {
85
+            self::$_all_countries = $this->get_all(array('order_by' => array('CNT_name' => 'ASC'), 'limit' => array(0, 99999)));
86 86
         }
87 87
         return self::$_all_countries;
88 88
     }
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
     */
97 97
     public function get_all_active_countries()
98 98
     {
99
-        if (! self::$_active_countries) {
100
-            self::$_active_countries =  $this->get_all(array( array( 'CNT_active' => true ), 'order_by' => array('CNT_name' => 'ASC'), 'limit' => array( 0, 99999 )));
99
+        if ( ! self::$_active_countries) {
100
+            self::$_active_countries = $this->get_all(array(array('CNT_active' => true), 'order_by' => array('CNT_name' => 'ASC'), 'limit' => array(0, 99999)));
101 101
         }
102 102
         return self::$_active_countries;
103 103
     }
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
     public function get_country_name_by_ISO($country_ISO)
111 111
     {
112 112
         if (
113
-            isset(self::$_all_countries[ $country_ISO ]) &&
114
-                self::$_all_countries[ $country_ISO ] instanceof EE_Country
113
+            isset(self::$_all_countries[$country_ISO]) &&
114
+                self::$_all_countries[$country_ISO] instanceof EE_Country
115 115
         ) {
116
-            return self::$_all_countries[ $country_ISO ]->name();
116
+            return self::$_all_countries[$country_ISO]->name();
117 117
         }
118
-        $names = $this->get_col(array( array( 'CNT_ISO' => $country_ISO ), 'limit' => 1), 'CNT_name');
118
+        $names = $this->get_col(array(array('CNT_ISO' => $country_ISO), 'limit' => 1), 'CNT_name');
119 119
         if (is_array($names) && ! empty($names)) {
120 120
             return reset($names);
121 121
         } else {
Please login to merge, or discard this patch.