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,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" ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user