Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,35 +12,49 @@
|
||||
namespace IPS\nexus\modules\admin\store;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Helpers\Table\Custom;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Coupon;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use function is_numeric;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* coupons
|
||||
*/
|
||||
class _coupons extends \IPS\Node\Controller
|
||||
class coupons extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\nexus\Coupon';
|
||||
protected string $nodeClass = 'IPS\nexus\Coupon';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'coupons_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'coupons_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -49,19 +63,19 @@ class _coupons extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function viewUses()
|
||||
public function viewUses() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
$coupon = \IPS\nexus\Coupon::load( \IPS\Request::i()->id );
|
||||
$coupon = Coupon::load( Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X234/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2X234/1', 404, '' );
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$usedBy = json_decode( $coupon->used_by, TRUE );
|
||||
$usedBy = $coupon->used_by ? json_decode( $coupon->used_by, TRUE ) : null;
|
||||
if ( $usedBy )
|
||||
{
|
||||
foreach ( $usedBy as $member => $uses )
|
||||
@@ -71,17 +85,17 @@ class _coupons extends \IPS\Node\Controller
|
||||
}
|
||||
|
||||
|
||||
$table = new \IPS\Helpers\Table\Custom( $data, \IPS\Http\Url::internal("app=nexus&module=store&controller=coupons&do=viewUses&id={$coupon->id}") );
|
||||
$table = new Custom( $data, Url::internal("app=nexus&module=store&controller=coupons&do=viewUses&id={$coupon->id}") );
|
||||
$table->parsers = array(
|
||||
'coupon_customer' => function ( $val )
|
||||
{
|
||||
return \is_numeric( $val ) ? \IPS\Theme::i()->getTemplate('global')->userLink( \IPS\Member::load( $val ) ) : $val;
|
||||
return is_numeric( $val ) ? Theme::i()->getTemplate('global')->userLink( Member::load( $val ) ) : $val;
|
||||
}
|
||||
);
|
||||
$table->sortBy = 'coupon_uses';
|
||||
$table->noSort = array( 'coupon_customer' );
|
||||
|
||||
\IPS\Output::i()->title = $coupon->code;
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
Output::i()->title = $coupon->code;
|
||||
Output::i()->output = (string) $table;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user