Completed
Branch master (d65695)
by
unknown
04:25
created
data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_shortcodes.dmsstage.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
     {
19 19
         $new_post_content = $this->_change_event_list_shortcode($old_row['post_content']);
20 20
         global $wpdb;
21
-        $wpdb->query($wpdb->prepare("UPDATE " . $this->_old_table . " SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID']));
21
+        $wpdb->query($wpdb->prepare("UPDATE ".$this->_old_table." SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID']));
22 22
     }
23 23
 
24 24
     /**
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     public function _count_records_to_migrate()
49 49
     {
50 50
         global $wpdb;
51
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM " . $this->_old_table . $this->_sql_to_only_select_non_drafts());
51
+        $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table.$this->_sql_to_only_select_non_drafts());
52 52
         return $count;
53 53
     }
54 54
 
Please login to merge, or discard this patch.
Indentation   +47 added lines, -48 removed lines patch added patch discarded remove patch
@@ -2,58 +2,57 @@
 block discarded – undo
2 2
 
3 3
 /**
4 4
  * Goes through all the posts and pages, and converts old shortcodes to new ones
5
-
6
-*/
5
+ */
7 6
 
8 7
 class EE_DMS_4_1_0_shortcodes extends EE_Data_Migration_Script_Stage
9 8
 {
10
-    public function __construct()
11
-    {
12
-        global $wpdb;
13
-        $this->_pretty_name = esc_html__("Shortcodes", "event_espresso");
14
-        $this->_old_table = $wpdb->posts;
15
-        parent::__construct();
16
-    }
17
-    protected function _migrate_old_row($old_row)
18
-    {
19
-        $new_post_content = $this->_change_event_list_shortcode($old_row['post_content']);
20
-        global $wpdb;
21
-        $wpdb->query($wpdb->prepare("UPDATE " . $this->_old_table . " SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID']));
22
-    }
9
+	public function __construct()
10
+	{
11
+		global $wpdb;
12
+		$this->_pretty_name = esc_html__("Shortcodes", "event_espresso");
13
+		$this->_old_table = $wpdb->posts;
14
+		parent::__construct();
15
+	}
16
+	protected function _migrate_old_row($old_row)
17
+	{
18
+		$new_post_content = $this->_change_event_list_shortcode($old_row['post_content']);
19
+		global $wpdb;
20
+		$wpdb->query($wpdb->prepare("UPDATE " . $this->_old_table . " SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID']));
21
+	}
23 22
 
24
-    /**
25
-     * replaces [EVENT_LIST... with [ESPRESSO_EVENTS...]
26
-     * @param string $old_content
27
-     */
28
-    private function _change_event_list_shortcode($old_content)
29
-    {
30
-        return str_replace("[EVENT_LIST", "[ESPRESSO_EVENTS", $old_content);
31
-    }
23
+	/**
24
+	 * replaces [EVENT_LIST... with [ESPRESSO_EVENTS...]
25
+	 * @param string $old_content
26
+	 */
27
+	private function _change_event_list_shortcode($old_content)
28
+	{
29
+		return str_replace("[EVENT_LIST", "[ESPRESSO_EVENTS", $old_content);
30
+	}
32 31
 
33
-    public function _migration_step($num_items = 50)
34
-    {
35
-        global $wpdb;
36
-        $start_at_record = $this->count_records_migrated();
37
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
38
-        $items_actually_migrated = 0;
39
-        foreach ($rows as $old_row) {
40
-            $this->_migrate_old_row($old_row);
41
-            $items_actually_migrated++;
42
-        }
43
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
44
-            $this->set_completed();
45
-        }
46
-        return $items_actually_migrated;
47
-    }
48
-    public function _count_records_to_migrate()
49
-    {
50
-        global $wpdb;
51
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM " . $this->_old_table . $this->_sql_to_only_select_non_drafts());
52
-        return $count;
53
-    }
32
+	public function _migration_step($num_items = 50)
33
+	{
34
+		global $wpdb;
35
+		$start_at_record = $this->count_records_migrated();
36
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
37
+		$items_actually_migrated = 0;
38
+		foreach ($rows as $old_row) {
39
+			$this->_migrate_old_row($old_row);
40
+			$items_actually_migrated++;
41
+		}
42
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
43
+			$this->set_completed();
44
+		}
45
+		return $items_actually_migrated;
46
+	}
47
+	public function _count_records_to_migrate()
48
+	{
49
+		global $wpdb;
50
+		$count = $wpdb->get_var("SELECT COUNT(id) FROM " . $this->_old_table . $this->_sql_to_only_select_non_drafts());
51
+		return $count;
52
+	}
54 53
 
55
-    private function _sql_to_only_select_non_drafts()
56
-    {
57
-        return " WHERE post_type NOT IN ('revision','auto-draft','attachment','nav_menu_item') ";
58
-    }
54
+	private function _sql_to_only_select_non_drafts()
55
+	{
56
+		return " WHERE post_type NOT IN ('revision','auto-draft','attachment','nav_menu_item') ";
57
+	}
59 58
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_checkins.dmsstage.php 2 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -26,160 +26,160 @@
 block discarded – undo
26 26
 
27 27
 class EE_DMS_4_1_0_checkins extends EE_Data_Migration_Script_Stage_Table
28 28
 {
29
-    private $_new_table;
30
-    public function __construct()
31
-    {
32
-        global $wpdb;
33
-        $this->_pretty_name = esc_html__('Checkins', 'event_espresso');
34
-        $this->_old_table = $wpdb->prefix . "events_attendee";
35
-        $this->select_expression = 'att.*, e.event_status';
36
-        $this->_extra_where_sql = 'AS att
29
+	private $_new_table;
30
+	public function __construct()
31
+	{
32
+		global $wpdb;
33
+		$this->_pretty_name = esc_html__('Checkins', 'event_espresso');
34
+		$this->_old_table = $wpdb->prefix . "events_attendee";
35
+		$this->select_expression = 'att.*, e.event_status';
36
+		$this->_extra_where_sql = 'AS att
37 37
             INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON att.event_id=e.id
38 38
             WHERE e.event_status!="D"';
39
-        $this->_new_table = $wpdb->prefix . "esp_checkin";
40
-        parent::__construct();
41
-    }
42
-    protected function _migrate_old_row($old_row)
43
-    {
44
-        global $wpdb;
45
-        $new_reg_table = $wpdb->prefix . "esp_registration";
39
+		$this->_new_table = $wpdb->prefix . "esp_checkin";
40
+		parent::__construct();
41
+	}
42
+	protected function _migrate_old_row($old_row)
43
+	{
44
+		global $wpdb;
45
+		$new_reg_table = $wpdb->prefix . "esp_registration";
46 46
 
47
-        $num_to_checkin_at_this_time = max(array(intval($old_row['checked_in_quantity']),intval($old_row['checked_in']))) ;
47
+		$num_to_checkin_at_this_time = max(array(intval($old_row['checked_in_quantity']),intval($old_row['checked_in']))) ;
48 48
 
49
-        $new_registrations_for_attendee = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $new_reg_table);
50
-        if (! $new_registrations_for_attendee) {
51
-            $new_registrations_for_attendee = array();
52
-        }
53
-        $new_datetime = $this->_try_to_find_datetime($old_row);
49
+		$new_registrations_for_attendee = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $new_reg_table);
50
+		if (! $new_registrations_for_attendee) {
51
+			$new_registrations_for_attendee = array();
52
+		}
53
+		$new_datetime = $this->_try_to_find_datetime($old_row);
54 54
 
55
-        // make sure registrations array is numerically indexed starting at 0 (it probably already is)
56
-        $new_registrations_for_attendee = array_values($new_registrations_for_attendee);
57
-        $new_checkin_ids = array();
58
-        for ($i = 0; $i < abs($num_to_checkin_at_this_time); $i++) {
59
-            $new_reg_id = $new_registrations_for_attendee[ $i ];
60
-            if (! $new_reg_id) {
61
-                $this->add_error(sprintf(
62
-                    esc_html__(
63
-                        /* translators: %1$s database row represented in JSON, %2$s number of registrations to check-in
55
+		// make sure registrations array is numerically indexed starting at 0 (it probably already is)
56
+		$new_registrations_for_attendee = array_values($new_registrations_for_attendee);
57
+		$new_checkin_ids = array();
58
+		for ($i = 0; $i < abs($num_to_checkin_at_this_time); $i++) {
59
+			$new_reg_id = $new_registrations_for_attendee[ $i ];
60
+			if (! $new_reg_id) {
61
+				$this->add_error(sprintf(
62
+					esc_html__(
63
+						/* translators: %1$s database row represented in JSON, %2$s number of registrations to check-in
64 64
                         *  %3$s number of registrations for the attendee, %4$s new registration rows represented in JSON
65 65
                         */
66
-                        // @codingStandardsIgnoreStart
67
-                        'It appears we wanted to check-in more registrations than actually exist. The old attendee record (%1$s) indicated we should check-in %2$d registrations, but there are only %3$d registrations for that attendee (%4$s)',
68
-                        // @codingStandardsIgnoreEnd
69
-                        'event_espresso'
70
-                    ),
71
-                    $this->_json_encode($old_row),
72
-                    abs($num_to_checkin_at_this_time),
73
-                    count($new_registrations_for_attendee),
74
-                    $this->_json_encode($new_registrations_for_attendee)
75
-                ));
76
-                break;
77
-            }
78
-            $existing_checkin_record = $wpdb->get_var(
79
-                $wpdb->prepare(
80
-                    "SELECT CHK_ID FROM $this->_new_table WHERE REG_ID = %d ORDER BY CHK_ID DESC LIMIT 1",
81
-                    $new_reg_id
82
-                )
83
-            );
84
-            if (! $existing_checkin_record) {
85
-                $new_id = $this->_insert_checkin_record($new_reg_id, $new_datetime);
86
-                if ($new_id) {
87
-                    $new_checkin_ids[] = $new_id;
88
-                }
89
-            }
90
-        }
91
-        if ($new_checkin_ids) {
92
-            $this->get_migration_script()->set_mapping(
93
-                $this->_old_table,
94
-                $old_row['id'],
95
-                $this->_new_table,
96
-                $new_checkin_ids
97
-            );
98
-        }
99
-    }
66
+						// @codingStandardsIgnoreStart
67
+						'It appears we wanted to check-in more registrations than actually exist. The old attendee record (%1$s) indicated we should check-in %2$d registrations, but there are only %3$d registrations for that attendee (%4$s)',
68
+						// @codingStandardsIgnoreEnd
69
+						'event_espresso'
70
+					),
71
+					$this->_json_encode($old_row),
72
+					abs($num_to_checkin_at_this_time),
73
+					count($new_registrations_for_attendee),
74
+					$this->_json_encode($new_registrations_for_attendee)
75
+				));
76
+				break;
77
+			}
78
+			$existing_checkin_record = $wpdb->get_var(
79
+				$wpdb->prepare(
80
+					"SELECT CHK_ID FROM $this->_new_table WHERE REG_ID = %d ORDER BY CHK_ID DESC LIMIT 1",
81
+					$new_reg_id
82
+				)
83
+			);
84
+			if (! $existing_checkin_record) {
85
+				$new_id = $this->_insert_checkin_record($new_reg_id, $new_datetime);
86
+				if ($new_id) {
87
+					$new_checkin_ids[] = $new_id;
88
+				}
89
+			}
90
+		}
91
+		if ($new_checkin_ids) {
92
+			$this->get_migration_script()->set_mapping(
93
+				$this->_old_table,
94
+				$old_row['id'],
95
+				$this->_new_table,
96
+				$new_checkin_ids
97
+			);
98
+		}
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * Tries to find the new datetime the Check-in was for, based on the attendee row
104
-     * (because we know the attendee was for an event as a specific time, and we know
105
-     * the event's OLD ID...)
106
-     * @global type $wpdb
107
-     * @param array $old_attendee_row
108
-     * @return array row of datetime from DB
109
-     */
110
-    private function _try_to_find_datetime($old_attendee)
111
-    {
112
-        global $wpdb;
102
+	/**
103
+	 * Tries to find the new datetime the Check-in was for, based on the attendee row
104
+	 * (because we know the attendee was for an event as a specific time, and we know
105
+	 * the event's OLD ID...)
106
+	 * @global type $wpdb
107
+	 * @param array $old_attendee_row
108
+	 * @return array row of datetime from DB
109
+	 */
110
+	private function _try_to_find_datetime($old_attendee)
111
+	{
112
+		global $wpdb;
113 113
 
114
-        $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_detail", $old_attendee['event_id'], $wpdb->posts);
115
-        if (! $new_event_id) {
116
-            $this->add_error(
117
-                sprintf(
118
-                    esc_html__(
119
-                        /* translators: 1: original event ID, 2: original attendee database row */
120
-                        // @codingStandardsIgnoreStart
121
-                        'Could not find new event ID with old event ID %1$d, on attendee row %2$s; and because of that couldn\'t find the correct datetime for Check-in',
122
-                        // @codingStandardsIgnoreEnd
123
-                        'event_espresso'
124
-                    ),
125
-                    $old_attendee['event_id'],
126
-                    $this->_json_encode($old_attendee)
127
-                )
128
-            );
129
-            return 0;
130
-        }
131
-        $old_att_start_date = $old_attendee['start_date'];
132
-        $old_att_start_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);
133
-        $old_att_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_start_date $old_att_start_time:00");
114
+		$new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_detail", $old_attendee['event_id'], $wpdb->posts);
115
+		if (! $new_event_id) {
116
+			$this->add_error(
117
+				sprintf(
118
+					esc_html__(
119
+						/* translators: 1: original event ID, 2: original attendee database row */
120
+						// @codingStandardsIgnoreStart
121
+						'Could not find new event ID with old event ID %1$d, on attendee row %2$s; and because of that couldn\'t find the correct datetime for Check-in',
122
+						// @codingStandardsIgnoreEnd
123
+						'event_espresso'
124
+					),
125
+					$old_attendee['event_id'],
126
+					$this->_json_encode($old_attendee)
127
+				)
128
+			);
129
+			return 0;
130
+		}
131
+		$old_att_start_date = $old_attendee['start_date'];
132
+		$old_att_start_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);
133
+		$old_att_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_start_date $old_att_start_time:00");
134 134
 
135
-        $datetime_table = $wpdb->prefix . "esp_datetime";
136
-        // add all conditions to an array from which we can SHIFT conditions off in order to widen our search
137
-        // the most important condition should be last, as it will be array_shift'ed off last
138
-        $conditions = array(
139
-            $wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime),// times match?
140
-            $wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id),// events match?
141
-        );
142
-        // start running queries, widening search each time by removing a condition
143
-        $datetime_found = null;
144
-        do {
145
-            $full_query = "SELECT * FROM $datetime_table WHERE " . implode(" AND ", $conditions) . " LIMIT 1";
146
-            $datetime_found = $wpdb->get_row($full_query, ARRAY_A);
147
-            array_shift($conditions);
148
-        } while (! $datetime_found && $conditions);
149
-        return $datetime_found;
150
-    }
135
+		$datetime_table = $wpdb->prefix . "esp_datetime";
136
+		// add all conditions to an array from which we can SHIFT conditions off in order to widen our search
137
+		// the most important condition should be last, as it will be array_shift'ed off last
138
+		$conditions = array(
139
+			$wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime),// times match?
140
+			$wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id),// events match?
141
+		);
142
+		// start running queries, widening search each time by removing a condition
143
+		$datetime_found = null;
144
+		do {
145
+			$full_query = "SELECT * FROM $datetime_table WHERE " . implode(" AND ", $conditions) . " LIMIT 1";
146
+			$datetime_found = $wpdb->get_row($full_query, ARRAY_A);
147
+			array_shift($conditions);
148
+		} while (! $datetime_found && $conditions);
149
+		return $datetime_found;
150
+	}
151 151
 
152
-    /**
153
-     * Adds a new Check-in/checkout record according for $new_reg_id,$new_datetime_id,$checking_in, and $timestmap
154
-     * @param int $new_reg_id
155
-     * @param int $new_datetime_id
156
-     * @param string $timestamp mysql datetime
157
-     * @return int new Check-in id
158
-     */
159
-    private function _insert_checkin_record($new_reg_id, $new_datetime)
160
-    {
161
-        global $wpdb;
152
+	/**
153
+	 * Adds a new Check-in/checkout record according for $new_reg_id,$new_datetime_id,$checking_in, and $timestmap
154
+	 * @param int $new_reg_id
155
+	 * @param int $new_datetime_id
156
+	 * @param string $timestamp mysql datetime
157
+	 * @return int new Check-in id
158
+	 */
159
+	private function _insert_checkin_record($new_reg_id, $new_datetime)
160
+	{
161
+		global $wpdb;
162 162
 
163 163
 
164
-        // ok we can actually do what we set out to do: add a checkin/checkout record
165
-        $cols_n_values = array(
166
-            'REG_ID' => $new_reg_id,
167
-            'DTT_ID' => $new_datetime['DTT_ID'],
168
-            'CHK_in' => true,
169
-            'CHK_timestamp' => $new_datetime['DTT_EVT_start']
170
-        );
171
-        $datatypes = array(
172
-            '%d',// REG_ID
173
-            '%d',// DTT_ID
174
-            '%d',// CHK_in
175
-            '%s',// CHK_timestamp
176
-        );
177
-        $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
178
-        if (! $success) {
179
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_checkin, $this->_new_table, $cols_n_values, $datatypes));
180
-            return 0;
181
-        }
182
-        $new_id = $wpdb->insert_id;
183
-        return $new_id;
184
-    }
164
+		// ok we can actually do what we set out to do: add a checkin/checkout record
165
+		$cols_n_values = array(
166
+			'REG_ID' => $new_reg_id,
167
+			'DTT_ID' => $new_datetime['DTT_ID'],
168
+			'CHK_in' => true,
169
+			'CHK_timestamp' => $new_datetime['DTT_EVT_start']
170
+		);
171
+		$datatypes = array(
172
+			'%d',// REG_ID
173
+			'%d',// DTT_ID
174
+			'%d',// CHK_in
175
+			'%s',// CHK_timestamp
176
+		);
177
+		$success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
178
+		if (! $success) {
179
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_checkin, $this->_new_table, $cols_n_values, $datatypes));
180
+			return 0;
181
+		}
182
+		$new_id = $wpdb->insert_id;
183
+		return $new_id;
184
+	}
185 185
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -31,23 +31,23 @@  discard block
 block discarded – undo
31 31
     {
32 32
         global $wpdb;
33 33
         $this->_pretty_name = esc_html__('Checkins', 'event_espresso');
34
-        $this->_old_table = $wpdb->prefix . "events_attendee";
34
+        $this->_old_table = $wpdb->prefix."events_attendee";
35 35
         $this->select_expression = 'att.*, e.event_status';
36 36
         $this->_extra_where_sql = 'AS att
37
-            INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON att.event_id=e.id
37
+            INNER JOIN ' . $wpdb->prefix.'events_detail AS e ON att.event_id=e.id
38 38
             WHERE e.event_status!="D"';
39
-        $this->_new_table = $wpdb->prefix . "esp_checkin";
39
+        $this->_new_table = $wpdb->prefix."esp_checkin";
40 40
         parent::__construct();
41 41
     }
42 42
     protected function _migrate_old_row($old_row)
43 43
     {
44 44
         global $wpdb;
45
-        $new_reg_table = $wpdb->prefix . "esp_registration";
45
+        $new_reg_table = $wpdb->prefix."esp_registration";
46 46
 
47
-        $num_to_checkin_at_this_time = max(array(intval($old_row['checked_in_quantity']),intval($old_row['checked_in']))) ;
47
+        $num_to_checkin_at_this_time = max(array(intval($old_row['checked_in_quantity']), intval($old_row['checked_in'])));
48 48
 
49 49
         $new_registrations_for_attendee = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $new_reg_table);
50
-        if (! $new_registrations_for_attendee) {
50
+        if ( ! $new_registrations_for_attendee) {
51 51
             $new_registrations_for_attendee = array();
52 52
         }
53 53
         $new_datetime = $this->_try_to_find_datetime($old_row);
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
         $new_registrations_for_attendee = array_values($new_registrations_for_attendee);
57 57
         $new_checkin_ids = array();
58 58
         for ($i = 0; $i < abs($num_to_checkin_at_this_time); $i++) {
59
-            $new_reg_id = $new_registrations_for_attendee[ $i ];
60
-            if (! $new_reg_id) {
59
+            $new_reg_id = $new_registrations_for_attendee[$i];
60
+            if ( ! $new_reg_id) {
61 61
                 $this->add_error(sprintf(
62 62
                     esc_html__(
63 63
                         /* translators: %1$s database row represented in JSON, %2$s number of registrations to check-in
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
                     $new_reg_id
82 82
                 )
83 83
             );
84
-            if (! $existing_checkin_record) {
84
+            if ( ! $existing_checkin_record) {
85 85
                 $new_id = $this->_insert_checkin_record($new_reg_id, $new_datetime);
86 86
                 if ($new_id) {
87 87
                     $new_checkin_ids[] = $new_id;
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
     {
112 112
         global $wpdb;
113 113
 
114
-        $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix . "events_detail", $old_attendee['event_id'], $wpdb->posts);
115
-        if (! $new_event_id) {
114
+        $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", $old_attendee['event_id'], $wpdb->posts);
115
+        if ( ! $new_event_id) {
116 116
             $this->add_error(
117 117
                 sprintf(
118 118
                     esc_html__(
@@ -132,20 +132,20 @@  discard block
 block discarded – undo
132 132
         $old_att_start_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);
133 133
         $old_att_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_start_date $old_att_start_time:00");
134 134
 
135
-        $datetime_table = $wpdb->prefix . "esp_datetime";
135
+        $datetime_table = $wpdb->prefix."esp_datetime";
136 136
         // add all conditions to an array from which we can SHIFT conditions off in order to widen our search
137 137
         // the most important condition should be last, as it will be array_shift'ed off last
138 138
         $conditions = array(
139
-            $wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime),// times match?
140
-            $wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id),// events match?
139
+            $wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime), // times match?
140
+            $wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id), // events match?
141 141
         );
142 142
         // start running queries, widening search each time by removing a condition
143 143
         $datetime_found = null;
144 144
         do {
145
-            $full_query = "SELECT * FROM $datetime_table WHERE " . implode(" AND ", $conditions) . " LIMIT 1";
145
+            $full_query = "SELECT * FROM $datetime_table WHERE ".implode(" AND ", $conditions)." LIMIT 1";
146 146
             $datetime_found = $wpdb->get_row($full_query, ARRAY_A);
147 147
             array_shift($conditions);
148
-        } while (! $datetime_found && $conditions);
148
+        }while ( ! $datetime_found && $conditions);
149 149
         return $datetime_found;
150 150
     }
151 151
 
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
             'CHK_timestamp' => $new_datetime['DTT_EVT_start']
170 170
         );
171 171
         $datatypes = array(
172
-            '%d',// REG_ID
173
-            '%d',// DTT_ID
174
-            '%d',// CHK_in
175
-            '%s',// CHK_timestamp
172
+            '%d', // REG_ID
173
+            '%d', // DTT_ID
174
+            '%d', // CHK_in
175
+            '%s', // CHK_timestamp
176 176
         );
177 177
         $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);
178
-        if (! $success) {
178
+        if ( ! $success) {
179 179
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_checkin, $this->_new_table, $cols_n_values, $datatypes));
180 180
             return 0;
181 181
         }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_9_0.dms.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 // unfortunately, this needs to be done upon INCLUSION of this file,
10 10
 // instead of construction, because it only gets constructed on first page load
11 11
 // (all other times it gets resurrected from a wordpress option)
12
-$stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*');
12
+$stages = glob(EE_CORE.'data_migration_scripts/4_9_0_stages/*');
13 13
 $class_to_filepath = array();
14 14
 foreach ($stages as $filepath) {
15 15
     $matches = array();
16 16
     preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
17
-    $class_to_filepath[ $matches[1] ] = $filepath;
17
+    $class_to_filepath[$matches[1]] = $filepath;
18 18
 }
19 19
 // give addons a chance to autoload their stages too
20 20
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath);
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
         if (version_compare($version_string, '4.9.0.decaf', '<') && version_compare($version_string, '4.8.0.decaf', '>=')) {
66 66
             //          echo "$version_string can be migrated from";
67 67
             return true;
68
-        } elseif (! $version_string) {
68
+        } elseif ( ! $version_string) {
69 69
             //          echo "no version string provided: $version_string";
70 70
             // no version string provided... this must be pre 4.3
71
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
71
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
72 72
         } else {
73 73
             //          echo "$version_string doesnt apply";
74 74
             return false;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function schema_changes_before_migration()
84 84
     {
85
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
85
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
86 86
         $now_in_mysql = current_time('mysql', true);
87 87
         $table_name = 'esp_answer';
88 88
         $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
Please login to merge, or discard this patch.
Indentation   +303 added lines, -303 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 $stages = glob(EE_CORE . 'data_migration_scripts/4_9_0_stages/*');
13 13
 $class_to_filepath = array();
14 14
 foreach ($stages as $filepath) {
15
-    $matches = array();
16
-    preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
17
-    $class_to_filepath[ $matches[1] ] = $filepath;
15
+	$matches = array();
16
+	preg_match('~4_9_0_stages/(.*).dmsstage.php~', $filepath, $matches);
17
+	$class_to_filepath[ $matches[1] ] = $filepath;
18 18
 }
19 19
 // give addons a chance to autoload their stages too
20 20
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_9_0__autoloaded_stages', $class_to_filepath);
@@ -33,68 +33,68 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class EE_DMS_Core_4_9_0 extends EE_Data_Migration_Script_Base
35 35
 {
36
-    /**
37
-     * return EE_DMS_Core_4_9_0
38
-     *
39
-     * @param TableManager  $table_manager
40
-     * @param TableAnalysis $table_analysis
41
-     */
42
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
43
-    {
44
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
45
-        $this->_priority = 10;
46
-        $this->_migration_stages = array(
47
-            new EE_DMS_4_9_0_Email_System_Question(),
48
-            new EE_DMS_4_9_0_Answers_With_No_Registration(),
49
-        );
50
-        parent::__construct($table_manager, $table_analysis);
51
-    }
36
+	/**
37
+	 * return EE_DMS_Core_4_9_0
38
+	 *
39
+	 * @param TableManager  $table_manager
40
+	 * @param TableAnalysis $table_analysis
41
+	 */
42
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
43
+	{
44
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.9.0", "event_espresso");
45
+		$this->_priority = 10;
46
+		$this->_migration_stages = array(
47
+			new EE_DMS_4_9_0_Email_System_Question(),
48
+			new EE_DMS_4_9_0_Answers_With_No_Registration(),
49
+		);
50
+		parent::__construct($table_manager, $table_analysis);
51
+	}
52 52
 
53 53
 
54 54
 
55
-    /**
56
-     * Whether to migrate or not.
57
-     *
58
-     * @param array $version_array
59
-     * @return bool
60
-     */
61
-    public function can_migrate_from_version($version_array)
62
-    {
63
-        $version_string = $version_array['Core'];
64
-        if (version_compare($version_string, '4.9.0.decaf', '<') && version_compare($version_string, '4.8.0.decaf', '>=')) {
65
-            //          echo "$version_string can be migrated from";
66
-            return true;
67
-        } elseif (! $version_string) {
68
-            //          echo "no version string provided: $version_string";
69
-            // no version string provided... this must be pre 4.3
70
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
71
-        } else {
72
-            //          echo "$version_string doesnt apply";
73
-            return false;
74
-        }
75
-    }
55
+	/**
56
+	 * Whether to migrate or not.
57
+	 *
58
+	 * @param array $version_array
59
+	 * @return bool
60
+	 */
61
+	public function can_migrate_from_version($version_array)
62
+	{
63
+		$version_string = $version_array['Core'];
64
+		if (version_compare($version_string, '4.9.0.decaf', '<') && version_compare($version_string, '4.8.0.decaf', '>=')) {
65
+			//          echo "$version_string can be migrated from";
66
+			return true;
67
+		} elseif (! $version_string) {
68
+			//          echo "no version string provided: $version_string";
69
+			// no version string provided... this must be pre 4.3
70
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
71
+		} else {
72
+			//          echo "$version_string doesnt apply";
73
+			return false;
74
+		}
75
+	}
76 76
 
77 77
 
78 78
 
79
-    /**
80
-     * @return bool
81
-     */
82
-    public function schema_changes_before_migration()
83
-    {
84
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
85
-        $now_in_mysql = current_time('mysql', true);
86
-        $table_name = 'esp_answer';
87
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
79
+	/**
80
+	 * @return bool
81
+	 */
82
+	public function schema_changes_before_migration()
83
+	{
84
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
85
+		$now_in_mysql = current_time('mysql', true);
86
+		$table_name = 'esp_answer';
87
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
88 88
 					REG_ID int(10) unsigned NOT NULL,
89 89
 					QST_ID int(10) unsigned NOT NULL,
90 90
 					ANS_value text NOT NULL,
91 91
 					PRIMARY KEY  (ANS_ID),
92 92
 					KEY REG_ID (REG_ID),
93 93
 					KEY QST_ID (QST_ID)";
94
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
95
-        $table_name = 'esp_attendee_meta';
96
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
97
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
94
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
95
+		$table_name = 'esp_attendee_meta';
96
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'ATT_email');
97
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
98 98
 				ATT_ID bigint(20) unsigned NOT NULL,
99 99
 				ATT_fname varchar(45) NOT NULL,
100 100
 				ATT_lname varchar(45) NOT NULL,
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 				KEY ATT_email (ATT_email(191)),
112 112
 				KEY ATT_lname (ATT_lname),
113 113
 				KEY ATT_fname (ATT_fname)";
114
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
115
-        $table_name = 'esp_checkin';
116
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
114
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
115
+		$table_name = 'esp_checkin';
116
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
117 117
 				REG_ID int(10) unsigned NOT NULL,
118 118
 				DTT_ID int(10) unsigned NOT NULL,
119 119
 				CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 				PRIMARY KEY  (CHK_ID),
122 122
 				KEY REG_ID (REG_ID),
123 123
 				KEY DTT_ID (DTT_ID)";
124
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
125
-        $table_name = 'esp_country';
126
-        $sql = "CNT_ISO varchar(2) NOT NULL,
124
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
125
+		$table_name = 'esp_country';
126
+		$sql = "CNT_ISO varchar(2) NOT NULL,
127 127
 				CNT_ISO3 varchar(3) NOT NULL,
128 128
 				RGN_ID tinyint(3) unsigned DEFAULT NULL,
129 129
 				CNT_name varchar(45) NOT NULL,
@@ -139,18 +139,18 @@  discard block
 block discarded – undo
139 139
 				CNT_is_EU tinyint(1) DEFAULT '0',
140 140
 				CNT_active tinyint(1) DEFAULT '0',
141 141
 				PRIMARY KEY  (CNT_ISO)";
142
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
143
-        $table_name = 'esp_currency';
144
-        $sql = "CUR_code varchar(6) NOT NULL,
142
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
143
+		$table_name = 'esp_currency';
144
+		$sql = "CUR_code varchar(6) NOT NULL,
145 145
 				CUR_single varchar(45) DEFAULT 'dollar',
146 146
 				CUR_plural varchar(45) DEFAULT 'dollars',
147 147
 				CUR_sign varchar(45) DEFAULT '$',
148 148
 				CUR_dec_plc varchar(1) NOT NULL DEFAULT '2',
149 149
 				CUR_active tinyint(1) DEFAULT '0',
150 150
 				PRIMARY KEY  (CUR_code)";
151
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
152
-        $table_name = 'esp_datetime';
153
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
151
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
152
+		$table_name = 'esp_datetime';
153
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
154 154
 				EVT_ID bigint(20) unsigned NOT NULL,
155 155
 				DTT_name varchar(255) NOT NULL DEFAULT '',
156 156
 				DTT_description text NOT NULL,
@@ -167,25 +167,25 @@  discard block
 block discarded – undo
167 167
 				KEY DTT_EVT_start (DTT_EVT_start),
168 168
 				KEY EVT_ID (EVT_ID),
169 169
 				KEY DTT_is_primary (DTT_is_primary)";
170
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
171
-        $table_name = "esp_datetime_ticket";
172
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
170
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
171
+		$table_name = "esp_datetime_ticket";
172
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
173 173
 				DTT_ID int(10) unsigned NOT NULL,
174 174
 				TKT_ID int(10) unsigned NOT NULL,
175 175
 				PRIMARY KEY  (DTK_ID),
176 176
 				KEY DTT_ID (DTT_ID),
177 177
 				KEY TKT_ID (TKT_ID)";
178
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
179
-        $table_name = 'esp_event_message_template';
180
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
178
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
179
+		$table_name = 'esp_event_message_template';
180
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
181 181
 				EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
182 182
 				GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
183 183
 				PRIMARY KEY  (EMT_ID),
184 184
 				KEY EVT_ID (EVT_ID),
185 185
 				KEY GRP_ID (GRP_ID)";
186
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
187
-        $table_name = 'esp_event_meta';
188
-        $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
186
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
187
+		$table_name = 'esp_event_meta';
188
+		$sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
189 189
 				EVT_ID bigint(20) unsigned NOT NULL,
190 190
 				EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
191 191
 				EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -200,34 +200,34 @@  discard block
 block discarded – undo
200 200
 				EVT_donations tinyint(1) NULL,
201 201
 				PRIMARY KEY  (EVTM_ID),
202 202
 				KEY EVT_ID (EVT_ID)";
203
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
204
-        $table_name = 'esp_event_question_group';
205
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
203
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
204
+		$table_name = 'esp_event_question_group';
205
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
206 206
 				EVT_ID bigint(20) unsigned NOT NULL,
207 207
 				QSG_ID int(10) unsigned NOT NULL,
208 208
 				EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
209 209
 				PRIMARY KEY  (EQG_ID),
210 210
 				KEY EVT_ID (EVT_ID),
211 211
 				KEY QSG_ID (QSG_ID)";
212
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
213
-        $table_name = 'esp_event_venue';
214
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
212
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
213
+		$table_name = 'esp_event_venue';
214
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
215 215
 				EVT_ID bigint(20) unsigned NOT NULL,
216 216
 				VNU_ID bigint(20) unsigned NOT NULL,
217 217
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
218 218
 				PRIMARY KEY  (EVV_ID)";
219
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
220
-        $table_name = 'esp_extra_meta';
221
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
219
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
220
+		$table_name = 'esp_extra_meta';
221
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
222 222
 				OBJ_ID int(11) DEFAULT NULL,
223 223
 				EXM_type varchar(45) DEFAULT NULL,
224 224
 				EXM_key varchar(45) DEFAULT NULL,
225 225
 				EXM_value text,
226 226
 				PRIMARY KEY  (EXM_ID),
227 227
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
228
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
229
-        $table_name = 'esp_extra_join';
230
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
228
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
229
+		$table_name = 'esp_extra_join';
230
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
231 231
 				EXJ_first_model_id varchar(6) NOT NULL,
232 232
 				EXJ_first_model_name varchar(20) NOT NULL,
233 233
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 				PRIMARY KEY  (EXJ_ID),
236 236
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
237 237
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
238
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
239
-        $table_name = 'esp_line_item';
240
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
238
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
239
+		$table_name = 'esp_line_item';
240
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
241 241
 				LIN_code varchar(245) NOT NULL DEFAULT '',
242 242
 				TXN_ID int(11) DEFAULT NULL,
243 243
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -258,11 +258,11 @@  discard block
 block discarded – undo
258 258
 				KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp),
259 259
 				KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type),
260 260
 				KEY obj_id_obj_type (OBJ_ID,OBJ_type)";
261
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
262
-        $this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
263
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
264
-        $table_name = 'esp_log';
265
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
261
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'TXN_ID');
262
+		$this->_get_table_manager()->dropIndex('esp_line_item', 'LIN_code');
263
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
264
+		$table_name = 'esp_log';
265
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
266 266
 				LOG_time datetime DEFAULT NULL,
267 267
 				OBJ_ID varchar(45) DEFAULT NULL,
268 268
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -273,12 +273,12 @@  discard block
 block discarded – undo
273 273
 				KEY LOG_time (LOG_time),
274 274
 				KEY OBJ (OBJ_type,OBJ_ID),
275 275
 				KEY LOG_type (LOG_type)";
276
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
277
-        $table_name = 'esp_message';
278
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
279
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
280
-        $this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
281
-        $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
276
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
277
+		$table_name = 'esp_message';
278
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_to');
279
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_from');
280
+		$this->_get_table_manager()->dropIndexIfSizeNot($table_name, 'MSG_subject');
281
+		$sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
282 282
 				GRP_ID int(10) unsigned NULL,
283 283
 				MSG_token varchar(255) NULL,
284 284
 				TXN_ID int(10) unsigned NULL,
@@ -310,18 +310,18 @@  discard block
 block discarded – undo
310 310
 				KEY STS_ID (STS_ID),
311 311
 				KEY MSG_created (MSG_created),
312 312
 				KEY MSG_modified (MSG_modified)";
313
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
314
-        $table_name = 'esp_message_template';
315
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
313
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
314
+		$table_name = 'esp_message_template';
315
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
316 316
 				GRP_ID int(10) unsigned NOT NULL,
317 317
 				MTP_context varchar(50) NOT NULL,
318 318
 				MTP_template_field varchar(30) NOT NULL,
319 319
 				MTP_content text NOT NULL,
320 320
 				PRIMARY KEY  (MTP_ID),
321 321
 				KEY GRP_ID (GRP_ID)";
322
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
323
-        $table_name = 'esp_message_template_group';
324
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
322
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
323
+		$table_name = 'esp_message_template_group';
324
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
325 325
 				MTP_user_id int(10) NOT NULL DEFAULT '1',
326 326
 				MTP_name varchar(245) NOT NULL DEFAULT '',
327 327
 				MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
 				MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
334 334
 				PRIMARY KEY  (GRP_ID),
335 335
 				KEY MTP_user_id (MTP_user_id)";
336
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
337
-        $table_name = 'esp_payment';
338
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
336
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
337
+		$table_name = 'esp_payment';
338
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
339 339
 				TXN_ID int(10) unsigned DEFAULT NULL,
340 340
 				STS_ID varchar(3) DEFAULT NULL,
341 341
 				PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -352,9 +352,9 @@  discard block
 block discarded – undo
352 352
 				PRIMARY KEY  (PAY_ID),
353 353
 				KEY PAY_timestamp (PAY_timestamp),
354 354
 				KEY TXN_ID (TXN_ID)";
355
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
356
-        $table_name = 'esp_payment_method';
357
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
355
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
356
+		$table_name = 'esp_payment_method';
357
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
358 358
 				PMD_type varchar(124) DEFAULT NULL,
359 359
 				PMD_name varchar(255) DEFAULT NULL,
360 360
 				PMD_desc text,
@@ -370,24 +370,24 @@  discard block
 block discarded – undo
370 370
 				PRIMARY KEY  (PMD_ID),
371 371
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
372 372
 				KEY PMD_type (PMD_type)";
373
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
374
-        $table_name = "esp_ticket_price";
375
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
373
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
374
+		$table_name = "esp_ticket_price";
375
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
376 376
 				TKT_ID int(10) unsigned NOT NULL,
377 377
 				PRC_ID int(10) unsigned NOT NULL,
378 378
 				PRIMARY KEY  (TKP_ID),
379 379
 				KEY TKT_ID (TKT_ID),
380 380
 				KEY PRC_ID (PRC_ID)";
381
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
382
-        $table_name = "esp_ticket_template";
383
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
381
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
382
+		$table_name = "esp_ticket_template";
383
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
384 384
 				TTM_name varchar(45) NOT NULL,
385 385
 				TTM_description text,
386 386
 				TTM_file varchar(45),
387 387
 				PRIMARY KEY  (TTM_ID)";
388
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
389
-        $table_name = 'esp_question';
390
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
388
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
389
+		$table_name = 'esp_question';
390
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
391 391
 				QST_display_text text NOT NULL,
392 392
 				QST_admin_label varchar(255) NOT NULL,
393 393
 				QST_system varchar(25) DEFAULT NULL,
@@ -401,18 +401,18 @@  discard block
 block discarded – undo
401 401
 				QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
402 402
 				PRIMARY KEY  (QST_ID),
403 403
 				KEY QST_order (QST_order)';
404
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
405
-        $table_name = 'esp_question_group_question';
406
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
404
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
405
+		$table_name = 'esp_question_group_question';
406
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
407 407
 				QSG_ID int(10) unsigned NOT NULL,
408 408
 				QST_ID int(10) unsigned NOT NULL,
409 409
 				QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
410 410
 				PRIMARY KEY  (QGQ_ID),
411 411
 				KEY QST_ID (QST_ID),
412 412
 				KEY QSG_ID_order (QSG_ID,QGQ_order)";
413
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
414
-        $table_name = 'esp_question_option';
415
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
413
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
414
+		$table_name = 'esp_question_option';
415
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
416 416
 				QSO_value varchar(255) NOT NULL,
417 417
 				QSO_desc text NOT NULL,
418 418
 				QST_ID int(10) unsigned NOT NULL,
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
 				PRIMARY KEY  (QSO_ID),
423 423
 				KEY QST_ID (QST_ID),
424 424
 				KEY QSO_order (QSO_order)";
425
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
426
-        $table_name = 'esp_registration';
427
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
425
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
426
+		$table_name = 'esp_registration';
427
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
428 428
 				EVT_ID bigint(20) unsigned NOT NULL,
429 429
 				ATT_ID bigint(20) unsigned NOT NULL,
430 430
 				TXN_ID int(10) unsigned NOT NULL,
@@ -448,18 +448,18 @@  discard block
 block discarded – undo
448 448
 				KEY TKT_ID (TKT_ID),
449 449
 				KEY EVT_ID (EVT_ID),
450 450
 				KEY STS_ID (STS_ID)";
451
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
452
-        $table_name = 'esp_registration_payment';
453
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
451
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
452
+		$table_name = 'esp_registration_payment';
453
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
454 454
 					  REG_ID int(10) unsigned NOT NULL,
455 455
 					  PAY_ID int(10) unsigned NULL,
456 456
 					  RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00',
457 457
 					  PRIMARY KEY  (RPY_ID),
458 458
 					  KEY REG_ID (REG_ID),
459 459
 					  KEY PAY_ID (PAY_ID)";
460
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
461
-        $table_name = 'esp_state';
462
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
460
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB ');
461
+		$table_name = 'esp_state';
462
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
463 463
 				CNT_ISO varchar(2) NOT NULL,
464 464
 				STA_abbrev varchar(24) NOT NULL,
465 465
 				STA_name varchar(100) NOT NULL,
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 				PRIMARY KEY  (STA_ID),
468 468
 				KEY STA_abbrev (STA_abbrev),
469 469
 				KEY CNT_ISO (CNT_ISO)";
470
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
471
-        $table_name = 'esp_status';
472
-        $sql = "STS_ID varchar(3) NOT NULL,
470
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
471
+		$table_name = 'esp_status';
472
+		$sql = "STS_ID varchar(3) NOT NULL,
473 473
 				STS_code varchar(45) NOT NULL,
474 474
 				STS_type varchar(45) NOT NULL,
475 475
 				STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -477,9 +477,9 @@  discard block
 block discarded – undo
477 477
 				STS_open tinyint(1) NOT NULL DEFAULT 1,
478 478
 				UNIQUE KEY STS_ID_UNIQUE (STS_ID),
479 479
 				KEY STS_type (STS_type)";
480
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
481
-        $table_name = 'esp_transaction';
482
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
480
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
481
+		$table_name = 'esp_transaction';
482
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
483 483
 				TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
484 484
 				TXN_total decimal(12,3) DEFAULT '0.00',
485 485
 				TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00',
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 				PRIMARY KEY  (TXN_ID),
492 492
 				KEY TXN_timestamp (TXN_timestamp),
493 493
 				KEY STS_ID (STS_ID)";
494
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
495
-        $table_name = 'esp_venue_meta';
496
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
494
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
495
+		$table_name = 'esp_venue_meta';
496
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
497 497
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
498 498
 			VNU_address varchar(255) DEFAULT NULL,
499 499
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -512,10 +512,10 @@  discard block
 block discarded – undo
512 512
 			KEY VNU_ID (VNU_ID),
513 513
 			KEY STA_ID (STA_ID),
514 514
 			KEY CNT_ISO (CNT_ISO)";
515
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
516
-        // modified tables
517
-        $table_name = "esp_price";
518
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
515
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
516
+		// modified tables
517
+		$table_name = "esp_price";
518
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
519 519
 				PRT_ID tinyint(3) unsigned NOT NULL,
520 520
 				PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00',
521 521
 				PRC_name varchar(245) NOT NULL,
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
 				PRC_parent int(10) unsigned DEFAULT 0,
529 529
 				PRIMARY KEY  (PRC_ID),
530 530
 				KEY PRT_ID (PRT_ID)";
531
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
532
-        $table_name = "esp_price_type";
533
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
531
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
532
+		$table_name = "esp_price_type";
533
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
534 534
 				PRT_name varchar(45) NOT NULL,
535 535
 				PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
536 536
 				PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -539,9 +539,9 @@  discard block
 block discarded – undo
539 539
 				PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
540 540
 				UNIQUE KEY PRT_name_UNIQUE (PRT_name),
541 541
 				PRIMARY KEY  (PRT_ID)";
542
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
543
-        $table_name = "esp_ticket";
544
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
542
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
543
+		$table_name = "esp_ticket";
544
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
545 545
 				TTM_ID int(10) unsigned NOT NULL,
546 546
 				TKT_name varchar(245) NOT NULL DEFAULT '',
547 547
 				TKT_description text NOT NULL,
@@ -564,9 +564,9 @@  discard block
 block discarded – undo
564 564
 				TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
565 565
 				PRIMARY KEY  (TKT_ID),
566 566
 				KEY TKT_start_date (TKT_start_date)";
567
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
568
-        $table_name = 'esp_question_group';
569
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
567
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
568
+		$table_name = 'esp_question_group';
569
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
570 570
 				QSG_name varchar(255) NOT NULL,
571 571
 				QSG_identifier varchar(100) NOT NULL,
572 572
 				QSG_desc text NULL,
@@ -579,165 +579,165 @@  discard block
 block discarded – undo
579 579
 				PRIMARY KEY  (QSG_ID),
580 580
 				UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
581 581
 				KEY QSG_order (QSG_order)';
582
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
583
-        $this->insert_default_data();
584
-        return true;
585
-    }
582
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
583
+		$this->insert_default_data();
584
+		return true;
585
+	}
586 586
 
587
-    /**
588
-     * Inserts default data after parent was called.
589
-     * @since 4.10.0.p
590
-     * @throws EE_Error
591
-     * @throws InvalidArgumentException
592
-     * @throws ReflectionException
593
-     * @throws InvalidDataTypeException
594
-     * @throws InvalidInterfaceException
595
-     */
596
-    public function insert_default_data()
597
-    {
598
-        /** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
599
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
600
-        // (because many need to convert old string states to foreign keys into the states table)
601
-        $script_4_1_defaults->insert_default_states();
602
-        $script_4_1_defaults->insert_default_countries();
603
-        /** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
604
-        $script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
605
-        $script_4_5_defaults->insert_default_price_types();
606
-        $script_4_5_defaults->insert_default_prices();
607
-        $script_4_5_defaults->insert_default_tickets();
608
-        /** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
609
-        $script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
610
-        $script_4_6_defaults->add_default_admin_only_payments();
611
-        $script_4_6_defaults->insert_default_currencies();
612
-        /** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
613
-        $script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
614
-        $script_4_8_defaults->verify_new_countries();
615
-        $script_4_8_defaults->verify_new_currencies();
616
-        $this->verify_db_collations();
617
-        $this->verify_db_collations_again();
618
-    }
587
+	/**
588
+	 * Inserts default data after parent was called.
589
+	 * @since 4.10.0.p
590
+	 * @throws EE_Error
591
+	 * @throws InvalidArgumentException
592
+	 * @throws ReflectionException
593
+	 * @throws InvalidDataTypeException
594
+	 * @throws InvalidInterfaceException
595
+	 */
596
+	public function insert_default_data()
597
+	{
598
+		/** @var EE_DMS_Core_4_1_0 $script_4_1_defaults */
599
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
600
+		// (because many need to convert old string states to foreign keys into the states table)
601
+		$script_4_1_defaults->insert_default_states();
602
+		$script_4_1_defaults->insert_default_countries();
603
+		/** @var EE_DMS_Core_4_5_0 $script_4_5_defaults */
604
+		$script_4_5_defaults = EE_Registry::instance()->load_dms('Core_4_5_0');
605
+		$script_4_5_defaults->insert_default_price_types();
606
+		$script_4_5_defaults->insert_default_prices();
607
+		$script_4_5_defaults->insert_default_tickets();
608
+		/** @var EE_DMS_Core_4_6_0 $script_4_6_defaults */
609
+		$script_4_6_defaults = EE_Registry::instance()->load_dms('Core_4_6_0');
610
+		$script_4_6_defaults->add_default_admin_only_payments();
611
+		$script_4_6_defaults->insert_default_currencies();
612
+		/** @var EE_DMS_Core_4_8_0 $script_4_8_defaults */
613
+		$script_4_8_defaults = EE_Registry::instance()->load_dms('Core_4_8_0');
614
+		$script_4_8_defaults->verify_new_countries();
615
+		$script_4_8_defaults->verify_new_currencies();
616
+		$this->verify_db_collations();
617
+		$this->verify_db_collations_again();
618
+	}
619 619
 
620 620
 
621 621
 
622
-    /**
623
-     * @return boolean
624
-     */
625
-    public function schema_changes_after_migration()
626
-    {
627
-        return true;
628
-    }
622
+	/**
623
+	 * @return boolean
624
+	 */
625
+	public function schema_changes_after_migration()
626
+	{
627
+		return true;
628
+	}
629 629
 
630 630
 
631 631
 
632
-    public function migration_page_hooks()
633
-    {
634
-    }
632
+	public function migration_page_hooks()
633
+	{
634
+	}
635 635
 
636 636
 
637 637
 
638
-    /**
639
-     * Verify all EE4 models' tables use utf8mb4 collation
640
-     *
641
-     * @return void
642
-     */
643
-    public function verify_db_collations()
644
-    {
645
-        global $wpdb;
646
-        // double-check we haven't already done it or that that the DB doesn't support utf8mb4
647
-        if (
648
-            'utf8mb4' !== $wpdb->charset
649
-            || get_option('ee_verified_db_collations', false)
650
-        ) {
651
-            return;
652
-        }
653
-        // grab tables from each model
654
-        $tables_to_check = array();
655
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
656
-            if (method_exists($model_name, 'instance')) {
657
-                $model_obj = call_user_func(array($model_name, 'instance'));
658
-                if ($model_obj instanceof EEM_Base) {
659
-                    foreach ($model_obj->get_tables() as $table) {
660
-                        if (
661
-                            strpos($table->get_table_name(), 'esp_')
662
-                            && (is_main_site()// for main tables, verify global tables
663
-                                || ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up)
664
-                            )
665
-                            && function_exists('maybe_convert_table_to_utf8mb4')
666
-                        ) {
667
-                            $tables_to_check[] = $table->get_table_name();
668
-                        }
669
-                    }
670
-                }
671
-            }
672
-        }
673
-        // and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
674
-        // when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
675
-        // of hard-coding this
676
-        $addon_tables = array(
677
-            // mailchimp
678
-            'esp_event_mailchimp_list_group',
679
-            'esp_event_question_mailchimp_field',
680
-            // multisite
681
-            'esp_blog_meta',
682
-            // people
683
-            'esp_people_to_post',
684
-            // promotions
685
-            'esp_promotion',
686
-            'esp_promotion_object',
687
-        );
688
-        foreach ($addon_tables as $table_name) {
689
-                $tables_to_check[] = $table_name;
690
-        }
691
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
692
-        // ok and now let's remember this was done (without needing to check the db schemas all over again)
693
-        add_option('ee_verified_db_collations', true, null, 'no');
694
-        // seeing how this ran with the fix from 10435, no need to check again
695
-        add_option('ee_verified_db_collations_again', true, null, 'no');
696
-    }
638
+	/**
639
+	 * Verify all EE4 models' tables use utf8mb4 collation
640
+	 *
641
+	 * @return void
642
+	 */
643
+	public function verify_db_collations()
644
+	{
645
+		global $wpdb;
646
+		// double-check we haven't already done it or that that the DB doesn't support utf8mb4
647
+		if (
648
+			'utf8mb4' !== $wpdb->charset
649
+			|| get_option('ee_verified_db_collations', false)
650
+		) {
651
+			return;
652
+		}
653
+		// grab tables from each model
654
+		$tables_to_check = array();
655
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
656
+			if (method_exists($model_name, 'instance')) {
657
+				$model_obj = call_user_func(array($model_name, 'instance'));
658
+				if ($model_obj instanceof EEM_Base) {
659
+					foreach ($model_obj->get_tables() as $table) {
660
+						if (
661
+							strpos($table->get_table_name(), 'esp_')
662
+							&& (is_main_site()// for main tables, verify global tables
663
+								|| ! $table->is_global()// if not the main site, then only verify non-global tables (avoid doubling up)
664
+							)
665
+							&& function_exists('maybe_convert_table_to_utf8mb4')
666
+						) {
667
+							$tables_to_check[] = $table->get_table_name();
668
+						}
669
+					}
670
+				}
671
+			}
672
+		}
673
+		// and let's just be sure these addons' tables get migrated too. They already get handled if their addons are active
674
+		// when this code is run, but not otherwise. Once we record what tables EE added, we'll be able to use that instead
675
+		// of hard-coding this
676
+		$addon_tables = array(
677
+			// mailchimp
678
+			'esp_event_mailchimp_list_group',
679
+			'esp_event_question_mailchimp_field',
680
+			// multisite
681
+			'esp_blog_meta',
682
+			// people
683
+			'esp_people_to_post',
684
+			// promotions
685
+			'esp_promotion',
686
+			'esp_promotion_object',
687
+		);
688
+		foreach ($addon_tables as $table_name) {
689
+				$tables_to_check[] = $table_name;
690
+		}
691
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
692
+		// ok and now let's remember this was done (without needing to check the db schemas all over again)
693
+		add_option('ee_verified_db_collations', true, null, 'no');
694
+		// seeing how this ran with the fix from 10435, no need to check again
695
+		add_option('ee_verified_db_collations_again', true, null, 'no');
696
+	}
697 697
 
698 698
 
699 699
 
700
-    /**
701
-     * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
702
-     * which meant some DB collations might not have been updated
703
-     * @return void
704
-     */
705
-    public function verify_db_collations_again()
706
-    {
707
-        global $wpdb;
708
-        // double-check we haven't already done this or that the DB doesn't support it
709
-        // compare to how WordPress' upgrade_430() function does this check
710
-        if (
711
-            'utf8mb4' !== $wpdb->charset
712
-            || get_option('ee_verified_db_collations_again', false)
713
-        ) {
714
-            return;
715
-        }
716
-        $tables_to_check = array(
717
-            'esp_attendee_meta',
718
-            'esp_message'
719
-        );
720
-        $this->_verify_db_collations_for_tables(array_unique($tables_to_check));
721
-        add_option('ee_verified_db_collations_again', true, null, 'no');
722
-    }
700
+	/**
701
+	 * Verifies DB collations because a bug was discovered on https://events.codebasehq.com/projects/event-espresso/tickets/10435
702
+	 * which meant some DB collations might not have been updated
703
+	 * @return void
704
+	 */
705
+	public function verify_db_collations_again()
706
+	{
707
+		global $wpdb;
708
+		// double-check we haven't already done this or that the DB doesn't support it
709
+		// compare to how WordPress' upgrade_430() function does this check
710
+		if (
711
+			'utf8mb4' !== $wpdb->charset
712
+			|| get_option('ee_verified_db_collations_again', false)
713
+		) {
714
+			return;
715
+		}
716
+		$tables_to_check = array(
717
+			'esp_attendee_meta',
718
+			'esp_message'
719
+		);
720
+		$this->_verify_db_collations_for_tables(array_unique($tables_to_check));
721
+		add_option('ee_verified_db_collations_again', true, null, 'no');
722
+	}
723 723
 
724 724
 
725 725
 
726
-    /**
727
-     * Runs maybe_convert_table_to_utf8mb4 on the specified tables
728
-     * @param $tables_to_check
729
-     * @return boolean true if logic ran, false if it didn't
730
-     */
731
-    protected function _verify_db_collations_for_tables($tables_to_check)
732
-    {
733
-        foreach ($tables_to_check as $table_name) {
734
-            $table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
735
-            if (
736
-                ! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
737
-                && $this->_get_table_analysis()->tableExists($table_name)
738
-            ) {
739
-                maybe_convert_table_to_utf8mb4($table_name);
740
-            }
741
-        }
742
-    }
726
+	/**
727
+	 * Runs maybe_convert_table_to_utf8mb4 on the specified tables
728
+	 * @param $tables_to_check
729
+	 * @return boolean true if logic ran, false if it didn't
730
+	 */
731
+	protected function _verify_db_collations_for_tables($tables_to_check)
732
+	{
733
+		foreach ($tables_to_check as $table_name) {
734
+			$table_name = $this->_table_analysis->ensureTableNameHasPrefix($table_name);
735
+			if (
736
+				! apply_filters('FHEE__EE_DMS_Core_4_9_0__verify_db_collations__check_overridden', false, $table_name)
737
+				&& $this->_get_table_analysis()->tableExists($table_name)
738
+			) {
739
+				maybe_convert_table_to_utf8mb4($table_name);
740
+			}
741
+		}
742
+	}
743 743
 }
Please login to merge, or discard this patch.
4_6_0_stages/EE_DMS_4_6_0_invoice_settings.dmsstage.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,8 +66,8 @@
 block discarded – undo
66 66
     {
67 67
 
68 68
         $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
69
-        $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
70
-        $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
69
+        $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', null, false, false, true);
70
+        $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', null, false, false, true);
71 71
         if ($overridden_invoice_body || $overridden_receipt_body) {
72 72
             new PersistentAdminNotice(
73 73
                 'invoice_overriding_templates',
Please login to merge, or discard this patch.
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -27,59 +27,59 @@
 block discarded – undo
27 27
  */
28 28
 class EE_DMS_4_6_0_invoice_settings extends EE_Data_Migration_Script_Stage
29 29
 {
30
-    /**
31
-     * Just initializes the status of the migration
32
-     */
33
-    public function __construct()
34
-    {
35
-        $this->_pretty_name = esc_html__('Update Invoice Settings', 'event_espresso');
36
-        parent::__construct();
37
-    }
30
+	/**
31
+	 * Just initializes the status of the migration
32
+	 */
33
+	public function __construct()
34
+	{
35
+		$this->_pretty_name = esc_html__('Update Invoice Settings', 'event_espresso');
36
+		parent::__construct();
37
+	}
38 38
 
39 39
 
40 40
 
41
-    /**
42
-     * _count_records_to_migrate
43
-     * Counts the records to migrate; the public version may cache it
44
-     *
45
-     * @access protected
46
-     * @return int
47
-     */
48
-    protected function _count_records_to_migrate()
49
-    {
50
-        return 1;
51
-    }
41
+	/**
42
+	 * _count_records_to_migrate
43
+	 * Counts the records to migrate; the public version may cache it
44
+	 *
45
+	 * @access protected
46
+	 * @return int
47
+	 */
48
+	protected function _count_records_to_migrate()
49
+	{
50
+		return 1;
51
+	}
52 52
 
53 53
 
54 54
 
55
-    /**
56
-     *    _migration_step
57
-     *
58
-     * @access protected
59
-     * @param int $num_items
60
-     * @throws EE_Error
61
-     * @return int number of items ACTUALLY migrated
62
-     * @throws InvalidDataTypeException
63
-     */
64
-    protected function _migration_step($num_items = 1)
65
-    {
55
+	/**
56
+	 *    _migration_step
57
+	 *
58
+	 * @access protected
59
+	 * @param int $num_items
60
+	 * @throws EE_Error
61
+	 * @return int number of items ACTUALLY migrated
62
+	 * @throws InvalidDataTypeException
63
+	 */
64
+	protected function _migration_step($num_items = 1)
65
+	{
66 66
 
67
-        $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
68
-        $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
69
-        $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
70
-        if ($overridden_invoice_body || $overridden_receipt_body) {
71
-            new PersistentAdminNotice(
72
-                'invoice_overriding_templates',
73
-                esc_html__(
74
-                    'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
75
-                    'event_espresso'
76
-                ),
77
-                true
78
-            );
79
-        }
67
+		$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
68
+		$overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
69
+		$overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
70
+		if ($overridden_invoice_body || $overridden_receipt_body) {
71
+			new PersistentAdminNotice(
72
+				'invoice_overriding_templates',
73
+				esc_html__(
74
+					'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
75
+					'event_espresso'
76
+				),
77
+				true
78
+			);
79
+		}
80 80
 
81
-        // regardless of whether it worked or not, we ought to continue the migration
82
-        $this->set_completed();
83
-        return 1;
84
-    }
81
+		// regardless of whether it worked or not, we ought to continue the migration
82
+		$this->set_completed();
83
+		return 1;
84
+	}
85 85
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_Public.strategy.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     protected function _generate_restrictions(): array
20 20
     {
21 21
         // if there are no standard caps for this model, then for allow full access
22
-        if (! $this->model()->cap_slug()) {
22
+        if ( ! $this->model()->cap_slug()) {
23 23
             return [];
24 24
         }
25 25
 
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
             )
33 33
         ) {
34 34
             if ($this->model() instanceof EEM_CPT_Base) {
35
-                $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
35
+                $restrictions[EE_Restriction_Generator_Base::get_cap_name(
36 36
                     $this->model(),
37 37
                     $this->action()
38
-                ) ] = new EE_Default_Where_Conditions(
38
+                )] = new EE_Default_Where_Conditions(
39 39
                     $this->addPublishedPostConditions()
40 40
                 );
41 41
             } elseif ($this->model() instanceof EEM_Soft_Delete_Base) {
42
-                $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
42
+                $restrictions[EE_Restriction_Generator_Base::get_cap_name(
43 43
                     $this->model(),
44 44
                     $this->action()
45
-                ) ] = new EE_Default_Where_Conditions(
45
+                )] = new EE_Default_Where_Conditions(
46 46
                     [$this->model()->deleted_field_name() => false]
47 47
                 );
48 48
             }
@@ -52,21 +52,21 @@  discard block
 block discarded – undo
52 52
             if (
53 53
                 EE_Restriction_Generator_Base::is_cap(
54 54
                     $this->model(),
55
-                    $this->action() . '_others'
55
+                    $this->action().'_others'
56 56
                 )
57 57
             ) {// both caps exist
58 58
                 if ($this->model() instanceof EEM_CPT_Base) {
59 59
                     // then if they don't have the others cap,
60 60
                     // AT MOST show them their own and other published ones
61
-                    $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
61
+                    $restrictions[EE_Restriction_Generator_Base::get_cap_name(
62 62
                         $this->model(),
63
-                        $this->action() . '_others'
64
-                    ) ] = new EE_Default_Where_Conditions(
63
+                        $this->action().'_others'
64
+                    )] = new EE_Default_Where_Conditions(
65 65
                         [
66
-                            'OR*' .
66
+                            'OR*'.
67 67
                             EE_Restriction_Generator_Base::get_cap_name(
68 68
                                 $this->model(),
69
-                                $this->action() . '_others'
69
+                                $this->action().'_others'
70 70
                             ) => $this->addPublishedPostConditions(
71 71
                                 [
72 72
                                     EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
                 } elseif ($this->model() instanceof EEM_Soft_Delete_Base) {
78 78
                     // then if they don't have the other cap,
79 79
                     // AT MOST show them their own or non deleted ones
80
-                    $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
80
+                    $restrictions[EE_Restriction_Generator_Base::get_cap_name(
81 81
                         $this->model(),
82
-                        $this->action() . '_others'
83
-                    ) ] = new EE_Default_Where_Conditions(
82
+                        $this->action().'_others'
83
+                    )] = new EE_Default_Where_Conditions(
84 84
                         [
85
-                            'OR*' .
85
+                            'OR*'.
86 86
                             EE_Restriction_Generator_Base::get_cap_name(
87 87
                                 $this->model(),
88
-                                $this->action() . '_others'
88
+                                $this->action().'_others'
89 89
                             ) => [
90 90
                                 EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
91 91
                                 $this->model()->deleted_field_name(
@@ -101,20 +101,20 @@  discard block
 block discarded – undo
101 101
                 if (
102 102
                     EE_Restriction_Generator_Base::is_cap(
103 103
                         $this->model(),
104
-                        $this->action() . '_private'
104
+                        $this->action().'_private'
105 105
                     ) && $this->model() instanceof EEM_CPT_Base
106 106
                 ) {
107 107
                     // if they have basic and others, but not private,
108 108
                     // restrict them to see theirs and others' that aren't private
109
-                    $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
109
+                    $restrictions[EE_Restriction_Generator_Base::get_cap_name(
110 110
                         $this->model(),
111
-                        $this->action() . '_private'
112
-                    ) ] = new EE_Default_Where_Conditions(
111
+                        $this->action().'_private'
112
+                    )] = new EE_Default_Where_Conditions(
113 113
                         [
114
-                            'OR*' .
114
+                            'OR*'.
115 115
                             EE_Restriction_Generator_Base::get_cap_name(
116 116
                                 $this->model(),
117
-                                $this->action() . '_private'
117
+                                $this->action().'_private'
118 118
                             ) => $this->addPublishedPostConditions(
119 119
                                 [
120 120
                                     EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
Please login to merge, or discard this patch.
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -11,123 +11,123 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Restriction_Generator_Public extends EE_Restriction_Generator_Base
13 13
 {
14
-    /**
15
-     * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
16
-     * @throws EE_Error
17
-     */
18
-    protected function _generate_restrictions(): array
19
-    {
20
-        // if there are no standard caps for this model, then for allow full access
21
-        if (! $this->model()->cap_slug()) {
22
-            return [];
23
-        }
14
+	/**
15
+	 * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
16
+	 * @throws EE_Error
17
+	 */
18
+	protected function _generate_restrictions(): array
19
+	{
20
+		// if there are no standard caps for this model, then for allow full access
21
+		if (! $this->model()->cap_slug()) {
22
+			return [];
23
+		}
24 24
 
25
-        $restrictions = [];
26
-        // does the basic cap exist? (eg 'ee_read_registrations')
27
-        if (
28
-            EE_Restriction_Generator_Base::is_cap(
29
-                $this->model(),
30
-                $this->action()
31
-            )
32
-        ) {
33
-            if ($this->model() instanceof EEM_CPT_Base) {
34
-                $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
35
-                    $this->model(),
36
-                    $this->action()
37
-                ) ] = new EE_Default_Where_Conditions(
38
-                    $this->addPublishedPostConditions()
39
-                );
40
-            } elseif ($this->model() instanceof EEM_Soft_Delete_Base) {
41
-                $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
42
-                    $this->model(),
43
-                    $this->action()
44
-                ) ] = new EE_Default_Where_Conditions(
45
-                    [$this->model()->deleted_field_name() => false]
46
-                );
47
-            }
48
-            // don't impose any restrictions if they don't have the basic reading cap
25
+		$restrictions = [];
26
+		// does the basic cap exist? (eg 'ee_read_registrations')
27
+		if (
28
+			EE_Restriction_Generator_Base::is_cap(
29
+				$this->model(),
30
+				$this->action()
31
+			)
32
+		) {
33
+			if ($this->model() instanceof EEM_CPT_Base) {
34
+				$restrictions[ EE_Restriction_Generator_Base::get_cap_name(
35
+					$this->model(),
36
+					$this->action()
37
+				) ] = new EE_Default_Where_Conditions(
38
+					$this->addPublishedPostConditions()
39
+				);
40
+			} elseif ($this->model() instanceof EEM_Soft_Delete_Base) {
41
+				$restrictions[ EE_Restriction_Generator_Base::get_cap_name(
42
+					$this->model(),
43
+					$this->action()
44
+				) ] = new EE_Default_Where_Conditions(
45
+					[$this->model()->deleted_field_name() => false]
46
+				);
47
+			}
48
+			// don't impose any restrictions if they don't have the basic reading cap
49 49
 
50
-            // does the others cap exist? (eg 'ee_read_others_registrations')
51
-            if (
52
-                EE_Restriction_Generator_Base::is_cap(
53
-                    $this->model(),
54
-                    $this->action() . '_others'
55
-                )
56
-            ) {// both caps exist
57
-                if ($this->model() instanceof EEM_CPT_Base) {
58
-                    // then if they don't have the others cap,
59
-                    // AT MOST show them their own and other published ones
60
-                    $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
61
-                        $this->model(),
62
-                        $this->action() . '_others'
63
-                    ) ] = new EE_Default_Where_Conditions(
64
-                        [
65
-                            'OR*' .
66
-                            EE_Restriction_Generator_Base::get_cap_name(
67
-                                $this->model(),
68
-                                $this->action() . '_others'
69
-                            ) => $this->addPublishedPostConditions(
70
-                                [
71
-                                    EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
72
-                                ]
73
-                            ),
74
-                        ]
75
-                    );
76
-                } elseif ($this->model() instanceof EEM_Soft_Delete_Base) {
77
-                    // then if they don't have the other cap,
78
-                    // AT MOST show them their own or non deleted ones
79
-                    $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
80
-                        $this->model(),
81
-                        $this->action() . '_others'
82
-                    ) ] = new EE_Default_Where_Conditions(
83
-                        [
84
-                            'OR*' .
85
-                            EE_Restriction_Generator_Base::get_cap_name(
86
-                                $this->model(),
87
-                                $this->action() . '_others'
88
-                            ) => [
89
-                                EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
90
-                                $this->model()->deleted_field_name(
91
-                                )                                    => false,
92
-                            ],
93
-                        ]
94
-                    );
95
-                }
96
-                // again, if they don't have the others cap,
97
-                // continue showing all because there are no inherently hidden ones
50
+			// does the others cap exist? (eg 'ee_read_others_registrations')
51
+			if (
52
+				EE_Restriction_Generator_Base::is_cap(
53
+					$this->model(),
54
+					$this->action() . '_others'
55
+				)
56
+			) {// both caps exist
57
+				if ($this->model() instanceof EEM_CPT_Base) {
58
+					// then if they don't have the others cap,
59
+					// AT MOST show them their own and other published ones
60
+					$restrictions[ EE_Restriction_Generator_Base::get_cap_name(
61
+						$this->model(),
62
+						$this->action() . '_others'
63
+					) ] = new EE_Default_Where_Conditions(
64
+						[
65
+							'OR*' .
66
+							EE_Restriction_Generator_Base::get_cap_name(
67
+								$this->model(),
68
+								$this->action() . '_others'
69
+							) => $this->addPublishedPostConditions(
70
+								[
71
+									EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
72
+								]
73
+							),
74
+						]
75
+					);
76
+				} elseif ($this->model() instanceof EEM_Soft_Delete_Base) {
77
+					// then if they don't have the other cap,
78
+					// AT MOST show them their own or non deleted ones
79
+					$restrictions[ EE_Restriction_Generator_Base::get_cap_name(
80
+						$this->model(),
81
+						$this->action() . '_others'
82
+					) ] = new EE_Default_Where_Conditions(
83
+						[
84
+							'OR*' .
85
+							EE_Restriction_Generator_Base::get_cap_name(
86
+								$this->model(),
87
+								$this->action() . '_others'
88
+							) => [
89
+								EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
90
+								$this->model()->deleted_field_name(
91
+								)                                    => false,
92
+							],
93
+						]
94
+					);
95
+				}
96
+				// again, if they don't have the others cap,
97
+				// continue showing all because there are no inherently hidden ones
98 98
 
99
-                // does the private cap exist (eg 'ee_read_others_private_events')
100
-                if (
101
-                    EE_Restriction_Generator_Base::is_cap(
102
-                        $this->model(),
103
-                        $this->action() . '_private'
104
-                    ) && $this->model() instanceof EEM_CPT_Base
105
-                ) {
106
-                    // if they have basic and others, but not private,
107
-                    // restrict them to see theirs and others' that aren't private
108
-                    $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
109
-                        $this->model(),
110
-                        $this->action() . '_private'
111
-                    ) ] = new EE_Default_Where_Conditions(
112
-                        [
113
-                            'OR*' .
114
-                            EE_Restriction_Generator_Base::get_cap_name(
115
-                                $this->model(),
116
-                                $this->action() . '_private'
117
-                            ) => $this->addPublishedPostConditions(
118
-                                [
119
-                                    EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
120
-                                ],
121
-                                false
122
-                            ),
123
-                        ]
124
-                    );
125
-                }
126
-            }
127
-        } else {
128
-            // there is no basic cap. So allow full access
129
-            $restrictions = [];
130
-        }
131
-        return $restrictions;
132
-    }
99
+				// does the private cap exist (eg 'ee_read_others_private_events')
100
+				if (
101
+					EE_Restriction_Generator_Base::is_cap(
102
+						$this->model(),
103
+						$this->action() . '_private'
104
+					) && $this->model() instanceof EEM_CPT_Base
105
+				) {
106
+					// if they have basic and others, but not private,
107
+					// restrict them to see theirs and others' that aren't private
108
+					$restrictions[ EE_Restriction_Generator_Base::get_cap_name(
109
+						$this->model(),
110
+						$this->action() . '_private'
111
+					) ] = new EE_Default_Where_Conditions(
112
+						[
113
+							'OR*' .
114
+							EE_Restriction_Generator_Base::get_cap_name(
115
+								$this->model(),
116
+								$this->action() . '_private'
117
+							) => $this->addPublishedPostConditions(
118
+								[
119
+									EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
120
+								],
121
+								false
122
+							),
123
+						]
124
+					);
125
+				}
126
+			}
127
+		} else {
128
+			// there is no basic cap. So allow full access
129
+			$restrictions = [];
130
+		}
131
+		return $restrictions;
132
+	}
133 133
 }
Please login to merge, or discard this patch.
strategies/EE_Restriction_Generator_Default_Protected.strategy.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function __construct(string $default_field_name, string $path_to_event_model)
44 44
     {
45 45
         $this->_default_field_name  = $default_field_name;
46
-        $this->_path_to_event_model = rtrim($path_to_event_model, '.') . '.';
46
+        $this->_path_to_event_model = rtrim($path_to_event_model, '.').'.';
47 47
     }
48 48
 
49 49
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     {
56 56
         // if there are no standard caps for this model, then for now
57 57
         // all we know is if they need the default cap to access this
58
-        if (! $this->model()->cap_slug()) {
58
+        if ( ! $this->model()->cap_slug()) {
59 59
             return [
60 60
                 self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(),
61 61
             ];
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         // if they don't have the "others" default capability,
84 84
         // restrict access to only their default ones, and non-default ones
85 85
         if (EE_Restriction_Generator_Base::is_cap($this->model(), $others_default)) {
86
-            $restrictions[ $this->getCapKey($this->model(), $others_default) ] = $this->othersDefaultRestrictions(
86
+            $restrictions[$this->getCapKey($this->model(), $others_default)] = $this->othersDefaultRestrictions(
87 87
                 $others_default
88 88
             );
89 89
         }
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
             [
127 127
                 // if they don't have the others default cap, they can't access others default items
128 128
                 // (but they can access their own default items, and non-default items)
129
-                'OR*no_' . $this->getCapKey($this->model(), $action) => [
129
+                'OR*no_'.$this->getCapKey($this->model(), $action) => [
130 130
                     'AND'                      => [
131
-                        $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
131
+                        $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
132 132
                         $this->_default_field_name                  => true,
133 133
                     ],
134 134
                     $this->_default_field_name => false,
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
     {
149 149
         return new EE_Default_Where_Conditions(
150 150
             [
151
-                'OR*no_' . $this->getCapKey($event_model, $action) => [
152
-                    $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
151
+                'OR*no_'.$this->getCapKey($event_model, $action) => [
152
+                    $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
153 153
                 ],
154 154
                 $this->_default_field_name                         => true,
155 155
             ]
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
     {
168 168
         return new EE_Default_Where_Conditions(
169 169
             [
170
-                'OR*no_' . $this->getCapKey($event_model, $action) => [
171
-                    $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
172
-                    $this->_path_to_event_model . 'status'      => ['!=', 'private'],
170
+                'OR*no_'.$this->getCapKey($event_model, $action) => [
171
+                    $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
172
+                    $this->_path_to_event_model.'status'      => ['!=', 'private'],
173 173
                     $this->_default_field_name                  => true,
174 174
                 ],
175 175
             ]
Please login to merge, or discard this patch.
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -14,164 +14,164 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Restriction_Generator_Default_Protected extends EE_Restriction_Generator_Base
16 16
 {
17
-    /**
18
-     * Name of the field on this model (or a related model, including the model chain to it)
19
-     * that is a boolean indicating whether or not a model object is considered "Default" or not
20
-     *
21
-     * @var string
22
-     */
23
-    protected $_default_field_name;
24
-
25
-    /**
26
-     * The model chain to follow to get to the event model, including the event model itself.
27
-     * Eg 'Ticket.Datetime.Event'
28
-     *
29
-     * @var string
30
-     */
31
-    protected $_path_to_event_model;
32
-
33
-
34
-    /**
35
-     * @param string $default_field_name  the name of the field Name of the field on this model
36
-     *                                    (or a related model, including the model chain to it)
37
-     *                                    that is a boolean indicating whether or not a model object
38
-     *                                    is considered "Default" or not
39
-     * @param string $path_to_event_model The model chain to follow to get to the event model,
40
-     *                                    including the event model itself. Eg 'Ticket.Datetime.Event'
41
-     */
42
-    public function __construct(string $default_field_name, string $path_to_event_model)
43
-    {
44
-        $this->_default_field_name  = $default_field_name;
45
-        $this->_path_to_event_model = rtrim($path_to_event_model, '.') . '.';
46
-    }
47
-
48
-
49
-    /**
50
-     * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
51
-     * @throws EE_Error
52
-     */
53
-    protected function _generate_restrictions(): array
54
-    {
55
-        // if there are no standard caps for this model, then for now
56
-        // all we know is if they need the default cap to access this
57
-        if (! $this->model()->cap_slug()) {
58
-            return [
59
-                self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(),
60
-            ];
61
-        }
62
-
63
-        $action         = $this->action();
64
-        $others         = "{$action}_others";
65
-        $private        = "{$action}_private";
66
-        $default        = "{$action}_default";
67
-        $others_default = "{$action}_others_default";
68
-        $event_model    = EEM_Event::instance();
69
-
70
-        $restrictions = [
71
-            // first: access to non-defaults is essentially controlled by which events are accessible
72
-            // if they don't have the basic event cap, they can't access ANY non-default items
73
-            $this->getCapKey($event_model, $action)    => $this->nonDefaultRestrictions(true),
74
-            // if they don't have the others event cap, they can't access others' non-default items
75
-            $this->getCapKey($event_model, $others)    => $this->othersNonDefaultRestrictions($event_model, $others),
76
-            // if they have basic and others, but not private, they can't access others' private non-default items
77
-            $this->getCapKey($event_model, $private)   => $this->privateRestrictions($event_model, $private),
78
-            // second: access to defaults is controlled by the default capabilities
79
-            // if they don't have the default capability, restrict access to only non-default items
80
-            $this->getCapKey($this->model(), $default) => $this->nonDefaultRestrictions(false),
81
-        ];
82
-        // if they don't have the "others" default capability,
83
-        // restrict access to only their default ones, and non-default ones
84
-        if (EE_Restriction_Generator_Base::is_cap($this->model(), $others_default)) {
85
-            $restrictions[ $this->getCapKey($this->model(), $others_default) ] = $this->othersDefaultRestrictions(
86
-                $others_default
87
-            );
88
-        }
89
-        return $restrictions;
90
-    }
91
-
92
-
93
-    /**
94
-     * @param EEM_Base $model
95
-     * @param string   $action
96
-     * @return string
97
-     * @since   5.0.0.p
98
-     */
99
-    private function getCapKey(EEM_Base $model, string $action): string
100
-    {
101
-        return EE_Restriction_Generator_Base::get_cap_name($model, $action);
102
-    }
103
-
104
-
105
-    /**
106
-     * @param bool $use_default_field_name
107
-     * @return EE_Default_Where_Conditions
108
-     * @since   5.0.0.p
109
-     */
110
-    private function nonDefaultRestrictions(bool $use_default_field_name): EE_Default_Where_Conditions
111
-    {
112
-        return new EE_Default_Where_Conditions([$this->_default_field_name => $use_default_field_name]);
113
-    }
114
-
115
-
116
-    /**
117
-     * @param string $action
118
-     * @return EE_Default_Where_Conditions
119
-     * @throws EE_Error
120
-     * @since   5.0.0.p
121
-     */
122
-    private function othersDefaultRestrictions(string $action): EE_Default_Where_Conditions
123
-    {
124
-        return new EE_Default_Where_Conditions(
125
-            [
126
-                // if they don't have the others default cap, they can't access others default items
127
-                // (but they can access their own default items, and non-default items)
128
-                'OR*no_' . $this->getCapKey($this->model(), $action) => [
129
-                    'AND'                      => [
130
-                        $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
131
-                        $this->_default_field_name                  => true,
132
-                    ],
133
-                    $this->_default_field_name => false,
134
-                ],
135
-            ]
136
-        );
137
-    }
138
-
139
-
140
-    /**
141
-     * @param EEM_Event $event_model
142
-     * @param string    $action
143
-     * @return EE_Default_Where_Conditions
144
-     * @since   5.0.0.p
145
-     */
146
-    private function othersNonDefaultRestrictions(EEM_Event $event_model, string $action): EE_Default_Where_Conditions
147
-    {
148
-        return new EE_Default_Where_Conditions(
149
-            [
150
-                'OR*no_' . $this->getCapKey($event_model, $action) => [
151
-                    $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
152
-                ],
153
-                $this->_default_field_name                         => true,
154
-            ]
155
-        );
156
-    }
157
-
158
-
159
-    /**
160
-     * @param EEM_Event $event_model
161
-     * @param string    $action
162
-     * @return EE_Default_Where_Conditions
163
-     * @since   5.0.0.p
164
-     */
165
-    private function privateRestrictions(EEM_Event $event_model, string $action): EE_Default_Where_Conditions
166
-    {
167
-        return new EE_Default_Where_Conditions(
168
-            [
169
-                'OR*no_' . $this->getCapKey($event_model, $action) => [
170
-                    $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
171
-                    $this->_path_to_event_model . 'status'      => ['!=', 'private'],
172
-                    $this->_default_field_name                  => true,
173
-                ],
174
-            ]
175
-        );
176
-    }
17
+	/**
18
+	 * Name of the field on this model (or a related model, including the model chain to it)
19
+	 * that is a boolean indicating whether or not a model object is considered "Default" or not
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $_default_field_name;
24
+
25
+	/**
26
+	 * The model chain to follow to get to the event model, including the event model itself.
27
+	 * Eg 'Ticket.Datetime.Event'
28
+	 *
29
+	 * @var string
30
+	 */
31
+	protected $_path_to_event_model;
32
+
33
+
34
+	/**
35
+	 * @param string $default_field_name  the name of the field Name of the field on this model
36
+	 *                                    (or a related model, including the model chain to it)
37
+	 *                                    that is a boolean indicating whether or not a model object
38
+	 *                                    is considered "Default" or not
39
+	 * @param string $path_to_event_model The model chain to follow to get to the event model,
40
+	 *                                    including the event model itself. Eg 'Ticket.Datetime.Event'
41
+	 */
42
+	public function __construct(string $default_field_name, string $path_to_event_model)
43
+	{
44
+		$this->_default_field_name  = $default_field_name;
45
+		$this->_path_to_event_model = rtrim($path_to_event_model, '.') . '.';
46
+	}
47
+
48
+
49
+	/**
50
+	 * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
51
+	 * @throws EE_Error
52
+	 */
53
+	protected function _generate_restrictions(): array
54
+	{
55
+		// if there are no standard caps for this model, then for now
56
+		// all we know is if they need the default cap to access this
57
+		if (! $this->model()->cap_slug()) {
58
+			return [
59
+				self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(),
60
+			];
61
+		}
62
+
63
+		$action         = $this->action();
64
+		$others         = "{$action}_others";
65
+		$private        = "{$action}_private";
66
+		$default        = "{$action}_default";
67
+		$others_default = "{$action}_others_default";
68
+		$event_model    = EEM_Event::instance();
69
+
70
+		$restrictions = [
71
+			// first: access to non-defaults is essentially controlled by which events are accessible
72
+			// if they don't have the basic event cap, they can't access ANY non-default items
73
+			$this->getCapKey($event_model, $action)    => $this->nonDefaultRestrictions(true),
74
+			// if they don't have the others event cap, they can't access others' non-default items
75
+			$this->getCapKey($event_model, $others)    => $this->othersNonDefaultRestrictions($event_model, $others),
76
+			// if they have basic and others, but not private, they can't access others' private non-default items
77
+			$this->getCapKey($event_model, $private)   => $this->privateRestrictions($event_model, $private),
78
+			// second: access to defaults is controlled by the default capabilities
79
+			// if they don't have the default capability, restrict access to only non-default items
80
+			$this->getCapKey($this->model(), $default) => $this->nonDefaultRestrictions(false),
81
+		];
82
+		// if they don't have the "others" default capability,
83
+		// restrict access to only their default ones, and non-default ones
84
+		if (EE_Restriction_Generator_Base::is_cap($this->model(), $others_default)) {
85
+			$restrictions[ $this->getCapKey($this->model(), $others_default) ] = $this->othersDefaultRestrictions(
86
+				$others_default
87
+			);
88
+		}
89
+		return $restrictions;
90
+	}
91
+
92
+
93
+	/**
94
+	 * @param EEM_Base $model
95
+	 * @param string   $action
96
+	 * @return string
97
+	 * @since   5.0.0.p
98
+	 */
99
+	private function getCapKey(EEM_Base $model, string $action): string
100
+	{
101
+		return EE_Restriction_Generator_Base::get_cap_name($model, $action);
102
+	}
103
+
104
+
105
+	/**
106
+	 * @param bool $use_default_field_name
107
+	 * @return EE_Default_Where_Conditions
108
+	 * @since   5.0.0.p
109
+	 */
110
+	private function nonDefaultRestrictions(bool $use_default_field_name): EE_Default_Where_Conditions
111
+	{
112
+		return new EE_Default_Where_Conditions([$this->_default_field_name => $use_default_field_name]);
113
+	}
114
+
115
+
116
+	/**
117
+	 * @param string $action
118
+	 * @return EE_Default_Where_Conditions
119
+	 * @throws EE_Error
120
+	 * @since   5.0.0.p
121
+	 */
122
+	private function othersDefaultRestrictions(string $action): EE_Default_Where_Conditions
123
+	{
124
+		return new EE_Default_Where_Conditions(
125
+			[
126
+				// if they don't have the others default cap, they can't access others default items
127
+				// (but they can access their own default items, and non-default items)
128
+				'OR*no_' . $this->getCapKey($this->model(), $action) => [
129
+					'AND'                      => [
130
+						$this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
131
+						$this->_default_field_name                  => true,
132
+					],
133
+					$this->_default_field_name => false,
134
+				],
135
+			]
136
+		);
137
+	}
138
+
139
+
140
+	/**
141
+	 * @param EEM_Event $event_model
142
+	 * @param string    $action
143
+	 * @return EE_Default_Where_Conditions
144
+	 * @since   5.0.0.p
145
+	 */
146
+	private function othersNonDefaultRestrictions(EEM_Event $event_model, string $action): EE_Default_Where_Conditions
147
+	{
148
+		return new EE_Default_Where_Conditions(
149
+			[
150
+				'OR*no_' . $this->getCapKey($event_model, $action) => [
151
+					$this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
152
+				],
153
+				$this->_default_field_name                         => true,
154
+			]
155
+		);
156
+	}
157
+
158
+
159
+	/**
160
+	 * @param EEM_Event $event_model
161
+	 * @param string    $action
162
+	 * @return EE_Default_Where_Conditions
163
+	 * @since   5.0.0.p
164
+	 */
165
+	private function privateRestrictions(EEM_Event $event_model, string $action): EE_Default_Where_Conditions
166
+	{
167
+		return new EE_Default_Where_Conditions(
168
+			[
169
+				'OR*no_' . $this->getCapKey($event_model, $action) => [
170
+					$this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
171
+					$this->_path_to_event_model . 'status'      => ['!=', 'private'],
172
+					$this->_default_field_name                  => true,
173
+				],
174
+			]
175
+		);
176
+	}
177 177
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_Protected.strategy.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     {
30 30
         // if there are no standard caps for this model, then for now all we know
31 31
         // if they need the default cap to access this
32
-        if (! $this->model()->cap_slug()) {
32
+        if ( ! $this->model()->cap_slug()) {
33 33
             return [
34 34
                 EE_Restriction_Generator_Base::get_default_restrictions_cap(
35 35
                 ) => new EE_Return_None_Where_Conditions(),
@@ -44,22 +44,22 @@  discard block
 block discarded – undo
44 44
                 $this->action()
45 45
             )
46 46
         ) {
47
-            $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
47
+            $restrictions[EE_Restriction_Generator_Base::get_cap_name(
48 48
                 $this->model(),
49 49
                 $this->action()
50
-            ) ] = new EE_Return_None_Where_Conditions();
50
+            )] = new EE_Return_None_Where_Conditions();
51 51
             // does the others cap exist? (eg 'ee_read_others_registrations')
52 52
             if (
53 53
                 EE_Restriction_Generator_Base::is_cap(
54 54
                     $this->model(),
55
-                    $this->action() . '_others'
55
+                    $this->action().'_others'
56 56
                 )
57 57
             ) {
58 58
                 // both caps exist
59
-                $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
59
+                $restrictions[EE_Restriction_Generator_Base::get_cap_name(
60 60
                     $this->model(),
61
-                    $this->action() . '_others'
62
-                ) ] = new EE_Default_Where_Conditions(
61
+                    $this->action().'_others'
62
+                )] = new EE_Default_Where_Conditions(
63 63
                     [
64 64
                         EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
65 65
                     ]
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
                 if (
69 69
                     EE_Restriction_Generator_Base::is_cap(
70 70
                         $this->model(),
71
-                        $this->action() . '_private'
71
+                        $this->action().'_private'
72 72
                     ) && $this->model() instanceof EEM_CPT_Base
73 73
                 ) {
74 74
                     // if they have basic and others, but not private,
75 75
                     // restrict them to see theirs and others' that aren't private
76
-                    $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
76
+                    $restrictions[EE_Restriction_Generator_Base::get_cap_name(
77 77
                         $this->model(),
78
-                        $this->action() . '_private'
79
-                    ) ] = new EE_Default_Where_Conditions(
78
+                        $this->action().'_private'
79
+                    )] = new EE_Default_Where_Conditions(
80 80
                         [
81
-                            'OR*no_' .
81
+                            'OR*no_'.
82 82
                             EE_Restriction_Generator_Base::get_cap_name(
83 83
                                 $this->model(),
84
-                                $this->action() . '_private'
84
+                                $this->action().'_private'
85 85
                             ) => [
86 86
                                 EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
87 87
                                 'status'                             => [
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
         } else {
97 97
             // there is no basic cap.
98 98
             // So they can only access this if they have the default admin cap
99
-            $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap(
100
-            ) ] = new EE_Return_None_Where_Conditions();
99
+            $restrictions[EE_Restriction_Generator_Base::get_default_restrictions_cap(
100
+            )] = new EE_Return_None_Where_Conditions();
101 101
         }
102 102
         return $restrictions;
103 103
     }
Please login to merge, or discard this patch.
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -20,84 +20,84 @@
 block discarded – undo
20 20
  */
21 21
 class EE_Restriction_Generator_Protected extends EE_Restriction_Generator_Base
22 22
 {
23
-    /**
24
-     * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
25
-     * @throws EE_Error
26
-     */
27
-    protected function _generate_restrictions(): array
28
-    {
29
-        // if there are no standard caps for this model, then for now all we know
30
-        // if they need the default cap to access this
31
-        if (! $this->model()->cap_slug()) {
32
-            return [
33
-                EE_Restriction_Generator_Base::get_default_restrictions_cap(
34
-                ) => new EE_Return_None_Where_Conditions(),
35
-            ];
36
-        }
23
+	/**
24
+	 * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
25
+	 * @throws EE_Error
26
+	 */
27
+	protected function _generate_restrictions(): array
28
+	{
29
+		// if there are no standard caps for this model, then for now all we know
30
+		// if they need the default cap to access this
31
+		if (! $this->model()->cap_slug()) {
32
+			return [
33
+				EE_Restriction_Generator_Base::get_default_restrictions_cap(
34
+				) => new EE_Return_None_Where_Conditions(),
35
+			];
36
+		}
37 37
 
38
-        $restrictions = [];
39
-        // does the basic cap exist? (eg 'ee_read_registrations')
40
-        if (
41
-            EE_Restriction_Generator_Base::is_cap(
42
-                $this->model(),
43
-                $this->action()
44
-            )
45
-        ) {
46
-            $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
47
-                $this->model(),
48
-                $this->action()
49
-            ) ] = new EE_Return_None_Where_Conditions();
50
-            // does the others cap exist? (eg 'ee_read_others_registrations')
51
-            if (
52
-                EE_Restriction_Generator_Base::is_cap(
53
-                    $this->model(),
54
-                    $this->action() . '_others'
55
-                )
56
-            ) {
57
-                // both caps exist
58
-                $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
59
-                    $this->model(),
60
-                    $this->action() . '_others'
61
-                ) ] = new EE_Default_Where_Conditions(
62
-                    [
63
-                        EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
64
-                    ]
65
-                );
66
-                // does the private cap exist (eg 'ee_read_others_private_events')
67
-                if (
68
-                    EE_Restriction_Generator_Base::is_cap(
69
-                        $this->model(),
70
-                        $this->action() . '_private'
71
-                    ) && $this->model() instanceof EEM_CPT_Base
72
-                ) {
73
-                    // if they have basic and others, but not private,
74
-                    // restrict them to see theirs and others' that aren't private
75
-                    $restrictions[ EE_Restriction_Generator_Base::get_cap_name(
76
-                        $this->model(),
77
-                        $this->action() . '_private'
78
-                    ) ] = new EE_Default_Where_Conditions(
79
-                        [
80
-                            'OR*no_' .
81
-                            EE_Restriction_Generator_Base::get_cap_name(
82
-                                $this->model(),
83
-                                $this->action() . '_private'
84
-                            ) => [
85
-                                EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
86
-                                'status'                             => [
87
-                                    '!=',
88
-                                    'private',
89
-                                ],
90
-                            ],
91
-                        ]
92
-                    );
93
-                }
94
-            }
95
-        } else {
96
-            // there is no basic cap.
97
-            // So they can only access this if they have the default admin cap
98
-            $restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap(
99
-            ) ] = new EE_Return_None_Where_Conditions();
100
-        }
101
-        return $restrictions;
102
-    }
38
+		$restrictions = [];
39
+		// does the basic cap exist? (eg 'ee_read_registrations')
40
+		if (
41
+			EE_Restriction_Generator_Base::is_cap(
42
+				$this->model(),
43
+				$this->action()
44
+			)
45
+		) {
46
+			$restrictions[ EE_Restriction_Generator_Base::get_cap_name(
47
+				$this->model(),
48
+				$this->action()
49
+			) ] = new EE_Return_None_Where_Conditions();
50
+			// does the others cap exist? (eg 'ee_read_others_registrations')
51
+			if (
52
+				EE_Restriction_Generator_Base::is_cap(
53
+					$this->model(),
54
+					$this->action() . '_others'
55
+				)
56
+			) {
57
+				// both caps exist
58
+				$restrictions[ EE_Restriction_Generator_Base::get_cap_name(
59
+					$this->model(),
60
+					$this->action() . '_others'
61
+				) ] = new EE_Default_Where_Conditions(
62
+					[
63
+						EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
64
+					]
65
+				);
66
+				// does the private cap exist (eg 'ee_read_others_private_events')
67
+				if (
68
+					EE_Restriction_Generator_Base::is_cap(
69
+						$this->model(),
70
+						$this->action() . '_private'
71
+					) && $this->model() instanceof EEM_CPT_Base
72
+				) {
73
+					// if they have basic and others, but not private,
74
+					// restrict them to see theirs and others' that aren't private
75
+					$restrictions[ EE_Restriction_Generator_Base::get_cap_name(
76
+						$this->model(),
77
+						$this->action() . '_private'
78
+					) ] = new EE_Default_Where_Conditions(
79
+						[
80
+							'OR*no_' .
81
+							EE_Restriction_Generator_Base::get_cap_name(
82
+								$this->model(),
83
+								$this->action() . '_private'
84
+							) => [
85
+								EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
86
+								'status'                             => [
87
+									'!=',
88
+									'private',
89
+								],
90
+							],
91
+						]
92
+					);
93
+				}
94
+			}
95
+		} else {
96
+			// there is no basic cap.
97
+			// So they can only access this if they have the default admin cap
98
+			$restrictions[ EE_Restriction_Generator_Base::get_default_restrictions_cap(
99
+			) ] = new EE_Return_None_Where_Conditions();
100
+		}
101
+		return $restrictions;
102
+	}
103 103
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Restriction_Generator_Global.strategy.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
     {
49 49
         // if there are no standard caps for this model, then for now
50 50
         // all we know is if they need the default cap to access this
51
-        if (! $this->model()->cap_slug()) {
51
+        if ( ! $this->model()->cap_slug()) {
52 52
             return [
53 53
                 EE_Restriction_Generator_Base::get_default_restrictions_cap(
54 54
                 ) => new EE_Return_None_Where_Conditions(),
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
             ) => new EE_Return_None_Where_Conditions(),
62 62
             EE_Restriction_Generator_Base::get_cap_name(
63 63
                 $this->model(),
64
-                $this->action() . '_others'
64
+                $this->action().'_others'
65 65
             ) => new EE_Default_Where_Conditions(
66 66
                 [
67 67
                     // I need to be the owner, or it must be a global item
68
-                    'OR*no_' .
68
+                    'OR*no_'.
69 69
                     EE_Restriction_Generator_Base::get_cap_name(
70 70
                         $this->model(),
71
-                        $this->action() . '_others'
71
+                        $this->action().'_others'
72 72
                     ) => [
73 73
                         EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
74 74
                         $this->_global_field_name            => true,
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             ),
78 78
             EE_Restriction_Generator_Base::get_cap_name(
79 79
                 $this->model(),
80
-                $this->action() . '_global'
80
+                $this->action().'_global'
81 81
             ) => new EE_Default_Where_Conditions(
82 82
                 [
83 83
                     // it mustn't be global
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -19,70 +19,70 @@
 block discarded – undo
19 19
  */
20 20
 class EE_Restriction_Generator_Global extends EE_Restriction_Generator_Base
21 21
 {
22
-    /**
23
-     * name of the model field that indicates whether or not a model object is
24
-     * "global"
25
-     *
26
-     * @var string
27
-     */
28
-    protected $_global_field_name;
22
+	/**
23
+	 * name of the model field that indicates whether or not a model object is
24
+	 * "global"
25
+	 *
26
+	 * @var string
27
+	 */
28
+	protected $_global_field_name;
29 29
 
30 30
 
31
-    /**
32
-     * @param string $global_field_name name of the model field that indicates
33
-     *                                  whether or not a model object is
34
-     *                                  "global"
35
-     */
36
-    public function __construct(string $global_field_name)
37
-    {
38
-        $this->_global_field_name = $global_field_name;
39
-    }
31
+	/**
32
+	 * @param string $global_field_name name of the model field that indicates
33
+	 *                                  whether or not a model object is
34
+	 *                                  "global"
35
+	 */
36
+	public function __construct(string $global_field_name)
37
+	{
38
+		$this->_global_field_name = $global_field_name;
39
+	}
40 40
 
41 41
 
42
-    /**
43
-     * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
44
-     * @throws EE_Error
45
-     */
46
-    protected function _generate_restrictions(): array
47
-    {
48
-        // if there are no standard caps for this model, then for now
49
-        // all we know is if they need the default cap to access this
50
-        if (! $this->model()->cap_slug()) {
51
-            return [
52
-                EE_Restriction_Generator_Base::get_default_restrictions_cap(
53
-                ) => new EE_Return_None_Where_Conditions(),
54
-            ];
55
-        }
56
-        return [
57
-            EE_Restriction_Generator_Base::get_cap_name(
58
-                $this->model(),
59
-                $this->action()
60
-            ) => new EE_Return_None_Where_Conditions(),
61
-            EE_Restriction_Generator_Base::get_cap_name(
62
-                $this->model(),
63
-                $this->action() . '_others'
64
-            ) => new EE_Default_Where_Conditions(
65
-                [
66
-                    // I need to be the owner, or it must be a global item
67
-                    'OR*no_' .
68
-                    EE_Restriction_Generator_Base::get_cap_name(
69
-                        $this->model(),
70
-                        $this->action() . '_others'
71
-                    ) => [
72
-                        EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
73
-                        $this->_global_field_name            => true,
74
-                    ],
75
-                ]
76
-            ),
77
-            EE_Restriction_Generator_Base::get_cap_name(
78
-                $this->model(),
79
-                $this->action() . '_global'
80
-            ) => new EE_Default_Where_Conditions(
81
-                [
82
-                    // it mustn't be global
83
-                    $this->_global_field_name => false,
84
-                ]
85
-            ),
86
-        ];
87
-    }
42
+	/**
43
+	 * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
44
+	 * @throws EE_Error
45
+	 */
46
+	protected function _generate_restrictions(): array
47
+	{
48
+		// if there are no standard caps for this model, then for now
49
+		// all we know is if they need the default cap to access this
50
+		if (! $this->model()->cap_slug()) {
51
+			return [
52
+				EE_Restriction_Generator_Base::get_default_restrictions_cap(
53
+				) => new EE_Return_None_Where_Conditions(),
54
+			];
55
+		}
56
+		return [
57
+			EE_Restriction_Generator_Base::get_cap_name(
58
+				$this->model(),
59
+				$this->action()
60
+			) => new EE_Return_None_Where_Conditions(),
61
+			EE_Restriction_Generator_Base::get_cap_name(
62
+				$this->model(),
63
+				$this->action() . '_others'
64
+			) => new EE_Default_Where_Conditions(
65
+				[
66
+					// I need to be the owner, or it must be a global item
67
+					'OR*no_' .
68
+					EE_Restriction_Generator_Base::get_cap_name(
69
+						$this->model(),
70
+						$this->action() . '_others'
71
+					) => [
72
+						EE_QUERY_PLACEHOLDER_USER_FIELD_NAME => EE_QUERY_PLACEHOLDER_CURRENT_USER,
73
+						$this->_global_field_name            => true,
74
+					],
75
+				]
76
+			),
77
+			EE_Restriction_Generator_Base::get_cap_name(
78
+				$this->model(),
79
+				$this->action() . '_global'
80
+			) => new EE_Default_Where_Conditions(
81
+				[
82
+					// it mustn't be global
83
+					$this->_global_field_name => false,
84
+				]
85
+			),
86
+		];
87
+	}
88 88
 }
Please login to merge, or discard this patch.
strategies/EE_Restriction_Generator_Event_Related_Public.strategy.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         // if there are no standard caps for this model, then for now
46 46
         // all we know if they need the default cap to access this
47
-        if (! $this->model()->cap_slug()) {
47
+        if ( ! $this->model()->cap_slug()) {
48 48
             return [
49 49
                 self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(),
50 50
             ];
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
             // they can't access others' non-default items
68 68
             self::get_cap_name(
69 69
                 $event_model,
70
-                $this->action() . '_others'
70
+                $this->action().'_others'
71 71
             ) => new EE_Default_Where_Conditions(
72 72
                 [
73
-                    'OR*' . self::get_cap_name(
73
+                    'OR*'.self::get_cap_name(
74 74
                         $event_model,
75
-                        $this->action() . '_others'
75
+                        $this->action().'_others'
76 76
                     ) => $this->addPublishedPostConditions(
77 77
                         [
78
-                            $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
78
+                            $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
79 79
                         ],
80 80
                         true,
81 81
                         $this->_path_to_event_model
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
             ),
85 85
             // if they have basic and others, but not private,
86 86
             // they can't access others' private non-default items
87
-            self::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions(
87
+            self::get_cap_name($event_model, $this->action().'_private') => new EE_Default_Where_Conditions(
88 88
                 [
89
-                    'OR*no_' . self::get_cap_name(
89
+                    'OR*no_'.self::get_cap_name(
90 90
                         $event_model,
91
-                        $this->action() . '_private'
91
+                        $this->action().'_private'
92 92
                     ) => $this->addPublishedPostConditions(
93 93
                         [
94
-                            $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
94
+                            $this->_path_to_event_model.'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
95 95
                         ],
96 96
                         false,
97 97
                         $this->_path_to_event_model
Please login to merge, or discard this patch.
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -13,90 +13,90 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Restriction_Generator_Event_Related_Public extends EE_Restriction_Generator_Base
15 15
 {
16
-    /**
17
-     * Path to the event model from the model this restriction generator will
18
-     * be applied to; including the event model itself. Eg
19
-     * "Ticket.Datetime.Event"
20
-     *
21
-     * @var string
22
-     */
23
-    protected $_path_to_event_model;
16
+	/**
17
+	 * Path to the event model from the model this restriction generator will
18
+	 * be applied to; including the event model itself. Eg
19
+	 * "Ticket.Datetime.Event"
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $_path_to_event_model;
24 24
 
25 25
 
26
-    /**
27
-     * @param string $path_to_event_model
28
-     */
29
-    public function __construct(string $path_to_event_model)
30
-    {
31
-        if (substr($path_to_event_model, -1, 1) != '.') {
32
-            $path_to_event_model .= '.';
33
-        }
34
-        $this->_path_to_event_model = $path_to_event_model;
35
-    }
26
+	/**
27
+	 * @param string $path_to_event_model
28
+	 */
29
+	public function __construct(string $path_to_event_model)
30
+	{
31
+		if (substr($path_to_event_model, -1, 1) != '.') {
32
+			$path_to_event_model .= '.';
33
+		}
34
+		$this->_path_to_event_model = $path_to_event_model;
35
+	}
36 36
 
37 37
 
38
-    /**
39
-     * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
40
-     * @throws EE_Error
41
-     */
42
-    protected function _generate_restrictions(): array
43
-    {
44
-        // if there are no standard caps for this model, then for now
45
-        // all we know if they need the default cap to access this
46
-        if (! $this->model()->cap_slug()) {
47
-            return [
48
-                self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(),
49
-            ];
50
-        }
38
+	/**
39
+	 * @return EE_Default_Where_Conditions[]|EE_Return_None_Where_Conditions[]
40
+	 * @throws EE_Error
41
+	 */
42
+	protected function _generate_restrictions(): array
43
+	{
44
+		// if there are no standard caps for this model, then for now
45
+		// all we know if they need the default cap to access this
46
+		if (! $this->model()->cap_slug()) {
47
+			return [
48
+				self::get_default_restrictions_cap() => new EE_Return_None_Where_Conditions(),
49
+			];
50
+		}
51 51
 
52
-        $event_model = EEM_Event::instance();
53
-        return [
54
-            // first: basically access to non-defaults is essentially
55
-            // controlled by which events are accessible
56
-            // if they don't have the basic event cap,
57
-            // they can only read things for published events
58
-            self::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(
59
-                $this->addPublishedPostConditions(
60
-                    [],
61
-                    true,
62
-                    $this->_path_to_event_model
63
-                )
64
-            ),
65
-            // if they don't have the others event cap,
66
-            // they can't access others' non-default items
67
-            self::get_cap_name(
68
-                $event_model,
69
-                $this->action() . '_others'
70
-            ) => new EE_Default_Where_Conditions(
71
-                [
72
-                    'OR*' . self::get_cap_name(
73
-                        $event_model,
74
-                        $this->action() . '_others'
75
-                    ) => $this->addPublishedPostConditions(
76
-                        [
77
-                            $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
78
-                        ],
79
-                        true,
80
-                        $this->_path_to_event_model
81
-                    ),
82
-                ]
83
-            ),
84
-            // if they have basic and others, but not private,
85
-            // they can't access others' private non-default items
86
-            self::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions(
87
-                [
88
-                    'OR*no_' . self::get_cap_name(
89
-                        $event_model,
90
-                        $this->action() . '_private'
91
-                    ) => $this->addPublishedPostConditions(
92
-                        [
93
-                            $this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
94
-                        ],
95
-                        false,
96
-                        $this->_path_to_event_model
97
-                    ),
98
-                ]
99
-            ),
100
-        ];
101
-    }
52
+		$event_model = EEM_Event::instance();
53
+		return [
54
+			// first: basically access to non-defaults is essentially
55
+			// controlled by which events are accessible
56
+			// if they don't have the basic event cap,
57
+			// they can only read things for published events
58
+			self::get_cap_name($event_model, $this->action()) => new EE_Default_Where_Conditions(
59
+				$this->addPublishedPostConditions(
60
+					[],
61
+					true,
62
+					$this->_path_to_event_model
63
+				)
64
+			),
65
+			// if they don't have the others event cap,
66
+			// they can't access others' non-default items
67
+			self::get_cap_name(
68
+				$event_model,
69
+				$this->action() . '_others'
70
+			) => new EE_Default_Where_Conditions(
71
+				[
72
+					'OR*' . self::get_cap_name(
73
+						$event_model,
74
+						$this->action() . '_others'
75
+					) => $this->addPublishedPostConditions(
76
+						[
77
+							$this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
78
+						],
79
+						true,
80
+						$this->_path_to_event_model
81
+					),
82
+				]
83
+			),
84
+			// if they have basic and others, but not private,
85
+			// they can't access others' private non-default items
86
+			self::get_cap_name($event_model, $this->action() . '_private') => new EE_Default_Where_Conditions(
87
+				[
88
+					'OR*no_' . self::get_cap_name(
89
+						$event_model,
90
+						$this->action() . '_private'
91
+					) => $this->addPublishedPostConditions(
92
+						[
93
+							$this->_path_to_event_model . 'EVT_wp_user' => EE_QUERY_PLACEHOLDER_CURRENT_USER,
94
+						],
95
+						false,
96
+						$this->_path_to_event_model
97
+					),
98
+				]
99
+			),
100
+		];
101
+	}
102 102
 }
Please login to merge, or discard this patch.