Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
//<?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 = call_user_func( "{$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 call_user_func_array( 'parent::delete', func_get_args() );
}
}
+28 -8
View File
@@ -9,19 +9,39 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
class downloads_hook_Forums extends _HOOK_CLASS_
{
/**
* Delete Record
* [Node] Get buttons to display in tree
*
* @return void
* @param string $url Base URL
* @param bool $subnode Is this a subnode?
* @return array
*/
public function delete()
public function getButtons( $url, $subnode=FALSE )
{
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'downloads_categories', array( "cforum_id=?", $this->_id ) ), 'IPS\downloads\Category' ) AS $category )
$buttons = parent::getButtons( $url, $subnode );
if ( isset( $buttons['delete'] ) AND $this->isUsedByADownloadsCategory() )
{
$category->forum_id = 0;
$category->save();
unset( $buttons['delete']['data'] );
}
return call_user_func_array( 'parent::delete', func_get_args() );
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;
}
}