Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -38,6 +38,7 @@ class _packages extends \IPS\Node\Controller
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'packages_manage' );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_store.js', 'nexus', 'admin' ) );
|
||||
parent::execute();
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__nexus_store_packages');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,10 +128,10 @@ class _packages extends \IPS\Node\Controller
|
||||
}
|
||||
|
||||
$changes = json_decode( \IPS\Request::i()->changes, TRUE );
|
||||
|
||||
|
||||
if ( !isset( \IPS\Request::i()->processing ) )
|
||||
{
|
||||
if ( isset( $changes['renew_options'] ) and $changes['renew_options'] )
|
||||
if ( isset( $changes['renew_options'] ) )
|
||||
{
|
||||
$matrix = new \IPS\Helpers\Form\Matrix( 'matrix', 'continue' );
|
||||
$matrix->manageable = FALSE;
|
||||
@@ -180,28 +181,31 @@ class _packages extends \IPS\Node\Controller
|
||||
},
|
||||
);
|
||||
|
||||
foreach ( json_decode( $changes['renew_options'], TRUE ) as $k => $oldOption )
|
||||
if ( $changes['renew_options'] )
|
||||
{
|
||||
$costs = array();
|
||||
foreach ( $oldOption['cost'] as $data )
|
||||
foreach ( json_decode( $changes['renew_options'], TRUE ) as $k => $oldOption )
|
||||
{
|
||||
$costs[] = new \IPS\nexus\Money( $data['amount'], $data['currency'] );
|
||||
$costs = array();
|
||||
foreach ( $oldOption['cost'] as $data )
|
||||
{
|
||||
$costs[] = new \IPS\nexus\Money( $data['amount'], $data['currency'] );
|
||||
}
|
||||
|
||||
switch ( $oldOption['unit'] )
|
||||
{
|
||||
case 'd':
|
||||
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_days', FALSE, array( 'pluralize' => array( $oldOption['term'] ) ) );
|
||||
break;
|
||||
case 'm':
|
||||
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_months', FALSE, array( 'pluralize' => array( $oldOption['term'] ) ) );
|
||||
break;
|
||||
case 'y':
|
||||
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_years', FALSE, array( 'pluralize' => array( $oldOption['term'] ) ) );
|
||||
break;
|
||||
}
|
||||
|
||||
$matrix->rows[ $k ] = array( \IPS\Member::loggedIn()->language()->addToStack( 'renew_option', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $costs, \IPS\Member::loggedIn()->language()->get('or_list_format') ), $term ) ) ), "o{$k}" );
|
||||
}
|
||||
|
||||
switch ( $oldOption['unit'] )
|
||||
{
|
||||
case 'd':
|
||||
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_days', FALSE, array( 'pluralize' => array( $oldOption['term'] ) ) );
|
||||
break;
|
||||
case 'm':
|
||||
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_months', FALSE, array( 'pluralize' => array( $oldOption['term'] ) ) );
|
||||
break;
|
||||
case 'y':
|
||||
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_years', FALSE, array( 'pluralize' => array( $oldOption['term'] ) ) );
|
||||
break;
|
||||
}
|
||||
|
||||
$matrix->rows[ $k ] = array( \IPS\Member::loggedIn()->language()->addToStack( 'renew_option', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $costs, \IPS\Member::loggedIn()->language()->get('or_list_format') ), $term ) ) ), "o{$k}" );
|
||||
}
|
||||
$matrix->rows['x'] = array( 'any_other_amount', '-' );
|
||||
|
||||
@@ -226,7 +230,7 @@ class _packages extends \IPS\Node\Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( isset( $changes['renew_options'] ) and !isset( \IPS\Request::i()->ba ) )
|
||||
{
|
||||
$needBaPrompt = FALSE;
|
||||
@@ -403,7 +407,7 @@ class _packages extends \IPS\Node\Controller
|
||||
'ps_member' => function( $val ) {
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Customer::load( $val )->link();
|
||||
return \IPS\Theme::i()->getTemplate('global', 'nexus')->userLink( \IPS\Member::load( $val ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
@@ -454,4 +458,34 @@ class _packages extends \IPS\Node\Controller
|
||||
\IPS\Output::i()->title = $package->_title;
|
||||
\IPS\Output::i()->output = $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Email Preview
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function emailPreview()
|
||||
{
|
||||
$functionName = 'emailPreview_' . mt_rand();
|
||||
\IPS\Theme::makeProcessFunction( \IPS\Request::i()->value, $functionName, '$purchase' );
|
||||
|
||||
$dummyPurchase = new \IPS\nexus\Purchase;
|
||||
$dummyPurchase->name = \IPS\Member::loggedIn()->language()->addToStack('p_email_preview_example');
|
||||
$dummyPurchase->member = \IPS\Member::loggedIn();
|
||||
$dummyPurchase->expires = \IPS\DateTime::create()->add( new \DateInterval('P1M') );
|
||||
$dummyPurchase->renewals = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( 10, \IPS\nexus\Customer::loggedIn()->defaultCurrency() ), new \DateInterval('P1M') );
|
||||
$dummyPurchase->custom_fields = array_fill( 0, \IPS\Db::i()->select( 'MAX(cf_id)', 'nexus_package_fields' )->first(), \IPS\Member::loggedIn()->language()->addToStack('p_email_preview_example') );
|
||||
$dummyPurchase->licenseKey = new \IPS\nexus\Purchase\LicenseKey\Standard;
|
||||
$dummyPurchase->licenseKey->key = 'XXXX-XXXX-XXXX-XXXX';
|
||||
|
||||
try
|
||||
{
|
||||
$output = \IPS\Email::buildFromContent( 'Test', call_user_func( 'IPS\\Theme\\'.$functionName, $dummyPurchase ) )->compileContent( 'html', \IPS\Member::loggedIn() );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
$output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( $e->getMessage(), 'error', $e->getMessage(), TRUE, TRUE );
|
||||
}
|
||||
\IPS\Output::i()->sendOutput( $output );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user