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,16 +11,44 @@
|
||||
namespace IPS\core\modules\front\clubs;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use IPS\Application;
|
||||
use IPS\Content\Search\Query;
|
||||
use IPS\core\Stream;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Club;
|
||||
use IPS\Member\Club\CustomField;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function floatval;
|
||||
use function in_array;
|
||||
use function intval;
|
||||
|
||||
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 List
|
||||
*/
|
||||
class _directory extends \IPS\Dispatcher\Controller
|
||||
class directory extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -30,7 +58,7 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
'community_area' => array( 'value' => 'search', 'odkUpdate' => 'true' )
|
||||
* )
|
||||
*/
|
||||
public static $dataLayerContext = array(
|
||||
public static array $dataLayerContext = array(
|
||||
'community_area' => [ 'value' => 'clubs', 'odkUpdate' => 'true']
|
||||
);
|
||||
|
||||
@@ -39,26 +67,22 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
/* Permission check */
|
||||
if ( !\IPS\Settings::i()->clubs )
|
||||
if ( !Settings::i()->clubs )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2C349/2', 403, '' );
|
||||
Output::i()->error( 'no_module_permission', '2C349/2', 403, '' );
|
||||
}
|
||||
|
||||
/* CSS */
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/clubs.css', 'core', 'front' ) );
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/clubs_responsive.css', 'core', 'front' ) );
|
||||
}
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'styles/clubs.css', 'core', 'front' ) );
|
||||
|
||||
/* JS */
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_clubs.js', 'core', 'front' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_clubs.js', 'core', 'front' ) );
|
||||
|
||||
/* Location for online list */
|
||||
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), array(), 'loc_clubs_directory' );
|
||||
Session::i()->setLocation( Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), array(), 'loc_clubs_directory' );
|
||||
|
||||
/* Pass up */
|
||||
parent::execute();
|
||||
@@ -69,33 +93,33 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$baseUrl = \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' );
|
||||
$baseUrl = Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' );
|
||||
|
||||
/* Display */
|
||||
$view = \IPS\Settings::i()->clubs_default_view;
|
||||
if ( \IPS\Settings::i()->clubs_allow_view_change )
|
||||
$view = Settings::i()->clubs_default_view;
|
||||
if ( Settings::i()->clubs_allow_view_change )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->view ) and \in_array( \IPS\Request::i()->view, array( 'grid', 'list' ) ) )
|
||||
if ( isset( Request::i()->view ) and in_array( Request::i()->view, array( 'grid', 'list' ) ) )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Request::i()->setCookie( 'clubs_view', \IPS\Request::i()->view, \IPS\DateTime::create()->add( new \DateInterval('P1Y' ) ) );
|
||||
$view = \IPS\Request::i()->view;
|
||||
Session::i()->csrfCheck();
|
||||
Request::i()->setCookie( 'clubs_view', Request::i()->view, DateTime::create()->add( new DateInterval('P1Y' ) ) );
|
||||
$view = Request::i()->view;
|
||||
|
||||
\IPS\Output::i()->redirect( $baseUrl );
|
||||
Output::i()->redirect( $baseUrl );
|
||||
}
|
||||
elseif ( isset( \IPS\Request::i()->cookie['clubs_view'] ) and \in_array( \IPS\Request::i()->cookie['clubs_view'], array( 'grid', 'list' ) ) )
|
||||
elseif ( isset( Request::i()->cookie['clubs_view'] ) and in_array( Request::i()->cookie['clubs_view'], array( 'grid', 'list' ) ) )
|
||||
{
|
||||
$view = \IPS\Request::i()->cookie['clubs_view'];
|
||||
$view = Request::i()->cookie['clubs_view'];
|
||||
}
|
||||
}
|
||||
|
||||
/* All Clubs: Sort */
|
||||
$sortOption = \IPS\Settings::i()->clubs_default_sort;
|
||||
if ( isset( \IPS\Request::i()->sort ) and \in_array( \IPS\Request::i()->sort, array( 'last_activity', 'members', 'content', 'created', 'name' ) ) )
|
||||
$sortOption = Settings::i()->clubs_default_sort;
|
||||
if ( isset( Request::i()->sort ) and in_array( Request::i()->sort, array( 'last_activity', 'members', 'content', 'created', 'name' ) ) )
|
||||
{
|
||||
$sortOption = \IPS\Request::i()->sort;
|
||||
$sortOption = Request::i()->sort;
|
||||
|
||||
$baseUrl = $baseUrl->setQueryString( 'sort', $sortOption );
|
||||
}
|
||||
@@ -104,16 +128,16 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
$filters = array();
|
||||
$mineOnly = FALSE;
|
||||
$extraWhere = NULL;
|
||||
if ( isset( \IPS\Request::i()->filter ) and \IPS\Request::i()->filter === 'mine' AND \IPS\Member::loggedIn()->member_id )
|
||||
if ( isset( Request::i()->filter ) and Request::i()->filter === 'mine' AND Member::loggedIn()->member_id )
|
||||
{
|
||||
$mineOnly = TRUE;
|
||||
$baseUrl = $baseUrl->setQueryString( 'filter', 'mine' );
|
||||
}
|
||||
if ( isset( \IPS\Request::i()->type ) and \in_array( \IPS\Request::i()->type, array( 'free', 'paid' ) ) )
|
||||
if ( isset( Request::i()->type ) and in_array( Request::i()->type, array( 'free', 'paid' ) ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'type', \IPS\Request::i()->type );
|
||||
$baseUrl = $baseUrl->setQueryString( 'type', Request::i()->type );
|
||||
|
||||
if ( \IPS\Request::i()->type === 'free' )
|
||||
if ( Request::i()->type === 'free' )
|
||||
{
|
||||
$extraWhere[] = array( 'fee IS NULL' );
|
||||
}
|
||||
@@ -122,19 +146,19 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
$extraWhere[] = array( 'fee IS NOT NULL' );
|
||||
}
|
||||
}
|
||||
foreach ( \IPS\Member\Club\CustomField::fields() as $field )
|
||||
foreach ( CustomField::fields() as $field )
|
||||
{
|
||||
$k = "f{$field->id}";
|
||||
if ( $field->filterable and isset( \IPS\Request::i()->$k ) )
|
||||
if ( $field->filterable and isset( Request::i()->$k ) )
|
||||
{
|
||||
switch ( $field->type )
|
||||
{
|
||||
case 'Checkbox':
|
||||
case 'YesNo':
|
||||
if ( \in_array( \IPS\Request::i()->$k, array( 0, 1 ) ) )
|
||||
if ( in_array( Request::i()->$k, array( 0, 1 ) ) )
|
||||
{
|
||||
$filters[ $field->id ] = \IPS\Request::i()->$k;
|
||||
$baseUrl = $baseUrl->setQueryString( 'f' . $field->id, \IPS\Request::i()->$k );
|
||||
$filters[ $field->id ] = Request::i()->$k;
|
||||
$baseUrl = $baseUrl->setQueryString( 'f' . $field->id, Request::i()->$k );
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -142,7 +166,7 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
case 'Radio':
|
||||
case 'Select':
|
||||
$options = json_decode( $field->extra, TRUE );
|
||||
foreach ( \IPS\Request::i()->$k as $id )
|
||||
foreach ( Request::i()->$k as $id )
|
||||
{
|
||||
if ( isset( $options[ $id ] ) )
|
||||
{
|
||||
@@ -167,28 +191,28 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Get Featured Clubs */
|
||||
$featuredClubs = \IPS\Member\Club::clubs( \IPS\Member::loggedIn(), NULL, 'RAND()', FALSE, array(), 'featured=1' );
|
||||
$featuredClubs = Club::clubs( Member::loggedIn(), NULL, 'RAND()', FALSE, array(), 'featured=1' );
|
||||
|
||||
/* Get All Clubs */
|
||||
$perPage = 24;
|
||||
$page = isset( \IPS\Request::i()->page ) ? \intval( \IPS\Request::i()->page ) : 1;
|
||||
$page = isset( Request::i()->page ) ? intval( Request::i()->page ) : 1;
|
||||
if( $page < 1 )
|
||||
{
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$clubsCount = \IPS\Member\Club::clubs( \IPS\Member::loggedIn(), array( ( $page - 1 ) * $perPage, $perPage ), $sortOption, $mineOnly, $filters, $extraWhere, TRUE );
|
||||
$allClubs = \IPS\Member\Club::clubs( \IPS\Member::loggedIn(), array( ( $page - 1 ) * $perPage, $perPage ), $sortOption, $mineOnly, $filters, $extraWhere );
|
||||
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl, ceil( $clubsCount / $perPage ), $page, $perPage );
|
||||
$clubsCount = Club::clubs( Member::loggedIn(), array( ( $page - 1 ) * $perPage, $perPage ), $sortOption, $mineOnly, $filters, $extraWhere, TRUE );
|
||||
$allClubs = Club::clubs( Member::loggedIn(), array( ( $page - 1 ) * $perPage, $perPage ), $sortOption, $mineOnly, $filters, $extraWhere );
|
||||
$pagination = Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl, ceil( $clubsCount / $perPage ), $page, $perPage );
|
||||
|
||||
/* Get my clubs and invites */
|
||||
$myClubsActivity = NULL;
|
||||
$myClubsInvites = NULL;
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
if ( Member::loggedIn()->member_id )
|
||||
{
|
||||
$myClubsActivity = new \IPS\core\Stream;
|
||||
$myClubsActivity = $myClubsActivity->query()->filterByClub( \IPS\Member::loggedIn()->clubs() )->setLimit(6)->setOrder( \IPS\Content\Search\Query::ORDER_NEWEST_UPDATED )->search();
|
||||
$myClubsInvites = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_clubs_memberships', array( 'member_id=? and ( status=? or status=? )', \IPS\Member::loggedIn()->member_id, \IPS\Member\Club::STATUS_REQUESTED, \IPS\Member\Club::STATUS_INVITED )
|
||||
$myClubsActivity = new Stream;
|
||||
$myClubsActivity = $myClubsActivity->query()->filterByClub( Member::loggedIn()->clubs() )->setLimit(6)->setOrder( Query::ORDER_NEWEST_UPDATED )->search();
|
||||
$myClubsInvites = new ActiveRecordIterator( Db::i()->select( '*', 'core_clubs_memberships', array( 'member_id=? and ( status=? or status=? )', Member::loggedIn()->member_id, Club::STATUS_REQUESTED, Club::STATUS_INVITED )
|
||||
)->join(
|
||||
'core_clubs',
|
||||
"core_clubs_memberships.club_id=core_clubs.id"
|
||||
@@ -197,62 +221,62 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Build Map */
|
||||
$mapMarkers = NULL;
|
||||
if ( \IPS\GeoLocation::enabled() )
|
||||
if ( GeoLocation::enabled() )
|
||||
{
|
||||
$mapMarkers = array();
|
||||
|
||||
$where = array( array( 'location_lat IS NOT NULL' ) );
|
||||
if ( !\IPS\Member::loggedIn()->member_id )
|
||||
if ( !Member::loggedIn()->member_id )
|
||||
{
|
||||
$where[] = array( "type<>?", \IPS\Member\Club::TYPE_PRIVATE );
|
||||
$where[] = array( "type<>?", Club::TYPE_PRIVATE );
|
||||
}
|
||||
elseif ( !\IPS\Member::loggedIn()->modPermission('can_access_all_clubs') )
|
||||
elseif ( !Member::loggedIn()->modPermission('can_access_all_clubs') )
|
||||
{
|
||||
$where[] = array( "( type<>? OR status IN('" . \IPS\Member\Club::STATUS_MEMBER . "','" . \IPS\Member\Club::STATUS_MODERATOR . "','" . \IPS\Member\Club::STATUS_LEADER . "','" . \IPS\Member\Club::STATUS_EXPIRED . "','" . \IPS\Member\Club::STATUS_EXPIRED_MODERATOR . "') )", \IPS\Member\Club::TYPE_PRIVATE );
|
||||
$where[] = array( "( type<>? OR status IN('" . Club::STATUS_MEMBER . "','" . Club::STATUS_MODERATOR . "','" . Club::STATUS_LEADER . "','" . Club::STATUS_EXPIRED . "','" . Club::STATUS_EXPIRED_MODERATOR . "') )", Club::TYPE_PRIVATE );
|
||||
}
|
||||
|
||||
$select = \IPS\Db::i()->select( array( 'id', 'name', 'location_lat', 'location_long' ), 'core_clubs', $where );
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
$select = Db::i()->select( array( 'id', 'name', 'location_lat', 'location_long' ), 'core_clubs', $where );
|
||||
if ( Member::loggedIn()->member_id )
|
||||
{
|
||||
$select->join( 'core_clubs_memberships', array( 'club_id=id AND member_id=?', \IPS\Member::loggedIn()->member_id ) );
|
||||
$select->join( 'core_clubs_memberships', array( 'club_id=id AND member_id=?', Member::loggedIn()->member_id ) );
|
||||
}
|
||||
|
||||
foreach ( $select as $club )
|
||||
{
|
||||
$mapMarkers[ $club['id'] ] = array(
|
||||
'lat' => \floatval( $club['location_lat'] ),
|
||||
'long' => \floatval( $club['location_long'] ),
|
||||
'lat' => floatval( $club['location_lat'] ),
|
||||
'long' => floatval( $club['location_long'] ),
|
||||
'title' => $club['name']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
if ( Member::loggedIn()->member_id )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate('clubs')->myClubsSidebar( \IPS\Member\Club::clubs( \IPS\Member::loggedIn(), 10, 'last_activity', TRUE ), $myClubsActivity, $myClubsInvites );
|
||||
Output::i()->sidebar['contextual'] = Theme::i()->getTemplate('clubs')->myClubsSidebar( Club::clubs( Member::loggedIn(), 10, 'last_activity', TRUE ), $myClubsActivity, $myClubsInvites );
|
||||
|
||||
/* Prime the cache */
|
||||
$allClubs = iterator_to_array( $allClubs );
|
||||
|
||||
if( \count( $allClubs ) )
|
||||
if( count( $allClubs ) )
|
||||
{
|
||||
foreach( $allClubs as $clubId => $clubData )
|
||||
{
|
||||
if( !isset( $allClubs[ $clubId ]->memberStatuses[ \IPS\Member::loggedIn()->member_id ] ) )
|
||||
if( !isset( $clubData->memberStatuses[ Member::loggedIn()->member_id ] ) )
|
||||
{
|
||||
$allClubs[ $clubId ]->memberStatuses[ \IPS\Member::loggedIn()->member_id ] = NULL;
|
||||
$clubData->memberStatuses[ Member::loggedIn()->member_id ] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_clubs_memberships', array( 'member_id=? AND ' . \IPS\Db::i()->in( 'club_id', array_keys( $allClubs ) ), \IPS\Member::loggedIn()->member_id ) ) as $clubMembership )
|
||||
foreach( Db::i()->select( '*', 'core_clubs_memberships', array( 'member_id=? AND ' . Db::i()->in( 'club_id', array_keys( $allClubs ) ), Member::loggedIn()->member_id ) ) as $clubMembership )
|
||||
{
|
||||
$allClubs[ $clubMembership['club_id'] ]->memberStatuses[ \IPS\Member::loggedIn()->member_id ] = $clubMembership['status'];
|
||||
$allClubs[ $clubMembership['club_id'] ]->memberStatuses[ Member::loggedIn()->member_id ] = $clubMembership['status'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clubs')->directory( $featuredClubs, $allClubs, $pagination, $baseUrl, $sortOption, $myClubsActivity, $mapMarkers, $view, $mineOnly );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('module__core_clubs');
|
||||
Output::i()->output = Theme::i()->getTemplate('clubs')->directory( $featuredClubs, $allClubs, $pagination, $baseUrl, $sortOption, $myClubsActivity, $mapMarkers, $view, $mineOnly );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -260,23 +284,23 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function filters()
|
||||
protected function filters() : void
|
||||
{
|
||||
$fields = \IPS\Member\Club\CustomField::roots();
|
||||
$fields = CustomField::roots();
|
||||
|
||||
$form = new \IPS\Helpers\Form('filter', 'filter');
|
||||
$form = new Form('filter', 'filter');
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
if ( Member::loggedIn()->member_id )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'club_filter_type', isset( \IPS\Request::i()->filter ) ? \IPS\Request::i()->filter : 'all', TRUE, array( 'options' => array(
|
||||
$form->add( new Radio( 'club_filter_type', isset( Request::i()->filter ) ? Request::i()->filter : 'all', TRUE, array( 'options' => array(
|
||||
'all' => 'all_clubs',
|
||||
'mine' => 'my_clubs'
|
||||
) ) ) );
|
||||
}
|
||||
|
||||
if ( \IPS\Application::appIsEnabled( 'nexus' ) and \IPS\Settings::i()->clubs_paid_on )
|
||||
if ( Application::appIsEnabled( 'nexus' ) and Settings::i()->clubs_paid_on )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'club_membership_fee', isset( \IPS\Request::i()->type ) ? \IPS\Request::i()->type : 'all', TRUE, array( 'options' => array(
|
||||
$form->add( new Radio( 'club_membership_fee', isset( Request::i()->type ) ? Request::i()->type : 'all', TRUE, array( 'options' => array(
|
||||
'all' => 'all_clubs',
|
||||
'free' => 'club_membership_free',
|
||||
'paid' => 'club_membership_paid'
|
||||
@@ -292,7 +316,7 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
case 'Checkbox':
|
||||
case 'YesNo':
|
||||
$input = new \IPS\Helpers\Form\CheckboxSet( 'field_' . $field->id, isset( \IPS\Request::i()->$k ) ? \IPS\Request::i()->$k : array( 1, 0 ), FALSE, array( 'options' => array(
|
||||
$input = new CheckboxSet( 'field_' . $field->id, isset( Request::i()->$k ) ? Request::i()->$k : array( 1, 0 ), FALSE, array( 'options' => array(
|
||||
1 => 'yes',
|
||||
0 => 'no',
|
||||
) ) );
|
||||
@@ -304,7 +328,7 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
case 'Radio':
|
||||
case 'Select':
|
||||
$options = json_decode( $field->extra, TRUE );
|
||||
$input = new \IPS\Helpers\Form\CheckboxSet( 'field_' . $field->id, isset( \IPS\Request::i()->$k ) ? \IPS\Request::i()->$k : array_keys( $options ), FALSE, array( 'options' => $options ) );
|
||||
$input = new CheckboxSet( 'field_' . $field->id, isset( Request::i()->$k ) ? Request::i()->$k : array_keys( $options ), FALSE, array( 'options' => $options ) );
|
||||
$input->label = $field->_title;
|
||||
$form->add( $input );
|
||||
break;
|
||||
@@ -314,14 +338,14 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$url = \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' );
|
||||
$url = Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' );
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id and $values['club_filter_type'] === 'mine' )
|
||||
if ( Member::loggedIn()->member_id and $values['club_filter_type'] === 'mine' )
|
||||
{
|
||||
$url = $url->setQueryString( 'filter', 'mine' );
|
||||
}
|
||||
|
||||
if ( \IPS\Application::appIsEnabled( 'nexus' ) and \IPS\Settings::i()->clubs_paid_on and $values['club_membership_fee'] !== 'all' )
|
||||
if ( Application::appIsEnabled( 'nexus' ) and Settings::i()->clubs_paid_on and $values['club_membership_fee'] !== 'all' )
|
||||
{
|
||||
$url = $url->setQueryString( 'type', $values['club_membership_fee'] );
|
||||
}
|
||||
@@ -334,7 +358,7 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
case 'Checkbox':
|
||||
case 'YesNo':
|
||||
if ( \count( $values[ 'field_' . $field->id ] ) === 1 )
|
||||
if ( count( $values[ 'field_' . $field->id ] ) === 1 )
|
||||
{
|
||||
$url = $url->setQueryString( 'f' . $field->id, array_pop( $values[ 'field_' . $field->id ] ) );
|
||||
}
|
||||
@@ -344,7 +368,7 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
case 'Radio':
|
||||
case 'Select':
|
||||
$options = json_decode( $field->extra, TRUE );
|
||||
if ( \count( $values[ 'field_' . $field->id ] ) > 0 and \count( $values[ 'field_' . $field->id ] ) < \count( $options ) )
|
||||
if ( count( $values[ 'field_' . $field->id ] ) > 0 and count( $values[ 'field_' . $field->id ] ) < count( $options ) )
|
||||
{
|
||||
$url = $url->setQueryString( 'f' . $field->id, $values[ 'field_' . $field->id ] );
|
||||
}
|
||||
@@ -353,16 +377,16 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
Output::i()->redirect( $url );
|
||||
}
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
Output::i()->output = $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,12 +395,12 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function create()
|
||||
protected function create() : void
|
||||
{
|
||||
$availableTypes = array();
|
||||
if ( \IPS\Member::loggedIn()->member_id ) // Guests can't create any type of clubs
|
||||
if ( Member::loggedIn()->member_id ) // Guests can't create any type of clubs
|
||||
{
|
||||
foreach ( explode( ',', \IPS\Member::loggedIn()->group['g_create_clubs'] ) as $type )
|
||||
foreach ( explode( ',', Member::loggedIn()->group['g_create_clubs'] ) as $type )
|
||||
{
|
||||
if ( $type !== '' )
|
||||
{
|
||||
@@ -386,32 +410,32 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
if ( !$availableTypes )
|
||||
{
|
||||
\IPS\Output::i()->error( \IPS\Member::loggedIn()->member_id ? 'no_module_permission' : 'no_module_permission_guest', '2C349/1', 403, '' );
|
||||
Output::i()->error( Member::loggedIn()->member_id ? 'no_module_permission' : 'no_module_permission_guest', '2C349/1', 403, '' );
|
||||
}
|
||||
|
||||
if ( \IPS\Member::loggedIn()->group['g_club_limit'] )
|
||||
if ( Member::loggedIn()->group['g_club_limit'] )
|
||||
{
|
||||
if ( \IPS\Db::i()->select( 'COUNT(*)', 'core_clubs', array( 'owner=?', \IPS\Member::loggedIn()->member_id ) )->first() >= \IPS\Member::loggedIn()->group['g_club_limit'] )
|
||||
if ( Db::i()->select( 'COUNT(*)', 'core_clubs', array( 'owner=?', Member::loggedIn()->member_id ) )->first() >= Member::loggedIn()->group['g_club_limit'] )
|
||||
{
|
||||
\IPS\Output::i()->error( \IPS\Member::loggedIn()->language()->addToStack( 'too_many_clubs', FALSE, array( 'pluralize' => array( \IPS\Member::loggedIn()->group['g_club_limit'] ) ) ), '2C349/3', 403, '' );
|
||||
Output::i()->error( Member::loggedIn()->language()->addToStack( 'too_many_clubs', FALSE, array( 'pluralize' => array( Member::loggedIn()->group['g_club_limit'] ) ) ), '2C349/3', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
$club = new \IPS\Member\Club;
|
||||
$club = new Club;
|
||||
if ( $form = $club->form( FALSE, TRUE, $availableTypes ) )
|
||||
{
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
$club->processForm( $values, FALSE, TRUE, $availableTypes );
|
||||
|
||||
\IPS\Output::i()->redirect( $club->url() );
|
||||
Output::i()->redirect( $club->url() );
|
||||
}
|
||||
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->class = 'ipsForm--vertical ipsForm--clubs-directory';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !$club->approved and \IPS\Member::loggedIn()->modPermission('can_access_all_clubs') )
|
||||
if ( !$club->approved and Member::loggedIn()->modPermission('can_access_all_clubs') )
|
||||
{
|
||||
$club->approved = TRUE;
|
||||
$club->save();
|
||||
@@ -419,20 +443,20 @@ class _directory extends \IPS\Dispatcher\Controller
|
||||
|
||||
if( $club->approved )
|
||||
{
|
||||
\IPS\Member::loggedIn()->achievementAction( 'core', 'NewClub', $club );
|
||||
Member::loggedIn()->achievementAction( 'core', 'NewClub', $club );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $club->url() );
|
||||
Output::i()->redirect( $club->url() );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('create_club');
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('create_club');
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
Output::i()->output = $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'clubs' )->create( $form );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'clubs' )->create( $form );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,27 +12,44 @@
|
||||
namespace IPS\core\modules\front\clubs;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\File;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Club;
|
||||
use IPS\Member\Club\Page as ClubPage;
|
||||
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' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* page
|
||||
*/
|
||||
class _page extends \IPS\Dispatcher\Controller
|
||||
class page extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Page
|
||||
*/
|
||||
protected $page;
|
||||
protected ?ClubPage $page = null;
|
||||
|
||||
/**
|
||||
* @brief These properties are used to specify datalayer context properties.
|
||||
*
|
||||
*/
|
||||
public static $dataLayerContext = array(
|
||||
public static array $dataLayerContext = array(
|
||||
'community_area' => [ 'value' => 'clubs', 'odkUpdate' => 'true']
|
||||
);
|
||||
|
||||
@@ -41,41 +58,41 @@ class _page extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->page = \IPS\Member\Club\Page::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
$this->page = ClubPage::loadAndCheckPerms( Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S410/4', 404, '' );
|
||||
Output::i()->error( 'node_error', '2S410/4', 404, '' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sidebar['contextual'] = '';
|
||||
Output::i()->sidebar['contextual'] = '';
|
||||
|
||||
/* Club info in sidebar */
|
||||
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
|
||||
if ( Settings::i()->clubs_header == 'sidebar' )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['contextual'] .= \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $this->page->club, NULL, 'sidebar', $this->page );
|
||||
Output::i()->sidebar['contextual'] .= Theme::i()->getTemplate( 'clubs', 'core' )->header( $this->page->club, NULL, 'sidebar', $this->page );
|
||||
}
|
||||
|
||||
if( ( \IPS\GeoLocation::enabled() and \IPS\Settings::i()->clubs_locations AND $location = $this->page->club->location() ) )
|
||||
if( ( GeoLocation::enabled() and Settings::i()->clubs_locations AND $location = $this->page->club->location() ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['contextual'] .= \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->clubLocationBox( $this->page->club, $location );
|
||||
Output::i()->sidebar['contextual'] .= Theme::i()->getTemplate( 'clubs', 'core' )->clubLocationBox( $this->page->club, $location );
|
||||
}
|
||||
|
||||
if( $this->page->club->type != \IPS\Member\Club::TYPE_PUBLIC AND $this->page->club->canViewMembers() )
|
||||
if( $this->page->club->type != Club::TYPE_PUBLIC AND $this->page->club->canViewMembers() )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['contextual'] .= \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->clubMemberBox( $this->page->club );
|
||||
Output::i()->sidebar['contextual'] .= Theme::i()->getTemplate( 'clubs', 'core' )->clubMemberBox( $this->page->club );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->breadcrumb[] = array( $this->page->club->url(), $this->page->club->name );
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, $this->page->title );
|
||||
Output::i()->breadcrumb[] = array( $this->page->club->url(), $this->page->club->name );
|
||||
Output::i()->breadcrumb[] = array( NULL, $this->page->title );
|
||||
|
||||
if( !$this->page->meta_index )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['robots'] = 'noindex';
|
||||
Output::i()->metaTags['robots'] = 'noindex';
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
@@ -86,15 +103,15 @@ class _page extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
if ( !$this->page->club->rulesAcknowledged() )
|
||||
{
|
||||
\IPS\Http\Url::internal( $this->page->club->url()->setQueryString( 'do', 'rules' ) );
|
||||
Url::internal( $this->page->club->url()->setQueryString( 'do', 'rules' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = $this->page->title;
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'clubs' )->viewPage( $this->page );
|
||||
Output::i()->title = $this->page->title;
|
||||
Output::i()->output = Theme::i()->getTemplate( 'clubs' )->viewPage( $this->page );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,17 +119,17 @@ class _page extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function edit()
|
||||
public function edit() : void
|
||||
{
|
||||
if( !$this->page->canEdit() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_noperm_edit', '2S410/1', 403, '' );
|
||||
Output::i()->error( 'node_noperm_edit', '2S410/1', 403, '' );
|
||||
}
|
||||
|
||||
/* Init form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class = 'ipsForm_vertical';
|
||||
\IPS\Member\Club\Page::form( $form, $this->page->club, $this->page );
|
||||
$form = new Form;
|
||||
$form->class = 'ipsForm--vertical ipsForm--edit-club-page';
|
||||
ClubPage::form( $form, $this->page->club, $this->page );
|
||||
|
||||
/* Form Submission */
|
||||
if ( $values = $form->values() )
|
||||
@@ -120,20 +137,20 @@ class _page extends \IPS\Dispatcher\Controller
|
||||
$this->page->formatFormValues( $values );
|
||||
$this->page->save();
|
||||
|
||||
\IPS\File::claimAttachments( "club-page-{$this->page->id}", $this->page->id );
|
||||
File::claimAttachments( "club-page-{$this->page->id}", $this->page->id );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( 'OK' );
|
||||
Output::i()->json( 'OK' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $this->page->url() );
|
||||
Output::i()->redirect( $this->page->url() );
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( "edit" );
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( "edit" );
|
||||
Output::i()->output = $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,17 +158,17 @@ class _page extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
if( !$this->page->canDelete() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_noperm_delete', '2S410/2', 403, '' );
|
||||
Output::i()->error( 'node_noperm_delete', '2S410/2', 403, '' );
|
||||
}
|
||||
|
||||
$this->page->delete();
|
||||
|
||||
\IPS\Output::i()->redirect( $this->page->club->url(), 'deleted' );
|
||||
Output::i()->redirect( $this->page->club->url(), 'deleted' );
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user