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,128 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Bulk mail extension
|
||||
* @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 Commerce
|
||||
* @since 20 Apr 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\BulkMail;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk mail extension
|
||||
*/
|
||||
class _Purchases
|
||||
{
|
||||
/**
|
||||
* Get Setting Field
|
||||
*
|
||||
* @param mixed $criteria Value returned from the save() method
|
||||
* @return array Array of form elements
|
||||
*/
|
||||
public function getSettingField( $criteria )
|
||||
{
|
||||
return array(
|
||||
new \IPS\Helpers\Form\Node( 'nexus_bm_filters_packages', isset( $criteria['nexus_bm_filters_packages'] ) ? array_filter( array_map( function( $val )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Package::load( $val );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}, explode( ',', $criteria['nexus_bm_filters_packages'] ) ) ) : 0, FALSE, array( 'zeroVal' => 'nexus_bm_filters_packages_none', 'multiple' => TRUE, 'class' => 'IPS\nexus\Package\Group', 'zeroValTogglesOff' => array( 'nexus_bm_filters_types' ), 'permissionCheck' => function( $node )
|
||||
{
|
||||
return !( $node instanceof \IPS\nexus\Package\Group );
|
||||
} ) ),
|
||||
new \IPS\Helpers\Form\CheckboxSet( 'nexus_bm_filters_type', isset( $criteria['nexus_bm_filters_type'] ) ? explode( ',', $criteria['nexus_bm_filters_type'] ) : array( 'active' ), FALSE, array( 'options' => array( 'active' => 'nexus_bm_filters_type_active', 'expired' => 'nexus_bm_filters_type_expired', 'canceled' => 'nexus_bm_filters_type_canceled' ) ), NULL, NULL, NULL, 'nexus_bm_filters_types' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the filter data
|
||||
*
|
||||
* @param array $post Form values
|
||||
* @return mixed False, or an array of data to use later when filtering the members
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function save( $post )
|
||||
{
|
||||
if ( is_array( $post['nexus_bm_filters_packages'] ) )
|
||||
{
|
||||
$ids = array();
|
||||
foreach ( $post['nexus_bm_filters_packages'] as $package )
|
||||
{
|
||||
$ids[] = $package->id;
|
||||
}
|
||||
|
||||
return array( 'nexus_bm_filters_packages' => implode( ',', $ids ), 'nexus_bm_filters_type' => implode( ',', $post['nexus_bm_filters_type'] ) );
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get where clause to add to the member retrieval database query
|
||||
*
|
||||
* @param mixed $data The array returned from the save() method
|
||||
* @return string|array|NULL Where clause
|
||||
*/
|
||||
public function getQueryWhereClause( $data )
|
||||
{
|
||||
if ( isset( $data['nexus_bm_filters_packages'] ) and $data['nexus_bm_filters_packages'] )
|
||||
{
|
||||
return 'ps_id IS NOT NULL';
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for member retrieval database query
|
||||
* Can be used to set joins
|
||||
*
|
||||
* @param mixed $data The array returned from the save() method
|
||||
* @param \IPS\Db\Query $query The query
|
||||
* @return void
|
||||
*/
|
||||
public function queryCallback( $data, &$query )
|
||||
{
|
||||
if ( isset( $data['nexus_bm_filters_packages'] ) and $data['nexus_bm_filters_packages'] )
|
||||
{
|
||||
$types = array();
|
||||
$_types = explode( ',', $data['nexus_bm_filters_type'] );
|
||||
if ( in_array( 'active', $_types ) )
|
||||
{
|
||||
$types[] = 'nexus_purchases.ps_active=1';
|
||||
}
|
||||
if ( in_array( 'expired', $_types ) )
|
||||
{
|
||||
$types[] = '( nexus_purchases.ps_active=0 AND nexus_purchases.ps_cancelled=0 )';
|
||||
}
|
||||
if ( in_array( 'canceled', $_types ) )
|
||||
{
|
||||
$types[] = 'nexus_purchases.ps_cancelled=1';
|
||||
}
|
||||
|
||||
|
||||
if ( !empty( $types ) )
|
||||
{
|
||||
$types = implode( ' OR ', $types );
|
||||
|
||||
$query->join( 'nexus_purchases', "nexus_purchases.ps_app='nexus' AND nexus_purchases.ps_type='package' AND nexus_purchases.ps_member=core_members.member_id AND " . \IPS\Db::i()->in( 'nexus_purchases.ps_item_id', explode( ',', $data['nexus_bm_filters_packages'] ) ) . " AND ( {$types} )" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Community Enhancements: EasyPost
|
||||
* @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 18 Jun 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\CommunityEnhancements;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Community Enhancement: EasyPost
|
||||
*/
|
||||
class _EasyPost
|
||||
{
|
||||
/**
|
||||
* @brief Enhancement is enabled?
|
||||
*/
|
||||
public $enabled = FALSE;
|
||||
|
||||
/**
|
||||
* @brief IPS-provided enhancement?
|
||||
*/
|
||||
public $ips = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Enhancement has configuration options?
|
||||
*/
|
||||
public $hasOptions = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Icon data
|
||||
*/
|
||||
public $icon = "easypost.png";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->enabled = (bool) \IPS\Settings::i()->easypost_api_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->test ) )
|
||||
{
|
||||
return $this->_test();
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'easypost_enable', (bool) \IPS\Settings::i()->easypost_api_key, FALSE, array( 'togglesOn' => array( 'easypost_api_key', 'easypost_phone', 'easypost_show_rates' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'easypost_api_key', \IPS\Settings::i()->easypost_api_key, FALSE, array(), NULL, NULL, NULL, 'easypost_api_key' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Tel( 'easypost_phone', \IPS\Settings::i()->easypost_phone, FALSE, array(), NULL, NULL, NULL, 'easypost_phone' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'easypost_show_rates', \IPS\Settings::i()->easypost_show_rates, FALSE, array(
|
||||
'options' => array( 1 => 'easypost_show_rates_1', 0 => 'easypost_show_rates_0' ),
|
||||
'toggles' => array( 1 => array( 'easypost_tax', 'easypost_price_adjustment', 'easypost_delivery_adjustment' ) )
|
||||
), NULL, NULL, NULL, 'easypost_show_rates' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'easypost_tax', \IPS\Settings::i()->easypost_tax, FALSE, array( 'class' => '\IPS\nexus\Tax', 'zeroVal' => 'do_not_tax' ), NULL, NULL, NULL, 'easypost_tax' ) );
|
||||
$form->add( new \IPS\nexus\Form\Money( 'easypost_price_adjustment', \IPS\Settings::i()->easypost_price_adjustment, FALSE, array(), NULL, NULL, NULL, 'easypost_price_adjustment' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'easypost_delivery_adjustment', \IPS\Settings::i()->easypost_delivery_adjustment, FALSE, array(), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'easypost_delivery_adjustment' ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$values['easypost_tax'] = $values['easypost_tax'] ? $values['easypost_tax']->_id : 0;
|
||||
$values['easypost_price_adjustment'] = json_encode( $values['easypost_price_adjustment'] );
|
||||
try
|
||||
{
|
||||
if ( $values['easypost_enable'] )
|
||||
{
|
||||
unset( $values['easypost_enable'] );
|
||||
$this->testSettings( $values['easypost_api_key'] );
|
||||
$form->saveAsSettings( $values );
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $values['easypost_enable'] );
|
||||
$values['easypost_api_key'] = '';
|
||||
$form->saveAsSettings( $values );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('saved');
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
{
|
||||
$form->error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
'help' => array(
|
||||
'title' => 'learn_more',
|
||||
'icon' => 'question-circle',
|
||||
'link' => \IPS\Http\Url::ips( 'docs/easypost' ),
|
||||
'target' => '_blank'
|
||||
),
|
||||
'test' => array(
|
||||
'title' => 'easypost_test',
|
||||
'icon' => 'cog',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=applications&controller=enhancements&do=edit&id=nexus_EasyPost&test=1' ),
|
||||
),
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable
|
||||
*
|
||||
* @param $enabled bool Enable/Disable
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function toggle( $enabled )
|
||||
{
|
||||
if ( $enabled )
|
||||
{
|
||||
throw new \LogicException;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => '' ), array( 'conf_key=?', 'easypost_api_key' ) );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Settings (on save to check if API key is valid)
|
||||
*
|
||||
* @param string|NULL $key Key to check
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
protected function testSettings( $key=NULL )
|
||||
{
|
||||
$response = \IPS\Http\Url::external( 'https://api.easypost.com/v2/addresses' )->request()->login( $key, '' )->get();
|
||||
if ( $response->httpResponseCode != 200 )
|
||||
{
|
||||
throw new \LogicException( \IPS\Member::loggedIn()->language()->addToStack('easypost_bad_api_key') );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Settings (full test)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _test()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->addMessage( 'easypost_test_blurb' );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'easypost_test_method', \IPS\Settings::i()->easypost_show_rates, TRUE, array(
|
||||
'options' => array( 1 => 'easypost_test_method_1', 0 => 'easypost_test_method_0' ),
|
||||
'toggles' => array(
|
||||
1 => array( 'easypost_test_products' ),
|
||||
0 => array( 'easypost_test_length', 'easypost_test_width', 'easypost_test_height', 'easypost_test_weight' )
|
||||
)
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'easypost_test_products', NULL, NULL, array( 'class' => 'IPS\nexus\Package\Group', 'multiple' => TRUE, 'permissionCheck' => function( $node )
|
||||
{
|
||||
if ( !( $node instanceof \IPS\nexus\Package\Product ) or !$node->physical )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
} ), function( $val )
|
||||
{
|
||||
if ( \IPS\Request::i()->easypost_test_method )
|
||||
{
|
||||
if ( empty( $val ) )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
}
|
||||
foreach ( $val as $package )
|
||||
{
|
||||
if ( !$package->physical )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'easypost_test_not_physical', FALSE, array( 'sprintf' => array( $package->_title ) ) ) );
|
||||
}
|
||||
foreach ( array( 'width', 'height', 'length' ) as $k )
|
||||
{
|
||||
if ( !$package->$k )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'easypost_test_no_' . $k, FALSE, array( 'sprintf' => array( $package->_title ) ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, NULL, NULL, 'easypost_test_products' ) );
|
||||
$form->add( new \IPS\nexus\Form\Length( 'easypost_test_length', NULL, NULL, array(), NULL, NULL, NULL, 'easypost_test_length' ) );
|
||||
$form->add( new \IPS\nexus\Form\Length( 'easypost_test_width', NULL, NULL, array(), NULL, NULL, NULL, 'easypost_test_width' ) );
|
||||
$form->add( new \IPS\nexus\Form\Length( 'easypost_test_height', NULL, NULL, array(), NULL, NULL, NULL, 'easypost_test_height' ) );
|
||||
$form->add( new \IPS\nexus\Form\Weight( 'easypost_test_weight', NULL, NULL, array(), NULL, NULL, NULL, 'easypost_test_weight' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Member( 'easypost_test_customer', \IPS\Member::loggedIn(), TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Address( 'easypost_test_address', NULL, TRUE ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
if ( $values['easypost_test_method'] )
|
||||
{
|
||||
$lengthInInches = 0;
|
||||
$widthInInches = 0;
|
||||
$heightInInches = 0;
|
||||
$weightInOz = 0;
|
||||
foreach ( $values['easypost_test_products'] as $package )
|
||||
{
|
||||
$weight = new \IPS\nexus\Shipping\Weight( $package->weight );
|
||||
$weightInOz += $weight->float('oz');
|
||||
|
||||
foreach ( array( 'length', 'width', 'height' ) as $k )
|
||||
{
|
||||
$length = new \IPS\nexus\Shipping\Length( $package->$k );
|
||||
|
||||
$v = "{$k}InInches";
|
||||
$$v += $length->float('in');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$lengthInInches = $values['easypost_test_length']->float('in');
|
||||
$widthInInches = $values['easypost_test_width']->float('in');
|
||||
$heightInInches = $values['easypost_test_height']->float('in');
|
||||
$weightInOz = $values['easypost_test_weight']->float('oz');
|
||||
}
|
||||
|
||||
$customer = \IPS\nexus\Customer::load( $values['easypost_test_customer']->member_id );
|
||||
|
||||
try
|
||||
{
|
||||
$rates = \IPS\nexus\Shipping\EasyPostRate::getRates( $lengthInInches, $widthInInches, $heightInInches, $weightInOz, $customer, $values['easypost_test_address'], $customer->defaultCurrency() );
|
||||
if ( isset( $rates['error'] ) )
|
||||
{
|
||||
\IPS\Output::i()->error( $rates['error']['message'], $rates['error']['code'] );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( $e->getMessage(), $e->getCode() );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'shiporders', 'nexus' )->easypostTest( $rates );
|
||||
return;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Community Enhancements: eNom
|
||||
* @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 08 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\CommunityEnhancements;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Community Enhancement
|
||||
*/
|
||||
class _Enom
|
||||
{
|
||||
/**
|
||||
* @brief Enhancement is enabled?
|
||||
*/
|
||||
public $enabled = FALSE;
|
||||
|
||||
/**
|
||||
* @brief IPS-provided enhancement?
|
||||
*/
|
||||
public $ips = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Enhancement has configuration options?
|
||||
*/
|
||||
public $hasOptions = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Icon data
|
||||
*/
|
||||
public $icon = "enom.gif";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->enabled = (bool) \IPS\Settings::i()->nexus_enom_un;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'nexus_enom_un', \IPS\Settings::i()->nexus_enom_un, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'nexus_enom_pw', \IPS\Settings::i()->nexus_enom_pw, TRUE ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
try
|
||||
{
|
||||
$enom = new \IPS\nexus\DomainRegistrar\Enom( $values['nexus_enom_un'], $values['nexus_enom_pw'] );
|
||||
$enom->check( 'example', 'com' );
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('saved');
|
||||
}
|
||||
catch ( \RuntimeException $e )
|
||||
{
|
||||
$form->error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
'help' => array(
|
||||
'title' => 'learn_more',
|
||||
'icon' => 'question-circle',
|
||||
'link' => \IPS\Http\Url::ips( 'docs/enom' ),
|
||||
'target' => '_blank'
|
||||
),
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable
|
||||
*
|
||||
* @param $enabled bool Enable/Disable
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function toggle( $enabled )
|
||||
{
|
||||
if ( $enabled )
|
||||
{
|
||||
throw new \LogicException;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => '' ), array( 'conf_key=? OR conf_key=?', 'nexus_enom_un', 'nexus_enom_pw' ) );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Community Enhancements: MaxMind
|
||||
* @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 07 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\CommunityEnhancements;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Community Enhancement
|
||||
*/
|
||||
class _MaxMind
|
||||
{
|
||||
/**
|
||||
* @brief Enhancement is enabled?
|
||||
*/
|
||||
public $enabled = FALSE;
|
||||
|
||||
/**
|
||||
* @brief IPS-provided enhancement?
|
||||
*/
|
||||
public $ips = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Enhancement has configuration options?
|
||||
*/
|
||||
public $hasOptions = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Icon data
|
||||
*/
|
||||
public $icon = "maxmind.png";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->enabled = (bool) \IPS\Settings::i()->maxmind_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'maxmind_enable', (bool) \IPS\Settings::i()->maxmind_key, FALSE, array( 'togglesOn' => array( 'maxmind_key', 'maxmind_error' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'maxmind_key', \IPS\Settings::i()->maxmind_key, FALSE, array(), NULL, NULL, NULL, 'maxmind_key' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'maxmind_error', \IPS\Settings::i()->maxmind_error, FALSE, array( 'options' => array( 'okay' => 'maxmind_error_okay', 'hold' => 'maxmind_error_hold' ) ), NULL, NULL, NULL, 'maxmind_error' ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $values['maxmind_enable'] )
|
||||
{
|
||||
unset( $values['maxmind_enable'] );
|
||||
$this->testSettings( $values['maxmind_key'] );
|
||||
$form->saveAsSettings( $values );
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $values['maxmind_enable'] );
|
||||
$values['maxmind_key'] = '';
|
||||
$form->saveAsSettings( $values );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('saved');
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
{
|
||||
$form->error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
'help' => array(
|
||||
'title' => 'learn_more',
|
||||
'icon' => 'question-circle',
|
||||
'link' => \IPS\Http\Url::ips( 'docs/maxmind' ),
|
||||
'target' => '_blank'
|
||||
),
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable
|
||||
*
|
||||
* @param $enabled bool Enable/Disable
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function toggle( $enabled )
|
||||
{
|
||||
if ( $enabled )
|
||||
{
|
||||
throw new \LogicException;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => '' ), array( 'conf_key=?', 'maxmind_key' ) );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Settings
|
||||
*
|
||||
* @param string|NULL $key Key to check
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
protected function testSettings( $key=NULL )
|
||||
{
|
||||
$testAddress = new \IPS\GeoLocation;
|
||||
$testAddress->addressLines = array( 'Invision Power Services, Inc.', 'PO Box 2365' );
|
||||
$testAddress->city = 'Forest';
|
||||
$testAddress->region = 'VA';
|
||||
$testAddress->country = 'US';
|
||||
$testAddress->postalCode = '24551';
|
||||
|
||||
$maxMind = new \IPS\nexus\Fraud\MaxMind\Request( FALSE, $key );
|
||||
$maxMind->setIpAddress( \IPS\Request::i()->ipAddress() );
|
||||
$maxMind->setBillingAddress( $testAddress );
|
||||
$maxMind = $maxMind->request();
|
||||
if ( $maxMind->err )
|
||||
{
|
||||
throw new \LogicException( $maxMind->err );
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Content Router extension: Reviews
|
||||
* @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 05 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\ContentRouter;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Content Router extension: Reviews
|
||||
*/
|
||||
class _Reviews
|
||||
{
|
||||
/**
|
||||
* @brief Content Item Classes
|
||||
*/
|
||||
public $classes = array( 'IPS\nexus\Package\Review' );
|
||||
|
||||
/**
|
||||
* @brief Item Classes for embed only
|
||||
*/
|
||||
public $embeddableContent = array( 'IPS\nexus\Package\Item' );
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Dashboard extension: Income
|
||||
* @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 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\Dashboard;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashboard extension: Income
|
||||
*/
|
||||
class _Income
|
||||
{
|
||||
/**
|
||||
* Can the current user view this dashboard item?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canView()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus' , 'transactions', 'transactions_manage' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the block HTML show on the dashboard
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBlock()
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart;
|
||||
|
||||
$chart->addHeader( "Day", 'date' );
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
$chart->addHeader( $currency, 'number' );
|
||||
}
|
||||
|
||||
$thirtyDaysAgo = \IPS\DateTime::create()->sub( new \DateInterval('P30D') );
|
||||
|
||||
$results = array();
|
||||
foreach( \IPS\Db::i()->select( "t_currency, DATE_FORMAT( FROM_UNIXTIME( t_date ), '%e %c %Y' ) AS date, SUM(t_amount)-SUM(t_partial_refund) AS amount", 'nexus_transactions', array( 't_date>? AND (t_status=? OR t_status=?)', $thirtyDaysAgo->getTimestamp(), \IPS\nexus\Transaction::STATUS_PAID, \IPS\nexus\Transaction::STATUS_PART_REFUNDED ), NULL, NULL, array( 't_currency', 'date' ) ) as $result )
|
||||
{
|
||||
$results[ $result['date'] ][ $result['t_currency'] ] = $result['amount'];
|
||||
}
|
||||
|
||||
$monthAndYear = date( 'n' ) . ' ' . date( 'Y' );
|
||||
foreach ( range( 30, 0 ) as $daysAgo )
|
||||
{
|
||||
$datetime = new \IPS\DateTime;
|
||||
$datetime->setTime( 0, 0, 0 );
|
||||
$datetime->sub( new \DateInterval( 'P' . $daysAgo . 'D' ) );
|
||||
$resultString = $datetime->format('j n Y');
|
||||
|
||||
if ( isset( $results[ $resultString ] ) )
|
||||
{
|
||||
$row = array( $datetime );
|
||||
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
if ( !isset( $results[ $resultString ][ $currency ] ) )
|
||||
{
|
||||
$row[] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$row[] = $results[ $resultString ][ $currency ];
|
||||
}
|
||||
}
|
||||
|
||||
$chart->addRow( $row );
|
||||
}
|
||||
else
|
||||
{
|
||||
$row = array( $datetime );
|
||||
foreach ( \IPS\nexus\Money::currencies() as $currency )
|
||||
{
|
||||
$row[] = 0;
|
||||
}
|
||||
$chart->addRow( $row );
|
||||
}
|
||||
}
|
||||
|
||||
return $chart->render( 'LineChart' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the block information
|
||||
*
|
||||
* @return array array( 'name' => 'Block title', 'key' => 'unique_key', 'size' => [1,2,3], 'by' => 'Author name' )
|
||||
*/
|
||||
public function getInfo()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the block data submitted. This method is only necessary if your block accepts some sort of submitted data to save (such as the 'admin notes' block).
|
||||
*
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function saveBlock()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Dashboard extension: PendingActions
|
||||
* @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 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\Dashboard;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Dashboard extension: PendingActions
|
||||
*/
|
||||
class _PendingActions
|
||||
{
|
||||
/**
|
||||
* Can the current user view this dashboard item?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canView()
|
||||
{
|
||||
return ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' )
|
||||
or
|
||||
\IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'shiporders_manage' )
|
||||
or
|
||||
\IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' )
|
||||
or
|
||||
\IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'hosting', 'errors_manage' )
|
||||
or
|
||||
\IPS\Settings::i()->nexus_payout and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the block HTML show on the dashboard
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBlock()
|
||||
{
|
||||
/* Pending transactions *might* happen some weird way, so always get the count... but only show the count if we have fraud rules set up */
|
||||
$pendingTransactions = NULL;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' ) )
|
||||
{
|
||||
$pendingTransactions = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( 't_status=?', \IPS\nexus\Transaction::STATUS_HELD ) )->first();
|
||||
if ( !$pendingTransactions and !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_fraud_rules' )->first() )
|
||||
{
|
||||
$pendingTransactions = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Same with shipments */
|
||||
$pendingShipments = NULL;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'shiporders_manage' ) )
|
||||
{
|
||||
$pendingShipments = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_ship_orders', array( 'o_status=?', \IPS\nexus\Shipping\Order::STATUS_PENDING ) )->first();
|
||||
if ( !$pendingShipments and !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages_products', 'p_physical=1' )->first() )
|
||||
{
|
||||
$pendingShipments = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* And advertisements */
|
||||
$pendingAdvertisements = NULL;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'promotion', 'advertisements_manage' ) )
|
||||
{
|
||||
$pendingAdvertisements = \IPS\Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_active=-1' ) )->first();
|
||||
if ( !$pendingAdvertisements and !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages_ads' )->first() )
|
||||
{
|
||||
$pendingAdvertisements = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* And hosting errors */
|
||||
$hostingErrors = NULL;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'hosting', 'errors_manage' ) )
|
||||
{
|
||||
$hostingErrors = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_hosting_errors' )->first();
|
||||
if ( !$hostingErrors and !\IPS\Db::i()->select( 'COUNT(*)', 'nexus_hosting_servers' )->first() )
|
||||
{
|
||||
$hostingErrors = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Withdrawals will only be if enabled */
|
||||
$pendingWithdrawals = NULL;
|
||||
if ( \IPS\Settings::i()->nexus_payout and \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'payouts_manage' ) )
|
||||
{
|
||||
$pendingWithdrawals = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', \IPS\nexus\Payout::STATUS_PENDING ) )->first();
|
||||
}
|
||||
|
||||
/* Show support if there are departments we can see */
|
||||
$openSupportRequests = NULL;
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'support', 'requests_manage' ) and \IPS\Db::i()->select( '*', 'nexus_support_departments', array( "( dpt_staff='*' OR " . \IPS\Db::i()->findInSet( 'dpt_staff', \IPS\nexus\Support\Department::staffDepartmentPerms() ) . ')' ) ) )
|
||||
{
|
||||
$myFilters = \IPS\nexus\Support\Request::myFilters();
|
||||
$openSupportRequests = \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_requests', array( array( "( dpt_staff='*' OR " . \IPS\Db::i()->findInSet( 'dpt_staff', \IPS\nexus\Support\Department::staffDepartmentPerms() ) . ')' ), $myFilters['whereClause'] ) )->join( 'nexus_support_departments', 'dpt_id=r_department' )->first();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'widgets.css', 'nexus', 'front' ) );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'dashboard', 'nexus' )->pendingActions( $pendingTransactions, $pendingShipments, $pendingWithdrawals, $openSupportRequests, $pendingAdvertisements, $hostingErrors );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the block information
|
||||
*
|
||||
* @return array array( 'name' => 'Block title', 'key' => 'unique_key', 'size' => [1,2,3], 'by' => 'Author name' )
|
||||
*/
|
||||
public function getInfo()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the block data submitted. This method is only necessary if your block accepts some sort of submitted data to save (such as the 'admin notes' block).
|
||||
*
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function saveBlock()
|
||||
{
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor Extension: Admin
|
||||
* @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 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Admin
|
||||
*/
|
||||
class _Admin
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $field The editor field
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member, $field )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @param array $attachment The attachment data
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment )
|
||||
{
|
||||
try
|
||||
{
|
||||
switch ( $id3 )
|
||||
{
|
||||
case 'pkg':
|
||||
case 'pkg-assoc':
|
||||
return \IPS\nexus\Package\Item::load( $id1 )->canView( $member );
|
||||
|
||||
case 'pkg-pg':
|
||||
$customer = \IPS\nexus\Customer::load( $member->member_id );
|
||||
if ( count( \IPS\nexus\extensions\nexus\Item\Package::getPurchases( $customer, $id1, FALSE ) ) )
|
||||
{
|
||||
$options = array( 'type' => 'attach', 'id' => $attachment['attach_id'], 'name' => $attachment['attach_file'] );
|
||||
if ( isset( $_SERVER['HTTP_REFERER'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$purchase = \IPS\nexus\Purchase::loadFromUrl( new \IPS\Http\Url( $_SERVER['HTTP_REFERER'] ) );
|
||||
$options['ps_id'] = $purchase->id;
|
||||
$options['ps_name'] = $purchase->name;
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
$customer->log( 'download', $options );
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
case 'invoice-header';
|
||||
case 'invoice-footer':
|
||||
case 'pgroup':
|
||||
return TRUE;
|
||||
|
||||
case 'network_status_text':
|
||||
return (bool) \IPS\Settings::i()->network_status;
|
||||
};
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
*
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
{
|
||||
switch ( $id3 )
|
||||
{
|
||||
case 'pkg':
|
||||
case 'pkg-assoc':
|
||||
case 'pkg-pg':
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&subnode=1&do=form&id={$id1}", 'admin' );
|
||||
|
||||
case 'pgroup':
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=store&controller=packages&do=form&id={$id1}", 'admin' );
|
||||
|
||||
case 'invoice-header';
|
||||
case 'invoice-footer':
|
||||
return \IPS\Http\Url::internal( 'app=nexus&module=payments&controller=invoices&do=settings', 'admin' );
|
||||
|
||||
case 'network_status_text':
|
||||
return \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=networkStatus', 'front', 'nexus_network_status' );
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild attachment images in non-content item areas
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildAttachmentImages( $offset, $max )
|
||||
{
|
||||
return $this->performRebuild( $offset, $max, array( 'IPS\Text\Parser', 'rebuildAttachmentUrls' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild content post-upgrade
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildContent( $offset, $max )
|
||||
{
|
||||
return $this->performRebuild( $offset, $max, array( 'IPS\Text\LegacyParser', 'parseStatic' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @param callable $callback Method to call to rebuild content
|
||||
* @return int Number completed
|
||||
*/
|
||||
protected function performRebuild( $offset, $max, $callback )
|
||||
{
|
||||
/* We will do everything except pages first */
|
||||
if( !$offset )
|
||||
{
|
||||
/* Language bits */
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_sys_lang_words', \IPS\Db::i()->in( 'word_key', array( 'nexus_com_rules_val', 'network_status_text_val' ) ) . " OR word_key LIKE 'nexus_donategoal_%_desc' OR word_key LIKE 'nexus_gateway_%_ins' OR word_key LIKE 'nexus_pgroup_%_desc' OR word_key LIKE 'nexus_package_%_desc' OR word_key LIKE 'nexus_package_%_page' OR word_key LIKE 'nexus_department_%_desc'", 'word_id ASC', array( $offset, $max ) ) as $word )
|
||||
{
|
||||
try
|
||||
{
|
||||
$rebuilt = call_user_func( $callback, $word['word_custom'] );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
{
|
||||
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
|
||||
{
|
||||
$rebuilt = preg_replace( "#\[/?([^\]]+?)\]#", '', $word['word_custom'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if( $rebuilt !== FALSE )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_sys_lang_words', array( 'word_custom' => $rebuilt ), 'word_id=' . $word['word_id'] );
|
||||
}
|
||||
}
|
||||
|
||||
/* Settings */
|
||||
foreach ( array( 'nexus_invoice_header', 'nexus_invoice_footer' ) as $k )
|
||||
{
|
||||
try
|
||||
{
|
||||
$newMessage = call_user_func( $callback, \IPS\Settings::i()->$k );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
{
|
||||
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
|
||||
{
|
||||
$newMessage = preg_replace( "#\[/?([^\]]+?)\]#", '', \IPS\Settings::i()->$k );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if( $newMessage !== FALSE )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => $newMessage ), array( "conf_key=?", $k ) );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Now do packages */
|
||||
$did = 0;
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_packages', null, 'p_id ASC', array( $offset, $max ) ) as $package )
|
||||
{
|
||||
$did++;
|
||||
|
||||
/* Update */
|
||||
try
|
||||
{
|
||||
$rebuilt = call_user_func( $callback, $package['p_page'] );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
{
|
||||
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
|
||||
{
|
||||
$rebuilt = preg_replace( "#\[/?([^\]]+?)\]#", '', $package['p_page'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if( $rebuilt !== FALSE )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_packages', array( 'p_page' => $rebuilt ), array( 'p_id=?', $package['p_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $did;
|
||||
}
|
||||
|
||||
/**
|
||||
* Total content count to be used in progress indicator
|
||||
*
|
||||
* @return int Total Count
|
||||
*/
|
||||
public function contentCount()
|
||||
{
|
||||
$count = 2;
|
||||
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*) as count', 'core_sys_lang_words', \IPS\Db::i()->in( 'word_key', array( 'nexus_com_rules_val', 'network_status_text_val' ) ) . " OR word_key LIKE 'nexus_donategoal_%_desc' OR word_key LIKE 'nexus_gateway_%_ins' OR word_key LIKE 'nexus_pgroup_%_desc' OR word_key LIKE 'nexus_package_%_desc' OR word_key LIKE 'nexus_package_%_page' OR word_key LIKE 'nexus_department_%_desc'" )->first();
|
||||
|
||||
$count += \IPS\Db::i()->select( 'COUNT(*) as count', 'nexus_packages' )->first();
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor Extension: Customer Fields and Notes
|
||||
* @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 29 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Customer Fields
|
||||
*/
|
||||
class _Customer
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $field The editor field
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member, $field )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
|
||||
{
|
||||
if ( ( $id3 !== 'note' and $member->member_id == $id1 ) or $member->hasAcpRestriction( 'nexus', 'customers', 'customers_view' ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
*
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
{
|
||||
if ( \IPS\Dispatcher::i()->controllerLocation === 'admin' )
|
||||
{
|
||||
return \IPS\nexus\Customer::load( $id1 )->acpUrl();
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo', array(), \IPS\Settings::i()->nexus_https );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild attachment images in non-content item areas
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @return int Number completed
|
||||
*/
|
||||
public function rebuildAttachmentImages( $offset, $max )
|
||||
{
|
||||
return $this->performRebuild( $offset, $max, array( 'IPS\Text\Parser', 'rebuildAttachmentUrls' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild content post-upgrade
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @return int Number completed
|
||||
* @note This method is optional and will only be called if it exists
|
||||
*/
|
||||
public function rebuildContent( $offset, $max )
|
||||
{
|
||||
return $this->performRebuild( $offset, $max, array( 'IPS\Text\LegacyParser', 'parseStatic' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
|
||||
*
|
||||
* @param int|null $offset Offset to start from
|
||||
* @param int|null $max Maximum to parse
|
||||
* @param callable $callback Method to call to rebuild content
|
||||
* @return int Number completed
|
||||
*/
|
||||
protected function performRebuild( $offset, $max, $callback )
|
||||
{
|
||||
$did = 0;
|
||||
|
||||
/* Get editor fields */
|
||||
$editorFields = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_customer_fields', "f_type='Editor'" ) as $field )
|
||||
{
|
||||
$editorFields[] = 'field_' . $field['f_id'];
|
||||
}
|
||||
|
||||
if( !count( $editorFields ) )
|
||||
{
|
||||
return $did;
|
||||
}
|
||||
|
||||
/* Now update the content */
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_customers', implode( " IS NOT NULL OR ", $editorFields ) . " IS NOT NULL", 'member_id ASC', array( $offset, $max ) ) as $member )
|
||||
{
|
||||
$did++;
|
||||
|
||||
/* Update */
|
||||
$toUpdate = array();
|
||||
|
||||
foreach( $editorFields as $fieldId )
|
||||
{
|
||||
try
|
||||
{
|
||||
$rebuilt = call_user_func( $callback, $member[ $fieldId ], \IPS\Member::load( $member['member_id'] ) );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
{
|
||||
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
|
||||
{
|
||||
$rebuilt = preg_replace( "#\[/?([^\]]+?)\]#", '', $member[ $fieldId ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if( $rebuilt )
|
||||
{
|
||||
$toUpdate[ $fieldId ] = $rebuilt;
|
||||
}
|
||||
}
|
||||
|
||||
if( count( $toUpdate ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customers', $toUpdate, array( 'member_id=?', $member['member_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $did;
|
||||
}
|
||||
|
||||
/**
|
||||
* Total content count to be used in progress indicator
|
||||
*
|
||||
* @return int Total Count
|
||||
*/
|
||||
public function contentCount()
|
||||
{
|
||||
/* Get editor fields */
|
||||
$editorFields = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_customer_fields', "f_type='Editor'" ) as $field )
|
||||
{
|
||||
$editorFields[] = 'field_' . $field['f_id'];
|
||||
}
|
||||
|
||||
if( !count( $editorFields ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return \IPS\Db::i()->select( 'COUNT(*) as count', 'nexus_customers', implode( " IS NOT NULL OR ", $editorFields ) . " IS NOT NULL" )->first();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor Extension: Purchase Custom 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 Nexus
|
||||
* @since 23 Feb 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Support
|
||||
*/
|
||||
class _Purchases
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $field The editor field
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member, $field )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Purchase::load( $id )->canView( $member );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
*
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
{
|
||||
return \IPS\nexus\Purchase::load( $id2 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor Extension: Product Reviews
|
||||
* @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 5 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Product Reviews
|
||||
*/
|
||||
class _Store
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $field The editor field
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member, $field )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return bool
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Package\Item::load( $id1 )->canView( $member );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
*
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
{
|
||||
return \IPS\nexus\Package\Review::load( $id2 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Editor Extension: Support
|
||||
* @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 09 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\EditorLocations;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Support
|
||||
*/
|
||||
class _Support
|
||||
{
|
||||
/**
|
||||
* Can we use HTML in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canUseHtml( $member )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can we use attachments in this editor?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Helpers\Form\Editor $field The editor field
|
||||
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
|
||||
*/
|
||||
public function canAttach( $member, $field )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permission check for attachments
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
*/
|
||||
public function attachmentPermissionCheck( $member, $id1, $id2, $id3 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\nexus\Support\Request::load( $id1 )->canView( $member );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment lookup
|
||||
*
|
||||
* @param int|null $id1 Primary ID
|
||||
* @param int|null $id2 Secondary ID
|
||||
* @param string|null $id3 Arbitrary data
|
||||
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function attachmentLookup( $id1, $id2, $id3 )
|
||||
{
|
||||
return \IPS\nexus\Support\Reply::load( $id2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* HTMLPurifier Configuration
|
||||
*
|
||||
* @param \HTMLPurifier_Config $config Configuration
|
||||
* @return void
|
||||
*/
|
||||
public function htmlPurifierConfig( \HTMLPurifier_Config $config )
|
||||
{
|
||||
$config->set( 'AutoFormat.Linkify', TRUE );
|
||||
$config->set( 'URI.Munge', (string) \IPS\Http\Url::internal( "app=core&module=system&controller=redirect&url=%s&key=%t&resource=%r", 'front' ) );
|
||||
$config->set( 'URI.MungeResources', TRUE );
|
||||
$config->set( 'URI.MungeSecretKey', md5( \IPS\Settings::i()->sql_pass . \IPS\Settings::i()->board_url . \IPS\Settings::i()->sql_database ) );
|
||||
}
|
||||
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Advertisement Images
|
||||
* @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 14 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Extension: Advertisement Images
|
||||
*/
|
||||
class _Ads
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ), 'ad_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$images = json_decode( $record['ad_images'], TRUE );
|
||||
foreach ( $images as $key => $location )
|
||||
{
|
||||
try
|
||||
{
|
||||
$images[ $key ] = (string) \IPS\File::get( $oldConfiguration ?: 'nexus_Ads', $location )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
\IPS\Db::i()->update( 'core_advertisements', array( 'ad_images' => json_encode( $images ) ), array( 'ad_id=?', $record['ad_id'] ) );
|
||||
unset( \IPS\Data\Cache::i()->advertisements );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ), 'ad_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$images = json_decode( $record['ad_images'], TRUE );
|
||||
|
||||
foreach ( $images as $key => $location )
|
||||
{
|
||||
$images[ $key ] = \IPS\File::repairUrl( $location );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_advertisements', array( 'ad_images' => json_encode( $images ) ), array( 'ad_id=?', $record['ad_id'] ) );
|
||||
unset( \IPS\Data\Cache::i()->advertisements );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) ) as $ad )
|
||||
{
|
||||
if ( in_array( (string) $file, json_decode( $ad['ad_images'], TRUE ) ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_advertisements', array( 'ad_member<>0 or ad_member IS NULL' ) ) as $ad )
|
||||
{
|
||||
foreach ( json_decode( $ad['ad_images'], TRUE ) as $key => $location )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Products', $location )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Customer 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 Nexus
|
||||
* @since 29 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Customer Fields
|
||||
*/
|
||||
class _Customer
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customers', implode( ' OR ', $where ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$ids = array();
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
throw new \Underflowexception;
|
||||
}
|
||||
|
||||
$customer = \IPS\Db::i()->select( '*', 'nexus_customers', implode( ' OR ', $where ) )->first();
|
||||
$update = array();
|
||||
foreach ( $ids as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
$update[ 'field_' . $id ] = (string) \IPS\File::get( $oldConfiguration ?: 'nexus_Customer', $update[ 'field_' . $id ] )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $update ) )
|
||||
{
|
||||
foreach( $update as $k => $v )
|
||||
{
|
||||
if ( $update[ $k ] == $customer[ $k ] )
|
||||
{
|
||||
unset( $update[ $k ] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $update ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customers', $update, array( 'member_id=?', $customer['member_id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$ids = array();
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
throw new \Underflowexception;
|
||||
}
|
||||
|
||||
$customer = \IPS\Db::i()->select( '*', 'nexus_customers', implode( ' OR ', $where ) )->first();
|
||||
$update = array();
|
||||
foreach ( $ids as $id )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $customer[ 'field_' . $id ] ) )
|
||||
{
|
||||
$update[ 'field_' . $id ] = $new;
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $update ) )
|
||||
{
|
||||
if ( count( $update ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customers', $update, array( 'member_id=?', $customer['member_id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
$_where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$_where[] = "field_{$field->id}=?";
|
||||
}
|
||||
if ( !count( $_where ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$where = array_fill( 0, count( $_where ), (string) $file );
|
||||
array_unshift( $where, implode( ' OR ', $_where ) );
|
||||
|
||||
return (bool) \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customers', $where )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$ids = array();
|
||||
$where = array();
|
||||
foreach ( \IPS\nexus\Customer\CustomField::roots( NULL, NULL, array( 'f_type=?', 'Upload' ) ) as $field )
|
||||
{
|
||||
$ids[] = $field->id;
|
||||
$where[] = "field_{$field->id}<>''";
|
||||
}
|
||||
if ( !count( $where ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_customers', implode( ' OR ', $where ) ) as $customer )
|
||||
{
|
||||
foreach ( $ids as $id )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Customer', $customer[ 'field_' . $id ] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Package Groups
|
||||
* @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 5 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Package Groups
|
||||
*/
|
||||
class _PackageGroups
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_package_groups', array( 'pg_image<>?', '' ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image<>?', '' ), 'pg_id', array( $offset, 1 ) )->first();
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::get( $oldConfiguration ?: 'nexus_PackageGroups', $record['pg_image'] )->move( $storageConfiguration );
|
||||
|
||||
if ( (string) $file != $record['pg_image'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_groups', array( 'pg_image' => (string) $file ), array( 'pg_id=?', $record['pg_id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image<>?', '' ), 'pg_id', array( $offset, 1 ) )->first();
|
||||
|
||||
if ( $new = \IPS\File::repairUrl( $record['pg_image'] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_groups', array( 'pg_image' => $new ), array( 'pg_id=?', $record['pg_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image=?', (string) $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_package_groups', array( 'pg_image<>?', '' ) ) as $product )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_PackageGroups', $product['pg_image'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Product Images
|
||||
* @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 5 May 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Package Images
|
||||
*/
|
||||
class _Products
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_package_images' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_images', array(), 'image_id', array( $offset, 1 ) )->first();
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::get( $oldConfiguration ?: 'nexus_Products', $record['image_location'] )->move( $storageConfiguration );
|
||||
|
||||
if ( (string) $file != $record['image_location'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_images', array( 'image_location' => (string) $file ), array( 'image_id=?', $record['image_id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_package_images', array(), 'image_id', array( $offset, 1 ) )->first();
|
||||
|
||||
if ( $new = \IPS\File::repairUrl( $record['image_location'] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_package_images', array( 'image_location' => $new ), array( 'image_id=?', $record['image_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_package_images', array( 'image_location=?', (string) $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_package_images', "image_location IS NOT NULL" ) as $product )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Products', $product['image_location'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Purchase Custom 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 Nexus
|
||||
* @since 23 Feb 2015
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Purchase Custom Fields
|
||||
*/
|
||||
class _PurchaseFields
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_package_fields', array( 'cf_type=?', 'upload' ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->packages )
|
||||
{
|
||||
$packages = array_merge( $packages, explode( ',', $field->packages ) );
|
||||
}
|
||||
}
|
||||
|
||||
$purchase = \IPS\Db::i()->select( '*', 'nexus_purchases', array(
|
||||
array( 'ps_app=?', 'nexus' ),
|
||||
array( 'ps_type=?', 'package' ),
|
||||
array( \IPS\Db::i()->in( 'ps_item_id', array_unique( $packages ) ) )
|
||||
), 'ps_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$fieldValues[ $k ] = \IPS\File::get( $oldConfiguration ?: 'nexus_PurchaseFields', $fieldValues[ $k ] )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_purchases', array( 'ps_custom_fields' => json_encode( $fieldValues ) ), array( 'ps_id=?', $purchase['ps_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->packages )
|
||||
{
|
||||
$packages = array_merge( $packages, explode( ',', $field->packages ) );
|
||||
}
|
||||
}
|
||||
|
||||
$purchase = \IPS\Db::i()->select( '*', 'nexus_purchases', array(
|
||||
array( 'ps_app=?', 'nexus' ),
|
||||
array( 'ps_type=?', 'package' ),
|
||||
array( \IPS\Db::i()->in( 'ps_item_id', array_unique( $packages ) ) )
|
||||
), 'ps_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $fieldValues[ $k ] ) )
|
||||
{
|
||||
$fieldValues[ $k ] = $new;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_purchases', array( 'ps_custom_fields' => json_encode( $fieldValues ) ), array( 'ps_id=?', $purchase['ps_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_purchases', array( "ps_custom_fields LIKE ?", "%{$file}%" ) ) as $purchase )
|
||||
{
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $fieldValues[ $field->id ] == (string) $file )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$customFields = \IPS\nexus\Package\CustomField::roots( NULL, NULL, array( 'cf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$packages = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->packages )
|
||||
{
|
||||
$packages = array_merge( $packages, explode( ',', $field->packages ) );
|
||||
}
|
||||
}
|
||||
|
||||
$where = array(
|
||||
array( 'ps_app=?', 'nexus' ),
|
||||
array( 'ps_type=?', 'package' ),
|
||||
array( \IPS\Db::i()->in( 'ps_item_id', array_unique( $packages ) ) )
|
||||
);
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_purchases', $where ) as $purchase )
|
||||
{
|
||||
$fieldValues = json_decode( $purchase['ps_custom_fields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_PurchaseFields', $fieldValues[ $k ] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Referral Banners
|
||||
* @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 18 Aug 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Referral Banners
|
||||
*/
|
||||
class _ReferralBanners
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_referral_banners', 'rb_upload=1' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_referral_banners', 'rb_upload=1', 'rb_id', array( $offset, 1 ) )->first();
|
||||
|
||||
try
|
||||
{
|
||||
$file = \IPS\File::get( $oldConfiguration ?: 'nexus_ReferralBanners', $record['rb_url'] )->move( $storageConfiguration );
|
||||
|
||||
if ( (string) $file != $record['rb_url'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_referral_banners', array( 'rb_url' => (string) $file ), array( 'rb_id=?', $record['rb_id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
$record = \IPS\Db::i()->select( '*', 'nexus_referral_banners', 'rb_upload=1', 'rb_id', array( $offset, 1 ) )->first();
|
||||
|
||||
if ( $new = \IPS\File::repairUrl( $record['rb_url'] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_referral_banners', array( 'rb_url' => $new ), array( 'rb_id=?', $record['rb_id'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_referral_banners', array( 'rb_url=? and rb_upload=1', (string) $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_referral_banners', 'rb_upload=1' ) as $banner )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_ReferralBanners', $banner['rb_url'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Storage Extension: Support Custom Fields / Severity Icons
|
||||
* @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 17 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FileStorage;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Storage Extension: Support Custom Fields / Severity Icons
|
||||
*/
|
||||
class _Support
|
||||
{
|
||||
/**
|
||||
* Count stored files
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_fields', array( 'sf_type=?', 'upload' ) )->first() + \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_severities', 'sev_icon IS NOT NULL' )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move stored files
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @param int $storageConfiguration New storage configuration ID
|
||||
* @param int|NULL $oldConfiguration Old storage configuration ID
|
||||
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
|
||||
* @return void
|
||||
*/
|
||||
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
|
||||
{
|
||||
if ( $offset === 0 )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_support_severities' ) as $severity )
|
||||
{
|
||||
if ( $severity['sev_icon'] )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_support_severities', array( 'sev_icon' => \IPS\File::get( $oldConfiguration ?: 'nexus_Support', $severity['sev_icon'] )->move( $storageConfiguration ) ), array( 'sev_id=?', $severity['sev_id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->departments and $field->departments !== '*' )
|
||||
{
|
||||
$departments = array_merge( $departments, explode( ',', $field->departments ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $where !== NULL )
|
||||
{
|
||||
$where = \IPS\Db::i()->in( 'r_department', array_unique( $departments ) );
|
||||
}
|
||||
|
||||
$request = \IPS\Db::i()->select( '*', 'nexus_support_requests', $where, 'r_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$fieldValues[ $k ] = \IPS\File::get( $oldConfiguration ?: 'nexus_Support', $fieldValues[ $k ] )->move( $storageConfiguration );
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Any issues are logged */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_support_requests', array( 'r_cfields' => json_encode( $fieldValues ) ), array( 'r_id=?', $request['r_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix all URLs
|
||||
*
|
||||
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
|
||||
* @return void
|
||||
*/
|
||||
public function fixUrls( $offset )
|
||||
{
|
||||
if ( $offset === 0 )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_support_severities' ) as $severity )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $severity['sev_icon'] ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_support_severities', array( 'sev_icon' => $new ), array( 'sev_id=?', $severity['sev_id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->departments and $field->departments !== '*' )
|
||||
{
|
||||
$departments = array_merge( $departments, explode( ',', $field->departments ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $where !== NULL )
|
||||
{
|
||||
$where = \IPS\Db::i()->in( 'r_department', array_unique( $departments ) );
|
||||
}
|
||||
|
||||
$request = \IPS\Db::i()->select( '*', 'nexus_support_requests', $where, 'r_id', array( $offset, 1 ) )->first();
|
||||
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
if ( $new = \IPS\File::repairUrl( $fieldValues[ $k ] ) )
|
||||
{
|
||||
$fieldValues[ $k ] = $new;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_support_requests', array( 'r_cfields' => json_encode( $fieldValues ) ), array( 'r_id=?', $request['r_id'] ) );
|
||||
}
|
||||
|
||||
throw new \UnderflowException;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a file is valid
|
||||
*
|
||||
* @param \IPS\Http\Url $file The file to check
|
||||
* @return bool
|
||||
*/
|
||||
public function isValidFile( $file )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'nexus_support_severities', array( 'sev_icon=?', (string) $file ) )->first();
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_support_requests', array( "r_cfields LIKE ?", "%{$file}%" ) ) as $request )
|
||||
{
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $fieldValues[ $field->id ] == (string) $file )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all stored files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
foreach ( \IPS\Db::i()->select( '*', 'nexus_support_severities' ) as $severity )
|
||||
{
|
||||
if ( $severity['sev_icon'] )
|
||||
{
|
||||
\IPS\File::get( 'nexus_Support', $severity['sev_icon'] )->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$customFields = \IPS\nexus\Support\CustomField::roots( NULL, NULL, array( 'sf_type=?', 'upload' ) );
|
||||
if ( count( $customFields ) )
|
||||
{
|
||||
$where = array();
|
||||
$departments = array();
|
||||
foreach ( $customFields as $field )
|
||||
{
|
||||
if ( $field->departments and $field->departments !== '*' )
|
||||
{
|
||||
$departments = array_merge( $departments, explode( ',', $departments ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( $where !== NULL )
|
||||
{
|
||||
$where = \IPS\Db::i()->in( 'r_department', array_unique( $departments ) );
|
||||
}
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'nexus_support_requests', $where ) as $request )
|
||||
{
|
||||
$fieldValues = json_decode( $request['r_cfields'], TRUE );
|
||||
foreach ( $fieldValues as $k => $v )
|
||||
{
|
||||
if ( array_key_exists( $k, $customFields ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'nexus_Support', $fieldValues[ $k ] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Front Navigation Extension: Store
|
||||
* @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 29 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Store
|
||||
*/
|
||||
class _Store
|
||||
{
|
||||
/**
|
||||
* Can access?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canView()
|
||||
{
|
||||
return !\IPS\Application::load('nexus')->hide_tab and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'store' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('module__nexus_store');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=store&controller=store", 'front', 'store' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'store';
|
||||
}
|
||||
|
||||
/**
|
||||
* Children
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function children()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Front Navigation Extension: Support
|
||||
* @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 08 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\FrontNavigation;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Front Navigation Extension: Support
|
||||
*/
|
||||
class _Support
|
||||
{
|
||||
/**
|
||||
* Can access?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canView()
|
||||
{
|
||||
return !\IPS\Application::load('nexus')->hide_tab and \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'support' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('support');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Link
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public function link()
|
||||
{
|
||||
return \IPS\Http\Url::internal( "app=nexus&module=support&controller=home", 'front', 'support' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Active?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function active()
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory === 'nexus' and \IPS\Dispatcher::i()->module and \IPS\Dispatcher::i()->module->key === 'support';
|
||||
}
|
||||
|
||||
/**
|
||||
* Children
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function children()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Nexus Incoming Email Handler
|
||||
* @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 07 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\IncomingEmail;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Community Enhancement
|
||||
*/
|
||||
class _Support
|
||||
{
|
||||
/**
|
||||
* Handle email
|
||||
*
|
||||
* @param \IPS\Email\Incoming $email The email
|
||||
* @return bool
|
||||
*/
|
||||
public function process( \IPS\Email\Incoming $email )
|
||||
{
|
||||
/* Is it from an actual member? */
|
||||
$member = \IPS\Member::load( $email->data['from'], 'email' );
|
||||
|
||||
/* Replying? */
|
||||
if ( preg_match( '/\[SR(\d+?)\.(.+?)(\.(\d+))?\]/', $email->data['raw'], $matches ) or preg_match( '/\[SR(\d+?)\.(.+?)(\.(\d+))?\]/', $email->data['message'], $matches ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$request = \IPS\nexus\Support\Request::load( $matches[1] );
|
||||
if ( $request->email_key === $matches[2] )
|
||||
{
|
||||
$staff = array_key_exists( $member->member_id, \IPS\nexus\Support\Request::staff() );
|
||||
|
||||
$pending = FALSE;
|
||||
$newMessage = NULL;
|
||||
if ( $staff and isset( $matches[4] ) )
|
||||
{
|
||||
$newMessage = $request->comments( 1, 0, 'date', 'desc' );
|
||||
if ( $matches[4] != $newMessage->id )
|
||||
{
|
||||
$pending = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
$request->status = \IPS\nexus\Support\Status::load( TRUE, $staff ? 'status_default_staff' : 'status_default_member' );
|
||||
$request->last_reply = time();
|
||||
$request->last_reply_by = (int) $member->member_id;
|
||||
$request->replies++;
|
||||
$request->save();
|
||||
|
||||
$reply = new \IPS\nexus\Support\Reply;
|
||||
$reply->request = $request->id;
|
||||
$reply->member = (int) $member->member_id;
|
||||
$reply->type = $staff ? ( $pending ? $reply::REPLY_PENDING : $reply::REPLY_STAFF ) : $reply::REPLY_EMAIL;
|
||||
$reply->post = $email->data['message'];
|
||||
$reply->date = time();
|
||||
$reply->email = $email->data['from'];
|
||||
$reply->cc = $email->data['cc'];
|
||||
$reply->raw = $email->data['raw'];
|
||||
$reply->textformat = $email->data['alternative'];
|
||||
$reply->save();
|
||||
static::makeAndClaimAttachments( $email->data['attachments'], $reply );
|
||||
|
||||
if ( $pending )
|
||||
{
|
||||
$notifyEmail = \IPS\Email::buildFromTemplate( 'nexus', 'staffReplyPending', array( $reply, $newMessage ) );
|
||||
$notifyEmail->send( $member );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $staff )
|
||||
{
|
||||
$defaultRecipients = $request->getDefaultRecipients();
|
||||
$reply->sendCustomerNotifications( $defaultRecipients['to'], $defaultRecipients['cc'], $defaultRecipients['bcc'] );
|
||||
}
|
||||
$reply->sendNotifications();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) {}
|
||||
}
|
||||
|
||||
/* Nope, creating a new one */
|
||||
try
|
||||
{
|
||||
/* Load department */
|
||||
$department = \IPS\nexus\Support\Department::load( $email->data['to'], 'dpt_email' );
|
||||
|
||||
/* Has it been forwarded? */
|
||||
if ( preg_match( '/^FWD?: (.*)$/i', $email->data['subject'], $matches ) )
|
||||
{
|
||||
$originallyFromEmail = NULL;
|
||||
if ( isset( $email->mail->headers['original-recipient'] ) )
|
||||
{
|
||||
$originallyFromEmail = preg_replace( '/^.*;(.*)$/', '$1', $email->mail->headers['original-recipient'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( preg_match( '/From:.+?(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)/i', $email->data['quoted'], $_matches ) )
|
||||
{
|
||||
$originallyFromEmail = $_matches[1];
|
||||
}
|
||||
}
|
||||
if ( $originallyFromEmail )
|
||||
{
|
||||
$originallyFrom = \IPS\Member::load( $originallyFromEmail, 'email' );
|
||||
if ( $member->member_id and array_key_exists( $member->member_id, \IPS\nexus\Support\Request::staff() ) )
|
||||
{
|
||||
/* Strip any headers from the forwarded message */
|
||||
$quoted = $email->data['quoted'];
|
||||
$haveInitialHeader = FALSE;
|
||||
$exploded = explode( '<br>', $quoted );
|
||||
foreach ( $exploded as $k => $line )
|
||||
{
|
||||
if ( $line )
|
||||
{
|
||||
if ( !$haveInitialHeader and preg_match( '/^.*:/', $line ) )
|
||||
{
|
||||
$haveInitialHeader = TRUE;
|
||||
}
|
||||
elseif ( !preg_match( '/^.*:.*$/', $line ) )
|
||||
{
|
||||
$quoted = implode( '<br>', array_splice( $exploded, $k ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$quoted = \IPS\Text\Parser::parseStatic( '<div>' . $quoted . '</div>' );
|
||||
|
||||
/* Create request */
|
||||
$request = new \IPS\nexus\Support\Request;
|
||||
$request->title = $matches[1];
|
||||
$request->department = $department;
|
||||
$request->member = (int) $originallyFrom->member_id;
|
||||
$request->status = \IPS\nexus\Support\Status::load( TRUE, 'status_default_member' );
|
||||
$request->severity = \IPS\nexus\Support\Severity::load( TRUE, 'sev_default' );
|
||||
$request->started = time();
|
||||
$request->last_reply = time();
|
||||
$request->last_reply_by = (int) $member->member_id;
|
||||
$request->last_new_reply = time();
|
||||
$request->replies = 1;
|
||||
$request->email = $originallyFromEmail;
|
||||
$request->save();
|
||||
|
||||
/* Create the reply */
|
||||
$reply = new \IPS\nexus\Support\Reply;
|
||||
$reply->request = $request->id;
|
||||
$reply->member = (int) $member->member_id;
|
||||
$reply->type = $reply::REPLY_EMAIL;
|
||||
$reply->post = $quoted;
|
||||
$reply->date = time();
|
||||
$reply->email = $originallyFromEmail;
|
||||
$reply->cc = $email->data['cc'];
|
||||
$reply->raw = $email->data['raw'];
|
||||
$reply->textformat = $email->data['alternative'];
|
||||
$reply->save();
|
||||
|
||||
/* Create a hidden note */
|
||||
if ( trim( $email->data['message'] ) or count( $email->data['attachments'] ) )
|
||||
{
|
||||
$note = new \IPS\nexus\Support\Reply;
|
||||
$note->request = $request->id;
|
||||
$note->member = (int) $member->member_id;
|
||||
$note->type = $reply::REPLY_HIDDEN;
|
||||
$note->post = $email->data['message'];
|
||||
$note->date = time();
|
||||
$note->email = $email->data['from'];
|
||||
$note->save();
|
||||
|
||||
static::makeAndClaimAttachments( $email->data['attachments'], $note );
|
||||
}
|
||||
|
||||
$request->sendNotifications();
|
||||
|
||||
/* Return */
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Nope - normal email */
|
||||
else
|
||||
{
|
||||
/* Create request */
|
||||
$request = new \IPS\nexus\Support\Request;
|
||||
$request->title = $email->data['subject'];
|
||||
$request->department = $department;
|
||||
$request->member = (int) $member->member_id;
|
||||
$request->status = \IPS\nexus\Support\Status::load( TRUE, 'status_default_member' );
|
||||
$request->severity = \IPS\nexus\Support\Severity::load( TRUE, 'sev_default' );
|
||||
$request->started = time();
|
||||
$request->last_reply = time();
|
||||
$request->last_reply_by = (int) $member->member_id;
|
||||
$request->last_new_reply = time();
|
||||
$request->replies = 1;
|
||||
$request->email = $email->data['from'];
|
||||
$request->save();
|
||||
|
||||
/* Create the reply */
|
||||
$reply = new \IPS\nexus\Support\Reply;
|
||||
$reply->request = $request->id;
|
||||
$reply->member = (int) $member->member_id;
|
||||
$reply->type = $reply::REPLY_EMAIL;
|
||||
$reply->post = $email->data['message'];
|
||||
$reply->date = time();
|
||||
$reply->email = $email->data['from'];
|
||||
$reply->cc = $email->data['cc'];
|
||||
$reply->raw = $email->data['raw'];
|
||||
$reply->textformat = $email->data['alternative'];
|
||||
$reply->save();
|
||||
static::makeAndClaimAttachments( $email->data['attachments'], $reply );
|
||||
|
||||
/* Send confirmation email */
|
||||
if ( \IPS\Settings::i()->nexus_sout_autoreply )
|
||||
{
|
||||
$confirmationEmail = \IPS\Email::buildFromTemplate( 'nexus', 'emailConfirmation', array( $request ) );
|
||||
$confirmationEmail->from = $request->department->email;
|
||||
switch ( \IPS\Settings::i()->nexus_sout_from )
|
||||
{
|
||||
case 'staff':
|
||||
case 'dpt':
|
||||
$confirmationEmail->fromName = $confirmationEmail->language->get( 'nexus_department_' . $request->department->_id );
|
||||
break;
|
||||
default:
|
||||
$confirmationEmail->fromName = \IPS\Settings::i()->nexus_sout_from;
|
||||
break;
|
||||
}
|
||||
$confirmationEmail->send( $member->member_id ? $member : $email->data['from'] );
|
||||
}
|
||||
|
||||
$request->sendNotifications();
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return TRUE;
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make and claim attachments
|
||||
*
|
||||
* @param array $files \IPS\File objects
|
||||
* @param \IPS\nexus\Support\Reply $reply The support request reply
|
||||
* @return void
|
||||
*/
|
||||
public static function makeAndClaimAttachments( array $files, \IPS\nexus\Support\Reply $reply )
|
||||
{
|
||||
foreach ( $files as $file )
|
||||
{
|
||||
$attachment = $file->makeAttachment('');
|
||||
|
||||
\IPS\Db::i()->insert( 'core_attachments_map', array(
|
||||
'attachment_id' => $attachment['attach_id'],
|
||||
'location_key' => 'nexus_Support',
|
||||
'id1' => $reply->request,
|
||||
'id2' => $reply->id,
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief IP Address Lookup extension
|
||||
* @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 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\IpAddresses;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* IP Address Lookup extension
|
||||
*/
|
||||
class _CustomerHistory
|
||||
{
|
||||
/**
|
||||
* Find Records by IP
|
||||
*
|
||||
* @param string $ip The IP Address
|
||||
* @param \IPS\Http\Url $baseUrl URL table will be displayed on or NULL to return a count
|
||||
* @return \IPS\Helpers\Table|null
|
||||
*/
|
||||
public function findByIp( $ip, \IPS\Http\Url $baseUrl = NULL )
|
||||
{
|
||||
/* Return count */
|
||||
if ( $baseUrl === NULL )
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_customer_history', array( "log_ip_address LIKE CONCAT( ?, '%' )", $ip ) )->first();
|
||||
}
|
||||
|
||||
|
||||
return (string) new \IPS\nexus\Customer\History( $baseUrl, array( "log_ip_address LIKE CONCAT( ?, '%' )", $ip ), FALSE, TRUE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find IPs by Member
|
||||
*
|
||||
* @code
|
||||
return array(
|
||||
'::1' => array(
|
||||
'ip' => '::1'// string (IP Address)
|
||||
'count' => ... // int (number of times this member has used this IP)
|
||||
'first' => ... // int (timestamp of first use)
|
||||
'last' => ... // int (timestamp of most recent use)
|
||||
),
|
||||
...
|
||||
);
|
||||
* @endcode
|
||||
* @param \IPS\Member $member The member
|
||||
* @return array|NULL
|
||||
*/
|
||||
public function findByMember( $member )
|
||||
{
|
||||
return \IPS\Db::i()->select( "log_ip_address AS ip, COUNT(*) AS count, MIN(log_date) AS first, MAX(log_date) AS last", 'nexus_customer_history', array( "log_member=?", $member->member_id ), NULL, NULL, "log_ip_address" )->setKeyField( 'ip' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief IP Address Lookup extension
|
||||
* @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 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\IpAddresses;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* IP Address Lookup extension
|
||||
*/
|
||||
class _Payouts
|
||||
{
|
||||
/**
|
||||
* Find Records by IP
|
||||
*
|
||||
* @param string $ip The IP Address
|
||||
* @param \IPS\Http\Url $baseUrl URL table will be displayed on or NULL to return a count
|
||||
* @return \IPS\Helpers\Table|null
|
||||
*/
|
||||
public function findByIp( $ip, \IPS\Http\Url $baseUrl = NULL )
|
||||
{
|
||||
/* Return count */
|
||||
if ( $baseUrl === NULL )
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( "po_ip LIKE CONCAT( ?, '%' )", $ip ) )->first();
|
||||
}
|
||||
|
||||
return (string) \IPS\nexus\Payout::table( array( "po_ip LIKE CONCAT( ?, '%' )", $ip ), $baseUrl );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find IPs by Member
|
||||
*
|
||||
* @code
|
||||
return array(
|
||||
'::1' => array(
|
||||
'ip' => '::1'// string (IP Address)
|
||||
'count' => ... // int (number of times this member has used this IP)
|
||||
'first' => ... // int (timestamp of first use)
|
||||
'last' => ... // int (timestamp of most recent use)
|
||||
),
|
||||
...
|
||||
);
|
||||
* @endcode
|
||||
* @param \IPS\Member $member The member
|
||||
* @return array|NULL
|
||||
*/
|
||||
public function findByMember( $member )
|
||||
{
|
||||
return \IPS\Db::i()->select( "po_ip AS ip, COUNT(*) AS count, MIN(po_date) AS first, MAX(po_date) AS last", 'nexus_payouts', array( "po_member=?", $member->member_id ), NULL, NULL, "po_ip" )->setKeyField( 'ip' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief IP Address Lookup extension
|
||||
* @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 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\IpAddresses;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* IP Address Lookup extension
|
||||
*/
|
||||
class _Support
|
||||
{
|
||||
/**
|
||||
* Find Records by IP
|
||||
*
|
||||
* @param string $ip The IP Address
|
||||
* @param \IPS\Http\Url $baseUrl URL table will be displayed on or NULL to return a count
|
||||
* @return \IPS\Helpers\Table|null
|
||||
*/
|
||||
public function findByIp( $ip, \IPS\Http\Url $baseUrl = NULL )
|
||||
{
|
||||
/* Return count */
|
||||
if ( $baseUrl === NULL )
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_support_replies', array( "reply_ip_address LIKE CONCAT( ?, '%' )", $ip ) )->first();
|
||||
}
|
||||
|
||||
$class = new \IPS\core\extensions\core\IpAddresses\Content;
|
||||
$class->class = 'IPS\nexus\Support\Reply';
|
||||
return $class->findByIp( $ip, $baseUrl );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find IPs by Member
|
||||
*
|
||||
* @code
|
||||
return array(
|
||||
'::1' => array(
|
||||
'ip' => '::1'// string (IP Address)
|
||||
'count' => ... // int (number of times this member has used this IP)
|
||||
'first' => ... // int (timestamp of first use)
|
||||
'last' => ... // int (timestamp of most recent use)
|
||||
),
|
||||
...
|
||||
);
|
||||
* @endcode
|
||||
* @param \IPS\Member $member The member
|
||||
* @return array|NULL
|
||||
*/
|
||||
public function findByMember( $member )
|
||||
{
|
||||
$class = new \IPS\core\extensions\core\IpAddresses\Content;
|
||||
$class->class = 'IPS\nexus\Support\Reply';
|
||||
return $class->findByMember( $member );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief IP Address Lookup extension
|
||||
* @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 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\IpAddresses;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* IP Address Lookup extension
|
||||
*/
|
||||
class _Transactions
|
||||
{
|
||||
/**
|
||||
* Find Records by IP
|
||||
*
|
||||
* @param string $ip The IP Address
|
||||
* @param \IPS\Http\Url $baseUrl URL table will be displayed on or NULL to return a count
|
||||
* @return \IPS\Helpers\Table|null
|
||||
*/
|
||||
public function findByIp( $ip, \IPS\Http\Url $baseUrl = NULL )
|
||||
{
|
||||
/* Return count */
|
||||
if ( $baseUrl === NULL )
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( "t_ip LIKE CONCAT( ?, '%' )", $ip ) )->first();
|
||||
}
|
||||
|
||||
return (string) \IPS\nexus\Transaction::table( array( array( "t_ip LIKE CONCAT( ?, '%' )", $ip ) ), $baseUrl );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find IPs by Member
|
||||
*
|
||||
* @code
|
||||
return array(
|
||||
'::1' => array(
|
||||
'ip' => '::1'// string (IP Address)
|
||||
'count' => ... // int (number of times this member has used this IP)
|
||||
'first' => ... // int (timestamp of first use)
|
||||
'last' => ... // int (timestamp of most recent use)
|
||||
),
|
||||
...
|
||||
);
|
||||
* @endcode
|
||||
* @param \IPS\Member $member The member
|
||||
* @return array|NULL
|
||||
*/
|
||||
public function findByMember( $member )
|
||||
{
|
||||
return \IPS\Db::i()->select( "t_ip AS ip, COUNT(*) AS count, MIN(t_date) AS first, MAX(t_date) AS last", 'nexus_transactions', array( "t_member=?", $member->member_id ), NULL, NULL, "t_ip" )->setKeyField( 'ip' );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief ACP Live Search Extension
|
||||
* @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 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\LiveSearch;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Live Search Extension
|
||||
*/
|
||||
class _Nexus
|
||||
{
|
||||
/**
|
||||
* Check we have access
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function hasAccess()
|
||||
{
|
||||
return \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_manage' )
|
||||
or \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' )
|
||||
or \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'purchases_view' )
|
||||
or \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'support', 'requests_manage' )
|
||||
or \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' )
|
||||
or \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'lkeys_view' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the search results
|
||||
*
|
||||
* @param string Search Term
|
||||
* @return array Array of results
|
||||
*/
|
||||
public function getResults( $searchTerm )
|
||||
{
|
||||
$results = array();
|
||||
|
||||
/* Numeric */
|
||||
if ( is_numeric( $searchTerm ) )
|
||||
{
|
||||
/* Invoice */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'invoices_manage' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->invoice( \IPS\nexus\Invoice::load( $searchTerm ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
/* Transaction */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'payments', 'transactions_manage' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->transaction( \IPS\nexus\Transaction::load( $searchTerm ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
/* Purchase */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'purchases_view' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->purchase( \IPS\nexus\Purchase::load( $searchTerm ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
/* Support */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'support', 'requests_manage' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$supportRequest = \IPS\nexus\Support\Request::load( $searchTerm );
|
||||
if ( $supportRequest->canView() )
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->support( $supportRequest );
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
/* Customer */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$customer = \IPS\nexus\Customer::load( $searchTerm );
|
||||
if ( $customer->member_id )
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->customer( $customer );
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
}
|
||||
|
||||
/* Textual */
|
||||
else
|
||||
{
|
||||
/* License Key */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'lkeys_view' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->licensekey( \IPS\nexus\Purchase\LicenseKey::load( $searchTerm ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
|
||||
/* Hosting Accounts */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'purchases_view' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$account = \IPS\nexus\Hosting\Account::constructFromData( \IPS\Db::i()->select( '*', 'nexus_hosting_accounts', array( 'LOWER(account_domain)=?', mb_strtolower( $searchTerm ) ) )->first() );
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->hosting( $account );
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
|
||||
try
|
||||
{
|
||||
$account = \IPS\nexus\Hosting\Account::constructFromData( \IPS\Db::i()->select( '*', 'nexus_hosting_accounts', array( 'LOWER(account_username)=?', mb_strtolower( $searchTerm ) ) )->first() );
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->hosting( $account );
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
}
|
||||
|
||||
/* Customers */
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'nexus', 'customers', 'customers_view' ) )
|
||||
{
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_customers', array( "LOWER( name ) LIKE CONCAT( '%', ?, '%' ) OR LOWER( email ) LIKE CONCAT( '%', ?, '%' ) OR CONCAT( LOWER( cm_first_name ), ' ', LOWER( cm_last_name ) ) LIKE CONCAT( '%', ?, '%' )", mb_strtolower( $searchTerm ), mb_strtolower( $searchTerm ), mb_strtolower( $searchTerm ) ), NULL, 50 )->join( 'core_members', 'core_members.member_id=nexus_customers.member_id' ), 'IPS\nexus\Customer' ) as $customer )
|
||||
{
|
||||
$results[] = \IPS\Theme::i()->getTemplate('livesearch', 'nexus')->customer( $customer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Admin CP Member Form
|
||||
* @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 Sep 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\MemberForm;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin CP Member Form
|
||||
*/
|
||||
class _Nexus
|
||||
{
|
||||
/**
|
||||
* Action Buttons
|
||||
*
|
||||
* @param \IPS\Member $member The Member
|
||||
* @return array
|
||||
*/
|
||||
public function actionButtons( $member )
|
||||
{
|
||||
return array(
|
||||
'id' => array(
|
||||
'title' => 'view_customer_data',
|
||||
'icon' => 'dollar',
|
||||
'link' => \IPS\Http\Url::internal( "app=nexus&module=customers&controller=view&id={$member->member_id}" ),
|
||||
'class' => ''
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Form
|
||||
*
|
||||
* @param \IPS\Form\Tabbed $form The form
|
||||
* @param \IPS\Member $member Existing Member
|
||||
* @return void
|
||||
*/
|
||||
public function process( &$form, $member )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Save
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @param \IPS\Member $member The member
|
||||
* @return void
|
||||
*/
|
||||
public function save( $values, &$member )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Member Sync
|
||||
* @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 31 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\MemberSync;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Member Sync
|
||||
*/
|
||||
class _Nexus
|
||||
{
|
||||
/**
|
||||
* Account Created
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return void
|
||||
*/
|
||||
public function onCreateAccount( $member )
|
||||
{
|
||||
if ( \IPS\Dispatcher::hasInstance() and \IPS\Dispatcher::i()->controllerLocation === 'front' and isset( \IPS\Request::i()->cookie['referred_by'] ) )
|
||||
{
|
||||
$referredBy = \IPS\Member::load( \IPS\Request::i()->cookie['referred_by'] );
|
||||
if ( $referredBy->member_id )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'nexus_referrals', array(
|
||||
'member_id' => $member->member_id,
|
||||
'referred_by' => \IPS\Request::i()->cookie['referred_by'],
|
||||
'amount' => '',
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $member->email )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_support_requests', array( 'r_member' => $member->member_id ), array( 'r_email=? AND r_member=0', $member->email ) );
|
||||
\IPS\Db::i()->update( 'nexus_support_replies', array( 'reply_member' => $member->member_id ), array( 'reply_email=? AND reply_member=0', $member->email ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Member has logged on
|
||||
*
|
||||
* @param \IPS\Member $member Member that logged in
|
||||
* @param \IPS\Http\Url $redirectUrl The URL to send the user back to
|
||||
* @return void
|
||||
*/
|
||||
public function onLogin( $member, $returnUrl )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->cookie['cm_reg'] ) and \IPS\Request::i()->cookie['cm_reg'] )
|
||||
{
|
||||
try
|
||||
{
|
||||
$invoice = \IPS\nexus\Invoice::load( \IPS\Request::i()->cookie['cm_reg'] );
|
||||
|
||||
\IPS\Request::i()->setCookie( 'cm_reg', 0 );
|
||||
|
||||
if ( !$invoice->member->member_id )
|
||||
{
|
||||
$invoice->member = $member;
|
||||
$invoice->save();
|
||||
}
|
||||
|
||||
if ( $invoice->member->member_id === $member->member_id )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $invoice->checkoutUrl() );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'cm_reg', 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Member is merged with another member
|
||||
*
|
||||
* @param \IPS\Member $member Member being kept
|
||||
* @param \IPS\Member $member2 Member being removed
|
||||
* @return void
|
||||
*/
|
||||
public function onMerge( $member, $member2 )
|
||||
{
|
||||
\IPS\Db::i()->update( 'nexus_customer_addresses', array( 'member' => $member->member_id ), array( 'member=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_customer_cards', array( 'card_member' => $member->member_id ), array( 'card_member=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_customer_history', array( 'log_member' => $member->member_id ), array( 'log_member=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_invoices', array( 'i_member' => $member->member_id ), array( 'i_member=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_purchases', array( 'ps_member' => $member->member_id ), array( 'ps_member=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_purchases', array( 'ps_pay_to' => $member->member_id ), array( 'ps_pay_to=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_referrals', array( 'member_id' => $member->member_id ), array( 'member_id=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_referrals', array( 'referred_by' => $member->member_id ), array( 'referred_by=?', $member2->member_id ) );
|
||||
\IPS\Db::i()->update( 'nexus_transactions', array( 't_member' => $member->member_id ), array( 't_member=?', $member2->member_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Member is deleted
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @return void
|
||||
*/
|
||||
public function onDelete( $member )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'nexus_customer_addresses', array( 'member=?', $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'nexus_customer_cards', array( 'card_member=?', $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'nexus_customer_history', array( 'log_member=?', $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'nexus_customers', array( 'member_id=?', $member->member_id ) );
|
||||
\IPS\Db::i()->delete( 'nexus_referrals', array( 'referred_by=?', $member->member_id ) ); // Don't delete the record for the referrer if this is the referree as that's still relevant for the referree's account
|
||||
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_purchases', array( 'ps_member=?', $member->member_id ) ), 'IPS\nexus\Purchase' ) as $purchase )
|
||||
{
|
||||
$purchase->delete();
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'nexus_purchases', array( 'ps_pay_to' => 0 ), array( 'ps_pay_to=?', $member->member_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Email address is changed
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param string $new New email address
|
||||
* @param string $old Old email address
|
||||
* @return void
|
||||
*/
|
||||
public function onEmailChange( $member, $new, $old )
|
||||
{
|
||||
\IPS\nexus\Customer::load( $member->member_id )->log( 'info', array( 'email' => $old ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Password is changed
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param string $new New password
|
||||
* @return void
|
||||
*/
|
||||
public function onPassChange( $member, $new )
|
||||
{
|
||||
\IPS\nexus\Customer::load( $member->member_id )->log( 'info', array( 'password' => '' ) );
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Template Plugin - Length
|
||||
* @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
|
||||
* @since 20 Oct 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\OutputPlugins;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Template Plugin - Length
|
||||
*/
|
||||
class _Length
|
||||
{
|
||||
/**
|
||||
* @brief Can be used when compiling CSS
|
||||
*/
|
||||
public static $canBeUsedInCss = FALSE;
|
||||
|
||||
/**
|
||||
* Run the plug-in
|
||||
*
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @return array array( 'pre' => Code to eval before 'return', 'return' => Code to eval to return desired value )
|
||||
*/
|
||||
public static function runPlugin( $data, $options )
|
||||
{
|
||||
return array(
|
||||
'pre' => '$length = new \IPS\nexus\Shipping\Length( ' . $data . " );",
|
||||
'return' => '$length->string()'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Template Plugin - Money
|
||||
* @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
|
||||
* @since 6 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\OutputPlugins;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Template Plugin - Money
|
||||
*/
|
||||
class _Money
|
||||
{
|
||||
/**
|
||||
* @brief Can be used when compiling CSS
|
||||
*/
|
||||
public static $canBeUsedInCss = FALSE;
|
||||
|
||||
/**
|
||||
* Run the plug-in
|
||||
*
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @return array array( 'pre' => Code to eval before 'return', 'return' => Code to eval to return desired value )
|
||||
*/
|
||||
public static function runPlugin( $data, $options )
|
||||
{
|
||||
if ( isset( $options['currency'] ) )
|
||||
{
|
||||
if ( mb_substr( $options['currency'], 0, 1 ) !== '\\' and mb_substr( $options['currency'], 0, 1 ) !== '$' )
|
||||
{
|
||||
$options['currency'] = "'{$options['currency']}'";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$options['currency'] = "( isset( \$_SESSION['currency'] ) ? \$_SESSION['currency'] : \\IPS\\nexus\\Customer::loggedIn()->defaultCurrency() )";
|
||||
}
|
||||
|
||||
return 'new \IPS\nexus\Money( ' . $data . ", {$options['currency']} )";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Template Plugin - Weight
|
||||
* @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
|
||||
* @since 20 Oct 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\extensions\core\OutputPlugins;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Template Plugin - Length
|
||||
*/
|
||||
class _Weight
|
||||
{
|
||||
/**
|
||||
* @brief Can be used when compiling CSS
|
||||
*/
|
||||
public static $canBeUsedInCss = FALSE;
|
||||
|
||||
/**
|
||||
* Run the plug-in
|
||||
*
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @return array array( 'pre' => Code to eval before 'return', 'return' => Code to eval to return desired value )
|
||||
*/
|
||||
public static function runPlugin( $data, $options )
|
||||
{
|
||||
return array(
|
||||
'pre' => '$weight = new \IPS\nexus\Shipping\Weight( ' . $data . " );",
|
||||
'return' => '$weight->string()'
|
||||
);
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
Whitespace-only changes.
Reference in new issue
Block a user