@@ -227,31 +227,45 @@ function ccgn_application_mc_review_submit_handler( $entry, $form ) {
227
227
);
228
228
update_user_meta ($ applicant_id , 'ccgn-user-mc-review ' , $ user_meta );
229
229
if ( ccgn_current_user_is_membership_council () || ccgn_current_user_is_final_approver () ) {
230
+ $ was_voted_no = get_user_meta ( $ applicant_id , 'ccgn-application-voted-no ' , true );
230
231
if ( $ entry [ CCGN_GF_MC_REVIEW_RESULT ] == 'Yes ' ) {
231
232
$ choose_vouchers_entry = ccgn_application_vouchers ($ applicant_id );
232
233
$ no_voucher = '' ;
233
234
$ first_voucher = ccgn_vouches_for_applicant_by_voucher ( $ applicant_id , $ choose_vouchers_entry [1 ] );
234
235
$ second_voucher = ccgn_vouches_for_applicant_by_voucher ( $ applicant_id , $ choose_vouchers_entry [2 ] );
235
-
236
- ccgn_registration_user_set_stage ( $ applicant_id , CCGN_APPLICATION_STATE_UPDATE_VOUCHERS );
237
- $ update_date = date ('Y-m-d H:i:s ' , strtotime ('now ' ));
238
-
239
- if ( $ first_voucher [0 ][CCGN_GF_VOUCH_DO_YOU_VOUCH ] == 'No ' ) {
240
- $ vouch = $ first_voucher [0 ];
241
- } elseif ( $ second_voucher [0 ][CCGN_GF_VOUCH_DO_YOU_VOUCH ] == 'No ' ) {
242
- $ vouch = $ second_voucher [0 ];
236
+ if ( $ was_voted_no ['status ' ] ) {
237
+ $ no_vote_entry_id = $ was_voted_no ['entry_id ' ];
238
+ $ no_vote_restore = array (
239
+ 'status ' => false ,
240
+ 'entry_id ' => false ,
241
+ 'date ' => date ('Y-m-d H:i:s ' , strtotime ('now ' ))
242
+ );
243
+ update_user_meta ($ applicant_id , 'ccgn-application-voted-no ' , $ no_vote_restore );
244
+ if (!empty ($ no_vote_entry_id )) {
245
+ GFAPI ::delete_entry ( $ no_vote_entry_id );
246
+ }
247
+ ccgn_registration_user_set_stage ( $ applicant_id , CCGN_APPLICATION_STATE_VOUCHING );
248
+ } else {
249
+ ccgn_registration_user_set_stage ( $ applicant_id , CCGN_APPLICATION_STATE_UPDATE_VOUCHERS );
250
+ $ update_date = date ('Y-m-d H:i:s ' , strtotime ('now ' ));
251
+
252
+ if ( $ first_voucher [0 ][CCGN_GF_VOUCH_DO_YOU_VOUCH ] == 'No ' ) {
253
+ $ vouch = $ first_voucher [0 ];
254
+ } elseif ( $ second_voucher [0 ][CCGN_GF_VOUCH_DO_YOU_VOUCH ] == 'No ' ) {
255
+ $ vouch = $ second_voucher [0 ];
256
+ }
257
+ $ vouch [CCGN_GF_VOUCH_DO_YOU_VOUCH ] = CCGN_GF_VOUCH_DO_YOU_VOUCH_REMOVED ;
258
+ GFAPI ::update_entry ($ vouch );
259
+ ccgn_set_entry_update_date ($ vouch , $ update_date );
260
+ // Update the date on the Choose Vouchers form, resetting the timescale
261
+ // for updating voucher choices
262
+ ccgn_set_entry_update_date ( $ choose_vouchers_entry , $ update_date );
263
+ ccgn_registration_email_to_applicant (
264
+ $ applicant_id ,
265
+ 'ccgn-email-mc-review-update-vouchers ' ,
266
+ $ entry [ CCGN_GF_MC_REVIEW_NOTE ]
267
+ );
243
268
}
244
- $ vouch [CCGN_GF_VOUCH_DO_YOU_VOUCH ] = CCGN_GF_VOUCH_DO_YOU_VOUCH_REMOVED ;
245
- GFAPI ::update_entry ($ vouch );
246
- ccgn_set_entry_update_date ($ vouch , $ update_date );
247
- // Update the date on the Choose Vouchers form, resetting the timescale
248
- // for updating voucher choices
249
- ccgn_set_entry_update_date ( $ choose_vouchers_entry , $ update_date );
250
- ccgn_registration_email_to_applicant (
251
- $ applicant_id ,
252
- 'ccgn-email-mc-review-update-vouchers ' ,
253
- $ entry [ CCGN_GF_MC_REVIEW_NOTE ]
254
- );
255
269
} elseif ( $ entry [ CCGN_GF_MC_REVIEW_RESULT ] == 'No ' ) {
256
270
ccgn_decline_and_notify_applicant ( $ applicant_id );
257
271
}
@@ -263,8 +277,9 @@ function ccgn_application_mc_review_submit_handler( $entry, $form ) {
263
277
// Handle vote form results
264
278
265
279
function ccgn_application_users_page_vote_form_submit_handler ( $ entry ,
266
- $ form ) {
267
- if ( $ form [ 'title ' ] == CCGN_GF_VOTE ) {
280
+ $ form ) {
281
+ $ applicant_id = $ entry [ '4 ' ];
282
+ if (!empty ($ applicant_id )) {
268
283
if (! ( ccgn_current_user_is_membership_council ()
269
284
|| ccgn_current_user_is_final_approver () ) ) {
270
285
echo 'Must be Membership Council member. ' ;
@@ -277,16 +292,25 @@ function ccgn_application_users_page_vote_form_submit_handler ( $entry,
277
292
echo 'Cannot Vote on Application you are a Voucher for. ' ;
278
293
exit ;
279
294
}
280
- $ applicant_id = $ entry [ CCGN_GF_VOTE_APPLICANT_ID ];
281
295
$ stage = ccgn_registration_user_get_stage ( $ applicant_id );
282
296
if ( $ stage != CCGN_APPLICATION_STATE_VOUCHING ) {
283
297
echo 'User already post-approved (or updating vouchers) ' ;
284
298
return ;
285
299
}
300
+ if ($ entry [CCGN_GF_VOTE_APPROVE_MEMBERSHIP_APPLICATION ] == 'No ' ) {
301
+ _ccgn_registration_user_set_stage ( $ applicant_id , CCGN_APPLICATION_STATE_REVIEW );
302
+ $ user_vote_no = array (
303
+ 'status ' => true ,
304
+ 'entry_id ' => $ entry ['id ' ],
305
+ 'date ' => date ('Y-m-d H:i:s ' , strtotime ('now ' ))
306
+ );
307
+ update_user_meta ($ applicant_id , 'ccgn-application-voted-no ' , $ user_vote_no );
308
+ }
286
309
}
287
310
}
288
311
289
312
function ccgn_application_users_page_vote_form ( $ applicant_id ) {
313
+
290
314
if ( ccgn_vouching_request_exists ( $ applicant_id ,
291
315
get_current_user_id () ) ) {
292
316
echo _ ('<i>You have been asked to Vouch for this application, you therefore cannot Vote on it as well.</i> ' );
@@ -547,7 +571,8 @@ function ccgn_application_users_page_render_state ( $applicant_id, $state ) {
547
571
} elseif ( $ state == '' ) {
548
572
echo _ ('<h2>New User.</h2> ' );
549
573
echo _ ("<p>They haven't completed an application yet.</p> " );
550
- } elseif ( $ state == CCGN_APPLICATION_STATE_REVIEW ) {
574
+ }
575
+ if ( $ state == CCGN_APPLICATION_STATE_REVIEW ) {
551
576
echo _ ('<h2>To be reviewed by Membership Comitee.</h2> ' );
552
577
echo _ ("<p>This application needs to be reviewed by the Membership Comitee.</p> " );
553
578
ccgn_application_mc_review_form ($ applicant_id );
@@ -647,16 +672,18 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
647
672
$ who_asked = '' ;
648
673
if (empty ($ asked_info ['user_id ' ])) {
649
674
$ log_user = ccgn_ask_clarification_log_get_id ($ applicant_id );
650
- foreach ($ log_user as $ entry ) {
651
- $ asked_meta = get_user_meta ($ entry ['voucher_id ' ], 'ccgn_need_to_clarify_vouch_reason_applicant_status ' , true );
652
- if (($ asked_meta ['status ' ] == 1 ) && ($ entry ['voucher_id ' ] == $ voucher ['id ' ])) {
653
- $ user_is_asked_for_clarification = 1 ;
654
- $ asked_class = 'asked-box ' ;
655
- $ who_asked = (!empty ($ asked_info ['ask_user ' ])) ? get_user_by ('ID ' ,$ asked_info ['ask_user ' ])->display_name : $ entry ['ask_user_name ' ];
656
- } else if (($ asked_meta ['status ' ] == 0 ) && ($ entry ['voucher_id ' ] == $ voucher ['id ' ])) {
657
- $ user_is_asked_for_clarification = 2 ;
658
- $ asked_class = 'asked-box-answered ' ;
659
- $ who_asked = (!empty ($ asked_info ['ask_user ' ])) ? get_user_by ('ID ' ,$ asked_info ['ask_user ' ])->display_name : $ entry ['ask_user_name ' ];
675
+ if (!empty ($ log_user )) {
676
+ foreach ($ log_user as $ entry ) {
677
+ $ asked_meta = get_user_meta ($ entry ['voucher_id ' ], 'ccgn_need_to_clarify_vouch_reason_applicant_status ' , true );
678
+ if (($ asked_meta ['status ' ] == 1 ) && ($ entry ['voucher_id ' ] == $ voucher ['id ' ])) {
679
+ $ user_is_asked_for_clarification = 1 ;
680
+ $ asked_class = 'asked-box ' ;
681
+ $ who_asked = (!empty ($ asked_info ['ask_user ' ])) ? get_user_by ('ID ' ,$ asked_info ['ask_user ' ])->display_name : $ entry ['ask_user_name ' ];
682
+ } else if (($ asked_meta ['status ' ] == 0 ) && ($ entry ['voucher_id ' ] == $ voucher ['id ' ])) {
683
+ $ user_is_asked_for_clarification = 2 ;
684
+ $ asked_class = 'asked-box-answered ' ;
685
+ $ who_asked = (!empty ($ asked_info ['ask_user ' ])) ? get_user_by ('ID ' ,$ asked_info ['ask_user ' ])->display_name : $ entry ['ask_user_name ' ];
686
+ }
660
687
}
661
688
}
662
689
0 commit comments