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,30 +12,49 @@
|
||||
namespace IPS\nexus\modules\admin\subscriptions;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Table\Db;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\nexus\Purchase;
|
||||
use IPS\nexus\Subscription;
|
||||
use IPS\nexus\Subscription\Package;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
use const IPS\Helpers\Table\SEARCH_CONTAINS_TEXT;
|
||||
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
|
||||
use const IPS\Helpers\Table\SEARCH_NODE;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribers
|
||||
*/
|
||||
class _subscribers extends \IPS\Dispatcher\Controller
|
||||
class subscribers extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'subscribers_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'subscribers_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -44,10 +63,18 @@ class _subscribers extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
protected function manage() : void
|
||||
{
|
||||
/* If we came from the Subscription Plans page, we might have a
|
||||
package ID passed in the URL */
|
||||
$where = [];
|
||||
if( isset( Request::i()->nexus_sub_package_id ) AND Request::i()->nexus_sub_package_id )
|
||||
{
|
||||
$where[] = array( 'sub_package_id=?', Request::i()->nexus_sub_package_id );
|
||||
}
|
||||
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'nexus_member_subscriptions', \IPS\Http\Url::internal( 'app=nexus&module=subscriptions&controller=subscribers' ) );
|
||||
$table = new Db( 'nexus_member_subscriptions', Url::internal( 'app=nexus&module=subscriptions&controller=subscribers' ), $where );
|
||||
$table->joins = array(
|
||||
array(
|
||||
'select' => 'core_members.*',
|
||||
@@ -72,26 +99,27 @@ class _subscribers extends \IPS\Dispatcher\Controller
|
||||
$table->parsers = array(
|
||||
'photo' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('customers')->rowPhoto( \IPS\Member::constructFromData( $row ) );
|
||||
return Theme::i()->getTemplate('customers')->rowPhoto( Member::constructFromData( $row ) );
|
||||
},
|
||||
'sub_member_id' => function( $val ) {
|
||||
return \IPS\Theme::i()->getTemplate('global', 'nexus')->userLink( \IPS\Member::load( $val ) );
|
||||
return Theme::i()->getTemplate('global', 'nexus')->userLink( Member::load( $val ) );
|
||||
},
|
||||
'sub_package_id' => function( $val ) {
|
||||
try
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('subscription', 'nexus')->packageLink( \IPS\nexus\Subscription\Package::load( $val ) );
|
||||
return Theme::i()->getTemplate('subscription', 'nexus')->packageLink( Package::load( $val ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e ) { }
|
||||
catch( OutOfRangeException ) { }
|
||||
return '';
|
||||
},
|
||||
'sub_start' => function( $val ) {
|
||||
return \IPS\DateTime::ts( $val );
|
||||
return DateTime::ts( $val );
|
||||
},
|
||||
'sub_expire' => function( $val, $row ) {
|
||||
return $val ? \IPS\nexus\Subscription::constructFromData( $row )->_expire : '';
|
||||
return $val ? Subscription::constructFromData( $row )->_expire : '';
|
||||
},
|
||||
'sub_active' => function( $val ) {
|
||||
return \IPS\Theme::i()->getTemplate('subscription', 'nexus')->status( $val );
|
||||
return Theme::i()->getTemplate('subscription', 'nexus')->status( $val );
|
||||
}
|
||||
);
|
||||
|
||||
@@ -103,7 +131,7 @@ class _subscribers extends \IPS\Dispatcher\Controller
|
||||
$return['purchase'] = array(
|
||||
'title' => 'nexus_subs_view_purchase',
|
||||
'icon' => 'search',
|
||||
'link' => \IPS\Http\Url::internal( "app=nexus&module=subscriptions&controller=subscribers&do=findPurchase&id=" . $row['sub_id'] )
|
||||
'link' => Url::internal( "app=nexus&module=subscriptions&controller=subscribers&do=findPurchase&id=" . $row['sub_id'] )
|
||||
);
|
||||
}
|
||||
|
||||
@@ -117,32 +145,32 @@ class _subscribers extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
|
||||
$table->advancedSearch = array(
|
||||
'cm_first_name' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'cm_last_name' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'email' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'name' => \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT,
|
||||
'sub_expire' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'sub_start' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'sub_package_id' => array( \IPS\Helpers\Table\SEARCH_NODE, array(
|
||||
'cm_first_name' => SEARCH_CONTAINS_TEXT,
|
||||
'cm_last_name' => SEARCH_CONTAINS_TEXT,
|
||||
'email' => SEARCH_CONTAINS_TEXT,
|
||||
'name' => SEARCH_CONTAINS_TEXT,
|
||||
'sub_expire' => SEARCH_DATE_RANGE,
|
||||
'sub_start' => SEARCH_DATE_RANGE,
|
||||
'sub_package_id' => array( SEARCH_NODE, array(
|
||||
'class' => '\IPS\nexus\Subscription\Package',
|
||||
'zeroVal' => 'any'
|
||||
) ),
|
||||
);
|
||||
|
||||
/* Breadcrumb? */
|
||||
if ( isset( \IPS\Request::i()->nexus_sub_package_id ) )
|
||||
if ( isset( Request::i()->nexus_sub_package_id ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$package = \IPS\nexus\Subscription\Package::load( \IPS\Request::i()->nexus_sub_package_id );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( "app=nexus&module=subscriptions&controller=subscriptions&id=" . $package->id ), $package->_title );
|
||||
$package = Package::load( Request::i()->nexus_sub_package_id );
|
||||
Output::i()->breadcrumb[] = array( Url::internal( "app=nexus&module=subscriptions&controller=subscriptions&id=" . $package->id ), $package->_title );
|
||||
}
|
||||
catch( \OutOfRangeException $e ) { }
|
||||
catch( OutOfRangeException ) { }
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('r__subscribers');
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('r__subscribers');
|
||||
Output::i()->output = (string) $table;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,17 +178,17 @@ class _subscribers extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function findPurchase()
|
||||
protected function findPurchase() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
$sub = \IPS\nexus\Subscription::load( \IPS\Request::i()->id );
|
||||
$purchase = \IPS\nexus\Purchase::load( $sub->purchase_id );
|
||||
\IPS\Output::i()->redirect( $purchase->acpUrl() );
|
||||
$sub = Subscription::load( Request::i()->id );
|
||||
$purchase = Purchase::load( $sub->purchase_id );
|
||||
Output::i()->redirect( $purchase->acpUrl() );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'nexus_sub_no_purchase', '2X378/2', 404, '' );
|
||||
Output::i()->error( 'nexus_sub_no_purchase', '2X378/2', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user