Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -1,5 +1,11 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class cms_hook_Topic extends _HOOK_CLASS_
|
||||
{
|
||||
/**
|
||||
@@ -15,43 +21,58 @@ class cms_hook_Topic extends _HOOK_CLASS_
|
||||
{
|
||||
if ( $action === 'delete' )
|
||||
{
|
||||
$databaseId = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
$database = \IPS\Db::i()->select( '*', 'cms_databases', array( array( 'database_forum_forum=? AND database_forum_comments=1', $this->forum_id ) ) )->first();
|
||||
$databaseId = $database['database_id'];
|
||||
}
|
||||
catch( \UnderflowException $ex )
|
||||
/* We used to restrict by forum ID but if you move a topic to a new forum then the forum ID will no longer match */
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_database_categories', array( 'category_forum_record=? AND category_forum_comments=?', 1, 1 ) ) as $category )
|
||||
{
|
||||
try
|
||||
{
|
||||
$category = \IPS\Db::i()->select( '*', 'cms_database_categories', array( array( 'category_forum_forum=? AND category_forum_comments=1', $this->forum_id ) ) )->first();
|
||||
$databaseId = $category['category_database_id'];
|
||||
$class = '\IPS\cms\Records' . $category['category_database_id'];
|
||||
|
||||
if( class_exists( $class ) )
|
||||
{
|
||||
$class::load( $this->tid, 'record_topicid' );
|
||||
|
||||
$database = \IPS\cms\Databases::load( $category['category_database_id'] );
|
||||
\IPS\Member::loggedIn()->language()->words['cms_delete_linked_topic'] = sprintf( \IPS\Member::loggedIn()->language()->get('cms_delete_linked_topic'), $database->recordWord( 1 ) );
|
||||
|
||||
\IPS\Output::i()->error( 'cms_delete_linked_topic', '1T281/1', 403, '' );
|
||||
}
|
||||
|
||||
}
|
||||
catch( \UnderflowException $ex )
|
||||
catch( \Exception $ex ) { }
|
||||
}
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_databases', array( 'database_forum_record=? AND database_forum_comments=?', 1, 1 ) ) as $database )
|
||||
{
|
||||
try
|
||||
{
|
||||
return parent::modAction( $action, $member, $reason );
|
||||
$class = '\IPS\cms\Records' . $database['database_id'];
|
||||
|
||||
$class::load( $this->tid, 'record_topicid' );
|
||||
|
||||
$database = \IPS\cms\Databases::constructFromData( $database );
|
||||
\IPS\Member::loggedIn()->language()->words['cms_delete_linked_topic'] = sprintf( \IPS\Member::loggedIn()->language()->get('cms_delete_linked_topic'), $database->recordWord( 1 ) );
|
||||
|
||||
\IPS\Output::i()->error( 'cms_delete_linked_topic', '1T281/1', 403, '' );
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
}
|
||||
}
|
||||
else if ( $action === 'lock' or $action === 'unlock' )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_databases', array( 'database_forum_record=? AND database_forum_comments=?', 1, 1 ) ) as $database )
|
||||
{
|
||||
try
|
||||
{
|
||||
$class = '\IPS\cms\Records' . $database['database_id'];
|
||||
$record = $class::load( $this->tid, 'record_topicid' );
|
||||
|
||||
$record->record_locked = ( $action === 'lock' ) ? 1 : 0;
|
||||
$record->save();
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
}
|
||||
|
||||
/* Still here? */
|
||||
$class = '\IPS\cms\Records' . $databaseId;
|
||||
|
||||
try
|
||||
{
|
||||
$class::load( $this->tid, 'record_topicid' );
|
||||
|
||||
$database = \IPS\cms\Databases::load( $databaseId );
|
||||
\IPS\Member::loggedIn()->language()->words['cms_delete_linked_topic'] = sprintf( \IPS\Member::loggedIn()->language()->get('cms_delete_linked_topic'), $database->recordWord( 1 ) );
|
||||
|
||||
\IPS\Output::i()->error( 'cms_delete_linked_topic', '1T281/1', 403, '' );
|
||||
}
|
||||
catch( \OutOfRangeException $ex )
|
||||
{
|
||||
/* Not attached to a database record */
|
||||
return parent::modAction( $action, $member, $reason );
|
||||
}
|
||||
}
|
||||
|
||||
return parent::modAction( $action, $member, $reason );
|
||||
|
||||
Reference in new issue
Block a user