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,53 @@
|
||||
namespace IPS\nexus\modules\admin\payments;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
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\Donation\Goal;
|
||||
use IPS\nexus\Invoice;
|
||||
use IPS\nexus\Money;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
|
||||
use const IPS\Helpers\Table\SEARCH_MEMBER;
|
||||
use const IPS\Helpers\Table\SEARCH_NODE;
|
||||
use const IPS\Helpers\Table\SEARCH_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* donations
|
||||
*/
|
||||
class _donations extends \IPS\Dispatcher\Controller
|
||||
class donations 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( 'donations_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'donations_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -44,18 +67,18 @@ class _donations extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
if( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'donationgoals_manage' ) )
|
||||
if( Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'donationgoals_manage' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions'][] = array(
|
||||
Output::i()->sidebar['actions'][] = array(
|
||||
'icon' => 'cog',
|
||||
'title' => 'donation_goals',
|
||||
'link' => \IPS\Http\Url::internal( "app=nexus&module=payments&controller=donationgoals" )
|
||||
'link' => Url::internal( "app=nexus&module=payments&controller=donationgoals" )
|
||||
);
|
||||
}
|
||||
|
||||
$table = new \IPS\Helpers\Table\Db( 'nexus_donate_logs', \IPS\Http\Url::internal('app=nexus&module=payments&controller=donations') );
|
||||
$table = new Db( 'nexus_donate_logs', Url::internal('app=nexus&module=payments&controller=donations') );
|
||||
|
||||
$table->include = array( 'dl_goal', 'dl_amount', 'dl_member', 'dl_invoice', 'dl_date' );
|
||||
$table->parsers = array(
|
||||
@@ -63,24 +86,24 @@ class _donations extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Donation\Goal::load( $val )->_title;
|
||||
return Goal::load( $val )->_title;
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
},
|
||||
'dl_member' => function ( $val )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('global')->userLink( \IPS\Member::load( $val ) );
|
||||
return Theme::i()->getTemplate('global')->userLink( Member::load( $val ) );
|
||||
},
|
||||
'dl_amount' => function( $val, $row )
|
||||
{
|
||||
try
|
||||
{
|
||||
return (string) new \IPS\nexus\Money( $val, \IPS\nexus\Donation\Goal::load( $row['dl_goal'] )->currency );
|
||||
return (string) new Money( $val, Goal::load( $row['dl_goal'] )->currency );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception )
|
||||
{
|
||||
return $val;
|
||||
}
|
||||
@@ -89,32 +112,38 @@ class _donations extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('invoices')->link( \IPS\nexus\Invoice::load( $val ), TRUE );
|
||||
return Theme::i()->getTemplate('invoices')->link( Invoice::load( $val ), TRUE );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'dl_date' => function( $val )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val );
|
||||
return DateTime::ts( $val );
|
||||
}
|
||||
);
|
||||
|
||||
foreach ( \IPS\nexus\Donation\Goal::roots() as $goal )
|
||||
foreach ( Goal::roots() as $goal )
|
||||
{
|
||||
$table->filters[ "nexus_donategoal_{$goal->_id}" ] = "dl_goal={$goal->_id}";
|
||||
}
|
||||
$table->advancedSearch = array(
|
||||
'dl_goal' => array( \IPS\Helpers\Table\SEARCH_NODE, array( 'class' => '\IPS\nexus\Donation\Goal' ) ),
|
||||
'dl_member' => \IPS\Helpers\Table\SEARCH_MEMBER,
|
||||
'dl_amount' => \IPS\Helpers\Table\SEARCH_NUMERIC,
|
||||
'dl_date' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'dl_goal' => array( SEARCH_NODE, array( 'class' => '\IPS\nexus\Donation\Goal' ) ),
|
||||
'dl_member' => SEARCH_MEMBER,
|
||||
'dl_amount' => SEARCH_NUMERIC,
|
||||
'dl_date' => SEARCH_DATE_RANGE,
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__nexus_payments_donations');
|
||||
|
||||
$message = '';
|
||||
if ( ! count( Widget::usedWhere( Application::load('nexus'), 'donations' ) ) )
|
||||
{
|
||||
/* Nudge the admin to add the sidebar block */
|
||||
$message = Theme::i()->getTemplate('forms', 'core' )->blurb( 'commerce_donation_goals_widget_not_in_use' );
|
||||
}
|
||||
|
||||
Output::i()->output = $message . $table;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__nexus_payments_donations');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user