Files
IPB/applications/core/data/defaults/extensions/MemberRestrictions.txt
T
2025-12-19 16:27:35 -08:00

94 lines
2.1 KiB
Plaintext

<?php
/**
* @brief Member Restrictions
* @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 {date}
*/
namespace IPS\{app}\extensions\core\MemberRestrictions;
use IPS\core\MemberACPProfile\Restriction;
use IPS\Db;
use IPS\Helpers\Form;
use IPS\Member as MemberClass;
use function defined;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* @brief Member Restrictions
*/
class {class} extends Restriction
{
/**
* Modify Edit Restrictions form
*
* @param Form $form The form
* @return void
*/
public function form( Form $form ) : void
{
// $form->add( ... );
}
/**
* Save Form
*
* @param array $values Values from form
* @return array
*/
public function save( array $values ): array
{
$return = array();
// $return['my_restriction'] = array( 'old' => $oldValue, 'new' => $values['my_restriction'] ); // used in changesForHistory()
// Db::i()->update( ... ); // Actually save the value
return $return;
}
/**
* What restrictions are active on the account?
*
* @return array
*/
public function activeRestrictions(): array
{
$return = array();
/*if ( ... )
{
$return[] = 'my_restricion';
}*/
return $return;
}
/**
* Get details of a change to show on history
*
* @param array $changes Changes as set in save()
* @param array $row Row of data from member history table.
* @return array
*/
public static function changesForHistory( array $changes, array $row ): array
{
$return = array();
if ( isset( $changes['my_restriction'] ) )
{
$return[] = MemberClass::loggedIn()->language()->addToStack( 'changed_my_restriction', FALSE, array( 'sprintf' => array( $changes['my_restriction']['new'], $changes['my_restriction']['new'] ) ) );
}
return $return;
}
}