Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -1,44 +0,0 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class downloads_hook_Forum extends _HOOK_CLASS_
|
||||
{
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function delete()
|
||||
{
|
||||
/* Load forum and verify that it is not used for comments */
|
||||
$nodeClass = $this->nodeClass;
|
||||
if ( \IPS\Request::i()->subnode )
|
||||
{
|
||||
$nodeClass = $nodeClass::$subnodeClass;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$node = $nodeClass::load( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S101/J', 404, '' );
|
||||
}
|
||||
|
||||
/* Is any downloads category synced with this forum? */
|
||||
if ( $dbCategory = $node->isUsedByADownloadsCategory() )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['downloads_forum_used'] = sprintf( \IPS\Member::loggedIn()->language()->get('downloads_forum_used'), $dbCategory->_title );
|
||||
\IPS\Output::i()->error( 'downloads_forum_used', '1D372/1', 403, '' );
|
||||
}
|
||||
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class downloads_hook_Forums extends _HOOK_CLASS_
|
||||
{
|
||||
/**
|
||||
* [Node] Get buttons to display in tree
|
||||
*
|
||||
* @param string $url Base URL
|
||||
* @param bool $subnode Is this a subnode?
|
||||
* @return array
|
||||
*/
|
||||
public function getButtons( $url, $subnode=FALSE )
|
||||
{
|
||||
$buttons = parent::getButtons( $url, $subnode );
|
||||
|
||||
if ( isset( $buttons['delete'] ) AND $this->isUsedByADownloadsCategory() )
|
||||
{
|
||||
unset( $buttons['delete']['data'] );
|
||||
}
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Forum used by any downloads app category ?
|
||||
*
|
||||
* @return bool|\IPS\downloads\Category
|
||||
*/
|
||||
public function isUsedByADownloadsCategory()
|
||||
{
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'downloads_categories' ), 'IPS\downloads\Category' ) AS $category )
|
||||
{
|
||||
if ( $category->forum_id and $category->forum_id == $this->id )
|
||||
{
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class downloads_hook_apiForum extends _HOOK_CLASS_
|
||||
{
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @param int|NULL $deleteChildrenOrMove -1 to delete all child nodes, or the new parent node ID to move the children to
|
||||
* @throws 2F363/8 The node ID does not exist
|
||||
* @throws 2F363/9 The target node cannot be deleted because it is in use by a Downloads Category
|
||||
* @return \IPS\Api\Response
|
||||
*/
|
||||
protected function _delete( $id, $deleteChildrenOrMove = NULL )
|
||||
{
|
||||
/* Load forum and verify that it is not used for comments */
|
||||
$nodeClass = $this->class;
|
||||
if ( \IPS\Request::i()->subnode )
|
||||
{
|
||||
$nodeClass = $nodeClass::$subnodeClass;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$node = $nodeClass::load( $id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'INVALID_ID', '2F363/8', 404 );
|
||||
}
|
||||
|
||||
if ( $dbCategory = $node->isUsedByADownloadsCategory() )
|
||||
{
|
||||
throw new \IPS\Api\Exception( 'FORUM_USED_BY_DOWNLOADS', '2F363/9', 403 );
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::_delete( $id, $deleteChildrenOrMove );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
//<?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;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
//<?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