@@ -8,9 +8,9 @@ discard block |
||
8 | 8 | * @param $class_file |
9 | 9 | * @return array |
10 | 10 | */ |
11 | -function espresso_invoice_template_files( $class_file) { |
|
11 | +function espresso_invoice_template_files($class_file) { |
|
12 | 12 | // read our template dir and build an array of files |
13 | - $dhandle = opendir(dirname($class_file) . '/lib/templates/css/'); //If the template files have been moved to the uploads folder |
|
13 | + $dhandle = opendir(dirname($class_file).'/lib/templates/css/'); //If the template files have been moved to the uploads folder |
|
14 | 14 | //} else return FALSE; |
15 | 15 | |
16 | 16 | $files = array(); |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @param string $selected |
51 | 51 | * @return string |
52 | 52 | */ |
53 | -function espresso_invoice_is_selected( $input_item, $selected='') { |
|
54 | - if ( $input_item === $selected ) { |
|
53 | +function espresso_invoice_is_selected($input_item, $selected = '') { |
|
54 | + if ($input_item === $selected) { |
|
55 | 55 | return 'selected="selected"'; |
56 | 56 | } else { |
57 | 57 | return ''; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
3 | 3 | use EventEspresso\core\services\database\TableManager; |
4 | 4 | |
5 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | 6 | exit('No direct script access allowed'); |
7 | 7 | } |
8 | 8 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | /** |
22 | 22 | */ |
23 | -class EE_DMS_Unknown_1_0_0 extends EE_Data_Migration_Script_Base{ |
|
23 | +class EE_DMS_Unknown_1_0_0 extends EE_Data_Migration_Script_Base { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Returns whether or not this data migration script can operate on the given version of the database. |
@@ -47,11 +47,11 @@ discard block |
||
47 | 47 | * @param TableManager $table_manager |
48 | 48 | * @param TableAnalysis $table_analysis |
49 | 49 | */ |
50 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
50 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
51 | 51 | $this->_migration_stages = array(); |
52 | 52 | $this->_pretty_name = __("Fatal Uncatchable Error Occurred", "event_espresso"); |
53 | 53 | // dd($this); |
54 | - parent::__construct( $table_manager, $table_analysis ); |
|
54 | + parent::__construct($table_manager, $table_analysis); |
|
55 | 55 | } |
56 | 56 | public function migration_page_hooks() { |
57 | 57 |
@@ -35,12 +35,12 @@ |
||
35 | 35 | |
36 | 36 | |
37 | 37 | /** |
38 | - * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
39 | - * @param string $column_name |
|
40 | - * @param string $column_info |
|
41 | - * @return bool|false|int |
|
42 | - */ |
|
43 | - public function addColumn( $table_name, $column_name, $column_info='INT UNSIGNED NOT NULL' ) |
|
38 | + * @param string $table_name which can optionally start with $wpdb->prefix or not |
|
39 | + * @param string $column_name |
|
40 | + * @param string $column_info |
|
41 | + * @return bool|false|int |
|
42 | + */ |
|
43 | + public function addColumn( $table_name, $column_name, $column_info='INT UNSIGNED NOT NULL' ) |
|
44 | 44 | { |
45 | 45 | if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
46 | 46 | return FALSE; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\services\database; |
3 | 3 | |
4 | -defined( 'EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
|
4 | +defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed'); |
|
5 | 5 | /** |
6 | 6 | * |
7 | 7 | * Class TableManager |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param TableAnalysis $TableAnalysis |
30 | 30 | */ |
31 | - public function __construct( TableAnalysis $TableAnalysis ) { |
|
31 | + public function __construct(TableAnalysis $TableAnalysis) { |
|
32 | 32 | $this->table_analysis = $TableAnalysis; |
33 | 33 | } |
34 | 34 | |
@@ -38,13 +38,13 @@ discard block |
||
38 | 38 | * @throws \EE_Error |
39 | 39 | */ |
40 | 40 | protected function getTableAnalysis() { |
41 | - if( $this->table_analysis instanceof TableAnalysis ) { |
|
41 | + if ($this->table_analysis instanceof TableAnalysis) { |
|
42 | 42 | return $this->table_analysis; |
43 | 43 | } else { |
44 | 44 | throw new \EE_Error( |
45 | 45 | sprintf( |
46 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
47 | - get_class( $this ) |
|
46 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
47 | + get_class($this) |
|
48 | 48 | ) |
49 | 49 | ); |
50 | 50 | } |
@@ -58,16 +58,16 @@ discard block |
||
58 | 58 | * @param string $column_info |
59 | 59 | * @return bool|false|int |
60 | 60 | */ |
61 | - public function addColumn( $table_name, $column_name, $column_info='INT UNSIGNED NOT NULL' ) |
|
61 | + public function addColumn($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') |
|
62 | 62 | { |
63 | - if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){ |
|
63 | + if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) { |
|
64 | 64 | return FALSE; |
65 | 65 | } |
66 | 66 | global $wpdb; |
67 | - $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
67 | + $full_table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
68 | 68 | $columns = $this->getTableColumns($table_name); |
69 | - if( !in_array( $column_name, $columns)){ |
|
70 | - $alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
69 | + if ( ! in_array($column_name, $columns)) { |
|
70 | + $alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info"; |
|
71 | 71 | return $wpdb->query($alter_query); |
72 | 72 | } |
73 | 73 | return TRUE; |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | * @param string $table_name |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - public function getTableColumns( $table_name ) |
|
83 | + public function getTableColumns($table_name) |
|
84 | 84 | { |
85 | 85 | global $wpdb; |
86 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
86 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
87 | 87 | $fieldArray = array(); |
88 | - if ( ! empty( $table_name )) { |
|
88 | + if ( ! empty($table_name)) { |
|
89 | 89 | $columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name "); |
90 | 90 | if ($columns !== FALSE) { |
91 | - foreach( $columns as $column ){ |
|
91 | + foreach ($columns as $column) { |
|
92 | 92 | $fieldArray[] = $column->Field; |
93 | 93 | } |
94 | 94 | } |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | * @param string $table_name |
105 | 105 | * @return int |
106 | 106 | */ |
107 | - public function dropTable( $table_name ) |
|
107 | + public function dropTable($table_name) |
|
108 | 108 | { |
109 | 109 | global $wpdb; |
110 | - if ( $this->getTableAnalysis()->tableExists( $table_name ) ) { |
|
111 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
112 | - return $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); |
|
110 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
111 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
112 | + return $wpdb->query("DROP TABLE IF EXISTS $table_name"); |
|
113 | 113 | } |
114 | 114 | return 0; |
115 | 115 | } |
@@ -122,17 +122,17 @@ discard block |
||
122 | 122 | * @param array $table_names |
123 | 123 | * @return array of table names which we deleted |
124 | 124 | */ |
125 | - public function dropTables( $table_names ) |
|
125 | + public function dropTables($table_names) |
|
126 | 126 | { |
127 | 127 | $tables_to_delete = array(); |
128 | - foreach( $table_names as $table_name ) { |
|
129 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
130 | - if( $this->getTableAnalysis()->tableExists( $table_name ) ) { |
|
128 | + foreach ($table_names as $table_name) { |
|
129 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
130 | + if ($this->getTableAnalysis()->tableExists($table_name)) { |
|
131 | 131 | $tables_to_delete[] = $table_name; |
132 | 132 | } |
133 | 133 | } |
134 | 134 | global $wpdb; |
135 | - $wpdb->query( 'DROP TABLE ' . implode( ', ', $tables_to_delete ) ); |
|
135 | + $wpdb->query('DROP TABLE '.implode(', ', $tables_to_delete)); |
|
136 | 136 | return $tables_to_delete; |
137 | 137 | } |
138 | 138 | |
@@ -145,19 +145,19 @@ discard block |
||
145 | 145 | * @param string $indexName |
146 | 146 | * @return int |
147 | 147 | */ |
148 | - public function dropIndex( $table_name, $indexName ) |
|
148 | + public function dropIndex($table_name, $indexName) |
|
149 | 149 | { |
150 | - if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){ |
|
150 | + if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) { |
|
151 | 151 | return FALSE; |
152 | 152 | } |
153 | 153 | global $wpdb; |
154 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
154 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
155 | 155 | $index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$indexName'"; |
156 | 156 | if ( |
157 | - $this->getTableAnalysis()->tableExists( $table_name ) |
|
158 | - && $wpdb->get_var( $index_exists_query ) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
157 | + $this->getTableAnalysis()->tableExists($table_name) |
|
158 | + && $wpdb->get_var($index_exists_query) === $table_name //using get_var with the $index_exists_query returns the table's name |
|
159 | 159 | ) { |
160 | - return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $indexName" ); |
|
160 | + return $wpdb->query("ALTER TABLE $table_name DROP INDEX $indexName"); |
|
161 | 161 | } |
162 | 162 | return 0; |
163 | 163 | } |
@@ -171,31 +171,31 @@ discard block |
||
171 | 171 | * @return void |
172 | 172 | * @throws \EE_Error |
173 | 173 | */ |
174 | - public function createTable( $table_name, $createSql, $engine = 'MyISAM' ) |
|
174 | + public function createTable($table_name, $createSql, $engine = 'MyISAM') |
|
175 | 175 | { |
176 | 176 | // does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns ) |
177 | - if ( preg_match( '((((.*?))(,\s))+)', $createSql, $valid_column_data ) ) { |
|
178 | - $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix( $table_name ); |
|
177 | + if (preg_match('((((.*?))(,\s))+)', $createSql, $valid_column_data)) { |
|
178 | + $table_name = $this->getTableAnalysis()->ensureTableNameHasPrefix($table_name); |
|
179 | 179 | $SQL = "CREATE TABLE $table_name ( $createSql ) ENGINE=$engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"; |
180 | 180 | /** @var \wpdb $wpdb */ |
181 | 181 | global $wpdb; |
182 | 182 | //get $wpdb to echo errors, but buffer them. This way at least WE know an error |
183 | 183 | //happened. And then we can choose to tell the end user |
184 | - $old_show_errors_policy = $wpdb->show_errors( TRUE ); |
|
185 | - $old_error_suppression_policy = $wpdb->suppress_errors( FALSE ); |
|
184 | + $old_show_errors_policy = $wpdb->show_errors(TRUE); |
|
185 | + $old_error_suppression_policy = $wpdb->suppress_errors(FALSE); |
|
186 | 186 | ob_start(); |
187 | - dbDelta( $SQL ); |
|
187 | + dbDelta($SQL); |
|
188 | 188 | $output = ob_get_contents(); |
189 | 189 | ob_end_clean(); |
190 | - $wpdb->show_errors( $old_show_errors_policy ); |
|
191 | - $wpdb->suppress_errors( $old_error_suppression_policy ); |
|
192 | - if( ! empty( $output ) ){ |
|
193 | - throw new \EE_Error( $output ); |
|
190 | + $wpdb->show_errors($old_show_errors_policy); |
|
191 | + $wpdb->suppress_errors($old_error_suppression_policy); |
|
192 | + if ( ! empty($output)) { |
|
193 | + throw new \EE_Error($output); |
|
194 | 194 | } |
195 | 195 | } else { |
196 | 196 | throw new \EE_Error( |
197 | 197 | sprintf( |
198 | - __( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ), |
|
198 | + __('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'), |
|
199 | 199 | '<br />', |
200 | 200 | $createSql |
201 | 201 | ) |
@@ -56,26 +56,26 @@ discard block |
||
56 | 56 | * @param bool $routing |
57 | 57 | * @return Registrations_Admin_Page |
58 | 58 | */ |
59 | - public function __construct( $routing = TRUE ) { |
|
60 | - parent::__construct( $routing ); |
|
61 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' )); |
|
59 | + public function __construct($routing = TRUE) { |
|
60 | + parent::__construct($routing); |
|
61 | + add_action('wp_loaded', array($this, 'wp_loaded')); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | 65 | |
66 | 66 | public function wp_loaded() { |
67 | 67 | // when adding a new registration... |
68 | - if ( isset( $this->_req_data[ 'action' ] ) && $this->_req_data[ 'action' ] == 'new_registration' ) { |
|
68 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] == 'new_registration') { |
|
69 | 69 | EE_System::do_not_cache(); |
70 | 70 | if ( |
71 | - ! isset( $this->_req_data[ 'processing_registration' ] ) |
|
72 | - || absint( $this->_req_data[ 'processing_registration' ] ) !== 1 |
|
71 | + ! isset($this->_req_data['processing_registration']) |
|
72 | + || absint($this->_req_data['processing_registration']) !== 1 |
|
73 | 73 | ) { |
74 | 74 | // and it's NOT the attendee information reg step |
75 | 75 | // force cookie expiration by setting time to last week |
76 | - setcookie( 'ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/' ); |
|
76 | + setcookie('ee_registration_added', 0, time() - WEEK_IN_SECONDS, '/'); |
|
77 | 77 | // and update the global |
78 | - $_COOKIE[ 'ee_registration_added' ] = 0; |
|
78 | + $_COOKIE['ee_registration_added'] = 0; |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | 'trash' => 'post.php' |
110 | 110 | ); |
111 | 111 | |
112 | - add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10 ); |
|
112 | + add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10); |
|
113 | 113 | //add filters so that the comment urls don't take users to a confusing 404 page |
114 | - add_filter('get_comment_link', array( $this, 'clear_comment_link' ), 10, 3 ); |
|
114 | + add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
118 | - public function clear_comment_link( $link, $comment, $args ) { |
|
118 | + public function clear_comment_link($link, $comment, $args) { |
|
119 | 119 | //gotta make sure this only happens on this route |
120 | - $post_type = get_post_type( $comment->comment_post_ID); |
|
121 | - if ( $post_type == 'espresso_attendees' ) |
|
120 | + $post_type = get_post_type($comment->comment_post_ID); |
|
121 | + if ($post_type == 'espresso_attendees') |
|
122 | 122 | return '#commentsdiv'; |
123 | 123 | return $link; |
124 | 124 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | protected function _ajax_hooks() { |
128 | 128 | //todo: all hooks for registrations ajax goes in here |
129 | - add_action( 'wp_ajax_toggle_checkin_status', array( $this, 'toggle_checkin_status' )); |
|
129 | + add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status')); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | 'add-attendee' => __('Add Contact', 'event_espresso'), |
142 | 142 | 'edit' => __('Edit Contact', 'event_espresso'), |
143 | 143 | 'report'=> __("Event Registrations CSV Report", "event_espresso"), |
144 | - 'report_all' => __( 'All Registrations CSV Report', 'event_espresso' ), |
|
145 | - 'contact_list_report' => __( 'Contact List Report', 'event_espresso' ), |
|
144 | + 'report_all' => __('All Registrations CSV Report', 'event_espresso'), |
|
145 | + 'contact_list_report' => __('Contact List Report', 'event_espresso'), |
|
146 | 146 | 'contact_list_export'=> __("Export Data", "event_espresso"), |
147 | 147 | ), |
148 | 148 | 'publishbox' => array( |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | |
171 | 171 | $this->_get_registration_status_array(); |
172 | 172 | |
173 | - $reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0; |
|
174 | - $att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) && ! is_array( $this->_req_data['ATT_ID'] ) ? $this->_req_data['ATT_ID'] : 0; |
|
175 | - $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id; |
|
173 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0; |
|
174 | + $att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) ? $this->_req_data['ATT_ID'] : 0; |
|
175 | + $att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] : $att_id; |
|
176 | 176 | |
177 | 177 | $this->_page_routes = array( |
178 | 178 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | 'restore_registrations' => array( |
207 | 207 | 'func' => '_trash_or_restore_registrations', |
208 | - 'args' => array( 'trash' => FALSE ), |
|
208 | + 'args' => array('trash' => FALSE), |
|
209 | 209 | 'noheader' => TRUE, |
210 | 210 | 'capability' => 'ee_delete_registrations' |
211 | 211 | ), |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | 'filename' => 'registrations_overview_other' |
439 | 439 | ) |
440 | 440 | ), |
441 | - 'help_tour' => array( 'Registration_Overview_Help_Tour' ), |
|
441 | + 'help_tour' => array('Registration_Overview_Help_Tour'), |
|
442 | 442 | 'qtips' => array('Registration_List_Table_Tips'), |
443 | 443 | 'list_table' => 'EE_Registrations_List_Table', |
444 | 444 | 'require_nonce' => FALSE |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | 'order' => 15, |
451 | 451 | 'url' => isset($this->_req_data['_REG_ID']) |
452 | 452 | ? add_query_arg( |
453 | - array('_REG_ID' => $this->_req_data['_REG_ID'] ), |
|
453 | + array('_REG_ID' => $this->_req_data['_REG_ID']), |
|
454 | 454 | $this->_current_page_view_url |
455 | 455 | ) |
456 | 456 | : $this->_admin_base_url, |
@@ -474,8 +474,8 @@ discard block |
||
474 | 474 | 'filename' => 'registrations_details_registrant_details' |
475 | 475 | ) |
476 | 476 | ), |
477 | - 'help_tour' => array( 'Registration_Details_Help_Tour' ), |
|
478 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_registration_details_metaboxes' ) ), |
|
477 | + 'help_tour' => array('Registration_Details_Help_Tour'), |
|
478 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_registration_details_metaboxes')), |
|
479 | 479 | 'require_nonce' => FALSE |
480 | 480 | ), |
481 | 481 | |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | 'order' => 15, |
500 | 500 | 'persistent' => FALSE |
501 | 501 | ), |
502 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes' ) ), |
|
502 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes')), |
|
503 | 503 | 'require_nonce' => FALSE |
504 | 504 | ), |
505 | 505 | |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | 'label' => __('Edit Contact', 'event_espresso'), |
509 | 509 | 'order' => 15, |
510 | 510 | 'persistent' => FALSE, |
511 | - 'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
511 | + 'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) : $this->_admin_base_url |
|
512 | 512 | ), |
513 | 513 | 'metaboxes' => array('attendee_editor_metaboxes'), |
514 | 514 | 'require_nonce' => FALSE |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | 'filename' => 'registrations_contact_list_other' |
539 | 539 | ) |
540 | 540 | ), |
541 | - 'help_tour' => array( 'Contact_List_Help_Tour' ), |
|
541 | + 'help_tour' => array('Contact_List_Help_Tour'), |
|
542 | 542 | 'metaboxes' => array(), |
543 | 543 | 'require_nonce' => FALSE |
544 | 544 | ), |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | protected function _add_screen_options() {} |
558 | 558 | protected function _add_feature_pointers() {} |
559 | 559 | public function admin_init() { |
560 | - EE_Registry::$i18n_js_strings[ 'update_att_qstns' ] = __( 'click "Update Registration Questions" to save your changes', 'event_espresso' ); |
|
560 | + EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', 'event_espresso'); |
|
561 | 561 | } |
562 | 562 | public function admin_notices() {} |
563 | 563 | public function admin_footer_scripts() {} |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @return void |
576 | 576 | */ |
577 | 577 | private function _get_registration_status_array() { |
578 | - self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE); |
|
578 | + self::$_reg_status = EEM_Registration::reg_status_array(array(), TRUE); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | public function load_scripts_styles() { |
599 | 599 | //style |
600 | 600 | //wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
601 | - wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
601 | + wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
602 | 602 | wp_enqueue_style('espresso_reg'); |
603 | 603 | |
604 | 604 | //script |
605 | - wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE); |
|
605 | + wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE); |
|
606 | 606 | wp_enqueue_script('espresso_reg'); |
607 | 607 | } |
608 | 608 | |
@@ -611,9 +611,9 @@ discard block |
||
611 | 611 | public function load_scripts_styles_edit_attendee() { |
612 | 612 | //stuff to only show up on our attendee edit details page. |
613 | 613 | $attendee_details_translations = array( |
614 | - 'att_publish_text' => sprintf( __('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created') ) |
|
614 | + 'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created')) |
|
615 | 615 | ); |
616 | - wp_localize_script( 'espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations ); |
|
616 | + wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations); |
|
617 | 617 | wp_enqueue_script('jquery-validate'); |
618 | 618 | } |
619 | 619 | |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | //styles |
623 | 623 | wp_enqueue_style('espresso-ui-theme'); |
624 | 624 | //scripts |
625 | - $this->_get_reg_custom_questions_form( $this->_registration->ID() ); |
|
626 | - $this->_reg_custom_questions_form->wp_enqueue_scripts( true ); |
|
625 | + $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
626 | + $this->_reg_custom_questions_form->wp_enqueue_scripts(true); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | |
634 | 634 | public function load_scripts_styles_contact_list() { |
635 | 635 | wp_deregister_style('espresso_reg'); |
636 | - wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION ); |
|
636 | + wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION); |
|
637 | 637 | wp_enqueue_style('espresso_att'); |
638 | 638 | } |
639 | 639 | |
@@ -642,9 +642,9 @@ discard block |
||
642 | 642 | |
643 | 643 | |
644 | 644 | public function load_scripts_styles_new_registration() { |
645 | - wp_register_script( 'ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
645 | + wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
646 | 646 | wp_enqueue_script('ee-spco-for-admin'); |
647 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
647 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
648 | 648 | EE_Form_Section_Proper::wp_enqueue_scripts(); |
649 | 649 | EED_Ticket_Selector::load_tckt_slctr_assets(); |
650 | 650 | EE_Datepicker_Input::enqueue_styles_and_scripts(); |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | //for notification related bulk actions we need to make sure only active messengers have an option. |
672 | 672 | EED_Messages::set_autoloaders(); |
673 | 673 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
674 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
674 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
675 | 675 | $active_mts = $message_resource_manager->list_of_active_message_types(); |
676 | 676 | //key= bulk_action_slug, value= message type. |
677 | 677 | $match_array = array( |
@@ -684,23 +684,23 @@ discard block |
||
684 | 684 | |
685 | 685 | /** setup reg status bulk actions **/ |
686 | 686 | $def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso'); |
687 | - if ( in_array( $match_array['approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
687 | + if (in_array($match_array['approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
688 | 688 | $def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', 'event_espresso'); |
689 | 689 | } |
690 | 690 | $def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso'); |
691 | - if ( in_array( $match_array['decline_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
691 | + if (in_array($match_array['decline_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
692 | 692 | $def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', 'event_espresso'); |
693 | 693 | } |
694 | 694 | $def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso'); |
695 | - if ( in_array( $match_array['pending_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
695 | + if (in_array($match_array['pending_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
696 | 696 | $def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', 'event_espresso'); |
697 | 697 | } |
698 | 698 | $def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso'); |
699 | - if ( in_array( $match_array['no_approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
699 | + if (in_array($match_array['no_approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
700 | 700 | $def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', 'event_espresso'); |
701 | 701 | } |
702 | 702 | $def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso'); |
703 | - if ( in_array( $match_array['cancel_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) { |
|
703 | + if (in_array($match_array['cancel_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) { |
|
704 | 704 | $def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', 'event_espresso'); |
705 | 705 | } |
706 | 706 | |
@@ -709,29 +709,29 @@ discard block |
||
709 | 709 | 'slug' => 'all', |
710 | 710 | 'label' => __('View All Registrations', 'event_espresso'), |
711 | 711 | 'count' => 0, |
712 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
712 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
713 | 713 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
714 | - ) ) |
|
714 | + )) |
|
715 | 715 | ), |
716 | 716 | 'month' => array( |
717 | 717 | 'slug' => 'month', |
718 | 718 | 'label' => __('This Month', 'event_espresso'), |
719 | 719 | 'count' => 0, |
720 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
720 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
721 | 721 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
722 | 722 | )) |
723 | 723 | ), |
724 | 724 | 'today' => array( |
725 | 725 | 'slug' => 'today', |
726 | - 'label' => sprintf( __('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp' ) ) ), |
|
726 | + 'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))), |
|
727 | 727 | 'count' => 0, |
728 | - 'bulk_action' => array_merge( $def_reg_status_actions, array( |
|
728 | + 'bulk_action' => array_merge($def_reg_status_actions, array( |
|
729 | 729 | 'trash_registrations' => __('Trash Registrations', 'event_espresso') |
730 | 730 | )) |
731 | 731 | ) |
732 | 732 | ); |
733 | 733 | |
734 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_delete_registration' ) ) { |
|
734 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_delete_registration')) { |
|
735 | 735 | $this->_views['incomplete'] = array( |
736 | 736 | 'slug' => 'incomplete', |
737 | 737 | 'label' => __('Incomplete', 'event_espresso'), |
@@ -767,7 +767,7 @@ discard block |
||
767 | 767 | ) |
768 | 768 | ); |
769 | 769 | |
770 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_trash_attendees' ) ) { |
|
770 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_trash_attendees')) { |
|
771 | 771 | $this->_views['trash'] = array( |
772 | 772 | 'slug' => 'trash', |
773 | 773 | 'label' => __('Trash', 'event_espresso'), |
@@ -806,18 +806,18 @@ discard block |
||
806 | 806 | 'desc' => __('View Transaction Invoice', 'event_espresso') |
807 | 807 | ), |
808 | 808 | ); |
809 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) { |
|
809 | + if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) { |
|
810 | 810 | $fc_items['resend_registration'] = array( |
811 | 811 | 'class' => 'dashicons dashicons-email-alt', |
812 | 812 | 'desc' => __('Resend Registration Details', 'event_espresso') |
813 | 813 | ); |
814 | 814 | } else { |
815 | - $fc_items['blank'] = array( 'class' => 'blank', 'desc' => '' ); |
|
815 | + $fc_items['blank'] = array('class' => 'blank', 'desc' => ''); |
|
816 | 816 | } |
817 | 817 | |
818 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_global_messages', 'view_filtered_messages' ) ) { |
|
819 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' ); |
|
820 | - if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) { |
|
818 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
819 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
820 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
821 | 821 | $fc_items['view_related_messages'] = array( |
822 | 822 | 'class' => $related_for_icon['css_class'], |
823 | 823 | 'desc' => $related_for_icon['label'], |
@@ -827,35 +827,35 @@ discard block |
||
827 | 827 | |
828 | 828 | $sc_items = array( |
829 | 829 | 'approved_status' => array( |
830 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
831 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) |
|
830 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved, |
|
831 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence') |
|
832 | 832 | ), |
833 | 833 | 'pending_status' => array( |
834 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
835 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) |
|
834 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment, |
|
835 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence') |
|
836 | 836 | ), |
837 | 837 | 'wait_list' => array( |
838 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
839 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_wait_list, false, 'sentence' ) |
|
838 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_wait_list, |
|
839 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') |
|
840 | 840 | ), |
841 | 841 | 'incomplete_status' => array( |
842 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete, |
|
843 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_incomplete, FALSE, 'sentence' ) |
|
842 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete, |
|
843 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, FALSE, 'sentence') |
|
844 | 844 | ), |
845 | 845 | 'not_approved' => array( |
846 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
847 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) |
|
846 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved, |
|
847 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence') |
|
848 | 848 | ), |
849 | 849 | 'declined_status' => array( |
850 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
851 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) |
|
850 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined, |
|
851 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence') |
|
852 | 852 | ), |
853 | 853 | 'cancelled_status' => array( |
854 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
855 | - 'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) |
|
854 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled, |
|
855 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence') |
|
856 | 856 | ) |
857 | 857 | ); |
858 | - return array_merge( $fc_items, $sc_items ); |
|
858 | + return array_merge($fc_items, $sc_items); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | |
@@ -869,45 +869,45 @@ discard block |
||
869 | 869 | */ |
870 | 870 | protected function _registrations_overview_list_table() { |
871 | 871 | $this->_template_args['admin_page_header'] = ''; |
872 | - $EVT_ID = ! empty( $this->_req_data['event_id'] ) ? absint( $this->_req_data['event_id'] ) : 0; |
|
873 | - if ( $EVT_ID ) { |
|
874 | - if ( EE_Registry::instance()->CAP->current_user_can( |
|
872 | + $EVT_ID = ! empty($this->_req_data['event_id']) ? absint($this->_req_data['event_id']) : 0; |
|
873 | + if ($EVT_ID) { |
|
874 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
875 | 875 | 'ee_edit_registrations', |
876 | 876 | 'espresso_registrations_new_registration', |
877 | 877 | $EVT_ID |
878 | 878 | ) |
879 | 879 | ) { |
880 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
880 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
881 | 881 | 'new_registration', |
882 | 882 | 'add-registrant', |
883 | - array( 'event_id' => $EVT_ID ), |
|
883 | + array('event_id' => $EVT_ID), |
|
884 | 884 | 'add-new-h2' |
885 | 885 | ); |
886 | 886 | } |
887 | - $event = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
888 | - if ( $event instanceof EE_Event ) { |
|
887 | + $event = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
888 | + if ($event instanceof EE_Event) { |
|
889 | 889 | $this->_template_args['admin_page_header'] = sprintf( |
890 | - __( '%s Viewing registrations for the event: %s%s', 'event_espresso' ), |
|
890 | + __('%s Viewing registrations for the event: %s%s', 'event_espresso'), |
|
891 | 891 | '<h3 style="line-height:1.5em;">', |
892 | - '<br /><a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
893 | - array( 'action' => 'edit', 'post' => $event->ID() ), |
|
892 | + '<br /><a href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
893 | + array('action' => 'edit', 'post' => $event->ID()), |
|
894 | 894 | EVENTS_ADMIN_URL |
895 | - ) . '"> ' . $event->get( 'EVT_name' ) . ' </a> ', |
|
895 | + ).'"> '.$event->get('EVT_name').' </a> ', |
|
896 | 896 | '</h3>' |
897 | 897 | ); |
898 | 898 | } |
899 | - $DTT_ID = ! empty( $this->_req_data['datetime_id'] ) ? absint( $this->_req_data['datetime_id'] ) : 0; |
|
900 | - $datetime = EEM_Datetime::instance()->get_one_by_ID( $DTT_ID ); |
|
901 | - if ( $datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '' ) { |
|
902 | - $this->_template_args['admin_page_header'] = substr( $this->_template_args['admin_page_header'], 0, -5 ); |
|
899 | + $DTT_ID = ! empty($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : 0; |
|
900 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
901 | + if ($datetime instanceof EE_Datetime && $this->_template_args['admin_page_header'] !== '') { |
|
902 | + $this->_template_args['admin_page_header'] = substr($this->_template_args['admin_page_header'], 0, -5); |
|
903 | 903 | $this->_template_args['admin_page_header'] .= ' <span class="drk-grey-text">'; |
904 | 904 | $this->_template_args['admin_page_header'] .= '<span class="dashicons dashicons-calendar"></span>'; |
905 | 905 | $this->_template_args['admin_page_header'] .= $datetime->name(); |
906 | - $this->_template_args['admin_page_header'] .= ' ( ' . $datetime->start_date() . ' )'; |
|
906 | + $this->_template_args['admin_page_header'] .= ' ( '.$datetime->start_date().' )'; |
|
907 | 907 | $this->_template_args['admin_page_header'] .= '</span></h3>'; |
908 | 908 | } |
909 | 909 | } |
910 | - $this->_template_args['after_list_table'] = $this->_display_legend( $this->_registration_legend_items() ); |
|
910 | + $this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items()); |
|
911 | 911 | $this->display_admin_list_table_page_with_no_sidebar(); |
912 | 912 | } |
913 | 913 | |
@@ -922,19 +922,19 @@ discard block |
||
922 | 922 | */ |
923 | 923 | private function _set_registration_object() { |
924 | 924 | //get out if we've already set the object |
925 | - if ( is_object( $this->_registration )) { |
|
925 | + if (is_object($this->_registration)) { |
|
926 | 926 | return TRUE; |
927 | 927 | } |
928 | 928 | |
929 | 929 | $REG = EEM_Registration::instance(); |
930 | 930 | |
931 | - $REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
|
931 | + $REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : FALSE; |
|
932 | 932 | |
933 | - if ( $this->_registration = $REG->get_one_by_ID( $REG_ID )) |
|
933 | + if ($this->_registration = $REG->get_one_by_ID($REG_ID)) |
|
934 | 934 | return TRUE; |
935 | 935 | else { |
936 | - $error_msg = sprintf( __('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID ); |
|
937 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
936 | + $error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID); |
|
937 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
938 | 938 | $this->_registration = NULL; |
939 | 939 | return FALSE; |
940 | 940 | } |
@@ -952,25 +952,25 @@ discard block |
||
952 | 952 | * @throws \EE_Error |
953 | 953 | * @return mixed (int|array) int = count || array of registration objects |
954 | 954 | */ |
955 | - public function get_registrations( $per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE ) { |
|
956 | - $EVT_ID = ! empty( $this->_req_data['event_id'] ) && $this->_req_data['event_id'] > 0 ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
957 | - $CAT_ID = ! empty( $this->_req_data['EVT_CAT'] ) && (int) $this->_req_data['EVT_CAT'] > 0? absint( $this->_req_data['EVT_CAT'] ) : FALSE; |
|
958 | - $DTT_ID = isset( $this->_req_data['datetime_id'] ) ? absint( $this->_req_data['datetime_id'] ) : null; |
|
959 | - $reg_status = ! empty( $this->_req_data['_reg_status'] ) ? sanitize_text_field( $this->_req_data['_reg_status'] ) : FALSE; |
|
960 | - $month_range = ! empty( $this->_req_data['month_range'] ) ? sanitize_text_field( $this->_req_data['month_range'] ) : FALSE;//should be like 2013-april |
|
961 | - $today_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'today' ? TRUE : FALSE; |
|
962 | - $this_month_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'month' ? TRUE : FALSE; |
|
955 | + public function get_registrations($per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE) { |
|
956 | + $EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0 ? absint($this->_req_data['event_id']) : FALSE; |
|
957 | + $CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int) $this->_req_data['EVT_CAT'] > 0 ? absint($this->_req_data['EVT_CAT']) : FALSE; |
|
958 | + $DTT_ID = isset($this->_req_data['datetime_id']) ? absint($this->_req_data['datetime_id']) : null; |
|
959 | + $reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status']) : FALSE; |
|
960 | + $month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range']) : FALSE; //should be like 2013-april |
|
961 | + $today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'today' ? TRUE : FALSE; |
|
962 | + $this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'month' ? TRUE : FALSE; |
|
963 | 963 | $start_date = FALSE; |
964 | 964 | $end_date = FALSE; |
965 | 965 | $_where = array(); |
966 | - $trash = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE; |
|
967 | - $incomplete = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE; |
|
966 | + $trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'trash' ? TRUE : FALSE; |
|
967 | + $incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] === 'incomplete' ? TRUE : FALSE; |
|
968 | 968 | |
969 | 969 | //set orderby |
970 | 970 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
971 | 971 | |
972 | 972 | |
973 | - switch ( $this->_req_data['orderby'] ) { |
|
973 | + switch ($this->_req_data['orderby']) { |
|
974 | 974 | case '_REG_ID': |
975 | 975 | $orderby = 'REG_ID'; |
976 | 976 | break; |
@@ -990,30 +990,30 @@ discard block |
||
990 | 990 | $orderby = 'REG_date'; |
991 | 991 | } |
992 | 992 | |
993 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC'; |
|
994 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
995 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
993 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC'; |
|
994 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
995 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
996 | 996 | |
997 | 997 | |
998 | - $offset = ($current_page-1)*$per_page; |
|
999 | - $limit = $count ? NULL : array( $offset, $per_page ); |
|
998 | + $offset = ($current_page - 1) * $per_page; |
|
999 | + $limit = $count ? NULL : array($offset, $per_page); |
|
1000 | 1000 | |
1001 | - if($EVT_ID){ |
|
1002 | - $_where['EVT_ID']=$EVT_ID; |
|
1001 | + if ($EVT_ID) { |
|
1002 | + $_where['EVT_ID'] = $EVT_ID; |
|
1003 | 1003 | } |
1004 | - if($CAT_ID){ |
|
1004 | + if ($CAT_ID) { |
|
1005 | 1005 | $_where['Event.Term_Taxonomy.term_id'] = $CAT_ID; |
1006 | 1006 | } |
1007 | 1007 | //if DTT is included we filter by that datetime. |
1008 | - if ( $DTT_ID ) { |
|
1008 | + if ($DTT_ID) { |
|
1009 | 1009 | $_where['Ticket.Datetime.DTT_ID'] = $DTT_ID; |
1010 | 1010 | } |
1011 | - if ( $incomplete ) { |
|
1011 | + if ($incomplete) { |
|
1012 | 1012 | $_where['STS_ID'] = EEM_Registration::status_id_incomplete; |
1013 | 1013 | } else if ( ! $trash) { |
1014 | - $_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete ); |
|
1014 | + $_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete); |
|
1015 | 1015 | } |
1016 | - if($reg_status){ |
|
1016 | + if ($reg_status) { |
|
1017 | 1017 | $_where['STS_ID'] = $reg_status; |
1018 | 1018 | } |
1019 | 1019 | |
@@ -1025,103 +1025,103 @@ discard block |
||
1025 | 1025 | $time_start = ' 00:00:00'; |
1026 | 1026 | $time_end = ' 23:59:59'; |
1027 | 1027 | |
1028 | - if($today_a || $today ){ |
|
1028 | + if ($today_a || $today) { |
|
1029 | 1029 | $curdate = date('Y-m-d', current_time('timestamp')); |
1030 | - $_where['REG_date']= array('BETWEEN', |
|
1030 | + $_where['REG_date'] = array('BETWEEN', |
|
1031 | 1031 | array( |
1032 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_start, 'Y-m-d H:i:s' ), |
|
1033 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_end, 'Y-m-d H:i:s' ), |
|
1032 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_start, 'Y-m-d H:i:s'), |
|
1033 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_end, 'Y-m-d H:i:s'), |
|
1034 | 1034 | )); |
1035 | - }elseif($this_month_a || $this_month){ |
|
1035 | + }elseif ($this_month_a || $this_month) { |
|
1036 | 1036 | $this_month_r = date('m', current_time('timestamp')); |
1037 | - $days_this_month = date( 't', current_time('timestamp') ); |
|
1038 | - $_where['REG_date']= array('BETWEEN', |
|
1037 | + $days_this_month = date('t', current_time('timestamp')); |
|
1038 | + $_where['REG_date'] = array('BETWEEN', |
|
1039 | 1039 | array( |
1040 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ), |
|
1041 | - EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' ) |
|
1040 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'), |
|
1041 | + EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, 'Y-m-d H:i:s') |
|
1042 | 1042 | )); |
1043 | - }elseif($month_range){ |
|
1043 | + }elseif ($month_range) { |
|
1044 | 1044 | $pieces = explode(' ', $this->_req_data['month_range'], 3); |
1045 | - $month_r = !empty($pieces[0]) ? date('m', strtotime( $month_range ) ) : ''; |
|
1046 | - $year_r = !empty($pieces[1]) ? $pieces[1] : ''; |
|
1047 | - $days_in_month = date('t', strtotime($year_r . '-' . $month_r . '-' . '01') ); |
|
1048 | - $_where['REG_date']= array('BETWEEN', |
|
1049 | - array( EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-' . $days_in_month . ' 23:59:59', 'Y-m-d H:i:s' ) ) ); |
|
1050 | - }elseif($start_date && $end_date){ |
|
1045 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($month_range)) : ''; |
|
1046 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1047 | + $days_in_month = date('t', strtotime($year_r.'-'.$month_r.'-'.'01')); |
|
1048 | + $_where['REG_date'] = array('BETWEEN', |
|
1049 | + array(EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-'.$days_in_month.' 23:59:59', 'Y-m-d H:i:s'))); |
|
1050 | + }elseif ($start_date && $end_date) { |
|
1051 | 1051 | throw new EE_Error("not yet supported"); |
1052 | - }elseif($start_date){ |
|
1052 | + }elseif ($start_date) { |
|
1053 | 1053 | throw new EE_Error("not yet supported"); |
1054 | - }elseif($end_date){ |
|
1054 | + }elseif ($end_date) { |
|
1055 | 1055 | throw new EE_Error("not yet supported"); |
1056 | 1056 | } |
1057 | 1057 | |
1058 | - if ( ! empty( $this->_req_data['s'] ) ) { |
|
1059 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
1058 | + if ( ! empty($this->_req_data['s'])) { |
|
1059 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
1060 | 1060 | $_where['OR'] = array( |
1061 | - 'Event.EVT_name' => array( 'LIKE', $sstr), |
|
1062 | - 'Event.EVT_desc' => array( 'LIKE', $sstr ), |
|
1063 | - 'Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
|
1064 | - 'Attendee.ATT_full_name' => array( 'LIKE', $sstr ), |
|
1065 | - 'Attendee.ATT_fname' => array( 'LIKE', $sstr ), |
|
1066 | - 'Attendee.ATT_lname' => array( 'LIKE', $sstr ), |
|
1067 | - 'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ), |
|
1068 | - 'Attendee.ATT_email' => array('LIKE', $sstr ), |
|
1069 | - 'Attendee.ATT_address' => array( 'LIKE', $sstr ), |
|
1070 | - 'Attendee.ATT_address2' => array( 'LIKE', $sstr ), |
|
1071 | - 'Attendee.ATT_city' => array( 'LIKE', $sstr ), |
|
1072 | - 'REG_final_price' => array( 'LIKE', $sstr ), |
|
1073 | - 'REG_code' => array( 'LIKE', $sstr ), |
|
1074 | - 'REG_count' => array( 'LIKE' , $sstr ), |
|
1075 | - 'REG_group_size' => array( 'LIKE' , $sstr ), |
|
1076 | - 'Ticket.TKT_name' => array( 'LIKE', $sstr ), |
|
1077 | - 'Ticket.TKT_description' => array( 'LIKE', $sstr ), |
|
1078 | - 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $sstr ) |
|
1061 | + 'Event.EVT_name' => array('LIKE', $sstr), |
|
1062 | + 'Event.EVT_desc' => array('LIKE', $sstr), |
|
1063 | + 'Event.EVT_short_desc' => array('LIKE', $sstr), |
|
1064 | + 'Attendee.ATT_full_name' => array('LIKE', $sstr), |
|
1065 | + 'Attendee.ATT_fname' => array('LIKE', $sstr), |
|
1066 | + 'Attendee.ATT_lname' => array('LIKE', $sstr), |
|
1067 | + 'Attendee.ATT_short_bio' => array('LIKE', $sstr), |
|
1068 | + 'Attendee.ATT_email' => array('LIKE', $sstr), |
|
1069 | + 'Attendee.ATT_address' => array('LIKE', $sstr), |
|
1070 | + 'Attendee.ATT_address2' => array('LIKE', $sstr), |
|
1071 | + 'Attendee.ATT_city' => array('LIKE', $sstr), |
|
1072 | + 'REG_final_price' => array('LIKE', $sstr), |
|
1073 | + 'REG_code' => array('LIKE', $sstr), |
|
1074 | + 'REG_count' => array('LIKE', $sstr), |
|
1075 | + 'REG_group_size' => array('LIKE', $sstr), |
|
1076 | + 'Ticket.TKT_name' => array('LIKE', $sstr), |
|
1077 | + 'Ticket.TKT_description' => array('LIKE', $sstr), |
|
1078 | + 'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr) |
|
1079 | 1079 | ); |
1080 | 1080 | } |
1081 | 1081 | |
1082 | 1082 | //capability checks |
1083 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations' ) ) { |
|
1083 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) { |
|
1084 | 1084 | $_where['AND'] = array( |
1085 | 1085 | 'Event.EVT_wp_user' => get_current_user_id() |
1086 | 1086 | ); |
1087 | 1087 | } |
1088 | 1088 | |
1089 | - if( $count ){ |
|
1090 | - if ( $trash ) { |
|
1091 | - return EEM_Registration::instance()->count_deleted( array( $_where )); |
|
1092 | - } else if ( $incomplete ) { |
|
1093 | - return EEM_Registration::instance()->count( array( $_where )); |
|
1089 | + if ($count) { |
|
1090 | + if ($trash) { |
|
1091 | + return EEM_Registration::instance()->count_deleted(array($_where)); |
|
1092 | + } else if ($incomplete) { |
|
1093 | + return EEM_Registration::instance()->count(array($_where)); |
|
1094 | 1094 | } else { |
1095 | - return EEM_Registration::instance()->count( array( $_where, 'default_where_conditions' => 'this_model_only' )); |
|
1095 | + return EEM_Registration::instance()->count(array($_where, 'default_where_conditions' => 'this_model_only')); |
|
1096 | 1096 | } |
1097 | 1097 | } else { |
1098 | 1098 | //make sure we remove default where conditions cause all registrations matching query are returned |
1099 | - $query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'default_where_conditions' => 'this_model_only' ); |
|
1100 | - if ( $per_page !== -1 ) { |
|
1099 | + $query_params = array($_where, 'order_by' => array($orderby => $sort), 'default_where_conditions' => 'this_model_only'); |
|
1100 | + if ($per_page !== -1) { |
|
1101 | 1101 | $query_params['limit'] = $limit; |
1102 | 1102 | } |
1103 | - $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params); |
|
1103 | + $registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params); |
|
1104 | 1104 | |
1105 | - if ( $EVT_ID && isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) { |
|
1105 | + if ($EVT_ID && isset($registrations[0]) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) { |
|
1106 | 1106 | $first_registration = $registrations[0]; |
1107 | 1107 | //EEH_Debug_Tools::printr( $registrations[0], '$registrations <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
1108 | 1108 | $event_name = $first_registration->event_obj()->name(); |
1109 | - $event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1109 | + $event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a'); // isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y, g:i:s a', $registrations[0]->DTT_EVT_start ) : ''; |
|
1110 | 1110 | // edit event link |
1111 | - if ( $event_name != '' ) { |
|
1112 | - $edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL ); |
|
1113 | - $edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
|
1114 | - $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
|
1111 | + if ($event_name != '') { |
|
1112 | + $edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit_event', 'EVT_ID'=>$EVT_ID), EVENTS_ADMIN_URL); |
|
1113 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
1114 | + $event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>'; |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | - $back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL ); |
|
1118 | - $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">« ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>'; |
|
1117 | + $back_2_reg_url = self::add_query_args_and_nonce(array('action'=>'default'), REG_ADMIN_URL); |
|
1118 | + $back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__('click to return to viewing all registrations ', 'event_espresso').'">« '.__('Back to All Registrations', 'event_espresso').'</a>'; |
|
1119 | 1119 | |
1120 | 1120 | $this->_template_args['before_admin_page_content'] = ' |
1121 | 1121 | <div id="admin-page-header"> |
1122 | - <h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1> |
|
1123 | - <h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3> |
|
1124 | - <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span> |
|
1122 | + <h1><span class="small-text not-bold">'.__('Event: ', 'event_espresso').'</span>'.$event_name.'</h1> |
|
1123 | + <h3><span class="small-text not-bold">'.__('Date: ', 'event_espresso').'</span>'.$event_date.'</h3> |
|
1124 | + <span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span> |
|
1125 | 1125 | </div> |
1126 | 1126 | '; |
1127 | 1127 | |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | |
1160 | 1160 | $this->_set_registration_object(); |
1161 | 1161 | |
1162 | - if ( is_object( $this->_registration )) { |
|
1162 | + if (is_object($this->_registration)) { |
|
1163 | 1163 | $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance(); |
1164 | 1164 | $this->_session = $transaction->session_data(); |
1165 | 1165 | |
@@ -1167,10 +1167,10 @@ discard block |
||
1167 | 1167 | |
1168 | 1168 | |
1169 | 1169 | $this->_template_args['reg_nmbr']['value'] = $this->_registration->ID(); |
1170 | - $this->_template_args['reg_nmbr']['label'] = __( 'Registration Number', 'event_espresso' ); |
|
1170 | + $this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso'); |
|
1171 | 1171 | |
1172 | - $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime( 'REG_date' ); |
|
1173 | - $this->_template_args['reg_datetime']['label'] = __( 'Date', 'event_espresso' ); |
|
1172 | + $this->_template_args['reg_datetime']['value'] = $this->_registration->get_i18n_datetime('REG_date'); |
|
1173 | + $this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso'); |
|
1174 | 1174 | |
1175 | 1175 | $this->_template_args['grand_total'] = $transaction->total(); |
1176 | 1176 | |
@@ -1178,20 +1178,20 @@ discard block |
||
1178 | 1178 | // link back to overview |
1179 | 1179 | $this->_template_args['reg_overview_url'] = REG_ADMIN_URL; |
1180 | 1180 | $this->_template_args['registration'] = $this->_registration; |
1181 | - $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $event_id ), REG_ADMIN_URL ); |
|
1182 | - $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions' ), admin_url( 'admin.php' ) ); |
|
1183 | - $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id ), admin_url( 'admin.php' ) ); |
|
1181 | + $this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $event_id), REG_ADMIN_URL); |
|
1182 | + $this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions'), admin_url('admin.php')); |
|
1183 | + $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id), admin_url('admin.php')); |
|
1184 | 1184 | |
1185 | 1185 | //next and previous links |
1186 | - $next_reg = $this->_registration->next(null, array(), 'REG_ID' ); |
|
1187 | - $this->_template_args['next_registration'] = $next_reg ? $this->_next_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-right ee-icon-size-22' ) : ''; |
|
1188 | - $previous_reg = $this->_registration->previous( null, array(), 'REG_ID' ); |
|
1189 | - $this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-left ee-icon-size-22' ) : ''; |
|
1186 | + $next_reg = $this->_registration->next(null, array(), 'REG_ID'); |
|
1187 | + $this->_template_args['next_registration'] = $next_reg ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : ''; |
|
1188 | + $previous_reg = $this->_registration->previous(null, array(), 'REG_ID'); |
|
1189 | + $this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : ''; |
|
1190 | 1190 | |
1191 | 1191 | // grab header |
1192 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php'; |
|
1192 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php'; |
|
1193 | 1193 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
1194 | - $this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
1194 | + $this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
1195 | 1195 | |
1196 | 1196 | } else { |
1197 | 1197 | |
@@ -1210,17 +1210,17 @@ discard block |
||
1210 | 1210 | |
1211 | 1211 | |
1212 | 1212 | protected function _registration_details_metaboxes() { |
1213 | - do_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this ); |
|
1213 | + do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this); |
|
1214 | 1214 | $this->_set_registration_object(); |
1215 | 1215 | $attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null; |
1216 | - add_meta_box( 'edit-reg-status-mbox', __( 'Registration Status', 'event_espresso' ), array( $this, 'set_reg_status_buttons_metabox' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1217 | - add_meta_box( 'edit-reg-details-mbox', __( 'Registration Details', 'event_espresso' ), array( $this, '_reg_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1218 | - if ( $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox' ) ) { |
|
1219 | - add_meta_box( 'edit-reg-questions-mbox', __( 'Registration Form Answers', 'event_espresso' ), array( $this, '_reg_questions_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1216 | + add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high'); |
|
1217 | + add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1218 | + if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')) { |
|
1219 | + add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1220 | 1220 | } |
1221 | - add_meta_box( 'edit-reg-registrant-mbox', __( 'Contact Details', 'event_espresso' ), array( $this, '_reg_registrant_side_meta_box' ), $this->wp_page_slug, 'side', 'high' ); |
|
1222 | - if ( $this->_registration->group_size() > 1 ) { |
|
1223 | - add_meta_box( 'edit-reg-attendees-mbox', __( 'Other Registrations in this Transaction', 'event_espresso' ), array( $this, '_reg_attendees_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
1221 | + add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high'); |
|
1222 | + if ($this->_registration->group_size() > 1) { |
|
1223 | + add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
1224 | 1224 | } |
1225 | 1225 | } |
1226 | 1226 | |
@@ -1262,25 +1262,25 @@ discard block |
||
1262 | 1262 | 'html_id' => 'reg-status-change-form', |
1263 | 1263 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
1264 | 1264 | 'subsections' => array( |
1265 | - 'return' => new EE_Hidden_Input( array( |
|
1265 | + 'return' => new EE_Hidden_Input(array( |
|
1266 | 1266 | 'name' => 'return', |
1267 | 1267 | 'default' => 'view_registration' |
1268 | - ) ), |
|
1269 | - 'REG_ID' => new EE_Hidden_Input( array( |
|
1268 | + )), |
|
1269 | + 'REG_ID' => new EE_Hidden_Input(array( |
|
1270 | 1270 | 'name' => 'REG_ID', |
1271 | 1271 | 'default' => $this->_registration->ID() |
1272 | - ) ), |
|
1272 | + )), |
|
1273 | 1273 | 'current_status' => new EE_Form_Section_HTML( |
1274 | 1274 | EEH_HTML::tr( |
1275 | 1275 | EEH_HTML::th( |
1276 | 1276 | EEH_HTML::label( |
1277 | - EEH_HTML::strong( __( 'Current Registration Status', 'event_espresso' ) ) |
|
1277 | + EEH_HTML::strong(__('Current Registration Status', 'event_espresso')) |
|
1278 | 1278 | ) |
1279 | - ) . |
|
1279 | + ). |
|
1280 | 1280 | EEH_HTML::td( |
1281 | 1281 | EEH_HTML::strong( |
1282 | 1282 | $this->_registration->pretty_status(), |
1283 | - '', 'status-' . $this->_registration->status_ID(), 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
1283 | + '', 'status-'.$this->_registration->status_ID(), 'line-height: 1em; font-size: 1.5em; font-weight: bold;' |
|
1284 | 1284 | ) |
1285 | 1285 | ) |
1286 | 1286 | ) |
@@ -1288,22 +1288,22 @@ discard block |
||
1288 | 1288 | 'reg_status' => new EE_Select_Input( |
1289 | 1289 | $this->_get_reg_statuses(), |
1290 | 1290 | array( |
1291 | - 'html_label_text' => __( 'Change Registration Status to', 'event_espresso' ), |
|
1291 | + 'html_label_text' => __('Change Registration Status to', 'event_espresso'), |
|
1292 | 1292 | 'default' => $this->_registration->status_ID(), |
1293 | 1293 | ) |
1294 | 1294 | ), |
1295 | 1295 | 'send_notifications' => new EE_Yes_No_Input( |
1296 | 1296 | array( |
1297 | - 'html_label_text' => __( 'Send Related Messages', 'event_espresso' ), |
|
1297 | + 'html_label_text' => __('Send Related Messages', 'event_espresso'), |
|
1298 | 1298 | 'default' => false, |
1299 | - 'html_help_text' => __( 'If set to "Yes", then the related messages will be sent to the registrant.', 'event_espresso' ), |
|
1299 | + 'html_help_text' => __('If set to "Yes", then the related messages will be sent to the registrant.', 'event_espresso'), |
|
1300 | 1300 | ) |
1301 | 1301 | ), |
1302 | - 'submit' => new EE_Submit_Input( array( |
|
1302 | + 'submit' => new EE_Submit_Input(array( |
|
1303 | 1303 | 'html_class' => 'button-primary', |
1304 | 1304 | 'html_label_text' => ' ', |
1305 | - 'default' => __( 'Update Registration Status', 'event_espresso' ) |
|
1306 | - ) ), |
|
1305 | + 'default' => __('Update Registration Status', 'event_espresso') |
|
1306 | + )), |
|
1307 | 1307 | ), |
1308 | 1308 | ) |
1309 | 1309 | ); |
@@ -1316,7 +1316,7 @@ discard block |
||
1316 | 1316 | * Returns an array of all the buttons for the various statuses and switch status actions |
1317 | 1317 | * @return string |
1318 | 1318 | */ |
1319 | - protected function _get_current_reg_status_help_text( $STS_ID = '' ) { |
|
1319 | + protected function _get_current_reg_status_help_text($STS_ID = '') { |
|
1320 | 1320 | //$reg_status_help_text = array( |
1321 | 1321 | // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
1322 | 1322 | // 'RAP' => __( 'XXXXXXXXXXX', 'event_espresso' ), |
@@ -1349,14 +1349,14 @@ discard block |
||
1349 | 1349 | */ |
1350 | 1350 | protected function _get_reg_statuses() { |
1351 | 1351 | $reg_status_array = EEM_Registration::instance()->reg_status_array(); |
1352 | - unset ( $reg_status_array[ EEM_Registration::status_id_incomplete ] ); |
|
1352 | + unset ($reg_status_array[EEM_Registration::status_id_incomplete]); |
|
1353 | 1353 | // get current reg status |
1354 | 1354 | $current_status = $this->_registration->status_ID(); |
1355 | 1355 | // is registration for free event? This will determine whether to display the pending payment option |
1356 | - if ( $current_status != EEM_Registration::status_id_pending_payment && $this->_registration->transaction()->is_free() ) { |
|
1357 | - unset( $reg_status_array[ EEM_Registration::status_id_pending_payment ] ); |
|
1356 | + if ($current_status != EEM_Registration::status_id_pending_payment && $this->_registration->transaction()->is_free()) { |
|
1357 | + unset($reg_status_array[EEM_Registration::status_id_pending_payment]); |
|
1358 | 1358 | } |
1359 | - return EEM_Status::instance()->localized_status( $reg_status_array, false, 'sentence' ); |
|
1359 | + return EEM_Status::instance()->localized_status($reg_status_array, false, 'sentence'); |
|
1360 | 1360 | } |
1361 | 1361 | |
1362 | 1362 | |
@@ -1369,15 +1369,15 @@ discard block |
||
1369 | 1369 | * |
1370 | 1370 | * @return array (array with reg_id(s) updated and whether update was successful. |
1371 | 1371 | */ |
1372 | - protected function _set_registration_status_from_request( $status = false, $notify = false ) { |
|
1373 | - if ( isset( $this->_req_data[ 'reg_status_change_form' ] ) ) { |
|
1374 | - $REG_IDs = isset( $this->_req_data[ 'reg_status_change_form' ][ 'REG_ID' ] ) |
|
1375 | - ? (array)$this->_req_data[ 'reg_status_change_form' ][ 'REG_ID' ] |
|
1372 | + protected function _set_registration_status_from_request($status = false, $notify = false) { |
|
1373 | + if (isset($this->_req_data['reg_status_change_form'])) { |
|
1374 | + $REG_IDs = isset($this->_req_data['reg_status_change_form']['REG_ID']) |
|
1375 | + ? (array) $this->_req_data['reg_status_change_form']['REG_ID'] |
|
1376 | 1376 | : array(); |
1377 | 1377 | } else { |
1378 | - $REG_IDs = isset( $this->_req_data[ '_REG_ID' ] ) ? (array)$this->_req_data[ '_REG_ID' ] : array(); |
|
1378 | + $REG_IDs = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array(); |
|
1379 | 1379 | } |
1380 | - $success = $this->_set_registration_status( $REG_IDs, $status ); |
|
1380 | + $success = $this->_set_registration_status($REG_IDs, $status); |
|
1381 | 1381 | //notify? |
1382 | 1382 | if ( |
1383 | 1383 | $success |
@@ -1404,21 +1404,21 @@ discard block |
||
1404 | 1404 | * @param bool $status |
1405 | 1405 | * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as the array of updated registrations). |
1406 | 1406 | */ |
1407 | - protected function _set_registration_status( $REG_IDs = array(), $status = false ) { |
|
1407 | + protected function _set_registration_status($REG_IDs = array(), $status = false) { |
|
1408 | 1408 | $success = false; |
1409 | 1409 | // typecast $REG_IDs |
1410 | - $REG_IDs = (array)$REG_IDs; |
|
1411 | - if ( ! empty( $REG_IDs ) ) { |
|
1410 | + $REG_IDs = (array) $REG_IDs; |
|
1411 | + if ( ! empty($REG_IDs)) { |
|
1412 | 1412 | $success = true; |
1413 | 1413 | // set default status if none is passed |
1414 | 1414 | $status = $status ? $status : EEM_Registration::status_id_pending_payment; |
1415 | 1415 | // sanitize $REG_IDs |
1416 | - $REG_IDs = array_filter( $REG_IDs, 'absint' ); |
|
1416 | + $REG_IDs = array_filter($REG_IDs, 'absint'); |
|
1417 | 1417 | //loop through REG_ID's and change status |
1418 | - foreach ( $REG_IDs as $REG_ID ) { |
|
1419 | - $registration = EEM_Registration::instance()->get_one_by_ID( $REG_ID ); |
|
1420 | - if ( $registration instanceof EE_Registration ) { |
|
1421 | - $registration->set_status( $status ); |
|
1418 | + foreach ($REG_IDs as $REG_ID) { |
|
1419 | + $registration = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
1420 | + if ($registration instanceof EE_Registration) { |
|
1421 | + $registration->set_status($status); |
|
1422 | 1422 | $result = $registration->save(); |
1423 | 1423 | // verifying explicit fails because update *may* just return 0 for 0 rows affected |
1424 | 1424 | $success = $result !== false ? $success : false; |
@@ -1428,7 +1428,7 @@ discard block |
||
1428 | 1428 | //reset _req_data['_REG_ID'] for any potential future messages notifications |
1429 | 1429 | $this->_req_data['_REG_ID'] = $REG_IDs; |
1430 | 1430 | //return $success and processed registrations |
1431 | - return array( 'REG_ID' => $REG_IDs, 'success' => $success ); |
|
1431 | + return array('REG_ID' => $REG_IDs, 'success' => $success); |
|
1432 | 1432 | } |
1433 | 1433 | |
1434 | 1434 | |
@@ -1440,49 +1440,49 @@ discard block |
||
1440 | 1440 | * @param bool $notify indicates whether the _set_registration_status_from_request does notifications or not. |
1441 | 1441 | * @return void |
1442 | 1442 | */ |
1443 | - protected function _reg_status_change_return( $STS_ID, $notify = false ) { |
|
1444 | - $result = ! empty( $STS_ID ) |
|
1445 | - ? $this->_set_registration_status_from_request( $STS_ID, $notify ) |
|
1446 | - : array( 'success' => false ); |
|
1447 | - $success = isset( $result['success'] ) && $result['success']; |
|
1443 | + protected function _reg_status_change_return($STS_ID, $notify = false) { |
|
1444 | + $result = ! empty($STS_ID) |
|
1445 | + ? $this->_set_registration_status_from_request($STS_ID, $notify) |
|
1446 | + : array('success' => false); |
|
1447 | + $success = isset($result['success']) && $result['success']; |
|
1448 | 1448 | //setup success message |
1449 | - if ( $success ) { |
|
1450 | - if ( is_array( $result[ 'REG_ID' ] ) && count( $result[ 'REG_ID' ] ) === 1 ) { |
|
1449 | + if ($success) { |
|
1450 | + if (is_array($result['REG_ID']) && count($result['REG_ID']) === 1) { |
|
1451 | 1451 | $msg = sprintf( |
1452 | - __( 'Registration status has been set to %s', 'event_espresso' ), |
|
1453 | - EEH_Template::pretty_status( $STS_ID, false, 'lower' ) |
|
1452 | + __('Registration status has been set to %s', 'event_espresso'), |
|
1453 | + EEH_Template::pretty_status($STS_ID, false, 'lower') |
|
1454 | 1454 | ); |
1455 | 1455 | } else { |
1456 | 1456 | $msg = sprintf( |
1457 | - __( 'Registrations have been set to %s.', 'event_espresso' ), |
|
1458 | - EEH_Template::pretty_status( $STS_ID, false, 'lower' ) |
|
1457 | + __('Registrations have been set to %s.', 'event_espresso'), |
|
1458 | + EEH_Template::pretty_status($STS_ID, false, 'lower') |
|
1459 | 1459 | ); |
1460 | 1460 | } |
1461 | - EE_Error::add_success( $msg ); |
|
1461 | + EE_Error::add_success($msg); |
|
1462 | 1462 | } else { |
1463 | 1463 | EE_Error::add_error( |
1464 | - __( 'Something went wrong, and the status was not changed', 'event_espresso' ), |
|
1464 | + __('Something went wrong, and the status was not changed', 'event_espresso'), |
|
1465 | 1465 | __FILE__, __LINE__, __FUNCTION__ |
1466 | 1466 | ); |
1467 | 1467 | } |
1468 | - if ( isset( $this->_req_data[ 'return' ] ) && $this->_req_data[ 'return' ] == 'view_registration' ) { |
|
1469 | - $route = array( 'action' => 'view_registration', '_REG_ID' => reset( $result[ 'REG_ID' ] ) ); |
|
1468 | + if (isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration') { |
|
1469 | + $route = array('action' => 'view_registration', '_REG_ID' => reset($result['REG_ID'])); |
|
1470 | 1470 | } else { |
1471 | - $route = array( 'action' => 'default' ); |
|
1471 | + $route = array('action' => 'default'); |
|
1472 | 1472 | } |
1473 | 1473 | //unset nonces |
1474 | - foreach ( $this->_req_data as $ref => $value ) { |
|
1475 | - if ( strpos( $ref, 'nonce' ) !== false ) { |
|
1476 | - unset( $this->_req_data[$ref] ); |
|
1474 | + foreach ($this->_req_data as $ref => $value) { |
|
1475 | + if (strpos($ref, 'nonce') !== false) { |
|
1476 | + unset($this->_req_data[$ref]); |
|
1477 | 1477 | continue; |
1478 | 1478 | } |
1479 | 1479 | |
1480 | - $value = is_array( $value ) ? array_map( 'urlencode', $value ) : urlencode( $value ); |
|
1480 | + $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value); |
|
1481 | 1481 | $this->_req_data[$ref] = $value; |
1482 | 1482 | } |
1483 | 1483 | //merge request vars so that the reloaded list table contains any existing filter query params |
1484 | - $route = array_merge( $this->_req_data, $route ); |
|
1485 | - $this->_redirect_after_action( $success, '', '', $route, true ); |
|
1484 | + $route = array_merge($this->_req_data, $route); |
|
1485 | + $this->_redirect_after_action($success, '', '', $route, true); |
|
1486 | 1486 | } |
1487 | 1487 | |
1488 | 1488 | |
@@ -1493,51 +1493,51 @@ discard block |
||
1493 | 1493 | protected function _change_reg_status() { |
1494 | 1494 | $this->_req_data['return'] = 'view_registration'; |
1495 | 1495 | //set notify based on whether the send notifications toggle is set or not |
1496 | - $notify = ! empty( $this->_req_data['reg_status_change_form']['send_notifications'] ); |
|
1496 | + $notify = ! empty($this->_req_data['reg_status_change_form']['send_notifications']); |
|
1497 | 1497 | //$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] ); |
1498 | - $this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ] = isset( |
|
1499 | - $this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ] |
|
1498 | + $this->_req_data['reg_status_change_form']['reg_status'] = isset( |
|
1499 | + $this->_req_data['reg_status_change_form']['reg_status'] |
|
1500 | 1500 | ) |
1501 | - ? $this->_req_data[ 'reg_status_change_form' ][ 'reg_status' ] |
|
1501 | + ? $this->_req_data['reg_status_change_form']['reg_status'] |
|
1502 | 1502 | : ''; |
1503 | 1503 | |
1504 | - switch ( $this->_req_data[ 'reg_status_change_form' ]['reg_status'] ) { |
|
1504 | + switch ($this->_req_data['reg_status_change_form']['reg_status']) { |
|
1505 | 1505 | |
1506 | 1506 | case EEM_Registration::status_id_approved : |
1507 | - case EEH_Template::pretty_status( EEM_Registration::status_id_approved, false, 'sentence' ) : |
|
1508 | - $this->approve_registration( $notify ); |
|
1507 | + case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') : |
|
1508 | + $this->approve_registration($notify); |
|
1509 | 1509 | break; |
1510 | 1510 | |
1511 | 1511 | case EEM_Registration::status_id_pending_payment : |
1512 | - case EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, false, 'sentence' ) : |
|
1513 | - $this->pending_registration( $notify ); |
|
1512 | + case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') : |
|
1513 | + $this->pending_registration($notify); |
|
1514 | 1514 | break; |
1515 | 1515 | |
1516 | 1516 | case EEM_Registration::status_id_not_approved : |
1517 | - case EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, false, 'sentence' ) : |
|
1518 | - $this->not_approve_registration( $notify ); |
|
1517 | + case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') : |
|
1518 | + $this->not_approve_registration($notify); |
|
1519 | 1519 | break; |
1520 | 1520 | |
1521 | 1521 | case EEM_Registration::status_id_declined : |
1522 | - case EEH_Template::pretty_status( EEM_Registration::status_id_declined, false, 'sentence' ) : |
|
1523 | - $this->decline_registration( $notify ); |
|
1522 | + case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') : |
|
1523 | + $this->decline_registration($notify); |
|
1524 | 1524 | break; |
1525 | 1525 | |
1526 | 1526 | case EEM_Registration::status_id_cancelled : |
1527 | - case EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, false, 'sentence' ) : |
|
1528 | - $this->cancel_registration( $notify ); |
|
1527 | + case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') : |
|
1528 | + $this->cancel_registration($notify); |
|
1529 | 1529 | break; |
1530 | 1530 | |
1531 | 1531 | case EEM_Registration::status_id_wait_list : |
1532 | - case EEH_Template::pretty_status( EEM_Registration::status_id_wait_list, false, 'sentence' ) : |
|
1533 | - $this->waitlist_registration( $notify ); |
|
1532 | + case EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence') : |
|
1533 | + $this->waitlist_registration($notify); |
|
1534 | 1534 | break; |
1535 | 1535 | |
1536 | 1536 | case EEM_Registration::status_id_incomplete : |
1537 | 1537 | default : |
1538 | 1538 | $result['success'] = false; |
1539 | - unset( $this->_req_data['return'] ); |
|
1540 | - $this->_reg_status_change_return( '', false ); |
|
1539 | + unset($this->_req_data['return']); |
|
1540 | + $this->_reg_status_change_return('', false); |
|
1541 | 1541 | break; |
1542 | 1542 | } |
1543 | 1543 | } |
@@ -1551,8 +1551,8 @@ discard block |
||
1551 | 1551 | * @param bool $notify whether or not to notify the registrant about their approval. |
1552 | 1552 | * @return void |
1553 | 1553 | */ |
1554 | - protected function approve_registration( $notify = false ) { |
|
1555 | - $this->_reg_status_change_return( EEM_Registration::status_id_approved, $notify ); |
|
1554 | + protected function approve_registration($notify = false) { |
|
1555 | + $this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify); |
|
1556 | 1556 | } |
1557 | 1557 | |
1558 | 1558 | |
@@ -1564,8 +1564,8 @@ discard block |
||
1564 | 1564 | * @param bool $notify whether or not to notify the registrant about their status change. |
1565 | 1565 | * @return void |
1566 | 1566 | */ |
1567 | - protected function decline_registration( $notify = false ) { |
|
1568 | - $this->_reg_status_change_return( EEM_Registration::status_id_declined, $notify ); |
|
1567 | + protected function decline_registration($notify = false) { |
|
1568 | + $this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify); |
|
1569 | 1569 | } |
1570 | 1570 | |
1571 | 1571 | |
@@ -1577,8 +1577,8 @@ discard block |
||
1577 | 1577 | * @param bool $notify whether or not to notify the registrant about their status change. |
1578 | 1578 | * @return void |
1579 | 1579 | */ |
1580 | - protected function cancel_registration( $notify = false ) { |
|
1581 | - $this->_reg_status_change_return( EEM_Registration::status_id_cancelled, $notify ); |
|
1580 | + protected function cancel_registration($notify = false) { |
|
1581 | + $this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify); |
|
1582 | 1582 | } |
1583 | 1583 | |
1584 | 1584 | |
@@ -1590,8 +1590,8 @@ discard block |
||
1590 | 1590 | * @param bool $notify whether or not to notify the registrant about their status change. |
1591 | 1591 | * @return void |
1592 | 1592 | */ |
1593 | - protected function not_approve_registration( $notify = false ) { |
|
1594 | - $this->_reg_status_change_return( EEM_Registration::status_id_not_approved, $notify ); |
|
1593 | + protected function not_approve_registration($notify = false) { |
|
1594 | + $this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify); |
|
1595 | 1595 | } |
1596 | 1596 | |
1597 | 1597 | |
@@ -1603,8 +1603,8 @@ discard block |
||
1603 | 1603 | * @param bool $notify whether or not to notify the registrant about their status change. |
1604 | 1604 | * @return void |
1605 | 1605 | */ |
1606 | - protected function pending_registration( $notify = false ) { |
|
1607 | - $this->_reg_status_change_return( EEM_Registration::status_id_pending_payment, $notify ); |
|
1606 | + protected function pending_registration($notify = false) { |
|
1607 | + $this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify); |
|
1608 | 1608 | } |
1609 | 1609 | |
1610 | 1610 | |
@@ -1616,8 +1616,8 @@ discard block |
||
1616 | 1616 | * @param bool $notify whether or not to notify the registrant about their status change. |
1617 | 1617 | * @return void |
1618 | 1618 | */ |
1619 | - protected function waitlist_registration( $notify = false ) { |
|
1620 | - $this->_reg_status_change_return( EEM_Registration::status_id_wait_list, $notify ); |
|
1619 | + protected function waitlist_registration($notify = false) { |
|
1620 | + $this->_reg_status_change_return(EEM_Registration::status_id_wait_list, $notify); |
|
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | |
@@ -1631,14 +1631,14 @@ discard block |
||
1631 | 1631 | public function _reg_details_meta_box() { |
1632 | 1632 | EEH_Autoloader::register_line_item_display_autoloaders(); |
1633 | 1633 | EEH_Autoloader::register_line_item_filter_autoloaders(); |
1634 | - EE_Registry::instance()->load_helper( 'Line_Item' ); |
|
1634 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
1635 | 1635 | $transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance(); |
1636 | 1636 | $this->_session = $transaction->session_data(); |
1637 | 1637 | |
1638 | 1638 | $filters = new EE_Line_Item_Filter_Collection(); |
1639 | 1639 | //$filters->add( new EE_Non_Zero_Line_Item_Filter() ); |
1640 | - $filters->add( new EE_Single_Registration_Line_Item_Filter( $this->_registration ) ); |
|
1641 | - $line_item_filter_processor = new EE_Line_Item_Filter_Processor( $filters, $transaction->total_line_item() ); |
|
1640 | + $filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration)); |
|
1641 | + $line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item()); |
|
1642 | 1642 | $filtered_line_item_tree = $line_item_filter_processor->process(); |
1643 | 1643 | $line_item_display = new EE_Line_Item_Display( |
1644 | 1644 | 'reg_admin_table', |
@@ -1646,7 +1646,7 @@ discard block |
||
1646 | 1646 | ); |
1647 | 1647 | $this->_template_args['line_item_table'] = $line_item_display->display_line_item( |
1648 | 1648 | $filtered_line_item_tree, |
1649 | - array( 'EE_Registration' => $this->_registration ) |
|
1649 | + array('EE_Registration' => $this->_registration) |
|
1650 | 1650 | ); |
1651 | 1651 | $attendee = $this->_registration->attendee(); |
1652 | 1652 | |
@@ -1656,7 +1656,7 @@ discard block |
||
1656 | 1656 | 'espresso_transactions_view_transaction' |
1657 | 1657 | ) |
1658 | 1658 | ) { |
1659 | - $this->_template_args[ 'view_transaction_button' ] = EEH_Template::get_button_or_link( |
|
1659 | + $this->_template_args['view_transaction_button'] = EEH_Template::get_button_or_link( |
|
1660 | 1660 | EE_Admin_Page::add_query_args_and_nonce( |
1661 | 1661 | array( |
1662 | 1662 | 'action' => 'view_transaction', |
@@ -1664,12 +1664,12 @@ discard block |
||
1664 | 1664 | ), |
1665 | 1665 | TXN_ADMIN_URL |
1666 | 1666 | ), |
1667 | - esc_html__( ' View Transaction' ), |
|
1667 | + esc_html__(' View Transaction'), |
|
1668 | 1668 | 'button secondary-button right', |
1669 | 1669 | 'dashicons dashicons-cart' |
1670 | 1670 | ); |
1671 | 1671 | } else { |
1672 | - $this->_template_args[ 'view_transaction_button' ] = ''; |
|
1672 | + $this->_template_args['view_transaction_button'] = ''; |
|
1673 | 1673 | } |
1674 | 1674 | |
1675 | 1675 | if ( |
@@ -1679,7 +1679,7 @@ discard block |
||
1679 | 1679 | 'espresso_registrations_resend_registration' |
1680 | 1680 | ) |
1681 | 1681 | ) { |
1682 | - $this->_template_args[ 'resend_registration_button' ] = EEH_Template::get_button_or_link( |
|
1682 | + $this->_template_args['resend_registration_button'] = EEH_Template::get_button_or_link( |
|
1683 | 1683 | EE_Admin_Page::add_query_args_and_nonce( |
1684 | 1684 | array( |
1685 | 1685 | 'action' => 'resend_registration', |
@@ -1688,55 +1688,55 @@ discard block |
||
1688 | 1688 | ), |
1689 | 1689 | REG_ADMIN_URL |
1690 | 1690 | ), |
1691 | - esc_html__( ' Resend Registration' ), |
|
1691 | + esc_html__(' Resend Registration'), |
|
1692 | 1692 | 'button secondary-button right', |
1693 | 1693 | 'dashicons dashicons-email-alt' |
1694 | 1694 | ); |
1695 | 1695 | } else { |
1696 | - $this->_template_args[ 'resend_registration_button' ] = ''; |
|
1696 | + $this->_template_args['resend_registration_button'] = ''; |
|
1697 | 1697 | } |
1698 | 1698 | |
1699 | 1699 | $this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign; |
1700 | - $payment = $transaction->get_first_related( 'Payment' ); |
|
1700 | + $payment = $transaction->get_first_related('Payment'); |
|
1701 | 1701 | $payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment; |
1702 | - $payment_method = $payment->get_first_related( 'Payment_Method' ); |
|
1702 | + $payment_method = $payment->get_first_related('Payment_Method'); |
|
1703 | 1703 | $payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method; |
1704 | 1704 | |
1705 | 1705 | $reg_details = array( |
1706 | 1706 | 'payment_method' => $payment_method->name(), |
1707 | 1707 | 'response_msg' => $payment->gateway_response(), |
1708 | - 'registration_id' => $this->_registration->get( 'REG_code' ), |
|
1708 | + 'registration_id' => $this->_registration->get('REG_code'), |
|
1709 | 1709 | 'registration_session' => $this->_registration->session_ID(), |
1710 | - 'ip_address' => isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '', |
|
1711 | - 'user_agent' => isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '', |
|
1710 | + 'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '', |
|
1711 | + 'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '', |
|
1712 | 1712 | ); |
1713 | 1713 | |
1714 | 1714 | |
1715 | - if ( isset( $reg_details['registration_id'] )) { |
|
1715 | + if (isset($reg_details['registration_id'])) { |
|
1716 | 1716 | $this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id']; |
1717 | - $this->_template_args['reg_details']['registration_id']['label'] = __( 'Registration ID', 'event_espresso' ); |
|
1717 | + $this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso'); |
|
1718 | 1718 | $this->_template_args['reg_details']['registration_id']['class'] = 'regular-text'; |
1719 | 1719 | } |
1720 | 1720 | |
1721 | - if ( isset( $reg_details['payment_method'] ) ) { |
|
1721 | + if (isset($reg_details['payment_method'])) { |
|
1722 | 1722 | $this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method']; |
1723 | - $this->_template_args['reg_details']['payment_method']['label'] = __( 'Most Recent Payment Method', 'event_espresso' ); |
|
1723 | + $this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso'); |
|
1724 | 1724 | $this->_template_args['reg_details']['payment_method']['class'] = 'regular-text'; |
1725 | 1725 | $this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg']; |
1726 | - $this->_template_args['reg_details']['response_msg']['label'] = __( 'Payment method response', 'event_espresso' ); |
|
1726 | + $this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso'); |
|
1727 | 1727 | $this->_template_args['reg_details']['response_msg']['class'] = 'regular-text'; |
1728 | 1728 | } |
1729 | 1729 | |
1730 | 1730 | $this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session']; |
1731 | - $this->_template_args['reg_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' ); |
|
1731 | + $this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso'); |
|
1732 | 1732 | $this->_template_args['reg_details']['registration_session']['class'] = 'regular-text'; |
1733 | 1733 | |
1734 | 1734 | $this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address']; |
1735 | - $this->_template_args['reg_details']['ip_address']['label'] = __( 'Registration placed from IP', 'event_espresso' ); |
|
1735 | + $this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso'); |
|
1736 | 1736 | $this->_template_args['reg_details']['ip_address']['class'] = 'regular-text'; |
1737 | 1737 | |
1738 | 1738 | $this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent']; |
1739 | - $this->_template_args['reg_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' ); |
|
1739 | + $this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso'); |
|
1740 | 1740 | $this->_template_args['reg_details']['user_agent']['class'] = 'large-text'; |
1741 | 1741 | |
1742 | 1742 | $this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( |
@@ -1749,8 +1749,8 @@ discard block |
||
1749 | 1749 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
1750 | 1750 | $this->_template_args['event_id'] = $this->_registration->event_ID(); |
1751 | 1751 | |
1752 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
1753 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
1752 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php'; |
|
1753 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
1754 | 1754 | |
1755 | 1755 | } |
1756 | 1756 | |
@@ -1764,14 +1764,14 @@ discard block |
||
1764 | 1764 | */ |
1765 | 1765 | public function _reg_questions_meta_box() { |
1766 | 1766 | //allow someone to override this method entirely |
1767 | - if( apply_filters( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration ) ) { |
|
1768 | - $form = $this->_get_reg_custom_questions_form( $this->_registration->ID() ); |
|
1769 | - $this->_template_args[ 'att_questions' ] = count( $form->subforms() ) > 0 ? $form->get_html_and_js() : ''; |
|
1767 | + if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration)) { |
|
1768 | + $form = $this->_get_reg_custom_questions_form($this->_registration->ID()); |
|
1769 | + $this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : ''; |
|
1770 | 1770 | $this->_template_args['reg_questions_form_action'] = 'edit_registration'; |
1771 | 1771 | $this->_template_args['REG_ID'] = $this->_registration->ID(); |
1772 | 1772 | |
1773 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
1774 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
1773 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
1774 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
1775 | 1775 | } |
1776 | 1776 | } |
1777 | 1777 | |
@@ -1785,12 +1785,12 @@ discard block |
||
1785 | 1785 | * @param string $output |
1786 | 1786 | * @return string |
1787 | 1787 | */ |
1788 | - public function form_before_question_group( $output ) { |
|
1788 | + public function form_before_question_group($output) { |
|
1789 | 1789 | EE_Error::doing_it_wrong( |
1790 | - __CLASS__ . '::' . __FUNCTION__, |
|
1791 | - __( 'This method would have been protected but was used on a filter callback' |
|
1790 | + __CLASS__.'::'.__FUNCTION__, |
|
1791 | + __('This method would have been protected but was used on a filter callback' |
|
1792 | 1792 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1793 | - 'event_espresso' ), |
|
1793 | + 'event_espresso'), |
|
1794 | 1794 | '4.8.32.rc.000' |
1795 | 1795 | ); |
1796 | 1796 | return ' |
@@ -1809,20 +1809,20 @@ discard block |
||
1809 | 1809 | * @param string $output |
1810 | 1810 | * @return string |
1811 | 1811 | */ |
1812 | - public function form_after_question_group( $output ) { |
|
1812 | + public function form_after_question_group($output) { |
|
1813 | 1813 | EE_Error::doing_it_wrong( |
1814 | - __CLASS__ . '::' . __FUNCTION__, |
|
1815 | - __( 'This method would have been protected but was used on a filter callback' |
|
1814 | + __CLASS__.'::'.__FUNCTION__, |
|
1815 | + __('This method would have been protected but was used on a filter callback' |
|
1816 | 1816 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1817 | - 'event_espresso' ), |
|
1817 | + 'event_espresso'), |
|
1818 | 1818 | '4.8.32.rc.000' |
1819 | 1819 | ); |
1820 | 1820 | return ' |
1821 | 1821 | <tr class="hide-if-no-js"> |
1822 | 1822 | <th> </th> |
1823 | 1823 | <td class="reg-admin-edit-attendee-question-td"> |
1824 | - <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__( 'click to edit question', 'event_espresso' ) . '"> |
|
1825 | - <span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __( 'edit the above question group', 'event_espresso' ) . '</span> |
|
1824 | + <a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__('click to edit question', 'event_espresso').'"> |
|
1825 | + <span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso').'</span> |
|
1826 | 1826 | <div class="dashicons dashicons-edit"></div> |
1827 | 1827 | </a> |
1828 | 1828 | </td> |
@@ -1842,18 +1842,18 @@ discard block |
||
1842 | 1842 | * @param string $label |
1843 | 1843 | * @return string |
1844 | 1844 | */ |
1845 | - public function form_form_field_label_wrap( $label ) { |
|
1845 | + public function form_form_field_label_wrap($label) { |
|
1846 | 1846 | EE_Error::doing_it_wrong( |
1847 | - __CLASS__ . '::' . __FUNCTION__, |
|
1848 | - __( 'This method would have been protected but was used on a filter callback' |
|
1847 | + __CLASS__.'::'.__FUNCTION__, |
|
1848 | + __('This method would have been protected but was used on a filter callback' |
|
1849 | 1849 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1850 | - 'event_espresso' ), |
|
1850 | + 'event_espresso'), |
|
1851 | 1851 | '4.8.32.rc.000' |
1852 | 1852 | ); |
1853 | 1853 | return ' |
1854 | 1854 | <tr> |
1855 | 1855 | <th> |
1856 | - ' . $label . ' |
|
1856 | + ' . $label.' |
|
1857 | 1857 | </th>'; |
1858 | 1858 | } |
1859 | 1859 | |
@@ -1867,17 +1867,17 @@ discard block |
||
1867 | 1867 | * @param string $input |
1868 | 1868 | * @return string |
1869 | 1869 | */ |
1870 | - public function form_form_field_input__wrap( $input ) { |
|
1870 | + public function form_form_field_input__wrap($input) { |
|
1871 | 1871 | EE_Error::doing_it_wrong( |
1872 | - __CLASS__ . '::' . __FUNCTION__, |
|
1873 | - __( 'This method would have been protected but was used on a filter callback' |
|
1872 | + __CLASS__.'::'.__FUNCTION__, |
|
1873 | + __('This method would have been protected but was used on a filter callback' |
|
1874 | 1874 | . 'so needed to be public. Please discontinue usage as it will be removed soon.', |
1875 | - 'event_espresso' ), |
|
1875 | + 'event_espresso'), |
|
1876 | 1876 | '4.8.32.rc.000' |
1877 | 1877 | ); |
1878 | 1878 | return ' |
1879 | 1879 | <td class="reg-admin-attendee-questions-input-td disabled-input"> |
1880 | - ' . $input . ' |
|
1880 | + ' . $input.' |
|
1881 | 1881 | </td> |
1882 | 1882 | </tr>'; |
1883 | 1883 | } |
@@ -1891,14 +1891,14 @@ discard block |
||
1891 | 1891 | * @return void |
1892 | 1892 | */ |
1893 | 1893 | protected function _update_attendee_registration_form() { |
1894 | - do_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this ); |
|
1895 | - if( $_SERVER['REQUEST_METHOD'] == 'POST'){ |
|
1896 | - $REG_ID = isset( $this->_req_data['_REG_ID'] ) ? absint( $this->_req_data['_REG_ID'] ) : FALSE; |
|
1897 | - $success = $this->_save_reg_custom_questions_form( $REG_ID ); |
|
1898 | - if( $success ) { |
|
1894 | + do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this); |
|
1895 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
1896 | + $REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : FALSE; |
|
1897 | + $success = $this->_save_reg_custom_questions_form($REG_ID); |
|
1898 | + if ($success) { |
|
1899 | 1899 | $what = __('Registration Form', 'event_espresso'); |
1900 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
1901 | - $this->_redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
1900 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
1901 | + $this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
1902 | 1902 | } |
1903 | 1903 | } |
1904 | 1904 | } |
@@ -1909,11 +1909,11 @@ discard block |
||
1909 | 1909 | * @param int $REG_ID |
1910 | 1910 | * @return EE_Registration_Custom_Questions_Form |
1911 | 1911 | */ |
1912 | - protected function _get_reg_custom_questions_form( $REG_ID ) { |
|
1913 | - if( ! $this->_reg_custom_questions_form ) { |
|
1914 | - require_once( REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php' ); |
|
1915 | - $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( EEM_Registration::instance()->get_one_by_ID( $REG_ID ) ); |
|
1916 | - $this->_reg_custom_questions_form->_construct_finalize( null, null ); |
|
1912 | + protected function _get_reg_custom_questions_form($REG_ID) { |
|
1913 | + if ( ! $this->_reg_custom_questions_form) { |
|
1914 | + require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php'); |
|
1915 | + $this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance()->get_one_by_ID($REG_ID)); |
|
1916 | + $this->_reg_custom_questions_form->_construct_finalize(null, null); |
|
1917 | 1917 | } |
1918 | 1918 | return $this->_reg_custom_questions_form; |
1919 | 1919 | } |
@@ -1926,17 +1926,17 @@ discard block |
||
1926 | 1926 | * @param bool $REG_ID |
1927 | 1927 | * @return bool |
1928 | 1928 | */ |
1929 | - private function _save_reg_custom_questions_form( $REG_ID = FALSE ) { |
|
1929 | + private function _save_reg_custom_questions_form($REG_ID = FALSE) { |
|
1930 | 1930 | |
1931 | 1931 | if ( ! $REG_ID) { |
1932 | - EE_Error::add_error( __('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1932 | + EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1933 | 1933 | } |
1934 | - $form = $this->_get_reg_custom_questions_form( $REG_ID ); |
|
1935 | - $form->receive_form_submission( $this->_req_data ); |
|
1934 | + $form = $this->_get_reg_custom_questions_form($REG_ID); |
|
1935 | + $form->receive_form_submission($this->_req_data); |
|
1936 | 1936 | $success = false; |
1937 | - if( $form->is_valid() ) { |
|
1938 | - foreach( $form->subforms() as $question_group_id => $question_group_form ) { |
|
1939 | - foreach( $question_group_form->inputs() as $question_id => $input ) { |
|
1937 | + if ($form->is_valid()) { |
|
1938 | + foreach ($form->subforms() as $question_group_id => $question_group_form) { |
|
1939 | + foreach ($question_group_form->inputs() as $question_id => $input) { |
|
1940 | 1940 | $where_conditions = array( |
1941 | 1941 | 'QST_ID' => $question_id, |
1942 | 1942 | 'REG_ID' => $REG_ID |
@@ -1944,19 +1944,19 @@ discard block |
||
1944 | 1944 | $possibly_new_values = array( |
1945 | 1945 | 'ANS_value' => $input->normalized_value() |
1946 | 1946 | ); |
1947 | - $answer = EEM_Answer::instance()->get_one( array( $where_conditions ) ); |
|
1948 | - if( $answer instanceof EE_Answer ) { |
|
1949 | - $success = $answer->save( $possibly_new_values ); |
|
1947 | + $answer = EEM_Answer::instance()->get_one(array($where_conditions)); |
|
1948 | + if ($answer instanceof EE_Answer) { |
|
1949 | + $success = $answer->save($possibly_new_values); |
|
1950 | 1950 | } else { |
1951 | 1951 | //insert it then |
1952 | - $cols_n_vals = array_merge( $where_conditions, $possibly_new_values ); |
|
1953 | - $answer = EE_Answer::new_instance( $cols_n_vals ); |
|
1952 | + $cols_n_vals = array_merge($where_conditions, $possibly_new_values); |
|
1953 | + $answer = EE_Answer::new_instance($cols_n_vals); |
|
1954 | 1954 | $success = $answer->save(); |
1955 | 1955 | } |
1956 | 1956 | } |
1957 | 1957 | } |
1958 | 1958 | } else { |
1959 | - EE_Error::add_error( $form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1959 | + EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__); |
|
1960 | 1960 | } |
1961 | 1961 | return $success; |
1962 | 1962 | } |
@@ -1974,31 +1974,31 @@ discard block |
||
1974 | 1974 | $registrations = $REG->get_all(array( |
1975 | 1975 | array( |
1976 | 1976 | 'TXN_ID'=>$this->_registration->transaction_ID(), |
1977 | - 'REG_ID'=>array('!=',$this->_registration->ID()) |
|
1977 | + 'REG_ID'=>array('!=', $this->_registration->ID()) |
|
1978 | 1978 | ), |
1979 | 1979 | 'force_join'=>array('Attendee'))); |
1980 | 1980 | |
1981 | 1981 | $this->_template_args['attendees'] = array(); |
1982 | 1982 | $this->_template_args['attendee_notice'] = ''; |
1983 | - if ( empty( $registrations) || ( is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations) ) ) { |
|
1984 | - EE_Error::add_error( __('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1983 | + if (empty($registrations) || (is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations))) { |
|
1984 | + EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1985 | 1985 | $this->_template_args['attendee_notice'] = EE_Error::get_notices(); |
1986 | 1986 | } else { |
1987 | 1987 | |
1988 | 1988 | $att_nmbr = 1; |
1989 | - foreach ( $registrations as $registration ) { |
|
1989 | + foreach ($registrations as $registration) { |
|
1990 | 1990 | /* @var $registration EE_Registration */ |
1991 | 1991 | $attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object(); |
1992 | - $this->_template_args['attendees'][ $att_nmbr ]['STS_ID'] = $registration->status_ID(); |
|
1993 | - $this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
1994 | - $this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
1995 | - $this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
1996 | - $this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
1992 | + $this->_template_args['attendees'][$att_nmbr]['STS_ID'] = $registration->status_ID(); |
|
1993 | + $this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : ''; |
|
1994 | + $this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : ''; |
|
1995 | + $this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : ''; |
|
1996 | + $this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : ''; |
|
1997 | 1997 | |
1998 | - $this->_template_args['attendees'][ $att_nmbr ]['address'] = implode( ', ', $attendee->full_address_as_array() ); |
|
1998 | + $this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', $attendee->full_address_as_array()); |
|
1999 | 1999 | |
2000 | - $this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
|
2001 | - $this->_template_args['attendees'][ $att_nmbr ]['event_name'] = $registration->event_obj()->name(); |
|
2000 | + $this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL); |
|
2001 | + $this->_template_args['attendees'][$att_nmbr]['event_name'] = $registration->event_obj()->name(); |
|
2002 | 2002 | |
2003 | 2003 | $att_nmbr++; |
2004 | 2004 | } |
@@ -2008,8 +2008,8 @@ discard block |
||
2008 | 2008 | |
2009 | 2009 | // $this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees' ), REG_ADMIN_URL ); |
2010 | 2010 | } |
2011 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php'; |
|
2012 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2011 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php'; |
|
2012 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2013 | 2013 | |
2014 | 2014 | } |
2015 | 2015 | |
@@ -2030,14 +2030,14 @@ discard block |
||
2030 | 2030 | $attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object(); |
2031 | 2031 | |
2032 | 2032 | //now let's determine if this is not the primary registration. If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show create button or not) |
2033 | - if ( ! $this->_registration->is_primary_registrant() ) { |
|
2033 | + if ( ! $this->_registration->is_primary_registrant()) { |
|
2034 | 2034 | |
2035 | 2035 | $primary_registration = $this->_registration->get_primary_registration(); |
2036 | 2036 | $primary_attendee = $primary_registration instanceof EE_Registration |
2037 | 2037 | ? $primary_registration->attendee() |
2038 | 2038 | : null; |
2039 | 2039 | |
2040 | - if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID() ) { |
|
2040 | + if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) { |
|
2041 | 2041 | //in here? This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg. |
2042 | 2042 | $primary_registration = NULL; |
2043 | 2043 | } |
@@ -2046,27 +2046,27 @@ discard block |
||
2046 | 2046 | } |
2047 | 2047 | |
2048 | 2048 | $this->_template_args['ATT_ID'] = $attendee->ID(); |
2049 | - $this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname; |
|
2050 | - $this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname; |
|
2051 | - $this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email; |
|
2049 | + $this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname; |
|
2050 | + $this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname; |
|
2051 | + $this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email; |
|
2052 | 2052 | $this->_template_args['phone'] = $attendee->phone(); |
2053 | 2053 | |
2054 | - $this->_template_args[ 'formatted_address' ] = EEH_Address::format( $attendee ); |
|
2054 | + $this->_template_args['formatted_address'] = EEH_Address::format($attendee); |
|
2055 | 2055 | |
2056 | 2056 | |
2057 | 2057 | //edit link |
2058 | - $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL ); |
|
2058 | + $this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL); |
|
2059 | 2059 | $this->_template_args['att_edit_label'] = __('View/Edit Contact', 'event_espresso'); |
2060 | 2060 | |
2061 | 2061 | //create link |
2062 | - $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID() ), REG_ADMIN_URL ): ''; |
|
2062 | + $this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID()), REG_ADMIN_URL) : ''; |
|
2063 | 2063 | $this->_template_args['create_label'] = __('Create Contact', 'event_espresso'); |
2064 | 2064 | |
2065 | 2065 | $this->_template_args['att_check'] = $att_check; |
2066 | 2066 | |
2067 | 2067 | |
2068 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php'; |
|
2069 | - echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2068 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php'; |
|
2069 | + echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2070 | 2070 | } |
2071 | 2071 | |
2072 | 2072 | |
@@ -2079,7 +2079,7 @@ discard block |
||
2079 | 2079 | * @access protected |
2080 | 2080 | * @return void |
2081 | 2081 | */ |
2082 | - protected function _trash_or_restore_registrations( $trash = TRUE ) { |
|
2082 | + protected function _trash_or_restore_registrations($trash = TRUE) { |
|
2083 | 2083 | $REGM = EEM_Registration::instance(); |
2084 | 2084 | |
2085 | 2085 | $success = 1; |
@@ -2089,26 +2089,26 @@ discard block |
||
2089 | 2089 | $dtts = array(); |
2090 | 2090 | |
2091 | 2091 | //if empty _REG_ID then get out because there's nothing to do |
2092 | - if ( empty( $this->_req_data['_REG_ID'] ) ) { |
|
2092 | + if (empty($this->_req_data['_REG_ID'])) { |
|
2093 | 2093 | $msg = $trash ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', 'event_espresso') : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', 'event_espresso'); |
2094 | - EE_Error::add_error( $msg, __FILE__, __LINE__, __FUNCTION__ ); |
|
2095 | - $this->_redirect_after_action(FALSE, '', '', array(), TRUE ); |
|
2094 | + EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__); |
|
2095 | + $this->_redirect_after_action(FALSE, '', '', array(), TRUE); |
|
2096 | 2096 | } |
2097 | 2097 | |
2098 | 2098 | //Checkboxes |
2099 | - if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2099 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2100 | 2100 | // if array has more than one element than success message should be plural |
2101 | - $success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1; |
|
2101 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
2102 | 2102 | // cycle thru checkboxes |
2103 | - while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) { |
|
2103 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
2104 | 2104 | /** @var EE_Registration $REG */ |
2105 | - $REG = $REGM->get_one_by_ID( $REG_ID); |
|
2105 | + $REG = $REGM->get_one_by_ID($REG_ID); |
|
2106 | 2106 | $payment_count = $REG->get_first_related('Transaction')->count_related('Payment'); |
2107 | - if ( $payment_count > 0 ) { |
|
2108 | - $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' ); |
|
2107 | + if ($payment_count > 0) { |
|
2108 | + $name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __('Unknown Attendee', 'event_espresso'); |
|
2109 | 2109 | $error = 1; |
2110 | 2110 | $success = 0; |
2111 | - EE_Error::add_error( sprintf( __('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
2111 | + EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction. If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__); |
|
2112 | 2112 | continue; //can't trash this registration because it has payments. |
2113 | 2113 | } |
2114 | 2114 | $ticket = $REG->get_first_related('Ticket'); |
@@ -2117,7 +2117,7 @@ discard block |
||
2117 | 2117 | $dtts = array_merge($dtts, $dtt); |
2118 | 2118 | |
2119 | 2119 | $updated = $trash ? $REG->delete() : $REG->restore(); |
2120 | - if ( !$updated ) { |
|
2120 | + if ( ! $updated) { |
|
2121 | 2121 | $success = 0; |
2122 | 2122 | } else { |
2123 | 2123 | $success = 2; |
@@ -2132,7 +2132,7 @@ discard block |
||
2132 | 2132 | $tickets[$ticket->ID()] = $ticket; |
2133 | 2133 | $dtts = $ticket->get_many_related('Datetime'); |
2134 | 2134 | $updated = $trash ? $REG->delete() : $REG->restore(); |
2135 | - if ( ! $updated ) { |
|
2135 | + if ( ! $updated) { |
|
2136 | 2136 | $success = 0; |
2137 | 2137 | } |
2138 | 2138 | |
@@ -2142,10 +2142,10 @@ discard block |
||
2142 | 2142 | EEM_Ticket::instance()->update_tickets_sold($tickets); |
2143 | 2143 | EEM_Datetime::instance()->update_sold($dtts); |
2144 | 2144 | |
2145 | - $what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' ); |
|
2146 | - $action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' ); |
|
2145 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
2146 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
2147 | 2147 | $overwrite_msgs = $error ? TRUE : FALSE; |
2148 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), $overwrite_msgs ); |
|
2148 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs); |
|
2149 | 2149 | } |
2150 | 2150 | |
2151 | 2151 | |
@@ -2169,16 +2169,16 @@ discard block |
||
2169 | 2169 | $success = 1; |
2170 | 2170 | |
2171 | 2171 | //Checkboxes |
2172 | - if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2172 | + if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) { |
|
2173 | 2173 | // if array has more than one element than success message should be plural |
2174 | - $success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1; |
|
2174 | + $success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1; |
|
2175 | 2175 | // cycle thru checkboxes |
2176 | - while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) { |
|
2176 | + while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) { |
|
2177 | 2177 | $REG = $REG_MDL->get_one_by_ID($REG_ID); |
2178 | - if ( ! $REG instanceof EE_Registration ) |
|
2178 | + if ( ! $REG instanceof EE_Registration) |
|
2179 | 2179 | continue; |
2180 | 2180 | $deleted = $this->_delete_registration($REG); |
2181 | - if ( !$deleted ) { |
|
2181 | + if ( ! $deleted) { |
|
2182 | 2182 | $success = 0; |
2183 | 2183 | } |
2184 | 2184 | } |
@@ -2188,15 +2188,15 @@ discard block |
||
2188 | 2188 | $REG_ID = $this->_req_data['_REG_ID']; |
2189 | 2189 | $REG = $REG_MDL->get_one_by_ID($REG_ID); |
2190 | 2190 | $deleted = $this->_delete_registration($REG); |
2191 | - if ( ! $deleted ) { |
|
2191 | + if ( ! $deleted) { |
|
2192 | 2192 | $success = 0; |
2193 | 2193 | } |
2194 | 2194 | |
2195 | 2195 | } |
2196 | 2196 | |
2197 | - $what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' ); |
|
2198 | - $action_desc = __( 'permanently deleted.', 'event_espresso' ); |
|
2199 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), TRUE ); |
|
2197 | + $what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso'); |
|
2198 | + $action_desc = __('permanently deleted.', 'event_espresso'); |
|
2199 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), TRUE); |
|
2200 | 2200 | } |
2201 | 2201 | |
2202 | 2202 | |
@@ -2208,31 +2208,31 @@ discard block |
||
2208 | 2208 | * @param EE_Registration $REG registration to be deleted permenantly |
2209 | 2209 | * @return boolean true = successful deletion, false = fail. |
2210 | 2210 | */ |
2211 | - protected function _delete_registration( EE_Registration $REG ) { |
|
2211 | + protected function _delete_registration(EE_Registration $REG) { |
|
2212 | 2212 | //first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed. |
2213 | 2213 | $TXN = $REG->get_first_related('Transaction'); |
2214 | 2214 | $REGS = $TXN->get_many_related('Registration'); |
2215 | 2215 | |
2216 | 2216 | $all_trashed = TRUE; |
2217 | - foreach ( $REGS as $registration ) { |
|
2218 | - if ( ! $registration->get('REG_deleted') ) |
|
2217 | + foreach ($REGS as $registration) { |
|
2218 | + if ( ! $registration->get('REG_deleted')) |
|
2219 | 2219 | $all_trashed = FALSE; |
2220 | 2220 | } |
2221 | 2221 | |
2222 | - if ( ! $all_trashed ) { |
|
2223 | - EE_Error::add_error( __('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2222 | + if ( ! $all_trashed) { |
|
2223 | + EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well. These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2224 | 2224 | return false; |
2225 | 2225 | } |
2226 | 2226 | |
2227 | 2227 | //k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one). |
2228 | - foreach ( $REGS as $registration ) { |
|
2228 | + foreach ($REGS as $registration) { |
|
2229 | 2229 | |
2230 | 2230 | //delete related answers |
2231 | 2231 | $registration->delete_related_permanently('Answer'); |
2232 | 2232 | |
2233 | 2233 | //remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact) |
2234 | 2234 | $attendee = $registration->get_first_related('Attendee'); |
2235 | - if ( $attendee instanceof EE_Attendee ) { |
|
2235 | + if ($attendee instanceof EE_Attendee) { |
|
2236 | 2236 | $registration->_remove_relation_to($attendee, 'Attendee'); |
2237 | 2237 | } |
2238 | 2238 | |
@@ -2242,7 +2242,7 @@ discard block |
||
2242 | 2242 | //now delete permanently the checkins related to this registration. |
2243 | 2243 | $registration->delete_related_permanently('Checkin'); |
2244 | 2244 | |
2245 | - if ( $registration->ID() === $REG->ID() ) |
|
2245 | + if ($registration->ID() === $REG->ID()) |
|
2246 | 2246 | continue; //we don't want to delete permanently the existing registration just yet. |
2247 | 2247 | |
2248 | 2248 | //remove relation to transaction for these registrations if NOT the existing registrations |
@@ -2279,35 +2279,35 @@ discard block |
||
2279 | 2279 | * @return void |
2280 | 2280 | */ |
2281 | 2281 | public function new_registration() { |
2282 | - if ( ! $this->_set_reg_event() ) { |
|
2283 | - throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso') ); |
|
2282 | + if ( ! $this->_set_reg_event()) { |
|
2283 | + throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso')); |
|
2284 | 2284 | } |
2285 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
2285 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
2286 | 2286 | // gotta start with a clean slate if we're not coming here via ajax |
2287 | 2287 | if ( |
2288 | - ! defined('DOING_AJAX' ) |
|
2289 | - && ( ! isset( $this->_req_data['processing_registration'] ) || isset( $this->_req_data['step_error'] ) ) |
|
2288 | + ! defined('DOING_AJAX') |
|
2289 | + && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error'])) |
|
2290 | 2290 | ) { |
2291 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
2291 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2292 | 2292 | } |
2293 | 2293 | |
2294 | - $this->_template_args['event_name'] = '' ; |
|
2294 | + $this->_template_args['event_name'] = ''; |
|
2295 | 2295 | // event name |
2296 | - if ( $this->_reg_event ) { |
|
2296 | + if ($this->_reg_event) { |
|
2297 | 2297 | $this->_template_args['event_name'] = $this->_reg_event->name(); |
2298 | - $edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$this->_reg_event->ID() ), EVENTS_ADMIN_URL ); |
|
2299 | - $edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $this->_reg_event->name() . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>'; |
|
2300 | - $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ; |
|
2298 | + $edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$this->_reg_event->ID()), EVENTS_ADMIN_URL); |
|
2299 | + $edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$this->_reg_event->name().'">'.__('Edit Event', 'event_espresso').'</a>'; |
|
2300 | + $this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>'; |
|
2301 | 2301 | } |
2302 | 2302 | |
2303 | 2303 | $this->_template_args['step_content'] = $this->_get_registration_step_content(); |
2304 | 2304 | |
2305 | - if ( defined('DOING_AJAX' ) ) { |
|
2305 | + if (defined('DOING_AJAX')) { |
|
2306 | 2306 | $this->_return_json(); |
2307 | 2307 | } |
2308 | 2308 | // grab header |
2309 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php'; |
|
2310 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE ); |
|
2309 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php'; |
|
2310 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE); |
|
2311 | 2311 | |
2312 | 2312 | //$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE ); |
2313 | 2313 | // the details template wrapper |
@@ -2324,7 +2324,7 @@ discard block |
||
2324 | 2324 | * @return string html |
2325 | 2325 | */ |
2326 | 2326 | protected function _get_registration_step_content() { |
2327 | - if ( isset( $_COOKIE[ 'ee_registration_added' ] ) && $_COOKIE[ 'ee_registration_added' ] ) { |
|
2327 | + if (isset($_COOKIE['ee_registration_added']) && $_COOKIE['ee_registration_added']) { |
|
2328 | 2328 | $warning_msg = sprintf( |
2329 | 2329 | __( |
2330 | 2330 | '%2$sWARNING!!!%3$s%1$sPlease do not use the back button to return to this page for the purpose of adding another registration.%1$sThis can result in lost and/or corrupted data.%1$sIf you wish to add another registration, then please click the%1$s%7$s"Add Another New Registration to Event"%8$s button%1$son the Transaction details page, after you are redirected.%1$s%1$s%4$s redirecting in %5$s seconds %6$s', |
@@ -2340,7 +2340,7 @@ discard block |
||
2340 | 2340 | '</b>' |
2341 | 2341 | ); |
2342 | 2342 | return ' |
2343 | - <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg . '</p></div> |
|
2343 | + <div id="ee-add-reg-back-button-dv"><p>' . $warning_msg.'</p></div> |
|
2344 | 2344 | <script > |
2345 | 2345 | // WHOAH !!! it appears that someone is using the back button from the Transaction admin page |
2346 | 2346 | // after just adding a new registration... we gotta try to put a stop to that !!! |
@@ -2375,16 +2375,16 @@ discard block |
||
2375 | 2375 | $cart = EE_Registry::instance()->SSN->cart(); |
2376 | 2376 | $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
2377 | 2377 | |
2378 | - switch ( $step ) { |
|
2378 | + switch ($step) { |
|
2379 | 2379 | case 'ticket' : |
2380 | 2380 | $hidden_fields['processing_registration']['value'] = 1; |
2381 | 2381 | $template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso'); |
2382 | - $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector( $this->_reg_event ); |
|
2382 | + $template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event); |
|
2383 | 2383 | $template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', 'event_espresso'); |
2384 | 2384 | $template_args['show_notification_toggle'] = FALSE; |
2385 | 2385 | break; |
2386 | 2386 | case 'questions' : |
2387 | - $hidden_fields[ 'processing_registration' ][ 'value' ] = 2; |
|
2387 | + $hidden_fields['processing_registration']['value'] = 2; |
|
2388 | 2388 | $template_args['title'] = __('Step Two: Add Registrant Details for this Registration', 'event_espresso'); |
2389 | 2389 | //in theory we should be able to run EED_SPCO at this point because the cart should have been setup properly by the first process_reg_step run. |
2390 | 2390 | $template_args['content'] = EED_Single_Page_Checkout::registration_checkout_for_admin(); |
@@ -2393,10 +2393,10 @@ discard block |
||
2393 | 2393 | break; |
2394 | 2394 | } |
2395 | 2395 | |
2396 | - $this->_set_add_edit_form_tags( 'process_reg_step', $hidden_fields ); //we come back to the process_registration_step route. |
|
2396 | + $this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); //we come back to the process_registration_step route. |
|
2397 | 2397 | |
2398 | 2398 | return EEH_Template::display_template( |
2399 | - REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php', $template_args, TRUE |
|
2399 | + REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php', $template_args, TRUE |
|
2400 | 2400 | ); |
2401 | 2401 | } |
2402 | 2402 | |
@@ -2411,11 +2411,11 @@ discard block |
||
2411 | 2411 | * @return boolean |
2412 | 2412 | */ |
2413 | 2413 | private function _set_reg_event() { |
2414 | - if ( is_object( $this->_reg_event )) { |
|
2414 | + if (is_object($this->_reg_event)) { |
|
2415 | 2415 | return TRUE; |
2416 | 2416 | } |
2417 | - $EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE; |
|
2418 | - if ( ! $EVT_ID ) { |
|
2417 | + $EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : FALSE; |
|
2418 | + if ( ! $EVT_ID) { |
|
2419 | 2419 | return FALSE; |
2420 | 2420 | } |
2421 | 2421 | |
@@ -2436,80 +2436,80 @@ discard block |
||
2436 | 2436 | public function process_reg_step() { |
2437 | 2437 | EE_System::do_not_cache(); |
2438 | 2438 | $this->_set_reg_event(); |
2439 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
2439 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
2440 | 2440 | |
2441 | 2441 | //what step are we on? |
2442 | 2442 | $cart = EE_Registry::instance()->SSN->cart(); |
2443 | 2443 | $step = ! $cart instanceof EE_Cart ? 'ticket' : 'questions'; |
2444 | 2444 | |
2445 | 2445 | //if doing ajax then we need to verify the nonce |
2446 | - if ( defined( 'DOING_AJAX' ) ) { |
|
2447 | - $nonce = isset( $this->_req_data[$this->_req_nonce] ) ? sanitize_text_field( $this->_req_data[$this->_req_nonce] ) : ''; |
|
2448 | - $this->_verify_nonce( $nonce, $this->_req_nonce ); |
|
2446 | + if (defined('DOING_AJAX')) { |
|
2447 | + $nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : ''; |
|
2448 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
2449 | 2449 | } |
2450 | 2450 | |
2451 | - switch ( $step ) { |
|
2451 | + switch ($step) { |
|
2452 | 2452 | |
2453 | 2453 | case 'ticket' : |
2454 | 2454 | //process ticket selection |
2455 | 2455 | $success = EED_Ticket_Selector::instance()->process_ticket_selections(); |
2456 | - if ( $success ) { |
|
2457 | - EE_Error::add_success( esc_html__( 'Tickets Selected. Now complete the registration.', 'event_espresso' ) ); |
|
2456 | + if ($success) { |
|
2457 | + EE_Error::add_success(esc_html__('Tickets Selected. Now complete the registration.', 'event_espresso')); |
|
2458 | 2458 | } else { |
2459 | 2459 | $query_args['step_error'] = $this->_req_data['step_error'] = TRUE; |
2460 | 2460 | } |
2461 | - if ( defined('DOING_AJAX') ) { |
|
2461 | + if (defined('DOING_AJAX')) { |
|
2462 | 2462 | $this->new_registration(); //display next step |
2463 | 2463 | } else { |
2464 | 2464 | $query_args['action'] = 'new_registration'; |
2465 | 2465 | $query_args['processing_registration'] = 1; |
2466 | 2466 | $query_args['event_id'] = $this->_reg_event->ID(); |
2467 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
2467 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
2468 | 2468 | } |
2469 | 2469 | break; |
2470 | 2470 | |
2471 | 2471 | case 'questions' : |
2472 | - if( ! isset( $this->_req_data[ 'txn_reg_status_change' ], $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] ) ) { |
|
2473 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15 ); |
|
2472 | + if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) { |
|
2473 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15); |
|
2474 | 2474 | } |
2475 | 2475 | //process registration |
2476 | 2476 | $transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin(); |
2477 | - if ( $cart instanceof EE_Cart ) { |
|
2477 | + if ($cart instanceof EE_Cart) { |
|
2478 | 2478 | $grand_total = $cart->get_cart_grand_total(); |
2479 | - if ( $grand_total instanceof EE_Line_Item ) { |
|
2479 | + if ($grand_total instanceof EE_Line_Item) { |
|
2480 | 2480 | $grand_total->save_this_and_descendants_to_txn(); |
2481 | 2481 | } |
2482 | 2482 | } |
2483 | - if ( ! $transaction instanceof EE_Transaction ) { |
|
2483 | + if ( ! $transaction instanceof EE_Transaction) { |
|
2484 | 2484 | $query_args = array( |
2485 | 2485 | 'action' => 'new_registration', |
2486 | 2486 | 'processing_registration' => 2, |
2487 | 2487 | 'event_id' => $this->_reg_event->ID() |
2488 | 2488 | ); |
2489 | 2489 | |
2490 | - if ( defined('DOING_AJAX' )) { |
|
2490 | + if (defined('DOING_AJAX')) { |
|
2491 | 2491 | //display registration form again because there are errors (maybe validation?) |
2492 | 2492 | $this->new_registration(); |
2493 | 2493 | return; |
2494 | 2494 | } else { |
2495 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
2495 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
2496 | 2496 | return; |
2497 | 2497 | } |
2498 | 2498 | } |
2499 | 2499 | // maybe update status, and make sure to save transaction if not done already |
2500 | - if ( ! $transaction->update_status_based_on_total_paid() ) { |
|
2500 | + if ( ! $transaction->update_status_based_on_total_paid()) { |
|
2501 | 2501 | $transaction->save(); |
2502 | 2502 | } |
2503 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
2503 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2504 | 2504 | $this->_req_data = array(); |
2505 | 2505 | $query_args = array( |
2506 | 2506 | 'action' => 'redirect_to_txn', |
2507 | 2507 | 'TXN_ID' => $transaction->ID(), |
2508 | 2508 | 'EVT_ID' => $this->_reg_event->ID(), |
2509 | - 'event_name' => urlencode( $this->_reg_event->name() ), |
|
2509 | + 'event_name' => urlencode($this->_reg_event->name()), |
|
2510 | 2510 | 'redirect_from' => 'new_registration' |
2511 | 2511 | ); |
2512 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
2512 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2513 | 2513 | break; |
2514 | 2514 | } |
2515 | 2515 | |
@@ -2526,21 +2526,21 @@ discard block |
||
2526 | 2526 | */ |
2527 | 2527 | public function redirect_to_txn() { |
2528 | 2528 | EE_System::do_not_cache(); |
2529 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
2529 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
2530 | 2530 | $query_args = array( |
2531 | 2531 | 'action' => 'view_transaction', |
2532 | - 'TXN_ID' => isset( $this->_req_data['TXN_ID'] ) ? absint( $this->_req_data[ 'TXN_ID' ] ) : 0, |
|
2532 | + 'TXN_ID' => isset($this->_req_data['TXN_ID']) ? absint($this->_req_data['TXN_ID']) : 0, |
|
2533 | 2533 | 'page' => 'espresso_transactions' |
2534 | 2534 | ); |
2535 | - if ( isset( $this->_req_data[ 'EVT_ID' ], $this->_req_data[ 'redirect_from' ] ) ) { |
|
2536 | - $query_args['EVT_ID'] = $this->_req_data[ 'EVT_ID' ]; |
|
2537 | - $query_args['event_name'] = urlencode( $this->_req_data[ 'event_name' ] ); |
|
2538 | - $query_args['redirect_from'] = $this->_req_data[ 'redirect_from' ]; |
|
2535 | + if (isset($this->_req_data['EVT_ID'], $this->_req_data['redirect_from'])) { |
|
2536 | + $query_args['EVT_ID'] = $this->_req_data['EVT_ID']; |
|
2537 | + $query_args['event_name'] = urlencode($this->_req_data['event_name']); |
|
2538 | + $query_args['redirect_from'] = $this->_req_data['redirect_from']; |
|
2539 | 2539 | } |
2540 | 2540 | EE_Error::add_success( |
2541 | - __( 'Registration Created. Please review the transaction and add any payments as necessary', 'event_espresso' ) |
|
2541 | + __('Registration Created. Please review the transaction and add any payments as necessary', 'event_espresso') |
|
2542 | 2542 | ); |
2543 | - $this->_redirect_after_action( false, '', '', $query_args, true ); |
|
2543 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
2544 | 2544 | } |
2545 | 2545 | |
2546 | 2546 | |
@@ -2551,7 +2551,7 @@ discard block |
||
2551 | 2551 | * @return void |
2552 | 2552 | */ |
2553 | 2553 | protected function _attendee_contact_list_table() { |
2554 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2554 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2555 | 2555 | $this->_search_btn_label = __('Contacts', 'event_espresso'); |
2556 | 2556 | $this->display_admin_list_table_page_with_no_sidebar(); |
2557 | 2557 | } |
@@ -2566,10 +2566,10 @@ discard block |
||
2566 | 2566 | * @access public |
2567 | 2567 | * @return array |
2568 | 2568 | */ |
2569 | - public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) { |
|
2569 | + public function get_attendees($per_page, $count = FALSE, $trash = FALSE) { |
|
2570 | 2570 | |
2571 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2572 | - require_once( REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php' ); |
|
2571 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2572 | + require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php'); |
|
2573 | 2573 | $ATT_MDL = EEM_Attendee::instance(); |
2574 | 2574 | |
2575 | 2575 | $this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : ''; |
@@ -2597,47 +2597,47 @@ discard block |
||
2597 | 2597 | $orderby = 'ATT_lname'; |
2598 | 2598 | } |
2599 | 2599 | |
2600 | - $sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
2600 | + $sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
2601 | 2601 | |
2602 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
2603 | - $per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10; |
|
2604 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
2602 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
2603 | + $per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10; |
|
2604 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
2605 | 2605 | |
2606 | 2606 | $_where = array(); |
2607 | 2607 | |
2608 | - if ( ! empty( $this->_req_data['s'] ) ) { |
|
2609 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2608 | + if ( ! empty($this->_req_data['s'])) { |
|
2609 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2610 | 2610 | $_where['OR'] = array( |
2611 | - 'Registration.Event.EVT_name' => array( 'LIKE', $sstr), |
|
2612 | - 'Registration.Event.EVT_desc' => array( 'LIKE', $sstr ), |
|
2613 | - 'Registration.Event.EVT_short_desc' => array( 'LIKE' , $sstr ), |
|
2614 | - 'ATT_fname' => array( 'LIKE', $sstr ), |
|
2615 | - 'ATT_lname' => array( 'LIKE', $sstr ), |
|
2616 | - 'ATT_short_bio' => array( 'LIKE', $sstr ), |
|
2617 | - 'ATT_email' => array('LIKE', $sstr ), |
|
2618 | - 'ATT_address' => array( 'LIKE', $sstr ), |
|
2619 | - 'ATT_address2' => array( 'LIKE', $sstr ), |
|
2620 | - 'ATT_city' => array( 'LIKE', $sstr ), |
|
2621 | - 'Country.CNT_name' => array( 'LIKE', $sstr ), |
|
2622 | - 'State.STA_name' => array('LIKE', $sstr ), |
|
2623 | - 'ATT_phone' => array( 'LIKE', $sstr ), |
|
2624 | - 'Registration.REG_final_price' => array( 'LIKE', $sstr ), |
|
2625 | - 'Registration.REG_code' => array( 'LIKE', $sstr ), |
|
2626 | - 'Registration.REG_count' => array( 'LIKE' , $sstr ), |
|
2627 | - 'Registration.REG_group_size' => array( 'LIKE' , $sstr ) |
|
2611 | + 'Registration.Event.EVT_name' => array('LIKE', $sstr), |
|
2612 | + 'Registration.Event.EVT_desc' => array('LIKE', $sstr), |
|
2613 | + 'Registration.Event.EVT_short_desc' => array('LIKE', $sstr), |
|
2614 | + 'ATT_fname' => array('LIKE', $sstr), |
|
2615 | + 'ATT_lname' => array('LIKE', $sstr), |
|
2616 | + 'ATT_short_bio' => array('LIKE', $sstr), |
|
2617 | + 'ATT_email' => array('LIKE', $sstr), |
|
2618 | + 'ATT_address' => array('LIKE', $sstr), |
|
2619 | + 'ATT_address2' => array('LIKE', $sstr), |
|
2620 | + 'ATT_city' => array('LIKE', $sstr), |
|
2621 | + 'Country.CNT_name' => array('LIKE', $sstr), |
|
2622 | + 'State.STA_name' => array('LIKE', $sstr), |
|
2623 | + 'ATT_phone' => array('LIKE', $sstr), |
|
2624 | + 'Registration.REG_final_price' => array('LIKE', $sstr), |
|
2625 | + 'Registration.REG_code' => array('LIKE', $sstr), |
|
2626 | + 'Registration.REG_count' => array('LIKE', $sstr), |
|
2627 | + 'Registration.REG_group_size' => array('LIKE', $sstr) |
|
2628 | 2628 | ); |
2629 | 2629 | } |
2630 | 2630 | |
2631 | 2631 | |
2632 | - $offset = ($current_page-1)*$per_page; |
|
2633 | - $limit = $count ? NULL : array( $offset, $per_page ); |
|
2632 | + $offset = ($current_page - 1) * $per_page; |
|
2633 | + $limit = $count ? NULL : array($offset, $per_page); |
|
2634 | 2634 | |
2635 | - if ( $trash ) { |
|
2636 | - $_where['status'] = array( '!=', 'publish' ); |
|
2637 | - $all_attendees = $count ? $ATT_MDL->count( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true ): $ATT_MDL->get_all( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
2635 | + if ($trash) { |
|
2636 | + $_where['status'] = array('!=', 'publish'); |
|
2637 | + $all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
2638 | 2638 | } else { |
2639 | - $_where['status'] = array( 'IN', array( 'publish' ) ); |
|
2640 | - $all_attendees = $count ? $ATT_MDL->count( array($_where, 'order_by'=>array($orderby=>$sort),'limit'=>$limit ), 'ATT_ID' , true ) : $ATT_MDL->get_all( array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit) ); |
|
2639 | + $_where['status'] = array('IN', array('publish')); |
|
2640 | + $all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit), 'ATT_ID', true) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)); |
|
2641 | 2641 | } |
2642 | 2642 | |
2643 | 2643 | return $all_attendees; |
@@ -2654,10 +2654,10 @@ discard block |
||
2654 | 2654 | */ |
2655 | 2655 | protected function _resend_registration() { |
2656 | 2656 | $this->_process_resend_registration(); |
2657 | - $query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'] ) : array( |
|
2657 | + $query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) : array( |
|
2658 | 2658 | 'action' => 'default' |
2659 | 2659 | ); |
2660 | - $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE ); |
|
2660 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
2661 | 2661 | } |
2662 | 2662 | |
2663 | 2663 | |
@@ -2665,26 +2665,26 @@ discard block |
||
2665 | 2665 | |
2666 | 2666 | |
2667 | 2667 | |
2668 | - public function _registrations_report(){ |
|
2669 | - if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
|
2670 | - wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
|
2668 | + public function _registrations_report() { |
|
2669 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
2670 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
2671 | 2671 | array( |
2672 | 2672 | 'page' => 'espresso_batch', |
2673 | 2673 | 'batch' => 'file', |
2674 | - 'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
|
2675 | - 'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' ), |
|
2676 | - 'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
|
2677 | - )) ); |
|
2674 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL, |
|
2675 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'), |
|
2676 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
2677 | + ))); |
|
2678 | 2678 | } else { |
2679 | 2679 | $new_request_args = array( |
2680 | 2680 | 'export' => 'report', |
2681 | 2681 | 'action' => 'registrations_report_for_event', |
2682 | - 'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL, |
|
2682 | + 'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL, |
|
2683 | 2683 | ); |
2684 | 2684 | $this->_req_data = array_merge($this->_req_data, $new_request_args); |
2685 | 2685 | |
2686 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2687 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2686 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2687 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2688 | 2688 | $EE_Export = EE_Export::instance($this->_req_data); |
2689 | 2689 | $EE_Export->export(); |
2690 | 2690 | } |
@@ -2693,26 +2693,26 @@ discard block |
||
2693 | 2693 | |
2694 | 2694 | |
2695 | 2695 | |
2696 | - public function _contact_list_export(){ |
|
2697 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2698 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2696 | + public function _contact_list_export() { |
|
2697 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2698 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2699 | 2699 | $EE_Export = EE_Export::instance($this->_req_data); |
2700 | 2700 | $EE_Export->export_attendees(); |
2701 | 2701 | } |
2702 | 2702 | } |
2703 | 2703 | |
2704 | - public function _contact_list_report(){ |
|
2705 | - if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) { |
|
2706 | - wp_redirect( EE_Admin_Page::add_query_args_and_nonce( |
|
2704 | + public function _contact_list_report() { |
|
2705 | + if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) { |
|
2706 | + wp_redirect(EE_Admin_Page::add_query_args_and_nonce( |
|
2707 | 2707 | array( |
2708 | 2708 | 'page' => 'espresso_batch', |
2709 | 2709 | 'batch' => 'file', |
2710 | - 'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\AttendeesReport' ), |
|
2711 | - 'return_url' => urlencode( $this->_req_data[ 'return_url' ] ), |
|
2712 | - )) ); |
|
2710 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'), |
|
2711 | + 'return_url' => urlencode($this->_req_data['return_url']), |
|
2712 | + ))); |
|
2713 | 2713 | } else { |
2714 | - if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
2715 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
2714 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
2715 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
2716 | 2716 | $EE_Export = EE_Export::instance($this->_req_data); |
2717 | 2717 | $EE_Export->report_attendees(); |
2718 | 2718 | } |
@@ -2731,73 +2731,73 @@ discard block |
||
2731 | 2731 | * @return void |
2732 | 2732 | */ |
2733 | 2733 | protected function _duplicate_attendee() { |
2734 | - $action = !empty( $this->_req_data['return'] ) ? $this->_req_data['return'] : 'default'; |
|
2734 | + $action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default'; |
|
2735 | 2735 | //verify we have necessary info |
2736 | - if ( empty($this->_req_data['_REG_ID'] ) ) { |
|
2737 | - EE_Error::add_error( __('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__ ); |
|
2738 | - $query_args = array( 'action' => $action ); |
|
2736 | + if (empty($this->_req_data['_REG_ID'])) { |
|
2737 | + EE_Error::add_error(__('Unable to create the contact for the registration because the required parameters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__); |
|
2738 | + $query_args = array('action' => $action); |
|
2739 | 2739 | $this->_redirect_after_action('', '', '', $query_args, TRUE); |
2740 | 2740 | } |
2741 | 2741 | |
2742 | 2742 | //okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration. |
2743 | - $registration = EEM_Registration::instance()->get_one_by_ID( $this->_req_data['_REG_ID'] ); |
|
2743 | + $registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']); |
|
2744 | 2744 | $attendee = $registration->attendee(); |
2745 | 2745 | |
2746 | 2746 | //remove relation of existing attendee on registration |
2747 | - $registration->_remove_relation_to($attendee, 'Attendee' ); |
|
2747 | + $registration->_remove_relation_to($attendee, 'Attendee'); |
|
2748 | 2748 | //new attendee |
2749 | 2749 | $new_attendee = clone $attendee; |
2750 | - $new_attendee->set( 'ATT_ID', 0 ); |
|
2750 | + $new_attendee->set('ATT_ID', 0); |
|
2751 | 2751 | $new_attendee->save(); |
2752 | 2752 | |
2753 | 2753 | //add new attendee to reg |
2754 | - $registration->_add_relation_to( $new_attendee, 'Attendee'); |
|
2754 | + $registration->_add_relation_to($new_attendee, 'Attendee'); |
|
2755 | 2755 | |
2756 | - EE_Error::add_success( __('New Contact record created. Now make any edits you wish to make for this contact.', 'event_espresso') ); |
|
2756 | + EE_Error::add_success(__('New Contact record created. Now make any edits you wish to make for this contact.', 'event_espresso')); |
|
2757 | 2757 | |
2758 | 2758 | //redirect to edit page for attendee |
2759 | - $query_args = array( 'post' => $new_attendee->ID(), 'action' => 'edit_attendee' ); |
|
2759 | + $query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee'); |
|
2760 | 2760 | |
2761 | - $this->_redirect_after_action( '', '', '', $query_args, TRUE ); |
|
2761 | + $this->_redirect_after_action('', '', '', $query_args, TRUE); |
|
2762 | 2762 | } |
2763 | 2763 | |
2764 | 2764 | |
2765 | 2765 | //related to cpt routes |
2766 | 2766 | protected function _insert_update_cpt_item($post_id, $post) { |
2767 | 2767 | $success = true; |
2768 | - $attendee = EEM_Attendee::instance()->get_one_by_ID( $post_id ); |
|
2768 | + $attendee = EEM_Attendee::instance()->get_one_by_ID($post_id); |
|
2769 | 2769 | //for attendee updates |
2770 | - if ( $post->post_type = 'espresso_attendees' && !empty( $attendee ) ) { |
|
2770 | + if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) { |
|
2771 | 2771 | //note we should only be UPDATING attendees at this point. |
2772 | 2772 | $updated_fields = array( |
2773 | 2773 | 'ATT_fname' => $this->_req_data['ATT_fname'], |
2774 | 2774 | 'ATT_lname' => $this->_req_data['ATT_lname'], |
2775 | - 'ATT_full_name'=> $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'], |
|
2775 | + 'ATT_full_name'=> $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'], |
|
2776 | 2776 | 'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '', |
2777 | 2777 | 'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '', |
2778 | - 'ATT_city' => isset( $this->_req_data['ATT_city'] ) ? $this->_req_data['ATT_city'] : '', |
|
2779 | - 'STA_ID' => isset( $this->_req_data['STA_ID'] ) ? $this->_req_data['STA_ID'] : '', |
|
2780 | - 'CNT_ISO' => isset( $this->_req_data['CNT_ISO'] ) ? $this->_req_data['CNT_ISO'] : '', |
|
2781 | - 'ATT_zip' => isset( $this->_req_data['ATT_zip'] ) ? $this->_req_data['ATT_zip'] : '', |
|
2782 | - 'ATT_email' => isset( $this->_req_data['ATT_email'] ) ? $this->_req_data['ATT_email'] : '', |
|
2783 | - 'ATT_phone' => isset( $this->_req_data['ATT_phone'] ) ? $this->_req_data['ATT_phone'] : '' |
|
2778 | + 'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '', |
|
2779 | + 'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '', |
|
2780 | + 'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '', |
|
2781 | + 'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '', |
|
2782 | + 'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '', |
|
2783 | + 'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : '' |
|
2784 | 2784 | ); |
2785 | - foreach ( $updated_fields as $field => $value ) { |
|
2785 | + foreach ($updated_fields as $field => $value) { |
|
2786 | 2786 | $attendee->set($field, $value); |
2787 | 2787 | } |
2788 | 2788 | |
2789 | 2789 | $success = $attendee->save(); |
2790 | 2790 | |
2791 | - $attendee_update_callbacks = apply_filters( 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array() ); |
|
2792 | - foreach ( $attendee_update_callbacks as $a_callback ) { |
|
2793 | - if ( FALSE === call_user_func_array( $a_callback, array($attendee, $this->_req_data ) ) ) { |
|
2794 | - throw new EE_Error( sprintf( __('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', 'event_espresso'), $a_callback ) ); |
|
2791 | + $attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array()); |
|
2792 | + foreach ($attendee_update_callbacks as $a_callback) { |
|
2793 | + if (FALSE === call_user_func_array($a_callback, array($attendee, $this->_req_data))) { |
|
2794 | + throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback. Please check the spelling.', 'event_espresso'), $a_callback)); |
|
2795 | 2795 | } |
2796 | 2796 | } |
2797 | 2797 | } |
2798 | 2798 | |
2799 | - if ( $success === FALSE ) |
|
2800 | - EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
2799 | + if ($success === FALSE) |
|
2800 | + EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
2801 | 2801 | |
2802 | 2802 | } |
2803 | 2803 | |
@@ -2817,17 +2817,17 @@ discard block |
||
2817 | 2817 | remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2818 | 2818 | remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2819 | 2819 | |
2820 | - if ( post_type_supports( 'espresso_attendees', 'excerpt') ) { |
|
2821 | - add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal' ); |
|
2820 | + if (post_type_supports('espresso_attendees', 'excerpt')) { |
|
2821 | + add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal'); |
|
2822 | 2822 | } |
2823 | 2823 | |
2824 | - if ( post_type_supports( 'espresso_attendees', 'comments') ) { |
|
2824 | + if (post_type_supports('espresso_attendees', 'comments')) { |
|
2825 | 2825 | add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
2826 | 2826 | } |
2827 | 2827 | |
2828 | - add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array( $this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core' ); |
|
2829 | - add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core' ); |
|
2830 | - add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array( $this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
2828 | + add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core'); |
|
2829 | + add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core'); |
|
2830 | + add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high'); |
|
2831 | 2831 | } |
2832 | 2832 | |
2833 | 2833 | |
@@ -2836,10 +2836,10 @@ discard block |
||
2836 | 2836 | * @param WP_Post $post wp post object |
2837 | 2837 | * @return string attendee contact info ( and form ) |
2838 | 2838 | */ |
2839 | - public function attendee_contact_info( $post ) { |
|
2839 | + public function attendee_contact_info($post) { |
|
2840 | 2840 | //get attendee object ( should already have it ) |
2841 | 2841 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
2842 | - $template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php'; |
|
2842 | + $template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php'; |
|
2843 | 2843 | EEH_Template::display_template($template, $this->_template_args); |
2844 | 2844 | } |
2845 | 2845 | |
@@ -2855,12 +2855,12 @@ discard block |
||
2855 | 2855 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
2856 | 2856 | $this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input( |
2857 | 2857 | new EE_Question_Form_Input( |
2858 | - EE_Question::new_instance( array( |
|
2858 | + EE_Question::new_instance(array( |
|
2859 | 2859 | 'QST_ID' => 0, |
2860 | 2860 | 'QST_display_text' => __('State/Province', 'event_espresso'), |
2861 | 2861 | 'QST_system' => 'admin-state' |
2862 | 2862 | )), |
2863 | - EE_Answer::new_instance( array( |
|
2863 | + EE_Answer::new_instance(array( |
|
2864 | 2864 | 'ANS_ID' => 0, |
2865 | 2865 | 'ANS_value' => $this->_cpt_model_obj->state_ID() |
2866 | 2866 | )), |
@@ -2873,12 +2873,12 @@ discard block |
||
2873 | 2873 | )); |
2874 | 2874 | $this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input( |
2875 | 2875 | new EE_Question_Form_Input( |
2876 | - EE_Question::new_instance( array( |
|
2876 | + EE_Question::new_instance(array( |
|
2877 | 2877 | 'QST_ID' => 0, |
2878 | 2878 | 'QST_display_text' => __('Country', 'event_espresso'), |
2879 | 2879 | 'QST_system' => 'admin-country' |
2880 | 2880 | )), |
2881 | - EE_Answer::new_instance( array( |
|
2881 | + EE_Answer::new_instance(array( |
|
2882 | 2882 | 'ANS_ID' => 0, |
2883 | 2883 | 'ANS_value' => $this->_cpt_model_obj->country_ID() |
2884 | 2884 | )), |
@@ -2889,8 +2889,8 @@ discard block |
||
2889 | 2889 | 'append_qstn_id' => FALSE |
2890 | 2890 | ) |
2891 | 2891 | )); |
2892 | - $template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php'; |
|
2893 | - EEH_Template::display_template($template, $this->_template_args ); |
|
2892 | + $template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php'; |
|
2893 | + EEH_Template::display_template($template, $this->_template_args); |
|
2894 | 2894 | |
2895 | 2895 | } |
2896 | 2896 | |
@@ -2900,11 +2900,11 @@ discard block |
||
2900 | 2900 | * @access protected |
2901 | 2901 | * @return void |
2902 | 2902 | */ |
2903 | - public function attendee_registrations_meta_box( $post ) { |
|
2903 | + public function attendee_registrations_meta_box($post) { |
|
2904 | 2904 | |
2905 | 2905 | $this->_template_args['attendee'] = $this->_cpt_model_obj; |
2906 | 2906 | $this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration'); |
2907 | - $template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php'; |
|
2907 | + $template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php'; |
|
2908 | 2908 | EEH_Template::display_template($template, $this->_template_args); |
2909 | 2909 | |
2910 | 2910 | } |
@@ -2918,8 +2918,8 @@ discard block |
||
2918 | 2918 | * @return string html for new form. |
2919 | 2919 | */ |
2920 | 2920 | public function after_title_form_fields($post) { |
2921 | - if ( $post->post_type == 'espresso_attendees' ) { |
|
2922 | - $template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php'; |
|
2921 | + if ($post->post_type == 'espresso_attendees') { |
|
2922 | + $template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php'; |
|
2923 | 2923 | $template_args['attendee'] = $this->_cpt_model_obj; |
2924 | 2924 | EEH_Template::display_template($template, $template_args); |
2925 | 2925 | } |
@@ -2936,21 +2936,21 @@ discard block |
||
2936 | 2936 | * @access protected |
2937 | 2937 | * @return void |
2938 | 2938 | */ |
2939 | - protected function _trash_or_restore_attendees( $trash = TRUE ) { |
|
2939 | + protected function _trash_or_restore_attendees($trash = TRUE) { |
|
2940 | 2940 | |
2941 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2941 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2942 | 2942 | |
2943 | 2943 | $ATT_MDL = EEM_Attendee::instance(); |
2944 | 2944 | |
2945 | 2945 | $success = 1; |
2946 | 2946 | //Checkboxes |
2947 | - if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2947 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
2948 | 2948 | // if array has more than one element than success message should be plural |
2949 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
2949 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
2950 | 2950 | // cycle thru checkboxes |
2951 | - while (list( $ATT_ID, $value ) = each($this->_req_data['checkbox'])) { |
|
2952 | - $updated = $trash ? $ATT_MDL->update_by_ID(array( 'status' => 'trash' ), $ATT_ID) : $ATT_MDL->update_by_ID( array('status' => 'publish' ), $ATT_ID); |
|
2953 | - if ( !$updated ) { |
|
2951 | + while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
2952 | + $updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID); |
|
2953 | + if ( ! $updated) { |
|
2954 | 2954 | $success = 0; |
2955 | 2955 | } |
2956 | 2956 | } |
@@ -2959,18 +2959,18 @@ discard block |
||
2959 | 2959 | // grab single id and delete |
2960 | 2960 | $ATT_ID = absint($this->_req_data['ATT_ID']); |
2961 | 2961 | //get attendee |
2962 | - $att = $ATT_MDL->get_one_by_ID( $ATT_ID ); |
|
2962 | + $att = $ATT_MDL->get_one_by_ID($ATT_ID); |
|
2963 | 2963 | $updated = $trash ? $att->set_status('trash') : $att->set_status('publish'); |
2964 | 2964 | $updated = $att->save(); |
2965 | - if ( ! $updated ) { |
|
2965 | + if ( ! $updated) { |
|
2966 | 2966 | $success = 0; |
2967 | 2967 | } |
2968 | 2968 | |
2969 | 2969 | } |
2970 | 2970 | |
2971 | - $what = $success > 1 ? __( 'Contacts', 'event_espresso' ) : __( 'Contact', 'event_espresso' ); |
|
2972 | - $action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' ); |
|
2973 | - $this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'contact_list' ) ); |
|
2971 | + $what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso'); |
|
2972 | + $action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso'); |
|
2973 | + $this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list')); |
|
2974 | 2974 | |
2975 | 2975 | } |
2976 | 2976 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * to indicate it successfully migrate some data, and has nothing left to do; or EE_Data_Migration_Manager::status_fatal_error to indicate |
25 | 25 | * an error occurred which means the ajax script should probably stop executing. |
26 | 26 | */ |
27 | -class EE_Data_Migration_Manager{ |
|
27 | +class EE_Data_Migration_Manager { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * of this EE installation. Keys should be the name of the version the script upgraded to |
82 | 82 | * @var EE_Data_Migration_Script_Base[] |
83 | 83 | */ |
84 | - private $_data_migrations_ran =null; |
|
84 | + private $_data_migrations_ran = null; |
|
85 | 85 | /** |
86 | 86 | * The last ran script. It's nice to store this somewhere accessible, as its easiest |
87 | 87 | * to know which was the last run by which is the newest wp option; but in most of the code |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public static function instance() { |
143 | 143 | // check if class object is instantiated |
144 | - if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) { |
|
144 | + if ( ! self::$_instance instanceof EE_Data_Migration_Manager) { |
|
145 | 145 | self::$_instance = new self(); |
146 | 146 | } |
147 | 147 | return self::$_instance; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * all new usages of the singleton should be made with Classname::instance()) and returns it |
152 | 152 | * @return EE_Data_Migration_Manager |
153 | 153 | */ |
154 | - public static function reset(){ |
|
154 | + public static function reset() { |
|
155 | 155 | self::$_instance = NULL; |
156 | 156 | return self::instance(); |
157 | 157 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | /** |
162 | 162 | * constructor |
163 | 163 | */ |
164 | - private function __construct(){ |
|
164 | + private function __construct() { |
|
165 | 165 | $this->stati_that_indicate_to_continue_migrations = array( |
166 | 166 | self::status_continue, |
167 | 167 | self::status_completed |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | ); |
181 | 181 | //make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class |
182 | 182 | //to be defined, because right now it doesn't get autoloaded on its own |
183 | - EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), TRUE ); |
|
184 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array(), TRUE ); |
|
185 | - EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), TRUE ); |
|
186 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), TRUE ); |
|
187 | - EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), TRUE ); |
|
188 | - $this->_table_manager = EE_Registry::instance()->create( 'TableManager', array(), true ); |
|
189 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
183 | + EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), TRUE); |
|
184 | + EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), TRUE); |
|
185 | + EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), TRUE); |
|
186 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), TRUE); |
|
187 | + EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), TRUE); |
|
188 | + $this->_table_manager = EE_Registry::instance()->create('TableManager', array(), true); |
|
189 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | |
@@ -199,21 +199,21 @@ discard block |
||
199 | 199 | * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set) |
200 | 200 | * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of that plugin (eg '4.1.0') |
201 | 201 | */ |
202 | - private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){ |
|
202 | + private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) { |
|
203 | 203 | $plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_name); |
204 | 204 | //check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style) |
205 | - $parts = explode(".",$plugin_slug_and_version_string); |
|
205 | + $parts = explode(".", $plugin_slug_and_version_string); |
|
206 | 206 | |
207 | - if(count($parts) == 4){ |
|
207 | + if (count($parts) == 4) { |
|
208 | 208 | //it's 4.2-style.eg Core.4.1.0 |
209 | - $plugin_slug = $parts[0];//eg Core |
|
209 | + $plugin_slug = $parts[0]; //eg Core |
|
210 | 210 | $version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0 |
211 | - }else{ |
|
211 | + } else { |
|
212 | 212 | //it's 4.1-style: eg 4.1.0 |
213 | 213 | $plugin_slug = 'Core'; |
214 | - $version_string = $plugin_slug_and_version_string;//eg 4.1.0 |
|
214 | + $version_string = $plugin_slug_and_version_string; //eg 4.1.0 |
|
215 | 215 | } |
216 | - return array($plugin_slug,$version_string); |
|
216 | + return array($plugin_slug, $version_string); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -224,21 +224,21 @@ discard block |
||
224 | 224 | * @return EE_Data_Migration_Script_Base |
225 | 225 | * @throws EE_Error |
226 | 226 | */ |
227 | - private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){ |
|
227 | + private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) { |
|
228 | 228 | $data_migration_data = maybe_unserialize($dms_option_value); |
229 | - if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){ |
|
229 | + if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) { |
|
230 | 230 | $class = new $data_migration_data['class']; |
231 | - if($class instanceof EE_Data_Migration_Script_Base){ |
|
231 | + if ($class instanceof EE_Data_Migration_Script_Base) { |
|
232 | 232 | $class->instantiate_from_array_of_properties($data_migration_data); |
233 | 233 | return $class; |
234 | - }else{ |
|
234 | + } else { |
|
235 | 235 | //huh, so its an object but not a data migration script?? that shouldn't happen |
236 | 236 | //just leave it as an array (which will probably just get ignored) |
237 | - throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class'])); |
|
237 | + throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'), $data_migration_data['class'])); |
|
238 | 238 | } |
239 | - }else{ |
|
239 | + } else { |
|
240 | 240 | //so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists |
241 | - throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name)); |
|
241 | + throw new EE_Error(sprintf(__("The wp option with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name)); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | /** |
@@ -246,34 +246,34 @@ discard block |
||
246 | 246 | * the last ran which hasn't finished yet |
247 | 247 | * @return array where each element should be an array of EE_Data_Migration_Script_Base (but also has a few legacy arrays in there - which should probably be ignored) |
248 | 248 | */ |
249 | - public function get_data_migrations_ran(){ |
|
250 | - if( ! $this->_data_migrations_ran ){ |
|
249 | + public function get_data_migrations_ran() { |
|
250 | + if ( ! $this->_data_migrations_ran) { |
|
251 | 251 | //setup autoloaders for each of the scripts in there |
252 | 252 | $this->get_all_data_migration_scripts_available(); |
253 | - $data_migrations_options = $this->get_all_migration_script_options();//get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array())); |
|
253 | + $data_migrations_options = $this->get_all_migration_script_options(); //get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array())); |
|
254 | 254 | |
255 | 255 | $data_migrations_ran = array(); |
256 | 256 | //convert into data migration script classes where possible |
257 | - foreach($data_migrations_options as $data_migration_option){ |
|
258 | - list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
257 | + foreach ($data_migrations_options as $data_migration_option) { |
|
258 | + list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']); |
|
259 | 259 | |
260 | - try{ |
|
261 | - $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']); |
|
260 | + try { |
|
261 | + $class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']); |
|
262 | 262 | $data_migrations_ran[$plugin_slug][$version_string] = $class; |
263 | 263 | //ok so far THIS is the 'last-ran-script'... unless we find another on next iteration |
264 | 264 | $this->_last_ran_script = $class; |
265 | - if( ! $class->is_completed()){ |
|
265 | + if ( ! $class->is_completed()) { |
|
266 | 266 | //sometimes we also like to know which was the last incomplete script (or if there are any at all) |
267 | 267 | $this->_last_ran_incomplete_script = $class; |
268 | 268 | } |
269 | - }catch(EE_Error $e){ |
|
269 | + } catch (EE_Error $e) { |
|
270 | 270 | //ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs |
271 | 271 | $data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']); |
272 | 272 | } |
273 | 273 | } |
274 | 274 | //so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays |
275 | 275 | $this->_data_migrations_ran = $data_migrations_ran; |
276 | - if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){ |
|
276 | + if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) { |
|
277 | 277 | $this->_data_migrations_ran = array(); |
278 | 278 | } |
279 | 279 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @param $new_table |
291 | 291 | * @return mixed string or int |
292 | 292 | */ |
293 | - public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){ |
|
293 | + public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) { |
|
294 | 294 | $script = EE_Registry::instance()->load_dms($script_name); |
295 | 295 | $mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table); |
296 | 296 | return $mapping; |
@@ -301,9 +301,9 @@ discard block |
||
301 | 301 | * option returned in this array is the most-recently ran DMS option |
302 | 302 | * @return array |
303 | 303 | */ |
304 | - public function get_all_migration_script_options(){ |
|
304 | + public function get_all_migration_script_options() { |
|
305 | 305 | global $wpdb; |
306 | - return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",ARRAY_A); |
|
306 | + return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC", ARRAY_A); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the |
312 | 312 | * folder name. |
313 | 313 | */ |
314 | - public function get_data_migration_script_folders(){ |
|
315 | - return apply_filters( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',array(EE_CORE.'data_migration_scripts') ); |
|
314 | + public function get_data_migration_script_folders() { |
|
315 | + return apply_filters('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array(EE_CORE.'data_migration_scripts')); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | * } |
325 | 325 | * @throws EE_Error |
326 | 326 | */ |
327 | - public function script_migrates_to_version($migration_script_name){ |
|
327 | + public function script_migrates_to_version($migration_script_name) { |
|
328 | 328 | $dms_info = $this->parse_dms_classname($migration_script_name); |
329 | 329 | return array( |
330 | - 'slug'=> $dms_info[ 'slug' ], |
|
331 | - 'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ] ); |
|
330 | + 'slug'=> $dms_info['slug'], |
|
331 | + 'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version'] ); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -337,13 +337,13 @@ discard block |
||
337 | 337 | * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints) |
338 | 338 | * @throws EE_Error |
339 | 339 | */ |
340 | - public function parse_dms_classname($classname){ |
|
340 | + public function parse_dms_classname($classname) { |
|
341 | 341 | $matches = array(); |
342 | - preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~',$classname,$matches); |
|
343 | - if( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))){ |
|
344 | - throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"),$classname)); |
|
342 | + preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches); |
|
343 | + if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) { |
|
344 | + throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"), $classname)); |
|
345 | 345 | } |
346 | - return array('slug'=>$matches[1],'major_version'=>intval($matches[2]),'minor_version'=>intval($matches[3]),'micro_version'=>intval($matches[4])); |
|
346 | + return array('slug'=>$matches[1], 'major_version'=>intval($matches[2]), 'minor_version'=>intval($matches[3]), 'micro_version'=>intval($matches[4])); |
|
347 | 347 | } |
348 | 348 | /** |
349 | 349 | * Ensures that the option indicating the current DB version is set. This should only be |
@@ -352,33 +352,33 @@ discard block |
||
352 | 352 | * to 4.1.x. |
353 | 353 | * @return string of current db state |
354 | 354 | */ |
355 | - public function ensure_current_database_state_is_set(){ |
|
356 | - $espresso_db_core_updates = get_option( 'espresso_db_update', array() ); |
|
355 | + public function ensure_current_database_state_is_set() { |
|
356 | + $espresso_db_core_updates = get_option('espresso_db_update', array()); |
|
357 | 357 | $db_state = get_option(EE_Data_Migration_Manager::current_database_state); |
358 | - if( ! $db_state ){ |
|
358 | + if ( ! $db_state) { |
|
359 | 359 | //mark the DB as being in the state as the last version in there. |
360 | 360 | //this is done to trigger maintenance mode and do data migration scripts |
361 | 361 | //if the admin installed this version of EE over 3.1.x or 4.0.x |
362 | 362 | //otherwise, the normal maintenance mode code is fine |
363 | 363 | $previous_versions_installed = array_keys($espresso_db_core_updates); |
364 | 364 | $previous_version_installed = end($previous_versions_installed); |
365 | - if(version_compare('4.1.0', $previous_version_installed)){ |
|
365 | + if (version_compare('4.1.0', $previous_version_installed)) { |
|
366 | 366 | //last installed version was less than 4.1 |
367 | 367 | //so we want the data migrations to happen. SO, we're going to say the DB is at that state |
368 | 368 | // echo "4.1.0 is greater than $previous_version_installed! update the option"; |
369 | 369 | $db_state = array('Core'=>$previous_version_installed); |
370 | - }else{ |
|
370 | + } else { |
|
371 | 371 | // echo "4.1.0 is SMALLER than $previous_version_installed"; |
372 | 372 | $db_state = array('Core'=>EVENT_ESPRESSO_VERSION); |
373 | 373 | } |
374 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
374 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
375 | 375 | } |
376 | 376 | //in 4.1, $db_state would have only been a simple string like '4.1.0', |
377 | 377 | //but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's |
378 | 378 | //db, and possibly other keys for other addons like 'Calendar','Permissions',etc |
379 | - if( ! is_array($db_state)){ |
|
379 | + if ( ! is_array($db_state)) { |
|
380 | 380 | $db_state = array('Core'=>$db_state); |
381 | - update_option(EE_Data_Migration_Manager::current_database_state,$db_state); |
|
381 | + update_option(EE_Data_Migration_Manager::current_database_state, $db_state); |
|
382 | 382 | } |
383 | 383 | return $db_state; |
384 | 384 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * or they don't apply), returns an empty array |
390 | 390 | * @return EE_Data_Migration_Script_Base[] |
391 | 391 | */ |
392 | - public function check_for_applicable_data_migration_scripts(){ |
|
392 | + public function check_for_applicable_data_migration_scripts() { |
|
393 | 393 | //get the option describing what options have already run |
394 | 394 | $scripts_ran = $this->get_data_migrations_ran(); |
395 | 395 | //$scripts_ran = array('4.1.0.core'=>array('monkey'=>null)); |
@@ -402,62 +402,62 @@ discard block |
||
402 | 402 | $iteration = 0; |
403 | 403 | $next_database_state_to_consider = $current_database_state; |
404 | 404 | $theoretical_database_state = NULL; |
405 | - do{ |
|
405 | + do { |
|
406 | 406 | //the next state after the currently-considered one will start off looking the same as the current, but we may make additions... |
407 | 407 | $theoretical_database_state = $next_database_state_to_consider; |
408 | 408 | //the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?) |
409 | - foreach($script_class_and_filepaths_available as $classname => $filepath){ |
|
409 | + foreach ($script_class_and_filepaths_available as $classname => $filepath) { |
|
410 | 410 | |
411 | 411 | $migrates_to_version = $this->script_migrates_to_version($classname); |
412 | - $script_converts_plugin_slug = $migrates_to_version[ 'slug' ]; |
|
413 | - $script_converts_to_version = $migrates_to_version[ 'version' ]; |
|
412 | + $script_converts_plugin_slug = $migrates_to_version['slug']; |
|
413 | + $script_converts_to_version = $migrates_to_version['version']; |
|
414 | 414 | //check if this version script is DONE or not; or if it's never been ran |
415 | - if( ! $scripts_ran || |
|
415 | + if ( ! $scripts_ran || |
|
416 | 416 | ! isset($scripts_ran[$script_converts_plugin_slug]) || |
417 | - ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])){ |
|
417 | + ! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) { |
|
418 | 418 | //we haven't ran this conversion script before |
419 | 419 | //now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available |
420 | - $script = new $classname( $this->_get_table_manager(), $this->_get_table_analysis() ); |
|
420 | + $script = new $classname($this->_get_table_manager(), $this->_get_table_analysis()); |
|
421 | 421 | /* @var $script EE_Data_Migration_Script_Base */ |
422 | 422 | $can_migrate = $script->can_migrate_from_version($theoretical_database_state); |
423 | - if($can_migrate){ |
|
423 | + if ($can_migrate) { |
|
424 | 424 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
425 | 425 | $migrates_to_version = $script->migrates_to_version(); |
426 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
426 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
427 | 427 | unset($script_class_and_filepaths_available[$classname]); |
428 | 428 | } |
429 | - } elseif($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base){ |
|
429 | + } elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) { |
|
430 | 430 | //this script has been ran, or at least started |
431 | 431 | $script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version]; |
432 | - if( $script->get_status() != self::status_completed){ |
|
432 | + if ($script->get_status() != self::status_completed) { |
|
433 | 433 | //this script is already underway... keep going with it |
434 | 434 | $script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script; |
435 | 435 | $migrates_to_version = $script->migrates_to_version(); |
436 | - $next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ]; |
|
436 | + $next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version']; |
|
437 | 437 | unset($script_class_and_filepaths_available[$classname]); |
438 | - }else{ |
|
438 | + } else { |
|
439 | 439 | //it must have a status that indicates it has finished, so we don't want to try and run it again |
440 | 440 | } |
441 | - }else{ |
|
441 | + } else { |
|
442 | 442 | //it exists but it's not a proper data migration script |
443 | 443 | //maybe the script got renamed? or was simply removed from EE? |
444 | 444 | //either way, its certainly not runnable! |
445 | 445 | } |
446 | 446 | } |
447 | 447 | $iteration++; |
448 | - }while( $next_database_state_to_consider != $theoretical_database_state && $iteration<6); |
|
448 | + }while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6); |
|
449 | 449 | //ok we have all the scripts that should run, now let's make them into flat array |
450 | 450 | $scripts_that_should_run = array(); |
451 | - foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){ |
|
451 | + foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) { |
|
452 | 452 | ksort($scripts_at_priority); |
453 | - foreach($scripts_at_priority as $scripts){ |
|
454 | - foreach($scripts as $script){ |
|
453 | + foreach ($scripts_at_priority as $scripts) { |
|
454 | + foreach ($scripts as $script) { |
|
455 | 455 | $scripts_that_should_run[get_class($script)] = $script; |
456 | 456 | } |
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
460 | - do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run ); |
|
460 | + do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run); |
|
461 | 461 | return $scripts_that_should_run; |
462 | 462 | } |
463 | 463 | |
@@ -471,14 +471,14 @@ discard block |
||
471 | 471 | * @param bool $include_completed_scripts |
472 | 472 | * @return EE_Data_Migration_Script_Base |
473 | 473 | */ |
474 | - public function get_last_ran_script($include_completed_scripts = false){ |
|
474 | + public function get_last_ran_script($include_completed_scripts = false) { |
|
475 | 475 | //make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script |
476 | - if( ! $this->_data_migrations_ran){ |
|
476 | + if ( ! $this->_data_migrations_ran) { |
|
477 | 477 | $this->get_data_migrations_ran(); |
478 | 478 | } |
479 | - if($include_completed_scripts){ |
|
479 | + if ($include_completed_scripts) { |
|
480 | 480 | return $this->_last_ran_script; |
481 | - }else{ |
|
481 | + } else { |
|
482 | 482 | return $this->_last_ran_incomplete_script; |
483 | 483 | } |
484 | 484 | } |
@@ -501,19 +501,19 @@ discard block |
||
501 | 501 | * @type string $message string describing what was done during this step |
502 | 502 | * } |
503 | 503 | */ |
504 | - public function migration_step( $step_size = 0 ){ |
|
504 | + public function migration_step($step_size = 0) { |
|
505 | 505 | |
506 | 506 | //bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535 |
507 | - if ( class_exists( 'EE_CPT_Strategy' ) ) { |
|
508 | - remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 ); |
|
507 | + if (class_exists('EE_CPT_Strategy')) { |
|
508 | + remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5); |
|
509 | 509 | } |
510 | 510 | |
511 | - try{ |
|
511 | + try { |
|
512 | 512 | $currently_executing_script = $this->get_last_ran_script(); |
513 | - if( ! $currently_executing_script){ |
|
513 | + if ( ! $currently_executing_script) { |
|
514 | 514 | //Find the next script that needs to execute |
515 | 515 | $scripts = $this->check_for_applicable_data_migration_scripts(); |
516 | - if( ! $scripts ){ |
|
516 | + if ( ! $scripts) { |
|
517 | 517 | //huh, no more scripts to run... apparently we're done! |
518 | 518 | //but dont forget to make sure initial data is there |
519 | 519 | //we should be good to allow them to exit maintenance mode now |
@@ -534,18 +534,18 @@ discard block |
||
534 | 534 | //and add to the array/wp option showing the scripts ran |
535 | 535 | // $this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script; |
536 | 536 | $migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script)); |
537 | - $plugin_slug = $migrates_to[ 'slug' ]; |
|
538 | - $version = $migrates_to[ 'version' ]; |
|
537 | + $plugin_slug = $migrates_to['slug']; |
|
538 | + $version = $migrates_to['version']; |
|
539 | 539 | $this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script; |
540 | 540 | } |
541 | 541 | $current_script_name = get_class($currently_executing_script); |
542 | - }catch(Exception $e){ |
|
542 | + } catch (Exception $e) { |
|
543 | 543 | //an exception occurred while trying to get migration scripts |
544 | 544 | |
545 | - $message = sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() ); |
|
545 | + $message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString()); |
|
546 | 546 | //record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations |
547 | 547 | //but that's ok-- it's just an FYI to support that we couldn't even run any data migrations |
548 | - $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message)); |
|
548 | + $this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message)); |
|
549 | 549 | return array( |
550 | 550 | 'records_to_migrate'=>1, |
551 | 551 | 'records_migrated'=>0, |
@@ -555,16 +555,16 @@ discard block |
||
555 | 555 | ); |
556 | 556 | } |
557 | 557 | //ok so we definitely have a data migration script |
558 | - try{ |
|
558 | + try { |
|
559 | 559 | //how big of a bite do we want to take? Allow users to easily override via their wp-config |
560 | - if( ! absint( $step_size ) > 0 ){ |
|
561 | - $step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
560 | + if ( ! absint($step_size) > 0) { |
|
561 | + $step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size; |
|
562 | 562 | } |
563 | 563 | //do what we came to do! |
564 | 564 | $currently_executing_script->migration_step($step_size); |
565 | 565 | //can we wrap it up and verify default data? |
566 | 566 | $init_dbs = false; |
567 | - switch($currently_executing_script->get_status()){ |
|
567 | + switch ($currently_executing_script->get_status()) { |
|
568 | 568 | case EE_Data_Migration_Manager::status_continue: |
569 | 569 | $response_array = array( |
570 | 570 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
@@ -576,16 +576,16 @@ discard block |
||
576 | 576 | case EE_Data_Migration_Manager::status_completed: |
577 | 577 | //ok so THAT script has completed |
578 | 578 | $this->update_current_database_state_to($this->script_migrates_to_version($current_script_name)); |
579 | - $response_array = array( |
|
579 | + $response_array = array( |
|
580 | 580 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
581 | 581 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
582 | 582 | 'status'=> EE_Data_Migration_Manager::status_completed, |
583 | 583 | 'message'=>$currently_executing_script->get_feedback_message(), |
584 | - 'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name()) |
|
584 | + 'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name()) |
|
585 | 585 | ); |
586 | 586 | //check if there are any more after this one. |
587 | 587 | $scripts_remaining = $this->check_for_applicable_data_migration_scripts(); |
588 | - if( ! $scripts_remaining ){ |
|
588 | + if ( ! $scripts_remaining) { |
|
589 | 589 | //we should be good to allow them to exit maintenance mode now |
590 | 590 | EE_Maintenance_Mode::instance()->set_maintenance_level(intval(EE_Maintenance_Mode::level_0_not_in_maintenance)); |
591 | 591 | ////huh, no more scripts to run... apparently we're done! |
@@ -599,39 +599,39 @@ discard block |
||
599 | 599 | 'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(), |
600 | 600 | 'records_migrated'=>$currently_executing_script->count_records_migrated(), |
601 | 601 | 'status'=> $currently_executing_script->get_status(), |
602 | - 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())), |
|
602 | + 'message'=> sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())), |
|
603 | 603 | 'script'=>$currently_executing_script->pretty_name() |
604 | 604 | ); |
605 | 605 | break; |
606 | 606 | } |
607 | - }catch(Exception $e){ |
|
607 | + } catch (Exception $e) { |
|
608 | 608 | //ok so some exception was thrown which killed the data migration script |
609 | 609 | //double-check we have a real script |
610 | - if($currently_executing_script instanceof EE_Data_Migration_Script_Base){ |
|
610 | + if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) { |
|
611 | 611 | $script_name = $currently_executing_script->pretty_name(); |
612 | 612 | $currently_executing_script->set_broken(); |
613 | 613 | $currently_executing_script->add_error($e->getMessage()); |
614 | - }else{ |
|
614 | + } else { |
|
615 | 615 | $script_name = __("Error getting Migration Script", "event_espresso"); |
616 | 616 | } |
617 | 617 | $response_array = array( |
618 | 618 | 'records_to_migrate'=>1, |
619 | 619 | 'records_migrated'=>0, |
620 | 620 | 'status'=>self::status_fatal_error, |
621 | - 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()), |
|
621 | + 'message'=> sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()), |
|
622 | 622 | 'script'=>$script_name |
623 | 623 | ); |
624 | 624 | } |
625 | 625 | $successful_save = $this->_save_migrations_ran(); |
626 | - if($successful_save !== TRUE){ |
|
626 | + if ($successful_save !== TRUE) { |
|
627 | 627 | //ok so the current wp option didn't save. that's tricky, because we'd like to update it |
628 | 628 | //and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION! |
629 | 629 | //however, if we throw an exception, and return that, then the next request |
630 | 630 | //won't have as much info in it, and it may be able to save |
631 | - throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"),$successful_save)); |
|
631 | + throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"), $successful_save)); |
|
632 | 632 | } |
633 | 633 | //if we're all done, initialize EE plugins' default data etc. |
634 | - if( $init_dbs ) { |
|
634 | + if ($init_dbs) { |
|
635 | 635 | $this->initialize_db_for_enqueued_ee_plugins(); |
636 | 636 | } |
637 | 637 | return $response_array; |
@@ -649,23 +649,23 @@ discard block |
||
649 | 649 | * 'message'=>a string, containing any message you want to show to the user. We may decide to split this up into errors, notifications, and successes |
650 | 650 | * 'script'=>a pretty name of the script currently running |
651 | 651 | */ |
652 | - public function response_to_migration_ajax_request(){ |
|
652 | + public function response_to_migration_ajax_request() { |
|
653 | 653 | // //start output buffer just to make sure we don't mess up the json |
654 | 654 | ob_start(); |
655 | - try{ |
|
655 | + try { |
|
656 | 656 | $response = $this->migration_step(); |
657 | - }catch(Exception $e){ |
|
657 | + } catch (Exception $e) { |
|
658 | 658 | $response = array( |
659 | 659 | 'records_to_migrate'=>0, |
660 | 660 | 'records_migrated'=>0, |
661 | 661 | 'status'=> EE_Data_Migration_Manager::status_fatal_error, |
662 | - 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()), |
|
662 | + 'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()), |
|
663 | 663 | 'script'=>'Unknown'); |
664 | 664 | $this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString()); |
665 | 665 | } |
666 | 666 | $warnings_etc = @ob_get_contents(); |
667 | 667 | ob_end_clean(); |
668 | - $response['message'] .=$warnings_etc; |
|
668 | + $response['message'] .= $warnings_etc; |
|
669 | 669 | return $response; |
670 | 670 | } |
671 | 671 | |
@@ -678,14 +678,14 @@ discard block |
||
678 | 678 | * } |
679 | 679 | * @return void |
680 | 680 | */ |
681 | - public function update_current_database_state_to($slug_and_version = null){ |
|
682 | - if( ! $slug_and_version ){ |
|
681 | + public function update_current_database_state_to($slug_and_version = null) { |
|
682 | + if ( ! $slug_and_version) { |
|
683 | 683 | //no version was provided, assume it should be at the current code version |
684 | 684 | $slug_and_version = array('slug' => 'Core', 'version' => espresso_version()); |
685 | 685 | } |
686 | 686 | $current_database_state = get_option(self::current_database_state); |
687 | - $current_database_state[ $slug_and_version[ 'slug' ] ]=$slug_and_version[ 'version' ]; |
|
688 | - update_option(self::current_database_state,$current_database_state); |
|
687 | + $current_database_state[$slug_and_version['slug']] = $slug_and_version['version']; |
|
688 | + update_option(self::current_database_state, $current_database_state); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -696,20 +696,20 @@ discard block |
||
696 | 696 | * } |
697 | 697 | * @return boolean |
698 | 698 | */ |
699 | - public function database_needs_updating_to( $slug_and_version ) { |
|
699 | + public function database_needs_updating_to($slug_and_version) { |
|
700 | 700 | |
701 | - $slug = $slug_and_version[ 'slug' ]; |
|
702 | - $version = $slug_and_version[ 'version' ]; |
|
701 | + $slug = $slug_and_version['slug']; |
|
702 | + $version = $slug_and_version['version']; |
|
703 | 703 | $current_database_state = get_option(self::current_database_state); |
704 | - if( ! isset( $current_database_state[ $slug ] ) ) { |
|
704 | + if ( ! isset($current_database_state[$slug])) { |
|
705 | 705 | return true; |
706 | - }else{ |
|
706 | + } else { |
|
707 | 707 | //just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes |
708 | - $version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3); |
|
709 | - $version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 ); |
|
708 | + $version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3); |
|
709 | + $version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3); |
|
710 | 710 | $needs_updating = false; |
711 | - foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) { |
|
712 | - if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) { |
|
711 | + foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) { |
|
712 | + if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) { |
|
713 | 713 | $needs_updating = true; |
714 | 714 | break; |
715 | 715 | } |
@@ -723,29 +723,29 @@ discard block |
||
723 | 723 | * in addons. Has the side effect of adding them for autoloading |
724 | 724 | * @return array keys are expected classnames, values are their filepaths |
725 | 725 | */ |
726 | - public function get_all_data_migration_scripts_available(){ |
|
727 | - if( ! $this->_data_migration_class_to_filepath_map){ |
|
726 | + public function get_all_data_migration_scripts_available() { |
|
727 | + if ( ! $this->_data_migration_class_to_filepath_map) { |
|
728 | 728 | $this->_data_migration_class_to_filepath_map = array(); |
729 | - foreach($this->get_data_migration_script_folders() as $folder_path){ |
|
730 | - if($folder_path[count($folder_path-1)] != DS ){ |
|
731 | - $folder_path.= DS; |
|
729 | + foreach ($this->get_data_migration_script_folders() as $folder_path) { |
|
730 | + if ($folder_path[count($folder_path - 1)] != DS) { |
|
731 | + $folder_path .= DS; |
|
732 | 732 | } |
733 | - $files = glob( $folder_path. '*.dms.php' ); |
|
733 | + $files = glob($folder_path.'*.dms.php'); |
|
734 | 734 | |
735 | - if ( empty( $files ) ) { |
|
735 | + if (empty($files)) { |
|
736 | 736 | continue; |
737 | 737 | } |
738 | 738 | |
739 | - foreach($files as $file){ |
|
740 | - $pos_of_last_slash = strrpos($file,DS); |
|
741 | - $classname = str_replace(".dms.php","", substr($file, $pos_of_last_slash+1)); |
|
742 | - $migrates_to = $this->script_migrates_to_version( $classname ); |
|
743 | - $slug = $migrates_to[ 'slug' ]; |
|
739 | + foreach ($files as $file) { |
|
740 | + $pos_of_last_slash = strrpos($file, DS); |
|
741 | + $classname = str_replace(".dms.php", "", substr($file, $pos_of_last_slash + 1)); |
|
742 | + $migrates_to = $this->script_migrates_to_version($classname); |
|
743 | + $slug = $migrates_to['slug']; |
|
744 | 744 | //check that the slug as contained in the DMS is associated with |
745 | 745 | //the slug of an addon or core |
746 | - if( $slug != 'Core' ){ |
|
747 | - if( ! EE_Registry::instance()->get_addon_by_name( $slug ) ) { |
|
748 | - EE_Error::doing_it_wrong(__FUNCTION__, sprintf( __( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ),$classname,$slug,implode(",", array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ), '4.3.0.alpha.019' ); |
|
746 | + if ($slug != 'Core') { |
|
747 | + if ( ! EE_Registry::instance()->get_addon_by_name($slug)) { |
|
748 | + EE_Error::doing_it_wrong(__FUNCTION__, sprintf(__('The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso'), $classname, $slug, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name()))), '4.3.0.alpha.019'); |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | $this->_data_migration_class_to_filepath_map[$classname] = $file; |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | * from each addon, and check if they need updating, |
766 | 766 | * @return boolean |
767 | 767 | */ |
768 | - public function addons_need_updating(){ |
|
768 | + public function addons_need_updating() { |
|
769 | 769 | return false; |
770 | 770 | } |
771 | 771 | /** |
@@ -774,25 +774,25 @@ discard block |
||
774 | 774 | * @param string $error_message |
775 | 775 | * @throws EE_Error |
776 | 776 | */ |
777 | - public function add_error_to_migrations_ran($error_message){ |
|
777 | + public function add_error_to_migrations_ran($error_message) { |
|
778 | 778 | //get last-ran migration script |
779 | 779 | global $wpdb; |
780 | - $last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1",ARRAY_A); |
|
780 | + $last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1", ARRAY_A); |
|
781 | 781 | |
782 | 782 | $last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null; |
783 | 783 | //now, tread lightly because we're here because a FATAL non-catchable error |
784 | 784 | //was thrown last time when we were trying to run a data migration script |
785 | 785 | //so the fatal error could have happened while getting the migration script |
786 | 786 | //or doing running it... |
787 | - $versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$last_migration_script_option['option_name']) : null; |
|
787 | + $versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $last_migration_script_option['option_name']) : null; |
|
788 | 788 | |
789 | 789 | //check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet |
790 | 790 | //because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done) |
791 | - if(isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed){ |
|
791 | + if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) { |
|
792 | 792 | //ok then just add this error to its list of errors |
793 | 793 | $last_ran_migration_script_properties['_errors'][] = $error_message; |
794 | 794 | $last_ran_migration_script_properties['_status'] = self::status_fatal_error; |
795 | - }else{ |
|
795 | + } else { |
|
796 | 796 | //so we don't even know which script was last running |
797 | 797 | //use the data migration error stub, which is designed specifically for this type of thing |
798 | 798 | $general_migration_error = new EE_DMS_Unknown_1_0_0(); |
@@ -802,39 +802,39 @@ discard block |
||
802 | 802 | $versions_migrated_to = 'Unknown.1.0.0'; |
803 | 803 | //now just to make sure appears as last (in case the were previously a fatal error like this) |
804 | 804 | //delete the old one |
805 | - delete_option( self::data_migration_script_option_prefix . $versions_migrated_to ); |
|
805 | + delete_option(self::data_migration_script_option_prefix.$versions_migrated_to); |
|
806 | 806 | } |
807 | - update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties); |
|
807 | + update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties); |
|
808 | 808 | |
809 | 809 | } |
810 | 810 | /** |
811 | 811 | * saves what data migrations have ran to the database |
812 | 812 | * @return mixed TRUE if successfully saved migrations ran, string if an error occurred |
813 | 813 | */ |
814 | - protected function _save_migrations_ran(){ |
|
815 | - if($this->_data_migrations_ran == null){ |
|
814 | + protected function _save_migrations_ran() { |
|
815 | + if ($this->_data_migrations_ran == null) { |
|
816 | 816 | $this->get_data_migrations_ran(); |
817 | 817 | } |
818 | 818 | //now, we don't want to save actual classes to the DB because that's messy |
819 | 819 | $successful_updates = true; |
820 | - foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){ |
|
821 | - foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){ |
|
820 | + foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) { |
|
821 | + foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) { |
|
822 | 822 | // echo "saving migration script to $version_string<br>"; |
823 | 823 | $plugin_slug_for_use_in_option_name = $plugin_slug."."; |
824 | 824 | $option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string; |
825 | 825 | $old_option_value = get_option($option_name); |
826 | - if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){ |
|
826 | + if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) { |
|
827 | 827 | $script_array_for_saving = $array_or_migration_obj->properties_as_array(); |
828 | - if( $old_option_value != $script_array_for_saving){ |
|
829 | - $successful_updates = update_option($option_name,$script_array_for_saving); |
|
828 | + if ($old_option_value != $script_array_for_saving) { |
|
829 | + $successful_updates = update_option($option_name, $script_array_for_saving); |
|
830 | 830 | } |
831 | - }else{//we don't know what this array-thing is. So just save it as-is |
|
831 | + } else {//we don't know what this array-thing is. So just save it as-is |
|
832 | 832 | // $array_of_migrations[$version_string] = $array_or_migration_obj; |
833 | - if($old_option_value != $array_or_migration_obj){ |
|
834 | - $successful_updates = update_option($option_name,$array_or_migration_obj); |
|
833 | + if ($old_option_value != $array_or_migration_obj) { |
|
834 | + $successful_updates = update_option($option_name, $array_or_migration_obj); |
|
835 | 835 | } |
836 | 836 | } |
837 | - if( ! $successful_updates ){ |
|
837 | + if ( ! $successful_updates) { |
|
838 | 838 | global $wpdb; |
839 | 839 | return $wpdb->last_error; |
840 | 840 | } |
@@ -858,17 +858,17 @@ discard block |
||
858 | 858 | * @return EE_Data_Migration_Script_Base |
859 | 859 | * @throws EE_Error |
860 | 860 | */ |
861 | - function _instantiate_script_from_properties_array($properties_array){ |
|
862 | - if( ! isset($properties_array['class'])){ |
|
863 | - throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"),implode(",",$properties_array))); |
|
861 | + function _instantiate_script_from_properties_array($properties_array) { |
|
862 | + if ( ! isset($properties_array['class'])) { |
|
863 | + throw new EE_Error(sprintf(__("Properties array has no 'class' properties. Here's what it has: %s", "event_espresso"), implode(",", $properties_array))); |
|
864 | 864 | } |
865 | 865 | $class_name = $properties_array['class']; |
866 | - if( ! class_exists($class_name)){ |
|
867 | - throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"),$class_name)); |
|
866 | + if ( ! class_exists($class_name)) { |
|
867 | + throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name)); |
|
868 | 868 | } |
869 | 869 | $class = new $class_name; |
870 | - if( ! $class instanceof EE_Data_Migration_Script_Base){ |
|
871 | - throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),$class_name,get_class($class))); |
|
870 | + if ( ! $class instanceof EE_Data_Migration_Script_Base) { |
|
871 | + throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"), $class_name, get_class($class))); |
|
872 | 872 | } |
873 | 873 | $class->instantiate_from_array_of_properties($properties_array); |
874 | 874 | return $class; |
@@ -880,25 +880,25 @@ discard block |
||
880 | 880 | * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core' |
881 | 881 | * @return string |
882 | 882 | */ |
883 | - public function get_most_up_to_date_dms($plugin_slug = 'Core'){ |
|
883 | + public function get_most_up_to_date_dms($plugin_slug = 'Core') { |
|
884 | 884 | $class_to_filepath_map = $this->get_all_data_migration_scripts_available(); |
885 | 885 | $most_up_to_date_dms_classname = NULL; |
886 | - foreach($class_to_filepath_map as $classname => $filepath){ |
|
887 | - if($most_up_to_date_dms_classname === NULL){ |
|
886 | + foreach ($class_to_filepath_map as $classname => $filepath) { |
|
887 | + if ($most_up_to_date_dms_classname === NULL) { |
|
888 | 888 | $migrates_to = $this->script_migrates_to_version($classname); |
889 | - $this_plugin_slug = $migrates_to[ 'slug' ]; |
|
889 | + $this_plugin_slug = $migrates_to['slug']; |
|
890 | 890 | // $version_string = $migrates_to[ 'version' ]; |
891 | 891 | // $details = $this->parse_dms_classname($classname); |
892 | - if($this_plugin_slug == $plugin_slug){ |
|
892 | + if ($this_plugin_slug == $plugin_slug) { |
|
893 | 893 | //if it's for core, it wins |
894 | 894 | $most_up_to_date_dms_classname = $classname; |
895 | 895 | } |
896 | 896 | //if it wasn't for core, we must keep searching for one that is! |
897 | 897 | continue; |
898 | - }else{ |
|
899 | - $champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
898 | + } else { |
|
899 | + $champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname); |
|
900 | 900 | $contender_migrates_to = $this->script_migrates_to_version($classname); |
901 | - if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){ |
|
901 | + if ($contender_migrates_to['slug'] == $plugin_slug && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<')) { |
|
902 | 902 | //so the contenders version is higher and its for Core |
903 | 903 | $most_up_to_date_dms_classname = $classname; |
904 | 904 | } |
@@ -918,11 +918,11 @@ discard block |
||
918 | 918 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
919 | 919 | * @return EE_Data_Migration_Script_Base |
920 | 920 | */ |
921 | - public function get_migration_ran( $version, $plugin_slug = 'Core' ) { |
|
921 | + public function get_migration_ran($version, $plugin_slug = 'Core') { |
|
922 | 922 | $migrations_ran = $this->get_data_migrations_ran(); |
923 | - if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){ |
|
924 | - return $migrations_ran[ $plugin_slug ][ $version ]; |
|
925 | - }else{ |
|
923 | + if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) { |
|
924 | + return $migrations_ran[$plugin_slug][$version]; |
|
925 | + } else { |
|
926 | 926 | return NULL; |
927 | 927 | } |
928 | 928 | } |
@@ -934,20 +934,20 @@ discard block |
||
934 | 934 | * @return bool |
935 | 935 | * @throws \EE_Error |
936 | 936 | */ |
937 | - public function reattempt(){ |
|
937 | + public function reattempt() { |
|
938 | 938 | //find if the last-ran script was borked |
939 | 939 | //set it as being non-borked (we shouldn't ever get DMSs that we don't recognize) |
940 | 940 | //add an 'error' saying that we attempted to reset |
941 | 941 | //does it have a stage that was borked too? if so make it no longer borked |
942 | 942 | //add an 'error' saying we attempted to reset |
943 | 943 | $last_ran_script = $this->get_last_ran_script(); |
944 | - if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){ |
|
944 | + if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) { |
|
945 | 945 | //if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it) |
946 | 946 | $last_ran_script->set_completed(); |
947 | - }elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) { |
|
947 | + }elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) { |
|
948 | 948 | $last_ran_script->reattempt(); |
949 | - }else{ |
|
950 | - throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) ); |
|
949 | + } else { |
|
950 | + throw new EE_Error(sprintf(__('Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso'), print_r($last_ran_script, true))); |
|
951 | 951 | } |
952 | 952 | return $this->_save_migrations_ran(); |
953 | 953 | } |
@@ -957,19 +957,19 @@ discard block |
||
957 | 957 | * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc |
958 | 958 | * @return boolean |
959 | 959 | */ |
960 | - public function migration_has_ran( $version, $plugin_slug = 'Core' ) { |
|
961 | - return $this->get_migration_ran( $version, $plugin_slug ) !== NULL; |
|
960 | + public function migration_has_ran($version, $plugin_slug = 'Core') { |
|
961 | + return $this->get_migration_ran($version, $plugin_slug) !== NULL; |
|
962 | 962 | } |
963 | 963 | /** |
964 | 964 | * Enqueues this ee plugin to have its data initialized |
965 | 965 | * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value |
966 | 966 | */ |
967 | - public function enqueue_db_initialization_for( $plugin_slug ) { |
|
967 | + public function enqueue_db_initialization_for($plugin_slug) { |
|
968 | 968 | $queue = $this->get_db_initialization_queue(); |
969 | - if( ! in_array( $plugin_slug, $queue ) ) { |
|
969 | + if ( ! in_array($plugin_slug, $queue)) { |
|
970 | 970 | $queue[] = $plugin_slug; |
971 | 971 | } |
972 | - update_option( self::db_init_queue_option_name, $queue ); |
|
972 | + update_option(self::db_init_queue_option_name, $queue); |
|
973 | 973 | } |
974 | 974 | /** |
975 | 975 | * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon |
@@ -979,26 +979,26 @@ discard block |
||
979 | 979 | public function initialize_db_for_enqueued_ee_plugins() { |
980 | 980 | // EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' ); |
981 | 981 | $queue = $this->get_db_initialization_queue(); |
982 | - foreach( $queue as $plugin_slug ) { |
|
983 | - $most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug ); |
|
984 | - if( ! $most_up_to_date_dms ) { |
|
982 | + foreach ($queue as $plugin_slug) { |
|
983 | + $most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug); |
|
984 | + if ( ! $most_up_to_date_dms) { |
|
985 | 985 | //if there is NO DMS for this plugin, obviously there's no schema to verify anyways |
986 | 986 | $verify_db = false; |
987 | - }else{ |
|
988 | - $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms ); |
|
989 | - $verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to ); |
|
987 | + } else { |
|
988 | + $most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms); |
|
989 | + $verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to); |
|
990 | 990 | } |
991 | - if( $plugin_slug == 'Core' ){ |
|
991 | + if ($plugin_slug == 'Core') { |
|
992 | 992 | EE_System::instance()->initialize_db_if_no_migrations_required( |
993 | 993 | false, |
994 | 994 | $verify_db |
995 | 995 | ); |
996 | - }else{ |
|
996 | + } else { |
|
997 | 997 | //just loop through the addons to make sure their database is setup |
998 | - foreach( EE_Registry::instance()->addons as $addon ) { |
|
999 | - if( $addon->name() == $plugin_slug ) { |
|
998 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
999 | + if ($addon->name() == $plugin_slug) { |
|
1000 | 1000 | |
1001 | - $addon->initialize_db_if_no_migrations_required( $verify_db ); |
|
1001 | + $addon->initialize_db_if_no_migrations_required($verify_db); |
|
1002 | 1002 | break; |
1003 | 1003 | } |
1004 | 1004 | } |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | // EEH_Debug_Tools::instance()->show_times(); |
1009 | 1009 | //because we just initialized the DBs for the enqueued ee plugins |
1010 | 1010 | //we don't need to keep remembering which ones needed to be initialized |
1011 | - delete_option( self::db_init_queue_option_name ); |
|
1011 | + delete_option(self::db_init_queue_option_name); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | /** |
@@ -1017,8 +1017,8 @@ discard block |
||
1017 | 1017 | * 'Core', or the return value of EE_Addon::name() for an addon |
1018 | 1018 | * @return array |
1019 | 1019 | */ |
1020 | - public function get_db_initialization_queue(){ |
|
1021 | - return get_option ( self::db_init_queue_option_name, array() ); |
|
1020 | + public function get_db_initialization_queue() { |
|
1021 | + return get_option(self::db_init_queue_option_name, array()); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | /** |
@@ -1027,13 +1027,13 @@ discard block |
||
1027 | 1027 | * @throws \EE_Error |
1028 | 1028 | */ |
1029 | 1029 | protected function _get_table_analysis() { |
1030 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
1030 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
1031 | 1031 | return $this->_table_analysis; |
1032 | 1032 | } else { |
1033 | 1033 | throw new \EE_Error( |
1034 | 1034 | sprintf( |
1035 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
1036 | - get_class( $this ) |
|
1035 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
1036 | + get_class($this) |
|
1037 | 1037 | ) |
1038 | 1038 | ); |
1039 | 1039 | } |
@@ -1045,13 +1045,13 @@ discard block |
||
1045 | 1045 | * @throws \EE_Error |
1046 | 1046 | */ |
1047 | 1047 | protected function _get_table_manager() { |
1048 | - if( $this->_table_manager instanceof TableManager ) { |
|
1048 | + if ($this->_table_manager instanceof TableManager) { |
|
1049 | 1049 | return $this->_table_manager; |
1050 | 1050 | } else { |
1051 | 1051 | throw new \EE_Error( |
1052 | 1052 | sprintf( |
1053 | - __( 'Table manager class on class %1$s is not set properly.', 'event_espresso'), |
|
1054 | - get_class( $this ) |
|
1053 | + __('Table manager class on class %1$s is not set properly.', 'event_espresso'), |
|
1054 | + get_class($this) |
|
1055 | 1055 | ) |
1056 | 1056 | ); |
1057 | 1057 | } |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | |
22 | 22 | |
23 | -abstract class EE_Data_Migration_Class_Base{ |
|
23 | +abstract class EE_Data_Migration_Class_Base { |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var $records_to_migrate int count of all that have been migrated |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param TableManager $table_manager |
73 | 73 | * @param TableAnalysis $table_analysis |
74 | 74 | */ |
75 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ){ |
|
75 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
76 | 76 | $this->_table_manager = $table_manager; |
77 | 77 | $this->_table_analysis = $table_analysis; |
78 | 78 | $this->set_status(EE_Data_Migration_Manager::status_continue); |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * @throws EE_Error |
86 | 86 | * @return string |
87 | 87 | */ |
88 | - public function pretty_name(){ |
|
89 | - if($this->_pretty_name === null){ |
|
90 | - throw new EE_Error(sprintf(__("Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", "event_espresso"),get_class($this))); |
|
88 | + public function pretty_name() { |
|
89 | + if ($this->_pretty_name === null) { |
|
90 | + throw new EE_Error(sprintf(__("Please give a pretty name to the migration script stage %s by assigning the property _pretty_name in the constructor", "event_espresso"), get_class($this))); |
|
91 | 91 | } |
92 | 92 | return $this->_pretty_name; |
93 | 93 | } |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @return int |
97 | 97 | */ |
98 | - public function count_records_to_migrate(){ |
|
99 | - if( $this->_records_to_migrate == null){ |
|
98 | + public function count_records_to_migrate() { |
|
99 | + if ($this->_records_to_migrate == null) { |
|
100 | 100 | $this->_records_to_migrate = $this->_count_records_to_migrate(); |
101 | 101 | } |
102 | 102 | return $this->_records_to_migrate; |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @return string one of EE_Data_Migration_Manager::status_* constants |
117 | 117 | * @throws EE_Error |
118 | 118 | */ |
119 | - public function get_status(){ |
|
120 | - if($this->_status === null){ |
|
121 | - throw new EE_Error(sprintf(__("Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", "event_espresso"),get_class($this))); |
|
119 | + public function get_status() { |
|
120 | + if ($this->_status === null) { |
|
121 | + throw new EE_Error(sprintf(__("Trying to get status of Migration class %s, but it has not been initialized yet. It should be set in the constructor.", "event_espresso"), get_class($this))); |
|
122 | 122 | } |
123 | 123 | return $this->_status; |
124 | 124 | } |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @param string $status |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - protected function set_status($status){ |
|
130 | + protected function set_status($status) { |
|
131 | 131 | $this->_status = $status; |
132 | 132 | } |
133 | 133 | /** |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | * Returns the last error that occurred. If none occurred, returns null |
140 | 140 | * @return string |
141 | 141 | */ |
142 | - public function get_last_error(){ |
|
142 | + public function get_last_error() { |
|
143 | 143 | $errors = $this->get_errors(); |
144 | - if($errors){ |
|
144 | + if ($errors) { |
|
145 | 145 | return end($errors); |
146 | - }else{ |
|
146 | + } else { |
|
147 | 147 | return null; |
148 | 148 | } |
149 | 149 | } |
@@ -152,26 +152,26 @@ discard block |
||
152 | 152 | * @param string $error a string describing the error that will be useful for debugging. Consider including all the data that led to the error, and a stack trace etc. |
153 | 153 | * @param boolean $force force the error to be added (because otherwise we have a limit). If forcing and errors are already at their limit, we will purposefully forget the first half |
154 | 154 | */ |
155 | - public function add_error($error, $force = FALSE ){ |
|
156 | - if( ! defined( 'EE_DMS_ERROR_LIMIT' ) ){ |
|
155 | + public function add_error($error, $force = FALSE) { |
|
156 | + if ( ! defined('EE_DMS_ERROR_LIMIT')) { |
|
157 | 157 | $limit = 50; |
158 | - }else{ |
|
158 | + } else { |
|
159 | 159 | $limit = EE_DMS_ERROR_LIMIT; |
160 | 160 | } |
161 | 161 | //make sure errors is an array, see ticket #8261 |
162 | - if( is_string( $this->_errors ) ){ |
|
163 | - $this->_errors = array( $this->_errors ); |
|
162 | + if (is_string($this->_errors)) { |
|
163 | + $this->_errors = array($this->_errors); |
|
164 | 164 | } |
165 | - if(count($this->_errors) >= $limit ){ |
|
166 | - if( $force ){ |
|
165 | + if (count($this->_errors) >= $limit) { |
|
166 | + if ($force) { |
|
167 | 167 | //get rid of the first half of the errors and any above the limit |
168 | - $this->_errors = array_slice( $this->_errors, $limit / 2, $limit / 2 ); |
|
168 | + $this->_errors = array_slice($this->_errors, $limit / 2, $limit / 2); |
|
169 | 169 | $this->_errors[] = "Limit reached; removed first half of errors to save space"; |
170 | 170 | $this->_errors[] = $error; |
171 | - }else{ |
|
172 | - $this->_errors[ $limit ] = 'More, but limit reached...'; |
|
171 | + } else { |
|
172 | + $this->_errors[$limit] = 'More, but limit reached...'; |
|
173 | 173 | } |
174 | - }else{ |
|
174 | + } else { |
|
175 | 175 | $this->_errors[] = $error; |
176 | 176 | } |
177 | 177 | } |
@@ -180,57 +180,57 @@ discard block |
||
180 | 180 | * Indicates there was a fatal error and the migration cannot possibly continue |
181 | 181 | * @return boolean |
182 | 182 | */ |
183 | - public function is_broken(){ |
|
183 | + public function is_broken() { |
|
184 | 184 | return $this->get_status() == EE_Data_Migration_Manager::status_fatal_error; |
185 | 185 | } |
186 | 186 | /** |
187 | 187 | * @deprecated since 4.6.12 |
188 | 188 | */ |
189 | - public function is_borked(){ |
|
190 | - EE_Error::doing_it_wrong('is_borked', __( 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso' ), '4.6.12'); |
|
189 | + public function is_borked() { |
|
190 | + EE_Error::doing_it_wrong('is_borked', __('The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso'), '4.6.12'); |
|
191 | 191 | return $this->is_broken(); |
192 | 192 | } |
193 | 193 | /** |
194 | 194 | * Sets the status to as having a fatal error |
195 | 195 | */ |
196 | - public function set_broken(){ |
|
196 | + public function set_broken() { |
|
197 | 197 | $this->_status = EE_Data_Migration_Manager::status_fatal_error; |
198 | 198 | } |
199 | 199 | /** |
200 | 200 | * |
201 | 201 | * @deprecated since 4.6.12 |
202 | 202 | */ |
203 | - public function set_borked(){ |
|
204 | - EE_Error::doing_it_wrong('is_borked', __( 'The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso' ), '4.6.12'); |
|
203 | + public function set_borked() { |
|
204 | + EE_Error::doing_it_wrong('is_borked', __('The cheeky "is_borked" method had been replaced with the more proper "is_broken"', 'event_espresso'), '4.6.12'); |
|
205 | 205 | return $this->set_broken(); |
206 | 206 | } |
207 | 207 | /** |
208 | 208 | * Checks if this thing believes it is completed |
209 | 209 | * @return boolean |
210 | 210 | */ |
211 | - public function is_completed(){ |
|
211 | + public function is_completed() { |
|
212 | 212 | return $this->get_status() == EE_Data_Migration_Manager::status_completed; |
213 | 213 | } |
214 | 214 | /** |
215 | 215 | * Checks if the current script has more to do or not (ie, if it's status is CONTINUE) |
216 | 216 | * @return boolean |
217 | 217 | */ |
218 | - public function has_more_to_do(){ |
|
218 | + public function has_more_to_do() { |
|
219 | 219 | return $this->get_status() == EE_Data_Migration_Manager::status_continue; |
220 | 220 | } |
221 | 221 | /** |
222 | 222 | * Marks that we believe this migration thing is completed |
223 | 223 | */ |
224 | - public function set_completed(){ |
|
224 | + public function set_completed() { |
|
225 | 225 | $this->_status = EE_Data_Migration_Manager::status_completed; |
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
229 | 229 | * Marks that we think this migration class can continue to migrate |
230 | 230 | */ |
231 | - public function reattempt(){ |
|
231 | + public function reattempt() { |
|
232 | 232 | $this->_status = EE_Data_Migration_Manager::status_continue; |
233 | - $this->add_error( __( 'Reattempt migration', 'event_espresso' ), TRUE ); |
|
233 | + $this->add_error(__('Reattempt migration', 'event_espresso'), TRUE); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * possible that this class is defined when it goes to sleep, but NOT available when it |
240 | 240 | * awakes (eg, this class is part of an addon that is deactivated at some point). |
241 | 241 | */ |
242 | - public function properties_as_array(){ |
|
243 | - $properties = get_object_vars($this); |
|
242 | + public function properties_as_array() { |
|
243 | + $properties = get_object_vars($this); |
|
244 | 244 | $properties['class'] = get_class($this); |
245 | 245 | unset($properties['_migration_script']); |
246 | 246 | return $properties; |
@@ -261,22 +261,22 @@ discard block |
||
261 | 261 | * @param array $data_types numerically indexed |
262 | 262 | * @return string |
263 | 263 | */ |
264 | - protected function _create_error_message_for_db_insertion($old_table, $old_row_as_array, $new_table, $new_row_as_array, $data_types){ |
|
264 | + protected function _create_error_message_for_db_insertion($old_table, $old_row_as_array, $new_table, $new_row_as_array, $data_types) { |
|
265 | 265 | global $wpdb; |
266 | 266 | $old_columns_and_values_for_string = array(); |
267 | - foreach($old_row_as_array as $column => $value){ |
|
267 | + foreach ($old_row_as_array as $column => $value) { |
|
268 | 268 | $old_columns_and_values_for_string[] = "$column => $value"; |
269 | 269 | } |
270 | 270 | $new_columns_and_values_for_string = array(); |
271 | 271 | $count = 0; |
272 | - foreach($new_row_as_array as $column => $value){ |
|
272 | + foreach ($new_row_as_array as $column => $value) { |
|
273 | 273 | $new_columns_and_values_for_string[] = " $column => $value (".$data_types[$count++].")"; |
274 | 274 | } |
275 | 275 | return sprintf( |
276 | 276 | __('Received error "%6$s" inserting row %5$s %1$s %5$s into table %2$s.%5$s Data used was %5$s %3$s %5$s from table %4%s.', "event_espresso"), |
277 | - implode(", ",$new_columns_and_values_for_string), |
|
277 | + implode(", ", $new_columns_and_values_for_string), |
|
278 | 278 | $new_table, |
279 | - implode(", ",$old_columns_and_values_for_string), |
|
279 | + implode(", ", $old_columns_and_values_for_string), |
|
280 | 280 | $old_table, |
281 | 281 | '<br/>', |
282 | 282 | $wpdb->last_error |
@@ -291,12 +291,12 @@ discard block |
||
291 | 291 | * @param array $array_of_data |
292 | 292 | * @return string |
293 | 293 | */ |
294 | - protected function _json_encode($array_of_data){ |
|
294 | + protected function _json_encode($array_of_data) { |
|
295 | 295 | //we'd rather NOT serialize the transaction details |
296 | 296 | $fields_to_include = array(); |
297 | - foreach($array_of_data as $name => $value){ |
|
297 | + foreach ($array_of_data as $name => $value) { |
|
298 | 298 | $unserialized_data = @unserialize($value); |
299 | - if($unserialized_data === FALSE){ |
|
299 | + if ($unserialized_data === FALSE) { |
|
300 | 300 | $fields_to_include[$name] = $value; |
301 | 301 | } |
302 | 302 | } |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | * @throws EE_Error |
310 | 310 | */ |
311 | 311 | protected function _get_table_manager() { |
312 | - if( $this->_table_manager instanceof TableManager ) { |
|
312 | + if ($this->_table_manager instanceof TableManager) { |
|
313 | 313 | return $this->_table_manager; |
314 | 314 | } else { |
315 | 315 | throw new EE_Error( |
316 | 316 | sprintf( |
317 | - __( 'Table manager on migration class %1$s is not set properly.', 'event_espresso'), |
|
318 | - get_class( $this ) |
|
317 | + __('Table manager on migration class %1$s is not set properly.', 'event_espresso'), |
|
318 | + get_class($this) |
|
319 | 319 | ) |
320 | 320 | ); |
321 | 321 | } |
@@ -327,13 +327,13 @@ discard block |
||
327 | 327 | * @throws EE_Error |
328 | 328 | */ |
329 | 329 | protected function _get_table_analysis() { |
330 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
330 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
331 | 331 | return $this->_table_analysis; |
332 | 332 | } else { |
333 | 333 | throw new EE_Error( |
334 | 334 | sprintf( |
335 | - __( 'Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), |
|
336 | - get_class( $this ) |
|
335 | + __('Table analysis class on migration class %1$s is not set properly.', 'event_espresso'), |
|
336 | + get_class($this) |
|
337 | 337 | ) |
338 | 338 | ); |
339 | 339 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
3 | 3 | use EventEspresso\core\services\database\TableManager; |
4 | 4 | |
5 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { |
|
5 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
6 | 6 | exit('No direct script access allowed'); |
7 | 7 | } |
8 | 8 | |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | * @param TableManager $table_manager |
125 | 125 | * @param TableAnalysis $table_analysis |
126 | 126 | */ |
127 | - public function __construct( TableManager $table_manager = null, TableAnalysis $table_analysis = null ) { |
|
128 | - $this->_migration_stages = (array) apply_filters('FHEE__'.get_class($this).'__construct__migration_stages',$this->_migration_stages); |
|
129 | - foreach($this->_migration_stages as $migration_stage){ |
|
130 | - if ( $migration_stage instanceof EE_Data_Migration_Script_Stage ) { |
|
127 | + public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null) { |
|
128 | + $this->_migration_stages = (array) apply_filters('FHEE__'.get_class($this).'__construct__migration_stages', $this->_migration_stages); |
|
129 | + foreach ($this->_migration_stages as $migration_stage) { |
|
130 | + if ($migration_stage instanceof EE_Data_Migration_Script_Stage) { |
|
131 | 131 | $migration_stage->_construct_finalize($this); |
132 | 132 | } |
133 | 133 | } |
134 | - parent::__construct( $table_manager, $table_analysis ); |
|
134 | + parent::__construct($table_manager, $table_analysis); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * Place to add hooks and filters for tweaking the migrations page, in order |
141 | 141 | * to customize it |
142 | 142 | */ |
143 | - public function migration_page_hooks(){ |
|
143 | + public function migration_page_hooks() { |
|
144 | 144 | //by default none are added because we normally like the default look of the migration page |
145 | 145 | } |
146 | 146 | |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | * @param int|string $new_pk eg posts.ID |
156 | 156 | * @return void |
157 | 157 | */ |
158 | - public function set_mapping($old_table,$old_pk,$new_table,$new_pk){ |
|
158 | + public function set_mapping($old_table, $old_pk, $new_table, $new_pk) { |
|
159 | 159 | //make sure it has the needed keys |
160 | - if( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])){ |
|
160 | + if ( ! isset($this->_mappings[$old_table]) || ! isset($this->_mappings[$old_table][$new_table])) { |
|
161 | 161 | $this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table); |
162 | 162 | } |
163 | 163 | $this->_mappings[$old_table][$new_table][$old_pk] = $new_pk; |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | * @param string $new_table with wpdb prefix (wp_). Eg: wp_posts |
174 | 174 | * @return mixed the primary key on the new table |
175 | 175 | */ |
176 | - public function get_mapping_new_pk($old_table,$old_pk,$new_table){ |
|
177 | - if( ! isset($this->_mappings[$old_table]) || |
|
178 | - ! isset($this->_mappings[$old_table][$new_table])){ |
|
176 | + public function get_mapping_new_pk($old_table, $old_pk, $new_table) { |
|
177 | + if ( ! isset($this->_mappings[$old_table]) || |
|
178 | + ! isset($this->_mappings[$old_table][$new_table])) { |
|
179 | 179 | //try fetching the option |
180 | 180 | $this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table); |
181 | 181 | } |
@@ -192,15 +192,15 @@ discard block |
||
192 | 192 | * @param mixed $new_pk |
193 | 193 | * @return mixed |
194 | 194 | */ |
195 | - public function get_mapping_old_pk($old_table,$new_table,$new_pk){ |
|
196 | - if( ! isset($this->_mappings[$old_table]) || |
|
197 | - ! isset($this->_mappings[$old_table][$new_table])){ |
|
195 | + public function get_mapping_old_pk($old_table, $new_table, $new_pk) { |
|
196 | + if ( ! isset($this->_mappings[$old_table]) || |
|
197 | + ! isset($this->_mappings[$old_table][$new_table])) { |
|
198 | 198 | //try fetching the option |
199 | 199 | $this->_mappings[$old_table][$new_table] = $this->_get_mapping_option($old_table, $new_table); |
200 | 200 | } |
201 | - if(isset($this->_mappings[$old_table][$new_table])){ |
|
201 | + if (isset($this->_mappings[$old_table][$new_table])) { |
|
202 | 202 | $new_pk_to_old_pk = array_flip($this->_mappings[$old_table][$new_table]); |
203 | - if(isset($new_pk_to_old_pk[$new_pk])){ |
|
203 | + if (isset($new_pk_to_old_pk[$new_pk])) { |
|
204 | 204 | return $new_pk_to_old_pk[$new_pk]; |
205 | 205 | } |
206 | 206 | } |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | * @param string $new_table_name |
216 | 216 | * @return array |
217 | 217 | */ |
218 | - protected function _get_mapping_option($old_table_name,$new_table_name){ |
|
219 | - $option = get_option($this->_get_mapping_option_name($old_table_name, $new_table_name),array()); |
|
218 | + protected function _get_mapping_option($old_table_name, $new_table_name) { |
|
219 | + $option = get_option($this->_get_mapping_option_name($old_table_name, $new_table_name), array()); |
|
220 | 220 | return $option; |
221 | 221 | } |
222 | 222 | |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | * @param array $mapping_array |
230 | 230 | * @return boolean success of updating option |
231 | 231 | */ |
232 | - protected function _set_mapping_option($old_table_name,$new_table_name,$mapping_array){ |
|
232 | + protected function _set_mapping_option($old_table_name, $new_table_name, $mapping_array) { |
|
233 | 233 | // echo "set mapping for $old_table_name $new_table_name".count($mapping_array)."<br>"; |
234 | - $success = update_option($this->_get_mapping_option_name($old_table_name, $new_table_name),$mapping_array); |
|
234 | + $success = update_option($this->_get_mapping_option_name($old_table_name, $new_table_name), $mapping_array); |
|
235 | 235 | return $success; |
236 | 236 | } |
237 | 237 | |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | * @param string $new_table_name |
244 | 244 | * @return string |
245 | 245 | */ |
246 | - protected function _get_mapping_option_name($old_table_name,$new_table_name){ |
|
246 | + protected function _get_mapping_option_name($old_table_name, $new_table_name) { |
|
247 | 247 | global $wpdb; |
248 | - $old_table_name_sans_wp = str_replace($wpdb->prefix,"",$old_table_name); |
|
249 | - $new_table_name_sans_wp = str_replace($wpdb->prefix,"",$new_table_name); |
|
248 | + $old_table_name_sans_wp = str_replace($wpdb->prefix, "", $old_table_name); |
|
249 | + $new_table_name_sans_wp = str_replace($wpdb->prefix, "", $new_table_name); |
|
250 | 250 | $migrates_to = EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this)); |
251 | - return substr( EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix . $migrates_to [ 'slug' ] . '_' . $migrates_to[ 'version' ] . '_' . $old_table_name_sans_wp . '_' . $new_table_name_sans_wp, 0, 64 ); |
|
251 | + return substr(EE_Data_Migration_Manager::data_migration_script_mapping_option_prefix.$migrates_to ['slug'].'_'.$migrates_to['version'].'_'.$old_table_name_sans_wp.'_'.$new_table_name_sans_wp, 0, 64); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | * 99% until the function "migration_step" returns EE_Data_Migration_Script_Base::status_complete. |
266 | 266 | * @return int |
267 | 267 | */ |
268 | - protected function _count_records_to_migrate(){ |
|
268 | + protected function _count_records_to_migrate() { |
|
269 | 269 | $count = 0; |
270 | - foreach($this->stages() as $stage){ |
|
271 | - $count+= $stage->count_records_to_migrate(); |
|
270 | + foreach ($this->stages() as $stage) { |
|
271 | + $count += $stage->count_records_to_migrate(); |
|
272 | 272 | } |
273 | 273 | return $count; |
274 | 274 | } |
@@ -280,10 +280,10 @@ discard block |
||
280 | 280 | * by just setting a transient and updating it after each migration_step |
281 | 281 | * @return int |
282 | 282 | */ |
283 | - public function count_records_migrated(){ |
|
283 | + public function count_records_migrated() { |
|
284 | 284 | $count = 0; |
285 | - foreach($this->stages() as $stage){ |
|
286 | - $count+= $stage->count_records_migrated(); |
|
285 | + foreach ($this->stages() as $stage) { |
|
286 | + $count += $stage->count_records_migrated(); |
|
287 | 287 | } |
288 | 288 | $this->_records_migrated = $count; |
289 | 289 | return $count; |
@@ -297,24 +297,24 @@ discard block |
||
297 | 297 | * @throws EE_Error |
298 | 298 | * @throws Exception |
299 | 299 | */ |
300 | - public function migration_step($num_records_to_migrate_limit){ |
|
300 | + public function migration_step($num_records_to_migrate_limit) { |
|
301 | 301 | //reset the feedback message |
302 | 302 | $this->_feedback_message = ''; |
303 | 303 | //if we haven't yet done the 1st schema changes, do them now. buffer any output |
304 | 304 | $this->_maybe_do_schema_changes(true); |
305 | 305 | |
306 | - $num_records_actually_migrated =0; |
|
306 | + $num_records_actually_migrated = 0; |
|
307 | 307 | $records_migrated_per_stage = array(); |
308 | 308 | //setup the 'stage' variable, which should hold the last run stage of the migration (or none at all if nothing runs) |
309 | 309 | $stage = null; |
310 | 310 | //get the next stage that isn't complete |
311 | - foreach($this->stages() as $stage){ |
|
312 | - if( $stage->get_status() == EE_Data_Migration_Manager::status_continue){ |
|
313 | - try{ |
|
311 | + foreach ($this->stages() as $stage) { |
|
312 | + if ($stage->get_status() == EE_Data_Migration_Manager::status_continue) { |
|
313 | + try { |
|
314 | 314 | $records_migrated_during_stage = $stage->migration_step($num_records_to_migrate_limit - $num_records_actually_migrated); |
315 | 315 | $num_records_actually_migrated += $records_migrated_during_stage; |
316 | 316 | $records_migrated_per_stage[$stage->pretty_name()] = $records_migrated_during_stage; |
317 | - }catch(Exception $e){ |
|
317 | + } catch (Exception $e) { |
|
318 | 318 | //yes if we catch an exception here, we consider that migration stage borked. |
319 | 319 | $stage->set_status(EE_Data_Migration_Manager::status_fatal_error); |
320 | 320 | $this->set_status(EE_Data_Migration_Manager::status_fatal_error); |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | throw $e; |
323 | 323 | } |
324 | 324 | //check that the migration stage didn't mark itself as having a fatal error |
325 | - if($stage->is_broken()){ |
|
325 | + if ($stage->is_broken()) { |
|
326 | 326 | $this->set_broken(); |
327 | 327 | throw new EE_Error($stage->get_last_error()); |
328 | 328 | } |
@@ -330,24 +330,24 @@ discard block |
||
330 | 330 | //once we've migrated all the number we intended to (possibly from different stages), stop migrating |
331 | 331 | //or if we had a fatal error |
332 | 332 | //or if the current script stopped early- its not done, but it's done all it thinks we should do on this step |
333 | - if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()){ |
|
333 | + if ($num_records_actually_migrated >= $num_records_to_migrate_limit || $stage->is_broken() || $stage->has_more_to_do()) { |
|
334 | 334 | break; |
335 | 335 | } |
336 | 336 | } |
337 | 337 | //check if we're all done this data migration... |
338 | 338 | //which is indicated by being done early AND the last stage claims to be done |
339 | - if($stage == NULL){ |
|
339 | + if ($stage == NULL) { |
|
340 | 340 | //this migration script apparently has NO stages... which is super weird, but whatever |
341 | 341 | $this->set_completed(); |
342 | 342 | $this->_maybe_do_schema_changes(false); |
343 | - }else if( $num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()){ |
|
343 | + } else if ($num_records_actually_migrated < $num_records_to_migrate_limit && ! $stage->has_more_to_do()) { |
|
344 | 344 | //apparently we're done, because we couldn't migrate the number we intended to |
345 | 345 | $this->set_completed(); |
346 | 346 | $this->_update_feedback_message(array_reverse($records_migrated_per_stage)); |
347 | 347 | //do schema changes for after the migration now |
348 | 348 | //first double-check we haven't already done this |
349 | 349 | $this->_maybe_do_schema_changes(false); |
350 | - }else{ |
|
350 | + } else { |
|
351 | 351 | //update feedback message, keeping in mind that we show them with the most recent at the top |
352 | 352 | $this->_update_feedback_message(array_reverse($records_migrated_per_stage)); |
353 | 353 | } |
@@ -361,12 +361,12 @@ discard block |
||
361 | 361 | * @param array $records_migrated_per_stage KEYS are pretty names for each stage; values are the count of records migrated from that stage |
362 | 362 | * @return void |
363 | 363 | */ |
364 | - private function _update_feedback_message($records_migrated_per_stage){ |
|
364 | + private function _update_feedback_message($records_migrated_per_stage) { |
|
365 | 365 | $feedback_message_array = array(); |
366 | - foreach($records_migrated_per_stage as $migration_stage_name => $num_records_migrated){ |
|
367 | - $feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"),$num_records_migrated,$migration_stage_name) ; |
|
366 | + foreach ($records_migrated_per_stage as $migration_stage_name => $num_records_migrated) { |
|
367 | + $feedback_message_array[] = sprintf(__("Migrated %d records successfully during %s", "event_espresso"), $num_records_migrated, $migration_stage_name); |
|
368 | 368 | } |
369 | - $this->_feedback_message .= implode("<br>",$feedback_message_array); |
|
369 | + $this->_feedback_message .= implode("<br>", $feedback_message_array); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -378,27 +378,27 @@ discard block |
||
378 | 378 | * @throws Exception |
379 | 379 | * @return void |
380 | 380 | */ |
381 | - private function _maybe_do_schema_changes($before = true){ |
|
381 | + private function _maybe_do_schema_changes($before = true) { |
|
382 | 382 | //so this property will be either _schema_changes_after_migration_ran or _schema_changes_before_migration_ran |
383 | - $property_name = '_schema_changes_'. ($before ? 'before' : 'after').'_migration_ran'; |
|
384 | - if ( ! $this->{$property_name} ){ |
|
385 | - try{ |
|
383 | + $property_name = '_schema_changes_'.($before ? 'before' : 'after').'_migration_ran'; |
|
384 | + if ( ! $this->{$property_name} ) { |
|
385 | + try { |
|
386 | 386 | ob_start(); |
387 | - if($before){ |
|
387 | + if ($before) { |
|
388 | 388 | $this->schema_changes_before_migration(); |
389 | - }else{ |
|
389 | + } else { |
|
390 | 390 | $this->schema_changes_after_migration(); |
391 | 391 | } |
392 | 392 | $output = ob_get_contents(); |
393 | 393 | ob_end_clean(); |
394 | - }catch(Exception $e){ |
|
394 | + } catch (Exception $e) { |
|
395 | 395 | $this->set_status(EE_Data_Migration_Manager::status_fatal_error); |
396 | 396 | throw $e; |
397 | 397 | } |
398 | 398 | //record that we've done these schema changes |
399 | 399 | $this->{$property_name} = true; |
400 | 400 | //if there were any warnings etc, record them as non-fatal errors |
401 | - if( $output ){ |
|
401 | + if ($output) { |
|
402 | 402 | //there were some warnings |
403 | 403 | $this->_errors[] = $output; |
404 | 404 | } |
@@ -425,9 +425,9 @@ discard block |
||
425 | 425 | * @param string $table_definition_sql |
426 | 426 | * @param string $engine_string |
427 | 427 | */ |
428 | - protected function _table_is_new_in_this_version($table_name,$table_definition_sql,$engine_string='ENGINE=InnoDB '){ |
|
428 | + protected function _table_is_new_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=InnoDB ') { |
|
429 | 429 | // EEH_Debug_Tools::instance()->start_timer( '_table_is_new_in_this_version_' . $table_name ); |
430 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( true ) ); |
|
430 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(true)); |
|
431 | 431 | // EEH_Debug_Tools::instance()->stop_timer( '_table_is_new_in_this_version_' . $table_name ); |
432 | 432 | } |
433 | 433 | |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | * @param string $table_definition_sql |
442 | 442 | * @param string $engine_string |
443 | 443 | */ |
444 | - protected function _table_is_changed_in_this_version($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){ |
|
444 | + protected function _table_is_changed_in_this_version($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') { |
|
445 | 445 | // EEH_Debug_Tools::instance()->start_timer( '_table_is_changed_in_this_version' . $table_name ); |
446 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( false ) ); |
|
446 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false)); |
|
447 | 447 | // EEH_Debug_Tools::instance()->stop_timer( '_table_is_changed_in_this_version' . $table_name ); |
448 | 448 | } |
449 | 449 | |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | * @param string $table_name |
455 | 455 | * @return boolean |
456 | 456 | */ |
457 | - protected function _old_table_exists( $table_name ) { |
|
458 | - return $this->_get_table_analysis()->tableExists( $table_name ); |
|
457 | + protected function _old_table_exists($table_name) { |
|
458 | + return $this->_get_table_analysis()->tableExists($table_name); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | * @param string $table_name |
466 | 466 | * @return boolean |
467 | 467 | */ |
468 | - protected function _delete_table_if_empty( $table_name ) { |
|
469 | - return EEH_Activation::delete_db_table_if_empty( $table_name ); |
|
468 | + protected function _delete_table_if_empty($table_name) { |
|
469 | + return EEH_Activation::delete_db_table_if_empty($table_name); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | |
@@ -485,9 +485,9 @@ discard block |
||
485 | 485 | * @param string $table_definition_sql |
486 | 486 | * @param string $engine_string |
487 | 487 | */ |
488 | - protected function _table_should_exist_previously($table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){ |
|
488 | + protected function _table_should_exist_previously($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') { |
|
489 | 489 | // EEH_Debug_Tools::instance()->start_timer( '_table_should_exist_previously' . $table_name ); |
490 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( false ) ); |
|
490 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false)); |
|
491 | 491 | // EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name ); |
492 | 492 | } |
493 | 493 | |
@@ -502,13 +502,13 @@ discard block |
||
502 | 502 | * @param string $table_definition_sql |
503 | 503 | * @param string $engine_string |
504 | 504 | */ |
505 | - protected function _table_has_not_changed_since_previous( $table_name,$table_definition_sql,$engine_string = 'ENGINE=MyISAM'){ |
|
506 | - if( $this->_currently_migrating() ) { |
|
505 | + protected function _table_has_not_changed_since_previous($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM') { |
|
506 | + if ($this->_currently_migrating()) { |
|
507 | 507 | //if we're doing a migration, and this table apparently already exists, then we don't need do anything right? |
508 | 508 | // EEH_Debug_Tools::instance()->stop_timer( '_table_should_exist_previously' . $table_name ); |
509 | 509 | return; |
510 | 510 | } |
511 | - $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped( false ) ); |
|
511 | + $this->_create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string, $this->_pre_existing_table_should_be_dropped(false)); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | /** |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | protected function _currently_migrating() { |
519 | 519 | //we want to know if we are currently performing a migration. We could just believe what was set on the _migrating property, but let's double-check (ie the script should apply and we should be in MM) |
520 | 520 | return $this->_migrating && |
521 | - $this->can_migrate_from_version( EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set() ) && |
|
521 | + $this->can_migrate_from_version(EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set()) && |
|
522 | 522 | EE_Maintenance_Mode::instance()->real_level() == EE_Maintenance_Mode::level_2_complete_maintenance; |
523 | 523 | } |
524 | 524 | |
@@ -529,17 +529,17 @@ discard block |
||
529 | 529 | * @param boolean $table_is_new |
530 | 530 | * @return boolean |
531 | 531 | */ |
532 | - protected function _pre_existing_table_should_be_dropped( $table_is_new ) { |
|
533 | - if( $table_is_new ) { |
|
534 | - if( $this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation || $this->_currently_migrating() ){ |
|
532 | + protected function _pre_existing_table_should_be_dropped($table_is_new) { |
|
533 | + if ($table_is_new) { |
|
534 | + if ($this->_get_req_type_for_plugin_corresponding_to_this_dms() == EE_System::req_type_new_activation || $this->_currently_migrating()) { |
|
535 | 535 | return true; |
536 | - }else{ |
|
536 | + } else { |
|
537 | 537 | return false; |
538 | 538 | } |
539 | - }else{ |
|
540 | - if(in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(),array(EE_System::req_type_new_activation))){ |
|
539 | + } else { |
|
540 | + if (in_array($this->_get_req_type_for_plugin_corresponding_to_this_dms(), array(EE_System::req_type_new_activation))) { |
|
541 | 541 | return true; |
542 | - }else{ |
|
542 | + } else { |
|
543 | 543 | return false; |
544 | 544 | } |
545 | 545 | } |
@@ -552,12 +552,12 @@ discard block |
||
552 | 552 | * @param string $engine_string |
553 | 553 | * @param boolean $drop_pre_existing_tables |
554 | 554 | */ |
555 | - private function _create_table_and_catch_errors( $table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE ){ |
|
556 | - try{ |
|
557 | - EEH_Activation::create_table($table_name,$table_definition_sql, $engine_string, $drop_pre_existing_tables); |
|
558 | - }catch( EE_Error $e ) { |
|
559 | - $message = $e->getMessage() . '<br>Stack Trace:' . $e->getTraceAsString(); |
|
560 | - $this->add_error( $message ); |
|
555 | + private function _create_table_and_catch_errors($table_name, $table_definition_sql, $engine_string = 'ENGINE=MyISAM', $drop_pre_existing_tables = FALSE) { |
|
556 | + try { |
|
557 | + EEH_Activation::create_table($table_name, $table_definition_sql, $engine_string, $drop_pre_existing_tables); |
|
558 | + } catch (EE_Error $e) { |
|
559 | + $message = $e->getMessage().'<br>Stack Trace:'.$e->getTraceAsString(); |
|
560 | + $this->add_error($message); |
|
561 | 561 | $this->_feedback_message .= $message; |
562 | 562 | } |
563 | 563 | } |
@@ -569,15 +569,15 @@ discard block |
||
569 | 569 | * @return int one of EE_System::_req_type_* constants |
570 | 570 | * @throws EE_Error |
571 | 571 | */ |
572 | - private function _get_req_type_for_plugin_corresponding_to_this_dms(){ |
|
573 | - if($this->slug() == 'Core'){ |
|
572 | + private function _get_req_type_for_plugin_corresponding_to_this_dms() { |
|
573 | + if ($this->slug() == 'Core') { |
|
574 | 574 | return EE_System::instance()->detect_req_type(); |
575 | - }else{//it must be for an addon |
|
575 | + } else {//it must be for an addon |
|
576 | 576 | $addon_name = $this->slug(); |
577 | - if( EE_Registry::instance()->get_addon_by_name($addon_name)){ |
|
577 | + if (EE_Registry::instance()->get_addon_by_name($addon_name)) { |
|
578 | 578 | return EE_Registry::instance()->get_addon_by_name($addon_name)->detect_req_type(); |
579 | - }else{ |
|
580 | - throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"),$this->slug(),$addon_name,implode(",",array_keys( EE_Registry::instance()->get_addons_by_name() ) ) ) ) ; |
|
579 | + } else { |
|
580 | + throw new EE_Error(sprintf(__("The DMS slug '%s' should correspond to the addon's name, which should also be '%s', but no such addon was registered. These are the registered addons' names: %s", "event_espresso"), $this->slug(), $addon_name, implode(",", array_keys(EE_Registry::instance()->get_addons_by_name())))); |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | } |
@@ -588,13 +588,13 @@ discard block |
||
588 | 588 | * returns an array of strings describing errors by all the script's stages |
589 | 589 | * @return array |
590 | 590 | */ |
591 | - public function get_errors(){ |
|
591 | + public function get_errors() { |
|
592 | 592 | $all_errors = $this->_errors; |
593 | - if( ! is_array($all_errors)){ |
|
593 | + if ( ! is_array($all_errors)) { |
|
594 | 594 | $all_errors = array(); |
595 | 595 | } |
596 | - foreach($this->stages() as $stage){ |
|
597 | - $all_errors = array_merge($stage->get_errors(),$all_errors); |
|
596 | + foreach ($this->stages() as $stage) { |
|
597 | + $all_errors = array_merge($stage->get_errors(), $all_errors); |
|
598 | 598 | } |
599 | 599 | return $all_errors; |
600 | 600 | } |
@@ -605,8 +605,8 @@ discard block |
||
605 | 605 | * Indicates whether or not this migration script should continue |
606 | 606 | * @return boolean |
607 | 607 | */ |
608 | - public function can_continue(){ |
|
609 | - return in_array($this->get_status(), EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script); |
|
608 | + public function can_continue() { |
|
609 | + return in_array($this->get_status(), EE_Data_Migration_Manager::instance()->stati_that_indicate_to_continue_single_migration_script); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
@@ -618,8 +618,8 @@ discard block |
||
618 | 618 | * get ordered by the indexes |
619 | 619 | * @return EE_Data_Migration_Script_Stage[] |
620 | 620 | */ |
621 | - protected function stages(){ |
|
622 | - $stages = apply_filters( 'FHEE__'.get_class($this).'__stages',$this->_migration_stages ); |
|
621 | + protected function stages() { |
|
622 | + $stages = apply_filters('FHEE__'.get_class($this).'__stages', $this->_migration_stages); |
|
623 | 623 | ksort($stages); |
624 | 624 | return $stages; |
625 | 625 | } |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | * can be displayed to the user |
632 | 632 | * @return string |
633 | 633 | */ |
634 | - public function get_feedback_message(){ |
|
634 | + public function get_feedback_message() { |
|
635 | 635 | return $this->_feedback_message; |
636 | 636 | } |
637 | 637 | |
@@ -643,16 +643,16 @@ discard block |
||
643 | 643 | * possible that this class is defined when it goes to sleep, but NOT available when it |
644 | 644 | * awakes (eg, this class is part of an addon that is deactivated at some point). |
645 | 645 | */ |
646 | - public function properties_as_array(){ |
|
646 | + public function properties_as_array() { |
|
647 | 647 | $properties = parent::properties_as_array(); |
648 | 648 | $properties['_migration_stages'] = array(); |
649 | - foreach($this->_migration_stages as $migration_stage_priority => $migration_stage_class){ |
|
649 | + foreach ($this->_migration_stages as $migration_stage_priority => $migration_stage_class) { |
|
650 | 650 | $properties['_migration_stages'][$migration_stage_priority] = $migration_stage_class->properties_as_array(); |
651 | 651 | } |
652 | 652 | unset($properties['_mappings']); |
653 | 653 | |
654 | - foreach($this->_mappings as $old_table_name => $mapping_to_new_table){ |
|
655 | - foreach($mapping_to_new_table as $new_table_name => $mapping){ |
|
654 | + foreach ($this->_mappings as $old_table_name => $mapping_to_new_table) { |
|
655 | + foreach ($mapping_to_new_table as $new_table_name => $mapping) { |
|
656 | 656 | $this->_set_mapping_option($old_table_name, $new_table_name, $mapping); |
657 | 657 | } |
658 | 658 | } |
@@ -667,19 +667,19 @@ discard block |
||
667 | 667 | * @param array $array_of_properties like what's produced from properties_as_array() method |
668 | 668 | * @return void |
669 | 669 | */ |
670 | - public function instantiate_from_array_of_properties($array_of_properties){ |
|
670 | + public function instantiate_from_array_of_properties($array_of_properties) { |
|
671 | 671 | $stages_properties_arrays = $array_of_properties['_migration_stages']; |
672 | 672 | unset($array_of_properties['_migration_stages']); |
673 | 673 | unset($array_of_properties['class']); |
674 | - foreach($array_of_properties as $property_name => $property_value){ |
|
674 | + foreach ($array_of_properties as $property_name => $property_value) { |
|
675 | 675 | $this->{$property_name} = $property_value; |
676 | 676 | } |
677 | 677 | //_migration_stages are already instantiated, but have only default data |
678 | - foreach($this->_migration_stages as $stage){ |
|
679 | - $stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage),$stages_properties_arrays); |
|
678 | + foreach ($this->_migration_stages as $stage) { |
|
679 | + $stage_data = $this->_find_migration_stage_data_with_classname(get_class($stage), $stages_properties_arrays); |
|
680 | 680 | //SO, if we found the stage data that was saved, use it. Otherwise, I guess the stage is new? (maybe added by |
681 | 681 | //an addon? Unlikely... not sure why it wouldn't exist, but if it doesn't just treat it like it was never started yet) |
682 | - if($stage_data){ |
|
682 | + if ($stage_data) { |
|
683 | 683 | $stage->instantiate_from_array_of_properties($stage_data); |
684 | 684 | } |
685 | 685 | } |
@@ -695,9 +695,9 @@ discard block |
||
695 | 695 | * @param array $migration_stage_data_arrays |
696 | 696 | * @return null |
697 | 697 | */ |
698 | - private function _find_migration_stage_data_with_classname($classname,$migration_stage_data_arrays){ |
|
699 | - foreach($migration_stage_data_arrays as $migration_stage_data_array){ |
|
700 | - if(isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname){ |
|
698 | + private function _find_migration_stage_data_with_classname($classname, $migration_stage_data_arrays) { |
|
699 | + foreach ($migration_stage_data_arrays as $migration_stage_data_array) { |
|
700 | + if (isset($migration_stage_data_array['class']) && $migration_stage_data_array['class'] == $classname) { |
|
701 | 701 | return $migration_stage_data_array; |
702 | 702 | } |
703 | 703 | } |
@@ -713,8 +713,8 @@ discard block |
||
713 | 713 | * @return array where the first key is the plugin's slug, the 2nd is the version of that plugin |
714 | 714 | * that will be updated to. Eg array('Core','4.1.0') |
715 | 715 | */ |
716 | - public final function migrates_to_version(){ |
|
717 | - return EE_Data_Migration_Manager::instance()->script_migrates_to_version( get_class( $this ) ); |
|
716 | + public final function migrates_to_version() { |
|
717 | + return EE_Data_Migration_Manager::instance()->script_migrates_to_version(get_class($this)); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | |
@@ -726,10 +726,10 @@ discard block |
||
726 | 726 | * Or 'Core' for core (non-addon). |
727 | 727 | * @return string |
728 | 728 | */ |
729 | - public function slug(){ |
|
729 | + public function slug() { |
|
730 | 730 | $migrates_to_version_info = $this->migrates_to_version(); |
731 | 731 | //the slug is the first part of the array |
732 | - return $migrates_to_version_info[ 'slug' ]; |
|
732 | + return $migrates_to_version_info['slug']; |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | * the database up so it can run), then you can set "A" to priority 3 or something. |
744 | 744 | * @return int |
745 | 745 | */ |
746 | - public function priority(){ |
|
746 | + public function priority() { |
|
747 | 747 | return $this->_priority; |
748 | 748 | } |
749 | 749 | |
@@ -756,18 +756,18 @@ discard block |
||
756 | 756 | * @param boolean $migrating |
757 | 757 | * @return void |
758 | 758 | */ |
759 | - public function set_migrating( $migrating = TRUE ){ |
|
759 | + public function set_migrating($migrating = TRUE) { |
|
760 | 760 | $this->_migrating = $migrating; |
761 | 761 | } |
762 | 762 | |
763 | 763 | /** |
764 | 764 | * Marks that we think this migration class can continue to migrate |
765 | 765 | */ |
766 | - public function reattempt(){ |
|
766 | + public function reattempt() { |
|
767 | 767 | parent::reattempt(); |
768 | 768 | //also, we want to reattempt any stages that were marked as borked |
769 | - foreach( $this->stages() as $stage ) { |
|
770 | - if( $stage->is_broken() ) { |
|
769 | + foreach ($this->stages() as $stage) { |
|
770 | + if ($stage->is_broken()) { |
|
771 | 771 | $stage->reattempt(); |
772 | 772 | } |
773 | 773 | } |
@@ -106,32 +106,32 @@ discard block |
||
106 | 106 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). |
107 | 107 | * Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
108 | 108 | */ |
109 | - protected function __construct( $timezone = null ) { |
|
110 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
111 | - $this->singular_item = __('Registration','event_espresso'); |
|
112 | - $this->plural_item = __('Registrations','event_espresso'); |
|
109 | + protected function __construct($timezone = null) { |
|
110 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
111 | + $this->singular_item = __('Registration', 'event_espresso'); |
|
112 | + $this->plural_item = __('Registrations', 'event_espresso'); |
|
113 | 113 | |
114 | 114 | $this->_tables = array( |
115 | - 'Registration'=>new EE_Primary_Table('esp_registration','REG_ID') |
|
115 | + 'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID') |
|
116 | 116 | ); |
117 | 117 | $this->_fields = array( |
118 | 118 | 'Registration'=>array( |
119 | - 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')), |
|
120 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
121 | - 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'), |
|
122 | - 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'), |
|
123 | - 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'), |
|
124 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
125 | - 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
126 | - 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total','event_espresso'), false, 0), |
|
127 | - 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration','event_espresso'), false, 0), |
|
128 | - 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''), |
|
129 | - 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''), |
|
130 | - 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''), |
|
131 | - 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1), |
|
132 | - 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1), |
|
133 | - 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false), |
|
134 | - 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false ) |
|
119 | + 'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')), |
|
120 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
121 | + 'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'), |
|
122 | + 'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'), |
|
123 | + 'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'), |
|
124 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'), |
|
125 | + 'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
126 | + 'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total', 'event_espresso'), false, 0), |
|
127 | + 'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration', 'event_espresso'), false, 0), |
|
128 | + 'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''), |
|
129 | + 'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''), |
|
130 | + 'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''), |
|
131 | + 'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1), |
|
132 | + 'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1), |
|
133 | + 'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false), |
|
134 | + 'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false) |
|
135 | 135 | ) |
136 | 136 | ); |
137 | 137 | $this->_model_relations = array( |
@@ -143,12 +143,12 @@ discard block |
||
143 | 143 | 'Answer'=>new EE_Has_Many_Relation(), |
144 | 144 | 'Checkin'=>new EE_Has_Many_Relation(), |
145 | 145 | 'Registration_Payment' => new EE_Has_Many_Relation(), |
146 | - 'Payment'=>new EE_HABTM_Relation( 'Registration_Payment' ), |
|
147 | - 'Message' => new EE_Has_Many_Any_Relation( false ) //allow deletes even if there are messages in the queue related |
|
146 | + 'Payment'=>new EE_HABTM_Relation('Registration_Payment'), |
|
147 | + 'Message' => new EE_Has_Many_Any_Relation(false) //allow deletes even if there are messages in the queue related |
|
148 | 148 | ); |
149 | 149 | $this->_model_chain_to_wp_user = 'Event'; |
150 | 150 | |
151 | - parent::__construct( $timezone ); |
|
151 | + parent::__construct($timezone); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | * @param bool $translated If true will return the values as singular localized strings |
244 | 244 | * @return array |
245 | 245 | */ |
246 | - public static function reg_status_array( $exclude = array(), $translated = FALSE ) { |
|
247 | - EEM_Registration::instance()->_get_registration_status_array( $exclude ); |
|
248 | - return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
246 | + public static function reg_status_array($exclude = array(), $translated = FALSE) { |
|
247 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
248 | + return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -256,18 +256,18 @@ discard block |
||
256 | 256 | * @param array $exclude |
257 | 257 | * @return array |
258 | 258 | */ |
259 | - private function _get_registration_status_array( $exclude = array() ) { |
|
259 | + private function _get_registration_status_array($exclude = array()) { |
|
260 | 260 | //in the very rare circumstance that we are deleting a model's table's data |
261 | 261 | //and the table hasn't actually been created, this could have an error |
262 | 262 | /** @type WPDB $wpdb */ |
263 | 263 | global $wpdb; |
264 | - if( $this->_get_table_analysis()->tableExists( $wpdb->prefix . 'esp_status' ) ){ |
|
265 | - $SQL = 'SELECT STS_ID, STS_code FROM '. $wpdb->prefix . 'esp_status WHERE STS_type = "registration"'; |
|
266 | - $results = $wpdb->get_results( $SQL ); |
|
264 | + if ($this->_get_table_analysis()->tableExists($wpdb->prefix.'esp_status')) { |
|
265 | + $SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"'; |
|
266 | + $results = $wpdb->get_results($SQL); |
|
267 | 267 | self::$_reg_status = array(); |
268 | - foreach ( $results as $status ) { |
|
269 | - if ( ! in_array( $status->STS_ID, $exclude )) { |
|
270 | - self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
268 | + foreach ($results as $status) { |
|
269 | + if ( ! in_array($status->STS_ID, $exclude)) { |
|
270 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | } |
@@ -280,13 +280,13 @@ discard block |
||
280 | 280 | * @throws \EE_Error |
281 | 281 | */ |
282 | 282 | protected function _get_table_analysis() { |
283 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
283 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
284 | 284 | return $this->_table_analysis; |
285 | 285 | } else { |
286 | 286 | throw new \EE_Error( |
287 | 287 | sprintf( |
288 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
289 | - get_class( $this ) |
|
288 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
289 | + get_class($this) |
|
290 | 290 | ) |
291 | 291 | ); |
292 | 292 | } |
@@ -301,15 +301,15 @@ discard block |
||
301 | 301 | * @return array |
302 | 302 | * @throws \EE_Error |
303 | 303 | */ |
304 | - public function get_reg_months_and_years( $where_params ) { |
|
304 | + public function get_reg_months_and_years($where_params) { |
|
305 | 305 | $query_params[0] = $where_params; |
306 | 306 | $query_params['group_by'] = array('reg_year', 'reg_month'); |
307 | - $query_params['order_by'] = array( 'REG_date' => 'DESC' ); |
|
307 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
308 | 308 | $columns_to_select = array( |
309 | 309 | 'reg_year' => array('YEAR(REG_date)', '%s'), |
310 | 310 | 'reg_month' => array('MONTHNAME(REG_date)', '%s') |
311 | 311 | ); |
312 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
312 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | * @param int $ATT_ID |
322 | 322 | * @return EE_Registration[] |
323 | 323 | */ |
324 | - public function get_all_registrations_for_attendee( $ATT_ID = 0 ) { |
|
325 | - if ( ! $ATT_ID ) { |
|
324 | + public function get_all_registrations_for_attendee($ATT_ID = 0) { |
|
325 | + if ( ! $ATT_ID) { |
|
326 | 326 | return FALSE; |
327 | 327 | } |
328 | - return $this->get_all( array( array( 'ATT_ID' => $ATT_ID ))); |
|
328 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * @param string $REG_url_link |
337 | 337 | * @return EE_Registration |
338 | 338 | */ |
339 | - public function get_registration_for_reg_url_link($REG_url_link){ |
|
340 | - if(!$REG_url_link){ |
|
339 | + public function get_registration_for_reg_url_link($REG_url_link) { |
|
340 | + if ( ! $REG_url_link) { |
|
341 | 341 | return false; |
342 | 342 | } |
343 | 343 | return $this->get_one(array(array('REG_url_link'=>$REG_url_link))); |
@@ -355,13 +355,13 @@ discard block |
||
355 | 355 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required |
356 | 356 | * @return mixed array on success, FALSE on fail |
357 | 357 | */ |
358 | - public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) { |
|
358 | + public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) { |
|
359 | 359 | return $this->get_one(array( |
360 | 360 | array( |
361 | 361 | 'TXN_ID'=>$TXN_ID, |
362 | 362 | 'ATT_ID'=>$ATT_ID |
363 | 363 | ), |
364 | - 'limit'=>array( min( ( $att_nmbr-1 ), 0 ), 1 ) |
|
364 | + 'limit'=>array(min(($att_nmbr - 1), 0), 1) |
|
365 | 365 | )); |
366 | 366 | } |
367 | 367 | |
@@ -373,16 +373,16 @@ discard block |
||
373 | 373 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
374 | 374 | * @return stdClass[] with properties regDate and total |
375 | 375 | */ |
376 | - public function get_registrations_per_day_report( $period = '-1 month' ) { |
|
376 | + public function get_registrations_per_day_report($period = '-1 month') { |
|
377 | 377 | |
378 | - $sql_date = $this->convert_datetime_for_query( 'REG_date', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' ); |
|
379 | - $where = array( 'REG_date' => array( '>=', $sql_date ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
378 | + $sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
379 | + $where = array('REG_date' => array('>=', $sql_date), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
380 | 380 | |
381 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) { |
|
381 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
382 | 382 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
383 | 383 | } |
384 | 384 | |
385 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'REG_date' ); |
|
385 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
386 | 386 | |
387 | 387 | $results = $this->_get_all_wpdb_results( |
388 | 388 | array( |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | ), |
393 | 393 | OBJECT, |
394 | 394 | array( |
395 | - 'regDate'=>array( 'DATE(' . $query_interval . ')','%s'), |
|
396 | - 'total'=>array('count(REG_ID)','%d') |
|
395 | + 'regDate'=>array('DATE('.$query_interval.')', '%s'), |
|
396 | + 'total'=>array('count(REG_ID)', '%d') |
|
397 | 397 | )); |
398 | 398 | return $results; |
399 | 399 | } |
@@ -408,22 +408,22 @@ discard block |
||
408 | 408 | * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
409 | 409 | * (i.e. RAP) |
410 | 410 | */ |
411 | - public function get_registrations_per_day_and_per_status_report( $period = '-1 month' ) { |
|
411 | + public function get_registrations_per_day_and_per_status_report($period = '-1 month') { |
|
412 | 412 | global $wpdb; |
413 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
413 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
414 | 414 | $event_table = $wpdb->posts; |
415 | - $sql_date = date("Y-m-d H:i:s", strtotime($period) ); |
|
415 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
416 | 416 | |
417 | 417 | //prepare the query interval for displaying offset |
418 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'dates.REG_date' ); |
|
418 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
|
419 | 419 | |
420 | 420 | //inner date query |
421 | 421 | $inner_date_query = "SELECT DISTINCT REG_date from $registration_table "; |
422 | 422 | $inner_where = " WHERE"; |
423 | 423 | //exclude events not authored by user if permissions in effect |
424 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
424 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
425 | 425 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
426 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
426 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
427 | 427 | } |
428 | 428 | $inner_where .= " REG_date >= '$sql_date'"; |
429 | 429 | $inner_date_query .= $inner_where; |
@@ -435,8 +435,8 @@ discard block |
||
435 | 435 | $select_parts = array(); |
436 | 436 | |
437 | 437 | //loop through registration stati to do parts for each status. |
438 | - foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) { |
|
439 | - if ( $STS_ID === EEM_Registration::status_id_incomplete ) { |
|
438 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
439 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
440 | 440 | continue; |
441 | 441 | } |
442 | 442 | $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
@@ -444,14 +444,14 @@ discard block |
||
444 | 444 | } |
445 | 445 | |
446 | 446 | //setup the selects |
447 | - $select .= implode(', ', $select_parts ); |
|
447 | + $select .= implode(', ', $select_parts); |
|
448 | 448 | $select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
449 | 449 | |
450 | 450 | //setup the joins |
451 | - $join .= implode( " LEFT JOIN ", $join_parts ); |
|
451 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
452 | 452 | |
453 | 453 | //now let's put it all together |
454 | - $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
454 | + $query = $select.$join.' GROUP BY Registration_REG_date'; |
|
455 | 455 | |
456 | 456 | //and execute it |
457 | 457 | $results = $wpdb->get_results( |
@@ -472,23 +472,23 @@ discard block |
||
472 | 472 | * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
473 | 473 | * @return stdClass[] each with properties event_name, reg_limit, and total |
474 | 474 | */ |
475 | - public function get_registrations_per_event_report( $period = '-1 month' ) { |
|
475 | + public function get_registrations_per_event_report($period = '-1 month') { |
|
476 | 476 | |
477 | - $date_sql = $this->convert_datetime_for_query( 'REG_date', date( "Y-m-d H:i:s", strtotime( $period )), 'Y-m-d H:i:s', 'UTC' ); |
|
478 | - $where = array( 'REG_date' => array( '>=', $date_sql ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ); |
|
477 | + $date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
478 | + $where = array('REG_date' => array('>=', $date_sql), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)); |
|
479 | 479 | |
480 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
480 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
481 | 481 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
482 | 482 | } |
483 | 483 | $results = $this->_get_all_wpdb_results(array( |
484 | 484 | $where, |
485 | 485 | 'group_by'=>'Event.EVT_name', |
486 | 486 | 'order_by'=>'Event.EVT_name', |
487 | - 'limit'=>array(0,24)), |
|
487 | + 'limit'=>array(0, 24)), |
|
488 | 488 | OBJECT, |
489 | 489 | array( |
490 | - 'event_name'=>array('Event_CPT.post_title','%s'), |
|
491 | - 'total'=>array('COUNT(REG_ID)','%s') |
|
490 | + 'event_name'=>array('Event_CPT.post_title', '%s'), |
|
491 | + 'total'=>array('COUNT(REG_ID)', '%s') |
|
492 | 492 | ) |
493 | 493 | ); |
494 | 494 | |
@@ -506,19 +506,19 @@ discard block |
||
506 | 506 | * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
507 | 507 | * (i.e. RAP) |
508 | 508 | */ |
509 | - public function get_registrations_per_event_and_per_status_report( $period = '-1 month' ) { |
|
509 | + public function get_registrations_per_event_and_per_status_report($period = '-1 month') { |
|
510 | 510 | global $wpdb; |
511 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
511 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
512 | 512 | $event_table = $wpdb->posts; |
513 | - $sql_date = date("Y-m-d H:i:s", strtotime($period) ); |
|
513 | + $sql_date = date("Y-m-d H:i:s", strtotime($period)); |
|
514 | 514 | |
515 | 515 | //inner date query |
516 | 516 | $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
517 | 517 | $inner_where = " WHERE"; |
518 | 518 | //exclude events not authored by user if permissions in effect |
519 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) { |
|
519 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
520 | 520 | $inner_date_query .= "LEFT JOIN $event_table ON ID = EVT_ID"; |
521 | - $inner_where .= " post_author = " . get_current_user_id() . " AND"; |
|
521 | + $inner_where .= " post_author = ".get_current_user_id()." AND"; |
|
522 | 522 | } |
523 | 523 | $inner_where .= " REG_date >= '$sql_date'"; |
524 | 524 | $inner_date_query .= $inner_where; |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | $select_parts = array(); |
531 | 531 | |
532 | 532 | //loop through registration stati to do parts for each status. |
533 | - foreach ( EEM_Registration::reg_status_array() as $STS_ID => $STS_code ) { |
|
534 | - if ( $STS_ID === EEM_Registration::status_id_incomplete ) { |
|
533 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
534 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
535 | 535 | continue; |
536 | 536 | } |
537 | 537 | $select_parts[] = "COUNT($STS_code.REG_ID) as $STS_ID"; |
@@ -539,14 +539,14 @@ discard block |
||
539 | 539 | } |
540 | 540 | |
541 | 541 | //setup the selects |
542 | - $select .= implode( ', ', $select_parts ); |
|
542 | + $select .= implode(', ', $select_parts); |
|
543 | 543 | $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
544 | 544 | |
545 | 545 | //setup remaining joins |
546 | - $join .= implode( " LEFT JOIN ", $join_parts ); |
|
546 | + $join .= implode(" LEFT JOIN ", $join_parts); |
|
547 | 547 | |
548 | 548 | //now put it all together |
549 | - $query = $select . $join . ' GROUP BY Registration_Event'; |
|
549 | + $query = $select.$join.' GROUP BY Registration_Event'; |
|
550 | 550 | |
551 | 551 | //and execute |
552 | 552 | $results = $wpdb->get_results( |
@@ -562,11 +562,11 @@ discard block |
||
562 | 562 | * @param int $TXN_ID |
563 | 563 | * @return EE_Registration |
564 | 564 | */ |
565 | - public function get_primary_registration_for_transaction_ID( $TXN_ID = 0){ |
|
566 | - if( ! $TXN_ID ){ |
|
565 | + public function get_primary_registration_for_transaction_ID($TXN_ID = 0) { |
|
566 | + if ( ! $TXN_ID) { |
|
567 | 567 | return false; |
568 | 568 | } |
569 | - return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
569 | + return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=> EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | |
@@ -578,11 +578,11 @@ discard block |
||
578 | 578 | * @param boolean $for_incomplete_payments |
579 | 579 | * @return int |
580 | 580 | */ |
581 | - public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) { |
|
581 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) { |
|
582 | 582 | // we only count approved registrations towards registration limits |
583 | - $query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) ); |
|
584 | - if( $for_incomplete_payments ){ |
|
585 | - $query_params[0]['Transaction.STS_ID']=array('!=', EEM_Transaction::complete_status_code); |
|
583 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
584 | + if ($for_incomplete_payments) { |
|
585 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | return $this->count($query_params); |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | /** @type WPDB $wpdb */ |
599 | 599 | global $wpdb; |
600 | 600 | return $wpdb->query( |
601 | - 'DELETE r FROM ' . $this->table() . ' r LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
601 | + 'DELETE r FROM '.$this->table().' r LEFT JOIN '.EEM_Transaction::instance()->table().' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' ); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | /** |
@@ -608,17 +608,17 @@ discard block |
||
608 | 608 | * @param boolean $checked_in whether to count registrations checked IN or OUT |
609 | 609 | * @return int |
610 | 610 | */ |
611 | - public function count_registrations_checked_into_datetime( $DTT_ID, $checked_in = true) { |
|
611 | + public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) { |
|
612 | 612 | global $wpdb; |
613 | 613 | //subquery to get latest checkin |
614 | 614 | $query = $wpdb->prepare( |
615 | 615 | 'SELECT ' |
616 | 616 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
617 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
617 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
618 | 618 | . '( SELECT ' |
619 | 619 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
620 | 620 | . 'REG_ID AS REG_ID ' |
621 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' ' |
|
621 | + . 'FROM '.EEM_Checkin::instance()->table().' ' |
|
622 | 622 | . 'WHERE DTT_ID=%d ' |
623 | 623 | . 'GROUP BY REG_ID' |
624 | 624 | . ') AS most_recent_checkin_per_reg ' |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | $DTT_ID, |
630 | 630 | $checked_in |
631 | 631 | ); |
632 | - return (int)$wpdb->get_var( $query ); |
|
632 | + return (int) $wpdb->get_var($query); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
@@ -639,18 +639,18 @@ discard block |
||
639 | 639 | * @param boolean $checked_in whether to count registrations checked IN or OUT |
640 | 640 | * @return int |
641 | 641 | */ |
642 | - public function count_registrations_checked_into_event( $EVT_ID, $checked_in = true ) { |
|
642 | + public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) { |
|
643 | 643 | global $wpdb; |
644 | 644 | //subquery to get latest checkin |
645 | 645 | $query = $wpdb->prepare( |
646 | 646 | 'SELECT ' |
647 | 647 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
648 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
648 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
649 | 649 | . '( SELECT ' |
650 | 650 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
651 | 651 | . 'REG_ID AS REG_ID ' |
652 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS c ' |
|
653 | - . 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d ' |
|
652 | + . 'FROM '.EEM_Checkin::instance()->table().' AS c ' |
|
653 | + . 'INNER JOIN '.EEM_Datetime::instance()->table().' AS d ' |
|
654 | 654 | . 'ON c.DTT_ID=d.DTT_ID ' |
655 | 655 | . 'WHERE d.EVT_ID=%d ' |
656 | 656 | . 'GROUP BY REG_ID' |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | $EVT_ID, |
663 | 663 | $checked_in |
664 | 664 | ); |
665 | - return (int)$wpdb->get_var( $query ); |
|
665 | + return (int) $wpdb->get_var($query); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | |
@@ -677,15 +677,15 @@ discard block |
||
677 | 677 | * @param array $attendee_ids |
678 | 678 | * @return EE_Registration[] |
679 | 679 | */ |
680 | - public function get_latest_registration_for_each_of_given_contacts( $attendee_ids = array() ) { |
|
680 | + public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) { |
|
681 | 681 | //first do a native wp_query to get the latest REG_ID's matching these attendees. |
682 | 682 | global $wpdb; |
683 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
683 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
684 | 684 | $attendee_table = $wpdb->posts; |
685 | - $attendee_ids = is_array( $attendee_ids ) |
|
686 | - ? array_map( 'absint', $attendee_ids ) |
|
687 | - : array( (int) $attendee_ids ); |
|
688 | - $attendee_ids = implode( ',', $attendee_ids ); |
|
685 | + $attendee_ids = is_array($attendee_ids) |
|
686 | + ? array_map('absint', $attendee_ids) |
|
687 | + : array((int) $attendee_ids); |
|
688 | + $attendee_ids = implode(',', $attendee_ids); |
|
689 | 689 | |
690 | 690 | |
691 | 691 | //first we do a query to get the registration ids |
@@ -710,24 +710,24 @@ discard block |
||
710 | 710 | ARRAY_A |
711 | 711 | ); |
712 | 712 | |
713 | - if ( empty( $registration_ids ) ) { |
|
713 | + if (empty($registration_ids)) { |
|
714 | 714 | return array(); |
715 | 715 | } |
716 | 716 | |
717 | 717 | $ids_for_model_query = array(); |
718 | 718 | //let's flatten the ids so they can be used in the model query. |
719 | - foreach ( $registration_ids as $registration_id ) { |
|
720 | - if ( isset( $registration_id['registration_id'] ) ) { |
|
719 | + foreach ($registration_ids as $registration_id) { |
|
720 | + if (isset($registration_id['registration_id'])) { |
|
721 | 721 | $ids_for_model_query[] = $registration_id['registration_id']; |
722 | 722 | } |
723 | 723 | } |
724 | 724 | |
725 | 725 | //construct query |
726 | 726 | $_where = array( |
727 | - 'REG_ID' => array( 'IN', $ids_for_model_query ) |
|
727 | + 'REG_ID' => array('IN', $ids_for_model_query) |
|
728 | 728 | ); |
729 | 729 | |
730 | - return $this->get_all( array( $_where ) ); |
|
730 | + return $this->get_all(array($_where)); |
|
731 | 731 | } |
732 | 732 | |
733 | 733 |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * @subpackage plugin api, messages |
6 | 6 | * @since 4.5.0 |
7 | 7 | */ |
8 | -if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
8 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
9 | + exit('No direct script access allowed'); |
|
10 | +} |
|
9 | 11 | |
10 | 12 | /** |
11 | 13 | * Use this to register or deregister a new message template pack variation for the EE messages system. |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\services\database\TableAnalysis; |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ){ |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | } |
6 | 6 | /** |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | 29 | //define some page related constants |
30 | - define( 'EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings' ); |
|
31 | - define( 'EE_PAYMENTS_ADMIN_URL', admin_url( 'admin.php?page=' . EE_PAYMENTS_PG_SLUG )); |
|
32 | - define( 'EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES . 'payments' . DS ); |
|
33 | - define( 'EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN . 'templates' . DS ); |
|
34 | - define( 'EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL . 'payments/assets/' ); |
|
35 | - $this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
|
30 | + define('EE_PAYMENTS_PG_SLUG', 'espresso_payment_settings'); |
|
31 | + define('EE_PAYMENTS_ADMIN_URL', admin_url('admin.php?page='.EE_PAYMENTS_PG_SLUG)); |
|
32 | + define('EE_PAYMENTS_ADMIN', EE_ADMIN_PAGES.'payments'.DS); |
|
33 | + define('EE_PAYMENTS_TEMPLATE_PATH', EE_PAYMENTS_ADMIN.'templates'.DS); |
|
34 | + define('EE_PAYMENTS_ASSETS_URL', EE_ADMIN_PAGES_URL.'payments/assets/'); |
|
35 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
36 | 36 | //check that there are active gateways on all admin page loads. but dont do it just yet |
37 | 37 | // echo "constructing payments admin page";die; |
38 | - add_action('admin_notices',array($this,'check_payment_gateway_setup')); |
|
38 | + add_action('admin_notices', array($this, 'check_payment_gateway_setup')); |
|
39 | 39 | parent::__construct(); |
40 | 40 | } |
41 | 41 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
59 | 59 | 'parent_slug' => 'espresso_events', |
60 | 60 | 'menu_slug' => EE_PAYMENTS_PG_SLUG, |
61 | - 'menu_label' => __( 'Payment Methods', 'event_espresso' ), |
|
61 | + 'menu_label' => __('Payment Methods', 'event_espresso'), |
|
62 | 62 | 'capability' => 'ee_manage_gateways', |
63 | 63 | 'admin_init_page' => $this, |
64 | 64 | ) |
@@ -72,25 +72,25 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @throws \EE_Error |
74 | 74 | */ |
75 | - public function check_payment_gateway_setup(){ |
|
75 | + public function check_payment_gateway_setup() { |
|
76 | 76 | //ONLY do this check if models can query |
77 | 77 | //and avoid a bug where when we nuke EE4's data that this causes a fatal error |
78 | 78 | //because the tables are deleted just before this request runs. see https://events.codebasehq.com/projects/event-espresso/tickets/7539 |
79 | 79 | if ( |
80 | 80 | ! EE_Maintenance_Mode::instance()->models_can_query() |
81 | - || ! $this->_get_table_analysis()->tableExists( EEM_Payment_Method::instance()->table() ) |
|
81 | + || ! $this->_get_table_analysis()->tableExists(EEM_Payment_Method::instance()->table()) |
|
82 | 82 | ) { |
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | 86 | |
87 | 87 | // ensure Payment_Method model is loaded |
88 | - EE_Registry::instance()->load_model( 'Payment_Method' ); |
|
89 | - $actives = EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ); |
|
90 | - if( $actives < 1 ){ |
|
88 | + EE_Registry::instance()->load_model('Payment_Method'); |
|
89 | + $actives = EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart); |
|
90 | + if ($actives < 1) { |
|
91 | 91 | $url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_PAYMENTS_ADMIN_URL); |
92 | 92 | echo '<div class="error"> |
93 | - <p>'. sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"),"<a href='$url'>","</a>").'</p> |
|
93 | + <p>'. sprintf(__("There are no Active Payment Methods setup for Event Espresso. Please %s activate at least one.%s", "event_espresso"), "<a href='$url'>", "</a>").'</p> |
|
94 | 94 | </div>'; |
95 | 95 | } |
96 | 96 | } |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | * @throws \EE_Error |
102 | 102 | */ |
103 | 103 | protected function _get_table_analysis() { |
104 | - if( $this->_table_analysis instanceof TableAnalysis ) { |
|
104 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
105 | 105 | return $this->_table_analysis; |
106 | 106 | } else { |
107 | 107 | throw new \EE_Error( |
108 | 108 | sprintf( |
109 | - __( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
110 | - get_class( $this ) |
|
109 | + __('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
110 | + get_class($this) |
|
111 | 111 | ) |
112 | 112 | ); |
113 | 113 | } |