@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | * |
27 | 27 | * ------------------------------------------------------------------------ |
28 | 28 | */ |
29 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
29 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
30 | 30 | |
31 | 31 | class EEM_Extra_Meta extends EEM_Base { |
32 | 32 | |
33 | 33 | // private instance of the Attendee object |
34 | 34 | protected static $_instance = NULL; |
35 | 35 | |
36 | - protected function __construct( $timezone = NULL ) { |
|
37 | - $this->singular_item = __('Extra Meta','event_espresso'); |
|
38 | - $this->plural_item = __('Extra Metas','event_espresso'); |
|
36 | + protected function __construct($timezone = NULL) { |
|
37 | + $this->singular_item = __('Extra Meta', 'event_espresso'); |
|
38 | + $this->plural_item = __('Extra Metas', 'event_espresso'); |
|
39 | 39 | $this->_tables = array( |
40 | 40 | 'Extra_Meta'=> new EE_Primary_Table('esp_extra_meta', 'EXM_ID') |
41 | 41 | ); |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | |
51 | 51 | )); |
52 | 52 | $this->_model_relations = array(); |
53 | - foreach($models_this_can_attach_to as $model){ |
|
53 | + foreach ($models_this_can_attach_to as $model) { |
|
54 | 54 | $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation(); |
55 | 55 | } |
56 | - foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ) { |
|
57 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( 'EXM_key', 'EXM_value' ); |
|
56 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
57 | + $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta('EXM_key', 'EXM_value'); |
|
58 | 58 | } |
59 | - parent::__construct( $timezone ); |
|
59 | + parent::__construct($timezone); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once( EE_CLASSES . 'EE_Question_Group.class.php'); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once(EE_CLASSES.'EE_Question_Group.class.php'); |
|
26 | 26 | class EEM_Question_Group extends EEM_Soft_Delete_Base { |
27 | 27 | const system_personal = 1; |
28 | 28 | const system_address = 2; |
@@ -30,25 +30,25 @@ discard block |
||
30 | 30 | protected static $_instance = NULL; |
31 | 31 | |
32 | 32 | |
33 | - protected function __construct( $timezone = NULL ) { |
|
34 | - $this->singular_item = __('Question Group','event_espresso'); |
|
35 | - $this->plural_item = __('Question Groups','event_espresso'); |
|
33 | + protected function __construct($timezone = NULL) { |
|
34 | + $this->singular_item = __('Question Group', 'event_espresso'); |
|
35 | + $this->plural_item = __('Question Groups', 'event_espresso'); |
|
36 | 36 | |
37 | 37 | $this->_tables = array( |
38 | - 'Question_Group'=>new EE_Primary_Table('esp_question_group','QSG_ID') |
|
38 | + 'Question_Group'=>new EE_Primary_Table('esp_question_group', 'QSG_ID') |
|
39 | 39 | ); |
40 | 40 | $this->_fields = array( |
41 | 41 | 'Question_Group'=>array( |
42 | - 'QSG_ID'=>new EE_Primary_Key_Int_Field('QSG_ID', __('Question Group ID','event_espresso')), |
|
43 | - 'QSG_name'=>new EE_Plain_Text_Field('QSG_name', __('Question Group Name','event_espresso'), false, ''), |
|
44 | - 'QSG_identifier'=>new EE_Plain_Text_Field('QSG_identifier', __('Text ID for question Group','event_espresso'), false, ''), |
|
45 | - 'QSG_desc'=>new EE_Post_Content_Field('QSG_desc', __('Description of Question Group','event_espresso'), true, ''), |
|
46 | - 'QSG_order'=>new EE_Integer_Field('QSG_order', __('Order in which to show the question group','event_espresso'), true, 0), |
|
47 | - 'QSG_show_group_name'=>new EE_Boolean_Field('QSG_show_group_name', __('Flag indicating whether to show the group\'s name on the registration page','event_espresso'), false, true), |
|
48 | - 'QSG_show_group_desc'=>new EE_Boolean_Field('QSG_show_group_desc', __('Flag indicating whether to show the group\s description on the registration page','event_espresso'), false, false), |
|
49 | - 'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', __('Question Group Creator ID', 'event_espresso'), FALSE ), |
|
50 | - 'QSG_system'=>new EE_Integer_Field('QSG_system', __('Indicate IF this is a system group and if it is what system group it corresponds to.','event_espresso'), false, 0), |
|
51 | - 'QSG_deleted'=>new EE_Trashed_Flag_Field('QSG_deleted', __('Flag indicating this question group was deleted','event_espresso'), false, false) |
|
42 | + 'QSG_ID'=>new EE_Primary_Key_Int_Field('QSG_ID', __('Question Group ID', 'event_espresso')), |
|
43 | + 'QSG_name'=>new EE_Plain_Text_Field('QSG_name', __('Question Group Name', 'event_espresso'), false, ''), |
|
44 | + 'QSG_identifier'=>new EE_Plain_Text_Field('QSG_identifier', __('Text ID for question Group', 'event_espresso'), false, ''), |
|
45 | + 'QSG_desc'=>new EE_Post_Content_Field('QSG_desc', __('Description of Question Group', 'event_espresso'), true, ''), |
|
46 | + 'QSG_order'=>new EE_Integer_Field('QSG_order', __('Order in which to show the question group', 'event_espresso'), true, 0), |
|
47 | + 'QSG_show_group_name'=>new EE_Boolean_Field('QSG_show_group_name', __('Flag indicating whether to show the group\'s name on the registration page', 'event_espresso'), false, true), |
|
48 | + 'QSG_show_group_desc'=>new EE_Boolean_Field('QSG_show_group_desc', __('Flag indicating whether to show the group\s description on the registration page', 'event_espresso'), false, false), |
|
49 | + 'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', __('Question Group Creator ID', 'event_espresso'), FALSE), |
|
50 | + 'QSG_system'=>new EE_Integer_Field('QSG_system', __('Indicate IF this is a system group and if it is what system group it corresponds to.', 'event_espresso'), false, 0), |
|
51 | + 'QSG_deleted'=>new EE_Trashed_Flag_Field('QSG_deleted', __('Flag indicating this question group was deleted', 'event_espresso'), false, false) |
|
52 | 52 | ) |
53 | 53 | ); |
54 | 54 | $this->_model_relations = array( |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | 'WP_User' => new EE_Belongs_To_Relation(), |
59 | 59 | ); |
60 | 60 | //this model is generally available for reading |
61 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
62 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
63 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
64 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
65 | - parent::__construct( $timezone ); |
|
61 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
62 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
63 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
64 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QSG_system'); |
|
65 | + parent::__construct($timezone); |
|
66 | 66 | |
67 | 67 | } |
68 | 68 | /** |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function get_latest_question_group_order() { |
74 | 74 | $columns_to_select = array( |
75 | - 'max_order' => array("MAX(QSG_order)","%d") |
|
75 | + 'max_order' => array("MAX(QSG_order)", "%d") |
|
76 | 76 | ); |
77 | - $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select ); |
|
77 | + $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select); |
|
78 | 78 | return $max[0]['max_order']; |
79 | 79 | } |
80 | 80 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once( EE_CLASSES . 'EE_Question_Option.class.php'); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once(EE_CLASSES.'EE_Question_Option.class.php'); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | class EEM_Question_Option extends EEM_Soft_Delete_Base { |
@@ -30,22 +30,22 @@ discard block |
||
30 | 30 | // private instance of the Attendee object |
31 | 31 | protected static $_instance = NULL; |
32 | 32 | |
33 | - protected function __construct( $timezone = NULL ) { |
|
34 | - $this->singular_item = __('Question Option','event_espresso'); |
|
35 | - $this->plural_item = __('Question Options','event_espresso'); |
|
33 | + protected function __construct($timezone = NULL) { |
|
34 | + $this->singular_item = __('Question Option', 'event_espresso'); |
|
35 | + $this->plural_item = __('Question Options', 'event_espresso'); |
|
36 | 36 | |
37 | 37 | $this->_tables = array( |
38 | - 'Question_Option'=>new EE_Primary_Table('esp_question_option','QSO_ID') |
|
38 | + 'Question_Option'=>new EE_Primary_Table('esp_question_option', 'QSO_ID') |
|
39 | 39 | ); |
40 | 40 | $this->_fields = array( |
41 | 41 | 'Question_Option'=>array( |
42 | - 'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID','event_espresso')), |
|
43 | - 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID','event_espresso'), false, 0, 'Question'), |
|
44 | - 'QSO_value'=>new EE_Plain_Text_Field('QSO_value', __("Question Option Value", "event_espresso"),false,''), |
|
45 | - 'QSO_desc'=>new EE_Post_Content_Field('QSO_desc', __('Question Option Description','event_espresso'), false, ''), |
|
46 | - 'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso' ), false, 0 ), |
|
47 | - 'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option','event_espresso'), TRUE, NULL ), |
|
48 | - 'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed','event_espresso'), false, false) |
|
42 | + 'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID', 'event_espresso')), |
|
43 | + 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'), |
|
44 | + 'QSO_value'=>new EE_Plain_Text_Field('QSO_value', __("Question Option Value", "event_espresso"), false, ''), |
|
45 | + 'QSO_desc'=>new EE_Post_Content_Field('QSO_desc', __('Question Option Description', 'event_espresso'), false, ''), |
|
46 | + 'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso'), false, 0), |
|
47 | + 'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option', 'event_espresso'), TRUE, NULL), |
|
48 | + 'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed', 'event_espresso'), false, false) |
|
49 | 49 | ) |
50 | 50 | ); |
51 | 51 | $this->_model_relations = array( |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | |
55 | 55 | $this->_model_chain_to_wp_user = 'Question'; |
56 | 56 | //this model is generally available for reading |
57 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
58 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
59 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
60 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
57 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
58 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
59 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
60 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
61 | 61 | $this->_caps_slug = 'questions'; |
62 | - parent::__construct( $timezone ); |
|
62 | + parent::__construct($timezone); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * EEH_URL helper |
4 | 6 | * Helper class for URL-related PHP functions |
@@ -62,7 +64,7 @@ discard block |
||
62 | 64 | isset($results['response']['code']) && |
63 | 65 | $results['response']['code'] == '200'){ |
64 | 66 | return true; |
65 | - }else{ |
|
67 | + } else{ |
|
66 | 68 | return false; |
67 | 69 | } |
68 | 70 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * Sum all the deleted items. |
147 | 147 | * @param array $query_params like EEM_Base::get_all |
148 | 148 | * @param string $field_to_sum |
149 | - * @return int |
|
149 | + * @return double |
|
150 | 150 | */ |
151 | 151 | public function sum_deleted($query_params = null, $field_to_sum = null){ |
152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
196 | 196 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
198 | - * @return boolean success |
|
198 | + * @return integer success |
|
199 | 199 | */ |
200 | 200 | public function delete_permanently($query_params = array(), $allow_blocking = true){ |
201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | /** |
279 | 279 | * Updates all the items of this model which match the $query params, regardless of whether |
280 | 280 | * they've been soft-deleted or not |
281 | - * @param array $field_n_values like EEM_Base::update's $fields_n_value |
|
281 | + * @param array $fields_n_values like EEM_Base::update's $fields_n_value |
|
282 | 282 | * @param array $query_params like EEM_base::get_all's $query_params |
283 | 283 | * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects |
284 | 284 | * in this model's entity map according to $fields_n_values that match $query_params. This |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once( EE_MODELS . 'EEM_Base.model.php'); |
|
2 | +require_once(EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * EEM_Soft_Delete_Base |
5 | 5 | * |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | * @subpackage includes/models/ |
26 | 26 | * @author Michael Nelson |
27 | 27 | */ |
28 | -abstract class EEM_Soft_Delete_Base extends EEM_Base{ |
|
28 | +abstract class EEM_Soft_Delete_Base extends EEM_Base { |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param null $timezone |
32 | 32 | */ |
33 | 33 | protected function __construct($timezone = NULL) { |
34 | - if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ){ |
|
34 | + if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) { |
|
35 | 35 | $this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions(); |
36 | 36 | } |
37 | 37 | parent::__construct($timezone); |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | * @return string |
43 | 43 | * @throws EE_Error |
44 | 44 | */ |
45 | - public function deleted_field_name(){ |
|
45 | + public function deleted_field_name() { |
|
46 | 46 | $field = $this->get_a_field_of_type('EE_Trashed_Flag_Field'); |
47 | - if($field){ |
|
47 | + if ($field) { |
|
48 | 48 | return $field->get_name(); |
49 | - }else{ |
|
50 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
49 | + } else { |
|
50 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param array $query_params like EEM_Base::get_all's $query_params |
58 | 58 | * @return EE_Soft_Delete_Base_Class |
59 | 59 | */ |
60 | - public function get_one_deleted($query_params = array()){ |
|
60 | + public function get_one_deleted($query_params = array()) { |
|
61 | 61 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
62 | 62 | return parent::get_one($query_params); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param array $query_params like EEM_base::get_all's $query_params |
68 | 68 | * @return EE_Soft_Delete_Base_Class |
69 | 69 | */ |
70 | - public function get_one_deleted_or_undeleted($query_params = array()){ |
|
70 | + public function get_one_deleted_or_undeleted($query_params = array()) { |
|
71 | 71 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
72 | 72 | return parent::get_one($query_params); |
73 | 73 | } |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | * @param int|string $id |
78 | 78 | * @return EE_Soft_Delete_Base_Class |
79 | 79 | */ |
80 | - public function get_one_by_ID_but_ignore_deleted($id){ |
|
80 | + public function get_one_by_ID_but_ignore_deleted($id) { |
|
81 | 81 | return $this->get_one( |
82 | 82 | $this->alter_query_params_to_restrict_by_ID( |
83 | 83 | $id, |
84 | - array( 'default_where_conditions' => 'default' ) |
|
84 | + array('default_where_conditions' => 'default') |
|
85 | 85 | ) |
86 | 86 | ); |
87 | 87 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
94 | 94 | * @return int |
95 | 95 | */ |
96 | - public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
96 | + public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
97 | 97 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
98 | 98 | return parent::count($query_params, $field_to_count, $distinct); |
99 | 99 | } |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | * @param array $query_params like EEM_Base::get_all's $query_params |
104 | 104 | * @return array like EEM_Base::get_all's $query_params |
105 | 105 | */ |
106 | - protected function _alter_query_params_so_only_trashed_items_included($query_params){ |
|
107 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
108 | - $query_params[0][$deletedFlagFieldName]=true; |
|
106 | + protected function _alter_query_params_so_only_trashed_items_included($query_params) { |
|
107 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
108 | + $query_params[0][$deletedFlagFieldName] = true; |
|
109 | 109 | return $query_params; |
110 | 110 | } |
111 | 111 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @param array $query_params |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - public function alter_query_params_so_deleted_and_undeleted_items_included( $query_params = array() ){ |
|
117 | + public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) { |
|
118 | 118 | return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
119 | 119 | } |
120 | 120 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @param array $query_params |
124 | 124 | * @return array |
125 | 125 | */ |
126 | - protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){ |
|
127 | - if( ! isset( $query_params[ 'default_where_conditions' ] ) ) { |
|
126 | + protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) { |
|
127 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
128 | 128 | $query_params['default_where_conditions'] = 'minimum'; |
129 | 129 | } |
130 | 130 | return $query_params; |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
138 | 138 | * @return int |
139 | 139 | */ |
140 | - public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE){ |
|
140 | + public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE) { |
|
141 | 141 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
142 | - return parent::count($query_params,$field_to_count, $distinct); |
|
142 | + return parent::count($query_params, $field_to_count, $distinct); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $field_to_sum |
149 | 149 | * @return int |
150 | 150 | */ |
151 | - public function sum_deleted($query_params = null, $field_to_sum = null){ |
|
151 | + public function sum_deleted($query_params = null, $field_to_sum = null) { |
|
152 | 152 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
153 | 153 | return parent::sum($query_params, $field_to_sum); |
154 | 154 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * @param string $field_to_sum |
160 | 160 | * @reutrn int |
161 | 161 | */ |
162 | - public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null){ |
|
162 | + public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) { |
|
163 | 163 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
164 | 164 | parent::sum($query_params, $field_to_sum); |
165 | 165 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param array $query_params like EEM_Base::get_all |
170 | 170 | * @return EE_Soft_Delete_Base_Class[] |
171 | 171 | */ |
172 | - public function get_all_deleted_and_undeleted($query_params = array()){ |
|
172 | + public function get_all_deleted_and_undeleted($query_params = array()) { |
|
173 | 173 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
174 | 174 | return parent::get_all($query_params); |
175 | 175 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param array $query_params like EEM_Base::get_all |
180 | 180 | * @return EE_Soft_Delete_Base_Class[] |
181 | 181 | */ |
182 | - public function get_all_deleted($query_params = array()){ |
|
182 | + public function get_all_deleted($query_params = array()) { |
|
183 | 183 | $query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params); |
184 | 184 | return parent::get_all($query_params); |
185 | 185 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
198 | 198 | * @return boolean success |
199 | 199 | */ |
200 | - public function delete_permanently($query_params = array(), $allow_blocking = true){ |
|
200 | + public function delete_permanently($query_params = array(), $allow_blocking = true) { |
|
201 | 201 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
202 | 202 | return parent::delete_permanently($query_params, $allow_blocking); |
203 | 203 | } |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @param mixed $ID int if primary key is an int, string otherwise |
209 | 209 | * @return boolean success |
210 | 210 | */ |
211 | - public function restore_by_ID($ID=FALSE){ |
|
212 | - return $this->delete_or_restore_by_ID(false,$ID); |
|
211 | + public function restore_by_ID($ID = FALSE) { |
|
212 | + return $this->delete_or_restore_by_ID(false, $ID); |
|
213 | 213 | } |
214 | 214 | /** |
215 | 215 | * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However, |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @param mixed $ID int if primary key is an int, string otherwise |
219 | 219 | * @return boolean |
220 | 220 | */ |
221 | - public function delete_or_restore_by_ID($delete=true,$ID=FALSE){ |
|
222 | - if ( ! $ID ) { |
|
221 | + public function delete_or_restore_by_ID($delete = true, $ID = FALSE) { |
|
222 | + if ( ! $ID) { |
|
223 | 223 | return FALSE; |
224 | 224 | } |
225 | 225 | if ( |
226 | 226 | $this->delete_or_restore( |
227 | 227 | $delete, |
228 | - $this->alter_query_params_to_restrict_by_ID( $ID ) |
|
228 | + $this->alter_query_params_to_restrict_by_ID($ID) |
|
229 | 229 | ) |
230 | 230 | ) { |
231 | 231 | return TRUE; |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param bool $block_deletes |
246 | 246 | * @return boolean |
247 | 247 | */ |
248 | - public function delete($query_params = array(), $block_deletes = false){ |
|
248 | + public function delete($query_params = array(), $block_deletes = false) { |
|
249 | 249 | //no matter what, we WON'T block soft deletes. |
250 | 250 | return $this->delete_or_restore(true, $query_params); |
251 | 251 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @param array $query_params like EEM_Base::get_all |
257 | 257 | * @return boolean |
258 | 258 | */ |
259 | - public function restore($query_params = array()){ |
|
259 | + public function restore($query_params = array()) { |
|
260 | 260 | return $this->delete_or_restore(false, $query_params); |
261 | 261 | } |
262 | 262 | /** |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * @param array $query_params like EEM_Base::get_all |
266 | 266 | * @return boolean |
267 | 267 | */ |
268 | - function delete_or_restore($delete=true,$query_params = array()){ |
|
269 | - $deletedFlagFieldName=$this->deleted_field_name(); |
|
268 | + function delete_or_restore($delete = true, $query_params = array()) { |
|
269 | + $deletedFlagFieldName = $this->deleted_field_name(); |
|
270 | 270 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
271 | - if ( $this->update (array($deletedFlagFieldName=>$delete), $query_params )) { |
|
271 | + if ($this->update(array($deletedFlagFieldName=>$delete), $query_params)) { |
|
272 | 272 | return TRUE; |
273 | 273 | } else { |
274 | 274 | return FALSE; |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | * be aware that model objects being used could get out-of-sync with the database |
287 | 287 | * @return int number of items updated |
288 | 288 | */ |
289 | - public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE ){ |
|
289 | + public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
290 | 290 | $query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params); |
291 | - return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync ); |
|
291 | + return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
292 | 292 | } |
293 | 293 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * EEH_URL helper |
4 | 6 | * Helper class for URL-related PHP functions |
@@ -62,7 +64,7 @@ discard block |
||
62 | 64 | isset($results['response']['code']) && |
63 | 65 | $results['response']['code'] == '200'){ |
64 | 66 | return true; |
65 | - }else{ |
|
67 | + } else{ |
|
66 | 68 | return false; |
67 | 69 | } |
68 | 70 | } |
@@ -21,61 +21,61 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
25 | 25 | |
26 | 26 | class EEM_Term_Relationship extends EEM_Base { |
27 | 27 | |
28 | 28 | // private instance of the Attendee object |
29 | 29 | protected static $_instance = NULL; |
30 | 30 | |
31 | - protected function __construct( $timezone = NULL ) { |
|
32 | - $this->singular_item = __('Term Relationship','event_espresso'); |
|
33 | - $this->plural_item = __('Term Relationships','event_espresso'); |
|
31 | + protected function __construct($timezone = NULL) { |
|
32 | + $this->singular_item = __('Term Relationship', 'event_espresso'); |
|
33 | + $this->plural_item = __('Term Relationships', 'event_espresso'); |
|
34 | 34 | $this->_tables = array( |
35 | 35 | 'Term_Relationship'=> new EE_Primary_Table('term_relationships') |
36 | 36 | ); |
37 | - $models_this_can_attach_to = array_keys( EE_Registry::instance()->cpt_models() ); |
|
37 | + $models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models()); |
|
38 | 38 | $this->_fields = array( |
39 | 39 | 'Term_Relationship'=>array( |
40 | - 'object_id'=> new EE_Foreign_Key_Int_Field('object_id', __('Object(Post) ID','event_espresso'), false,0, $models_this_can_attach_to ), |
|
41 | - 'term_taxonomy_id'=>new EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'), |
|
42 | - 'term_order'=>new EE_Integer_Field('term_order', __('Term Order','event_espresso'), false, 0) |
|
40 | + 'object_id'=> new EE_Foreign_Key_Int_Field('object_id', __('Object(Post) ID', 'event_espresso'), false, 0, $models_this_can_attach_to), |
|
41 | + 'term_taxonomy_id'=>new EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID', 'event_espresso'), false, 0, 'Term_Taxonomy'), |
|
42 | + 'term_order'=>new EE_Integer_Field('term_order', __('Term Order', 'event_espresso'), false, 0) |
|
43 | 43 | )); |
44 | 44 | $this->_model_relations = array( |
45 | 45 | 'Term_Taxonomy'=>new EE_Belongs_To_Relation() |
46 | 46 | ); |
47 | - foreach( $models_this_can_attach_to as $model_name ) { |
|
48 | - $this->_model_relations[ $model_name ] = new EE_Belongs_To_Relation(); |
|
47 | + foreach ($models_this_can_attach_to as $model_name) { |
|
48 | + $this->_model_relations[$model_name] = new EE_Belongs_To_Relation(); |
|
49 | 49 | } |
50 | 50 | $this->_indexes = array( |
51 | - 'PRIMARY'=>new EE_Primary_Key_Index(array('object_id','term_taxonomy_id')) |
|
51 | + 'PRIMARY'=>new EE_Primary_Key_Index(array('object_id', 'term_taxonomy_id')) |
|
52 | 52 | ); |
53 | 53 | $path_to_event_model = 'Event.'; |
54 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( $path_to_event_model ); |
|
55 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( $path_to_event_model ); |
|
56 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( $path_to_event_model ); |
|
57 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( $path_to_event_model, EEM_Base::caps_edit ); |
|
54 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public($path_to_event_model); |
|
55 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model); |
|
56 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model); |
|
57 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model, EEM_Base::caps_edit); |
|
58 | 58 | |
59 | 59 | $path_to_tax_model = 'Term_Taxonomy.'; |
60 | 60 | //add cap restrictions for editing term relations to the "ee_assign_*" |
61 | 61 | //and for deleting term relations too |
62 | - $cap_contexts_affected = array( EEM_Base::caps_edit, EEM_Base::caps_delete ); |
|
63 | - foreach( $cap_contexts_affected as $cap_context_affected ) { |
|
64 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_category'] = new EE_Default_Where_Conditions( |
|
62 | + $cap_contexts_affected = array(EEM_Base::caps_edit, EEM_Base::caps_delete); |
|
63 | + foreach ($cap_contexts_affected as $cap_context_affected) { |
|
64 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_category'] = new EE_Default_Where_Conditions( |
|
65 | 65 | array( |
66 | - $path_to_tax_model . 'taxonomy*ee_assign_event_category' => array( '!=', 'espresso_event_categories' ) |
|
66 | + $path_to_tax_model.'taxonomy*ee_assign_event_category' => array('!=', 'espresso_event_categories') |
|
67 | 67 | )); |
68 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_venue_category'] = new EE_Default_Where_Conditions( |
|
68 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_venue_category'] = new EE_Default_Where_Conditions( |
|
69 | 69 | array( |
70 | - $path_to_tax_model . 'taxonomy*ee_assign_venue_category' => array( '!=', 'espresso_venue_categories' ) |
|
70 | + $path_to_tax_model.'taxonomy*ee_assign_venue_category' => array('!=', 'espresso_venue_categories') |
|
71 | 71 | )); |
72 | - $this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
|
72 | + $this->_cap_restrictions[$cap_context_affected]['ee_assign_event_type'] = new EE_Default_Where_Conditions( |
|
73 | 73 | array( |
74 | - $path_to_tax_model . 'taxonomy*ee_assign_event_type' => array( '!=', 'espresso_event_type' ) |
|
74 | + $path_to_tax_model.'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type') |
|
75 | 75 | )); |
76 | 76 | } |
77 | 77 | |
78 | - parent::__construct( $timezone ); |
|
78 | + parent::__construct($timezone); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -84,17 +84,17 @@ discard block |
||
84 | 84 | * @global type $wpdb |
85 | 85 | * @return int the number of rows affected |
86 | 86 | */ |
87 | - public function update_term_taxonomy_counts($term_taxonomy_id = NULL){ |
|
87 | + public function update_term_taxonomy_counts($term_taxonomy_id = NULL) { |
|
88 | 88 | //because this uses a subquery and sometimes assigning to column to be another column's |
89 | 89 | //value, we just write the SQL directly. |
90 | 90 | global $wpdb; |
91 | - if( $term_taxonomy_id ){ |
|
92 | - $second_operand = $wpdb->prepare('%d',$term_taxonomy_id); |
|
93 | - }else{ |
|
91 | + if ($term_taxonomy_id) { |
|
92 | + $second_operand = $wpdb->prepare('%d', $term_taxonomy_id); |
|
93 | + } else { |
|
94 | 94 | $second_operand = 'tr.term_taxonomy_id'; |
95 | 95 | } |
96 | - $rows_affected = $this->_do_wpdb_query( 'query' , array("UPDATE {$wpdb->term_taxonomy} AS tt SET count = (select count(*) as proper_count |
|
97 | -from {$wpdb->term_relationships} AS tr WHERE tt.term_taxonomy_id = $second_operand)" ) ); |
|
96 | + $rows_affected = $this->_do_wpdb_query('query', array("UPDATE {$wpdb->term_taxonomy} AS tt SET count = (select count(*) as proper_count |
|
97 | +from {$wpdb->term_relationships} AS tr WHERE tt.term_taxonomy_id = $second_operand)")); |
|
98 | 98 | return $rows_affected; |
99 | 99 | } |
100 | 100 | |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function insert($field_n_values) { |
108 | 108 | $return = parent::insert($field_n_values); |
109 | - if( isset( $field_n_values[ 'term_taxonomy_id' ] ) ) { |
|
110 | - $this->update_term_taxonomy_counts($field_n_values[ 'term_taxonomy_id' ] ); |
|
109 | + if (isset($field_n_values['term_taxonomy_id'])) { |
|
110 | + $this->update_term_taxonomy_counts($field_n_values['term_taxonomy_id']); |
|
111 | 111 | } |
112 | 112 | return $return; |
113 | 113 | } |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @return int |
124 | 124 | */ |
125 | 125 | public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
126 | - $count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync ); |
|
127 | - if( $count ){ |
|
126 | + $count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync); |
|
127 | + if ($count) { |
|
128 | 128 | $this->update_term_taxonomy_counts(); |
129 | 129 | } |
130 | 130 | return $count; |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function delete($query_params, $allow_blocking = true) { |
140 | 140 | $count = parent::delete($query_params, $allow_blocking); |
141 | - if( $count ){ |
|
141 | + if ($count) { |
|
142 | 142 | $this->update_term_taxonomy_counts(); |
143 | 143 | } |
144 | 144 | return $count; |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
25 | 25 | |
26 | 26 | class EEM_Term_Taxonomy extends EEM_Base { |
27 | 27 | |
@@ -29,67 +29,67 @@ discard block |
||
29 | 29 | protected static $_instance = NULL; |
30 | 30 | |
31 | 31 | |
32 | - protected function __construct( $timezone = NULL ) { |
|
33 | - $this->singular_item = __('Term Taxonomy','event_espresso'); |
|
34 | - $this->plural_item = __('Term Taxonomy','event_espresso'); |
|
32 | + protected function __construct($timezone = NULL) { |
|
33 | + $this->singular_item = __('Term Taxonomy', 'event_espresso'); |
|
34 | + $this->plural_item = __('Term Taxonomy', 'event_espresso'); |
|
35 | 35 | $this->_tables = array( |
36 | 36 | 'Term_Taxonomy'=> new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id') |
37 | 37 | ); |
38 | 38 | $this->_fields = array( |
39 | 39 | 'Term_Taxonomy'=>array( |
40 | - 'term_taxonomy_id'=> new EE_Primary_Key_Int_Field('term_taxonomy_id', __('Term-Taxonomy ID','event_espresso')), |
|
41 | - 'term_id'=>new EE_Foreign_Key_Int_Field('term_id', __("Term Id", "event_espresso"), false, 0, 'Term'), //EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'), |
|
42 | - 'taxonomy'=>new EE_Plain_Text_Field('taxonomy', __('Taxonomy Name','event_espresso'), false, 'category'), |
|
43 | - 'description'=>new EE_Post_Content_Field('description', __("Description of Term", "event_espresso"), false,''), |
|
44 | - 'parent'=>new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false,0), |
|
40 | + 'term_taxonomy_id'=> new EE_Primary_Key_Int_Field('term_taxonomy_id', __('Term-Taxonomy ID', 'event_espresso')), |
|
41 | + 'term_id'=>new EE_Foreign_Key_Int_Field('term_id', __("Term Id", "event_espresso"), false, 0, 'Term'), //EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'), |
|
42 | + 'taxonomy'=>new EE_Plain_Text_Field('taxonomy', __('Taxonomy Name', 'event_espresso'), false, 'category'), |
|
43 | + 'description'=>new EE_Post_Content_Field('description', __("Description of Term", "event_espresso"), false, ''), |
|
44 | + 'parent'=>new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0), |
|
45 | 45 | 'term_count'=> new EE_Integer_Field('count', __("Count of Objects attached", 'event_espresso'), false, 0) |
46 | 46 | )); |
47 | 47 | $this->_model_relations = array( |
48 | 48 | 'Term_Relationship'=>new EE_Has_Many_Relation(), |
49 | 49 | 'Term'=>new EE_Belongs_To_Relation(), |
50 | 50 | ); |
51 | - $cpt_models = array_keys( EE_Registry::instance()->cpt_models() ); |
|
52 | - foreach( $cpt_models as $model_name ) { |
|
53 | - $this->_model_relations[ $model_name ] = new EE_HABTM_Relation( 'Term_Relationship' ); |
|
51 | + $cpt_models = array_keys(EE_Registry::instance()->cpt_models()); |
|
52 | + foreach ($cpt_models as $model_name) { |
|
53 | + $this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship'); |
|
54 | 54 | } |
55 | 55 | $this->_indexes = array( |
56 | - 'term_id_taxonomy'=>new EE_Unique_Index(array('term_id','taxonomy')) |
|
56 | + 'term_id_taxonomy'=>new EE_Unique_Index(array('term_id', 'taxonomy')) |
|
57 | 57 | ); |
58 | 58 | $path_to_tax_model = ''; |
59 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
60 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( $path_to_tax_model ); |
|
61 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false; |
|
62 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false; |
|
59 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
60 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected($path_to_tax_model); |
|
61 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = false; |
|
62 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = false; |
|
63 | 63 | |
64 | 64 | //add cap restrictions for editing relating to the "ee_edit_*" |
65 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
65 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions( |
|
66 | 66 | array( |
67 | - $path_to_tax_model . 'taxonomy*ee_edit_event_category' => array( '!=', 'espresso_event_categories' ) |
|
67 | + $path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories') |
|
68 | 68 | )); |
69 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
69 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions( |
|
70 | 70 | array( |
71 | - $path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array( '!=', 'espresso_venue_categories' ) |
|
71 | + $path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories') |
|
72 | 72 | )); |
73 | - $this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
73 | + $this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions( |
|
74 | 74 | array( |
75 | - $path_to_tax_model . 'taxonomy*ee_edit_event_type' => array( '!=', 'espresso_event_type' ) |
|
75 | + $path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type') |
|
76 | 76 | )); |
77 | 77 | |
78 | 78 | //add cap restrictions for deleting relating to the "ee_deleting_*" |
79 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
79 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions( |
|
80 | 80 | array( |
81 | - $path_to_tax_model . 'taxonomy*ee_delete_event_category' => array( '!=', 'espresso_event_categories' ) |
|
81 | + $path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories') |
|
82 | 82 | )); |
83 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
83 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions( |
|
84 | 84 | array( |
85 | - $path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array( '!=', 'espresso_venue_categories' ) |
|
85 | + $path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories') |
|
86 | 86 | )); |
87 | - $this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
87 | + $this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions( |
|
88 | 88 | array( |
89 | - $path_to_tax_model . 'taxonomy*ee_delete_event_type' => array( '!=', 'espresso_event_type' ) |
|
89 | + $path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type') |
|
90 | 90 | )); |
91 | 91 | |
92 | - parent::__construct( $timezone ); |
|
92 | + parent::__construct($timezone); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
25 | 25 | |
26 | 26 | class EEM_Venue extends EEM_CPT_Base { |
27 | 27 | |
28 | 28 | // private instance of the Attendee object |
29 | 29 | protected static $_instance = NULL; |
30 | 30 | |
31 | - protected function __construct( $timezone = NULL ) { |
|
32 | - $this->singular_item = __('Venue','event_espresso'); |
|
33 | - $this->plural_item = __('Venues','event_espresso'); |
|
31 | + protected function __construct($timezone = NULL) { |
|
32 | + $this->singular_item = __('Venue', 'event_espresso'); |
|
33 | + $this->plural_item = __('Venues', 'event_espresso'); |
|
34 | 34 | $this->_tables = array( |
35 | 35 | 'Venue_CPT'=> new EE_Primary_Table('posts', 'ID'), |
36 | 36 | 'Venue_Meta'=>new EE_Secondary_Table('esp_venue_meta', 'VNUM_ID', 'VNU_ID') |
@@ -39,32 +39,32 @@ discard block |
||
39 | 39 | 'Venue_CPT'=>array( |
40 | 40 | 'VNU_ID'=>new EE_Primary_Key_Int_Field('ID', __("Venue ID", "event_espresso")), |
41 | 41 | 'VNU_name'=>new EE_Plain_Text_Field('post_title', __("Venue Name", "event_espresso"), false, ''), |
42 | - 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false,''), |
|
43 | - 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false,''), |
|
44 | - 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE,time()), |
|
45 | - 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true,''), |
|
46 | - 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE,time()), |
|
47 | - 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false ), |
|
48 | - 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false,0), |
|
42 | + 'VNU_desc'=>new EE_Post_Content_Field('post_content', __("Venue Description", "event_espresso"), false, ''), |
|
43 | + 'VNU_identifier'=>new EE_Slug_Field('post_name', __("Venue Identifier", "event_espresso"), false, ''), |
|
44 | + 'VNU_created'=>new EE_Datetime_Field('post_date', __("Date Venue Created", "event_espresso"), FALSE, time()), |
|
45 | + 'VNU_short_desc'=>new EE_Plain_Text_Field('post_excerpt', __("Short Description of Venue", "event_espresso"), true, ''), |
|
46 | + 'VNU_modified'=>new EE_Datetime_Field('post_modified', __("Venue Modified Date", "event_espresso"), FALSE, time()), |
|
47 | + 'VNU_wp_user'=>new EE_WP_User_Field('post_author', __("Venue Creator ID", "event_espresso"), false), |
|
48 | + 'parent'=>new EE_Integer_Field('post_parent', __("Venue Parent ID", "event_espresso"), false, 0), |
|
49 | 49 | 'VNU_order'=>new EE_Integer_Field('menu_order', __("Venue order", "event_espresso"), false, 1), |
50 | - 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'),// EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
50 | + 'post_type'=>new EE_WP_Post_Type_Field('espresso_venues'), // EE_Plain_Text_Field('post_type', __("Venue post type", "event_espresso"), false, 'espresso_venues'), |
|
51 | 51 | ), |
52 | 52 | 'Venue_Meta'=>array( |
53 | 53 | 'VNUM_ID'=>new EE_DB_Only_Int_Field('VNUM_ID', __("ID of Venue Meta Row", "event_espresso"), false), |
54 | 54 | 'VNU_ID_fk'=>new EE_DB_Only_Int_Field('VNU_ID', __("Foreign Key to Venue Post ", "event_espresso"), false), |
55 | 55 | 'VNU_address'=>new EE_Plain_Text_Field('VNU_address', __("Venue Address line 1", "event_espresso"), true, ''), |
56 | - 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true,''), |
|
56 | + 'VNU_address2'=>new EE_Plain_Text_Field('VNU_address2', __("Venue Address line 2", "event_espresso"), true, ''), |
|
57 | 57 | 'VNU_city'=>new EE_Plain_Text_Field('VNU_city', __("Venue City", "event_espresso"), true, ''), |
58 | 58 | 'STA_ID'=>new EE_Foreign_Key_Int_Field('STA_ID', __("State ID", "event_espresso"), true, null, 'State'), |
59 | 59 | 'CNT_ISO'=>new EE_Foreign_Key_String_Field('CNT_ISO', __("Country Code", "event_espresso"), true, null, 'Country'), |
60 | 60 | 'VNU_zip'=>new EE_Plain_Text_Field('VNU_zip', __("Venue Zip/Postal Code", "event_espresso"), true), |
61 | 61 | 'VNU_phone'=>new EE_Plain_Text_Field('VNU_phone', __("Venue Phone", "event_espresso"), true), |
62 | - 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true,EE_INF), |
|
62 | + 'VNU_capacity'=>new EE_Infinite_Integer_Field('VNU_capacity', __("Venue Capacity", "event_espresso"), true, EE_INF), |
|
63 | 63 | 'VNU_url'=>new EE_Plain_Text_Field('VNU_url', __('Venue Website', 'event_espresso'), true), |
64 | 64 | 'VNU_virtual_phone'=>new EE_Plain_Text_Field('VNU_virtual_phone', __('Call in Number', 'event_espresso'), true), |
65 | - 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true ), |
|
66 | - 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true ), |
|
67 | - 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false ) |
|
65 | + 'VNU_virtual_url'=>new EE_Plain_Text_Field('VNU_virtual_url', __('Virtual URL', 'event_espresso'), true), |
|
66 | + 'VNU_google_map_link'=>new EE_Plain_Text_Field('VNU_google_map_link', __('Google Map Link', 'event_espresso'), true), |
|
67 | + 'VNU_enable_for_gmap'=>new EE_Boolean_Field('VNU_enable_for_gmap', __('Show Google Map?', 'event_espresso'), false, false) |
|
68 | 68 | |
69 | 69 | )); |
70 | 70 | $this->_model_relations = array( |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | ); |
77 | 77 | $this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_venues', 'VNUM_ID'); |
78 | 78 | //this model is generally available for reading |
79 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
80 | - parent::__construct( $timezone ); |
|
79 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
80 | + parent::__construct($timezone); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | //so in case teh IPN is arriving later, let's try to process an IPN! |
91 | 91 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
92 | 92 | return $this->handle_ipn($_POST, $transaction ); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return parent::finalize_payment_for( $transaction ); |
95 | 95 | } |
96 | 96 | } |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | -require_once( EE_MODELS . 'fields/EE_Integer_Field.php'); |
|
3 | -class EE_Boolean_Field extends EE_Integer_Field{ |
|
2 | +require_once(EE_MODELS.'fields/EE_Integer_Field.php'); |
|
3 | +class EE_Boolean_Field extends EE_Integer_Field { |
|
4 | 4 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
5 | - if ($value_inputted_for_field_on_model_object){ |
|
5 | + if ($value_inputted_for_field_on_model_object) { |
|
6 | 6 | return true; |
7 | - }else{ |
|
7 | + } else { |
|
8 | 8 | return false; |
9 | 9 | } |
10 | 10 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @return boolean |
15 | 15 | */ |
16 | 16 | function prepare_for_set_from_db($value_inputted_for_field_on_model_object) { |
17 | - return intval( $value_inputted_for_field_on_model_object ) ? true : false; |
|
17 | + return intval($value_inputted_for_field_on_model_object) ? true : false; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * @param boolean $value_on_field_to_be_outputted |
23 | 23 | * @return string Yes or No |
24 | 24 | */ |
25 | - function prepare_for_pretty_echoing( $value_on_field_to_be_outputted ) { |
|
25 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted) { |
|
26 | 26 | return apply_filters( |
27 | 27 | 'FHEE__EE_Boolean_Field__prepare_for_pretty_echoing__return', |
28 | - $value_on_field_to_be_outputted ? __( 'Yes', 'event_espresso' ) : __( 'No', 'event_espresso' ), |
|
28 | + $value_on_field_to_be_outputted ? __('Yes', 'event_espresso') : __('No', 'event_espresso'), |
|
29 | 29 | $value_on_field_to_be_outputted |
30 | 30 | ); |
31 | 31 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | public function construction_finalized(){ |
93 | 93 | if( $this->_model instanceof EEM_Base && $this->_action ){ |
94 | 94 | return true; |
95 | - }else{ |
|
95 | + } else{ |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | public function has_generated_cap_restrictions(){ |
126 | 126 | if( $this->_cap_restrictions_generated === false ){ |
127 | 127 | return false; |
128 | - }else{ |
|
128 | + } else{ |
|
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $caps_for_admin = EE_Registry::instance()->CAP->get_ee_capabilities( 'administrator' ); |
154 | 154 | if( in_array( self::get_cap_name( $model, $action ), $caps_for_admin ) ) { |
155 | 155 | return true; |
156 | - }else{ |
|
156 | + } else{ |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | } |
@@ -7,32 +7,32 @@ discard block |
||
7 | 7 | * other than explicitly setting it to EE_INF. |
8 | 8 | * Makes use of constant EE_INF_IN_DB set in espresso.php, and EE_INF, which is a PHP constant definedin the ether |
9 | 9 | */ |
10 | -class EE_Infinite_Integer_Field extends EE_Model_Field_Base{ |
|
11 | - function get_wpdb_data_type(){ |
|
10 | +class EE_Infinite_Integer_Field extends EE_Model_Field_Base { |
|
11 | + function get_wpdb_data_type() { |
|
12 | 12 | return '%d'; |
13 | 13 | } |
14 | 14 | function prepare_for_use_in_db($value_of_field_on_model_object) { |
15 | - if($value_of_field_on_model_object === EE_INF){ |
|
15 | + if ($value_of_field_on_model_object === EE_INF) { |
|
16 | 16 | return EE_INF_IN_DB; |
17 | - }else{ |
|
17 | + } else { |
|
18 | 18 | return intval($value_of_field_on_model_object); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
22 | - if($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
22 | + if ($value_inputted_for_field_on_model_object === EE_INF_IN_DB || |
|
23 | 23 | $value_inputted_for_field_on_model_object === EE_INF || |
24 | 24 | $value_inputted_for_field_on_model_object === "EE_INF" |
25 | - ){ |
|
25 | + ) { |
|
26 | 26 | return EE_INF; |
27 | - }else{ |
|
27 | + } else { |
|
28 | 28 | return intval($value_inputted_for_field_on_model_object); |
29 | 29 | } |
30 | 30 | } |
31 | 31 | function prepare_for_set_from_db($value_inputted_for_field_on_model_object) { |
32 | 32 | $intval = intval($value_inputted_for_field_on_model_object); |
33 | - if($intval == EE_INF_IN_DB){ |
|
33 | + if ($intval == EE_INF_IN_DB) { |
|
34 | 34 | return EE_INF; |
35 | - }else{ |
|
35 | + } else { |
|
36 | 36 | return $intval; |
37 | 37 | } |
38 | 38 | } |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param string $schema input, symbol, text; or any string you want to show if the value equals EE_INF |
46 | 46 | * @return string |
47 | 47 | */ |
48 | - function prepare_for_pretty_echoing( $value_on_field_to_be_outputted, $schema = null ) { |
|
49 | - if( $value_on_field_to_be_outputted === EE_INF ){ |
|
50 | - switch($schema){ |
|
48 | + function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
|
49 | + if ($value_on_field_to_be_outputted === EE_INF) { |
|
50 | + switch ($schema) { |
|
51 | 51 | case 'input': |
52 | 52 | return ''; |
53 | 53 | case 'symbol': |