Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

@@ -12,7 +12,7 @@
namespace IPS\nexus\modules\front\clients;
/* 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;
@@ -49,29 +49,18 @@ class _invoices extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'node_error', '2X215/1', 404, '' );
}
}
else if ( isset( \IPS\Request::i()->do ) and \IPS\Request::i()->do == 'printout' and isset( $_SESSION['nexusMember'] ) )
{
$this->invoice = \IPS\nexus\Invoice::load( \IPS\Request::i()->id );
$guest = $this->invoice->guest_data;
if ( $guest['member']['email'] != $_SESSION['nexusMember']['email'] )
{
\IPS\Output::i()->error( 'node_error', '2X215/5', 404, '' );
}
}
else if ( isset( \IPS\Request::i()->do ) and \IPS\Request::i()->do == 'printout' and isset( \IPS\Request::i()->key ) )
{
$this->invoice = \IPS\nexus\Invoice::load( \IPS\Request::i()->id );
$guest = $this->invoice->guest_data;
if ( md5( $guest['member']['email'] . ';' . $guest['member']['joined'] ) != \IPS\Request::i()->key )
{
\IPS\Output::i()->error( 'node_error', '2X215/7', 404, '' );
}
}
else
{
\IPS\Output::i()->error( 'no_module_permission_guest', '2X215/6', 404, '' );
/* Prevent the vid key from being exposed in referrers */
\IPS\Output::i()->sendHeader( "Referrer-Policy: origin" );
$key = isset( \IPS\Request::i()->key ) ? \IPS\Request::i()->key : ( isset( \IPS\Request::i()->cookie['guestTransactionKey'] ) ? \IPS\Request::i()->cookie['guestTransactionKey'] : NULL );
$this->invoice = \IPS\nexus\Invoice::load( \IPS\Request::i()->id );
if( $this->invoice->member->member_id or !$key or !isset( $this->invoice->guest_data['guestTransactionKey'] ) or !\IPS\Login::compareHashes( $key, $this->invoice->guest_data['guestTransactionKey'] ) )
{
\IPS\Output::i()->error( 'no_module_permission_guest', '2X215/6', 404, '' );
}
}
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=invoices', 'front', 'clientsinvoices' ), \IPS\Member::loggedIn()->language()->addToStack('client_invoices') );
@@ -112,7 +101,7 @@ class _invoices extends \IPS\Dispatcher\Controller
{
$where = array( 'i_member=?', \IPS\Member::loggedIn()->member_id );
$parentContacts = \IPS\nexus\Customer::loggedIn()->parentContacts( array( 'billing=1' ) );
if ( count( $parentContacts ) )
if ( \count( $parentContacts ) )
{
$or = array();
foreach ( array_keys( iterator_to_array( $parentContacts ) ) as $id )
@@ -170,7 +159,7 @@ class _invoices extends \IPS\Dispatcher\Controller
$this->invoice->save();
\IPS\Output::i()->redirect( $this->invoice->url() );
}
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );;
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );;
}
/**
@@ -190,7 +179,7 @@ class _invoices extends \IPS\Dispatcher\Controller
$this->invoice->save();
\IPS\Output::i()->redirect( $this->invoice->url() );
}
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );;
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );;
}
/**
@@ -200,21 +189,7 @@ class _invoices extends \IPS\Dispatcher\Controller
*/
public function printout()
{
$address = NULL;
if ( $this->invoice->billaddress )
{
$address = $this->invoice->billaddress;
}
else
{
try
{
$address = \IPS\nexus\Customer\Address::constructFromData( \IPS\Db::i()->select( '*', 'nexus_customer_addresses', array( "member=? AND primary_billing=?", $this->invoice->member->member_id, 1 ) )->first() )->address;
}
catch( \UnderflowException $e ) {}
}
$output = \IPS\Theme::i()->getTemplate( 'invoices', 'nexus', 'global' )->printInvoice( $this->invoice, $this->invoice->summary(), $address );
$output = \IPS\Theme::i()->getTemplate( 'invoices', 'nexus', 'global' )->printInvoice( $this->invoice, $this->invoice->summary(), $this->invoice->billaddress ?: $this->invoice->member->primaryBillingAddress() );
\IPS\Output::i()->title = 'I' . $this->invoice->id;
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->blankTemplate( $output ) );
}
@@ -229,12 +204,12 @@ class _invoices extends \IPS\Dispatcher\Controller
/* CSRF check */
\IPS\Session::i()->csrfCheck();
/* Can only cancel the invoice if it's pending */
if ( $this->invoice->status !== \IPS\nexus\Invoice::STATUS_PENDING )
/* Can only cancel the invoice if it's pending and there are no processing transactions */
if ( $this->invoice->status !== \IPS\nexus\Invoice::STATUS_PENDING or \count( $this->invoice->transactions( [ \IPS\nexus\Transaction::STATUS_HELD, \IPS\nexus\Transaction::STATUS_REVIEW, \IPS\nexus\Transaction::STATUS_GATEWAY_PENDING, \IPS\nexus\Transaction::STATUS_DISPUTED ] ) ) )
{
\IPS\Output::i()->error( 'order_already_paid', '2X215/4', 403, '' );
}
/* If they have already made a partial payment, refund it to their account credit */
foreach ( $this->invoice->transactions( array( \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED ) ) as $transaction )
{