Version 5.0.0 beta 10

This commit is contained in:
Neo committed 2025-12-19 17:53:48 -08:00
1 parent 56979f8ee8
commit 264eeb97e0
325 files changed
+6442 -1849

No files matched your search

@@ -1061,7 +1061,7 @@ class Stripe extends Gateway
*/
public function settings( Form $form ): void
{
$settings = json_decode( $this->settings, TRUE );
$settings = $this->settings ? json_decode( $this->settings, TRUE ) : null;
$form->addHeader('stripe_keys');
$form->addMessage('stripe_keys_blurb');
$form->add( new Text( 'stripe_secret_key', $settings ? $settings['secret_key'] : NULL, TRUE ) );
@@ -150,14 +150,18 @@ class CustomField extends SystemCustomField
parent::form( $form );
$packages = array();
foreach ( array_filter( explode( ',', $this->packages ) ) as $id )
if( $this->packages )
{
try
foreach ( array_filter( explode( ',', $this->packages ) ) as $id )
{
$packages[] = Package::load( $id );
try
{
$packages[] = Package::load( $id );
}
catch ( OutOfRangeException ) { }
}
catch ( OutOfRangeException ) { }
}
$form->add( new Node( 'cf_packages', $packages, FALSE, array( 'class' => 'IPS\nexus\Package\Group', 'noParentNodes' => 'custom_packages', 'multiple' => TRUE, 'permissionCheck' => function( $node )
{
return !( $node instanceof Group);
@@ -379,9 +379,21 @@ class Group extends Model
}
$oldImage = $this->image;
$oldId = $this->id;
parent::__clone();
$attachmentsMap = [];
foreach( Db::i()->select( '*', 'core_attachments_map', [ 'location_key=? and id1=? and id3=?', 'nexus_Admin', $oldId, 'pgroup' ] ) as $attachment )
{
$attachment['id1'] = $this->id;
$attachmentsMap[] = $attachment;
}
if( count( $attachmentsMap ) )
{
Db::i()->insert( 'core_attachments_map', $attachmentsMap );
}
if ( $oldImage )
{
try
@@ -439,4 +451,16 @@ class Group extends Model
return $buttons;
}
/**
* [ActiveRecord] Delete Record
*
* @return void
*/
public function delete(): void
{
parent::delete();
File::unclaimAttachments( 'nexus_Admin', $this->id, null, 'pgroup' );
}
}
+28 -2
View File
@@ -308,6 +308,11 @@ class Package extends Model
{
Lang::deleteCustom( 'nexus', "nexus_package_{$this->id}{$suffix}" );
}
foreach( [ 'pkg-assoc', 'pkg', 'pkg-pg' ] as $id3 )
{
SystemFile::unclaimAttachments( 'nexus_Admin', $this->_id, null, $id3 );
}
}
/**
@@ -357,6 +362,23 @@ class Package extends Model
Lang::saveCustom( 'nexus', static::$titleLangPrefix . $id . $suffix, iterator_to_array( Db::i()->select( 'word_custom, lang_id', 'core_sys_lang_words', array( 'word_key=?', static::$titleLangPrefix . $oldId . $suffix ) )->setKeyField( 'lang_id' )->setValueField('word_custom') ) );
}
/* If the description had attachments, link them */
$attachmentMappings = [];
foreach( Db::i()->select( '*', 'core_attachments_map', [
[ 'location_key=?', 'nexus_Admin' ],
[ 'id1=?', $oldId ],
[ 'id2 is null' ],
[ Db::i()->in( 'id3', [ 'pkg-assoc', 'pkg', 'pkg-pg' ] ) ]
] ) as $attachment )
{
$attachment['id1'] = $this->_id;
$attachmentMappings[] = $attachment;
}
if( count( $attachmentMappings ) )
{
Db::i()->insert( 'core_attachments_map', $attachmentMappings );
}
Db::i()->insert( 'nexus_package_base_prices', Db::i()->select( "{$id} AS id, " . implode( ',', array_map( function( $val )
{
return "`{$val}`";
@@ -2504,7 +2526,11 @@ class Package extends Model
}
else
{
$customFieldsForm->addDummy( $field->_title, $field->displayValue( $value ) );
$customFieldValue = $field->displayValue( $value );
if( $customFieldValue )
{
$customFieldsForm->addDummy( $field->_title, $customFieldValue );
}
}
}
if ( !$editable )
@@ -2624,7 +2650,7 @@ class Package extends Model
case 'reactivate':
if( !$purchase->cancelled OR ( $purchase->cancelled AND !$purchase->can_reactivate ) )
{
\IPS\Output::i()->error( 'package_cannot_reactivate_error', '2S437/1', 403, '' );
Output::i()->error( 'package_cannot_reactivate_error', '2S437/1', 403, '' );
}
$currency = $purchase->original_invoice->currency;
@@ -152,7 +152,8 @@ class Purchase extends Model
{
try
{
if ( trim( CustomField::load( $k )->displayValue( $v, TRUE ) ) )
$customFieldValue = CustomField::load( $k )->displayValue( $v, TRUE );
if ( $customFieldValue and trim( $customFieldValue ) )
{
$hasCustomFields = TRUE;
break;