Version 4.0.13.1
This commit is contained in:
1 parent
f9e857d255
commit
c6a86f0d9b
7517 files changed
+597400
-668041
No files matched your search
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Comission Rules
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage
|
||||
* @since 15 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comission Rules
|
||||
*/
|
||||
class _commissionrules extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\nexus\CommissionRule';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'commission_rules_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'commission_rules_blurb', TRUE, TRUE );
|
||||
return parent::manage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief fields
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage
|
||||
* @since 12 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* fields
|
||||
*/
|
||||
class _fields extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\nexus\Customer\CustomField';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'customer_fields_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,480 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Purchases
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Nexus
|
||||
* @since 11 Feb 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purchases
|
||||
*/
|
||||
class _purchases extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* View
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_view' );
|
||||
|
||||
if ( \IPS\Request::i()->do !== 'findHostingAccount' )
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->purchase = \IPS\nexus\Purchase::load( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X195/2', 404, '' );
|
||||
}
|
||||
|
||||
|
||||
\IPS\Output::i()->title = $this->purchase->name . " (#{$this->purchase->id})";
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'purchases.css', 'nexus', 'admin' ) );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* View
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function view()
|
||||
{
|
||||
/* Popup view */
|
||||
if ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->hovercard ) )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'purchases' )->hovercard( $this->purchase );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create children tree */
|
||||
$children = \IPS\nexus\Purchase::tree( $this->purchase->acpUrl(), array(), "p{$this->purchase->id}", $this->purchase, FALSE );
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $children;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create associated invoices table */
|
||||
try
|
||||
{
|
||||
$originalInvoice = $this->purchase->original_invoice;
|
||||
$invoices = \IPS\nexus\Invoice::table( array( array( 'i_id=? OR ' . \IPS\Db::i()->findInSet( 'i_renewal_ids', array( $this->purchase->id ) ), $originalInvoice->id ) ), $this->purchase->acpUrl(), "p.{$this->purchase->id}" );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
$invoices = \IPS\nexus\Invoice::table( array( array( \IPS\Db::i()->findInSet( 'i_renewal_ids', array( $this->purchase->id ) ) ) ), $this->purchase->acpUrl(), "p.{$this->purchase->id}" );
|
||||
}
|
||||
$invoices->filters = array(
|
||||
'paid' => array( 'i_status=?', \IPS\nexus\Invoice::STATUS_PAID )
|
||||
);
|
||||
$invoices->advancedSearch = array(
|
||||
'i_status' => array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => \IPS\nexus\Invoice::statuses(), 'multiple' => TRUE ) ),
|
||||
'i_total' => \IPS\Helpers\Table\SEARCH_NUMERIC,
|
||||
'i_date' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
);
|
||||
|
||||
/* Custom Fields */
|
||||
$customFields = array();
|
||||
foreach ( $this->purchase->custom_fields as $k => $v )
|
||||
{
|
||||
try
|
||||
{
|
||||
$customFields[ $k ] = \IPS\nexus\Package\CustomField::load( $k )->displayValue( $v );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->sidebar['actions'] = $this->purchase->buttons();
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'purchases' )->view( $this->purchase, $children, $invoices, $customFields );
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function edit()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_edit' );
|
||||
|
||||
/* Work stuff out */
|
||||
$renewals = $this->purchase->renewals ?: NULL;
|
||||
$groupedChildren = array();
|
||||
if ( $renewals and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_purchases', array( 'ps_parent=? AND ps_grouped_renewals<>?', $this->purchase->id, '' ) )->first() )
|
||||
{
|
||||
$costPerDay = $this->purchase->renewals->costPerDay()->amount;
|
||||
foreach ( $this->purchase->children() as $child )
|
||||
{
|
||||
if ( $child->grouped_renewals )
|
||||
{
|
||||
$groupedChildren[] = $child;
|
||||
$childGroupedRenewals = $child->grouped_renewals;
|
||||
$childGroupedRenewalTerm = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $childGroupedRenewals['price'], $this->purchase->renewals->cost->currency ), new \DateInterval( 'P' . $childGroupedRenewals['term'] . mb_strtoupper( $childGroupedRenewals['unit'] ) ) );
|
||||
$costPerDay -= $childGroupedRenewalTerm->costPerDay()->amount;
|
||||
}
|
||||
}
|
||||
$renewals = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $costPerDay * $renewals->days(), $this->purchase->renewals->cost->currency ), $renewals->interval );
|
||||
}
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$this->purchase->acpEdit( $form, $renewals );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Ungroup children */
|
||||
foreach ( $groupedChildren as $child )
|
||||
{
|
||||
$child->ungroupFromParent();
|
||||
}
|
||||
|
||||
/* Update purchase */
|
||||
$this->purchase->acpEditSave( $values );
|
||||
|
||||
/* Regroup children */
|
||||
foreach ( $groupedChildren as $child )
|
||||
{
|
||||
$child->groupWithParent();
|
||||
}
|
||||
|
||||
/* Log */
|
||||
$this->purchase->member->log( 'purchase', array( 'type' => 'info', 'id' => $this->purchase->id, 'name' => $this->purchase->name ) );
|
||||
|
||||
/* Redirect */
|
||||
$this->_redirect();
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function transfer()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_transfer' );
|
||||
if ( $this->purchase->grouped_renewals )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_grouped', '2X195/6', 403, '' );
|
||||
}
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'ps_member', NULL, TRUE ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Transfer */
|
||||
$previousOwner = $this->purchase->member;
|
||||
$this->purchase->transfer( $values['ps_member'] );
|
||||
|
||||
/* Log */
|
||||
$previousOwner->log( 'purchase', array( 'type' => 'transfer_from', 'id' => $this->purchase->id, 'name' => $this->purchase->name, 'to' => $values['ps_member']->member_id ) );
|
||||
$this->purchase->member->log( 'purchase', array( 'type' => 'transfer_to', 'id' => $this->purchase->id, 'name' => $this->purchase->name, 'from' => $previousOwner->member_id ) );
|
||||
|
||||
/* Redirect */
|
||||
$this->_redirect();
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renew
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function renew()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_edit', 'nexus', 'payments' );
|
||||
if ( $this->purchase->grouped_renewals )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_grouped', '2X195/7', 403, '' );
|
||||
}
|
||||
|
||||
/* If this purchase has renewal term, we cannot generate a renewal invoice */
|
||||
if ( !$this->purchase->renewals )
|
||||
{
|
||||
\IPS\Output::i()->error( 'purchase_no_renew', '2X195/3', 403, '' );
|
||||
}
|
||||
if ( !$this->purchase->expire )
|
||||
{
|
||||
\IPS\Output::i()->error( 'purchase_no_expire', '1X195/C', 403, '' );
|
||||
}
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$cycles = $this->purchase->canRenewUntil( NULL, TRUE, TRUE );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'renew_cycles', 1, TRUE, array( 'min' => 1, 'max' => ( $cycles === TRUE ? NULL : $cycles ) ) ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Generate Invoice */
|
||||
$invoice = new \IPS\nexus\Invoice;
|
||||
$invoice->currency = $this->purchase->renewal_currency;
|
||||
$invoice->member = $this->purchase->member;
|
||||
$invoice->addItem( \IPS\nexus\Invoice\Item\Renewal::create( $this->purchase, $values['renew_cycles'] ) );
|
||||
$invoice->save();
|
||||
$invoice->sendNotification();
|
||||
|
||||
/* Update the purchase */
|
||||
$this->purchase->invoice_pending = $invoice;
|
||||
$this->purchase->save();
|
||||
|
||||
/* Take us to that invoice */
|
||||
\IPS\Output::i()->redirect( $invoice->acpUrl() );
|
||||
}
|
||||
|
||||
/* If this purchase already has an unpaid renewal invoice, display a warning */
|
||||
if ( $this->purchase->invoice_pending )
|
||||
{
|
||||
/* Which will be a proper warning if that invoice is still pending */
|
||||
if ( $this->purchase->invoice_pending->status === \IPS\nexus\Invoice::STATUS_PENDING )
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( \IPS\Member::loggedIn()->language()->addToStack('warn_renew_invoice_pending', FALSE, array( 'sprintf' => array( $this->purchase->invoice_pending->acpUrl() ) ) ), 'warning', NULL, FALSE, TRUE );
|
||||
}
|
||||
/* Or just informational if it is canceled or expired */
|
||||
elseif ( $this->purchase->invoice_pending->status !== \IPS\nexus\Invoice::STATUS_PAID )
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( \IPS\Member::loggedIn()->language()->addToStack('info_renew_invoice_pending', FALSE, array( 'sprintf' => array( $this->purchase->invoice_pending->acpUrl() ) ) ), 'information', NULL, FALSE, TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output .= $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function cancel()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_cancel' );
|
||||
if ( $this->purchase->grouped_renewals )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_grouped', '2X195/8', 403, '' );
|
||||
}
|
||||
|
||||
/* What options are available for cancelling? */
|
||||
$options = array();
|
||||
if ( $this->purchase->renewals )
|
||||
{
|
||||
$options['no_renew'] = 'cancel_type_no_renew';
|
||||
}
|
||||
$options['cancel'] = 'cancel_type_cancel';
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'cancel_type', 'no_renew', FALSE, array(
|
||||
'options' => $options,
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'ps_can_reactivate', FALSE ) );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Update purchase and log */
|
||||
if ( $values['cancel_type'] === 'no_renew' )
|
||||
{
|
||||
$this->purchase->renewals = NULL;
|
||||
$this->purchase->member->log( 'purchase', array( 'type' => 'info', 'id' => $this->purchase->id, 'name' => $this->purchase->name, 'info' => 'remove_renewals' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->purchase->cancelled = TRUE;
|
||||
$this->purchase->member->log( 'purchase', array( 'type' => 'cancel', 'id' => $this->purchase->id, 'name' => $this->purchase->name ) );
|
||||
}
|
||||
$this->purchase->can_reactivate = $values['ps_can_reactivate'];
|
||||
$this->purchase->save();
|
||||
|
||||
/* Redirect */
|
||||
$this->_redirect();
|
||||
}
|
||||
|
||||
/* Display form */
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reactivate
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function reactivate()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_cancel' );
|
||||
if ( $this->purchase->grouped_renewals )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_grouped', '2X195/9', 403, '' );
|
||||
}
|
||||
|
||||
$this->purchase->cancelled = FALSE;
|
||||
$this->purchase->save();
|
||||
$this->purchase->member->log( 'purchase', array( 'type' => 'uncancel', 'id' => $this->purchase->id, 'name' => $this->purchase->name ) );
|
||||
|
||||
$this->_redirect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function delete()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_delete' );
|
||||
|
||||
if ( $this->purchase->grouped_renewals )
|
||||
{
|
||||
\IPS\Output::i()->error( 'not_with_grouped', '2X195/A', 403, '' );
|
||||
}
|
||||
|
||||
$this->purchase->member->log( 'purchase', array( 'type' => 'delete', 'id' => $this->purchase->id, 'name' => $this->purchase->name ) );
|
||||
$this->purchase->delete();
|
||||
|
||||
\IPS\Output::i()->redirect( $this->purchase->member->acpUrl() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Extra
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function extra()
|
||||
{
|
||||
if ( $output = $this->purchase->acpAction() )
|
||||
{
|
||||
\IPS\Output::i()->output = $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->purchase->acpUrl() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Group
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function group()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_edit' );
|
||||
try
|
||||
{
|
||||
$this->purchase->groupWithParent();
|
||||
$this->purchase->member->log( 'purchase', array( 'type' => 'group', 'id' => $this->purchase->id, 'name' => $this->purchase->name ) );
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'grouperr_' . $e->getMessage(), '1X195/4', 403, '' );
|
||||
}
|
||||
$this->_redirect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ungroup
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function ungroup()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'purchases_edit' );
|
||||
try
|
||||
{
|
||||
$this->purchase->ungroupFromParent();
|
||||
$this->purchase->member->log( 'purchase', array( 'type' => 'ungroup', 'id' => $this->purchase->id, 'name' => $this->purchase->name ) );
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( '', '1X195/5', 403, '' );
|
||||
}
|
||||
$this->_redirect();
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _redirect()
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->r ) )
|
||||
{
|
||||
switch ( mb_substr( \IPS\Request::i()->r, 0, 1 ) )
|
||||
{
|
||||
case 'p':
|
||||
try
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\nexus\Purchase::load( $this->purchase->parent )->acpUrl() );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->purchase->member->acpUrl() );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
\IPS\Output::i()->redirect( $this->purchase->acpUrl() );
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
\IPS\Output::i()->redirect( $this->purchase->member->acpUrl() );
|
||||
break;
|
||||
|
||||
case 's':
|
||||
\IPS\Output::i()->redirect( \IPS\nexus\Support\Request::load( mb_substr( \IPS\Request::i()->r, 2 ) )->acpUrl() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $this->purchase->acpUrl() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Hosting Account
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function findHostingAccount()
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\nexus\Purchase::load( \IPS\Db::i()->select( 'ps_id', 'nexus_hosting_accounts', array( 'account_username=?', \IPS\Request::i()->username ) )->first() )->acpUrl() );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2X195/B', 404, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief referralbanners
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage
|
||||
* @since 18 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* referralbanners
|
||||
*/
|
||||
class _referralbanners extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\nexus\ReferralBanner';
|
||||
|
||||
/**
|
||||
* Title can contain HTML?
|
||||
*/
|
||||
public $_titleHtml = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'referralbanners_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'referral_banners_blurb', TRUE, TRUE );
|
||||
return parent::manage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function form()
|
||||
{
|
||||
parent::form();
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('referral_banners');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Referrals
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Nexus
|
||||
* @since 15 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Referrals
|
||||
*/
|
||||
class _referrals extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Call
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __call( $method, $args )
|
||||
{
|
||||
$tabs = array();
|
||||
if( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'referrals_manage' ) )
|
||||
{
|
||||
$tabs['refersettings'] = 'settings';
|
||||
}
|
||||
if( \IPS\Settings::i()->cm_ref_on and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'referrals_commission_rules' ) )
|
||||
{
|
||||
$tabs['commissionrules'] = 'commission_rules';
|
||||
}
|
||||
if( \IPS\Settings::i()->cm_ref_on and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'referrals_banners' ) )
|
||||
{
|
||||
$tabs['referralbanners'] = 'referral_banners';
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->tab ) and isset( $tabs[ \IPS\Request::i()->tab ] ) )
|
||||
{
|
||||
$activeTab = \IPS\Request::i()->tab;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_tabs = array_keys( $tabs ) ;
|
||||
$activeTab = array_shift( $_tabs );
|
||||
}
|
||||
|
||||
$classname = 'IPS\nexus\modules\admin\customers\\' . $activeTab;
|
||||
$class = new $classname;
|
||||
$class->url = \IPS\Http\Url::internal("app=nexus&module=customers&controller=referrals&tab={$activeTab}");
|
||||
$class->execute();
|
||||
|
||||
if ( $method !== 'manage' or \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__nexus_customers_referrals');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, \IPS\Output::i()->output, \IPS\Http\Url::internal( "app=nexus&module=customers&controller=referrals" ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Referral Settings
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Nexus
|
||||
* @since 15 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Referral Settings
|
||||
*/
|
||||
class _refersettings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$tabsKey = md5( \IPS\Http\Url::internal("app=nexus&module=customers&controller=referrals") );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'cm_ref_on', \IPS\Settings::i()->cm_ref_on, FALSE, array( 'togglesOn' => array( 'nexus_com_rules' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'nexus_com_rules', \IPS\Settings::i()->nexus_com_rules, FALSE, array( 'togglesOff' => array( 'nexus_com_rules_alt' ) ), NULL, NULL, NULL, 'nexus_com_rules' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'nexus_com_rules_alt', NULL, FALSE, array( 'app' => 'nexus', 'key' => 'nexus_com_rules_val', 'editor' => array( 'app' => 'core', 'key' => 'Admin', 'autoSaveKey' => 'nexus_com_rules_alt', 'attachIds' => array( NULL, NULL, 'nexus_com_rules_alt' ) ) ), NULL, NULL, NULL, 'nexus_com_rules_alt' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Lang::saveCustom( 'nexus', 'nexus_com_rules_val', $values['nexus_com_rules_alt'] );
|
||||
unset( $values['nexus_com_rules_alt'] );
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=nexus&module=customers&controller=referrals') );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Customer Search
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @subpackage Nexus
|
||||
* @since 12 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\admin\customers;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer Search
|
||||
*/
|
||||
class _search extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'customers_view' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* View Customers
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$table = new \IPS\Helpers\Table\Db( 'nexus_customers', \IPS\Http\Url::internal('app=nexus&module=customers&controller=search') );
|
||||
$table->langPrefix = 'customerTable_';
|
||||
$table->joins = array(
|
||||
array(
|
||||
'select' => 'core_members.*',
|
||||
'from' => 'core_members',
|
||||
'where' => 'core_members.member_id=nexus_customers.member_id'
|
||||
),
|
||||
array(
|
||||
'select' => 'address',
|
||||
'from' => 'nexus_customer_addresses',
|
||||
'where' => 'nexus_customer_addresses.member=nexus_customers.member_id AND primary_billing=1'
|
||||
)
|
||||
);
|
||||
$table->include = array( 'photo', 'cm_last_name', 'cm_first_name', 'email', 'address' );
|
||||
$table->parsers = array(
|
||||
'photo' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('customers')->rowPhoto( \IPS\Member::constructFromData( $row ) );
|
||||
},
|
||||
'address' => function( $val )
|
||||
{
|
||||
return \IPS\GeoLocation::buildFromJson( $val );
|
||||
}
|
||||
);
|
||||
$table->noSort = array( 'photo', 'address' );
|
||||
$table->quickSearch = 'email';
|
||||
|
||||
$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
|
||||
);
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots() as $field )
|
||||
{
|
||||
switch ( $field->type )
|
||||
{
|
||||
case 'Checkbox':
|
||||
case 'YesNo':
|
||||
$table->advancedSearch[ $field->column ] = \IPS\Helpers\Table\SEARCH_BOOL;
|
||||
break;
|
||||
|
||||
case 'CheckboxSet':
|
||||
case 'Select':
|
||||
case 'Radio':
|
||||
$table->advancedSearch[ $field->column ] = array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => json_decode( $field->extra ), 'multiple' => $field->multiple ) );
|
||||
break;
|
||||
|
||||
case 'Date':
|
||||
$table->advancedSearch[ $field->column ] = \IPS\Helpers\Table\SEARCH_DATE_RANGE;
|
||||
break;
|
||||
|
||||
case 'Member':
|
||||
$table->advancedSearch[ $field->column ] = array( \IPS\Helpers\Table\SEARCH_MEMBER, array( 'multiple' => $field->multiple ) );
|
||||
break;
|
||||
|
||||
case 'Number':
|
||||
$table->advancedSearch[ $field->column ] = \IPS\Helpers\Table\SEARCH_NUMERIC;
|
||||
break;
|
||||
|
||||
default:
|
||||
$table->advancedSearch[ $field->column ] = \IPS\Helpers\Table\SEARCH_CONTAINS_TEXT;
|
||||
break;
|
||||
}
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words[ 'customerTable_field_' . $field->id ] = $field->_title;
|
||||
|
||||
$table->parsers[ $field->column ] = array( $field, 'displayValue' );
|
||||
}
|
||||
|
||||
$table->rowButtons = function( $row )
|
||||
{
|
||||
return array(
|
||||
'view' => array(
|
||||
'icon' => 'search',
|
||||
'title' => 'view',
|
||||
'link' => \IPS\Http\Url::internal("app=nexus&module=customers&controller=view&id={$row['member_id']}"),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__nexus_customers');
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user