Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -1,7 +1,7 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class downloads_hook_Forum extends _HOOK_CLASS_
|
||||
|
||||
try
|
||||
{
|
||||
$node = call_user_func( "{$nodeClass}::load", \IPS\Request::i()->id );
|
||||
$node = $nodeClass::load( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
@@ -38,7 +38,7 @@ class downloads_hook_Forum extends _HOOK_CLASS_
|
||||
\IPS\Output::i()->error( 'downloads_forum_used', '1D372/1', 403, '' );
|
||||
}
|
||||
|
||||
return call_user_func_array( 'parent::delete', func_get_args() );
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class downloads_hook_frontModcp extends _HOOK_CLASS_
|
||||
{
|
||||
|
||||
/**
|
||||
* Get hidden content types
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _getContentTypes(): array
|
||||
{
|
||||
$parent = parent::_getContentTypes();
|
||||
unset( $parent['downloads_downloads']['downloads_file_pendingversion'] );
|
||||
|
||||
return $parent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class downloads_hook_nexusPackage extends _HOOK_CLASS_
|
||||
{
|
||||
/**
|
||||
* Delete Package Data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
/* Let parent do its thing first */
|
||||
parent::delete();
|
||||
|
||||
/* Look for files linked to this product */
|
||||
foreach( \IPS\Db::i()->select( '*', 'downloads_files', array( \IPS\Db::i()->findInSet( 'file_nexus', array( $this->id ) ) ) ) as $file )
|
||||
{
|
||||
$packages = explode( ',', $file['file_nexus'] );
|
||||
$packages = array_filter( $packages, function( $packageId ){
|
||||
return $packageId != $this->id;
|
||||
} );
|
||||
|
||||
/* If the only package was the one we just deleted, set it as not purchasable but do not remove the file_nexus value or the product will become downloadable by anyone */
|
||||
if( !\count( $packages ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'downloads_files', array( 'file_purchasable' => 0 ), array( 'file_id=?', $file['file_id'] ) );
|
||||
}
|
||||
/* Otherwise if there are other products that can be purchased, remove this product from the purchasable list */
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->update( 'downloads_files', array( 'file_nexus' => implode( ',', $packages ) ), array( 'file_id=?', $file['file_id'] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user