diff --git a/modules/overview/_includes.php b/modules/overview/_includes.php index 2cc0d0dc..fde288bd 100644 --- a/modules/overview/_includes.php +++ b/modules/overview/_includes.php @@ -27,6 +27,7 @@ include($includePath . './screens/Overview/components/AdminAlerts/AdminAlerts.component.php'); include($includePath . './screens/Overview/components/EmailChangeInfo/EmailChangeInfo.component.php'); include($includePath . './screens/Overview/components/NewMessagesInfo/NewMessagesInfo.component.php'); + include($includePath . './screens/Overview/components/NewSurveysInfo/NewSurveysInfo.component.php'); include($includePath . './screens/Overview/components/PlanetsListElement/PlanetsListElement.component.php'); include($includePath . './screens/Overview/components/ResourcesTransport/ResourcesTransport.component.php'); include($includePath . './screens/Overview/components/StatsList/StatsList.component.php'); diff --git a/modules/overview/screens/Overview/components/NewSurveysInfo/NewSurveysInfo.component.php b/modules/overview/screens/Overview/components/NewSurveysInfo/NewSurveysInfo.component.php new file mode 100644 index 00000000..1c10ce58 --- /dev/null +++ b/modules/overview/screens/Overview/components/NewSurveysInfo/NewSurveysInfo.component.php @@ -0,0 +1,74 @@ + 0); + + return ( + $hasUserVoted ? + 0 : + 1 + ); + }); + $surveysWithoutVotesCount = array_sum($surveysWithoutVotes); + + if ($surveysWithoutVotesCount == 0) { + return [ + 'componentHTML' => '', + ]; + } + + $localTemplateLoader = createLocalTemplateLoader(__DIR__); + + /** + * TODO: Use a better translation system to support more languages. + */ + $content = vsprintf( + $_Lang['PollBox_You_can_vote_in_new_polls'], + ( + $surveysWithoutVotesCount > 1 ? + $_Lang['PollBox_More'] : + $_Lang['PollBox_One'] + ) + ); + + $tplBodyParams = [ + 'content' => $content, + ]; + + $componentHTML = parsetemplate( + $localTemplateLoader('body'), + $tplBodyParams + ); + + return [ + 'componentHTML' => $componentHTML, + ]; +} + +?> diff --git a/modules/overview/screens/Overview/components/NewSurveysInfo/body.tpl b/modules/overview/screens/Overview/components/NewSurveysInfo/body.tpl new file mode 100644 index 00000000..d62e24b1 --- /dev/null +++ b/modules/overview/screens/Overview/components/NewSurveysInfo/body.tpl @@ -0,0 +1,7 @@ + + + + {content} + + + diff --git a/modules/overview/screens/Overview/components/NewSurveysInfo/index.php b/modules/overview/screens/Overview/components/NewSurveysInfo/index.php new file mode 100644 index 00000000..bc99142d --- /dev/null +++ b/modules/overview/screens/Overview/components/NewSurveysInfo/index.php @@ -0,0 +1,5 @@ + diff --git a/overview.php b/overview.php index ac824d6e..f7f3382b 100644 --- a/overview.php +++ b/overview.php @@ -136,22 +136,9 @@ ])['componentHTML']; // --- New Polls Information Box ------------------------------------------------------------------------- - $SQLResult_GetPolls = doquery("SELECT {{table}}.`id`, `votes`.`id` AS `vote_id` FROM {{table}} LEFT JOIN {{prefix}}poll_votes AS `votes` ON `votes`.`poll_id` = {{table}}.id AND `votes`.`user_id` = {$_User['id']} WHERE {{table}}.`open` = 1 ORDER BY {{table}}.`time` DESC;", 'polls'); - if($SQLResult_GetPolls->num_rows > 0) - { - $AvailablePolls = 0; - while($PollData = $SQLResult_GetPolls->fetch_assoc()) - { - if($PollData['vote_id'] <= 0) - { - $AvailablePolls += 1; - } - } - if($AvailablePolls > 0) - { - $parse['NewPollsBox'] = ''.vsprintf($_Lang['PollBox_You_can_vote_in_new_polls'], ($AvailablePolls > 1) ? $_Lang['PollBox_More'] : $_Lang['PollBox_One']).''; - } - } + $parse['NewPollsBox'] = Overview\Screens\Overview\Components\NewSurveysInfo\render([ + 'userId' => $_User['id'], + ])['componentHTML']; // --- Get users activity informations ----------------------------------------------------------- $TodaysStartTimeStamp = mktime(0, 0, 0);