Completed
Branch BUG-10236-FIX-RESET-CAPABILITI... (cbd980)
by
unknown
26:22 queued 14:04
created
finalize_registration/EE_SPCO_Reg_Step_Finalize_Registration.class.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 
57 57
 
58 58
 
59
-    /**
60
-     * @return string
61
-     * @throws \EE_Error
62
-     */
59
+	/**
60
+	 * @return string
61
+	 * @throws \EE_Error
62
+	 */
63 63
 	public function generate_reg_form() {
64 64
 		// create empty form so that things don't break
65 65
 		$this->reg_form = new EE_Form_Section_Proper();
@@ -68,26 +68,26 @@  discard block
 block discarded – undo
68 68
 
69 69
 
70 70
 
71
-    /**
72
-     * @return boolean
73
-     * @throws \RuntimeException
74
-     * @throws \EE_Error
75
-     */
71
+	/**
72
+	 * @return boolean
73
+	 * @throws \RuntimeException
74
+	 * @throws \EE_Error
75
+	 */
76 76
 	public function process_reg_step() {
77
-        // ensure all data gets refreshed from the db
77
+		// ensure all data gets refreshed from the db
78 78
 		$this->checkout->refresh_all_entities( true );
79 79
 		// ensures that all details and statuses for transaction, registration, and payments are updated
80 80
 		$txn_update_params = $this->_finalize_transaction();
81
-        // maybe send messages
82
-        $this->_set_notification_triggers();
83
-        // send messages
84
-        /** @type EE_Registration_Processor $registration_processor */
85
-        $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
86
-        $registration_processor->trigger_registration_update_notifications(
87
-            $this->checkout->transaction->primary_registration(),
88
-            $txn_update_params
89
-        );
90
-        // set a hook point
81
+		// maybe send messages
82
+		$this->_set_notification_triggers();
83
+		// send messages
84
+		/** @type EE_Registration_Processor $registration_processor */
85
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
86
+		$registration_processor->trigger_registration_update_notifications(
87
+			$this->checkout->transaction->primary_registration(),
88
+			$txn_update_params
89
+		);
90
+		// set a hook point
91 91
 		do_action(
92 92
 			'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
93 93
 			$this->checkout,
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		if (
105 105
 			! (
106 106
 				$this->checkout->payment_method instanceof EE_Payment_Method
107
-		        && $this->checkout->payment_method->is_off_site()
107
+				&& $this->checkout->payment_method->is_off_site()
108 108
 			)
109 109
 		) {
110 110
 			// mark this reg step as completed
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 
117 117
 
118 118
 
119
-    /**
120
-     * _finalize_transaction
121
-     * ensures that all details and statuses for transaction, registration, and payments are updated
122
-     *
123
-     * @return array
124
-     * @throws \RuntimeException
125
-     * @throws \EE_Error
126
-     */
119
+	/**
120
+	 * _finalize_transaction
121
+	 * ensures that all details and statuses for transaction, registration, and payments are updated
122
+	 *
123
+	 * @return array
124
+	 * @throws \RuntimeException
125
+	 * @throws \EE_Error
126
+	 */
127 127
 	protected function _finalize_transaction() {
128 128
 		/** @type EE_Transaction_Processor $transaction_processor */
129 129
 		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
@@ -139,17 +139,17 @@  discard block
 block discarded – undo
139 139
 		}
140 140
 		// maybe update status, but don't save transaction just yet
141 141
 		$this->checkout->transaction->update_status_based_on_total_paid( false );
142
-        // this will result in the base session properties getting saved to the TXN_Session_data field
142
+		// this will result in the base session properties getting saved to the TXN_Session_data field
143 143
 		$this->checkout->transaction->set_txn_session_data(
144 144
 			EE_Registry::instance()->SSN->get_session_data( null, true )
145 145
 		);
146
-        // update the TXN if payment conditions have changed, but do NOT trigger notifications,
147
-        // because we will do that in process_reg_step() after setting some more triggers
146
+		// update the TXN if payment conditions have changed, but do NOT trigger notifications,
147
+		// because we will do that in process_reg_step() after setting some more triggers
148 148
 		return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
149 149
 			$this->checkout->transaction,
150 150
 			$this->checkout->payment,
151 151
 			$this->checkout->reg_cache_where_params,
152
-            false
152
+			false
153 153
 		);
154 154
 	}
155 155
 
@@ -167,43 +167,43 @@  discard block
 block discarded – undo
167 167
 	protected function _set_notification_triggers() {
168 168
 
169 169
 		if ( $this->checkout->payment_method instanceof EE_Payment_Method ) {
170
-		    // let's start with the assumption that we need to trigger notifications
171
-            // then toggle this to false for conditions where we know we don't need to
172
-		    $deliver_notifications = true;
173
-            if (
174
-                // if SPCO revisit
175
-                filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN)
176
-                // and TXN or REG statuses have NOT changed due to a payment
177
-                && ! (
178
-                    $this->checkout->transaction->txn_status_updated()
179
-                    || $this->checkout->any_reg_status_updated()
180
-                )
181
-            ) {
182
-                $deliver_notifications = false;
183
-            }
184
-            if ($this->checkout->payment_method->is_off_site()) {
185
-                /** @var EE_Gateway $gateway */
186
-                $gateway = $this->checkout->payment_method->type_obj()->get_gateway();
187
-                // and the gateway uses a separate request to process the IPN
188
-                if (
189
-                    $gateway instanceof EE_Offsite_Gateway
190
-                    && $gateway->handle_IPN_in_this_request(\EE_Registry::instance()->REQ->params(), true)
191
-                ) {
192
-                    // IPN request will handle triggering notifications
193
-                    $deliver_notifications = false;
194
-                    // no really... don't send any notices in this request
195
-                    remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications');
196
-                    add_filter(
197
-                        'FHEE__EED_Messages___maybe_registration__deliver_notifications',
198
-                        '__return_false',
199
-                        15
200
-                    );
201
-                }
202
-            }
203
-            if ($deliver_notifications) {
204
-                // send out notifications
205
-                add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
206
-            }
170
+			// let's start with the assumption that we need to trigger notifications
171
+			// then toggle this to false for conditions where we know we don't need to
172
+			$deliver_notifications = true;
173
+			if (
174
+				// if SPCO revisit
175
+				filter_var($this->checkout->revisit, FILTER_VALIDATE_BOOLEAN)
176
+				// and TXN or REG statuses have NOT changed due to a payment
177
+				&& ! (
178
+					$this->checkout->transaction->txn_status_updated()
179
+					|| $this->checkout->any_reg_status_updated()
180
+				)
181
+			) {
182
+				$deliver_notifications = false;
183
+			}
184
+			if ($this->checkout->payment_method->is_off_site()) {
185
+				/** @var EE_Gateway $gateway */
186
+				$gateway = $this->checkout->payment_method->type_obj()->get_gateway();
187
+				// and the gateway uses a separate request to process the IPN
188
+				if (
189
+					$gateway instanceof EE_Offsite_Gateway
190
+					&& $gateway->handle_IPN_in_this_request(\EE_Registry::instance()->REQ->params(), true)
191
+				) {
192
+					// IPN request will handle triggering notifications
193
+					$deliver_notifications = false;
194
+					// no really... don't send any notices in this request
195
+					remove_all_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications');
196
+					add_filter(
197
+						'FHEE__EED_Messages___maybe_registration__deliver_notifications',
198
+						'__return_false',
199
+						15
200
+					);
201
+				}
202
+			}
203
+			if ($deliver_notifications) {
204
+				// send out notifications
205
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
206
+			}
207 207
 		}
208 208
 	}
209 209
 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 * @access    public
22 22
 	 * @param    EE_Checkout $checkout
23 23
 	 */
24
-	public function __construct( EE_Checkout $checkout ) {
24
+	public function __construct(EE_Checkout $checkout) {
25 25
 		$this->_slug = 'finalize_registration';
26
-		$this->_name = __( 'Finalize Registration', 'event_espresso' );
26
+		$this->_name = __('Finalize Registration', 'event_espresso');
27 27
 		$this->_submit_button_text = $this->_name;
28 28
 		$this->_template = '';
29 29
 		$this->checkout = $checkout;
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function initialize_reg_step() {
48 48
 		// there's actually no reg form to process if this is the final step
49
-		if ( $this->is_current_step() ) {
49
+		if ($this->is_current_step()) {
50 50
 			$this->checkout->step = $_REQUEST['step'] = $this->slug();
51 51
 			$this->checkout->action = $_REQUEST['action'] = 'process_reg_step';
52 52
 			$this->checkout->generate_reg_form = false;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
 	public function process_reg_step() {
77 77
         // ensure all data gets refreshed from the db
78
-		$this->checkout->refresh_all_entities( true );
78
+		$this->checkout->refresh_all_entities(true);
79 79
 		// ensures that all details and statuses for transaction, registration, and payments are updated
80 80
 		$txn_update_params = $this->_finalize_transaction();
81 81
         // maybe send messages
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 			$txn_update_params
95 95
 		);
96 96
 		// check if transaction has a primary registrant and that it has a related Attendee object
97
-		if ( ! $this->_validate_primary_registrant() ) {
97
+		if ( ! $this->_validate_primary_registrant()) {
98 98
 			return false;
99 99
 		}
100 100
 		// you don't have to go home but you can't stay here !
101 101
 		$this->checkout->redirect = true;
102 102
 		$this->checkout->continue_reg = true;
103
-		$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
103
+		$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
104 104
 		if (
105 105
 			! (
106 106
 				$this->checkout->payment_method instanceof EE_Payment_Method
@@ -126,22 +126,22 @@  discard block
 block discarded – undo
126 126
      */
127 127
 	protected function _finalize_transaction() {
128 128
 		/** @type EE_Transaction_Processor $transaction_processor */
129
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
129
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
130 130
 		//set revisit flag in txn processor
131
-		$transaction_processor->set_revisit( $this->checkout->revisit );
131
+		$transaction_processor->set_revisit($this->checkout->revisit);
132 132
 		// at this point we'll consider a TXN to not have been abandoned
133 133
 		$this->checkout->transaction->toggle_abandoned_transaction_status();
134
-		if ( $this->checkout->cart instanceof EE_Cart ) {
134
+		if ($this->checkout->cart instanceof EE_Cart) {
135 135
 			// save TXN data to the cart
136 136
 			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn(
137 137
 				$this->checkout->transaction->ID()
138 138
 			);
139 139
 		}
140 140
 		// maybe update status, but don't save transaction just yet
141
-		$this->checkout->transaction->update_status_based_on_total_paid( false );
141
+		$this->checkout->transaction->update_status_based_on_total_paid(false);
142 142
         // this will result in the base session properties getting saved to the TXN_Session_data field
143 143
 		$this->checkout->transaction->set_txn_session_data(
144
-			EE_Registry::instance()->SSN->get_session_data( null, true )
144
+			EE_Registry::instance()->SSN->get_session_data(null, true)
145 145
 		);
146 146
         // update the TXN if payment conditions have changed, but do NOT trigger notifications,
147 147
         // because we will do that in process_reg_step() after setting some more triggers
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	protected function _set_notification_triggers() {
168 168
 
169
-		if ( $this->checkout->payment_method instanceof EE_Payment_Method ) {
169
+		if ($this->checkout->payment_method instanceof EE_Payment_Method) {
170 170
 		    // let's start with the assumption that we need to trigger notifications
171 171
             // then toggle this to false for conditions where we know we don't need to
172 172
 		    $deliver_notifications = true;
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 	 * @throws \EE_Error
217 217
 	 */
218 218
 	protected function _validate_primary_registrant() {
219
-		if ( ! $this->checkout->transaction_has_primary_registrant() ) {
219
+		if ( ! $this->checkout->transaction_has_primary_registrant()) {
220 220
 			EE_Error::add_error(
221
-				__( 'A valid Primary Registration for this Transaction could not be found.', 'event_espresso' ),
221
+				__('A valid Primary Registration for this Transaction could not be found.', 'event_espresso'),
222 222
 				__FILE__,
223 223
 				__FUNCTION__,
224 224
 				__LINE__
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 		}
230 230
 		// setup URL for redirect
231 231
 		$this->checkout->redirect_url = add_query_arg(
232
-			array( 'e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link() ),
232
+			array('e_reg_url_link' => $this->checkout->transaction->primary_registration()->reg_url_link()),
233 233
 			$this->checkout->thank_you_page_url
234 234
 		);
235 235
 		return true;
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	public function update_reg_step() {
244 244
 		EE_Error::doing_it_wrong(
245
-			__CLASS__ . '::' . __FILE__,
245
+			__CLASS__.'::'.__FILE__,
246 246
 			__(
247 247
 				'Can not call update_reg_step() on the Finalize Registration reg step.',
248 248
 				'event_espresso'
Please login to merge, or discard this patch.
core/entities/models/JsonModelSchema.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -39,7 +39,6 @@  discard block
 block discarded – undo
39 39
 
40 40
     /**
41 41
      * Return the schema for a given model from a given model.
42
-     * @param \EEM_Base $model
43 42
      * @return array
44 43
      */
45 44
     public function getModelSchema()
@@ -103,7 +102,6 @@  discard block
 block discarded – undo
103 102
 
104 103
     /**
105 104
      * Outputs the schema header for a model.
106
-     * @param \EEM_Base $model
107 105
      * @return array
108 106
      */
109 107
     public function getInitialSchemaStructure()
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     public function getModelSchemaForFields(array $model_fields, array $schema)
65 65
     {
66 66
         foreach ($model_fields as $field => $model_field) {
67
-            if (! $model_field instanceof EE_Model_Field_Base) {
67
+            if ( ! $model_field instanceof EE_Model_Field_Base) {
68 68
                 continue;
69 69
             }
70 70
             $schema['properties'][$field] = $model_field->getSchema();
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     public function getModelSchemaForRelations(array $relations_on_model, array $schema)
96 96
     {
97 97
         foreach ($relations_on_model as $model_name => $relation) {
98
-            if (! $relation instanceof EE_Model_Relation_Base) {
98
+            if ( ! $relation instanceof EE_Model_Relation_Base) {
99 99
                 continue;
100 100
             }
101 101
             $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
Please login to merge, or discard this patch.
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -25,120 +25,120 @@
 block discarded – undo
25 25
 class JsonModelSchema
26 26
 {
27 27
 
28
-    /**
29
-     * @var \EEM_Base
30
-     */
31
-    protected $model;
32
-
33
-    /**
34
-     * JsonModelSchema constructor.
35
-     *
36
-     * @param \EEM_Base $model
37
-     */
38
-    public function __construct(EEM_Base $model)
39
-    {
40
-        $this->model = $model;
41
-    }
42
-
43
-    /**
44
-     * Return the schema for a given model from a given model.
45
-     * @param \EEM_Base $model
46
-     * @return array
47
-     */
48
-    public function getModelSchema()
49
-    {
50
-        return $this->getModelSchemaForRelations(
51
-            $this->model->relation_settings(),
52
-            $this->getModelSchemaForFields(
53
-                $this->model->field_settings(),
54
-                $this->getInitialSchemaStructure()
55
-            )
56
-        );
57
-    }
58
-
59
-
60
-    /**
61
-     * Get the schema for a given set of model fields.
62
-     * @param \EE_Model_Field_Base[]     $model_fields
63
-     * @return array
64
-     */
65
-    public function getModelSchemaForFields(array $model_fields, array $schema)
66
-    {
67
-        foreach ($model_fields as $field => $model_field) {
68
-            if (! $model_field instanceof EE_Model_Field_Base) {
69
-                continue;
70
-            }
71
-            $schema['properties'][$field] = $model_field->getSchema();
72
-
73
-            //if this is a primary key field add the primary key item
74
-            if ($model_field instanceof EE_Primary_Key_Field_Base) {
75
-                $schema['properties'][$field]['primary_key'] = true;
76
-                if ($model_field instanceof EE_Primary_Key_Int_Field) {
77
-                    $schema['properties'][$field]['readonly'] = true;
78
-                }
79
-            }
80
-
81
-            //if this is a foreign key field add the foreign key item
82
-            if ($model_field instanceof EE_Foreign_Key_Field_Base) {
83
-                $schema['properties'][$field]['foreign_key'] = array(
84
-                    'description' => esc_html__('This is a foreign key the points to the given models.', 'event_espresso'),
85
-                    'type' => 'array',
86
-                    'enum' => $model_field->get_model_class_names_pointed_to()
87
-                );
88
-            }
89
-        }
90
-        return $schema;
91
-    }
92
-
93
-
94
-    /**
95
-     * Get the schema for a given set of model relations
96
-     * @param EE_Model_Relation_Base[] $relations_on_model
97
-     * @return array
98
-     */
99
-    public function getModelSchemaForRelations(array $relations_on_model, array $schema)
100
-    {
101
-        foreach ($relations_on_model as $model_name => $relation) {
102
-            if (! $relation instanceof EE_Model_Relation_Base) {
103
-                continue;
104
-            }
105
-            $model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
106
-                ? strtolower($model_name)
107
-                : EEH_Inflector::pluralize_and_lower($model_name);
108
-            $schema['properties'][$model_name_for_schema] = $relation->getSchema();
109
-            $schema['properties'][$model_name_for_schema]['relation_model'] = $model_name;
110
-        }
111
-        return $schema;
112
-    }
113
-
114
-
115
-    /**
116
-     * Outputs the schema header for a model.
117
-     * @param \EEM_Base $model
118
-     * @return array
119
-     */
120
-    public function getInitialSchemaStructure()
121
-    {
122
-        return array(
123
-            '$schema' => 'http://json-schema.org/draft-04/schema#',
124
-            'title' => $this->model->get_this_model_name(),
125
-            'type' => 'object',
126
-            'properties' => array()
127
-        );
128
-    }
129
-
130
-
131
-    /**
132
-     * Allows one to just use the object as a string to get the json.
133
-     * eg.
134
-     *
135
-     * $json_schema = new JsonModelSchema(EEM_Event::instance());
136
-     * echo $json_schema; //outputs the schema as a json formatted string.
137
-     *
138
-     * @return bool|false|mixed|string
139
-     */
140
-    public function __toString()
141
-    {
142
-        return wp_json_encode($this->getModelSchema());
143
-    }
28
+	/**
29
+	 * @var \EEM_Base
30
+	 */
31
+	protected $model;
32
+
33
+	/**
34
+	 * JsonModelSchema constructor.
35
+	 *
36
+	 * @param \EEM_Base $model
37
+	 */
38
+	public function __construct(EEM_Base $model)
39
+	{
40
+		$this->model = $model;
41
+	}
42
+
43
+	/**
44
+	 * Return the schema for a given model from a given model.
45
+	 * @param \EEM_Base $model
46
+	 * @return array
47
+	 */
48
+	public function getModelSchema()
49
+	{
50
+		return $this->getModelSchemaForRelations(
51
+			$this->model->relation_settings(),
52
+			$this->getModelSchemaForFields(
53
+				$this->model->field_settings(),
54
+				$this->getInitialSchemaStructure()
55
+			)
56
+		);
57
+	}
58
+
59
+
60
+	/**
61
+	 * Get the schema for a given set of model fields.
62
+	 * @param \EE_Model_Field_Base[]     $model_fields
63
+	 * @return array
64
+	 */
65
+	public function getModelSchemaForFields(array $model_fields, array $schema)
66
+	{
67
+		foreach ($model_fields as $field => $model_field) {
68
+			if (! $model_field instanceof EE_Model_Field_Base) {
69
+				continue;
70
+			}
71
+			$schema['properties'][$field] = $model_field->getSchema();
72
+
73
+			//if this is a primary key field add the primary key item
74
+			if ($model_field instanceof EE_Primary_Key_Field_Base) {
75
+				$schema['properties'][$field]['primary_key'] = true;
76
+				if ($model_field instanceof EE_Primary_Key_Int_Field) {
77
+					$schema['properties'][$field]['readonly'] = true;
78
+				}
79
+			}
80
+
81
+			//if this is a foreign key field add the foreign key item
82
+			if ($model_field instanceof EE_Foreign_Key_Field_Base) {
83
+				$schema['properties'][$field]['foreign_key'] = array(
84
+					'description' => esc_html__('This is a foreign key the points to the given models.', 'event_espresso'),
85
+					'type' => 'array',
86
+					'enum' => $model_field->get_model_class_names_pointed_to()
87
+				);
88
+			}
89
+		}
90
+		return $schema;
91
+	}
92
+
93
+
94
+	/**
95
+	 * Get the schema for a given set of model relations
96
+	 * @param EE_Model_Relation_Base[] $relations_on_model
97
+	 * @return array
98
+	 */
99
+	public function getModelSchemaForRelations(array $relations_on_model, array $schema)
100
+	{
101
+		foreach ($relations_on_model as $model_name => $relation) {
102
+			if (! $relation instanceof EE_Model_Relation_Base) {
103
+				continue;
104
+			}
105
+			$model_name_for_schema = $relation instanceof EE_Belongs_To_Relation
106
+				? strtolower($model_name)
107
+				: EEH_Inflector::pluralize_and_lower($model_name);
108
+			$schema['properties'][$model_name_for_schema] = $relation->getSchema();
109
+			$schema['properties'][$model_name_for_schema]['relation_model'] = $model_name;
110
+		}
111
+		return $schema;
112
+	}
113
+
114
+
115
+	/**
116
+	 * Outputs the schema header for a model.
117
+	 * @param \EEM_Base $model
118
+	 * @return array
119
+	 */
120
+	public function getInitialSchemaStructure()
121
+	{
122
+		return array(
123
+			'$schema' => 'http://json-schema.org/draft-04/schema#',
124
+			'title' => $this->model->get_this_model_name(),
125
+			'type' => 'object',
126
+			'properties' => array()
127
+		);
128
+	}
129
+
130
+
131
+	/**
132
+	 * Allows one to just use the object as a string to get the json.
133
+	 * eg.
134
+	 *
135
+	 * $json_schema = new JsonModelSchema(EEM_Event::instance());
136
+	 * echo $json_schema; //outputs the schema as a json formatted string.
137
+	 *
138
+	 * @return bool|false|mixed|string
139
+	 */
140
+	public function __toString()
141
+	{
142
+		return wp_json_encode($this->getModelSchema());
143
+	}
144 144
 }
Please login to merge, or discard this patch.
core/entities/interfaces/HasSchemaInterface.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -5,63 +5,63 @@
 block discarded – undo
5 5
 
6 6
 interface HasSchemaInterface
7 7
 {
8
-    /**
9
-     * Returns whatever is set as the nicename for the object.
10
-     *
11
-     * @return string
12
-     */
13
-    public function getSchemaDescription();
8
+	/**
9
+	 * Returns whatever is set as the nicename for the object.
10
+	 *
11
+	 * @return string
12
+	 */
13
+	public function getSchemaDescription();
14 14
 
15 15
 
16
-    /**
17
-     * Returns whatever is set as the $_schema_type property for the object.
18
-     * Note: this will automatically add 'null' to the schema if the object is_nullable()
19
-     *
20
-     * @return string|array
21
-     */
22
-    public function getSchemaType();
16
+	/**
17
+	 * Returns whatever is set as the $_schema_type property for the object.
18
+	 * Note: this will automatically add 'null' to the schema if the object is_nullable()
19
+	 *
20
+	 * @return string|array
21
+	 */
22
+	public function getSchemaType();
23 23
 
24 24
 
25
-    /**
26
-     * This is usually present when the $_schema_type property is 'object'.  Any child classes will need to override
27
-     * this method and return the properties for the schema.
28
-     * The reason this is not a property on the class is because there may be filters set on the values for the property
29
-     * that won't be exposed on construct.  For example enum type schemas may have the enum values filtered.
30
-     *
31
-     * @return array
32
-     */
33
-    public function getSchemaProperties();
25
+	/**
26
+	 * This is usually present when the $_schema_type property is 'object'.  Any child classes will need to override
27
+	 * this method and return the properties for the schema.
28
+	 * The reason this is not a property on the class is because there may be filters set on the values for the property
29
+	 * that won't be exposed on construct.  For example enum type schemas may have the enum values filtered.
30
+	 *
31
+	 * @return array
32
+	 */
33
+	public function getSchemaProperties();
34 34
 
35
-    /**
36
-     * If a child class has enum values, they should override this method and provide a simple array
37
-     * of the enum values.
38
-     * The reason this is not a property on the class is because there may be filterable enum values that
39
-     * are set on the instantiated object that could be filtered after construct.
40
-     *
41
-     * @return array
42
-     */
43
-    public function getSchemaEnum();
35
+	/**
36
+	 * If a child class has enum values, they should override this method and provide a simple array
37
+	 * of the enum values.
38
+	 * The reason this is not a property on the class is because there may be filterable enum values that
39
+	 * are set on the instantiated object that could be filtered after construct.
40
+	 *
41
+	 * @return array
42
+	 */
43
+	public function getSchemaEnum();
44 44
 
45
-    /**
46
-     * This returns the value of the $_schema_format property on the object.
47
-     *
48
-     * @return string
49
-     */
50
-    public function getSchemaFormat();
45
+	/**
46
+	 * This returns the value of the $_schema_format property on the object.
47
+	 *
48
+	 * @return string
49
+	 */
50
+	public function getSchemaFormat();
51 51
 
52
-    /**
53
-     * This returns the value of the $_schema_readonly property on the object.
54
-     *
55
-     * @return bool
56
-     */
57
-    public function getSchemaReadonly();
52
+	/**
53
+	 * This returns the value of the $_schema_readonly property on the object.
54
+	 *
55
+	 * @return bool
56
+	 */
57
+	public function getSchemaReadonly();
58 58
 
59 59
 
60
-    /**
61
-     * This returns elements used to represent this field in the json schema.
62
-     *
63
-     * @link http://json-schema.org/
64
-     * @return array
65
-     */
66
-    public function getSchema();
60
+	/**
61
+	 * This returns elements used to represent this field in the json schema.
62
+	 *
63
+	 * @link http://json-schema.org/
64
+	 * @return array
65
+	 */
66
+	public function getSchema();
67 67
 }
68 68
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_Text_Field_Base.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -7,36 +7,36 @@
 block discarded – undo
7 7
 abstract class EE_Text_Field_Base extends EE_Model_Field_Base
8 8
 {
9 9
 
10
-    function prepare_for_get($value_of_field_on_model_object)
11
-    {
12
-        return is_string($value_of_field_on_model_object) ? stripslashes($value_of_field_on_model_object) : $value_of_field_on_model_object;
13
-    }
10
+	function prepare_for_get($value_of_field_on_model_object)
11
+	{
12
+		return is_string($value_of_field_on_model_object) ? stripslashes($value_of_field_on_model_object) : $value_of_field_on_model_object;
13
+	}
14 14
 
15
-    /**
16
-     * Accepts schema of 'form_input' which formats the string for echoing in form input's value.
17
-     *
18
-     * @param string $value_on_field_to_be_outputted
19
-     * @param string $schema
20
-     * @return string
21
-     */
22
-    function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
23
-    {
24
-        if ($schema == 'form_input') {
25
-            $value_on_field_to_be_outputted = htmlentities($value_on_field_to_be_outputted, ENT_QUOTES, 'UTF-8');
26
-        }
27
-        return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
28
-    }
15
+	/**
16
+	 * Accepts schema of 'form_input' which formats the string for echoing in form input's value.
17
+	 *
18
+	 * @param string $value_on_field_to_be_outputted
19
+	 * @param string $schema
20
+	 * @return string
21
+	 */
22
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null)
23
+	{
24
+		if ($schema == 'form_input') {
25
+			$value_on_field_to_be_outputted = htmlentities($value_on_field_to_be_outputted, ENT_QUOTES, 'UTF-8');
26
+		}
27
+		return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema);
28
+	}
29 29
 
30
-    /**
31
-     * In form inputs, we should have called htmlentities and addslashes on form inputs,
32
-     * so we need to undo that on setting of these fields
33
-     *
34
-     * @param string $value_inputted_for_field_on_model_object
35
-     * @return string
36
-     */
37
-    function prepare_for_set($value_inputted_for_field_on_model_object)
38
-    {
39
-        return stripslashes(html_entity_decode(parent::prepare_for_set($value_inputted_for_field_on_model_object),
40
-            ENT_QUOTES, 'UTF-8'));
41
-    }
30
+	/**
31
+	 * In form inputs, we should have called htmlentities and addslashes on form inputs,
32
+	 * so we need to undo that on setting of these fields
33
+	 *
34
+	 * @param string $value_inputted_for_field_on_model_object
35
+	 * @return string
36
+	 */
37
+	function prepare_for_set($value_inputted_for_field_on_model_object)
38
+	{
39
+		return stripslashes(html_entity_decode(parent::prepare_for_set($value_inputted_for_field_on_model_object),
40
+			ENT_QUOTES, 'UTF-8'));
41
+	}
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_Primary_Key_String_Field.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -4,22 +4,22 @@
 block discarded – undo
4 4
 class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base
5 5
 {
6 6
 
7
-    public function __construct($table_column, $nicename)
8
-    {
9
-        parent::__construct($table_column, $nicename, null);
10
-    }
7
+	public function __construct($table_column, $nicename)
8
+	{
9
+		parent::__construct($table_column, $nicename, null);
10
+	}
11 11
 
12
-    /**
13
-     * removes all tags when setting
14
-     *
15
-     * @param string $value_inputted_for_field_on_model_object
16
-     * @return string
17
-     */
18
-    function prepare_for_set($value_inputted_for_field_on_model_object)
19
-    {
20
-        if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
21
-            $value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
22
-        }
23
-        return wp_strip_all_tags($value_inputted_for_field_on_model_object);
24
-    }
12
+	/**
13
+	 * removes all tags when setting
14
+	 *
15
+	 * @param string $value_inputted_for_field_on_model_object
16
+	 * @return string
17
+	 */
18
+	function prepare_for_set($value_inputted_for_field_on_model_object)
19
+	{
20
+		if ($this->is_model_obj_of_type_pointed_to($value_inputted_for_field_on_model_object)) {
21
+			$value_inputted_for_field_on_model_object = $value_inputted_for_field_on_model_object->ID();
22
+		}
23
+		return wp_strip_all_tags($value_inputted_for_field_on_model_object);
24
+	}
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -4,6 +4,9 @@
 block discarded – undo
4 4
 class EE_Primary_Key_String_Field extends EE_Primary_Key_Field_Base
5 5
 {
6 6
 
7
+    /**
8
+     * @param string $table_column
9
+     */
7 10
     public function __construct($table_column, $nicename)
8 11
     {
9 12
         parent::__construct($table_column, $nicename, null);
Please login to merge, or discard this patch.
core/db_models/fields/EE_All_Caps_Text_Field.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@
 block discarded – undo
6 6
  */
7 7
 class EE_All_Caps_Text_Field extends EE_Text_Field_Base
8 8
 {
9
-    /**
10
-     * makes it all upper case, and key-like
11
-     *
12
-     * @param string $value_inputted_for_field_on_model_object
13
-     * @return string
14
-     */
15
-    function prepare_for_set($value_inputted_for_field_on_model_object)
16
-    {
17
-        return strtoupper(sanitize_key($value_inputted_for_field_on_model_object));
18
-    }
9
+	/**
10
+	 * makes it all upper case, and key-like
11
+	 *
12
+	 * @param string $value_inputted_for_field_on_model_object
13
+	 * @return string
14
+	 */
15
+	function prepare_for_set($value_inputted_for_field_on_model_object)
16
+	{
17
+		return strtoupper(sanitize_key($value_inputted_for_field_on_model_object));
18
+	}
19 19
 }
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
reg_steps/attendee_information/attendee_info_main.template.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 /** @var string $default_hidden_inputs */
5 5
 ?>
6 6
 	<p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text">
7
-		<?php echo apply_filters( 'FHEE__registration_page_attendee_information__attendee_information_pg', sprintf( __('In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', 'event_espresso'), '<br />', '<span class="asterisk">*</span>' )); ?>
7
+		<?php echo apply_filters('FHEE__registration_page_attendee_information__attendee_information_pg', sprintf(__('In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.', 'event_espresso'), '<br />', '<span class="asterisk">*</span>')); ?>
8 8
 	</p>
9 9
 
10 10
 <?php
@@ -12,34 +12,34 @@  discard block
 block discarded – undo
12 12
 $prev_event = 0;
13 13
 $prev_ticket = 0;
14 14
 
15
-if ( count( $registrations ) > 0 ) {
16
-	foreach ( $registrations as $registration ) {
17
-		if ( $registration instanceof EE_Registration ) {
15
+if (count($registrations) > 0) {
16
+	foreach ($registrations as $registration) {
17
+		if ($registration instanceof EE_Registration) {
18 18
 			$att_nmbr++;
19 19
 ?>
20 20
 
21
-		<div id="spco-attendee-panel-dv-<?php echo $registration->reg_url_link();?>" class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo $registration->ticket()->ID();?>">
21
+		<div id="spco-attendee-panel-dv-<?php echo $registration->reg_url_link(); ?>" class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo $registration->ticket()->ID(); ?>">
22 22
 
23
-			<?php if ( $registration->event()->ID() !== $prev_event ) { ?>
23
+			<?php if ($registration->event()->ID() !== $prev_event) { ?>
24 24
 			<h4 id="event_title-<?php echo $registration->event()->ID() ?>" class="big-event-title-hdr">
25 25
 				<?php echo $registration->event()->name(); ?>
26 26
 			</h4>
27 27
 			<?php } ?>
28
-			<?php if ( $registration->ticket()->ID() !== $prev_ticket ) { ?>
29
-				<?php if ( ! $revisit ) { ?>
28
+			<?php if ($registration->ticket()->ID() !== $prev_ticket) { ?>
29
+				<?php if ( ! $revisit) { ?>
30 30
 			<div class="spco-ticket-info-dv small-text">
31
-				<h5><?php _e('Details', 'event_espresso');?></h5>
31
+				<h5><?php _e('Details', 'event_espresso'); ?></h5>
32 32
 				<table>
33 33
 					<thead>
34 34
 						<tr>
35
-							<th scope="col" width=""><?php _e('Name and Description', 'event_espresso');?></th>
36
-							<th scope="col" width="7.5%" class="jst-rght"><?php _e('Qty', 'event_espresso');?></th>
37
-							<th scope="col" width="17.5%" class="jst-rght"><?php _e('Price', 'event_espresso');?></th>
38
-							<th scope="col" width="17.5%" class="jst-rght"><?php _e('Total', 'event_espresso');?></th>
35
+							<th scope="col" width=""><?php _e('Name and Description', 'event_espresso'); ?></th>
36
+							<th scope="col" width="7.5%" class="jst-rght"><?php _e('Qty', 'event_espresso'); ?></th>
37
+							<th scope="col" width="17.5%" class="jst-rght"><?php _e('Price', 'event_espresso'); ?></th>
38
+							<th scope="col" width="17.5%" class="jst-rght"><?php _e('Total', 'event_espresso'); ?></th>
39 39
 						</tr>
40 40
 					</thead>
41 41
 					<tbody>
42
-					<?php echo $ticket_line_item[ $registration->ticket()->ID() ]; ?>
42
+					<?php echo $ticket_line_item[$registration->ticket()->ID()]; ?>
43 43
 					</tbody>
44 44
 				</table>
45 45
 			</div>
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 			<?php
50 50
 			// ATTENDEE QUESTIONS
51
-			$reg_form = EE_Template_Layout::get_subform_name( $registration->reg_url_link() );
51
+			$reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link());
52 52
 			echo ${$reg_form};
53 53
 			?>
54 54
 
Please login to merge, or discard this patch.
core/db_models/fields/EE_DB_Only_Field_Base.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
      * @param string $table_column
16 16
      * @param string $nicename
17 17
      * @param bool   $nullable
18
-     * @param null   $default_value
18
+     * @param string|null   $default_value
19 19
      */
20 20
     public function __construct($table_column, $nicename, $nullable, $default_value = null)
21 21
     {
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -11,28 +11,28 @@
 block discarded – undo
11 11
 abstract class EE_DB_Only_Field_Base extends EE_Model_Field_Base
12 12
 {
13 13
 
14
-    /**
15
-     * @param string $table_column
16
-     * @param string $nicename
17
-     * @param bool   $nullable
18
-     * @param null   $default_value
19
-     */
20
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
21
-    {
22
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
23
-        $this->setSchemaReadOnly(true);
24
-    }
14
+	/**
15
+	 * @param string $table_column
16
+	 * @param string $nicename
17
+	 * @param bool   $nullable
18
+	 * @param null   $default_value
19
+	 */
20
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
21
+	{
22
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
23
+		$this->setSchemaReadOnly(true);
24
+	}
25 25
 
26 26
 
27
-    /**
28
-     * All these children classes are for the db-only (meaning, we should select them
29
-     * on get_all queries, update, delete, and will still want to set their default value
30
-     * on inserts, but the model object won't have reference to these fields)
31
-     *
32
-     * @return boolean
33
-     */
34
-    function is_db_only_field()
35
-    {
36
-        return true;
37
-    }
27
+	/**
28
+	 * All these children classes are for the db-only (meaning, we should select them
29
+	 * on get_all queries, update, delete, and will still want to set their default value
30
+	 * on inserts, but the model object won't have reference to these fields)
31
+	 *
32
+	 * @return boolean
33
+	 */
34
+	function is_db_only_field()
35
+	{
36
+		return true;
37
+	}
38 38
 }
39 39
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/fields/EE_Email_Field.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      * @param string $table_column
14 14
      * @param string $nicename
15 15
      * @param bool   $nullable
16
-     * @param null   $default_value
16
+     * @param string   $default_value
17 17
      */
18 18
     public function __construct($table_column, $nicename, $nullable, $default_value = null)
19 19
     {
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -9,48 +9,48 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Email_Field extends EE_Text_Field_Base
11 11
 {
12
-    /**
13
-     * @param string $table_column
14
-     * @param string $nicename
15
-     * @param bool   $nullable
16
-     * @param null   $default_value
17
-     */
18
-    public function __construct($table_column, $nicename, $nullable, $default_value = null)
19
-    {
20
-        parent::__construct($table_column, $nicename, $nullable, $default_value);
21
-        $this->setSchemaFormat('email');
22
-    }
12
+	/**
13
+	 * @param string $table_column
14
+	 * @param string $nicename
15
+	 * @param bool   $nullable
16
+	 * @param null   $default_value
17
+	 */
18
+	public function __construct($table_column, $nicename, $nullable, $default_value = null)
19
+	{
20
+		parent::__construct($table_column, $nicename, $nullable, $default_value);
21
+		$this->setSchemaFormat('email');
22
+	}
23 23
 
24 24
 
25
-    /**
26
-     * In form inputs, we should have called htmlentities and addslashes() on form inputs,
27
-     * so we need to undo that on setting of these fields
28
-     *
29
-     * @param string $email_address
30
-     * @return string
31
-     */
32
-    function prepare_for_set($email_address)
33
-    {
34
-        $validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
35
-            ? EE_Registry::instance()->CFG->registration->email_validation_level
36
-            : 'wp_default';
37
-        if ($validation_level === 'basic' && ! preg_match('/^.+\@\S+$/', $email_address)) {
38
-            // email not even in correct {string}@{string} format
39
-            return '';
40
-        } else if ($validation_level === 'wp_default' && ! is_email($email_address)) {
41
-            //not a valid email.
42
-            return '';
43
-        } else if (
44
-            ($validation_level === 'i18n' || $validation_level === 'i18n_dns')
45
-            // plz see http://stackoverflow.com/a/24817336 re: the following regex
46
-            && ! preg_match(
47
-                '/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u',
48
-                $email_address
49
-            )
50
-        ) {
51
-            //not a valid email.
52
-            return '';
53
-        }
54
-        return $email_address;
55
-    }
25
+	/**
26
+	 * In form inputs, we should have called htmlentities and addslashes() on form inputs,
27
+	 * so we need to undo that on setting of these fields
28
+	 *
29
+	 * @param string $email_address
30
+	 * @return string
31
+	 */
32
+	function prepare_for_set($email_address)
33
+	{
34
+		$validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
35
+			? EE_Registry::instance()->CFG->registration->email_validation_level
36
+			: 'wp_default';
37
+		if ($validation_level === 'basic' && ! preg_match('/^.+\@\S+$/', $email_address)) {
38
+			// email not even in correct {string}@{string} format
39
+			return '';
40
+		} else if ($validation_level === 'wp_default' && ! is_email($email_address)) {
41
+			//not a valid email.
42
+			return '';
43
+		} else if (
44
+			($validation_level === 'i18n' || $validation_level === 'i18n_dns')
45
+			// plz see http://stackoverflow.com/a/24817336 re: the following regex
46
+			&& ! preg_match(
47
+				'/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u',
48
+				$email_address
49
+			)
50
+		) {
51
+			//not a valid email.
52
+			return '';
53
+		}
54
+		return $email_address;
55
+	}
56 56
 }
Please login to merge, or discard this patch.