Completed
Branch FET/reg-form-v2 (f85ea5)
by
unknown
06:45 queued 04:35
created
core/libraries/form_sections/inputs/EE_Country_Select_Input.php 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -14,80 +14,80 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Country_Select_Input extends EE_Select_Input
16 16
 {
17
-    /**
18
-     * $input_settings key used for detecting the "get" option
19
-     */
20
-    const OPTION_GET_KEY = 'get';
17
+	/**
18
+	 * $input_settings key used for detecting the "get" option
19
+	 */
20
+	const OPTION_GET_KEY = 'get';
21 21
 
22
-    /**
23
-     * indicates that ALL countries should be retrieved from the db for the input
24
-     */
25
-    const OPTION_GET_ALL = 'all';
22
+	/**
23
+	 * indicates that ALL countries should be retrieved from the db for the input
24
+	 */
25
+	const OPTION_GET_ALL = 'all';
26 26
 
27
-    /**
28
-     * indicates that only ACTIVE countries should be retrieved from the db for the input
29
-     */
30
-    const OPTION_GET_ACTIVE = 'active';
27
+	/**
28
+	 * indicates that only ACTIVE countries should be retrieved from the db for the input
29
+	 */
30
+	const OPTION_GET_ACTIVE = 'active';
31 31
 
32 32
 
33
-    /**
34
-     * @param array|null $country_options
35
-     * @param array      $input_settings
36
-     * @throws EE_Error
37
-     * @throws InvalidArgumentException
38
-     * @throws InvalidDataTypeException
39
-     * @throws InvalidInterfaceException
40
-     * @throws ReflectionException
41
-     */
42
-    public function __construct(?array $country_options = null, $input_settings = [])
43
-    {
44
-        $get = $input_settings[ self::OPTION_GET_KEY ] ?? self::OPTION_GET_ACTIVE;
33
+	/**
34
+	 * @param array|null $country_options
35
+	 * @param array      $input_settings
36
+	 * @throws EE_Error
37
+	 * @throws InvalidArgumentException
38
+	 * @throws InvalidDataTypeException
39
+	 * @throws InvalidInterfaceException
40
+	 * @throws ReflectionException
41
+	 */
42
+	public function __construct(?array $country_options = null, $input_settings = [])
43
+	{
44
+		$get = $input_settings[ self::OPTION_GET_KEY ] ?? self::OPTION_GET_ACTIVE;
45 45
 
46
-        $country_options = apply_filters(
47
-            'FHEE__EE_Country_Select_Input____construct__country_options',
48
-            $this->get_country_answer_options($country_options, $get),
49
-            $this,
50
-            $get
51
-        );
52
-        $input_settings['html_class'] = isset($input_settings['html_class'])
53
-            ? $input_settings['html_class'] . ' ee-country-select-js'
54
-            : 'ee-country-select-js';
55
-        parent::__construct($country_options, $input_settings);
56
-    }
46
+		$country_options = apply_filters(
47
+			'FHEE__EE_Country_Select_Input____construct__country_options',
48
+			$this->get_country_answer_options($country_options, $get),
49
+			$this,
50
+			$get
51
+		);
52
+		$input_settings['html_class'] = isset($input_settings['html_class'])
53
+			? $input_settings['html_class'] . ' ee-country-select-js'
54
+			: 'ee-country-select-js';
55
+		parent::__construct($country_options, $input_settings);
56
+	}
57 57
 
58 58
 
59
-    /**
60
-     * get_country_answer_options
61
-     *
62
-     * @param array|null $country_options
63
-     * @param string     $get
64
-     * @return array
65
-     * @throws EE_Error
66
-     * @throws InvalidArgumentException
67
-     * @throws ReflectionException
68
-     * @throws InvalidDataTypeException
69
-     * @throws InvalidInterfaceException
70
-     */
71
-    public function get_country_answer_options(
72
-        ?array $country_options = null,
73
-        string $get = self::OPTION_GET_ACTIVE
74
-    ): ?array {
75
-        // if passed something that is NOT an array
76
-        if (empty($country_options)) {
77
-            // get possibly cached list of countries
78
-            $countries = $get === self::OPTION_GET_ALL
79
-                ? EEM_Country::instance()->get_all_countries()
80
-                : EEM_Country::instance()->get_all_active_countries();
81
-            if (empty($countries)) {
82
-                return [];
83
-            }
84
-            $country_options[''] = '';
85
-            foreach ($countries as $country) {
86
-                if ($country instanceof EE_Country) {
87
-                    $country_options[ $country->ID() ] = $country->name();
88
-                }
89
-            }
90
-        }
91
-        return $country_options;
92
-    }
59
+	/**
60
+	 * get_country_answer_options
61
+	 *
62
+	 * @param array|null $country_options
63
+	 * @param string     $get
64
+	 * @return array
65
+	 * @throws EE_Error
66
+	 * @throws InvalidArgumentException
67
+	 * @throws ReflectionException
68
+	 * @throws InvalidDataTypeException
69
+	 * @throws InvalidInterfaceException
70
+	 */
71
+	public function get_country_answer_options(
72
+		?array $country_options = null,
73
+		string $get = self::OPTION_GET_ACTIVE
74
+	): ?array {
75
+		// if passed something that is NOT an array
76
+		if (empty($country_options)) {
77
+			// get possibly cached list of countries
78
+			$countries = $get === self::OPTION_GET_ALL
79
+				? EEM_Country::instance()->get_all_countries()
80
+				: EEM_Country::instance()->get_all_active_countries();
81
+			if (empty($countries)) {
82
+				return [];
83
+			}
84
+			$country_options[''] = '';
85
+			foreach ($countries as $country) {
86
+				if ($country instanceof EE_Country) {
87
+					$country_options[ $country->ID() ] = $country->name();
88
+				}
89
+			}
90
+		}
91
+		return $country_options;
92
+	}
93 93
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function __construct(?array $country_options = null, $input_settings = [])
43 43
     {
44
-        $get = $input_settings[ self::OPTION_GET_KEY ] ?? self::OPTION_GET_ACTIVE;
44
+        $get = $input_settings[self::OPTION_GET_KEY] ?? self::OPTION_GET_ACTIVE;
45 45
 
46 46
         $country_options = apply_filters(
47 47
             'FHEE__EE_Country_Select_Input____construct__country_options',
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
             $get
51 51
         );
52 52
         $input_settings['html_class'] = isset($input_settings['html_class'])
53
-            ? $input_settings['html_class'] . ' ee-country-select-js'
53
+            ? $input_settings['html_class'].' ee-country-select-js'
54 54
             : 'ee-country-select-js';
55 55
         parent::__construct($country_options, $input_settings);
56 56
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             $country_options[''] = '';
85 85
             foreach ($countries as $country) {
86 86
                 if ($country instanceof EE_Country) {
87
-                    $country_options[ $country->ID() ] = $country->name();
87
+                    $country_options[$country->ID()] = $country->name();
88 88
                 }
89 89
             }
90 90
         }
Please login to merge, or discard this patch.
strategies/validation/EE_Min_Length_Validation_Strategy.strategy.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -12,46 +12,46 @@
 block discarded – undo
12 12
 class EE_Min_Length_Validation_Strategy extends EE_Validation_Strategy_Base
13 13
 {
14 14
 
15
-    protected $_min_length;
16
-
17
-
18
-    public function __construct($validation_error_message = null, $min_length = 0)
19
-    {
20
-        $this->_min_length = $min_length;
21
-        if ($validation_error_message === null) {
22
-            $validation_error_message = sprintf(
23
-                esc_html__('Input is too short. Minimum number of characters is %1$s', 'event_espresso'),
24
-                $min_length
25
-            );
26
-        }
27
-        parent::__construct($validation_error_message);
28
-    }
29
-
30
-
31
-    /**
32
-     * @param $normalized_value
33
-     * @throws EE_Validation_Error
34
-     */
35
-    public function validate($normalized_value)
36
-    {
37
-        if (
38
-            $this->_min_length > 0 && $normalized_value && is_string($normalized_value)
39
-            && strlen($normalized_value)
40
-               < $this->_min_length
41
-        ) {
42
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'minlength');
43
-        }
44
-    }
45
-
46
-
47
-    /**
48
-     * @return array
49
-     */
50
-    public function get_jquery_validation_rule_array(): array
51
-    {
52
-        return [
53
-            'minlength' => $this->_min_length,
54
-            'messages'  => ['minlength' => $this->get_validation_error_message()],
55
-        ];
56
-    }
15
+	protected $_min_length;
16
+
17
+
18
+	public function __construct($validation_error_message = null, $min_length = 0)
19
+	{
20
+		$this->_min_length = $min_length;
21
+		if ($validation_error_message === null) {
22
+			$validation_error_message = sprintf(
23
+				esc_html__('Input is too short. Minimum number of characters is %1$s', 'event_espresso'),
24
+				$min_length
25
+			);
26
+		}
27
+		parent::__construct($validation_error_message);
28
+	}
29
+
30
+
31
+	/**
32
+	 * @param $normalized_value
33
+	 * @throws EE_Validation_Error
34
+	 */
35
+	public function validate($normalized_value)
36
+	{
37
+		if (
38
+			$this->_min_length > 0 && $normalized_value && is_string($normalized_value)
39
+			&& strlen($normalized_value)
40
+			   < $this->_min_length
41
+		) {
42
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'minlength');
43
+		}
44
+	}
45
+
46
+
47
+	/**
48
+	 * @return array
49
+	 */
50
+	public function get_jquery_validation_rule_array(): array
51
+	{
52
+		return [
53
+			'minlength' => $this->_min_length,
54
+			'messages'  => ['minlength' => $this->get_validation_error_message()],
55
+		];
56
+	}
57 57
 }
Please login to merge, or discard this patch.
strategies/validation/EE_Max_Length_Validation_Strategy.strategy.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -12,51 +12,51 @@
 block discarded – undo
12 12
 class EE_Max_Length_Validation_Strategy extends EE_Validation_Strategy_Base
13 13
 {
14 14
 
15
-    protected $_max_length;
16
-
17
-
18
-    public function __construct($validation_error_message = null, $max_length = EE_INF)
19
-    {
20
-        $this->_max_length = $max_length;
21
-        if ($validation_error_message === null) {
22
-            $validation_error_message = sprintf(
23
-                esc_html__('Input is too long. Maximum number of characters is %1$s', 'event_espresso'),
24
-                $max_length
25
-            );
26
-        }
27
-        parent::__construct($validation_error_message);
28
-    }
29
-
30
-
31
-    /**
32
-     * @param $normalized_value
33
-     * @throws EE_Validation_Error
34
-     */
35
-    public function validate($normalized_value)
36
-    {
37
-        if (
38
-            $this->_max_length !== EE_INF && $normalized_value && is_string($normalized_value)
39
-            && strlen(
40
-                   $normalized_value
41
-               ) > $this->_max_length
42
-        ) {
43
-            throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength');
44
-        }
45
-    }
46
-
47
-
48
-    /**
49
-     * @return array
50
-     */
51
-    public function get_jquery_validation_rule_array(): array
52
-    {
53
-        if ($this->_max_length !== EE_INF) {
54
-            return [
55
-                'maxlength' => $this->_max_length,
56
-                'messages'  => ['maxlength' => $this->get_validation_error_message()],
57
-            ];
58
-        } else {
59
-            return [];
60
-        }
61
-    }
15
+	protected $_max_length;
16
+
17
+
18
+	public function __construct($validation_error_message = null, $max_length = EE_INF)
19
+	{
20
+		$this->_max_length = $max_length;
21
+		if ($validation_error_message === null) {
22
+			$validation_error_message = sprintf(
23
+				esc_html__('Input is too long. Maximum number of characters is %1$s', 'event_espresso'),
24
+				$max_length
25
+			);
26
+		}
27
+		parent::__construct($validation_error_message);
28
+	}
29
+
30
+
31
+	/**
32
+	 * @param $normalized_value
33
+	 * @throws EE_Validation_Error
34
+	 */
35
+	public function validate($normalized_value)
36
+	{
37
+		if (
38
+			$this->_max_length !== EE_INF && $normalized_value && is_string($normalized_value)
39
+			&& strlen(
40
+				   $normalized_value
41
+			   ) > $this->_max_length
42
+		) {
43
+			throw new EE_Validation_Error($this->get_validation_error_message(), 'maxlength');
44
+		}
45
+	}
46
+
47
+
48
+	/**
49
+	 * @return array
50
+	 */
51
+	public function get_jquery_validation_rule_array(): array
52
+	{
53
+		if ($this->_max_length !== EE_INF) {
54
+			return [
55
+				'maxlength' => $this->_max_length,
56
+				'messages'  => ['maxlength' => $this->get_validation_error_message()],
57
+			];
58
+		} else {
59
+			return [];
60
+		}
61
+	}
62 62
 }
Please login to merge, or discard this patch.
4_12_0_stages/EE_DMS_4_12_0_Create_Default_Form_Sections.dmsstage.php 2 patches
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -10,94 +10,94 @@  discard block
 block discarded – undo
10 10
 class EE_DMS_4_12_0_Create_Default_Form_Sections extends EE_Data_Migration_Script_Stage_Table
11 11
 {
12 12
 
13
-    // tables
14
-
15
-    /**
16
-     * @var string
17
-     */
18
-    protected $datetime_table;
19
-
20
-    /**
21
-     * @var string
22
-     */
23
-    protected $event_meta_table;
24
-
25
-    /**
26
-     * @var string
27
-     */
28
-    protected $event_question_group_table;
29
-
30
-    /**
31
-     * @var string
32
-     */
33
-    protected $question_group_table;
34
-
35
-    // clauses
36
-
37
-    /**
38
-     * @var string
39
-     */
40
-    protected $event_datetime_join_clause;
41
-
42
-    /**
43
-     * @var string
44
-     */
45
-    protected $event_question_group_join_clause;
46
-
47
-    /**
48
-     * @var string
49
-     */
50
-    protected $group_by_clause;
51
-
52
-
53
-    /**
54
-     * Just initializes the status of the migration EE_DMS_4_12_0_Create_Default_Form_Sections
55
-     */
56
-    public function __construct()
57
-    {
58
-        $this->_pretty_name = esc_html__('Create Default Form Sections', 'event_espresso');
59
-        // tables
60
-        global $wpdb;
61
-        $this->datetime_table             = $wpdb->prefix . 'esp_datetime';
62
-        $this->event_meta_table           = $wpdb->prefix . 'esp_event_meta';
63
-        $this->event_question_group_table = $wpdb->prefix . 'esp_event_question_group';
64
-        $this->question_group_table       = $wpdb->prefix . 'esp_question_group';
65
-        $this->_old_table                 = $this->event_question_group_table;
66
-        // plus $wpdb->posts for events
67
-
68
-        // join clauses
69
-        $this->event_datetime_join_clause       = " JOIN {$this->datetime_table}";
70
-        $this->event_datetime_join_clause       .= " ON {$wpdb->posts}.`ID` = {$this->datetime_table}.`EVT_ID`";
71
-        $this->event_question_group_join_clause = " JOIN {$this->event_question_group_table}";
72
-        $this->event_question_group_join_clause .= " ON {$wpdb->posts}.`ID` = {$this->event_question_group_table}.`EVT_ID`";
73
-
74
-        // where clauses
75
-        $this->_extra_where_sql = " WHERE {$this->datetime_table}.`DTT_EVT_start` > CURRENT_TIMESTAMP";
76
-        $this->_extra_where_sql .= " AND {$wpdb->posts}.`post_type` = 'espresso_events'";
77
-        $this->_extra_where_sql .= " AND {$wpdb->posts}.`post_status` = 'publish'";
78
-        $this->_extra_where_sql .= " AND {$this->datetime_table}.`DTT_deleted` = 0";
79
-        $this->group_by_clause  = " GROUP BY {$wpdb->posts}.`ID`";
80
-        parent::__construct();
81
-    }
82
-
83
-
84
-    /**
85
-     * SELECT `wp_posts`.`ID` FROM `wp_posts`
86
-     * JOIN `wp_esp_datetime` ON `wp_posts`.`ID` = `wp_esp_datetime`.`EVT_ID`
87
-     * WHERE `wp_esp_datetime`.`DTT_EVT_start` > CURRENT_TIMESTAMP
88
-     * AND `wp_posts`.`post_type` = 'espresso_events'
89
-     * AND `wp_posts`.`post_status` = 'publish'
90
-     * AND `wp_esp_datetime`.`DTT_deleted` = 0
91
-     * GROUP BY `wp_posts`.`ID`
92
-     * LIMIT 50;
93
-     *
94
-     * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
95
-     * @global wpdb $wpdb
96
-     */
97
-    protected function getUpcomingEvents(): array
98
-    {
99
-        global $wpdb;
100
-        $SQL = <<<QUERY
13
+	// tables
14
+
15
+	/**
16
+	 * @var string
17
+	 */
18
+	protected $datetime_table;
19
+
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected $event_meta_table;
24
+
25
+	/**
26
+	 * @var string
27
+	 */
28
+	protected $event_question_group_table;
29
+
30
+	/**
31
+	 * @var string
32
+	 */
33
+	protected $question_group_table;
34
+
35
+	// clauses
36
+
37
+	/**
38
+	 * @var string
39
+	 */
40
+	protected $event_datetime_join_clause;
41
+
42
+	/**
43
+	 * @var string
44
+	 */
45
+	protected $event_question_group_join_clause;
46
+
47
+	/**
48
+	 * @var string
49
+	 */
50
+	protected $group_by_clause;
51
+
52
+
53
+	/**
54
+	 * Just initializes the status of the migration EE_DMS_4_12_0_Create_Default_Form_Sections
55
+	 */
56
+	public function __construct()
57
+	{
58
+		$this->_pretty_name = esc_html__('Create Default Form Sections', 'event_espresso');
59
+		// tables
60
+		global $wpdb;
61
+		$this->datetime_table             = $wpdb->prefix . 'esp_datetime';
62
+		$this->event_meta_table           = $wpdb->prefix . 'esp_event_meta';
63
+		$this->event_question_group_table = $wpdb->prefix . 'esp_event_question_group';
64
+		$this->question_group_table       = $wpdb->prefix . 'esp_question_group';
65
+		$this->_old_table                 = $this->event_question_group_table;
66
+		// plus $wpdb->posts for events
67
+
68
+		// join clauses
69
+		$this->event_datetime_join_clause       = " JOIN {$this->datetime_table}";
70
+		$this->event_datetime_join_clause       .= " ON {$wpdb->posts}.`ID` = {$this->datetime_table}.`EVT_ID`";
71
+		$this->event_question_group_join_clause = " JOIN {$this->event_question_group_table}";
72
+		$this->event_question_group_join_clause .= " ON {$wpdb->posts}.`ID` = {$this->event_question_group_table}.`EVT_ID`";
73
+
74
+		// where clauses
75
+		$this->_extra_where_sql = " WHERE {$this->datetime_table}.`DTT_EVT_start` > CURRENT_TIMESTAMP";
76
+		$this->_extra_where_sql .= " AND {$wpdb->posts}.`post_type` = 'espresso_events'";
77
+		$this->_extra_where_sql .= " AND {$wpdb->posts}.`post_status` = 'publish'";
78
+		$this->_extra_where_sql .= " AND {$this->datetime_table}.`DTT_deleted` = 0";
79
+		$this->group_by_clause  = " GROUP BY {$wpdb->posts}.`ID`";
80
+		parent::__construct();
81
+	}
82
+
83
+
84
+	/**
85
+	 * SELECT `wp_posts`.`ID` FROM `wp_posts`
86
+	 * JOIN `wp_esp_datetime` ON `wp_posts`.`ID` = `wp_esp_datetime`.`EVT_ID`
87
+	 * WHERE `wp_esp_datetime`.`DTT_EVT_start` > CURRENT_TIMESTAMP
88
+	 * AND `wp_posts`.`post_type` = 'espresso_events'
89
+	 * AND `wp_posts`.`post_status` = 'publish'
90
+	 * AND `wp_esp_datetime`.`DTT_deleted` = 0
91
+	 * GROUP BY `wp_posts`.`ID`
92
+	 * LIMIT 50;
93
+	 *
94
+	 * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
95
+	 * @global wpdb $wpdb
96
+	 */
97
+	protected function getUpcomingEvents(): array
98
+	{
99
+		global $wpdb;
100
+		$SQL = <<<QUERY
101 101
 SELECT {$wpdb->posts}.`ID` FROM {$wpdb->posts}
102 102
 JOIN {$this->datetime_table} ON {$wpdb->posts}.`ID` = {$this->datetime_table}.`EVT_ID`
103 103
 WHERE {$this->datetime_table}.`DTT_EVT_start` > CURRENT_TIMESTAMP
@@ -106,82 +106,82 @@  discard block
 block discarded – undo
106 106
 AND {$this->datetime_table}.`DTT_deleted` = 0
107 107
 GROUP BY {$wpdb->posts}.`ID`
108 108
 QUERY;
109
-        return $wpdb->get_results($SQL, ARRAY_A);
110
-    }
111
-
112
-
113
-    /**
114
-     * SELECT * FROM `wp_esp_event_question_group`
115
-     * JOIN `wp_esp_question_group` ON `wp_esp_event_question_group`.`QSG_ID` = `wp_esp_question_group`.`QSG_ID`
116
-     * WHERE `wp_esp_event_question_group`.`EVT_ID` IN (1, 2, 3, ...);
117
-     *
118
-     * @param array $EVT_IDs
119
-     * @param int   $limit
120
-     * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
121
-     * @global wpdb $wpdb
122
-     */
123
-    protected function getEventQuestionGroups(array $EVT_IDs, int $limit): array
124
-    {
125
-        // remove invalid event ids
126
-        $EVT_IDs = array_filter($EVT_IDs, 'absint');
127
-        // generate array of same length but filled with placeholders
128
-        $placeholders = array_fill(0, count($EVT_IDs), '%d');
129
-        // convert to string
130
-        $placeholders = implode(', ', $placeholders);
131
-        global $wpdb;
132
-        $SQL  = <<<QUERY
109
+		return $wpdb->get_results($SQL, ARRAY_A);
110
+	}
111
+
112
+
113
+	/**
114
+	 * SELECT * FROM `wp_esp_event_question_group`
115
+	 * JOIN `wp_esp_question_group` ON `wp_esp_event_question_group`.`QSG_ID` = `wp_esp_question_group`.`QSG_ID`
116
+	 * WHERE `wp_esp_event_question_group`.`EVT_ID` IN (1, 2, 3, ...);
117
+	 *
118
+	 * @param array $EVT_IDs
119
+	 * @param int   $limit
120
+	 * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
121
+	 * @global wpdb $wpdb
122
+	 */
123
+	protected function getEventQuestionGroups(array $EVT_IDs, int $limit): array
124
+	{
125
+		// remove invalid event ids
126
+		$EVT_IDs = array_filter($EVT_IDs, 'absint');
127
+		// generate array of same length but filled with placeholders
128
+		$placeholders = array_fill(0, count($EVT_IDs), '%d');
129
+		// convert to string
130
+		$placeholders = implode(', ', $placeholders);
131
+		global $wpdb;
132
+		$SQL  = <<<QUERY
133 133
 SELECT * FROM {$this->event_question_group_table}
134 134
 JOIN {$this->question_group_table} ON {$this->event_question_group_table}.`QSG_ID` = {$this->question_group_table}.`QSG_ID`
135 135
 WHERE {$this->event_question_group_table}.`EVT_ID` IN ({$placeholders})
136 136
 LIMIT %d;
137 137
 QUERY;
138
-        $args = $EVT_IDs;
139
-        array_push($args, $limit);
140
-        return $wpdb->get_results($wpdb->prepare($SQL, $args), ARRAY_A);
141
-    }
142
-
143
-
144
-    /**
145
-     * SELECT `wp_posts`.`ID`, `wp_esp_event_question_group`.`EQG_primary`, `wp_esp_event_question_group`.`EQG_additional`
146
-     * FROM `wp_posts`,
147
-     * JOIN `wp_esp_event_question_group` ON `wp_posts`.`ID` = `wp_esp_event_question_group`.`EVT_ID`
148
-     * JOIN `wp_esp_datetime` ON `wp_posts`.`ID` = `wp_esp_datetime`.`EVT_ID`
149
-     * WHERE `wp_esp_datetime`.`DTT_EVT_start` > CURRENT_TIMESTAMP
150
-     * AND `wp_posts`.`post_type` = 'espresso_events'
151
-     * AND `wp_posts`.`post_status` = 'publish'
152
-     * AND `wp_esp_datetime`.`DTT_deleted` = 0
153
-     * GROUP BY `wp_posts`.`ID`;
154
-     *
155
-     * @param int   $limit
156
-     * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
157
-     * @global wpdb $wpdb
158
-     */
159
-    protected function _get_rows($limit)
160
-    {
161
-        global $wpdb;
162
-        $query = "SELECT {$wpdb->posts}.`ID`";
163
-        $query .= ", {$wpdb->event_question_group_table}.`EQG_primary`";
164
-        $query .= ", {$wpdb->event_question_group_table}.`EQG_additional`";
165
-        $query .= " FROM {$wpdb->posts}";
166
-        $query .= $this->event_datetime_join_clause;
167
-        $query .= $this->event_question_group_join_clause;
168
-        $query .= $this->_extra_where_sql;
169
-        $query .= $this->group_by_clause;
170
-        $query .= ' LIMIT %d';
171
-        return $wpdb->get_results($wpdb->prepare($query, $limit), ARRAY_A);
172
-    }
173
-
174
-
175
-    /**
176
-     * Removes the duplicate event_question_group rows that only had EQG_primary=0. Now we just have one row
177
-     * joining event-to-question-groups with two columns: EQG_primary and EQG_additional, indicating which question
178
-     * groups apply to which category of registrant.
179
-     *
180
-     * @param array $old_row an associative array where keys are column names and values are their values.
181
-     * @return void
182
-     */
183
-    protected function _migrate_old_row($old_row)
184
-    {
185
-        \EEH_Debug_Tools::printr($old_row, '$old_row', __FILE__, __LINE__);
186
-    }
138
+		$args = $EVT_IDs;
139
+		array_push($args, $limit);
140
+		return $wpdb->get_results($wpdb->prepare($SQL, $args), ARRAY_A);
141
+	}
142
+
143
+
144
+	/**
145
+	 * SELECT `wp_posts`.`ID`, `wp_esp_event_question_group`.`EQG_primary`, `wp_esp_event_question_group`.`EQG_additional`
146
+	 * FROM `wp_posts`,
147
+	 * JOIN `wp_esp_event_question_group` ON `wp_posts`.`ID` = `wp_esp_event_question_group`.`EVT_ID`
148
+	 * JOIN `wp_esp_datetime` ON `wp_posts`.`ID` = `wp_esp_datetime`.`EVT_ID`
149
+	 * WHERE `wp_esp_datetime`.`DTT_EVT_start` > CURRENT_TIMESTAMP
150
+	 * AND `wp_posts`.`post_type` = 'espresso_events'
151
+	 * AND `wp_posts`.`post_status` = 'publish'
152
+	 * AND `wp_esp_datetime`.`DTT_deleted` = 0
153
+	 * GROUP BY `wp_posts`.`ID`;
154
+	 *
155
+	 * @param int   $limit
156
+	 * @return array of arrays like $wpdb->get_results($sql, ARRAY_A)
157
+	 * @global wpdb $wpdb
158
+	 */
159
+	protected function _get_rows($limit)
160
+	{
161
+		global $wpdb;
162
+		$query = "SELECT {$wpdb->posts}.`ID`";
163
+		$query .= ", {$wpdb->event_question_group_table}.`EQG_primary`";
164
+		$query .= ", {$wpdb->event_question_group_table}.`EQG_additional`";
165
+		$query .= " FROM {$wpdb->posts}";
166
+		$query .= $this->event_datetime_join_clause;
167
+		$query .= $this->event_question_group_join_clause;
168
+		$query .= $this->_extra_where_sql;
169
+		$query .= $this->group_by_clause;
170
+		$query .= ' LIMIT %d';
171
+		return $wpdb->get_results($wpdb->prepare($query, $limit), ARRAY_A);
172
+	}
173
+
174
+
175
+	/**
176
+	 * Removes the duplicate event_question_group rows that only had EQG_primary=0. Now we just have one row
177
+	 * joining event-to-question-groups with two columns: EQG_primary and EQG_additional, indicating which question
178
+	 * groups apply to which category of registrant.
179
+	 *
180
+	 * @param array $old_row an associative array where keys are column names and values are their values.
181
+	 * @return void
182
+	 */
183
+	protected function _migrate_old_row($old_row)
184
+	{
185
+		\EEH_Debug_Tools::printr($old_row, '$old_row', __FILE__, __LINE__);
186
+	}
187 187
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
         $this->_pretty_name = esc_html__('Create Default Form Sections', 'event_espresso');
59 59
         // tables
60 60
         global $wpdb;
61
-        $this->datetime_table             = $wpdb->prefix . 'esp_datetime';
62
-        $this->event_meta_table           = $wpdb->prefix . 'esp_event_meta';
63
-        $this->event_question_group_table = $wpdb->prefix . 'esp_event_question_group';
64
-        $this->question_group_table       = $wpdb->prefix . 'esp_question_group';
61
+        $this->datetime_table             = $wpdb->prefix.'esp_datetime';
62
+        $this->event_meta_table           = $wpdb->prefix.'esp_event_meta';
63
+        $this->event_question_group_table = $wpdb->prefix.'esp_event_question_group';
64
+        $this->question_group_table       = $wpdb->prefix.'esp_question_group';
65 65
         $this->_old_table                 = $this->event_question_group_table;
66 66
         // plus $wpdb->posts for events
67 67
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $this->_extra_where_sql .= " AND {$wpdb->posts}.`post_type` = 'espresso_events'";
77 77
         $this->_extra_where_sql .= " AND {$wpdb->posts}.`post_status` = 'publish'";
78 78
         $this->_extra_where_sql .= " AND {$this->datetime_table}.`DTT_deleted` = 0";
79
-        $this->group_by_clause  = " GROUP BY {$wpdb->posts}.`ID`";
79
+        $this->group_by_clause = " GROUP BY {$wpdb->posts}.`ID`";
80 80
         parent::__construct();
81 81
     }
82 82
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
         // convert to string
130 130
         $placeholders = implode(', ', $placeholders);
131 131
         global $wpdb;
132
-        $SQL  = <<<QUERY
132
+        $SQL = <<<QUERY
133 133
 SELECT * FROM {$this->event_question_group_table}
134 134
 JOIN {$this->question_group_table} ON {$this->event_question_group_table}.`QSG_ID` = {$this->question_group_table}.`QSG_ID`
135 135
 WHERE {$this->event_question_group_table}.`EVT_ID` IN ({$placeholders})
Please login to merge, or discard this patch.
attendee_information/EE_SPCO_Reg_Step_Attendee_Information.class.php 2 patches
Indentation   +461 added lines, -461 removed lines patch added patch discarded remove patch
@@ -20,465 +20,465 @@
 block discarded – undo
20 20
  */
21 21
 class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step
22 22
 {
23
-    /**
24
-     * @var RegFormFactory
25
-     */
26
-    protected $reg_form_factory;
27
-
28
-    /**
29
-     * @var string
30
-     */
31
-    protected $reg_form_factory_version = RegFormFactory::VERSION_2;
32
-
33
-
34
-    /**
35
-     *    class constructor
36
-     *
37
-     * @access    public
38
-     * @param EE_Checkout $checkout
39
-     */
40
-    public function __construct(EE_Checkout $checkout)
41
-    {
42
-        $this->_slug    = 'attendee_information';
43
-        $this->_name    = esc_html__('Attendee Information', 'event_espresso');
44
-        $this->checkout = $checkout;
45
-        $this->_reset_success_message();
46
-        $this->set_instructions(
47
-            esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
48
-        );
49
-        $this->reg_form_factory = new RegFormFactory($this->reg_form_factory_version);
50
-    }
51
-
52
-
53
-    public function translate_js_strings()
54
-    {
55
-        EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
56
-            ' is a required question.',
57
-            'event_espresso'
58
-        );
59
-        EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
60
-            ' is a required question. Please enter a value for at least one of the options.',
61
-            'event_espresso'
62
-        );
63
-        EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
64
-            'Please answer all required questions correctly before proceeding.',
65
-            'event_espresso'
66
-        );
67
-        EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
68
-            esc_html_x(
69
-                'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
70
-                'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
71
-                'event_espresso'
72
-            ),
73
-            '<br/>'
74
-        );
75
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
76
-            'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
77
-            'event_espresso'
78
-        );
79
-        EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
80
-            'You must enter a valid email address.',
81
-            'event_espresso'
82
-        );
83
-        EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
84
-            'You must enter a valid email address and answer all other required questions before you can proceed.',
85
-            'event_espresso'
86
-        );
87
-    }
88
-
89
-
90
-    public function enqueue_styles_and_scripts()
91
-    {
92
-    }
93
-
94
-
95
-    /**
96
-     * @return boolean
97
-     */
98
-    public function initialize_reg_step(): bool
99
-    {
100
-        return true;
101
-    }
102
-
103
-
104
-    /**
105
-     * @return FormSectionProperInterface
106
-     * @throws EE_Error
107
-     * @throws ReflectionException
108
-     */
109
-    public function generate_reg_form(): FormSectionProperInterface
110
-    {
111
-        return $this->reg_form_factory->getRegForm([$this]);
112
-    }
113
-
114
-
115
-    /**
116
-     * looking for hooks?
117
-     * this method has been replaced by:
118
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm()
119
-     *
120
-     * @deprecated   $VID:$
121
-     */
122
-    private function _registrations_reg_form()
123
-    {
124
-    }
125
-
126
-
127
-    /**
128
-     * looking for hooks?
129
-     * this method has been replaced by:
130
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput()
131
-     *
132
-     * @deprecated   $VID:$
133
-     */
134
-    private function _additional_attendee_reg_info_input()
135
-    {
136
-    }
137
-
138
-
139
-    /**
140
-     * looking for hooks?
141
-     * this method has been replaced by:
142
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm()
143
-     *
144
-     * @deprecated   $VID:$
145
-     */
146
-    private function _question_group_reg_form()
147
-    {
148
-    }
149
-
150
-
151
-    /**
152
-     * looking for hooks?
153
-     * this method has been replaced by:
154
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader()
155
-     *
156
-     * @deprecated   $VID:$
157
-     */
158
-    private function _question_group_header()
159
-    {
160
-    }
161
-
162
-
163
-    /**
164
-     * looking for hooks?
165
-     * this method has been replaced by:
166
-     * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
167
-     *
168
-     * @deprecated   $VID:$
169
-     */
170
-    private function _copy_attendee_info_form()
171
-    {
172
-    }
173
-
174
-
175
-    /**
176
-     * looking for hooks?
177
-     * this method has been replaced by:
178
-     * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm
179
-     *
180
-     * @deprecated   $VID:$
181
-     */
182
-    private function _auto_copy_attendee_info()
183
-    {
184
-    }
185
-
186
-
187
-    /**
188
-     * looking for hooks?
189
-     * this method has been replaced by:
190
-     * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
191
-     *
192
-     * @deprecated   $VID:$
193
-     */
194
-    private function _copy_attendee_info_inputs()
195
-    {
196
-    }
197
-
198
-
199
-    /**
200
-     * looking for hooks?
201
-     * this method has been replaced by:
202
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs()
203
-     *
204
-     * @deprecated   $VID:$
205
-     */
206
-    private function _additional_primary_registrant_inputs()
207
-    {
208
-    }
209
-
210
-
211
-    /**
212
-     * looking for hooks?
213
-     * this method has been replaced by:
214
-     * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create()
215
-     *
216
-     * @param EE_Registration $registration
217
-     * @param EE_Question     $question
218
-     * @return EE_Form_Input_Base
219
-     * @throws EE_Error
220
-     * @throws ReflectionException
221
-     * @deprecated   $VID:$
222
-     */
223
-    public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base
224
-    {
225
-        /** @var RegFormQuestionFactory $reg_form_question_factory */
226
-        $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class);
227
-        return $reg_form_question_factory->create($registration, $question);
228
-    }
229
-
230
-
231
-    /**
232
-     * looking for hooks?
233
-     * this method has been replaced by:
234
-     * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput()
235
-     *
236
-     * @deprecated   $VID:$
237
-     */
238
-    private function _generate_question_input()
239
-    {
240
-    }
241
-
242
-
243
-    /**
244
-     * looking for hooks?
245
-     * this method has been replaced by:
246
-     * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput()
247
-     *
248
-     * @param array|null           $countries_list
249
-     * @param EE_Question|null     $question
250
-     * @param EE_Registration|null $registration
251
-     * @param EE_Answer|null       $answer
252
-     * @return array 2d keys are country IDs, values are their names
253
-     * @throws EE_Error
254
-     * @throws ReflectionException
255
-     * @deprecated   $VID:$
256
-     */
257
-    public function use_cached_countries_for_form_input(
258
-        array $countries_list = null,
259
-        EE_Question $question = null,
260
-        EE_Registration $registration = null,
261
-        EE_Answer $answer = null
262
-    ): array {
263
-        /** @var CountryOptions $country_options */
264
-        $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]);
265
-        return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer);
266
-    }
267
-
268
-
269
-    /**
270
-     * looking for hooks?
271
-     * this method has been replaced by:
272
-     * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput()
273
-     *
274
-     * @param array|null           $states_list
275
-     * @param EE_Question|null     $question
276
-     * @param EE_Registration|null $registration
277
-     * @param EE_Answer|null       $answer
278
-     * @return array 2d keys are state IDs, values are their names
279
-     * @throws EE_Error
280
-     * @throws ReflectionException
281
-     * @deprecated   $VID:$
282
-     */
283
-    public function use_cached_states_for_form_input(
284
-        array $states_list = null,
285
-        EE_Question $question = null,
286
-        EE_Registration $registration = null,
287
-        EE_Answer $answer = null
288
-    ): array {
289
-        /** @var StateOptions $state_options */
290
-        $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]);
291
-        return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer);
292
-    }
293
-
294
-
295
-    /********************************************************************************************************/
296
-    /****************************************  PROCESS REG STEP  ****************************************/
297
-    /********************************************************************************************************/
298
-
299
-
300
-    /**
301
-     * @return bool
302
-     * @throws EE_Error
303
-     * @throws InvalidArgumentException
304
-     * @throws ReflectionException
305
-     * @throws RuntimeException
306
-     * @throws InvalidDataTypeException
307
-     * @throws InvalidInterfaceException
308
-     */
309
-    public function process_reg_step(): bool
310
-    {
311
-        // grab validated data from form
312
-        $valid_data = $this->checkout->current_step->valid_data();
313
-        // if we don't have any $valid_data then something went TERRIBLY WRONG !!!
314
-        if (empty($valid_data)) {
315
-            return $this->inValidDataError();
316
-        }
317
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
318
-            return $this->inValidTransactionError();
319
-        }
320
-        // get cached registrations
321
-        $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
322
-        // verify we got the goods
323
-        if (empty($registrations)) {
324
-            return $this->noRegistrationsError();
325
-        }
326
-        $reg_form_handler = $this->reg_form_factory->getRegFormHandler($this->checkout);
327
-        // extract attendee info from form data and save to model objects
328
-        if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
329
-            // return immediately if the previous step exited early due to errors
330
-            return false;
331
-        }
332
-        // if first pass thru SPCO,
333
-        // then let's check processed registrations against the total number of tickets in the cart
334
-        $registrations_processed = $reg_form_handler->attendeeCount();
335
-        if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
336
-            return $this->registrationProcessingError($registrations_processed);
337
-        }
338
-        // mark this reg step as completed
339
-        $this->set_completed();
340
-        $this->_set_success_message(
341
-            esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
342
-        );
343
-        // do action in case a plugin wants to do something with the data submitted in step 1.
344
-        // passes EE_Single_Page_Checkout, and it's posted data
345
-        do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
346
-        return true;
347
-    }
348
-
349
-
350
-    /**
351
-     * @return bool
352
-     * @since   $VID:$
353
-     */
354
-    private function inValidDataError(): bool
355
-    {
356
-        EE_Error::add_error(
357
-            esc_html__('No valid question responses were received.', 'event_espresso'),
358
-            __FILE__,
359
-            __FUNCTION__,
360
-            __LINE__
361
-        );
362
-        return false;
363
-    }
364
-
365
-
366
-    /**
367
-     * @return bool
368
-     * @since   $VID:$
369
-     */
370
-    private function inValidTransactionError(): bool
371
-    {
372
-        EE_Error::add_error(
373
-            esc_html__(
374
-                'A valid transaction could not be initiated for processing your registrations.',
375
-                'event_espresso'
376
-            ),
377
-            __FILE__,
378
-            __FUNCTION__,
379
-            __LINE__
380
-        );
381
-        return false;
382
-    }
383
-
384
-
385
-    /**
386
-     * @return bool
387
-     * @since   $VID:$
388
-     */
389
-    private function noRegistrationsError(): bool
390
-    {
391
-        // combine the old translated string with a new one, in order to not break translations
392
-        $error_message = esc_html__(
393
-            'Your form data could not be applied to any valid registrations.',
394
-            'event_espresso'
395
-        );
396
-        $error_message .= sprintf(
397
-            esc_html_x(
398
-                '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.',
399
-                '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
400
-                'event_espresso'
401
-            ),
402
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
403
-            '</a>',
404
-            '<br />'
405
-        );
406
-        EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__);
407
-        return false;
408
-    }
409
-
410
-
411
-    /**
412
-     * @param int $registrations_processed
413
-     * @return bool
414
-     * @since   $VID:$
415
-     */
416
-    private function registrationProcessingError(int $registrations_processed): bool
417
-    {
418
-        // generate a correctly translated string for all possible singular/plural combinations
419
-        if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
420
-            $error_msg = sprintf(
421
-                esc_html_x(
422
-                    'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
423
-                    'There was 1 ticket in the Event Queue, but 2 registrations were processed',
424
-                    'event_espresso'
425
-                ),
426
-                $this->checkout->total_ticket_count,
427
-                $registrations_processed
428
-            );
429
-        } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
430
-            $error_msg = sprintf(
431
-                esc_html_x(
432
-                    'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
433
-                    'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed',
434
-                    'event_espresso'
435
-                ),
436
-                $this->checkout->total_ticket_count,
437
-                $registrations_processed
438
-            );
439
-        } else {
440
-            $error_msg = sprintf(
441
-                esc_html__(
442
-                    'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed',
443
-                    'event_espresso'
444
-                ),
445
-                $this->checkout->total_ticket_count,
446
-                $registrations_processed
447
-            );
448
-        }
449
-        EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
450
-        return false;
451
-    }
452
-
453
-
454
-    /**
455
-     *    update_reg_step
456
-     *    this is the final step after a user  revisits the site to edit their attendee information
457
-     *    this gets called AFTER the process_reg_step() method above
458
-     *
459
-     * @return bool
460
-     * @throws EE_Error
461
-     * @throws InvalidArgumentException
462
-     * @throws ReflectionException
463
-     * @throws RuntimeException
464
-     * @throws InvalidDataTypeException
465
-     * @throws InvalidInterfaceException
466
-     */
467
-    public function update_reg_step(): bool
468
-    {
469
-        // save everything
470
-        if ($this->process_reg_step()) {
471
-            $this->checkout->redirect     = true;
472
-            $this->checkout->redirect_url = add_query_arg(
473
-                [
474
-                    'e_reg_url_link' => $this->checkout->reg_url_link,
475
-                    'revisit'        => true,
476
-                ],
477
-                $this->checkout->thank_you_page_url
478
-            );
479
-            $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
480
-            return true;
481
-        }
482
-        return false;
483
-    }
23
+	/**
24
+	 * @var RegFormFactory
25
+	 */
26
+	protected $reg_form_factory;
27
+
28
+	/**
29
+	 * @var string
30
+	 */
31
+	protected $reg_form_factory_version = RegFormFactory::VERSION_2;
32
+
33
+
34
+	/**
35
+	 *    class constructor
36
+	 *
37
+	 * @access    public
38
+	 * @param EE_Checkout $checkout
39
+	 */
40
+	public function __construct(EE_Checkout $checkout)
41
+	{
42
+		$this->_slug    = 'attendee_information';
43
+		$this->_name    = esc_html__('Attendee Information', 'event_espresso');
44
+		$this->checkout = $checkout;
45
+		$this->_reset_success_message();
46
+		$this->set_instructions(
47
+			esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso')
48
+		);
49
+		$this->reg_form_factory = new RegFormFactory($this->reg_form_factory_version);
50
+	}
51
+
52
+
53
+	public function translate_js_strings()
54
+	{
55
+		EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
56
+			' is a required question.',
57
+			'event_espresso'
58
+		);
59
+		EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
60
+			' is a required question. Please enter a value for at least one of the options.',
61
+			'event_espresso'
62
+		);
63
+		EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__(
64
+			'Please answer all required questions correctly before proceeding.',
65
+			'event_espresso'
66
+		);
67
+		EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
68
+			esc_html_x(
69
+				'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
70
+				'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
71
+				'event_espresso'
72
+			),
73
+			'<br/>'
74
+		);
75
+		EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
76
+			'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
77
+			'event_espresso'
78
+		);
79
+		EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
80
+			'You must enter a valid email address.',
81
+			'event_espresso'
82
+		);
83
+		EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__(
84
+			'You must enter a valid email address and answer all other required questions before you can proceed.',
85
+			'event_espresso'
86
+		);
87
+	}
88
+
89
+
90
+	public function enqueue_styles_and_scripts()
91
+	{
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return boolean
97
+	 */
98
+	public function initialize_reg_step(): bool
99
+	{
100
+		return true;
101
+	}
102
+
103
+
104
+	/**
105
+	 * @return FormSectionProperInterface
106
+	 * @throws EE_Error
107
+	 * @throws ReflectionException
108
+	 */
109
+	public function generate_reg_form(): FormSectionProperInterface
110
+	{
111
+		return $this->reg_form_factory->getRegForm([$this]);
112
+	}
113
+
114
+
115
+	/**
116
+	 * looking for hooks?
117
+	 * this method has been replaced by:
118
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm()
119
+	 *
120
+	 * @deprecated   $VID:$
121
+	 */
122
+	private function _registrations_reg_form()
123
+	{
124
+	}
125
+
126
+
127
+	/**
128
+	 * looking for hooks?
129
+	 * this method has been replaced by:
130
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput()
131
+	 *
132
+	 * @deprecated   $VID:$
133
+	 */
134
+	private function _additional_attendee_reg_info_input()
135
+	{
136
+	}
137
+
138
+
139
+	/**
140
+	 * looking for hooks?
141
+	 * this method has been replaced by:
142
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm()
143
+	 *
144
+	 * @deprecated   $VID:$
145
+	 */
146
+	private function _question_group_reg_form()
147
+	{
148
+	}
149
+
150
+
151
+	/**
152
+	 * looking for hooks?
153
+	 * this method has been replaced by:
154
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader()
155
+	 *
156
+	 * @deprecated   $VID:$
157
+	 */
158
+	private function _question_group_header()
159
+	{
160
+	}
161
+
162
+
163
+	/**
164
+	 * looking for hooks?
165
+	 * this method has been replaced by:
166
+	 * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
167
+	 *
168
+	 * @deprecated   $VID:$
169
+	 */
170
+	private function _copy_attendee_info_form()
171
+	{
172
+	}
173
+
174
+
175
+	/**
176
+	 * looking for hooks?
177
+	 * this method has been replaced by:
178
+	 * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm
179
+	 *
180
+	 * @deprecated   $VID:$
181
+	 */
182
+	private function _auto_copy_attendee_info()
183
+	{
184
+	}
185
+
186
+
187
+	/**
188
+	 * looking for hooks?
189
+	 * this method has been replaced by:
190
+	 * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm
191
+	 *
192
+	 * @deprecated   $VID:$
193
+	 */
194
+	private function _copy_attendee_info_inputs()
195
+	{
196
+	}
197
+
198
+
199
+	/**
200
+	 * looking for hooks?
201
+	 * this method has been replaced by:
202
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs()
203
+	 *
204
+	 * @deprecated   $VID:$
205
+	 */
206
+	private function _additional_primary_registrant_inputs()
207
+	{
208
+	}
209
+
210
+
211
+	/**
212
+	 * looking for hooks?
213
+	 * this method has been replaced by:
214
+	 * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create()
215
+	 *
216
+	 * @param EE_Registration $registration
217
+	 * @param EE_Question     $question
218
+	 * @return EE_Form_Input_Base
219
+	 * @throws EE_Error
220
+	 * @throws ReflectionException
221
+	 * @deprecated   $VID:$
222
+	 */
223
+	public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base
224
+	{
225
+		/** @var RegFormQuestionFactory $reg_form_question_factory */
226
+		$reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class);
227
+		return $reg_form_question_factory->create($registration, $question);
228
+	}
229
+
230
+
231
+	/**
232
+	 * looking for hooks?
233
+	 * this method has been replaced by:
234
+	 * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput()
235
+	 *
236
+	 * @deprecated   $VID:$
237
+	 */
238
+	private function _generate_question_input()
239
+	{
240
+	}
241
+
242
+
243
+	/**
244
+	 * looking for hooks?
245
+	 * this method has been replaced by:
246
+	 * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput()
247
+	 *
248
+	 * @param array|null           $countries_list
249
+	 * @param EE_Question|null     $question
250
+	 * @param EE_Registration|null $registration
251
+	 * @param EE_Answer|null       $answer
252
+	 * @return array 2d keys are country IDs, values are their names
253
+	 * @throws EE_Error
254
+	 * @throws ReflectionException
255
+	 * @deprecated   $VID:$
256
+	 */
257
+	public function use_cached_countries_for_form_input(
258
+		array $countries_list = null,
259
+		EE_Question $question = null,
260
+		EE_Registration $registration = null,
261
+		EE_Answer $answer = null
262
+	): array {
263
+		/** @var CountryOptions $country_options */
264
+		$country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]);
265
+		return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer);
266
+	}
267
+
268
+
269
+	/**
270
+	 * looking for hooks?
271
+	 * this method has been replaced by:
272
+	 * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput()
273
+	 *
274
+	 * @param array|null           $states_list
275
+	 * @param EE_Question|null     $question
276
+	 * @param EE_Registration|null $registration
277
+	 * @param EE_Answer|null       $answer
278
+	 * @return array 2d keys are state IDs, values are their names
279
+	 * @throws EE_Error
280
+	 * @throws ReflectionException
281
+	 * @deprecated   $VID:$
282
+	 */
283
+	public function use_cached_states_for_form_input(
284
+		array $states_list = null,
285
+		EE_Question $question = null,
286
+		EE_Registration $registration = null,
287
+		EE_Answer $answer = null
288
+	): array {
289
+		/** @var StateOptions $state_options */
290
+		$state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]);
291
+		return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer);
292
+	}
293
+
294
+
295
+	/********************************************************************************************************/
296
+	/****************************************  PROCESS REG STEP  ****************************************/
297
+	/********************************************************************************************************/
298
+
299
+
300
+	/**
301
+	 * @return bool
302
+	 * @throws EE_Error
303
+	 * @throws InvalidArgumentException
304
+	 * @throws ReflectionException
305
+	 * @throws RuntimeException
306
+	 * @throws InvalidDataTypeException
307
+	 * @throws InvalidInterfaceException
308
+	 */
309
+	public function process_reg_step(): bool
310
+	{
311
+		// grab validated data from form
312
+		$valid_data = $this->checkout->current_step->valid_data();
313
+		// if we don't have any $valid_data then something went TERRIBLY WRONG !!!
314
+		if (empty($valid_data)) {
315
+			return $this->inValidDataError();
316
+		}
317
+		if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
318
+			return $this->inValidTransactionError();
319
+		}
320
+		// get cached registrations
321
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
322
+		// verify we got the goods
323
+		if (empty($registrations)) {
324
+			return $this->noRegistrationsError();
325
+		}
326
+		$reg_form_handler = $this->reg_form_factory->getRegFormHandler($this->checkout);
327
+		// extract attendee info from form data and save to model objects
328
+		if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
329
+			// return immediately if the previous step exited early due to errors
330
+			return false;
331
+		}
332
+		// if first pass thru SPCO,
333
+		// then let's check processed registrations against the total number of tickets in the cart
334
+		$registrations_processed = $reg_form_handler->attendeeCount();
335
+		if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
336
+			return $this->registrationProcessingError($registrations_processed);
337
+		}
338
+		// mark this reg step as completed
339
+		$this->set_completed();
340
+		$this->_set_success_message(
341
+			esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso')
342
+		);
343
+		// do action in case a plugin wants to do something with the data submitted in step 1.
344
+		// passes EE_Single_Page_Checkout, and it's posted data
345
+		do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data);
346
+		return true;
347
+	}
348
+
349
+
350
+	/**
351
+	 * @return bool
352
+	 * @since   $VID:$
353
+	 */
354
+	private function inValidDataError(): bool
355
+	{
356
+		EE_Error::add_error(
357
+			esc_html__('No valid question responses were received.', 'event_espresso'),
358
+			__FILE__,
359
+			__FUNCTION__,
360
+			__LINE__
361
+		);
362
+		return false;
363
+	}
364
+
365
+
366
+	/**
367
+	 * @return bool
368
+	 * @since   $VID:$
369
+	 */
370
+	private function inValidTransactionError(): bool
371
+	{
372
+		EE_Error::add_error(
373
+			esc_html__(
374
+				'A valid transaction could not be initiated for processing your registrations.',
375
+				'event_espresso'
376
+			),
377
+			__FILE__,
378
+			__FUNCTION__,
379
+			__LINE__
380
+		);
381
+		return false;
382
+	}
383
+
384
+
385
+	/**
386
+	 * @return bool
387
+	 * @since   $VID:$
388
+	 */
389
+	private function noRegistrationsError(): bool
390
+	{
391
+		// combine the old translated string with a new one, in order to not break translations
392
+		$error_message = esc_html__(
393
+			'Your form data could not be applied to any valid registrations.',
394
+			'event_espresso'
395
+		);
396
+		$error_message .= sprintf(
397
+			esc_html_x(
398
+				'%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.',
399
+				'(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
400
+				'event_espresso'
401
+			),
402
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" >',
403
+			'</a>',
404
+			'<br />'
405
+		);
406
+		EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__);
407
+		return false;
408
+	}
409
+
410
+
411
+	/**
412
+	 * @param int $registrations_processed
413
+	 * @return bool
414
+	 * @since   $VID:$
415
+	 */
416
+	private function registrationProcessingError(int $registrations_processed): bool
417
+	{
418
+		// generate a correctly translated string for all possible singular/plural combinations
419
+		if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) {
420
+			$error_msg = sprintf(
421
+				esc_html_x(
422
+					'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed',
423
+					'There was 1 ticket in the Event Queue, but 2 registrations were processed',
424
+					'event_espresso'
425
+				),
426
+				$this->checkout->total_ticket_count,
427
+				$registrations_processed
428
+			);
429
+		} elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) {
430
+			$error_msg = sprintf(
431
+				esc_html_x(
432
+					'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed',
433
+					'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed',
434
+					'event_espresso'
435
+				),
436
+				$this->checkout->total_ticket_count,
437
+				$registrations_processed
438
+			);
439
+		} else {
440
+			$error_msg = sprintf(
441
+				esc_html__(
442
+					'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed',
443
+					'event_espresso'
444
+				),
445
+				$this->checkout->total_ticket_count,
446
+				$registrations_processed
447
+			);
448
+		}
449
+		EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
450
+		return false;
451
+	}
452
+
453
+
454
+	/**
455
+	 *    update_reg_step
456
+	 *    this is the final step after a user  revisits the site to edit their attendee information
457
+	 *    this gets called AFTER the process_reg_step() method above
458
+	 *
459
+	 * @return bool
460
+	 * @throws EE_Error
461
+	 * @throws InvalidArgumentException
462
+	 * @throws ReflectionException
463
+	 * @throws RuntimeException
464
+	 * @throws InvalidDataTypeException
465
+	 * @throws InvalidInterfaceException
466
+	 */
467
+	public function update_reg_step(): bool
468
+	{
469
+		// save everything
470
+		if ($this->process_reg_step()) {
471
+			$this->checkout->redirect     = true;
472
+			$this->checkout->redirect_url = add_query_arg(
473
+				[
474
+					'e_reg_url_link' => $this->checkout->reg_url_link,
475
+					'revisit'        => true,
476
+				],
477
+				$this->checkout->thank_you_page_url
478
+			);
479
+			$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
480
+			return true;
481
+		}
482
+		return false;
483
+	}
484 484
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 
53 53
     public function translate_js_strings()
54 54
     {
55
-        EE_Registry::$i18n_js_strings['required_field']            = esc_html__(
55
+        EE_Registry::$i18n_js_strings['required_field'] = esc_html__(
56 56
             ' is a required question.',
57 57
             'event_espresso'
58 58
         );
59
-        EE_Registry::$i18n_js_strings['required_multi_field']      = esc_html__(
59
+        EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__(
60 60
             ' is a required question. Please enter a value for at least one of the options.',
61 61
             'event_espresso'
62 62
         );
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             'Please answer all required questions correctly before proceeding.',
65 65
             'event_espresso'
66 66
         );
67
-        EE_Registry::$i18n_js_strings['attendee_info_copied']      = sprintf(
67
+        EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf(
68 68
             esc_html_x(
69 69
                 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.',
70 70
                 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.',
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
             ),
73 73
             '<br/>'
74 74
         );
75
-        EE_Registry::$i18n_js_strings['attendee_info_copy_error']  = esc_html__(
75
+        EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__(
76 76
             'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.',
77 77
             'event_espresso'
78 78
         );
79
-        EE_Registry::$i18n_js_strings['enter_valid_email']         = esc_html__(
79
+        EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__(
80 80
             'You must enter a valid email address.',
81 81
             'event_espresso'
82 82
         );
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         if (empty($valid_data)) {
315 315
             return $this->inValidDataError();
316 316
         }
317
-        if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
317
+        if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) {
318 318
             return $this->inValidTransactionError();
319 319
         }
320 320
         // get cached registrations
@@ -325,14 +325,14 @@  discard block
 block discarded – undo
325 325
         }
326 326
         $reg_form_handler = $this->reg_form_factory->getRegFormHandler($this->checkout);
327 327
         // extract attendee info from form data and save to model objects
328
-        if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
328
+        if ( ! $reg_form_handler->processRegistrations($registrations, $valid_data)) {
329 329
             // return immediately if the previous step exited early due to errors
330 330
             return false;
331 331
         }
332 332
         // if first pass thru SPCO,
333 333
         // then let's check processed registrations against the total number of tickets in the cart
334 334
         $registrations_processed = $reg_form_handler->attendeeCount();
335
-        if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
335
+        if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) {
336 336
             return $this->registrationProcessingError($registrations_processed);
337 337
         }
338 338
         // mark this reg step as completed
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
                 '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.',
400 400
                 'event_espresso'
401 401
             ),
402
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" >',
402
+            '<a href="'.get_post_type_archive_link('espresso_events').'" >',
403 403
             '</a>',
404 404
             '<br />'
405 405
         );
Please login to merge, or discard this patch.