Completed
Branch BUG/3615-empty-array-arguments (44a08d)
by
unknown
13:14 queued 10:24
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_Answer.model.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null)
100 100
     {
101
-        $answer_obj = $this->get_one(array( array( 'QST_ID' => $question_id, 'REG_ID' => $registration->ID() )));
101
+        $answer_obj = $this->get_one(array(array('QST_ID' => $question_id, 'REG_ID' => $registration->ID())));
102 102
         return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
103 103
     }
104 104
 
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
         if (is_numeric($question_system_id)) {
122 122
             // find this question's QST_system value
123 123
             $question_id = $question_system_id;
124
-            $question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system');
124
+            $question_system_id = EEM_Question::instance()->get_var(array(array('QST_ID' => $question_system_id)), 'QST_system');
125 125
         } else {
126
-            $question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID');
126
+            $question_id = (int) EEM_Question::instance()->get_var(array(array('QST_system' => $question_system_id)), 'QST_ID');
127 127
         }
128 128
         // only bother checking if the registration has an attendee
129 129
         if ($registration->attendee() instanceof EE_Attendee) {
Please login to merge, or discard this patch.
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -10,142 +10,142 @@
 block discarded – undo
10 10
 class EEM_Answer extends EEM_Base
11 11
 {
12 12
 
13
-    /**
14
-     * private instance of the EEM_Answer object
15
-     * @type EEM_Answer
16
-     */
17
-    protected static $_instance = null;
13
+	/**
14
+	 * private instance of the EEM_Answer object
15
+	 * @type EEM_Answer
16
+	 */
17
+	protected static $_instance = null;
18 18
 
19
-    /**
20
-     * Mapping from system question ids to attendee field names
21
-     * @type array
22
-     * @deprecated since version 4.8.8
23
-     */
24
-    protected $_question_id_to_att_field_map = array(
25
-        EEM_Attendee::fname_question_id => 'ATT_fname',
26
-        EEM_Attendee::lname_question_id => 'ATT_lname',
27
-        EEM_Attendee::email_question_id => 'ATT_email',
28
-        EEM_Attendee::address_question_id => 'ATT_address',
29
-        EEM_Attendee::address2_question_id => 'ATT_address2',
30
-        EEM_Attendee::city_question_id => 'ATT_city',
31
-        EEM_Attendee::state_question_id => 'STA_ID',
32
-        EEM_Attendee::country_question_id => 'CNT_ISO',
33
-        EEM_Attendee::zip_question_id => 'ATT_zip',
34
-        EEM_Attendee::phone_question_id => 'ATT_phone'
35
-    );
19
+	/**
20
+	 * Mapping from system question ids to attendee field names
21
+	 * @type array
22
+	 * @deprecated since version 4.8.8
23
+	 */
24
+	protected $_question_id_to_att_field_map = array(
25
+		EEM_Attendee::fname_question_id => 'ATT_fname',
26
+		EEM_Attendee::lname_question_id => 'ATT_lname',
27
+		EEM_Attendee::email_question_id => 'ATT_email',
28
+		EEM_Attendee::address_question_id => 'ATT_address',
29
+		EEM_Attendee::address2_question_id => 'ATT_address2',
30
+		EEM_Attendee::city_question_id => 'ATT_city',
31
+		EEM_Attendee::state_question_id => 'STA_ID',
32
+		EEM_Attendee::country_question_id => 'CNT_ISO',
33
+		EEM_Attendee::zip_question_id => 'ATT_zip',
34
+		EEM_Attendee::phone_question_id => 'ATT_phone'
35
+	);
36 36
 
37 37
 
38 38
 
39
-    /**
40
-     *  constructor
41
-     */
42
-    protected function __construct($timezone = null)
43
-    {
44
-        $this->singular_item = esc_html__('Answer', 'event_espresso');
45
-        $this->plural_item = esc_html__('Answers', 'event_espresso');
46
-        $this->_tables = array(
47
-            'Answer' => new EE_Primary_Table('esp_answer', 'ANS_ID')
48
-        );
49
-        $this->_fields = array(
50
-            'Answer' => array(
51
-                'ANS_ID' => new EE_Primary_Key_Int_Field('ANS_ID', esc_html__('Answer ID', 'event_espresso')),
52
-                'REG_ID' => new EE_Foreign_Key_Int_Field('REG_ID', esc_html__('Registration ID', 'event_espresso'), false, 0, 'Registration'),
53
-                'QST_ID' => new EE_Foreign_Key_Int_Field('QST_ID', esc_html__('Question ID', 'event_espresso'), false, 0, 'Question'),
54
-                'ANS_value' => new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', esc_html__('Answer Value', 'event_espresso'), false, '')
55
-            ));
56
-        $this->_model_relations = array(
57
-            'Registration' => new EE_Belongs_To_Relation(),
58
-            'Question' => new EE_Belongs_To_Relation()
59
-        );
60
-        $this->_model_chain_to_wp_user = 'Registration.Event';
61
-        $this->_caps_slug = 'registrations';
62
-        parent::__construct($timezone);
63
-    }
39
+	/**
40
+	 *  constructor
41
+	 */
42
+	protected function __construct($timezone = null)
43
+	{
44
+		$this->singular_item = esc_html__('Answer', 'event_espresso');
45
+		$this->plural_item = esc_html__('Answers', 'event_espresso');
46
+		$this->_tables = array(
47
+			'Answer' => new EE_Primary_Table('esp_answer', 'ANS_ID')
48
+		);
49
+		$this->_fields = array(
50
+			'Answer' => array(
51
+				'ANS_ID' => new EE_Primary_Key_Int_Field('ANS_ID', esc_html__('Answer ID', 'event_espresso')),
52
+				'REG_ID' => new EE_Foreign_Key_Int_Field('REG_ID', esc_html__('Registration ID', 'event_espresso'), false, 0, 'Registration'),
53
+				'QST_ID' => new EE_Foreign_Key_Int_Field('QST_ID', esc_html__('Question ID', 'event_espresso'), false, 0, 'Question'),
54
+				'ANS_value' => new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', esc_html__('Answer Value', 'event_espresso'), false, '')
55
+			));
56
+		$this->_model_relations = array(
57
+			'Registration' => new EE_Belongs_To_Relation(),
58
+			'Question' => new EE_Belongs_To_Relation()
59
+		);
60
+		$this->_model_chain_to_wp_user = 'Registration.Event';
61
+		$this->_caps_slug = 'registrations';
62
+		parent::__construct($timezone);
63
+	}
64 64
 
65 65
 
66 66
 
67
-    /**
68
-     * Gets the string answer to the question for this registration (it could either be stored
69
-     * on the attendee or in the answer table. This function finds its value regardless)
70
-     * @param EE_Registration $registration
71
-     * @param int $question_id
72
-     * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value'
73
-     * @return string
74
-     */
75
-    public function get_answer_value_to_question(EE_Registration $registration, $question_id = null, $pretty_answer = false)
76
-    {
77
-        $value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer);
78
-        if ($value === null) {
79
-            $answer_obj = $this->get_registration_question_answer_object($registration, $question_id);
80
-            if ($answer_obj instanceof EE_Answer) {
81
-                if ($pretty_answer) {
82
-                    $value = $answer_obj->pretty_value();
83
-                } else {
84
-                    $value = $answer_obj->value();
85
-                }
86
-            }
87
-        }
88
-        return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id);
89
-    }
67
+	/**
68
+	 * Gets the string answer to the question for this registration (it could either be stored
69
+	 * on the attendee or in the answer table. This function finds its value regardless)
70
+	 * @param EE_Registration $registration
71
+	 * @param int $question_id
72
+	 * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value'
73
+	 * @return string
74
+	 */
75
+	public function get_answer_value_to_question(EE_Registration $registration, $question_id = null, $pretty_answer = false)
76
+	{
77
+		$value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer);
78
+		if ($value === null) {
79
+			$answer_obj = $this->get_registration_question_answer_object($registration, $question_id);
80
+			if ($answer_obj instanceof EE_Answer) {
81
+				if ($pretty_answer) {
82
+					$value = $answer_obj->pretty_value();
83
+				} else {
84
+					$value = $answer_obj->value();
85
+				}
86
+			}
87
+		}
88
+		return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id);
89
+	}
90 90
 
91 91
 
92 92
 
93
-    /**
94
-     * Gets the EE_Answer object for the question for this registration (if it exists)
95
-     * @param EE_Registration $registration
96
-     * @param int $question_id
97
-     * @return EE_Answer
98
-     */
99
-    public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null)
100
-    {
101
-        $answer_obj = $this->get_one(array( array( 'QST_ID' => $question_id, 'REG_ID' => $registration->ID() )));
102
-        return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
103
-    }
93
+	/**
94
+	 * Gets the EE_Answer object for the question for this registration (if it exists)
95
+	 * @param EE_Registration $registration
96
+	 * @param int $question_id
97
+	 * @return EE_Answer
98
+	 */
99
+	public function get_registration_question_answer_object(EE_Registration $registration, $question_id = null)
100
+	{
101
+		$answer_obj = $this->get_one(array( array( 'QST_ID' => $question_id, 'REG_ID' => $registration->ID() )));
102
+		return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id);
103
+	}
104 104
 
105 105
 
106 106
 
107
-    /**
108
-     * Gets the string answer to the question for this registration's attendee
109
-     * @param EE_Registration $registration
110
-     * @param int|string $question_system_id if an INT this is understood to be the question's ID; if a string then it should be its QST_system value.
111
-     *  Passing in the QST_system value is more efficient
112
-     * @param boolean $pretty_answer
113
-     * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for
114
-     * a question corresponding to an attendee field, returns null)
115
-     */
116
-    public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = null, $pretty_answer = false)
117
-    {
118
-        $field_name = null;
119
-        $value = null;
120
-                // backward compat: we still want to find the question's ID
121
-        if (is_numeric($question_system_id)) {
122
-            // find this question's QST_system value
123
-            $question_id = $question_system_id;
124
-            $question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system');
125
-        } else {
126
-            $question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID');
127
-        }
128
-        // only bother checking if the registration has an attendee
129
-        if ($registration->attendee() instanceof EE_Attendee) {
130
-            $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id);
131
-            if ($field_name) {
132
-                if ($pretty_answer) {
133
-                    if ($field_name === 'STA_ID') {
134
-                        $state = $registration->attendee()->state_obj();
135
-                        $value = $state instanceof EE_State ? $state->name() : sprintf(esc_html__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID());
136
-                    } elseif ($field_name === 'CNT_ISO') {
137
-                        $country = $registration->attendee()->country_obj();
138
-                        $value = $country instanceof EE_Country ? $country->name() : sprintf(esc_html__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID());
139
-                    } else {
140
-                        $value = $registration->attendee()->get_pretty($field_name);
141
-                    }
142
-                    // if field name is blank, leave the value as null too
143
-                } else {
144
-                    $value = $registration->attendee()->get($field_name);
145
-                }
146
-            }
147
-            // if no field was found, leave value blank
148
-        }
149
-        return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id);
150
-    }
107
+	/**
108
+	 * Gets the string answer to the question for this registration's attendee
109
+	 * @param EE_Registration $registration
110
+	 * @param int|string $question_system_id if an INT this is understood to be the question's ID; if a string then it should be its QST_system value.
111
+	 *  Passing in the QST_system value is more efficient
112
+	 * @param boolean $pretty_answer
113
+	 * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for
114
+	 * a question corresponding to an attendee field, returns null)
115
+	 */
116
+	public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = null, $pretty_answer = false)
117
+	{
118
+		$field_name = null;
119
+		$value = null;
120
+				// backward compat: we still want to find the question's ID
121
+		if (is_numeric($question_system_id)) {
122
+			// find this question's QST_system value
123
+			$question_id = $question_system_id;
124
+			$question_system_id = EEM_Question::instance()->get_var(array( array( 'QST_ID' => $question_system_id ) ), 'QST_system');
125
+		} else {
126
+			$question_id = (int) EEM_Question::instance()->get_var(array( array( 'QST_system' => $question_system_id ) ), 'QST_ID');
127
+		}
128
+		// only bother checking if the registration has an attendee
129
+		if ($registration->attendee() instanceof EE_Attendee) {
130
+			$field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id);
131
+			if ($field_name) {
132
+				if ($pretty_answer) {
133
+					if ($field_name === 'STA_ID') {
134
+						$state = $registration->attendee()->state_obj();
135
+						$value = $state instanceof EE_State ? $state->name() : sprintf(esc_html__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID());
136
+					} elseif ($field_name === 'CNT_ISO') {
137
+						$country = $registration->attendee()->country_obj();
138
+						$value = $country instanceof EE_Country ? $country->name() : sprintf(esc_html__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID());
139
+					} else {
140
+						$value = $registration->attendee()->get_pretty($field_name);
141
+					}
142
+					// if field name is blank, leave the value as null too
143
+				} else {
144
+					$value = $registration->attendee()->get($field_name);
145
+				}
146
+			}
147
+			// if no field was found, leave value blank
148
+		}
149
+		return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id);
150
+	}
151 151
 }
Please login to merge, or discard this patch.