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
@@ -11,31 +11,53 @@
|
||||
namespace IPS\core\modules\admin\members;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use BadFunctionCallException;
|
||||
use DateInterval;
|
||||
use Exception;
|
||||
use IPS\Api\OAuthClient;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Http\UserAgent;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Device;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Session\Store;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Device Tools
|
||||
*/
|
||||
class _devices extends \IPS\Dispatcher\Controller
|
||||
class devices extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'membertools_ip' );
|
||||
return parent::execute();
|
||||
Dispatcher::i()->checkAcpPermission( 'membertools_ip' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,42 +65,42 @@ class _devices extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function device()
|
||||
protected function device() : void
|
||||
{
|
||||
/* Load */
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->member );
|
||||
$member = Member::load( Request::i()->member );
|
||||
try
|
||||
{
|
||||
$device = \IPS\Member\Device::loadAndAuthenticate( \IPS\Request::i()->key, $member );
|
||||
$device = Device::loadAndAuthenticate( Request::i()->key, $member );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C355/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C355/1', 404, '' );
|
||||
}
|
||||
$url = \IPS\Http\Url::internal( "app=core&module=members&controller=devices&do=device&key={$device->device_key}&member={$member->member_id}" );
|
||||
$url = Url::internal( "app=core&module=members&controller=devices&do=device&key={$device->device_key}&member={$member->member_id}" );
|
||||
|
||||
/* Set title and breadcrumb */
|
||||
$userAgent = $device->userAgent();
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'member_names_device', FALSE, array( 'sprintf' => array( $member->name, $userAgent->platform ) ) );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( "app=core&module=members&controller=members" ), 'members' );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( "app=core&module=members&controller=members&do=view&id={$member->member_id}" ), $member->name );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( "app=core&module=members&controller=devices&do=member&id={$member->member_id}" ), 'members_devices' );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, $userAgent );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'member_names_device', FALSE, array( 'sprintf' => array( $member->name, $userAgent->platform ) ) );
|
||||
Output::i()->breadcrumb[] = array( Url::internal( "app=core&module=members&controller=members" ), 'members' );
|
||||
Output::i()->breadcrumb[] = array( Url::internal( "app=core&module=members&controller=members&do=view&id={$member->member_id}" ), $member->name );
|
||||
Output::i()->breadcrumb[] = array( Url::internal( "app=core&module=members&controller=devices&do=member&id={$member->member_id}" ), 'members_devices' );
|
||||
Output::i()->breadcrumb[] = array( NULL, $userAgent );
|
||||
|
||||
/* Define table */
|
||||
$activeTabContents = '';
|
||||
$tabs = array(
|
||||
'info' => 'device_info',
|
||||
'member' => \IPS\Member::loggedIn()->language()->addToStack( 'device_ips_from_member', FALSE, array( 'sprintf' => array( $member->name ) ) ),
|
||||
'member' => Member::loggedIn()->language()->addToStack( 'device_ips_from_member', FALSE, array( 'sprintf' => array( $member->name ) ) ),
|
||||
'others' => 'device_other_members'
|
||||
);
|
||||
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'info';
|
||||
$activeTab = ( isset( Request::i()->tab ) and array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'info';
|
||||
|
||||
if ( $activeTab === 'info' )
|
||||
{
|
||||
$oauthClients = \IPS\Api\OAuthClient::roots();
|
||||
$oauthClients = OAuthClient::roots();
|
||||
$apps = array();
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_oauth_server_access_tokens', array( 'member_id=? AND device_key=?', $member->member_id, $device->device_key ), 'issued DESC' ) as $accessToken )
|
||||
foreach ( Db::i()->select( '*', 'core_oauth_server_access_tokens', array( 'member_id=? AND device_key=?', $member->member_id, $device->device_key ), 'issued DESC' ) as $accessToken )
|
||||
{
|
||||
if ( isset( $oauthClients[ $accessToken['client_id'] ] ) )
|
||||
{
|
||||
@@ -86,7 +108,7 @@ class _devices extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
$activeTabContents = \IPS\Theme::i()->getTemplate( 'members' )->deviceInfo( $device, $apps, $oauthClients );
|
||||
$activeTabContents = Theme::i()->getTemplate( 'members' )->deviceInfo( $device, $apps, $oauthClients );
|
||||
}
|
||||
elseif ( $activeTab === 'member' )
|
||||
{
|
||||
@@ -98,19 +120,19 @@ class _devices extends \IPS\Dispatcher\Controller
|
||||
'location' => function( $val, $row ) {
|
||||
try
|
||||
{
|
||||
return \IPS\GeoLocation::getByIp( $row['ip_address'] );
|
||||
return GeoLocation::getByIp( $row['ip_address'] );
|
||||
}
|
||||
catch ( \BadFunctionCallException $e )
|
||||
catch ( BadFunctionCallException $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('geolocation_enable_service');
|
||||
return Member::loggedIn()->language()->addToStack('geolocation_enable_service');
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('unknown');
|
||||
return Member::loggedIn()->language()->addToStack('unknown');
|
||||
}
|
||||
},
|
||||
'last_seen' => function( $val ) {
|
||||
return \IPS\DateTime::ts( $val );
|
||||
return DateTime::ts( $val );
|
||||
}
|
||||
);
|
||||
$table->rowButtons = function( $row ) {
|
||||
@@ -118,12 +140,12 @@ class _devices extends \IPS\Dispatcher\Controller
|
||||
'view' => array(
|
||||
'title' => 'view',
|
||||
'icon' => 'search',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=ip' )->setQueryString( 'ip', $row['ip_address'] ),
|
||||
'link' => Url::internal( 'app=core&module=members&controller=ip' )->setQueryString( 'ip', $row['ip_address'] ),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
$activeTabContents = \IPS\Theme::i()->getTemplate( 'forms' )->blurb( \IPS\Member::loggedIn()->language()->addToStack( 'device_ips_from_member_info', FALSE, array( 'sprintf' => array( $member->name, \IPS\Http\Url::internal( "app=core&module=members&controller=members&do=ip&id={$member->member_id}" ) ) ) ), TRUE, TRUE ) . $table . \IPS\Theme::i()->getTemplate( 'members' )->geoipDisclaimer();
|
||||
$activeTabContents = Theme::i()->getTemplate( 'forms' )->blurb( Member::loggedIn()->language()->addToStack( 'device_ips_from_member_info', FALSE, array( 'sprintf' => array( $member->name, Url::internal( "app=core&module=members&controller=members&do=ip&id={$member->member_id}" ) ) ) ), TRUE, TRUE ) . $table . Theme::i()->getTemplate( 'members' )->geoipDisclaimer();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -133,18 +155,18 @@ class _devices extends \IPS\Dispatcher\Controller
|
||||
$table->sortBy = $table->sortBy ?: 'last_seen';
|
||||
$table->parsers = array(
|
||||
'member_id' => function( $val ) {
|
||||
$member = \IPS\Member::load( $val );
|
||||
$member = Member::load( $val );
|
||||
if ( $member->member_id )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core' )->userPhoto( $member, 'tiny' ) . \IPS\Theme::i()->getTemplate( 'global', 'core' )->userLink( $member, 'tiny' );
|
||||
return Theme::i()->getTemplate( 'global', 'core' )->userPhoto( $member, 'tiny' ) . Theme::i()->getTemplate( 'global', 'core' )->userLink( $member, 'tiny' );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('deleted_member');
|
||||
return Member::loggedIn()->language()->addToStack('deleted_member');
|
||||
}
|
||||
},
|
||||
'last_seen' => function( $val ) {
|
||||
return \IPS\DateTime::ts( $val );
|
||||
return DateTime::ts( $val );
|
||||
}
|
||||
);
|
||||
$table->rowButtons = function( $row ) {
|
||||
@@ -152,30 +174,30 @@ class _devices extends \IPS\Dispatcher\Controller
|
||||
'view' => array(
|
||||
'title' => 'view',
|
||||
'icon' => 'search',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=view' )->setQueryString( 'id', $row['member_id'] ),
|
||||
'link' => Url::internal( 'app=core&module=members&controller=members&do=view' )->setQueryString( 'id', $row['member_id'] ),
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
$activeTabContents = \IPS\Theme::i()->getTemplate( 'forms' )->blurb( 'device_other_members_info', TRUE, TRUE ) . $table;
|
||||
$activeTabContents = Theme::i()->getTemplate( 'forms' )->blurb( 'device_other_members_info', TRUE, TRUE ) . $table;
|
||||
}
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $activeTabContents;
|
||||
Output::i()->output = $activeTabContents;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $device->login_key )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['deauthorize'] = array(
|
||||
Output::i()->sidebar['actions']['deauthorize'] = array(
|
||||
'icon' => 'times',
|
||||
'title' => 'sign_out',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=members&controller=devices&do=deauthorize" )->setQueryString( array( 'device' => $device->device_key, 'member' => $member->member_id, 'r' => 'device' ) )->csrf()
|
||||
'link' => Url::internal( "app=core&module=members&controller=devices&do=deauthorize" )->setQueryString( array( 'device' => $device->device_key, 'member' => $member->member_id, 'r' => 'device' ) )->csrf()
|
||||
);
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->tabs( $tabs, $activeTab, $activeTabContents, $url );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->tabs( $tabs, $activeTab, $activeTabContents, $url );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,38 +206,38 @@ class _devices extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function member()
|
||||
protected function member() : void
|
||||
{
|
||||
/* Load */
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->id );
|
||||
$member = Member::load( Request::i()->id );
|
||||
if ( !$member->member_id )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C355/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C355/1', 404, '' );
|
||||
}
|
||||
|
||||
/* Build table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_members_known_devices', \IPS\Http\Url::internal("app=core&module=members&controller=devices&do=member&id={$member->member_id}"), array( 'member_id=?', $member->member_id ) );
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_members_known_devices', Url::internal("app=core&module=members&controller=devices&do=member&id={$member->member_id}"), array( 'member_id=?', $member->member_id ) );
|
||||
$table->langPrefix = 'device_table_';
|
||||
$table->include = array( 'user_agent', 'login_key', 'login_handler', 'last_seen', 'other_members' );
|
||||
$table->noSort = array( 'login_key', 'other_members' );
|
||||
$table->sortBy = $table->sortBy ?: 'last_seen';
|
||||
$table->parsers = array(
|
||||
'user_agent' => function( $val ) {
|
||||
return (string) \IPS\Http\UserAgent::parse( $val );
|
||||
return (string) UserAgent::parse( $val );
|
||||
},
|
||||
'login_key' => function( $val, $row ) {
|
||||
return \IPS\Theme::i()->getTemplate('members')->deviceAuthorization( (bool) $val, $row['last_seen'] >= ( new \IPS\DateTime )->sub( new \DateInterval( \IPS\Member\Device::LOGIN_KEY_VALIDITY ) )->getTimestamp(), $row['anonymous'] );
|
||||
return Theme::i()->getTemplate('members')->deviceAuthorization( (bool) $val, $row['last_seen'] >= ( new DateTime )->sub( new DateInterval( Device::LOGIN_KEY_VALIDITY ) )->getTimestamp(), $row['anonymous'] );
|
||||
},
|
||||
'login_handler' => function( $val, $row ) {
|
||||
return \IPS\Theme::i()->getTemplate('members')->deviceHandler( $val );
|
||||
return Theme::i()->getTemplate('members')->deviceHandler( $val );
|
||||
},
|
||||
'last_seen' => function( $val ) {
|
||||
return \IPS\DateTime::ts( $val );
|
||||
return DateTime::ts( $val );
|
||||
},
|
||||
'other_members' => function( $val, $row ) {
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'core_members_known_devices', array( 'device_key=? AND member_id<>?', $row['device_key'], $row['member_id'] ) )->first() )
|
||||
if ( Db::i()->select( 'COUNT(*)', 'core_members_known_devices', array( 'device_key=? AND member_id<>?', $row['device_key'], $row['member_id'] ) )->first() )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('members')->deviceDuplicate();
|
||||
return Theme::i()->getTemplate('members')->deviceDuplicate();
|
||||
}
|
||||
return '';
|
||||
},
|
||||
@@ -226,7 +248,7 @@ class _devices extends \IPS\Dispatcher\Controller
|
||||
'view' => array(
|
||||
'title' => 'view',
|
||||
'icon' => 'search',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=devices&do=device' )->setQueryString( 'key', $row['device_key'] )->setQueryString( 'member', $row['member_id'] ),
|
||||
'link' => Url::internal( 'app=core&module=members&controller=devices&do=device' )->setQueryString( 'key', $row['device_key'] )->setQueryString( 'member', $row['member_id'] ),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -235,7 +257,7 @@ class _devices extends \IPS\Dispatcher\Controller
|
||||
$return['deauthorize'] = array(
|
||||
'title' => 'sign_out',
|
||||
'icon' => 'times',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=devices&do=deauthorize' )->setQueryString( array(
|
||||
'link' => Url::internal( 'app=core&module=members&controller=devices&do=deauthorize' )->setQueryString( array(
|
||||
'device' => $row['device_key'],
|
||||
'member' => $row['member_id']
|
||||
) )->csrf(),
|
||||
@@ -246,11 +268,11 @@ class _devices extends \IPS\Dispatcher\Controller
|
||||
};
|
||||
|
||||
/* Output */
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'members' )->deviceTable( $table );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'member_names_devices', FALSE, array( 'sprintf' => array( $member->name ) ) );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( "app=core&module=members&controller=members" ), 'members' );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( "app=core&module=members&controller=members&do=view&id={$member->member_id}" ), $member->name );
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( "app=core&module=members&controller=devices&do=member&id={$member->member_id}" ), 'members_devices' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'members' )->deviceTable( $table );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'member_names_devices', FALSE, array( 'sprintf' => array( $member->name ) ) );
|
||||
Output::i()->breadcrumb[] = array( Url::internal( "app=core&module=members&controller=members" ), 'members' );
|
||||
Output::i()->breadcrumb[] = array( Url::internal( "app=core&module=members&controller=members&do=view&id={$member->member_id}" ), $member->name );
|
||||
Output::i()->breadcrumb[] = array( Url::internal( "app=core&module=members&controller=devices&do=member&id={$member->member_id}" ), 'members_devices' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,33 +280,33 @@ class _devices extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function deauthorize()
|
||||
protected function deauthorize() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->member );
|
||||
$device = \IPS\Member\Device::loadAndAuthenticate( \IPS\Request::i()->device, $member );
|
||||
$member = Member::load( Request::i()->member );
|
||||
$device = Device::loadAndAuthenticate( Request::i()->device, $member );
|
||||
$device->login_key = NULL;
|
||||
$device->save();
|
||||
|
||||
\IPS\Db::i()->update( 'core_oauth_server_access_tokens', array( 'status' => 'revoked' ), array( 'member_id=? AND device_key=?', $device->member_id, $device->device_key ) );
|
||||
Db::i()->update( 'core_oauth_server_access_tokens', array( 'status' => 'revoked' ), array( 'member_id=? AND device_key=?', $device->member_id, $device->device_key ) );
|
||||
|
||||
$member->logHistory( 'core', 'login', array( 'type' => 'logout', 'device' => $device->device_key ) );
|
||||
\IPS\Session::i()->log( 'acplog__members_disabled_autologin', array( $member->name => FALSE ) );
|
||||
Session::i()->log( 'acplog__members_disabled_autologin', array( $member->name => FALSE ) );
|
||||
|
||||
\IPS\Session\Store::i()->deleteByMember( $device->member_id, $device->user_agent );
|
||||
Store::i()->deleteByMember( $device->member_id, $device->user_agent );
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
catch ( Exception $e ) { }
|
||||
|
||||
if ( isset( \IPS\Request::i()->r ) and \IPS\Request::i()->r === 'device' )
|
||||
if ( isset( Request::i()->r ) and Request::i()->r === 'device' )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal("app=core&module=members&controller=devices&do=device")->setQueryString( array( 'key' => \IPS\Request::i()->device, 'member' => \IPS\Request::i()->member ) ) );
|
||||
Output::i()->redirect( Url::internal("app=core&module=members&controller=devices&do=device")->setQueryString( array( 'key' => Request::i()->device, 'member' => Request::i()->member ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal("app=core&module=members&controller=devices&do=member")->setQueryString( 'id', \IPS\Request::i()->member ) );
|
||||
Output::i()->redirect( Url::internal("app=core&module=members&controller=devices&do=member")->setQueryString( 'id', Request::i()->member ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,30 +11,61 @@
|
||||
namespace IPS\core\modules\admin\members;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Application;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Checkbox;
|
||||
use IPS\Helpers\Form\Matrix;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Group;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Session\Store;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function is_callable;
|
||||
use function is_null;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Groups
|
||||
*/
|
||||
class _groups extends \IPS\Dispatcher\Controller
|
||||
class groups extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'groups_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'groups_manage' );
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
@@ -44,38 +75,38 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->searchResult ) )
|
||||
if ( isset( Request::i()->searchResult ) )
|
||||
{
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( sprintf( \IPS\Member::loggedIn()->language()->get('search_results_in_nodes'), mb_strtolower( \IPS\Member::loggedIn()->language()->get('group') ) ), 'information' );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->message( sprintf( Member::loggedIn()->language()->get('search_results_in_nodes'), mb_strtolower( Member::loggedIn()->language()->get('group') ) ), 'information' );
|
||||
}
|
||||
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_groups', \IPS\Http\Url::internal( 'app=core&module=members&controller=groups' ) );
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_groups', Url::internal( 'app=core&module=members&controller=groups' ) );
|
||||
|
||||
$table->include = array( 'word_custom', 'members' );
|
||||
$table->noSort = array( 'members' );
|
||||
$table->langPrefix = 'acpgroups_';
|
||||
|
||||
$table->joins = array(
|
||||
array( 'select' => 'w.word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'core_group_', core_groups.g_id ) AND w.lang_id=" . \IPS\Member::loggedIn()->language()->id )
|
||||
array( 'select' => 'w.word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'core_group_', core_groups.g_id ) AND w.lang_id=" . Member::loggedIn()->language()->id )
|
||||
);
|
||||
|
||||
$table->parsers = array(
|
||||
'word_custom' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Member\Group::constructFromData( $row )->formattedName;
|
||||
return Group::constructFromData( $row )->formattedName;
|
||||
},
|
||||
'members' => function( $val, $row )
|
||||
{
|
||||
if ( $row['g_id'] == \IPS\Settings::i()->guest_group )
|
||||
if ( $row['g_id'] == Settings::i()->guest_group )
|
||||
{
|
||||
$onlineGuests = \IPS\Session\Store::i()->getOnlineUsers( \IPS\Session\Store::ONLINE_GUESTS | \IPS\Session\Store::ONLINE_COUNT_ONLY );
|
||||
$onlineGuests = Store::i()->getOnlineUsers( Store::ONLINE_GUESTS | Store::ONLINE_COUNT_ONLY );
|
||||
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( 'online_guests', FALSE, array( 'pluralize' => array( $onlineGuests ) ) );
|
||||
return Member::loggedIn()->language()->addToStack( 'online_guests', FALSE, array( 'pluralize' => array( $onlineGuests ) ) );
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'members' )->memberCounts( $row );
|
||||
return Theme::i()->getTemplate( 'members' )->memberCounts( $row );
|
||||
}
|
||||
);
|
||||
|
||||
@@ -85,37 +116,37 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
$table->sortBy = $table->sortBy ?: 'word_custom';
|
||||
$table->sortDirection = $table->sortDirection ?: 'asc';
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'groups_add' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'groups_add' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['add'] = array(
|
||||
Output::i()->sidebar['actions']['add'] = array(
|
||||
'primary' => true,
|
||||
'icon' => 'plus',
|
||||
'title' => 'groups_add',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=groups&do=form' ),
|
||||
'link' => Url::internal( 'app=core&module=members&controller=groups&do=form' ),
|
||||
);
|
||||
}
|
||||
|
||||
/* Show an extra warning if we are going to delete a group that Commerce intends to move subscribers back to */
|
||||
$warnGroups = array();
|
||||
if( \IPS\Db::i()->checkForColumn( 'core_members', 'cm_return_group' ) )
|
||||
if( Db::i()->checkForColumn( 'core_members', 'cm_return_group' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$warnGroups = iterator_to_array( \IPS\Db::i()->select( 'DISTINCT(cm_return_group)', 'core_members' ) );
|
||||
$warnGroups = iterator_to_array( Db::i()->select( 'DISTINCT(cm_return_group)', 'core_members' ) );
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception $e ){}
|
||||
}
|
||||
|
||||
$table->rowButtons = function( $row ) use ( $warnGroups )
|
||||
{
|
||||
$return = array();
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'groups_edit' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'groups_edit' ) )
|
||||
{
|
||||
$editLink = \IPS\Http\Url::internal( 'app=core&module=members&controller=groups&do=form&id=' . $row['g_id'] );
|
||||
if ( isset( \IPS\Request::i()->searchResult ) )
|
||||
$editLink = Url::internal( 'app=core&module=members&controller=groups&do=form&id=' . $row['g_id'] );
|
||||
if ( isset( Request::i()->searchResult ) )
|
||||
{
|
||||
$editLink = $editLink->setQueryString( 'searchResult', \IPS\Request::i()->searchResult );
|
||||
$editLink = $editLink->setQueryString( 'searchResult', Request::i()->searchResult );
|
||||
}
|
||||
$return['edit'] = array(
|
||||
'icon' => 'pencil',
|
||||
@@ -126,38 +157,38 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
$return['permissions'] = array(
|
||||
'icon' => 'lock',
|
||||
'title' => 'permissions',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=groups&do=permissions&id=' ) . $row['g_id'],
|
||||
'link' => Url::internal( 'app=core&module=members&controller=groups&do=permissions&id=' ) . $row['g_id'],
|
||||
);
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'groups_add' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'groups_add' ) )
|
||||
{
|
||||
$return['copy'] = array(
|
||||
'icon' => 'files-o',
|
||||
'icon' => 'file',
|
||||
'title' => 'copy',
|
||||
'data' => array( 'confirm' => '', 'confirmMessage' => \IPS\Member::loggedIn()->language()->addToStack( 'group_clone_confirm_message' ), 'confirmSubMessage' => \IPS\Member::loggedIn()->language()->addToStack( 'group_clone_confirm_sub_message' ) ),
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=groups&do=copy&id=' . $row['g_id'] )->csrf(),
|
||||
'data' => array( 'confirm' => '', 'confirmMessage' => Member::loggedIn()->language()->addToStack( 'group_clone_confirm_message' ), 'confirmSubMessage' => Member::loggedIn()->language()->addToStack( 'group_clone_confirm_sub_message' ) ),
|
||||
'link' => Url::internal( 'app=core&module=members&controller=groups&do=copy&id=' . $row['g_id'] )->csrf(),
|
||||
);
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'member_export' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'member_export' ) )
|
||||
{
|
||||
$return['download'] = array(
|
||||
'icon' => 'cloud-download',
|
||||
'title' => 'members_export',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=export&_new=1&group=' ) . $row['g_id'],
|
||||
'link' => Url::internal( 'app=core&module=members&controller=members&do=export&_new=1&group=' ) . $row['g_id'],
|
||||
);
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'groups_delete' ) AND \IPS\Member\Group::load($row['g_id'] )->canDelete() )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'groups_delete' ) AND Group::load($row['g_id'] )->canDelete() )
|
||||
{
|
||||
$return['delete'] = array(
|
||||
'icon' => 'times-circle',
|
||||
'title' => 'delete',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=groups&do=delete&id=' ) . $row['g_id'],
|
||||
'data' => \IPS\Db::i()->select( 'COUNT(*)', 'core_members', array( 'member_group_id=?', $row['g_id'] ) )->first() ?
|
||||
array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack( "core_group_{$row['g_id']}" ) ) :
|
||||
array( 'delete' => '', 'delete-warning' => ( \in_array( $row['g_id'], $warnGroups ) ) ? \IPS\Member::loggedIn()->language()->addToStack( "nexus_dont_delete_group", FALSE, array( 'sprintf' => array( \IPS\Member\Group::load( \IPS\Settings::i()->member_group )->name ) ) ) : '' ),
|
||||
'link' => Url::internal( 'app=core&module=members&controller=groups&do=delete&id=' ) . $row['g_id'],
|
||||
'data' => Db::i()->select( 'COUNT(*)', 'core_members', array( 'member_group_id=?', $row['g_id'] ) )->first() ?
|
||||
array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack( "core_group_{$row['g_id']}" ) ) :
|
||||
array( 'delete' => '', 'delete-warning' => ( in_array( $row['g_id'], $warnGroups ) ) ? Member::loggedIn()->language()->addToStack( "nexus_dont_delete_group", FALSE, array( 'sprintf' => array( Group::load( Settings::i()->member_group )->name ) ) ) : '' ),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -165,8 +196,8 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
};
|
||||
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('groups');
|
||||
\IPS\Output::i()->output .= (string) $table;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('groups');
|
||||
Output::i()->output .= $table;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,9 +206,9 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
* @note Fetched via AJAX after the page is loaded as this can be intensive with lots of groups and lots of members
|
||||
* @return void
|
||||
*/
|
||||
public function getCount()
|
||||
public function getCount() : void
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Member\Group::load( \IPS\Request::i()->group )->getCount(), 200, 'text/html' );
|
||||
Output::i()->sendOutput( Group::load( Request::i()->group )->getCount() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,23 +216,23 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function form()
|
||||
public function form() : void
|
||||
{
|
||||
/* Load group */
|
||||
try
|
||||
{
|
||||
$group = \IPS\Member\Group::load( \IPS\Request::i()->id );
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'groups_edit' );
|
||||
$group = Group::load( Request::i()->id );
|
||||
Dispatcher::i()->checkAcpPermission( 'groups_edit' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'groups_add' );
|
||||
$group = new \IPS\Member\Group;
|
||||
Dispatcher::i()->checkAcpPermission( 'groups_add' );
|
||||
$group = new Group;
|
||||
}
|
||||
/* Get extensions */
|
||||
$extensions = \IPS\Application::allExtensions( 'core', 'GroupForm', FALSE, 'core', 'GroupSettings', TRUE );
|
||||
$extensions = Application::allExtensions( 'core', 'GroupForm', FALSE, 'core', 'GroupSettings', TRUE );
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form( ( !$group->g_id ? 'groups_add' : $group->g_id ) );
|
||||
$form = new Form( ( !$group->g_id ? 'groups_add' : $group->g_id ) );
|
||||
foreach ( $extensions as $k => $class )
|
||||
{
|
||||
$form->addTab( 'group__' . $k );
|
||||
@@ -227,15 +258,15 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* And save */
|
||||
$group->save();
|
||||
\IPS\Session::i()->log( ( $new ) ? 'acplog__groups_created' : 'acplog__groups_edited', array( "core_group_". $group->g_id => TRUE ) );
|
||||
Session::i()->log( ( $new ) ? 'acplog__groups_created' : 'acplog__groups_edited', array( "core_group_". $group->g_id => TRUE ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=members&controller=groups' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=members&controller=groups' ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = ( $group->g_id ? $group->name : \IPS\Member::loggedIn()->language()->addToStack('groups_add') );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Output::i()->title );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( \IPS\Output::i()->title, $form );
|
||||
Output::i()->title = ( $group->g_id ? $group->name : Member::loggedIn()->language()->addToStack('groups_add') );
|
||||
Output::i()->breadcrumb[] = array( NULL, Output::i()->title );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( Output::i()->title, $form );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,42 +274,43 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function permissions()
|
||||
public function permissions() : void
|
||||
{
|
||||
/* Load group */
|
||||
try
|
||||
{
|
||||
$group = \IPS\Member\Group::load( \IPS\Request::i()->id );
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'groups_edit' );
|
||||
$group = Group::load( Request::i()->id );
|
||||
Dispatcher::i()->checkAcpPermission( 'groups_edit' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C108/3', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C108/3', 404, '' );
|
||||
}
|
||||
|
||||
/* Load Permissions */
|
||||
$current = array();
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_permission_index' ) as $row )
|
||||
foreach ( Db::i()->select( '*', 'core_permission_index' ) as $row )
|
||||
{
|
||||
$current[ $row['app'] ][ $row['perm_type'] ][ $row['perm_type_id'] ] = $row;
|
||||
}
|
||||
|
||||
/* Init Form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
|
||||
/* Add Tabs */
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'Permissions', FALSE ) as $ext )
|
||||
foreach ( Application::allExtensions( 'core', 'Permissions', FALSE ) as $ext )
|
||||
{
|
||||
foreach ( $ext->getNodeClasses() as $class => $callback )
|
||||
{
|
||||
if( !\is_callable( $callback ) )
|
||||
if( !is_callable( $callback ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* @var Model $class */
|
||||
/* Start a new section */
|
||||
$form->addTab( '__app_' . $class::$permApp );
|
||||
$matrix = new \IPS\Helpers\Form\Matrix( $class );
|
||||
$matrix = new Matrix( $class );
|
||||
$matrix->classes = array( 'cGroupPermissions' );
|
||||
$matrix->styledRowTitle = TRUE;
|
||||
$matrix->showTooltips = TRUE;
|
||||
@@ -299,13 +331,13 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
$node = $class::load( $nodeId );
|
||||
|
||||
if ( !$node->canManagePermissions() )
|
||||
throw new \DomainException;
|
||||
throw new DomainException;
|
||||
|
||||
$acpUrl = $node->acpUrl( 'permissions' );
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
catch ( Exception $e ) { }
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->titleWithLink( $value, $acpUrl, 'all_permissions', \IPS\Member::loggedIn()->language()->addToStack( "all_permissions_node_hovertitle", FALSE, array( 'sprintf' => [ $value ] ) ) );
|
||||
return Theme::i()->getTemplate( 'global', 'core', 'global' )->titleWithLink( $value, $acpUrl, 'all_permissions', Member::loggedIn()->language()->addToStack( "all_permissions_node_hovertitle", FALSE, array( 'sprintf' => [ $value ] ) ) );
|
||||
}
|
||||
);
|
||||
$matrix->widths = array( 'label' => 30 );
|
||||
@@ -315,15 +347,15 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$matrix->columns[ $class::$permissionLangPrefix . 'perm__' . $k ] = function( $key, $value, $data ) use ( $class )
|
||||
{
|
||||
return new \IPS\Helpers\Form\Checkbox( $class::$permApp . $key, $value, FALSE, array( 'disabled' => \is_null( $value ) ) );
|
||||
return new Checkbox( $class::$permApp . $key, $value, FALSE, array( 'disabled' => is_null( $value ) ) );
|
||||
};
|
||||
|
||||
if( isset( $current[ $class::$permApp ][ $class::$permType ] ) AND \is_array( $current[ $class::$permApp ][ $class::$permType ] ) )
|
||||
if( isset( $current[ $class::$permApp ][ $class::$permType ] ) AND is_array( $current[ $class::$permApp ][ $class::$permType ] ) )
|
||||
{
|
||||
foreach( $current[ $class::$permApp ][ $class::$permType ] AS $x => $y )
|
||||
{
|
||||
$matrix->checkAlls[ $class::$permissionLangPrefix . 'perm__' . $k ] = TRUE;
|
||||
if ( $y["perm_{$v}"] !== '*' AND !\in_array( $group->g_id, explode( ',', $y["perm_{$v}"] ) ) )
|
||||
if ( $y["perm_{$v}"] !== '*' AND !in_array( $group->g_id, explode( ',', $y["perm_{$v}"] ) ) )
|
||||
{
|
||||
$matrix->checkAlls[ $class::$permissionLangPrefix . 'perm__' . $k ] = FALSE;
|
||||
break;
|
||||
@@ -340,14 +372,14 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$matrix->rows = $callback( $current[ $class::$permApp ][ $class::$permType ], $group );
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
if( $e->getCode() != 199 )
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->error( 'generic_error', '4T382/1', 500, $e->getMessage() );
|
||||
Output::i()->error( 'generic_error', '4T382/1', 500, $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,24 +404,22 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear out member's cached "Create Menu" contents */
|
||||
\IPS\Member::clearCreateMenu();
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
/* Log */
|
||||
\IPS\Session::i()->log( 'permissions_adjusted_node', array( "core_group_". $group->g_id => TRUE ) );
|
||||
Session::i()->log( 'permissions_adjusted_node', array( "core_group_". $group->g_id => TRUE ) );
|
||||
|
||||
/* Redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=members&controller=groups' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=members&controller=groups' ), 'saved' );
|
||||
}
|
||||
|
||||
if( !count( $form->elements ) )
|
||||
{
|
||||
$form = Theme::i()->getTemplate( 'members' )->emptyGroupPermissions();
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'members/group.css', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->title = $group->name;
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Output::i()->title );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'permissions', $form );
|
||||
Output::i()->title = $group->name;
|
||||
Output::i()->breadcrumb[] = array( NULL, Output::i()->title );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'permissions', $form );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,27 +427,27 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function copy()
|
||||
public function copy() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'groups_add' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Dispatcher::i()->checkAcpPermission( 'groups_add' );
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
/* Load group */
|
||||
try
|
||||
{
|
||||
$group = \IPS\Member\Group::load( \IPS\Request::i()->id );
|
||||
$group = Group::load( Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C108/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C108/1', 404, '' );
|
||||
}
|
||||
|
||||
/* Copy */
|
||||
$newGroup = clone $group;
|
||||
\IPS\Session::i()->log( 'acplog__groups_copied', array( "core_group_". $newGroup->g_id => TRUE ) );
|
||||
Session::i()->log( 'acplog__groups_copied', array( "core_group_". $newGroup->g_id => TRUE ) );
|
||||
|
||||
/* And redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=members&controller=groups&do=form&id={$newGroup->g_id}" ) );
|
||||
Output::i()->redirect( Url::internal( "app=core&module=members&controller=groups&do=form&id={$newGroup->g_id}" ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -425,49 +455,48 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'groups_delete' );
|
||||
Dispatcher::i()->checkAcpPermission( 'groups_delete' );
|
||||
|
||||
/* Load group */
|
||||
try
|
||||
{
|
||||
$group = \IPS\Member\Group::load( \IPS\Request::i()->id );
|
||||
$group = Group::load( Request::i()->id );
|
||||
if( !$group->canDelete() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'cannot_delete_group', '2C108/5', 403, '' );
|
||||
Output::i()->error( 'cannot_delete_group', '2C108/5', 403, '' );
|
||||
}
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'core_members', array( 'member_group_id=?', $group->g_id ) )->first();
|
||||
$count = Db::i()->select( 'COUNT(*)', 'core_members', array( 'member_group_id=?', $group->g_id ) )->first();
|
||||
|
||||
/* Any members in it? */
|
||||
if ( $count )
|
||||
{
|
||||
/* Create the options, but don't let the admin move members in the group back into this same group */
|
||||
$groupOptions = \IPS\Member\Group::groups( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'member_move_admin2' ), FALSE );
|
||||
$groupOptions = Group::groups( Member::loggedIn()->hasAcpRestriction( 'core', 'members', 'member_move_admin2' ), FALSE );
|
||||
unset( $groupOptions[ $group->g_id ] );
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'form', 'delete' );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'delete_group_move_to', NULL, TRUE, array( 'options' => $groupOptions, 'parse' => 'normal' ) ) );
|
||||
$form = new Form( 'form', 'delete' );
|
||||
$form->add( new Select( 'delete_group_move_to', NULL, TRUE, array( 'options' => $groupOptions, 'parse' => 'normal' ) ) );
|
||||
$form->hiddenValues['wasConfirmed'] = 1;
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_members', array( 'member_group_id' => $values['delete_group_move_to'] ), array( 'member_group_id=?', $group->g_id ) );
|
||||
\IPS\Member::clearCreateMenu();
|
||||
Db::i()->update( 'core_members', array( 'member_group_id' => $values['delete_group_move_to'] ), array( 'member_group_id=?', $group->g_id ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
Request::i()->confirmedDelete();
|
||||
}
|
||||
|
||||
/* remove this from members secondary groups column */
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_members', \IPS\Db::i()->findInSet( 'mgroup_others', array( $group->g_id ) ) ), 'IPS\Member') AS $member )
|
||||
foreach ( new ActiveRecordIterator( Db::i()->select( '*', 'core_members', Db::i()->findInSet( 'mgroup_others', array( $group->g_id ) ) ), 'IPS\Member') AS $member )
|
||||
{
|
||||
$secondaryGroups= $member->mgroup_others ? explode( ',', $member->mgroup_others ) : array();
|
||||
|
||||
@@ -479,25 +508,25 @@ class _groups extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_members', array( 'mgroup_others' => implode( ',', array_filter( $secondaryGroups ) ) ), array( 'member_id=?', $member->member_id ) );
|
||||
Db::i()->update( 'core_members', array( 'mgroup_others' => implode( ',', array_filter( $secondaryGroups ) ) ), array( 'member_id=?', $member->member_id ) );
|
||||
}
|
||||
|
||||
$name = $group->name;
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $name );
|
||||
Member::loggedIn()->language()->parseOutputForDisplay( $name );
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__groups_deleted', array( $name => FALSE ) );
|
||||
Session::i()->log( 'acplog__groups_deleted', array( $name => FALSE ) );
|
||||
$group->delete();
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C108/2', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C108/2', 404, '' );
|
||||
}
|
||||
catch( \InvalidArgumentException $e )
|
||||
catch( InvalidArgumentException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'cannot_delete_protected_group', '1C108/4', 403, '' );
|
||||
Output::i()->error( 'cannot_delete_protected_group', '1C108/4', 403, '' );
|
||||
}
|
||||
|
||||
/* And redirect */
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=members&controller=groups" ) );
|
||||
Output::i()->redirect( Url::internal( "app=core&module=members&controller=groups" ) );
|
||||
}
|
||||
}
|
||||
@@ -11,41 +11,53 @@
|
||||
namespace IPS\core\modules\admin\members;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Member as FormMember;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* IP Address Tools
|
||||
*/
|
||||
class _ip extends \IPS\Dispatcher\Controller
|
||||
class ip extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief GeoLocation
|
||||
*/
|
||||
protected $geoLocation = NULL;
|
||||
|
||||
/**
|
||||
* @brief GeoLocation Exception
|
||||
*/
|
||||
protected $getLocationException = NULL;
|
||||
protected ?GeoLocation $geoLocation = NULL;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'membertools_ip' );
|
||||
return parent::execute();
|
||||
Dispatcher::i()->checkAcpPermission( 'membertools_ip' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,24 +65,24 @@ class _ip extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->ip ) )
|
||||
if ( isset( Request::i()->ip ) )
|
||||
{
|
||||
$ip = \IPS\Request::i()->ip;
|
||||
\IPS\Output::i()->title = $ip;
|
||||
$ip = Request::i()->ip;
|
||||
Output::i()->title = $ip;
|
||||
|
||||
$url = \IPS\Http\Url::internal( 'app=core&module=members&controller=ip' )->setQueryString( 'ip', $ip );
|
||||
$url = Url::internal( 'app=core&module=members&controller=ip' )->setQueryString( 'ip', $ip );
|
||||
|
||||
if ( isset( \IPS\Request::i()->area ) )
|
||||
if ( isset( Request::i()->area ) )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( $url, $ip );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, 'ipAddresses__' . \IPS\Request::i()->area );
|
||||
Output::i()->breadcrumb[] = array( $url, $ip );
|
||||
Output::i()->breadcrumb[] = array( NULL, 'ipAddresses__' . Request::i()->area );
|
||||
|
||||
$exploded = explode( '_', \IPS\Request::i()->area );
|
||||
$extensions = \IPS\Application::load( $exploded[0] )->extensions( 'core', 'IpAddresses' );
|
||||
$class = $extensions[ mb_substr( \IPS\Request::i()->area, mb_strlen( $exploded[0] ) + 1 ) ];
|
||||
\IPS\Output::i()->output = $class->findByIp( str_replace( '*', '%', $ip ), $url->setQueryString( 'area', \IPS\Request::i()->area ) );
|
||||
$exploded = explode( '_', Request::i()->area );
|
||||
$extensions = Application::load( $exploded[0] )->extensions( 'core', 'IpAddresses' );
|
||||
$class = $extensions[ mb_substr( Request::i()->area, mb_strlen( $exploded[0] ) + 1 ) ];
|
||||
Output::i()->output = $class->findByIp( str_replace( '*', '%', $ip ), $url->setQueryString( 'area', Request::i()->area ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -82,21 +94,21 @@ class _ip extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
$geolocation = \IPS\GeoLocation::getByIp( $ip );
|
||||
$geolocation = GeoLocation::getByIp( $ip );
|
||||
$map = $geolocation->map()->render( 400, 350, 0.6 );
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
catch ( Exception $e ) {}
|
||||
|
||||
$hostName = @gethostbyaddr( $ip );
|
||||
}
|
||||
|
||||
$contentCounts = array();
|
||||
$otherCounts = array();
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'IpAddresses' ) as $k => $ext )
|
||||
foreach ( Application::allExtensions( 'core', 'IpAddresses' ) as $k => $ext )
|
||||
{
|
||||
/* If the method does not exist, we presume it is supported - this is for legacy purposes as the method is new so
|
||||
third parties won't have it present */
|
||||
if( method_exists( $ext, 'supportedInAcp' ) AND !$ext->supportedInAcp() )
|
||||
if( !$ext->supportedInAcp() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -119,35 +131,35 @@ class _ip extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( '', \IPS\Theme::i()->getTemplate( 'members', 'core', 'global' )->ipLookup( $url, $geolocation, $map, $hostName, array_merge( $otherCounts, $contentCounts ) ) );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( '', Theme::i()->getTemplate( 'members', 'core', 'global' )->ipLookup( $url, $geolocation, $map, $hostName, array_merge( $otherCounts, $contentCounts ) ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form', 'continue' );
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'ip_address', NULL, TRUE, array(), function( $val )
|
||||
$form = new Form( 'form', 'continue' );
|
||||
$form->add( new Text( 'ip_address', NULL, TRUE, array(), function( $val )
|
||||
{
|
||||
if( trim( $val, '*' ) == '' )
|
||||
{
|
||||
throw new \DomainException('not_just_asterisk');
|
||||
throw new DomainException('not_just_asterisk');
|
||||
}
|
||||
} ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=members&controller=ip' )->setQueryString( 'ip', $values['ip_address'] ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=members&controller=ip' )->setQueryString( 'ip', $values['ip_address'] ) );
|
||||
}
|
||||
|
||||
$members = new \IPS\Helpers\Form( 'members', 'continue' );
|
||||
$members->add( new \IPS\Helpers\Form\Member( 'ip_username', NULL, TRUE ) );
|
||||
$members = new Form( 'members', 'continue' );
|
||||
$members->add( new FormMember( 'ip_username', NULL, TRUE ) );
|
||||
|
||||
if ( $values = $members->values() )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=ip' )->setQueryString( 'id', $values['ip_username']->member_id ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=members&controller=members&do=ip' )->setQueryString( 'id', $values['ip_username']->member_id ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_members_ip');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'members' )->ipform( $form, $members );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_members_ip');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'members' )->ipform( $form, $members );
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -13,38 +13,54 @@ namespace IPS\core\modules\admin\members;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Url as FormUrl;
|
||||
use IPS\Helpers\Table\Db as TableDb;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Member\PrivacyAction;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* privacy
|
||||
*/
|
||||
class _privacy extends \IPS\Dispatcher\Controller
|
||||
class privacy extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'privacy_manage' );
|
||||
\IPS\Output::i()->sidebar['actions']['settings'] = array(
|
||||
Dispatcher::i()->checkAcpPermission( 'privacy_manage' );
|
||||
Output::i()->sidebar['actions']['settings'] = array(
|
||||
'icon' => 'cog',
|
||||
'title' => 'settings',
|
||||
'link' => $this->url->setQueryString( 'do', 'settings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('settings') )
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('settings') )
|
||||
);
|
||||
parent::execute();
|
||||
}
|
||||
@@ -54,19 +70,19 @@ class _privacy extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
/* Some advanced search links may bring us here */
|
||||
\IPS\Output::i()->bypassCsrfKeyCheck = true;
|
||||
Output::i()->bypassCsrfKeyCheck = true;
|
||||
|
||||
/* Create the table */
|
||||
$where = [ [ \IPS\Db::i()->in('action', [\IPS\Member\PrivacyAction::TYPE_REQUEST_DELETE, \IPS\Member\PrivacyAction::TYPE_REQUEST_PII] ) ], ['approved=?', 0] ];
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_member_privacy_actions', \IPS\Http\Url::internal( 'app=core&module=members&controller=privacy' ), $where );
|
||||
$where = [ [ Db::i()->in('action', [ PrivacyAction::TYPE_REQUEST_DELETE, PrivacyAction::TYPE_REQUEST_PII] ) ], ['approved=?', 0] ];
|
||||
$table = new TableDb( 'core_member_privacy_actions', Url::internal( 'app=core&module=members&controller=privacy' ), $where );
|
||||
$table->include = [ 'photo', 'name', 'email', 'joined','action','request_date' ];
|
||||
|
||||
$table->filters = [
|
||||
'deletion_request' => ['action=?', \IPS\Member\PrivacyAction::TYPE_REQUEST_DELETE],
|
||||
'pii_data' => ['action=?', \IPS\Member\PrivacyAction::TYPE_REQUEST_PII],
|
||||
'deletion_request' => ['action=?', PrivacyAction::TYPE_REQUEST_DELETE],
|
||||
'pii_data' => ['action=?', PrivacyAction::TYPE_REQUEST_PII],
|
||||
];
|
||||
|
||||
$table->joins = [
|
||||
@@ -76,50 +92,51 @@ class _privacy extends \IPS\Dispatcher\Controller
|
||||
$table->parsers = [
|
||||
'photo' => function( $val, $row )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core' )->userPhoto( \IPS\Member::constructFromData( $row ), 'tiny' );
|
||||
return Theme::i()->getTemplate( 'global', 'core' )->userPhoto( Member::constructFromData( $row ), 'tiny' );
|
||||
},
|
||||
'name' => function( $val, $row ){
|
||||
if( $val )
|
||||
{
|
||||
$member = \IPS\Member::constructFromData( $row );
|
||||
$member = Member::constructFromData( $row );
|
||||
|
||||
if( $banned = $member->isBanned() )
|
||||
{
|
||||
if( $banned instanceof \IPS\DateTime )
|
||||
if( $banned instanceof DateTime )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'suspended_until', FALSE, array( 'sprintf' => array( $banned->localeDate() ) ) );
|
||||
$title = Member::loggedIn()->language()->addToStack( 'suspended_until', FALSE, array( 'sprintf' => array( $banned->localeDate() ) ) );
|
||||
}else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'banned' );
|
||||
$title = Member::loggedIn()->language()->addToStack( 'banned' );
|
||||
}
|
||||
return "<a href='".\IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=view&id=' ).$row[ 'member_id' ]."'>".htmlentities( $val, ENT_DISALLOWED, 'UTF-8', FALSE )."</a> <span class='ipsBadge ipsBadge_negative'>".$title.'</span> ';
|
||||
return "<a href='". Url::internal( 'app=core&module=members&controller=members&do=view&id=' ).$row[ 'member_id' ]."'>".htmlentities( $val, ENT_DISALLOWED, 'UTF-8', FALSE )."</a> <span class='ipsBadge ipsBadge--negative'>".$title.'</span> ';
|
||||
}else
|
||||
{
|
||||
return "<a href='".\IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=view&id=' ).$row[ 'member_id' ]."'>".htmlentities( $val, ENT_DISALLOWED, 'UTF-8', FALSE ).'</a>';
|
||||
return "<a href='". Url::internal( 'app=core&module=members&controller=members&do=view&id=' ).$row[ 'member_id' ]."'>".htmlentities( $val, ENT_DISALLOWED, 'UTF-8', FALSE ).'</a>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'members', 'core', 'admin' )->memberReserved( \IPS\Member::constructFromData( $row ) );
|
||||
return Theme::i()->getTemplate( 'members', 'core', 'admin' )->memberReserved( Member::constructFromData( $row ) );
|
||||
}
|
||||
},
|
||||
'joined' => function( $val, $row )
|
||||
'joined' => function( $val )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->localeDate();
|
||||
return DateTime::ts( $val )->localeDate();
|
||||
},
|
||||
'request_date' => function( $val, $row )
|
||||
'request_date' => function( $val )
|
||||
{
|
||||
return \IPS\DateTime::ts( $val )->localeDate();
|
||||
return DateTime::ts( $val )->localeDate();
|
||||
},
|
||||
'action' => function( $val, $row )
|
||||
'action' => function( $val )
|
||||
{
|
||||
switch ( $val )
|
||||
{
|
||||
case \IPS\Member\PrivacyAction::TYPE_REQUEST_PII:
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('pii_download_requested');
|
||||
case \IPS\Member\PrivacyAction::TYPE_REQUEST_DELETE:
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('account_deletion_requested');
|
||||
case PrivacyAction::TYPE_REQUEST_PII:
|
||||
return Member::loggedIn()->language()->addToStack('pii_download_requested');
|
||||
case PrivacyAction::TYPE_REQUEST_DELETE:
|
||||
return Member::loggedIn()->language()->addToStack('account_deletion_requested');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
];
|
||||
|
||||
@@ -127,33 +144,33 @@ class _privacy extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$return = [];
|
||||
|
||||
if( $row['action'] == \IPS\Member\PrivacyAction::TYPE_REQUEST_PII )
|
||||
if( $row['action'] == PrivacyAction::TYPE_REQUEST_PII )
|
||||
{
|
||||
$return[ 'approve' ] = [
|
||||
'title' => 'approve',
|
||||
'icon' => 'check-circle',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=privacy&do=approvePii&id='.$row[ 'id' ] )->csrf()->getSafeUrlFromFilters(),
|
||||
'link' => Url::internal( 'app=core&module=members&controller=privacy&do=approvePii&id='.$row[ 'id' ] )->csrf()->getSafeUrlFromFilters(),
|
||||
];
|
||||
$return['reject'] = [
|
||||
'icon' => 'times',
|
||||
'title' => 'reject',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=privacy&do=rejectPii&id=' . $row['id'] )->csrf()->getSafeUrlFromFilters(),
|
||||
'link' => Url::internal( 'app=core&module=members&controller=privacy&do=rejectPii&id=' . $row['id'] )->csrf()->getSafeUrlFromFilters(),
|
||||
];
|
||||
}
|
||||
else if( $row['action'] == \IPS\Member\PrivacyAction::TYPE_REQUEST_DELETE )
|
||||
else if( $row['action'] == PrivacyAction::TYPE_REQUEST_DELETE )
|
||||
{
|
||||
$member = \IPS\Member::constructFromData( $row );
|
||||
$member = Member::constructFromData( $row );
|
||||
|
||||
$return[ 'approveDeletion' ] = [
|
||||
'title' => 'approve',
|
||||
'icon' => 'check-circle',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=privacy&do=approveDeletion&id='.$row[ 'id' ] )->csrf()->getSafeUrlFromFilters(),
|
||||
'data' => [ 'confirm' => '', 'confirmSubMessage' => \IPS\Member::loggedIn()->language()->addToStack( 'delete_member_confirm', FALSE, array( 'sprintf' => $member->name ) ) ]
|
||||
'link' => Url::internal( 'app=core&module=members&controller=privacy&do=approveDeletion&id='.$row[ 'id' ] )->csrf()->getSafeUrlFromFilters(),
|
||||
'data' => [ 'confirm' => '', 'confirmSubMessage' => Member::loggedIn()->language()->addToStack( 'delete_member_confirm', FALSE, array( 'sprintf' => $member->name ) ) ]
|
||||
];
|
||||
$return['rejectDeletion'] = [
|
||||
'icon' => 'times',
|
||||
'title' => 'reject',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=members&controller=privacy&do=rejectDeletion&id=' . $row['id'] )->csrf()->getSafeUrlFromFilters(),
|
||||
'link' => Url::internal( 'app=core&module=members&controller=privacy&do=rejectDeletion&id=' . $row['id'] )->csrf()->getSafeUrlFromFilters(),
|
||||
'data' => array(
|
||||
|
||||
)
|
||||
@@ -165,8 +182,8 @@ class _privacy extends \IPS\Dispatcher\Controller
|
||||
};
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'menu__core_members_privacy');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $table );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'menu__core_members_privacy');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $table );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,20 +191,20 @@ class _privacy extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function approvePii()
|
||||
protected function approvePii() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
try
|
||||
{
|
||||
$request = \IPS\Member\PrivacyAction::load( \IPS\Request::i()->id );
|
||||
$request = PrivacyAction::load( Request::i()->id );
|
||||
$request->approvePiiRequest();
|
||||
\IPS\Session::i()->log( 'acplog__piirequest_approved', array( $request->member->name => FALSE ) );
|
||||
Session::i()->log( 'acplog__piirequest_approved', array( $request->member->name => FALSE ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C432/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C432/1', 404, '' );
|
||||
}
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=members&controller=privacy' )->getSafeUrlFromFilters(), 'approved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=members&controller=privacy' )->getSafeUrlFromFilters(), 'approved' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,20 +212,20 @@ class _privacy extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function rejectPii()
|
||||
protected function rejectPii() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
try
|
||||
{
|
||||
$request = \IPS\Member\PrivacyAction::load( \IPS\Request::i()->id );
|
||||
$request = PrivacyAction::load( Request::i()->id );
|
||||
$request->rejectPiiRequest();
|
||||
\IPS\Session::i()->log( 'acplog__piirequest_rejected', array( $request->member->name => FALSE ) );
|
||||
Session::i()->log( 'acplog__piirequest_rejected', array( $request->member->name => FALSE ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C432/2', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C432/2', 404, '' );
|
||||
}
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=members&controller=privacy' )->getSafeUrlFromFilters(), 'pii_request_rejected' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=members&controller=privacy' )->getSafeUrlFromFilters(), 'pii_request_rejected' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,24 +233,24 @@ class _privacy extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function approveDeletion()
|
||||
protected function approveDeletion() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$request = \IPS\Member\PrivacyAction::load( \IPS\Request::i()->id );
|
||||
$request = PrivacyAction::load( Request::i()->id );
|
||||
|
||||
\IPS\Request::i()->confirmedDelete( message: \IPS\Member::loggedIn()->language()->addToStack( 'delete_member_confirm', FALSE, array( 'sprintf' => $request->member->name ) ) );
|
||||
Request::i()->confirmedDelete( message: Member::loggedIn()->language()->addToStack( 'delete_member_confirm', FALSE, array( 'sprintf' => $request->member->name ) ) );
|
||||
|
||||
$request->deleteAccount();
|
||||
\IPS\Session::i()->log( 'acplog__deletionrequest__approved', array( $request->member->name => FALSE ) );
|
||||
Session::i()->log( 'acplog__deletionrequest__approved', array( $request->member->name => FALSE ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C432/3', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C432/3', 404, '' );
|
||||
}
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=members&controller=privacy' )->getSafeUrlFromFilters(), 'approved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=members&controller=privacy' )->getSafeUrlFromFilters(), 'approved' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,26 +258,26 @@ class _privacy extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function rejectDeletion()
|
||||
protected function rejectDeletion() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
try
|
||||
{
|
||||
$request = \IPS\Member\PrivacyAction::load( \IPS\Request::i()->id );
|
||||
$request = PrivacyAction::load( Request::i()->id );
|
||||
$request->rejectDeletionRequest();
|
||||
\IPS\Session::i()->log( 'acplog__deletionrequest__rejected', array( $request->member->name => FALSE ) );
|
||||
Session::i()->log( 'acplog__deletionrequest__rejected', array( $request->member->name => FALSE ) );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C432/4', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C432/4', 404, '' );
|
||||
}
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=members&controller=privacy' )->getSafeUrlFromFilters(), 'rejected' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=members&controller=privacy' )->getSafeUrlFromFilters(), 'rejected' );
|
||||
}
|
||||
|
||||
protected function settings()
|
||||
protected function settings() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form();
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'pii_type', \IPS\Settings::i()->pii_type, FALSE, array(
|
||||
$form = new Form();
|
||||
$form->add( new Radio( 'pii_type', Settings::i()->pii_type, FALSE, array(
|
||||
'options' => array(
|
||||
'off' => 'disabled',
|
||||
'on' => 'enabled',
|
||||
@@ -272,10 +289,10 @@ class _privacy extends \IPS\Dispatcher\Controller
|
||||
)
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'pii_link', \IPS\Settings::i()->pii_link, FALSE, array(), NULL, NULL, NULL, 'pii_link' ) );
|
||||
$form->add( new FormUrl( 'pii_link', Settings::i()->pii_link, FALSE, array(), NULL, NULL, NULL, 'pii_link' ) );
|
||||
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'right_to_be_forgotten_type', \IPS\Settings::i()->right_to_be_forgotten_type, FALSE, array(
|
||||
$form->add( new Radio( 'right_to_be_forgotten_type', Settings::i()->right_to_be_forgotten_type, FALSE, array(
|
||||
'options' => array(
|
||||
'off' => 'disabled',
|
||||
'on' => 'enabled',
|
||||
@@ -286,15 +303,15 @@ class _privacy extends \IPS\Dispatcher\Controller
|
||||
'on' => array(),
|
||||
)
|
||||
) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'right_to_be_forgotten_link', \IPS\Settings::i()->right_to_be_forgotten_link, FALSE, array(), NULL, NULL, NULL, 'right_to_be_forgotten_link' ) );
|
||||
$form->add( new FormUrl( 'right_to_be_forgotten_link', Settings::i()->right_to_be_forgotten_link, FALSE, array(), NULL, NULL, NULL, 'right_to_be_forgotten_link' ) );
|
||||
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
$form->saveAsSettings();
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=members&controller=privacy' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=members&controller=privacy' ), 'saved' );
|
||||
}
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'settings');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $form );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'settings');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->block( 'title', (string) $form );
|
||||
}
|
||||
}
|
||||
@@ -11,35 +11,43 @@
|
||||
namespace IPS\core\modules\admin\members;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Output;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* promotions
|
||||
*/
|
||||
class _promotions extends \IPS\Node\Controller
|
||||
class promotions extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = '\IPS\Member\GroupPromotion';
|
||||
protected string $nodeClass = '\IPS\Member\GroupPromotion';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'promotions_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'promotions_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -48,9 +56,9 @@ class _promotions extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('forms')->blurb( \IPS\Application::appIsEnabled('nexus') ? 'group_promotion_blurb_commerce' : 'group_promotion_blurb' );
|
||||
Output::i()->output = Theme::i()->getTemplate('forms')->blurb( Application::appIsEnabled('nexus') ? 'group_promotion_blurb_commerce' : 'group_promotion_blurb' );
|
||||
parent::manage();
|
||||
}
|
||||
}
|
||||
@@ -11,31 +11,41 @@
|
||||
namespace IPS\core\modules\admin\members;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Session;
|
||||
use IPS\Task;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recount and Reset Tools
|
||||
*/
|
||||
class _reset extends \IPS\Dispatcher\Controller
|
||||
class reset extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'member_recount_content' );
|
||||
return parent::execute();
|
||||
Dispatcher::i()->checkAcpPermission( 'member_recount_content' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,12 +53,12 @@ class _reset extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function posts()
|
||||
public function posts() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Task::queue( 'core', 'RecountMemberContent', array(), 4 );
|
||||
\IPS\Session::i()->log( 'acplog__recount_member_content' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=members&controller=members' ), \IPS\Member::loggedIn()->language()->addToStack( 'member_recount_content_process' ) );
|
||||
Session::i()->csrfCheck();
|
||||
Task::queue( 'core', 'RecountMemberContent', array(), 4 );
|
||||
Session::i()->log( 'acplog__recount_member_content' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=members&controller=members' ), Member::loggedIn()->language()->addToStack( 'member_recount_content_process' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,11 +66,11 @@ class _reset extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rep()
|
||||
public function rep() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Task::queue( 'core', 'RecountMemberReputation', array(), 4 );
|
||||
\IPS\Session::i()->log( 'acplog__recount_member_rep' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=members&controller=members' ), \IPS\Member::loggedIn()->language()->addToStack( 'member_recount_rep_process' ) );
|
||||
Session::i()->csrfCheck();
|
||||
Task::queue( 'core', 'RecountMemberReputation', array(), 4 );
|
||||
Session::i()->log( 'acplog__recount_member_rep' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=members&controller=members' ), Member::loggedIn()->language()->addToStack( 'member_recount_rep_process' ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user