Version 4.0.13.1

This commit is contained in:
Neo committed 2025-12-19 04:57:54 -08:00
1 parent f9e857d255
commit c6a86f0d9b
7517 files changed
+597400 -668041

No files matched your search

+184
View File
@@ -0,0 +1,184 @@
<?php
/**
* @brief Nexus Application Class
* @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 10 Feb 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus;
/* 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;
}
/**
* Nexus Application Class
*/
class _Application extends \IPS\Application
{
/**
* Init - catches legacy PayPal IPN messages
*
* @return void
*/
public function init()
{
if ( \IPS\Request::i()->app == 'nexus' and \IPS\Request::i()->module == 'payments' and \IPS\Request::i()->section == 'receive' and \IPS\Request::i()->validate == 'paypal' )
{
if ( \IPS\Request::i()->txn_type == 'subscr_payment' and \IPS\Request::i()->payment_status == 'Completed' )
{
try
{
/* Get the subscription */
$subscription = \IPS\Db::i()->select( '*', 'nexus_subscriptions', array( 's_gateway_key=? AND s_id=?', 'paypal', \IPS\Request::i()->subscr_id ) )->first();
$items = \unserialize( $subscription['s_items'] );
if ( !is_array( $items ) or empty( $items ) )
{
exit;
}
/* If the gateway still exists, fetch it */
$gateway = NULL;
try
{
$gateway = \IPS\nexus\Gateway::load( $subscription['s_method'] );
}
catch ( \OutOfRangeException $e ) { }
/* Check this waas actually a PayPal IPN message */
try
{
$response = \IPS\Http\Url::external( 'https://www.' . ( \IPS\NEXUS_TEST_GATEWAYS ? 'sandbox.' : '' ) . 'paypal.com/cgi-bin/webscr/' )->request()->setHeaders( array( 'Accept' => 'application/x-www-form-urlencoded' ) )->post( array_merge( array( 'cmd' => '_notify-validate' ), $_POST ) );
if ( (string) $response !== 'VERIFIED' )
{
exit;
}
}
catch ( \Exception $e )
{
exit;
}
/* Has an invoice already been generated? */
$_items = $items;
try
{
$invoice = \IPS\nexus\Invoice::constructFromData( \IPS\Db::i()->select( '*', 'nexus_invoices', array( 'i_member=? AND i_status=?', $subscription['s_member'], 'pend' ), 'i_date DESC', 1 )->first() );
foreach ( $invoice->items as $item )
{
if ( $item instanceof \IPS\nexus\Invoice\Item\Renewal and in_array( $item->id, $_items ) )
{
unset( $_items[ array_search( $item->id, $_items ) ] );
}
}
}
catch ( \UnderflowException $e ) { }
/* No, create one */
if ( count( $_items ) )
{
$invoice = new \IPS\nexus\Invoice;
$invoice->member = \IPS\nexus\Customer::load( $subscription['s_member'] );
foreach ( $items as $purchaseId )
{
try
{
$purchase = \IPS\nexus\Purchase::load( $purchaseId );
if ( !$purchase->cancelled )
{
$invoice->addItem( \IPS\nexus\Invoice\Item\Renewal::create( $purchase ) );
}
}
catch ( \OutOfRangeException $e ) { }
}
if ( !count( $invoice->items ) )
{
exit;
}
$invoice->save();
}
/* And then log a transaction */
$transaction = new \IPS\nexus\Transaction;
$transaction->member = $invoice->member;
$transaction->invoice = $invoice;
$transaction->method = $gateway;
$transaction->amount = new \IPS\nexus\Money( $_POST['mc_gross'], $_POST['mc_currency'] );
$transaction->gw_id = $_POST['txn_id'];
$transaction->approve();
}
catch ( \UnderflowException $e ) { }
}
exit;
}
}
/**
* ACP Menu Numbers
*
* @param array $queryString Query String
* @return int
*/
public function acpMenuNumber( $queryString )
{
parse_str( $queryString, $queryString );
switch ( $queryString['controller'] )
{
case 'transactions':
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_transactions', array( 't_status=?', \IPS\nexus\Transaction::STATUS_HELD ) )->first();
break;
case 'shipping':
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_ship_orders', array( 'o_status=?', \IPS\nexus\Shipping\Order::STATUS_PENDING ) )->first();
break;
case 'payouts':
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_payouts', array( 'po_status=?', \IPS\nexus\Payout::STATUS_PENDING ) )->first();
break;
case 'requests':
$myFilters = \IPS\nexus\Support\Request::myFilters();
return \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();
break;
case 'errors':
return \IPS\Db::i()->select( 'COUNT(*)', 'nexus_hosting_errors' )->first();
break;
}
}
/**
* Cart count
*
* @return int
*/
public static function cartCount()
{
$count = 0;
foreach ( $_SESSION['cart'] as $item )
{
$count += $item->quantity;
}
return $count;
}
/**
* [Node] Get Icon for tree
*
* @note Return the class for the icon (e.g. 'globe')
* @return string|null
*/
protected function get__icon()
{
return 'shopping-cart';
}
}
+164
View File
@@ -0,0 +1,164 @@
{
"payments": {
"transactions": {
"tab": "nexus",
"controller": "transactions",
"do": "",
"restriction": "transactions_manage"
},
"invoices": {
"tab": "nexus",
"controller": "invoices",
"do": "",
"restriction": "invoices_manage"
},
"shipping": {
"tab": "nexus",
"controller": "shipping",
"do": "",
"restriction": "shiporders_manage"
},
"donations": {
"tab": "nexus",
"controller": "donations",
"do": "",
"restriction": "donations_manage"
},
"payouts": {
"tab": "nexus",
"controller": "payouts",
"do": "",
"restriction": "payouts_manage"
},
"paymentsettings": {
"tab": "nexus",
"controller": "paymentsettings",
"do": "",
"restriction": "paymentsettings_overview"
}
},
"customers": {
"search": {
"tab": "nexus",
"controller": "search",
"do": "",
"restriction": "customers_view"
},
"fields": {
"tab": "nexus",
"controller": "fields",
"do": "",
"restriction": "fields_manage"
},
"referrals": {
"tab": "nexus",
"controller": "referrals",
"do": "",
"restriction": "referrals_manage"
}
},
"support": {
"requests": {
"tab": "nexus",
"controller": "requests",
"do": "",
"restriction": "requests_manage"
},
"reports": {
"tab": "nexus",
"controller": "reports",
"do": "",
"restriction": "reports_manage"
},
"settings": {
"tab": "nexus",
"controller": "settings",
"do": "",
"restriction": "settings_manage"
},
"volume": {
"tab": "stats",
"controller": "volume",
"do": "",
"restriction": "volume_manage"
}
},
"store": {
"packages": {
"tab": "nexus",
"controller": "packages",
"do": "",
"restriction": "packages_manage"
},
"fields": {
"tab": "nexus",
"controller": "fields",
"do": "",
"restriction": "package_fields_manage"
},
"coupons": {
"tab": "nexus",
"controller": "coupons",
"do": "",
"restriction": "coupons_manage"
},
"settings": {
"tab": "nexus",
"controller": "settings",
"do": "",
"restriction": "settings_manage"
}
},
"hosting": {
"queues": {
"tab": "nexus",
"controller": "queues",
"do": "",
"restriction": "queues_manage"
},
"servers": {
"tab": "nexus",
"controller": "servers",
"do": "",
"restriction": "servers_manage"
},
"monitoring": {
"tab": "nexus",
"controller": "monitoring",
"do": "",
"restriction": null
},
"errors": {
"tab": "nexus",
"controller": "errors",
"do": "",
"restriction": "errors_manage"
},
"settings": {
"tab": "nexus",
"controller": "settings",
"do": "",
"restriction": "settings_manage"
}
},
"reports": {
"purchases": {
"tab": "stats",
"controller": "purchases",
"do": "",
"restriction": "purchases_manage"
},
"income": {
"tab": "stats",
"controller": "income",
"do": "",
"restriction": "income_manage"
},
"markets": {
"tab": "stats",
"controller": "markets",
"do": "",
"restriction": "markets_manage"
}
}
}
@@ -0,0 +1,175 @@
{
"payments": {
"transactions": {
"transactions_manage": "transactions_manage",
"transactions_edit": "transactions_edit",
"transactions_refund": "transactions_refund",
"transactions_delete": "transactions_delete"
},
"invoices": {
"invoices_manage": "invoices_manage",
"invoices_add": "invoices_add",
"invoices_edit": "invoices_edit",
"chargetocard": "chargetocard",
"invoices_resend": "invoices_resend",
"invoices_delete": "invoices_delete",
"invoices_settings": "invoices_settings"
},
"shipping": {
"shiporders_manage": "shiporders_manage",
"shiporders_edit": "shiporders_edit",
"shiporders_delete": "shiporders_delete",
"shipmethods_manage": "shipmethods_manage"
},
"paymentsettings": {
"paymentsettings_overview": "paymentsettings_overview",
"gateways_manage": "gateways_manage",
"tax_manage": "tax_manage",
"fraud_manage": "fraud_manage",
"currencies_manage": "currencies_manage",
"checkout_settings": "checkout_settings",
"transaction_review_settings": "transaction_review_settings",
"email_copies_settings": "email_copies_settings"
},
"payouts": {
"payouts_manage": "payouts_manage",
"payouts_process": "payouts_process",
"payouts_cancel": "payouts_cancel",
"payouts_delete": "payouts_delete",
"payouts_settings": "payouts_settings"
},
"donations": {
"donations_manage": "donations_manage",
"donationgoals_manage": "donationgoals_manage"
}
},
"customers": {
"purchases": {
"purchases_view": "purchases_view",
"purchases_edit": "purchases_edit",
"purchases_transfer": "purchases_transfer",
"purchases_cancel": "purchases_cancel",
"purchases_delete": "purchases_delete",
"lkeys_view": "lkeys_view",
"lkeys_reset": "lkeys_reset"
},
"customer_fields": {
"customer_fields_manage": "customer_fields_manage",
"customer_fields_add": "customer_fields_add",
"customer_fields_edit": "customer_fields_edit",
"customer_fields_delete": "customer_fields_delete"
},
"customers": {
"customers_view": "customers_view",
"customers_edit_details": "customers_edit_details",
"customers_edit_credit": "customers_edit_credit",
"customers_edit_cards": "customers_edit_cards",
"customers_void": "customers_void"
},
"referrals": {
"referrals_manage": "referrals_manage",
"referrals_commission_rules": "referrals_commission_rules",
"referrals_banners": "referrals_banners"
},
"notes": {
"customer_notes_view": "customer_notes_view",
"customer_notes_add": "customer_notes_add",
"customer_notes_edit": "customer_notes_edit",
"customer_notes_delete": "customer_notes_delete"
}
},
"support": {
"requests": {
"requests_manage": "requests_manage",
"requests_create": "requests_create",
"requests_merge": "requests_merge",
"requests_delete": "requests_delete",
"requests_reply_delete": "requests_reply_delete",
"requests_block_sev": "requests_block_sev",
"requests_ratings": "requests_ratings",
"requests_ratings_feedback": "requests_ratings_feedback"
},
"support_reports": {
"reports_manage": "reports_manage"
},
"settings": {
"settings_manage": "settings_manage",
"departments_manage": "departments_manage",
"stockactions_manage": "stockactions_manage",
"scfields_manage": "scfields_manage",
"severities_manage": "severities_manage",
"statuses_manage": "statuses_manage",
"autoresolve_manage": "autoresolve_manage",
"customerfeedback_manage": "customerfeedback_manage",
"outgoingemail_manage": "outgoingemail_manage",
"incomingemail_manage": "incomingemail_manage",
"support_display_settings": "support_display_settings"
},
"stats": {
"volume_manage": "volume_manage"
}
},
"store": {
"packages": {
"packages_manage": "packages_manage",
"packages_edit": "packages_edit",
"packages_delete": "packages_delete",
"packages_add": "packages_add"
},
"coupons": {
"coupons_manage": "coupons_manage",
"coupons_add": "coupons_add",
"coupons_edit": "coupons_edit",
"coupons_delete": "coupons_delete"
},
"settings": {
"settings_manage": "settings_manage"
},
"package_fields": {
"package_fields_manage": "package_fields_manage",
"package_fields_add": "package_fields_add",
"package_fields_edit": "package_fields_edit",
"package_fields_delete": "package_fields_delete"
}
},
"hosting": {
"queues": {
"queues_manage": "queues_manage",
"queues_add": "queues_add",
"queues_edit": "queues_edit",
"queues_delete": "queues_delete"
},
"servers": {
"servers_manage": "servers_manage",
"servers_add": "servers_add",
"servers_edit": "servers_edit",
"servers_delete": "servers_delete",
"servers_reboot": "servers_reboot",
"servers_audit": "servers_audit"
},
"monitoring": {
"monitoring_settings": "monitoring_settings",
"monitoring_eom_view": "monitoring_eom_view",
"monitoring_eom_add": "monitoring_eom_add",
"monitoring_eom_edit": "monitoring_eom_edit",
"monitoring_eom_delete": "monitoring_eom_delete"
},
"settings": {
"settings_manage": "settings_manage"
},
"errors": {
"errors_manage": "errors_manage"
}
},
"reports": {
"purchases": {
"purchases_manage": "purchases_manage"
},
"income": {
"income_manage": "income_manage"
},
"markets": {
"markets_manage": "markets_manage"
}
}
}
+1
View File
@@ -0,0 +1 @@
{"app=nexus&module=payments&controller=paymentsettings&tab=currencies":{"lang_key":"currencies","restriction":"currencies_manage","keywords":["currency","currencies","dollar","pound","euro","money"]},"app=nexus&module=payments&controller=paymentsettings&tab=gateways":{"lang_key":"payment_methods","restriction":"gateways_manage","keywords":["gateways","methods","bank","paypal","cards","credit","debit","credit cards","stripe","sagepay","sage pay","2checkout","authorize.net","auth.net","checks","cheques"]},"app=nexus&module=payments&controller=paymentsettings&tab=tax":{"lang_key":"tax_rates","restriction":"tax_manage","keywords":["tax","vat","sales tax"]},"app=nexus&module=payments&controller=paymentsettings&tab=checkoutsettings&searchResult=form_nexus_https":{"lang_key":"nexus_https","restriction":"checkout_settings","keywords":["https","secure","ssl"]},"app=nexus&module=payments&controller=paymentsettings&tab=checkoutsettings&searchResult=form_nexus_split_payments_on":{"lang_key":"nexus_split_payments_on","restriction":"checkout_settings","keywords":["split","cards"]},"app=nexus&module=payments&controller=paymentsettings&tab=checkoutsettings&searchResult=form_nexus_tac":{"lang_key":"nexus_tac","restriction":"checkout_settings","keywords":["terms and conditions","checkout"]},"app=nexus&module=payments&controller=paymentsettings&tab=checkoutsettings":{"lang_key":"checkout_settings","restriction":"checkout_settings","keywords":["checkout"]},"app=nexus&module=payments&controller=invoices":{"lang_key":"menu__nexus_payments_invoices","restriction":"invoices_manage","keywords":["invoices","orders"]},"app=nexus&module=payments&controller=invoices&do=settings&searchResult=form_cm_invoice_expireafter":{"lang_key":"cm_invoice_expireafter","restriction":"invoices_settings","keywords":["invoices"]},"app=nexus&module=payments&controller=invoices&do=settings&searchResult=form_cm_invoice_generate":{"lang_key":"cm_invoice_generate","restriction":"invoices_settings","keywords":["invoices","renewal"]},"app=nexus&module=payments&controller=invoices&do=settings&searchResult=form_cm_invoice_warning":{"lang_key":"cm_invoice_warning","restriction":"invoices_settings","keywords":["invoices","renewal","cards"]},"app=nexus&module=payments&controller=shippingrates":{"lang_key":"shipping_rates","restriction":"shipmethods_manage","keywords":["shipping","shipments","orders","usps","mail","post","fedex","ups","royal mail","airmail","air mail","tracking"]},"app=nexus&module=support&controller=settings&tab=departments":{"lang_key":"departments","restriction":"departments_manage","keywords":["departments","categories","email"]},"app=nexus&module=support&controller=settings&tab=severities":{"lang_key":"severities","restriction":"severities_manage","keywords":["severity","severities","critical","urgent","urgency","emergency"]},"app=nexus&module=support&controller=settings&tab=statuses":{"lang_key":"statuses","restriction":"settings_manage","keywords":["statuses","open","closed","resolved","tags"]},"app=nexus&module=support&controller=settings&tab=stockactions":{"lang_key":"stock_actions","restriction":"stockactions_manage","keywords":["stock actions","stock replies","stock messages","stock","preset","pre set","predefined","pre defined","defined"]},"app=nexus&module=support&controller=settings&tab=fields":{"lang_key":"custom_support_fields","restriction":"scfields_manage","keywords":["custom support fields","support custom fields","support form","support fields","ticket fields","ticket information","support information","ticket custom fields","custom ticket fields"]},"app=nexus&module=support&controller=settings&tab=autoresolve":{"lang_key":"autoresolve","restriction":"autoresolve_manage","keywords":["resolve","autoresolve","auto-resolve","auto resolve","automatic resolve","automatically resolve"]},"app=nexus&module=support&controller=settings&tab=customerfeedback":{"lang_key":"customer_feedback","restriction":"customerfeedback_manage","keywords":["feedback","satisfaction","ratings","performance"]},"app=nexus&module=support&controller=settings&tab=outgoingemail":{"lang_key":"outgoing_emails","restriction":"outgoingemail_manage","keywords":["support emails","ticket emails"]},"app=nexus&module=support&controller=settings&tab=outgoingemail&searchResult=form_nexus_sout_chrome":{"lang_key":"nexus_sout_chrome","restriction":"settings_manage","keywords":["email format","email template"]},"app=nexus&module=support&controller=settings&tab=outgoingemail&searchResult=form_nexus_sout_from":{"lang_key":"nexus_sout_from","restriction":"settings_manage","keywords":["email from"]},"app=nexus&module=support&controller=settings&tab=outgoingemail&searchResult=form_nexus_sout_autoreply":{"lang_key":"nexus_sout_autoreply","restriction":"settings_manage","keywords":["support confirmation","ticket confirmation"]},"app=nexus&module=support&controller=settings&tab=incomingemail":{"lang_key":"incoming_emails","restriction":"incomingemail_manage","keywords":["incoming emLine truncated
+8
View File
@@ -0,0 +1,8 @@
{
"application_title": "Commerce",
"app_author": "",
"app_directory": "nexus",
"app_protected": 0,
"app_website": null,
"app_update_check": null
}
@@ -0,0 +1,83 @@
<?php
/**
* @brief {class}
* @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 {date}
* @version SVN_VERSION_NUMBER
*/
namespace IPS\{app}\extensions\nexus\Item;
/* 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;
}
/**
* {class}
*/
class _{class} extends \IPS\nexus\Invoice\Item\Charge // or \IPS\nexus\Invoice\Item\Purchase
{
/**
* @brief Application
*/
public static $application = '{app}';
/**
* @brief Application
*/
public static $type = '';
/**
* @brief Icon
*/
public static $icon = '';
/**
* @brief Title
*/
public static $title = '';
/**
* Generate Invoice Form
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function form( \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
{
}
/**
* Create From Form
*
* @param array $values Values from form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return \IPS\nexus\extensions\nexus\Item\MiscellaneousCharge
*/
public static function createFromForm( array $values, \IPS\nexus\Invoice $invoice )
{
}
/**
* On Paid
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public function onPaid( \IPS\nexus\Invoice $invoice )
{
}
// Other actions available. See the class you are extending for more information
}
Whitespace-only changes.
Whitespace-only changes.
File diff suppressed because it is too large. Load diff
+134
View File
@@ -0,0 +1,134 @@
/**
* Friendly URL Structure
*
* For each value in the $furl array:
* The key should be the "SEO Template" - an identifier which you'll use when displaying a URL.
* The value should be an associative array with two or three elements: 'friendly' and 'real', and optionally 'verify':
* 'friendly'
* The friendly URL to use - encase variables in {curly braces} containing a symbol, followed by the name of the parameter that matches in the "real" URL
* The symbol should be # for numbers or @ for strings
* For example, if the "real" URL contains id=XXX, where XXX is a number, you should include {#id} somewhere in the friendly URL.
* You can also use the tag {?} for the "SEO Title" (that is, any variables that shouldn't be part of the real URL, such as the name of the topipc being viewed).
* If you want to support more than one SEO Title, you can give them zero-indexed keys like so: {?0} {?1} {?2}
* 'real'
* This should be the base of the real URL. You should not include parameters which will be parsed out from the friendly URL.
* 'verify'
* This should be the name of a class that contains a loadFromUrl() and an url() method. The dynamic URL (i.e. app=core&...) will be passed to loadFromUrl(), and the url()
* method will subsequently be called to retrieve the correct URL, ideal with ActiveRecord pattern classes.
*
* IMPORTANT: Ensure values are listed with the most specific ones first. This is to ensure that non-FURL redirects are done correctly. For example, if you have these FURLs:
* /index.php?app=myapp&module=mymodule&controller=mycontroller&do=myaction -> /myfolder/myaction
* /index.php?app=myapp&module=mymodule&controller=mycontroller -> /myfolder
* They must be provided in that order, otherwise the former will redirec to /myfolder/?do=myaction rather than /myfolder/myaction
*/
{
"topLevel": "",
"pages": {
"nexus_checkout": {
"friendly": "checkout/{#id}",
"real": "app=nexus&module=checkout&controller=checkout"
},
"support_create": {
"friendly": "support/create",
"real": "app=nexus&module=support&controller=home&do=create"
},
"support_view": {
"friendly": "support/{#id}",
"real": "app=nexus&module=support&controller=view",
"verify": "\\IPS\\nexus\\Support\\Request"
},
"support": {
"friendly": "support",
"real": "app=nexus&module=support&controller=home"
},
"store_group": {
"friendly": "store/category/{#cat}-{?}",
"real": "app=nexus&module=store&controller=store",
"verify": "\\IPS\\nexus\\Package\\Group"
},
"store_product": {
"friendly": "store/product/{#id}-{?}",
"real": "app=nexus&module=store&controller=product",
"verify": "\\IPS\\nexus\\Package\\Item"
},
"store_cart": {
"friendly": "store/cart",
"real": "app=nexus&module=store&controller=cart"
},
"store_giftvouchers_redeem": {
"friendly": "store/redeem",
"real": "app=nexus&module=store&controller=gifts&do=redeem"
},
"store_giftvouchers": {
"friendly": "store/gift-cards",
"real": "app=nexus&module=store&controller=gifts"
},
"store": {
"friendly": "store",
"real": "app=nexus&module=store&controller=store"
},
"clientspurchase": {
"friendly": "clients/purchases/{#id}-{?}",
"real": "app=nexus&module=clients&controller=purchases&do=view",
"verify": "\\IPS\\nexus\\Purchase"
},
"clientspurchases": {
"friendly": "clients/purchases",
"real": "app=nexus&module=clients&controller=purchases"
},
"clientsinvoice": {
"friendly": "clients/orders/{#id}",
"real": "app=nexus&module=clients&controller=invoices&do=view",
"verify": "\\IPS\\nexus\\Invoice"
},
"clientsinvoices": {
"friendly": "clients/orders",
"real": "app=nexus&module=clients&controller=invoices"
},
"clientsaddresses": {
"friendly": "clients/addresses",
"real": "app=nexus&module=clients&controller=addresses"
},
"clientscards": {
"friendly": "clients/cards",
"real": "app=nexus&module=clients&controller=cards"
},
"clientsalternatives": {
"friendly": "clients/alternative-contacts",
"real": "app=nexus&module=clients&controller=alternatives"
},
"clientscredit": {
"friendly": "clients/credit",
"real": "app=nexus&module=clients&controller=credit"
},
"clientsdonate": {
"friendly": "clients/donations/{#id}-{?}",
"real": "app=nexus&module=clients&controller=donations&do=donate",
"verify": "\\IPS\\nexus\\Donation\\Goal"
},
"clientsdonations": {
"friendly": "clients/donations",
"real": "app=nexus&module=clients&controller=donations"
},
"clientsreferrals": {
"friendly": "clients/referrals",
"real": "app=nexus&module=clients&controller=referrals"
},
"clientsinfo": {
"friendly": "clients/info",
"real": "app=nexus&module=clients&controller=info"
},
"clients": {
"friendly": "clients",
"real": "app=nexus&module=clients&controller=invoices"
},
"referral": {
"friendly": "refer/{#id}",
"real": "app=nexus&module=promotion&controller=referral"
},
"nexus_network_status": {
"friendly": "network-status",
"real": "app=nexus&module=clients&controller=networkStatus"
}
}
}
+18
View File
@@ -0,0 +1,18 @@
{
"allowStoreRegistrationGuests": {
"type": "C",
"class": "\\IPS\\core\\modules\\front\\system\\register "
},
"register": {
"type": "C",
"class": "\\IPS\\core\\modules\\front\\system\\register"
},
"clientAreaLinkLoad": {
"type": "C",
"class": "\\IPS\\Data\\Store\\Database"
},
"clientAreaLink": {
"type": "S",
"class": "\\IPS\\Theme\\class_core_front_global"
}
}
View File
Whitespace-only changes.
+18
View File
@@ -0,0 +1,18 @@
{
"nexus_status_1_front": "Open",
"nexus_status_1_admin": "Open",
"nexus_status_2_front": "On Hold",
"nexus_status_2_admin": "Hold",
"nexus_status_3_front": "Awaiting your reply",
"nexus_status_3_admin": "Closed",
"nexus_status_4_front": "Resolved",
"nexus_status_4_admin": "Resolved",
"nexus_status_4_set": "Mark Resolved",
"nexus_status_5_front": "Marked as Spam - Reply if this is an error",
"nexus_status_5_admin": "Spam",
"nexus_status_6_front": "In Progress",
"nexus_status_6_admin": "Working",
"nexus_severity_1": "Normal",
"cm_phone": "Phone Number",
"nexus_ccfield_1": "Phone Number"
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+50
View File
@@ -0,0 +1,50 @@
{
"front": {
"store": {
"default_controller": "store",
"protected": 0
},
"checkout": {
"default_controller": null,
"protected": 1
},
"support": {
"default_controller": "home",
"protected": 0
},
"clients": {
"default_controller": "splash",
"protected": 0
},
"promotion": {
"default_controller": "",
"protected": false
}
},
"admin": {
"payments": {
"default_controller": "transactions",
"protected": 0
},
"customers": {
"default_controller": null,
"protected": 0
},
"support": {
"default_controller": "",
"protected": 0
},
"store": {
"default_controller": "",
"protected": 0
},
"hosting": {
"default_controller": "",
"protected": 0
},
"reports": {
"default_controller": "",
"protected": 0
}
}
}
Whitespace-only changes.
@@ -0,0 +1,20 @@
<?php
$check = urldecode( $_GET['check'] );
if ( substr( $check, 0, 7 ) != 'http://' and substr( $check, 0, 8 ) != 'https://' )
{
exit;
}
$response = @file_get_contents( $check );
if ( $response === FALSE )
{
echo "FAIL";
}
else
{
echo $response;
}
file_put_contents( "./monitor.txt", time() . "\n" . $_GET['notify'] );
@@ -0,0 +1,6 @@
<?php
define( 'VERSION', 1000 );
echo "SUCCESS\n";
echo VERSION;
File diff suppressed because it is too large. Load diff
+310
View File
@@ -0,0 +1,310 @@
[
{
"key": "cm_invoice_expireafter",
"default": "30"
},
{
"key": "cm_invoice_generate",
"default": "10"
},
{
"key": "cm_invoice_warning",
"default": "3"
},
{
"key": "cm_protected",
"default": ""
},
{
"key": "cm_ref_on",
"default": "0"
},
{
"key": "easypost_api_key",
"default": ""
},
{
"key": "easypost_delivery_adjustment",
"default": "0"
},
{
"key": "easypost_phone",
"default": ""
},
{
"key": "easypost_price_adjustment",
"default": ""
},
{
"key": "easypost_show_rates",
"default": "0"
},
{
"key": "easypost_tax",
"default": "0"
},
{
"key": "idm_nexus_display",
"default": "purchases"
},
{
"key": "idm_nexus_gateways",
"default": ""
},
{
"key": "idm_nexus_on",
"default": "0"
},
{
"key": "idm_nexus_percent",
"default": "100"
},
{
"key": "idm_nexus_tax",
"default": "0"
},
{
"key": "idm_nexus_transfee",
"default": "{}"
},
{
"key": "maxmind_error",
"default": "okay"
},
{
"key": "maxmind_key",
"default": ""
},
{
"key": "monitoring_alert",
"default": ""
},
{
"key": "monitoring_allowed_fails",
"default": "1"
},
{
"key": "monitoring_backup",
"default": ""
},
{
"key": "monitoring_from",
"default": ""
},
{
"key": "monitoring_panic",
"default": "6"
},
{
"key": "monitoring_script",
"default": ""
},
{
"key": "network_status",
"default": "0"
},
{
"key": "nexus_autoresolve_applicable",
"default": "3"
},
{
"key": "nexus_autoresolve_days",
"default": "0"
},
{
"key": "nexus_autoresolve_departments",
"default": "*"
},
{
"key": "nexus_autoresolve_notify",
"default": "24"
},
{
"key": "nexus_autoresolve_status",
"default": "4"
},
{
"key": "nexus_checkreg_captcha",
"default": "0"
},
{
"key": "nexus_checkreg_usernames",
"default": "0"
},
{
"key": "nexus_com_rules",
"default": "1"
},
{
"key": "nexus_currency",
"default": "USD"
},
{
"key": "nexus_domain_prices",
"default": "{}"
},
{
"key": "nexus_domain_tax",
"default": "0"
},
{
"key": "nexus_donate_loggedin",
"default": "0"
},
{
"key": "nexus_enom_pw",
"default": ""
},
{
"key": "nexus_enom_un",
"default": ""
},
{
"key": "nexus_gift_vouchers",
"default": ""
},
{
"key": "nexus_gift_vouchers_free",
"default": "0"
},
{
"key": "nexus_hosting_allow_own_domain",
"default": "1"
},
{
"key": "nexus_hosting_bandwidth",
"default": ""
},
{
"key": "nexus_hosting_error_emails",
"default": ""
},
{
"key": "nexus_hosting_nameservers",
"default": ""
},
{
"key": "nexus_hosting_subdomains",
"default": ""
},
{
"key": "nexus_hosting_terminate",
"default": "60"
},
{
"key": "nexus_https",
"default": "0"
},
{
"key": "nexus_invoice_footer",
"default": ""
},
{
"key": "nexus_invoice_header",
"default": ""
},
{
"key": "nexus_max_credit",
"default": ""
},
{
"key": "nexus_min_topup",
"default": ""
},
{
"key": "nexus_minimum_order",
"default": ""
},
{
"key": "nexus_no_commission",
"default": ""
},
{
"key": "nexus_notify_copy_email",
"default": ""
},
{
"key": "nexus_notify_copy_types",
"default": ""
},
{
"key": "nexus_payout",
"default": ""
},
{
"key": "nexus_payout_approve",
"default": "1"
},
{
"key": "nexus_payout_min",
"default": ""
},
{
"key": "nexus_reg_force",
"default": "0"
},
{
"key": "nexus_reg_group",
"default": "0"
},
{
"key": "nexus_revw_sa",
"default": "0"
},
{
"key": "nexus_severities",
"default": "1"
},
{
"key": "nexus_show_stock",
"default": "0"
},
{
"key": "nexus_show_tax",
"default": "0"
},
{
"key": "nexus_sout_autoreply",
"default": "0"
},
{
"key": "nexus_sout_chrome",
"default": "0"
},
{
"key": "nexus_sout_from",
"default": "staff"
},
{
"key": "nexus_split_payments",
"default": "0"
},
{
"key": "nexus_store_new",
"default": "10,30"
},
{
"key": "nexus_store_popular",
"default": "10,365"
},
{
"key": "nexus_support_satisfaction",
"default": "1"
},
{
"key": "nexus_tac",
"default": "none"
},
{
"key": "nexus_tac_link",
"default": ""
},
{
"key": "support_old_number",
"default": "0"
},
{
"key": "support_old_stat",
"default": "r_last_new_reply"
}
]
+1
View File
@@ -0,0 +1 @@
{"capture":"P0Y0M0DT1H0M0S","sendInvoiceWarnings":"P0Y0M0DT1H0M0S","generateRenewalInvoices":"P0Y0M0DT0H30M0S","expirePurchases":"P0Y0M0DT1H0M0S","expireInvoices":"P0Y0M0DT1H0M0S","supportAutoresolve":"P0Y0M0DT1H0M0S","supportAssignedReminder":"P0Y0M1DT0H0M0S","monitor":"P0Y0M0DT0H5M0S","terminateHosting":"P0Y0M1DT0H0M0S","expectedOutputMonitoring":"P0Y0M0DT0H30M0S"}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,14 @@
[
{
"sc_key": "cm_store_view",
"sc_type": "Select",
"sc_multiple": 0,
"sc_content": "[{\"key\":\"grid\",\"value\":\"Grid\"},{\"key\":\"list\",\"value\":\"List\"}]",
"sc_app": "nexus",
"sc_default": "grid",
"sc_tab_key": "custom",
"sc_show_in_vse": 0,
"sc_title": "themesetting_cm_store_view",
"sc_order": 10
}
]
+115
View File
@@ -0,0 +1,115 @@
{
"10000": "1.0 Alpha 1",
"10001": "1.0 Alpha 2",
"10002": "1.0 Alpha 3",
"10003": "1.0 Alpha 4",
"10004": "1.0 Alpha 5",
"10005": "1.0 Alpha 6",
"10006": "1.0 Beta 1",
"10007": "1.0 Beta 2",
"10008": "1.0 Beta 3",
"10009": "1.0 Beta 4",
"10010": "1.0 Beta 5",
"10011": "1.0 Beta 6",
"10012": "1.0 Beta 7",
"10013": "1.0 Beta 8",
"10014": "1.0.0",
"10015": "1.0.1",
"10016": "1.0.2",
"10017": "1.0.3",
"10100": "1.1.0 Alpha 1",
"10101": "1.1.0 Alpha 2",
"10102": "1.1.0 Alpha 3",
"10103": "1.1.0 Alpha 4",
"10104": "1.1.0 Alpha 5",
"10105": "1.1.0 Beta 1",
"11000": "1.1.0",
"11001": "1.1.1",
"11002": "1.1.2",
"11003": "1.1.3",
"11100": "1.2 Alpha 1",
"11101": "1.2 Alpha 2",
"11102": "1.2 Alpha 3",
"11103": "1.2 Alpha 4",
"11104": "1.2 Beta 1",
"11105": "1.2 Beta 2",
"11106": "1.2 Beta 3",
"11107": "1.2 Beta 4",
"11108": "1.2 Beta 5",
"11109": "1.2.0",
"12001": "1.2.1",
"12002": "1.2.2",
"12100": "1.3.0 Alpha 1",
"13000": "1.3.0",
"13001": "1.3.0 Beta 2",
"13002": "1.3.0",
"13003": "1.3.1",
"13004": "1.3.2",
"14000": "1.4.0 Beta 1",
"14001": "1.4.0 Beta 2",
"14002": "1.4.0",
"14003": "1.4.1",
"14004": "1.4.2",
"15000": "1.5.0 Alpha 1",
"15001": "1.5.0 Alpha 2",
"15002": "1.5.0 Alpha 3",
"15003": "1.5.0 Beta 1",
"15004": "1.5.0 Beta 2",
"15005": "1.5.0",
"15006": "1.5.1",
"15007": "1.5.2",
"15008": "1.5.3",
"15009": "1.5.4",
"15010": "1.5.5",
"15011": "1.5.6",
"15012": "1.5.7",
"15013": "1.5.8",
"15014": "1.5.9",
"40000": "4.0.0",
"100000": "4.0.0 Beta 0",
"100001": "4.0.0 Beta 1",
"100002": "4.0.0 Beta 2",
"100003": "4.0.0 Beta 3",
"100004": "4.0.0 Beta 3a",
"100005": "4.0.0 Beta 4",
"100006": "4.0.0 Beta 4a",
"100007": "4.0.0 Beta 4b",
"100008": "4.0.0 Beta 5",
"100009": "4.0.0 Beta 5a",
"100010": "4.0.0 Beta 6",
"100011": "4.0.0 Beta 7",
"100012": "4.0.0 Beta 7a",
"100013": "4.0.0 Beta 8",
"100014": "4.0.0 RC1",
"100015": "4.0.0 RC2",
"100016": "4.0.0 RC3",
"100017": "4.0.0 RC4",
"100018": "4.0.0 RC5",
"100019": "4.0.0 RC5a",
"100020": "4.0.0 RC6",
"100021": "4.0.0 RC7",
"100022": "4.0.0 RC7a",
"100023": "4.0.0",
"100024": "4.0.1",
"100025": "4.0.2",
"100026": "4.0.3",
"100027": "4.0.4",
"100028": "4.0.5",
"100029": "4.0.5.1",
"100030": "4.0.6",
"100031": "4.0.6.1",
"100032": "4.0.7",
"100033": "4.0.8",
"100034": "4.0.8.1",
"100035": "4.0.9",
"100036": "4.0.9.1",
"100037": "4.0.9.2",
"100038": "4.0.10",
"100039": "4.0.10.1",
"100040": "4.0.10.2",
"100041": "4.0.11",
"100042": "4.0.12",
"100043": "4.0.12.1",
"100044": "4.0.13",
"100045": "4.0.13.1"
}
+24
View File
@@ -0,0 +1,24 @@
{
"pendingActions": {
"class": "\\IPS\\Widget",
"restrict": [
"sidebar",
"cms"
],
"default_area": "",
"allow_reuse": false,
"menu_style": "menu",
"embeddable": true
},
"donations": {
"class": "\\IPS\\Widget\\StaticCache",
"restrict": [
"sidebar",
"cms"
],
"default_area": "",
"allow_reuse": false,
"menu_style": "menu",
"embeddable": true
}
}
@@ -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.
Whitespace-only changes.
@@ -0,0 +1,157 @@
<?php
/**
* @brief Account Credit Increase
* @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 25 Mar 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\extensions\nexus\Item;
/* 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;
}
/**
* Account Credit Topup
*/
class _AccountCreditIncrease extends \IPS\nexus\Invoice\Item\Charge
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'topup';
/**
* @brief Icon
*/
public static $icon = 'folder-open';
/**
* @brief Title
*/
public static $title = 'account_credit_increase';
/**
* @brief Can use coupons?
*/
public static $canUseCoupons = FALSE;
/**
* @brief Can use account credit?
*/
public static $canUseAccountCredit = FALSE;
/**
* Generate Invoice Form
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function form( \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
{
$form->add( new \IPS\Helpers\Form\Number( 'credit_amount', 0, TRUE, array( 'decimals' => TRUE ), NULL, NULL, $invoice->currency ) );
}
/**
* Create From Form
*
* @param array $values Values from form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return \IPS\nexus\extensions\nexus\Item\MiscellaneousCharge
*/
public static function createFromForm( array $values, \IPS\nexus\Invoice $invoice )
{
$obj = new static( $invoice->member->language()->get('account_credit'), new \IPS\nexus\Money( $values['credit_amount'], $invoice->currency ) );
return $obj;
}
/**
* On Paid
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public function onPaid( \IPS\nexus\Invoice $invoice )
{
$credits = $invoice->member->cm_credits;
$oldAmount = $credits[ $this->price->currency ]->amount;
$credits[ $this->price->currency ]->amount += $this->price->amount;
$invoice->member->cm_credits = $credits;
$invoice->member->save();
$invoice->member->log( 'comission', array(
'type' => 'bought',
'currency' => $this->price->currency,
'amount' => $oldAmount,
'new_amount' => $credits[ $this->price->currency ]->amount,
'invoice_id' => $invoice->id,
'invoice_title' => $invoice->title
) );
}
/**
* On Unpaid description
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @return array
*/
public function onUnpaidDescription( \IPS\nexus\Invoice $invoice )
{
$return = parent::onUnpaidDescription( $invoice );
$message = \IPS\Member::loggedIn()->language()->addToStack('account_credit_remove', FALSE, array( 'sprintf' => array( $this->price, $invoice->member->cm_name ) ) );
$credits = $invoice->member->cm_credits;
if ( ( $credits[ $this->price->currency ]->amount - $this->price->amount ) < 0 )
{
$return[] = array( 'message' => $message, 'warning' => \IPS\Member::loggedIn()->language()->addToStack('account_credit_remove_neg') );
}
else
{
$return[] = $message;
}
return $return;
}
/**
* On Unpaid
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @param string $status Status
* @return void
*/
public function onUnpaid( \IPS\nexus\Invoice $invoice, $status )
{
$credits = $invoice->member->cm_credits;
$oldAmount = $credits[ $this->price->currency ]->amount;
$credits[ $this->price->currency ]->amount -= $this->price->amount;
$invoice->member->cm_credits = $credits;
$invoice->member->save();
$invoice->member->log( 'comission', array(
'type' => 'bought',
'currency' => $this->price->currency,
'amount' => $oldAmount,
'new_amount' => $credits[ $this->price->currency ]->amount,
'invoice_id' => $invoice->id,
'invoice_title' => $invoice->title
) );
}
}
@@ -0,0 +1,119 @@
<?php
/**
* @brief Bandwidth
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Nexus
* @since 11 Sep 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\extensions\nexus\Item;
/* 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;
}
/**
* Bandwidth
*/
class _Bandwidth extends \IPS\nexus\Invoice\Item\Purchase
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'bandwidth';
/**
* @brief Icon
*/
public static $icon = 'cloud-upload';
/**
* @brief Title
*/
public static $title = 'bandwidth';
/**
* Show Purchase Record?
*
* @return bool
*/
public function showPurchaseRecord()
{
return FALSE;
}
/**
* On Purchase Generated
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function onPurchaseGenerated( \IPS\nexus\Purchase $purchase, \IPS\nexus\Invoice $invoice )
{
try
{
$account = \IPS\nexus\Hosting\Account::load( $purchase->parent );
$account->changeBandWidthLimit( $account->monthlyBandwidthAllowance() + ( $purchase->extra['bwAmount'] * 1000000 ) );
}
catch ( \IPS\nexus\Hosting\Exception $e )
{
$e->log();
}
catch ( \OutOfRangeException $e ) { }
}
/**
* On Purchase Expired
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return void
*/
public static function onExpire( \IPS\nexus\Purchase $purchase )
{
$purchase->delete();
}
/**
* On Purchase Canceled
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return void
*/
public static function onCancel( \IPS\nexus\Purchase $purchase )
{
$purchase->delete();
}
/**
* On Purchase Deleted
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return void
*/
public static function onDelete( \IPS\nexus\Purchase $purchase )
{
try
{
$account = \IPS\nexus\Hosting\Account::load( $purchase->parent );
$account->changeBandWidthLimit( $account->monthlyBandwidthAllowance() - ( $purchase->extra['bwAmount'] * 1000000 ) );
}
catch ( \IPS\nexus\Hosting\Exception $e )
{
$e->log();
}
catch ( \OutOfRangeException $e ) { }
}
}
@@ -0,0 +1,119 @@
<?php
/**
* @brief Coupon Discount
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Nexus
* @since 12 May 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\extensions\nexus\Item;
/* 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;
}
/**
* Coupon Discount
*/
class _CouponDiscount extends \IPS\nexus\Invoice\Item\Charge
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'coupon';
/**
* @brief Icon
*/
public static $icon = 'ticket';
/**
* @brief Title
*/
public static $title = 'coupon';
/**
* On Paid
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public function onPaid( \IPS\nexus\Invoice $invoice )
{
try
{
$coupon = \IPS\nexus\Coupon::load( $this->id );
if ( $coupon->max_uses >= 1 )
{
$coupon->max_uses--;
$coupon->save();
}
}
catch ( \OutOfRangeException $e ) { }
}
/**
* On Unpaid
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @param string $status Status
* @return void
*/
public function onUnpaid( \IPS\nexus\Invoice $invoice, $status )
{
try
{
$coupon = \IPS\nexus\Coupon::load( $this->id );
if ( $coupon->max_uses != -1 )
{
$coupon->max_uses++;
$coupon->save();
}
$this->onInvoiceCancel( $invoice );
}
catch ( \OutOfRangeException $e ) { }
}
/**
* On Invoice Cancel (when unpaid)
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public function onInvoiceCancel( \IPS\nexus\Invoice $invoice )
{
try
{
$coupon = \IPS\nexus\Coupon::load( $this->id );
$uses = $coupon->used_by ? json_decode( $coupon->used_by, TRUE ) : array();
$member = isset( $this->extra['usedBy'] ) ? $this->extra['usedBy'] : $invoice->member->member_id;
if ( isset( $uses[ $member ] ) )
{
if ( $uses[ $member ] === 1 )
{
unset( $uses[ $member ] );
}
else
{
$uses[ $member ]--;
}
$coupon->used_by = json_encode( $uses );
$coupon->save();
}
}
catch ( \OutOfRangeException $e ) { }
}
}
@@ -0,0 +1,455 @@
<?php
/**
* @brief Custom Package
* @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 Aug 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\extensions\nexus\Item;
/* 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;
}
/**
* Custom Package
*/
class _CustomPackage extends \IPS\nexus\extensions\nexus\Item\Package
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'custom';
/**
* @brief Icon
*/
public static $icon = 'asterisk';
/**
* @brief Title
*/
public static $title = 'custom';
/**
* Generate Invoice Form
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function form( \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
{
$groups = array();
foreach ( \IPS\Member\Group::groups() as $group )
{
$groups[ $group->g_id ] = $group->name;
}
$types = array();
$typeFields = array();
$typeFieldToggles = array();
$formId = 'form_new';
foreach ( new \DirectoryIterator( \IPS\ROOT_PATH . '/applications/nexus/sources/Package' ) as $file )
{
if ( !$file->isDot() and $file != 'Dedi.php' and $file != 'index.html' and !$file->isDir() )
{
require_once $file->getPathname();
$key = mb_substr( $file, 0, -4 );
$class = 'IPS\nexus\Package\_' . $key;
if ( class_exists( $class, FALSE ) and in_array( 'IPS\nexus\Package', class_parents( $class ) ) )
{
$forceShow = TRUE;
$types[ mb_strtolower( $key ) ] = 'p_type_' . $key;
foreach ( $class::acpFormFields( new $class, TRUE ) as $group => $fields )
{
foreach ( $fields as $field )
{
if ( $field->name === 'p_show' )
{
$forceShow = FALSE;
}
if ( !$field->htmlId )
{
$field->htmlId = $field->name;
$typeFieldToggles[ mb_strtolower( $key ) ][] = $field->htmlId;
}
$typeFields[ $group ][] = $field;
}
}
if ( $forceShow )
{
$typeFieldToggles[ mb_strtolower( $key ) ] = array_merge( isset( $typeFieldToggles[ mb_strtolower( $key ) ] ) ? $typeFieldToggles[ mb_strtolower( $key ) ] : array(), array( "{$formId}_tab_package_client_area", "{$formId}_header_package_associations", "{$formId}_header_package_associations_desc", 'p_associate', "{$formId}_header_package_renewals", 'p_renews', 'p_support_severity', 'p_lkey' ) );
}
}
}
}
$form->addTab('package_settings');
$form->add( new \IPS\Helpers\Form\Radio( 'p_type', 'product', TRUE, array( 'options' => $types, 'toggles' => $typeFieldToggles ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'p_name', NULL, TRUE ) );
foreach ( $typeFields['package_settings'] as $field )
{
$form->add( $field );
}
$form->addTab( 'package_pricing' );
$form->add( new \IPS\Helpers\Form\Number( 'p_base_price', 0, TRUE, array(), NULL, NULL, $invoice->currency ) );
$form->add( new \IPS\Helpers\Form\Node( 'p_tax', 0, FALSE, array( 'class' => 'IPS\nexus\Tax', 'zeroVal' => 'do_not_tax' ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_renews', FALSE, FALSE, array( 'togglesOn' => array( 'p_renew_options', 'p_renew' ) ), NULL, NULL, NULL, 'p_renews' ) );
$form->add( new \IPS\nexus\Form\RenewalTerm( 'p_renew_options', NULL, FALSE, array( 'currency' => $invoice->currency ), NULL, NULL, NULL, 'p_renew_options' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_renew', FALSE, FALSE, array( 'togglesOn' => array( 'p_renewal_days', 'p_renewal_days_advance' ) ), NULL, NULL, NULL, 'p_renew' ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_renewal_days', -1, FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'any_time' ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days_before_expiry'), 'p_renewal_days' ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_renewal_days_advance', -1, FALSE, array( 'unlimited' => -1 ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'p_renewal_days_advance' ) );
$form->addTab( 'package_benefits' );
unset( $groups[ \IPS\Settings::i()->guest_group ] );
$form->add( new \IPS\Helpers\Form\Select( 'p_primary_group', '*', FALSE, array( 'options' => $groups, 'unlimited' => '*', 'unlimitedLang' => 'do_not_change', 'unlimitedToggles' => array( 'p_return_primary' ), 'unlimitedToggleOn' => FALSE ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_return_primary', TRUE, FALSE, array(), NULL, NULL, NULL, 'p_return_primary' ) );
$form->add( new \IPS\Helpers\Form\Select( 'p_secondary_group', '*', FALSE, array( 'options' => $groups, 'multiple' => TRUE, 'unlimited' => '*', 'unlimitedLang' => 'do_not_change', 'unlimitedToggles' => array( 'p_return_secondary' ), 'unlimitedToggleOn' => FALSE ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_return_secondary', TRUE, FALSE, array(), NULL, NULL, NULL, 'p_return_secondary' ) );
$form->add( new \IPS\Helpers\Form\Node( 'p_support_severity', 0, FALSE, array( 'class' => 'IPS\nexus\Support\Severity', 'zeroVal' => 'none' ), NULL, NULL, NULL, 'p_support_severity' ) );
foreach ( $typeFields['package_benefits'] as $field )
{
$form->add( $field );
}
$form->addTab('package_client_area_display');
$form->add( new \IPS\Helpers\Form\Editor( 'p_page', NULL, FALSE, array(
'app' => 'nexus',
'key' => 'Admin',
'autoSaveKey' => "nexus-new-pkg-pg",
'attachIds' => NULL, 'minimize' => 'p_page_placeholder'
), NULL, NULL, NULL, 'p_desc_editor' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_support', FALSE, FALSE, array( 'togglesOn' => array( 'p_support_department' ) ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'p_support_department', 0, FALSE, array( 'class' => 'IPS\nexus\Support\Department', 'zeroVal' => 'none' ), NULL, NULL, NULL, 'p_support_department' ) );
}
/**
* Generate Invoice Form: Second Step
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return bool
*/
public static function formSecondStep( array $values, \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
{
$classname = 'IPS\nexus\Package\\' . ucfirst( $values['p_type'] );
if ( method_exists( $classname, 'generateInvoiceForm' ) )
{
if ( isset( \IPS\Request::i()->customPackageId ) )
{
$package = \IPS\nexus\Package::load( \IPS\Request::i()->customPackageId );
}
else
{
$package = static::_createPackage( $values, $invoice );
}
$form->hiddenValues['customPackageId'] = $package->id;
$package->generateInvoiceForm( $form, '' );
return TRUE;
}
else
{
return FALSE;
}
}
/**
* Create the package
*
* @param array $values Values from form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return \IPS\nexus\Package
*/
protected static function _createPackage( array $values, \IPS\nexus\Invoice $invoice )
{
/* Init */
$package = new \IPS\nexus\Package;
/* Set default values for stuff we didn't have */
$values['p_member_groups'] = array();
$values['p_notify'] = array();
$values['p_usergroup_discounts'] = array();
$values['p_loyalty_discounts'] = array();
$values['p_bulk_discounts'] = array();
$values['p_images'] = array();
$values['p_group'] = new \StdClass;
$values['p_group']->id = 0;
$renewTerm = $values['p_renews'] ? new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( \IPS\Request::i()->p_renew_options['amount'], \IPS\Request::i()->p_renew_options['currency'] ), new \DateInterval( 'P' . \IPS\Request::i()->p_renew_options['term'] . mb_strtoupper( \IPS\Request::i()->p_renew_options['unit'] ) ), NULL, FALSE ) : NULL;
$values['p_renew_options'] = array();
/* Save */
$package->saveForm( $package->formatFormValues( $values ) );
/* Custom-specific */
$package = \IPS\nexus\Package::load( $package->id );
$package->name = $values['p_name'];
$package->base_price = json_encode( array( $invoice->currency => array( 'amount' => $values['p_base_price'], 'currency' => $invoice->currency ) ) );
if ( $values['p_renews'] )
{
$term = $renewTerm->getTerm();
$package->renew_options = json_encode( array( array(
'cost' => $renewTerm->cost,
'term' => $term['term'],
'unit' => $term['unit'],
'add' => FALSE
) ) );
}
else
{
$package->renew_options = NULL;
}
$package->store = 0;
$package->page = $values['p_page'];
$package->custom = $invoice->member->member_id;
$package->save();
/* Return */
return $package;
}
/**
* Create From Form
*
* @param array $values Values from form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return \IPS\nexus\extensions\nexus\Item\CustomPackage
*/
public static function createFromForm( array $values, \IPS\nexus\Invoice $invoice )
{
/* Create the package */
if ( isset( \IPS\Request::i()->customPackageId ) )
{
$package = \IPS\nexus\Package::load( \IPS\Request::i()->customPackageId );
}
else
{
$package = static::_createPackage( $values, $invoice );
}
/* Work stuff out */
$basePrice = json_decode( $package->base_price, TRUE );
if ( $package->renew_options )
{
$renewTerm = json_decode( $package->renew_options, TRUE );
$renewTerm = array_pop( $renewTerm );
$renewTerm = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $renewTerm['cost']['amount'], $renewTerm['cost']['currency'] ), new \DateInterval( 'P' . $renewTerm['term'] . mb_strtoupper( $renewTerm['unit'] ) ), NULL, FALSE );
}
else
{
$renewTerm = NULL;
}
/* Now create an item */
$item = new static( $package->name, new \IPS\nexus\Money( $basePrice[ $invoice->currency ]['amount'], $invoice->currency ) );
$item->renewalTerm = $renewTerm;
$item->quantity = 1;
$item->id = $package->id;
$item->tax = $package->tax ? \IPS\nexus\Tax::load( $package->tax ) : NULL;
if ( $package instanceof \IPS\nexus\Package\Product and $package->physical )
{
$item->physical = TRUE;
$item->weight = new \IPS\nexus\Shipping\Weight( $package->weight );
$item->length = new \IPS\nexus\Shipping\Length( $package->length );
$item->width = new \IPS\nexus\Shipping\Length( $package->width );
$item->height = new \IPS\nexus\Shipping\Length( $package->height );
if ( $package->shipping !== '*' )
{
$item->shippingMethodIds = explode( ',', $package->shipping );
}
}
$package->acpAddToInvoice( $item, $values, '', $invoice );
/* And return */
return $item;
}
/**
* ACP Edit Form
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Purchase\RenewalTerm $renewals The renewal term
* @return string
*/
public static function acpEdit( \IPS\nexus\Purchase $purchase, \IPS\Helpers\Form $form, $renewals )
{
$form->addTab( 'basic_settings' );
parent::acpEdit( $purchase, $form, $renewals );
$package = \IPS\nexus\Package::load( $purchase->item_id );
$typeFields = $package->acpFormFields( $package, TRUE, TRUE );
$groups = array();
foreach ( \IPS\Member\Group::groups() as $group )
{
$groups[ $group->g_id ] = $group->name;
}
if ( isset( $typeFields['package_settings'] ) )
{
foreach ( $typeFields['package_settings'] as $field )
{
$form->add( $field );
}
}
$form->add( new \IPS\Helpers\Form\YesNo( 'p_renew', $package->renewal_days != 0, FALSE, array( 'togglesOn' => array( 'p_renewal_days', 'p_renewal_days_advance' ) ), NULL, NULL, NULL, 'p_renew' ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_renewal_days', $package->renewal_days, FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'any_time' ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days_before_expiry'), 'p_renewal_days' ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_renewal_days_advance', $package->renewal_days_advance, FALSE, array( 'unlimited' => -1 ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'p_renewal_days_advance' ) );
$form->addTab( 'package_benefits' );
unset( $groups[ \IPS\Settings::i()->guest_group ] );
$form->add( new \IPS\Helpers\Form\Select( 'p_primary_group', $package->primary_group ?: '*', FALSE, array( 'options' => $groups, 'unlimited' => '*', 'unlimitedLang' => 'do_not_change', 'unlimitedToggles' => array( 'p_return_primary' ), 'unlimitedToggleOn' => FALSE ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_return_primary', $package->return_primary, FALSE, array(), NULL, NULL, NULL, 'p_return_primary' ) );
$form->add( new \IPS\Helpers\Form\Select( 'p_secondary_group', $package->secondary_group ? explode( ',', $package->member_groups ) : '*', FALSE, array( 'options' => $groups, 'multiple' => TRUE, 'unlimited' => '*', 'unlimitedLang' => 'do_not_change', 'unlimitedToggles' => array( 'p_return_secondary' ), 'unlimitedToggleOn' => FALSE ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_return_secondary', $package->return_secondary, FALSE, array(), NULL, NULL, NULL, 'p_return_secondary' ) );
$form->add( new \IPS\Helpers\Form\Node( 'p_support_severity', 0, $package->support_severity ?: 0, array( 'class' => 'IPS\nexus\Support\Severity', 'zeroVal' => 'none' ), NULL, NULL, NULL, 'p_support_severity' ) );
if ( isset( $typeFields['package_benefits'] ) )
{
foreach ( $typeFields['package_benefits'] as $field )
{
$form->add( $field );
}
}
$form->addTab('package_client_area_display');
$form->add( new \IPS\Helpers\Form\Editor( 'p_page', $package->page, FALSE, array(
'app' => 'nexus',
'key' => 'Admin',
'autoSaveKey' => "nexus-new-pkg-pg",
'attachIds' => NULL, 'minimize' => 'p_page_placeholder'
), NULL, NULL, NULL, 'p_desc_editor' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_support', $package->support, FALSE, array( 'togglesOn' => array( 'p_support_department' ) ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'p_support_department', $package->support ?: 0, FALSE, array( 'class' => 'IPS\nexus\Support\Department', 'zeroVal' => 'none' ), NULL, NULL, NULL, 'p_support_department' ) );
}
/**
* ACP Edit Save
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param array $values Values from form
* @return string
*/
public static function acpEditSave( \IPS\nexus\Purchase $purchase, array $values )
{
parent::acpEditSave( $purchase, $values );
$package = \IPS\nexus\Package::load( $purchase->item_id );
$package->_removeUsergroups( $purchase );
$resetLkey = FALSE;
$updateLkey = FALSE;
$deleteLkey = FALSE;
$package->show = $values['p_show'];
$package->renewal_days = $values['p_renew'] ? $values['p_renewal_days'] : 0;
$package->renewal_days_advance = $values['p_renew'] ? $values['p_renewal_days_advance'] : 0;
$package->primary_group = $values['p_primary_group'] == '*' ? 0 : $values['p_primary_group'];
$package->return_primary = $values['p_return_primary'];
$package->secondary_group = $values['p_secondary_group'] == '*' ? '*' : implode( ',', $values['p_secondary_group'] );
$package->return_secondary = $values['p_return_secondary'];
$package->support_severity = $values['p_support_severity'] ? $values['p_support_severity']->id : 0;
if ( $values['p_lkey'] != $package->lkey )
{
$package->lkey = $values['p_lkey'];
if ( $values['p_lkey'] )
{
$resetLkey = TRUE;
}
else
{
$deleteLkey = TRUE;
}
}
if ( $values['p_lkey_identifier'] != $package->lkey_identifier )
{
$package->lkey_identifier = $values['p_lkey_identifier'];
$updateLkey = TRUE;
}
if ( $values['p_lkey_uses'] != $package->lkey_uses )
{
$package->lkey_uses = $values['p_lkey_uses'];
$updateLkey = TRUE;
}
$package->page = $values['p_page'];
$package->support = ( $values['p_support'] and $values['p_support_department'] ) ? $values['p_support_department']->id : 0;
$package->save();
$package->_addUsergroups( $purchase );
if ( $resetLkey or $updateLkey or $deleteLkey )
{
if ( $resetLkey or $deleteLkey )
{
try
{
$purchase->licenseKey()->delete();
}
catch ( \OutOfRangeException $e ) { }
if ( $resetLkey )
{
$class = 'IPS\nexus\Purchase\LicenseKey\\' . ucfirst( $package->lkey );
$licenseKey = new $class;
}
}
elseif ( $updateLkey )
{
try
{
$licenseKey = $purchase->licenseKey();
}
catch ( \OutOfRangeException $e )
{
$class = 'IPS\nexus\Purchase\LicenseKey\\' . ucfirst( $package->lkey );
$licenseKey = new $class;
}
}
if ( $resetLkey or $updateLkey )
{
$licenseKey->identifier = $package->lkey_identifier;
$licenseKey->purchase = $purchase;
$licenseKey->max_uses = $package->lkey_uses;
$licenseKey->save();
}
}
}
/**
* Show Purchase Record?
*
* @return bool
*/
public function showPurchaseRecord()
{
return call_user_func_array( array( \IPS\nexus\Package::load( $this->id ), 'showPurchaseRecord' ), func_get_args() );
}
}
@@ -0,0 +1,119 @@
<?php
/**
* @brief Dedicated Server
* @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 Aug 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\extensions\nexus\Item;
/* 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;
}
/**
* Dedicated Server
*/
class _DedicatedServer extends \IPS\nexus\extensions\nexus\Item\CustomPackage
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'dedi';
/**
* @brief Icon
*/
public static $icon = 'server';
/**
* @brief Title
*/
public static $title = 'dedicated_server';
/**
* Generate Invoice Form
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function form( \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
{
$groups = array();
foreach ( \IPS\Member\Group::groups() as $group )
{
$groups[ $group->g_id ] = $group->name;
}
$form->addTab('package_settings');
$form->add( new \IPS\Helpers\Form\Node( 'dedicated_server', NULL, TRUE, array( 'class' => 'IPS\nexus\Hosting\Server', 'permissionCheck' => function( $server )
{
return $server->type == 'none';
} ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_base_price', 0, TRUE, array(), NULL, NULL, $invoice->currency ) );
$form->add( new \IPS\Helpers\Form\Node( 'p_tax', 0, FALSE, array( 'class' => 'IPS\nexus\Tax', 'zeroVal' => 'do_not_tax' ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_renews', FALSE, FALSE, array( 'togglesOn' => array( 'p_renew_options', 'p_renew' ) ), NULL, NULL, NULL, 'p_renews' ) );
$form->add( new \IPS\nexus\Form\RenewalTerm( 'p_renew_options', NULL, FALSE, array( 'currency' => $invoice->currency ), NULL, NULL, NULL, 'p_renew_options' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_renew', FALSE, FALSE, array( 'togglesOn' => array( 'p_renewal_days', 'p_renewal_days_advance' ) ), NULL, NULL, NULL, 'p_renew' ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_renewal_days', -1, FALSE, array( 'unlimited' => -1, 'unlimitedLang' => 'any_time' ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days_before_expiry'), 'p_renewal_days' ) );
$form->add( new \IPS\Helpers\Form\Number( 'p_renewal_days_advance', -1, FALSE, array( 'unlimited' => -1 ), NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('days'), 'p_renewal_days_advance' ) );
$form->addTab( 'package_benefits' );
unset( $groups[ \IPS\Settings::i()->guest_group ] );
$form->add( new \IPS\Helpers\Form\Select( 'p_primary_group', '*', FALSE, array( 'options' => $groups, 'unlimited' => '*', 'unlimitedLang' => 'do_not_change', 'unlimitedToggles' => array( 'p_return_primary' ), 'unlimitedToggleOn' => FALSE ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_return_primary', TRUE, FALSE, array(), NULL, NULL, NULL, 'p_return_primary' ) );
$form->add( new \IPS\Helpers\Form\Select( 'p_secondary_group', '*', FALSE, array( 'options' => $groups, 'multiple' => TRUE, 'unlimited' => '*', 'unlimitedLang' => 'do_not_change', 'unlimitedToggles' => array( 'p_return_secondary' ), 'unlimitedToggleOn' => FALSE ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_return_secondary', TRUE, FALSE, array(), NULL, NULL, NULL, 'p_return_secondary' ) );
$form->add( new \IPS\Helpers\Form\Node( 'p_support_severity', 0, FALSE, array( 'class' => 'IPS\nexus\Support\Severity', 'zeroVal' => 'none' ), NULL, NULL, NULL, 'p_support_severity' ) );
$form->addTab('package_client_area_display');
$form->add( new \IPS\Helpers\Form\Editor( 'p_page', NULL, FALSE, array(
'app' => 'nexus',
'key' => 'Admin',
'autoSaveKey' => "nexus-new-pkg-pg",
'attachIds' => NULL, 'minimize' => 'p_page_placeholder'
), NULL, NULL, NULL, 'p_desc_editor' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'p_support', FALSE, FALSE, array( 'togglesOn' => array( 'p_support_department' ) ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'p_support_department', 0, FALSE, array( 'class' => 'IPS\nexus\Support\Department', 'zeroVal' => 'none' ), NULL, NULL, NULL, 'p_support_department' ) );
}
/**
* Create the package
*
* @param array $values Values from form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return \IPS\nexus\Package
*/
protected static function _createPackage( array $values, \IPS\nexus\Invoice $invoice )
{
$values['p_type'] = 'dedi';
$values['p_name'] = $values['dedicated_server']->hostname;
return parent::_createPackage( $values, $invoice );
}
/**
* Generate Invoice Form: Second Step
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return bool
*/
public static function formSecondStep( array $values, \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
{
return FALSE;
}
}
@@ -0,0 +1,180 @@
<?php
/**
* @brief Domain
* @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 Aug 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\extensions\nexus\Item;
/* 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;
}
/**
* Domain
*/
class _Domain extends \IPS\nexus\Invoice\Item\Purchase
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'domain';
/**
* @brief Icon
*/
public static $icon = 'globe';
/**
* @brief Title
*/
public static $title = 'domain';
/**
* Generate Invoice Form: First Step
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function form( \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
{
$domainPrices = json_decode( \IPS\Settings::i()->nexus_domain_prices, TRUE );
$form->add( new \IPS\Helpers\Form\Custom( 'ha_domain_to_buy', NULL, NULL, array(
'getHtml' => function( $field ) use ( $domainPrices, $invoice )
{
$prices = array();
foreach ( $domainPrices as $tld => $_prices )
{
$prices[ $tld ] = new \IPS\nexus\Money( $_prices[ $invoice->currency ]['amount'], $invoice->currency );
}
return \IPS\Theme::i()->getTemplate( 'store', 'nexus', 'front' )->domainBuy( $field, $prices );
},
'validate' => function( $field )
{
if ( !$field->value['tld'] or !$field->value['sld'] )
{
throw new \DomainException('form_required');
}
else
{
$enom = new \IPS\nexus\DomainRegistrar\Enom( \IPS\Settings::i()->nexus_enom_un, \IPS\Settings::i()->nexus_enom_pw );
if ( !$enom->check( $field->value['sld'], $field->value['tld'] ) )
{
throw new \DomainException('domain_not_available');
}
}
}
), NULL, NULL, NULL, 'ha_domain_to_buy' ) );
$form->add( new \IPS\Helpers\Form\Stack( 'server_nameservers', explode( ',', \IPS\Settings::i()->nexus_hosting_nameservers ), TRUE ) );
}
/**
* Create From Form
*
* @param array $values Values from form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return \IPS\nexus\extensions\nexus\Item\Domain
*/
public static function createFromForm( array $values, \IPS\nexus\Invoice $invoice )
{
$domainPrices = json_decode( \IPS\Settings::i()->nexus_domain_prices, TRUE );
$cost = new \IPS\nexus\Money( $domainPrices[ $values['ha_domain_to_buy']['tld'] ][ $invoice->currency ]['amount'], $invoice->currency );
$tax = NULL;
if ( \IPS\Settings::i()->nexus_domain_tax )
{
try
{
$tax = \IPS\nexus\Tax::load( \IPS\Settings::i()->nexus_domain_tax );
}
catch ( \OutOfRangeException $e ) { }
}
$domain = new \IPS\nexus\extensions\nexus\Item\Domain( $values['ha_domain_to_buy']['sld'] . '.' . $values['ha_domain_to_buy']['tld'], $cost );
$domain->renewalTerm = new \IPS\nexus\Purchase\RenewalTerm( $cost, new \DateInterval('P1Y'), $tax );
$domain->tax = $tax;
$domain->extra = array_merge( $values['ha_domain_to_buy'], array( 'nameservers' => $values['server_nameservers'] ) );
return $domain;
}
/**
* On Purchase Generated
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function onPurchaseGenerated( \IPS\nexus\Purchase $purchase, \IPS\nexus\Invoice $invoice )
{
$enom = new \IPS\nexus\DomainRegistrar\Enom( \IPS\Settings::i()->nexus_enom_un, \IPS\Settings::i()->nexus_enom_pw );
try
{
$enom->register( $purchase->extra['sld'], $purchase->extra['tld'], $purchase->extra['nameservers'], $invoice->member, $invoice->billaddress );
}
catch ( \Exception $e )
{
\IPS\Log::i( \LOG_ERR )->write( 'eNom: ' . $e->getMessage() );
}
}
/**
* Admin can change expire date / renewal term?
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return bool
*/
public static function canChangeExpireDate( \IPS\nexus\Purchase $purchase )
{
return FALSE;
}
/**
* Can Renew Until
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param bool $admin If TRUE, is for ACP. If FALSE, is for front-end.
* @return \IPS\DateTime|bool TRUE means can renew as much as they like. FALSE means cannot renew at all. \IPS\DateTime means can renew until that date
*/
public static function canRenewUntil( \IPS\nexus\Purchase $purchase, $admin )
{
return \IPS\DateTime::create()->add( new \DateInterval( 'P10Y' ) );
}
/**
* On Renew (Renewal invoice paid. Is not called if expiry data is manually changed)
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param int $cycles Cycles
* @return void
*/
public static function onRenew( \IPS\nexus\Purchase $purchase, $cycles )
{
$enom = new \IPS\nexus\DomainRegistrar\Enom( \IPS\Settings::i()->nexus_enom_un, \IPS\Settings::i()->nexus_enom_pw );
try
{
$enom->renew( $purchase->extra['sld'], $purchase->extra['tld'], $cycles );
}
catch ( \Exception $e )
{
\IPS\Log::i( \LOG_ERR )->write( 'eNom: ' . $e->getMessage() );
}
}
}
@@ -0,0 +1,93 @@
<?php
/**
* @brief Donation
* @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\nexus\Item;
/* 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;
}
/**
* Donation
*/
class _Donation extends \IPS\nexus\Invoice\Item\Charge
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'donation';
/**
* @brief Icon
*/
public static $icon = 'money';
/**
* @brief Title
*/
public static $title = 'donation';
/**
* @brief Can use coupons?
*/
public static $canUseCoupons = FALSE;
/**
* @brief Can use account credit?
*/
public static $canUseAccountCredit = FALSE;
/**
* On Paid
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public function onPaid( \IPS\nexus\Invoice $invoice )
{
try
{
$goal = \IPS\nexus\Donation\Goal::load( $this->id );
$goal->current += $this->price->amount;
$goal->save();
}
catch ( \Exception $e ) { }
\IPS\Db::i()->insert( 'nexus_donate_logs', array(
'dl_goal' => $this->id,
'dl_member' => $invoice->member->member_id,
'dl_amount' => $this->price->amount,
'dl_invoice'=> $invoice->id,
'dl_date' => time()
) );
}
/**
* On Unpaid
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @param string $status Status
* @return void
*/
public function onUnpaid( \IPS\nexus\Invoice $invoice, $status )
{
}
}
@@ -0,0 +1,208 @@
<?php
/**
* @brief Gift Voucher
* @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\nexus\Item;
/* 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;
}
/**
* Gift Voucher
*/
class _GiftVoucher extends \IPS\nexus\Invoice\Item\Purchase
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'giftvoucher';
/**
* @brief Icon
*/
public static $icon = 'gift';
/**
* @brief Title
*/
public static $title = 'gift_voucher';
/**
* @brief Can use coupons?
*/
public static $canUseCoupons = FALSE;
/**
* Get purchase from redeem code
*
* @param string $code The redemption code
* @return \IPS\nexus\Purchase
* @throws \InvalidArgumentException
*/
public static function getPurchase( $redemptionCode )
{
$exploded = explode( 'X', $redemptionCode );
if ( !isset( $exploded[0] ) or !is_numeric( $exploded[0] ) )
{
throw new \InvalidArgumentException('BAD_FORMAT');
}
try
{
$purchase = \IPS\nexus\Purchase::load( $exploded[0] );
}
catch ( \OutOfRangeException $e )
{
throw new \InvalidArgumentException('NO_PURCHASE');
}
if ( $purchase->app != 'nexus' or $purchase->type != 'giftvoucher' )
{
throw new \InvalidArgumentException('BAD_PURCHASE');
}
if ( !$purchase->active or $purchase->cancelled )
{
throw new \InvalidArgumentException('CANCELED');
}
$extra = $purchase->extra;
if ( !isset( $extra['code'] ) or $redemptionCode != "{$extra['code']}" )
{
throw new \InvalidArgumentException('BAD_CODE');
}
return $purchase;
}
/**
* Generate Invoice Form
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function form( \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
{
$form->add( new \IPS\Helpers\Form\Number( 'gift_voucher_amount', 0, TRUE, array(), NULL, NULL, $invoice->currency ) );
$form->add( new \IPS\Helpers\Form\Radio( 'gift_voucher_method', 'print', TRUE, array( 'options' => array( 'email' => 'gift_voucher_email', 'print' => 'gift_voucher_print' ), 'toggles' => array( 'email' => array( 'gift_voucher_email' ) ) ) ) );
$form->add( new \IPS\Helpers\Form\Email( 'gift_voucher_email', NULL, NULL, array(), function( $val )
{
if ( !$val and \IPS\Request::i()->gift_voucher_method === 'email' )
{
throw new \DomainException('form_required');
}
}, NULL, NULL, 'gift_voucher_email' ) );
$form->add( new \IPS\Helpers\Form\Text( 'gift_voucher_recipient' ) );
$form->add( new \IPS\Helpers\Form\Text( 'gift_voucher_sender', $invoice->member->name ) );
$form->add( new \IPS\Helpers\Form\TextArea( 'gift_voucher_message' ) );
}
/**
* Create From Form
*
* @param array $values Values from form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return \IPS\nexus\extensions\nexus\Item\MiscellaneousCharge
*/
public static function createFromForm( array $values, \IPS\nexus\Invoice $invoice )
{
$item = new \IPS\nexus\extensions\nexus\Item\GiftVoucher( \IPS\Member::loggedIn()->language()->get('gift_voucher'), new \IPS\nexus\Money( $values['gift_voucher_amount'], $memberCurrency ) );
$item->paymentMethodIds = array_keys( \IPS\nexus\Gateway::roots( NULL, NULL, array( 'm_active=1 AND m_gateway<>?', 'TwoCheckout' ) ) ); // It is against 2CO terms to use them for buying gift vouchers
$item->extra['method'] = $values['gift_voucher_method'];
$item->extra['recipient_email'] = $values['gift_voucher_email'];
$item->extra['recipient_name'] = $values['gift_voucher_recipient'];
$item->extra['sender'] = $values['gift_voucher_sender'];
$item->extra['message'] = $values['gift_voucher_message'];
$item->extra['amount'] = $values['gift_voucher_amount'];
$item->extra['currency'] = $invoice->currency;
return $item;
}
/**
* On Purchase Generated
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function onPurchaseGenerated( \IPS\nexus\Purchase $purchase, \IPS\nexus\Invoice $invoice )
{
/* Generate a redemption code */
$code = "{$purchase->id}X{$purchase->member->member_id}X";
foreach ( range( 1, 10 ) as $j )
{
do
{
$chr = rand( 48, 90 );
}
while ( in_array( $chr, array( 58, 59, 60, 61, 62, 63, 64, 88 ) ) );
$code .= chr( $chr );
}
$extra = $purchase->extra;
$extra['code'] = $code;
$purchase->extra = $extra;
$purchase->save();
/* Send the email */
if ( $purchase->extra['method'] === 'email' )
{
\IPS\Email::buildFromTemplate( 'nexus', 'giftVoucher', array( $purchase->extra['recipient_name'], new \IPS\nexus\Money( $purchase->extra['amount'], $purchase->extra['currency'] ), $code, $purchase->extra['message'], $purchase->extra['sender'], $purchase->extra['color'] ) )->send( $purchase->extra['recipient_email'] );
}
}
/**
* Get ACP Page HTML
*
* @return string
*/
public static function acpPage( \IPS\nexus\Purchase $purchase )
{
$extra = $purchase->extra;
return \IPS\Theme::i()->getTemplate('purchases')->giftvoucher( $purchase, $extra );
}
/**
* Get Client Area Page HTML
*
* @return string
*/
public static function clientAreaPage( \IPS\nexus\Purchase $purchase )
{
$extra = $purchase->extra;
return array(
'purchaseInfo' => \IPS\Theme::i()->getTemplate('purchases')->giftvoucher( $purchase, $extra )
);
}
/**
* Get Client Area Page HTML
*
* @return string
*/
public static function clientAreaAction( \IPS\nexus\Purchase $purchase )
{
$extra = $purchase->extra;
if ( $extra['method'] === 'print' )
{
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'purchases' )->giftvoucherPrint( $extra ), 200, 'text/html', \IPS\Output::i()->httpHeaders );
return;
}
}
}
@@ -0,0 +1,117 @@
<?php
/**
* @brief Miscellaneous Charge
* @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 25 Mar 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\extensions\nexus\Item;
/* 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;
}
/**
* Miscellaneous Charge
*/
class _MiscellaneousCharge extends \IPS\nexus\Invoice\Item\Charge
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'charge';
/**
* @brief Icon
*/
public static $icon = 'dollar';
/**
* @brief Title
*/
public static $title = 'miscellaneous_charge';
/**
* Generate Invoice Form
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function form( \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
{
$form->add( new \IPS\Helpers\Form\Text( 'item_name', NULL, TRUE ) );
$form->add( new \IPS\Helpers\Form\Number( 'item_net_price', 0, TRUE, array( 'decimals' => TRUE, 'min' => NULL ), NULL, NULL, $invoice->currency ) );
$form->add( new \IPS\Helpers\Form\Node( 'item_tax_rate', 0, FALSE, array( 'class' => 'IPS\nexus\Tax', 'zeroVal' => 'item_tax_rate_none' ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'item_paymethods', 0, FALSE, array( 'class' => 'IPS\nexus\Gateway', 'multiple' => TRUE, 'zeroVal' => 'all' ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'item_physical', FALSE, FALSE, array( 'togglesOn' => array( 'item_weight', 'item_shipmethods' ) ) ) );
$form->add( new \IPS\nexus\Form\Weight( 'item_weight', NULL, FALSE, array(), NULL, NULL, NULL, 'item_weight' ) );
$availableShippingMethods = array();
foreach ( \IPS\nexus\Shipping\FlatRate::roots() as $rate )
{
$availableShippingMethods[ $rate->_id ] = $rate->_title;
}
if ( \IPS\Settings::i()->easypost_api_key and \IPS\Settings::i()->easypost_show_rates )
{
$availableShippingMethods['easypost'] = 'enhancements__nexus_EasyPost';
}
$form->add( new \IPS\Helpers\Form\Select( 'item_shipmethods', '*', FALSE, array( 'options' => $availableShippingMethods, 'multiple' => TRUE, 'unlimited' => '*' ), NULL, NULL, NULL, 'item_shipmethods' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'item_pay_other', FALSE, FALSE, array( 'togglesOn' => array( 'item_pay_to', 'item_commission', 'item_fee' ) ) ) );
$form->add( new \IPS\Helpers\Form\Member( 'item_pay_to', FALSE, FALSE, array(), NULL, NULL, NULL, 'item_pay_to' ) );
$form->add( new \IPS\Helpers\Form\Number( 'item_commission', FALSE, FALSE, array( 'min' => 0, 'max' => 100 ), NULL, NULL, '%', 'item_commission' ) );
$form->add( new \IPS\Helpers\Form\Number( 'item_fee', FALSE, FALSE, array(), NULL, NULL, $invoice->currency, 'item_fee' ) );
$form->add( new \IPS\Helpers\Form\Number( 'invoice_quantity', 1, FALSE, array( 'min' => 1 ) ) );
}
/**
* Create From Form
*
* @param array $values Values from form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return \IPS\nexus\extensions\nexus\Item\MiscellaneousCharge
*/
public static function createFromForm( array $values, \IPS\nexus\Invoice $invoice )
{
$obj = new static( $values['item_name'], new \IPS\nexus\Money( $values['item_net_price'], $invoice->currency ) );
$obj->quantity = $values['invoice_quantity'];
if ( $values['item_tax_rate'] )
{
$obj->tax = $values['item_tax_rate'];
}
if ( $values['item_paymethods'] )
{
$obj->paymentMethodIds = array_keys( $values['item_paymethods'] );
}
if ( $values['item_physical'] )
{
$obj->physical = TRUE;
$obj->weight = $values['item_weight'];
if ( $values['item_shipmethods'] !== '*' )
{
$obj->shippingMethodIds = array_keys( $values['item_shipmethods'] );
}
}
if ( $values['item_pay_other'] )
{
$obj->payTo = $values['item_pay_to'];
$obj->commission = $values['item_commission'];
$obj->fee = new \IPS\nexus\Money( $values['item_fee'], $invoice->currency );
}
return $obj;
}
}
@@ -0,0 +1,900 @@
<?php
/**
* @brief Package
* @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\nexus\Item;
/* 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;
}
/**
* Package
*/
class _Package extends \IPS\nexus\Invoice\Item\Purchase
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'package';
/**
* @brief Icon
*/
public static $icon = 'archive';
/**
* @brief Title
*/
public static $title = 'product';
/**
* Get (can be used to override static properties like icon and title in an instance)
*
* @param string $k Property
* @return mixed
*/
public function __get( $k )
{
if ( $k === '_icon' or $k === '_title' )
{
try
{
$package = \IPS\nexus\Package::load( $this->id );
return $k === '_icon' ? $package::$icon : $package::$title;
}
catch ( \Exception $e ) { }
}
return parent::__get( $k );
}
/**
* Get Icon
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return string
*/
public static function getIcon( \IPS\nexus\Purchase $purchase )
{
try
{
$class = \IPS\nexus\Package::load( $purchase->item_id );
return $class::$icon;
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* Get Title
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return string
*/
public static function getTypeTitle( \IPS\nexus\Purchase $purchase )
{
try
{
$class = \IPS\nexus\Package::load( $purchase->item_id );
return $class::$title;
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* Image
*
* @return |IPS\File|NULL
*/
public function image()
{
try
{
$imageUrl = \IPS\nexus\Package::load( $this->id )->image;
if ( !$imageUrl )
{
return NULL;
}
return \IPS\File::get( 'nexus_Products', $imageUrl );
}
catch ( \Exception $e ) {}
return NULL;
}
/**
* Image
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return |IPS\File|NULL
*/
public static function purchaseImage( \IPS\nexus\Purchase $purchase )
{
try
{
$imageUrl = \IPS\nexus\Package::load( $purchase->item_id )->image;
if ( !$imageUrl )
{
return NULL;
}
return \IPS\File::get( 'nexus_Products', $imageUrl );
}
catch ( \Exception $e )
{
return NULL;
}
}
/**
* Generate Invoice Form: First Step
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function form( \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
{
$form->class = 'ipsForm_vertical';
$form->add( new \IPS\Helpers\Form\Custom( 'invoice_products', array(), TRUE, array(
'rowHtml' => function( $field )
{
return \IPS\Theme::i()->getTemplate('invoices')->packageSelector( $field->value );
}
) ) );
}
/**
* Generate Invoice Form: Second Step
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return bool
*/
public static function formSecondStep( array $values, \IPS\Helpers\Form $form, \IPS\nexus\Invoice $invoice )
{
$displayForm = FALSE;
/* Do an initial loop so we know what we can associate with */
$justSelected = array_filter( $values['invoice_products'] );
/* Now do the actual loop */
foreach ( array_filter( $values['invoice_products'] ) as $id => $qty )
{
$package = \IPS\nexus\Package::load( $id );
$customFields = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_package_fields', \IPS\Db::i()->findInSet( 'cf_packages', array( $package->id ) ) ), 'IPS\nexus\Package\CustomField' );
$renewOptions = $package->renew_options ? json_decode( $package->renew_options, TRUE ) : array();
for ( $i = 0; $i < $qty; $i++ )
{
if ( count( $customFields ) or count( $renewOptions ) > 1 or count( $package->associablePackages() ) or method_exists( $package, 'generateInvoiceForm' ) )
{
$displayForm = TRUE;
$form->addHeader( $package->_title );
if ( count( $customFields ) )
{
foreach ( $customFields as $field )
{
$field = $field->buildHelper();
$field->label = \IPS\Member::loggedIn()->language()->addToStack( $field->name );
$field->name = "{$field->name}_{$id}_{$i}";
$form->add( $field );
}
}
if ( count( $renewOptions ) > 1 )
{
$options = array();
foreach ( $renewOptions as $k => $option )
{
switch ( $option['unit'] )
{
case 'd':
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_days', FALSE, array( 'pluralize' => array( $option['term'] ) ) );
break;
case 'm':
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_months', FALSE, array( 'pluralize' => array( $option['term'] ) ) );
break;
case 'y':
$term = \IPS\Member::loggedIn()->language()->addToStack('renew_years', FALSE, array( 'pluralize' => array( $option['term'] ) ) );
break;
}
$options[ $k ] =
\IPS\Member::loggedIn()->language()->addToStack( 'renew_option', FALSE, array( 'sprintf' => array(
(string) new \IPS\nexus\Money( $option['cost'][ $invoice->currency ]['amount'], $invoice->currency ),
$term
) ) );
}
$field = new \IPS\Helpers\Form\Radio( "renewal_term_{$id}_{$i}", NULL, TRUE, array( 'options' => $options ) );
$field->label = 'renewal_term';
$form->add( $field );
}
if ( count( $package->associablePackages() ) )
{
$associableIds = array_keys( $package->associablePackages() );
$associableOptions = array();
if ( !$package->force_assoc )
{
$associableOptions[0] = 'no_parent';
}
$selected = NULL;
foreach ( $justSelected as $k => $_qty )
{
if ( in_array( $k, $associableIds ) )
{
for ( $j = 0; $j < $_qty; $j++ )
{
$associableOptions['just_selected'][ "2.{$k}.{$j}" ] = \IPS\nexus\Package::load( $k )->_title;
if ( $j === $i )
{
$selected = "2.{$k}.{$j}";
}
}
}
}
foreach ( $invoice->items as $k => $item )
{
if ( in_array( $item->id, $associableIds ) )
{
for ( $i = 0; $i < $item->quantity; $i++ )
{
$name = $item->name;
if ( count( $item->details ) )
{
$customFields = \IPS\nexus\Package\CustomField::roots();
$stickyFields = array();
foreach ( $item->details as $k => $v )
{
if ( $v and isset( $customFields[ $k ] ) and $customFields[ $k ]->sticky )
{
$stickyFields[] = $v;
}
}
if ( count( $stickyFields ) )
{
$name .= ' (' . implode( ' &middot; ', $stickyFields ) . ')';
}
}
$associableOptions['on_invoice']["0.{$k}"] = $name;
}
}
}
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_purchases', array( array( 'ps_member=? AND ps_app=? AND ps_type=?', $invoice->member->member_id, 'nexus', 'package' ), \IPS\Db::i()->in( 'ps_item_id', $associableIds ) ) ), 'IPS\nexus\Purchase' ) as $purchase )
{
$associableOptions['existing_purchases'][ "1.{$purchase->id}" ] = $purchase->name;
}
$field = new \IPS\Helpers\Form\Select( "associate_with_{$id}_{$i}", $selected, $package->force_assoc, array( 'options' => $associableOptions ) );
$field->label = 'associate_with';
$form->add( $field );
}
if ( method_exists( $package, 'generateInvoiceForm' ) )
{
$package->generateInvoiceForm( $form, "_{$id}_{$i}" );
}
}
}
}
return $displayForm;
}
/**
* Create From Form
*
* @param array $values Values from form
* @param \IPS\nexus\Invoice $invoice The invoice
* @return array
*/
public static function createFromForm( array $values, \IPS\nexus\Invoice $invoice )
{
/* Get the packages we want to add */
if ( isset( \IPS\Request::i()->firstStep ) )
{
$data = json_decode( \IPS\Request::i()->firstStep, TRUE );
$data = $data['invoice_products'];
}
else
{
$data = $values['invoice_products'];
}
/* Loop them */
$items = array();
$itemsToBeAssociated = array();
foreach ( array_filter( $data ) as $id => $qty )
{
/* Load package */
$package = \IPS\nexus\Package::load( $id );
/* Get the number already on the invoice for the purposes of discounts */
$initialCount = 0;
foreach ( $invoice->items as $_item )
{
if ( $_item instanceof \IPS\nexus\extensions\nexus\Item\Package and $_item->id == $id )
{
$initialCount += $_item->quantity;
}
}
/* Loop for each qty */
for ( $i = 0; $i < $qty; $i++ )
{
/* Base price */
$price = $package->price( $invoice->member, TRUE, TRUE, TRUE, $initialCount + $i )->amount;
/* Custom Fields */
$details = array();
foreach ( $values as $k => $v )
{
if ( preg_match( "/nexus_pfield_(\d+)_{$id}_{$i}/", $k, $matches ) )
{
$details[ $matches[1] ] = $v;
}
}
/* Work out renewal term */
$renewalTerm = NULL;
$renewOptions = $package->renew_options ? json_decode( $package->renew_options, TRUE ) : array();
if ( count( $renewOptions ) )
{
if ( count( $renewOptions ) === 1 )
{
$chosenRenewOption = array_pop( $renewOptions );
}
else
{
$chosenRenewOption = $renewOptions[ $values["renewal_term_{$id}_{$i}"] ];
}
$renewalTerm = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $chosenRenewOption['cost'][ $invoice->currency ]['amount'], $invoice->currency ), new \DateInterval( 'P' . $chosenRenewOption['term'] . mb_strtoupper( $chosenRenewOption['unit'] ) ), $package->tax ? \IPS\nexus\Tax::load( $package->tax ) : NULL );
if ( $chosenRenewOption['add'] )
{
$price += $renewalTerm->cost->amount;
}
}
/* Create item */
$item = new \IPS\nexus\extensions\nexus\Item\Package( \IPS\Member::loggedIn()->language()->get( 'nexus_package_' . $package->id ), new \IPS\nexus\Money( $price, $invoice->currency ) );
$item->renewalTerm = $renewalTerm;
$item->id = $package->id;
$item->tax = $package->tax ? \IPS\nexus\Tax::load( $package->tax ) : NULL;
if ( $package instanceof \IPS\nexus\Package\Product and $package->physical )
{
$item->physical = TRUE;
$item->weight = new \IPS\nexus\Shipping\Weight( $package->weight );
$item->length = new \IPS\nexus\Shipping\Length( $package->length );
$item->width = new \IPS\nexus\Shipping\Length( $package->width );
$item->height = new \IPS\nexus\Shipping\Length( $package->height );
if ( $package->shipping !== '*' )
{
$item->shippingMethodIds = explode( ',', $package->shipping );
}
}
if ( $package->methods and $package->methods != '*' )
{
$item->paymentMethodIds = explode( ',', $package->methods );
}
$item->details = $details;
/* Associations */
if ( isset( $values["associate_with_{$id}_{$i}"] ) and $values["associate_with_{$id}_{$i}"] )
{
$exploded = explode( '.', $values["associate_with_{$id}_{$i}"] );
switch ( $exploded[0] )
{
case '0':
$item->parent = (int) $exploded[1];
break;
case '1':
$item->parent = \IPS\nexus\Purchase::load( $exploded[1] );
break;
case '2':
$itemsToBeAssociated["{$id}.{$i}"] = "{$exploded[1]}.{$exploded[2]}";
break;
}
}
/* Do any package-sepcific modifications */
$package->acpAddToInvoice( $item, $values, "_{$id}_{$i}", $invoice );
/* Add it */
$items["{$id}.{$i}"] = $item;
}
}
/* Sort out any associations */
$added = array();
foreach( $itemsToBeAssociated as $itemKey => $associateKey )
{
if ( !array_key_exists( $associateKey, $added ) )
{
$added[ $associateKey ] = $invoice->addItem( $items[ $associateKey ] );
}
$items[ $itemKey ]->parent = $added[ $associateKey ];
}
/* Group wherever we can */
$itemsToAdd = array();
foreach ( $items as $key => $item )
{
if ( !array_key_exists( $key, $added ) )
{
/* Is this the same as any of the other items? */
foreach ( $itemsToAdd as $_item )
{
$cloned = clone $_item;
$cloned->quantity = 1;
if ( $cloned == $item )
{
$_item->quantity++;
continue 2;
}
}
/* Or anything on the invoice? */
foreach ( $invoice->items as $k => $_item )
{
$cloned = clone $_item;
$cloned->quantity = 1;
if ( $cloned == $item )
{
$invoice->changeItem( $k, array( 'quantity' => $_item->quantity + 1 ) );
continue 2;
}
}
/* Nope, give it it's own entry */
$itemsToAdd[] = $item;
}
}
/* Return */
return $itemsToAdd;
}
/**
* Get additional name info
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return array
*/
public static function getPurchaseNameInfo( \IPS\nexus\Purchase $purchase )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'getPurchaseNameInfo' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return array();
}
}
/**
* Get ACP Page HTML
*
* @return string
*/
public static function acpPage( \IPS\nexus\Purchase $purchase )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'acpPage' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return '';
}
}
/**
* Get ACP Page Buttons
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param \IPS\Http\Url $url The page URL
* @return array
*/
public static function acpButtons( \IPS\nexus\Purchase $purchase, \IPS\Http\Url $url )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'acpButtons' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return array();
}
}
/**
* ACP Action
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return void
*/
public static function acpAction( \IPS\nexus\Purchase $purchase )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'acpAction' ), func_get_args() );
}
catch ( \OutOfRangeException $e ) {}
}
/**
* ACP Edit Form
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param \IPS\Helpers\Form $form The form
* @param \IPS\nexus\Purchase\RenewalTerm $renewals The renewal term
* @return void
*/
public static function acpEdit( \IPS\nexus\Purchase $purchase, \IPS\Helpers\Form $form, $renewals )
{
$form->addHeader('nexus_purchase_settings');
parent::acpEdit( $purchase, $form, $renewals );
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'acpEdit' ), func_get_args() );
}
catch ( \OutOfRangeException $e ) { }
}
/**
* ACP Edit Save
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param array $values Values from form
* @return void
*/
public static function acpEditSave( \IPS\nexus\Purchase $purchase, array $values )
{
try
{
call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'acpEditSave' ), func_get_args() );
}
catch ( \OutOfRangeException $e ) { }
parent::acpEditSave( $purchase, $values );
}
/**
* Get Client Area Page HTML
*
* @return array( 'packageInfo' => '...', 'purchaseInfo' => '...' )
*/
public static function clientAreaPage( \IPS\nexus\Purchase $purchase )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'clientAreaPage' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return array( 'packageInfo' => '', 'purchaseInfo' => '' );
}
}
/**
* Client Area Action
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return string
*/
public static function clientAreaAction( \IPS\nexus\Purchase $purchase )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'clientAreaAction' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* Support Severity
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return \IPS\nexus\Support\Severity|NULL
*/
public static function supportSeverity( \IPS\nexus\Purchase $purchase )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'supportSeverity' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* On Paid
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public function onPaid( \IPS\nexus\Invoice $invoice )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $this->id ), 'onPaid' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* On Unpaid description
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @return array
*/
public function onUnpaidDescription( \IPS\nexus\Invoice $invoice )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $this->id ), 'onUnpaidDescription' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return array();
}
}
/**
* On Unpaid
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @param string $status Status
* @return void
*/
public function onUnpaid( \IPS\nexus\Invoice $invoice, $status )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $this->id ), 'onUnpaid' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* On Invoice Cancel (when unpaid)
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public function onInvoiceCancel( \IPS\nexus\Invoice $invoice )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $this->id ), 'onInvoiceCancel' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* On Purchase Generated
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public static function onPurchaseGenerated( \IPS\nexus\Purchase $purchase, \IPS\nexus\Invoice $invoice )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'onPurchaseGenerated' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* On Renew (Renewal invoice paid. Is not called if expiry data is manually changed)
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param int $cycles Cycles
* @return void
*/
public static function onRenew( \IPS\nexus\Purchase $purchase, $cycles )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'onRenew' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* On Expiration Date Change
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return void
*/
public static function onExpirationDateChange( \IPS\nexus\Purchase $purchase )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'onExpirationDateChange' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* On Purchase Expired
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return void
*/
public static function onExpire( \IPS\nexus\Purchase $purchase )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'onExpire' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* On Purchase Canceled
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return void
*/
public static function onCancel( \IPS\nexus\Purchase $purchase )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'onCancel' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* On Purchase Deleted
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return void
*/
public static function onDelete( \IPS\nexus\Purchase $purchase )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'onDelete' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* On Purchase Reactivated (renewed after being expired or reactivated after being canceled)
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return void
*/
public static function onReactivate( \IPS\nexus\Purchase $purchase )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'onReactivate' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* On Transfer (is ran before transferring)
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param \IPS\Member $newCustomer New Customer
* @return void
*/
public static function onTransfer( \IPS\nexus\Purchase $purchase, \IPS\Member $newCustomer )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'onTransfer' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* Can Renew Until
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @param bool $admin If TRUE, is for ACP. If FALSE, is for front-end.
* @return \IPS\DateTime|bool TRUE means can renew as much as they like. FALSE means cannot renew at all. \IPS\DateTime means can renew until that date
*/
public static function canRenewUntil( \IPS\nexus\Purchase $purchase, $admin )
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $purchase->item_id ), 'canRenewUntil' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return FALSE;
}
}
/**
* Show Purchase Record?
*
* @return bool
*/
public function showPurchaseRecord()
{
try
{
return call_user_func_array( array( \IPS\nexus\Package::load( $this->id ), 'showPurchaseRecord' ), func_get_args() );
}
catch ( \OutOfRangeException $e )
{
return FALSE;
}
}
}
@@ -0,0 +1,46 @@
<?php
/**
* @brief Invoice Item Class for Shipping Charges
* @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 20 Mar 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\extensions\nexus\Item;
/* 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;
}
/**
* Invoice Item Class for Shipping Charges
*/
class _ShippingCharge extends \IPS\nexus\Invoice\Item\Charge
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'shipping';
/**
* @brief Icon
*/
public static $icon = 'truck';
/**
* @brief Title
*/
public static $title = 'checkout_shipping';
}
@@ -0,0 +1,46 @@
<?php
/**
* @brief Support Charge
* @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 Apr 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\extensions\nexus\Item;
/* 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;
}
/**
* Support Charge
*/
class _SupportCharge extends \IPS\nexus\Invoice\Item\Purchase
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'ppi';
/**
* @brief Icon
*/
public static $icon = 'life-ring';
/**
* @brief Title
*/
public static $title = 'support_charge';
}
@@ -0,0 +1,143 @@
<?php
/**
* @brief Invoice Item Class for Package Upgrade Charges
* @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 8 May 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\nexus\extensions\nexus\Item;
/* 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;
}
/**
* Invoice Item Class for Shipping Charges
*/
class _UpgradeCharge extends \IPS\nexus\Invoice\Item\Charge
{
/**
* @brief Application
*/
public static $application = 'nexus';
/**
* @brief Application
*/
public static $type = 'upgrade';
/**
* @brief Icon
*/
public static $icon = 'level-up';
/**
* @brief Title
*/
public static $title = 'upgrade_charge';
/**
* On Paid
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @return void
*/
public function onPaid( \IPS\nexus\Invoice $invoice )
{
try
{
$purchase = \IPS\nexus\Purchase::load( $this->id );
$oldPackage = \IPS\nexus\Package::load( $this->extra['oldPackage'] );
$newPackage = \IPS\nexus\Package::load( $this->extra['newPackage'] );
$oldPackage->upgradeDowngrade( $purchase, $newPackage, $this->extra['renewalOption'], TRUE );
$purchase->member->log( 'purchase', array( 'type' => 'change', 'id' => $purchase->id, 'old' => $oldPackage->_title, 'name' => $newPackage->_title, 'system' => TRUE ) );
}
catch ( \OutOfRangeException $e ){}
}
/**
* On Unpaid description
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @return array
*/
public function onUnpaidDescription( \IPS\nexus\Invoice $invoice )
{
$return = parent::onUnpaidDescription( $invoice );
try
{
$oldPackage = \IPS\nexus\Package::load( $this->extra['oldPackage'] );
$newPackage = \IPS\nexus\Package::load( $this->extra['newPackage'] );
$return[] = \IPS\Member::loggedIn()->language()->addToStack( 'invoice_unpaid_change', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'purchase_number', FALSE, array( 'sprintf' => array( $this->id ) ) ), $newPackage->_title, $oldPackage->_title ) ) );
}
catch ( \OutOfRangeException $e ){}
return $return;
}
/**
* On Unpaid
*
* @param \IPS\nexus\Invoice $invoice The invoice
* @param string $status Status
* @return void
*/
public function onUnpaid( \IPS\nexus\Invoice $invoice, $status )
{
try
{
$previousRenewalTerm = $this->extra['previousRenewalTerms'] ? new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $this->extra['previousRenewalTerms']['cost'], $this->extra['previousRenewalTerms']['currency'] ), new \DateInterval( 'P' . $this->extra['previousRenewalTerms']['term']['term'] . mb_strtoupper( $this->extra['previousRenewalTerms']['term']['unit'] ) ) ) : NULL;
$purchase = \IPS\nexus\Purchase::load( $this->id );
$oldPackage = \IPS\nexus\Package::load( $this->extra['oldPackage'] );
$newPackage = \IPS\nexus\Package::load( $this->extra['newPackage'] );
$newPackage->upgradeDowngrade( $purchase, $oldPackage, $previousRenewalTerm, TRUE );
$purchase->member->log( 'purchase', array( 'type' => 'change', 'id' => $purchase->id, 'old' => $newPackage->_title, 'name' => $oldPackage->_title, 'system' => TRUE ) );
}
catch ( \OutOfRangeException $e ){}
}
/**
* Client Area URL
*
* @return |IPS\Http\Url|NULL
*/
public function url()
{
try
{
return \IPS\nexus\Purchase::load( $this->id )->url();
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
/**
* ACP URL
*
* @return |IPS\Http\Url|NULL
*/
public function acpUrl()
{
try
{
return \IPS\nexus\Purchase::load( $this->id )->acpUrl();
}
catch ( \OutOfRangeException $e )
{
return NULL;
}
}
}
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,19 @@
//<?php
class nexus_hook_allowStoreRegistrationGuests extends _HOOK_CLASS_
{
/**
* Define that the page should load even if the user is banned and not logged in
*
* @return bool
*/
protected function notAllowedBannedPage()
{
if( $this->application->directory == 'nexus' AND \IPS\Settings::i()->nexus_reg_force AND ( $this->module->key == 'store' OR $this->module->key == 'checkout' ) )
{
return FALSE;
}
return parent::notAllowedBannedPage();
}
}
+106
View File
@@ -0,0 +1,106 @@
//<?php
class nexus_hook_clientAreaLink extends _HOOK_CLASS_
{
/* !Hook Data - DO NOT REMOVE */
public static function hookData() {
return array_merge_recursive( array (
'userBar' =>
array (
0 =>
array (
'selector' => '#elAccountSettingsLink',
'type' => 'add_after',
'content' => '{{if \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( \'nexus\', \'clients\' ) )}}
<li class=\'ipsMenu_item\'><a href=\'{url="app=nexus&module=clients&controller=splash" seoTemplate="clients" protocol="\IPS\Settings::i()->nexus_https"}\' title=\'{lang="module__nexus_clients"}\'>{lang="module__nexus_clients"}</a></li>
{{endif}}',
),
1 =>
array (
'selector' => '#cUserLink',
'type' => 'add_before',
'content' => '{{if \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( \'nexus\', \'store\' ) )}}
{template="cartHeader" app="nexus" group="store" params=""}
{{endif}}',
),
2 =>
array (
'selector' => '#elSignInLink',
'type' => 'add_before',
'content' => '{{if \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( \'nexus\', \'store\' ) )}}
{template="cartHeader" app="nexus" group="store" params=""}
{{endif}}',
),
),
'footer' =>
array (
0 =>
array (
'selector' => '#elFooterLinks',
'type' => 'add_inside_end',
'content' => '{{if \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( \'nexus\', \'clients\' ) ) and settings.network_status}}
<li><a href=\'{url="app=nexus&module=clients&controller=networkStatus" seoTemplate="nexus_network_status"}\'>{lang=\'network_status\'}</a></li>
{{endif}}',
),
),
'mobileNavigation' =>
array (
0 =>
array (
'selector' => '#elAccountSettingsLinkMobile',
'type' => 'add_after',
'content' => '{{if \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( \'nexus\', \'clients\' ) )}}
<li><a href=\'{url="app=nexus&module=clients&controller=splash" seoTemplate="clients" protocol="\IPS\Settings::i()->nexus_https"}\' title=\'{lang="module__nexus_clients"}\'>{lang="module__nexus_clients"}</a></li>
{{endif}}',
),
),
'mobileNavBar' =>
array (
0 =>
array (
'selector' => '#elMobileNav li:last-child',
'type' => 'add_before',
'content' => '{{if \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( \'nexus\', \'store\' ) )}}
{template="cartHeaderMobile" app="nexus" group="store" params=""}
{{endif}}',
),
),
), parent::hookData() );
}
/* End Hook Data */
}
@@ -0,0 +1,16 @@
//<?php
class nexus_hook_clientAreaLinkLoad extends _HOOK_CLASS_
{
/**
* Constructor
* Gets stores which are always needed to save individual queries
*
* @return void
*/
public function __construct()
{
parent::__construct();
$this->templateLoad[] = array( 'nexus', 'front', 'store' );
}
}
View File
Whitespace-only changes.
+19
View File
@@ -0,0 +1,19 @@
//<?php
class nexus_hook_register extends _HOOK_CLASS_
{
/**
* Register
*
* @return void
*/
protected function manage()
{
if ( \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'nexus', 'store' ) ) and ( \IPS\Settings::i()->nexus_reg_force or ( !isset( \IPS\Request::i()->noPurchase ) and \IPS\Db::i()->select( 'COUNT(*)', 'nexus_packages', 'p_reg=1' )->first() ) ) )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=store&controller=store&do=register', 'front', 'store' ) );
}
return call_user_func_array( 'parent::manage', func_get_args() );
}
}
View File
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,42 @@
<?php
/**
* @brief Send/Discard handler for pending support replies
* @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 25 Apr 2014
* @version SVN_VERSION_NUMBER
*/
require_once '../../../../init.php';
try
{
$reply = \IPS\nexus\Support\Reply::load( \IPS\Request::i()->id );
if ( \IPS\Request::i()->key !== md5( $reply->item()->email_key . $reply->date ) )
{
throw new \OutOfRangeException;
}
}
catch ( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2X206/1', 404, '' );
}
if ( $reply->type !== \IPS\nexus\Support\Reply::REPLY_PENDING )
{
\IPS\Output::i()->error( 'support_reply_not_pending', '1X206/2', 403, '' );
}
if ( \IPS\Request::i()->send )
{
$reply->sendPending();
}
else
{
$reply->delete();
}
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->blankTemplate( \IPS\Theme::i()->getTemplate( 'support', 'nexus', 'front' )->pendingDone( \IPS\Request::i()->send ? 'support_pending_sent' : 'support_pending_discarded' ) ) );
@@ -0,0 +1,53 @@
<?php
/**
* @brief 2Checkout Gateway
* @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 Mar 2014
* @version SVN_VERSION_NUMBER
*/
require_once '../../../../init.php';
try
{
$transaction = \IPS\nexus\Transaction::load( \IPS\Request::i()->nexustransactionid );
if ( $transaction->status !== \IPS\nexus\Transaction::STATUS_PENDING )
{
throw new \OutofRangeException;
}
}
catch ( \OutOfRangeException $e )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=nexus&module=payments&controller=checkout&do=transaction&id=&t=" . \IPS\Request::i()->nexustransactionid, 'front', 'nexus_checkout', \IPS\Settings::i()->nexus_https ) );
}
$settings = json_decode( $transaction->method->settings, TRUE );
$hash = mb_strtoupper( md5( $settings['word'] . $settings['sid'] . ( \IPS\NEXUS_TEST_GATEWAYS ? 1 : \IPS\Request::i()->order_number ) . number_format( $transaction->amount->amount, 2 ) ) );
if ( $hash !== \IPS\Request::i()->key )
{
\IPS\Output::i()->redirect( $transaction->invoice->checkoutUrl()->setQueryString( array( '_step' => 'checkout_pay', 'err' => $transaction->member->language()->get('gateway_err') ) ) );
}
if ( \IPS\Request::i()->credit_card_processed !== 'Y' )
{
\IPS\Output::i()->redirect( $transaction->invoice->checkoutUrl()->setQueryString( array( '_step' => 'checkout_pay', 'err' => $transaction->member->language()->get('card_refused') ) ) );
}
$transaction->gw_id = \IPS\Request::i()->order_number;
$transaction->save();
$maxMind = NULL;
if ( \IPS\Settings::i()->maxmind_key )
{
$maxMind = new \IPS\nexus\Fraud\MaxMind\Request;
$maxMind->setTransaction( $transaction );
}
$transaction->checkFraudRulesAndCapture( $maxMind );
$transaction->sendNotification();
\IPS\Session::i()->setMember( $transaction->invoice->member ); // This is in case the checkout was a guest, meaning checkFraudRulesAndCapture() may have just created an account. There is no security issue as we have just verified they were just bounced back from 2CheckOut
\IPS\Output::i()->redirect( $transaction->url() );
@@ -0,0 +1,90 @@
<?php
/**
* @brief Authorize.Net DPM Gateway
* @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 17 Mar 2014
* @version SVN_VERSION_NUMBER
*/
require_once '../../../../init.php';
try
{
$invoice = \IPS\nexus\Invoice::load( \IPS\Request::i()->x_invoice_num );
}
catch ( \Exception $e )
{
\IPS\Output::i()->sendOutput( '', 404 );
exit;
}
try
{
/* Load Gateway */
$gateway = \IPS\nexus\Gateway::load( \IPS\Request::i()->payment_method );
$settings = json_decode( $gateway->settings, TRUE );
/* Check MD5 hash */
if ( \IPS\Request::i()->x_MD5_Hash != mb_strtoupper( md5( $settings['hash'] . $settings['login'] . \IPS\Request::i()->x_trans_id . \IPS\Request::i()->x_amount ) ) )
{
throw new \Exception( $invoice->member->language()->addToStack('gateway_err') );
}
/* Was it accepted? */
if ( \IPS\Request::i()->x_response_code != 1 )
{
throw new \IPS\nexus\Gateway\AuthorizeNet\Exception( \IPS\Request::i()->x_response_reason_code );
}
/* Create a transaction */
$transaction = new \IPS\nexus\Transaction;
$transaction->member = \IPS\Member::load( \IPS\Request::i()->x_cust_id );
$transaction->invoice = $invoice;
$transaction->method = $gateway;
$transaction->amount = \IPS\Request::i()->x_amount;
$transaction->currency = $invoice->currency;
$transaction->gw_id = \IPS\Request::i()->x_trans_id;
$transaction->ip = \IPS\Request::i()->x_customer_ip;
$extra = $transaction->extra;
$extra['lastFour'] = str_replace( 'X', '', \IPS\Request::i()->x_account_number );
$transaction->extra = $extra;
$transaction->auth = \IPS\DateTime::create()->add( new \DateInterval( 'P30D' ) );
/* Create a MaxMind request */
$maxMind = NULL;
if ( \IPS\Settings::i()->maxmind_key )
{
$maxMind = new \IPS\nexus\Fraud\MaxMind\Request;
$maxMind->setTransaction( $transaction );
$maxMind->setTransactionType( 'creditcard' );
$maxMind->setAVS( \IPS\Request::i()->x_avs_code );
}
/* Check Fraud Rules and capture */
$transaction->checkFraudRulesAndCapture( $maxMind );
$transaction->sendNotification();
/* Show thanks screen */
$url = $transaction->url();
}
catch ( \Exception $e )
{
$url = $invoice->checkoutUrl()->setQueryString( array( '_step' => 'checkout_pay', 'err' => $e->getMessage() ) );
}
?>
<html>
<head>
<script type='text/javascript' charset='utf-8'>
window.location='<?php echo $url; ?>';
</script>
<noscript>
<meta http-equiv='refresh' content='1;url=<?php echo $url; ?>'>
</noscript>
</head>
<body></body>
</html>
Whitespace-only changes.
@@ -0,0 +1,52 @@
<?php
/**
* @brief PayPal Gateway
* @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
*/
require_once '../../../../init.php';
\IPS\Session\Front::i();
try
{
$transaction = \IPS\nexus\Transaction::load( \IPS\Request::i()->nexusTransactionId );
if ( $transaction->status !== \IPS\nexus\Transaction::STATUS_PENDING )
{
throw new \OutofRangeException;
}
}
catch ( \OutOfRangeException $e )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=nexus&module=payments&controller=checkout&do=transaction&id=&t=" . \IPS\Request::i()->nexusTransactionId, 'front', 'nexus_checkout', \IPS\Settings::i()->nexus_https ) );
}
try
{
$response = $transaction->method->api( "payments/payment/{$transaction->gw_id}/execute", array(
'payer_id' => \IPS\Request::i()->PayerID,
) );
$maxMind = NULL;
if ( \IPS\Settings::i()->maxmind_key )
{
$maxMind = new \IPS\nexus\Fraud\MaxMind\Request;
$maxMind->setTransaction( $transaction );
$maxMind->setTransactionType( 'paypal' );
}
$transaction->checkFraudRulesAndCapture( $maxMind );
$transaction->sendNotification();
\IPS\Session::i()->setMember( $transaction->invoice->member ); // This is in case the checkout was a guest, meaning checkFraudRulesAndCapture() may have just created an account. There is no security issue as we have just verified they were just bounced back from PayPal
\IPS\Output::i()->redirect( $transaction->url() );
}
catch ( \Exception $e )
{
\IPS\Output::i()->redirect( $transaction->invoice->checkoutUrl()->setQueryString( array( '_step' => 'checkout_pay', 'err' => $e->getMessage() ) ) );
}
@@ -0,0 +1,64 @@
<?php
/**
* @brief SagePay Gateway
* @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 19 Mar 2014
* @version SVN_VERSION_NUMBER
*/
require_once '../../../../init.php';
function returnData( $status, $detail, $returnUrl )
{
echo "Status={$status}\r\nStatusDetail={$detail}\r\nRedirectURL={$returnUrl}";
exit;
}
/* Load */
try
{
$transaction = \IPS\nexus\Transaction::load( \IPS\Request::i()->VendorTxCode );
if ( $transaction->status !== \IPS\nexus\Transaction::STATUS_PENDING )
{
throw new \OutofRangeException;
}
}
catch ( \OutOfRangeException $e )
{
returnData( 'ERROR', 'NO_TRANSACTION', \IPS\Settings::i()->base_url );
}
/* Authenticate */
$settings = json_decode( $transaction->method->settings, TRUE );
$extra = $transaction->extra;
if ( \IPS\Request::i()->VPSSignature !== mb_strtoupper( md5( \IPS\Request::i()->VPSTxId . \IPS\Request::i()->VendorTxCode . \IPS\Request::i()->Status . \IPS\Request::i()->TxAuthNo . mb_strtolower( $settings['vendor'] ) . \IPS\Request::i()->AVSCV2 . $extra['sagepaySecurityKey'] . \IPS\Request::i()->AddressResult . \IPS\Request::i()->PostCodeResult . \IPS\Request::i()->CV2Result . \IPS\Request::i()->GiftAid . \IPS\Request::i()->__get('3DSecureStatus') . \IPS\Request::i()->CAVV . \IPS\Request::i()->AddressStatus . \IPS\Request::i()->PayerStatus . \IPS\Request::i()->CardType . \IPS\Request::i()->Last4Digits . \IPS\Request::i()->DeclineCode . \IPS\Request::i()->ExpiryDate . \IPS\Request::i()->FraudResponse . \IPS\Request::i()->BankAuthCode ) ) )
{
returnData( 'INVALID', 'MD5', $transaction->invoice->checkoutUrl()->setQueryString( array( '_step' => 'checkout_pay', 'err' => $transaction->member->language()->get( 'gateway_err' ) ) ) );
}
/* Save the auth code */
$extra['sagepayAuth'] = \IPS\Request::i()->TxAuthNo;
$transaction->extra = $extra;
$transaction->save();
/* Handle */
if ( \IPS\Request::i()->Status === 'OK' )
{
$maxMind = NULL;
if ( \IPS\Settings::i()->maxmind_key )
{
$maxMind = new \IPS\nexus\Fraud\MaxMind\Request;
$maxMind->setTransaction( $transaction );
}
$transaction->checkFraudRulesAndCapture( $maxMind );
$transaction->sendNotification();
}
/* Respond */
returnData( 'OK', 'MD5', $transaction->url() );
Loaded 100 of 7517 files, more files were not shown because too many files have changed in this diff. Show more