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
@@ -12,26 +12,35 @@
|
||||
namespace IPS\forums\extensions\core\LiveSearch;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Extensions\LiveSearchAbstract;
|
||||
use IPS\forums\Forum;
|
||||
use IPS\Member;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ACP Live Search Extension
|
||||
*/
|
||||
class _Forums
|
||||
class Forums extends LiveSearchAbstract
|
||||
{
|
||||
/**
|
||||
* Check we have access
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAccess()
|
||||
public function hasAccess(): bool
|
||||
{
|
||||
/* Check Permissions */
|
||||
return \IPS\Member::loggedIn()->hasAcpRestriction( 'forums', 'forums', 'forums_manage' );
|
||||
return Member::loggedIn()->hasAcpRestriction( 'forums', 'forums', 'forums_manage' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +49,7 @@ class _Forums
|
||||
* @param string $searchTerm Search Term
|
||||
* @return array Array of results
|
||||
*/
|
||||
public function getResults( $searchTerm )
|
||||
public function getResults( string $searchTerm ): array
|
||||
{
|
||||
/* Init */
|
||||
$results = array();
|
||||
@@ -50,10 +59,10 @@ class _Forums
|
||||
if( $this->hasAccess() )
|
||||
{
|
||||
/* Perform the search */
|
||||
$forums = \IPS\Db::i()->select(
|
||||
$forums = Db::i()->select(
|
||||
"*",
|
||||
'forums_forums',
|
||||
array( "club_id IS NULL AND word_custom LIKE CONCAT( '%', ?, '%' ) AND lang_id=?", $searchTerm, \IPS\Member::loggedIn()->language()->id ),
|
||||
array( "club_id IS NULL AND word_custom LIKE CONCAT( '%', ?, '%' ) AND lang_id=?", $searchTerm, Member::loggedIn()->language()->id ),
|
||||
NULL,
|
||||
NULL
|
||||
)->join(
|
||||
@@ -64,9 +73,9 @@ class _Forums
|
||||
/* Format results */
|
||||
foreach ( $forums as $forum )
|
||||
{
|
||||
$forum = \IPS\forums\Forum::constructFromData( $forum );
|
||||
$forum = Forum::constructFromData( $forum );
|
||||
|
||||
$results[] = \IPS\Theme::i()->getTemplate( 'livesearch', 'forums', 'admin' )->forum( $forum );
|
||||
$results[] = Theme::i()->getTemplate( 'livesearch', 'forums', 'admin' )->forum( $forum );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,8 +87,8 @@ class _Forums
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDefault()
|
||||
public function isDefault(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory == 'forums';
|
||||
return Dispatcher::i()->application->directory == 'forums';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user