Version 4.6.0

This commit is contained in:
Neo committed 2025-12-19 05:55:31 -08:00
1 parent f79dcf067a
commit 517a5e1f70
2036 files changed
+110041 -26162

No files matched your search

@@ -44,28 +44,44 @@ class _Screenshots
*/
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
{
$record = \IPS\Db::i()->select( '*', 'downloads_files_records', array( 'record_type=?', 'ssupload' ), 'record_id', array( $offset, 1 ) )->first();
$record = \IPS\Db::i()->select( '*', 'downloads_files_records', array( 'record_type=?', 'ssupload' ), 'record_id', array( $offset, 1 ) )->first();
$updates = array();
try
{
$file = \IPS\File::get( $oldConfiguration ?: 'downloads_Screenshots', $record['record_location'] )->move( $storageConfiguration );
if ( (string) $file != $record['record_location'] )
{
\IPS\Db::i()->update( 'downloads_files_records', array( 'record_location' => (string) $file ), array( 'record_id=?', $record['record_id'] ) );
$updates['record_location'] = (string) $file;
}
$file = \IPS\File::get( $oldConfiguration ?: 'downloads_Screenshots', $record['record_thumb'] )->move( $storageConfiguration );
if ( (string) $file != $record['record_thumb'] )
{
\IPS\Db::i()->update( 'downloads_files_records', array( 'record_thumb' => (string) $file ), array( 'record_id=?', $record['record_id'] ) );
$updates['record_thumb'] = (string) $file;
}
if( $record['record_no_watermark'] )
{
$file = \IPS\File::get( $oldConfiguration ?: 'downloads_Screenshots', $record['record_no_watermark'] )->move( $storageConfiguration );
if ( (string) $file != $record['record_no_watermark'] )
{
$updates['record_no_watermark'] = (string) $file;
}
}
}
catch( \Exception $e )
{
/* Any issues are logged */
}
if( \count( $updates ) )
{
\IPS\Db::i()->update( 'downloads_files_records', $updates, array( 'record_id=?', $record['record_id'] ) );
}
}
/**
@@ -87,6 +103,11 @@ class _Screenshots
{
\IPS\Db::i()->update( 'downloads_files_records', array( 'record_thumb' => $new ), array( 'record_id=?', $record['record_id'] ) );
}
if ( $record['record_no_watermark'] and $new = \IPS\File::repairUrl( $record['record_no_watermark'] ) )
{
\IPS\Db::i()->update( 'downloads_files_records', array( 'record_no_watermark' => $new ), array( 'record_id=?', $record['record_id'] ) );
}
}
/**
@@ -99,7 +120,8 @@ class _Screenshots
{
try
{
$record = \IPS\Db::i()->select( '*', 'downloads_files_records', array( '( record_location=? OR record_thumb=? ) AND record_type=?', (string) $file, (string) $file, 'ssupload' ) )->first();
$fileName = (string) $file;
$record = \IPS\Db::i()->select( '*', 'downloads_files_records', array( '( record_location=? OR record_thumb=? OR record_no_watermark=? ) AND record_type=?', $fileName, $fileName, $fileName, 'ssupload' ) )->first();
return TRUE;
}
@@ -35,7 +35,7 @@ class _Downloads
return array (
'exclude' => array(),
'lessIsMore' => array( 'idm_wait_period' ),
'neg1IsBest' => array(),
'neg1IsBest' => array( 'idm_max_size' ),
'zeroIsBest' => array( 'idm_throttling' ),
'callback' => array( 'idm_restrictions' => function( $a, $b, $k )
{
@@ -88,6 +88,7 @@ class _Files
public static function parse_mobile_new_file_version( \IPS\Lang $language, \IPS\downloads\File $file )
{
return array(
'title' => $language->addToStack( 'notification__new_file_version_title' ),
'body' => $language->addToStack( 'notification__new_file_version', FALSE, array( 'htmlsprintf' => array(
$file->author()->name,
$file->mapped('title')
@@ -71,7 +71,7 @@ class _RebuildScreenshotWatermarks
* @return int New offset
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
public function run( &$data, $offset )
{
$last = NULL;
$watermark = \IPS\Settings::i()->idm_watermarkpath ? \IPS\Image::create( \IPS\File::get( 'core_Theme', \IPS\Settings::i()->idm_watermarkpath )->contents() ) : NULL;
@@ -77,6 +77,64 @@ class _File extends \IPS\nexus\Invoice\Item\Purchase
return NULL;
}
}
/**
* Client Area Action
*
* @param \IPS\nexus\Purchase $purchase The purchase
* @return string
*/
public static function clientAreaAction( \IPS\nexus\Purchase $purchase )
{
if( \IPS\Request::i()->act == 'reactivate' AND $purchase->can_reactivate )
{
/* Cannot renew, do not set renewal periods */
$file = \IPS\downloads\File::load( $purchase->item_id );
if( !$file->container()->can( 'download', $purchase->member ) )
{
return parent::clientAreaAction( $purchase );
}
try
{
$file = \IPS\downloads\File::load( $purchase->item_id );
}
catch ( \OutOfRangeException $e )
{
return parent::clientAreaAction( $purchase );
}
$renewalCosts = json_decode( $file->renewal_price, TRUE );
$currency = $purchase->original_invoice->currency;
$tax = NULL;
if ( $purchase->tax )
{
try
{
$tax = \IPS\nexus\Tax::load( $purchase->tax );
}
catch ( \Exception $e ) { }
}
\IPS\Session::i()->csrfCheck();
$purchase->renewals = new \IPS\nexus\Purchase\RenewalTerm( new \IPS\nexus\Money( $renewalCosts[ $currency ]['amount'], $currency ), new \DateInterval( 'P' . $file->renewal_term . mb_strtoupper( $file->renewal_units ) ), $tax );
$purchase->cancelled = FALSE;
$purchase->save();
$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 $cycles = $purchase->canRenewUntil( NULL, TRUE ) AND $cycles !== FALSE )
{
$url = $cycles === 1 ? $purchase->url()->setQueryString( 'do', 'renew' )->csrf() : $purchase->url()->setQueryString( 'do', 'renew' );
\IPS\Output::i()->redirect( $url );
}
else
{
\IPS\Output::i()->redirect( $purchase->url() );
}
}
}
/**
* Get Client Area Page HTML
@@ -89,8 +147,15 @@ class _File extends \IPS\nexus\Invoice\Item\Purchase
try
{
$file = \IPS\downloads\File::load( $purchase->item_id );
/* Reactivate */
$reactivateUrl = NULL;
if ( $file->container()->can( 'download', $purchase->member ) and !$purchase->renewals and $file->renewal_term and $file->renewal_units and $file->renewal_price and $purchase->can_reactivate and ( !$purchase->billing_agreement or $purchase->billing_agreement->canceled ) )
{
$reactivateUrl = \IPS\Http\Url::internal( "app=nexus&module=clients&controller=purchases&id={$purchase->id}&do=extra&act=reactivate", 'front', 'clientspurchaseextra', \IPS\Http\Url::seoTitle( $purchase->name ) )->csrf();
}
return array( 'packageInfo' => \IPS\Theme::i()->getTemplate( 'nexus', 'downloads' )->fileInfo( $file ), 'purchaseInfo' => \IPS\Theme::i()->getTemplate( 'nexus', 'downloads' )->filePurchaseInfo( $file ) );
return array( 'packageInfo' => \IPS\Theme::i()->getTemplate( 'nexus', 'downloads' )->fileInfo( $file ), 'purchaseInfo' => \IPS\Theme::i()->getTemplate( 'nexus', 'downloads' )->filePurchaseInfo( $file, $reactivateUrl ) );
}
catch ( \OutOfRangeException $e ) { }
@@ -171,7 +236,8 @@ class _File extends \IPS\nexus\Invoice\Item\Purchase
{
$file = \IPS\downloads\File::load( $purchase->item_id );
if( $file->canView( \IPS\Member::load( $purchase->member_id ) ) )
/* File is viewable and basic download permission check is good */
if( $file->canView( $purchase->member ) AND $file->container()->can( 'download', $purchase->member ) )
{
return TRUE;
}