EconomyHelper impl update
This commit is contained in:
parent
b98250e808
commit
8ad30a129a
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Alphaland\Economy\EconomyHelper;
|
||||||
use Alphaland\Users\User;
|
use Alphaland\Users\User;
|
||||||
use Alphaland\Web\WebContextManager;
|
use Alphaland\Web\WebContextManager;
|
||||||
|
|
||||||
|
|
@ -13,18 +14,12 @@ if(isset($_GET['id']))
|
||||||
//handle purchasing items
|
//handle purchasing items
|
||||||
if(isset($_POST['buyitem']))
|
if(isset($_POST['buyitem']))
|
||||||
{
|
{
|
||||||
$result = buyItem($id);
|
try {
|
||||||
if ($result == 0)
|
if (EconomyHelper::PurchaseItem($user->id, $id)) {
|
||||||
{
|
WebContextManager::Redirect("/catalog/view?id=". $id . "");
|
||||||
$alert = "<div class='alert alert-danger' role='alert'>You don't have enough Alphabux</div>";
|
}
|
||||||
}
|
} catch (Exception $e) {
|
||||||
elseif ($result == 1)
|
$alert = "<div class='alert alert-danger' role='alert'>".$e->getMessage()."</div>";
|
||||||
{
|
|
||||||
$alert = "<div class='alert alert-danger' role='alert'>You already own this item</div>";
|
|
||||||
}
|
|
||||||
elseif ($result == 2)
|
|
||||||
{
|
|
||||||
WebContextManager::Redirect("/catalog/view?id=". $id . "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ...
|
// ...
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ Alphaland 2021
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Alphaland\Assets\Asset;
|
use Alphaland\Assets\Asset;
|
||||||
|
use Alphaland\Economy\EconomyHelper;
|
||||||
use Alphaland\Web\WebContextManager;
|
use Alphaland\Web\WebContextManager;
|
||||||
|
|
||||||
$body = '';
|
$body = '';
|
||||||
|
|
@ -172,7 +173,7 @@ function uploadCosmetic()
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove currency
|
//remove currency
|
||||||
if (!removeCurrency($minimumprice, "Creation of cosmetic name ".$name))
|
if (!EconomyHelper::RemoveAlphabux($minimumprice, $GLOBALS['user']->id, "Creation of cosmetic name ".$name))
|
||||||
{
|
{
|
||||||
return "You don't have enough currency";
|
return "You don't have enough currency";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue