From abec2cb6a35cc40c1fd7b407c373b8bcf3219637 Mon Sep 17 00:00:00 2001 From: Thomas Citharel <tcit@tcit.fr> Date: Thu, 19 Apr 2018 16:53:54 +0200 Subject: [PATCH] Refactor and fix indentation a bit, add a <pre> section for email collection and string changes Signed-off-by: Thomas Citharel <tcit@tcit.fr> --- adminstuds.php | 31 ++++++++++---------------- locale/en.json | 12 +++++----- tpl/display_mails.tpl | 51 ++++++++++++++++++++++++++----------------- 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/adminstuds.php b/adminstuds.php index 993ad138..f4e472e2 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -80,7 +80,7 @@ $messagePollCreated = $sessionService->get("Framadate", "messagePollCreated", FA if ($messagePollCreated) { $sessionService->remove("Framadate", "messagePollCreated"); - + $message = new Message('success', __('adminstuds', 'The poll is created.')); } @@ -417,28 +417,21 @@ if (isset($_GET['collect_mail'])) { $column_str = strval(Utils::base64url_decode($column_str)); $column = intval($column_str); $votes = $pollService->splitVotes($pollService->allVotesByPollId($poll_id)); - $mails_yes = []; - $mails_ifneedbe = []; - $mails_no = []; - $size = count($votes); - for ($i = 0; $i < $size; $i++) -{ - if(intval($votes[$i]->choices[$column]) === 2 && $votes[$i]->mail !== NULL) { - $mails_yes[]=$votes[$i]->mail; + $mails_yes = $mails_ifneedbe = $mails_no = []; + foreach ($votes as $vote) { + if (intval($vote->choices[$column]) === 2 && $vote->mail !== NULL) { + $mails_yes[] = $vote->mail; + } elseif (intval($vote->choices[$column]) === 1 && $vote->mail !== NULL) { + $mails_ifneedbe[] = $vote->mail; + } elseif($vote->mail !== NULL) { + $mails_no[] = $vote->mail; } - else { - if(intval($votes[$i]->choices[$column]) === 1 && $votes[$i]->mail !== NULL) { - $mails_ifneedbe[]=$votes[$i]->mail; - } - elseif($votes[$i]->mail !== NULL) { - $mails_no[]=$votes[$i]->mail; - } - } -} + } + $smarty->assign('poll_id', $poll_id); $smarty->assign('admin_poll_id', $admin_poll_id); $smarty->assign('admin', true); - $smarty->assign('title', __('Generic', 'Poll') . ' - ' . $poll->title . ' - ' . __('adminstuds', 'Collect the emails of the polled users for this column')); + $smarty->assign('title', __('Generic', 'Poll') . ' - ' . $poll->title . ' - ' . __('adminstuds', 'Collect the emails of the polled users for the choice')); $smarty->assign('mails_yes', $mails_yes); $smarty->assign('mails_ifneedbe', $mails_ifneedbe); $smarty->assign('mails_no', $mails_no); diff --git a/locale/en.json b/locale/en.json index 3681c0a2..88d67b26 100644 --- a/locale/en.json +++ b/locale/en.json @@ -458,11 +458,11 @@ "Your vote has been registered successfully, but be careful: regarding this poll options, you need to keep this personal link to edit your own vote:": "Your vote has been saved, but please note: you need to keep this personalised link to be able to edit your vote." }, "display_mails": { - "People who have answered 'Yes' to this option have not left any email addresses." : "People who have answered 'Yes' to this option have not left any email addresses.", - "People who have answered 'If need be' to this option have not left any email addresses." : "People who have answered 'If need be' to this option have not left any email addresses.", - "People who have answered 'No' to this option have not left any email addresses." : "People who have answered 'No' to this option have not left any email addresses.", - "People who have answered 'Yes' to this option have left those email addresses :" : "People who have answered 'Yes' to this option have left those email addresses :", - "People who have answered 'If need be' to this option have left those email addresses :" : "People who have answered 'If need be' to this option have left those email addresses :", - "People who have answered 'No' to this option have left those email addresses :" : "People who have answered 'No' to this option have left those email addresses :" + "No one voted 'Yes' to this option." : "No one voted 'Yes' to this option.", + "No one voted 'If need be' to this option." : "No one voted 'If need be' to this option.", + "No one voted 'No' to this option." : "No one voted 'No' to this option.", + "People who have answered 'Yes' to this option have left these email addresses:" : "People who have answered 'Yes' to this option have left these email addresses:", + "People who have answered 'If need be' to this option have left these email addresses:" : "People who have answered 'If need be' to this option have left these email addresses:", + "People who have answered 'No' to this option have left these email addresses:" : "People who have answered 'No' to this option have left these email addresses:" } } diff --git a/tpl/display_mails.tpl b/tpl/display_mails.tpl index b77aaa5f..b7c45be9 100644 --- a/tpl/display_mails.tpl +++ b/tpl/display_mails.tpl @@ -1,34 +1,45 @@ {extends file='page.tpl'} {block name=main} - <body> + <main> {if ($mails_yes|count) === 0} - {__('display_mails', "People who have answered 'Yes' to this option have not left any email addresses.")}</br> + {__('display_mails', "No one voted 'Yes' to this option.")}</br> {else} - {__('display_mails', "People who have answered 'Yes' to this option have left those email addresses :")}</br> - {foreach $mails_yes as $mail} - <strong>{$mail|html}</strong> </br> - {/foreach} + {__('display_mails', "People who have answered 'Yes' to this option have left these email addresses:")}</br> + {strip} + <pre> + {foreach $mails_yes as $mail} + {$mail|html}<br /> + {/foreach} + </pre> + {/strip} {/if} - </br> + <br /> {if ($mails_ifneedbe|count) === 0} - {__('display_mails', "People who have answered 'If need be' to this option have not left any email addresses.")}</br> + {__('display_mails', "No one voted 'If need be' to this option.")}</br> {else} - {__('display_mails', "People who have answered 'If need be' to this option have left those email addresses :")}</br> - {foreach $mails_ifneedbe as $mail} - <strong>{$mail|html}</strong> </br> - {/foreach} + {__('display_mails', "People who have answered 'If need be' to this option have left these email addresses:")}</br> + {strip} + <pre> + {foreach $mails_ifneedbe as $mail} + {$mail|html}<br /> + {/foreach} + </pre> + {/strip} {/if} - </br> + <br /> {if ($mails_no|count) === 0} - {__('display_mails', "People who have answered 'No' to this option have not left any email addresses.")}</br> + {__('display_mails', "No one voted 'No' to this option.")}</br> {else} - {__('display_mails', "People who have answered 'No' to this option have left those email addresses :")}</br> - {foreach $mails_no as $mail} - <strong>{$mail|html}</strong> </br> - {/foreach} + {__('display_mails', "People who have answered 'No' to this option have left these email addresses:")}</br> + {strip} + <pre> + {foreach $mails_no as $mail} + {$mail|html}<br /> + {/foreach} + </pre> + {/strip} {/if} - </br> + <br /> <a href="{poll_url id=$admin_poll_id admin=true}" class="btn btn-default" name="back">{__('adminstuds', 'Back to the poll')}</a> - </body> {/block} -- GitLab