Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -225,6 +225,12 @@ class _Package extends \IPS\Node\Model
|
||||
$this->item()->delete();
|
||||
parent::delete();
|
||||
\IPS\Db::i()->delete( static::$packageDatabaseTable, array( 'p_id=?', $this->id ) );
|
||||
|
||||
/* Translatables */
|
||||
foreach ( array( '_assoc', '_page', '_email_purchase_subject', '_email_expire_soon_subject', '_email_expire_subject' ) as $suffix )
|
||||
{
|
||||
\IPS\Lang::deleteCustom( 'nexus', "nexus_package_{$this->id}{$suffix}" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,9 +271,14 @@ class _Package extends \IPS\Node\Model
|
||||
$secondaryTable['p_id'] = $id;
|
||||
\IPS\Db::i()->insert( static::$packageDatabaseTable, $secondaryTable );
|
||||
|
||||
\IPS\Lang::saveCustom( 'nexus', "nexus_package_{$id}", iterator_to_array( \IPS\Db::i()->select( 'CONCAT(word_custom, \' ' . \IPS\Member::loggedIn()->language()->get('copy_noun') . '\') as word_custom, lang_id', 'core_sys_lang_words', array( 'word_key=?', static::$titleLangPrefix . $this->_id ) )->setKeyField( 'lang_id' )->setValueField('word_custom') ) );
|
||||
/* Translatables */
|
||||
\IPS\Lang::saveCustom( 'nexus', static::$titleLangPrefix . $id, iterator_to_array( \IPS\Db::i()->select( 'CONCAT(word_custom, \' ' . \IPS\Member::loggedIn()->language()->get('copy_noun') . '\') as word_custom, lang_id', 'core_sys_lang_words', array( 'word_key=?', static::$titleLangPrefix . $this->_id ) )->setKeyField( 'lang_id' )->setValueField('word_custom') ) );
|
||||
\IPS\Lang::saveCustom( 'nexus', static::$titleLangPrefix . $id . static::$descriptionLangSuffix, iterator_to_array( \IPS\Db::i()->select( 'word_custom, lang_id', 'core_sys_lang_words', array( 'word_key=?', static::$titleLangPrefix . $oldId . static::$descriptionLangSuffix ) )->setKeyField( 'lang_id' )->setValueField('word_custom') ) );
|
||||
\IPS\Lang::saveCustom( 'nexus', "nexus_package_{$id}_assoc", iterator_to_array( \IPS\Db::i()->select( 'word_custom, lang_id', 'core_sys_lang_words', array( 'word_key=?', "nexus_package_{$oldId}_assoc" ) )->setKeyField( 'lang_id' )->setValueField('word_custom') ) );
|
||||
|
||||
foreach ( array( '_assoc', '_page', '_email_purchase_subject', '_email_expire_soon_subject', '_email_expire_subject' ) as $suffix )
|
||||
{
|
||||
\IPS\Lang::saveCustom( 'nexus', static::$titleLangPrefix . $id . $suffix, iterator_to_array( \IPS\Db::i()->select( 'word_custom, lang_id', 'core_sys_lang_words', array( 'word_key=?', static::$titleLangPrefix . $oldId . $suffix ) )->setKeyField( 'lang_id' )->setValueField('word_custom') ) );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'nexus_package_base_prices', \IPS\Db::i()->select( "{$id} AS id, " . implode( ',', array_map( function( $val )
|
||||
{
|
||||
@@ -699,7 +710,7 @@ class _Package extends \IPS\Node\Model
|
||||
* @return float
|
||||
* @return string|NULL
|
||||
*/
|
||||
public static function fullPriceInfoFromData( \IPS\nexus\Customer $customer = NULL, $currency, $packageId, $prices, $discounts, $renewOptions, $stock, $tax, $initialTerm )
|
||||
public static function fullPriceInfoFromData( ?\IPS\nexus\Customer $customer, $currency, $packageId, $prices, $discounts, $renewOptions, $stock, $tax, $initialTerm )
|
||||
{
|
||||
/* Get customer / currency */
|
||||
$customer = $customer ?: \IPS\nexus\Customer::loggedIn();
|
||||
@@ -1230,7 +1241,7 @@ class _Package extends \IPS\Node\Model
|
||||
$form->addTab('package_store');
|
||||
$form->addHeader('package_store_permissions');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'p_store', $this->store, FALSE, array( 'togglesOn' => array( 'p_member_groups', 'p_featured', 'p_desc_editor', 'p_images', 'p_reviewable', "{$form->id}_header_package_store_display", "{$form->id}_header_package_reviews" ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'p_member_groups', $this->member_groups === '*' ? '*' : explode( ',', $this->member_groups ), FALSE, array( 'options' => $groups, 'multiple' => TRUE, 'unlimited' => '*', 'unlimitedLang' => 'all' ), NULL, NULL, NULL, 'p_member_groups' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'p_member_groups', $this->member_groups === '*' ? '*' : explode( ',', $this->member_groups ), FALSE, array( 'options' => $groups, 'multiple' => TRUE, 'unlimited' => '*', 'unlimitedLang' => 'all', 'impliedUnlimited' => TRUE ), NULL, NULL, NULL, 'p_member_groups' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'p_methods', ( !$this->methods or $this->methods === '*' ) ? 0 : explode( ',', $this->methods ), TRUE, array( 'class' => 'IPS\nexus\Gateway', 'multiple' => TRUE, 'zeroVal' => 'any' ) ) );
|
||||
foreach ( $typeFields['store_permissions'] as $field )
|
||||
{
|
||||
@@ -1570,7 +1581,7 @@ class _Package extends \IPS\Node\Model
|
||||
}
|
||||
$values['p_renew_options'] = json_encode( $renewOptions );
|
||||
|
||||
if ( $values['p_initial_term'] and $values['p_initial_term']->interval )
|
||||
if ( isset( $values['p_initial_term'] ) and $values['p_initial_term']->interval )
|
||||
{
|
||||
$term = $values['p_initial_term']->getTerm();
|
||||
$values['p_initial_term'] = $term['term'] . mb_strtoupper( $term['unit'] );
|
||||
@@ -2278,10 +2289,7 @@ class _Package extends \IPS\Node\Model
|
||||
$added = FALSE;
|
||||
foreach ( $_SESSION['cart'] as $_id => $_item )
|
||||
{
|
||||
$cloned = clone $_item;
|
||||
$cloned->quantity = $quantity;
|
||||
|
||||
if ( $cloned == $item )
|
||||
if ( $_item->isSameAsOtherItem( $item ) )
|
||||
{
|
||||
$_item->quantity += $quantity;
|
||||
$added = TRUE;
|
||||
@@ -2312,7 +2320,8 @@ class _Package extends \IPS\Node\Model
|
||||
/* Turn off guest page caching */
|
||||
if ( \IPS\CACHE_PAGE_TIMEOUT and !\IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
\IPS\Request::i()->setCookie( 'noCache', 1 );
|
||||
/* Set the cookie for 20 minutes - if the guest hasn't checked out by then they may no longer see their cart on every page but as long as their session is still valid they will still be able to check out. */
|
||||
\IPS\Request::i()->setCookie( 'noCache', 1, \IPS\DateTime::ts( time() + 1200 ) );
|
||||
}
|
||||
|
||||
/* Return */
|
||||
@@ -2524,10 +2533,11 @@ class _Package extends \IPS\Node\Model
|
||||
}
|
||||
|
||||
$purchase->member->log( 'purchase', array( 'type' => 'info', 'id' => $purchase->id, 'name' => $purchase->name, 'info' => 'change_renewals', 'to' => array( 'cost' => $purchase->renewals->cost->amount, 'currency' => $purchase->renewals->cost->currency, 'term' => $purchase->renewals->getTerm() ) ) );
|
||||
|
||||
if ( !$purchase->active and $purchase->canRenewUntil() !== FALSE )
|
||||
|
||||
if ( !$purchase->active and $cycles = $purchase->canRenewUntil( NULL, TRUE ) AND $cycles !== FALSE )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $purchase->url()->setQueryString( 'do', 'renew' )->csrf() );
|
||||
$url = $cycles === 1 ? $purchase->url()->setQueryString( 'do', 'renew' )->csrf() : $purchase->url()->setQueryString( 'do', 'renew' );
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2559,10 +2569,11 @@ class _Package extends \IPS\Node\Model
|
||||
}
|
||||
|
||||
$purchase->member->log( 'purchase', array( 'type' => 'info', 'id' => $purchase->id, 'name' => $purchase->name, 'info' => 'change_renewals', 'to' => array( 'cost' => $purchase->renewals->cost->amount, 'currency' => $purchase->renewals->cost->currency, 'term' => $purchase->renewals->getTerm() ) ) );
|
||||
|
||||
if ( !$purchase->active and $purchase->canRenewUntil() !== FALSE )
|
||||
|
||||
if ( !$purchase->active and $cycles = $purchase->canRenewUntil( NULL, TRUE ) AND $cycles !== FALSE )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $purchase->url()->setQueryString( 'do', 'renew' )->csrf() );
|
||||
$url = $cycles === 1 ? $purchase->url()->setQueryString( 'do', 'renew' )->csrf() : $purchase->url()->setQueryString( 'do', 'renew' );
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2764,6 +2775,17 @@ class _Package extends \IPS\Node\Model
|
||||
{
|
||||
// Blank for hooking
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning to display to admin when cancelling a purchase
|
||||
*
|
||||
* @param \IPS\nexus\Purchase $purchase The purchase
|
||||
* @return string
|
||||
*/
|
||||
public function onCancelWarning( \IPS\nexus\Purchase $purchase )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for member
|
||||
@@ -2973,7 +2995,7 @@ class _Package extends \IPS\Node\Model
|
||||
{
|
||||
if ( $this->$typeKey == 'wysiwyg' )
|
||||
{
|
||||
$email = \IPS\Email::buildFromContent( $purchase->member->language()->get( "nexus_package_{$this->id}_email_{$type}_subject" ), $this->$valueKey, NULL, \IPS\Email::TYPE_TRANSACTIONAL, TRUE, 'package_customemail' );
|
||||
$email = \IPS\Email::buildFromContent( $purchase->member->language()->get( "nexus_package_{$this->id}_email_{$type}_subject" ), \IPS\Text\Parser::removeLazyLoad( $this->$valueKey ), NULL, \IPS\Email::TYPE_TRANSACTIONAL, TRUE, 'package_customemail' );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user