Skip to content

Commit

Permalink
GH-230 Move gift items infobox to its own component
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Jul 15, 2022
1 parent c050b3c commit f46dee6
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 5 deletions.
1 change: 1 addition & 0 deletions modules/overview/_includes.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
include($includePath . './screens/Overview/components/AccountActivationInfoBox/AccountActivationInfoBox.component.php');
include($includePath . './screens/Overview/components/AdminAlerts/AdminAlerts.component.php');
include($includePath . './screens/Overview/components/EmailChangeInfo/EmailChangeInfo.component.php');
include($includePath . './screens/Overview/components/GiftItemsInfoBox/GiftItemsInfoBox.component.php');
include($includePath . './screens/Overview/components/Morale/Morale.component.php');
include($includePath . './screens/Overview/components/Morale/Morale.utils.php');
include($includePath . './screens/Overview/components/NewMessagesInfo/NewMessagesInfo.component.php');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\GiftItemsInfoBox;

/**
* @param array $props
* @param number $props['userId']
*/
function render($props) {
global $_Lang;

$userId = $props['userId'];

$getGiftItemsDataQuery = (
"SELECT " .
"COUNT(`ID`) as `Count` " .
"FROM {{table}} " .
"WHERE " .
"`UserID` = {$userId} AND " .
"`Used` = false " .
";"
);
$giftItemsData = doquery($getGiftItemsDataQuery, 'premium_free', true);

if ($giftItemsData['Count'] == 0) {
return [
'componentHTML' => '',
];
}

$localTemplateLoader = createLocalTemplateLoader(__DIR__);

$content = sprintf(
$_Lang['FreePremItem_Text'],
$giftItemsData['Count']
);

$componentHTML = parsetemplate(
$localTemplateLoader('body'),
[
'content' => $content,
]
);

return [
'componentHTML' => $componentHTML,
];
}

?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<tr>
<th colspan="3">
<a class="orange" href="galacticshop.php?show=free">
{content}
</a>
</th>
</tr>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

header("Location: ../index.php");

?>
8 changes: 3 additions & 5 deletions overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,9 @@
$parse['P_SFBInfobox'] = FlightControl\Components\SmartFleetBlockadeInfoBox\render()['componentHTML'];

// --- Free Premium Items Info Box -----------------------------------------------------------------------
$GetFreeItems = doquery("SELECT COUNT(`ID`) as `Count` FROM {{table}} WHERE `UserID` = {$_User['id']} AND `Used` = false;", 'premium_free', true);
if($GetFreeItems['Count'] > 0)
{
$parse['FreePremiumItemsBox'] = '<tr><th colspan="3"><a class="orange" href="galacticshop.php?show=free">'.sprintf($_Lang['FreePremItem_Text'], $GetFreeItems['Count']).'</a></th></tr>';
}
$parse['FreePremiumItemsBox'] = Overview\Screens\Overview\Components\GiftItemsInfoBox\render([
'userId' => $_User['id'],
])['componentHTML'];

// --- System Messages Box -------------------------------------------------------------------------------
if(!empty($_GET['showmsg']))
Expand Down

0 comments on commit f46dee6

Please sign in to comment.