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\downloads\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\downloads\Category;
|
||||
use IPS\Extensions\LiveSearchAbstract;
|
||||
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 _downloads
|
||||
class downloads extends LiveSearchAbstract
|
||||
{
|
||||
/**
|
||||
* Check we have access
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAccess()
|
||||
public function hasAccess(): bool
|
||||
{
|
||||
/* Check Permissions */
|
||||
return \IPS\Member::loggedIn()->hasAcpRestriction( 'downloads', 'downloads', 'categories_manage' );
|
||||
return Member::loggedIn()->hasAcpRestriction( 'downloads', 'downloads', 'categories_manage' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +49,7 @@ class _downloads
|
||||
* @param string $searchTerm Search Term
|
||||
* @return array Array of results
|
||||
*/
|
||||
public function getResults( $searchTerm )
|
||||
public function getResults( string $searchTerm ): array
|
||||
{
|
||||
if( !$this->hasAccess() )
|
||||
{
|
||||
@@ -52,10 +61,10 @@ class _downloads
|
||||
$searchTerm = mb_strtolower( $searchTerm );
|
||||
|
||||
/* Perform the search */
|
||||
$categories = \IPS\Db::i()->select(
|
||||
$categories = Db::i()->select(
|
||||
"*",
|
||||
'downloads_categories',
|
||||
array( "cclub_id IS NULL AND word_custom LIKE CONCAT( '%', ?, '%' ) AND lang_id=?", $searchTerm, \IPS\Member::loggedIn()->language()->id ),
|
||||
array( "cclub_id IS NULL AND word_custom LIKE CONCAT( '%', ?, '%' ) AND lang_id=?", $searchTerm, Member::loggedIn()->language()->id ),
|
||||
NULL,
|
||||
NULL
|
||||
)->join(
|
||||
@@ -66,9 +75,9 @@ class _downloads
|
||||
/* Format results */
|
||||
foreach ( $categories as $category )
|
||||
{
|
||||
$category = \IPS\downloads\Category::constructFromData( $category );
|
||||
$category = Category::constructFromData( $category );
|
||||
|
||||
$results[] = \IPS\Theme::i()->getTemplate( 'livesearch', 'downloads', 'admin' )->category( $category );
|
||||
$results[] = Theme::i()->getTemplate( 'livesearch', 'downloads', 'admin' )->category( $category );
|
||||
}
|
||||
|
||||
return $results;
|
||||
@@ -79,8 +88,8 @@ class _downloads
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDefault()
|
||||
public function isDefault(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory == 'downloads';
|
||||
return Dispatcher::i()->application->directory == 'downloads';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user