Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\nexus\modules\admin\payments;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -23,6 +23,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _gateways extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
@@ -78,22 +83,20 @@ class _gateways extends \IPS\Node\Controller
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'plupload/plupload.full.min.js', 'core', 'interface' ) );
|
||||
}
|
||||
\IPS\Output::i()->output = new \IPS\Helpers\Wizard( array(
|
||||
\IPS\Output::i()->output = (string) new \IPS\Helpers\Wizard( array(
|
||||
'gateways_gateway' => function( $data )
|
||||
{
|
||||
$options = array();
|
||||
foreach ( new \DirectoryIterator( \IPS\ROOT_PATH . '/applications/nexus/sources/Gateway' ) as $file )
|
||||
foreach ( \IPS\nexus\Gateway::gateways() as $key => $class )
|
||||
{
|
||||
if ( $file->isDir() and !$file->isDot() )
|
||||
/* Deprecate Authorize.net, don't allow it to be used for new gateways */
|
||||
if( $key === 'AuthorizeNet' )
|
||||
{
|
||||
if ( ( (string) $file === 'Test' and !\IPS\NEXUS_TEST_GATEWAYS ) or (string) $file === 'SagePay' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$options[ (string) $file ] = 'gateway__' . $file;
|
||||
continue;
|
||||
}
|
||||
$options[ $key ] = 'gateway__' . $key;
|
||||
}
|
||||
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'gateways_gateway', TRUE, NULL, array( 'options' => $options ) ) );
|
||||
if ( $values = $form->values() )
|
||||
@@ -105,19 +108,18 @@ class _gateways extends \IPS\Node\Controller
|
||||
'gateways_details' => function( $data )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form('gw');
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'paymethod_name', \IPS\Member::loggedIn()->language()->addToStack( 'gateway__' . $data['gateway'] ), TRUE ) );
|
||||
$class = 'IPS\nexus\Gateway\\' . $data['gateway'];
|
||||
$class = \IPS\nexus\Gateway::gateways()[ $data['gateway'] ];
|
||||
$obj = new $class;
|
||||
$obj->gateway = $data['gateway'];
|
||||
$obj->active = TRUE;
|
||||
$obj->settings( $form );
|
||||
$obj->form( $form );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
|
||||
$settings = array();
|
||||
foreach ( $values as $k => $v )
|
||||
{
|
||||
if ( $k !== 'paymethod_name' )
|
||||
if ( $k !== 'paymethod_name' AND $k !== 'paymethod_countries' )
|
||||
{
|
||||
$settings[ mb_substr( $k, mb_strlen( $data['gateway'] ) + 1 ) ] = $v;
|
||||
}
|
||||
@@ -131,11 +133,13 @@ class _gateways extends \IPS\Node\Controller
|
||||
$form->error = $e->getMessage();
|
||||
return $form;
|
||||
}
|
||||
$obj->settings = json_encode( $settings );
|
||||
$obj->save();
|
||||
\IPS\Lang::saveCustom( 'nexus', "nexus_paymethod_{$obj->id}", $values['paymethod_name'] );
|
||||
|
||||
|
||||
$name = $values['paymethod_name'];
|
||||
$values = $obj->formatFormValues( $values );
|
||||
$obj->settings = json_encode( $settings );
|
||||
$obj->countries = $values['countries'];
|
||||
$obj->save();
|
||||
\IPS\Lang::saveCustom( 'nexus', "nexus_paymethod_{$obj->id}", $name );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=payments&controller=paymentsettings&tab=gateways') );
|
||||
}
|
||||
@@ -144,4 +148,48 @@ class _gateways extends \IPS\Node\Controller
|
||||
), \IPS\Http\Url::internal('app=nexus&module=payments&controller=paymentsettings&tab=gateways&do=form') );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function delete()
|
||||
{
|
||||
/* Get node */
|
||||
$nodeClass = $this->nodeClass;
|
||||
if ( \IPS\Request::i()->subnode )
|
||||
{
|
||||
$nodeClass = $nodeClass::$subnodeClass;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$node = $nodeClass::load( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X411/1', 404, '' );
|
||||
}
|
||||
|
||||
/* Permission check */
|
||||
if( !$node->canDelete() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_noperm_delete', '2X411/2', 403, '' );
|
||||
}
|
||||
|
||||
if( $node->hasActiveBillingAgreements() )
|
||||
{
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
|
||||
\IPS\Task::queue( 'nexus', 'DeletePaymentMethod', array( 'id' => $node->id ), 3, array( 'id' ) );
|
||||
\IPS\Session::i()->log( 'acplog__node_deleted_c', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $node->parent() ? $node->parent()->_id : '' ) ) ), 'deleted' );
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user