Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -11,35 +11,59 @@
namespace IPS\core\modules\admin\discovery;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomXPath;
use IPS\Application;
use IPS\Content\Reaction;
use IPS\Db;
use IPS\Db\Exception;
use IPS\Dispatcher;
use IPS\Helpers\Form;
use IPS\Helpers\Form\CheckboxSet;
use IPS\Helpers\Form\Number;
use IPS\Helpers\Form\YesNo;
use IPS\Http\Url;
use IPS\Lang;
use IPS\Member;
use IPS\Node\Controller;
use IPS\Output;
use IPS\Session;
use IPS\Settings;
use IPS\Xml\DOMDocument;
use function defined;
use function in_array;
use function intval;
use const IPS\CIC;
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;
}
/**
* streams
*/
class _streams extends \IPS\Node\Controller
class streams extends Controller
{
/**
* @brief Has been CSRF-protected
*/
public static $csrfProtected = TRUE;
public static bool $csrfProtected = TRUE;
/**
* Node Class
*/
protected $nodeClass = 'IPS\core\Stream';
protected string $nodeClass = 'IPS\core\Stream';
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
\IPS\Dispatcher::i()->checkAcpPermission( 'streams_manage' );
Dispatcher::i()->checkAcpPermission( 'streams_manage' );
parent::execute();
}
@@ -48,24 +72,35 @@ class _streams extends \IPS\Node\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
\IPS\Output::i()->sidebar['actions'] = array(
Output::i()->sidebar['actions'] = array(
'rebuildIndex' => array(
'title' => 'all_activity_stream_settings',
'icon' => 'cog',
'link' => \IPS\Http\Url::internal( 'app=core&module=discovery&controller=streams&do=allActivitySettings' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('all_activity_stream_settings') )
'link' => Url::internal( 'app=core&module=discovery&controller=streams&do=allActivitySettings' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('all_activity_stream_settings') )
),
'rebuildDefault' => array(
'title' => 'restore_default_streams',
'icon' => 'cog',
'link' => \IPS\Http\Url::internal( 'app=core&module=discovery&controller=streams&do=restoreDefaultStreams' )->csrf(),
'data' => array( 'confirm' => '', 'confirmMessage' => \IPS\Member::loggedIn()->language()->addToStack('restore_default_streams_confirm') )
'link' => Url::internal( 'app=core&module=discovery&controller=streams&do=restoreDefaultStreams' )->csrf(),
'data' => array( 'confirm' => '', 'confirmMessage' => Member::loggedIn()->language()->addToStack('restore_default_streams_confirm') )
),
);
return parent::manage();
parent::manage();
}
/**
* Add/Edit Form
*
* @return void
*/
protected function form() : void
{
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'admin_streams.js', 'core', 'admin' ) );
parent::form();
}
/**
@@ -73,23 +108,23 @@ class _streams extends \IPS\Node\Controller
*
* @return void
*/
protected function restoreDefaultStreams()
protected function restoreDefaultStreams() : void
{
\IPS\Session::i()->csrfCheck();
Session::i()->csrfCheck();
$schema = json_decode( file_get_contents( \IPS\ROOT_PATH . "/applications/core/data/schema.json" ), TRUE );
/* Get the default language strings */
$defaultLanguages = array();
if( file_exists( \IPS\ROOT_PATH . "/applications/core/data/lang.xml" ) )
{
/* Open XML file */
$dom = new \IPS\Xml\DOMDocument( '1.0', 'UTF-8' );
$dom = new DOMDocument( '1.0', 'UTF-8' );
$dom->load( \IPS\ROOT_PATH . "/applications/core/data/lang.xml" );
$xp = new \DomXPath( $dom );
$xp = new DomXPath( $dom );
$results = $xp->query('//language/app/word[contains(@key, "stream_title_")]');
$defaultLanguages = array();
foreach( $results as $lang )
{
@@ -101,21 +136,21 @@ class _streams extends \IPS\Node\Controller
{
try
{
$newId = \IPS\Db::i()->replace( 'core_streams', $insertData, TRUE );
$newId = Db::i()->replace( 'core_streams', $insertData, TRUE );
$oldId = $insertData['id'];
if ( $oldId and $newId )
{
\IPS\Lang::saveCustom( 'core', "stream_title_{$newId}", $defaultLanguages[ $oldId ] );
Lang::saveCustom( 'core', "stream_title_{$newId}", $defaultLanguages[ $oldId ] );
}
}
catch( \IPS\Db\Exception $e )
catch( Exception $e )
{}
}
\IPS\Session::i()->log( 'acplog__streams_restored' );
Session::i()->log( 'acplog__streams_restored' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=discovery&controller=streams' ), 'restore_default_streams_restored' );
Output::i()->redirect( Url::internal( 'app=core&module=discovery&controller=streams' ), 'restore_default_streams_restored' );
}
/**
@@ -123,26 +158,26 @@ class _streams extends \IPS\Node\Controller
*
* @return void
*/
protected function allActivitySettings()
protected function allActivitySettings() : void
{
$types = array( 'register', 'follow_member', 'follow_content', 'photo' );
if ( \IPS\Settings::i()->reputation_enabled )
if ( Settings::i()->reputation_enabled )
{
$types[] = 'like';
}
if ( \IPS\Settings::i()->clubs )
if ( Settings::i()->clubs )
{
$types[] = 'clubs';
}
/* Extensions */
foreach ( \IPS\Application::allExtensions( 'core', 'StreamItems', TRUE, 'core' ) as $key => $extension )
foreach ( Application::allExtensions( 'core', 'StreamItems', TRUE, 'core' ) as $key => $extension )
{
$extensionKey = mb_strtolower( $key );
$settingKey = "all_activity_{$extensionKey}";
/* Only add the option if a setting for it exists - the setting must be defined by the application the extension is for. */
if( isset( \IPS\Settings::i()->$settingKey ) )
if( isset( Settings::i()->$settingKey ) )
{
$types[] = mb_strtolower( $key );
}
@@ -153,19 +188,19 @@ class _streams extends \IPS\Node\Controller
foreach ( $types as $k )
{
$key = "all_activity_{$k}";
if ( \IPS\Settings::i()->$key )
if ( Settings::i()->$key )
{
$currentValuesStream[] = $k;
}
$options[ $k ] = ( $k == 'like' and !\IPS\Content\Reaction::isLikeMode() ) ? 'all_activity_react' : $key;
$options[ $k ] = ( $k == 'like' and !Reaction::isLikeMode() ) ? 'all_activity_react' : $key;
}
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'all_activity_extra_stream', $currentValuesStream, FALSE, array( 'options' => $options ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'activity_stream_rss', \IPS\Settings::i()->activity_stream_rss ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'activity_stream_subscriptions', \IPS\Settings::i()->activity_stream_subscriptions, FALSE, ['togglesOn' => ['activity_stream_subscriptions_max', 'activity_stream_subscriptions_inactive_limit' ] ] ) );
$form->add( new \IPS\Helpers\Form\Number( 'activity_stream_subscriptions_max', \IPS\Settings::i()->activity_stream_subscriptions_max, TRUE, ['min' => 1, 'max' => \IPS\CIC ? 10:NULL ], NULL, NULL, NULL,'activity_stream_subscriptions_max' ) );
$form->add( new \IPS\Helpers\Form\Number( 'activity_stream_subscriptions_inactive_limit', \IPS\Settings::i()->activity_stream_subscriptions_inactive_limit, TRUE, [ ], NULL, NULL, NULL,'activity_stream_subscriptions_inactive_limit' ) );
$form = new Form;
$form->add( new CheckboxSet( 'all_activity_extra_stream', $currentValuesStream, FALSE, array( 'options' => $options ) ) );
$form->add( new YesNo( 'activity_stream_rss', Settings::i()->activity_stream_rss ) );
$form->add( new YesNo( 'activity_stream_subscriptions', Settings::i()->activity_stream_subscriptions, FALSE, ['togglesOn' => ['activity_stream_subscriptions_max', 'activity_stream_subscriptions_inactive_limit' ] ] ) );
$form->add( new Number( 'activity_stream_subscriptions_max', Settings::i()->activity_stream_subscriptions_max, TRUE, ['min' => 1, 'max' => CIC ? 10:NULL ], NULL, NULL, NULL,'activity_stream_subscriptions_max' ) );
$form->add( new Number( 'activity_stream_subscriptions_inactive_limit', Settings::i()->activity_stream_subscriptions_inactive_limit, TRUE, [ ], NULL, NULL, NULL,'activity_stream_subscriptions_inactive_limit' ) );
if ( $values = $form->values() )
@@ -173,20 +208,19 @@ class _streams extends \IPS\Node\Controller
$toSave = array();
foreach ( $types as $k )
{
$toSave[ "all_activity_{$k}" ] = \intval( \in_array( $k, $values['all_activity_extra_stream'] ) );
$toSave[ "all_activity_{$k}" ] = intval( in_array( $k, $values['all_activity_extra_stream'] ) );
}
$toSave[ 'activity_stream_rss' ] = $values['activity_stream_rss'];
$toSave[ 'activity_stream_subscriptions' ] = $values['activity_stream_subscriptions'];
$toSave[ 'activity_stream_subscriptions_max' ] = $values['activity_stream_subscriptions_max'];
$toSave[ 'activity_stream_subscriptions_inactive_limit' ] = $values['activity_stream_subscriptions_inactive_limit'];
\IPS\Session::i()->Log( 'acplog__all_activity_settings' );
Session::i()->Log( 'acplog__all_activity_settings' );
$form->saveAsSettings( $toSave );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=discovery&controller=streams' ), 'saved' );
Output::i()->redirect( Url::internal( 'app=core&module=discovery&controller=streams' ), 'saved' );
}
\IPS\Output::i()->output = $form;
Output::i()->output = $form;
}
}