Skip to content

Commit 9fbdec0

Browse files
authored
Merge pull request creativecommons#412 from creativecommons/hold-application
process to hold application when application is voted 'no'
2 parents 86eb732 + 889676b commit 9fbdec0

File tree

5 files changed

+70
-36
lines changed

5 files changed

+70
-36
lines changed

plugins/cc-global-network/admin/assets/css/admin_styles.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ table.ccgn-profile tr td.title {
226226
font-size: .7rem;
227227
}
228228
.applicant-columns .ccgn-box .applicant-reason {
229-
width: 15rem;
229+
max-width: 15rem;
230230
}
231231
.preview-details {
232232
margin-bottom: 2rem;

plugins/cc-global-network/admin/user-application-page.php

+60-33
Original file line numberDiff line numberDiff line change
@@ -227,31 +227,45 @@ function ccgn_application_mc_review_submit_handler( $entry, $form ) {
227227
);
228228
update_user_meta($applicant_id, 'ccgn-user-mc-review', $user_meta);
229229
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 );
230231
if ( $entry[ CCGN_GF_MC_REVIEW_RESULT ] == 'Yes' ) {
231232
$choose_vouchers_entry = ccgn_application_vouchers($applicant_id);
232233
$no_voucher = '';
233234
$first_voucher = ccgn_vouches_for_applicant_by_voucher( $applicant_id, $choose_vouchers_entry[1] );
234235
$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+
);
243268
}
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-
);
255269
} elseif ( $entry[ CCGN_GF_MC_REVIEW_RESULT ] == 'No' ) {
256270
ccgn_decline_and_notify_applicant( $applicant_id );
257271
}
@@ -263,8 +277,9 @@ function ccgn_application_mc_review_submit_handler( $entry, $form ) {
263277
// Handle vote form results
264278

265279
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)) {
268283
if (! ( ccgn_current_user_is_membership_council()
269284
|| ccgn_current_user_is_final_approver() ) ) {
270285
echo 'Must be Membership Council member.';
@@ -277,16 +292,25 @@ function ccgn_application_users_page_vote_form_submit_handler ( $entry,
277292
echo 'Cannot Vote on Application you are a Voucher for.';
278293
exit;
279294
}
280-
$applicant_id = $entry[ CCGN_GF_VOTE_APPLICANT_ID ];
281295
$stage = ccgn_registration_user_get_stage( $applicant_id);
282296
if ( $stage != CCGN_APPLICATION_STATE_VOUCHING ) {
283297
echo 'User already post-approved (or updating vouchers)';
284298
return;
285299
}
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+
}
286309
}
287310
}
288311

289312
function ccgn_application_users_page_vote_form ( $applicant_id ) {
313+
290314
if ( ccgn_vouching_request_exists( $applicant_id,
291315
get_current_user_id() ) ) {
292316
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 ) {
547571
} elseif ( $state == '' ) {
548572
echo _('<h2>New User.</h2>');
549573
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 ) {
551576
echo _('<h2>To be reviewed by Membership Comitee.</h2>');
552577
echo _("<p>This application needs to be reviewed by the Membership Comitee.</p>");
553578
ccgn_application_mc_review_form($applicant_id);
@@ -647,16 +672,18 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
647672
$who_asked = '';
648673
if (empty($asked_info['user_id'])) {
649674
$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+
}
660687
}
661688
}
662689

plugins/cc-global-network/cc-global-network.php

+6
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,12 @@ function ccgn_sanitize_user_not_strict($user, $raw_user, $strict)
316316
10,
317317
2
318318
);
319+
add_action(
320+
'gform_after_submission_43',
321+
'ccgn_application_users_page_vote_form_submit_handler',
322+
10,
323+
2
324+
);
319325
add_action(
320326
'gform_after_submission',
321327
'ccgn_application_users_page_legal_approval_form_submit_handler',

plugins/cc-global-network/includes/gravityforms-interaction.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,8 @@ function ccgn_application_vouches_counts($applicant_id)
965965
function ccgn_application_can_be_voted($applicant_id)
966966
{
967967
$vouches = ccgn_application_vouches_counts($applicant_id);
968-
if ($vouches['yes'] >= 2) {
968+
$votes = ccgn_application_votes_counts( $applicant_id );
969+
if ( ($vouches['yes'] >= 2) && ($votes['yes'] < 5) ) {
969970
return true;
970971
} else {
971972
return false;

themes/cc-commoners-2019/functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,4 @@ function enqueue_scripts(){
276276
* Instantiate the class object
277277
* */
278278

279-
$_s = site::get_instance();
279+
$_s = site::get_instance();

0 commit comments

Comments
 (0)