Skip to content

Commit a0f7d11

Browse files
authored
Merge pull request creativecommons#306 from creativecommons/staging
Merge staging branch
2 parents bbb2c91 + ed47c06 commit a0f7d11

10 files changed

+507
-19
lines changed

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

+21
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
margin: 1.5rem 0;
6464
}
6565
.color-guide .colors {
66+
display: flex;
6667
list-style-type: none;
6768
}
6869
.color-guide .colors li {
@@ -82,13 +83,29 @@
8283
.color-guide .colors li .color.green {
8384
background-color: #cff9cf;
8485
}
86+
.color-guide .colors li .color.orange {
87+
background-color: #fcf3e6;
88+
}
89+
.color-guide .colors li .color.blue {
90+
background-color: #cff9f7;
91+
}
8592
/* Marked Rows */
8693
.dataTable tbody tr.red-mark {
8794
background-color: #fff4f4;
8895
}
8996
.dataTable tbody tr.green-mark {
9097
background-color: #cff9cf;
9198
}
99+
.dataTable tbody tr.orange-mark {
100+
background-color: #fcf3e6;
101+
}
102+
.dataTable tbody tr.blue-mark {
103+
background-color: #cff9f7;
104+
}
105+
/* CELL STYLES */
106+
.dataTable tbody tr td.text-center {
107+
text-align: center;
108+
}
92109

93110
/*USER PROFILE*/
94111
.title-container {
@@ -168,13 +185,17 @@ table.ccgn-profile tr td.title {
168185
.applicant-columns .ccgn-box {
169186
padding: .5rem 1.5rem 1rem 1.5rem;
170187
margin-right: 1rem;
188+
margin-bottom: 1rem;
171189
background-color: white;
172190
border-radius: .2rem;
173191
box-shadow: 0 1px 4px rgba(0,0,0,.2);
174192
}
175193
.applicant-columns .ccgn-box.asked-box {
176194
background-color: #fef6e1;
177195
}
196+
.applicant-columns .ccgn-box.asked-box-answered {
197+
background-color: #cff9f7;
198+
}
178199
.applicant-columns .ccgn-box.applicant {
179200
text-align: center;
180201
}

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

+30-9
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,33 @@ $.fn.dataTable.ext.search.push(
3131
);
3232
function format(d) {
3333
// `d` is the original data object for the row
34+
var still_asked = '',
35+
left_class = '';
36+
if ( d.is_asked == 1) {
37+
still_asked = '<td class="data-right"><strong>Clarification asked to </strong></td>' +
38+
'<td>' + d.who_is_asked + '</td>';
39+
left_class = ' class="data-left"';
40+
}
3441
return '<table cellpadding="5" class="detail-table" cellspacing="0" border="0" style="padding-left:50px;">' +
3542
'<tr>' +
36-
'<td><strong>Vouchers declined</strong></td>' +
37-
'<td class="data-left">' + d.vouches_declined + '</td>' +
43+
'<td><strong>Vouchers declined</strong></td>' +
44+
'<td class="data-left">' + d.vouches_declined + '</td>' +
3845

39-
'<td class="data-right"><strong>Votes for</strong></td>' +
40-
'<td>' + d.votes_for + '</td>' +
46+
'<td class="data-right"><strong>Votes for</strong></td>' +
47+
'<td'+left_class+'>' + d.votes_for + '</td>' +
48+
49+
still_asked +
50+
4151
'</tr>' +
4252
'<tr>' +
43-
'<td><strong>Vouchers for</strong></td>' +
44-
'<td class="data-left">' + d.vouches_for + '</td>' +
53+
'<td><strong>Vouchers for</strong></td>' +
54+
'<td class="data-left">' + d.vouches_for + '</td>' +
4555
'<td class="data-right"><strong>Votes against</strong></td>' +
4656
'<td>' + d.votes_against + '</td>' +
4757
'</tr>' +
4858
'<tr>' +
49-
'<td><strong>Vouchers against</strong></td>' +
50-
'<td class="data-left">' + d.vouches_against + '</td>' +
59+
'<td><strong>Vouchers against</strong></td>' +
60+
'<td class="data-left">' + d.vouches_against + '</td>' +
5161
'</tr>' +
5262
'</table>';
5363
}
@@ -216,7 +226,7 @@ jQuery(document).ready(function ($) {
216226
},
217227
{ 'data': 'applicant' },
218228
{ 'data': 'applicant_type' },
219-
{ 'data': 'user_mail' },
229+
{ 'data': 'votes_for' },
220230
{ 'data': 'vouching_status' },
221231
{ 'data': 'voting_status' },
222232
{ 'data': 'application_date' }
@@ -227,6 +237,10 @@ jQuery(document).ready(function ($) {
227237
'render': function (data, type, row, meta) {
228238
return '<a href="' + row.applicant_url + '">' + data + '</a>';
229239
}
240+
},
241+
{
242+
targets: 3,
243+
'className': 'text-center'
230244
}
231245
],
232246
'ajax': {
@@ -237,10 +251,17 @@ jQuery(document).ready(function ($) {
237251
},
238252
'data': { 'current_user': wpApiSettings.current_user }
239253
},
254+
"pageLength": 50,
240255
rowCallback: function (row, data) {
241256
if (data.already_voted_by_me == 'yes') {
242257
$(row).addClass('green-mark');
243258
}
259+
if (data.is_asked == 1) {
260+
$(row).addClass('orange-mark');
261+
}
262+
if (data.is_asked == 2) {
263+
$(row).addClass('blue-mark');
264+
}
244265
}
245266
});
246267
var table_members = $('#ccgn-list-new-individuals').DataTable({

plugins/cc-global-network/admin/options-emails.php

+106
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,49 @@ function ccgn_settings_emails_ask_voucher_message()
333333

334334
}
335335

336+
function ccgn_settings_emails_update_details_first_subject()
337+
{
338+
$options = get_option('ccgn-email-update-details-first-reminder');
339+
?>
340+
<input type="text" name="ccgn-email-update-details-first-reminder[subject]"
341+
class="large-text"
342+
value="<?php echo $options['subject']; ?>" />
343+
<?php
344+
345+
}
346+
347+
function ccgn_settings_emails_update_details_first_message()
348+
{
349+
$options = get_option('ccgn-email-update-details-first-reminder');
350+
?>
351+
<textarea name="ccgn-email-update-details-first-reminder[message]"
352+
rows="12" cols="64" class="large-text"
353+
><?php echo $options['message']; ?></textarea>
354+
<?php
355+
}
356+
357+
function ccgn_settings_emails_update_details_second_subject()
358+
{
359+
$options = get_option('ccgn-email-update-details-second-reminder');
360+
?>
361+
<input type="text" name="ccgn-email-update-details-second-reminder[subject]"
362+
class="large-text"
363+
value="<?php echo $options['subject']; ?>" />
364+
<?php
365+
366+
}
367+
368+
function ccgn_settings_emails_update_details_second_message()
369+
{
370+
$options = get_option('ccgn-email-update-details-second-reminder');
371+
?>
372+
<textarea name="ccgn-email-update-details-second-reminder[message]"
373+
rows="12" cols="64" class="large-text"
374+
><?php echo $options['message']; ?></textarea>
375+
<?php
376+
377+
}
378+
336379
function ccgn_settings_emails_options_page () {
337380
add_options_page(
338381
'Global Network Emails',
@@ -874,6 +917,67 @@ function ccgn_settings_emails_options_ask_voucher()
874917
);
875918
}
876919

920+
function ccgn_settings_emails_options_update_details_first_reminder()
921+
{
922+
register_setting(
923+
'ccgn-emails',
924+
'ccgn-email-update-details-first-reminder'
925+
);
926+
927+
add_settings_section(
928+
'ccgn-email-update-details-first-reminder',
929+
'Update details first reminder',
930+
'ccgn_settings_emails_section_callback',
931+
'global-network-emails'
932+
);
933+
934+
add_settings_field(
935+
'registration-subject',
936+
'Subject',
937+
'ccgn_settings_emails_update_details_first_subject',
938+
'global-network-emails',
939+
'ccgn-email-update-details-first-reminder'
940+
);
941+
942+
add_settings_field(
943+
'registration-message',
944+
'Message Wrapper',
945+
'ccgn_settings_emails_update_details_first_message',
946+
'global-network-emails',
947+
'ccgn-email-update-details-first-reminder'
948+
);
949+
}
950+
function ccgn_settings_emails_options_update_details_second_reminder()
951+
{
952+
register_setting(
953+
'ccgn-emails',
954+
'ccgn-email-update-details-second-reminder'
955+
);
956+
957+
add_settings_section(
958+
'ccgn-email-update-details-second-reminder',
959+
'Update details second reminder',
960+
'ccgn_settings_emails_section_callback',
961+
'global-network-emails'
962+
);
963+
964+
add_settings_field(
965+
'registration-subject',
966+
'Subject',
967+
'ccgn_settings_emails_update_details_second_subject',
968+
'global-network-emails',
969+
'ccgn-email-update-details-second-reminder'
970+
);
971+
972+
add_settings_field(
973+
'registration-message',
974+
'Message Wrapper',
975+
'ccgn_settings_emails_update_details_second_message',
976+
'global-network-emails',
977+
'ccgn-email-update-details-second-reminder'
978+
);
979+
}
980+
877981
function ccgn_settings_emails_register () {
878982
ccgn_settings_emails_options_page();
879983
ccgn_settings_emails_options_sender();
@@ -894,6 +998,8 @@ function ccgn_settings_emails_register () {
894998
ccgn_settings_emails_options_notify_legal();
895999
ccgn_settings_emails_options_chapter_contact();
8961000
ccgn_settings_emails_options_ask_voucher();
1001+
ccgn_settings_emails_options_update_details_first_reminder();
1002+
ccgn_settings_emails_options_update_details_second_reminder();
8971003
}
8981004

8991005
function ccgn_settings_emails_print_info () {

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

+35-5
Original file line numberDiff line numberDiff line change
@@ -543,18 +543,48 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
543543
);
544544
foreach ($vouchers as $voucher) {
545545
$asked = get_user_meta($voucher['id'], 'ccgn_need_to_clarify_vouch_reason', true);
546-
$asked_class = ($asked) ? ' asked-box' : '';
547-
echo '<div class="ccgn-box applicant'.$asked_class.'">';
546+
$asked_info = get_user_meta($voucher['id'], 'ccgn_need_to_clarify_vouch_reason_applicant_status', true);
547+
$user_is_asked_for_clarification = 0;
548+
$applicant_votes = ccgn_application_votes_counts($applicant_id);
549+
$asked_class = '';
550+
$who_asked = '';
551+
//print_r($voucher);
552+
if (empty($asked_info['user_id'])) {
553+
$log_user = ccgn_ask_clarification_log_get_id($applicant_id);
554+
foreach ($log_user as $entry) {
555+
$asked_meta = get_user_meta($entry['voucher_id'], 'ccgn_need_to_clarify_vouch_reason_applicant_status', true);
556+
557+
if (($asked_meta['status'] == 1) && ($entry['voucher_id'] == $voucher['id'])) {
558+
$user_is_asked_for_clarification = 1;
559+
$asked_class = 'asked-box';
560+
$who_asked = $entry['ask_user_name'];
561+
} else if (($asked_meta['status'] == 0) && ($entry['voucher_id'] == $voucher['id'])) {
562+
$user_is_asked_for_clarification = 2;
563+
$asked_class = 'asked-box-answered';
564+
$who_asked = $entry['ask_user_name'];
565+
}
566+
}
567+
568+
} else {
569+
$who_asked = get_user_by('ID', $asked_info['user_id'])->display_name;
570+
$user_is_asked_for_clarification = $asked_info['status'];
571+
}
572+
echo '<div class="ccgn-box applicant '.$asked_class.'">';
548573
//echo '<div class="icon"><span class="dashicons dashicons-admin-users"></span></div>';
549574
echo '<h3 class="applicant-name">'.$voucher['name'].'</h3>';
550575
echo '<span class="date">'.$voucher['date'].'</span>';
551-
if ($asked) {
576+
if ($user_is_asked_for_clarification) {
552577
echo '<br><small><em>Asked for clarification</em></small>';
578+
if (!empty($who_asked)) {
579+
echo '<br><small><em><strong>Asked by:</strong> '.$who_asked.'</em></small>';
580+
}
553581
}
554582
if ($voucher['vouched'] == 'Yes') {
555583
echo '<p class="applicant-reason">' . $voucher['reason'] . '</p>';
556584
} else {
557-
echo '<p class="applicant-reason">' . $voucher['reason_no'] . '</p>';
585+
if ($applicant_votes['yes'] < 5) {
586+
echo '<p class="applicant-reason">' . $voucher['reason_no'] . '</p>';
587+
}
558588
}
559589
echo '<p class="state"><strong>Vouched:</strong> '.$voucher['vouched'].'</p>';
560590
if (($voucher['vouched'] == 'Yes') && (ccgn_current_user_is_final_approver($applicant_id) || ccgn_current_user_is_membership_council($applicant_id)) ) {
@@ -747,7 +777,7 @@ function ccgn_ajax_ask_voucher()
747777
if (check_ajax_referer('ask_voucher', 'sec') && (!empty($user_id))) {
748778
ccgn_ask_email_vouching_request($applicant_id,$user_id);
749779
//set user state to clarification of the reason to vouch applicant
750-
$update_ask_status = array('status' => 1, 'applicant_id' => $applicant_id);
780+
$update_ask_status = array('status' => 1, 'applicant_id' => $applicant_id, 'user_id' => $user_id);
751781
update_user_meta($user_id, 'ccgn_need_to_clarify_vouch_reason_applicant_status', $update_ask_status );
752782
update_user_meta($user_id,'ccgn_need_to_clarify_vouch_reason',1);
753783
ccgn_ask_clarification_log_append($applicant_id,$user_id);

plugins/cc-global-network/admin/user-final-approval-list-page.php

+19-2
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ function ccgn_application_approval_page () {
321321
<div class="color-guide">
322322
<ul class="colors">
323323
<li><span class="color green"></span> Already voted</li>
324+
<li><span class="color orange"></span> Asked for clarification</li>
325+
<li><span class="color blue"></span> Statement updated</li>
324326
</ul>
325327
</div>
326328
<div class="ccgn-table-container">
@@ -331,7 +333,7 @@ function ccgn_application_approval_page () {
331333
<th>Applicant</th>
332334
<th>Type</th>
333335
<?php// if ( ccgn_current_user_is_final_approver() ) { ?>
334-
<th>Email</th>
336+
<th>Votes</th>
335337
<th>Vouching Status</th>
336338
<!-- <th>Vouches Declined</th>
337339
<th>Vouches For</th>
@@ -431,7 +433,20 @@ function ccgn_rest_return_application_approval_list() {
431433
foreach ($user_entries as $user_id) {
432434
$user_data = array();
433435
$user = get_user_by('ID', $user_id);
434-
$user_application_status = get_user_meta($user_id, 'ccgn-application-state', true);
436+
$user_application_status = get_user_meta($user_id, 'ccgn-application-state', true);
437+
$log_user = ccgn_ask_clarification_log_get_id($user_id);
438+
$user_is_asked_for_clarification = 0;
439+
$voucher_asked = null;
440+
foreach ($log_user as $entry) {
441+
$asked_meta = get_user_meta($entry['voucher_id'], 'ccgn_need_to_clarify_vouch_reason_applicant_status', true);
442+
if ( ($asked_meta['status'] == 1) && ($asked_meta['applicant_id'] == $user_id) ) {
443+
$user_is_asked_for_clarification = 1;
444+
$asked_voucher_user = get_user_by('ID', $entry['voucher_id'])->display_name;
445+
} else if (($asked_meta['status'] == 0) && ($asked_meta['applicant_id'] == $user_id)) {
446+
$user_is_asked_for_clarification = 2;
447+
$asked_voucher_user = get_user_by('ID', $entry['voucher_id'])->display_name;
448+
}
449+
}
435450
// The last form the user filled out, so the time to use
436451
$vouchers_entry = ccgn_application_vouchers($user_id);
437452
// The actual count of vouches
@@ -474,6 +489,8 @@ function ccgn_rest_return_application_approval_list() {
474489
$user_data['votes_for'] = $vote_counts[ 'yes'];
475490
$user_data['votes_against'] = $vote_counts[ 'no'];
476491
$user_data['application_date'] = date('Y-m-d', strtotime($vouchers_entry[ 'date_created' ]));
492+
$user_data['is_asked'] = $user_is_asked_for_clarification;
493+
$user_data['who_is_asked'] = $asked_voucher_user;
477494

478495
$return_data['data'][] = $user_data;
479496
}

0 commit comments

Comments
 (0)