Files
IPB/system/Extensions/MemberFilterAbstract.php
2025-12-19 16:27:35 -08:00

88 lines
2.3 KiB
PHP

<?php
/**
* @brief MemberFilterAbstract
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage
* @since 11/20/2023
*/
namespace IPS\Extensions;
/* To prevent PHP errors (extending class does not exist) revealing path */
use IPS\Db\Select;
use IPS\Member;
use LogicException;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
abstract class MemberFilterAbstract
{
/**
* Determine if the filter is available in a given area
*
* @param string $area Area to check (bulkmail, group_promotions, automatic_moderation, passwordreset)
* @return bool
*/
abstract public function availableIn( string $area ): bool;
/**
* Get Setting Field
*
* @param array $criteria Value returned from the save() method
* @return array Array of form elements
*/
abstract public function getSettingField( array $criteria ): array;
/**
* Save the filter data
*
* @param array $post Form values
* @return array|bool False, or an array of data to use later when filtering the members
* @throws LogicException
*/
abstract public function save( array $post ) : array|bool;
/**
* Get where clause to add to the member retrieval database query
*
* @param array $data The array returned from the save() method
* @return array|NULL Where clause - must be a single array( "clause" )
*/
abstract public function getQueryWhereClause( array $data ): ?array;
/**
* Callback for member retrieval database query
* Can be used to set joins
*
* @param array $data The array returned from the save() method
* @param Select $query The query
* @return void
*/
public function queryCallback( array $data, Select $query ) : void
{
}
/**
* Determine if a member matches specified filters
*
* @note This is only necessary if availableIn() includes group_promotions
* @param Member $member Member object to check
* @param array $filters Previously defined filters
* @param object|NULL $object Calling class
* @return bool
*/
public function matches( Member $member, array $filters, ?object $object=NULL ): bool
{
return TRUE;
}
}