Skip to content

Commit 973cd86

Browse files
committed
fix creativecommons#317 - check name who ask for clarification, added to user meta for fast access
1 parent 78d4c1a commit 973cd86

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

plugins/cc-global-network/admin/assets/js/script.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,14 @@ jQuery(document).ready(function ($) {
203203
success: function (data) {
204204
this_button.text("Yes, I'm sure");
205205
$('#alert-messages').html('');
206-
if (data == 'ok') {
207-
tb_remove();
206+
if (data.trim() == 'ok') {
208207
$('#alert-messages').append('<div class="updated notice is-dismissible"><p>The request was sended to the user</p></div>').find('.notice').delay(3200).fadeOut(300);
209208
$('#search-all-members').trigger('click');
210209
}
211-
if (data == 'error') {
210+
if (data.trim() == 'error') {
212211
$('#alert-messages').append('<div class="error notice is-dismissible"><p>There was an error sending your request</p></div>').find('.notice').delay(3200).fadeOut(300);
213-
tb_remove();
214212
}
213+
tb_remove();
215214
}
216215
});
217216
});

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -553,20 +553,20 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
553553
$log_user = ccgn_ask_clarification_log_get_id($applicant_id);
554554
foreach ($log_user as $entry) {
555555
$asked_meta = get_user_meta($entry['voucher_id'], 'ccgn_need_to_clarify_vouch_reason_applicant_status', true);
556-
557556
if (($asked_meta['status'] == 1) && ($entry['voucher_id'] == $voucher['id'])) {
558557
$user_is_asked_for_clarification = 1;
559558
$asked_class = 'asked-box';
560-
$who_asked = $entry['ask_user_name'];
559+
$who_asked = (!empty($asked_info['ask_user'])) ? get_user_by('ID',$asked_info['ask_user'])->display_name : $entry['ask_user_name'];
561560
} else if (($asked_meta['status'] == 0) && ($entry['voucher_id'] == $voucher['id'])) {
562561
$user_is_asked_for_clarification = 2;
563562
$asked_class = 'asked-box-answered';
564-
$who_asked = $entry['ask_user_name'];
563+
$who_asked = (!empty($asked_info['ask_user'])) ? get_user_by('ID',$asked_info['ask_user'])->display_name : $entry['ask_user_name'];
565564
}
566565
}
567566

568567
} else {
569-
$who_asked = get_user_by('ID', $asked_info['user_id'])->display_name;
568+
$log_user = ccgn_ask_clarification_log_get_id($asked_info['applicant_id']);
569+
$who_asked = (!empty($asked_info['ask_user'])) ? get_user_by('ID',$asked_info['ask_user'])->display_name : $log_user[count($log_user)-1]['ask_user_name'];
570570
$user_is_asked_for_clarification = $asked_info['status'];
571571
}
572572
echo '<div class="ccgn-box applicant '.$asked_class.'">';
@@ -774,14 +774,15 @@ function ccgn_ajax_ask_voucher()
774774
{
775775
$user_id = $_POST['user_id'];
776776
$applicant_id = $_POST['applicant_id'];
777+
$current_user_ask = get_current_user_id();
777778
if (check_ajax_referer('ask_voucher', 'sec') && (!empty($user_id))) {
778779
ccgn_ask_email_vouching_request($applicant_id,$user_id);
779780
//set user state to clarification of the reason to vouch applicant
780-
$update_ask_status = array('status' => 1, 'applicant_id' => $applicant_id, 'user_id' => $user_id);
781+
$update_ask_status = array('status' => 1, 'applicant_id' => $applicant_id, 'user_id' => $user_id, 'ask_user' => $current_user_ask, 'time' => time());
781782
update_user_meta($user_id, 'ccgn_need_to_clarify_vouch_reason_applicant_status', $update_ask_status );
782783
update_user_meta($user_id,'ccgn_need_to_clarify_vouch_reason',1);
783784
ccgn_ask_clarification_log_append($applicant_id,$user_id);
784-
echo 'ok';
785+
echo 'ok';
785786
}
786787
exit(0);
787788
}

0 commit comments

Comments
 (0)