Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\modules\front\discover;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -46,6 +46,12 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'styles/streams_responsive.css', 'core', 'front' ) );
|
||||
}
|
||||
|
||||
/* Add any global CSS from other apps */
|
||||
foreach( \IPS\Application::applications() as $app )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'global.css', $app->directory, 'front' ) );
|
||||
}
|
||||
|
||||
/* Execute */
|
||||
return parent::execute();
|
||||
@@ -90,6 +96,13 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2C280/1', 404, '' );
|
||||
}
|
||||
|
||||
/* In order to make most streams more efficient, if we are looking at newest items first, and we haven't set a custom date, then just look for the last 12 months max */
|
||||
if ( \IPS\Settings::i()->search_method != 'elastic' and $stream->date_type == 'all' and $stream->sort == 'newest' )
|
||||
{
|
||||
$stream->date_relative_days = 365;
|
||||
$stream->date_type = 'relative';
|
||||
}
|
||||
|
||||
/* Suitable for guests? */
|
||||
if ( !\IPS\Member::loggedIn()->member_id and !$member and !( ( $stream->ownership == 'all' or $stream->ownership == 'custom' ) and $stream->read == 'all' and $stream->follow == 'all' and $stream->date_type != 'last_visit' ) )
|
||||
@@ -135,6 +148,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
$form = $this->_buildForm( $stream );
|
||||
|
||||
/* Set title and breadcrumb */
|
||||
|
||||
\IPS\Output::i()->breadcrumb[] = array( $stream->url(), $stream->_title );
|
||||
\IPS\Output::i()->title = $stream->_title;
|
||||
}
|
||||
@@ -184,11 +198,14 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('all_activity');
|
||||
}
|
||||
|
||||
/* Store the URL before we add query strings to it, etc */
|
||||
$streamUrl = $stream->url();
|
||||
|
||||
/* Look for url params that can come from view switch or load more button */
|
||||
/* but only if we haven't submitted the form on this request */
|
||||
if( !\IPS\Request::i()->stream_submitted )
|
||||
{
|
||||
$streamFields = array( 'include_comments', 'classes', 'ownership', 'custom_members', 'read', 'follow', 'followed_types', 'date_type', 'date_start', 'date_end', 'date_relative_days', 'sort', 'tags', 'unread_links' );
|
||||
$streamFields = array( 'include_comments', 'classes', 'ownership', 'custom_members', 'read', 'follow', 'followed_types', 'date_type', 'date_start', 'date_end', 'date_relative_days', 'sort', 'tags' );
|
||||
|
||||
/* Clubs enabled? */
|
||||
if( \IPS\Settings::i()->clubs )
|
||||
@@ -216,7 +233,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
|
||||
$_values['stream_custom_members'] = $members;
|
||||
}
|
||||
else if ( in_array( $field, $streamFields ) && ( $field == 'classes' || $field == 'followed_types' ) && is_array( \IPS\Request::i()->{ 'stream_' . $field } ) )
|
||||
else if ( \in_array( $field, $streamFields ) && ( $field == 'classes' || $field == 'followed_types' ) && \is_array( \IPS\Request::i()->{ 'stream_' . $field } ) )
|
||||
{
|
||||
/* Some array values will come in as key=1 params, so we only need the keys here */
|
||||
$_values[ $requestKey ] = array_keys( $requestField );
|
||||
@@ -234,6 +251,8 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
|
||||
$formattedValues = $stream->formatFormValues( $_values );
|
||||
|
||||
$rebuildForm = FALSE;
|
||||
|
||||
/* Overwrite stream config if present in the request */
|
||||
foreach ( $streamFields as $k )
|
||||
{
|
||||
@@ -245,12 +264,13 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$stream->$k = $formattedValues[ $k ];
|
||||
$stream->baseUrl = $stream->baseUrl->setQueryString( 'stream_' . $k, \IPS\Request::i()->$requestKey );
|
||||
$rebuildForm = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Containers are special */
|
||||
if ( isset( \IPS\Request::i()->stream_containers ) and is_array( \IPS\Request::i()->stream_containers ) )
|
||||
if ( isset( \IPS\Request::i()->stream_containers ) and \is_array( \IPS\Request::i()->stream_containers ) )
|
||||
{
|
||||
/* Remove null/'' values as we no longer want to restrict by container for this class if that occurs */
|
||||
$cleanedContainers = array();
|
||||
@@ -262,25 +282,19 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( array_diff_assoc( $cleanedContainers, $stream::containersToUrl( $stream->containers ) ) ) )
|
||||
if ( \count( array_diff_assoc( $cleanedContainers, $stream::containersToUrl( $stream->containers ) ) ) )
|
||||
{
|
||||
$stream->containers = $stream::containersFromUrl( $cleanedContainers );
|
||||
$stream->baseUrl = $stream->baseUrl->setQueryString( 'stream_containers', $cleanedContainers );
|
||||
$rebuildForm = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Request::i()->id ) )
|
||||
if ( isset( \IPS\Request::i()->id ) AND $rebuildForm )
|
||||
{
|
||||
/* reset the form to account for all the modifications to $stream class variables */
|
||||
$form = $this->_buildForm( $stream );
|
||||
}
|
||||
}
|
||||
|
||||
/* In order to make most streams more efficient, if we are looking at newest items first, and we haven't set a custom date, then just look for the last 12 months max */
|
||||
if ( $stream->date_type == 'all' and $stream->sort == 'newest' )
|
||||
{
|
||||
$stream->date_relative_days = 365;
|
||||
$stream->date_type = 'relative';
|
||||
}
|
||||
|
||||
/* Build the query */
|
||||
@@ -288,7 +302,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Set page or the before/after date */
|
||||
$currentPage = 1;
|
||||
if ( isset( \IPS\Request::i()->page ) AND intval( \IPS\Request::i()->page ) > 0 )
|
||||
if ( isset( \IPS\Request::i()->page ) AND \intval( \IPS\Request::i()->page ) > 0 )
|
||||
{
|
||||
$currentPage = \IPS\Request::i()->page;
|
||||
$query->setPage( $currentPage );
|
||||
@@ -353,7 +367,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/* Is anything turned on? */
|
||||
$extra = array();
|
||||
foreach ( array( 'register', 'follow_member', 'follow_content', 'photo', 'like', 'react', 'clubs' ) as $k )
|
||||
foreach ( array( 'register', 'follow_member', 'follow_content', 'photo', 'like', 'votes', 'react', 'clubs' ) as $k )
|
||||
{
|
||||
$key = "all_activity_{$k}";
|
||||
if ( \IPS\Settings::i()->$key )
|
||||
@@ -375,6 +389,12 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$view = \IPS\Request::i()->cookie['stream_view_' . $streamID];
|
||||
}
|
||||
elseif( isset( \IPS\Request::i()->view ) AND \IPS\Login::compareHashes( (string) \IPS\Session::i()->csrfKey, (string) \IPS\Request::i()->csrfKey ) )
|
||||
{
|
||||
$view = \IPS\Request::i()->view;
|
||||
|
||||
\IPS\Request::i()->setCookie( 'stream_view_' . $streamID, \IPS\Request::i()->view, \IPS\DateTime::create()->add( new \DateInterval( 'P1Y' ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$view = $stream->default_view;
|
||||
@@ -389,7 +409,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
'title' => htmlspecialchars( $stream->_title, ENT_DISALLOWED | ENT_QUOTES, 'UTF-8', FALSE ),
|
||||
'blurb' => $stream->blurb(),
|
||||
'config' => json_encode( $stream->config() ),
|
||||
'count' => count( $results ),
|
||||
'count' => \count( $results ),
|
||||
'results' => $output,
|
||||
'id' => ( $stream->id ) ? $stream->id : '',
|
||||
'url' => $stream->url()
|
||||
@@ -412,7 +432,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sendOutput( $document->asXML(), 200, 'text/xml' );
|
||||
\IPS\Output::i()->sendOutput( $document->asXML(), 200, 'text/xml', array(), TRUE );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -441,6 +461,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
/* Display */
|
||||
$output = \IPS\Theme::i()->getTemplate('streams')->stream( $stream, $results, $stream->id ? FALSE : TRUE, TRUE, ( $stream->id and !$stream->include_comments ) ? 'last_comment' : 'date', $view );
|
||||
|
||||
\IPS\Output::i()->linkTags['canonical'] = (string) $streamUrl;
|
||||
\IPS\Output::i()->jsVars['stream_config'] = $stream->config();
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('streams')->streamWrapper( $stream, $output, $form, $rssLink, isset( \IPS\Request::i()->id ) and $stream->member and \IPS\Member::loggedIn()->member_id and $stream->member != \IPS\Member::loggedIn()->member_id );
|
||||
}
|
||||
@@ -511,7 +532,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
/* Output */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->genericBlock( $form, NULL, 'ipsPad' ), 200, 'text/html', \IPS\Output::i()->httpHeaders );
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->genericBlock( $form, NULL, 'ipsPad' ), 200, 'text/html' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'stream_edit_title' );
|
||||
@@ -600,15 +621,18 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
|
||||
foreach ( \IPS\Content::routedClasses( TRUE, FALSE, TRUE ) as $class )
|
||||
{
|
||||
$classes[ $class ] = $class::$title . '_pl';
|
||||
if ( isset( $class::$containerNodeClass ) and $class == \IPS\Request::i()->className )
|
||||
if( is_subclass_of( $class, 'IPS\Content\Searchable' ) )
|
||||
{
|
||||
$url = $stream ? $stream->baseUrl->setQueryString( 'className', $class ) : \IPS\Request::i()->url()->setQueryString( 'className', $class );
|
||||
$containerClass = $class::$containerNodeClass;
|
||||
$field = new \IPS\Helpers\Form\Node( 'stream_containers_' . $class::$title, isset( $currentContainers[ $class ] ) ? $currentContainers[ $class ] : array(), NULL, array( 'url' => $url, 'class' => $class::$containerNodeClass, 'multiple' => TRUE, 'permissionCheck' => $containerClass::searchableNodesPermission(), 'clubs' => ( \IPS\Settings::i()->clubs AND \IPS\IPS::classUsesTrait( $containerClass, 'IPS\Content\ClubContainer' ) ) ), NULL, NULL, NULL, 'stream_containers_' . $class::$title );
|
||||
$field->label = \IPS\Member::loggedIn()->language()->addToStack( 'stream_narrow_by_container_label', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $containerClass::$nodeTitle ) ) ) );
|
||||
|
||||
return \IPS\Output::i()->json( array( 'node' => \IPS\Theme::i()->getTemplate('streams')->filterFormContentTypeContent( $field, $class, \IPS\Request::i()->key ) ) );
|
||||
$classes[ $class ] = $class::$title . '_pl';
|
||||
if ( isset( $class::$containerNodeClass ) and $class == \IPS\Request::i()->className )
|
||||
{
|
||||
$url = $stream ? $stream->baseUrl->setQueryString( 'className', $class ) : \IPS\Request::i()->url()->setQueryString( 'className', $class );
|
||||
$containerClass = $class::$containerNodeClass;
|
||||
$field = new \IPS\Helpers\Form\Node( 'stream_containers_' . $class::$title, isset( $currentContainers[ $class ] ) ? $currentContainers[ $class ] : array(), NULL, array( 'url' => $url, 'class' => $class::$containerNodeClass, 'multiple' => TRUE, 'permissionCheck' => $containerClass::searchableNodesPermission(), 'clubs' => ( \IPS\Settings::i()->clubs AND \IPS\IPS::classUsesTrait( $containerClass, 'IPS\Content\ClubContainer' ) ) ), NULL, NULL, NULL, 'stream_containers_' . $class::$title );
|
||||
$field->label = \IPS\Member::loggedIn()->language()->addToStack( 'stream_narrow_by_container_label', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $containerClass::$nodeTitle ) ) ) );
|
||||
|
||||
return \IPS\Output::i()->json( array( 'node' => \IPS\Theme::i()->getTemplate('streams')->filterFormContentTypeContent( $field, $class, \IPS\Request::i()->key ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,13 +646,13 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function getClubElement()
|
||||
{
|
||||
if( !\IPS\Settings::i()->clubs )
|
||||
if( !\IPS\Settings::i()->clubs or !\IPS\Member\Club::clubs( \IPS\Member::loggedIn(), NULL, 'name', TRUE, array(), \IPS\Settings::i()->clubs_require_approval ? array( 'approved=1' ) : NULL, TRUE ) )
|
||||
{
|
||||
return \IPS\Output::i()->json( array( 'field' => '' ) );
|
||||
}
|
||||
|
||||
$clubOptions = array();
|
||||
foreach ( \IPS\Member\Club::clubs( \IPS\Member::loggedIn(), NULL, 'name', TRUE ) as $club )
|
||||
foreach ( \IPS\Member\Club::clubs( \IPS\Member::loggedIn(), NULL, 'name', TRUE, array(), \IPS\Settings::i()->clubs_require_approval ? array( 'approved=1' ) : NULL ) as $club )
|
||||
{
|
||||
$clubOptions[ "c{$club->id}" ] = $club->name;
|
||||
}
|
||||
@@ -732,7 +756,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$formattedValues = $stream->formatFormValues( $values );
|
||||
|
||||
foreach ( array( 'include_comments', 'classes', 'containers', 'clubs', 'ownership', 'custom_members', 'read', 'follow', 'followed_types', 'date_type', 'date_start', 'date_end', 'date_relative_days', 'sort', 'tags', 'unread_links' ) as $k )
|
||||
foreach ( array( 'include_comments', 'classes', 'containers', 'clubs', 'ownership', 'custom_members', 'read', 'follow', 'followed_types', 'date_type', 'date_start', 'date_end', 'date_relative_days', 'sort', 'tags' ) as $k )
|
||||
{
|
||||
$requestKey = 'stream_' . $k;
|
||||
|
||||
@@ -748,7 +772,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( !$stream->id )
|
||||
{
|
||||
$stream->position = \IPS\Db::i()->select( 'MAX(position)', 'core_streams', array( 'member=?', \IPS\Member::loggedIn()->member_id ) )->first() + 1;
|
||||
$stream->position = \IPS\Db::i()->select( 'MAX(position)', 'core_streams', array( '`member`=?', \IPS\Member::loggedIn()->member_id ) )->first() + 1;
|
||||
$redirectAfterSave = TRUE;
|
||||
}
|
||||
else
|
||||
@@ -771,7 +795,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Display */
|
||||
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'streams', 'core' ) ), $stream->id ? 'filterInlineForm' : 'filterCreateForm' ) );
|
||||
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'streams', 'core' ), $stream->id ? 'filterInlineForm' : 'filterCreateForm' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -782,7 +806,7 @@ class _streams extends \IPS\Dispatcher\Controller
|
||||
protected function _rebuildStreams()
|
||||
{
|
||||
$default = \IPS\Member::loggedIn()->defaultStream;
|
||||
\IPS\Member::loggedIn()->member_streams = json_encode( array( 'default' => $default, 'streams' => iterator_to_array( \IPS\Db::i()->select( 'id, title', 'core_streams', array( 'member=?', \IPS\Member::loggedIn()->member_id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->setKeyField('id')->setValueField('title') ) ) );
|
||||
\IPS\Member::loggedIn()->member_streams = json_encode( array( 'default' => $default, 'streams' => iterator_to_array( \IPS\Db::i()->select( 'id, title', 'core_streams', array( '`member`=?', \IPS\Member::loggedIn()->member_id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->setKeyField('id')->setValueField('title') ) ) );
|
||||
\IPS\Member::loggedIn()->save();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user