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,70 @@
|
||||
namespace IPS\core\modules\admin\clubs;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Table\Db as TableDb;
|
||||
use IPS\Helpers\Tree\Tree;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Http\Url\Friendly;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Club;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use const IPS\Helpers\Table\SEARCH_DATE_RANGE;
|
||||
use const IPS\Helpers\Table\SEARCH_MEMBER;
|
||||
use const IPS\Helpers\Table\SEARCH_NUMERIC;
|
||||
use const IPS\Helpers\Table\SEARCH_QUERY_TEXT;
|
||||
use const IPS\Helpers\Table\SEARCH_SELECT;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clubs
|
||||
*/
|
||||
class _clubs extends \IPS\Dispatcher\Controller
|
||||
class clubs extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected ?string $nodeClass = null;
|
||||
|
||||
/**
|
||||
* @var Club|null
|
||||
*/
|
||||
protected ?Club $club = null;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'clubs_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'clubs_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -43,37 +83,37 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_clubs_clubs');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_clubs_clubs');
|
||||
|
||||
if ( \IPS\Settings::i()->clubs )
|
||||
if ( Settings::i()->clubs )
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'core_clubs', \IPS\Http\Url::internal( 'app=core&module=clubs&controller=clubs' ) );
|
||||
$table = new TableDb( 'core_clubs', Url::internal( 'app=core&module=clubs&controller=clubs' ) );
|
||||
$table->include = array( 'name', 'type', 'members', 'owner', 'created' );
|
||||
$table->langPrefix = 'club_';
|
||||
$table->parsers = array(
|
||||
'name' => function( $value, $row )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate('clubs')->name( $value, $row );
|
||||
return Theme::i()->getTemplate('clubs')->name( $value, $row );
|
||||
},
|
||||
'type' => function( $value ) {
|
||||
return \IPS\Theme::i()->getTemplate('clubs')->privacy( $value );
|
||||
return Theme::i()->getTemplate('clubs')->privacy( $value );
|
||||
},
|
||||
'created' => function( $value ) {
|
||||
return \IPS\DateTime::ts( $value );
|
||||
return DateTime::ts( $value );
|
||||
},
|
||||
'members' => function( $value, $row ) {
|
||||
if ( $row['type'] !== \IPS\Member\Club::TYPE_PUBLIC )
|
||||
if ( $row['type'] !== Club::TYPE_PUBLIC )
|
||||
{
|
||||
$link = \IPS\Http\Url::internal( "app=core&module=clubs&controller=view&id={$row['id']}&do=members", 'front', 'clubs_view', array( \IPS\Http\Url\Friendly::seoTitle( $row['name'] ) ) );
|
||||
return \IPS\Theme::i()->getTemplate('clubs')->members( $value, $link );
|
||||
$link = Url::internal( "app=core&module=clubs&controller=view&id={$row['id']}&do=members", 'front', 'clubs_view', array( Friendly::seoTitle( $row['name'] ) ) );
|
||||
return Theme::i()->getTemplate('clubs')->members( $value, $link );
|
||||
}
|
||||
return '';
|
||||
},
|
||||
'owner' => function( $value ) {
|
||||
return \IPS\Theme::i()->getTemplate('clubs')->owner( \IPS\Member::load( $value ) );
|
||||
return Theme::i()->getTemplate('clubs')->owner( Member::load( $value ) );
|
||||
},
|
||||
'_highlight' => function( $row ) {
|
||||
if ( !$row['approved'] )
|
||||
@@ -87,96 +127,96 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
$table->sortBy = $table->sortBy ?: 'members';
|
||||
$table->quickSearch = 'name';
|
||||
$table->advancedSearch = array(
|
||||
'name' => \IPS\Helpers\Table\SEARCH_QUERY_TEXT,
|
||||
'members' => \IPS\Helpers\Table\SEARCH_NUMERIC,
|
||||
'owner' => \IPS\Helpers\Table\SEARCH_MEMBER,
|
||||
'created' => \IPS\Helpers\Table\SEARCH_DATE_RANGE,
|
||||
'name' => SEARCH_QUERY_TEXT,
|
||||
'members' => SEARCH_NUMERIC,
|
||||
'owner' => SEARCH_MEMBER,
|
||||
'created' => SEARCH_DATE_RANGE,
|
||||
);
|
||||
if ( \IPS\Settings::i()->clubs_require_approval )
|
||||
if ( Settings::i()->clubs_require_approval )
|
||||
{
|
||||
$table->filters = array(
|
||||
'pending_approval' => 'approved=0'
|
||||
);
|
||||
$table->advancedSearch['type'] = array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => array(
|
||||
\IPS\Member\Club::TYPE_PUBLIC => 'club_type_' . \IPS\Member\Club::TYPE_PUBLIC,
|
||||
\IPS\Member\Club::TYPE_OPEN => 'club_type_' . \IPS\Member\Club::TYPE_OPEN,
|
||||
\IPS\Member\Club::TYPE_CLOSED => 'club_type_' . \IPS\Member\Club::TYPE_CLOSED,
|
||||
\IPS\Member\Club::TYPE_PRIVATE => 'club_type_' . \IPS\Member\Club::TYPE_PRIVATE,
|
||||
\IPS\Member\Club::TYPE_READONLY => 'club_type_' . \IPS\Member\Club::TYPE_READONLY,
|
||||
$table->advancedSearch['type'] = array( SEARCH_SELECT, array( 'options' => array(
|
||||
Club::TYPE_PUBLIC => 'club_type_' . Club::TYPE_PUBLIC,
|
||||
Club::TYPE_OPEN => 'club_type_' . Club::TYPE_OPEN,
|
||||
Club::TYPE_CLOSED => 'club_type_' . Club::TYPE_CLOSED,
|
||||
Club::TYPE_PRIVATE => 'club_type_' . Club::TYPE_PRIVATE,
|
||||
Club::TYPE_READONLY => 'club_type_' . Club::TYPE_READONLY,
|
||||
), 'multiple' => TRUE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->filters = array(
|
||||
'club_type_' . \IPS\Member\Club::TYPE_PUBLIC => array( 'type=?', \IPS\Member\Club::TYPE_PUBLIC ),
|
||||
'club_type_' . \IPS\Member\Club::TYPE_OPEN => array( 'type=?', \IPS\Member\Club::TYPE_OPEN ),
|
||||
'club_type_' . \IPS\Member\Club::TYPE_CLOSED => array( 'type=?', \IPS\Member\Club::TYPE_CLOSED ),
|
||||
'club_type_' . \IPS\Member\Club::TYPE_PRIVATE => array( 'type=?', \IPS\Member\Club::TYPE_PRIVATE ),
|
||||
'club_type_' . \IPS\Member\Club::TYPE_READONLY => array( 'type=?', \IPS\Member\Club::TYPE_READONLY )
|
||||
'club_type_' . Club::TYPE_PUBLIC => array( 'type=?', Club::TYPE_PUBLIC ),
|
||||
'club_type_' . Club::TYPE_OPEN => array( 'type=?', Club::TYPE_OPEN ),
|
||||
'club_type_' . Club::TYPE_CLOSED => array( 'type=?', Club::TYPE_CLOSED ),
|
||||
'club_type_' . Club::TYPE_PRIVATE => array( 'type=?', Club::TYPE_PRIVATE ),
|
||||
'club_type_' . Club::TYPE_READONLY => array( 'type=?', Club::TYPE_READONLY )
|
||||
);
|
||||
}
|
||||
$table->rowButtons = function( $row ) {
|
||||
$return = array();
|
||||
if ( !$row['approved'] )
|
||||
{
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_edit' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_edit' ) )
|
||||
{
|
||||
$return['approve'] = array(
|
||||
'title' => 'approve',
|
||||
'icon' => 'check',
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs&do=approve&id={$row['id']}")->csrf()
|
||||
'link' => Url::internal("app=core&module=clubs&controller=clubs&do=approve&id={$row['id']}")->csrf()
|
||||
);
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_delete' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_delete' ) )
|
||||
{
|
||||
$return['delete'] = array(
|
||||
'title' => 'delete',
|
||||
'icon' => 'times',
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs&do=delete&id={$row['id']}"),
|
||||
'data' => \IPS\Db::i()->select( 'COUNT(*)', 'core_clubs_node_map', array( 'club_id=?', $row['id'] ) )->first() ? array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('delete') ) : array( 'delete' => '' )
|
||||
'link' => Url::internal("app=core&module=clubs&controller=clubs&do=delete&id={$row['id']}"),
|
||||
'data' => Db::i()->select( 'COUNT(*)', 'core_clubs_node_map', array( 'club_id=?', $row['id'] ) )->first() ? array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('delete') ) : array( 'delete' => '' )
|
||||
);
|
||||
}
|
||||
}
|
||||
$return['open'] = array(
|
||||
'title' => 'view',
|
||||
'icon' => 'search',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=clubs&controller=view&id={$row['id']}", 'front', 'clubs_view', array( \IPS\Http\Url\Friendly::seoTitle( $row['name'] ) ) ),
|
||||
'link' => Url::internal( "app=core&module=clubs&controller=view&id={$row['id']}", 'front', 'clubs_view', array( Friendly::seoTitle( $row['name'] ) ) ),
|
||||
'target'=> '_blank'
|
||||
);
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_edit' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_edit' ) )
|
||||
{
|
||||
$return['edit'] = array(
|
||||
'title' => 'edit',
|
||||
'icon' => 'pencil',
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs&do=edit&id={$row['id']}")
|
||||
'link' => Url::internal("app=core&module=clubs&controller=clubs&do=edit&id={$row['id']}")
|
||||
);
|
||||
}
|
||||
if ( !isset( $return['delete'] ) and \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_delete' ) )
|
||||
if ( !isset( $return['delete'] ) and Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_delete' ) )
|
||||
{
|
||||
$return['delete'] = array(
|
||||
'title' => 'delete',
|
||||
'icon' => 'times-circle',
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs&do=delete&id={$row['id']}"),
|
||||
'data' => \IPS\Db::i()->select( 'COUNT(*)', 'core_clubs_node_map', array( 'club_id=?', $row['id'] ) )->first() ? array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('delete') ) : array( 'delete' => '' )
|
||||
'link' => Url::internal("app=core&module=clubs&controller=clubs&do=delete&id={$row['id']}"),
|
||||
'data' => Db::i()->select( 'COUNT(*)', 'core_clubs_node_map', array( 'club_id=?', $row['id'] ) )->first() ? array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('delete') ) : array( 'delete' => '' )
|
||||
);
|
||||
}
|
||||
return $return;
|
||||
};
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output = (string) $table;
|
||||
Output::i()->output = (string) $table;
|
||||
}
|
||||
else
|
||||
{
|
||||
$availableTypes = array();
|
||||
foreach ( \IPS\Member\Club::availableNodeTypes( NULL ) as $class )
|
||||
foreach ( Club::availableNodeTypes( NULL ) as $class )
|
||||
{
|
||||
$availableTypes[] = \IPS\Member::loggedIn()->language()->addToStack( $class::clubAcpTitle() );
|
||||
$availableTypes[] = Member::loggedIn()->language()->addToStack( $class::clubAcpTitle() );
|
||||
}
|
||||
|
||||
$availableTypes = \IPS\Member::loggedIn()->language()->formatList( $availableTypes );
|
||||
$availableTypes = Member::loggedIn()->language()->formatList( $availableTypes );
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'clubs' )->disabled( $availableTypes );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'clubs' )->disabled( $availableTypes );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,18 +225,18 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function enable()
|
||||
protected function enable() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'clubs_settings_manage' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Dispatcher::i()->checkAcpPermission( 'clubs_settings_manage' );
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
\IPS\Settings::i()->changeValues( array( 'clubs' => true ) );
|
||||
Settings::i()->changeValues( array( 'clubs' => true ) );
|
||||
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'clubrebuild' ) );
|
||||
Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'clubrebuild' ) );
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__club_settings' );
|
||||
Session::i()->log( 'acplog__club_settings' );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=clubs&controller=clubs') );
|
||||
Output::i()->redirect( Url::internal('app=core&module=clubs&controller=clubs') );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,28 +245,28 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
* @csrfChecked Uses node form() 7 Oct 2019
|
||||
* @return void
|
||||
*/
|
||||
protected function edit()
|
||||
protected function edit() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'clubs_edit' );
|
||||
Dispatcher::i()->checkAcpPermission( 'clubs_edit' );
|
||||
|
||||
/* Load Club */
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( \IPS\Request::i()->id );
|
||||
$club = Club::load( Request::i()->id );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C352/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C352/1', 404, '' );
|
||||
}
|
||||
$editUrl = \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs&do=edit&id={$club->id}");
|
||||
$editUrl = Url::internal("app=core&module=clubs&controller=clubs&do=edit&id={$club->id}");
|
||||
|
||||
/* Tabs */
|
||||
$tabs = array( 'settings' => 'settings' );
|
||||
foreach ( \IPS\Member\Club::availableNodeTypes( \IPS\Member::loggedIn() ) as $class )
|
||||
foreach ( Club::availableNodeTypes( Member::loggedIn() ) as $class )
|
||||
{
|
||||
$tabs[ str_replace( '\\', '-', preg_replace( '/^IPS\\\/', '', $class ) ) ] = $class::clubAcpTitle();
|
||||
}
|
||||
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'settings';
|
||||
$activeTab = ( isset( Request::i()->tab ) and array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'settings';
|
||||
|
||||
/* Settings */
|
||||
if ( $activeTab === 'settings' )
|
||||
@@ -244,16 +284,16 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( !empty( $changes ) )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->decision( 'product_change_blurb', array(
|
||||
'product_change_blurb_existing' => \IPS\Http\Url::internal( "app=core&module=clubs&controller=clubs&do=updateExisting&id={$club->id}" )->setQueryString( 'changes', json_encode( $changes ) )->csrf(),
|
||||
'product_change_blurb_new' => \IPS\Http\Url::internal( "app=core&module=clubs&controller=clubs" ),
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core', 'global' )->decision( 'product_change_blurb', array(
|
||||
'product_change_blurb_existing' => Url::internal( "app=core&module=clubs&controller=clubs&do=updateExisting&id={$club->id}" )->setQueryString( 'changes', json_encode( $changes ) )->csrf(),
|
||||
'product_change_blurb_new' => Url::internal( "app=core&module=clubs&controller=clubs" ),
|
||||
) );
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs"), "saved" );
|
||||
Output::i()->redirect( Url::internal("app=core&module=clubs&controller=clubs"), "saved" );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -265,21 +305,22 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
/* Node List */
|
||||
else
|
||||
{
|
||||
$nodeClass = 'IPS\\' . str_replace( '-', '\\', \IPS\Request::i()->tab );
|
||||
$nodeClass = 'IPS\\' . str_replace( '-', '\\', Request::i()->tab );
|
||||
$this->nodeClass = $nodeClass;
|
||||
$this->club = $club;
|
||||
|
||||
$tree = new \IPS\Helpers\Tree\Tree( $editUrl->setQueryString( 'tab', \IPS\Request::i()->tab ), 'x', array( $this, '_getNodeRows' ), array( $this, '_getNodeRow' ), function() { return NULL; }, function() { return array(); }, function() use( $nodeClass ) {
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_add_nodes' ) )
|
||||
|
||||
/* @var Model $nodeClass */
|
||||
$tree = new Tree( $editUrl->setQueryString( 'tab', Request::i()->tab ), 'x', array( $this, '_getNodeRows' ), array( $this, '_getNodeRow' ), function() { return NULL; }, function() { return array(); }, function() use( $nodeClass ) {
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_add_nodes' ) )
|
||||
{
|
||||
return array(
|
||||
'create' => array(
|
||||
'title' => 'add',
|
||||
'icon' => 'plus',
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs&do=nodeForm&club={$this->club->id}&nodeClass={$nodeClass}" ),
|
||||
'link' => Url::internal("app=core&module=clubs&controller=clubs&do=nodeForm&club={$this->club->id}&nodeClass={$nodeClass}" ),
|
||||
'data' => array(
|
||||
'ipsDialog' => '',
|
||||
'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack( $nodeClass::clubAcpTitle() )
|
||||
'ipsDialog-title' => Member::loggedIn()->language()->addToStack( $nodeClass::clubAcpTitle() )
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -291,14 +332,14 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Output */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $activeTabContents;
|
||||
Output::i()->output = $activeTabContents;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = $club->name;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, $activeTabContents, $editUrl );
|
||||
Output::i()->title = $club->name;
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, $activeTabContents, $editUrl );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,19 +348,19 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function approve()
|
||||
protected function approve() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'clubs_edit' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Dispatcher::i()->checkAcpPermission( 'clubs_edit' );
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
/* Load Club */
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( \IPS\Request::i()->id );
|
||||
$club = Club::load( Request::i()->id );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C352/8', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C352/8', 404, '' );
|
||||
}
|
||||
|
||||
/* Approve */
|
||||
@@ -329,13 +370,13 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
$club->onApprove();
|
||||
|
||||
/* Redirect */
|
||||
$target = \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs");
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'core_clubs', array( 'approved=0 AND id!=?', $club->id ) )->first() )
|
||||
$target = Url::internal("app=core&module=clubs&controller=clubs");
|
||||
if ( Db::i()->select( 'COUNT(*)', 'core_clubs', array( 'approved=0 AND id!=?', $club->id ) )->first() )
|
||||
{
|
||||
$target = $target->setQueryString( 'filter', 'pending_approval' );
|
||||
}
|
||||
\IPS\Session::i()->modLog( 'acplog__club_approved', array( $club->name => FALSE ) );
|
||||
\IPS\Output::i()->redirect( $target, "approved" );
|
||||
Session::i()->modLog( 'acplog__club_approved', array( $club->name => FALSE ) );
|
||||
Output::i()->redirect( $target, "approved" );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,38 +384,38 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function delete()
|
||||
protected function delete() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'clubs_delete' );
|
||||
Dispatcher::i()->checkAcpPermission( 'clubs_delete' );
|
||||
|
||||
/* Load Club */
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( \IPS\Request::i()->id );
|
||||
$club = Club::load( Request::i()->id );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C352/7', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C352/7', 404, '' );
|
||||
}
|
||||
|
||||
/* Ask what to do with each node */
|
||||
$nodes = $club->nodes();
|
||||
if ( \count( $nodes ) )
|
||||
if ( count( $nodes ) )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form', 'delete' );
|
||||
$form = new Form( 'form', 'delete' );
|
||||
$form->addMessage( 'club_delete_blurb' );
|
||||
foreach ( $nodes as $data )
|
||||
{
|
||||
try
|
||||
{
|
||||
$field = new \IPS\Helpers\Form\Node( 'node_' . str_replace( '\\', '-', preg_replace( '/^IPS\\\/', '', $data['node_class'] ) ) . '_' . $data['node_id'], 0, TRUE, array( 'class' => $data['node_class'], 'disabled' => array( $data['node_id'] ), 'disabledLang' => 'node_move_delete', 'zeroVal' => 'node_delete_content', 'subnodes' => FALSE, 'permissionCheck' => function( $node )
|
||||
$field = new Node( 'node_' . str_replace( '\\', '-', preg_replace( '/^IPS\\\/', '', $data['node_class'] ) ) . '_' . $data['node_id'], 0, TRUE, array( 'class' => $data['node_class'], 'disabled' => array( $data['node_id'] ), 'disabledLang' => 'node_move_delete', 'zeroVal' => 'node_delete_content', 'subnodes' => FALSE, 'permissionCheck' => function( $node )
|
||||
{
|
||||
return array_key_exists( 'add', $node->permissionTypes() );
|
||||
}, 'clubs' => TRUE ) );
|
||||
$field->label = htmlspecialchars( $data['name'] );
|
||||
$form->add( $field );
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
catch ( Exception $e ) {}
|
||||
}
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -385,6 +426,7 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
|
||||
try
|
||||
{
|
||||
/* @var Model $nodeClass */
|
||||
$node = $nodeClass::load( $exploded[2] );
|
||||
|
||||
$nodesToQueue = array( $node );
|
||||
@@ -410,35 +452,35 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
$_node->deleteOrMoveFormSubmit( $_values );
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
catch ( Exception $e ) {}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
Request::i()->confirmedDelete();
|
||||
}
|
||||
|
||||
/* Delete it */
|
||||
\IPS\Session::i()->log( 'acplog__club_deleted', array( $club->name => FALSE ) );
|
||||
Session::i()->log( 'acplog__club_deleted', array( $club->name => FALSE ) );
|
||||
$club->delete();
|
||||
\IPS\Db::i()->delete( 'core_clubs_memberships', array( 'club_id=?', $club->id ) );
|
||||
\IPS\Db::i()->delete( 'core_clubs_node_map', array( 'club_id=?', $club->id ) );
|
||||
\IPS\Db::i()->delete( 'core_clubs_fieldvalues', array( 'club_id=?', $club->id ) );
|
||||
Db::i()->delete( 'core_clubs_memberships', array( 'club_id=?', $club->id ) );
|
||||
Db::i()->delete( 'core_clubs_node_map', array( 'club_id=?', $club->id ) );
|
||||
Db::i()->delete( 'core_clubs_fieldvalues', array( 'club_id=?', $club->id ) );
|
||||
|
||||
/* Boink */
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( "OK" );
|
||||
Output::i()->json( "OK" );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal('app=core&module=clubs&controller=clubs'), 'deleted' );
|
||||
Output::i()->redirect( Url::internal('app=core&module=clubs&controller=clubs'), 'deleted' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,59 +489,59 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function nodeForm()
|
||||
protected function nodeForm() : void
|
||||
{
|
||||
/* Load Club */
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( \IPS\Request::i()->club );
|
||||
$club = Club::load( Request::i()->club );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C352/2', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C352/2', 404, '' );
|
||||
}
|
||||
|
||||
/* Load Node */
|
||||
$nodeClass = \IPS\Request::i()->nodeClass;
|
||||
if ( isset( \IPS\Request::i()->nodeId ) )
|
||||
$nodeClass = Request::i()->nodeClass;
|
||||
if ( isset( Request::i()->nodeId ) )
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'clubs_edit_nodes' );
|
||||
Dispatcher::i()->checkAcpPermission( 'clubs_edit_nodes' );
|
||||
|
||||
try
|
||||
{
|
||||
$node = $nodeClass::load( \IPS\Request::i()->nodeId );
|
||||
$node = $nodeClass::load( Request::i()->nodeId );
|
||||
$nodeClub = $node->club();
|
||||
if ( !$nodeClub or $nodeClub->id !== $club->id )
|
||||
{
|
||||
throw new \Exception;
|
||||
throw new Exception;
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C352/3', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C352/3', 404, '' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'clubs_add_nodes' );
|
||||
Dispatcher::i()->checkAcpPermission( 'clubs_add_nodes' );
|
||||
$node = new $nodeClass;
|
||||
}
|
||||
|
||||
/* Build Form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
$node->clubForm( $form, $club );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$node->saveClubForm( $club, $values );
|
||||
\IPS\Session::i()->log( 'acplog__node_edited_club', array( $nodeClass::$nodeTitle => TRUE, $node->titleForLog() => FALSE, $club->name => FALSE ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=clubs&controller=clubs&do=edit&id={$club->id}&tab=" . str_replace( '\\', '-', preg_replace( '/^IPS\\\/', '', $nodeClass ) ) ) );
|
||||
Session::i()->log( 'acplog__node_edited_club', array( $nodeClass::$nodeTitle => TRUE, $node->titleForLog() => FALSE, $club->name => FALSE ) );
|
||||
Output::i()->redirect( Url::internal( "app=core&module=clubs&controller=clubs&do=edit&id={$club->id}&tab=" . str_replace( '\\', '-', preg_replace( '/^IPS\\\/', '', $nodeClass ) ) ) );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = $node->_title;
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->title = $node->_title;
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -507,36 +549,36 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function deleteNode()
|
||||
protected function deleteNode() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'clubs_delete_nodes' );
|
||||
Dispatcher::i()->checkAcpPermission( 'clubs_delete_nodes' );
|
||||
|
||||
/* Load Club */
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( \IPS\Request::i()->club );
|
||||
$club = Club::load( Request::i()->club );
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C352/4', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C352/4', 404, '' );
|
||||
}
|
||||
|
||||
/* Load Node */
|
||||
$nodeClass = \IPS\Request::i()->nodeClass;
|
||||
$nodeClass = Request::i()->nodeClass;
|
||||
try
|
||||
{
|
||||
$node = $nodeClass::load( \IPS\Request::i()->nodeId );
|
||||
$node = $nodeClass::load( Request::i()->nodeId );
|
||||
$nodeClub = $node->club();
|
||||
if ( !$nodeClub or $nodeClub->id !== $club->id )
|
||||
{
|
||||
throw new \Exception;
|
||||
throw new Exception;
|
||||
}
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C352/5', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C352/5', 404, '' );
|
||||
}
|
||||
$targetUrl = \IPS\Http\Url::internal( "app=core&module=clubs&controller=clubs&do=edit&id={$club->id}&tab=" . str_replace( '\\', '-', preg_replace( '/^IPS\\\/', '', $nodeClass ) ) );
|
||||
$targetUrl = Url::internal( "app=core&module=clubs&controller=clubs&do=edit&id={$club->id}&tab=" . str_replace( '\\', '-', preg_replace( '/^IPS\\\/', '', $nodeClass ) ) );
|
||||
|
||||
/* Do we have any children or content? */
|
||||
if ( $node->hasChildren( NULL, NULL, TRUE ) or $node->showDeleteOrMoveForm() )
|
||||
@@ -544,36 +586,36 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
$form = $node->deleteOrMoveForm( FALSE );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_clubs_node_map', array( 'club_id=? AND node_class=? AND node_id=?', $club->id, $nodeClass, $node->_id ) );
|
||||
Db::i()->delete( 'core_clubs_node_map', array( 'club_id=? AND node_class=? AND node_id=?', $club->id, $nodeClass, $node->_id ) );
|
||||
$node->deleteOrMoveFormSubmit( $values );
|
||||
\IPS\Output::i()->redirect( $targetUrl );
|
||||
Output::i()->redirect( $targetUrl );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Show form */
|
||||
\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();
|
||||
}
|
||||
|
||||
/* Delete it */
|
||||
\IPS\Db::i()->delete( 'core_clubs_node_map', array( 'club_id=? AND node_class=? AND node_id=?', $club->id, $nodeClass, $node->_id ) );
|
||||
\IPS\Session::i()->log( 'acplog__node_deleted_club', array( $nodeClass::$nodeTitle => TRUE, $node->titleForLog() => FALSE, $club->name => FALSE ) );
|
||||
Db::i()->delete( 'core_clubs_node_map', array( 'club_id=? AND node_class=? AND node_id=?', $club->id, $nodeClass, $node->_id ) );
|
||||
Session::i()->log( 'acplog__node_deleted_club', array( $nodeClass::$nodeTitle => TRUE, $node->titleForLog() => FALSE, $club->name => FALSE ) );
|
||||
$node->delete();
|
||||
|
||||
/* Boink */
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( "OK" );
|
||||
Output::i()->json( "OK" );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $targetUrl );
|
||||
Output::i()->redirect( $targetUrl );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,8 +624,9 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _getNodeRows()
|
||||
public function _getNodeRows() : array
|
||||
{
|
||||
/* @var Model $nodeClass */
|
||||
$nodeClass = $this->nodeClass;
|
||||
$rows = array();
|
||||
foreach( $nodeClass::roots( NULL, NULL, array( $nodeClass::$databasePrefix . $nodeClass::clubIdColumn() . '=?', $this->club->id ) ) as $node )
|
||||
@@ -602,11 +645,11 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
* @param bool $noSort If TRUE, sort options will be disabled (used for search results)
|
||||
* @return string
|
||||
*/
|
||||
public function _getNodeRow( $id, $root=FALSE, $noSort=FALSE )
|
||||
public function _getNodeRow( mixed $id, bool $root=FALSE, bool $noSort=FALSE ) : string
|
||||
{
|
||||
$nodeClass = $this->nodeClass;
|
||||
|
||||
if ( $id instanceof \IPS\Node\Model )
|
||||
if ( $id instanceof Model )
|
||||
{
|
||||
$node = $id;
|
||||
}
|
||||
@@ -614,11 +657,12 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
/* @var Model $nodeClass */
|
||||
$node = $nodeClass::load( $id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C352/6', 404, '' );
|
||||
Output::i()->error( 'node_error', '2C352/6', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,29 +675,29 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
'target'=> '_blank',
|
||||
)
|
||||
);
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_edit_nodes' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_edit_nodes' ) )
|
||||
{
|
||||
$buttons['edit'] = array(
|
||||
'title' => 'edit',
|
||||
'icon' => 'pencil',
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs&do=nodeForm&club={$this->club->id}&nodeClass={$nodeClass}&nodeId={$node->_id}"),
|
||||
'link' => Url::internal("app=core&module=clubs&controller=clubs&do=nodeForm&club={$this->club->id}&nodeClass={$nodeClass}&nodeId={$node->_id}"),
|
||||
'data' => array(
|
||||
'ipsDialog' => '',
|
||||
'ipsDialog-title' => $node->_title
|
||||
)
|
||||
);
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_delete_nodes' ) )
|
||||
if ( Member::loggedIn()->hasAcpRestriction( 'core', 'clubs', 'clubs_delete_nodes' ) )
|
||||
{
|
||||
$buttons['delete'] = array(
|
||||
'title' => 'delete',
|
||||
'icon' => 'times-circle',
|
||||
'link' => \IPS\Http\Url::internal("app=core&module=clubs&controller=clubs&do=deleteNode&club={$this->club->id}&nodeClass={$nodeClass}&nodeId={$node->_id}"),
|
||||
'link' => Url::internal("app=core&module=clubs&controller=clubs&do=deleteNode&club={$this->club->id}&nodeClass={$nodeClass}&nodeId={$node->_id}"),
|
||||
'data' => ( $node->hasChildren( NULL, NULL, TRUE ) or $node->showDeleteOrMoveForm() ) ? array( 'ipsDialog' => '', 'ipsDialog-title' => $node->_title ) : array( 'delete' => '' ),
|
||||
);
|
||||
}
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'trees', 'core' )->row(
|
||||
return Theme::i()->getTemplate( 'trees', 'core' )->row(
|
||||
NULL,
|
||||
$node->_id,
|
||||
$node->_title,
|
||||
@@ -668,23 +712,23 @@ class _clubs extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function updateExisting()
|
||||
public function updateExisting() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
try
|
||||
{
|
||||
$club = \IPS\Member\Club::load( \IPS\Request::i()->id );
|
||||
$club = Club::load( Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '3C352/8', 403, '' );
|
||||
Output::i()->error( 'no_module_permission', '3C352/8', 403, '' );
|
||||
}
|
||||
|
||||
$changes = json_decode( \IPS\Request::i()->changes, TRUE );
|
||||
$changes = json_decode( Request::i()->changes, TRUE );
|
||||
|
||||
\IPS\Task::queue( 'core', 'UpdateClubRenewals', array( 'changes' => $changes, 'club' => $club->id ), 5 );
|
||||
Task::queue( 'core', 'UpdateClubRenewals', array( 'changes' => $changes, 'club' => $club->id ), 5 );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=clubs&controller=clubs" ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( "app=core&module=clubs&controller=clubs" ), 'saved' );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user