@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | private function add_hooks() { |
| 40 | 40 | |
| 41 | 41 | // in case entry is edited (on admin or frontend) |
| 42 | - add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2); |
|
| 42 | + add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 ); |
|
| 43 | 43 | |
| 44 | 44 | // when using the User opt-in field, check on entry submission |
| 45 | 45 | add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 ); |
| 46 | 46 | |
| 47 | 47 | // process ajax approve entry requests |
| 48 | - add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved')); |
|
| 48 | + add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) ); |
|
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | |
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public static function get_entry_status( $entry, $value_or_label = 'label' ) { |
| 64 | 64 | |
| 65 | - $entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry ); |
|
| 65 | + $entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry ); |
|
| 66 | 66 | |
| 67 | 67 | $status = gform_get_meta( $entry_id, self::meta_key ); |
| 68 | 68 | |
| 69 | 69 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
| 70 | 70 | |
| 71 | - if( 'value' === $value_or_label ) { |
|
| 71 | + if ( 'value' === $value_or_label ) { |
|
| 72 | 72 | return $status; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -93,16 +93,16 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function ajax_update_approved() { |
| 95 | 95 | |
| 96 | - $form_id = intval( rgpost('form_id') ); |
|
| 96 | + $form_id = intval( rgpost( 'form_id' ) ); |
|
| 97 | 97 | |
| 98 | - $entry_id = GVCommon::get_entry_id( rgpost('entry_slug'), true ); |
|
| 98 | + $entry_id = GVCommon::get_entry_id( rgpost( 'entry_slug' ), true ); |
|
| 99 | 99 | |
| 100 | - $approval_status = rgpost('approved'); |
|
| 100 | + $approval_status = rgpost( 'approved' ); |
|
| 101 | 101 | |
| 102 | - $nonce = rgpost('nonce'); |
|
| 102 | + $nonce = rgpost( 'nonce' ); |
|
| 103 | 103 | |
| 104 | 104 | // Valid status |
| 105 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
| 105 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) { |
|
| 106 | 106 | |
| 107 | 107 | do_action( 'gravityview_log_error', __METHOD__ . ': Invalid approval status', $_POST ); |
| 108 | 108 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the `gravityview_moderate_entries` capability.' ); |
| 135 | 135 | |
| 136 | - $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') ); |
|
| 136 | + $result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) ); |
|
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @param $form array Gravity Forms form object |
| 167 | 167 | */ |
| 168 | 168 | public function after_submission( $entry, $form ) { |
| 169 | - $this->after_update_entry_update_approved_meta( $form , $entry['id'] ); |
|
| 169 | + $this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] ); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -180,18 +180,18 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) { |
| 182 | 182 | |
| 183 | - $approved_column = self::get_approved_column( $form['id'] ); |
|
| 183 | + $approved_column = self::get_approved_column( $form[ 'id' ] ); |
|
| 184 | 184 | |
| 185 | 185 | /** |
| 186 | 186 | * If the form doesn't contain the approve field, don't assume anything. |
| 187 | 187 | */ |
| 188 | - if( empty( $approved_column ) ) { |
|
| 188 | + if ( empty( $approved_column ) ) { |
|
| 189 | 189 | return; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $entry = GFAPI::get_entry( $entry_id ); |
| 193 | 193 | |
| 194 | - self::update_approved_meta( $entry_id, $entry[ (string)$approved_column ], $form['id'] ); |
|
| 194 | + self::update_approved_meta( $entry_id, $entry[ (string)$approved_column ], $form[ 'id' ] ); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $success = true; |
| 232 | 232 | foreach ( $entries as $entry_id ) { |
| 233 | - $update_success = self::update_approved( (int) $entry_id, $approved, $form_id, $approved_column_id ); |
|
| 233 | + $update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id ); |
|
| 234 | 234 | |
| 235 | 235 | if ( ! $update_success ) { |
| 236 | 236 | $success = false; |
@@ -256,12 +256,12 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | public static function update_approved( $entry_id = 0, $approved = 0, $form_id = 0, $approvedcolumn = 0 ) { |
| 258 | 258 | |
| 259 | - if( !class_exists( 'GFAPI' ) ) { |
|
| 259 | + if ( ! class_exists( 'GFAPI' ) ) { |
|
| 260 | 260 | do_action( 'gravityview_log_error', __METHOD__ . 'GFAPI does not exist' ); |
| 261 | 261 | return false; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
| 264 | + if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) { |
|
| 265 | 265 | do_action( 'gravityview_log_error', __METHOD__ . ': Not a valid approval value.' ); |
| 266 | 266 | return false; |
| 267 | 267 | } |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | // If the form has an Approve/Reject field, update that value |
| 279 | 279 | $result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn ); |
| 280 | 280 | |
| 281 | - if( is_wp_error( $result ) ) { |
|
| 281 | + if ( is_wp_error( $result ) ) { |
|
| 282 | 282 | do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - Entry approval not updated: %s', $result->get_error_message() ) ); |
| 283 | 283 | return false; |
| 284 | 284 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | |
| 291 | 291 | // add note to entry if approval field updating worked or there was no approved field |
| 292 | 292 | // There's no validation for the meta |
| 293 | - if( true === $result ) { |
|
| 293 | + if ( true === $result ) { |
|
| 294 | 294 | |
| 295 | 295 | // Add an entry note |
| 296 | 296 | self::add_approval_status_updated_note( $entry_id, $approved ); |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | $note_id = false; |
| 345 | 345 | |
| 346 | - if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
| 346 | + if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) { |
|
| 347 | 347 | |
| 348 | 348 | $current_user = wp_get_current_user(); |
| 349 | 349 | |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | */ |
| 366 | 366 | private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) { |
| 367 | 367 | |
| 368 | - if( empty( $approvedcolumn ) ) { |
|
| 368 | + if ( empty( $approvedcolumn ) ) { |
|
| 369 | 369 | $approvedcolumn = self::get_approved_column( $form_id ); |
| 370 | 370 | } |
| 371 | 371 | |
@@ -413,16 +413,16 @@ discard block |
||
| 413 | 413 | private static function update_approved_meta( $entry_id, $status, $form_id = 0 ) { |
| 414 | 414 | |
| 415 | 415 | if ( ! GravityView_Entry_Approval_Status::is_valid( $status ) ) { |
| 416 | - do_action('gravityview_log_error', __METHOD__ . ': $is_approved not valid value', $status ); |
|
| 416 | + do_action( 'gravityview_log_error', __METHOD__ . ': $is_approved not valid value', $status ); |
|
| 417 | 417 | return; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | $status = GravityView_Entry_Approval_Status::maybe_convert_status( $status ); |
| 421 | 421 | |
| 422 | 422 | // update entry meta |
| 423 | - if( function_exists('gform_update_meta') ) { |
|
| 423 | + if ( function_exists( 'gform_update_meta' ) ) { |
|
| 424 | 424 | |
| 425 | - if( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) { |
|
| 425 | + if ( GravityView_Entry_Approval_Status::is_unapproved( $status ) ) { |
|
| 426 | 426 | gform_delete_meta( $entry_id, self::meta_key ); |
| 427 | 427 | } else { |
| 428 | 428 | gform_update_meta( $entry_id, self::meta_key, $status, $form_id ); |
@@ -445,11 +445,11 @@ discard block |
||
| 445 | 445 | * @since 1.18 Added "unapproved" |
| 446 | 446 | * @param int $entry_id ID of the Gravity Forms entry |
| 447 | 447 | */ |
| 448 | - do_action( 'gravityview/approve_entries/' . $action , $entry_id ); |
|
| 448 | + do_action( 'gravityview/approve_entries/' . $action, $entry_id ); |
|
| 449 | 449 | |
| 450 | 450 | } else { |
| 451 | 451 | |
| 452 | - do_action('gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
| 452 | + do_action( 'gravityview_log_error', __METHOD__ . ' - `gform_update_meta` does not exist.' ); |
|
| 453 | 453 | |
| 454 | 454 | } |
| 455 | 455 | } |
@@ -464,29 +464,29 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | static public function get_approved_column( $form ) { |
| 466 | 466 | |
| 467 | - if( empty( $form ) ) { |
|
| 467 | + if ( empty( $form ) ) { |
|
| 468 | 468 | return null; |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - if( !is_array( $form ) ) { |
|
| 471 | + if ( ! is_array( $form ) ) { |
|
| 472 | 472 | $form = GVCommon::get_form( $form ); |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | - foreach( $form['fields'] as $key => $field ) { |
|
| 475 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
| 476 | 476 | |
| 477 | - $field = (array) $field; |
|
| 477 | + $field = (array)$field; |
|
| 478 | 478 | |
| 479 | - if( !empty( $field['gravityview_approved'] ) ) { |
|
| 480 | - if( !empty($field['inputs'][0]['id']) ) { |
|
| 481 | - return $field['inputs'][0]['id']; |
|
| 479 | + if ( ! empty( $field[ 'gravityview_approved' ] ) ) { |
|
| 480 | + if ( ! empty( $field[ 'inputs' ][ 0 ][ 'id' ] ) ) { |
|
| 481 | + return $field[ 'inputs' ][ 0 ][ 'id' ]; |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
| 486 | - if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
| 487 | - foreach ( $field['inputs'] as $key2 => $input ) { |
|
| 488 | - if ( strtolower( $input['label'] ) == 'approved' ) { |
|
| 489 | - return $input['id']; |
|
| 486 | + if ( 'checkbox' == $field[ 'type' ] && isset( $field[ 'inputs' ] ) && is_array( $field[ 'inputs' ] ) ) { |
|
| 487 | + foreach ( $field[ 'inputs' ] as $key2 => $input ) { |
|
| 488 | + if ( strtolower( $input[ 'label' ] ) == 'approved' ) { |
|
| 489 | + return $input[ 'id' ]; |
|
| 490 | 490 | } |
| 491 | 491 | } |
| 492 | 492 | } |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | * @since 1.11 |
| 53 | 53 | * @param boolean $boolean Whether to trigger update on user registration (default: true) |
| 54 | 54 | */ |
| 55 | - if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
| 55 | + if ( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) { |
|
| 56 | 56 | |
| 57 | - add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 ); |
|
| 57 | + add_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10, 2 ); |
|
| 58 | 58 | |
| 59 | 59 | // last resort in case the current user display name don't match any of the defaults |
| 60 | 60 | add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 ); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function update_user( $form = array(), $entry_id = 0 ) { |
| 74 | 74 | |
| 75 | - if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) { |
|
| 75 | + if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) || empty( $entry_id ) ) { |
|
| 76 | 76 | return; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -101,15 +101,15 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry ); |
| 103 | 103 | |
| 104 | - if( $preserve_role ) { |
|
| 105 | - $config['meta']['role'] = 'gfur_preserve_role'; |
|
| 104 | + if ( $preserve_role ) { |
|
| 105 | + $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role'; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * Make sure the current display name is not changed with the update user method. |
| 110 | 110 | * @since 1.15 |
| 111 | 111 | */ |
| 112 | - $config['meta']['displayname'] = $this->match_current_display_name( $entry['created_by'] ); |
|
| 112 | + $config[ 'meta' ][ 'displayname' ] = $this->match_current_display_name( $entry[ 'created_by' ] ); |
|
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -128,8 +128,8 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | // If an Update feed, make sure the conditions are met. |
| 131 | - if( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
| 132 | - if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
| 131 | + if ( rgars( $config, 'meta/feedType' ) === 'update' ) { |
|
| 132 | + if ( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) { |
|
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | // In case we can't find the current display name format, or it is the 'nickname' format (which Gravity Forms doesn't support) |
| 166 | 166 | // trigger last resort method at the 'gform_user_updated' hook |
| 167 | - if( false === $format || 'nickname' === $format ) { |
|
| 167 | + if ( false === $format || 'nickname' === $format ) { |
|
| 168 | 168 | $this->_user_before_update = $user; |
| 169 | 169 | $format = 'nickname'; |
| 170 | 170 | } |
@@ -184,18 +184,18 @@ discard block |
||
| 184 | 184 | public function generate_display_names( $profileuser ) { |
| 185 | 185 | |
| 186 | 186 | $public_display = array(); |
| 187 | - $public_display['nickname'] = $profileuser->nickname; |
|
| 188 | - $public_display['username'] = $profileuser->user_login; |
|
| 187 | + $public_display[ 'nickname' ] = $profileuser->nickname; |
|
| 188 | + $public_display[ 'username' ] = $profileuser->user_login; |
|
| 189 | 189 | |
| 190 | - if ( !empty($profileuser->first_name) ) |
|
| 191 | - $public_display['firstname'] = $profileuser->first_name; |
|
| 190 | + if ( ! empty( $profileuser->first_name ) ) |
|
| 191 | + $public_display[ 'firstname' ] = $profileuser->first_name; |
|
| 192 | 192 | |
| 193 | - if ( !empty($profileuser->last_name) ) |
|
| 194 | - $public_display['lastname'] = $profileuser->last_name; |
|
| 193 | + if ( ! empty( $profileuser->last_name ) ) |
|
| 194 | + $public_display[ 'lastname' ] = $profileuser->last_name; |
|
| 195 | 195 | |
| 196 | - if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { |
|
| 197 | - $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 198 | - $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 196 | + if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) { |
|
| 197 | + $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name; |
|
| 198 | + $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | $public_display = array_map( 'trim', $public_display ); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | */ |
| 226 | 226 | $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true ); |
| 227 | 227 | |
| 228 | - $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' ); |
|
| 228 | + $is_update_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'update' ); |
|
| 229 | 229 | |
| 230 | 230 | /** |
| 231 | 231 | * Don't restore display name: |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * - or we don't need as we found the correct format before updating user. |
| 235 | 235 | * @since 1.14.4 |
| 236 | 236 | */ |
| 237 | - if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 237 | + if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) { |
|
| 238 | 238 | return; |
| 239 | 239 | } |
| 240 | 240 | |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | |
| 261 | 261 | $updated = wp_update_user( $restored_user ); |
| 262 | 262 | |
| 263 | - if( is_wp_error( $updated ) ) { |
|
| 264 | - do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 263 | + if ( is_wp_error( $updated ) ) { |
|
| 264 | + do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated ); |
|
| 265 | 265 | } else { |
| 266 | - do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 266 | + do_action( 'gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) ); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | $this->_user_before_update = null; |