@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api\controllers\model; |
3 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -22,20 +22,20 @@ discard block |
||
22 | 22 | * @param \WP_REST_Request $request |
23 | 23 | * @return array|\WP_REST_Response |
24 | 24 | */ |
25 | - public static function handle_request_models_meta( \WP_REST_Request $request ) { |
|
25 | + public static function handle_request_models_meta(\WP_REST_Request $request) { |
|
26 | 26 | $controller = new Meta(); |
27 | - try{ |
|
27 | + try { |
|
28 | 28 | $matches = $controller->parse_route( |
29 | 29 | $request->get_route(), |
30 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . 'resources~', |
|
31 | - array( 'version' ) ); |
|
32 | - if( $matches instanceof \WP_REST_Response ) { |
|
30 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'resources~', |
|
31 | + array('version') ); |
|
32 | + if ($matches instanceof \WP_REST_Response) { |
|
33 | 33 | return $matches; |
34 | 34 | } |
35 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
36 | - return $controller->send_response( $controller->_get_models_metadata_entity() ); |
|
37 | - } catch( \Exception $e ) { |
|
38 | - return $controller->send_response( $e ); |
|
35 | + $controller->set_requested_version($matches['version']); |
|
36 | + return $controller->send_response($controller->_get_models_metadata_entity()); |
|
37 | + } catch (\Exception $e) { |
|
38 | + return $controller->send_response($e); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
@@ -43,58 +43,58 @@ discard block |
||
43 | 43 | * Gets the model metadata resource entity |
44 | 44 | * @return array for JSON response, describing all the models available in teh requested version |
45 | 45 | */ |
46 | - protected function _get_models_metadata_entity(){ |
|
46 | + protected function _get_models_metadata_entity() { |
|
47 | 47 | $response = array(); |
48 | - foreach( $this->get_model_version_info()->models_for_requested_version() as $model_name => $model_classname ){ |
|
49 | - $model = $this->get_model_version_info()->load_model( $model_name ); |
|
48 | + foreach ($this->get_model_version_info()->models_for_requested_version() as $model_name => $model_classname) { |
|
49 | + $model = $this->get_model_version_info()->load_model($model_name); |
|
50 | 50 | $fields_json = array(); |
51 | - foreach( $this->get_model_version_info()->fields_on_model_in_this_version( $model ) as $field_name => $field_obj ) { |
|
52 | - if( $this->get_model_version_info()->field_is_ignored( $field_obj ) ) { |
|
51 | + foreach ($this->get_model_version_info()->fields_on_model_in_this_version($model) as $field_name => $field_obj) { |
|
52 | + if ($this->get_model_version_info()->field_is_ignored($field_obj)) { |
|
53 | 53 | continue; |
54 | 54 | } |
55 | - if( $field_obj instanceof \EE_Boolean_Field ) { |
|
55 | + if ($field_obj instanceof \EE_Boolean_Field) { |
|
56 | 56 | $datatype = 'Boolean'; |
57 | - }elseif( $field_obj->get_wpdb_data_type() == '%d' ) { |
|
57 | + }elseif ($field_obj->get_wpdb_data_type() == '%d') { |
|
58 | 58 | $datatype = 'Number'; |
59 | - }elseif( $field_name instanceof \EE_Serialized_Text_Field ) { |
|
59 | + }elseif ($field_name instanceof \EE_Serialized_Text_Field) { |
|
60 | 60 | $datatype = 'Object'; |
61 | - }else{ |
|
61 | + } else { |
|
62 | 62 | $datatype = 'String'; |
63 | 63 | } |
64 | 64 | $default_value = $field_obj->get_default_value(); |
65 | - if( $default_value === EE_INF ) { |
|
65 | + if ($default_value === EE_INF) { |
|
66 | 66 | $default_value = EE_INF_IN_DB; |
67 | - } elseif( $field_obj instanceof \EE_Datetime_Field && |
|
68 | - $default_value instanceof \DateTime ) { |
|
69 | - $default_value = $default_value->format( 'c' ); |
|
67 | + } elseif ($field_obj instanceof \EE_Datetime_Field && |
|
68 | + $default_value instanceof \DateTime) { |
|
69 | + $default_value = $default_value->format('c'); |
|
70 | 70 | } |
71 | 71 | $field_json = array( |
72 | 72 | 'name' => $field_name, |
73 | 73 | 'nicename' => $field_obj->get_nicename(), |
74 | - 'has_rendered_format' => $this->get_model_version_info()->field_has_rendered_format( $field_obj ), |
|
75 | - 'has_pretty_format' => $this->get_model_version_info()->field_has_pretty_format( $field_obj ), |
|
76 | - 'type' => str_replace('EE_', '', get_class( $field_obj ) ), |
|
74 | + 'has_rendered_format' => $this->get_model_version_info()->field_has_rendered_format($field_obj), |
|
75 | + 'has_pretty_format' => $this->get_model_version_info()->field_has_pretty_format($field_obj), |
|
76 | + 'type' => str_replace('EE_', '', get_class($field_obj)), |
|
77 | 77 | 'datatype' => $datatype, |
78 | 78 | 'nullable' => $field_obj->is_nullable(), |
79 | 79 | 'default' => $default_value, |
80 | 80 | 'table_alias' => $field_obj->get_table_alias(), |
81 | 81 | 'table_column' => $field_obj->get_table_column(), |
82 | 82 | ); |
83 | - $fields_json[ $field_json[ 'name' ] ] = $field_json; |
|
83 | + $fields_json[$field_json['name']] = $field_json; |
|
84 | 84 | |
85 | 85 | } |
86 | - $fields_json = array_merge( $fields_json, $this->get_model_version_info()->extra_resource_properties_for_model( $model ) ); |
|
87 | - $response[ $model_name ]['fields'] = apply_filters( 'FHEE__Meta__handle_request_models_meta__fields', $fields_json, $model ); |
|
86 | + $fields_json = array_merge($fields_json, $this->get_model_version_info()->extra_resource_properties_for_model($model)); |
|
87 | + $response[$model_name]['fields'] = apply_filters('FHEE__Meta__handle_request_models_meta__fields', $fields_json, $model); |
|
88 | 88 | $relations_json = array(); |
89 | - foreach( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
89 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
90 | 90 | $relation_json = array( |
91 | 91 | 'name' => $relation_name, |
92 | - 'type' => str_replace( 'EE_', '', get_class( $relation_obj ) ), |
|
92 | + 'type' => str_replace('EE_', '', get_class($relation_obj)), |
|
93 | 93 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false, |
94 | 94 | ); |
95 | - $relations_json[ $relation_name ] = $relation_json; |
|
95 | + $relations_json[$relation_name] = $relation_json; |
|
96 | 96 | } |
97 | - $response[ $model_name ][ 'relations' ] = apply_filters( 'FHEE__Meta__handle_request_models_meta__relations', $relations_json, $model ); |
|
97 | + $response[$model_name]['relations'] = apply_filters('FHEE__Meta__handle_request_models_meta__relations', $relations_json, $model); |
|
98 | 98 | } |
99 | 99 | return $response; |
100 | 100 | } |
@@ -104,23 +104,23 @@ discard block |
||
104 | 104 | * @param \WP_REST_Response $rest_response_obj |
105 | 105 | * @return \WP_REST_Response |
106 | 106 | */ |
107 | - public static function filter_ee_metadata_into_index( \WP_REST_Response $rest_response_obj ) { |
|
107 | + public static function filter_ee_metadata_into_index(\WP_REST_Response $rest_response_obj) { |
|
108 | 108 | $response_data = $rest_response_obj->get_data(); |
109 | 109 | $addons = array(); |
110 | - foreach( \EE_Registry::instance()->addons as $addon){ |
|
110 | + foreach (\EE_Registry::instance()->addons as $addon) { |
|
111 | 111 | $addon_json = array( |
112 | 112 | 'name' => $addon->name(), |
113 | 113 | 'version' => $addon->version() |
114 | 114 | ); |
115 | - $addons[ $addon_json[ 'name' ] ] = $addon_json; |
|
115 | + $addons[$addon_json['name']] = $addon_json; |
|
116 | 116 | } |
117 | - $response_data[ 'ee' ] = array( |
|
117 | + $response_data['ee'] = array( |
|
118 | 118 | 'version' => \EEM_System_Status::instance()->get_ee_version(), |
119 | 119 | 'addons' => $addons, |
120 | 120 | 'maintenance_mode' => \EE_Maintenance_Mode::instance()->real_level(), |
121 | - 'served_core_versions' => array_keys( \EED_Core_Rest_Api::versions_served() ) |
|
121 | + 'served_core_versions' => array_keys(\EED_Core_Rest_Api::versions_served()) |
|
122 | 122 | ); |
123 | - $rest_response_obj->set_data( $response_data ); |
|
123 | + $rest_response_obj->set_data($response_data); |
|
124 | 124 | return $rest_response_obj; |
125 | 125 | } |
126 | 126 | } |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | use EventEspresso\core\libraries\rest_api\controllers\Base as Base; |
3 | 3 | use EventEspresso\core\libraries\rest_api\controllers\model\Read; |
4 | 4 | |
5 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
6 | - exit( 'No direct script access allowed' ); |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | + exit('No direct script access allowed'); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | /** |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | * @param \WP_REST_Request $request |
25 | 25 | * @return \WP_Error|\WP_REST_Response |
26 | 26 | */ |
27 | - public static function handle_request_toggle_checkin( \WP_REST_Request $request ) { |
|
27 | + public static function handle_request_toggle_checkin(\WP_REST_Request $request) { |
|
28 | 28 | $controller = new Checkin(); |
29 | - return $controller->_create_checkin_checkout_object( $request ); |
|
29 | + return $controller->_create_checkin_checkout_object($request); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
@@ -37,47 +37,47 @@ discard block |
||
37 | 37 | * @param \WP_REST_Request $request |
38 | 38 | * @return \WP_Error|\WP_REST_Response |
39 | 39 | */ |
40 | - protected function _create_checkin_checkout_object( \WP_REST_Request $request ) { |
|
41 | - $reg_id = $request->get_param( 'REG_ID' ); |
|
42 | - $dtt_id = $request->get_param( 'DTT_ID' ); |
|
43 | - $force = $request->get_param( 'force' ); |
|
44 | - if( $force == 'true' ) { |
|
40 | + protected function _create_checkin_checkout_object(\WP_REST_Request $request) { |
|
41 | + $reg_id = $request->get_param('REG_ID'); |
|
42 | + $dtt_id = $request->get_param('DTT_ID'); |
|
43 | + $force = $request->get_param('force'); |
|
44 | + if ($force == 'true') { |
|
45 | 45 | $force = true; |
46 | 46 | } else { |
47 | 47 | $force = false; |
48 | 48 | } |
49 | - $reg = \EEM_Registration::instance()->get_one_by_ID( $reg_id ); |
|
50 | - if( ! $reg instanceof \EE_Registration ) { |
|
49 | + $reg = \EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
50 | + if ( ! $reg instanceof \EE_Registration) { |
|
51 | 51 | return $this->send_response( |
52 | 52 | new \WP_Error( |
53 | 53 | 'rest_registration_toggle_checkin_invalid_id', |
54 | 54 | sprintf( |
55 | - __( 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', 'event_espresso' ), |
|
55 | + __('You cannot checkin registration with ID %1$s because it doesn\'t exist.', 'event_espresso'), |
|
56 | 56 | $reg_id |
57 | 57 | ), |
58 | - array( 'status' => 422 ) |
|
58 | + array('status' => 422) |
|
59 | 59 | ) |
60 | 60 | ); |
61 | 61 | } |
62 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id ) ) { |
|
62 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
63 | 63 | return $this->send_response( |
64 | 64 | new \WP_Error( |
65 | 65 | 'rest_user_cannot_toggle_checkin', |
66 | 66 | sprintf( |
67 | - __( 'You are not allowed to checkin registration with ID %1$s.', 'event_espresso' ), |
|
67 | + __('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'), |
|
68 | 68 | $reg_id |
69 | 69 | ), |
70 | - array( 'status' => 403 ) |
|
70 | + array('status' => 403) |
|
71 | 71 | ) |
72 | 72 | ); |
73 | 73 | } |
74 | - $success = $reg->toggle_checkin_status( $dtt_id, ! $force ); |
|
75 | - if( $success === false ) { |
|
74 | + $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
|
75 | + if ($success === false) { |
|
76 | 76 | //rely on EE_Error::add_error messages to have been added to give more data about hwy it failed |
77 | 77 | return $this->send_response( |
78 | 78 | new \WP_Error( |
79 | 79 | 'rest_toggle_checkin_failed', |
80 | - __( 'Registration checkin failed. Please see additional error data.', 'event_espresso' ) |
|
80 | + __('Registration checkin failed. Please see additional error data.', 'event_espresso') |
|
81 | 81 | ) |
82 | 82 | ); |
83 | 83 | } |
@@ -92,28 +92,28 @@ discard block |
||
92 | 92 | ) |
93 | 93 | ) |
94 | 94 | ); |
95 | - if( ! $checkin instanceof \EE_Checkin ) { |
|
95 | + if ( ! $checkin instanceof \EE_Checkin) { |
|
96 | 96 | return $this->send_response( |
97 | 97 | new \WP_Error( |
98 | 98 | 'rest_toggle_checkin_error', |
99 | 99 | sprintf( |
100 | - __( 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', 'event_espresso' ), |
|
100 | + __('Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', 'event_espresso'), |
|
101 | 101 | $reg_id, |
102 | 102 | $dtt_id |
103 | 103 | ) |
104 | 104 | ) |
105 | 105 | ); |
106 | 106 | } |
107 | - $requested_version = $this->get_requested_version( $request->get_route() ); |
|
107 | + $requested_version = $this->get_requested_version($request->get_route()); |
|
108 | 108 | $get_request = new \WP_REST_Request( |
109 | 109 | 'GET', |
110 | - \EED_Core_Rest_Api::ee_api_namespace . $requested_version . '/checkins/' . $checkin->ID() |
|
110 | + \EED_Core_Rest_Api::ee_api_namespace.$requested_version.'/checkins/'.$checkin->ID() |
|
111 | 111 | ); |
112 | 112 | $get_request->set_url_params( |
113 | 113 | array( |
114 | 114 | 'id' => $checkin->ID() |
115 | 115 | ) |
116 | 116 | ); |
117 | - return Read::handle_request_get_one( $get_request ); |
|
117 | + return Read::handle_request_get_one($get_request); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | \ No newline at end of file |
@@ -22,35 +22,35 @@ discard block |
||
22 | 22 | * @param EE_Response $response |
23 | 23 | * @return EE_Response |
24 | 24 | */ |
25 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
25 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
26 | 26 | $this->_request = $request; |
27 | 27 | $this->_response = $response; |
28 | 28 | //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
29 | 29 | //$this->_response->set_notice( 1, 'hey look at this' ); |
30 | 30 | // check required WP version |
31 | - if ( ! $this->_minimum_wp_version_required() ) { |
|
32 | - $this->_request->un_set( 'activate', true ); |
|
33 | - add_action( 'admin_notices', array( $this, 'minimum_wp_version_error' ), 1 ); |
|
31 | + if ( ! $this->_minimum_wp_version_required()) { |
|
32 | + $this->_request->un_set('activate', true); |
|
33 | + add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
34 | 34 | //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
35 | 35 | $this->_response->terminate_request(); |
36 | 36 | } |
37 | 37 | // check required PHP version |
38 | - if ( ! $this->_minimum_php_version_required() ) { |
|
39 | - $this->_request->un_set( 'activate', true ); |
|
40 | - add_action( 'admin_notices', array( $this, 'minimum_php_version_error' ), 1 ); |
|
38 | + if ( ! $this->_minimum_php_version_required()) { |
|
39 | + $this->_request->un_set('activate', true); |
|
40 | + add_action('admin_notices', array($this, 'minimum_php_version_error'), 1); |
|
41 | 41 | //$this->_response->add_output( "\n<br />" . 'minimum_php_version_error' ); |
42 | 42 | $this->_response->terminate_request(); |
43 | 43 | } |
44 | 44 | // check recommended WP version |
45 | - if ( ! $this->_minimum_wp_version_recommended() ) { |
|
45 | + if ( ! $this->_minimum_wp_version_recommended()) { |
|
46 | 46 | $this->_display_minimum_recommended_wp_version_notice(); |
47 | 47 | } |
48 | 48 | // check recommended PHP version |
49 | - if ( ! $this->_minimum_php_version_recommended() ) { |
|
49 | + if ( ! $this->_minimum_php_version_recommended()) { |
|
50 | 50 | $this->_display_minimum_recommended_php_version_notice(); |
51 | 51 | } |
52 | 52 | $this->_test_for_php_version_7(); |
53 | - $this->_response = $this->process_request_stack( $this->_request, $this->_response ); |
|
53 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
54 | 54 | //$this->_response->add_output( "\n\t OUT << " . __CLASS__ ); |
55 | 55 | return $this->_response; |
56 | 56 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * @param string $min_version |
65 | 65 | * @return boolean |
66 | 66 | */ |
67 | - private function _check_wp_version( $min_version = EE_MIN_WP_VER_REQUIRED ) { |
|
67 | + private function _check_wp_version($min_version = EE_MIN_WP_VER_REQUIRED) { |
|
68 | 68 | global $wp_version; |
69 | - return version_compare( $wp_version, $min_version, '>=' ) ? true : false; |
|
69 | + return version_compare($wp_version, $min_version, '>=') ? true : false; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @return boolean |
79 | 79 | */ |
80 | 80 | private function _minimum_wp_version_required() { |
81 | - return $this->_check_wp_version( EE_MIN_WP_VER_REQUIRED ); |
|
81 | + return $this->_check_wp_version(EE_MIN_WP_VER_REQUIRED); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return boolean |
91 | 91 | */ |
92 | 92 | private function _minimum_wp_version_recommended() { |
93 | - return $this->_check_wp_version( EE_MIN_WP_VER_RECOMMENDED ); |
|
93 | + return $this->_check_wp_version(EE_MIN_WP_VER_RECOMMENDED); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | * @param string $min_version |
103 | 103 | * @return boolean |
104 | 104 | */ |
105 | - private function _check_php_version( $min_version = EE_MIN_PHP_VER_RECOMMENDED ) { |
|
106 | - return version_compare( PHP_VERSION, $min_version, '>=' ) ? true : false; |
|
105 | + private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) { |
|
106 | + return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @return boolean |
116 | 116 | */ |
117 | 117 | private function _minimum_php_version_required() { |
118 | - return $this->_check_php_version( EE_MIN_PHP_VER_REQUIRED ); |
|
118 | + return $this->_check_php_version(EE_MIN_PHP_VER_REQUIRED); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @return boolean |
128 | 128 | */ |
129 | 129 | private function _minimum_php_version_recommended() { |
130 | - return $this->_check_php_version( EE_MIN_PHP_VER_RECOMMENDED ); |
|
130 | + return $this->_check_php_version(EE_MIN_PHP_VER_RECOMMENDED); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | <p> |
145 | 145 | <?php |
146 | 146 | printf( |
147 | - __( 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso' ), |
|
147 | + __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso'), |
|
148 | 148 | EE_MIN_WP_VER_REQUIRED, |
149 | 149 | $wp_version, |
150 | 150 | '<br/>', |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | <p> |
170 | 170 | <?php |
171 | 171 | printf( |
172 | - __( 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso' ), |
|
172 | + __('We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso'), |
|
173 | 173 | EE_MIN_PHP_VER_REQUIRED, |
174 | 174 | PHP_VERSION, |
175 | 175 | '<br/>', |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | private function _display_minimum_recommended_wp_version_notice() { |
193 | 193 | global $wp_version; |
194 | 194 | EE_Error::add_persistent_admin_notice( |
195 | - 'wp_version_' . str_replace( '.', '-', EE_MIN_WP_VER_RECOMMENDED ) . '_recommended', |
|
195 | + 'wp_version_'.str_replace('.', '-', EE_MIN_WP_VER_RECOMMENDED).'_recommended', |
|
196 | 196 | sprintf( |
197 | - __( 'Event Espresso recommends WordPress version %1$s or greater in order for everything to operate properly. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso' ), |
|
197 | + __('Event Espresso recommends WordPress version %1$s or greater in order for everything to operate properly. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso'), |
|
198 | 198 | EE_MIN_WP_VER_RECOMMENDED, |
199 | 199 | $wp_version, |
200 | 200 | '<br/>', |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | */ |
214 | 214 | private function _display_minimum_recommended_php_version_notice() { |
215 | 215 | EE_Error::add_persistent_admin_notice( |
216 | - 'php_version_' . str_replace( '.', '-', EE_MIN_PHP_VER_RECOMMENDED ) . '_recommended', |
|
216 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
217 | 217 | sprintf( |
218 | - __( 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso' ), |
|
218 | + __('Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso'), |
|
219 | 219 | EE_MIN_PHP_VER_RECOMMENDED, |
220 | 220 | PHP_VERSION, |
221 | 221 | '<br/>', |
@@ -232,10 +232,10 @@ discard block |
||
232 | 232 | * @access private |
233 | 233 | */ |
234 | 234 | private function _test_for_php_version_7() { |
235 | - if ( $this->_check_php_version( '7' ) ) { |
|
236 | - define( 'EE_PHP_7', true ); |
|
235 | + if ($this->_check_php_version('7')) { |
|
236 | + define('EE_PHP_7', true); |
|
237 | 237 | } else { |
238 | - define( 'EE_PHP_7', false ); |
|
238 | + define('EE_PHP_7', false); |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @return EED_Core_Rest_Api |
28 | 28 | */ |
29 | 29 | public static function instance() { |
30 | - return parent::get_instance( __CLASS__ ); |
|
30 | + return parent::get_instance(__CLASS__); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | |
58 | 58 | |
59 | 59 | public static function set_hooks_both() { |
60 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
61 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
62 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
63 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
60 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
61 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
62 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
63 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | protected static function _set_hooks_for_changes() { |
76 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
77 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
76 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
77 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
78 | 78 | //ignore the base parent class |
79 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
79 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
80 | 80 | continue; |
81 | 81 | } |
82 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
83 | - if ( class_exists( $full_classname )) { |
|
82 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
83 | + if (class_exists($full_classname)) { |
|
84 | 84 | $instance_of_class = new $full_classname; |
85 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
85 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
86 | 86 | $instance_of_class->set_hooks(); |
87 | 87 | } |
88 | 88 | } |
@@ -95,16 +95,16 @@ discard block |
||
95 | 95 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
96 | 96 | */ |
97 | 97 | public static function register_routes() { |
98 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
99 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
100 | - foreach( $routes as $route ) { |
|
98 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
99 | + foreach ($relative_urls as $endpoint => $routes) { |
|
100 | + foreach ($routes as $route) { |
|
101 | 101 | register_rest_route( |
102 | 102 | $namespace, |
103 | 103 | $endpoint, |
104 | 104 | array( |
105 | - 'callback' => $route[ 'callback' ], |
|
106 | - 'methods' => $route[ 'methods' ], |
|
107 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
105 | + 'callback' => $route['callback'], |
|
106 | + 'methods' => $route['methods'], |
|
107 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
108 | 108 | ) |
109 | 109 | ); |
110 | 110 | } |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | * } |
122 | 122 | */ |
123 | 123 | public static function get_ee_route_data() { |
124 | - $ee_routes = get_option( self::saved_routes_option_names, null ); |
|
125 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
124 | + $ee_routes = get_option(self::saved_routes_option_names, null); |
|
125 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
126 | 126 | self::save_ee_routes(); |
127 | - $ee_routes = get_option( self::saved_routes_option_names, array() ); |
|
127 | + $ee_routes = get_option(self::saved_routes_option_names, array()); |
|
128 | 128 | } |
129 | 129 | return $ee_routes; |
130 | 130 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @return void |
136 | 136 | */ |
137 | 137 | public static function save_ee_routes() { |
138 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
138 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
139 | 139 | $instance = self::instance(); |
140 | 140 | $routes = apply_filters( |
141 | 141 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $instance->_register_rpc_routes() |
147 | 147 | ) |
148 | 148 | ); |
149 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
149 | + update_option(self::saved_routes_option_names, $routes, true); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @return array @see get_ee_route_data |
156 | 156 | */ |
157 | 157 | protected function _register_model_routes() { |
158 | - EE_Registry::instance()->load_helper( 'Inflector' ); |
|
158 | + EE_Registry::instance()->load_helper('Inflector'); |
|
159 | 159 | $models_to_register = apply_filters( |
160 | 160 | 'FHEE__EED_Core_REST_API___register_model_routes', |
161 | 161 | EE_Registry::instance()->non_abstract_db_models |
@@ -164,23 +164,23 @@ discard block |
||
164 | 164 | unset($models_to_register['Extra_Meta']); |
165 | 165 | unset($models_to_register['Extra_Join']); |
166 | 166 | $model_routes = array( ); |
167 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
167 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
168 | 168 | |
169 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
169 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
170 | 170 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
171 | - $ee_namespace = self::ee_api_namespace . $version; |
|
172 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
173 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
174 | - $model_routes[ $ee_namespace ][ $plural_model_route ] = array( |
|
171 | + $ee_namespace = self::ee_api_namespace.$version; |
|
172 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
173 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
174 | + $model_routes[$ee_namespace][$plural_model_route] = array( |
|
175 | 175 | array( |
176 | 176 | 'callback' => array( |
177 | 177 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
178 | 178 | 'handle_request_get_all' ), |
179 | 179 | 'methods' => WP_REST_Server::READABLE, |
180 | 180 | 'hidden_endpoint' => $hidden_endpoint, |
181 | - 'args' => $this->_get_read_query_params( $model_name ), |
|
181 | + 'args' => $this->_get_read_query_params($model_name), |
|
182 | 182 | '_links' => array( |
183 | - 'self' => rest_url( $ee_namespace . $singular_model_route ), |
|
183 | + 'self' => rest_url($ee_namespace.$singular_model_route), |
|
184 | 184 | ) |
185 | 185 | ), |
186 | 186 | // array( |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | // 'hidden_endpoint' => $hidden_endpoint |
192 | 192 | // ) |
193 | 193 | ); |
194 | - $model_routes[ $ee_namespace ][ $singular_model_route ] = array( |
|
194 | + $model_routes[$ee_namespace][$singular_model_route] = array( |
|
195 | 195 | array( |
196 | 196 | 'callback' => array( |
197 | 197 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | 'include' => array( |
203 | 203 | 'required' => false, |
204 | 204 | 'default' => '*', |
205 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
205 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
206 | 206 | ), |
207 | 207 | ) |
208 | 208 | ), |
@@ -215,20 +215,20 @@ discard block |
||
215 | 215 | // ), |
216 | 216 | ); |
217 | 217 | //@todo: also handle DELETE for a single item |
218 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
219 | - foreach ( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
218 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
219 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
220 | 220 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
221 | 221 | $relation_name, |
222 | 222 | $relation_obj |
223 | 223 | ); |
224 | - $model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
224 | + $model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
225 | 225 | array( |
226 | 226 | 'callback' => array( |
227 | 227 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
228 | 228 | 'handle_request_get_related' ), |
229 | 229 | 'methods' => WP_REST_Server::READABLE, |
230 | 230 | 'hidden_endpoint' => $hidden_endpoint, |
231 | - 'args' => $this->_get_read_query_params( $relation_name ), |
|
231 | + 'args' => $this->_get_read_query_params($relation_name), |
|
232 | 232 | ), |
233 | 233 | // array( |
234 | 234 | // 'callback' => array( |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | */ |
253 | 253 | protected function _register_rpc_routes() { |
254 | 254 | $routes = array(); |
255 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
256 | - $ee_namespace = self::ee_api_namespace . $version; |
|
255 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
256 | + $ee_namespace = self::ee_api_namespace.$version; |
|
257 | 257 | $this_versions_routes = array(); |
258 | 258 | //checkin endpoint |
259 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
259 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
260 | 260 | array( |
261 | 261 | 'callback' => array( |
262 | 262 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | 'force' => array( |
268 | 268 | 'required' => false, |
269 | 269 | 'default' => false, |
270 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
270 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
271 | 271 | ) |
272 | 272 | ) |
273 | 273 | ) |
274 | 274 | ); |
275 | - $routes[ $ee_namespace ] = apply_filters( |
|
275 | + $routes[$ee_namespace] = apply_filters( |
|
276 | 276 | 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
277 | 277 | $this_versions_routes, |
278 | 278 | $version, |
@@ -287,47 +287,47 @@ discard block |
||
287 | 287 | * @param string $model_name eg 'Event' or 'Venue' |
288 | 288 | * @return array describing the args acceptable when querying this model |
289 | 289 | */ |
290 | - protected function _get_read_query_params( $model_name ) { |
|
291 | - $model = EE_Registry::instance()->load_model( $model_name ); |
|
290 | + protected function _get_read_query_params($model_name) { |
|
291 | + $model = EE_Registry::instance()->load_model($model_name); |
|
292 | 292 | $default_orderby = array(); |
293 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
294 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
293 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
294 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
295 | 295 | } |
296 | 296 | return array( |
297 | 297 | 'where' => array( |
298 | 298 | 'required' => false, |
299 | 299 | 'default' => array(), |
300 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso' ), |
|
300 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso'), |
|
301 | 301 | ), |
302 | 302 | 'limit' => array( |
303 | 303 | 'required' => false, |
304 | 304 | 'default' => 50, |
305 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso' ) |
|
305 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso') |
|
306 | 306 | ), |
307 | 307 | 'order_by' => array( |
308 | 308 | 'required' => false, |
309 | 309 | 'default' => $default_orderby, |
310 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso' ) |
|
310 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso') |
|
311 | 311 | ), |
312 | 312 | 'group_by' => array( |
313 | 313 | 'required' => false, |
314 | 314 | 'default' => null, |
315 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso' ) |
|
315 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso') |
|
316 | 316 | ), |
317 | 317 | 'having' => array( |
318 | 318 | 'required' => false, |
319 | 319 | 'default' => null, |
320 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso' ) |
|
320 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso') |
|
321 | 321 | ), |
322 | 322 | 'caps' => array( |
323 | 323 | 'required' => false, |
324 | 324 | 'default' => EEM_Base::caps_read, |
325 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso' ) |
|
325 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso') |
|
326 | 326 | ), |
327 | 327 | 'include' => array( |
328 | 328 | 'required' => false, |
329 | 329 | 'default' => '*', |
330 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
330 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
331 | 331 | ), |
332 | 332 | ); |
333 | 333 | } |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | */ |
339 | 339 | protected function _register_config_routes() { |
340 | 340 | $config_routes = array(); |
341 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
342 | - $config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array( |
|
341 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
342 | + $config_routes[self::ee_api_namespace.$version]['config'] = array( |
|
343 | 343 | array( |
344 | 344 | 'callback' => array( |
345 | 345 | 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | */ |
359 | 359 | protected function _register_meta_routes() { |
360 | 360 | $meta_routes = array(); |
361 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
362 | - $meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array( |
|
361 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
362 | + $meta_routes[self::ee_api_namespace.$version]['/resources'] = array( |
|
363 | 363 | array( |
364 | 364 | 'callback' => array( |
365 | 365 | 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
@@ -380,13 +380,13 @@ discard block |
||
380 | 380 | * @param array $route_data |
381 | 381 | * @return array |
382 | 382 | */ |
383 | - public static function hide_old_endpoints( $route_data ) { |
|
384 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
385 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
386 | - foreach( $routes as $route ) { |
|
387 | - if( $route[ 'hidden_endpoint' ] ) { |
|
388 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
389 | - unset( $route_data[ $full_route ] ); |
|
383 | + public static function hide_old_endpoints($route_data) { |
|
384 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
385 | + foreach ($relative_urls as $endpoint => $routes) { |
|
386 | + foreach ($routes as $route) { |
|
387 | + if ($route['hidden_endpoint']) { |
|
388 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
389 | + unset($route_data[$full_route]); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | */ |
424 | 424 | public static function latest_rest_api_version() { |
425 | 425 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
426 | - return end( array_keys( $versions_served ) ); |
|
426 | + return end(array_keys($versions_served)); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -437,32 +437,32 @@ discard block |
||
437 | 437 | public static function versions_served() { |
438 | 438 | $versions_served = array(); |
439 | 439 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
440 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
441 | - reset( $possibly_served_versions ); |
|
442 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
443 | - $latest_version = end( $versions_served_historically ); |
|
444 | - reset( $versions_served_historically ); |
|
440 | + $lowest_compatible_version = end($possibly_served_versions); |
|
441 | + reset($possibly_served_versions); |
|
442 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
443 | + $latest_version = end($versions_served_historically); |
|
444 | + reset($versions_served_historically); |
|
445 | 445 | //for each version of core we have ever served: |
446 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
446 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
447 | 447 | //if it's not above the current core version, and it's compatible with the current version of core |
448 | - if( $key_versioned_endpoint == $latest_version ) { |
|
448 | + if ($key_versioned_endpoint == $latest_version) { |
|
449 | 449 | //don't hide the latest version in the index |
450 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
451 | - } else if( |
|
450 | + $versions_served[$key_versioned_endpoint] = false; |
|
451 | + } else if ( |
|
452 | 452 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
453 | 453 | && $key_versioned_endpoint >= $lowest_compatible_version |
454 | 454 | ) { |
455 | 455 | //include, but hide, previous versions which are still supported |
456 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
457 | - } elseif( |
|
456 | + $versions_served[$key_versioned_endpoint] = true; |
|
457 | + } elseif ( |
|
458 | 458 | apply_filters( |
459 | 459 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
460 | 460 | false, |
461 | 461 | $possibly_served_versions |
462 | 462 | ) |
463 | - ){ |
|
463 | + ) { |
|
464 | 464 | //if a version is no longer supported, don't include it in index or list of versions served |
465 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
465 | + $versions_served[$key_versioned_endpoint] = true; |
|
466 | 466 | } |
467 | 467 | } |
468 | 468 | return $versions_served; |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | * @return string |
476 | 476 | */ |
477 | 477 | public static function core_version() { |
478 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
478 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | * @param WP $WP |
488 | 488 | * @return void |
489 | 489 | */ |
490 | - public function run( $WP ) { |
|
490 | + public function run($WP) { |
|
491 | 491 | |
492 | 492 | } |
493 | 493 |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | $this->reg_page_base_url = EE_Registry::instance()->CFG->core->reg_page_url(); |
243 | 243 | $this->thank_you_page_url = EE_Registry::instance()->CFG->core->thank_you_page_url(); |
244 | 244 | $this->cancel_page_url = EE_Registry::instance()->CFG->core->cancel_page_url(); |
245 | - $this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', TRUE ); |
|
245 | + $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', TRUE); |
|
246 | 246 | $this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->ajax; |
247 | - $this->reg_cache_where_params = array( 'order_by' => array( 'REG_count' => 'ASC' )); |
|
247 | + $this->reg_cache_where_params = array('order_by' => array('REG_count' => 'ASC')); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | * @return array |
255 | 255 | */ |
256 | 256 | public function any_reg_status_updated() { |
257 | - foreach ( $this->reg_status_updated as $reg_status ) { |
|
258 | - if ( $reg_status ) { |
|
257 | + foreach ($this->reg_status_updated as $reg_status) { |
|
258 | + if ($reg_status) { |
|
259 | 259 | return true; |
260 | 260 | } |
261 | 261 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | * @param $REG_ID |
269 | 269 | * @return array |
270 | 270 | */ |
271 | - public function reg_status_updated( $REG_ID ) { |
|
272 | - return isset( $this->reg_status_updated[ $REG_ID ] ) ? $this->reg_status_updated[ $REG_ID ] : false; |
|
271 | + public function reg_status_updated($REG_ID) { |
|
272 | + return isset($this->reg_status_updated[$REG_ID]) ? $this->reg_status_updated[$REG_ID] : false; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | * @param $REG_ID |
279 | 279 | * @param $reg_status |
280 | 280 | */ |
281 | - public function set_reg_status_updated( $REG_ID, $reg_status ) { |
|
282 | - $this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN ); |
|
281 | + public function set_reg_status_updated($REG_ID, $reg_status) { |
|
282 | + $this->reg_status_updated[$REG_ID] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * can ONLY be set by the Finalize_Registration reg step |
301 | 301 | */ |
302 | 302 | public function set_exit_spco() { |
303 | - if ( $this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
303 | + if ($this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
304 | 304 | $this->exit_spco = true; |
305 | 305 | } |
306 | 306 | } |
@@ -317,12 +317,12 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function reset_for_current_request() { |
319 | 319 | $this->process_form_submission = FALSE; |
320 | - $this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', true ); |
|
320 | + $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true); |
|
321 | 321 | $this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->front_ajax; |
322 | 322 | $this->continue_reg = true; |
323 | 323 | $this->redirect = false; |
324 | 324 | // don't reset the cached redirect form if we're about to be asked to display it !!! |
325 | - if ( EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ) !== 'redirect_form' ) { |
|
325 | + if (EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step') !== 'redirect_form') { |
|
326 | 326 | $this->redirect_form = ''; |
327 | 327 | } |
328 | 328 | $this->redirect_url = ''; |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_SPCO_Reg_Step $reg_step_obj |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - public function add_reg_step( EE_SPCO_Reg_Step $reg_step_obj ) { |
|
343 | - $this->reg_steps[ $reg_step_obj->slug() ] = $reg_step_obj; |
|
342 | + public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj) { |
|
343 | + $this->reg_steps[$reg_step_obj->slug()] = $reg_step_obj; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -356,22 +356,22 @@ discard block |
||
356 | 356 | * @param string $reg_step_slug |
357 | 357 | * @return void |
358 | 358 | */ |
359 | - public function skip_reg_step( $reg_step_slug = '' ) { |
|
360 | - $step_to_skip = $this->find_reg_step( $reg_step_slug ); |
|
361 | - if ( $step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step() ) { |
|
362 | - $step_to_skip->set_is_current_step( false ); |
|
359 | + public function skip_reg_step($reg_step_slug = '') { |
|
360 | + $step_to_skip = $this->find_reg_step($reg_step_slug); |
|
361 | + if ($step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step()) { |
|
362 | + $step_to_skip->set_is_current_step(false); |
|
363 | 363 | $step_to_skip->set_completed(); |
364 | 364 | // advance to the next step |
365 | - $this->set_current_step( $this->next_step->slug() ); |
|
365 | + $this->set_current_step($this->next_step->slug()); |
|
366 | 366 | // also reset the step param in the request in case any other code references that directly |
367 | - EE_Registry::instance()->REQ->set( 'step', $this->current_step->slug() ); |
|
367 | + EE_Registry::instance()->REQ->set('step', $this->current_step->slug()); |
|
368 | 368 | // since we are skipping a step and setting the current step to be what was previously the next step, |
369 | 369 | // we need to check that the next step is now correct, and not still set to the current step. |
370 | - if ( $this->current_step->slug() == $this->next_step->slug() ) { |
|
370 | + if ($this->current_step->slug() == $this->next_step->slug()) { |
|
371 | 371 | // correctly setup the next step |
372 | 372 | $this->set_next_step(); |
373 | 373 | } |
374 | - $this->set_reg_step_initiated( $this->current_step ); |
|
374 | + $this->set_reg_step_initiated($this->current_step); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | * @param bool $reset whether to reset reg steps after removal |
386 | 386 | * @throws EE_Error |
387 | 387 | */ |
388 | - public function remove_reg_step( $reg_step_slug = '', $reset = true ) { |
|
389 | - unset( $this->reg_steps[ $reg_step_slug ] ); |
|
390 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
388 | + public function remove_reg_step($reg_step_slug = '', $reset = true) { |
|
389 | + unset($this->reg_steps[$reg_step_slug]); |
|
390 | + if ($this->transaction instanceof EE_Transaction) { |
|
391 | 391 | /** @type EE_Transaction_Processor $transaction_processor */ |
392 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
392 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
393 | 393 | // now remove reg step from TXN and save |
394 | - $transaction_processor->remove_reg_step( $this->transaction, $reg_step_slug ); |
|
394 | + $transaction_processor->remove_reg_step($this->transaction, $reg_step_slug); |
|
395 | 395 | $this->transaction->save(); |
396 | 396 | } |
397 | - if ( $reset ) { |
|
397 | + if ($reset) { |
|
398 | 398 | $this->reset_reg_steps(); |
399 | 399 | } |
400 | 400 | } |
@@ -409,9 +409,9 @@ discard block |
||
409 | 409 | * @param int $order |
410 | 410 | * @return void |
411 | 411 | */ |
412 | - public function set_reg_step_order( $reg_step_slug = '', $order = 100 ) { |
|
413 | - if ( isset( $this->reg_steps[ $reg_step_slug ] )) { |
|
414 | - $this->reg_steps[ $reg_step_slug ]->set_order( $order ); |
|
412 | + public function set_reg_step_order($reg_step_slug = '', $order = 100) { |
|
413 | + if (isset($this->reg_steps[$reg_step_slug])) { |
|
414 | + $this->reg_steps[$reg_step_slug]->set_order($order); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
@@ -424,25 +424,25 @@ discard block |
||
424 | 424 | * @param string $current_step |
425 | 425 | * @return void |
426 | 426 | */ |
427 | - public function set_current_step( $current_step ) { |
|
427 | + public function set_current_step($current_step) { |
|
428 | 428 | // grab what step we're on |
429 | - $this->current_step = isset( $this->reg_steps[ $current_step ] ) ? $this->reg_steps[ $current_step ] : reset( $this->reg_steps ); |
|
429 | + $this->current_step = isset($this->reg_steps[$current_step]) ? $this->reg_steps[$current_step] : reset($this->reg_steps); |
|
430 | 430 | // verify instance |
431 | - if ( $this->current_step instanceof EE_SPCO_Reg_Step ) { |
|
431 | + if ($this->current_step instanceof EE_SPCO_Reg_Step) { |
|
432 | 432 | // we don't want to repeat completed steps if this is the first time through SPCO |
433 | - if ( $this->continue_reg && $this->current_step->completed() && ! $this->revisit ) { |
|
433 | + if ($this->continue_reg && $this->current_step->completed() && ! $this->revisit) { |
|
434 | 434 | // so advance to the next step |
435 | 435 | $this->set_next_step(); |
436 | - if ( $this->next_step instanceof EE_SPCO_Reg_Step ) { |
|
436 | + if ($this->next_step instanceof EE_SPCO_Reg_Step) { |
|
437 | 437 | // and attempt to set it as the current step |
438 | - $this->set_current_step( $this->next_step->slug() ); |
|
438 | + $this->set_current_step($this->next_step->slug()); |
|
439 | 439 | } |
440 | 440 | return; |
441 | 441 | } |
442 | - $this->current_step->set_is_current_step( TRUE ); |
|
442 | + $this->current_step->set_is_current_step(TRUE); |
|
443 | 443 | } else { |
444 | 444 | EE_Error::add_error( |
445 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
445 | + __('The current step could not be set.', 'event_espresso'), |
|
446 | 446 | __FILE__, __FUNCTION__, __LINE__ |
447 | 447 | ); |
448 | 448 | } |
@@ -459,20 +459,20 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function set_next_step() { |
461 | 461 | // set pointer to start of array |
462 | - reset( $this->reg_steps ); |
|
462 | + reset($this->reg_steps); |
|
463 | 463 | // if there is more than one step |
464 | - if ( count( $this->reg_steps ) > 1 ) { |
|
464 | + if (count($this->reg_steps) > 1) { |
|
465 | 465 | // advance to the current step and set pointer |
466 | - while ( key( $this->reg_steps ) != $this->current_step->slug() && key( $this->reg_steps ) != '' ) { |
|
467 | - next( $this->reg_steps ); |
|
466 | + while (key($this->reg_steps) != $this->current_step->slug() && key($this->reg_steps) != '') { |
|
467 | + next($this->reg_steps); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | // advance one more spot ( if it exists ) |
471 | - $this->next_step = next( $this->reg_steps ); |
|
471 | + $this->next_step = next($this->reg_steps); |
|
472 | 472 | // verify instance |
473 | - $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL; |
|
473 | + $this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL; |
|
474 | 474 | // then back to current step to reset |
475 | - prev( $this->reg_steps ); |
|
475 | + prev($this->reg_steps); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | |
@@ -486,8 +486,8 @@ discard block |
||
486 | 486 | * @return EE_SPCO_Reg_Step | null |
487 | 487 | */ |
488 | 488 | public function get_next_reg_step() { |
489 | - $next = next( $this->reg_steps ); |
|
490 | - prev( $this->reg_steps ); |
|
489 | + $next = next($this->reg_steps); |
|
490 | + prev($this->reg_steps); |
|
491 | 491 | return $next instanceof EE_SPCO_Reg_Step ? $next : null; |
492 | 492 | } |
493 | 493 | |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | * @return EE_SPCO_Reg_Step | null |
503 | 503 | */ |
504 | 504 | public function get_prev_reg_step() { |
505 | - $prev = prev( $this->reg_steps ); |
|
506 | - next( $this->reg_steps ); |
|
505 | + $prev = prev($this->reg_steps); |
|
506 | + next($this->reg_steps); |
|
507 | 507 | return $prev instanceof EE_SPCO_Reg_Step ? $prev : null; |
508 | 508 | } |
509 | 509 | |
@@ -516,8 +516,8 @@ discard block |
||
516 | 516 | * @return void |
517 | 517 | */ |
518 | 518 | public function sort_reg_steps() { |
519 | - $reg_step_sorting_callback = apply_filters( 'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback' ); |
|
520 | - uasort( $this->reg_steps, array( $this, $reg_step_sorting_callback )); |
|
519 | + $reg_step_sorting_callback = apply_filters('FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback'); |
|
520 | + uasort($this->reg_steps, array($this, $reg_step_sorting_callback)); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -530,19 +530,19 @@ discard block |
||
530 | 530 | * @param string $reg_step_slug |
531 | 531 | * @return EE_SPCO_Reg_Step|null |
532 | 532 | */ |
533 | - public function find_reg_step( $reg_step_slug = '' ) { |
|
534 | - if ( ! empty( $reg_step_slug ) ) { |
|
533 | + public function find_reg_step($reg_step_slug = '') { |
|
534 | + if ( ! empty($reg_step_slug)) { |
|
535 | 535 | // copy reg step array |
536 | 536 | $reg_steps = $this->reg_steps; |
537 | 537 | // set pointer to start of array |
538 | - reset( $reg_steps ); |
|
538 | + reset($reg_steps); |
|
539 | 539 | // if there is more than one step |
540 | - if ( count( $reg_steps ) > 1 ) { |
|
540 | + if (count($reg_steps) > 1) { |
|
541 | 541 | // advance to the current step and set pointer |
542 | - while ( key( $reg_steps ) != $reg_step_slug && key( $reg_steps ) != '' ) { |
|
543 | - next( $reg_steps ); |
|
542 | + while (key($reg_steps) != $reg_step_slug && key($reg_steps) != '') { |
|
543 | + next($reg_steps); |
|
544 | 544 | } |
545 | - return current( $reg_steps ); |
|
545 | + return current($reg_steps); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | return null; |
@@ -558,17 +558,17 @@ discard block |
||
558 | 558 | * @param EE_SPCO_Reg_Step $reg_step_B |
559 | 559 | * @return array() |
560 | 560 | */ |
561 | - public function reg_step_sorting_callback( EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B ) { |
|
561 | + public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B) { |
|
562 | 562 | // send finalize_registration step to the end of the array |
563 | - if ( $reg_step_A->slug() == 'finalize_registration' ) { |
|
563 | + if ($reg_step_A->slug() == 'finalize_registration') { |
|
564 | 564 | return 1; |
565 | - } else if ( $reg_step_B->slug() == 'finalize_registration' ) { |
|
565 | + } else if ($reg_step_B->slug() == 'finalize_registration') { |
|
566 | 566 | return -1; |
567 | 567 | } |
568 | - if ( $reg_step_A->order() == $reg_step_B->order() ) { |
|
568 | + if ($reg_step_A->order() == $reg_step_B->order()) { |
|
569 | 569 | return 0; |
570 | 570 | } |
571 | - return ( $reg_step_A->order() > $reg_step_B->order() ) ? 1 : -1; |
|
571 | + return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1; |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | * @access public |
580 | 580 | * @param EE_SPCO_Reg_Step $reg_step |
581 | 581 | */ |
582 | - public function set_reg_step_initiated( EE_SPCO_Reg_Step $reg_step ) { |
|
582 | + public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step) { |
|
583 | 583 | // call set_reg_step_initiated ??? |
584 | 584 | if ( |
585 | 585 | // first time visiting SPCO ? |
@@ -592,13 +592,13 @@ discard block |
||
592 | 592 | ) |
593 | 593 | ) { |
594 | 594 | /** @type EE_Transaction_Processor $transaction_processor */ |
595 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
595 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
596 | 596 | // set the start time for this reg step |
597 | - if ( ! $transaction_processor->set_reg_step_initiated( $this->transaction, $reg_step->slug() ) ) { |
|
598 | - if ( WP_DEBUG ) { |
|
597 | + if ( ! $transaction_processor->set_reg_step_initiated($this->transaction, $reg_step->slug())) { |
|
598 | + if (WP_DEBUG) { |
|
599 | 599 | EE_Error::add_error( |
600 | 600 | sprintf( |
601 | - __( 'The "%1$s" registration step was not initialized properly.', 'event_espresso' ), |
|
601 | + __('The "%1$s" registration step was not initialized properly.', 'event_espresso'), |
|
602 | 602 | $reg_step->name() |
603 | 603 | ), |
604 | 604 | __FILE__, __FUNCTION__, __LINE__ |
@@ -617,10 +617,10 @@ discard block |
||
617 | 617 | * @return void |
618 | 618 | */ |
619 | 619 | public function set_reg_step_JSON_info() { |
620 | - EE_Registry::$i18n_js_strings[ 'reg_steps' ] = array(); |
|
620 | + EE_Registry::$i18n_js_strings['reg_steps'] = array(); |
|
621 | 621 | // pass basic reg step data to JS |
622 | - foreach ( $this->reg_steps as $reg_step ) { |
|
623 | - EE_Registry::$i18n_js_strings[ 'reg_steps' ][] = $reg_step->slug(); |
|
622 | + foreach ($this->reg_steps as $reg_step) { |
|
623 | + EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug(); |
|
624 | 624 | } |
625 | 625 | // reset reg step html |
626 | 626 | // $this->json_response->set_reg_step_html( '' ); |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | */ |
637 | 637 | public function reset_reg_steps() { |
638 | 638 | $this->sort_reg_steps(); |
639 | - $this->set_current_step( EE_Registry::instance()->REQ->get( 'step' )); |
|
639 | + $this->set_current_step(EE_Registry::instance()->REQ->get('step')); |
|
640 | 640 | $this->set_next_step(); |
641 | 641 | // the text that appears on the reg step form submit button |
642 | 642 | $this->current_step->set_submit_button_text(); |
@@ -653,9 +653,9 @@ discard block |
||
653 | 653 | */ |
654 | 654 | public function get_registration_time_limit() { |
655 | 655 | |
656 | - $registration_time_limit = (float)( EE_Registry::instance() ->SSN->expiration() - time() ); |
|
656 | + $registration_time_limit = (float) (EE_Registry::instance() ->SSN->expiration() - time()); |
|
657 | 657 | $time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s'; |
658 | - $registration_time_limit = gmdate( $time_limit_format, $registration_time_limit ); |
|
658 | + $registration_time_limit = gmdate($time_limit_format, $registration_time_limit); |
|
659 | 659 | return apply_filters( |
660 | 660 | 'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit', |
661 | 661 | $registration_time_limit |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | // overpaid TXN |
676 | 676 | // free TXN ( total = 0.00 ) |
677 | 677 | // then payment required is TRUE |
678 | - return ! ( $this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free() ) ? TRUE : FALSE; |
|
678 | + return ! ($this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free()) ? TRUE : FALSE; |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | |
@@ -688,8 +688,8 @@ discard block |
||
688 | 688 | */ |
689 | 689 | public function initialize_txn_reg_steps_array() { |
690 | 690 | $txn_reg_steps_array = array(); |
691 | - foreach ( $this->reg_steps as $reg_step ) { |
|
692 | - $txn_reg_steps_array[ $reg_step->slug() ] = FALSE; |
|
691 | + foreach ($this->reg_steps as $reg_step) { |
|
692 | + $txn_reg_steps_array[$reg_step->slug()] = FALSE; |
|
693 | 693 | } |
694 | 694 | return $txn_reg_steps_array; |
695 | 695 | } |
@@ -705,13 +705,13 @@ discard block |
||
705 | 705 | public function update_txn_reg_steps_array() { |
706 | 706 | $updated = FALSE; |
707 | 707 | /** @type EE_Transaction_Processor $transaction_processor */ |
708 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
709 | - foreach ( $this->reg_steps as $reg_step ) { |
|
710 | - if ( $reg_step->completed() ) { |
|
711 | - $updated = $transaction_processor->set_reg_step_completed( $this->transaction, $reg_step->slug() ) ? TRUE : $updated; |
|
708 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
709 | + foreach ($this->reg_steps as $reg_step) { |
|
710 | + if ($reg_step->completed()) { |
|
711 | + $updated = $transaction_processor->set_reg_step_completed($this->transaction, $reg_step->slug()) ? TRUE : $updated; |
|
712 | 712 | } |
713 | 713 | } |
714 | - if ( $updated ) { |
|
714 | + if ($updated) { |
|
715 | 715 | $this->transaction->save(); |
716 | 716 | } |
717 | 717 | return $updated; |
@@ -726,14 +726,14 @@ discard block |
||
726 | 726 | * @return void |
727 | 727 | */ |
728 | 728 | public function stash_transaction_and_checkout() { |
729 | - if ( ! $this->revisit ) { |
|
729 | + if ( ! $this->revisit) { |
|
730 | 730 | $this->update_txn_reg_steps_array(); |
731 | 731 | } |
732 | 732 | $this->track_transaction_and_registration_status_updates(); |
733 | 733 | // save all data to the db, but suppress errors |
734 | 734 | //$this->save_all_data( FALSE ); |
735 | 735 | // cache the checkout in the session |
736 | - EE_Registry::instance()->SSN->set_checkout( $this ); |
|
736 | + EE_Registry::instance()->SSN->set_checkout($this); |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | |
@@ -749,21 +749,21 @@ discard block |
||
749 | 749 | */ |
750 | 750 | public function track_transaction_and_registration_status_updates() { |
751 | 751 | // verify the transaction |
752 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
752 | + if ($this->transaction instanceof EE_Transaction) { |
|
753 | 753 | /** @type EE_Transaction_Payments $transaction_payments */ |
754 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
754 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
755 | 755 | /** @type EE_Transaction_Processor $transaction_processor */ |
756 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
756 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
757 | 757 | // has there been a TXN status change during this checkout? |
758 | - if ( $transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated() ) { |
|
758 | + if ($transaction_payments->txn_status_updated() || $transaction_processor->txn_status_updated()) { |
|
759 | 759 | $this->txn_status_updated = true; |
760 | 760 | } |
761 | 761 | /** @type EE_Registration_Processor $registration_processor */ |
762 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
762 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
763 | 763 | // grab the saved registrations from the transaction |
764 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) { |
|
765 | - if ( $registration_processor->reg_status_updated( $registration->ID() ) ) { |
|
766 | - $this->set_reg_status_updated( $registration->ID(), true ); |
|
764 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) { |
|
765 | + if ($registration_processor->reg_status_updated($registration->ID())) { |
|
766 | + $this->set_reg_status_updated($registration->ID(), true); |
|
767 | 767 | } |
768 | 768 | } |
769 | 769 | } |
@@ -785,8 +785,8 @@ discard block |
||
785 | 785 | * @param EE_Registration $registration |
786 | 786 | * @return bool |
787 | 787 | */ |
788 | - public function visit_allows_processing_of_this_registration( EE_Registration $registration ) { |
|
789 | - return ! $this->revisit || $this->primary_revisit || ( $this->revisit && $this->reg_url_link == $registration->reg_url_link() ) ? TRUE : FALSE; |
|
788 | + public function visit_allows_processing_of_this_registration(EE_Registration $registration) { |
|
789 | + return ! $this->revisit || $this->primary_revisit || ($this->revisit && $this->reg_url_link == $registration->reg_url_link()) ? TRUE : FALSE; |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | |
@@ -811,18 +811,18 @@ discard block |
||
811 | 811 | * @param bool $show_errors |
812 | 812 | * @return bool |
813 | 813 | */ |
814 | - public function save_all_data( $show_errors = TRUE ) { |
|
814 | + public function save_all_data($show_errors = TRUE) { |
|
815 | 815 | // verify the transaction |
816 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
816 | + if ($this->transaction instanceof EE_Transaction) { |
|
817 | 817 | // save to ensure that TXN has ID |
818 | 818 | $this->transaction->save(); |
819 | 819 | // grab the saved registrations from the transaction |
820 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) { |
|
821 | - $this->_save_registration( $registration, $show_errors ); |
|
820 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) { |
|
821 | + $this->_save_registration($registration, $show_errors); |
|
822 | 822 | } |
823 | 823 | } else { |
824 | - if ( $show_errors ) { |
|
825 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to save your registration information.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
824 | + if ($show_errors) { |
|
825 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
826 | 826 | } |
827 | 827 | return FALSE; |
828 | 828 | } |
@@ -837,32 +837,32 @@ discard block |
||
837 | 837 | * @param bool $show_errors |
838 | 838 | * @return void |
839 | 839 | */ |
840 | - private function _save_registration( $registration, $show_errors = TRUE ) { |
|
840 | + private function _save_registration($registration, $show_errors = TRUE) { |
|
841 | 841 | // verify object |
842 | - if ( $registration instanceof EE_Registration ) { |
|
842 | + if ($registration instanceof EE_Registration) { |
|
843 | 843 | // should this registration be processed during this visit ? |
844 | - if ( $this->visit_allows_processing_of_this_registration( $registration ) ) { |
|
844 | + if ($this->visit_allows_processing_of_this_registration($registration)) { |
|
845 | 845 | //set TXN ID |
846 | - if ( ! $registration->transaction_ID() ) { |
|
847 | - $registration->set_transaction_id( $this->transaction->ID() ); |
|
846 | + if ( ! $registration->transaction_ID()) { |
|
847 | + $registration->set_transaction_id($this->transaction->ID()); |
|
848 | 848 | } |
849 | 849 | // verify and save the attendee |
850 | - $this->_save_registration_attendee( $registration, $show_errors ); |
|
850 | + $this->_save_registration_attendee($registration, $show_errors); |
|
851 | 851 | // save answers to reg form questions |
852 | - $this->_save_registration_answers( $registration, $show_errors ); |
|
852 | + $this->_save_registration_answers($registration, $show_errors); |
|
853 | 853 | // save changes |
854 | 854 | $registration->save(); |
855 | 855 | // update txn cache |
856 | - if ( ! $this->transaction->update_cache_after_object_save( 'Registration', $registration )) { |
|
857 | - if ( $show_errors ) { |
|
858 | - EE_Error::add_error( __( 'The newly saved Registration object could not be cached on the Transaction.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
856 | + if ( ! $this->transaction->update_cache_after_object_save('Registration', $registration)) { |
|
857 | + if ($show_errors) { |
|
858 | + EE_Error::add_error(__('The newly saved Registration object could not be cached on the Transaction.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
859 | 859 | } |
860 | 860 | } |
861 | 861 | } |
862 | 862 | } else { |
863 | - if ( $show_errors ) { |
|
863 | + if ($show_errors) { |
|
864 | 864 | EE_Error::add_error( |
865 | - __( 'An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
865 | + __('An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
866 | 866 | __FILE__, __FUNCTION__, __LINE__ |
867 | 867 | ); |
868 | 868 | } |
@@ -878,26 +878,26 @@ discard block |
||
878 | 878 | * @param bool $show_errors |
879 | 879 | * @return void |
880 | 880 | */ |
881 | - private function _save_registration_attendee( $registration, $show_errors = TRUE ) { |
|
882 | - if ( $registration->attendee() instanceof EE_Attendee ) { |
|
881 | + private function _save_registration_attendee($registration, $show_errors = TRUE) { |
|
882 | + if ($registration->attendee() instanceof EE_Attendee) { |
|
883 | 883 | // save so that ATT has ID |
884 | 884 | $registration->attendee()->save(); |
885 | - if ( ! $registration->update_cache_after_object_save( 'Attendee', $registration->attendee() )) { |
|
886 | - if ( $show_errors ) { |
|
885 | + if ( ! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) { |
|
886 | + if ($show_errors) { |
|
887 | 887 | EE_Error::add_error( |
888 | - __( 'The newly saved Attendee object could not be cached on the registration.', 'event_espresso' ), |
|
888 | + __('The newly saved Attendee object could not be cached on the registration.', 'event_espresso'), |
|
889 | 889 | __FILE__, __FUNCTION__, __LINE__ |
890 | 890 | ); |
891 | 891 | } |
892 | 892 | } |
893 | 893 | } else { |
894 | - if ( $show_errors ) { |
|
894 | + if ($show_errors) { |
|
895 | 895 | ob_start(); |
896 | - var_dump( $registration->attendee() ); |
|
896 | + var_dump($registration->attendee()); |
|
897 | 897 | EE_Error::add_error( |
898 | 898 | sprintf( |
899 | 899 | '%1$s||%1$s $attendee = %2$s', |
900 | - __( 'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
900 | + __('Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
901 | 901 | ob_get_clean() |
902 | 902 | ), |
903 | 903 | __FILE__, __FUNCTION__, __LINE__ |
@@ -915,25 +915,25 @@ discard block |
||
915 | 915 | * @param bool $show_errors |
916 | 916 | * @return void |
917 | 917 | */ |
918 | - private function _save_registration_answers( $registration, $show_errors = TRUE ) { |
|
918 | + private function _save_registration_answers($registration, $show_errors = TRUE) { |
|
919 | 919 | // now save the answers |
920 | - foreach ( $registration->answers() as $cache_key => $answer ) { |
|
920 | + foreach ($registration->answers() as $cache_key => $answer) { |
|
921 | 921 | // verify object |
922 | - if ( $answer instanceof EE_Answer ) { |
|
923 | - $answer->set_registration( $registration->ID() ); |
|
922 | + if ($answer instanceof EE_Answer) { |
|
923 | + $answer->set_registration($registration->ID()); |
|
924 | 924 | $answer->save(); |
925 | - if ( ! $registration->update_cache_after_object_save( 'Answer', $answer, $cache_key )) { |
|
926 | - if ( $show_errors ) { |
|
925 | + if ( ! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) { |
|
926 | + if ($show_errors) { |
|
927 | 927 | EE_Error::add_error( |
928 | - __( 'The newly saved Answer object could not be cached on the registration.', 'event_espresso' ), |
|
928 | + __('The newly saved Answer object could not be cached on the registration.', 'event_espresso'), |
|
929 | 929 | __FILE__, __FUNCTION__, __LINE__ |
930 | 930 | ); |
931 | 931 | } |
932 | 932 | } |
933 | 933 | } else { |
934 | - if ( $show_errors ) { |
|
934 | + if ($show_errors) { |
|
935 | 935 | EE_Error::add_error( |
936 | - __( 'An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso' ), |
|
936 | + __('An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso'), |
|
937 | 937 | __FILE__, __FUNCTION__, __LINE__ |
938 | 938 | ); |
939 | 939 | } |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | * @param bool $from_db |
952 | 952 | * @return bool |
953 | 953 | */ |
954 | - public function refresh_all_entities( $from_db = false ) { |
|
954 | + public function refresh_all_entities($from_db = false) { |
|
955 | 955 | $from_db = $this->current_step->is_final_step() || $this->action == 'process_gateway_response' ? true : $from_db; |
956 | 956 | //$this->log( |
957 | 957 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -972,11 +972,11 @@ discard block |
||
972 | 972 | */ |
973 | 973 | protected function refresh_from_db() { |
974 | 974 | // verify the transaction |
975 | - if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) { |
|
975 | + if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) { |
|
976 | 976 | // pull fresh TXN data from the db |
977 | - $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db( $this->transaction->ID() ); |
|
977 | + $this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID()); |
|
978 | 978 | // update EE_Checkout's cached primary_attendee object |
979 | - $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db( $this->transaction ); |
|
979 | + $this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction); |
|
980 | 980 | // update EE_Checkout's cached payment object |
981 | 981 | $payment = $this->transaction->last_payment(); |
982 | 982 | $this->payment = $payment instanceof EE_Payment ? $payment : $this->payment; |
@@ -984,15 +984,15 @@ discard block |
||
984 | 984 | $payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null; |
985 | 985 | $this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method : $this->payment_method; |
986 | 986 | //now refresh the cart, based on the TXN |
987 | - $this->cart = EE_Cart::get_cart_from_txn( $this->transaction ); |
|
987 | + $this->cart = EE_Cart::get_cart_from_txn($this->transaction); |
|
988 | 988 | // verify and update the cart because inaccurate totals are not so much fun |
989 | - if ( $this->cart instanceof EE_Cart ) { |
|
989 | + if ($this->cart instanceof EE_Cart) { |
|
990 | 990 | $this->cart->get_grand_total()->recalculate_total_including_taxes(); |
991 | 991 | } else { |
992 | - $this->cart = EE_Registry::instance()->load_core( 'Cart' ); |
|
992 | + $this->cart = EE_Registry::instance()->load_core('Cart'); |
|
993 | 993 | } |
994 | 994 | } else { |
995 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
995 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
996 | 996 | return FALSE; |
997 | 997 | } |
998 | 998 | return TRUE; |
@@ -1006,24 +1006,24 @@ discard block |
||
1006 | 1006 | * @param EE_Transaction $transaction |
1007 | 1007 | * @return EE_Attendee | null |
1008 | 1008 | */ |
1009 | - protected function _refresh_primary_attendee_obj_from_db( EE_Transaction $transaction ) { |
|
1009 | + protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction) { |
|
1010 | 1010 | |
1011 | 1011 | $primary_attendee_obj = null; |
1012 | 1012 | // grab the saved registrations from the transaction |
1013 | - foreach ( $transaction->registrations( $this->reg_cache_where_params, true ) as $registration ) { |
|
1013 | + foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) { |
|
1014 | 1014 | // verify object |
1015 | - if ( $registration instanceof EE_Registration ) { |
|
1015 | + if ($registration instanceof EE_Registration) { |
|
1016 | 1016 | $attendee = $registration->attendee(); |
1017 | 1017 | // verify object |
1018 | - if ( $attendee instanceof EE_Attendee ) { |
|
1018 | + if ($attendee instanceof EE_Attendee) { |
|
1019 | 1019 | // maybe cache primary_attendee_obj ? |
1020 | - if ( $registration->is_primary_registrant() ) { |
|
1020 | + if ($registration->is_primary_registrant()) { |
|
1021 | 1021 | $primary_attendee_obj = $attendee; |
1022 | 1022 | } |
1023 | 1023 | } |
1024 | 1024 | } else { |
1025 | 1025 | EE_Error::add_error( |
1026 | - __( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1026 | + __('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1027 | 1027 | __FILE__, __FUNCTION__, __LINE__ |
1028 | 1028 | ); |
1029 | 1029 | } |
@@ -1043,43 +1043,43 @@ discard block |
||
1043 | 1043 | */ |
1044 | 1044 | protected function refresh_entity_map() { |
1045 | 1045 | // verify the transaction |
1046 | - if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) { |
|
1046 | + if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) { |
|
1047 | 1047 | // never cache payment info |
1048 | - $this->transaction->clear_cache( 'Payment' ); |
|
1048 | + $this->transaction->clear_cache('Payment'); |
|
1049 | 1049 | /** @type EE_Transaction_Processor $transaction_processor */ |
1050 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1050 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1051 | 1051 | // is the Payment Options Reg Step completed ? |
1052 | - if ( $transaction_processor->reg_step_completed( $this->transaction, 'payment_options' ) ) { |
|
1052 | + if ($transaction_processor->reg_step_completed($this->transaction, 'payment_options')) { |
|
1053 | 1053 | // then check for payments and update TXN accordingly |
1054 | 1054 | /** @type EE_Transaction_Payments $transaction_payments */ |
1055 | - $transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' ); |
|
1056 | - $transaction_payments->calculate_total_payments_and_update_status( $this->transaction ); |
|
1055 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
1056 | + $transaction_payments->calculate_total_payments_and_update_status($this->transaction); |
|
1057 | 1057 | } |
1058 | 1058 | // grab the saved registrations from the transaction |
1059 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $reg_cache_ID => $registration ) { |
|
1060 | - $this->_refresh_registration( $reg_cache_ID, $registration ); |
|
1059 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration) { |
|
1060 | + $this->_refresh_registration($reg_cache_ID, $registration); |
|
1061 | 1061 | } |
1062 | 1062 | // make sure our cached TXN is added to the model entity mapper |
1063 | - $this->transaction = $this->transaction->get_model()->refresh_entity_map_with( $this->transaction->ID(), $this->transaction ); |
|
1063 | + $this->transaction = $this->transaction->get_model()->refresh_entity_map_with($this->transaction->ID(), $this->transaction); |
|
1064 | 1064 | |
1065 | 1065 | } else { |
1066 | - EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
1066 | + EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1067 | 1067 | return FALSE; |
1068 | 1068 | } |
1069 | 1069 | // verify and update the cart because inaccurate totals are not so much fun |
1070 | - if ( $this->cart instanceof EE_Cart ) { |
|
1070 | + if ($this->cart instanceof EE_Cart) { |
|
1071 | 1071 | $grand_total = $this->cart->get_grand_total(); |
1072 | - if ( $grand_total instanceof EE_Line_Item && $grand_total->ID() ) { |
|
1072 | + if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) { |
|
1073 | 1073 | $grand_total->recalculate_total_including_taxes(); |
1074 | 1074 | $grand_total = $grand_total->get_model()->refresh_entity_map_with( |
1075 | 1075 | $this->cart->get_grand_total()->ID(), |
1076 | 1076 | $this->cart->get_grand_total() |
1077 | 1077 | ); |
1078 | 1078 | } |
1079 | - if ( $grand_total instanceof EE_Line_Item ) { |
|
1080 | - $this->cart = EE_Cart::instance( $grand_total ); |
|
1079 | + if ($grand_total instanceof EE_Line_Item) { |
|
1080 | + $this->cart = EE_Cart::instance($grand_total); |
|
1081 | 1081 | } else { |
1082 | - EE_Error::add_error( __( 'A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1082 | + EE_Error::add_error(__('A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1083 | 1083 | return false; |
1084 | 1084 | } |
1085 | 1085 | } |
@@ -1095,19 +1095,19 @@ discard block |
||
1095 | 1095 | * @param EE_Registration $registration |
1096 | 1096 | * @return void |
1097 | 1097 | */ |
1098 | - protected function _refresh_registration( $reg_cache_ID, $registration ) { |
|
1098 | + protected function _refresh_registration($reg_cache_ID, $registration) { |
|
1099 | 1099 | |
1100 | 1100 | // verify object |
1101 | - if ( $registration instanceof EE_Registration ) { |
|
1101 | + if ($registration instanceof EE_Registration) { |
|
1102 | 1102 | // update the entity mapper attendee |
1103 | - $this->_refresh_registration_attendee( $registration ); |
|
1103 | + $this->_refresh_registration_attendee($registration); |
|
1104 | 1104 | // update the entity mapper answers for reg form questions |
1105 | - $this->_refresh_registration_answers( $registration ); |
|
1105 | + $this->_refresh_registration_answers($registration); |
|
1106 | 1106 | // make sure the cached registration is added to the model entity mapper |
1107 | - $registration->get_model()->refresh_entity_map_with( $reg_cache_ID, $registration ); |
|
1107 | + $registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration); |
|
1108 | 1108 | } else { |
1109 | 1109 | EE_Error::add_error( |
1110 | - __( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1110 | + __('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1111 | 1111 | __FILE__, __FUNCTION__, __LINE__ |
1112 | 1112 | ); |
1113 | 1113 | } |
@@ -1121,15 +1121,15 @@ discard block |
||
1121 | 1121 | * @param EE_Registration $registration |
1122 | 1122 | * @return void |
1123 | 1123 | */ |
1124 | - protected function _refresh_registration_attendee( $registration ) { |
|
1124 | + protected function _refresh_registration_attendee($registration) { |
|
1125 | 1125 | |
1126 | 1126 | $attendee = $registration->attendee(); |
1127 | 1127 | // verify object |
1128 | - if ( $attendee instanceof EE_Attendee && $attendee->ID() ) { |
|
1128 | + if ($attendee instanceof EE_Attendee && $attendee->ID()) { |
|
1129 | 1129 | // make sure the cached attendee is added to the model entity mapper |
1130 | - $registration->attendee()->get_model()->refresh_entity_map_with( $attendee->ID(), $attendee ); |
|
1130 | + $registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee); |
|
1131 | 1131 | // maybe cache primary_attendee_obj ? |
1132 | - if ( $registration->is_primary_registrant() ) { |
|
1132 | + if ($registration->is_primary_registrant()) { |
|
1133 | 1133 | $this->primary_attendee_obj = $attendee; |
1134 | 1134 | } |
1135 | 1135 | } |
@@ -1143,19 +1143,19 @@ discard block |
||
1143 | 1143 | * @param EE_Registration $registration |
1144 | 1144 | * @return void |
1145 | 1145 | */ |
1146 | - protected function _refresh_registration_answers( $registration ) { |
|
1146 | + protected function _refresh_registration_answers($registration) { |
|
1147 | 1147 | |
1148 | 1148 | // now update the answers |
1149 | - foreach ( $registration->answers() as $cache_key => $answer ) { |
|
1149 | + foreach ($registration->answers() as $cache_key => $answer) { |
|
1150 | 1150 | // verify object |
1151 | - if ( $answer instanceof EE_Answer ) { |
|
1152 | - if ( $answer->ID() ) { |
|
1151 | + if ($answer instanceof EE_Answer) { |
|
1152 | + if ($answer->ID()) { |
|
1153 | 1153 | // make sure the cached answer is added to the model entity mapper |
1154 | - $answer->get_model()->refresh_entity_map_with( $answer->ID(), $answer ); |
|
1154 | + $answer->get_model()->refresh_entity_map_with($answer->ID(), $answer); |
|
1155 | 1155 | } |
1156 | 1156 | } else { |
1157 | 1157 | EE_Error::add_error( |
1158 | - __( 'An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso' ), |
|
1158 | + __('An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso'), |
|
1159 | 1159 | __FILE__, __FUNCTION__, __LINE__ |
1160 | 1160 | ); |
1161 | 1161 | } |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object |
1171 | 1171 | */ |
1172 | 1172 | function __wakeup() { |
1173 | - foreach ( $this->reg_steps as $reg_step ) { |
|
1173 | + foreach ($this->reg_steps as $reg_step) { |
|
1174 | 1174 | $reg_step->checkout = $this; |
1175 | 1175 | } |
1176 | 1176 | } |
@@ -1186,11 +1186,11 @@ discard block |
||
1186 | 1186 | * @param array $info |
1187 | 1187 | * @param bool $display_request |
1188 | 1188 | */ |
1189 | - function log( $class = '', $func = '', $line = '', $info = array(), $display_request = false ) { |
|
1190 | - if ( WP_DEBUG && false ) { |
|
1191 | - $debug_data = get_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array() ); |
|
1189 | + function log($class = '', $func = '', $line = '', $info = array(), $display_request = false) { |
|
1190 | + if (WP_DEBUG && false) { |
|
1191 | + $debug_data = get_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), array()); |
|
1192 | 1192 | $default_data = array( |
1193 | - $class => $func . '() : ' . $line, |
|
1193 | + $class => $func.'() : '.$line, |
|
1194 | 1194 | 'request->step' => $this->step, |
1195 | 1195 | 'request->action' => $this->action, |
1196 | 1196 | 'current_step->slug' => $this->current_step instanceof EE_SPCO_Reg_Step ? |
@@ -1202,24 +1202,24 @@ discard block |
||
1202 | 1202 | 'reg_url_link' => $this->reg_url_link, |
1203 | 1203 | 'REQ' => $display_request ? $_REQUEST : '', |
1204 | 1204 | ); |
1205 | - if ( $this->transaction instanceof EE_Transaction ) { |
|
1206 | - $default_data[ 'TXN_status' ] = $this->transaction->status_ID(); |
|
1207 | - $default_data[ 'TXN_reg_steps' ] = $this->transaction->reg_steps(); |
|
1208 | - foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $REG_ID => $registration ) { |
|
1209 | - $default_data[ 'registrations' ][ $REG_ID ] = $registration->status_ID(); |
|
1205 | + if ($this->transaction instanceof EE_Transaction) { |
|
1206 | + $default_data['TXN_status'] = $this->transaction->status_ID(); |
|
1207 | + $default_data['TXN_reg_steps'] = $this->transaction->reg_steps(); |
|
1208 | + foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) { |
|
1209 | + $default_data['registrations'][$REG_ID] = $registration->status_ID(); |
|
1210 | 1210 | } |
1211 | - if ( $this->transaction->ID() ) { |
|
1212 | - $TXN_ID = 'EE_Transaction: ' . $this->transaction->ID(); |
|
1211 | + if ($this->transaction->ID()) { |
|
1212 | + $TXN_ID = 'EE_Transaction: '.$this->transaction->ID(); |
|
1213 | 1213 | // don't serialize objects |
1214 | - $info = $this->_strip_objects( $info ); |
|
1215 | - if ( ! isset( $debug_data[ $TXN_ID ] ) ) { |
|
1216 | - $debug_data[ $TXN_ID ] = array(); |
|
1214 | + $info = $this->_strip_objects($info); |
|
1215 | + if ( ! isset($debug_data[$TXN_ID])) { |
|
1216 | + $debug_data[$TXN_ID] = array(); |
|
1217 | 1217 | } |
1218 | - $debug_data[ $TXN_ID ][ microtime() ] = array_merge( |
|
1218 | + $debug_data[$TXN_ID][microtime()] = array_merge( |
|
1219 | 1219 | $default_data, |
1220 | 1220 | $info |
1221 | 1221 | ); |
1222 | - update_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data ); |
|
1222 | + update_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), $debug_data); |
|
1223 | 1223 | } |
1224 | 1224 | } |
1225 | 1225 | } |
@@ -1232,23 +1232,23 @@ discard block |
||
1232 | 1232 | * @param array $info |
1233 | 1233 | * @return array |
1234 | 1234 | */ |
1235 | - function _strip_objects( $info = array() ) { |
|
1236 | - foreach ( $info as $key => $value ) { |
|
1237 | - if ( is_array( $value )) { |
|
1238 | - $info[ $key ] = $this->_strip_objects( $value ); |
|
1239 | - } else if ( is_object( $value ) ) { |
|
1240 | - $object_class = get_class( $value ); |
|
1241 | - $info[ $object_class ] = array(); |
|
1242 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : 0; |
|
1243 | - if ( method_exists( $value, 'status' ) ) { |
|
1244 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
1245 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
1246 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
1235 | + function _strip_objects($info = array()) { |
|
1236 | + foreach ($info as $key => $value) { |
|
1237 | + if (is_array($value)) { |
|
1238 | + $info[$key] = $this->_strip_objects($value); |
|
1239 | + } else if (is_object($value)) { |
|
1240 | + $object_class = get_class($value); |
|
1241 | + $info[$object_class] = array(); |
|
1242 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0; |
|
1243 | + if (method_exists($value, 'status')) { |
|
1244 | + $info[$object_class]['status'] = $value->status(); |
|
1245 | + } else if (method_exists($value, 'status_ID')) { |
|
1246 | + $info[$object_class]['status'] = $value->status_ID(); |
|
1247 | 1247 | } |
1248 | - unset( $info[ $key ] ); |
|
1248 | + unset($info[$key]); |
|
1249 | 1249 | } |
1250 | 1250 | } |
1251 | - return (array)$info; |
|
1251 | + return (array) $info; |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | 1254 |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | * @return void |
29 | 29 | */ |
30 | 30 | public static function set_hooks() { |
31 | - add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) ); |
|
32 | - add_action( 'wp_ajax_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )); |
|
33 | - add_action( 'wp_ajax_nopriv_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )); |
|
34 | - add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )); |
|
35 | - add_action( 'wp_ajax_nopriv_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )); |
|
36 | - add_action( 'wp_ajax_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) ); |
|
37 | - add_action( 'wp_ajax_nopriv_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) |
|
31 | + add_filter('FHEE__SPCO__EE_Line_Item_Filter_Collection', array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')); |
|
32 | + add_action('wp_ajax_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')); |
|
33 | + add_action('wp_ajax_nopriv_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')); |
|
34 | + add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
35 | + add_action('wp_ajax_nopriv_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')); |
|
36 | + add_action('wp_ajax_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')); |
|
37 | + add_action('wp_ajax_nopriv_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details') |
|
38 | 38 | ); |
39 | - add_filter( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), 10, 1 ); |
|
39 | + add_filter('FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), 10, 1); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * ajax switch_spco_billing_form |
46 | 46 | */ |
47 | 47 | public static function switch_spco_billing_form() { |
48 | - EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' ); |
|
48 | + EED_Single_Page_Checkout::process_ajax_request('switch_payment_method'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * ajax save_payer_details |
55 | 55 | */ |
56 | 56 | public static function save_payer_details() { |
57 | - EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' ); |
|
57 | + EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * ajax get_transaction_details |
64 | 64 | */ |
65 | 65 | public static function get_transaction_details() { |
66 | - EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' ); |
|
66 | + EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @param EE_Checkout $checkout |
92 | 92 | * @return \EE_SPCO_Reg_Step_Payment_Options |
93 | 93 | */ |
94 | - public function __construct( EE_Checkout $checkout ) { |
|
94 | + public function __construct(EE_Checkout $checkout) { |
|
95 | 95 | $this->_slug = 'payment_options'; |
96 | 96 | $this->_name = __('Payment Options', 'event_espresso'); |
97 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php'; |
|
97 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php'; |
|
98 | 98 | $this->checkout = $checkout; |
99 | 99 | $this->_reset_success_message(); |
100 | - $this->set_instructions( __('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso')); |
|
100 | + $this->set_instructions(__('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso')); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * @param null $line_item_display |
116 | 116 | */ |
117 | - public function set_line_item_display( $line_item_display ) { |
|
117 | + public function set_line_item_display($line_item_display) { |
|
118 | 118 | $this->line_item_display = $line_item_display; |
119 | 119 | } |
120 | 120 | |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | * @return void |
126 | 126 | */ |
127 | 127 | public function translate_js_strings() { |
128 | - EE_Registry::$i18n_js_strings['no_payment_method'] = __( 'Please select a method of payment in order to continue.', 'event_espresso' ); |
|
129 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso' ); |
|
130 | - EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __( 'Forwarding to Secure Payment Provider.', 'event_espresso' ); |
|
128 | + EE_Registry::$i18n_js_strings['no_payment_method'] = __('Please select a method of payment in order to continue.', 'event_espresso'); |
|
129 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso'); |
|
130 | + EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __('Forwarding to Secure Payment Provider.', 'event_espresso'); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | // $ 0.00 transactions (no payment required) |
157 | 157 | ! $this->checkout->payment_required() |
158 | 158 | // but do NOT remove if current action being called belongs to this reg step |
159 | - && ! is_callable( array( $this, $this->checkout->action ) ) |
|
159 | + && ! is_callable(array($this, $this->checkout->action)) |
|
160 | 160 | && ! $this->completed() |
161 | 161 | ) { |
162 | 162 | // and if so, then we no longer need the Payment Options step |
163 | - if ( $this->is_current_step() ) { |
|
163 | + if ($this->is_current_step()) { |
|
164 | 164 | $this->checkout->generate_reg_form = false; |
165 | 165 | } |
166 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
166 | + $this->checkout->remove_reg_step($this->_slug); |
|
167 | 167 | // DEBUG LOG |
168 | 168 | //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ ); |
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | // load EEM_Payment_Method |
172 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
172 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
173 | 173 | // get all active payment methods |
174 | 174 | $this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction( |
175 | 175 | $this->checkout->transaction, EEM_Payment_Method::scope_cart |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @return bool |
184 | 184 | */ |
185 | 185 | public function generate_reg_form() { |
186 | - EE_Registry::instance()->load_helper( 'HTML' ); |
|
186 | + EE_Registry::instance()->load_helper('HTML'); |
|
187 | 187 | // reset in case someone changes their mind |
188 | 188 | $this->_reset_selected_method_of_payment(); |
189 | 189 | // set some defaults |
@@ -194,15 +194,15 @@ discard block |
||
194 | 194 | $sold_out_events = array(); |
195 | 195 | $reg_count = 0; |
196 | 196 | // loop thru registrations to gather info |
197 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
198 | - foreach ( $registrations as $registration ) { |
|
197 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
198 | + foreach ($registrations as $registration) { |
|
199 | 199 | /** @var $registration EE_Registration */ |
200 | 200 | $reg_count++; |
201 | 201 | // if returning registrant is Approved then do NOT do this |
202 | - if ( ! ( $this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved )) { |
|
203 | - if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true )) { |
|
202 | + if ( ! ($this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved)) { |
|
203 | + if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) { |
|
204 | 204 | // add event to list of events that are sold out |
205 | - $sold_out_events[ $registration->event()->ID() ] = $registration->event(); |
|
205 | + $sold_out_events[$registration->event()->ID()] = $registration->event(); |
|
206 | 206 | do_action( |
207 | 207 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event', |
208 | 208 | $registration->event(), |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | ); |
211 | 211 | } |
212 | 212 | // event requires admin approval |
213 | - if ( $registration->status_ID() == EEM_Registration::status_id_not_approved ) { |
|
213 | + if ($registration->status_ID() == EEM_Registration::status_id_not_approved) { |
|
214 | 214 | // add event to list of events with pre-approval reg status |
215 | - $registrations_requiring_pre_approval[ $registration->ID() ] = $registration; |
|
215 | + $registrations_requiring_pre_approval[$registration->ID()] = $registration; |
|
216 | 216 | do_action( |
217 | 217 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval', |
218 | 218 | $registration->event(), |
@@ -221,29 +221,29 @@ discard block |
||
221 | 221 | } |
222 | 222 | } |
223 | 223 | // are they allowed to pay now and is there monies owing? |
224 | - if ( $registration->owes_monies_and_can_pay() ) { |
|
225 | - $registrations_requiring_payment[ $registration->ID() ] = $registration; |
|
224 | + if ($registration->owes_monies_and_can_pay()) { |
|
225 | + $registrations_requiring_payment[$registration->ID()] = $registration; |
|
226 | 226 | do_action( |
227 | 227 | 'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment', |
228 | 228 | $registration->event(), |
229 | 229 | $this |
230 | 230 | ); |
231 | - } else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free() ) { |
|
232 | - $registrations_for_free_events[ $registration->event()->ID() ] = $registration; |
|
231 | + } else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()) { |
|
232 | + $registrations_for_free_events[$registration->event()->ID()] = $registration; |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | $subsections = array(); |
236 | 236 | // now decide which template to load |
237 | - if ( ! empty( $sold_out_events )) { |
|
238 | - $subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events ); |
|
237 | + if ( ! empty($sold_out_events)) { |
|
238 | + $subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events); |
|
239 | 239 | } |
240 | - if ( ! empty( $registrations_requiring_pre_approval )) { |
|
241 | - $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( $registrations_requiring_pre_approval ); |
|
240 | + if ( ! empty($registrations_requiring_pre_approval)) { |
|
241 | + $subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval($registrations_requiring_pre_approval); |
|
242 | 242 | } |
243 | - if ( ! empty( $registrations_for_free_events ) ) { |
|
244 | - $subsections[ 'no_payment_required' ] = $this->_no_payment_required( $registrations_for_free_events ); |
|
243 | + if ( ! empty($registrations_for_free_events)) { |
|
244 | + $subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events); |
|
245 | 245 | } |
246 | - if ( ! empty( $registrations_requiring_payment ) ) { |
|
246 | + if ( ! empty($registrations_requiring_payment)) { |
|
247 | 247 | // autoload Line_Item_Display classes |
248 | 248 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
249 | 249 | $line_item_filter_processor = new EE_Line_Item_Filter_Processor( |
@@ -254,17 +254,17 @@ discard block |
||
254 | 254 | $this->checkout->cart->get_grand_total() |
255 | 255 | ); |
256 | 256 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
257 | - if ( $this->checkout->amount_owing > 0 ) { |
|
257 | + if ($this->checkout->amount_owing > 0) { |
|
258 | 258 | EEH_Autoloader::register_line_item_display_autoloaders(); |
259 | - $this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) ); |
|
260 | - $subsections[ 'payment_options' ] = $this->_display_payment_options( |
|
259 | + $this->set_line_item_display(new EE_Line_Item_Display('spco')); |
|
260 | + $subsections['payment_options'] = $this->_display_payment_options( |
|
261 | 261 | $this->line_item_display->display_line_item( |
262 | 262 | $filtered_line_item_tree, |
263 | - array( 'registrations' => $registrations ) |
|
263 | + array('registrations' => $registrations) |
|
264 | 264 | ) |
265 | 265 | ); |
266 | 266 | $this->checkout->amount_owing = $filtered_line_item_tree->total(); |
267 | - $this->_apply_registration_payments_to_amount_owing( $registrations ); |
|
267 | + $this->_apply_registration_payments_to_amount_owing($registrations); |
|
268 | 268 | } |
269 | 269 | } else { |
270 | 270 | $this->_hide_reg_step_submit_button_if_revisit(); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection |
298 | 298 | * @return \EE_Line_Item_Filter_Collection |
299 | 299 | */ |
300 | - public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) { |
|
300 | + public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) { |
|
301 | 301 | $line_item_filter_collection->add( |
302 | 302 | new EE_Billable_Line_Item_Filter( |
303 | 303 | EE_Registry::instance()->SSN->checkout()->transaction->registrations( |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | ) |
306 | 306 | ) |
307 | 307 | ); |
308 | - $line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() ); |
|
308 | + $line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter()); |
|
309 | 309 | return $line_item_filter_collection; |
310 | 310 | } |
311 | 311 | |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * @return void |
320 | 320 | */ |
321 | 321 | protected function _hide_reg_step_submit_button_if_revisit() { |
322 | - if ( $this->checkout->revisit ) { |
|
323 | - add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' ); |
|
322 | + if ($this->checkout->revisit) { |
|
323 | + add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string'); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * @param \EE_Event[] $sold_out_events_array |
332 | 332 | * @return \EE_Form_Section_Proper |
333 | 333 | */ |
334 | - private function _sold_out_events( $sold_out_events_array = array() ) { |
|
334 | + private function _sold_out_events($sold_out_events_array = array()) { |
|
335 | 335 | // set some defaults |
336 | 336 | $this->checkout->selected_method_of_payment = 'events_sold_out'; |
337 | 337 | $sold_out_events = ''; |
338 | - foreach ( $sold_out_events_array as $sold_out_event ) { |
|
339 | - $sold_out_events .= EEH_HTML::li( EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' )); |
|
338 | + foreach ($sold_out_events_array as $sold_out_event) { |
|
339 | + $sold_out_events .= EEH_HTML::li(EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')); |
|
340 | 340 | } |
341 | 341 | return new EE_Form_Section_Proper( |
342 | 342 | array( |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | ), |
349 | 349 | 'layout_strategy' => new EE_Template_Layout( |
350 | 350 | array( |
351 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'sold_out_events.template.php', // layout_template |
|
351 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'sold_out_events.template.php', // layout_template |
|
352 | 352 | 'template_args' => apply_filters( |
353 | 353 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
354 | 354 | array( |
355 | 355 | 'sold_out_events' => $sold_out_events, |
356 | 356 | 'sold_out_events_msg' => apply_filters( |
357 | 357 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg', |
358 | - __( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ) |
|
358 | + __('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso') |
|
359 | 359 | ) |
360 | 360 | ) |
361 | 361 | ) |
@@ -372,14 +372,14 @@ discard block |
||
372 | 372 | * @param array $registrations_requiring_pre_approval |
373 | 373 | * @return \EE_Form_Section_Proper |
374 | 374 | */ |
375 | - private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array()) { |
|
375 | + private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) { |
|
376 | 376 | $events_requiring_pre_approval = ''; |
377 | - foreach ( $registrations_requiring_pre_approval as $registration ) { |
|
378 | - if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) { |
|
379 | - $events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li( |
|
380 | - EEH_HTML::span( '', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
377 | + foreach ($registrations_requiring_pre_approval as $registration) { |
|
378 | + if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) { |
|
379 | + $events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li( |
|
380 | + EEH_HTML::span('', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text' |
|
381 | 381 | ) |
382 | - . EEH_HTML::span( $registration->event()->name(), '', 'orange-text' ) |
|
382 | + . EEH_HTML::span($registration->event()->name(), '', 'orange-text') |
|
383 | 383 | ); |
384 | 384 | } |
385 | 385 | } |
@@ -391,14 +391,14 @@ discard block |
||
391 | 391 | ), |
392 | 392 | 'layout_strategy' => new EE_Template_Layout( |
393 | 393 | array( |
394 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'events_requiring_pre_approval.template.php', // layout_template |
|
394 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'events_requiring_pre_approval.template.php', // layout_template |
|
395 | 395 | 'template_args' => apply_filters( |
396 | 396 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args', |
397 | 397 | array( |
398 | - 'events_requiring_pre_approval' => implode( '', $events_requiring_pre_approval ), |
|
398 | + 'events_requiring_pre_approval' => implode('', $events_requiring_pre_approval), |
|
399 | 399 | 'events_requiring_pre_approval_msg' => apply_filters( |
400 | 400 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg', |
401 | - __( 'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso' ) |
|
401 | + __('The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso') |
|
402 | 402 | ) |
403 | 403 | ) |
404 | 404 | ), |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @param \EE_Event[] $registrations_for_free_events |
417 | 417 | * @return \EE_Form_Section_Proper |
418 | 418 | */ |
419 | - private function _no_payment_required( $registrations_for_free_events = array() ) { |
|
419 | + private function _no_payment_required($registrations_for_free_events = array()) { |
|
420 | 420 | // set some defaults |
421 | 421 | $this->checkout->selected_method_of_payment = 'no_payment_required'; |
422 | 422 | // generate no_payment_required form |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | ), |
429 | 429 | 'layout_strategy' => new EE_Template_Layout( |
430 | 430 | array( |
431 | - 'layout_template_file' => SPCO_REG_STEPS_PATH . $this->_slug . DS . 'no_payment_required.template.php', // layout_template |
|
431 | + 'layout_template_file' => SPCO_REG_STEPS_PATH.$this->_slug.DS.'no_payment_required.template.php', // layout_template |
|
432 | 432 | 'template_args' => apply_filters( |
433 | 433 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args', |
434 | 434 | array( |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | 'registrations' => array(), |
437 | 437 | 'ticket_count' => array(), |
438 | 438 | 'registrations_for_free_events' => $registrations_for_free_events, |
439 | - 'no_payment_required_msg' => EEH_HTML::p( __( 'This is a free event, so no billing will occur.', 'event_espresso' )) |
|
439 | + 'no_payment_required_msg' => EEH_HTML::p(__('This is a free event, so no billing will occur.', 'event_espresso')) |
|
440 | 440 | ) |
441 | 441 | ), |
442 | 442 | ) |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @param string $transaction_details |
454 | 454 | * @return \EE_Form_Section_Proper |
455 | 455 | */ |
456 | - private function _display_payment_options( $transaction_details = '' ) { |
|
456 | + private function _display_payment_options($transaction_details = '') { |
|
457 | 457 | // has method_of_payment been set by no-js user? |
458 | 458 | $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(); |
459 | 459 | // build payment options form |
@@ -465,20 +465,20 @@ discard block |
||
465 | 465 | 'before_payment_options' => apply_filters( |
466 | 466 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', |
467 | 467 | new EE_Form_Section_Proper( |
468 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
468 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
469 | 469 | ) |
470 | 470 | ), |
471 | 471 | 'payment_options' => $this->_setup_payment_options(), |
472 | 472 | 'after_payment_options' => apply_filters( |
473 | 473 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options', |
474 | 474 | new EE_Form_Section_Proper( |
475 | - array( 'layout_strategy' => new EE_Div_Per_Section_Layout() ) |
|
475 | + array('layout_strategy' => new EE_Div_Per_Section_Layout()) |
|
476 | 476 | ) |
477 | 477 | ), |
478 | 478 | 'default_hidden_inputs' => $this->reg_step_hidden_inputs(), |
479 | - 'extra_hidden_inputs' => $this->_extra_hidden_inputs( FALSE ) |
|
479 | + 'extra_hidden_inputs' => $this->_extra_hidden_inputs(FALSE) |
|
480 | 480 | ), |
481 | - 'layout_strategy' => new EE_Template_Layout( array( |
|
481 | + 'layout_strategy' => new EE_Template_Layout(array( |
|
482 | 482 | 'layout_template_file' => $this->_template, |
483 | 483 | 'template_args' => apply_filters( |
484 | 484 | 'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args', |
@@ -502,11 +502,11 @@ discard block |
||
502 | 502 | * @param bool $no_payment_required |
503 | 503 | * @return \EE_Form_Section_Proper |
504 | 504 | */ |
505 | - private function _extra_hidden_inputs( $no_payment_required = TRUE ) { |
|
505 | + private function _extra_hidden_inputs($no_payment_required = TRUE) { |
|
506 | 506 | |
507 | 507 | return new EE_Form_Section_Proper( |
508 | 508 | array( |
509 | - 'html_id' => 'ee-' . $this->slug() . '-extra-hidden-inputs', |
|
509 | + 'html_id' => 'ee-'.$this->slug().'-extra-hidden-inputs', |
|
510 | 510 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
511 | 511 | 'subsections' => array( |
512 | 512 | 'spco_no_payment_required' => new EE_Hidden_Input( |
@@ -539,16 +539,16 @@ discard block |
||
539 | 539 | * @access protected |
540 | 540 | * @return void |
541 | 541 | */ |
542 | - protected function _apply_registration_payments_to_amount_owing( $registrations ) { |
|
542 | + protected function _apply_registration_payments_to_amount_owing($registrations) { |
|
543 | 543 | $payments = array(); |
544 | - foreach ( $registrations as $registration ) { |
|
545 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
544 | + foreach ($registrations as $registration) { |
|
545 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
546 | 546 | $payments = $payments + $registration->registration_payments(); |
547 | 547 | } |
548 | 548 | } |
549 | - if ( ! empty( $payments ) ) { |
|
550 | - foreach ( $payments as $payment ) { |
|
551 | - if ( $payment instanceof EE_Registration_Payment ) { |
|
549 | + if ( ! empty($payments)) { |
|
550 | + foreach ($payments as $payment) { |
|
551 | + if ($payment instanceof EE_Registration_Payment) { |
|
552 | 552 | $this->checkout->amount_owing -= $payment->amount(); |
553 | 553 | } |
554 | 554 | } |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | * @param bool $force_reset |
564 | 564 | * @return void |
565 | 565 | */ |
566 | - private function _reset_selected_method_of_payment( $force_reset = FALSE ) { |
|
567 | - $reset_payment_method = $force_reset ? TRUE : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', FALSE )); |
|
568 | - if ( $reset_payment_method ) { |
|
566 | + private function _reset_selected_method_of_payment($force_reset = FALSE) { |
|
567 | + $reset_payment_method = $force_reset ? TRUE : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', FALSE)); |
|
568 | + if ($reset_payment_method) { |
|
569 | 569 | $this->checkout->selected_method_of_payment = NULL; |
570 | 570 | $this->checkout->payment_method = NULL; |
571 | 571 | $this->checkout->billing_form = NULL; |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | * @param string $selected_method_of_payment |
585 | 585 | * @return EE_Billing_Info_Form |
586 | 586 | */ |
587 | - private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) { |
|
588 | - $selected_method_of_payment = ! empty( $selected_method_of_payment ) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment; |
|
589 | - EE_Registry::instance()->SSN->set_session_data( array( 'selected_method_of_payment' => $selected_method_of_payment )); |
|
587 | + private function _save_selected_method_of_payment($selected_method_of_payment = '') { |
|
588 | + $selected_method_of_payment = ! empty($selected_method_of_payment) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment; |
|
589 | + EE_Registry::instance()->SSN->set_session_data(array('selected_method_of_payment' => $selected_method_of_payment)); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | |
@@ -599,40 +599,40 @@ discard block |
||
599 | 599 | // load payment method classes |
600 | 600 | $this->checkout->available_payment_methods = $this->_get_available_payment_methods(); |
601 | 601 | // switch up header depending on number of available payment methods |
602 | - $payment_method_header = count( $this->checkout->available_payment_methods ) > 1 |
|
603 | - ? apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Please Select Your Method of Payment', 'event_espresso' )) |
|
604 | - : apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Method of Payment', 'event_espresso' )); |
|
602 | + $payment_method_header = count($this->checkout->available_payment_methods) > 1 |
|
603 | + ? apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Please Select Your Method of Payment', 'event_espresso')) |
|
604 | + : apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Method of Payment', 'event_espresso')); |
|
605 | 605 | $available_payment_methods = array( |
606 | 606 | // display the "Payment Method" header |
607 | 607 | 'payment_method_header' => new EE_Form_Section_HTML( |
608 | - EEH_HTML::h4 ( $payment_method_header, 'method-of-payment-hdr' ) |
|
608 | + EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr') |
|
609 | 609 | ) |
610 | 610 | ); |
611 | 611 | // the list of actual payment methods ( invoice, paypal, etc ) in a ( slug => HTML ) format |
612 | 612 | $available_payment_method_options = array(); |
613 | 613 | $default_payment_method_option = array(); |
614 | 614 | // additional instructions to be displayed and hidden below payment methods (adding a clearing div to start) |
615 | - $payment_methods_billing_info = array( new EE_Form_Section_HTML( EEH_HTML::div ( '<br />', '', '', 'clear:both;' ))); |
|
615 | + $payment_methods_billing_info = array(new EE_Form_Section_HTML(EEH_HTML::div('<br />', '', '', 'clear:both;'))); |
|
616 | 616 | // loop through payment methods |
617 | - foreach( $this->checkout->available_payment_methods as $payment_method ) { |
|
618 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
619 | - $payment_method_button = EEH_HTML::img( $payment_method->button_url(), $payment_method->name(), 'spco-payment-method-' . $payment_method->slug() . '-btn-img', 'spco-payment-method-btn-img' ); |
|
617 | + foreach ($this->checkout->available_payment_methods as $payment_method) { |
|
618 | + if ($payment_method instanceof EE_Payment_Method) { |
|
619 | + $payment_method_button = EEH_HTML::img($payment_method->button_url(), $payment_method->name(), 'spco-payment-method-'.$payment_method->slug().'-btn-img', 'spco-payment-method-btn-img'); |
|
620 | 620 | // check if any payment methods are set as default |
621 | 621 | // if payment method is already selected OR nothing is selected and this payment method should be open_by_default |
622 | - if (( $this->checkout->selected_method_of_payment == $payment_method->slug() ) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() )) { |
|
622 | + if (($this->checkout->selected_method_of_payment == $payment_method->slug()) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())) { |
|
623 | 623 | $this->checkout->selected_method_of_payment = $payment_method->slug(); |
624 | 624 | $this->_save_selected_method_of_payment(); |
625 | - $default_payment_method_option[ $payment_method->slug() ] = $payment_method_button; |
|
625 | + $default_payment_method_option[$payment_method->slug()] = $payment_method_button; |
|
626 | 626 | } else { |
627 | - $available_payment_method_options[ $payment_method->slug() ] = $payment_method_button; |
|
627 | + $available_payment_method_options[$payment_method->slug()] = $payment_method_button; |
|
628 | 628 | } |
629 | - $payment_methods_billing_info[ $payment_method->slug() . '-info' ] = $this->_payment_method_billing_info( $payment_method ); |
|
629 | + $payment_methods_billing_info[$payment_method->slug().'-info'] = $this->_payment_method_billing_info($payment_method); |
|
630 | 630 | } |
631 | 631 | } |
632 | 632 | // prepend available_payment_method_options with default_payment_method_option so that it appears first in list of PMs |
633 | 633 | $available_payment_method_options = $default_payment_method_option + $available_payment_method_options; |
634 | 634 | // now generate the actual form inputs |
635 | - $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs( $available_payment_method_options ); |
|
635 | + $available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs($available_payment_method_options); |
|
636 | 636 | $available_payment_methods = $available_payment_methods + $payment_methods_billing_info; |
637 | 637 | |
638 | 638 | // build the available payment methods form |
@@ -652,19 +652,19 @@ discard block |
||
652 | 652 | * @return EE_Payment_Method[] |
653 | 653 | */ |
654 | 654 | protected function _get_available_payment_methods() { |
655 | - if ( ! empty( $this->checkout->available_payment_methods )) { |
|
655 | + if ( ! empty($this->checkout->available_payment_methods)) { |
|
656 | 656 | return $this->checkout->available_payment_methods; |
657 | 657 | } |
658 | 658 | $available_payment_methods = array(); |
659 | 659 | // load EEM_Payment_Method |
660 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
660 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
661 | 661 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
662 | 662 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
663 | 663 | // get all active payment methods |
664 | - $payment_methods = $EEM_Payment_Method->get_all_for_transaction( $this->checkout->transaction, EEM_Payment_Method::scope_cart ); |
|
665 | - foreach ( $payment_methods as $payment_method ) { |
|
666 | - if ( $payment_method instanceof EE_Payment_Method ) { |
|
667 | - $available_payment_methods[ $payment_method->slug() ] = $payment_method; |
|
664 | + $payment_methods = $EEM_Payment_Method->get_all_for_transaction($this->checkout->transaction, EEM_Payment_Method::scope_cart); |
|
665 | + foreach ($payment_methods as $payment_method) { |
|
666 | + if ($payment_method instanceof EE_Payment_Method) { |
|
667 | + $available_payment_methods[$payment_method->slug()] = $payment_method; |
|
668 | 668 | } |
669 | 669 | } |
670 | 670 | return $available_payment_methods; |
@@ -680,14 +680,14 @@ discard block |
||
680 | 680 | * @param array $available_payment_method_options |
681 | 681 | * @return \EE_Form_Section_Proper |
682 | 682 | */ |
683 | - private function _available_payment_method_inputs( $available_payment_method_options = array() ) { |
|
683 | + private function _available_payment_method_inputs($available_payment_method_options = array()) { |
|
684 | 684 | // generate inputs |
685 | 685 | return new EE_Form_Section_Proper( |
686 | 686 | array( |
687 | 687 | 'html_id' => 'ee-available-payment-method-inputs', |
688 | 688 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
689 | 689 | 'subsections' => array( |
690 | - '' => new EE_Radio_Button_Input ( |
|
690 | + '' => new EE_Radio_Button_Input( |
|
691 | 691 | $available_payment_method_options, |
692 | 692 | array( |
693 | 693 | 'html_name' => 'selected_method_of_payment', |
@@ -711,36 +711,36 @@ discard block |
||
711 | 711 | * @param EE_Payment_Method $payment_method |
712 | 712 | * @return \EE_Form_Section_Proper |
713 | 713 | */ |
714 | - private function _payment_method_billing_info( EE_Payment_Method $payment_method ) { |
|
714 | + private function _payment_method_billing_info(EE_Payment_Method $payment_method) { |
|
715 | 715 | $currently_selected = $this->checkout->selected_method_of_payment == $payment_method->slug() ? TRUE : FALSE; |
716 | 716 | // generate the billing form for payment method |
717 | - $billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method( $payment_method ) : new EE_Form_Section_HTML(); |
|
717 | + $billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method($payment_method) : new EE_Form_Section_HTML(); |
|
718 | 718 | $this->checkout->billing_form = $currently_selected ? $billing_form : $this->checkout->billing_form; |
719 | 719 | // it's all in the details |
720 | - $info_html = EEH_HTML::h3 ( __( 'Important information regarding your payment', 'event_espresso' ), '', 'spco-payment-method-hdr' ); |
|
720 | + $info_html = EEH_HTML::h3(__('Important information regarding your payment', 'event_espresso'), '', 'spco-payment-method-hdr'); |
|
721 | 721 | // add some info regarding the step, either from what's saved in the admin, or a default string depending on whether the PM has a billing form or not |
722 | - if ( $payment_method->description() ) { |
|
722 | + if ($payment_method->description()) { |
|
723 | 723 | $payment_method_info = $payment_method->description(); |
724 | - } elseif ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
725 | - $payment_method_info = sprintf( __( 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() ); |
|
724 | + } elseif ($billing_form instanceof EE_Billing_Info_Form) { |
|
725 | + $payment_method_info = sprintf(__('Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text()); |
|
726 | 726 | } else { |
727 | - $payment_method_info = sprintf( __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() ); |
|
727 | + $payment_method_info = sprintf(__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text()); |
|
728 | 728 | } |
729 | - $info_html .= EEH_HTML::p ( |
|
730 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info ), |
|
729 | + $info_html .= EEH_HTML::p( |
|
730 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info), |
|
731 | 731 | '', |
732 | 732 | 'spco-payment-method-desc ee-attention' |
733 | 733 | ); |
734 | 734 | |
735 | 735 | return new EE_Form_Section_Proper( |
736 | 736 | array( |
737 | - 'html_id' => 'spco-payment-method-info-' . $payment_method->slug(), |
|
737 | + 'html_id' => 'spco-payment-method-info-'.$payment_method->slug(), |
|
738 | 738 | 'html_class' => 'spco-payment-method-info-dv', |
739 | 739 | // only display the selected or default PM |
740 | 740 | 'html_style' => $currently_selected ? '' : 'display:none;', |
741 | 741 | 'layout_strategy' => new EE_Div_Per_Section_Layout(), |
742 | 742 | 'subsections' => array( |
743 | - 'info' => new EE_Form_Section_HTML( $info_html ), |
|
743 | + 'info' => new EE_Form_Section_HTML($info_html), |
|
744 | 744 | 'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML() |
745 | 745 | ) |
746 | 746 | ) |
@@ -758,12 +758,12 @@ discard block |
||
758 | 758 | */ |
759 | 759 | public function get_billing_form_html_for_payment_method() { |
760 | 760 | // how have they chosen to pay? |
761 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE ); |
|
761 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE); |
|
762 | 762 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
763 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
763 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
764 | 764 | return FALSE; |
765 | 765 | } |
766 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) { |
|
766 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
767 | 767 | EE_Error::add_success( |
768 | 768 | apply_filters( |
769 | 769 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
@@ -772,20 +772,20 @@ discard block |
||
772 | 772 | ); |
773 | 773 | } |
774 | 774 | // now generate billing form for selected method of payment |
775 | - $payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
775 | + $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
776 | 776 | // fill form with attendee info if applicable |
777 | - if ( $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) { |
|
778 | - $payment_method_billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() ); |
|
777 | + if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) { |
|
778 | + $payment_method_billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee()); |
|
779 | 779 | } |
780 | 780 | // and debug content |
781 | - if ( $payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
782 | - $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $payment_method_billing_form ); |
|
781 | + if ($payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) { |
|
782 | + $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($payment_method_billing_form); |
|
783 | 783 | } |
784 | 784 | $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper ? $payment_method_billing_form->get_html() : ''; |
785 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info )); |
|
785 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info)); |
|
786 | 786 | // localize validation rules for main form |
787 | 787 | $this->checkout->current_step->reg_form->localize_validation_rules(); |
788 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
788 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
789 | 789 | return TRUE; |
790 | 790 | } |
791 | 791 | |
@@ -798,15 +798,15 @@ discard block |
||
798 | 798 | * @param EE_Payment_Method $payment_method |
799 | 799 | * @return \EE_Billing_Info_Form |
800 | 800 | */ |
801 | - private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) { |
|
802 | - $billing_form = $payment_method->type_obj()->billing_form( $this->checkout->transaction, array( 'amount_owing' => $this->checkout->amount_owing ) ); |
|
803 | - if ( $billing_form instanceof EE_Billing_Info_Form ) { |
|
804 | - if ( EE_Registry::instance()->REQ->is_set( 'payment_method' )) { |
|
805 | - if ( apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false )) { |
|
801 | + private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) { |
|
802 | + $billing_form = $payment_method->type_obj()->billing_form($this->checkout->transaction, array('amount_owing' => $this->checkout->amount_owing)); |
|
803 | + if ($billing_form instanceof EE_Billing_Info_Form) { |
|
804 | + if (EE_Registry::instance()->REQ->is_set('payment_method')) { |
|
805 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
806 | 806 | EE_Error::add_success( |
807 | 807 | apply_filters( |
808 | 808 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
809 | - sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $payment_method->name() ) |
|
809 | + sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $payment_method->name()) |
|
810 | 810 | ) |
811 | 811 | ); |
812 | 812 | } |
@@ -831,27 +831,27 @@ discard block |
||
831 | 831 | * @param string $request_param |
832 | 832 | * @return NULL|string |
833 | 833 | */ |
834 | - private function _get_selected_method_of_payment( $required = FALSE, $request_param = 'selected_method_of_payment' ) { |
|
834 | + private function _get_selected_method_of_payment($required = FALSE, $request_param = 'selected_method_of_payment') { |
|
835 | 835 | // is selected_method_of_payment set in the request ? |
836 | - $selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, FALSE ); |
|
837 | - if ( $selected_method_of_payment ) { |
|
836 | + $selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, FALSE); |
|
837 | + if ($selected_method_of_payment) { |
|
838 | 838 | // sanitize it |
839 | - $selected_method_of_payment = is_array( $selected_method_of_payment ) ? array_shift( $selected_method_of_payment ) : $selected_method_of_payment; |
|
840 | - $selected_method_of_payment = sanitize_text_field( $selected_method_of_payment ); |
|
839 | + $selected_method_of_payment = is_array($selected_method_of_payment) ? array_shift($selected_method_of_payment) : $selected_method_of_payment; |
|
840 | + $selected_method_of_payment = sanitize_text_field($selected_method_of_payment); |
|
841 | 841 | // store it in the session so that it's available for all subsequent requests including AJAX |
842 | - $this->_save_selected_method_of_payment( $selected_method_of_payment ); |
|
842 | + $this->_save_selected_method_of_payment($selected_method_of_payment); |
|
843 | 843 | } else { |
844 | 844 | // or is is set in the session ? |
845 | - $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( 'selected_method_of_payment' ); |
|
845 | + $selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data('selected_method_of_payment'); |
|
846 | 846 | } |
847 | 847 | // do ya really really gotta have it? |
848 | - if ( empty( $selected_method_of_payment ) && $required ) { |
|
848 | + if (empty($selected_method_of_payment) && $required) { |
|
849 | 849 | EE_Error::add_error( |
850 | 850 | sprintf( |
851 | - __( 'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso' ), |
|
851 | + __('The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso'), |
|
852 | 852 | '<br/>', |
853 | 853 | '<br/>', |
854 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
854 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
855 | 855 | ), |
856 | 856 | __FILE__, __FUNCTION__, __LINE__ |
857 | 857 | ); |
@@ -877,37 +877,37 @@ discard block |
||
877 | 877 | * @return string |
878 | 878 | */ |
879 | 879 | public function switch_payment_method() { |
880 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
880 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
881 | 881 | return FALSE; |
882 | 882 | } |
883 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) { |
|
883 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) { |
|
884 | 884 | EE_Error::add_success( |
885 | 885 | apply_filters( |
886 | 886 | 'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', |
887 | - sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $this->checkout->payment_method->name() ) |
|
887 | + sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $this->checkout->payment_method->name()) |
|
888 | 888 | ) |
889 | 889 | ); |
890 | 890 | } |
891 | 891 | // generate billing form for selected method of payment if it hasn't been done already |
892 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
893 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
892 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
893 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
894 | 894 | } |
895 | 895 | // fill form with attendee info if applicable |
896 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) { |
|
897 | - $this->checkout->billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() ); |
|
896 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) { |
|
897 | + $this->checkout->billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee()); |
|
898 | 898 | } |
899 | 899 | // and debug content |
900 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
901 | - $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $this->checkout->billing_form ); |
|
900 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) { |
|
901 | + $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($this->checkout->billing_form); |
|
902 | 902 | } |
903 | 903 | // get html and validation rules for form |
904 | - if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) { |
|
905 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => $this->checkout->billing_form->get_html() )); |
|
904 | + if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) { |
|
905 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => $this->checkout->billing_form->get_html())); |
|
906 | 906 | // localize validation rules for main form |
907 | - $this->checkout->billing_form->localize_validation_rules( TRUE ); |
|
908 | - $this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() ); |
|
907 | + $this->checkout->billing_form->localize_validation_rules(TRUE); |
|
908 | + $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization()); |
|
909 | 909 | } else { |
910 | - $this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' )); |
|
910 | + $this->checkout->json_response->set_return_data(array('payment_method_info' => '')); |
|
911 | 911 | } |
912 | 912 | //prevents advancement to next step |
913 | 913 | $this->checkout->continue_reg = FALSE; |
@@ -922,12 +922,12 @@ discard block |
||
922 | 922 | */ |
923 | 923 | protected function _verify_payment_method_is_set() { |
924 | 924 | // generate billing form for selected method of payment if it hasn't been done already |
925 | - if ( empty( $this->checkout->selected_method_of_payment )) { |
|
925 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
926 | 926 | // how have they chosen to pay? |
927 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE ); |
|
927 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE); |
|
928 | 928 | } |
929 | 929 | // verify payment method |
930 | - if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) { |
|
930 | + if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) { |
|
931 | 931 | // get payment method for selected method of payment |
932 | 932 | $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment(); |
933 | 933 | } |
@@ -947,23 +947,23 @@ discard block |
||
947 | 947 | * @return void |
948 | 948 | */ |
949 | 949 | public function save_payer_details_via_ajax() { |
950 | - if ( ! $this->_verify_payment_method_is_set() ) { |
|
950 | + if ( ! $this->_verify_payment_method_is_set()) { |
|
951 | 951 | return; |
952 | 952 | } |
953 | 953 | // generate billing form for selected method of payment if it hasn't been done already |
954 | - if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
955 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
954 | + if ($this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
955 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
956 | 956 | } |
957 | 957 | // generate primary attendee from payer info if applicable |
958 | 958 | if ( ! $this->checkout->transaction_has_primary_registrant()) { |
959 | 959 | $attendee = $this->_create_attendee_from_request_data(); |
960 | - if ( $attendee instanceof EE_Attendee ) { |
|
961 | - foreach ( $this->checkout->transaction->registrations() as $registration ) { |
|
962 | - if ( $registration->is_primary_registrant() ) { |
|
960 | + if ($attendee instanceof EE_Attendee) { |
|
961 | + foreach ($this->checkout->transaction->registrations() as $registration) { |
|
962 | + if ($registration->is_primary_registrant()) { |
|
963 | 963 | $this->checkout->primary_attendee_obj = $attendee; |
964 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
965 | - $registration->set_attendee_id( $attendee->ID() ); |
|
966 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
964 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
965 | + $registration->set_attendee_id($attendee->ID()); |
|
966 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
967 | 967 | } |
968 | 968 | } |
969 | 969 | } |
@@ -976,56 +976,56 @@ discard block |
||
976 | 976 | * uses info from alternate GET or POST data (such as AJAX) to create a new attendee |
977 | 977 | * @return \EE_Attendee |
978 | 978 | */ |
979 | - protected function _create_attendee_from_request_data(){ |
|
979 | + protected function _create_attendee_from_request_data() { |
|
980 | 980 | // get State ID |
981 | - $STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : ''; |
|
982 | - if ( ! empty( $STA_ID )) { |
|
981 | + $STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : ''; |
|
982 | + if ( ! empty($STA_ID)) { |
|
983 | 983 | // can we get state object from name ? |
984 | - EE_Registry::instance()->load_model( 'State' ); |
|
985 | - $state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1), 'STA_ID' ); |
|
986 | - $STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID; |
|
984 | + EE_Registry::instance()->load_model('State'); |
|
985 | + $state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID'); |
|
986 | + $STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID; |
|
987 | 987 | } |
988 | 988 | // get Country ISO |
989 | - $CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : ''; |
|
990 | - if ( ! empty( $CNT_ISO )) { |
|
989 | + $CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : ''; |
|
990 | + if ( ! empty($CNT_ISO)) { |
|
991 | 991 | // can we get country object from name ? |
992 | - EE_Registry::instance()->load_model( 'Country' ); |
|
993 | - $country = EEM_Country::instance()->get_col( array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1), 'CNT_ISO' ); |
|
994 | - $CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO; |
|
992 | + EE_Registry::instance()->load_model('Country'); |
|
993 | + $country = EEM_Country::instance()->get_col(array(array('CNT_name' => $CNT_ISO), 'limit' => 1), 'CNT_ISO'); |
|
994 | + $CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO; |
|
995 | 995 | } |
996 | 996 | // grab attendee data |
997 | 997 | $attendee_data = array( |
998 | - 'ATT_fname' => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '', |
|
999 | - 'ATT_lname' => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '', |
|
1000 | - 'ATT_email' => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '', |
|
1001 | - 'ATT_address' => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '', |
|
1002 | - 'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '', |
|
1003 | - 'ATT_city' => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '', |
|
998 | + 'ATT_fname' => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '', |
|
999 | + 'ATT_lname' => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '', |
|
1000 | + 'ATT_email' => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '', |
|
1001 | + 'ATT_address' => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '', |
|
1002 | + 'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '', |
|
1003 | + 'ATT_city' => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '', |
|
1004 | 1004 | 'STA_ID' => $STA_ID, |
1005 | 1005 | 'CNT_ISO' => $CNT_ISO, |
1006 | - 'ATT_zip' => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '', |
|
1007 | - 'ATT_phone' => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '', |
|
1006 | + 'ATT_zip' => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '', |
|
1007 | + 'ATT_phone' => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '', |
|
1008 | 1008 | ); |
1009 | 1009 | // validate the email address since it is the most important piece of info |
1010 | - if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] != $_REQUEST['email'] ) { |
|
1011 | - EE_Error::add_error( __( 'An invalid email address was submitted.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1010 | + if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] != $_REQUEST['email']) { |
|
1011 | + EE_Error::add_error(__('An invalid email address was submitted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1012 | 1012 | } |
1013 | 1013 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1014 | - if ( ! empty( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_email'] ) ) { |
|
1015 | - $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array( |
|
1014 | + if ( ! empty($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_email'])) { |
|
1015 | + $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array( |
|
1016 | 1016 | 'ATT_fname' => $attendee_data['ATT_fname'], |
1017 | 1017 | 'ATT_lname' => $attendee_data['ATT_lname'], |
1018 | 1018 | 'ATT_email' => $attendee_data['ATT_email'] |
1019 | 1019 | )); |
1020 | - if ( $existing_attendee instanceof EE_Attendee ) { |
|
1020 | + if ($existing_attendee instanceof EE_Attendee) { |
|
1021 | 1021 | return $existing_attendee; |
1022 | 1022 | } |
1023 | 1023 | } |
1024 | 1024 | // no existing attendee? kk let's create a new one |
1025 | 1025 | // kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist |
1026 | - $attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email']; |
|
1027 | - $attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email']; |
|
1028 | - return EE_Attendee::new_instance( $attendee_data ); |
|
1026 | + $attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email']; |
|
1027 | + $attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email']; |
|
1028 | + return EE_Attendee::new_instance($attendee_data); |
|
1029 | 1029 | } |
1030 | 1030 | |
1031 | 1031 | |
@@ -1045,22 +1045,22 @@ discard block |
||
1045 | 1045 | */ |
1046 | 1046 | public function process_reg_step() { |
1047 | 1047 | // how have they chosen to pay? |
1048 | - $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment( TRUE ); |
|
1048 | + $this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment(TRUE); |
|
1049 | 1049 | // choose your own adventure based on method_of_payment |
1050 | - switch( $this->checkout->selected_method_of_payment ) { |
|
1050 | + switch ($this->checkout->selected_method_of_payment) { |
|
1051 | 1051 | |
1052 | 1052 | case 'events_sold_out' : |
1053 | 1053 | $this->checkout->redirect = TRUE; |
1054 | 1054 | $this->checkout->redirect_url = $this->checkout->cancel_page_url; |
1055 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1055 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1056 | 1056 | // mark this reg step as completed |
1057 | 1057 | $this->set_completed(); |
1058 | 1058 | return FALSE; |
1059 | 1059 | break; |
1060 | 1060 | |
1061 | 1061 | case 'payments_closed' : |
1062 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false ) ) { |
|
1063 | - EE_Error::add_success( __( 'no payment required at this time.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1062 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false)) { |
|
1063 | + EE_Error::add_success(__('no payment required at this time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1064 | 1064 | } |
1065 | 1065 | // mark this reg step as completed |
1066 | 1066 | $this->set_completed(); |
@@ -1068,8 +1068,8 @@ discard block |
||
1068 | 1068 | break; |
1069 | 1069 | |
1070 | 1070 | case 'no_payment_required' : |
1071 | - if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false ) ) { |
|
1072 | - EE_Error::add_success( __( 'no payment required.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1071 | + if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false)) { |
|
1072 | + EE_Error::add_success(__('no payment required.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1073 | 1073 | } |
1074 | 1074 | // mark this reg step as completed |
1075 | 1075 | $this->set_completed(); |
@@ -1078,9 +1078,9 @@ discard block |
||
1078 | 1078 | |
1079 | 1079 | default: |
1080 | 1080 | $payment_successful = $this->_process_payment(); |
1081 | - if ( $payment_successful ) { |
|
1081 | + if ($payment_successful) { |
|
1082 | 1082 | $this->checkout->continue_reg = true; |
1083 | - $this->_maybe_set_completed( $this->checkout->payment_method ); |
|
1083 | + $this->_maybe_set_completed($this->checkout->payment_method); |
|
1084 | 1084 | } else { |
1085 | 1085 | $this->checkout->continue_reg = false; |
1086 | 1086 | } |
@@ -1098,8 +1098,8 @@ discard block |
||
1098 | 1098 | * @param \EE_Payment_Method $payment_method |
1099 | 1099 | * @return void |
1100 | 1100 | */ |
1101 | - protected function _maybe_set_completed( EE_Payment_Method $payment_method ) { |
|
1102 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1101 | + protected function _maybe_set_completed(EE_Payment_Method $payment_method) { |
|
1102 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1103 | 1103 | case EE_PMT_Base::offsite : |
1104 | 1104 | break; |
1105 | 1105 | case EE_PMT_Base::onsite : |
@@ -1122,15 +1122,15 @@ discard block |
||
1122 | 1122 | public function update_reg_step() { |
1123 | 1123 | $success = TRUE; |
1124 | 1124 | // if payment required |
1125 | - if ( $this->checkout->transaction->total() > 0 ) { |
|
1126 | - do_action ('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction ); |
|
1125 | + if ($this->checkout->transaction->total() > 0) { |
|
1126 | + do_action('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction); |
|
1127 | 1127 | // attempt payment via payment method |
1128 | 1128 | $success = $this->process_reg_step(); |
1129 | 1129 | } |
1130 | - if ( $success && ! $this->checkout->redirect ) { |
|
1131 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $this->checkout->transaction->ID() ); |
|
1130 | + if ($success && ! $this->checkout->redirect) { |
|
1131 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($this->checkout->transaction->ID()); |
|
1132 | 1132 | // set return URL |
1133 | - $this->checkout->redirect_url = add_query_arg( array( 'e_reg_url_link' => $this->checkout->reg_url_link ), $this->checkout->thank_you_page_url ); |
|
1133 | + $this->checkout->redirect_url = add_query_arg(array('e_reg_url_link' => $this->checkout->reg_url_link), $this->checkout->thank_you_page_url); |
|
1134 | 1134 | } |
1135 | 1135 | return $success; |
1136 | 1136 | } |
@@ -1150,24 +1150,24 @@ discard block |
||
1150 | 1150 | // clear any previous errors related to not selecting a payment method |
1151 | 1151 | // EE_Error::overwrite_errors(); |
1152 | 1152 | // ya gotta make a choice man |
1153 | - if ( empty( $this->checkout->selected_method_of_payment )) { |
|
1154 | - $this->checkout->json_response->set_plz_select_method_of_payment( __( 'Please select a method of payment before proceeding.', 'event_espresso' )); |
|
1153 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1154 | + $this->checkout->json_response->set_plz_select_method_of_payment(__('Please select a method of payment before proceeding.', 'event_espresso')); |
|
1155 | 1155 | return FALSE; |
1156 | 1156 | } |
1157 | 1157 | // get EE_Payment_Method object |
1158 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1158 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1159 | 1159 | return FALSE; |
1160 | 1160 | } |
1161 | 1161 | // setup billing form |
1162 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1163 | - $this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method ); |
|
1162 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1163 | + $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method); |
|
1164 | 1164 | // bad billing form ? |
1165 | - if ( ! $this->_billing_form_is_valid() ) { |
|
1165 | + if ( ! $this->_billing_form_is_valid()) { |
|
1166 | 1166 | return FALSE; |
1167 | 1167 | } |
1168 | 1168 | } |
1169 | 1169 | // ensure primary registrant has been fully processed |
1170 | - if ( ! $this->_setup_primary_registrant_prior_to_payment() ) { |
|
1170 | + if ( ! $this->_setup_primary_registrant_prior_to_payment()) { |
|
1171 | 1171 | return FALSE; |
1172 | 1172 | } |
1173 | 1173 | /** @type EE_Transaction_Processor $transaction_processor */ |
@@ -1175,24 +1175,24 @@ discard block |
||
1175 | 1175 | // in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved |
1176 | 1176 | //$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params ); |
1177 | 1177 | // attempt payment |
1178 | - $payment = $this->_attempt_payment( $this->checkout->payment_method ); |
|
1178 | + $payment = $this->_attempt_payment($this->checkout->payment_method); |
|
1179 | 1179 | // process results |
1180 | - $payment = $this->_validate_payment( $payment ); |
|
1181 | - $payment = $this->_post_payment_processing( $payment ); |
|
1180 | + $payment = $this->_validate_payment($payment); |
|
1181 | + $payment = $this->_post_payment_processing($payment); |
|
1182 | 1182 | // verify payment |
1183 | - if ( $payment instanceof EE_Payment ) { |
|
1183 | + if ($payment instanceof EE_Payment) { |
|
1184 | 1184 | // store that for later |
1185 | 1185 | $this->checkout->payment = $payment; |
1186 | 1186 | /** @type EE_Transaction_Processor $transaction_processor */ |
1187 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1187 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1188 | 1188 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1189 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1190 | - if ( $payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending ) { |
|
1189 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1190 | + if ($payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending) { |
|
1191 | 1191 | return true; |
1192 | 1192 | } else { |
1193 | 1193 | return false; |
1194 | 1194 | } |
1195 | - } else if ( $payment === true ) { |
|
1195 | + } else if ($payment === true) { |
|
1196 | 1196 | // please note that offline payment methods will NOT make a payment, |
1197 | 1197 | // but instead just mark themselves as the PMD_ID on the transaction, and return true |
1198 | 1198 | $this->checkout->payment = $payment; |
@@ -1211,10 +1211,10 @@ discard block |
||
1211 | 1211 | * @return bool |
1212 | 1212 | */ |
1213 | 1213 | public function redirect_form() { |
1214 | - $payment_method_billing_info = $this->_payment_method_billing_info( $this->_get_payment_method_for_selected_method_of_payment() ); |
|
1214 | + $payment_method_billing_info = $this->_payment_method_billing_info($this->_get_payment_method_for_selected_method_of_payment()); |
|
1215 | 1215 | $html = $payment_method_billing_info->get_html_and_js(); |
1216 | 1216 | $html .= $this->checkout->redirect_form; |
1217 | - EE_Registry::instance()->REQ->add_output( $html ); |
|
1217 | + EE_Registry::instance()->REQ->add_output($html); |
|
1218 | 1218 | return TRUE; |
1219 | 1219 | } |
1220 | 1220 | |
@@ -1227,36 +1227,36 @@ discard block |
||
1227 | 1227 | * @return bool |
1228 | 1228 | */ |
1229 | 1229 | private function _billing_form_is_valid() { |
1230 | - if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) { |
|
1230 | + if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) { |
|
1231 | 1231 | return TRUE; |
1232 | 1232 | } |
1233 | - if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) { |
|
1234 | - if ( $this->checkout->billing_form->was_submitted() ) { |
|
1233 | + if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) { |
|
1234 | + if ($this->checkout->billing_form->was_submitted()) { |
|
1235 | 1235 | $this->checkout->billing_form->receive_form_submission(); |
1236 | - if ( $this->checkout->billing_form->is_valid() ) { |
|
1236 | + if ($this->checkout->billing_form->is_valid()) { |
|
1237 | 1237 | return TRUE; |
1238 | 1238 | } |
1239 | 1239 | $validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated(); |
1240 | 1240 | $error_strings = array(); |
1241 | - foreach( $validation_errors as $validation_error ){ |
|
1242 | - if( $validation_error instanceof EE_Validation_Error ){ |
|
1241 | + foreach ($validation_errors as $validation_error) { |
|
1242 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1243 | 1243 | $form_section = $validation_error->get_form_section(); |
1244 | - if( $form_section instanceof EE_Form_Input_Base ){ |
|
1244 | + if ($form_section instanceof EE_Form_Input_Base) { |
|
1245 | 1245 | $label = $form_section->html_label_text(); |
1246 | - }elseif( $form_section instanceof EE_Form_Section_Base ){ |
|
1246 | + }elseif ($form_section instanceof EE_Form_Section_Base) { |
|
1247 | 1247 | $label = $form_section->name(); |
1248 | - }else{ |
|
1249 | - $label = __( 'Validation Error', 'event_espresso' ); |
|
1248 | + } else { |
|
1249 | + $label = __('Validation Error', 'event_espresso'); |
|
1250 | 1250 | } |
1251 | - $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage() ); |
|
1251 | + $error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage()); |
|
1252 | 1252 | } |
1253 | 1253 | } |
1254 | - EE_Error::add_error( sprintf( __( 'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso' ), '<br/>', implode( '<br/>', $error_strings ) ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1254 | + EE_Error::add_error(sprintf(__('One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso'), '<br/>', implode('<br/>', $error_strings)), __FILE__, __FUNCTION__, __LINE__); |
|
1255 | 1255 | } else { |
1256 | - EE_Error::add_error( __( 'The billing form was not submitted or something prevented it\'s submission.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1256 | + EE_Error::add_error(__('The billing form was not submitted or something prevented it\'s submission.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1257 | 1257 | } |
1258 | 1258 | } else { |
1259 | - EE_Error::add_error( __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1259 | + EE_Error::add_error(__('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1260 | 1260 | } |
1261 | 1261 | return FALSE; |
1262 | 1262 | } |
@@ -1274,9 +1274,9 @@ discard block |
||
1274 | 1274 | */ |
1275 | 1275 | private function _setup_primary_registrant_prior_to_payment() { |
1276 | 1276 | // check if transaction has a primary registrant and that it has a related Attendee object |
1277 | - if ( ! $this->checkout->transaction_has_primary_registrant() ) { |
|
1277 | + if ( ! $this->checkout->transaction_has_primary_registrant()) { |
|
1278 | 1278 | // need to at least gather some primary registrant data before attempting payment |
1279 | - if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form() ) { |
|
1279 | + if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form()) { |
|
1280 | 1280 | return FALSE; |
1281 | 1281 | } |
1282 | 1282 | } |
@@ -1284,13 +1284,13 @@ discard block |
||
1284 | 1284 | // grab the primary_registration object |
1285 | 1285 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1286 | 1286 | /** @type EE_Transaction_Processor $transaction_processor */ |
1287 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1287 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1288 | 1288 | // at this point we'll consider a TXN to not have been failed |
1289 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1289 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1290 | 1290 | // save the TXN ( which clears cached copy of primary_registration) |
1291 | 1291 | $this->checkout->transaction->save(); |
1292 | 1292 | // grab TXN ID and save it to the primary_registration |
1293 | - $primary_registration->set_transaction_id( $this->checkout->transaction->ID() ); |
|
1293 | + $primary_registration->set_transaction_id($this->checkout->transaction->ID()); |
|
1294 | 1294 | // save what we have so far |
1295 | 1295 | $primary_registration->save(); |
1296 | 1296 | return TRUE; |
@@ -1307,41 +1307,41 @@ discard block |
||
1307 | 1307 | private function _capture_primary_registration_data_from_billing_form() { |
1308 | 1308 | // convert billing form data into an attendee |
1309 | 1309 | $this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data(); |
1310 | - if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) { |
|
1310 | + if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) { |
|
1311 | 1311 | EE_Error::add_error( |
1312 | 1312 | sprintf( |
1313 | - __( 'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1313 | + __('The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1314 | 1314 | '<br/>', |
1315 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1315 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1316 | 1316 | ), __FILE__, __FUNCTION__, __LINE__ |
1317 | 1317 | ); |
1318 | 1318 | return FALSE; |
1319 | 1319 | } |
1320 | 1320 | $primary_registration = $this->checkout->transaction->primary_registration(); |
1321 | - if ( ! $primary_registration instanceof EE_Registration ) { |
|
1321 | + if ( ! $primary_registration instanceof EE_Registration) { |
|
1322 | 1322 | EE_Error::add_error( |
1323 | 1323 | sprintf( |
1324 | - __( 'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1324 | + __('The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1325 | 1325 | '<br/>', |
1326 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1326 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1327 | 1327 | ), __FILE__, __FUNCTION__, __LINE__ |
1328 | 1328 | ); |
1329 | 1329 | return FALSE; |
1330 | 1330 | } |
1331 | - if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) instanceof EE_Attendee ) { |
|
1331 | + if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') instanceof EE_Attendee) { |
|
1332 | 1332 | EE_Error::add_error( |
1333 | 1333 | sprintf( |
1334 | - __( 'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1334 | + __('The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1335 | 1335 | '<br/>', |
1336 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1336 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1337 | 1337 | ), __FILE__, __FUNCTION__, __LINE__ |
1338 | 1338 | ); |
1339 | 1339 | return FALSE; |
1340 | 1340 | } |
1341 | 1341 | /** @type EE_Registration_Processor $registration_processor */ |
1342 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1342 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1343 | 1343 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1344 | - $registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration ); |
|
1344 | + $registration_processor->toggle_incomplete_registration_status_to_default($primary_registration); |
|
1345 | 1345 | |
1346 | 1346 | return TRUE; |
1347 | 1347 | } |
@@ -1357,35 +1357,35 @@ discard block |
||
1357 | 1357 | */ |
1358 | 1358 | private function _get_payment_method_for_selected_method_of_payment() { |
1359 | 1359 | // get EE_Payment_Method object |
1360 | - if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] )) { |
|
1361 | - $payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ]; |
|
1360 | + if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) { |
|
1361 | + $payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment]; |
|
1362 | 1362 | } else { |
1363 | 1363 | // load EEM_Payment_Method |
1364 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
1364 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
1365 | 1365 | /** @type EEM_Payment_Method $EEM_Payment_Method */ |
1366 | 1366 | $EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method; |
1367 | - $payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment ); |
|
1367 | + $payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment); |
|
1368 | 1368 | } |
1369 | 1369 | // verify $payment_method |
1370 | - if ( ! $payment_method instanceof EE_Payment_Method ) { |
|
1370 | + if ( ! $payment_method instanceof EE_Payment_Method) { |
|
1371 | 1371 | // not a payment |
1372 | 1372 | EE_Error::add_error( |
1373 | 1373 | sprintf( |
1374 | - __( 'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1374 | + __('The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1375 | 1375 | '<br/>', |
1376 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1376 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1377 | 1377 | ), __FILE__, __FUNCTION__, __LINE__ |
1378 | 1378 | ); |
1379 | 1379 | return NULL; |
1380 | 1380 | } |
1381 | 1381 | // and verify it has a valid Payment_Method Type object |
1382 | - if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) { |
|
1382 | + if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) { |
|
1383 | 1383 | // not a payment |
1384 | 1384 | EE_Error::add_error( |
1385 | 1385 | sprintf( |
1386 | - __( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1386 | + __('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1387 | 1387 | '<br/>', |
1388 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1388 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1389 | 1389 | ), __FILE__, __FUNCTION__, __LINE__ |
1390 | 1390 | ); |
1391 | 1391 | return NULL; |
@@ -1404,30 +1404,30 @@ discard block |
||
1404 | 1404 | * @type EE_Payment_Method $payment_method |
1405 | 1405 | * @return mixed EE_Payment | boolean |
1406 | 1406 | */ |
1407 | - private function _attempt_payment( EE_Payment_Method $payment_method ) { |
|
1408 | - $payment =NULL; |
|
1407 | + private function _attempt_payment(EE_Payment_Method $payment_method) { |
|
1408 | + $payment = NULL; |
|
1409 | 1409 | $this->checkout->transaction->save(); |
1410 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1411 | - if ( ! $payment_processor instanceof EE_Payment_Processor ) { |
|
1410 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1411 | + if ( ! $payment_processor instanceof EE_Payment_Processor) { |
|
1412 | 1412 | return FALSE; |
1413 | 1413 | } |
1414 | 1414 | try { |
1415 | - $payment_processor->set_revisit( $this->checkout->revisit ); |
|
1415 | + $payment_processor->set_revisit($this->checkout->revisit); |
|
1416 | 1416 | // generate payment object |
1417 | 1417 | $payment = $payment_processor->process_payment( |
1418 | 1418 | $payment_method, |
1419 | 1419 | $this->checkout->transaction, |
1420 | 1420 | $this->checkout->amount_owing, |
1421 | 1421 | $this->checkout->billing_form, |
1422 | - $this->_get_return_url( $payment_method ), |
|
1422 | + $this->_get_return_url($payment_method), |
|
1423 | 1423 | 'CART', |
1424 | 1424 | $this->checkout->admin_request, |
1425 | 1425 | TRUE, |
1426 | 1426 | $this->reg_step_url() |
1427 | 1427 | ); |
1428 | 1428 | |
1429 | - } catch( Exception $e ) { |
|
1430 | - $this->_handle_payment_processor_exception( $e ); |
|
1429 | + } catch (Exception $e) { |
|
1430 | + $this->_handle_payment_processor_exception($e); |
|
1431 | 1431 | } |
1432 | 1432 | return $payment; |
1433 | 1433 | } |
@@ -1441,12 +1441,12 @@ discard block |
||
1441 | 1441 | * @param \Exception $e |
1442 | 1442 | * @return void |
1443 | 1443 | */ |
1444 | - protected function _handle_payment_processor_exception( Exception $e ) { |
|
1444 | + protected function _handle_payment_processor_exception(Exception $e) { |
|
1445 | 1445 | EE_Error::add_error( |
1446 | 1446 | sprintf( |
1447 | - __( 'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso' ), |
|
1447 | + __('The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso'), |
|
1448 | 1448 | '<br/>', |
1449 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ), |
|
1449 | + EE_Registry::instance()->CFG->organization->get_pretty('email'), |
|
1450 | 1450 | $e->getMessage(), |
1451 | 1451 | $e->getFile(), |
1452 | 1452 | $e->getLine() |
@@ -1463,9 +1463,9 @@ discard block |
||
1463 | 1463 | * @param \EE_Payment_Method $payment_method |
1464 | 1464 | * @return string |
1465 | 1465 | */ |
1466 | - protected function _get_return_url( EE_Payment_Method $payment_method ) { |
|
1466 | + protected function _get_return_url(EE_Payment_Method $payment_method) { |
|
1467 | 1467 | $return_url = ''; |
1468 | - switch ( $payment_method->type_obj()->payment_occurs() ) { |
|
1468 | + switch ($payment_method->type_obj()->payment_occurs()) { |
|
1469 | 1469 | |
1470 | 1470 | case EE_PMT_Base::offsite : |
1471 | 1471 | $return_url = add_query_arg( |
@@ -1496,18 +1496,18 @@ discard block |
||
1496 | 1496 | * @param EE_Payment $payment |
1497 | 1497 | * @return EE_Payment | FALSE |
1498 | 1498 | */ |
1499 | - private function _validate_payment( $payment = NULL ) { |
|
1500 | - if ( $this->checkout->payment_method->is_off_line() ) { |
|
1499 | + private function _validate_payment($payment = NULL) { |
|
1500 | + if ($this->checkout->payment_method->is_off_line()) { |
|
1501 | 1501 | return TRUE; |
1502 | 1502 | } |
1503 | 1503 | // verify payment object |
1504 | - if ( ! $payment instanceof EE_Payment ) { |
|
1504 | + if ( ! $payment instanceof EE_Payment) { |
|
1505 | 1505 | // not a payment |
1506 | 1506 | EE_Error::add_error( |
1507 | 1507 | sprintf( |
1508 | - __( 'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ), |
|
1508 | + __('A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'), |
|
1509 | 1509 | '<br/>', |
1510 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1510 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1511 | 1511 | ), __FILE__, __FUNCTION__, __LINE__ |
1512 | 1512 | ); |
1513 | 1513 | return FALSE; |
@@ -1524,23 +1524,23 @@ discard block |
||
1524 | 1524 | * @param EE_Payment $payment |
1525 | 1525 | * @return bool |
1526 | 1526 | */ |
1527 | - private function _post_payment_processing( $payment = NULL ) { |
|
1527 | + private function _post_payment_processing($payment = NULL) { |
|
1528 | 1528 | // On-Site payment? |
1529 | - if ( $this->checkout->payment_method->is_on_site() ) { |
|
1530 | - if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite )) { |
|
1529 | + if ($this->checkout->payment_method->is_on_site()) { |
|
1530 | + if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) { |
|
1531 | 1531 | //$this->_setup_redirect_for_next_step(); |
1532 | 1532 | $this->checkout->continue_reg = false; |
1533 | 1533 | } |
1534 | 1534 | // Off-Site payment? |
1535 | - } else if ( $this->checkout->payment_method->is_off_site() ) { |
|
1535 | + } else if ($this->checkout->payment_method->is_off_site()) { |
|
1536 | 1536 | // if a payment object was made and it specifies a redirect url, then we'll setup that redirect info |
1537 | - if ( $payment instanceof EE_Payment && $payment->redirect_url() ){ |
|
1538 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' ); |
|
1537 | + if ($payment instanceof EE_Payment && $payment->redirect_url()) { |
|
1538 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()'); |
|
1539 | 1539 | $this->checkout->redirect = TRUE; |
1540 | 1540 | $this->checkout->redirect_form = $payment->redirect_form(); |
1541 | - $this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' ); |
|
1541 | + $this->checkout->redirect_url = $this->reg_step_url('redirect_form'); |
|
1542 | 1542 | // set JSON response |
1543 | - $this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form ); |
|
1543 | + $this->checkout->json_response->set_redirect_form($this->checkout->redirect_form); |
|
1544 | 1544 | // set cron job for finalizing the TXN |
1545 | 1545 | // in case the user does not return from the off-site gateway |
1546 | 1546 | EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check( |
@@ -1548,21 +1548,21 @@ discard block |
||
1548 | 1548 | $this->checkout->transaction->ID() |
1549 | 1549 | ); |
1550 | 1550 | // and lastly, let's bump the payment status to pending |
1551 | - $payment->set_status( EEM_Payment::status_id_pending ); |
|
1551 | + $payment->set_status(EEM_Payment::status_id_pending); |
|
1552 | 1552 | $payment->save(); |
1553 | 1553 | } else { |
1554 | 1554 | // not a payment |
1555 | 1555 | $this->checkout->continue_reg = false; |
1556 | 1556 | EE_Error::add_error( |
1557 | 1557 | sprintf( |
1558 | - __( 'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1558 | + __('It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1559 | 1559 | '<br/>', |
1560 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1560 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1561 | 1561 | ), __FILE__, __FUNCTION__, __LINE__ |
1562 | 1562 | ); |
1563 | 1563 | } |
1564 | 1564 | // Off-Line payment? |
1565 | - } else if ( $payment === TRUE ) { |
|
1565 | + } else if ($payment === TRUE) { |
|
1566 | 1566 | //$this->_setup_redirect_for_next_step(); |
1567 | 1567 | return TRUE; |
1568 | 1568 | } else { |
@@ -1598,65 +1598,65 @@ discard block |
||
1598 | 1598 | * @return bool |
1599 | 1599 | * @throws \EE_Error |
1600 | 1600 | */ |
1601 | - private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) { |
|
1601 | + private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) { |
|
1602 | 1602 | // off-line payment? carry on |
1603 | - if ( $payment_occurs == EE_PMT_Base::offline ) { |
|
1603 | + if ($payment_occurs == EE_PMT_Base::offline) { |
|
1604 | 1604 | return true; |
1605 | 1605 | } |
1606 | 1606 | // verify payment validity |
1607 | - if ( $payment instanceof EE_Payment ) { |
|
1608 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' ); |
|
1607 | + if ($payment instanceof EE_Payment) { |
|
1608 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()'); |
|
1609 | 1609 | $msg = $payment->gateway_response(); |
1610 | 1610 | // check results |
1611 | - switch ( $payment->status() ) { |
|
1611 | + switch ($payment->status()) { |
|
1612 | 1612 | |
1613 | 1613 | // good payment |
1614 | 1614 | case EEM_Payment::status_id_approved : |
1615 | - EE_Error::add_success( __( 'Your payment was processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1615 | + EE_Error::add_success(__('Your payment was processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1616 | 1616 | return TRUE; |
1617 | 1617 | break; |
1618 | 1618 | |
1619 | 1619 | // slow payment |
1620 | 1620 | case EEM_Payment::status_id_pending : |
1621 | - if ( empty( $msg )) { |
|
1622 | - $msg = __( 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso' ); |
|
1621 | + if (empty($msg)) { |
|
1622 | + $msg = __('Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso'); |
|
1623 | 1623 | } |
1624 | - EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1624 | + EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1625 | 1625 | return TRUE; |
1626 | 1626 | break; |
1627 | 1627 | |
1628 | 1628 | // don't wanna payment |
1629 | 1629 | case EEM_Payment::status_id_cancelled : |
1630 | - if ( empty( $msg )) { |
|
1630 | + if (empty($msg)) { |
|
1631 | 1631 | $msg = _n( |
1632 | 1632 | 'Payment cancelled. Please try again.', |
1633 | 1633 | 'Payment cancelled. Please try again or select another method of payment.', |
1634 | - count( $this->checkout->available_payment_methods ), |
|
1634 | + count($this->checkout->available_payment_methods), |
|
1635 | 1635 | 'event_espresso' |
1636 | 1636 | ); |
1637 | 1637 | } |
1638 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1638 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1639 | 1639 | return FALSE; |
1640 | 1640 | break; |
1641 | 1641 | |
1642 | 1642 | // not enough payment |
1643 | 1643 | case EEM_Payment::status_id_declined : |
1644 | - if ( empty( $msg )) { |
|
1644 | + if (empty($msg)) { |
|
1645 | 1645 | $msg = _n( |
1646 | 1646 | 'We\'re sorry but your payment was declined. Please try again.', |
1647 | 1647 | 'We\'re sorry but your payment was declined. Please try again or select another method of payment.', |
1648 | - count( $this->checkout->available_payment_methods ), |
|
1648 | + count($this->checkout->available_payment_methods), |
|
1649 | 1649 | 'event_espresso' |
1650 | 1650 | ); |
1651 | 1651 | } |
1652 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1652 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1653 | 1653 | return FALSE; |
1654 | 1654 | break; |
1655 | 1655 | |
1656 | 1656 | // bad payment |
1657 | 1657 | case EEM_Payment::status_id_failed : |
1658 | - if ( ! empty( $msg ) ) { |
|
1659 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1658 | + if ( ! empty($msg)) { |
|
1659 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1660 | 1660 | return false; |
1661 | 1661 | } |
1662 | 1662 | // default to error below |
@@ -1666,14 +1666,14 @@ discard block |
||
1666 | 1666 | } |
1667 | 1667 | // off-site payment gateway responses are too unreliable, so let's just assume that |
1668 | 1668 | // the payment processing is just running slower than the registrant's request |
1669 | - if ( $payment_occurs == EE_PMT_Base::offsite ) { |
|
1669 | + if ($payment_occurs == EE_PMT_Base::offsite) { |
|
1670 | 1670 | return true; |
1671 | 1671 | } |
1672 | 1672 | EE_Error::add_error( |
1673 | 1673 | sprintf( |
1674 | - __( 'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ), |
|
1674 | + __('Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'), |
|
1675 | 1675 | '<br/>', |
1676 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1676 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1677 | 1677 | ), |
1678 | 1678 | __FILE__, __FUNCTION__, __LINE__ |
1679 | 1679 | ); |
@@ -1706,13 +1706,13 @@ discard block |
||
1706 | 1706 | public function process_gateway_response() { |
1707 | 1707 | $payment = null; |
1708 | 1708 | // how have they chosen to pay? |
1709 | - $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true ); |
|
1709 | + $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true); |
|
1710 | 1710 | // get EE_Payment_Method object |
1711 | - if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) { |
|
1711 | + if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) { |
|
1712 | 1712 | $this->checkout->continue_reg = false; |
1713 | 1713 | return false; |
1714 | 1714 | } |
1715 | - if ( ! $this->checkout->payment_method->is_off_site() ) { |
|
1715 | + if ( ! $this->checkout->payment_method->is_off_site()) { |
|
1716 | 1716 | return false; |
1717 | 1717 | } |
1718 | 1718 | $this->_validate_offsite_return(); |
@@ -1726,23 +1726,23 @@ discard block |
||
1726 | 1726 | // true |
1727 | 1727 | //); |
1728 | 1728 | // verify TXN |
1729 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
1729 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1730 | 1730 | $gateway = $this->checkout->payment_method->type_obj()->get_gateway(); |
1731 | - if ( ! $gateway instanceof EE_Offsite_Gateway ) { |
|
1731 | + if ( ! $gateway instanceof EE_Offsite_Gateway) { |
|
1732 | 1732 | $this->checkout->continue_reg = false; |
1733 | 1733 | return false; |
1734 | 1734 | } |
1735 | - $payment = $this->_process_off_site_payment( $gateway ); |
|
1736 | - $payment = $this->_process_cancelled_payments( $payment ); |
|
1737 | - $payment = $this->_validate_payment( $payment ); |
|
1735 | + $payment = $this->_process_off_site_payment($gateway); |
|
1736 | + $payment = $this->_process_cancelled_payments($payment); |
|
1737 | + $payment = $this->_validate_payment($payment); |
|
1738 | 1738 | // if payment was not declined by the payment gateway or cancelled by the registrant |
1739 | - if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) { |
|
1739 | + if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) { |
|
1740 | 1740 | //$this->_setup_redirect_for_next_step(); |
1741 | 1741 | // store that for later |
1742 | 1742 | $this->checkout->payment = $payment; |
1743 | 1743 | // mark this reg step as completed, as long as gateway doesn't use a separate IPN request, |
1744 | 1744 | // because we will complete this step during the IPN processing then |
1745 | - if ( $gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request() ) { |
|
1745 | + if ($gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request()) { |
|
1746 | 1746 | $this->set_completed(); |
1747 | 1747 | } |
1748 | 1748 | return true; |
@@ -1765,19 +1765,19 @@ discard block |
||
1765 | 1765 | * @return bool |
1766 | 1766 | */ |
1767 | 1767 | private function _validate_offsite_return() { |
1768 | - $TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 ); |
|
1769 | - if ( $TXN_ID != $this->checkout->transaction->ID() ) { |
|
1768 | + $TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0); |
|
1769 | + if ($TXN_ID != $this->checkout->transaction->ID()) { |
|
1770 | 1770 | // Houston... we might have a problem |
1771 | 1771 | $invalid_TXN = false; |
1772 | 1772 | // first gather some info |
1773 | - $valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID ); |
|
1773 | + $valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID); |
|
1774 | 1774 | $primary_registrant = $valid_TXN instanceof EE_Transaction ? $valid_TXN->primary_registration() : null; |
1775 | 1775 | // let's start by retrieving the cart for this TXN |
1776 | - $cart = EE_Cart::get_cart_from_txn( $this->checkout->transaction ); |
|
1777 | - if ( $cart instanceof EE_Cart ) { |
|
1776 | + $cart = EE_Cart::get_cart_from_txn($this->checkout->transaction); |
|
1777 | + if ($cart instanceof EE_Cart) { |
|
1778 | 1778 | // verify that the current cart has tickets |
1779 | 1779 | $tickets = $cart->get_tickets(); |
1780 | - if ( empty( $tickets ) ) { |
|
1780 | + if (empty($tickets)) { |
|
1781 | 1781 | $invalid_TXN = true; |
1782 | 1782 | } |
1783 | 1783 | } else { |
@@ -1785,39 +1785,39 @@ discard block |
||
1785 | 1785 | } |
1786 | 1786 | $valid_TXN_SID = $primary_registrant instanceof EE_Registration ? $primary_registrant->session_ID() : null; |
1787 | 1787 | // validate current Session ID and compare against valid TXN session ID |
1788 | - if ( EE_Session::instance()->id() === null ) { |
|
1788 | + if (EE_Session::instance()->id() === null) { |
|
1789 | 1789 | $invalid_TXN = true; |
1790 | - } else if ( EE_Session::instance()->id() === $valid_TXN_SID ) { |
|
1790 | + } else if (EE_Session::instance()->id() === $valid_TXN_SID) { |
|
1791 | 1791 | // WARNING !!! |
1792 | 1792 | // this could be PayPal sending back duplicate requests (ya they do that) |
1793 | 1793 | // or it **could** mean someone is simply registering AGAIN after having just done so |
1794 | 1794 | // so now we need to determine if this current TXN looks valid or not |
1795 | 1795 | /** @type EE_Transaction_Processor $transaction_processor */ |
1796 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1796 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1797 | 1797 | // has this step even been started ? |
1798 | - if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false ) |
|
1798 | + if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false) |
|
1799 | 1799 | ) { |
1800 | 1800 | // really? you're half way through this reg step, but you never started it ? |
1801 | 1801 | $invalid_TXN = true; |
1802 | 1802 | } |
1803 | 1803 | } |
1804 | - if ( $invalid_TXN ) { |
|
1804 | + if ($invalid_TXN) { |
|
1805 | 1805 | // is the valid TXN completed ? |
1806 | - if ( $valid_TXN instanceof EE_Transaction ) { |
|
1806 | + if ($valid_TXN instanceof EE_Transaction) { |
|
1807 | 1807 | /** @type EE_Transaction_Processor $transaction_processor */ |
1808 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1808 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1809 | 1809 | // has this step even been started ? |
1810 | - $reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() ); |
|
1811 | - if ( $reg_step_completed !== false && $reg_step_completed !== true ) { |
|
1810 | + $reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug()); |
|
1811 | + if ($reg_step_completed !== false && $reg_step_completed !== true) { |
|
1812 | 1812 | // so it **looks** like this is a double request from PayPal |
1813 | 1813 | // so let's try to pick up where we left off |
1814 | 1814 | $this->checkout->transaction = $valid_TXN; |
1815 | - $this->checkout->refresh_all_entities( true ); |
|
1815 | + $this->checkout->refresh_all_entities(true); |
|
1816 | 1816 | return; |
1817 | 1817 | } |
1818 | 1818 | } |
1819 | 1819 | // you appear to be lost? |
1820 | - $this->_redirect_wayward_request( $primary_registrant ); |
|
1820 | + $this->_redirect_wayward_request($primary_registrant); |
|
1821 | 1821 | } |
1822 | 1822 | } |
1823 | 1823 | } |
@@ -1831,16 +1831,16 @@ discard block |
||
1831 | 1831 | * @param \EE_Registration $primary_registrant |
1832 | 1832 | * @return bool |
1833 | 1833 | */ |
1834 | - private function _redirect_wayward_request( EE_Registration $primary_registrant ) { |
|
1835 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
1834 | + private function _redirect_wayward_request(EE_Registration $primary_registrant) { |
|
1835 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
1836 | 1836 | // try redirecting based on the current TXN |
1837 | 1837 | $primary_registrant = $this->checkout->transaction instanceof EE_Transaction ? $this->checkout->transaction->primary_registration() : null; |
1838 | - if ( ! $primary_registrant instanceof EE_Registration ) { |
|
1838 | + if ( ! $primary_registrant instanceof EE_Registration) { |
|
1839 | 1839 | EE_Error::add_error( |
1840 | 1840 | sprintf( |
1841 | - __( 'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ), |
|
1841 | + __('Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'), |
|
1842 | 1842 | '<br/>', |
1843 | - EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) |
|
1843 | + EE_Registry::instance()->CFG->organization->get_pretty('email') |
|
1844 | 1844 | ), |
1845 | 1845 | __FILE__, __FUNCTION__, __LINE__ |
1846 | 1846 | ); |
@@ -1868,16 +1868,16 @@ discard block |
||
1868 | 1868 | * @param \EE_Offsite_Gateway $gateway |
1869 | 1869 | * @return \EE_Payment |
1870 | 1870 | */ |
1871 | - private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) { |
|
1871 | + private function _process_off_site_payment(EE_Offsite_Gateway $gateway) { |
|
1872 | 1872 | try { |
1873 | 1873 | // if gateway uses_separate_IPN_request, then we don't have to process the IPN manually |
1874 | - if ( $gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request() ) { |
|
1874 | + if ($gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request()) { |
|
1875 | 1875 | $payment = $this->checkout->transaction->last_payment(); |
1876 | 1876 | //$payment_source = 'last_payment'; |
1877 | 1877 | } else { |
1878 | 1878 | // get payment details and process results |
1879 | 1879 | /** @type EE_Payment_Processor $payment_processor */ |
1880 | - $payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' ); |
|
1880 | + $payment_processor = EE_Registry::instance()->load_core('Payment_Processor'); |
|
1881 | 1881 | $payment = $payment_processor->process_ipn( |
1882 | 1882 | $_REQUEST, |
1883 | 1883 | $this->checkout->transaction, |
@@ -1887,14 +1887,14 @@ discard block |
||
1887 | 1887 | ); |
1888 | 1888 | //$payment_source = 'process_ipn'; |
1889 | 1889 | } |
1890 | - } catch ( Exception $e ) { |
|
1890 | + } catch (Exception $e) { |
|
1891 | 1891 | // let's just eat the exception and try to move on using any previously set payment info |
1892 | 1892 | $payment = $this->checkout->transaction->last_payment(); |
1893 | 1893 | //$payment_source = 'last_payment after Exception'; |
1894 | 1894 | // but if we STILL don't have a payment object |
1895 | - if ( ! $payment instanceof EE_Payment ) { |
|
1895 | + if ( ! $payment instanceof EE_Payment) { |
|
1896 | 1896 | // then we'll object ! ( not object like a thing... but object like what a lawyer says ! ) |
1897 | - $this->_handle_payment_processor_exception( $e ); |
|
1897 | + $this->_handle_payment_processor_exception($e); |
|
1898 | 1898 | } |
1899 | 1899 | } |
1900 | 1900 | // DEBUG LOG |
@@ -1918,13 +1918,13 @@ discard block |
||
1918 | 1918 | * @param EE_Payment $payment |
1919 | 1919 | * @return EE_Payment | FALSE |
1920 | 1920 | */ |
1921 | - private function _process_cancelled_payments( $payment = NULL ) { |
|
1921 | + private function _process_cancelled_payments($payment = NULL) { |
|
1922 | 1922 | if ( |
1923 | - isset( $_REQUEST[ 'ee_cancel_payment' ] ) |
|
1923 | + isset($_REQUEST['ee_cancel_payment']) |
|
1924 | 1924 | && $payment instanceof EE_Payment |
1925 | 1925 | && $payment->status() == EEM_Payment::status_id_failed |
1926 | 1926 | ) { |
1927 | - $payment->set_status( EEM_Payment::status_id_cancelled ); |
|
1927 | + $payment->set_status(EEM_Payment::status_id_cancelled); |
|
1928 | 1928 | } |
1929 | 1929 | return $payment; |
1930 | 1930 | } |
@@ -1941,23 +1941,23 @@ discard block |
||
1941 | 1941 | public function get_transaction_details_for_gateways() { |
1942 | 1942 | $txn_details = array(); |
1943 | 1943 | // ya gotta make a choice man |
1944 | - if ( empty( $this->checkout->selected_method_of_payment ) ) { |
|
1944 | + if (empty($this->checkout->selected_method_of_payment)) { |
|
1945 | 1945 | $txn_details = array( |
1946 | - 'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' ) |
|
1946 | + 'error' => __('Please select a method of payment before proceeding.', 'event_espresso') |
|
1947 | 1947 | ); |
1948 | 1948 | } |
1949 | 1949 | // get EE_Payment_Method object |
1950 | 1950 | if ( |
1951 | - empty( $txn_details ) && |
|
1951 | + empty($txn_details) && |
|
1952 | 1952 | ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() |
1953 | 1953 | ) { |
1954 | 1954 | $txn_details = array( |
1955 | 1955 | 'selected_method_of_payment' => $this->checkout->selected_method_of_payment, |
1956 | - 'error' => __( 'A valid Payment Method could not be determined.', 'event_espresso' ) |
|
1956 | + 'error' => __('A valid Payment Method could not be determined.', 'event_espresso') |
|
1957 | 1957 | ); |
1958 | 1958 | } |
1959 | - if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) { |
|
1960 | - $return_url = $this->_get_return_url( $this->checkout->payment_method ); |
|
1959 | + if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) { |
|
1960 | + $return_url = $this->_get_return_url($this->checkout->payment_method); |
|
1961 | 1961 | $txn_details = array( |
1962 | 1962 | 'TXN_ID' => $this->checkout->transaction->ID(), |
1963 | 1963 | 'TXN_timestamp' => $this->checkout->transaction->datetime(), |
@@ -1968,7 +1968,7 @@ discard block |
||
1968 | 1968 | 'PMD_ID' => $this->checkout->transaction->payment_method_ID(), |
1969 | 1969 | 'payment_amount' => $this->checkout->amount_owing, |
1970 | 1970 | 'return_url' => $return_url, |
1971 | - 'cancel_url' => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ), |
|
1971 | + 'cancel_url' => add_query_arg(array('ee_cancel_payment' => true), $return_url), |
|
1972 | 1972 | 'notify_url' => EE_Config::instance()->core->txn_page_url( |
1973 | 1973 | array( |
1974 | 1974 | 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link(), |
@@ -1977,7 +1977,7 @@ discard block |
||
1977 | 1977 | ) |
1978 | 1978 | ); |
1979 | 1979 | } |
1980 | - echo json_encode( $txn_details ); |
|
1980 | + echo json_encode($txn_details); |
|
1981 | 1981 | exit(); |
1982 | 1982 | } |
1983 | 1983 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return EEG_Paypal_Standard |
69 | 69 | */ |
70 | 70 | public function __construct() { |
71 | - $this->set_uses_separate_IPN_request( true ) ; |
|
71 | + $this->set_uses_separate_IPN_request(true); |
|
72 | 72 | parent::__construct(); |
73 | 73 | } |
74 | 74 | |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | * Also sets the gateway url class variable based on whether debug mode is enabled or not |
79 | 79 | * @param array $settings_array |
80 | 80 | */ |
81 | - public function set_settings($settings_array){ |
|
81 | + public function set_settings($settings_array) { |
|
82 | 82 | parent::set_settings($settings_array); |
83 | - if($this->_debug_mode){ |
|
83 | + if ($this->_debug_mode) { |
|
84 | 84 | $this->_gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; |
85 | - }else{ |
|
85 | + } else { |
|
86 | 86 | $this->_gateway_url = 'https://www.paypal.com/cgi-bin/webscr'; |
87 | 87 | } |
88 | 88 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param string $cancel_url URL to send the user to after a cancelled payment attempt on teh payment provider's website |
98 | 98 | * @return EEI_Payment |
99 | 99 | */ |
100 | - public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ){ |
|
100 | + public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) { |
|
101 | 101 | $redirect_args = array(); |
102 | 102 | $transaction = $payment->transaction(); |
103 | 103 | $primary_registrant = $transaction->primary_registration(); |
@@ -107,42 +107,42 @@ discard block |
||
107 | 107 | |
108 | 108 | $total_discounts_to_cart_total = $transaction->paid(); |
109 | 109 | //only itemize the order if we're paying for the rest of the order's amount |
110 | - if( $payment->amount() == $transaction->total() ) { |
|
111 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true ); |
|
110 | + if ($payment->amount() == $transaction->total()) { |
|
111 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true); |
|
112 | 112 | //this payment is for the remaining transaction amount, |
113 | 113 | //keep track of exactly how much the itemized order amount equals |
114 | 114 | $itemized_sum = 0; |
115 | 115 | $shipping_previously_added = 0; |
116 | 116 | //so let's show all the line items |
117 | - foreach($total_line_item->get_items() as $line_item){ |
|
118 | - if ( $line_item instanceof EE_Line_Item ) { |
|
117 | + foreach ($total_line_item->get_items() as $line_item) { |
|
118 | + if ($line_item instanceof EE_Line_Item) { |
|
119 | 119 | //it's some kind of discount |
120 | - if( $line_item->total() < 0 ) { |
|
121 | - $total_discounts_to_cart_total += abs( $line_item->total() ); |
|
120 | + if ($line_item->total() < 0) { |
|
121 | + $total_discounts_to_cart_total += abs($line_item->total()); |
|
122 | 122 | $itemized_sum += $line_item->total(); |
123 | 123 | continue; |
124 | 124 | } |
125 | 125 | //dont include shipping again. |
126 | - if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) { |
|
126 | + if (strpos($line_item->code(), 'paypal_shipping_') === 0) { |
|
127 | 127 | $shipping_previously_added = $line_item->total(); |
128 | 128 | continue; |
129 | 129 | } |
130 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
131 | - sprintf( _x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ), $line_item->name(), $line_item->ticket_event_name() ), |
|
130 | + $redirect_args['item_name_'.$item_num] = substr( |
|
131 | + sprintf(_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), $line_item->name(), $line_item->ticket_event_name()), |
|
132 | 132 | 0, 127 |
133 | 133 | ); |
134 | - $redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price(); |
|
135 | - $redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity(); |
|
134 | + $redirect_args['amount_'.$item_num] = $line_item->unit_price(); |
|
135 | + $redirect_args['quantity_'.$item_num] = $line_item->quantity(); |
|
136 | 136 | //if we're not letting PayPal calculate shipping, tell them its 0 |
137 | - if ( ! $this->_paypal_shipping ) { |
|
138 | - $redirect_args[ 'shipping_' . $item_num ] = '0'; |
|
139 | - $redirect_args[ 'shipping2_' . $item_num ] = '0'; |
|
137 | + if ( ! $this->_paypal_shipping) { |
|
138 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
139 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
140 | 140 | } |
141 | 141 | $item_num++; |
142 | 142 | $itemized_sum += $line_item->total(); |
143 | 143 | } |
144 | 144 | } |
145 | - $taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item ); |
|
145 | + $taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item); |
|
146 | 146 | //ideally itemized sum equals the transaction total. but if not (which is weird) |
147 | 147 | //and the itemized sum is LESS than the transaction total |
148 | 148 | //add another line item |
@@ -152,47 +152,47 @@ discard block |
||
152 | 152 | $transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added, |
153 | 153 | 2 |
154 | 154 | ); |
155 | - if( $itemized_sum_diff_from_txn_total < 0 ) { |
|
155 | + if ($itemized_sum_diff_from_txn_total < 0) { |
|
156 | 156 | //itemized sum is too big |
157 | - $total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total ); |
|
158 | - } elseif( $itemized_sum_diff_from_txn_total > 0 ) { |
|
159 | - $redirect_args[ 'item_name_' . $item_num ] = substr( |
|
160 | - __( 'Other charges', 'event_espresso' ), 0, 127 ); |
|
161 | - $redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total ); |
|
162 | - $redirect_args[ 'quantity_' . $item_num ] = 1; |
|
157 | + $total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total); |
|
158 | + } elseif ($itemized_sum_diff_from_txn_total > 0) { |
|
159 | + $redirect_args['item_name_'.$item_num] = substr( |
|
160 | + __('Other charges', 'event_espresso'), 0, 127 ); |
|
161 | + $redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total); |
|
162 | + $redirect_args['quantity_'.$item_num] = 1; |
|
163 | 163 | $item_num++; |
164 | 164 | } |
165 | - if( $total_discounts_to_cart_total > 0 ) { |
|
166 | - $redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total ); |
|
165 | + if ($total_discounts_to_cart_total > 0) { |
|
166 | + $redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total); |
|
167 | 167 | } |
168 | 168 | //add our taxes to the order if we're NOT using PayPal's |
169 | - if( ! $this->_paypal_taxes ){ |
|
169 | + if ( ! $this->_paypal_taxes) { |
|
170 | 170 | $redirect_args['tax_cart'] = $total_line_item->get_total_tax(); |
171 | 171 | } |
172 | 172 | } else { |
173 | - $payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false ); |
|
173 | + $payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false); |
|
174 | 174 | //partial payment that's not for the remaining amount, so we can't send an itemized list |
175 | - $redirect_args['item_name_' . $item_num] = substr( |
|
176 | - sprintf( __('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code() ), |
|
175 | + $redirect_args['item_name_'.$item_num] = substr( |
|
176 | + sprintf(__('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code()), |
|
177 | 177 | 0, 127 |
178 | 178 | ); |
179 | - $redirect_args['amount_' . $item_num] = $payment->amount(); |
|
180 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
181 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
179 | + $redirect_args['amount_'.$item_num] = $payment->amount(); |
|
180 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
181 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
182 | 182 | $redirect_args['tax_cart'] = '0'; |
183 | 183 | $item_num++; |
184 | 184 | } |
185 | 185 | |
186 | - if($this->_debug_mode){ |
|
187 | - $redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
188 | - $redirect_args['amount_' . $item_num] = 0; |
|
186 | + if ($this->_debug_mode) { |
|
187 | + $redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode'; |
|
188 | + $redirect_args['amount_'.$item_num] = 0; |
|
189 | 189 | $redirect_args['on0_'.$item_num] = 'NOTIFY URL'; |
190 | - $redirect_args['os0_' . $item_num] = $notify_url; |
|
190 | + $redirect_args['os0_'.$item_num] = $notify_url; |
|
191 | 191 | $redirect_args['on1_'.$item_num] = 'RETURN URL'; |
192 | - $redirect_args['os1_' . $item_num] = $return_url; |
|
192 | + $redirect_args['os1_'.$item_num] = $return_url; |
|
193 | 193 | // $redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ? |
194 | - $redirect_args['shipping_' . $item_num ] = '0'; |
|
195 | - $redirect_args['shipping2_' . $item_num ] = '0'; |
|
194 | + $redirect_args['shipping_'.$item_num] = '0'; |
|
195 | + $redirect_args['shipping2_'.$item_num] = '0'; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $redirect_args['business'] = $this->_paypal_id; |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | $redirect_args['cmd'] = '_cart'; |
203 | 203 | $redirect_args['upload'] = 1; |
204 | 204 | $redirect_args['currency_code'] = $payment->currency_code(); |
205 | - $redirect_args['rm'] = 2;//makes the user return with method=POST |
|
206 | - if($this->_image_url){ |
|
205 | + $redirect_args['rm'] = 2; //makes the user return with method=POST |
|
206 | + if ($this->_image_url) { |
|
207 | 207 | $redirect_args['image_url'] = $this->_image_url; |
208 | 208 | } |
209 | 209 | $redirect_args['no_shipping'] = $this->_shipping_details; |
210 | - $redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this |
|
210 | + $redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this |
|
211 | 211 | |
212 | - $redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this ); |
|
212 | + $redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this); |
|
213 | 213 | |
214 | 214 | $payment->set_redirect_url($this->_gateway_url); |
215 | 215 | $payment->set_redirect_args($redirect_args); |
@@ -230,55 +230,55 @@ discard block |
||
230 | 230 | * @return \EEI_Payment updated |
231 | 231 | * @throws \EE_Error |
232 | 232 | */ |
233 | - public function handle_payment_update( $update_info, $transaction ){ |
|
233 | + public function handle_payment_update($update_info, $transaction) { |
|
234 | 234 | //verify there's payment data that's been sent |
235 | - if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) { |
|
235 | + if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) { |
|
236 | 236 | // waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/) |
237 | 237 | // indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes |
238 | - if ( isset( $update_info[ 'tx' ] ) ) { |
|
238 | + if (isset($update_info['tx'])) { |
|
239 | 239 | return $transaction->last_payment(); |
240 | 240 | } else { |
241 | 241 | return null; |
242 | 242 | } |
243 | 243 | } |
244 | - $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
245 | - if ( ! $payment instanceof EEI_Payment ) { |
|
244 | + $payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']); |
|
245 | + if ( ! $payment instanceof EEI_Payment) { |
|
246 | 246 | $payment = $transaction->last_payment(); |
247 | 247 | } |
248 | 248 | // ok, then validate the IPN. Even if we've already processed this payment, |
249 | 249 | // let PayPal know we don't want to hear from them anymore! |
250 | - if ( ! $this->validate_ipn( $update_info, $payment ) ) { |
|
250 | + if ( ! $this->validate_ipn($update_info, $payment)) { |
|
251 | 251 | return $payment; |
252 | 252 | } |
253 | 253 | //ok, well let's process this payment then! |
254 | - switch ( $update_info[ 'payment_status' ] ) { |
|
254 | + switch ($update_info['payment_status']) { |
|
255 | 255 | |
256 | 256 | case 'Completed' : |
257 | 257 | $status = $this->_pay_model->approved_status(); |
258 | - $gateway_response = __( 'The payment is approved.', 'event_espresso' ); |
|
258 | + $gateway_response = __('The payment is approved.', 'event_espresso'); |
|
259 | 259 | break; |
260 | 260 | |
261 | 261 | case 'Pending' : |
262 | 262 | $status = $this->_pay_model->pending_status(); |
263 | - $gateway_response = __( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' ); |
|
263 | + $gateway_response = __('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso'); |
|
264 | 264 | break; |
265 | 265 | |
266 | 266 | case 'Denied' : |
267 | 267 | $status = $this->_pay_model->declined_status(); |
268 | - $gateway_response = __( 'The payment has been declined.', 'event_espresso' ); |
|
268 | + $gateway_response = __('The payment has been declined.', 'event_espresso'); |
|
269 | 269 | break; |
270 | 270 | |
271 | 271 | case 'Expired' : |
272 | 272 | case 'Failed' : |
273 | 273 | $status = $this->_pay_model->failed_status(); |
274 | - $gateway_response = __( 'The payment failed for technical reasons or expired.', 'event_espresso' ); |
|
274 | + $gateway_response = __('The payment failed for technical reasons or expired.', 'event_espresso'); |
|
275 | 275 | break; |
276 | 276 | |
277 | 277 | case 'Refunded' : |
278 | 278 | case 'Partially_Refunded' : |
279 | 279 | // even though it's a refund, we consider the payment as approved, it just has a negative value |
280 | 280 | $status = $this->_pay_model->approved_status(); |
281 | - $gateway_response = __( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' ); |
|
281 | + $gateway_response = __('The payment has been refunded. Please update registrations accordingly.', 'event_espresso'); |
|
282 | 282 | break; |
283 | 283 | |
284 | 284 | case 'Voided' : |
@@ -286,25 +286,25 @@ discard block |
||
286 | 286 | case 'Canceled_Reversal' : |
287 | 287 | default : |
288 | 288 | $status = $this->_pay_model->cancelled_status(); |
289 | - $gateway_response = __( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' ); |
|
289 | + $gateway_response = __('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso'); |
|
290 | 290 | break; |
291 | 291 | |
292 | 292 | } |
293 | 293 | |
294 | 294 | //check if we've already processed this payment |
295 | - if ( $payment instanceof EEI_Payment ) { |
|
295 | + if ($payment instanceof EEI_Payment) { |
|
296 | 296 | //payment exists. if this has the exact same status and amount, don't bother updating. just return |
297 | - if ( $payment->status() == $status && $payment->amount() == $update_info[ 'mc_gross' ] ) { |
|
297 | + if ($payment->status() == $status && $payment->amount() == $update_info['mc_gross']) { |
|
298 | 298 | // DUPLICATED IPN! dont bother updating transaction foo!; |
299 | - $message_log = sprintf( __( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ), $payment->ID() ); |
|
299 | + $message_log = sprintf(__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'), $payment->ID()); |
|
300 | 300 | } else { |
301 | 301 | // new payment yippee !!! |
302 | - $payment->set_status( $status ); |
|
303 | - $payment->set_amount( floatval( $update_info[ 'mc_gross' ] ) ); |
|
304 | - $payment->set_gateway_response( $gateway_response ); |
|
305 | - $payment->set_details( $update_info ); |
|
306 | - $payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] ); |
|
307 | - $message_log = sprintf( __( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ) ); |
|
302 | + $payment->set_status($status); |
|
303 | + $payment->set_amount(floatval($update_info['mc_gross'])); |
|
304 | + $payment->set_gateway_response($gateway_response); |
|
305 | + $payment->set_details($update_info); |
|
306 | + $payment->set_txn_id_chq_nmbr($update_info['txn_id']); |
|
307 | + $message_log = sprintf(__('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso')); |
|
308 | 308 | } |
309 | 309 | $this->log( |
310 | 310 | array( |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | $payment |
317 | 317 | ); |
318 | 318 | } |
319 | - do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this ); |
|
319 | + do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this); |
|
320 | 320 | // kill request here if this is a refund |
321 | - if ( $update_info[ 'payment_status' ] == 'Refunded' || $update_info[ 'payment_status' ] == 'Partially_Refunded' ) { |
|
322 | - if ( apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) ) { |
|
323 | - status_header( 200 ); |
|
321 | + if ($update_info['payment_status'] == 'Refunded' || $update_info['payment_status'] == 'Partially_Refunded') { |
|
322 | + if (apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)) { |
|
323 | + status_header(200); |
|
324 | 324 | exit(); |
325 | 325 | } |
326 | 326 | } |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | * @param EE_Payment|EEI_Payment $payment |
337 | 337 | * @return boolean |
338 | 338 | */ |
339 | - public function validate_ipn( $update_info, $payment ) { |
|
339 | + public function validate_ipn($update_info, $payment) { |
|
340 | 340 | //allow us to skip validating IPNs with PayPal (useful for testing) |
341 | - if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) { |
|
341 | + if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) { |
|
342 | 342 | return true; |
343 | 343 | } |
344 | 344 | //...otherwise, we actually don't care what the $update_info is, we need to look |
@@ -346,22 +346,22 @@ discard block |
||
346 | 346 | // Reading POSTed data directly from $_POST causes serialization issues with array data in the POST. |
347 | 347 | // Instead, read raw POST data from the input stream. |
348 | 348 | // @see https://gist.github.com/xcommerce-gists/3440401 |
349 | - $raw_post_data = file_get_contents( 'php://input' ); |
|
350 | - $raw_post_array = explode( '&', $raw_post_data ); |
|
349 | + $raw_post_data = file_get_contents('php://input'); |
|
350 | + $raw_post_array = explode('&', $raw_post_data); |
|
351 | 351 | $update_info = array(); |
352 | - foreach ( $raw_post_array as $keyval ) { |
|
353 | - $keyval = explode( '=', $keyval ); |
|
354 | - if ( count( $keyval ) == 2 ) |
|
355 | - $update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] ); |
|
352 | + foreach ($raw_post_array as $keyval) { |
|
353 | + $keyval = explode('=', $keyval); |
|
354 | + if (count($keyval) == 2) |
|
355 | + $update_info[$keyval[0]] = urldecode($keyval[1]); |
|
356 | 356 | } |
357 | 357 | // read the IPN message sent from PayPal and prepend 'cmd=_notify-validate' |
358 | 358 | $req = 'cmd=_notify-validate'; |
359 | - $get_magic_quotes_exists = function_exists( 'get_magic_quotes_gpc' ) ? true : false; |
|
360 | - foreach ( $update_info as $key => $value ) { |
|
361 | - if ( $get_magic_quotes_exists && get_magic_quotes_gpc() == 1 ) { |
|
362 | - $value = urlencode( stripslashes( $value ) ); |
|
359 | + $get_magic_quotes_exists = function_exists('get_magic_quotes_gpc') ? true : false; |
|
360 | + foreach ($update_info as $key => $value) { |
|
361 | + if ($get_magic_quotes_exists && get_magic_quotes_gpc() == 1) { |
|
362 | + $value = urlencode(stripslashes($value)); |
|
363 | 363 | } else { |
364 | - $value = urlencode( $value ); |
|
364 | + $value = urlencode($value); |
|
365 | 365 | } |
366 | 366 | $req .= "&$key=$value"; |
367 | 367 | } |
@@ -371,34 +371,34 @@ discard block |
||
371 | 371 | array( |
372 | 372 | 'body' => $req, |
373 | 373 | 'sslverify' => false, |
374 | - 'timeout' => 60 , |
|
374 | + 'timeout' => 60, |
|
375 | 375 | // make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal |
376 | 376 | // plz see: https://github.com/websharks/s2member/issues/610 |
377 | - 'user-agent' => 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(), |
|
377 | + 'user-agent' => 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(), |
|
378 | 378 | 'httpversion' => '1.1' |
379 | 379 | ) |
380 | 380 | ); |
381 | 381 | // then check the response |
382 | - if ( ! is_wp_error( $response ) && array_key_exists( 'body', $response ) && strcmp( $response[ 'body' ], "VERIFIED" ) == 0 ) { |
|
382 | + if ( ! is_wp_error($response) && array_key_exists('body', $response) && strcmp($response['body'], "VERIFIED") == 0) { |
|
383 | 383 | return true; |
384 | 384 | } else { |
385 | 385 | // huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly, |
386 | 386 | // or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html |
387 | - if( is_wp_error( $response ) ) { |
|
387 | + if (is_wp_error($response)) { |
|
388 | 388 | $error_msg = sprintf( |
389 | - __( 'WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso' ), |
|
389 | + __('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'), |
|
390 | 390 | $response->get_error_code(), |
391 | 391 | $response->get_error_message(), |
392 | - print_r( $response->get_error_data, true ) |
|
392 | + print_r($response->get_error_data, true) |
|
393 | 393 | ); |
394 | - } elseif( is_array( $response ) && isset( $response[ 'body' ] ) ) { |
|
395 | - $error_msg = $response[ 'body' ]; |
|
394 | + } elseif (is_array($response) && isset($response['body'])) { |
|
395 | + $error_msg = $response['body']; |
|
396 | 396 | } else { |
397 | - $error_msg = print_r( $response, true ); |
|
397 | + $error_msg = print_r($response, true); |
|
398 | 398 | } |
399 | - $payment->set_gateway_response( sprintf( __( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $error_msg ) ); |
|
400 | - $payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) ); |
|
401 | - $payment->set_status( EEM_Payment::status_id_failed ); |
|
399 | + $payment->set_gateway_response(sprintf(__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $error_msg)); |
|
400 | + $payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response)); |
|
401 | + $payment->set_status(EEM_Payment::status_id_failed); |
|
402 | 402 | // log the results |
403 | 403 | $this->log( |
404 | 404 | array( |
@@ -420,9 +420,9 @@ discard block |
||
420 | 420 | */ |
421 | 421 | protected function _process_response_url() { |
422 | 422 | EE_Registry::instance()->load_helper('URL'); |
423 | - if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) { |
|
423 | + if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) { |
|
424 | 424 | $url = is_ssl() ? 'https://' : 'http://'; |
425 | - $url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' ); |
|
425 | + $url .= EEH_URL::filter_input_server_url('HTTP_HOST'); |
|
426 | 426 | $url .= EEH_URL::filter_input_server_url(); |
427 | 427 | } else { |
428 | 428 | $url = 'unknown'; |
@@ -438,30 +438,30 @@ discard block |
||
438 | 438 | * like the taxes or shipping |
439 | 439 | * @param EEI_Payment $payment |
440 | 440 | */ |
441 | - public function update_txn_based_on_payment( $payment ) { |
|
441 | + public function update_txn_based_on_payment($payment) { |
|
442 | 442 | $update_info = $payment->details(); |
443 | 443 | $transaction = $payment->transaction(); |
444 | - $payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false ); |
|
445 | - if( ! $transaction ){ |
|
446 | - $this->log( __( 'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso' ), $payment ); |
|
444 | + $payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false); |
|
445 | + if ( ! $transaction) { |
|
446 | + $this->log(__('Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso'), $payment); |
|
447 | 447 | return; |
448 | 448 | } |
449 | - if( ! is_array( $update_info ) || ! isset( $update_info[ 'mc_shipping' ] ) || ! isset( $update_info[ 'tax' ] ) ) { |
|
449 | + if ( ! is_array($update_info) || ! isset($update_info['mc_shipping']) || ! isset($update_info['tax'])) { |
|
450 | 450 | $this->log( |
451 | 451 | array( |
452 | 452 | 'url' => $this->_process_response_url(), |
453 | - 'message' => __( 'Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso' ), |
|
453 | + 'message' => __('Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso'), |
|
454 | 454 | 'payment' => $payment->model_field_array() |
455 | 455 | ), |
456 | 456 | $payment |
457 | 457 | ); |
458 | 458 | return; |
459 | 459 | } |
460 | - if( $payment->status() !== $this->_pay_model->approved_status() ) { |
|
460 | + if ($payment->status() !== $this->_pay_model->approved_status()) { |
|
461 | 461 | $this->log( |
462 | 462 | array( |
463 | 463 | 'url' => $this->_process_response_url(), |
464 | - 'message' => __( 'We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso' ), |
|
464 | + 'message' => __('We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso'), |
|
465 | 465 | 'payment' => $payment->model_field_array() |
466 | 466 | ), |
467 | 467 | $payment |
@@ -471,43 +471,43 @@ discard block |
||
471 | 471 | $grand_total_needs_resaving = false; |
472 | 472 | |
473 | 473 | //might paypal have changed the taxes? |
474 | - if( $this->_paypal_taxes && $payment_was_itemized ){ |
|
474 | + if ($this->_paypal_taxes && $payment_was_itemized) { |
|
475 | 475 | //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable |
476 | - $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' ); |
|
476 | + $this->_line_item->set_line_items_taxable($transaction->total_line_item(), true, 'paypal_shipping'); |
|
477 | 477 | $this->_line_item->set_total_tax_to( |
478 | 478 | $transaction->total_line_item(), |
479 | - floatval( $update_info['tax'] ), |
|
480 | - __( 'Taxes', 'event_espresso' ), |
|
481 | - __( 'Calculated by Paypal', 'event_espresso' ), |
|
479 | + floatval($update_info['tax']), |
|
480 | + __('Taxes', 'event_espresso'), |
|
481 | + __('Calculated by Paypal', 'event_espresso'), |
|
482 | 482 | 'paypal_tax' |
483 | 483 | ); |
484 | 484 | $grand_total_needs_resaving = TRUE; |
485 | 485 | } |
486 | 486 | |
487 | - $shipping_amount = floatval( $update_info[ 'mc_shipping' ] ); |
|
487 | + $shipping_amount = floatval($update_info['mc_shipping']); |
|
488 | 488 | //might paypal have added shipping? |
489 | - if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){ |
|
489 | + if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) { |
|
490 | 490 | $this->_line_item->add_unrelated_item( |
491 | 491 | $transaction->total_line_item(), |
492 | - sprintf( __('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ), |
|
492 | + sprintf(__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()), |
|
493 | 493 | $shipping_amount, |
494 | 494 | __('Shipping charges calculated by Paypal', 'event_espresso'), |
495 | 495 | 1, |
496 | 496 | false, |
497 | - 'paypal_shipping_' . $transaction->ID() |
|
497 | + 'paypal_shipping_'.$transaction->ID() |
|
498 | 498 | ); |
499 | 499 | $grand_total_needs_resaving = true; |
500 | 500 | } |
501 | 501 | |
502 | - if( $grand_total_needs_resaving ){ |
|
503 | - $transaction->total_line_item()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
504 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
505 | - $registration_processor->update_registration_final_prices( $transaction ); |
|
502 | + if ($grand_total_needs_resaving) { |
|
503 | + $transaction->total_line_item()->save_this_and_descendants_to_txn($transaction->ID()); |
|
504 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
505 | + $registration_processor->update_registration_final_prices($transaction); |
|
506 | 506 | } |
507 | 507 | $this->log( |
508 | 508 | array( |
509 | 509 | 'url' => $this->_process_response_url(), |
510 | - 'message' => __( 'Updated transaction related to payment', 'event_espresso' ), |
|
510 | + 'message' => __('Updated transaction related to payment', 'event_espresso'), |
|
511 | 511 | 'transaction (updated)' => $transaction->model_field_array(), |
512 | 512 | 'payment (updated)' => $payment->model_field_array(), |
513 | 513 | 'use_paypal_shipping' => $this->_paypal_shipping, |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | * Returns the name of the field's name that points to the WP_User table |
810 | 810 | * on this model (or follows the _model_chain_to_wp_user and uses that model's |
811 | 811 | * foreign key to the WP_User table) |
812 | - * @return string|boolean string on success, boolean false when there is no |
|
812 | + * @return string|false string on success, boolean false when there is no |
|
813 | 813 | * foreign key to the WP_User table |
814 | 814 | */ |
815 | 815 | function wp_user_field_name() { |
@@ -906,6 +906,7 @@ discard block |
||
906 | 906 | * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array. |
907 | 907 | * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection |
908 | 908 | * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d')) |
909 | + * @param string $columns_to_select |
|
909 | 910 | * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
910 | 911 | */ |
911 | 912 | public function get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){ |
@@ -1248,7 +1249,7 @@ discard block |
||
1248 | 1249 | * @param bool $pretty Whether to return the pretty formats (true) or not (false). |
1249 | 1250 | * @throws EE_Error If the given field_name is not of the EE_Datetime_Field type. |
1250 | 1251 | * |
1251 | - * @return array formats in an array with the date format first, and the time format last. |
|
1252 | + * @return string[] formats in an array with the date format first, and the time format last. |
|
1252 | 1253 | */ |
1253 | 1254 | public function get_formats_for( $field_name, $pretty = false ) { |
1254 | 1255 | $field_settings = $this->field_settings_for( $field_name ); |
@@ -1283,7 +1284,7 @@ discard block |
||
1283 | 1284 | * |
1284 | 1285 | * @throws EE_Error If the given field_name is not of the EE_Datetime_Field type. |
1285 | 1286 | * |
1286 | - * @return int|string If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
|
1287 | + * @return string|null If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
|
1287 | 1288 | * exception is triggered. |
1288 | 1289 | */ |
1289 | 1290 | public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) { |
@@ -1982,7 +1983,7 @@ discard block |
||
1982 | 1983 | /** |
1983 | 1984 | * Verifies the EE addons' database is up-to-date and records that we've done it on |
1984 | 1985 | * EEM_Base::$_db_verification_level |
1985 | - * @param $wpdb_method |
|
1986 | + * @param string $wpdb_method |
|
1986 | 1987 | * @param $arguments_to_provide |
1987 | 1988 | * @return string |
1988 | 1989 | */ |
@@ -2050,7 +2051,6 @@ discard block |
||
2050 | 2051 | * 'hasAndBelongsToMany' relationships: checks that there isn't already an entry in the join table, and adds one. |
2051 | 2052 | * If one of the model Objects has not yet been saved to the database, it is saved before adding the entry in the join table |
2052 | 2053 | * |
2053 | - * @param EE_Base_Class/int $thisModelObject |
|
2054 | 2054 | * @param EE_Base_Class/int $id_or_obj EE_base_Class or ID of other Model Object |
2055 | 2055 | * @param string $relationName, key in EEM_Base::_relations |
2056 | 2056 | * an attendee to a group, you also want to specify which role they will have in that group. So you would use this parameter to specify array('role-column-name'=>'role-id') |
@@ -2072,8 +2072,8 @@ discard block |
||
2072 | 2072 | * |
2073 | 2073 | * 'hasAndBelongsToMany' relationships:removes any existing entry in the join table between the two models. |
2074 | 2074 | * |
2075 | - * @param EE_Base_Class/int $id_or_obj |
|
2076 | - * @param EE_Base_Class/int $other_model_id_or_obj EE_Base_Class or ID of other Model Object |
|
2075 | + * @param EE_CPT_Base $id_or_obj |
|
2076 | + * @param EE_Term_Taxonomy $other_model_id_or_obj EE_Base_Class or ID of other Model Object |
|
2077 | 2077 | * @param string $relationName key in EEM_Base::_relations |
2078 | 2078 | * @return boolean of success |
2079 | 2079 | * @param array $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM). Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well. |
@@ -2149,7 +2149,7 @@ discard block |
||
2149 | 2149 | /** |
2150 | 2150 | * Instead of getting the related model objects, simply counts them. Ignores default_where_conditions by default, |
2151 | 2151 | * unless otherwise specified in the $query_params |
2152 | - * @param int/EE_Base_Class $id_or_obj |
|
2152 | + * @param EE_Event $id_or_obj |
|
2153 | 2153 | * @param string $model_name like 'Event', or 'Registration' |
2154 | 2154 | * @param array $query_params like EEM_Base::get_all's |
2155 | 2155 | * @param string $field_to_count name of field to count by. By default, uses primary key |
@@ -2538,7 +2538,7 @@ discard block |
||
2538 | 2538 | /** |
2539 | 2539 | * Finds all the fields that correspond to the given table |
2540 | 2540 | * @param string $table_alias, array key in EEM_Base::_tables |
2541 | - * @return EE_Model_Field_Base[] |
|
2541 | + * @return EE_Model_Field_Base |
|
2542 | 2542 | */ |
2543 | 2543 | function _get_fields_for_table($table_alias){ |
2544 | 2544 | return $this->_fields[$table_alias]; |
@@ -3630,8 +3630,8 @@ discard block |
||
3630 | 3630 | /** |
3631 | 3631 | * gets the field object of type 'primary_key' from the fieldsSettings attribute. |
3632 | 3632 | * Eg, on EE_Answer that would be ANS_ID field object |
3633 | - * @param $field_obj |
|
3634 | - * @return EE_Model_Field_Base |
|
3633 | + * @param EE_Model_Field_Base $field_obj |
|
3634 | + * @return boolean |
|
3635 | 3635 | */ |
3636 | 3636 | public function is_primary_key_field( $field_obj ){ |
3637 | 3637 | return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE; |
@@ -3725,7 +3725,7 @@ discard block |
||
3725 | 3725 | * Gets the actual table for the table alias |
3726 | 3726 | * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe |
3727 | 3727 | * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works |
3728 | - * @return EE_Table_Base |
|
3728 | + * @return string |
|
3729 | 3729 | */ |
3730 | 3730 | function get_table_for_alias($table_alias){ |
3731 | 3731 | $table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias); |
@@ -3852,7 +3852,7 @@ discard block |
||
3852 | 3852 | * The purpose of this method is to allow us to create a model object that is not in the db that holds default values. |
3853 | 3853 | * A typical example of where this is used is when creating a new item and the initial load of a form. We dont' necessarily want to test for if the object is present but just assume it is BUT load the defaults from the object (as set in the model_field!). |
3854 | 3854 | * |
3855 | - * @return EE_Base_Class single EE_Base_Class object with default values for the properties. |
|
3855 | + * @return boolean single EE_Base_Class object with default values for the properties. |
|
3856 | 3856 | */ |
3857 | 3857 | public function create_default_object() { |
3858 | 3858 | |
@@ -4242,7 +4242,7 @@ discard block |
||
4242 | 4242 | } |
4243 | 4243 | /** |
4244 | 4244 | * Read comments for assume_values_already_prepared_by_model_object() |
4245 | - * @return int |
|
4245 | + * @return boolean |
|
4246 | 4246 | */ |
4247 | 4247 | public function get_assumption_concerning_values_already_prepared_by_model_object(){ |
4248 | 4248 | return $this->_values_already_prepared_by_model_object; |
@@ -604,10 +604,10 @@ discard block |
||
604 | 604 | $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) ); |
605 | 605 | $status_array = array(); |
606 | 606 | foreach ( $stati as $status ) { |
607 | - $status_array[ $status->ID() ] = $status->get('STS_code'); |
|
608 | - } |
|
609 | - return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array; |
|
610 | - } |
|
607 | + $status_array[ $status->ID() ] = $status->get('STS_code'); |
|
608 | + } |
|
609 | + return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array; |
|
610 | + } |
|
611 | 611 | |
612 | 612 | |
613 | 613 | |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | * |
618 | 618 | * @var array $0 (where) array { |
619 | 619 | * eg: array('QST_display_text'=>'Are you bob?','QST_admin_text'=>'Determine if user is bob') |
620 | - * becomes |
|
620 | + * becomes |
|
621 | 621 | * SQL >> "...WHERE QST_display_text = 'Are you bob?' AND QST_admin_text = 'Determine if user is bob'...") |
622 | 622 | * |
623 | 623 | * To add WHERE conditions based on related models (and even models-related-to-related-models) prepend the model's name |
@@ -1605,7 +1605,7 @@ discard block |
||
1605 | 1605 | * Deletes a single row from the DB given the model object's primary key value. (eg, EE_Attendee->ID()'s value). |
1606 | 1606 | * Wrapper for EEM_Base::delete() |
1607 | 1607 | * @param mixed $id |
1608 | - * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
1608 | + * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info |
|
1609 | 1609 | * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects |
1610 | 1610 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
1611 | 1611 | * @return boolean whether the row got deleted or not |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @since EE4 |
24 | 24 | * |
25 | 25 | */ |
26 | -abstract class EEM_Base extends EE_Base{ |
|
26 | +abstract class EEM_Base extends EE_Base { |
|
27 | 27 | |
28 | 28 | //admin posty |
29 | 29 | //basic -> grants access to mine -> if they don't have it, select none |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * Flag indicating whether this model has a primary key or not |
236 | 236 | * @var boolean |
237 | 237 | */ |
238 | - protected $_has_primary_key_field=null; |
|
238 | + protected $_has_primary_key_field = null; |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Whether or not this model is based off a table in WP core only (CPTs should set |
@@ -297,19 +297,19 @@ discard block |
||
297 | 297 | * operators that work like 'BETWEEN'. Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'" |
298 | 298 | * @var array |
299 | 299 | */ |
300 | - protected $_between_style_operators = array( 'BETWEEN' ); |
|
300 | + protected $_between_style_operators = array('BETWEEN'); |
|
301 | 301 | |
302 | 302 | /** |
303 | 303 | * operators that are used for handling NUll and !NULL queries. Typically used for when checking if a row exists on a join table. |
304 | 304 | * @var array |
305 | 305 | */ |
306 | - protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL'); |
|
306 | + protected $_null_style_operators = array('IS NOT NULL', 'IS NULL'); |
|
307 | 307 | |
308 | 308 | /** |
309 | 309 | * Allowed values for $query_params['order'] for ordering in queries |
310 | 310 | * @var array |
311 | 311 | */ |
312 | - protected $_allowed_order_values = array('asc','desc','ASC','DESC'); |
|
312 | + protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC'); |
|
313 | 313 | |
314 | 314 | /** |
315 | 315 | * When these are keys in a WHERE or HAVING clause, they are handled much differently |
@@ -323,13 +323,13 @@ discard block |
||
323 | 323 | * 'where', but 'where' clauses are so common that we thought we'd omit it |
324 | 324 | * @var array |
325 | 325 | */ |
326 | - private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps'); |
|
326 | + private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps'); |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * All the data types that can be used in $wpdb->prepare statements. |
330 | 330 | * @var array |
331 | 331 | */ |
332 | - private $_valid_wpdb_data_types = array('%d','%s','%f'); |
|
332 | + private $_valid_wpdb_data_types = array('%d', '%s', '%f'); |
|
333 | 333 | |
334 | 334 | /** |
335 | 335 | * EE_Registry Object |
@@ -362,17 +362,17 @@ discard block |
||
362 | 362 | /** |
363 | 363 | * constant used to show EEM_Base has not yet verified the db on this http request |
364 | 364 | */ |
365 | - const db_verified_none = 0; |
|
365 | + const db_verified_none = 0; |
|
366 | 366 | /** |
367 | 367 | * constant used to show EEM_Base has verified the EE core db on this http request, |
368 | 368 | * but not the addons' dbs |
369 | 369 | */ |
370 | - const db_verified_core = 1; |
|
370 | + const db_verified_core = 1; |
|
371 | 371 | /** |
372 | 372 | * constant used to show EEM_Base has verified the addons' dbs (and implicitly |
373 | 373 | * the EE core db too) |
374 | 374 | */ |
375 | - const db_verified_addons = 2; |
|
375 | + const db_verified_addons = 2; |
|
376 | 376 | |
377 | 377 | /** |
378 | 378 | * indicates whether an EEM_Base child has already re-verified the DB |
@@ -409,13 +409,13 @@ discard block |
||
409 | 409 | * @param null $timezone |
410 | 410 | * @throws \EE_Error |
411 | 411 | */ |
412 | - protected function __construct( $timezone = NULL ){ |
|
412 | + protected function __construct($timezone = NULL) { |
|
413 | 413 | // check that the model has not been loaded too soon |
414 | - if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) { |
|
415 | - throw new EE_Error ( |
|
414 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons')) { |
|
415 | + throw new EE_Error( |
|
416 | 416 | sprintf( |
417 | - __( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ), |
|
418 | - get_class( $this ) |
|
417 | + __('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'), |
|
418 | + get_class($this) |
|
419 | 419 | ) |
420 | 420 | ); |
421 | 421 | } |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | * just use EE_Register_Model_Extension |
426 | 426 | * @var EE_Table_Base[] $_tables |
427 | 427 | */ |
428 | - $this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables ); |
|
429 | - foreach($this->_tables as $table_alias => $table_obj){ |
|
428 | + $this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables); |
|
429 | + foreach ($this->_tables as $table_alias => $table_obj) { |
|
430 | 430 | /** @var $table_obj EE_Table_Base */ |
431 | 431 | $table_obj->_construct_finalize_with_alias($table_alias); |
432 | - if( $table_obj instanceof EE_Secondary_Table ){ |
|
432 | + if ($table_obj instanceof EE_Secondary_Table) { |
|
433 | 433 | /** @var $table_obj EE_Secondary_Table */ |
434 | 434 | $table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table()); |
435 | 435 | } |
@@ -439,54 +439,54 @@ discard block |
||
439 | 439 | * EE_Register_Model_Extension |
440 | 440 | * @param EE_Model_Field_Base[] $_fields |
441 | 441 | */ |
442 | - $this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields); |
|
442 | + $this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields); |
|
443 | 443 | $this->_invalidate_field_caches(); |
444 | - foreach($this->_fields as $table_alias => $fields_for_table){ |
|
445 | - if ( ! array_key_exists( $table_alias, $this->_tables )){ |
|
446 | - throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields))); |
|
444 | + foreach ($this->_fields as $table_alias => $fields_for_table) { |
|
445 | + if ( ! array_key_exists($table_alias, $this->_tables)) { |
|
446 | + throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields))); |
|
447 | 447 | } |
448 | - foreach($fields_for_table as $field_name => $field_obj){ |
|
448 | + foreach ($fields_for_table as $field_name => $field_obj) { |
|
449 | 449 | /** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */ |
450 | 450 | //primary key field base has a slightly different _construct_finalize |
451 | 451 | /** @var $field_obj EE_Model_Field_Base */ |
452 | - $field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() ); |
|
452 | + $field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name()); |
|
453 | 453 | } |
454 | 454 | } |
455 | 455 | |
456 | 456 | // everything is related to Extra_Meta |
457 | - if( get_class($this) != 'EEM_Extra_Meta'){ |
|
457 | + if (get_class($this) != 'EEM_Extra_Meta') { |
|
458 | 458 | //make extra meta related to everything, but don't block deleting things just |
459 | 459 | //because they have related extra meta info. For now just orphan those extra meta |
460 | 460 | //in the future we should automatically delete them |
461 | - $this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE ); |
|
461 | + $this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE); |
|
462 | 462 | } |
463 | 463 | //and change logs |
464 | - if( get_class( $this) != 'EEM_Change_Log' ) { |
|
465 | - $this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE ); |
|
464 | + if (get_class($this) != 'EEM_Change_Log') { |
|
465 | + $this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE); |
|
466 | 466 | } |
467 | 467 | /** |
468 | 468 | * Filters the list of relations on a model. It is best to NOT use this directly and instead just use |
469 | 469 | * EE_Register_Model_Extension |
470 | 470 | * @param EE_Model_Relation_Base[] $_model_relations |
471 | 471 | */ |
472 | - $this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations); |
|
473 | - foreach($this->_model_relations as $model_name => $relation_obj){ |
|
472 | + $this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations); |
|
473 | + foreach ($this->_model_relations as $model_name => $relation_obj) { |
|
474 | 474 | /** @var $relation_obj EE_Model_Relation_Base */ |
475 | 475 | $relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name); |
476 | 476 | } |
477 | - foreach($this->_indexes as $index_name => $index_obj){ |
|
477 | + foreach ($this->_indexes as $index_name => $index_obj) { |
|
478 | 478 | /** @var $index_obj EE_Index */ |
479 | 479 | $index_obj->_construct_finalize($index_name, $this->get_this_model_name()); |
480 | 480 | } |
481 | 481 | |
482 | 482 | $this->set_timezone($timezone); |
483 | 483 | //finalize default where condition strategy, or set default |
484 | - if( ! $this->_default_where_conditions_strategy){ |
|
484 | + if ( ! $this->_default_where_conditions_strategy) { |
|
485 | 485 | //nothing was set during child constructor, so set default |
486 | 486 | $this->_default_where_conditions_strategy = new EE_Default_Where_Conditions(); |
487 | 487 | } |
488 | 488 | $this->_default_where_conditions_strategy->_finalize_construct($this); |
489 | - if( ! $this->_minimum_where_conditions_strategy){ |
|
489 | + if ( ! $this->_minimum_where_conditions_strategy) { |
|
490 | 490 | //nothing was set during child constructor, so set default |
491 | 491 | $this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions(); |
492 | 492 | } |
@@ -494,15 +494,15 @@ discard block |
||
494 | 494 | |
495 | 495 | //if the cap slug hasn't been set, and we haven't set it to false on purpose |
496 | 496 | //to indicate to NOT set it, set it to the logical default |
497 | - if( $this->_caps_slug === null ) { |
|
498 | - EE_Registry::instance()->load_helper( 'Inflector' ); |
|
499 | - $this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() ); |
|
497 | + if ($this->_caps_slug === null) { |
|
498 | + EE_Registry::instance()->load_helper('Inflector'); |
|
499 | + $this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name()); |
|
500 | 500 | } |
501 | 501 | //initialize the standard cap restriction generators if none were specified by the child constructor |
502 | - if( $this->_cap_restriction_generators !== false ){ |
|
503 | - foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){ |
|
504 | - if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) { |
|
505 | - $this->_cap_restriction_generators[ $cap_context ] = apply_filters( |
|
502 | + if ($this->_cap_restriction_generators !== false) { |
|
503 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
504 | + if ( ! isset($this->_cap_restriction_generators[$cap_context])) { |
|
505 | + $this->_cap_restriction_generators[$cap_context] = apply_filters( |
|
506 | 506 | 'FHEE__EEM_Base___construct__standard_cap_restriction_generator', |
507 | 507 | new EE_Restriction_Generator_Protected(), |
508 | 508 | $cap_context, |
@@ -512,23 +512,23 @@ discard block |
||
512 | 512 | } |
513 | 513 | } |
514 | 514 | //if there are cap restriction generators, use them to make the default cap restrictions |
515 | - if( $this->_cap_restriction_generators !== false ){ |
|
516 | - foreach( $this->_cap_restriction_generators as $context => $generator_object ) { |
|
517 | - if( ! $generator_object ){ |
|
515 | + if ($this->_cap_restriction_generators !== false) { |
|
516 | + foreach ($this->_cap_restriction_generators as $context => $generator_object) { |
|
517 | + if ( ! $generator_object) { |
|
518 | 518 | continue; |
519 | 519 | } |
520 | - if( ! $generator_object instanceof EE_Restriction_Generator_Base ){ |
|
520 | + if ( ! $generator_object instanceof EE_Restriction_Generator_Base) { |
|
521 | 521 | throw new EE_Error( |
522 | 522 | sprintf( |
523 | - __( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ), |
|
523 | + __('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'), |
|
524 | 524 | $context, |
525 | 525 | $this->get_this_model_name() |
526 | 526 | ) |
527 | 527 | ); |
528 | 528 | } |
529 | - $action = $this->cap_action_for_context( $context ); |
|
530 | - if( ! $generator_object->construction_finalized() ){ |
|
531 | - $generator_object->_construct_finalize( $this, $action ); |
|
529 | + $action = $this->cap_action_for_context($context); |
|
530 | + if ( ! $generator_object->construction_finalized()) { |
|
531 | + $generator_object->_construct_finalize($this, $action); |
|
532 | 532 | } |
533 | 533 | |
534 | 534 | } |
@@ -542,11 +542,11 @@ discard block |
||
542 | 542 | * @param string $context one of EEM_Base::valid_cap_contexts() |
543 | 543 | * @return EE_Default_Where_Conditions[] |
544 | 544 | */ |
545 | - protected function _generate_cap_restrictions( $context ){ |
|
546 | - if( isset( $this->_cap_restriction_generators[ $context ] ) && |
|
547 | - $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) { |
|
548 | - return $this->_cap_restriction_generators[ $context ]->generate_restrictions(); |
|
549 | - }else{ |
|
545 | + protected function _generate_cap_restrictions($context) { |
|
546 | + if (isset($this->_cap_restriction_generators[$context]) && |
|
547 | + $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) { |
|
548 | + return $this->_cap_restriction_generators[$context]->generate_restrictions(); |
|
549 | + } else { |
|
550 | 550 | return array(); |
551 | 551 | } |
552 | 552 | } |
@@ -559,16 +559,16 @@ discard block |
||
559 | 559 | * @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) |
560 | 560 | * @return static (as in the concrete child class) |
561 | 561 | */ |
562 | - public static function instance( $timezone = NULL ){ |
|
562 | + public static function instance($timezone = NULL) { |
|
563 | 563 | |
564 | 564 | // check if instance of Espresso_model already exists |
565 | 565 | if ( ! static::$_instance instanceof static) { |
566 | 566 | // instantiate Espresso_model |
567 | - static::$_instance = new static( $timezone ); |
|
567 | + static::$_instance = new static($timezone); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | //we might have a timezone set, let set_timezone decide what to do with it |
571 | - static::$_instance->set_timezone( $timezone ); |
|
571 | + static::$_instance->set_timezone($timezone); |
|
572 | 572 | |
573 | 573 | // Espresso_model object |
574 | 574 | return static::$_instance; |
@@ -581,11 +581,11 @@ discard block |
||
581 | 581 | * @param null | string $timezone |
582 | 582 | * @return static |
583 | 583 | */ |
584 | - public static function reset( $timezone = NULL ){ |
|
585 | - if ( ! is_null( static::$_instance ) ) { |
|
584 | + public static function reset($timezone = NULL) { |
|
585 | + if ( ! is_null(static::$_instance)) { |
|
586 | 586 | static::$_instance = null; |
587 | 587 | |
588 | - return self::instance( $timezone ); |
|
588 | + return self::instance($timezone); |
|
589 | 589 | } |
590 | 590 | return null; |
591 | 591 | } |
@@ -596,15 +596,15 @@ discard block |
||
596 | 596 | * @param boolean $translated return localized strings or JUST the array. |
597 | 597 | * @return array |
598 | 598 | */ |
599 | - public function status_array( $translated = FALSE ) { |
|
600 | - if ( !array_key_exists('Status', $this->_model_relations ) ) |
|
599 | + public function status_array($translated = FALSE) { |
|
600 | + if ( ! array_key_exists('Status', $this->_model_relations)) |
|
601 | 601 | return array(); |
602 | 602 | $model_name = $this->get_this_model_name(); |
603 | - $status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) ); |
|
604 | - $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) ); |
|
603 | + $status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name))); |
|
604 | + $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type))); |
|
605 | 605 | $status_array = array(); |
606 | - foreach ( $stati as $status ) { |
|
607 | - $status_array[ $status->ID() ] = $status->get('STS_code'); |
|
606 | + foreach ($stati as $status) { |
|
607 | + $status_array[$status->ID()] = $status->get('STS_code'); |
|
608 | 608 | } |
609 | 609 | return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array; |
610 | 610 | } |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | * 'order_by'=>array('ANS_value'=>'ASC') |
788 | 788 | * )); |
789 | 789 | */ |
790 | - function get_all($query_params = array()){ |
|
790 | + function get_all($query_params = array()) { |
|
791 | 791 | return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL)); |
792 | 792 | } |
793 | 793 | |
@@ -797,10 +797,10 @@ discard block |
||
797 | 797 | * @param array $query_params @see EEM_Base::get_all() |
798 | 798 | * @return array like EEM_Base::get_all |
799 | 799 | */ |
800 | - function alter_query_params_to_only_include_mine( $query_params = array() ) { |
|
800 | + function alter_query_params_to_only_include_mine($query_params = array()) { |
|
801 | 801 | $wp_user_field_name = $this->wp_user_field_name(); |
802 | - if( $wp_user_field_name ){ |
|
803 | - $query_params[0][ $wp_user_field_name ] = get_current_user_id(); |
|
802 | + if ($wp_user_field_name) { |
|
803 | + $query_params[0][$wp_user_field_name] = get_current_user_id(); |
|
804 | 804 | } |
805 | 805 | return $query_params; |
806 | 806 | } |
@@ -813,19 +813,19 @@ discard block |
||
813 | 813 | * foreign key to the WP_User table |
814 | 814 | */ |
815 | 815 | function wp_user_field_name() { |
816 | - try{ |
|
817 | - if( ! empty( $this->_model_chain_to_wp_user ) ) { |
|
818 | - $models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user ); |
|
819 | - $last_model_name = end( $models_to_follow_to_wp_users ); |
|
820 | - $model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name ); |
|
821 | - $model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.'; |
|
822 | - }else{ |
|
816 | + try { |
|
817 | + if ( ! empty($this->_model_chain_to_wp_user)) { |
|
818 | + $models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user); |
|
819 | + $last_model_name = end($models_to_follow_to_wp_users); |
|
820 | + $model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name); |
|
821 | + $model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.'; |
|
822 | + } else { |
|
823 | 823 | $model_with_fk_to_wp_users = $this; |
824 | 824 | $model_chain_to_wp_user = ''; |
825 | 825 | } |
826 | - $wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' ); |
|
827 | - return $model_chain_to_wp_user . $wp_user_field->get_name(); |
|
828 | - }catch( EE_Error $e ) { |
|
826 | + $wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User'); |
|
827 | + return $model_chain_to_wp_user.$wp_user_field->get_name(); |
|
828 | + } catch (EE_Error $e) { |
|
829 | 829 | return false; |
830 | 830 | } |
831 | 831 | } |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | * (or transiently-related model) |
840 | 840 | * @return string |
841 | 841 | */ |
842 | - public function model_chain_to_wp_user(){ |
|
842 | + public function model_chain_to_wp_user() { |
|
843 | 843 | return $this->_model_chain_to_wp_user; |
844 | 844 | } |
845 | 845 | |
@@ -851,13 +851,13 @@ discard block |
||
851 | 851 | * @return boolean |
852 | 852 | */ |
853 | 853 | public function is_owned() { |
854 | - if( $this->model_chain_to_wp_user() ){ |
|
854 | + if ($this->model_chain_to_wp_user()) { |
|
855 | 855 | return true; |
856 | - }else{ |
|
857 | - try{ |
|
858 | - $this->get_foreign_key_to( 'WP_User' ); |
|
856 | + } else { |
|
857 | + try { |
|
858 | + $this->get_foreign_key_to('WP_User'); |
|
859 | 859 | return true; |
860 | - }catch( EE_Error $e ){ |
|
860 | + } catch (EE_Error $e) { |
|
861 | 861 | return false; |
862 | 862 | } |
863 | 863 | } |
@@ -876,21 +876,21 @@ discard block |
||
876 | 876 | * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d')) |
877 | 877 | * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
878 | 878 | */ |
879 | - protected function _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){ |
|
879 | + protected function _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) { |
|
880 | 880 | //remember the custom selections, if any |
881 | - if(is_array($columns_to_select)){ |
|
881 | + if (is_array($columns_to_select)) { |
|
882 | 882 | $this->_custom_selections = $columns_to_select; |
883 | - }elseif(is_string($columns_to_select)){ |
|
883 | + }elseif (is_string($columns_to_select)) { |
|
884 | 884 | $this->_custom_selections = array($this->_custom_selections); |
885 | - }else{ |
|
885 | + } else { |
|
886 | 886 | $this->_custom_selections = array(); |
887 | 887 | } |
888 | 888 | |
889 | 889 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
890 | 890 | $select_expressions = $columns_to_select ? $this->_construct_select_from_input($columns_to_select) : $this->_construct_default_select_sql($model_query_info); |
891 | - $SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
891 | + $SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
892 | 892 | // echo "sql:$SQL"; |
893 | - $results = $this->_do_wpdb_query( 'get_results', array($SQL, $output ) );// $wpdb->get_results($SQL, $output); |
|
893 | + $results = $this->_do_wpdb_query('get_results', array($SQL, $output)); // $wpdb->get_results($SQL, $output); |
|
894 | 894 | return $results; |
895 | 895 | } |
896 | 896 | |
@@ -908,7 +908,7 @@ discard block |
||
908 | 908 | * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d')) |
909 | 909 | * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT) |
910 | 910 | */ |
911 | - public function get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){ |
|
911 | + public function get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) { |
|
912 | 912 | return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select); |
913 | 913 | } |
914 | 914 | |
@@ -920,12 +920,12 @@ discard block |
||
920 | 920 | * @throws EE_Error |
921 | 921 | * @return string |
922 | 922 | */ |
923 | - private function _construct_select_from_input($columns_to_select){ |
|
924 | - if(is_array($columns_to_select)){ |
|
923 | + private function _construct_select_from_input($columns_to_select) { |
|
924 | + if (is_array($columns_to_select)) { |
|
925 | 925 | $select_sql_array = array(); |
926 | 926 | |
927 | - foreach($columns_to_select as $alias => $selection_and_datatype){ |
|
928 | - if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){ |
|
927 | + foreach ($columns_to_select as $alias => $selection_and_datatype) { |
|
928 | + if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) { |
|
929 | 929 | throw new EE_Error( |
930 | 930 | sprintf( |
931 | 931 | __( |
@@ -937,24 +937,24 @@ discard block |
||
937 | 937 | ) |
938 | 938 | ); |
939 | 939 | } |
940 | - if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){ |
|
940 | + if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) { |
|
941 | 941 | throw new EE_Error( |
942 | 942 | sprintf( |
943 | 943 | __( |
944 | 944 | "Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)", |
945 | 945 | "event_espresso" |
946 | 946 | ), |
947 | - $selection_and_datatype[ 1 ], |
|
948 | - $selection_and_datatype[ 0 ], |
|
947 | + $selection_and_datatype[1], |
|
948 | + $selection_and_datatype[0], |
|
949 | 949 | $alias, |
950 | - implode( ",", $this->_valid_wpdb_data_types ) |
|
950 | + implode(",", $this->_valid_wpdb_data_types) |
|
951 | 951 | ) |
952 | 952 | ); |
953 | 953 | } |
954 | 954 | $select_sql_array[] = "{$selection_and_datatype[0]} AS $alias"; |
955 | 955 | } |
956 | - $columns_to_select_string = implode(", ",$select_sql_array); |
|
957 | - }else{ |
|
956 | + $columns_to_select_string = implode(", ", $select_sql_array); |
|
957 | + } else { |
|
958 | 958 | $columns_to_select_string = $columns_to_select; |
959 | 959 | } |
960 | 960 | return $columns_to_select_string; |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | * Convenient wrapper for getting the primary key field's name. Eg, on Registration, this would be 'REG_ID' |
968 | 968 | * @return string |
969 | 969 | */ |
970 | - function primary_key_name(){ |
|
970 | + function primary_key_name() { |
|
971 | 971 | return $this->get_primary_key_field()->get_name(); |
972 | 972 | } |
973 | 973 | |
@@ -979,14 +979,14 @@ discard block |
||
979 | 979 | * @param mixed $id int or string, depending on the type of the model's primary key |
980 | 980 | * @return EE_Base_Class |
981 | 981 | */ |
982 | - function get_one_by_ID($id){ |
|
983 | - if( $this->get_from_entity_map( $id ) ){ |
|
984 | - return $this->get_from_entity_map( $id ); |
|
982 | + function get_one_by_ID($id) { |
|
983 | + if ($this->get_from_entity_map($id)) { |
|
984 | + return $this->get_from_entity_map($id); |
|
985 | 985 | } |
986 | 986 | return $this->get_one( |
987 | 987 | $this->alter_query_params_to_restrict_by_ID( |
988 | 988 | $id, |
989 | - array( 'default_where_conditions' => 'minimum' ) |
|
989 | + array('default_where_conditions' => 'minimum') |
|
990 | 990 | ) |
991 | 991 | ); |
992 | 992 | } |
@@ -998,15 +998,15 @@ discard block |
||
998 | 998 | * @param array $query_params |
999 | 999 | * @return array of normal query params, @see EEM_Base::get_all |
1000 | 1000 | */ |
1001 | - public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) { |
|
1002 | - if( ! isset( $query_params[ 0 ] ) ) { |
|
1003 | - $query_params[ 0 ] = array(); |
|
1001 | + public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) { |
|
1002 | + if ( ! isset($query_params[0])) { |
|
1003 | + $query_params[0] = array(); |
|
1004 | 1004 | } |
1005 | - if( $this->has_primary_key_field ( ) ) { |
|
1006 | - $query_params[ 0 ][ $this->primary_key_name() ] = $id ; |
|
1007 | - }else{ |
|
1005 | + if ($this->has_primary_key_field( )) { |
|
1006 | + $query_params[0][$this->primary_key_name()] = $id; |
|
1007 | + } else { |
|
1008 | 1008 | //no primary key, so the $id must be from the get_index_primary_key_string() |
1009 | - $query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) ); |
|
1009 | + $query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id)); |
|
1010 | 1010 | } |
1011 | 1011 | return $query_params; |
1012 | 1012 | } |
@@ -1018,16 +1018,16 @@ discard block |
||
1018 | 1018 | * @param array $query_params like EEM_Base's $query_params variable. |
1019 | 1019 | * @return EE_Base_Class | NULL |
1020 | 1020 | */ |
1021 | - function get_one($query_params = array()){ |
|
1022 | - if( ! is_array( $query_params ) ){ |
|
1023 | - EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
1021 | + function get_one($query_params = array()) { |
|
1022 | + if ( ! is_array($query_params)) { |
|
1023 | + EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
1024 | 1024 | $query_params = array(); |
1025 | 1025 | } |
1026 | 1026 | $query_params['limit'] = 1; |
1027 | 1027 | $items = $this->get_all($query_params); |
1028 | - if(empty($items)){ |
|
1028 | + if (empty($items)) { |
|
1029 | 1029 | return null; |
1030 | - }else{ |
|
1030 | + } else { |
|
1031 | 1031 | return array_shift($items); |
1032 | 1032 | } |
1033 | 1033 | } |
@@ -1051,8 +1051,8 @@ discard block |
||
1051 | 1051 | * |
1052 | 1052 | * @return EE_Base_Class[]|array |
1053 | 1053 | */ |
1054 | - public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
1055 | - return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select ); |
|
1054 | + public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
1055 | + return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | |
@@ -1075,8 +1075,8 @@ discard block |
||
1075 | 1075 | * |
1076 | 1076 | * @return EE_Base_Class[]|array |
1077 | 1077 | */ |
1078 | - public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
1079 | - return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select ); |
|
1078 | + public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
1079 | + return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select); |
|
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | |
@@ -1098,9 +1098,9 @@ discard block |
||
1098 | 1098 | * |
1099 | 1099 | * @return EE_Base_Class|null|array() |
1100 | 1100 | */ |
1101 | - public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
1102 | - $results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select ); |
|
1103 | - return empty( $results ) ? null : reset( $results ); |
|
1101 | + public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
1102 | + $results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select); |
|
1103 | + return empty($results) ? null : reset($results); |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | |
@@ -1122,9 +1122,9 @@ discard block |
||
1122 | 1122 | * |
1123 | 1123 | * @return EE_Base_Class|null|array() |
1124 | 1124 | */ |
1125 | - public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
1126 | - $results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select ); |
|
1127 | - return empty( $results ) ? null : reset( $results ); |
|
1125 | + public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
1126 | + $results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select); |
|
1127 | + return empty($results) ? null : reset($results); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | |
@@ -1150,40 +1150,40 @@ discard block |
||
1150 | 1150 | * @return EE_Base_Class[]|array |
1151 | 1151 | * @throws EE_Error |
1152 | 1152 | */ |
1153 | - protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
1153 | + protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
1154 | 1154 | //if $field_to_order_by is empty then let's assume we're ordering by the primary key. |
1155 | - if ( empty( $field_to_order_by ) ) { |
|
1156 | - if ( $this->has_primary_key_field() ) { |
|
1155 | + if (empty($field_to_order_by)) { |
|
1156 | + if ($this->has_primary_key_field()) { |
|
1157 | 1157 | $field_to_order_by = $this->get_primary_key_field()->get_name(); |
1158 | 1158 | } else { |
1159 | 1159 | |
1160 | - if ( WP_DEBUG ) { |
|
1161 | - throw new EE_Error( __( 'EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field. Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso' ) ); |
|
1160 | + if (WP_DEBUG) { |
|
1161 | + throw new EE_Error(__('EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field. Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso')); |
|
1162 | 1162 | } |
1163 | - EE_Error::add_error( __('There was an error with the query.', 'event_espresso') ); |
|
1163 | + EE_Error::add_error(__('There was an error with the query.', 'event_espresso')); |
|
1164 | 1164 | return array(); |
1165 | 1165 | } |
1166 | 1166 | } |
1167 | 1167 | |
1168 | - if( ! is_array( $query_params ) ){ |
|
1169 | - EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
1168 | + if ( ! is_array($query_params)) { |
|
1169 | + EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
1170 | 1170 | $query_params = array(); |
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | //let's add the where query param for consecutive look up. |
1174 | - $query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value ); |
|
1174 | + $query_params[0][$field_to_order_by] = array($operand, $current_field_value); |
|
1175 | 1175 | $query_params['limit'] = $limit; |
1176 | 1176 | |
1177 | 1177 | //set direction |
1178 | - $incoming_orderby = isset( $query_params['order_by'] ) ? $query_params['order_by'] : array(); |
|
1179 | - $query_params['order_by'] = $operand == '>' ? array( $field_to_order_by => 'ASC' ) + $incoming_orderby : array( $field_to_order_by => 'DESC') + $incoming_orderby; |
|
1178 | + $incoming_orderby = isset($query_params['order_by']) ? $query_params['order_by'] : array(); |
|
1179 | + $query_params['order_by'] = $operand == '>' ? array($field_to_order_by => 'ASC') + $incoming_orderby : array($field_to_order_by => 'DESC') + $incoming_orderby; |
|
1180 | 1180 | |
1181 | 1181 | //if $columns_to_select is empty then that means we're returning EE_Base_Class objects |
1182 | - if ( empty( $columns_to_select ) ) { |
|
1183 | - return $this->get_all( $query_params ); |
|
1182 | + if (empty($columns_to_select)) { |
|
1183 | + return $this->get_all($query_params); |
|
1184 | 1184 | } else { |
1185 | 1185 | //getting just the fields |
1186 | - return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select ); |
|
1186 | + return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select); |
|
1187 | 1187 | } |
1188 | 1188 | } |
1189 | 1189 | |
@@ -1194,18 +1194,18 @@ discard block |
||
1194 | 1194 | * This sets the _timezone property after model object has been instantiated. |
1195 | 1195 | * @param null | string $timezone valid PHP DateTimeZone timezone string |
1196 | 1196 | */ |
1197 | - public function set_timezone( $timezone ) { |
|
1198 | - if ( $timezone !== null ) { |
|
1197 | + public function set_timezone($timezone) { |
|
1198 | + if ($timezone !== null) { |
|
1199 | 1199 | $this->_timezone = $timezone; |
1200 | 1200 | } |
1201 | 1201 | //note we need to loop through relations and set the timezone on those objects as well. |
1202 | - foreach ( $this->_model_relations as $relation ) { |
|
1203 | - $relation->set_timezone( $timezone ); |
|
1202 | + foreach ($this->_model_relations as $relation) { |
|
1203 | + $relation->set_timezone($timezone); |
|
1204 | 1204 | } |
1205 | 1205 | //and finally we do the same for any datetime fields |
1206 | - foreach ( $this->_fields as $field ) { |
|
1207 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1208 | - $field->set_timezone( $timezone ); |
|
1206 | + foreach ($this->_fields as $field) { |
|
1207 | + if ($field instanceof EE_Datetime_Field) { |
|
1208 | + $field->set_timezone($timezone); |
|
1209 | 1209 | } |
1210 | 1210 | } |
1211 | 1211 | } |
@@ -1220,9 +1220,9 @@ discard block |
||
1220 | 1220 | */ |
1221 | 1221 | public function get_timezone() { |
1222 | 1222 | //first validate if timezone is set. If not, then let's set it be whatever is set on the model fields. |
1223 | - if ( empty( $this->_timezone ) ) { |
|
1224 | - foreach( $this->_fields as $field ) { |
|
1225 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1223 | + if (empty($this->_timezone)) { |
|
1224 | + foreach ($this->_fields as $field) { |
|
1225 | + if ($field instanceof EE_Datetime_Field) { |
|
1226 | 1226 | $this->set_timezone($field->get_timezone()); |
1227 | 1227 | break; |
1228 | 1228 | } |
@@ -1230,9 +1230,9 @@ discard block |
||
1230 | 1230 | } |
1231 | 1231 | |
1232 | 1232 | //if timezone STILL empty then return the default timezone for the site. |
1233 | - if ( empty( $this->_timezone ) ) { |
|
1234 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
1235 | - $this->set_timezone( EEH_DTT_Helper::get_timezone() ); |
|
1233 | + if (empty($this->_timezone)) { |
|
1234 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1235 | + $this->set_timezone(EEH_DTT_Helper::get_timezone()); |
|
1236 | 1236 | } |
1237 | 1237 | return $this->_timezone; |
1238 | 1238 | } |
@@ -1250,19 +1250,19 @@ discard block |
||
1250 | 1250 | * |
1251 | 1251 | * @return array formats in an array with the date format first, and the time format last. |
1252 | 1252 | */ |
1253 | - public function get_formats_for( $field_name, $pretty = false ) { |
|
1254 | - $field_settings = $this->field_settings_for( $field_name ); |
|
1253 | + public function get_formats_for($field_name, $pretty = false) { |
|
1254 | + $field_settings = $this->field_settings_for($field_name); |
|
1255 | 1255 | |
1256 | 1256 | //if not a valid EE_Datetime_Field then throw error |
1257 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
1258 | - throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) ); |
|
1257 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
1258 | + throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name)); |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | //while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on |
1262 | 1262 | //the field. |
1263 | 1263 | $this->_timezone = $field_settings->get_timezone(); |
1264 | 1264 | |
1265 | - return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) ); |
|
1265 | + return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty)); |
|
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | |
@@ -1286,25 +1286,25 @@ discard block |
||
1286 | 1286 | * @return int|string If the given field_name is not of the EE_Datetime_Field type, then an EE_Error |
1287 | 1287 | * exception is triggered. |
1288 | 1288 | */ |
1289 | - public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) { |
|
1290 | - $formats = $this->get_formats_for( $field_name ); |
|
1289 | + public function current_time_for_query($field_name, $timestamp = false, $what = 'both') { |
|
1290 | + $formats = $this->get_formats_for($field_name); |
|
1291 | 1291 | |
1292 | - $DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) ); |
|
1292 | + $DateTime = new DateTime("now", new DateTimeZone($this->_timezone)); |
|
1293 | 1293 | |
1294 | - if ( $timestamp ) { |
|
1295 | - return $DateTime->format( 'U' ); |
|
1294 | + if ($timestamp) { |
|
1295 | + return $DateTime->format('U'); |
|
1296 | 1296 | } |
1297 | 1297 | |
1298 | 1298 | //not returning timestamp, so return formatted string in timezone. |
1299 | - switch( $what ) { |
|
1299 | + switch ($what) { |
|
1300 | 1300 | case 'time' : |
1301 | - return $DateTime->format( $formats[1] ); |
|
1301 | + return $DateTime->format($formats[1]); |
|
1302 | 1302 | break; |
1303 | 1303 | case 'date' : |
1304 | - return $DateTime->format( $formats[0] ); |
|
1304 | + return $DateTime->format($formats[0]); |
|
1305 | 1305 | break; |
1306 | 1306 | default : |
1307 | - return $DateTime->format( implode( ' ', $formats ) ); |
|
1307 | + return $DateTime->format(implode(' ', $formats)); |
|
1308 | 1308 | break; |
1309 | 1309 | } |
1310 | 1310 | } |
@@ -1328,20 +1328,20 @@ discard block |
||
1328 | 1328 | * 'U', this is ignored. |
1329 | 1329 | * @return DateTime |
1330 | 1330 | */ |
1331 | - public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) { |
|
1331 | + public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') { |
|
1332 | 1332 | |
1333 | 1333 | //just using this to ensure the timezone is set correctly internally |
1334 | - $this->get_formats_for( $field_name ); |
|
1334 | + $this->get_formats_for($field_name); |
|
1335 | 1335 | |
1336 | 1336 | //load EEH_DTT_Helper |
1337 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
1338 | - $set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
1337 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1338 | + $set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone; |
|
1339 | 1339 | |
1340 | - $incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) ); |
|
1341 | - if( $incomingDateTime ) { |
|
1342 | - return $incomingDateTime->setTimeZone( new DateTimeZone( $this->_timezone ) ); |
|
1340 | + $incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone)); |
|
1341 | + if ($incomingDateTime) { |
|
1342 | + return $incomingDateTime->setTimeZone(new DateTimeZone($this->_timezone)); |
|
1343 | 1343 | } else { |
1344 | - return new DateTime( null, new DateTimeZone( $set_timezone ) ); |
|
1344 | + return new DateTime(null, new DateTimeZone($set_timezone)); |
|
1345 | 1345 | } |
1346 | 1346 | } |
1347 | 1347 | |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects |
1353 | 1353 | * @return EE_Table_Base[] |
1354 | 1354 | */ |
1355 | - function get_tables(){ |
|
1355 | + function get_tables() { |
|
1356 | 1356 | return $this->_tables; |
1357 | 1357 | } |
1358 | 1358 | |
@@ -1386,9 +1386,9 @@ discard block |
||
1386 | 1386 | * be aware that model objects being used could get out-of-sync with the database |
1387 | 1387 | * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad) |
1388 | 1388 | */ |
1389 | - function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){ |
|
1390 | - if( ! is_array( $query_params ) ){ |
|
1391 | - EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
1389 | + function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) { |
|
1390 | + if ( ! is_array($query_params)) { |
|
1391 | + EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
1392 | 1392 | $query_params = array(); |
1393 | 1393 | } |
1394 | 1394 | /** |
@@ -1398,7 +1398,7 @@ discard block |
||
1398 | 1398 | * @param array $fields_n_values the updated fields and their new values |
1399 | 1399 | * @param array $query_params @see EEM_Base::get_all() |
1400 | 1400 | */ |
1401 | - do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params ); |
|
1401 | + do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params); |
|
1402 | 1402 | /** |
1403 | 1403 | * Filters the fields about to be updated given the query parameters. You can provide the |
1404 | 1404 | * $query_params to $this->get_all() to find exactly which records will be updated |
@@ -1406,10 +1406,10 @@ discard block |
||
1406 | 1406 | * @param EEM_Base $model the model being queried |
1407 | 1407 | * @param array $query_params see EEM_Base::get_all() |
1408 | 1408 | */ |
1409 | - $fields_n_values = apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params ); |
|
1409 | + $fields_n_values = apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params); |
|
1410 | 1410 | //need to verify that, for any entry we want to update, there are entries in each secondary table. |
1411 | 1411 | //to do that, for each table, verify that it's PK isn't null. |
1412 | - $tables= $this->get_tables(); |
|
1412 | + $tables = $this->get_tables(); |
|
1413 | 1413 | |
1414 | 1414 | //and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query |
1415 | 1415 | //NOTE: we should make this code more efficient by NOT querying twice |
@@ -1419,29 +1419,29 @@ discard block |
||
1419 | 1419 | //we want to make sure the default_where strategy is ignored |
1420 | 1420 | $this->_ignore_where_strategy = TRUE; |
1421 | 1421 | $wpdb_select_results = $this->_get_all_wpdb_results($query_params); |
1422 | - foreach( $wpdb_select_results as $wpdb_result ){ |
|
1422 | + foreach ($wpdb_select_results as $wpdb_result) { |
|
1423 | 1423 | // type cast stdClass as array |
1424 | - $wpdb_result = (array)$wpdb_result; |
|
1424 | + $wpdb_result = (array) $wpdb_result; |
|
1425 | 1425 | //get the model object's PK, as we'll want this if we need to insert a row into secondary tables |
1426 | - if( $this->has_primary_key_field() ){ |
|
1427 | - $main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ]; |
|
1428 | - }else{ |
|
1426 | + if ($this->has_primary_key_field()) { |
|
1427 | + $main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()]; |
|
1428 | + } else { |
|
1429 | 1429 | //if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work) |
1430 | 1430 | $main_table_pk_value = null; |
1431 | 1431 | } |
1432 | 1432 | //if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables |
1433 | 1433 | //and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query |
1434 | - if(count($tables) > 1){ |
|
1434 | + if (count($tables) > 1) { |
|
1435 | 1435 | //foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry |
1436 | 1436 | //in that table, and so we'll want to insert one |
1437 | - foreach($tables as $table_obj){ |
|
1437 | + foreach ($tables as $table_obj) { |
|
1438 | 1438 | $this_table_pk_column = $table_obj->get_fully_qualified_pk_column(); |
1439 | 1439 | //if there is no private key for this table on the results, it means there's no entry |
1440 | 1440 | //in this table, right? so insert a row in the current table, using any fields available |
1441 | - if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){ |
|
1441 | + if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) { |
|
1442 | 1442 | $success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value); |
1443 | 1443 | //if we died here, report the error |
1444 | - if( ! $success ) { |
|
1444 | + if ( ! $success) { |
|
1445 | 1445 | return false; |
1446 | 1446 | } |
1447 | 1447 | } |
@@ -1461,44 +1461,44 @@ discard block |
||
1461 | 1461 | //if this wasn't called from a model object (to update itself) |
1462 | 1462 | //then we want to make sure we keep all the existing |
1463 | 1463 | //model objects in sync with the db |
1464 | - if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){ |
|
1465 | - if( $this->has_primary_key_field() ){ |
|
1466 | - $model_objs_affected_ids = $this->get_col( $query_params ); |
|
1467 | - }else{ |
|
1464 | + if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) { |
|
1465 | + if ($this->has_primary_key_field()) { |
|
1466 | + $model_objs_affected_ids = $this->get_col($query_params); |
|
1467 | + } else { |
|
1468 | 1468 | //we need to select a bunch of columns and then combine them into the the "index primary key string"s |
1469 | - $models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A ); |
|
1469 | + $models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A); |
|
1470 | 1470 | $model_objs_affected_ids = array(); |
1471 | - foreach( $models_affected_key_columns as $row ){ |
|
1472 | - $combined_index_key = $this->get_index_primary_key_string( $row ); |
|
1473 | - $model_objs_affected_ids[ $combined_index_key ] = $combined_index_key; |
|
1471 | + foreach ($models_affected_key_columns as $row) { |
|
1472 | + $combined_index_key = $this->get_index_primary_key_string($row); |
|
1473 | + $model_objs_affected_ids[$combined_index_key] = $combined_index_key; |
|
1474 | 1474 | } |
1475 | 1475 | |
1476 | 1476 | } |
1477 | 1477 | |
1478 | - if( ! $model_objs_affected_ids ){ |
|
1478 | + if ( ! $model_objs_affected_ids) { |
|
1479 | 1479 | //wait wait wait- if nothing was affected let's stop here |
1480 | 1480 | return 0; |
1481 | 1481 | } |
1482 | - foreach( $model_objs_affected_ids as $id ){ |
|
1483 | - $model_obj_in_entity_map = $this->get_from_entity_map( $id ); |
|
1484 | - if( $model_obj_in_entity_map ){ |
|
1485 | - foreach( $fields_n_values as $field => $new_value ){ |
|
1486 | - $model_obj_in_entity_map->set( $field, $new_value ); |
|
1482 | + foreach ($model_objs_affected_ids as $id) { |
|
1483 | + $model_obj_in_entity_map = $this->get_from_entity_map($id); |
|
1484 | + if ($model_obj_in_entity_map) { |
|
1485 | + foreach ($fields_n_values as $field => $new_value) { |
|
1486 | + $model_obj_in_entity_map->set($field, $new_value); |
|
1487 | 1487 | } |
1488 | 1488 | } |
1489 | 1489 | } |
1490 | 1490 | //if there is a primary key on this model, we can now do a slight optimization |
1491 | - if( $this->has_primary_key_field() ){ |
|
1491 | + if ($this->has_primary_key_field()) { |
|
1492 | 1492 | //we already know what we want to update. So let's make the query simpler so it's a little more efficient |
1493 | 1493 | $query_params = array( |
1494 | - array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ), |
|
1495 | - 'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' ); |
|
1494 | + array($this->primary_key_name() => array('IN', $model_objs_affected_ids)), |
|
1495 | + 'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' ); |
|
1496 | 1496 | } |
1497 | 1497 | } |
1498 | 1498 | |
1499 | - $model_query_info = $this->_create_model_query_info_carrier( $query_params ); |
|
1500 | - $SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc. |
|
1501 | - $rows_affected = $this->_do_wpdb_query('query', array( $SQL ) ); |
|
1499 | + $model_query_info = $this->_create_model_query_info_carrier($query_params); |
|
1500 | + $SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc. |
|
1501 | + $rows_affected = $this->_do_wpdb_query('query', array($SQL)); |
|
1502 | 1502 | /** |
1503 | 1503 | * Action called after a model update call has been made. |
1504 | 1504 | * |
@@ -1507,8 +1507,8 @@ discard block |
||
1507 | 1507 | * @param array $query_params @see EEM_Base::get_all() |
1508 | 1508 | * @param int $rows_affected |
1509 | 1509 | */ |
1510 | - do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected ); |
|
1511 | - return $rows_affected;//how many supposedly got updated |
|
1510 | + do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected); |
|
1511 | + return $rows_affected; //how many supposedly got updated |
|
1512 | 1512 | } |
1513 | 1513 | |
1514 | 1514 | /** |
@@ -1520,22 +1520,22 @@ discard block |
||
1520 | 1520 | * @param string $field_to_select |
1521 | 1521 | * @return array just like $wpdb->get_col() |
1522 | 1522 | */ |
1523 | - public function get_col( $query_params = array(), $field_to_select = NULL ){ |
|
1523 | + public function get_col($query_params = array(), $field_to_select = NULL) { |
|
1524 | 1524 | |
1525 | - if( $field_to_select ){ |
|
1526 | - $field = $this->field_settings_for( $field_to_select ); |
|
1527 | - }elseif( $this->has_primary_key_field ( ) ){ |
|
1525 | + if ($field_to_select) { |
|
1526 | + $field = $this->field_settings_for($field_to_select); |
|
1527 | + }elseif ($this->has_primary_key_field( )) { |
|
1528 | 1528 | $field = $this->get_primary_key_field(); |
1529 | - }else{ |
|
1529 | + } else { |
|
1530 | 1530 | //no primary key, just grab the first column |
1531 | - $field = reset( $this->field_settings()); |
|
1531 | + $field = reset($this->field_settings()); |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | |
1535 | 1535 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1536 | 1536 | $select_expressions = $field->get_qualified_column(); |
1537 | - $SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1538 | - $results = $this->_do_wpdb_query('get_col', array( $SQL ) ); |
|
1537 | + $SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1538 | + $results = $this->_do_wpdb_query('get_col', array($SQL)); |
|
1539 | 1539 | return $results; |
1540 | 1540 | } |
1541 | 1541 | |
@@ -1545,12 +1545,12 @@ discard block |
||
1545 | 1545 | * @param string $field_to_select @see EEM_Base::get_col() |
1546 | 1546 | * @return string |
1547 | 1547 | */ |
1548 | - public function get_var( $query_params = array(), $field_to_select = NULL ) { |
|
1549 | - $query_params[ 'limit' ] = 1; |
|
1550 | - $col = $this->get_col( $query_params, $field_to_select ); |
|
1551 | - if( ! empty( $col ) ) { |
|
1552 | - return reset( $col ); |
|
1553 | - }else{ |
|
1548 | + public function get_var($query_params = array(), $field_to_select = NULL) { |
|
1549 | + $query_params['limit'] = 1; |
|
1550 | + $col = $this->get_col($query_params, $field_to_select); |
|
1551 | + if ( ! empty($col)) { |
|
1552 | + return reset($col); |
|
1553 | + } else { |
|
1554 | 1554 | return NULL; |
1555 | 1555 | } |
1556 | 1556 | } |
@@ -1564,19 +1564,19 @@ discard block |
||
1564 | 1564 | * @param array $fields_n_values array keys are field names on this model, and values are what those fields should be updated to in the DB |
1565 | 1565 | * @return string of SQL |
1566 | 1566 | */ |
1567 | - function _construct_update_sql($fields_n_values){ |
|
1567 | + function _construct_update_sql($fields_n_values) { |
|
1568 | 1568 | /** @type WPDB $wpdb */ |
1569 | 1569 | global $wpdb; |
1570 | 1570 | $cols_n_values = array(); |
1571 | - foreach($fields_n_values as $field_name => $value){ |
|
1571 | + foreach ($fields_n_values as $field_name => $value) { |
|
1572 | 1572 | $field_obj = $this->field_settings_for($field_name); |
1573 | 1573 | //if the value is NULL, we want to assign the value to that. |
1574 | 1574 | //wpdb->prepare doesn't really handle that properly |
1575 | - $prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values ); |
|
1576 | - $value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value ); |
|
1575 | + $prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values); |
|
1576 | + $value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value); |
|
1577 | 1577 | $cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql; |
1578 | 1578 | } |
1579 | - return implode(",",$cols_n_values); |
|
1579 | + return implode(",", $cols_n_values); |
|
1580 | 1580 | |
1581 | 1581 | } |
1582 | 1582 | |
@@ -1589,10 +1589,10 @@ discard block |
||
1589 | 1589 | * @param boolean $allow_blocking whether to block deletion if related things exist, or not |
1590 | 1590 | * @return boolean whether the row got deleted or not |
1591 | 1591 | */ |
1592 | - public function delete_permanently_by_ID( $id, $allow_blocking = true ) { |
|
1592 | + public function delete_permanently_by_ID($id, $allow_blocking = true) { |
|
1593 | 1593 | return $this->delete_permanently( |
1594 | 1594 | array( |
1595 | - array( $this->get_primary_key_field()->get_name() => $id ), |
|
1595 | + array($this->get_primary_key_field()->get_name() => $id), |
|
1596 | 1596 | 'limit' => 1 |
1597 | 1597 | ), |
1598 | 1598 | $allow_blocking |
@@ -1610,10 +1610,10 @@ discard block |
||
1610 | 1610 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
1611 | 1611 | * @return boolean whether the row got deleted or not |
1612 | 1612 | */ |
1613 | - public function delete_by_ID( $id, $allow_blocking = true ){ |
|
1613 | + public function delete_by_ID($id, $allow_blocking = true) { |
|
1614 | 1614 | return $this->delete( |
1615 | 1615 | array( |
1616 | - array( $this->get_primary_key_field()->get_name() => $id ), |
|
1616 | + array($this->get_primary_key_field()->get_name() => $id), |
|
1617 | 1617 | 'limit' => 1 |
1618 | 1618 | ), |
1619 | 1619 | $allow_blocking |
@@ -1627,7 +1627,7 @@ discard block |
||
1627 | 1627 | * @param boolean $allow_blocking |
1628 | 1628 | * @return @see EEM_Base::delete_permanently |
1629 | 1629 | */ |
1630 | - function delete($query_params,$allow_blocking = true){ |
|
1630 | + function delete($query_params, $allow_blocking = true) { |
|
1631 | 1631 | return $this->delete_permanently($query_params, $allow_blocking); |
1632 | 1632 | } |
1633 | 1633 | |
@@ -1643,7 +1643,7 @@ discard block |
||
1643 | 1643 | * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB |
1644 | 1644 | * @return int how many rows got deleted |
1645 | 1645 | */ |
1646 | - function delete_permanently($query_params,$allow_blocking = true){ |
|
1646 | + function delete_permanently($query_params, $allow_blocking = true) { |
|
1647 | 1647 | /** |
1648 | 1648 | * Action called just before performing a real deletion query. You can use the |
1649 | 1649 | * model and its $query_params to find exactly which items will be deleted |
@@ -1652,34 +1652,34 @@ discard block |
||
1652 | 1652 | * @param boolean $allow_blocking whether or not to allow related model objects |
1653 | 1653 | * to block (prevent) this deletion |
1654 | 1654 | */ |
1655 | - do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking ); |
|
1655 | + do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking); |
|
1656 | 1656 | //some MySQL databases may be running safe mode, which may restrict |
1657 | 1657 | //deletion if there is no KEY column used in the WHERE statement of a deletion. |
1658 | 1658 | //to get around this, we first do a SELECT, get all the IDs, and then run another query |
1659 | 1659 | //to delete them |
1660 | 1660 | $items_for_deletion = $this->_get_all_wpdb_results($query_params); |
1661 | - $deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking); |
|
1662 | - if($deletion_where){ |
|
1661 | + $deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking); |
|
1662 | + if ($deletion_where) { |
|
1663 | 1663 | //echo "objects for deletion:";var_dump($objects_for_deletion); |
1664 | 1664 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1665 | 1665 | $table_aliases = array(); |
1666 | - foreach(array_keys($this->_tables) as $table_alias){ |
|
1666 | + foreach (array_keys($this->_tables) as $table_alias) { |
|
1667 | 1667 | $table_aliases[] = $table_alias; |
1668 | 1668 | } |
1669 | - $SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where; |
|
1669 | + $SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where; |
|
1670 | 1670 | |
1671 | 1671 | // /echo "delete sql:$SQL"; |
1672 | - $rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) ); |
|
1673 | - }else{ |
|
1672 | + $rows_deleted = $this->_do_wpdb_query('query', array($SQL)); |
|
1673 | + } else { |
|
1674 | 1674 | $rows_deleted = 0; |
1675 | 1675 | } |
1676 | 1676 | |
1677 | 1677 | //and lastly make sure those items are removed from the entity map; if they could be put into it at all |
1678 | - if( $this->has_primary_key_field() ){ |
|
1679 | - foreach($items_for_deletion as $item_for_deletion_row ){ |
|
1680 | - $pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ]; |
|
1681 | - if( isset( $this->_entity_map[ $pk_value ] ) ){ |
|
1682 | - unset( $this->_entity_map[ $pk_value ] ); |
|
1678 | + if ($this->has_primary_key_field()) { |
|
1679 | + foreach ($items_for_deletion as $item_for_deletion_row) { |
|
1680 | + $pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()]; |
|
1681 | + if (isset($this->_entity_map[$pk_value])) { |
|
1682 | + unset($this->_entity_map[$pk_value]); |
|
1683 | 1683 | } |
1684 | 1684 | } |
1685 | 1685 | } |
@@ -1691,8 +1691,8 @@ discard block |
||
1691 | 1691 | * @param array $query_params @see EEM_Base::get_all() |
1692 | 1692 | * @param int $rows_deleted |
1693 | 1693 | */ |
1694 | - do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted ); |
|
1695 | - return $rows_deleted;//how many supposedly got deleted |
|
1694 | + do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted); |
|
1695 | + return $rows_deleted; //how many supposedly got deleted |
|
1696 | 1696 | } |
1697 | 1697 | |
1698 | 1698 | |
@@ -1708,28 +1708,28 @@ discard block |
||
1708 | 1708 | * blocking its deletion before removing the relation between A and B |
1709 | 1709 | * @return boolean |
1710 | 1710 | */ |
1711 | - public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){ |
|
1711 | + public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) { |
|
1712 | 1712 | //first, if $ignore_this_model_obj was supplied, get its model |
1713 | - if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){ |
|
1713 | + if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) { |
|
1714 | 1714 | $ignored_model = $ignore_this_model_obj->get_model(); |
1715 | - }else{ |
|
1715 | + } else { |
|
1716 | 1716 | $ignored_model = null; |
1717 | 1717 | } |
1718 | 1718 | //now check all the relations of $this_model_obj_or_id and see if there |
1719 | 1719 | //are any related model objects blocking it? |
1720 | 1720 | $is_blocked = false; |
1721 | - foreach($this->_model_relations as $relation_name => $relation_obj){ |
|
1722 | - if( $relation_obj->block_delete_if_related_models_exist()){ |
|
1721 | + foreach ($this->_model_relations as $relation_name => $relation_obj) { |
|
1722 | + if ($relation_obj->block_delete_if_related_models_exist()) { |
|
1723 | 1723 | //if $ignore_this_model_obj was supplied, then for the query |
1724 | 1724 | //on that model needs to be told to ignore $ignore_this_model_obj |
1725 | - if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){ |
|
1726 | - $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array( |
|
1727 | - array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID())))); |
|
1728 | - }else{ |
|
1725 | + if ($ignored_model && $relation_name == $ignored_model->get_this_model_name()) { |
|
1726 | + $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array( |
|
1727 | + array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID())))); |
|
1728 | + } else { |
|
1729 | 1729 | $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id); |
1730 | 1730 | } |
1731 | 1731 | |
1732 | - if($related_model_objects){ |
|
1732 | + if ($related_model_objects) { |
|
1733 | 1733 | EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__); |
1734 | 1734 | $is_blocked = true; |
1735 | 1735 | } |
@@ -1749,65 +1749,65 @@ discard block |
||
1749 | 1749 | * @throws EE_Error |
1750 | 1750 | * @return string everything that comes after the WHERE statement. |
1751 | 1751 | */ |
1752 | - protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) { |
|
1753 | - if($this->has_primary_key_field()){ |
|
1752 | + protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) { |
|
1753 | + if ($this->has_primary_key_field()) { |
|
1754 | 1754 | $primary_table = $this->_get_main_table(); |
1755 | 1755 | $other_tables = $this->_get_other_tables(); |
1756 | 1756 | $deletes = $query = array(); |
1757 | - foreach ( $objects_for_deletion as $delete_object ) { |
|
1757 | + foreach ($objects_for_deletion as $delete_object) { |
|
1758 | 1758 | //before we mark this object for deletion, |
1759 | 1759 | //make sure there's no related objects blocking its deletion (if we're checking) |
1760 | - if( $allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()]) ){ |
|
1760 | + if ($allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()])) { |
|
1761 | 1761 | continue; |
1762 | 1762 | } |
1763 | 1763 | |
1764 | 1764 | //primary table deletes |
1765 | - if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) ) |
|
1765 | + if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()])) |
|
1766 | 1766 | $deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()]; |
1767 | 1767 | |
1768 | 1768 | //other tables |
1769 | - if ( !empty( $other_tables ) ) { |
|
1770 | - foreach ( $other_tables as $ot ) { |
|
1769 | + if ( ! empty($other_tables)) { |
|
1770 | + foreach ($other_tables as $ot) { |
|
1771 | 1771 | |
1772 | 1772 | //first check if we've got the foreign key column here. |
1773 | - if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) ) |
|
1773 | + if (isset($delete_object[$ot->get_fully_qualified_fk_column()])) |
|
1774 | 1774 | $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()]; |
1775 | 1775 | |
1776 | 1776 | //wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables |
1777 | - if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) ) |
|
1777 | + if (isset($delete_object[$ot->get_fully_qualified_pk_column()])) |
|
1778 | 1778 | $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
1779 | 1779 | |
1780 | 1780 | //finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there! |
1781 | - if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) ) |
|
1781 | + if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()])) |
|
1782 | 1782 | $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
1783 | 1783 | } |
1784 | 1784 | } |
1785 | 1785 | } |
1786 | 1786 | |
1787 | 1787 | //we should have deletes now, so let's just go through and setup the where statement |
1788 | - foreach ( $deletes as $column => $values ) { |
|
1788 | + foreach ($deletes as $column => $values) { |
|
1789 | 1789 | //make sure we have unique $values; |
1790 | 1790 | $values = array_unique($values); |
1791 | - $query[] = $column . ' IN(' . implode(",",$values) . ')'; |
|
1791 | + $query[] = $column.' IN('.implode(",", $values).')'; |
|
1792 | 1792 | } |
1793 | 1793 | |
1794 | - return !empty($query) ? implode(' AND ', $query ) : ''; |
|
1795 | - }elseif(count($this->get_combined_primary_key_fields()) > 1){ |
|
1794 | + return ! empty($query) ? implode(' AND ', $query) : ''; |
|
1795 | + }elseif (count($this->get_combined_primary_key_fields()) > 1) { |
|
1796 | 1796 | $ways_to_identify_a_row = array(); |
1797 | 1797 | $fields = $this->get_combined_primary_key_fields(); |
1798 | 1798 | //note: because there' sno primary key, that means nothing else can be pointing to this model, right? |
1799 | - foreach($objects_for_deletion as $delete_object){ |
|
1799 | + foreach ($objects_for_deletion as $delete_object) { |
|
1800 | 1800 | $values_for_each_cpk_for_a_row = array(); |
1801 | - foreach($fields as $cpk_field){ |
|
1801 | + foreach ($fields as $cpk_field) { |
|
1802 | 1802 | $values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()]; |
1803 | 1803 | } |
1804 | - $ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")"; |
|
1804 | + $ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")"; |
|
1805 | 1805 | } |
1806 | - return implode(" OR ",$ways_to_identify_a_row); |
|
1807 | - }else{ |
|
1806 | + return implode(" OR ", $ways_to_identify_a_row); |
|
1807 | + } else { |
|
1808 | 1808 | //so there's no primary key and no combined key... |
1809 | 1809 | //sorry, can't help you |
1810 | - throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this))); |
|
1810 | + throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this))); |
|
1811 | 1811 | } |
1812 | 1812 | } |
1813 | 1813 | |
@@ -1821,21 +1821,21 @@ discard block |
||
1821 | 1821 | * @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; |
1822 | 1822 | * @return int |
1823 | 1823 | */ |
1824 | - function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
1824 | + function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
1825 | 1825 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1826 | - if($field_to_count){ |
|
1826 | + if ($field_to_count) { |
|
1827 | 1827 | $field_obj = $this->field_settings_for($field_to_count); |
1828 | 1828 | $column_to_count = $field_obj->get_qualified_column(); |
1829 | - }elseif($this->has_primary_key_field ()){ |
|
1829 | + }elseif ($this->has_primary_key_field()) { |
|
1830 | 1830 | $pk_field_obj = $this->get_primary_key_field(); |
1831 | 1831 | $column_to_count = $pk_field_obj->get_qualified_column(); |
1832 | - }else{//there's no primary key |
|
1832 | + } else {//there's no primary key |
|
1833 | 1833 | $column_to_count = '*'; |
1834 | 1834 | } |
1835 | 1835 | |
1836 | - $column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count; |
|
1837 | - $SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info); |
|
1838 | - return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) ); |
|
1836 | + $column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count; |
|
1837 | + $SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1838 | + return (int) $this->_do_wpdb_query('get_var', array($SQL)); |
|
1839 | 1839 | } |
1840 | 1840 | |
1841 | 1841 | /** |
@@ -1845,23 +1845,23 @@ discard block |
||
1845 | 1845 | * @param string $field_to_sum name of field (array key in $_fields array) |
1846 | 1846 | * @return float |
1847 | 1847 | */ |
1848 | - function sum($query_params, $field_to_sum = NULL){ |
|
1848 | + function sum($query_params, $field_to_sum = NULL) { |
|
1849 | 1849 | $model_query_info = $this->_create_model_query_info_carrier($query_params); |
1850 | 1850 | |
1851 | - if($field_to_sum){ |
|
1851 | + if ($field_to_sum) { |
|
1852 | 1852 | $field_obj = $this->field_settings_for($field_to_sum); |
1853 | 1853 | |
1854 | - }else{ |
|
1854 | + } else { |
|
1855 | 1855 | $field_obj = $this->get_primary_key_field(); |
1856 | 1856 | } |
1857 | 1857 | $column_to_count = $field_obj->get_qualified_column(); |
1858 | 1858 | |
1859 | - $SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info); |
|
1860 | - $return_value = $this->_do_wpdb_query('get_var',array( $SQL ) ); |
|
1861 | - if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){ |
|
1862 | - return (float)$return_value; |
|
1863 | - }else{//must be %f |
|
1864 | - return (float)$return_value; |
|
1859 | + $SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info); |
|
1860 | + $return_value = $this->_do_wpdb_query('get_var', array($SQL)); |
|
1861 | + if ($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s') { |
|
1862 | + return (float) $return_value; |
|
1863 | + } else {//must be %f |
|
1864 | + return (float) $return_value; |
|
1865 | 1865 | } |
1866 | 1866 | } |
1867 | 1867 | |
@@ -1876,33 +1876,33 @@ discard block |
||
1876 | 1876 | * @global wpdb $wpdb |
1877 | 1877 | * @return mixed |
1878 | 1878 | */ |
1879 | - protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){ |
|
1879 | + protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) { |
|
1880 | 1880 | //if we're in maintenance mode level 2, DON'T run any queries |
1881 | 1881 | //because level 2 indicates the database needs updating and |
1882 | 1882 | //is probably out of sync with the code |
1883 | - if( ! EE_Maintenance_Mode::instance()->models_can_query()){ |
|
1883 | + if ( ! EE_Maintenance_Mode::instance()->models_can_query()) { |
|
1884 | 1884 | throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso"))); |
1885 | 1885 | } |
1886 | 1886 | /** @type WPDB $wpdb */ |
1887 | 1887 | global $wpdb; |
1888 | - if( ! method_exists( $wpdb, $wpdb_method ) ){ |
|
1889 | - throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) ); |
|
1888 | + if ( ! method_exists($wpdb, $wpdb_method)) { |
|
1889 | + throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method)); |
|
1890 | 1890 | } |
1891 | - if( WP_DEBUG ){ |
|
1891 | + if (WP_DEBUG) { |
|
1892 | 1892 | $old_show_errors_value = $wpdb->show_errors; |
1893 | - $wpdb->show_errors( FALSE ); |
|
1894 | - } |
|
1895 | - $result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide ); |
|
1896 | - $this->show_db_query_if_previously_requested( $wpdb->last_query ); |
|
1897 | - if( WP_DEBUG ){ |
|
1898 | - $wpdb->show_errors( $old_show_errors_value ); |
|
1899 | - if( ! empty( $wpdb->last_error ) ){ |
|
1900 | - throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) ); |
|
1901 | - }elseif( $result === false ){ |
|
1902 | - throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) ); |
|
1893 | + $wpdb->show_errors(FALSE); |
|
1894 | + } |
|
1895 | + $result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide); |
|
1896 | + $this->show_db_query_if_previously_requested($wpdb->last_query); |
|
1897 | + if (WP_DEBUG) { |
|
1898 | + $wpdb->show_errors($old_show_errors_value); |
|
1899 | + if ( ! empty($wpdb->last_error)) { |
|
1900 | + throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error)); |
|
1901 | + }elseif ($result === false) { |
|
1902 | + throw new EE_Error(sprintf(__('WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso'), $wpdb_method, var_export($arguments_to_provide, true))); |
|
1903 | 1903 | } |
1904 | - }elseif( $result === false ) { |
|
1905 | - EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__); |
|
1904 | + }elseif ($result === false) { |
|
1905 | + EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__); |
|
1906 | 1906 | } |
1907 | 1907 | return $result; |
1908 | 1908 | } |
@@ -1918,23 +1918,23 @@ discard block |
||
1918 | 1918 | * @param array $arguments_to_provide |
1919 | 1919 | * @return mixed |
1920 | 1920 | */ |
1921 | - private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) { |
|
1921 | + private function _process_wpdb_query($wpdb_method, $arguments_to_provide) { |
|
1922 | 1922 | /** @type WPDB $wpdb */ |
1923 | 1923 | global $wpdb; |
1924 | 1924 | $wpdb->last_error = null; |
1925 | - $result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide ); |
|
1925 | + $result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide); |
|
1926 | 1926 | // was there an error running the query? |
1927 | - if ( ( $result === false || ! empty( $wpdb->last_error ) ) ) { |
|
1928 | - switch ( EEM_Base::$_db_verification_level ) { |
|
1927 | + if (($result === false || ! empty($wpdb->last_error))) { |
|
1928 | + switch (EEM_Base::$_db_verification_level) { |
|
1929 | 1929 | |
1930 | 1930 | case EEM_Base::db_verified_none : |
1931 | 1931 | // let's double-check core's DB |
1932 | - $error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide ); |
|
1932 | + $error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide); |
|
1933 | 1933 | break; |
1934 | 1934 | |
1935 | 1935 | case EEM_Base::db_verified_core : |
1936 | 1936 | // STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed |
1937 | - $error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide ); |
|
1937 | + $error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide); |
|
1938 | 1938 | break; |
1939 | 1939 | |
1940 | 1940 | case EEM_Base::db_verified_addons : |
@@ -1942,11 +1942,11 @@ discard block |
||
1942 | 1942 | return $result; |
1943 | 1943 | break; |
1944 | 1944 | } |
1945 | - if ( ! empty( $error_message ) ) { |
|
1946 | - EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' ); |
|
1947 | - trigger_error( $error_message ); |
|
1945 | + if ( ! empty($error_message)) { |
|
1946 | + EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error'); |
|
1947 | + trigger_error($error_message); |
|
1948 | 1948 | } |
1949 | - return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide ); |
|
1949 | + return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide); |
|
1950 | 1950 | |
1951 | 1951 | } |
1952 | 1952 | |
@@ -1962,18 +1962,18 @@ discard block |
||
1962 | 1962 | * @param array $arguments_to_provide |
1963 | 1963 | * @return string |
1964 | 1964 | */ |
1965 | - private function _verify_core_db( $wpdb_method, $arguments_to_provide ){ |
|
1965 | + private function _verify_core_db($wpdb_method, $arguments_to_provide) { |
|
1966 | 1966 | /** @type WPDB $wpdb */ |
1967 | 1967 | global $wpdb; |
1968 | 1968 | //ok remember that we've already attempted fixing the core db, in case the problem persists |
1969 | 1969 | EEM_Base::$_db_verification_level = EEM_Base::db_verified_core; |
1970 | 1970 | $error_message = sprintf( |
1971 | - __( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ), |
|
1971 | + __('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'), |
|
1972 | 1972 | $wpdb->last_error, |
1973 | 1973 | $wpdb_method, |
1974 | - json_encode( $arguments_to_provide ) |
|
1974 | + json_encode($arguments_to_provide) |
|
1975 | 1975 | ); |
1976 | - EE_System::instance()->initialize_db_if_no_migrations_required( false, true ); |
|
1976 | + EE_System::instance()->initialize_db_if_no_migrations_required(false, true); |
|
1977 | 1977 | return $error_message; |
1978 | 1978 | } |
1979 | 1979 | |
@@ -1986,16 +1986,16 @@ discard block |
||
1986 | 1986 | * @param $arguments_to_provide |
1987 | 1987 | * @return string |
1988 | 1988 | */ |
1989 | - private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) { |
|
1989 | + private function _verify_addons_db($wpdb_method, $arguments_to_provide) { |
|
1990 | 1990 | /** @type WPDB $wpdb */ |
1991 | 1991 | global $wpdb; |
1992 | 1992 | //ok remember that we've already attempted fixing the addons dbs, in case the problem persists |
1993 | 1993 | EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons; |
1994 | 1994 | $error_message = sprintf( |
1995 | - __( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ), |
|
1995 | + __('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'), |
|
1996 | 1996 | $wpdb->last_error, |
1997 | 1997 | $wpdb_method, |
1998 | - json_encode( $arguments_to_provide ) |
|
1998 | + json_encode($arguments_to_provide) |
|
1999 | 1999 | ); |
2000 | 2000 | EE_System::instance()->initialize_addons(); |
2001 | 2001 | return $error_message; |
@@ -2010,7 +2010,7 @@ discard block |
||
2010 | 2010 | * @param EE_Model_Query_Info_Carrier $model_query_info |
2011 | 2011 | * @return string |
2012 | 2012 | */ |
2013 | - private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){ |
|
2013 | + private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) { |
|
2014 | 2014 | return " FROM ".$model_query_info->get_full_join_sql(). |
2015 | 2015 | $model_query_info->get_where_sql(). |
2016 | 2016 | $model_query_info->get_group_by_sql(). |
@@ -2023,7 +2023,7 @@ discard block |
||
2023 | 2023 | * Set to easily debug the next X queries ran from this model. |
2024 | 2024 | * @param int $count |
2025 | 2025 | */ |
2026 | - function show_next_x_db_queries($count = 1){ |
|
2026 | + function show_next_x_db_queries($count = 1) { |
|
2027 | 2027 | $this->_show_next_x_db_queries = $count; |
2028 | 2028 | } |
2029 | 2029 | |
@@ -2032,8 +2032,8 @@ discard block |
||
2032 | 2032 | /** |
2033 | 2033 | * @param $sql_query |
2034 | 2034 | */ |
2035 | - function show_db_query_if_previously_requested($sql_query){ |
|
2036 | - if($this->_show_next_x_db_queries > 0){ |
|
2035 | + function show_db_query_if_previously_requested($sql_query) { |
|
2036 | + if ($this->_show_next_x_db_queries > 0) { |
|
2037 | 2037 | echo $sql_query; |
2038 | 2038 | $this->_show_next_x_db_queries--; |
2039 | 2039 | } |
@@ -2057,9 +2057,9 @@ discard block |
||
2057 | 2057 | * @param array $extra_join_model_fields_n_values This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM). Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well. |
2058 | 2058 | * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj |
2059 | 2059 | */ |
2060 | - public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){ |
|
2060 | + public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) { |
|
2061 | 2061 | $relation_obj = $this->related_settings_for($relationName); |
2062 | - return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values); |
|
2062 | + return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values); |
|
2063 | 2063 | } |
2064 | 2064 | |
2065 | 2065 | /** |
@@ -2078,9 +2078,9 @@ discard block |
||
2078 | 2078 | * @return boolean of success |
2079 | 2079 | * @param array $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM). Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well. |
2080 | 2080 | */ |
2081 | - public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query= array() ){ |
|
2081 | + public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) { |
|
2082 | 2082 | $relation_obj = $this->related_settings_for($relationName); |
2083 | - return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query ); |
|
2083 | + return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query); |
|
2084 | 2084 | } |
2085 | 2085 | |
2086 | 2086 | |
@@ -2093,9 +2093,9 @@ discard block |
||
2093 | 2093 | * @param EE_Base_Class[] objects to which relations were removed |
2094 | 2094 | * @return \EE_Base_Class[] |
2095 | 2095 | */ |
2096 | - public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){ |
|
2096 | + public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) { |
|
2097 | 2097 | $relation_obj = $this->related_settings_for($relationName); |
2098 | - return $relation_obj->remove_relations($id_or_obj, $where_query_params ); |
|
2098 | + return $relation_obj->remove_relations($id_or_obj, $where_query_params); |
|
2099 | 2099 | } |
2100 | 2100 | |
2101 | 2101 | |
@@ -2108,10 +2108,10 @@ discard block |
||
2108 | 2108 | * @param array $query_params like EEM_Base::get_all |
2109 | 2109 | * @return EE_Base_Class[] |
2110 | 2110 | */ |
2111 | - function get_all_related($id_or_obj, $model_name, $query_params = null){ |
|
2111 | + function get_all_related($id_or_obj, $model_name, $query_params = null) { |
|
2112 | 2112 | $model_obj = $this->ensure_is_obj($id_or_obj); |
2113 | 2113 | $relation_settings = $this->related_settings_for($model_name); |
2114 | - return $relation_settings->get_all_related($model_obj,$query_params); |
|
2114 | + return $relation_settings->get_all_related($model_obj, $query_params); |
|
2115 | 2115 | } |
2116 | 2116 | |
2117 | 2117 | /** |
@@ -2124,10 +2124,10 @@ discard block |
||
2124 | 2124 | * @param array $query_params |
2125 | 2125 | * @return int how many deleted |
2126 | 2126 | */ |
2127 | - public function delete_related($id_or_obj,$model_name, $query_params = array()){ |
|
2127 | + public function delete_related($id_or_obj, $model_name, $query_params = array()) { |
|
2128 | 2128 | $model_obj = $this->ensure_is_obj($id_or_obj); |
2129 | 2129 | $relation_settings = $this->related_settings_for($model_name); |
2130 | - return $relation_settings->delete_all_related($model_obj,$query_params); |
|
2130 | + return $relation_settings->delete_all_related($model_obj, $query_params); |
|
2131 | 2131 | } |
2132 | 2132 | |
2133 | 2133 | /** |
@@ -2140,10 +2140,10 @@ discard block |
||
2140 | 2140 | * @param array $query_params |
2141 | 2141 | * @return int how many deleted |
2142 | 2142 | */ |
2143 | - public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){ |
|
2143 | + public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) { |
|
2144 | 2144 | $model_obj = $this->ensure_is_obj($id_or_obj); |
2145 | 2145 | $relation_settings = $this->related_settings_for($model_name); |
2146 | - return $relation_settings->delete_related_permanently($model_obj,$query_params); |
|
2146 | + return $relation_settings->delete_related_permanently($model_obj, $query_params); |
|
2147 | 2147 | } |
2148 | 2148 | |
2149 | 2149 | /** |
@@ -2156,17 +2156,17 @@ discard block |
||
2156 | 2156 | * @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; |
2157 | 2157 | * @return int |
2158 | 2158 | */ |
2159 | - function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){ |
|
2159 | + function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) { |
|
2160 | 2160 | $related_model = $this->get_related_model_obj($model_name); |
2161 | 2161 | //we're just going to use the query params on the related model's normal get_all query, |
2162 | 2162 | //except add a condition to say to match the current mod |
2163 | - if( ! isset($query_params['default_where_conditions'])){ |
|
2164 | - $query_params['default_where_conditions']='none'; |
|
2163 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
2164 | + $query_params['default_where_conditions'] = 'none'; |
|
2165 | 2165 | } |
2166 | 2166 | $this_model_name = $this->get_this_model_name(); |
2167 | 2167 | $this_pk_field_name = $this->get_primary_key_field()->get_name(); |
2168 | - $query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj; |
|
2169 | - return $related_model->count($query_params,$field_to_count,$distinct); |
|
2168 | + $query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj; |
|
2169 | + return $related_model->count($query_params, $field_to_count, $distinct); |
|
2170 | 2170 | } |
2171 | 2171 | |
2172 | 2172 | |
@@ -2180,21 +2180,21 @@ discard block |
||
2180 | 2180 | * @param string $field_to_sum name of field to count by. By default, uses primary key |
2181 | 2181 | * @return float |
2182 | 2182 | */ |
2183 | - function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){ |
|
2183 | + function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) { |
|
2184 | 2184 | $related_model = $this->get_related_model_obj($model_name); |
2185 | - if( ! is_array( $query_params ) ){ |
|
2186 | - EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
2185 | + if ( ! is_array($query_params)) { |
|
2186 | + EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
2187 | 2187 | $query_params = array(); |
2188 | 2188 | } |
2189 | 2189 | //we're just going to use the query params on the related model's normal get_all query, |
2190 | 2190 | //except add a condition to say to match the current mod |
2191 | - if( ! isset($query_params['default_where_conditions'])){ |
|
2192 | - $query_params['default_where_conditions']='none'; |
|
2191 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
2192 | + $query_params['default_where_conditions'] = 'none'; |
|
2193 | 2193 | } |
2194 | 2194 | $this_model_name = $this->get_this_model_name(); |
2195 | 2195 | $this_pk_field_name = $this->get_primary_key_field()->get_name(); |
2196 | - $query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj; |
|
2197 | - return $related_model->sum($query_params,$field_to_sum); |
|
2196 | + $query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj; |
|
2197 | + return $related_model->sum($query_params, $field_to_sum); |
|
2198 | 2198 | } |
2199 | 2199 | |
2200 | 2200 | |
@@ -2206,12 +2206,12 @@ discard block |
||
2206 | 2206 | * @param array $query_params like EEM_Base::get_all's |
2207 | 2207 | * @return EE_Base_Class |
2208 | 2208 | */ |
2209 | - public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){ |
|
2210 | - $query_params['limit']=1; |
|
2211 | - $results = $this->get_all_related($id_or_obj,$other_model_name,$query_params); |
|
2212 | - if( $results ){ |
|
2209 | + public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) { |
|
2210 | + $query_params['limit'] = 1; |
|
2211 | + $results = $this->get_all_related($id_or_obj, $other_model_name, $query_params); |
|
2212 | + if ($results) { |
|
2213 | 2213 | return array_shift($results); |
2214 | - }else{ |
|
2214 | + } else { |
|
2215 | 2215 | return null; |
2216 | 2216 | } |
2217 | 2217 | |
@@ -2221,8 +2221,8 @@ discard block |
||
2221 | 2221 | * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event |
2222 | 2222 | * @return string |
2223 | 2223 | */ |
2224 | - function get_this_model_name(){ |
|
2225 | - return str_replace("EEM_","",get_class($this)); |
|
2224 | + function get_this_model_name() { |
|
2225 | + return str_replace("EEM_", "", get_class($this)); |
|
2226 | 2226 | } |
2227 | 2227 | |
2228 | 2228 | /** |
@@ -2230,14 +2230,14 @@ discard block |
||
2230 | 2230 | * @return EE_Any_Foreign_Model_Name_Field |
2231 | 2231 | * @throws EE_Error |
2232 | 2232 | */ |
2233 | - public function get_field_containing_related_model_name(){ |
|
2234 | - foreach($this->field_settings(true) as $field){ |
|
2235 | - if($field instanceof EE_Any_Foreign_Model_Name_Field){ |
|
2233 | + public function get_field_containing_related_model_name() { |
|
2234 | + foreach ($this->field_settings(true) as $field) { |
|
2235 | + if ($field instanceof EE_Any_Foreign_Model_Name_Field) { |
|
2236 | 2236 | $field_with_model_name = $field; |
2237 | 2237 | } |
2238 | 2238 | } |
2239 | - if( !isset($field_with_model_name) || !$field_with_model_name ){ |
|
2240 | - throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() )); |
|
2239 | + if ( ! isset($field_with_model_name) || ! $field_with_model_name) { |
|
2240 | + throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name())); |
|
2241 | 2241 | } |
2242 | 2242 | return $field_with_model_name; |
2243 | 2243 | } |
@@ -2258,19 +2258,19 @@ discard block |
||
2258 | 2258 | * @return int new primary key on main table that got inserted |
2259 | 2259 | * @throws EE_Error |
2260 | 2260 | */ |
2261 | - function insert($field_n_values){ |
|
2261 | + function insert($field_n_values) { |
|
2262 | 2262 | /** |
2263 | 2263 | * Filters the fields and their values before inserting an item using the models |
2264 | 2264 | * @param array $fields_n_values keys are the fields and values are their new values |
2265 | 2265 | * @param EEM_Base $model the model used |
2266 | 2266 | */ |
2267 | - $field_n_values = apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this ); |
|
2268 | - if($this->_satisfies_unique_indexes($field_n_values)){ |
|
2267 | + $field_n_values = apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this); |
|
2268 | + if ($this->_satisfies_unique_indexes($field_n_values)) { |
|
2269 | 2269 | $main_table = $this->_get_main_table(); |
2270 | 2270 | $new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false); |
2271 | - if( $new_id !== false ) { |
|
2272 | - foreach($this->_get_other_tables() as $other_table){ |
|
2273 | - $this->_insert_into_specific_table($other_table, $field_n_values,$new_id); |
|
2271 | + if ($new_id !== false) { |
|
2272 | + foreach ($this->_get_other_tables() as $other_table) { |
|
2273 | + $this->_insert_into_specific_table($other_table, $field_n_values, $new_id); |
|
2274 | 2274 | } |
2275 | 2275 | } |
2276 | 2276 | /** |
@@ -2280,9 +2280,9 @@ discard block |
||
2280 | 2280 | * @param array $fields_n_values fields and their values |
2281 | 2281 | * @param int|string the ID of the newly-inserted model object |
2282 | 2282 | */ |
2283 | - do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id ); |
|
2283 | + do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id); |
|
2284 | 2284 | return $new_id; |
2285 | - }else{ |
|
2285 | + } else { |
|
2286 | 2286 | return FALSE; |
2287 | 2287 | } |
2288 | 2288 | } |
@@ -2295,11 +2295,11 @@ discard block |
||
2295 | 2295 | * @param string $action |
2296 | 2296 | * @return boolean |
2297 | 2297 | */ |
2298 | - protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){ |
|
2299 | - foreach($this->unique_indexes() as $index_name => $index){ |
|
2298 | + protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') { |
|
2299 | + foreach ($this->unique_indexes() as $index_name => $index) { |
|
2300 | 2300 | $uniqueness_where_params = array_intersect_key($field_n_values, $index->fields()); |
2301 | - if($this->exists(array($uniqueness_where_params))){ |
|
2302 | - EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"),$action,$this->_get_class_name(),$index_name,implode(",",$index->field_names()),http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__ ); |
|
2301 | + if ($this->exists(array($uniqueness_where_params))) { |
|
2302 | + EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"), $action, $this->_get_class_name(), $index_name, implode(",", $index->field_names()), http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__); |
|
2303 | 2303 | return false; |
2304 | 2304 | } |
2305 | 2305 | } |
@@ -2320,28 +2320,28 @@ discard block |
||
2320 | 2320 | * @throws EE_Error |
2321 | 2321 | * @return EE_Base_Class |
2322 | 2322 | */ |
2323 | - public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){ |
|
2324 | - if($obj_or_fields_array instanceof EE_Base_Class){ |
|
2323 | + public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) { |
|
2324 | + if ($obj_or_fields_array instanceof EE_Base_Class) { |
|
2325 | 2325 | $fields_n_values = $obj_or_fields_array->model_field_array(); |
2326 | - }elseif( is_array($obj_or_fields_array)){ |
|
2326 | + }elseif (is_array($obj_or_fields_array)) { |
|
2327 | 2327 | $fields_n_values = $obj_or_fields_array; |
2328 | - }else{ |
|
2329 | - throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array)); |
|
2328 | + } else { |
|
2329 | + throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"), get_class($this), $obj_or_fields_array)); |
|
2330 | 2330 | } |
2331 | - $query_params = array( 'default_where_conditions' => 'minimum' ); |
|
2332 | - if( $this->has_primary_key_field() && |
|
2333 | - ( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) && |
|
2334 | - isset($fields_n_values[$this->primary_key_name()])){ |
|
2331 | + $query_params = array('default_where_conditions' => 'minimum'); |
|
2332 | + if ($this->has_primary_key_field() && |
|
2333 | + ($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) && |
|
2334 | + isset($fields_n_values[$this->primary_key_name()])) { |
|
2335 | 2335 | $query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()]; |
2336 | 2336 | } |
2337 | - foreach($this->unique_indexes() as $unique_index_name=>$unique_index){ |
|
2337 | + foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) { |
|
2338 | 2338 | $uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields()); |
2339 | 2339 | $query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params; |
2340 | 2340 | } |
2341 | 2341 | //if there is nothing to base this search on, then we shouldn't find anything |
2342 | - if( ! isset( $query_params[0] ) || ( isset( $query_params[0] ) && empty( $query_params[0] ) ) ) { |
|
2342 | + if ( ! isset($query_params[0]) || (isset($query_params[0]) && empty($query_params[0]))) { |
|
2343 | 2343 | return array(); |
2344 | - }else{ |
|
2344 | + } else { |
|
2345 | 2345 | return $this->get_one($query_params); |
2346 | 2346 | } |
2347 | 2347 | } |
@@ -2351,7 +2351,7 @@ discard block |
||
2351 | 2351 | * @param array $query_params |
2352 | 2352 | * @return boolean |
2353 | 2353 | */ |
2354 | - function exists($query_params){ |
|
2354 | + function exists($query_params) { |
|
2355 | 2355 | $query_params['limit'] = 1; |
2356 | 2356 | return $this->count($query_params) > 0; |
2357 | 2357 | } |
@@ -2361,7 +2361,7 @@ discard block |
||
2361 | 2361 | * @param int|string $id |
2362 | 2362 | * @return boolean |
2363 | 2363 | */ |
2364 | - function exists_by_ID($id){ |
|
2364 | + function exists_by_ID($id) { |
|
2365 | 2365 | return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id))); |
2366 | 2366 | } |
2367 | 2367 | |
@@ -2381,45 +2381,45 @@ discard block |
||
2381 | 2381 | * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert |
2382 | 2382 | * @return int ID of new row inserted, or FALSE on failure |
2383 | 2383 | */ |
2384 | - protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){ |
|
2384 | + protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) { |
|
2385 | 2385 | global $wpdb; |
2386 | 2386 | $insertion_col_n_values = array(); |
2387 | 2387 | $format_for_insertion = array(); |
2388 | 2388 | $fields_on_table = $this->_get_fields_for_table($table->get_table_alias()); |
2389 | - foreach($fields_on_table as $field_name => $field_obj){ |
|
2389 | + foreach ($fields_on_table as $field_name => $field_obj) { |
|
2390 | 2390 | //check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing |
2391 | - if($field_obj->is_auto_increment()){ |
|
2391 | + if ($field_obj->is_auto_increment()) { |
|
2392 | 2392 | continue; |
2393 | 2393 | } |
2394 | 2394 | $prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values); |
2395 | 2395 | //if the value we want to assign it to is NULL, just don't mention it for the insertion |
2396 | - if( $prepared_value !== NULL ){ |
|
2397 | - $insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value; |
|
2396 | + if ($prepared_value !== NULL) { |
|
2397 | + $insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value; |
|
2398 | 2398 | $format_for_insertion[] = $field_obj->get_wpdb_data_type(); |
2399 | 2399 | } |
2400 | 2400 | } |
2401 | 2401 | |
2402 | - if($table instanceof EE_Secondary_Table && $new_id){ |
|
2402 | + if ($table instanceof EE_Secondary_Table && $new_id) { |
|
2403 | 2403 | //its not the main table, so we should have already saved the main table's PK which we just inserted |
2404 | 2404 | //so add the fk to the main table as a column |
2405 | 2405 | $insertion_col_n_values[$table->get_fk_on_table()] = $new_id; |
2406 | - $format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs |
|
2406 | + $format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs |
|
2407 | 2407 | } |
2408 | 2408 | //insert the new entry |
2409 | - $result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) ); |
|
2410 | - if( $result === false ) { |
|
2409 | + $result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion)); |
|
2410 | + if ($result === false) { |
|
2411 | 2411 | return false; |
2412 | 2412 | } |
2413 | 2413 | //ok, now what do we return for the ID of the newly-inserted thing? |
2414 | - if($this->has_primary_key_field()){ |
|
2415 | - if($this->get_primary_key_field()->is_auto_increment()){ |
|
2414 | + if ($this->has_primary_key_field()) { |
|
2415 | + if ($this->get_primary_key_field()->is_auto_increment()) { |
|
2416 | 2416 | return $wpdb->insert_id; |
2417 | - }else{ |
|
2417 | + } else { |
|
2418 | 2418 | //it's not an auto-increment primary key, so |
2419 | 2419 | //it must have been supplied |
2420 | 2420 | return $fields_n_values[$this->get_primary_key_field()->get_name()]; |
2421 | 2421 | } |
2422 | - }else{ |
|
2422 | + } else { |
|
2423 | 2423 | //we can't return a primary key because there is none. instead return |
2424 | 2424 | //a unique string indicating this model |
2425 | 2425 | return $this->get_index_primary_key_string($fields_n_values); |
@@ -2434,15 +2434,15 @@ discard block |
||
2434 | 2434 | * @param array $fields_n_values |
2435 | 2435 | * @return mixed string|int|float depending on what the table column will be expecting |
2436 | 2436 | */ |
2437 | - protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){ |
|
2437 | + protected function _prepare_value_or_use_default($field_obj, $fields_n_values) { |
|
2438 | 2438 | //if this field doesn't allow nullable, don't allow it |
2439 | - if( ! $field_obj->is_nullable() && ( |
|
2440 | - ! isset( $fields_n_values[ $field_obj->get_name() ] ) || |
|
2441 | - $fields_n_values[ $field_obj->get_name() ] === NULL ) ){ |
|
2442 | - $fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value(); |
|
2439 | + if ( ! $field_obj->is_nullable() && ( |
|
2440 | + ! isset($fields_n_values[$field_obj->get_name()]) || |
|
2441 | + $fields_n_values[$field_obj->get_name()] === NULL )) { |
|
2442 | + $fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value(); |
|
2443 | 2443 | } |
2444 | - $unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL; |
|
2445 | - return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj); |
|
2444 | + $unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL; |
|
2445 | + return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj); |
|
2446 | 2446 | } |
2447 | 2447 | |
2448 | 2448 | |
@@ -2454,9 +2454,9 @@ discard block |
||
2454 | 2454 | * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection |
2455 | 2455 | * @return mixed a value ready for use in the database for insertions, updating, or in a where clause |
2456 | 2456 | */ |
2457 | - private function _prepare_value_for_use_in_db($value, $field){ |
|
2458 | - if($field && $field instanceof EE_Model_Field_Base){ |
|
2459 | - switch( $this->_values_already_prepared_by_model_object ){ |
|
2457 | + private function _prepare_value_for_use_in_db($value, $field) { |
|
2458 | + if ($field && $field instanceof EE_Model_Field_Base) { |
|
2459 | + switch ($this->_values_already_prepared_by_model_object) { |
|
2460 | 2460 | /** @noinspection PhpMissingBreakStatementInspection */ |
2461 | 2461 | case self::not_prepared_by_model_object: |
2462 | 2462 | $value = $field->prepare_for_set($value); |
@@ -2467,7 +2467,7 @@ discard block |
||
2467 | 2467 | //leave the value alone |
2468 | 2468 | } |
2469 | 2469 | return $value; |
2470 | - }else{ |
|
2470 | + } else { |
|
2471 | 2471 | return $value; |
2472 | 2472 | } |
2473 | 2473 | } |
@@ -2477,13 +2477,13 @@ discard block |
||
2477 | 2477 | * @return EE_Primary_Table |
2478 | 2478 | * @throws EE_Error |
2479 | 2479 | */ |
2480 | - protected function _get_main_table(){ |
|
2481 | - foreach($this->_tables as $table){ |
|
2482 | - if($table instanceof EE_Primary_Table){ |
|
2480 | + protected function _get_main_table() { |
|
2481 | + foreach ($this->_tables as $table) { |
|
2482 | + if ($table instanceof EE_Primary_Table) { |
|
2483 | 2483 | return $table; |
2484 | 2484 | } |
2485 | 2485 | } |
2486 | - throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this))); |
|
2486 | + throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this))); |
|
2487 | 2487 | } |
2488 | 2488 | |
2489 | 2489 | /** |
@@ -2502,7 +2502,7 @@ discard block |
||
2502 | 2502 | */ |
2503 | 2503 | public function second_table() { |
2504 | 2504 | // grab second table from tables array |
2505 | - $second_table = end( $this->_tables ); |
|
2505 | + $second_table = end($this->_tables); |
|
2506 | 2506 | return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL; |
2507 | 2507 | } |
2508 | 2508 | |
@@ -2515,8 +2515,8 @@ discard block |
||
2515 | 2515 | * @param string $table_alias |
2516 | 2516 | * @return EE_Primary_Table | EE_Secondary_Table |
2517 | 2517 | */ |
2518 | - public function get_table_obj_by_alias( $table_alias = '' ) { |
|
2519 | - return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL; |
|
2518 | + public function get_table_obj_by_alias($table_alias = '') { |
|
2519 | + return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL; |
|
2520 | 2520 | } |
2521 | 2521 | |
2522 | 2522 | |
@@ -2525,10 +2525,10 @@ discard block |
||
2525 | 2525 | * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables |
2526 | 2526 | * @return EE_Secondary_Table[] |
2527 | 2527 | */ |
2528 | - protected function _get_other_tables(){ |
|
2529 | - $other_tables =array(); |
|
2530 | - foreach($this->_tables as $table_alias => $table){ |
|
2531 | - if($table instanceof EE_Secondary_Table){ |
|
2528 | + protected function _get_other_tables() { |
|
2529 | + $other_tables = array(); |
|
2530 | + foreach ($this->_tables as $table_alias => $table) { |
|
2531 | + if ($table instanceof EE_Secondary_Table) { |
|
2532 | 2532 | $other_tables[$table_alias] = $table; |
2533 | 2533 | } |
2534 | 2534 | } |
@@ -2540,7 +2540,7 @@ discard block |
||
2540 | 2540 | * @param string $table_alias, array key in EEM_Base::_tables |
2541 | 2541 | * @return EE_Model_Field_Base[] |
2542 | 2542 | */ |
2543 | - function _get_fields_for_table($table_alias){ |
|
2543 | + function _get_fields_for_table($table_alias) { |
|
2544 | 2544 | return $this->_fields[$table_alias]; |
2545 | 2545 | } |
2546 | 2546 | |
@@ -2552,29 +2552,29 @@ discard block |
||
2552 | 2552 | * @param array $query_params like EEM_Base::get_all's $query_parameters['where'] |
2553 | 2553 | * @return EE_Model_Query_Info_Carrier |
2554 | 2554 | */ |
2555 | - function _extract_related_models_from_query($query_params){ |
|
2555 | + function _extract_related_models_from_query($query_params) { |
|
2556 | 2556 | $query_info_carrier = new EE_Model_Query_Info_Carrier(); |
2557 | - if(array_key_exists(0,$query_params)){ |
|
2558 | - $this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,0); |
|
2559 | - } |
|
2560 | - if(array_key_exists('group_by', $query_params)){ |
|
2561 | - if(is_array($query_params['group_by'])){ |
|
2562 | - $this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by'); |
|
2563 | - }elseif( ! empty ( $query_params['group_by'] )){ |
|
2564 | - $this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by'); |
|
2557 | + if (array_key_exists(0, $query_params)) { |
|
2558 | + $this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0); |
|
2559 | + } |
|
2560 | + if (array_key_exists('group_by', $query_params)) { |
|
2561 | + if (is_array($query_params['group_by'])) { |
|
2562 | + $this->_extract_related_models_from_sub_params_array_values($query_params['group_by'], $query_info_carrier, 'group_by'); |
|
2563 | + }elseif ( ! empty ($query_params['group_by'])) { |
|
2564 | + $this->_extract_related_model_info_from_query_param($query_params['group_by'], $query_info_carrier, 'group_by'); |
|
2565 | 2565 | } |
2566 | 2566 | } |
2567 | - if(array_key_exists('having',$query_params)){ |
|
2568 | - $this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having'); |
|
2567 | + if (array_key_exists('having', $query_params)) { |
|
2568 | + $this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 'having'); |
|
2569 | 2569 | } |
2570 | - if(array_key_exists('order_by', $query_params)){ |
|
2571 | - if ( is_array( $query_params['order_by'] ) ) |
|
2572 | - $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by'); |
|
2573 | - elseif( ! empty( $query_params['order_by'] )) |
|
2574 | - $this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by'); |
|
2570 | + if (array_key_exists('order_by', $query_params)) { |
|
2571 | + if (is_array($query_params['order_by'])) |
|
2572 | + $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_info_carrier, 'order_by'); |
|
2573 | + elseif ( ! empty($query_params['order_by'])) |
|
2574 | + $this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_info_carrier, 'order_by'); |
|
2575 | 2575 | } |
2576 | - if(array_key_exists('force_join', $query_params)){ |
|
2577 | - $this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join'); |
|
2576 | + if (array_key_exists('force_join', $query_params)) { |
|
2577 | + $this->_extract_related_models_from_sub_params_array_values($query_params['force_join'], $query_info_carrier, 'force_join'); |
|
2578 | 2578 | } |
2579 | 2579 | return $query_info_carrier; |
2580 | 2580 | } |
@@ -2587,34 +2587,34 @@ discard block |
||
2587 | 2587 | * @throws EE_Error |
2588 | 2588 | * @return \EE_Model_Query_Info_Carrier |
2589 | 2589 | */ |
2590 | - private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){ |
|
2591 | - if (!empty($sub_query_params)){ |
|
2590 | + private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) { |
|
2591 | + if ( ! empty($sub_query_params)) { |
|
2592 | 2592 | $sub_query_params = (array) $sub_query_params; |
2593 | - foreach($sub_query_params as $param => $possibly_array_of_params){ |
|
2593 | + foreach ($sub_query_params as $param => $possibly_array_of_params) { |
|
2594 | 2594 | //$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount' |
2595 | - $this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type); |
|
2595 | + $this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type); |
|
2596 | 2596 | |
2597 | 2597 | //if $possibly_array_of_params is an array, try recursing into it, searching for keys which |
2598 | 2598 | //indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried |
2599 | 2599 | //extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value |
2600 | 2600 | //of array('Registration.TXN_ID'=>23) |
2601 | 2601 | $query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param); |
2602 | - if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){ |
|
2603 | - if (! is_array($possibly_array_of_params)){ |
|
2602 | + if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) { |
|
2603 | + if ( ! is_array($possibly_array_of_params)) { |
|
2604 | 2604 | throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"), |
2605 | - $param,$possibly_array_of_params)); |
|
2606 | - }else{ |
|
2607 | - $this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type); |
|
2605 | + $param, $possibly_array_of_params)); |
|
2606 | + } else { |
|
2607 | + $this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type); |
|
2608 | 2608 | } |
2609 | - }elseif($query_param_type === 0 //ie WHERE |
|
2609 | + }elseif ($query_param_type === 0 //ie WHERE |
|
2610 | 2610 | && is_array($possibly_array_of_params) |
2611 | 2611 | && isset($possibly_array_of_params[2]) |
2612 | - && $possibly_array_of_params[2] == true){ |
|
2612 | + && $possibly_array_of_params[2] == true) { |
|
2613 | 2613 | //then $possible_array_of_params looks something like array('<','DTT_sold',true) |
2614 | 2614 | //indicating that $possible_array_of_params[1] is actually a field name, |
2615 | 2615 | //from which we should extract query parameters! |
2616 | - if(! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])){ |
|
2617 | - throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params))); |
|
2616 | + if ( ! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])) { |
|
2617 | + throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params))); |
|
2618 | 2618 | } |
2619 | 2619 | $this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type); |
2620 | 2620 | } |
@@ -2633,14 +2633,14 @@ discard block |
||
2633 | 2633 | * @throws EE_Error |
2634 | 2634 | * @return \EE_Model_Query_Info_Carrier |
2635 | 2635 | */ |
2636 | - private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){ |
|
2637 | - if (!empty($sub_query_params)){ |
|
2638 | - if(!is_array($sub_query_params)){ |
|
2639 | - throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params)); |
|
2636 | + private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) { |
|
2637 | + if ( ! empty($sub_query_params)) { |
|
2638 | + if ( ! is_array($sub_query_params)) { |
|
2639 | + throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params)); |
|
2640 | 2640 | } |
2641 | - foreach($sub_query_params as $param){ |
|
2641 | + foreach ($sub_query_params as $param) { |
|
2642 | 2642 | //$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount' |
2643 | - $this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type); |
|
2643 | + $this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type); |
|
2644 | 2644 | } |
2645 | 2645 | } |
2646 | 2646 | return $model_query_info_carrier; |
@@ -2659,81 +2659,81 @@ discard block |
||
2659 | 2659 | * @throws EE_Error |
2660 | 2660 | * @return EE_Model_Query_Info_Carrier |
2661 | 2661 | */ |
2662 | - function _create_model_query_info_carrier($query_params){ |
|
2663 | - if( ! is_array( $query_params ) ){ |
|
2664 | - EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
2662 | + function _create_model_query_info_carrier($query_params) { |
|
2663 | + if ( ! is_array($query_params)) { |
|
2664 | + EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
2665 | 2665 | $query_params = array(); |
2666 | 2666 | } |
2667 | - if( isset( $query_params[0] ) ) { |
|
2667 | + if (isset($query_params[0])) { |
|
2668 | 2668 | $where_query_params = $query_params[0]; |
2669 | - }else{ |
|
2669 | + } else { |
|
2670 | 2670 | $where_query_params = array(); |
2671 | 2671 | } |
2672 | 2672 | //first check if we should alter the query to account for caps or not |
2673 | 2673 | //because the caps might require us to do extra joins |
2674 | - if( isset( $query_params[ 'caps' ] ) && $query_params[ 'caps' ] != 'none' ) { |
|
2675 | - $query_params[0] = $where_query_params = array_replace_recursive( $where_query_params, $this->caps_where_conditions( $query_params[ 'caps' ] ) ); |
|
2674 | + if (isset($query_params['caps']) && $query_params['caps'] != 'none') { |
|
2675 | + $query_params[0] = $where_query_params = array_replace_recursive($where_query_params, $this->caps_where_conditions($query_params['caps'])); |
|
2676 | 2676 | } |
2677 | 2677 | $query_object = $this->_extract_related_models_from_query($query_params); |
2678 | 2678 | |
2679 | 2679 | //verify where_query_params has NO numeric indexes.... that's simply not how you use it! |
2680 | - foreach($where_query_params as $key => $value){ |
|
2681 | - if(is_int($key)){ |
|
2682 | - throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"),$key, var_export( $value, true ), var_export( $query_params, true ), get_class($this))); |
|
2680 | + foreach ($where_query_params as $key => $value) { |
|
2681 | + if (is_int($key)) { |
|
2682 | + throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"), $key, var_export($value, true), var_export($query_params, true), get_class($this))); |
|
2683 | 2683 | } |
2684 | 2684 | } |
2685 | - if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){ |
|
2685 | + if (array_key_exists('default_where_conditions', $query_params) && ! empty($query_params['default_where_conditions'])) { |
|
2686 | 2686 | $use_default_where_conditions = $query_params['default_where_conditions']; |
2687 | - }else{ |
|
2687 | + } else { |
|
2688 | 2688 | $use_default_where_conditions = 'all'; |
2689 | 2689 | } |
2690 | - $where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params ); |
|
2691 | - $query_object->set_where_sql( $this->_construct_where_clause($where_query_params)); |
|
2690 | + $where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object, $use_default_where_conditions, $where_query_params), $where_query_params); |
|
2691 | + $query_object->set_where_sql($this->_construct_where_clause($where_query_params)); |
|
2692 | 2692 | |
2693 | 2693 | |
2694 | 2694 | //if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join. So we need to setup a subquery and use that for the main join. Note for now this only works on the primary table for the model. So for instance, you could set the limit array like this: |
2695 | 2695 | //array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) ) |
2696 | - if ( array_key_exists('on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] )) { |
|
2697 | - $query_object->set_main_model_join_sql( $this->_construct_limit_join_select( $query_params['on_join_limit'][0], $query_params['on_join_limit'][1] ) ); |
|
2696 | + if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) { |
|
2697 | + $query_object->set_main_model_join_sql($this->_construct_limit_join_select($query_params['on_join_limit'][0], $query_params['on_join_limit'][1])); |
|
2698 | 2698 | } |
2699 | 2699 | |
2700 | 2700 | |
2701 | 2701 | //set limit |
2702 | - if(array_key_exists('limit',$query_params)){ |
|
2703 | - if(is_array($query_params['limit'])){ |
|
2704 | - if( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])){ |
|
2705 | - $e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"), http_build_query($query_params['limit'])); |
|
2702 | + if (array_key_exists('limit', $query_params)) { |
|
2703 | + if (is_array($query_params['limit'])) { |
|
2704 | + if ( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])) { |
|
2705 | + $e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"), http_build_query($query_params['limit'])); |
|
2706 | 2706 | throw new EE_Error($e."|".$e); |
2707 | 2707 | } |
2708 | 2708 | //they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25 |
2709 | 2709 | $query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]); |
2710 | - }elseif( ! empty ( $query_params['limit'] )){ |
|
2710 | + }elseif ( ! empty ($query_params['limit'])) { |
|
2711 | 2711 | $query_object->set_limit_sql((" LIMIT ".$query_params['limit'])); |
2712 | 2712 | } |
2713 | 2713 | } |
2714 | 2714 | //set order by |
2715 | - if(array_key_exists('order_by',$query_params)){ |
|
2716 | - if(is_array($query_params['order_by'])){ |
|
2715 | + if (array_key_exists('order_by', $query_params)) { |
|
2716 | + if (is_array($query_params['order_by'])) { |
|
2717 | 2717 | //if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must |
2718 | 2718 | //specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So |
2719 | 2719 | //including 'order' wouldn't make any sense if 'order_by' has already specified which way to order! |
2720 | - if(array_key_exists('order', $query_params)){ |
|
2720 | + if (array_key_exists('order', $query_params)) { |
|
2721 | 2721 | throw new EE_Error(sprintf(__("In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ", "event_espresso"), |
2722 | - get_class($this),implode(", ",array_keys($query_params['order_by'])),implode(", ",$query_params['order_by']),$query_params['order'])); |
|
2722 | + get_class($this), implode(", ", array_keys($query_params['order_by'])), implode(", ", $query_params['order_by']), $query_params['order'])); |
|
2723 | 2723 | } |
2724 | - $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_object,'order_by'); |
|
2724 | + $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_object, 'order_by'); |
|
2725 | 2725 | //assume it's an array of fields to order by |
2726 | 2726 | $order_array = array(); |
2727 | - foreach($query_params['order_by'] as $field_name_to_order_by => $order){ |
|
2727 | + foreach ($query_params['order_by'] as $field_name_to_order_by => $order) { |
|
2728 | 2728 | $order = $this->_extract_order($order); |
2729 | 2729 | $order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order; |
2730 | 2730 | } |
2731 | - $query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array)); |
|
2732 | - }elseif( ! empty ( $query_params['order_by'] )){ |
|
2733 | - $this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']); |
|
2734 | - if(isset($query_params['order'])){ |
|
2731 | + $query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array)); |
|
2732 | + }elseif ( ! empty ($query_params['order_by'])) { |
|
2733 | + $this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_object, 'order', $query_params['order_by']); |
|
2734 | + if (isset($query_params['order'])) { |
|
2735 | 2735 | $order = $this->_extract_order($query_params['order']); |
2736 | - }else{ |
|
2736 | + } else { |
|
2737 | 2737 | $order = 'DESC'; |
2738 | 2738 | } |
2739 | 2739 | $query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order); |
@@ -2741,46 +2741,46 @@ discard block |
||
2741 | 2741 | } |
2742 | 2742 | |
2743 | 2743 | //if 'order_by' wasn't set, maybe they are just using 'order' on its own? |
2744 | - if( ! array_key_exists('order_by',$query_params) && array_key_exists('order',$query_params) && ! empty( $query_params['order'] )){ |
|
2744 | + if ( ! array_key_exists('order_by', $query_params) && array_key_exists('order', $query_params) && ! empty($query_params['order'])) { |
|
2745 | 2745 | $pk_field = $this->get_primary_key_field(); |
2746 | 2746 | $order = $this->_extract_order($query_params['order']); |
2747 | 2747 | $query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order); |
2748 | 2748 | } |
2749 | 2749 | |
2750 | 2750 | //set group by |
2751 | - if(array_key_exists('group_by',$query_params)){ |
|
2752 | - if(is_array($query_params['group_by'])){ |
|
2751 | + if (array_key_exists('group_by', $query_params)) { |
|
2752 | + if (is_array($query_params['group_by'])) { |
|
2753 | 2753 | //it's an array, so assume we'll be grouping by a bunch of stuff |
2754 | 2754 | $group_by_array = array(); |
2755 | - foreach($query_params['group_by'] as $field_name_to_group_by){ |
|
2755 | + foreach ($query_params['group_by'] as $field_name_to_group_by) { |
|
2756 | 2756 | $group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by); |
2757 | 2757 | } |
2758 | - $query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array)); |
|
2759 | - }elseif( ! empty ( $query_params['group_by'] )){ |
|
2758 | + $query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array)); |
|
2759 | + }elseif ( ! empty ($query_params['group_by'])) { |
|
2760 | 2760 | $query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by'])); |
2761 | 2761 | } |
2762 | 2762 | } |
2763 | 2763 | //set having |
2764 | - if(array_key_exists('having',$query_params) && $query_params['having']){ |
|
2765 | - $query_object->set_having_sql( $this->_construct_having_clause($query_params['having'])); |
|
2764 | + if (array_key_exists('having', $query_params) && $query_params['having']) { |
|
2765 | + $query_object->set_having_sql($this->_construct_having_clause($query_params['having'])); |
|
2766 | 2766 | } |
2767 | 2767 | |
2768 | 2768 | //now, just verify they didn't pass anything wack |
2769 | - foreach($query_params as $query_key => $query_value){ |
|
2770 | - if( ! in_array($query_key,$this->_allowed_query_params,true)){ |
|
2769 | + foreach ($query_params as $query_key => $query_value) { |
|
2770 | + if ( ! in_array($query_key, $this->_allowed_query_params, true)) { |
|
2771 | 2771 | throw new EE_Error( |
2772 | 2772 | sprintf( |
2773 | - __("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s",'event_espresso'), |
|
2773 | + __("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s", 'event_espresso'), |
|
2774 | 2774 | $query_key, |
2775 | 2775 | get_class($this), |
2776 | 2776 | // print_r( $this->_allowed_query_params, TRUE ) |
2777 | - implode( ',', $this->_allowed_query_params ) |
|
2777 | + implode(',', $this->_allowed_query_params) |
|
2778 | 2778 | ) |
2779 | 2779 | ); |
2780 | 2780 | } |
2781 | 2781 | } |
2782 | 2782 | $main_model_join_sql = $query_object->get_main_model_join_sql(); |
2783 | - if ( empty( $main_model_join_sql ) ) |
|
2783 | + if (empty($main_model_join_sql)) |
|
2784 | 2784 | $query_object->set_main_model_join_sql($this->_construct_internal_join()); |
2785 | 2785 | return $query_object; |
2786 | 2786 | } |
@@ -2791,17 +2791,17 @@ discard block |
||
2791 | 2791 | * @param string $context one of EEM_Base::valid_cap_contexts() |
2792 | 2792 | * @return array like EEM_Base::get_all() 's $query_params[0] |
2793 | 2793 | */ |
2794 | - public function caps_where_conditions( $context = self::caps_read ) { |
|
2795 | - EEM_Base::verify_is_valid_cap_context( $context ); |
|
2794 | + public function caps_where_conditions($context = self::caps_read) { |
|
2795 | + EEM_Base::verify_is_valid_cap_context($context); |
|
2796 | 2796 | $cap_where_conditions = array(); |
2797 | - $cap_restrictions = $this->caps_missing( $context ); |
|
2797 | + $cap_restrictions = $this->caps_missing($context); |
|
2798 | 2798 | /** |
2799 | 2799 | * @var $cap_restrictions EE_Default_Where_Conditions[] |
2800 | 2800 | */ |
2801 | - foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) { |
|
2802 | - $cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() ); |
|
2801 | + foreach ($cap_restrictions as $cap => $restriction_if_no_cap) { |
|
2802 | + $cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions()); |
|
2803 | 2803 | } |
2804 | - return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions ); |
|
2804 | + return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions); |
|
2805 | 2805 | } |
2806 | 2806 | |
2807 | 2807 | /** |
@@ -2811,11 +2811,11 @@ discard block |
||
2811 | 2811 | * @return string either ASC, asc, DESC or desc |
2812 | 2812 | * @throws EE_Error |
2813 | 2813 | */ |
2814 | - private function _extract_order($should_be_order_string){ |
|
2815 | - if(in_array($should_be_order_string, $this->_allowed_order_values)){ |
|
2814 | + private function _extract_order($should_be_order_string) { |
|
2815 | + if (in_array($should_be_order_string, $this->_allowed_order_values)) { |
|
2816 | 2816 | return $should_be_order_string; |
2817 | - }else{ |
|
2818 | - throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string)); |
|
2817 | + } else { |
|
2818 | + throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string)); |
|
2819 | 2819 | } |
2820 | 2820 | } |
2821 | 2821 | |
@@ -2833,7 +2833,7 @@ discard block |
||
2833 | 2833 | * @throws EE_Error |
2834 | 2834 | * @return array like $query_params[0], see EEM_Base::get_all for documentation |
2835 | 2835 | */ |
2836 | - private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){ |
|
2836 | + private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) { |
|
2837 | 2837 | $allowed_used_default_where_conditions_values = array( |
2838 | 2838 | 'all', |
2839 | 2839 | 'this_model_only', |
@@ -2841,23 +2841,23 @@ discard block |
||
2841 | 2841 | 'minimum', |
2842 | 2842 | 'none' |
2843 | 2843 | ); |
2844 | - if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){ |
|
2845 | - throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values))); |
|
2844 | + if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) { |
|
2845 | + throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values))); |
|
2846 | 2846 | } |
2847 | - if( in_array($use_default_where_conditions, array('all','this_model_only')) ){ |
|
2847 | + if (in_array($use_default_where_conditions, array('all', 'this_model_only'))) { |
|
2848 | 2848 | $universal_query_params = $this->_get_default_where_conditions(); |
2849 | - }elseif( $use_default_where_conditions == 'minimum' ) { |
|
2849 | + }elseif ($use_default_where_conditions == 'minimum') { |
|
2850 | 2850 | $universal_query_params = $this->_get_minimum_where_conditions(); |
2851 | - }else{ |
|
2851 | + } else { |
|
2852 | 2852 | $universal_query_params = array(); |
2853 | 2853 | } |
2854 | 2854 | |
2855 | - if(in_array($use_default_where_conditions,array('all', 'minimum', 'other_models_only'))){ |
|
2856 | - foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){ |
|
2855 | + if (in_array($use_default_where_conditions, array('all', 'minimum', 'other_models_only'))) { |
|
2856 | + foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) { |
|
2857 | 2857 | $related_model = $this->get_related_model_obj($model_name); |
2858 | - if( $use_default_where_conditions == 'minimum' ) { |
|
2858 | + if ($use_default_where_conditions == 'minimum') { |
|
2859 | 2859 | $related_model_universal_where_params = $related_model->_get_minimum_where_conditions($model_relation_path); |
2860 | - }else{ |
|
2860 | + } else { |
|
2861 | 2861 | $related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path); |
2862 | 2862 | } |
2863 | 2863 | |
@@ -2884,22 +2884,22 @@ discard block |
||
2884 | 2884 | * @param string $model_relation_path like 'Transaction.Payment.' |
2885 | 2885 | * @return array like EEM_Base::get_all's $query_params[0] |
2886 | 2886 | */ |
2887 | - private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){ |
|
2887 | + private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) { |
|
2888 | 2888 | $null_friendly_where_conditions = array(); |
2889 | 2889 | $none_overridden = true; |
2890 | 2890 | $or_condition_key_for_defaults = 'OR*'.get_class($model); |
2891 | 2891 | |
2892 | - foreach($default_where_conditions as $key => $val){ |
|
2893 | - if( isset($provided_where_conditions[$key])){ |
|
2892 | + foreach ($default_where_conditions as $key => $val) { |
|
2893 | + if (isset($provided_where_conditions[$key])) { |
|
2894 | 2894 | $none_overridden = false; |
2895 | - }else{ |
|
2895 | + } else { |
|
2896 | 2896 | $null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val; |
2897 | 2897 | } |
2898 | 2898 | } |
2899 | - if( $none_overridden && $default_where_conditions){ |
|
2900 | - if($model->has_primary_key_field()){ |
|
2899 | + if ($none_overridden && $default_where_conditions) { |
|
2900 | + if ($model->has_primary_key_field()) { |
|
2901 | 2901 | $null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL'); |
2902 | - }else{ |
|
2902 | + } else { |
|
2903 | 2903 | //@todo NO PK, use other defaults |
2904 | 2904 | } |
2905 | 2905 | } |
@@ -2914,8 +2914,8 @@ discard block |
||
2914 | 2914 | * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment." |
2915 | 2915 | * @return array like EEM_Base::get_all's $query_params[0] (where conditions) |
2916 | 2916 | */ |
2917 | - protected function _get_default_where_conditions($model_relation_path = null){ |
|
2918 | - if ( $this->_ignore_where_strategy ) |
|
2917 | + protected function _get_default_where_conditions($model_relation_path = null) { |
|
2918 | + if ($this->_ignore_where_strategy) |
|
2919 | 2919 | return array(); |
2920 | 2920 | |
2921 | 2921 | return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path); |
@@ -2930,8 +2930,8 @@ discard block |
||
2930 | 2930 | * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment." |
2931 | 2931 | * @return array like EEM_Base::get_all's $query_params[0] (where conditions) |
2932 | 2932 | */ |
2933 | - protected function _get_minimum_where_conditions($model_relation_path = null){ |
|
2934 | - if ( $this->_ignore_where_strategy ) |
|
2933 | + protected function _get_minimum_where_conditions($model_relation_path = null) { |
|
2934 | + if ($this->_ignore_where_strategy) |
|
2935 | 2935 | return array(); |
2936 | 2936 | |
2937 | 2937 | return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path); |
@@ -2942,13 +2942,13 @@ discard block |
||
2942 | 2942 | * @param EE_Model_Query_Info_Carrier $model_query_info |
2943 | 2943 | * @return string |
2944 | 2944 | */ |
2945 | - private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){ |
|
2945 | + private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) { |
|
2946 | 2946 | $selects = $this->_get_columns_to_select_for_this_model(); |
2947 | - foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){ |
|
2947 | + foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) { |
|
2948 | 2948 | $other_model_included = $this->get_related_model_obj($name_of_other_model_included); |
2949 | 2949 | $selects = array_merge($selects, $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain)); |
2950 | 2950 | } |
2951 | - return implode(", ",$selects); |
|
2951 | + return implode(", ", $selects); |
|
2952 | 2952 | } |
2953 | 2953 | |
2954 | 2954 | /** |
@@ -2957,19 +2957,19 @@ discard block |
||
2957 | 2957 | * @param string $model_relation_chain like 'Question.Question_Group.Event' |
2958 | 2958 | * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'" |
2959 | 2959 | */ |
2960 | - public function _get_columns_to_select_for_this_model($model_relation_chain = ''){ |
|
2960 | + public function _get_columns_to_select_for_this_model($model_relation_chain = '') { |
|
2961 | 2961 | $fields = $this->field_settings(); |
2962 | 2962 | $selects = array(); |
2963 | 2963 | $table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name()); |
2964 | - foreach($fields as $field_obj){ |
|
2965 | - $selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'"; |
|
2964 | + foreach ($fields as $field_obj) { |
|
2965 | + $selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'"; |
|
2966 | 2966 | } |
2967 | 2967 | //make sure we are also getting the PKs of each table |
2968 | 2968 | $tables = $this->get_tables(); |
2969 | - if(count($tables) > 1){ |
|
2970 | - foreach($tables as $table_obj){ |
|
2971 | - $qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column(); |
|
2972 | - if( ! in_array($qualified_pk_column,$selects)){ |
|
2969 | + if (count($tables) > 1) { |
|
2970 | + foreach ($tables as $table_obj) { |
|
2971 | + $qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column(); |
|
2972 | + if ( ! in_array($qualified_pk_column, $selects)) { |
|
2973 | 2973 | $selects[] = "$qualified_pk_column AS '$qualified_pk_column'"; |
2974 | 2974 | } |
2975 | 2975 | } |
@@ -2993,66 +2993,66 @@ discard block |
||
2993 | 2993 | * @throws EE_Error |
2994 | 2994 | * @return void only modifies the EEM_Related_Model_Info_Carrier passed into it |
2995 | 2995 | */ |
2996 | - private function _extract_related_model_info_from_query_param( $query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL ){ |
|
2997 | - if($original_query_param == NULL){ |
|
2996 | + private function _extract_related_model_info_from_query_param($query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL) { |
|
2997 | + if ($original_query_param == NULL) { |
|
2998 | 2998 | $original_query_param = $query_param; |
2999 | 2999 | } |
3000 | 3000 | $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); |
3001 | 3001 | /** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */ |
3002 | - $allow_logic_query_params = in_array($query_param_type,array('where','having')); |
|
3003 | - $allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order')); |
|
3002 | + $allow_logic_query_params = in_array($query_param_type, array('where', 'having')); |
|
3003 | + $allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order')); |
|
3004 | 3004 | //check to see if we have a field on this model |
3005 | 3005 | $this_model_fields = $this->field_settings(true); |
3006 | - if(array_key_exists($query_param,$this_model_fields)){ |
|
3007 | - if($allow_fields){ |
|
3006 | + if (array_key_exists($query_param, $this_model_fields)) { |
|
3007 | + if ($allow_fields) { |
|
3008 | 3008 | return; |
3009 | - }else{ |
|
3009 | + } else { |
|
3010 | 3010 | throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"), |
3011 | - $query_param,get_class($this),$query_param_type,$original_query_param)); |
|
3011 | + $query_param, get_class($this), $query_param_type, $original_query_param)); |
|
3012 | 3012 | } |
3013 | 3013 | } |
3014 | 3014 | //check if this is a special logic query param |
3015 | - elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){ |
|
3016 | - if($allow_logic_query_params){ |
|
3015 | + elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) { |
|
3016 | + if ($allow_logic_query_params) { |
|
3017 | 3017 | return; |
3018 | - }else{ |
|
3018 | + } else { |
|
3019 | 3019 | throw new EE_Error( |
3020 | 3020 | sprintf( |
3021 | - __( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ), |
|
3022 | - implode( '", "', $this->_logic_query_param_keys ), |
|
3023 | - $query_param , |
|
3024 | - get_class( $this ), |
|
3021 | + __('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'), |
|
3022 | + implode('", "', $this->_logic_query_param_keys), |
|
3023 | + $query_param, |
|
3024 | + get_class($this), |
|
3025 | 3025 | '<br />', |
3026 | - "\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param |
|
3026 | + "\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param |
|
3027 | 3027 | ) |
3028 | 3028 | ); |
3029 | 3029 | } |
3030 | 3030 | } |
3031 | 3031 | |
3032 | 3032 | //check if it's a custom selection |
3033 | - elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
3033 | + elseif (array_key_exists($query_param, $this->_custom_selections)) { |
|
3034 | 3034 | return; |
3035 | 3035 | } |
3036 | 3036 | |
3037 | 3037 | //check if has a model name at the beginning |
3038 | 3038 | //and |
3039 | 3039 | //check if it's a field on a related model |
3040 | - foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){ |
|
3041 | - if(strpos($query_param, $valid_related_model_name.".") === 0){ |
|
3042 | - $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param); |
|
3040 | + foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) { |
|
3041 | + if (strpos($query_param, $valid_related_model_name.".") === 0) { |
|
3042 | + $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param); |
|
3043 | 3043 | $query_param = substr($query_param, strlen($valid_related_model_name.".")); |
3044 | - if($query_param == ''){ |
|
3044 | + if ($query_param == '') { |
|
3045 | 3045 | //nothing left to $query_param |
3046 | 3046 | //we should actually end in a field name, not a model like this! |
3047 | 3047 | throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"), |
3048 | - $query_param,$query_param_type,get_class($this),$valid_related_model_name)); |
|
3049 | - }else{ |
|
3048 | + $query_param, $query_param_type, get_class($this), $valid_related_model_name)); |
|
3049 | + } else { |
|
3050 | 3050 | $related_model_obj = $this->get_related_model_obj($valid_related_model_name); |
3051 | 3051 | $related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param); |
3052 | 3052 | return; |
3053 | 3053 | } |
3054 | - }elseif($query_param == $valid_related_model_name){ |
|
3055 | - $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param); |
|
3054 | + }elseif ($query_param == $valid_related_model_name) { |
|
3055 | + $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param); |
|
3056 | 3056 | return; |
3057 | 3057 | } |
3058 | 3058 | } |
@@ -3062,7 +3062,7 @@ discard block |
||
3062 | 3062 | //and we previously confirmed it wasn't a logic query param or field on the current model |
3063 | 3063 | //it's wack, that's what it is |
3064 | 3064 | throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"), |
3065 | - $query_param,get_class($this),$query_param_type,$original_query_param)); |
|
3065 | + $query_param, get_class($this), $query_param_type, $original_query_param)); |
|
3066 | 3066 | |
3067 | 3067 | } |
3068 | 3068 | |
@@ -3079,26 +3079,26 @@ discard block |
||
3079 | 3079 | * what models to prepend onto its default query params or in case it wants to rename tables (in case there are multiple joins to the same table) |
3080 | 3080 | * @return void |
3081 | 3081 | */ |
3082 | - private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){ |
|
3082 | + private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) { |
|
3083 | 3083 | $relation_obj = $this->related_settings_for($model_name); |
3084 | 3084 | |
3085 | 3085 | $model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param); |
3086 | 3086 | //check if the relation is HABTM, because then we're essentially doing two joins |
3087 | 3087 | //If so, join first to the JOIN table, and add its data types, and then continue as normal |
3088 | - if($relation_obj instanceof EE_HABTM_Relation){ |
|
3088 | + if ($relation_obj instanceof EE_HABTM_Relation) { |
|
3089 | 3089 | $join_model_obj = $relation_obj->get_join_model(); |
3090 | 3090 | //replace the model specified with the join model for this relation chain, whi |
3091 | 3091 | $relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain); |
3092 | 3092 | $new_query_info = new EE_Model_Query_Info_Carrier( |
3093 | 3093 | array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()), |
3094 | 3094 | $relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model)); |
3095 | - $passed_in_query_info->merge( $new_query_info ); |
|
3095 | + $passed_in_query_info->merge($new_query_info); |
|
3096 | 3096 | } |
3097 | 3097 | //now just join to the other table pointed to by the relation object, and add its data types |
3098 | 3098 | $new_query_info = new EE_Model_Query_Info_Carrier( |
3099 | 3099 | array($model_relation_chain=>$model_name), |
3100 | 3100 | $relation_obj->get_join_statement($model_relation_chain)); |
3101 | - $passed_in_query_info->merge( $new_query_info ); |
|
3101 | + $passed_in_query_info->merge($new_query_info); |
|
3102 | 3102 | } |
3103 | 3103 | |
3104 | 3104 | |
@@ -3107,11 +3107,11 @@ discard block |
||
3107 | 3107 | * @param array $where_params like EEM_Base::get_all |
3108 | 3108 | * @return string of SQL |
3109 | 3109 | */ |
3110 | - private function _construct_where_clause($where_params){ |
|
3110 | + private function _construct_where_clause($where_params) { |
|
3111 | 3111 | $SQL = $this->_construct_condition_clause_recursive($where_params, ' AND '); |
3112 | - if($SQL){ |
|
3113 | - return " WHERE ". $SQL; |
|
3114 | - }else{ |
|
3112 | + if ($SQL) { |
|
3113 | + return " WHERE ".$SQL; |
|
3114 | + } else { |
|
3115 | 3115 | return ''; |
3116 | 3116 | } |
3117 | 3117 | } |
@@ -3122,11 +3122,11 @@ discard block |
||
3122 | 3122 | * @param array $having_params |
3123 | 3123 | * @return string |
3124 | 3124 | */ |
3125 | - private function _construct_having_clause($having_params){ |
|
3125 | + private function _construct_having_clause($having_params) { |
|
3126 | 3126 | $SQL = $this->_construct_condition_clause_recursive($having_params, ' AND '); |
3127 | - if($SQL){ |
|
3128 | - return " HAVING ". $SQL; |
|
3129 | - }else{ |
|
3127 | + if ($SQL) { |
|
3128 | + return " HAVING ".$SQL; |
|
3129 | + } else { |
|
3130 | 3130 | return ''; |
3131 | 3131 | } |
3132 | 3132 | |
@@ -3140,17 +3140,17 @@ discard block |
||
3140 | 3140 | * @return EE_Model_Field_Base |
3141 | 3141 | * @throws EE_Error |
3142 | 3142 | */ |
3143 | - protected function _get_field_on_model($field_name,$model_name){ |
|
3143 | + protected function _get_field_on_model($field_name, $model_name) { |
|
3144 | 3144 | $model_class = 'EEM_'.$model_name; |
3145 | 3145 | $model_filepath = $model_class.".model.php"; |
3146 | - EE_Registry::instance()->load_helper( 'File' ); |
|
3147 | - if ( is_readable($model_filepath)){ |
|
3146 | + EE_Registry::instance()->load_helper('File'); |
|
3147 | + if (is_readable($model_filepath)) { |
|
3148 | 3148 | require_once($model_filepath); |
3149 | - $model_instance=call_user_func($model_name."::instance"); |
|
3149 | + $model_instance = call_user_func($model_name."::instance"); |
|
3150 | 3150 | /* @var $model_instance EEM_Base */ |
3151 | 3151 | return $model_instance->field_settings_for($field_name); |
3152 | - }else{ |
|
3153 | - throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath)); |
|
3152 | + } else { |
|
3153 | + throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath)); |
|
3154 | 3154 | } |
3155 | 3155 | } |
3156 | 3156 | |
@@ -3163,43 +3163,43 @@ discard block |
||
3163 | 3163 | * @throws EE_Error |
3164 | 3164 | * @return string of SQL |
3165 | 3165 | */ |
3166 | - private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){ |
|
3167 | - $where_clauses=array(); |
|
3168 | - foreach($where_params as $query_param => $op_and_value_or_sub_condition){ |
|
3169 | - $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param); |
|
3170 | - if(in_array($query_param,$this->_logic_query_param_keys)){ |
|
3171 | - switch($query_param){ |
|
3166 | + private function _construct_condition_clause_recursive($where_params, $glue = ' AND') { |
|
3167 | + $where_clauses = array(); |
|
3168 | + foreach ($where_params as $query_param => $op_and_value_or_sub_condition) { |
|
3169 | + $query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param); |
|
3170 | + if (in_array($query_param, $this->_logic_query_param_keys)) { |
|
3171 | + switch ($query_param) { |
|
3172 | 3172 | case 'not': |
3173 | 3173 | case 'NOT': |
3174 | - $where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")"; |
|
3174 | + $where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")"; |
|
3175 | 3175 | break; |
3176 | 3176 | case 'and': |
3177 | 3177 | case 'AND': |
3178 | - $where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")"; |
|
3178 | + $where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")"; |
|
3179 | 3179 | break; |
3180 | 3180 | case 'or': |
3181 | 3181 | case 'OR': |
3182 | - $where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")"; |
|
3182 | + $where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")"; |
|
3183 | 3183 | break; |
3184 | 3184 | } |
3185 | - }else{ |
|
3185 | + } else { |
|
3186 | 3186 | $field_obj = $this->_deduce_field_from_query_param($query_param); |
3187 | 3187 | |
3188 | 3188 | //if it's not a normal field, maybe it's a custom selection? |
3189 | - if( ! $field_obj){ |
|
3190 | - if(isset( $this->_custom_selections[$query_param][1])){ |
|
3189 | + if ( ! $field_obj) { |
|
3190 | + if (isset($this->_custom_selections[$query_param][1])) { |
|
3191 | 3191 | $field_obj = $this->_custom_selections[$query_param][1]; |
3192 | - }else{ |
|
3193 | - throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param)); |
|
3192 | + } else { |
|
3193 | + throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param)); |
|
3194 | 3194 | } |
3195 | 3195 | } |
3196 | 3196 | $op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj); |
3197 | - $where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql; |
|
3197 | + $where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql; |
|
3198 | 3198 | } |
3199 | 3199 | } |
3200 | - if($where_clauses){ |
|
3201 | - $SQL = implode($glue,$where_clauses); |
|
3202 | - }else{ |
|
3200 | + if ($where_clauses) { |
|
3201 | + $SQL = implode($glue, $where_clauses); |
|
3202 | + } else { |
|
3203 | 3203 | $SQL = ''; |
3204 | 3204 | } |
3205 | 3205 | return $SQL; |
@@ -3213,18 +3213,18 @@ discard block |
||
3213 | 3213 | * @throws EE_Error |
3214 | 3214 | * @return string table alias and column name for SQL, eg "Transaction.TXN_ID" |
3215 | 3215 | */ |
3216 | - private function _deduce_column_name_from_query_param($query_param){ |
|
3216 | + private function _deduce_column_name_from_query_param($query_param) { |
|
3217 | 3217 | $field = $this->_deduce_field_from_query_param($query_param); |
3218 | 3218 | |
3219 | - if( $field ){ |
|
3220 | - $table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param ); |
|
3221 | - return $table_alias_prefix . $field->get_qualified_column(); |
|
3222 | - }elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
3219 | + if ($field) { |
|
3220 | + $table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param); |
|
3221 | + return $table_alias_prefix.$field->get_qualified_column(); |
|
3222 | + }elseif (array_key_exists($query_param, $this->_custom_selections)) { |
|
3223 | 3223 | //maybe it's custom selection item? |
3224 | 3224 | //if so, just use it as the "column name" |
3225 | 3225 | return $query_param; |
3226 | - }else{ |
|
3227 | - throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections))); |
|
3226 | + } else { |
|
3227 | + throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections))); |
|
3228 | 3228 | } |
3229 | 3229 | } |
3230 | 3230 | |
@@ -3236,11 +3236,11 @@ discard block |
||
3236 | 3236 | * @param string $condition_query_param_key |
3237 | 3237 | * @return string |
3238 | 3238 | */ |
3239 | - private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){ |
|
3239 | + private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
3240 | 3240 | $pos_of_star = strpos($condition_query_param_key, '*'); |
3241 | - if($pos_of_star === FALSE){ |
|
3241 | + if ($pos_of_star === FALSE) { |
|
3242 | 3242 | return $condition_query_param_key; |
3243 | - }else{ |
|
3243 | + } else { |
|
3244 | 3244 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
3245 | 3245 | return $condition_query_param_sans_star; |
3246 | 3246 | } |
@@ -3255,54 +3255,54 @@ discard block |
||
3255 | 3255 | * @throws EE_Error |
3256 | 3256 | * @return string |
3257 | 3257 | */ |
3258 | - private function _construct_op_and_value($op_and_value, $field_obj){ |
|
3259 | - if(is_array( $op_and_value )){ |
|
3258 | + private function _construct_op_and_value($op_and_value, $field_obj) { |
|
3259 | + if (is_array($op_and_value)) { |
|
3260 | 3260 | $operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null; |
3261 | - if( ! $operator){ |
|
3261 | + if ( ! $operator) { |
|
3262 | 3262 | $php_array_like_string = array(); |
3263 | - foreach($op_and_value as $key => $value){ |
|
3263 | + foreach ($op_and_value as $key => $value) { |
|
3264 | 3264 | $php_array_like_string[] = "$key=>$value"; |
3265 | 3265 | } |
3266 | - throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string))); |
|
3266 | + throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",", $php_array_like_string))); |
|
3267 | 3267 | } |
3268 | 3268 | $value = isset($op_and_value[1]) ? $op_and_value[1] : null; |
3269 | - }else{ |
|
3269 | + } else { |
|
3270 | 3270 | $operator = '='; |
3271 | 3271 | $value = $op_and_value; |
3272 | 3272 | } |
3273 | 3273 | |
3274 | 3274 | //check to see if the value is actually another field |
3275 | - if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){ |
|
3275 | + if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) { |
|
3276 | 3276 | return $operator.SP.$this->_deduce_column_name_from_query_param($value); |
3277 | - }elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){ |
|
3277 | + }elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) { |
|
3278 | 3278 | //in this case, the value should be an array, or at least a comma-separated list |
3279 | 3279 | //it will need to handle a little differently |
3280 | 3280 | $cleaned_value = $this->_construct_in_value($value, $field_obj); |
3281 | 3281 | //note: $cleaned_value has already been run through $wpdb->prepare() |
3282 | 3282 | return $operator.SP.$cleaned_value; |
3283 | - } elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) { |
|
3283 | + } elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) { |
|
3284 | 3284 | //the value should be an array with count of two. |
3285 | - if ( count($value) !== 2 ) |
|
3286 | - throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) ); |
|
3287 | - $cleaned_value = $this->_construct_between_value( $value, $field_obj ); |
|
3285 | + if (count($value) !== 2) |
|
3286 | + throw new EE_Error(sprintf(__("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN")); |
|
3287 | + $cleaned_value = $this->_construct_between_value($value, $field_obj); |
|
3288 | 3288 | return $operator.SP.$cleaned_value; |
3289 | - } elseif( in_array( $operator, $this->_null_style_operators ) ) { |
|
3290 | - if($value != NULL){ |
|
3291 | - throw new EE_Error(sprintf(__("You attempted to give a value (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator)); |
|
3289 | + } elseif (in_array($operator, $this->_null_style_operators)) { |
|
3290 | + if ($value != NULL) { |
|
3291 | + throw new EE_Error(sprintf(__("You attempted to give a value (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"), $value, $operator)); |
|
3292 | 3292 | } |
3293 | 3293 | return $operator; |
3294 | - }elseif( $operator == 'LIKE' && ! is_array($value)){ |
|
3294 | + }elseif ($operator == 'LIKE' && ! is_array($value)) { |
|
3295 | 3295 | //if the operator is 'LIKE', we want to allow percent signs (%) and not |
3296 | 3296 | //remove other junk. So just treat it as a string. |
3297 | 3297 | return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s'); |
3298 | - }elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){ |
|
3299 | - return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj); |
|
3300 | - }elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){ |
|
3301 | - throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator)); |
|
3302 | - }elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){ |
|
3303 | - throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator)); |
|
3304 | - }else{ |
|
3305 | - throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"), http_build_query($op_and_value))); |
|
3298 | + }elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) { |
|
3299 | + return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj); |
|
3300 | + }elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) { |
|
3301 | + throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))", 'event_espresso'), $operator, $operator)); |
|
3302 | + }elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) { |
|
3303 | + throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))", 'event_espresso'), $operator, $operator)); |
|
3304 | + } else { |
|
3305 | + throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"), http_build_query($op_and_value))); |
|
3306 | 3306 | } |
3307 | 3307 | } |
3308 | 3308 | |
@@ -3314,12 +3314,12 @@ discard block |
||
3314 | 3314 | * @param EE_Model_Field_Base|string $field_obj if string, it should be the datatype to be used when querying, eg '%s' |
3315 | 3315 | * @return string |
3316 | 3316 | */ |
3317 | - function _construct_between_value( $values, $field_obj ) { |
|
3317 | + function _construct_between_value($values, $field_obj) { |
|
3318 | 3318 | $cleaned_values = array(); |
3319 | - foreach ( $values as $value ) { |
|
3320 | - $cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj); |
|
3319 | + foreach ($values as $value) { |
|
3320 | + $cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj); |
|
3321 | 3321 | } |
3322 | - return $cleaned_values[0] . " AND " . $cleaned_values[1]; |
|
3322 | + return $cleaned_values[0]." AND ".$cleaned_values[1]; |
|
3323 | 3323 | } |
3324 | 3324 | |
3325 | 3325 | |
@@ -3335,26 +3335,26 @@ discard block |
||
3335 | 3335 | * @param EE_Model_Field_Base|string $field_obj if string, it should be a wpdb data type like '%s', or '%d' |
3336 | 3336 | * @return string of SQL to follow an 'IN' or 'NOT IN' operator |
3337 | 3337 | */ |
3338 | - function _construct_in_value($values, $field_obj){ |
|
3338 | + function _construct_in_value($values, $field_obj) { |
|
3339 | 3339 | //check if the value is a CSV list |
3340 | - if(is_string($values)){ |
|
3340 | + if (is_string($values)) { |
|
3341 | 3341 | //in which case, turn it into an array |
3342 | - $values = explode(",",$values); |
|
3342 | + $values = explode(",", $values); |
|
3343 | 3343 | } |
3344 | 3344 | $cleaned_values = array(); |
3345 | - foreach($values as $value){ |
|
3346 | - $cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj); |
|
3345 | + foreach ($values as $value) { |
|
3346 | + $cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj); |
|
3347 | 3347 | } |
3348 | 3348 | //we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()", |
3349 | 3349 | //but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set |
3350 | 3350 | //which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns |
3351 | - if(empty($cleaned_values)){ |
|
3351 | + if (empty($cleaned_values)) { |
|
3352 | 3352 | $all_fields = $this->field_settings(); |
3353 | 3353 | $a_field = array_shift($all_fields); |
3354 | 3354 | $main_table = $this->_get_main_table(); |
3355 | 3355 | $cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE"; |
3356 | 3356 | } |
3357 | - return "(".implode(",",$cleaned_values).")"; |
|
3357 | + return "(".implode(",", $cleaned_values).")"; |
|
3358 | 3358 | } |
3359 | 3359 | |
3360 | 3360 | |
@@ -3366,16 +3366,16 @@ discard block |
||
3366 | 3366 | * @throws EE_Error |
3367 | 3367 | * @return false|null|string |
3368 | 3368 | */ |
3369 | - private function _wpdb_prepare_using_field($value,$field_obj){ |
|
3369 | + private function _wpdb_prepare_using_field($value, $field_obj) { |
|
3370 | 3370 | /** @type WPDB $wpdb */ |
3371 | 3371 | global $wpdb; |
3372 | - if($field_obj instanceof EE_Model_Field_Base){ |
|
3373 | - return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj)); |
|
3374 | - }else{//$field_obj should really just be a data type |
|
3375 | - if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){ |
|
3376 | - throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types))); |
|
3372 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
3373 | + return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj)); |
|
3374 | + } else {//$field_obj should really just be a data type |
|
3375 | + if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) { |
|
3376 | + throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types))); |
|
3377 | 3377 | } |
3378 | - return $wpdb->prepare($field_obj,$value); |
|
3378 | + return $wpdb->prepare($field_obj, $value); |
|
3379 | 3379 | } |
3380 | 3380 | } |
3381 | 3381 | |
@@ -3387,27 +3387,27 @@ discard block |
||
3387 | 3387 | * @throws EE_Error |
3388 | 3388 | * @return EE_Model_Field_Base |
3389 | 3389 | */ |
3390 | - protected function _deduce_field_from_query_param($query_param_name){ |
|
3390 | + protected function _deduce_field_from_query_param($query_param_name) { |
|
3391 | 3391 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
3392 | 3392 | //which will help us find the database table and column |
3393 | 3393 | |
3394 | - $query_param_parts = explode(".",$query_param_name); |
|
3395 | - if(empty($query_param_parts)){ |
|
3396 | - throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
3394 | + $query_param_parts = explode(".", $query_param_name); |
|
3395 | + if (empty($query_param_parts)) { |
|
3396 | + throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
3397 | 3397 | } |
3398 | 3398 | $number_of_parts = count($query_param_parts); |
3399 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
3400 | - if($number_of_parts == 1){ |
|
3399 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
3400 | + if ($number_of_parts == 1) { |
|
3401 | 3401 | $field_name = $last_query_param_part; |
3402 | 3402 | $model_obj = $this; |
3403 | - }else{// $number_of_parts >= 2 |
|
3403 | + } else {// $number_of_parts >= 2 |
|
3404 | 3404 | //the last part is the column name, and there are only 2parts. therefore... |
3405 | 3405 | $field_name = $last_query_param_part; |
3406 | - $model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]); |
|
3406 | + $model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]); |
|
3407 | 3407 | } |
3408 | - try{ |
|
3408 | + try { |
|
3409 | 3409 | return $model_obj->field_settings_for($field_name); |
3410 | - }catch(EE_Error $e){ |
|
3410 | + } catch (EE_Error $e) { |
|
3411 | 3411 | return null; |
3412 | 3412 | } |
3413 | 3413 | } |
@@ -3421,13 +3421,13 @@ discard block |
||
3421 | 3421 | * @throws EE_Error |
3422 | 3422 | * @return string |
3423 | 3423 | */ |
3424 | - function _get_qualified_column_for_field($field_name){ |
|
3424 | + function _get_qualified_column_for_field($field_name) { |
|
3425 | 3425 | $all_fields = $this->field_settings(); |
3426 | 3426 | $field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE; |
3427 | - if($field){ |
|
3427 | + if ($field) { |
|
3428 | 3428 | return $field->get_qualified_column(); |
3429 | - }else{ |
|
3430 | - throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this))); |
|
3429 | + } else { |
|
3430 | + throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this))); |
|
3431 | 3431 | } |
3432 | 3432 | } |
3433 | 3433 | |
@@ -3441,14 +3441,14 @@ discard block |
||
3441 | 3441 | * @param mixed|string $limit The limit for this select |
3442 | 3442 | * @return string The final select join element for the query. |
3443 | 3443 | */ |
3444 | - function _construct_limit_join_select( $table_alias, $limit ) { |
|
3444 | + function _construct_limit_join_select($table_alias, $limit) { |
|
3445 | 3445 | $SQL = ''; |
3446 | 3446 | |
3447 | - foreach ( $this->_tables as $table_obj ) { |
|
3448 | - if ( $table_obj instanceof EE_Primary_Table ) { |
|
3449 | - $SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit( $limit ) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP; |
|
3450 | - } elseif ( $table_obj instanceof EE_Secondary_Table ) { |
|
3451 | - $SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP . $table_obj->get_join_sql( $table_alias ).SP; |
|
3447 | + foreach ($this->_tables as $table_obj) { |
|
3448 | + if ($table_obj instanceof EE_Primary_Table) { |
|
3449 | + $SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit($limit) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP; |
|
3450 | + } elseif ($table_obj instanceof EE_Secondary_Table) { |
|
3451 | + $SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP.$table_obj->get_join_sql($table_alias).SP; |
|
3452 | 3452 | } |
3453 | 3453 | } |
3454 | 3454 | return $SQL; |
@@ -3461,7 +3461,7 @@ discard block |
||
3461 | 3461 | * Eg "wp_post AS Event" or "wp_post AS Event INNER JOIN wp_postmeta Event_Meta ON Event.ID = Event_Meta.post_id" |
3462 | 3462 | * @return string SQL |
3463 | 3463 | */ |
3464 | - function _construct_internal_join(){ |
|
3464 | + function _construct_internal_join() { |
|
3465 | 3465 | $SQL = $this->_get_main_table()->get_table_sql(); |
3466 | 3466 | $SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias()); |
3467 | 3467 | return $SQL; |
@@ -3482,17 +3482,17 @@ discard block |
||
3482 | 3482 | * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause) |
3483 | 3483 | * @return string |
3484 | 3484 | */ |
3485 | - function _construct_internal_join_to_table_with_alias($alias_prefixed){ |
|
3485 | + function _construct_internal_join_to_table_with_alias($alias_prefixed) { |
|
3486 | 3486 | $SQL = ''; |
3487 | 3487 | $alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed); |
3488 | - foreach($this->_tables as $table_obj){ |
|
3489 | - if($table_obj instanceof EE_Secondary_Table){//table is secondary table |
|
3490 | - if($alias_sans_prefix == $table_obj->get_table_alias()){ |
|
3488 | + foreach ($this->_tables as $table_obj) { |
|
3489 | + if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table |
|
3490 | + if ($alias_sans_prefix == $table_obj->get_table_alias()) { |
|
3491 | 3491 | //so we're joining to this table, meaning the table is already in |
3492 | 3492 | //the FROM statement, BUT the primary table isn't. So we want |
3493 | 3493 | //to add the inverse join sql |
3494 | 3494 | $SQL .= $table_obj->get_inverse_join_sql($alias_prefixed); |
3495 | - }else{ |
|
3495 | + } else { |
|
3496 | 3496 | //just add a regular JOIN to this table from the primary table |
3497 | 3497 | $SQL .= $table_obj->get_join_sql($alias_prefixed); |
3498 | 3498 | } |
@@ -3506,9 +3506,9 @@ discard block |
||
3506 | 3506 | * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc) |
3507 | 3507 | * @return array |
3508 | 3508 | */ |
3509 | - function _get_data_types(){ |
|
3509 | + function _get_data_types() { |
|
3510 | 3510 | $data_types = array(); |
3511 | - foreach(array_values($this->field_settings()) as $field_obj){ |
|
3511 | + foreach (array_values($this->field_settings()) as $field_obj) { |
|
3512 | 3512 | //$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type(); |
3513 | 3513 | /** @var $field_obj EE_Model_Field_Base */ |
3514 | 3514 | $data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type(); |
@@ -3524,11 +3524,11 @@ discard block |
||
3524 | 3524 | * @throws EE_Error |
3525 | 3525 | * @return EEM_Base |
3526 | 3526 | */ |
3527 | - function get_related_model_obj($model_name){ |
|
3527 | + function get_related_model_obj($model_name) { |
|
3528 | 3528 | |
3529 | 3529 | $model_classname = "EEM_".$model_name; |
3530 | - if(!class_exists($model_classname)){ |
|
3531 | - throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname)); |
|
3530 | + if ( ! class_exists($model_classname)) { |
|
3531 | + throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname)); |
|
3532 | 3532 | } |
3533 | 3533 | $model_obj = call_user_func($model_classname."::instance"); |
3534 | 3534 | return $model_obj; |
@@ -3539,7 +3539,7 @@ discard block |
||
3539 | 3539 | * Returns the array of EE_ModelRelations for this model. |
3540 | 3540 | * @return EE_Model_Relation_Base[] |
3541 | 3541 | */ |
3542 | - public function relation_settings(){ |
|
3542 | + public function relation_settings() { |
|
3543 | 3543 | return $this->_model_relations; |
3544 | 3544 | } |
3545 | 3545 | |
@@ -3549,10 +3549,10 @@ discard block |
||
3549 | 3549 | * (Eg, without an event, datetimes have little purpose.) |
3550 | 3550 | * @return EE_Belongs_To_Relation[] |
3551 | 3551 | */ |
3552 | - public function belongs_to_relations(){ |
|
3552 | + public function belongs_to_relations() { |
|
3553 | 3553 | $belongs_to_relations = array(); |
3554 | - foreach($this->relation_settings() as $model_name => $relation_obj){ |
|
3555 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
3554 | + foreach ($this->relation_settings() as $model_name => $relation_obj) { |
|
3555 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
3556 | 3556 | $belongs_to_relations[$model_name] = $relation_obj; |
3557 | 3557 | } |
3558 | 3558 | } |
@@ -3567,15 +3567,15 @@ discard block |
||
3567 | 3567 | * @throws EE_Error |
3568 | 3568 | * @return EE_Model_Relation_Base |
3569 | 3569 | */ |
3570 | - public function related_settings_for($relation_name){ |
|
3571 | - $relatedModels=$this->relation_settings(); |
|
3572 | - if(!array_key_exists($relation_name,$relatedModels)){ |
|
3570 | + public function related_settings_for($relation_name) { |
|
3571 | + $relatedModels = $this->relation_settings(); |
|
3572 | + if ( ! array_key_exists($relation_name, $relatedModels)) { |
|
3573 | 3573 | throw new EE_Error( |
3574 | 3574 | sprintf( |
3575 | - __('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'), |
|
3575 | + __('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'), |
|
3576 | 3576 | $relation_name, |
3577 | 3577 | $this->_get_class_name(), |
3578 | - implode( ', ', array_keys( $relatedModels )) |
|
3578 | + implode(', ', array_keys($relatedModels)) |
|
3579 | 3579 | ) |
3580 | 3580 | ); |
3581 | 3581 | } |
@@ -3590,10 +3590,10 @@ discard block |
||
3590 | 3590 | * @throws EE_Error |
3591 | 3591 | * @return EE_Model_Field_Base |
3592 | 3592 | */ |
3593 | - public function field_settings_for($fieldName){ |
|
3594 | - $fieldSettings=$this->field_settings(true); |
|
3595 | - if( ! array_key_exists($fieldName,$fieldSettings)){ |
|
3596 | - throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this))); |
|
3593 | + public function field_settings_for($fieldName) { |
|
3594 | + $fieldSettings = $this->field_settings(true); |
|
3595 | + if ( ! array_key_exists($fieldName, $fieldSettings)) { |
|
3596 | + throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this))); |
|
3597 | 3597 | } |
3598 | 3598 | return $fieldSettings[$fieldName]; |
3599 | 3599 | } |
@@ -3603,11 +3603,11 @@ discard block |
||
3603 | 3603 | * @param string $fieldName a key in the model's _field_settings array |
3604 | 3604 | * @return boolean |
3605 | 3605 | */ |
3606 | - public function has_field($fieldName){ |
|
3606 | + public function has_field($fieldName) { |
|
3607 | 3607 | $fieldSettings = $this->field_settings(true); |
3608 | - if( isset($fieldSettings[$fieldName])){ |
|
3608 | + if (isset($fieldSettings[$fieldName])) { |
|
3609 | 3609 | return true; |
3610 | - }else{ |
|
3610 | + } else { |
|
3611 | 3611 | return false; |
3612 | 3612 | } |
3613 | 3613 | } |
@@ -3617,11 +3617,11 @@ discard block |
||
3617 | 3617 | * @param string $relation_name possibly one of the keys in the relation_settings array |
3618 | 3618 | * @return boolean |
3619 | 3619 | */ |
3620 | - public function has_relation($relation_name){ |
|
3620 | + public function has_relation($relation_name) { |
|
3621 | 3621 | $relations = $this->relation_settings(); |
3622 | - if(isset($relations[$relation_name])){ |
|
3622 | + if (isset($relations[$relation_name])) { |
|
3623 | 3623 | return true; |
3624 | - }else{ |
|
3624 | + } else { |
|
3625 | 3625 | return false; |
3626 | 3626 | } |
3627 | 3627 | } |
@@ -3633,7 +3633,7 @@ discard block |
||
3633 | 3633 | * @param $field_obj |
3634 | 3634 | * @return EE_Model_Field_Base |
3635 | 3635 | */ |
3636 | - public function is_primary_key_field( $field_obj ){ |
|
3636 | + public function is_primary_key_field($field_obj) { |
|
3637 | 3637 | return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE; |
3638 | 3638 | } |
3639 | 3639 | |
@@ -3645,16 +3645,16 @@ discard block |
||
3645 | 3645 | * @return EE_Model_Field_Base |
3646 | 3646 | * @throws EE_Error |
3647 | 3647 | */ |
3648 | - public function get_primary_key_field(){ |
|
3649 | - if( $this->_primary_key_field === NULL ){ |
|
3650 | - foreach( $this->field_settings( TRUE ) as $field_obj ){ |
|
3651 | - if( $this->is_primary_key_field( $field_obj )){ |
|
3648 | + public function get_primary_key_field() { |
|
3649 | + if ($this->_primary_key_field === NULL) { |
|
3650 | + foreach ($this->field_settings(TRUE) as $field_obj) { |
|
3651 | + if ($this->is_primary_key_field($field_obj)) { |
|
3652 | 3652 | $this->_primary_key_field = $field_obj; |
3653 | 3653 | break; |
3654 | 3654 | } |
3655 | 3655 | } |
3656 | - if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){ |
|
3657 | - throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this))); |
|
3656 | + if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) { |
|
3657 | + throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this))); |
|
3658 | 3658 | } |
3659 | 3659 | } |
3660 | 3660 | return $this->_primary_key_field; |
@@ -3667,12 +3667,12 @@ discard block |
||
3667 | 3667 | * Internally does some caching. |
3668 | 3668 | * @return boolean |
3669 | 3669 | */ |
3670 | - public function has_primary_key_field(){ |
|
3671 | - if($this->_has_primary_key_field === null){ |
|
3672 | - try{ |
|
3670 | + public function has_primary_key_field() { |
|
3671 | + if ($this->_has_primary_key_field === null) { |
|
3672 | + try { |
|
3673 | 3673 | $this->get_primary_key_field(); |
3674 | 3674 | $this->_has_primary_key_field = true; |
3675 | - }catch(EE_Error $e){ |
|
3675 | + } catch (EE_Error $e) { |
|
3676 | 3676 | $this->_has_primary_key_field = false; |
3677 | 3677 | } |
3678 | 3678 | } |
@@ -3686,9 +3686,9 @@ discard block |
||
3686 | 3686 | * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc |
3687 | 3687 | * @return EE_Model_Field_Base or null if none is found |
3688 | 3688 | */ |
3689 | - public function get_a_field_of_type($field_class_name){ |
|
3690 | - foreach($this->field_settings() as $field){ |
|
3691 | - if( $field instanceof $field_class_name ){ |
|
3689 | + public function get_a_field_of_type($field_class_name) { |
|
3690 | + foreach ($this->field_settings() as $field) { |
|
3691 | + if ($field instanceof $field_class_name) { |
|
3692 | 3692 | return $field; |
3693 | 3693 | } |
3694 | 3694 | } |
@@ -3702,21 +3702,21 @@ discard block |
||
3702 | 3702 | * @return EE_Foreign_Key_Field_Base |
3703 | 3703 | * @throws EE_Error |
3704 | 3704 | */ |
3705 | - public function get_foreign_key_to($model_name){ |
|
3706 | - if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){ |
|
3707 | - foreach($this->field_settings() as $field){ |
|
3705 | + public function get_foreign_key_to($model_name) { |
|
3706 | + if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) { |
|
3707 | + foreach ($this->field_settings() as $field) { |
|
3708 | 3708 | // if(is_subclass_of($field, 'EE_Foreign_Key_Field_Base')){ |
3709 | - if( $field instanceof EE_Foreign_Key_Field_Base ){ |
|
3710 | - if (in_array($model_name,$field->get_model_names_pointed_to() ) ) { |
|
3711 | - $this->_cache_foreign_key_to_fields[ $model_name ] = $field; |
|
3709 | + if ($field instanceof EE_Foreign_Key_Field_Base) { |
|
3710 | + if (in_array($model_name, $field->get_model_names_pointed_to())) { |
|
3711 | + $this->_cache_foreign_key_to_fields[$model_name] = $field; |
|
3712 | 3712 | } |
3713 | 3713 | } |
3714 | 3714 | } |
3715 | - if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){ |
|
3716 | - throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this))); |
|
3715 | + if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) { |
|
3716 | + throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this))); |
|
3717 | 3717 | } |
3718 | 3718 | } |
3719 | - return $this->_cache_foreign_key_to_fields[ $model_name ]; |
|
3719 | + return $this->_cache_foreign_key_to_fields[$model_name]; |
|
3720 | 3720 | } |
3721 | 3721 | |
3722 | 3722 | |
@@ -3727,7 +3727,7 @@ discard block |
||
3727 | 3727 | * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works |
3728 | 3728 | * @return EE_Table_Base |
3729 | 3729 | */ |
3730 | - function get_table_for_alias($table_alias){ |
|
3730 | + function get_table_for_alias($table_alias) { |
|
3731 | 3731 | $table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias); |
3732 | 3732 | return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name(); |
3733 | 3733 | } |
@@ -3740,25 +3740,25 @@ discard block |
||
3740 | 3740 | * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields |
3741 | 3741 | * @return EE_Model_Field_Base[] where the keys are the field's name |
3742 | 3742 | */ |
3743 | - public function field_settings($include_db_only_fields = false){ |
|
3744 | - if( $include_db_only_fields ){ |
|
3745 | - if( $this->_cached_fields === NULL ){ |
|
3743 | + public function field_settings($include_db_only_fields = false) { |
|
3744 | + if ($include_db_only_fields) { |
|
3745 | + if ($this->_cached_fields === NULL) { |
|
3746 | 3746 | $this->_cached_fields = array(); |
3747 | - foreach($this->_fields as $fields_corresponding_to_table){ |
|
3748 | - foreach($fields_corresponding_to_table as $field_name => $field_obj){ |
|
3749 | - $this->_cached_fields[$field_name]=$field_obj; |
|
3747 | + foreach ($this->_fields as $fields_corresponding_to_table) { |
|
3748 | + foreach ($fields_corresponding_to_table as $field_name => $field_obj) { |
|
3749 | + $this->_cached_fields[$field_name] = $field_obj; |
|
3750 | 3750 | } |
3751 | 3751 | } |
3752 | 3752 | } |
3753 | 3753 | return $this->_cached_fields; |
3754 | - }else{ |
|
3755 | - if( $this->_cached_fields_non_db_only === NULL ){ |
|
3754 | + } else { |
|
3755 | + if ($this->_cached_fields_non_db_only === NULL) { |
|
3756 | 3756 | $this->_cached_fields_non_db_only = array(); |
3757 | - foreach($this->_fields as $fields_corresponding_to_table){ |
|
3758 | - foreach($fields_corresponding_to_table as $field_name => $field_obj){ |
|
3757 | + foreach ($this->_fields as $fields_corresponding_to_table) { |
|
3758 | + foreach ($fields_corresponding_to_table as $field_name => $field_obj) { |
|
3759 | 3759 | /** @var $field_obj EE_Model_Field_Base */ |
3760 | - if( ! $field_obj->is_db_only_field() ){ |
|
3761 | - $this->_cached_fields_non_db_only[$field_name]=$field_obj; |
|
3760 | + if ( ! $field_obj->is_db_only_field()) { |
|
3761 | + $this->_cached_fields_non_db_only[$field_name] = $field_obj; |
|
3762 | 3762 | } |
3763 | 3763 | } |
3764 | 3764 | } |
@@ -3777,67 +3777,67 @@ discard block |
||
3777 | 3777 | * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed) |
3778 | 3778 | * @throws \EE_Error |
3779 | 3779 | */ |
3780 | - protected function _create_objects( $rows = array() ) { |
|
3781 | - $array_of_objects=array(); |
|
3782 | - if(empty($rows)){ |
|
3780 | + protected function _create_objects($rows = array()) { |
|
3781 | + $array_of_objects = array(); |
|
3782 | + if (empty($rows)) { |
|
3783 | 3783 | return array(); |
3784 | 3784 | } |
3785 | 3785 | $count_if_model_has_no_primary_key = 0; |
3786 | 3786 | $has_primary_key = $this->has_primary_key_field(); |
3787 | - if( $has_primary_key ) { |
|
3787 | + if ($has_primary_key) { |
|
3788 | 3788 | $primary_key_field = $this->get_primary_key_field(); |
3789 | 3789 | } else { |
3790 | 3790 | $primary_key_field = null; |
3791 | 3791 | } |
3792 | - foreach ( $rows as $row ) { |
|
3793 | - if(empty($row)){ |
|
3792 | + foreach ($rows as $row) { |
|
3793 | + if (empty($row)) { |
|
3794 | 3794 | //wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful... |
3795 | 3795 | return array(); |
3796 | 3796 | } |
3797 | 3797 | //check if we've already set this object in the results array, |
3798 | 3798 | //in which case there's no need to process it further (again) |
3799 | - if( $has_primary_key ) { |
|
3799 | + if ($has_primary_key) { |
|
3800 | 3800 | $table_pk_value = $this->_get_column_value_with_table_alias_or_not( |
3801 | 3801 | $row, |
3802 | 3802 | $primary_key_field->get_qualified_column(), |
3803 | 3803 | $primary_key_field->get_table_column() |
3804 | 3804 | ); |
3805 | - if( $table_pk_value && |
|
3806 | - isset( $array_of_objects[ $table_pk_value ] ) ) { |
|
3805 | + if ($table_pk_value && |
|
3806 | + isset($array_of_objects[$table_pk_value])) { |
|
3807 | 3807 | continue; |
3808 | 3808 | } |
3809 | 3809 | } |
3810 | - $classInstance=$this->instantiate_class_from_array_or_object($row); |
|
3811 | - if( ! $classInstance ) { |
|
3810 | + $classInstance = $this->instantiate_class_from_array_or_object($row); |
|
3811 | + if ( ! $classInstance) { |
|
3812 | 3812 | throw new EE_Error( |
3813 | 3813 | sprintf( |
3814 | - __( 'Could not create instance of class %s from row %s', 'event_espresso' ), |
|
3814 | + __('Could not create instance of class %s from row %s', 'event_espresso'), |
|
3815 | 3815 | $this->get_this_model_name(), |
3816 | - http_build_query( $row ) |
|
3816 | + http_build_query($row) |
|
3817 | 3817 | ) |
3818 | 3818 | ); |
3819 | 3819 | } |
3820 | 3820 | //set the timezone on the instantiated objects |
3821 | - $classInstance->set_timezone( $this->_timezone ); |
|
3821 | + $classInstance->set_timezone($this->_timezone); |
|
3822 | 3822 | //make sure if there is any timezone setting present that we set the timezone for the object |
3823 | 3823 | $key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++; |
3824 | - $array_of_objects[ $key ] = $classInstance; |
|
3824 | + $array_of_objects[$key] = $classInstance; |
|
3825 | 3825 | //also, for all the relations of type BelongsTo, see if we can cache |
3826 | 3826 | //those related models |
3827 | 3827 | //(we could do this for other relations too, but if there are conditions |
3828 | 3828 | //that filtered out some fo the results, then we'd be caching an incomplete set |
3829 | 3829 | //so it requires a little more thought than just caching them immediately...) |
3830 | - foreach($this->_model_relations as $modelName => $relation_obj){ |
|
3831 | - if( $relation_obj instanceof EE_Belongs_To_Relation){ |
|
3830 | + foreach ($this->_model_relations as $modelName => $relation_obj) { |
|
3831 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
3832 | 3832 | //check if this model's INFO is present. If so, cache it on the model |
3833 | 3833 | $other_model = $relation_obj->get_other_model(); |
3834 | 3834 | |
3835 | 3835 | $other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row); |
3836 | 3836 | |
3837 | 3837 | //if we managed to make a model object from the results, cache it on the main model object |
3838 | - if( $other_model_obj_maybe ){ |
|
3838 | + if ($other_model_obj_maybe) { |
|
3839 | 3839 | //set timezone on these other model objects if they are present |
3840 | - $other_model_obj_maybe->set_timezone( $this->_timezone ); |
|
3840 | + $other_model_obj_maybe->set_timezone($this->_timezone); |
|
3841 | 3841 | $classInstance->cache($modelName, $other_model_obj_maybe); |
3842 | 3842 | } |
3843 | 3843 | } |
@@ -3858,12 +3858,12 @@ discard block |
||
3858 | 3858 | |
3859 | 3859 | $this_model_fields_and_values = array(); |
3860 | 3860 | //setup the row using default values; |
3861 | - foreach ( $this->field_settings() as $field_name => $field_obj ) { |
|
3861 | + foreach ($this->field_settings() as $field_name => $field_obj) { |
|
3862 | 3862 | $this_model_fields_and_values[$field_name] = $field_obj->get_default_value(); |
3863 | 3863 | } |
3864 | 3864 | |
3865 | 3865 | $className = $this->_get_class_name(); |
3866 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE ); |
|
3866 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE); |
|
3867 | 3867 | |
3868 | 3868 | return $classInstance; |
3869 | 3869 | } |
@@ -3876,45 +3876,45 @@ discard block |
||
3876 | 3876 | * or an stdClass where each property is the name of a column, |
3877 | 3877 | * @return EE_Base_Class |
3878 | 3878 | */ |
3879 | - public function instantiate_class_from_array_or_object($cols_n_values){ |
|
3880 | - if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) { |
|
3881 | - $cols_n_values = get_object_vars( $cols_n_values ); |
|
3879 | + public function instantiate_class_from_array_or_object($cols_n_values) { |
|
3880 | + if ( ! is_array($cols_n_values) && is_object($cols_n_values)) { |
|
3881 | + $cols_n_values = get_object_vars($cols_n_values); |
|
3882 | 3882 | } |
3883 | 3883 | $primary_key = NULL; |
3884 | 3884 | //make sure the array only has keys that are fields/columns on this model |
3885 | - $this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values ); |
|
3886 | - if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){ |
|
3887 | - $primary_key = $this_model_fields_n_values[ $this->primary_key_name() ]; |
|
3885 | + $this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values); |
|
3886 | + if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) { |
|
3887 | + $primary_key = $this_model_fields_n_values[$this->primary_key_name()]; |
|
3888 | 3888 | } |
3889 | - $className=$this->_get_class_name(); |
|
3889 | + $className = $this->_get_class_name(); |
|
3890 | 3890 | |
3891 | 3891 | //check we actually found results that we can use to build our model object |
3892 | 3892 | //if not, return null |
3893 | - if( $this->has_primary_key_field()){ |
|
3894 | - if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){ |
|
3893 | + if ($this->has_primary_key_field()) { |
|
3894 | + if (empty($this_model_fields_n_values[$this->primary_key_name()])) { |
|
3895 | 3895 | return NULL; |
3896 | 3896 | } |
3897 | - }else if($this->unique_indexes()){ |
|
3897 | + } else if ($this->unique_indexes()) { |
|
3898 | 3898 | $first_column = reset($this_model_fields_n_values); |
3899 | - if(empty($first_column)){ |
|
3899 | + if (empty($first_column)) { |
|
3900 | 3900 | return NULL; |
3901 | 3901 | } |
3902 | 3902 | } |
3903 | 3903 | |
3904 | 3904 | // if there is no primary key or the object doesn't already exist in the entity map, then create a new instance |
3905 | - if ( $primary_key){ |
|
3906 | - $classInstance = $this->get_from_entity_map( $primary_key ); |
|
3907 | - if( ! $classInstance) { |
|
3908 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE ); |
|
3905 | + if ($primary_key) { |
|
3906 | + $classInstance = $this->get_from_entity_map($primary_key); |
|
3907 | + if ( ! $classInstance) { |
|
3908 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE); |
|
3909 | 3909 | // add this new object to the entity map |
3910 | - $classInstance = $this->add_to_entity_map( $classInstance ); |
|
3910 | + $classInstance = $this->add_to_entity_map($classInstance); |
|
3911 | 3911 | } |
3912 | - }else{ |
|
3913 | - $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE ); |
|
3912 | + } else { |
|
3913 | + $classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE); |
|
3914 | 3914 | } |
3915 | 3915 | |
3916 | 3916 | //it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example). In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property. |
3917 | - $this->set_timezone( $classInstance->get_timezone() ); |
|
3917 | + $this->set_timezone($classInstance->get_timezone()); |
|
3918 | 3918 | return $classInstance; |
3919 | 3919 | } |
3920 | 3920 | /** |
@@ -3922,8 +3922,8 @@ discard block |
||
3922 | 3922 | * @param int|string $id the ID of the model object |
3923 | 3923 | * @return EE_Base_Class |
3924 | 3924 | */ |
3925 | - public function get_from_entity_map( $id ){ |
|
3926 | - return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL; |
|
3925 | + public function get_from_entity_map($id) { |
|
3926 | + return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL; |
|
3927 | 3927 | } |
3928 | 3928 | |
3929 | 3929 | |
@@ -3942,21 +3942,21 @@ discard block |
||
3942 | 3942 | * @throws EE_Error |
3943 | 3943 | * @return \EE_Base_Class |
3944 | 3944 | */ |
3945 | - public function add_to_entity_map( EE_Base_Class $object) { |
|
3945 | + public function add_to_entity_map(EE_Base_Class $object) { |
|
3946 | 3946 | $className = $this->_get_class_name(); |
3947 | - if( ! $object instanceof $className ){ |
|
3948 | - throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) ); |
|
3947 | + if ( ! $object instanceof $className) { |
|
3948 | + throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className)); |
|
3949 | 3949 | } |
3950 | 3950 | /** @var $object EE_Base_Class */ |
3951 | - if ( ! $object->ID() ){ |
|
3952 | - throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this))); |
|
3951 | + if ( ! $object->ID()) { |
|
3952 | + throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this))); |
|
3953 | 3953 | } |
3954 | 3954 | // double check it's not already there |
3955 | - $classInstance = $this->get_from_entity_map( $object->ID() ); |
|
3956 | - if ( $classInstance ) { |
|
3955 | + $classInstance = $this->get_from_entity_map($object->ID()); |
|
3956 | + if ($classInstance) { |
|
3957 | 3957 | return $classInstance; |
3958 | 3958 | } else { |
3959 | - $this->_entity_map[ $object->ID() ] = $object; |
|
3959 | + $this->_entity_map[$object->ID()] = $object; |
|
3960 | 3960 | return $object; |
3961 | 3961 | } |
3962 | 3962 | } |
@@ -3969,8 +3969,8 @@ discard block |
||
3969 | 3969 | * @param array $cols_n_values |
3970 | 3970 | * @return array |
3971 | 3971 | */ |
3972 | - public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) { |
|
3973 | - return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values ); |
|
3972 | + public function deduce_fields_n_values_from_cols_n_values($cols_n_values) { |
|
3973 | + return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values); |
|
3974 | 3974 | } |
3975 | 3975 | |
3976 | 3976 | |
@@ -3983,40 +3983,40 @@ discard block |
||
3983 | 3983 | * @param string $cols_n_values |
3984 | 3984 | * @return array |
3985 | 3985 | */ |
3986 | - protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){ |
|
3986 | + protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) { |
|
3987 | 3987 | $this_model_fields_n_values = array(); |
3988 | - foreach( $this->get_tables() as $table_alias => $table_obj ) { |
|
3989 | - $table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() ); |
|
3988 | + foreach ($this->get_tables() as $table_alias => $table_obj) { |
|
3989 | + $table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column()); |
|
3990 | 3990 | //there is a primary key on this table and its not set. Use defaults for all its columns |
3991 | - if( $table_obj->get_pk_column() && $table_pk_value === NULL ){ |
|
3992 | - foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) { |
|
3993 | - if( ! $field_obj->is_db_only_field() ){ |
|
3991 | + if ($table_obj->get_pk_column() && $table_pk_value === NULL) { |
|
3992 | + foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) { |
|
3993 | + if ( ! $field_obj->is_db_only_field()) { |
|
3994 | 3994 | //prepare field as if its coming from db |
3995 | - $prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() ); |
|
3996 | - $this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value ); |
|
3995 | + $prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value()); |
|
3996 | + $this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value); |
|
3997 | 3997 | } |
3998 | 3998 | } |
3999 | - }else{ |
|
3999 | + } else { |
|
4000 | 4000 | //the table's rows existed. Use their values |
4001 | - foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) { |
|
4002 | - if( ! $field_obj->is_db_only_field() ) |
|
4003 | - $this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() ); |
|
4001 | + foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) { |
|
4002 | + if ( ! $field_obj->is_db_only_field()) |
|
4003 | + $this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column()); |
|
4004 | 4004 | } |
4005 | 4005 | } |
4006 | 4006 | } |
4007 | 4007 | return $this_model_fields_n_values; |
4008 | 4008 | } |
4009 | 4009 | |
4010 | - protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){ |
|
4010 | + protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) { |
|
4011 | 4011 | //ask the field what it think it's table_name.column_name should be, and call it the "qualified column" |
4012 | 4012 | //does the field on the model relate to this column retrieved from the db? |
4013 | 4013 | //or is it a db-only field? (not relating to the model) |
4014 | - if( isset( $cols_n_values[ $qualified_column ] ) ){ |
|
4015 | - $value = $cols_n_values[ $qualified_column ]; |
|
4014 | + if (isset($cols_n_values[$qualified_column])) { |
|
4015 | + $value = $cols_n_values[$qualified_column]; |
|
4016 | 4016 | |
4017 | - }elseif( isset( $cols_n_values[ $regular_column ] ) ){ |
|
4018 | - $value = $cols_n_values[ $regular_column ]; |
|
4019 | - }else{ |
|
4017 | + }elseif (isset($cols_n_values[$regular_column])) { |
|
4018 | + $value = $cols_n_values[$regular_column]; |
|
4019 | + } else { |
|
4020 | 4020 | $value = NULL; |
4021 | 4021 | } |
4022 | 4022 | |
@@ -4034,23 +4034,23 @@ discard block |
||
4034 | 4034 | * @param int|string $id |
4035 | 4035 | * @return EE_Base_Class |
4036 | 4036 | */ |
4037 | - public function refresh_entity_map_from_db( $id ){ |
|
4038 | - $obj_in_map = $this->get_from_entity_map( $id ); |
|
4039 | - if( $obj_in_map ){ |
|
4040 | - $wpdb_results = $this->_get_all_wpdb_results( array( array ( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) ); |
|
4041 | - if( $wpdb_results && is_array( $wpdb_results ) ){ |
|
4042 | - $one_row = reset( $wpdb_results ); |
|
4043 | - foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) { |
|
4044 | - $obj_in_map->set_from_db( $field_name, $db_value ); |
|
4037 | + public function refresh_entity_map_from_db($id) { |
|
4038 | + $obj_in_map = $this->get_from_entity_map($id); |
|
4039 | + if ($obj_in_map) { |
|
4040 | + $wpdb_results = $this->_get_all_wpdb_results(array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1)); |
|
4041 | + if ($wpdb_results && is_array($wpdb_results)) { |
|
4042 | + $one_row = reset($wpdb_results); |
|
4043 | + foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) { |
|
4044 | + $obj_in_map->set_from_db($field_name, $db_value); |
|
4045 | 4045 | } |
4046 | 4046 | //clear the cache of related model objects |
4047 | - foreach ( $this->relation_settings() as $relation_name => $relation_obj ){ |
|
4048 | - $obj_in_map->clear_cache($relation_name, NULL, TRUE ); |
|
4047 | + foreach ($this->relation_settings() as $relation_name => $relation_obj) { |
|
4048 | + $obj_in_map->clear_cache($relation_name, NULL, TRUE); |
|
4049 | 4049 | } |
4050 | 4050 | } |
4051 | 4051 | return $obj_in_map; |
4052 | - }else{ |
|
4053 | - return $this->get_one_by_ID( $id ); |
|
4052 | + } else { |
|
4053 | + return $this->get_one_by_ID($id); |
|
4054 | 4054 | } |
4055 | 4055 | } |
4056 | 4056 | |
@@ -4068,24 +4068,24 @@ discard block |
||
4068 | 4068 | * @param EE_Base_Class $replacing_model_obj |
4069 | 4069 | * @return \EE_Base_Class |
4070 | 4070 | */ |
4071 | - public function refresh_entity_map_with( $id, $replacing_model_obj ) { |
|
4072 | - $obj_in_map = $this->get_from_entity_map( $id ); |
|
4073 | - if( $obj_in_map ){ |
|
4074 | - if( $replacing_model_obj instanceof EE_Base_Class ){ |
|
4075 | - foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) { |
|
4076 | - $obj_in_map->set( $field_name, $value ); |
|
4071 | + public function refresh_entity_map_with($id, $replacing_model_obj) { |
|
4072 | + $obj_in_map = $this->get_from_entity_map($id); |
|
4073 | + if ($obj_in_map) { |
|
4074 | + if ($replacing_model_obj instanceof EE_Base_Class) { |
|
4075 | + foreach ($replacing_model_obj->model_field_array() as $field_name => $value) { |
|
4076 | + $obj_in_map->set($field_name, $value); |
|
4077 | 4077 | } |
4078 | 4078 | //make the model object in the entity map's cache match the $replacing_model_obj |
4079 | - foreach ( $this->relation_settings() as $relation_name => $relation_obj ){ |
|
4080 | - $obj_in_map->clear_cache($relation_name, NULL, TRUE ); |
|
4081 | - foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) { |
|
4082 | - $obj_in_map->cache( $relation_name, $cached_obj, $cache_id ); |
|
4079 | + foreach ($this->relation_settings() as $relation_name => $relation_obj) { |
|
4080 | + $obj_in_map->clear_cache($relation_name, NULL, TRUE); |
|
4081 | + foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) { |
|
4082 | + $obj_in_map->cache($relation_name, $cached_obj, $cache_id); |
|
4083 | 4083 | } |
4084 | 4084 | } |
4085 | 4085 | } |
4086 | 4086 | return $obj_in_map; |
4087 | - }else{ |
|
4088 | - $this->add_to_entity_map( $replacing_model_obj ); |
|
4087 | + } else { |
|
4088 | + $this->add_to_entity_map($replacing_model_obj); |
|
4089 | 4089 | return $replacing_model_obj; |
4090 | 4090 | } |
4091 | 4091 | } |
@@ -4098,7 +4098,7 @@ discard block |
||
4098 | 4098 | * require_once($this->_getClassName().".class.php"); |
4099 | 4099 | * @return string |
4100 | 4100 | */ |
4101 | - private function _get_class_name(){ |
|
4101 | + private function _get_class_name() { |
|
4102 | 4102 | return "EE_".$this->get_this_model_name(); |
4103 | 4103 | } |
4104 | 4104 | |
@@ -4111,10 +4111,10 @@ discard block |
||
4111 | 4111 | * @param int $quantity |
4112 | 4112 | * @return string |
4113 | 4113 | */ |
4114 | - public function item_name($quantity = 1){ |
|
4115 | - if($quantity == 1){ |
|
4114 | + public function item_name($quantity = 1) { |
|
4115 | + if ($quantity == 1) { |
|
4116 | 4116 | return $this->singular_item; |
4117 | - }else{ |
|
4117 | + } else { |
|
4118 | 4118 | return $this->plural_item; |
4119 | 4119 | } |
4120 | 4120 | } |
@@ -4143,13 +4143,13 @@ discard block |
||
4143 | 4143 | * @throws EE_Error |
4144 | 4144 | * @return mixed whatever the plugin which calls add_filter decides |
4145 | 4145 | */ |
4146 | - public function __call($methodName,$args){ |
|
4147 | - $className=get_class($this); |
|
4148 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
4149 | - if(!has_filter($tagName)){ |
|
4146 | + public function __call($methodName, $args) { |
|
4147 | + $className = get_class($this); |
|
4148 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
4149 | + if ( ! has_filter($tagName)) { |
|
4150 | 4150 | throw new EE_Error( |
4151 | 4151 | sprintf( |
4152 | - __( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s /*function body*/%4$s return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ), |
|
4152 | + __('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s /*function body*/%4$s return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'), |
|
4153 | 4153 | $methodName, |
4154 | 4154 | $className, |
4155 | 4155 | $tagName, |
@@ -4158,7 +4158,7 @@ discard block |
||
4158 | 4158 | ); |
4159 | 4159 | } |
4160 | 4160 | |
4161 | - return apply_filters($tagName,null,$this,$args); |
|
4161 | + return apply_filters($tagName, null, $this, $args); |
|
4162 | 4162 | } |
4163 | 4163 | |
4164 | 4164 | |
@@ -4171,22 +4171,22 @@ discard block |
||
4171 | 4171 | * @throws EE_Error |
4172 | 4172 | * @return EE_Base_Class |
4173 | 4173 | */ |
4174 | - public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){ |
|
4174 | + public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) { |
|
4175 | 4175 | $className = $this->_get_class_name(); |
4176 | 4176 | $primary_key_field = $this->get_primary_key_field(); |
4177 | - if( $base_class_obj_or_id instanceof $className ){ |
|
4177 | + if ($base_class_obj_or_id instanceof $className) { |
|
4178 | 4178 | $model_object = $base_class_obj_or_id; |
4179 | - }elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && ( |
|
4180 | - is_int( $base_class_obj_or_id ) || |
|
4181 | - is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101) |
|
4179 | + }elseif ($primary_key_field instanceof EE_Primary_Key_Int_Field && ( |
|
4180 | + is_int($base_class_obj_or_id) || |
|
4181 | + is_string($base_class_obj_or_id) )) {//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101) |
|
4182 | 4182 | $model_object = $this->get_one_by_ID($base_class_obj_or_id); |
4183 | - }elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){ |
|
4183 | + }elseif ($primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id)) { |
|
4184 | 4184 | //assume its a string representation of the object |
4185 | 4185 | $model_object = $this->get_one_by_ID($base_class_obj_or_id); |
4186 | - }else{ |
|
4187 | - throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true))); |
|
4186 | + } else { |
|
4187 | + throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true))); |
|
4188 | 4188 | } |
4189 | - if( $model_object->ID() == NULL && $ensure_is_in_db){ |
|
4189 | + if ($model_object->ID() == NULL && $ensure_is_in_db) { |
|
4190 | 4190 | $model_object->save(); |
4191 | 4191 | } |
4192 | 4192 | return $model_object; |
@@ -4202,19 +4202,19 @@ discard block |
||
4202 | 4202 | * @return int|string depending on the type of this model object's ID |
4203 | 4203 | * @throws EE_Error |
4204 | 4204 | */ |
4205 | - public function ensure_is_ID($base_class_obj_or_id){ |
|
4205 | + public function ensure_is_ID($base_class_obj_or_id) { |
|
4206 | 4206 | $className = $this->_get_class_name(); |
4207 | - if( $base_class_obj_or_id instanceof $className ){ |
|
4207 | + if ($base_class_obj_or_id instanceof $className) { |
|
4208 | 4208 | /** @var $base_class_obj_or_id EE_Base_Class */ |
4209 | 4209 | $id = $base_class_obj_or_id->ID(); |
4210 | - }elseif(is_int($base_class_obj_or_id)){ |
|
4210 | + }elseif (is_int($base_class_obj_or_id)) { |
|
4211 | 4211 | //assume it's an ID |
4212 | 4212 | $id = $base_class_obj_or_id; |
4213 | - }elseif(is_string($base_class_obj_or_id)){ |
|
4213 | + }elseif (is_string($base_class_obj_or_id)) { |
|
4214 | 4214 | //assume its a string representation of the object |
4215 | 4215 | $id = $base_class_obj_or_id; |
4216 | - }else{ |
|
4217 | - throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true))); |
|
4216 | + } else { |
|
4217 | + throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true))); |
|
4218 | 4218 | } |
4219 | 4219 | return $id; |
4220 | 4220 | } |
@@ -4237,14 +4237,14 @@ discard block |
||
4237 | 4237 | * @param int $values_already_prepared like one of the constants on EEM_Base |
4238 | 4238 | * @return void |
4239 | 4239 | */ |
4240 | - public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){ |
|
4240 | + public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) { |
|
4241 | 4241 | $this->_values_already_prepared_by_model_object = $values_already_prepared; |
4242 | 4242 | } |
4243 | 4243 | /** |
4244 | 4244 | * Read comments for assume_values_already_prepared_by_model_object() |
4245 | 4245 | * @return int |
4246 | 4246 | */ |
4247 | - public function get_assumption_concerning_values_already_prepared_by_model_object(){ |
|
4247 | + public function get_assumption_concerning_values_already_prepared_by_model_object() { |
|
4248 | 4248 | return $this->_values_already_prepared_by_model_object; |
4249 | 4249 | } |
4250 | 4250 | |
@@ -4252,17 +4252,17 @@ discard block |
||
4252 | 4252 | * Gets all the indexes on this model |
4253 | 4253 | * @return EE_Index[] |
4254 | 4254 | */ |
4255 | - public function indexes(){ |
|
4255 | + public function indexes() { |
|
4256 | 4256 | return $this->_indexes; |
4257 | 4257 | } |
4258 | 4258 | /** |
4259 | 4259 | * Gets all the Unique Indexes on this model |
4260 | 4260 | * @return EE_Unique_Index[] |
4261 | 4261 | */ |
4262 | - public function unique_indexes(){ |
|
4262 | + public function unique_indexes() { |
|
4263 | 4263 | $unique_indexes = array(); |
4264 | - foreach($this->_indexes as $name => $index){ |
|
4265 | - if($index instanceof EE_Unique_Index){ |
|
4264 | + foreach ($this->_indexes as $name => $index) { |
|
4265 | + if ($index instanceof EE_Unique_Index) { |
|
4266 | 4266 | $unique_indexes [$name] = $index; |
4267 | 4267 | } |
4268 | 4268 | } |
@@ -4275,9 +4275,9 @@ discard block |
||
4275 | 4275 | * on a primary index |
4276 | 4276 | * @return EE_Model_Field_Base[] |
4277 | 4277 | */ |
4278 | - public function get_combined_primary_key_fields(){ |
|
4279 | - foreach($this->indexes() as $index){ |
|
4280 | - if($index instanceof EE_Primary_Key_Index){ |
|
4278 | + public function get_combined_primary_key_fields() { |
|
4279 | + foreach ($this->indexes() as $index) { |
|
4280 | + if ($index instanceof EE_Primary_Key_Index) { |
|
4281 | 4281 | return $index->fields(); |
4282 | 4282 | } |
4283 | 4283 | } |
@@ -4290,7 +4290,7 @@ discard block |
||
4290 | 4290 | * @param array $cols_n_values keys are field names, values are their values |
4291 | 4291 | * @return string |
4292 | 4292 | */ |
4293 | - public function get_index_primary_key_string($cols_n_values){ |
|
4293 | + public function get_index_primary_key_string($cols_n_values) { |
|
4294 | 4294 | $cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields()); |
4295 | 4295 | return http_build_query($cols_n_values_for_primary_key_index); |
4296 | 4296 | } |
@@ -4302,13 +4302,13 @@ discard block |
||
4302 | 4302 | * @param string $index_primary_key_string |
4303 | 4303 | * @return null|array |
4304 | 4304 | */ |
4305 | - function parse_index_primary_key_string( $index_primary_key_string) { |
|
4305 | + function parse_index_primary_key_string($index_primary_key_string) { |
|
4306 | 4306 | $key_fields = $this->get_combined_primary_key_fields(); |
4307 | 4307 | //check all of them are in the $id |
4308 | 4308 | $key_vals_in_combined_pk = array(); |
4309 | - parse_str( $index_primary_key_string, $key_vals_in_combined_pk ); |
|
4310 | - foreach( $key_fields as $key_field_name => $field_obj ) { |
|
4311 | - if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){ |
|
4309 | + parse_str($index_primary_key_string, $key_vals_in_combined_pk); |
|
4310 | + foreach ($key_fields as $key_field_name => $field_obj) { |
|
4311 | + if ( ! isset($key_vals_in_combined_pk[$key_field_name])) { |
|
4312 | 4312 | return NULL; |
4313 | 4313 | } |
4314 | 4314 | } |
@@ -4321,10 +4321,10 @@ discard block |
||
4321 | 4321 | * @param array $key_vals |
4322 | 4322 | * @return boolean |
4323 | 4323 | */ |
4324 | - function has_all_combined_primary_key_fields( $key_vals ) { |
|
4325 | - $keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() ); |
|
4326 | - foreach( $keys_it_should_have as $key ){ |
|
4327 | - if( ! isset( $key_vals[ $key ] ) ){ |
|
4324 | + function has_all_combined_primary_key_fields($key_vals) { |
|
4325 | + $keys_it_should_have = array_keys($this->get_combined_primary_key_fields()); |
|
4326 | + foreach ($keys_it_should_have as $key) { |
|
4327 | + if ( ! isset($key_vals[$key])) { |
|
4328 | 4328 | return false; |
4329 | 4329 | } |
4330 | 4330 | } |
@@ -4340,23 +4340,23 @@ discard block |
||
4340 | 4340 | * @throws EE_Error |
4341 | 4341 | * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed) |
4342 | 4342 | */ |
4343 | - public function get_all_copies($model_object_or_attributes_array, $query_params = array()){ |
|
4343 | + public function get_all_copies($model_object_or_attributes_array, $query_params = array()) { |
|
4344 | 4344 | |
4345 | - if($model_object_or_attributes_array instanceof EE_Base_Class){ |
|
4345 | + if ($model_object_or_attributes_array instanceof EE_Base_Class) { |
|
4346 | 4346 | $attributes_array = $model_object_or_attributes_array->model_field_array(); |
4347 | - }elseif(is_array($model_object_or_attributes_array)){ |
|
4347 | + }elseif (is_array($model_object_or_attributes_array)) { |
|
4348 | 4348 | $attributes_array = $model_object_or_attributes_array; |
4349 | - }else{ |
|
4350 | - throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array)); |
|
4349 | + } else { |
|
4350 | + throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array)); |
|
4351 | 4351 | } |
4352 | 4352 | //even copies obviously won't have the same ID, so remove the primary key |
4353 | 4353 | //from the WHERE conditions for finding copies (if there is a primary key, of course) |
4354 | - if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){ |
|
4354 | + if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) { |
|
4355 | 4355 | unset($attributes_array[$this->primary_key_name()]); |
4356 | 4356 | } |
4357 | - if(isset($query_params[0])){ |
|
4358 | - $query_params[0] = array_merge($attributes_array,$query_params); |
|
4359 | - }else{ |
|
4357 | + if (isset($query_params[0])) { |
|
4358 | + $query_params[0] = array_merge($attributes_array, $query_params); |
|
4359 | + } else { |
|
4360 | 4360 | $query_params[0] = $attributes_array; |
4361 | 4361 | } |
4362 | 4362 | return $this->get_all($query_params); |
@@ -4370,16 +4370,16 @@ discard block |
||
4370 | 4370 | * @param array $query_params |
4371 | 4371 | * @return EE_Base_Class |
4372 | 4372 | */ |
4373 | - function get_one_copy($model_object_or_attributes_array,$query_params = array()){ |
|
4374 | - if( ! is_array( $query_params ) ){ |
|
4375 | - EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' ); |
|
4373 | + function get_one_copy($model_object_or_attributes_array, $query_params = array()) { |
|
4374 | + if ( ! is_array($query_params)) { |
|
4375 | + EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0'); |
|
4376 | 4376 | $query_params = array(); |
4377 | 4377 | } |
4378 | 4378 | $query_params['limit'] = 1; |
4379 | - $copies = $this->get_all_copies($model_object_or_attributes_array,$query_params); |
|
4380 | - if(is_array($copies)){ |
|
4379 | + $copies = $this->get_all_copies($model_object_or_attributes_array, $query_params); |
|
4380 | + if (is_array($copies)) { |
|
4381 | 4381 | return array_shift($copies); |
4382 | - }else{ |
|
4382 | + } else { |
|
4383 | 4383 | return null; |
4384 | 4384 | } |
4385 | 4385 | } |
@@ -4393,10 +4393,10 @@ discard block |
||
4393 | 4393 | * @param int|string $id the value of the primary key to update |
4394 | 4394 | * @return int number of rows updated |
4395 | 4395 | */ |
4396 | - public function update_by_ID($fields_n_values,$id){ |
|
4396 | + public function update_by_ID($fields_n_values, $id) { |
|
4397 | 4397 | $query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id), |
4398 | 4398 | 'default_where_conditions'=>'other_models_only',); |
4399 | - return $this->update($fields_n_values,$query_params); |
|
4399 | + return $this->update($fields_n_values, $query_params); |
|
4400 | 4400 | } |
4401 | 4401 | |
4402 | 4402 | |
@@ -4407,12 +4407,12 @@ discard block |
||
4407 | 4407 | * @return string an operator which can be used in SQL |
4408 | 4408 | * @throws EE_Error |
4409 | 4409 | */ |
4410 | - private function _prepare_operator_for_sql($operator_supplied){ |
|
4410 | + private function _prepare_operator_for_sql($operator_supplied) { |
|
4411 | 4411 | $sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null; |
4412 | - if($sql_operator){ |
|
4412 | + if ($sql_operator) { |
|
4413 | 4413 | return $sql_operator; |
4414 | - }else{ |
|
4415 | - throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators)))); |
|
4414 | + } else { |
|
4415 | + throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators)))); |
|
4416 | 4416 | } |
4417 | 4417 | } |
4418 | 4418 | |
@@ -4422,10 +4422,10 @@ discard block |
||
4422 | 4422 | * @param array $query_params like get_all's |
4423 | 4423 | * @return string[] |
4424 | 4424 | */ |
4425 | - public function get_all_names($query_params = array()){ |
|
4425 | + public function get_all_names($query_params = array()) { |
|
4426 | 4426 | $objs = $this->get_all($query_params); |
4427 | 4427 | $names = array(); |
4428 | - foreach($objs as $obj){ |
|
4428 | + foreach ($objs as $obj) { |
|
4429 | 4429 | $names[$obj->ID()] = $obj->name(); |
4430 | 4430 | } |
4431 | 4431 | return $names; |
@@ -4440,22 +4440,22 @@ discard block |
||
4440 | 4440 | * @param boolean $filter_out_empty_ids if a model object has an ID of '' or 0, don't bother including it in the returned array |
4441 | 4441 | * @return array |
4442 | 4442 | */ |
4443 | - public function get_IDs( $model_objects, $filter_out_empty_ids = false) { |
|
4444 | - if( ! $this->has_primary_key_field() ) { |
|
4445 | - if( WP_DEBUG ) { |
|
4446 | - EE_Error::add_error( __( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
4443 | + public function get_IDs($model_objects, $filter_out_empty_ids = false) { |
|
4444 | + if ( ! $this->has_primary_key_field()) { |
|
4445 | + if (WP_DEBUG) { |
|
4446 | + EE_Error::add_error(__('Trying to get IDs from a model than has no primary key', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
4447 | 4447 | return array(); |
4448 | 4448 | } |
4449 | 4449 | } |
4450 | 4450 | $IDs = array(); |
4451 | - foreach( $model_objects as $model_object ) { |
|
4451 | + foreach ($model_objects as $model_object) { |
|
4452 | 4452 | $id = $model_object->ID(); |
4453 | - if( ! $id ) { |
|
4454 | - if( $filter_out_empty_ids ) { |
|
4453 | + if ( ! $id) { |
|
4454 | + if ($filter_out_empty_ids) { |
|
4455 | 4455 | continue; |
4456 | 4456 | } |
4457 | - if( WP_DEBUG ) { |
|
4458 | - EE_Error::add_error(__( 'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
4457 | + if (WP_DEBUG) { |
|
4458 | + EE_Error::add_error(__('Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
4459 | 4459 | } |
4460 | 4460 | } |
4461 | 4461 | $IDs[] = $id; |
@@ -4468,8 +4468,8 @@ discard block |
||
4468 | 4468 | * are no capabilities that relate to this model returns false |
4469 | 4469 | * @return string|false |
4470 | 4470 | */ |
4471 | - public function cap_slug(){ |
|
4472 | - return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this); |
|
4471 | + public function cap_slug() { |
|
4472 | + return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this); |
|
4473 | 4473 | } |
4474 | 4474 | |
4475 | 4475 | /** |
@@ -4481,27 +4481,27 @@ discard block |
||
4481 | 4481 | * @param string $context |
4482 | 4482 | * @return EE_Default_Where_Conditions[] indexed by associated capability |
4483 | 4483 | */ |
4484 | - public function cap_restrictions( $context = EEM_Base::caps_read ) { |
|
4485 | - EEM_Base::verify_is_valid_cap_context( $context ); |
|
4484 | + public function cap_restrictions($context = EEM_Base::caps_read) { |
|
4485 | + EEM_Base::verify_is_valid_cap_context($context); |
|
4486 | 4486 | //check if we ought to run the restriction generator first |
4487 | - if( isset( $this->_cap_restriction_generators[ $context ] ) && |
|
4488 | - $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base && |
|
4489 | - ! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions() ) { |
|
4490 | - $this->_cap_restrictions[ $context ] = array_merge( $this->_cap_restrictions[ $context ], $this->_cap_restriction_generators[ $context ]->generate_restrictions() ); |
|
4487 | + if (isset($this->_cap_restriction_generators[$context]) && |
|
4488 | + $this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base && |
|
4489 | + ! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()) { |
|
4490 | + $this->_cap_restrictions[$context] = array_merge($this->_cap_restrictions[$context], $this->_cap_restriction_generators[$context]->generate_restrictions()); |
|
4491 | 4491 | } |
4492 | 4492 | //and make sure we've finalized the construction of each restriction |
4493 | - foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) { |
|
4494 | - $where_conditions_obj->_finalize_construct( $this ); |
|
4493 | + foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) { |
|
4494 | + $where_conditions_obj->_finalize_construct($this); |
|
4495 | 4495 | } |
4496 | 4496 | |
4497 | - return $this->_cap_restrictions[ $context ]; |
|
4497 | + return $this->_cap_restrictions[$context]; |
|
4498 | 4498 | } |
4499 | 4499 | |
4500 | 4500 | /** |
4501 | 4501 | * Indicating whether or not this model thinks its a wp core model |
4502 | 4502 | * @return boolean |
4503 | 4503 | */ |
4504 | - public function is_wp_core_model(){ |
|
4504 | + public function is_wp_core_model() { |
|
4505 | 4505 | return $this->_wp_core_model; |
4506 | 4506 | } |
4507 | 4507 | |
@@ -4511,12 +4511,12 @@ discard block |
||
4511 | 4511 | * @param string $context one of EEM_Base::caps_ constants |
4512 | 4512 | * @return EE_Default_Where_Conditions[] indexed by capability name |
4513 | 4513 | */ |
4514 | - public function caps_missing( $context = EEM_Base::caps_read ) { |
|
4514 | + public function caps_missing($context = EEM_Base::caps_read) { |
|
4515 | 4515 | $missing_caps = array(); |
4516 | - $cap_restrictions = $this->cap_restrictions( $context ); |
|
4517 | - foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) { |
|
4518 | - if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) { |
|
4519 | - $missing_caps[ $cap ] = $restriction_if_no_cap; |
|
4516 | + $cap_restrictions = $this->cap_restrictions($context); |
|
4517 | + foreach ($cap_restrictions as $cap => $restriction_if_no_cap) { |
|
4518 | + if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) { |
|
4519 | + $missing_caps[$cap] = $restriction_if_no_cap; |
|
4520 | 4520 | } |
4521 | 4521 | } |
4522 | 4522 | return $missing_caps; |
@@ -4528,7 +4528,7 @@ discard block |
||
4528 | 4528 | * one of 'read', 'edit', or 'delete' |
4529 | 4529 | */ |
4530 | 4530 | public function cap_contexts_to_cap_action_map() { |
4531 | - return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this ); |
|
4531 | + return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this); |
|
4532 | 4532 | } |
4533 | 4533 | |
4534 | 4534 | |
@@ -4539,19 +4539,19 @@ discard block |
||
4539 | 4539 | * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values |
4540 | 4540 | * @throws \EE_Error |
4541 | 4541 | */ |
4542 | - public function cap_action_for_context( $context ) { |
|
4542 | + public function cap_action_for_context($context) { |
|
4543 | 4543 | $mapping = $this->cap_contexts_to_cap_action_map(); |
4544 | - if( isset( $mapping[ $context ] ) ) { |
|
4545 | - return $mapping[ $context ]; |
|
4544 | + if (isset($mapping[$context])) { |
|
4545 | + return $mapping[$context]; |
|
4546 | 4546 | } |
4547 | - if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) { |
|
4547 | + if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) { |
|
4548 | 4548 | return $action; |
4549 | 4549 | } |
4550 | 4550 | throw new EE_Error( |
4551 | 4551 | sprintf( |
4552 | - __( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ), |
|
4552 | + __('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'), |
|
4553 | 4553 | $context, |
4554 | - implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) ) |
|
4554 | + implode(',', array_keys($this->cap_contexts_to_cap_action_map())) |
|
4555 | 4555 | ) |
4556 | 4556 | ); |
4557 | 4557 | |
@@ -4562,7 +4562,7 @@ discard block |
||
4562 | 4562 | * @return array |
4563 | 4563 | */ |
4564 | 4564 | static public function valid_cap_contexts() { |
4565 | - return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array( |
|
4565 | + return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array( |
|
4566 | 4566 | self::caps_read, |
4567 | 4567 | self::caps_read_admin, |
4568 | 4568 | self::caps_edit, |
@@ -4578,17 +4578,17 @@ discard block |
||
4578 | 4578 | * @return bool |
4579 | 4579 | * @throws \EE_Error |
4580 | 4580 | */ |
4581 | - static public function verify_is_valid_cap_context( $context ) { |
|
4581 | + static public function verify_is_valid_cap_context($context) { |
|
4582 | 4582 | $valid_cap_contexts = EEM_Base::valid_cap_contexts(); |
4583 | - if( in_array( $context, $valid_cap_contexts ) ) { |
|
4583 | + if (in_array($context, $valid_cap_contexts)) { |
|
4584 | 4584 | return true; |
4585 | - }else{ |
|
4585 | + } else { |
|
4586 | 4586 | throw new EE_Error( |
4587 | 4587 | sprintf( |
4588 | - __( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ), |
|
4588 | + __('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'), |
|
4589 | 4589 | $context, |
4590 | - 'EEM_Base' , |
|
4591 | - implode(',', $valid_cap_contexts ) |
|
4590 | + 'EEM_Base', |
|
4591 | + implode(',', $valid_cap_contexts) |
|
4592 | 4592 | ) |
4593 | 4593 | ); |
4594 | 4594 | } |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | if( isset( $this->_cap_restriction_generators[ $context ] ) && |
547 | 547 | $this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) { |
548 | 548 | return $this->_cap_restriction_generators[ $context ]->generate_restrictions(); |
549 | - }else{ |
|
549 | + } else{ |
|
550 | 550 | return array(); |
551 | 551 | } |
552 | 552 | } |
@@ -597,8 +597,9 @@ discard block |
||
597 | 597 | * @return array |
598 | 598 | */ |
599 | 599 | public function status_array( $translated = FALSE ) { |
600 | - if ( !array_key_exists('Status', $this->_model_relations ) ) |
|
601 | - return array(); |
|
600 | + if ( !array_key_exists('Status', $this->_model_relations ) ) { |
|
601 | + return array(); |
|
602 | + } |
|
602 | 603 | $model_name = $this->get_this_model_name(); |
603 | 604 | $status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) ); |
604 | 605 | $stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) ); |
@@ -819,13 +820,13 @@ discard block |
||
819 | 820 | $last_model_name = end( $models_to_follow_to_wp_users ); |
820 | 821 | $model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name ); |
821 | 822 | $model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.'; |
822 | - }else{ |
|
823 | + } else{ |
|
823 | 824 | $model_with_fk_to_wp_users = $this; |
824 | 825 | $model_chain_to_wp_user = ''; |
825 | 826 | } |
826 | 827 | $wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' ); |
827 | 828 | return $model_chain_to_wp_user . $wp_user_field->get_name(); |
828 | - }catch( EE_Error $e ) { |
|
829 | + } catch( EE_Error $e ) { |
|
829 | 830 | return false; |
830 | 831 | } |
831 | 832 | } |
@@ -853,11 +854,11 @@ discard block |
||
853 | 854 | public function is_owned() { |
854 | 855 | if( $this->model_chain_to_wp_user() ){ |
855 | 856 | return true; |
856 | - }else{ |
|
857 | + } else{ |
|
857 | 858 | try{ |
858 | 859 | $this->get_foreign_key_to( 'WP_User' ); |
859 | 860 | return true; |
860 | - }catch( EE_Error $e ){ |
|
861 | + } catch( EE_Error $e ){ |
|
861 | 862 | return false; |
862 | 863 | } |
863 | 864 | } |
@@ -880,9 +881,9 @@ discard block |
||
880 | 881 | //remember the custom selections, if any |
881 | 882 | if(is_array($columns_to_select)){ |
882 | 883 | $this->_custom_selections = $columns_to_select; |
883 | - }elseif(is_string($columns_to_select)){ |
|
884 | + } elseif(is_string($columns_to_select)){ |
|
884 | 885 | $this->_custom_selections = array($this->_custom_selections); |
885 | - }else{ |
|
886 | + } else{ |
|
886 | 887 | $this->_custom_selections = array(); |
887 | 888 | } |
888 | 889 | |
@@ -954,7 +955,7 @@ discard block |
||
954 | 955 | $select_sql_array[] = "{$selection_and_datatype[0]} AS $alias"; |
955 | 956 | } |
956 | 957 | $columns_to_select_string = implode(", ",$select_sql_array); |
957 | - }else{ |
|
958 | + } else{ |
|
958 | 959 | $columns_to_select_string = $columns_to_select; |
959 | 960 | } |
960 | 961 | return $columns_to_select_string; |
@@ -1004,7 +1005,7 @@ discard block |
||
1004 | 1005 | } |
1005 | 1006 | if( $this->has_primary_key_field ( ) ) { |
1006 | 1007 | $query_params[ 0 ][ $this->primary_key_name() ] = $id ; |
1007 | - }else{ |
|
1008 | + } else{ |
|
1008 | 1009 | //no primary key, so the $id must be from the get_index_primary_key_string() |
1009 | 1010 | $query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) ); |
1010 | 1011 | } |
@@ -1027,7 +1028,7 @@ discard block |
||
1027 | 1028 | $items = $this->get_all($query_params); |
1028 | 1029 | if(empty($items)){ |
1029 | 1030 | return null; |
1030 | - }else{ |
|
1031 | + } else{ |
|
1031 | 1032 | return array_shift($items); |
1032 | 1033 | } |
1033 | 1034 | } |
@@ -1425,7 +1426,7 @@ discard block |
||
1425 | 1426 | //get the model object's PK, as we'll want this if we need to insert a row into secondary tables |
1426 | 1427 | if( $this->has_primary_key_field() ){ |
1427 | 1428 | $main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ]; |
1428 | - }else{ |
|
1429 | + } else{ |
|
1429 | 1430 | //if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work) |
1430 | 1431 | $main_table_pk_value = null; |
1431 | 1432 | } |
@@ -1464,7 +1465,7 @@ discard block |
||
1464 | 1465 | if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){ |
1465 | 1466 | if( $this->has_primary_key_field() ){ |
1466 | 1467 | $model_objs_affected_ids = $this->get_col( $query_params ); |
1467 | - }else{ |
|
1468 | + } else{ |
|
1468 | 1469 | //we need to select a bunch of columns and then combine them into the the "index primary key string"s |
1469 | 1470 | $models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A ); |
1470 | 1471 | $model_objs_affected_ids = array(); |
@@ -1524,9 +1525,9 @@ discard block |
||
1524 | 1525 | |
1525 | 1526 | if( $field_to_select ){ |
1526 | 1527 | $field = $this->field_settings_for( $field_to_select ); |
1527 | - }elseif( $this->has_primary_key_field ( ) ){ |
|
1528 | + } elseif( $this->has_primary_key_field ( ) ){ |
|
1528 | 1529 | $field = $this->get_primary_key_field(); |
1529 | - }else{ |
|
1530 | + } else{ |
|
1530 | 1531 | //no primary key, just grab the first column |
1531 | 1532 | $field = reset( $this->field_settings()); |
1532 | 1533 | } |
@@ -1550,7 +1551,7 @@ discard block |
||
1550 | 1551 | $col = $this->get_col( $query_params, $field_to_select ); |
1551 | 1552 | if( ! empty( $col ) ) { |
1552 | 1553 | return reset( $col ); |
1553 | - }else{ |
|
1554 | + } else{ |
|
1554 | 1555 | return NULL; |
1555 | 1556 | } |
1556 | 1557 | } |
@@ -1670,7 +1671,7 @@ discard block |
||
1670 | 1671 | |
1671 | 1672 | // /echo "delete sql:$SQL"; |
1672 | 1673 | $rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) ); |
1673 | - }else{ |
|
1674 | + } else{ |
|
1674 | 1675 | $rows_deleted = 0; |
1675 | 1676 | } |
1676 | 1677 | |
@@ -1712,7 +1713,7 @@ discard block |
||
1712 | 1713 | //first, if $ignore_this_model_obj was supplied, get its model |
1713 | 1714 | if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){ |
1714 | 1715 | $ignored_model = $ignore_this_model_obj->get_model(); |
1715 | - }else{ |
|
1716 | + } else{ |
|
1716 | 1717 | $ignored_model = null; |
1717 | 1718 | } |
1718 | 1719 | //now check all the relations of $this_model_obj_or_id and see if there |
@@ -1725,7 +1726,7 @@ discard block |
||
1725 | 1726 | if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){ |
1726 | 1727 | $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array( |
1727 | 1728 | array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID())))); |
1728 | - }else{ |
|
1729 | + } else{ |
|
1729 | 1730 | $related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id); |
1730 | 1731 | } |
1731 | 1732 | |
@@ -1762,24 +1763,28 @@ discard block |
||
1762 | 1763 | } |
1763 | 1764 | |
1764 | 1765 | //primary table deletes |
1765 | - if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) ) |
|
1766 | - $deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()]; |
|
1766 | + if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) ) { |
|
1767 | + $deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()]; |
|
1768 | + } |
|
1767 | 1769 | |
1768 | 1770 | //other tables |
1769 | 1771 | if ( !empty( $other_tables ) ) { |
1770 | 1772 | foreach ( $other_tables as $ot ) { |
1771 | 1773 | |
1772 | 1774 | //first check if we've got the foreign key column here. |
1773 | - if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) ) |
|
1774 | - $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()]; |
|
1775 | + if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) ) { |
|
1776 | + $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()]; |
|
1777 | + } |
|
1775 | 1778 | |
1776 | 1779 | //wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables |
1777 | - if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) ) |
|
1778 | - $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
|
1780 | + if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) ) { |
|
1781 | + $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
|
1782 | + } |
|
1779 | 1783 | |
1780 | 1784 | //finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there! |
1781 | - if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) ) |
|
1782 | - $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
|
1785 | + if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) ) { |
|
1786 | + $deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()]; |
|
1787 | + } |
|
1783 | 1788 | } |
1784 | 1789 | } |
1785 | 1790 | } |
@@ -1792,7 +1797,7 @@ discard block |
||
1792 | 1797 | } |
1793 | 1798 | |
1794 | 1799 | return !empty($query) ? implode(' AND ', $query ) : ''; |
1795 | - }elseif(count($this->get_combined_primary_key_fields()) > 1){ |
|
1800 | + } elseif(count($this->get_combined_primary_key_fields()) > 1){ |
|
1796 | 1801 | $ways_to_identify_a_row = array(); |
1797 | 1802 | $fields = $this->get_combined_primary_key_fields(); |
1798 | 1803 | //note: because there' sno primary key, that means nothing else can be pointing to this model, right? |
@@ -1804,7 +1809,7 @@ discard block |
||
1804 | 1809 | $ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")"; |
1805 | 1810 | } |
1806 | 1811 | return implode(" OR ",$ways_to_identify_a_row); |
1807 | - }else{ |
|
1812 | + } else{ |
|
1808 | 1813 | //so there's no primary key and no combined key... |
1809 | 1814 | //sorry, can't help you |
1810 | 1815 | throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this))); |
@@ -1826,10 +1831,10 @@ discard block |
||
1826 | 1831 | if($field_to_count){ |
1827 | 1832 | $field_obj = $this->field_settings_for($field_to_count); |
1828 | 1833 | $column_to_count = $field_obj->get_qualified_column(); |
1829 | - }elseif($this->has_primary_key_field ()){ |
|
1834 | + } elseif($this->has_primary_key_field ()){ |
|
1830 | 1835 | $pk_field_obj = $this->get_primary_key_field(); |
1831 | 1836 | $column_to_count = $pk_field_obj->get_qualified_column(); |
1832 | - }else{//there's no primary key |
|
1837 | + } else{//there's no primary key |
|
1833 | 1838 | $column_to_count = '*'; |
1834 | 1839 | } |
1835 | 1840 | |
@@ -1851,7 +1856,7 @@ discard block |
||
1851 | 1856 | if($field_to_sum){ |
1852 | 1857 | $field_obj = $this->field_settings_for($field_to_sum); |
1853 | 1858 | |
1854 | - }else{ |
|
1859 | + } else{ |
|
1855 | 1860 | $field_obj = $this->get_primary_key_field(); |
1856 | 1861 | } |
1857 | 1862 | $column_to_count = $field_obj->get_qualified_column(); |
@@ -1860,7 +1865,7 @@ discard block |
||
1860 | 1865 | $return_value = $this->_do_wpdb_query('get_var',array( $SQL ) ); |
1861 | 1866 | if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){ |
1862 | 1867 | return (float)$return_value; |
1863 | - }else{//must be %f |
|
1868 | + } else{//must be %f |
|
1864 | 1869 | return (float)$return_value; |
1865 | 1870 | } |
1866 | 1871 | } |
@@ -1898,10 +1903,10 @@ discard block |
||
1898 | 1903 | $wpdb->show_errors( $old_show_errors_value ); |
1899 | 1904 | if( ! empty( $wpdb->last_error ) ){ |
1900 | 1905 | throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) ); |
1901 | - }elseif( $result === false ){ |
|
1906 | + } elseif( $result === false ){ |
|
1902 | 1907 | throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) ); |
1903 | 1908 | } |
1904 | - }elseif( $result === false ) { |
|
1909 | + } elseif( $result === false ) { |
|
1905 | 1910 | EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__); |
1906 | 1911 | } |
1907 | 1912 | return $result; |
@@ -2211,7 +2216,7 @@ discard block |
||
2211 | 2216 | $results = $this->get_all_related($id_or_obj,$other_model_name,$query_params); |
2212 | 2217 | if( $results ){ |
2213 | 2218 | return array_shift($results); |
2214 | - }else{ |
|
2219 | + } else{ |
|
2215 | 2220 | return null; |
2216 | 2221 | } |
2217 | 2222 | |
@@ -2282,7 +2287,7 @@ discard block |
||
2282 | 2287 | */ |
2283 | 2288 | do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id ); |
2284 | 2289 | return $new_id; |
2285 | - }else{ |
|
2290 | + } else{ |
|
2286 | 2291 | return FALSE; |
2287 | 2292 | } |
2288 | 2293 | } |
@@ -2323,9 +2328,9 @@ discard block |
||
2323 | 2328 | public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){ |
2324 | 2329 | if($obj_or_fields_array instanceof EE_Base_Class){ |
2325 | 2330 | $fields_n_values = $obj_or_fields_array->model_field_array(); |
2326 | - }elseif( is_array($obj_or_fields_array)){ |
|
2331 | + } elseif( is_array($obj_or_fields_array)){ |
|
2327 | 2332 | $fields_n_values = $obj_or_fields_array; |
2328 | - }else{ |
|
2333 | + } else{ |
|
2329 | 2334 | throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array)); |
2330 | 2335 | } |
2331 | 2336 | $query_params = array( 'default_where_conditions' => 'minimum' ); |
@@ -2341,7 +2346,7 @@ discard block |
||
2341 | 2346 | //if there is nothing to base this search on, then we shouldn't find anything |
2342 | 2347 | if( ! isset( $query_params[0] ) || ( isset( $query_params[0] ) && empty( $query_params[0] ) ) ) { |
2343 | 2348 | return array(); |
2344 | - }else{ |
|
2349 | + } else{ |
|
2345 | 2350 | return $this->get_one($query_params); |
2346 | 2351 | } |
2347 | 2352 | } |
@@ -2414,12 +2419,12 @@ discard block |
||
2414 | 2419 | if($this->has_primary_key_field()){ |
2415 | 2420 | if($this->get_primary_key_field()->is_auto_increment()){ |
2416 | 2421 | return $wpdb->insert_id; |
2417 | - }else{ |
|
2422 | + } else{ |
|
2418 | 2423 | //it's not an auto-increment primary key, so |
2419 | 2424 | //it must have been supplied |
2420 | 2425 | return $fields_n_values[$this->get_primary_key_field()->get_name()]; |
2421 | 2426 | } |
2422 | - }else{ |
|
2427 | + } else{ |
|
2423 | 2428 | //we can't return a primary key because there is none. instead return |
2424 | 2429 | //a unique string indicating this model |
2425 | 2430 | return $this->get_index_primary_key_string($fields_n_values); |
@@ -2467,7 +2472,7 @@ discard block |
||
2467 | 2472 | //leave the value alone |
2468 | 2473 | } |
2469 | 2474 | return $value; |
2470 | - }else{ |
|
2475 | + } else{ |
|
2471 | 2476 | return $value; |
2472 | 2477 | } |
2473 | 2478 | } |
@@ -2560,7 +2565,7 @@ discard block |
||
2560 | 2565 | if(array_key_exists('group_by', $query_params)){ |
2561 | 2566 | if(is_array($query_params['group_by'])){ |
2562 | 2567 | $this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by'); |
2563 | - }elseif( ! empty ( $query_params['group_by'] )){ |
|
2568 | + } elseif( ! empty ( $query_params['group_by'] )){ |
|
2564 | 2569 | $this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by'); |
2565 | 2570 | } |
2566 | 2571 | } |
@@ -2568,10 +2573,11 @@ discard block |
||
2568 | 2573 | $this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having'); |
2569 | 2574 | } |
2570 | 2575 | if(array_key_exists('order_by', $query_params)){ |
2571 | - if ( is_array( $query_params['order_by'] ) ) |
|
2572 | - $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by'); |
|
2573 | - elseif( ! empty( $query_params['order_by'] )) |
|
2574 | - $this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by'); |
|
2576 | + if ( is_array( $query_params['order_by'] ) ) { |
|
2577 | + $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by'); |
|
2578 | + } elseif( ! empty( $query_params['order_by'] )) { |
|
2579 | + $this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by'); |
|
2580 | + } |
|
2575 | 2581 | } |
2576 | 2582 | if(array_key_exists('force_join', $query_params)){ |
2577 | 2583 | $this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join'); |
@@ -2603,10 +2609,10 @@ discard block |
||
2603 | 2609 | if (! is_array($possibly_array_of_params)){ |
2604 | 2610 | throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"), |
2605 | 2611 | $param,$possibly_array_of_params)); |
2606 | - }else{ |
|
2612 | + } else{ |
|
2607 | 2613 | $this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type); |
2608 | 2614 | } |
2609 | - }elseif($query_param_type === 0 //ie WHERE |
|
2615 | + } elseif($query_param_type === 0 //ie WHERE |
|
2610 | 2616 | && is_array($possibly_array_of_params) |
2611 | 2617 | && isset($possibly_array_of_params[2]) |
2612 | 2618 | && $possibly_array_of_params[2] == true){ |
@@ -2666,7 +2672,7 @@ discard block |
||
2666 | 2672 | } |
2667 | 2673 | if( isset( $query_params[0] ) ) { |
2668 | 2674 | $where_query_params = $query_params[0]; |
2669 | - }else{ |
|
2675 | + } else{ |
|
2670 | 2676 | $where_query_params = array(); |
2671 | 2677 | } |
2672 | 2678 | //first check if we should alter the query to account for caps or not |
@@ -2684,7 +2690,7 @@ discard block |
||
2684 | 2690 | } |
2685 | 2691 | if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){ |
2686 | 2692 | $use_default_where_conditions = $query_params['default_where_conditions']; |
2687 | - }else{ |
|
2693 | + } else{ |
|
2688 | 2694 | $use_default_where_conditions = 'all'; |
2689 | 2695 | } |
2690 | 2696 | $where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params ); |
@@ -2707,7 +2713,7 @@ discard block |
||
2707 | 2713 | } |
2708 | 2714 | //they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25 |
2709 | 2715 | $query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]); |
2710 | - }elseif( ! empty ( $query_params['limit'] )){ |
|
2716 | + } elseif( ! empty ( $query_params['limit'] )){ |
|
2711 | 2717 | $query_object->set_limit_sql((" LIMIT ".$query_params['limit'])); |
2712 | 2718 | } |
2713 | 2719 | } |
@@ -2729,11 +2735,11 @@ discard block |
||
2729 | 2735 | $order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order; |
2730 | 2736 | } |
2731 | 2737 | $query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array)); |
2732 | - }elseif( ! empty ( $query_params['order_by'] )){ |
|
2738 | + } elseif( ! empty ( $query_params['order_by'] )){ |
|
2733 | 2739 | $this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']); |
2734 | 2740 | if(isset($query_params['order'])){ |
2735 | 2741 | $order = $this->_extract_order($query_params['order']); |
2736 | - }else{ |
|
2742 | + } else{ |
|
2737 | 2743 | $order = 'DESC'; |
2738 | 2744 | } |
2739 | 2745 | $query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order); |
@@ -2756,7 +2762,7 @@ discard block |
||
2756 | 2762 | $group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by); |
2757 | 2763 | } |
2758 | 2764 | $query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array)); |
2759 | - }elseif( ! empty ( $query_params['group_by'] )){ |
|
2765 | + } elseif( ! empty ( $query_params['group_by'] )){ |
|
2760 | 2766 | $query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by'])); |
2761 | 2767 | } |
2762 | 2768 | } |
@@ -2780,8 +2786,9 @@ discard block |
||
2780 | 2786 | } |
2781 | 2787 | } |
2782 | 2788 | $main_model_join_sql = $query_object->get_main_model_join_sql(); |
2783 | - if ( empty( $main_model_join_sql ) ) |
|
2784 | - $query_object->set_main_model_join_sql($this->_construct_internal_join()); |
|
2789 | + if ( empty( $main_model_join_sql ) ) { |
|
2790 | + $query_object->set_main_model_join_sql($this->_construct_internal_join()); |
|
2791 | + } |
|
2785 | 2792 | return $query_object; |
2786 | 2793 | } |
2787 | 2794 | |
@@ -2814,7 +2821,7 @@ discard block |
||
2814 | 2821 | private function _extract_order($should_be_order_string){ |
2815 | 2822 | if(in_array($should_be_order_string, $this->_allowed_order_values)){ |
2816 | 2823 | return $should_be_order_string; |
2817 | - }else{ |
|
2824 | + } else{ |
|
2818 | 2825 | throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string)); |
2819 | 2826 | } |
2820 | 2827 | } |
@@ -2846,9 +2853,9 @@ discard block |
||
2846 | 2853 | } |
2847 | 2854 | if( in_array($use_default_where_conditions, array('all','this_model_only')) ){ |
2848 | 2855 | $universal_query_params = $this->_get_default_where_conditions(); |
2849 | - }elseif( $use_default_where_conditions == 'minimum' ) { |
|
2856 | + } elseif( $use_default_where_conditions == 'minimum' ) { |
|
2850 | 2857 | $universal_query_params = $this->_get_minimum_where_conditions(); |
2851 | - }else{ |
|
2858 | + } else{ |
|
2852 | 2859 | $universal_query_params = array(); |
2853 | 2860 | } |
2854 | 2861 | |
@@ -2857,7 +2864,7 @@ discard block |
||
2857 | 2864 | $related_model = $this->get_related_model_obj($model_name); |
2858 | 2865 | if( $use_default_where_conditions == 'minimum' ) { |
2859 | 2866 | $related_model_universal_where_params = $related_model->_get_minimum_where_conditions($model_relation_path); |
2860 | - }else{ |
|
2867 | + } else{ |
|
2861 | 2868 | $related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path); |
2862 | 2869 | } |
2863 | 2870 | |
@@ -2892,14 +2899,14 @@ discard block |
||
2892 | 2899 | foreach($default_where_conditions as $key => $val){ |
2893 | 2900 | if( isset($provided_where_conditions[$key])){ |
2894 | 2901 | $none_overridden = false; |
2895 | - }else{ |
|
2902 | + } else{ |
|
2896 | 2903 | $null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val; |
2897 | 2904 | } |
2898 | 2905 | } |
2899 | 2906 | if( $none_overridden && $default_where_conditions){ |
2900 | 2907 | if($model->has_primary_key_field()){ |
2901 | 2908 | $null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL'); |
2902 | - }else{ |
|
2909 | + } else{ |
|
2903 | 2910 | //@todo NO PK, use other defaults |
2904 | 2911 | } |
2905 | 2912 | } |
@@ -2915,8 +2922,9 @@ discard block |
||
2915 | 2922 | * @return array like EEM_Base::get_all's $query_params[0] (where conditions) |
2916 | 2923 | */ |
2917 | 2924 | protected function _get_default_where_conditions($model_relation_path = null){ |
2918 | - if ( $this->_ignore_where_strategy ) |
|
2919 | - return array(); |
|
2925 | + if ( $this->_ignore_where_strategy ) { |
|
2926 | + return array(); |
|
2927 | + } |
|
2920 | 2928 | |
2921 | 2929 | return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path); |
2922 | 2930 | } |
@@ -2931,8 +2939,9 @@ discard block |
||
2931 | 2939 | * @return array like EEM_Base::get_all's $query_params[0] (where conditions) |
2932 | 2940 | */ |
2933 | 2941 | protected function _get_minimum_where_conditions($model_relation_path = null){ |
2934 | - if ( $this->_ignore_where_strategy ) |
|
2935 | - return array(); |
|
2942 | + if ( $this->_ignore_where_strategy ) { |
|
2943 | + return array(); |
|
2944 | + } |
|
2936 | 2945 | |
2937 | 2946 | return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path); |
2938 | 2947 | } |
@@ -3006,7 +3015,7 @@ discard block |
||
3006 | 3015 | if(array_key_exists($query_param,$this_model_fields)){ |
3007 | 3016 | if($allow_fields){ |
3008 | 3017 | return; |
3009 | - }else{ |
|
3018 | + } else{ |
|
3010 | 3019 | throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"), |
3011 | 3020 | $query_param,get_class($this),$query_param_type,$original_query_param)); |
3012 | 3021 | } |
@@ -3015,7 +3024,7 @@ discard block |
||
3015 | 3024 | elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){ |
3016 | 3025 | if($allow_logic_query_params){ |
3017 | 3026 | return; |
3018 | - }else{ |
|
3027 | + } else{ |
|
3019 | 3028 | throw new EE_Error( |
3020 | 3029 | sprintf( |
3021 | 3030 | __( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ), |
@@ -3046,12 +3055,12 @@ discard block |
||
3046 | 3055 | //we should actually end in a field name, not a model like this! |
3047 | 3056 | throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"), |
3048 | 3057 | $query_param,$query_param_type,get_class($this),$valid_related_model_name)); |
3049 | - }else{ |
|
3058 | + } else{ |
|
3050 | 3059 | $related_model_obj = $this->get_related_model_obj($valid_related_model_name); |
3051 | 3060 | $related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param); |
3052 | 3061 | return; |
3053 | 3062 | } |
3054 | - }elseif($query_param == $valid_related_model_name){ |
|
3063 | + } elseif($query_param == $valid_related_model_name){ |
|
3055 | 3064 | $this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param); |
3056 | 3065 | return; |
3057 | 3066 | } |
@@ -3111,7 +3120,7 @@ discard block |
||
3111 | 3120 | $SQL = $this->_construct_condition_clause_recursive($where_params, ' AND '); |
3112 | 3121 | if($SQL){ |
3113 | 3122 | return " WHERE ". $SQL; |
3114 | - }else{ |
|
3123 | + } else{ |
|
3115 | 3124 | return ''; |
3116 | 3125 | } |
3117 | 3126 | } |
@@ -3126,7 +3135,7 @@ discard block |
||
3126 | 3135 | $SQL = $this->_construct_condition_clause_recursive($having_params, ' AND '); |
3127 | 3136 | if($SQL){ |
3128 | 3137 | return " HAVING ". $SQL; |
3129 | - }else{ |
|
3138 | + } else{ |
|
3130 | 3139 | return ''; |
3131 | 3140 | } |
3132 | 3141 | |
@@ -3149,7 +3158,7 @@ discard block |
||
3149 | 3158 | $model_instance=call_user_func($model_name."::instance"); |
3150 | 3159 | /* @var $model_instance EEM_Base */ |
3151 | 3160 | return $model_instance->field_settings_for($field_name); |
3152 | - }else{ |
|
3161 | + } else{ |
|
3153 | 3162 | throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath)); |
3154 | 3163 | } |
3155 | 3164 | } |
@@ -3182,14 +3191,14 @@ discard block |
||
3182 | 3191 | $where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")"; |
3183 | 3192 | break; |
3184 | 3193 | } |
3185 | - }else{ |
|
3194 | + } else{ |
|
3186 | 3195 | $field_obj = $this->_deduce_field_from_query_param($query_param); |
3187 | 3196 | |
3188 | 3197 | //if it's not a normal field, maybe it's a custom selection? |
3189 | 3198 | if( ! $field_obj){ |
3190 | 3199 | if(isset( $this->_custom_selections[$query_param][1])){ |
3191 | 3200 | $field_obj = $this->_custom_selections[$query_param][1]; |
3192 | - }else{ |
|
3201 | + } else{ |
|
3193 | 3202 | throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param)); |
3194 | 3203 | } |
3195 | 3204 | } |
@@ -3199,7 +3208,7 @@ discard block |
||
3199 | 3208 | } |
3200 | 3209 | if($where_clauses){ |
3201 | 3210 | $SQL = implode($glue,$where_clauses); |
3202 | - }else{ |
|
3211 | + } else{ |
|
3203 | 3212 | $SQL = ''; |
3204 | 3213 | } |
3205 | 3214 | return $SQL; |
@@ -3219,11 +3228,11 @@ discard block |
||
3219 | 3228 | if( $field ){ |
3220 | 3229 | $table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param ); |
3221 | 3230 | return $table_alias_prefix . $field->get_qualified_column(); |
3222 | - }elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
3231 | + } elseif(array_key_exists($query_param,$this->_custom_selections)){ |
|
3223 | 3232 | //maybe it's custom selection item? |
3224 | 3233 | //if so, just use it as the "column name" |
3225 | 3234 | return $query_param; |
3226 | - }else{ |
|
3235 | + } else{ |
|
3227 | 3236 | throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections))); |
3228 | 3237 | } |
3229 | 3238 | } |
@@ -3240,7 +3249,7 @@ discard block |
||
3240 | 3249 | $pos_of_star = strpos($condition_query_param_key, '*'); |
3241 | 3250 | if($pos_of_star === FALSE){ |
3242 | 3251 | return $condition_query_param_key; |
3243 | - }else{ |
|
3252 | + } else{ |
|
3244 | 3253 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
3245 | 3254 | return $condition_query_param_sans_star; |
3246 | 3255 | } |
@@ -3266,7 +3275,7 @@ discard block |
||
3266 | 3275 | throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string))); |
3267 | 3276 | } |
3268 | 3277 | $value = isset($op_and_value[1]) ? $op_and_value[1] : null; |
3269 | - }else{ |
|
3278 | + } else{ |
|
3270 | 3279 | $operator = '='; |
3271 | 3280 | $value = $op_and_value; |
3272 | 3281 | } |
@@ -3274,7 +3283,7 @@ discard block |
||
3274 | 3283 | //check to see if the value is actually another field |
3275 | 3284 | if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){ |
3276 | 3285 | return $operator.SP.$this->_deduce_column_name_from_query_param($value); |
3277 | - }elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){ |
|
3286 | + } elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){ |
|
3278 | 3287 | //in this case, the value should be an array, or at least a comma-separated list |
3279 | 3288 | //it will need to handle a little differently |
3280 | 3289 | $cleaned_value = $this->_construct_in_value($value, $field_obj); |
@@ -3282,8 +3291,9 @@ discard block |
||
3282 | 3291 | return $operator.SP.$cleaned_value; |
3283 | 3292 | } elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) { |
3284 | 3293 | //the value should be an array with count of two. |
3285 | - if ( count($value) !== 2 ) |
|
3286 | - throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) ); |
|
3294 | + if ( count($value) !== 2 ) { |
|
3295 | + throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) ); |
|
3296 | + } |
|
3287 | 3297 | $cleaned_value = $this->_construct_between_value( $value, $field_obj ); |
3288 | 3298 | return $operator.SP.$cleaned_value; |
3289 | 3299 | } elseif( in_array( $operator, $this->_null_style_operators ) ) { |
@@ -3291,17 +3301,17 @@ discard block |
||
3291 | 3301 | throw new EE_Error(sprintf(__("You attempted to give a value (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator)); |
3292 | 3302 | } |
3293 | 3303 | return $operator; |
3294 | - }elseif( $operator == 'LIKE' && ! is_array($value)){ |
|
3304 | + } elseif( $operator == 'LIKE' && ! is_array($value)){ |
|
3295 | 3305 | //if the operator is 'LIKE', we want to allow percent signs (%) and not |
3296 | 3306 | //remove other junk. So just treat it as a string. |
3297 | 3307 | return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s'); |
3298 | - }elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){ |
|
3308 | + } elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){ |
|
3299 | 3309 | return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj); |
3300 | - }elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){ |
|
3310 | + } elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){ |
|
3301 | 3311 | throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator)); |
3302 | - }elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){ |
|
3312 | + } elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){ |
|
3303 | 3313 | throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator)); |
3304 | - }else{ |
|
3314 | + } else{ |
|
3305 | 3315 | throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"), http_build_query($op_and_value))); |
3306 | 3316 | } |
3307 | 3317 | } |
@@ -3371,7 +3381,7 @@ discard block |
||
3371 | 3381 | global $wpdb; |
3372 | 3382 | if($field_obj instanceof EE_Model_Field_Base){ |
3373 | 3383 | return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj)); |
3374 | - }else{//$field_obj should really just be a data type |
|
3384 | + } else{//$field_obj should really just be a data type |
|
3375 | 3385 | if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){ |
3376 | 3386 | throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types))); |
3377 | 3387 | } |
@@ -3400,14 +3410,14 @@ discard block |
||
3400 | 3410 | if($number_of_parts == 1){ |
3401 | 3411 | $field_name = $last_query_param_part; |
3402 | 3412 | $model_obj = $this; |
3403 | - }else{// $number_of_parts >= 2 |
|
3413 | + } else{// $number_of_parts >= 2 |
|
3404 | 3414 | //the last part is the column name, and there are only 2parts. therefore... |
3405 | 3415 | $field_name = $last_query_param_part; |
3406 | 3416 | $model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]); |
3407 | 3417 | } |
3408 | 3418 | try{ |
3409 | 3419 | return $model_obj->field_settings_for($field_name); |
3410 | - }catch(EE_Error $e){ |
|
3420 | + } catch(EE_Error $e){ |
|
3411 | 3421 | return null; |
3412 | 3422 | } |
3413 | 3423 | } |
@@ -3426,7 +3436,7 @@ discard block |
||
3426 | 3436 | $field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE; |
3427 | 3437 | if($field){ |
3428 | 3438 | return $field->get_qualified_column(); |
3429 | - }else{ |
|
3439 | + } else{ |
|
3430 | 3440 | throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this))); |
3431 | 3441 | } |
3432 | 3442 | } |
@@ -3492,7 +3502,7 @@ discard block |
||
3492 | 3502 | //the FROM statement, BUT the primary table isn't. So we want |
3493 | 3503 | //to add the inverse join sql |
3494 | 3504 | $SQL .= $table_obj->get_inverse_join_sql($alias_prefixed); |
3495 | - }else{ |
|
3505 | + } else{ |
|
3496 | 3506 | //just add a regular JOIN to this table from the primary table |
3497 | 3507 | $SQL .= $table_obj->get_join_sql($alias_prefixed); |
3498 | 3508 | } |
@@ -3607,7 +3617,7 @@ discard block |
||
3607 | 3617 | $fieldSettings = $this->field_settings(true); |
3608 | 3618 | if( isset($fieldSettings[$fieldName])){ |
3609 | 3619 | return true; |
3610 | - }else{ |
|
3620 | + } else{ |
|
3611 | 3621 | return false; |
3612 | 3622 | } |
3613 | 3623 | } |
@@ -3621,7 +3631,7 @@ discard block |
||
3621 | 3631 | $relations = $this->relation_settings(); |
3622 | 3632 | if(isset($relations[$relation_name])){ |
3623 | 3633 | return true; |
3624 | - }else{ |
|
3634 | + } else{ |
|
3625 | 3635 | return false; |
3626 | 3636 | } |
3627 | 3637 | } |
@@ -3672,7 +3682,7 @@ discard block |
||
3672 | 3682 | try{ |
3673 | 3683 | $this->get_primary_key_field(); |
3674 | 3684 | $this->_has_primary_key_field = true; |
3675 | - }catch(EE_Error $e){ |
|
3685 | + } catch(EE_Error $e){ |
|
3676 | 3686 | $this->_has_primary_key_field = false; |
3677 | 3687 | } |
3678 | 3688 | } |
@@ -3751,7 +3761,7 @@ discard block |
||
3751 | 3761 | } |
3752 | 3762 | } |
3753 | 3763 | return $this->_cached_fields; |
3754 | - }else{ |
|
3764 | + } else{ |
|
3755 | 3765 | if( $this->_cached_fields_non_db_only === NULL ){ |
3756 | 3766 | $this->_cached_fields_non_db_only = array(); |
3757 | 3767 | foreach($this->_fields as $fields_corresponding_to_table){ |
@@ -3894,7 +3904,7 @@ discard block |
||
3894 | 3904 | if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){ |
3895 | 3905 | return NULL; |
3896 | 3906 | } |
3897 | - }else if($this->unique_indexes()){ |
|
3907 | + } else if($this->unique_indexes()){ |
|
3898 | 3908 | $first_column = reset($this_model_fields_n_values); |
3899 | 3909 | if(empty($first_column)){ |
3900 | 3910 | return NULL; |
@@ -3909,7 +3919,7 @@ discard block |
||
3909 | 3919 | // add this new object to the entity map |
3910 | 3920 | $classInstance = $this->add_to_entity_map( $classInstance ); |
3911 | 3921 | } |
3912 | - }else{ |
|
3922 | + } else{ |
|
3913 | 3923 | $classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE ); |
3914 | 3924 | } |
3915 | 3925 | |
@@ -3996,11 +4006,12 @@ discard block |
||
3996 | 4006 | $this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value ); |
3997 | 4007 | } |
3998 | 4008 | } |
3999 | - }else{ |
|
4009 | + } else{ |
|
4000 | 4010 | //the table's rows existed. Use their values |
4001 | 4011 | foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) { |
4002 | - if( ! $field_obj->is_db_only_field() ) |
|
4003 | - $this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() ); |
|
4012 | + if( ! $field_obj->is_db_only_field() ) { |
|
4013 | + $this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() ); |
|
4014 | + } |
|
4004 | 4015 | } |
4005 | 4016 | } |
4006 | 4017 | } |
@@ -4014,9 +4025,9 @@ discard block |
||
4014 | 4025 | if( isset( $cols_n_values[ $qualified_column ] ) ){ |
4015 | 4026 | $value = $cols_n_values[ $qualified_column ]; |
4016 | 4027 | |
4017 | - }elseif( isset( $cols_n_values[ $regular_column ] ) ){ |
|
4028 | + } elseif( isset( $cols_n_values[ $regular_column ] ) ){ |
|
4018 | 4029 | $value = $cols_n_values[ $regular_column ]; |
4019 | - }else{ |
|
4030 | + } else{ |
|
4020 | 4031 | $value = NULL; |
4021 | 4032 | } |
4022 | 4033 | |
@@ -4049,7 +4060,7 @@ discard block |
||
4049 | 4060 | } |
4050 | 4061 | } |
4051 | 4062 | return $obj_in_map; |
4052 | - }else{ |
|
4063 | + } else{ |
|
4053 | 4064 | return $this->get_one_by_ID( $id ); |
4054 | 4065 | } |
4055 | 4066 | } |
@@ -4084,7 +4095,7 @@ discard block |
||
4084 | 4095 | } |
4085 | 4096 | } |
4086 | 4097 | return $obj_in_map; |
4087 | - }else{ |
|
4098 | + } else{ |
|
4088 | 4099 | $this->add_to_entity_map( $replacing_model_obj ); |
4089 | 4100 | return $replacing_model_obj; |
4090 | 4101 | } |
@@ -4114,7 +4125,7 @@ discard block |
||
4114 | 4125 | public function item_name($quantity = 1){ |
4115 | 4126 | if($quantity == 1){ |
4116 | 4127 | return $this->singular_item; |
4117 | - }else{ |
|
4128 | + } else{ |
|
4118 | 4129 | return $this->plural_item; |
4119 | 4130 | } |
4120 | 4131 | } |
@@ -4176,14 +4187,14 @@ discard block |
||
4176 | 4187 | $primary_key_field = $this->get_primary_key_field(); |
4177 | 4188 | if( $base_class_obj_or_id instanceof $className ){ |
4178 | 4189 | $model_object = $base_class_obj_or_id; |
4179 | - }elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && ( |
|
4190 | + } elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && ( |
|
4180 | 4191 | is_int( $base_class_obj_or_id ) || |
4181 | 4192 | is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101) |
4182 | 4193 | $model_object = $this->get_one_by_ID($base_class_obj_or_id); |
4183 | - }elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){ |
|
4194 | + } elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){ |
|
4184 | 4195 | //assume its a string representation of the object |
4185 | 4196 | $model_object = $this->get_one_by_ID($base_class_obj_or_id); |
4186 | - }else{ |
|
4197 | + } else{ |
|
4187 | 4198 | throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true))); |
4188 | 4199 | } |
4189 | 4200 | if( $model_object->ID() == NULL && $ensure_is_in_db){ |
@@ -4207,13 +4218,13 @@ discard block |
||
4207 | 4218 | if( $base_class_obj_or_id instanceof $className ){ |
4208 | 4219 | /** @var $base_class_obj_or_id EE_Base_Class */ |
4209 | 4220 | $id = $base_class_obj_or_id->ID(); |
4210 | - }elseif(is_int($base_class_obj_or_id)){ |
|
4221 | + } elseif(is_int($base_class_obj_or_id)){ |
|
4211 | 4222 | //assume it's an ID |
4212 | 4223 | $id = $base_class_obj_or_id; |
4213 | - }elseif(is_string($base_class_obj_or_id)){ |
|
4224 | + } elseif(is_string($base_class_obj_or_id)){ |
|
4214 | 4225 | //assume its a string representation of the object |
4215 | 4226 | $id = $base_class_obj_or_id; |
4216 | - }else{ |
|
4227 | + } else{ |
|
4217 | 4228 | throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true))); |
4218 | 4229 | } |
4219 | 4230 | return $id; |
@@ -4344,9 +4355,9 @@ discard block |
||
4344 | 4355 | |
4345 | 4356 | if($model_object_or_attributes_array instanceof EE_Base_Class){ |
4346 | 4357 | $attributes_array = $model_object_or_attributes_array->model_field_array(); |
4347 | - }elseif(is_array($model_object_or_attributes_array)){ |
|
4358 | + } elseif(is_array($model_object_or_attributes_array)){ |
|
4348 | 4359 | $attributes_array = $model_object_or_attributes_array; |
4349 | - }else{ |
|
4360 | + } else{ |
|
4350 | 4361 | throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array)); |
4351 | 4362 | } |
4352 | 4363 | //even copies obviously won't have the same ID, so remove the primary key |
@@ -4356,7 +4367,7 @@ discard block |
||
4356 | 4367 | } |
4357 | 4368 | if(isset($query_params[0])){ |
4358 | 4369 | $query_params[0] = array_merge($attributes_array,$query_params); |
4359 | - }else{ |
|
4370 | + } else{ |
|
4360 | 4371 | $query_params[0] = $attributes_array; |
4361 | 4372 | } |
4362 | 4373 | return $this->get_all($query_params); |
@@ -4379,7 +4390,7 @@ discard block |
||
4379 | 4390 | $copies = $this->get_all_copies($model_object_or_attributes_array,$query_params); |
4380 | 4391 | if(is_array($copies)){ |
4381 | 4392 | return array_shift($copies); |
4382 | - }else{ |
|
4393 | + } else{ |
|
4383 | 4394 | return null; |
4384 | 4395 | } |
4385 | 4396 | } |
@@ -4411,7 +4422,7 @@ discard block |
||
4411 | 4422 | $sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null; |
4412 | 4423 | if($sql_operator){ |
4413 | 4424 | return $sql_operator; |
4414 | - }else{ |
|
4425 | + } else{ |
|
4415 | 4426 | throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators)))); |
4416 | 4427 | } |
4417 | 4428 | } |
@@ -4582,7 +4593,7 @@ discard block |
||
4582 | 4593 | $valid_cap_contexts = EEM_Base::valid_cap_contexts(); |
4583 | 4594 | if( in_array( $context, $valid_cap_contexts ) ) { |
4584 | 4595 | return true; |
4585 | - }else{ |
|
4596 | + } else{ |
|
4586 | 4597 | throw new EE_Error( |
4587 | 4598 | sprintf( |
4588 | 4599 | __( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ), |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <div id="admin-primary-mbox-dv" class="admin-primary-mbox-dv"> |
2 | 2 | |
3 | 3 | <h3 class="admin-primary-mbox-h4 hdr-has-icon"> |
4 | - <span class="dashicons dashicons-cart"></span><?php _e( 'Transaction Items', 'event_espresso' );?> |
|
4 | + <span class="dashicons dashicons-cart"></span><?php _e('Transaction Items', 'event_espresso'); ?> |
|
5 | 5 | </h3> |
6 | 6 | |
7 | 7 | <div class="admin-primary-mbox-tbl-wrap"> |
@@ -10,27 +10,27 @@ discard block |
||
10 | 10 | </div> |
11 | 11 | |
12 | 12 | <a id="display-additional-transaction-session-info" class="display-the-hidden smaller-text" rel="additional-transaction-session-info"> |
13 | - <span class="dashicons dashicons-plus-alt"></span><?php _e( 'view additional transaction session details', 'event_espresso' );?> |
|
13 | + <span class="dashicons dashicons-plus-alt"></span><?php _e('view additional transaction session details', 'event_espresso'); ?> |
|
14 | 14 | </a> |
15 | 15 | |
16 | 16 | <div id="additional-transaction-session-info-dv" class="hidden"> |
17 | 17 | |
18 | 18 | <a id="hide-additional-transaction-session-info" class="hide-the-displayed hidden smaller-text" rel="additional-transaction-session-info"> |
19 | - <span class="dashicons dashicons-dismiss"></span><?php _e( 'hide additional transaction session details', 'event_espresso' );?> |
|
19 | + <span class="dashicons dashicons-dismiss"></span><?php _e('hide additional transaction session details', 'event_espresso'); ?> |
|
20 | 20 | </a> |
21 | 21 | <br class="clear"/> |
22 | 22 | |
23 | - <h3 class="admin-primary-mbox-h4"><?php _e( 'Transaction Session Details', 'event_espresso' );?></h3> |
|
23 | + <h3 class="admin-primary-mbox-h4"><?php _e('Transaction Session Details', 'event_espresso'); ?></h3> |
|
24 | 24 | |
25 | 25 | <table id="admin-primary-mbox-txn-extra-session-info-tbl" class="form-table skinny-rows"> |
26 | 26 | <tbody> |
27 | - <?php foreach ( $txn_details as $key => $txn_detail ) : ?> |
|
27 | + <?php foreach ($txn_details as $key => $txn_detail) : ?> |
|
28 | 28 | <tr> |
29 | 29 | <th> |
30 | - <label for="<?php echo $key;?>"><?php echo $txn_detail['label'];?></label> |
|
30 | + <label for="<?php echo $key; ?>"><?php echo $txn_detail['label']; ?></label> |
|
31 | 31 | </th> |
32 | 32 | <td> |
33 | - <?php echo $txn_detail['value'];?> |
|
33 | + <?php echo $txn_detail['value']; ?> |
|
34 | 34 | </td> |
35 | 35 | </tr> |
36 | 36 | <?php endforeach; // $txn_details?> |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | <br class="clear"/> |
41 | 41 | |
42 | 42 | |
43 | - <?php if ( $attendee instanceof EE_Attendee && ( $grand_raw_total > 0 || $TXN_status != 'TCM' || ! empty( $payments ) ) ) : ?> |
|
43 | + <?php if ($attendee instanceof EE_Attendee && ($grand_raw_total > 0 || $TXN_status != 'TCM' || ! empty($payments))) : ?> |
|
44 | 44 | |
45 | 45 | <h3 class="admin-primary-mbox-h4 hdr-has-icon"> |
46 | - <span class="ee-icon ee-icon-cash"></span><?php _e( 'Payment Details', 'event_espresso' );?> |
|
46 | + <span class="ee-icon ee-icon-cash"></span><?php _e('Payment Details', 'event_espresso'); ?> |
|
47 | 47 | </h3> |
48 | 48 | |
49 | 49 | <div class="admin-primary-mbox-tbl-wrap"> |
@@ -52,75 +52,75 @@ discard block |
||
52 | 52 | <tr> |
53 | 53 | <th></th> |
54 | 54 | <th class="jst-cntr"></th> |
55 | - <th class="jst-cntr"><?php _e( 'ID', 'event_espresso' );?></th> |
|
56 | - <th class="jst-left"><?php _e( 'Date', 'event_espresso' );?></th> |
|
57 | - <th class="jst-cntr"><?php _e( 'Source', 'event_espresso' );?></th> |
|
58 | - <th class="jst-left"><?php _e( 'Method', 'event_espresso' );?></th> |
|
59 | - <th class="jst-left"><?php _e( 'Gateway Response', 'event_espresso' );?></th> |
|
60 | - <th class="jst-left"><?php _e( 'TXN ID / CHQ #', 'event_espresso' );?></th> |
|
61 | - <th class="jst-left"><?php _e( 'P.O. / S.O. #', 'event_espresso' );?></th> |
|
62 | - <th class="jst-left"><?php _e( 'Notes / Extra Accounting', 'event_espresso' );?></th> |
|
63 | - <!--<th class="jst-left"><?php _e( 'Details', 'event_espresso' );?></th>--> |
|
64 | - <th class="jst-cntr"><?php _e( 'Amount', 'event_espresso' );?></th> |
|
55 | + <th class="jst-cntr"><?php _e('ID', 'event_espresso'); ?></th> |
|
56 | + <th class="jst-left"><?php _e('Date', 'event_espresso'); ?></th> |
|
57 | + <th class="jst-cntr"><?php _e('Source', 'event_espresso'); ?></th> |
|
58 | + <th class="jst-left"><?php _e('Method', 'event_espresso'); ?></th> |
|
59 | + <th class="jst-left"><?php _e('Gateway Response', 'event_espresso'); ?></th> |
|
60 | + <th class="jst-left"><?php _e('TXN ID / CHQ #', 'event_espresso'); ?></th> |
|
61 | + <th class="jst-left"><?php _e('P.O. / S.O. #', 'event_espresso'); ?></th> |
|
62 | + <th class="jst-left"><?php _e('Notes / Extra Accounting', 'event_espresso'); ?></th> |
|
63 | + <!--<th class="jst-left"><?php _e('Details', 'event_espresso'); ?></th>--> |
|
64 | + <th class="jst-cntr"><?php _e('Amount', 'event_espresso'); ?></th> |
|
65 | 65 | </tr> |
66 | 66 | </thead> |
67 | 67 | <tbody> |
68 | - <?php if ( $payments ) : ?> |
|
68 | + <?php if ($payments) : ?> |
|
69 | 69 | <?php $payment_total = 0; ?> |
70 | - <?php foreach ( $payments as $PAY_ID => $payment ) : ?> |
|
71 | - <tr id="txn-admin-payment-tr-<?php echo $PAY_ID;?>"> |
|
70 | + <?php foreach ($payments as $PAY_ID => $payment) : ?> |
|
71 | + <tr id="txn-admin-payment-tr-<?php echo $PAY_ID; ?>"> |
|
72 | 72 | <td> |
73 | 73 | <span id="payment-status-<?php echo $PAY_ID; ?>" class="ee-status-strip-td ee-status-strip pymt-status-<?php echo $payment->STS_ID(); ?>"></span> |
74 | - <div id="payment-STS_ID-<?php echo $PAY_ID;?>" class="hidden"><?php echo $payment->STS_ID();?></div> |
|
75 | - <div id="reg-payments-<?php echo $PAY_ID;?>" class="hidden"><?php echo json_encode( $existing_reg_payments[ $PAY_ID ] );?></div> |
|
74 | + <div id="payment-STS_ID-<?php echo $PAY_ID; ?>" class="hidden"><?php echo $payment->STS_ID(); ?></div> |
|
75 | + <div id="reg-payments-<?php echo $PAY_ID; ?>" class="hidden"><?php echo json_encode($existing_reg_payments[$PAY_ID]); ?></div> |
|
76 | 76 | </td> |
77 | 77 | <td class=" jst-cntr"> |
78 | 78 | <ul class="txn-overview-actions-ul"> |
79 | 79 | <li> |
80 | - <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e( 'Edit Payment', 'event_espresso' );?>" data-payment-id="<?php echo $PAY_ID;?>"> |
|
80 | + <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e('Edit Payment', 'event_espresso'); ?>" data-payment-id="<?php echo $PAY_ID; ?>"> |
|
81 | 81 | <div class="dashicons dashicons-edit" style="margin: 0;"></div> |
82 | 82 | </a> |
83 | 83 | </li> |
84 | 84 | <li> |
85 | - <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e( 'Delete Payment', 'event_espresso' );?>" data-payment-id="<?php echo $PAY_ID;?>"> |
|
85 | + <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e('Delete Payment', 'event_espresso'); ?>" data-payment-id="<?php echo $PAY_ID; ?>"> |
|
86 | 86 | <div class="dashicons dashicons-trash" style="margin: 0;"></div> |
87 | 87 | </a> |
88 | 88 | </li> |
89 | 89 | </ul> |
90 | 90 | </td> |
91 | 91 | <td class=" jst-rght"> |
92 | - <div id="payment-id-<?php echo $PAY_ID;?>"><?php echo $PAY_ID;?></div> |
|
92 | + <div id="payment-id-<?php echo $PAY_ID; ?>"><?php echo $PAY_ID; ?></div> |
|
93 | 93 | </td> |
94 | 94 | <td class=" jst-left"> |
95 | - <div id="payment-date-<?php echo $PAY_ID;?>" class="payment-date-dv"><?php echo $payment->timestamp('Y-m-d', 'g:i a');?></div> |
|
95 | + <div id="payment-date-<?php echo $PAY_ID; ?>" class="payment-date-dv"><?php echo $payment->timestamp('Y-m-d', 'g:i a'); ?></div> |
|
96 | 96 | </td> |
97 | 97 | <td class=" jst-cntr"> |
98 | - <div id="payment-method-<?php echo $PAY_ID;?>"> |
|
99 | - <?php echo $payment->source();?> |
|
98 | + <div id="payment-method-<?php echo $PAY_ID; ?>"> |
|
99 | + <?php echo $payment->source(); ?> |
|
100 | 100 | </div> |
101 | 101 | </td> |
102 | 102 | <td class=" jst-left"> |
103 | - <div id="payment-gateway-<?php echo $PAY_ID;?>"> |
|
104 | - <?php echo $payment->payment_method() ? $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso');?> |
|
103 | + <div id="payment-gateway-<?php echo $PAY_ID; ?>"> |
|
104 | + <?php echo $payment->payment_method() ? $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso'); ?> |
|
105 | 105 | </div> |
106 | - <div id="payment-gateway-id-<?php echo $PAY_ID;?>" class="hidden"><?php echo $payment->payment_method() ? $payment->payment_method()->ID() : 0;?></div> |
|
106 | + <div id="payment-gateway-id-<?php echo $PAY_ID; ?>" class="hidden"><?php echo $payment->payment_method() ? $payment->payment_method()->ID() : 0; ?></div> |
|
107 | 107 | </td> |
108 | 108 | <td class=" jst-left"> |
109 | - <div id="payment-response-<?php echo $PAY_ID;?>"><?php echo $payment->gateway_response();?></div> |
|
109 | + <div id="payment-response-<?php echo $PAY_ID; ?>"><?php echo $payment->gateway_response(); ?></div> |
|
110 | 110 | </td> |
111 | 111 | <td class=" jst-left"> |
112 | - <div id="payment-txn-id-chq-nmbr-<?php echo $PAY_ID;?>"><?php echo $payment->txn_id_chq_nmbr();?></div> |
|
112 | + <div id="payment-txn-id-chq-nmbr-<?php echo $PAY_ID; ?>"><?php echo $payment->txn_id_chq_nmbr(); ?></div> |
|
113 | 113 | </td> |
114 | 114 | <td class=" jst-left"> |
115 | - <div id="payment-po-nmbr-<?php echo $PAY_ID;?>"><?php echo $payment->po_number();?></div> |
|
115 | + <div id="payment-po-nmbr-<?php echo $PAY_ID; ?>"><?php echo $payment->po_number(); ?></div> |
|
116 | 116 | </td> |
117 | 117 | <td class=" jst-left"> |
118 | - <div id="payment-accntng-<?php echo $PAY_ID;?>"><?php echo $payment->extra_accntng();?></div> |
|
118 | + <div id="payment-accntng-<?php echo $PAY_ID; ?>"><?php echo $payment->extra_accntng(); ?></div> |
|
119 | 119 | </td> |
120 | 120 | <td class=" jst-rght"> |
121 | - <?php $payment_class = $payment->amount() > 0 ? 'txn-admin-payment-status-' . $payment->STS_ID() : 'txn-admin-payment-status-PDC'; ?> |
|
122 | - <span class="<?php echo $payment_class;?>"> |
|
123 | - <div id="payment-amount-<?php echo $PAY_ID;?>" style="display:inline;"><?php echo EEH_Template::format_currency($payment->amount(), FALSE, FALSE ); ?></div> |
|
121 | + <?php $payment_class = $payment->amount() > 0 ? 'txn-admin-payment-status-'.$payment->STS_ID() : 'txn-admin-payment-status-PDC'; ?> |
|
122 | + <span class="<?php echo $payment_class; ?>"> |
|
123 | + <div id="payment-amount-<?php echo $PAY_ID; ?>" style="display:inline;"><?php echo EEH_Template::format_currency($payment->amount(), FALSE, FALSE); ?></div> |
|
124 | 124 | </span> |
125 | 125 | </td> |
126 | 126 | </tr> |
@@ -130,25 +130,25 @@ discard block |
||
130 | 130 | <?php endforeach; // $payment?> |
131 | 131 | <?php |
132 | 132 | $pay_totals_class = $payment_total > $grand_raw_total ? ' important-notice' : ''; |
133 | - $overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">' . __( 'This transaction has been overpaid ! ', 'event_espresso' ) . '</span>' : ''; |
|
133 | + $overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">'.__('This transaction has been overpaid ! ', 'event_espresso').'</span>' : ''; |
|
134 | 134 | ?> |
135 | 135 | <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr hidden"> |
136 | 136 | <td class=" jst-rght" colspan="11"> |
137 | - <span class="important-notice"><?php _e( 'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso' ); ?></span> |
|
137 | + <span class="important-notice"><?php _e('No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso'); ?></span> |
|
138 | 138 | </td> |
139 | 139 | </tr> |
140 | - <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr<?php echo $pay_totals_class;?>"> |
|
141 | - <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo $overpaid . sprintf( __( 'Payments Total %s', 'event_espresso' ), '(' . EE_Registry::instance()->CFG->currency->code . ')' );?></span></th> |
|
142 | - <th class=" jst-rght"><span id="txn-admin-payment-total"><?php echo EEH_Template::format_currency($payment_total, FALSE, FALSE);?></span></th> |
|
140 | + <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr<?php echo $pay_totals_class; ?>"> |
|
141 | + <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo $overpaid.sprintf(__('Payments Total %s', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); ?></span></th> |
|
142 | + <th class=" jst-rght"><span id="txn-admin-payment-total"><?php echo EEH_Template::format_currency($payment_total, FALSE, FALSE); ?></span></th> |
|
143 | 143 | </tr> |
144 | 144 | <?php else : ?> |
145 | 145 | <tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr"> |
146 | 146 | <td class=" jst-rght" colspan="11"> |
147 | - <span class="important-notice"><?php _e( 'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso' ); ?></span> |
|
147 | + <span class="important-notice"><?php _e('No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso'); ?></span> |
|
148 | 148 | </td> |
149 | 149 | </tr> |
150 | 150 | <tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr hidden"> |
151 | - <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo __( 'Payments Total', 'event_espresso' );?></span></th> |
|
151 | + <th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo __('Payments Total', 'event_espresso'); ?></span></th> |
|
152 | 152 | <th class=" jst-rght"><span id="txn-admin-payment-total"></span></th> |
153 | 153 | </tr> |
154 | 154 | <?php endif; // $payments?> |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | <td class=" jst-cntr"> |
162 | 162 | <ul class="txn-overview-actions-ul"> |
163 | 163 | <li> |
164 | - <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e( 'Edit Payment', 'event_espresso' );?>" data-payment-id="PAY_ID"> |
|
164 | + <a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e('Edit Payment', 'event_espresso'); ?>" data-payment-id="PAY_ID"> |
|
165 | 165 | <div class="dashicons dashicons-edit" style="margin: 0;"></div> |
166 | 166 | </a> |
167 | 167 | </li> |
168 | 168 | <li> |
169 | - <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e( 'Delete Payment', 'event_espresso' );?>" data-payment-id="PAY_ID"> |
|
169 | + <a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e('Delete Payment', 'event_espresso'); ?>" data-payment-id="PAY_ID"> |
|
170 | 170 | <div class="dashicons dashicons-trash" style="margin: 0;"></div> |
171 | 171 | </a> |
172 | 172 | </li> |
@@ -213,12 +213,12 @@ discard block |
||
213 | 213 | <ul id="txn-admin-payment-options-ul"> |
214 | 214 | <li> |
215 | 215 | <a id="display-txn-admin-apply-payment" class="button-primary no-icon no-hide" rel="txn-admin-apply-payment" > <!--display-the-hidden --> |
216 | - <?php _e( 'Apply Payment', 'event_espresso' );?> |
|
216 | + <?php _e('Apply Payment', 'event_espresso'); ?> |
|
217 | 217 | </a> |
218 | 218 | </li> |
219 | 219 | <li> |
220 | 220 | <a id="display-txn-admin-apply-refund" class="button-secondary no-icon no-hide" rel="txn-admin-apply-refund" > <!--display-the-hidden --> |
221 | - <?php _e( 'Apply Refund', 'event_espresso' );?> |
|
221 | + <?php _e('Apply Refund', 'event_espresso'); ?> |
|
222 | 222 | </a> |
223 | 223 | </li> |
224 | 224 | </ul> |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | |
229 | 229 | <h2 id="admin-modal-dialog-apply-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
230 | 230 | <div class="ee-icon ee-icon-cash-add float-left"></div> |
231 | - <?php echo __( 'Apply a Payment to Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?> |
|
231 | + <?php echo __('Apply a Payment to Transaction #', 'event_espresso').$txn_nmbr['value']; ?> |
|
232 | 232 | </h2> |
233 | 233 | |
234 | 234 | <h2 id="admin-modal-dialog-edit-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
235 | 235 | <div class="ee-icon ee-icon-cash-edit float-left"></div> |
236 | 236 | <?php |
237 | 237 | echo sprintf( |
238 | - __( 'Edit Payment #%s for Transaction #%s', 'event_espresso' ), |
|
238 | + __('Edit Payment #%s for Transaction #%s', 'event_espresso'), |
|
239 | 239 | '<span></span>', |
240 | 240 | $txn_nmbr['value'] |
241 | 241 | ); |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | <div class="ee-icon ee-icon-cash-edit float-left"></div> |
247 | 247 | <?php |
248 | 248 | echo sprintf( |
249 | - __( 'Edit Refund #%s for Transaction #%s', 'event_espresso' ), |
|
249 | + __('Edit Refund #%s for Transaction #%s', 'event_espresso'), |
|
250 | 250 | '<span></span>', |
251 | 251 | $txn_nmbr['value'] |
252 | 252 | ); |
@@ -255,14 +255,14 @@ discard block |
||
255 | 255 | |
256 | 256 | <h2 id="admin-modal-dialog-apply-refund-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
257 | 257 | <div class="ee-icon ee-icon-cash-remove float-left"></div> |
258 | - <?php echo __( 'Apply a Refund to Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?> |
|
258 | + <?php echo __('Apply a Refund to Transaction #', 'event_espresso').$txn_nmbr['value']; ?> |
|
259 | 259 | </h2> |
260 | 260 | |
261 | 261 | <form name="txn-admin-apply-payment-frm" id="txn-admin-apply-payment-frm" action="<?php echo $apply_payment_form_url; ?>"> |
262 | 262 | <div class="admin-modal-dialog-wrap"> |
263 | 263 | <div class="admin-modal-dialog-inner"> |
264 | 264 | |
265 | - <input type="hidden" name="espresso_apply_payment_nonce" id="espresso_apply_payment_nonce" value="<?php echo wp_create_nonce( 'espresso_apply_payment_nonce' );?>"/> |
|
265 | + <input type="hidden" name="espresso_apply_payment_nonce" id="espresso_apply_payment_nonce" value="<?php echo wp_create_nonce('espresso_apply_payment_nonce'); ?>"/> |
|
266 | 266 | <input type="hidden" name="espresso_ajax" id="espresso-ajax" value="0"/> |
267 | 267 | <input type="hidden" name="noheader" id="txn-admin-noheader-inp" value="0"/> |
268 | 268 | <input type="hidden" name="txn_admin_payment[PAY_ID]" id="txn-admin-payment-payment-id-inp" class="txn-admin-apply-payment-inp" value="0"/> |
@@ -270,108 +270,108 @@ discard block |
||
270 | 270 | <input type="hidden" name="txn_admin_payment[type]" id="txn-admin-payment-type-inp" value="1"/> |
271 | 271 | <input type="hidden" name="txn_admin_payment[details]" id="txn-admin-payment-details-inp" value=""/> |
272 | 272 | <input type="hidden" name="txn_admin_delete_payment_form_url" id="txn-admin-delete-payment-form-url-inp" value="<?php echo $delete_payment_form_url; ?>"/> |
273 | - <input type="hidden" name="txn_admin_todays_date" id="txn-admin-todays-date-inp" value="<?php echo date( 'Y-m-d h:i a', current_time( 'timestamp' )); ?>"/> |
|
273 | + <input type="hidden" name="txn_admin_todays_date" id="txn-admin-todays-date-inp" value="<?php echo date('Y-m-d h:i a', current_time('timestamp')); ?>"/> |
|
274 | 274 | |
275 | 275 | <div class="txn-admin-apply-payment-date-dv admin-modal-dialog-row"> |
276 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
277 | - <label for="txn-admin-payment-date-inp" class=""><?php _e( 'Payment Date', 'event_espresso' );?></label> |
|
278 | - <input name="[date]txn_admin_payment" id="txn-admin-payment-date-inp" class="txn-admin-apply-payment-inp required" type="text" value="<?php echo date( 'Y-m-d g:i a', current_time( 'timestamp' )); ?>"/> |
|
279 | - <p class="description"><?php _e( 'The date the payment was actually made on', 'event_espresso' );?></p> |
|
276 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
277 | + <label for="txn-admin-payment-date-inp" class=""><?php _e('Payment Date', 'event_espresso'); ?></label> |
|
278 | + <input name="[date]txn_admin_payment" id="txn-admin-payment-date-inp" class="txn-admin-apply-payment-inp required" type="text" value="<?php echo date('Y-m-d g:i a', current_time('timestamp')); ?>"/> |
|
279 | + <p class="description"><?php _e('The date the payment was actually made on', 'event_espresso'); ?></p> |
|
280 | 280 | </div> |
281 | 281 | |
282 | 282 | <div class="txn-admin-apply-payment-amount-dv admin-modal-dialog-row"> |
283 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
284 | - <label for="txn-admin-payment-amount-inp" class=""><?php _e( 'Amount', 'event_espresso' );?></label> |
|
283 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
284 | + <label for="txn-admin-payment-amount-inp" class=""><?php _e('Amount', 'event_espresso'); ?></label> |
|
285 | 285 | <input name="txn_admin_payment[amount]" id="txn-admin-payment-amount-inp" class="txn-admin-apply-payment-inp required" type="text" value=""/> |
286 | - <p class="description"><?php _e( 'The amount of the payment', 'event_espresso' );?></p> |
|
286 | + <p class="description"><?php _e('The amount of the payment', 'event_espresso'); ?></p> |
|
287 | 287 | </div> |
288 | 288 | |
289 | 289 | <div class="txn-admin-apply-payment-method-dv admin-modal-dialog-row"> |
290 | - <div class="validation-notice-dv"><?php _e( 'The following is a required field', 'event_espresso' );?></div> |
|
291 | - <label for="txn-admin-payment-method-inp" class=""><?php _e( 'Method of Payment', 'event_espresso' );?></label> |
|
290 | + <div class="validation-notice-dv"><?php _e('The following is a required field', 'event_espresso'); ?></div> |
|
291 | + <label for="txn-admin-payment-method-inp" class=""><?php _e('Method of Payment', 'event_espresso'); ?></label> |
|
292 | 292 | <select name="txn_admin_payment[PMD_ID]" id="txn-admin-payment-method-slct" class="txn-admin-apply-payment-slct required" type="text" > |
293 | - <?php foreach ( $payment_methods as $method ) : ?> |
|
293 | + <?php foreach ($payment_methods as $method) : ?> |
|
294 | 294 | <?php $selected = $method->slug() == 'cash' ? ' selected="selected"' : ''; ?> |
295 | - <option id="payment-method-opt-<?php echo $method->slug(); ?>" value="<?php echo $method->ID(); ?>"<?php echo $selected; ?>><?php echo sanitize_key( $method->admin_desc() ) ? substr( $method->admin_desc(), 0, 128) : $method->admin_name() ; ?> </option> |
|
295 | + <option id="payment-method-opt-<?php echo $method->slug(); ?>" value="<?php echo $method->ID(); ?>"<?php echo $selected; ?>><?php echo sanitize_key($method->admin_desc()) ? substr($method->admin_desc(), 0, 128) : $method->admin_name(); ?> </option> |
|
296 | 296 | <?php endforeach; ?> |
297 | 297 | </select> |
298 | - <p class="description"><?php _e( 'Whether the payment was made via PayPal, Credit Card, Cheque, or Cash', 'event_espresso' );?></p> |
|
298 | + <p class="description"><?php _e('Whether the payment was made via PayPal, Credit Card, Cheque, or Cash', 'event_espresso'); ?></p> |
|
299 | 299 | </div> |
300 | 300 | |
301 | 301 | <div class="mop-PP mop-CC mop-CHQ mop"> |
302 | 302 | <div class="txn-admin-apply-payment-gw-txn-id-dv admin-modal-dialog-row"> |
303 | - <label for="txn-admin-payment-txn-id-inp" class=""><?php _e( 'TXN ID / CHQ #', 'event_espresso' );?></label> |
|
303 | + <label for="txn-admin-payment-txn-id-inp" class=""><?php _e('TXN ID / CHQ #', 'event_espresso'); ?></label> |
|
304 | 304 | <input name="txn_admin_payment[txn_id_chq_nmbr]" id="txn-admin-payment-txn-id-chq-nmbr-inp" class="txn-admin-apply-payment-inp" type="text" maxlength="100"/> |
305 | - <p class="description"><?php _e( 'The Transaction ID sent back from the payment gateway, or the Cheque #', 'event_espresso' );?></p> |
|
305 | + <p class="description"><?php _e('The Transaction ID sent back from the payment gateway, or the Cheque #', 'event_espresso'); ?></p> |
|
306 | 306 | </div> |
307 | 307 | </div> |
308 | 308 | |
309 | 309 | <div class="mop-CC mop" style="display:none"> |
310 | 310 | <div class="txn-admin-apply-payment-response-dv admin-modal-dialog-row"> |
311 | - <label for="txn-admin-payment-gateway-response-inp" class=""><?php _e( 'Gateway Response', 'event_espresso' );?></label> |
|
311 | + <label for="txn-admin-payment-gateway-response-inp" class=""><?php _e('Gateway Response', 'event_espresso'); ?></label> |
|
312 | 312 | <input name="txn_admin_payment[gateway_response]" id="txn-admin-payment-gateway-response-inp" class="txn-admin-apply-payment-inp" type="text"/> |
313 | - <p class="description"><?php _e( 'The gateway response string (optional)', 'event_espresso' );?></p> |
|
313 | + <p class="description"><?php _e('The gateway response string (optional)', 'event_espresso'); ?></p> |
|
314 | 314 | </div> |
315 | 315 | </div> |
316 | 316 | |
317 | 317 | <div class="mop-PP mop-CC mop"> |
318 | 318 | <div class="txn-admin-apply-payment-status-dv admin-modal-dialog-row"> |
319 | - <label for="txn-admin-payment-status-inp" class=""><?php _e( 'Payment Status', 'event_espresso' );?></label> |
|
319 | + <label for="txn-admin-payment-status-inp" class=""><?php _e('Payment Status', 'event_espresso'); ?></label> |
|
320 | 320 | <select name="txn_admin_payment[status]" id="txn-admin-payment-status-slct" class="txn-admin-apply-payment-slct" type="text" > |
321 | - <?php foreach ( $payment_status as $STS_ID => $STS_code ) : ?> |
|
321 | + <?php foreach ($payment_status as $STS_ID => $STS_code) : ?> |
|
322 | 322 | <?php $selected = $STS_ID == 'PAP' ? ' selected="selected"' : ''; ?> |
323 | 323 | <option id="payment-status-opt-<?php echo $STS_ID; ?>" value="<?php echo $STS_ID; ?>"<?php echo $selected; ?>><?php echo $STS_code; ?> </option> |
324 | 324 | <?php endforeach; ?> |
325 | 325 | </select> |
326 | - <p class="description"><?php _e( 'Whether the payment was approved, cancelled, declined or failed after submission to the gateway', 'event_espresso' );?></p> |
|
326 | + <p class="description"><?php _e('Whether the payment was approved, cancelled, declined or failed after submission to the gateway', 'event_espresso'); ?></p> |
|
327 | 327 | </div> |
328 | 328 | </div> |
329 | 329 | |
330 | 330 | <div class="txn-admin-apply-payment-po-nmbr-dv admin-modal-dialog-row"> |
331 | - <label for="txn-admin-payment-po-nmbr-inp" class=""><?php _e( 'P.O. / S.O. #', 'event_espresso' );?></label> |
|
331 | + <label for="txn-admin-payment-po-nmbr-inp" class=""><?php _e('P.O. / S.O. #', 'event_espresso'); ?></label> |
|
332 | 332 | <input name="txn_admin_payment[po_number]" id="txn-admin-payment-po-nmbr-inp" class="txn-admin-apply-payment-inp" type="text" maxlength="100"/> |
333 | - <p class="description"><?php _e( 'The Purchase or Sales Order Number if any (optional)', 'event_espresso' );?></p> |
|
333 | + <p class="description"><?php _e('The Purchase or Sales Order Number if any (optional)', 'event_espresso'); ?></p> |
|
334 | 334 | </div> |
335 | 335 | |
336 | 336 | <div class="txn-admin-apply-payment-accounting-dv admin-modal-dialog-row"> |
337 | - <label for="txn-admin-payment-accounting-inp" class="last"><?php _e( 'Notes / Extra Accounting', 'event_espresso' );?></label> |
|
337 | + <label for="txn-admin-payment-accounting-inp" class="last"><?php _e('Notes / Extra Accounting', 'event_espresso'); ?></label> |
|
338 | 338 | <input name="txn_admin_payment[accounting]" id="txn-admin-payment-accounting-inp" class="txn-admin-apply-payment-inp" type="text" value="<?php echo $REG_code; ?>" maxlength="100"/> <input type="hidden" id="txn-admin-reg-code-inp" value="<?php echo $REG_code; ?>"/> |
339 | - <p class="description"><?php _e( 'An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.', 'event_espresso' );?></p> |
|
339 | + <p class="description"><?php _e('An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.', 'event_espresso'); ?></p> |
|
340 | 340 | </div> |
341 | 341 | |
342 | 342 | <div class="txn-admin-apply-payment-registrations-dv admin-modal-dialog-row"> |
343 | - <label for="txn-admin-payment-registrations-inp" class="last"><?php _e( 'Registrations to Apply Payment to:', 'event_espresso' ); ?></label> |
|
343 | + <label for="txn-admin-payment-registrations-inp" class="last"><?php _e('Registrations to Apply Payment to:', 'event_espresso'); ?></label> |
|
344 | 344 | <label class="txn-admin-apply-payment-to-registrations-lbl"> |
345 | 345 | <input type="radio" value="1" id="txn-admin-apply-payment-to-all-registrations-inp" name="txn_admin_payment[apply_to_all_registrations]" checked="checked"/> |
346 | - <?php _e( 'ALL Registrations', 'event_espresso' ); ?> |
|
346 | + <?php _e('ALL Registrations', 'event_espresso'); ?> |
|
347 | 347 | </label> |
348 | 348 | <label class="txn-admin-apply-payment-to-registrations-lbl"> |
349 | 349 | <input type="radio" value="0" id="txn-admin-apply-payment-to-some-registrations-inp" name="txn_admin_payment[apply_to_all_registrations]" /> |
350 | - <?php _e( 'Just the following Registrations', 'event_espresso' ); ?> |
|
350 | + <?php _e('Just the following Registrations', 'event_espresso'); ?> |
|
351 | 351 | </label> |
352 | 352 | <?php echo $registrations_to_apply_payment_to; ?> |
353 | 353 | </div> |
354 | 354 | |
355 | 355 | <div class="txn-admin-payment-reg-status-dv admin-modal-dialog-row"> |
356 | - <label for="txn-admin-payment-reg-status-inp" class="last"><?php _e( 'Change Registration Status?', 'event_espresso' );?></label> |
|
356 | + <label for="txn-admin-payment-reg-status-inp" class="last"><?php _e('Change Registration Status?', 'event_espresso'); ?></label> |
|
357 | 357 | <?php echo $status_change_select; ?> |
358 | - <p class="description"><?php _e( 'If you wish to change the status for the registrations selected above, then select which status from this dropdown.', 'event_espresso' ); ?></p> |
|
358 | + <p class="description"><?php _e('If you wish to change the status for the registrations selected above, then select which status from this dropdown.', 'event_espresso'); ?></p> |
|
359 | 359 | <br/> |
360 | 360 | </div> |
361 | 361 | |
362 | 362 | <div class="txn-admin-apply-payment-send-notifications-dv admin-modal-dialog-row"> |
363 | 363 | |
364 | - <label for="txn-admin-payment-send-notifications-inp" class="last"><?php _e( 'Send Related Messages?', 'event_espresso' );?></label> |
|
364 | + <label for="txn-admin-payment-send-notifications-inp" class="last"><?php _e('Send Related Messages?', 'event_espresso'); ?></label> |
|
365 | 365 | <label class="txn-admin-payment-send-notifications-lbl"> |
366 | 366 | <input type="checkbox" value="1" name="txn_payments[send_notifications]" checked="checked" aria-checked="true" style="vertical-align: middle;"> |
367 | - <?php _e( 'Payment Messages?', 'event_espresso' ); ?> |
|
367 | + <?php _e('Payment Messages?', 'event_espresso'); ?> |
|
368 | 368 | </label> |
369 | 369 | <label class="txn-admin-payment-send-notifications-lbl"> |
370 | 370 | <input type="checkbox" value="1" name="txn_reg_status_change[send_notifications]" style="vertical-align: middle;"> |
371 | - <?php _e( 'Registration Messages?', 'event_espresso' ); ?> |
|
371 | + <?php _e('Registration Messages?', 'event_espresso'); ?> |
|
372 | 372 | </label> |
373 | 373 | <br class="clear-float"/> |
374 | - <p class="description"><?php printf( __('By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.', 'event_espresso'), '<strong>', '</strong>', '<br />' ); ?></p> |
|
374 | + <p class="description"><?php printf(__('By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.', 'event_espresso'), '<strong>', '</strong>', '<br />'); ?></p> |
|
375 | 375 | <label></label> |
376 | 376 | </div> |
377 | 377 | <div class="clear"></div> |
@@ -382,27 +382,27 @@ discard block |
||
382 | 382 | <ul id="admin-modal-dialog-options-ul"> |
383 | 383 | <li> |
384 | 384 | <a id="txn-admin-modal-dialog-apply-payment-lnk" class="button-primary no-icon" style="display:none;" > |
385 | - <?php _e( 'Apply Payment', 'event_espresso' );?> |
|
385 | + <?php _e('Apply Payment', 'event_espresso'); ?> |
|
386 | 386 | </a> |
387 | 387 | </li> |
388 | 388 | <li> |
389 | 389 | <a id="txn-admin-modal-dialog-edit-payment-lnk" class="button-primary no-icon" style="display:none;" > |
390 | - <?php _e( 'Save Payment Details', 'event_espresso' );?> |
|
390 | + <?php _e('Save Payment Details', 'event_espresso'); ?> |
|
391 | 391 | </a> |
392 | 392 | </li> |
393 | 393 | <li> |
394 | 394 | <a id="txn-admin-modal-dialog-edit-refund-lnk" class="button-primary no-icon" style="display:none;" > |
395 | - <?php _e( 'Save Refund Details', 'event_espresso' );?> |
|
395 | + <?php _e('Save Refund Details', 'event_espresso'); ?> |
|
396 | 396 | </a> |
397 | 397 | </li> |
398 | 398 | <li> |
399 | 399 | <a id="txn-admin-modal-dialog-apply-refund-lnk" class="button-primary no-icon" style="display:none;" > |
400 | - <?php _e( 'Apply Refund', 'event_espresso' );?> |
|
400 | + <?php _e('Apply Refund', 'event_espresso'); ?> |
|
401 | 401 | </a> |
402 | 402 | </li> |
403 | 403 | <li> |
404 | 404 | <a id="txn-admin-modal-dialog-cancel-lnk" class="button-secondary no-icon" > |
405 | - <?php _e( 'Cancel', 'event_espresso' );?> |
|
405 | + <?php _e('Cancel', 'event_espresso'); ?> |
|
406 | 406 | </a> |
407 | 407 | </li> |
408 | 408 | <li> |
@@ -419,29 +419,29 @@ discard block |
||
419 | 419 | |
420 | 420 | <h2 id="admin-modal-dialog-delete-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;"> |
421 | 421 | <span class="ee-icon ee-icon-cash-add"></span> |
422 | - <?php echo __( 'Delete Payment/Refund for Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?> |
|
422 | + <?php echo __('Delete Payment/Refund for Transaction #', 'event_espresso').$txn_nmbr['value']; ?> |
|
423 | 423 | </h2> |
424 | 424 | |
425 | 425 | <form name="txn-admin-delete-payment-frm" id="txn-admin-delete-payment-frm" action="<?php echo $delete_payment_url; ?>"> |
426 | 426 | <div class="admin-modal-dialog-wrap"> |
427 | 427 | <div class="admin-modal-dialog-inner"> |
428 | 428 | |
429 | - <input type="hidden" name="espresso_delete_payment_nonce" id="espresso_delete_payment_nonce" value="<?php echo wp_create_nonce( 'espresso_delete_payment_nonce' );?>"/> |
|
429 | + <input type="hidden" name="espresso_delete_payment_nonce" id="espresso_delete_payment_nonce" value="<?php echo wp_create_nonce('espresso_delete_payment_nonce'); ?>"/> |
|
430 | 430 | <input type="hidden" name="delete_espresso_ajax" id="delete-espresso-ajax" value="0"/> |
431 | 431 | <input type="hidden" name="delete_noheader" id="delete-txn-admin-noheader-inp" value="0"/> |
432 | 432 | <input type="hidden" name="delete_txn_admin_payment[PAY_ID]" id="delete-txn-admin-payment-payment-id-inp" class="txn-admin-apply-payment-inp" value="0"/> |
433 | 433 | <input type="hidden" name="delete_txn_admin_payment[TXN_ID]" id="delete-txn-admin-payment-txn-id-inp" value="<?php echo $txn_nmbr['value']; ?>"/> |
434 | 434 | |
435 | 435 | <div class="txn-admin-apply-payment-accounting-dv admin-modal-dialog-row"> |
436 | - <label for="delete-txn-admin-payment-reg-status-inp" class="last"><?php _e( 'Change Registration Status?', 'event_espresso' );?></label> |
|
436 | + <label for="delete-txn-admin-payment-reg-status-inp" class="last"><?php _e('Change Registration Status?', 'event_espresso'); ?></label> |
|
437 | 437 | <?php echo $delete_status_change_select; ?> |
438 | - <p class="description"><?php printf( __('If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s', 'event_espresso'), '<strong>', '</strong>' ); ?></p> |
|
438 | + <p class="description"><?php printf(__('If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
439 | 439 | </div> |
440 | 440 | |
441 | 441 | <div class="ee-attention txn-admin-apply-payment-accounting-dv admin-modal-dialog-row"> |
442 | - <label for="delete-txn-admin-payment-accounting-inp" class="last"><?php _e( 'Send Related Messages?', 'event_espresso' );?></label> |
|
442 | + <label for="delete-txn-admin-payment-accounting-inp" class="last"><?php _e('Send Related Messages?', 'event_espresso'); ?></label> |
|
443 | 443 | <input type="checkbox" value="1" name="delete_txn_reg_status_change[send_notifications]"> |
444 | - <p class="description"><?php _e( 'If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.', 'event_espresso' );?></p> |
|
444 | + <p class="description"><?php _e('If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.', 'event_espresso'); ?></p> |
|
445 | 445 | </div> |
446 | 446 | <div class="clear"></div> |
447 | 447 | |
@@ -451,12 +451,12 @@ discard block |
||
451 | 451 | <ul id="del-admin-modal-dialog-options-ul"> |
452 | 452 | <li> |
453 | 453 | <a id="txn-admin-modal-dialog-delete-lnk" class="button-primary no-icon" style="display:none;" > |
454 | - <?php _e( 'Delete', 'event_espresso' );?> |
|
454 | + <?php _e('Delete', 'event_espresso'); ?> |
|
455 | 455 | </a> |
456 | 456 | </li> |
457 | 457 | <li> |
458 | 458 | <a id="del-txn-admin-modal-dialog-cancel-lnk" class="button-secondary no-icon" > |
459 | - <?php _e( 'Cancel', 'event_espresso' );?> |
|
459 | + <?php _e('Cancel', 'event_espresso'); ?> |
|
460 | 460 | </a> |
461 | 461 | </li> |
462 | 462 | <li> |
@@ -472,30 +472,30 @@ discard block |
||
472 | 472 | <?php endif; // $grand_raw_total > 0?> |
473 | 473 | |
474 | 474 | <?php |
475 | - if ( WP_DEBUG ) { |
|
476 | - $delivered_messages = get_option( 'EED_Messages__payment', array() ); |
|
477 | - if ( isset( $delivered_messages[ $TXN_ID ] )) { |
|
475 | + if (WP_DEBUG) { |
|
476 | + $delivered_messages = get_option('EED_Messages__payment', array()); |
|
477 | + if (isset($delivered_messages[$TXN_ID])) { |
|
478 | 478 | ?> |
479 | - <h4 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-email-alt"></span><?php _e( 'Messages Sent to Primary Registrant', 'event_espresso' );?></h4> |
|
479 | + <h4 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-email-alt"></span><?php _e('Messages Sent to Primary Registrant', 'event_espresso'); ?></h4> |
|
480 | 480 | |
481 | 481 | <div class="admin-primary-mbox-tbl-wrap"> |
482 | 482 | <table class="admin-primary-mbox-tbl"> |
483 | 483 | <thead> |
484 | 484 | <tr> |
485 | - <th class="jst-left"><?php _e( 'Date & Time', 'event_espresso' );?></th> |
|
486 | - <th class="jst-left"><?php _e( 'Message Type', 'event_espresso' );?></th> |
|
487 | - <th class="jst-left"><?php _e( 'Payment Status Upon Sending', 'event_espresso' );?></th> |
|
488 | - <th class="jst-left"><?php _e( 'TXN Status Upon Sending', 'event_espresso' );?></th> |
|
485 | + <th class="jst-left"><?php _e('Date & Time', 'event_espresso'); ?></th> |
|
486 | + <th class="jst-left"><?php _e('Message Type', 'event_espresso'); ?></th> |
|
487 | + <th class="jst-left"><?php _e('Payment Status Upon Sending', 'event_espresso'); ?></th> |
|
488 | + <th class="jst-left"><?php _e('TXN Status Upon Sending', 'event_espresso'); ?></th> |
|
489 | 489 | </tr> |
490 | 490 | </thead> |
491 | 491 | <tbody> |
492 | - <?php foreach ( $delivered_messages[ $TXN_ID ] as $timestamp => $delivered_message ) : |
|
492 | + <?php foreach ($delivered_messages[$TXN_ID] as $timestamp => $delivered_message) : |
|
493 | 493 | ?> |
494 | 494 | <tr> |
495 | - <td class="jst-left"><?php echo gmdate( get_option('date_format') . ' ' . get_option('time_format'), ( $timestamp + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );?></td> |
|
496 | - <td class="jst-left"><?php echo isset( $delivered_message['message_type'] ) ? $delivered_message['message_type'] : '';?></td> |
|
497 | - <td class="jst-left"><?php echo isset( $delivered_message['pay_status'] ) ? $delivered_message['pay_status'] : '';?></td> |
|
498 | - <td class="jst-left"><?php echo isset( $delivered_message['txn_status'] ) ? $delivered_message['txn_status'] : '';?></td> |
|
495 | + <td class="jst-left"><?php echo gmdate(get_option('date_format').' '.get_option('time_format'), ($timestamp + (get_option('gmt_offset') * HOUR_IN_SECONDS))); ?></td> |
|
496 | + <td class="jst-left"><?php echo isset($delivered_message['message_type']) ? $delivered_message['message_type'] : ''; ?></td> |
|
497 | + <td class="jst-left"><?php echo isset($delivered_message['pay_status']) ? $delivered_message['pay_status'] : ''; ?></td> |
|
498 | + <td class="jst-left"><?php echo isset($delivered_message['txn_status']) ? $delivered_message['txn_status'] : ''; ?></td> |
|
499 | 499 | </tr> |
500 | 500 | <?php endforeach; // $delivered_messages?> |
501 | 501 | </tbody> |