Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -13,6 +13,7 @@ namespace IPS\core\modules\front\clubs;
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use DateInterval;
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
use IPS\Content\Search\Query;
|
||||
use IPS\core\Stream;
|
||||
@@ -21,6 +22,7 @@ use IPS\Db;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Address;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Text;
|
||||
@@ -118,14 +120,19 @@ class directory extends Controller
|
||||
|
||||
/* All Clubs: Sort */
|
||||
$sortOption = Settings::i()->clubs_default_sort;
|
||||
if ( isset( Request::i()->sort ) and in_array( Request::i()->sort, array( 'last_activity', 'members', 'content', 'created', 'name' ) ) )
|
||||
$allSortOptions = array( 'last_activity', 'members', 'content', 'created', 'name' );
|
||||
if( Settings::i()->clubs_locations and GeoLocation::enabled() )
|
||||
{
|
||||
$allSortOptions[] = 'distance';
|
||||
}
|
||||
if ( isset( Request::i()->sort ) and in_array( Request::i()->sort, $allSortOptions ) )
|
||||
{
|
||||
$sortOption = Request::i()->sort;
|
||||
|
||||
$baseUrl = $baseUrl->setQueryString( 'sort', $sortOption );
|
||||
}
|
||||
|
||||
/* All Clubs: Filters */
|
||||
|
||||
/* All Clubs: Filters */
|
||||
$filters = array();
|
||||
$mineOnly = FALSE;
|
||||
$extraWhere = [];
|
||||
@@ -139,6 +146,36 @@ class directory extends Controller
|
||||
$mineOnly = TRUE;
|
||||
$baseUrl = $baseUrl->setQueryString( 'filter', 'mine' );
|
||||
}
|
||||
|
||||
/* Are we sorting by location? */
|
||||
$location = null;
|
||||
if( ( $sortOption == 'distance' or ( isset( Request::i()->location ) and Request::i()->location ) ) and Settings::i()->clubs_locations )
|
||||
{
|
||||
if( isset( Request::i()->location ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'location', Request::i()->location );
|
||||
$geo = explode( ",", Request::i()->location );
|
||||
$location = array( 'lat' => $geo[0], 'lon' => $geo[1] );
|
||||
|
||||
/* If we are filtering by location, we can leave out clubs with no location */
|
||||
$extraWhere[] = [ 'location_lat is not null AND location_long is not null' ];
|
||||
}
|
||||
elseif( GeoLocation::enabled() )
|
||||
{
|
||||
/* Do an IP lookup */
|
||||
try
|
||||
{
|
||||
$geo = GeoLocation::getRequesterLocation();
|
||||
$location = array( 'lat' => $geo->lat, 'lon' => $geo->long );
|
||||
}
|
||||
catch ( Exception $e )
|
||||
{
|
||||
$location = array( 'lat' => Settings::i()->map_center_lat, 'lon' => Settings::i()->map_center_lon );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( isset( Request::i()->type ) and in_array( Request::i()->type, array( 'free', 'paid' ) ) )
|
||||
{
|
||||
$baseUrl = $baseUrl->setQueryString( 'type', Request::i()->type );
|
||||
@@ -207,8 +244,8 @@ class directory extends Controller
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$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 );
|
||||
$clubsCount = Club::clubs( Member::loggedIn(), array( ( $page - 1 ) * $perPage, $perPage ), $sortOption, $mineOnly, $filters, $extraWhere, TRUE, $location );
|
||||
$allClubs = iterator_to_array( Club::clubs( Member::loggedIn(), array( ( $page - 1 ) * $perPage, $perPage ), $sortOption, $mineOnly, $filters, $extraWhere, false, $location ) );
|
||||
$pagination = Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination( $baseUrl, ceil( $clubsCount / $perPage ), $page, $perPage );
|
||||
|
||||
/* Get my clubs and invites */
|
||||
@@ -262,8 +299,6 @@ class directory extends Controller
|
||||
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 ) )
|
||||
{
|
||||
foreach( $allClubs as $clubId => $clubData )
|
||||
@@ -282,7 +317,7 @@ class directory extends Controller
|
||||
}
|
||||
|
||||
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 );
|
||||
Output::i()->output = Theme::i()->getTemplate('clubs')->directory( $featuredClubs, $allClubs, $pagination, $baseUrl, $sortOption, $myClubsActivity, $mapMarkers, $view, $mineOnly, $allSortOptions );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,7 +327,7 @@ class directory extends Controller
|
||||
*/
|
||||
protected function filters() : void
|
||||
{
|
||||
$fields = CustomField::roots();
|
||||
$fields = CustomField::fields();
|
||||
|
||||
$form = new Form('filter', 'filter');
|
||||
|
||||
@@ -305,6 +340,14 @@ class directory extends Controller
|
||||
'mine' => 'my_clubs'
|
||||
) ) ) );
|
||||
}
|
||||
|
||||
if( Settings::i()->clubs_locations )
|
||||
{
|
||||
$form->add( new Address( 'club_filter_location', null, false, [
|
||||
'requireFullAddress' => false,
|
||||
'minimize' => true
|
||||
] ) );
|
||||
}
|
||||
|
||||
if ( Application::appIsEnabled( 'nexus' ) and Settings::i()->clubs_paid_on )
|
||||
{
|
||||
@@ -353,6 +396,12 @@ class directory extends Controller
|
||||
$url = $url->setQueryString( 'name', $values['club_filter_name'] );
|
||||
}
|
||||
|
||||
if( !empty( $values['club_filter_location'] ) and $values['club_filter_location'] instanceof GeoLocation)
|
||||
{
|
||||
$values['club_filter_location']->getLatLong();
|
||||
$url = $url->setQueryString( 'location', $values['club_filter_location']->lat . ',' . $values['club_filter_location']->long );
|
||||
}
|
||||
|
||||
if ( Member::loggedIn()->member_id and $values['club_filter_type'] === 'mine' )
|
||||
{
|
||||
$url = $url->setQueryString( 'filter', 'mine' );
|
||||
|
||||
Reference in new issue
Block a user