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\admin\overview;
|
||||
|
||||
/* 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;
|
||||
@@ -22,6 +22,11 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _dashboard extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Show the ACP dashboard
|
||||
*
|
||||
@@ -54,7 +59,7 @@ class _dashboard extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
foreach( $toShow as $row )
|
||||
{
|
||||
if( in_array( $key, $row ) )
|
||||
if( \in_array( $key, $row ) )
|
||||
{
|
||||
$blocks[ $key ] = $extension->getBlock();
|
||||
break;
|
||||
@@ -64,352 +69,10 @@ class _dashboard extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/* ACP Bulletin */
|
||||
$bulletin = isset( \IPS\Data\Store::i()->acpBulletin ) ? \IPS\Data\Store::i()->acpBulletin : NULL;
|
||||
if ( !$bulletin or $bulletin['time'] < ( time() - 86400 ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$bulletins = \IPS\Http\Url::ips('bulletin')->request()->get()->decodeJson();
|
||||
\IPS\Data\Store::i()->acpBulletin = array(
|
||||
'time' => time(),
|
||||
'content' => $bulletins ?: array()
|
||||
);
|
||||
}
|
||||
catch( \RuntimeException $e )
|
||||
{
|
||||
$bulletins = array();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bulletins = $bulletin['content'];
|
||||
}
|
||||
if( !empty( $bulletins ) )
|
||||
{
|
||||
foreach ( $bulletins as $k => $data )
|
||||
{
|
||||
if ( count( $data['files'] ) )
|
||||
{
|
||||
$skip = TRUE;
|
||||
foreach ( $data['files'] as $file )
|
||||
{
|
||||
if ( filemtime( \IPS\ROOT_PATH . '/' . $file ) < $data['timestamp'] )
|
||||
{
|
||||
$skip = FALSE;
|
||||
}
|
||||
}
|
||||
if ( $skip )
|
||||
{
|
||||
unset( $bulletins[ $k ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Warnings */
|
||||
$warnings = array();
|
||||
|
||||
$functionsToDisable = array( 'exec', 'system', 'passhtru', 'pcntl_exec', 'popen', 'proc_open', 'shell_exec' );
|
||||
$showingFunctionWarning = FALSE;
|
||||
foreach ( $functionsToDisable as $k => $function )
|
||||
{
|
||||
if ( function_exists( $function ) )
|
||||
{
|
||||
$showingFunctionWarning = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $functionsToDisable[ $k ] );
|
||||
}
|
||||
}
|
||||
if ( $showingFunctionWarning )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'disable_functions',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack('disable_functions_title'),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack('disable_functions_desc', FALSE, array( 'sprintf' => array( implode( ', ', $functionsToDisable ) ) ) ),
|
||||
);
|
||||
}
|
||||
|
||||
if ( !\IPS\IN_DEV and ( (bool) ini_get( 'display_errors' ) ) !== FALSE AND ini_get( 'display_errors' ) !== 'Off' )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'display_errors',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack('display_errors_title'),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack('display_errors_desc'),
|
||||
'risk' => "medium",
|
||||
);
|
||||
}
|
||||
|
||||
$tasks = \IPS\Db::i()->select( '*', 'core_tasks', 'lock_count >= 3 AND enabled=1' );
|
||||
$keys = array();
|
||||
foreach( $tasks as $task )
|
||||
{
|
||||
$keys[] = $task['key'];
|
||||
}
|
||||
if ( !empty( $keys ) )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dashboard_tasks_broken',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasks_broken' ),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasks_broken_desc', TRUE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $keys ) ) ) )
|
||||
);
|
||||
}
|
||||
|
||||
if( isset( \IPS\Data\Store::i()->failedMailCount ) AND \IPS\Data\Store::i()->failedMailCount >= 3 )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dashboard_email_broken',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_email_broken' ),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_email_broken_desc', TRUE )
|
||||
);
|
||||
}
|
||||
|
||||
$supportAccount = \IPS\Member::load( 'nobody@invisionpower.com', 'email' );
|
||||
if ( $supportAccount->member_id )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dashboard_support_account',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_support_account' ),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_support_account_desc', TRUE, array( 'sprintf' => array( $supportAccount->acpUrl() ) ) )
|
||||
);
|
||||
}
|
||||
|
||||
if( !\IPS\Settings::i()->orig_tables_checked )
|
||||
{
|
||||
/* Check if we have any orig_* tables */
|
||||
$tables = \IPS\Db::i()->getTables( 'orig_' . \IPS\Db::i()->prefix );
|
||||
|
||||
/* If we don't have any, we're good. Set a flag so we don't check this every dashboard load. */
|
||||
if( !count( $tables ) )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_sys_conf_settings', array( 'conf_value' => 1 ), array( 'conf_key=?', 'orig_tables_checked' ) );
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Determine if the background queue task has already been launched */
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->select( '*', 'core_queue', array( "`key`=?", 'CleanupOrigTables' ) )->first();
|
||||
$inProgress = TRUE;
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
$inProgress = FALSE;
|
||||
}
|
||||
|
||||
/* Launch the task if we clicked to do so */
|
||||
if( !$inProgress AND isset( \IPS\Request::i()->cleanupOrigTables ) AND \IPS\Request::i()->cleanupOrigTables )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'CleanupOrigTables', array( 'originalCount' => count( $tables ) ), 5 );
|
||||
|
||||
$inProgress = TRUE;
|
||||
|
||||
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('orig_tables_rebuilding');
|
||||
}
|
||||
|
||||
if( !$inProgress )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'block_core_OrigTables',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack('block_core_OrigTables'),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack('orig_cleanup_suggested')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check Tasks */
|
||||
try
|
||||
{
|
||||
$task = \IPS\DateTime::ts( \IPS\Db::i()->select( 'next_run', 'core_tasks', array( 'core_tasks.enabled=1 AND (core_plugins.plugin_enabled=1 OR core_applications.app_enabled=1)' ), 'next_run ASC' )
|
||||
->join( 'core_applications', array( 'core_applications.app_directory=core_tasks.app' ) )
|
||||
->join( 'core_plugins', array( 'core_plugins.plugin_id=core_tasks.plugin' ) )
|
||||
->first() );
|
||||
$today = new \IPS\DateTime;
|
||||
$difference = $today->diff( $task )->h + ( $today->diff( $task )->days * 24 );
|
||||
|
||||
if ( $difference >= 36 )
|
||||
{
|
||||
if( \IPS\Settings::i()->task_use_cron == 'cron' )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dashboard_tasksrun_broken',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasksrun_broken' ),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( \IPS\CIC ? 'dashboard_tasks_cron_broken_desc_cic' : 'dashboard_tasks_cron_broken_desc' )
|
||||
);
|
||||
}
|
||||
elseif( \IPS\Settings::i()->task_use_cron == 'web' )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dashboard_tasksrun_broken',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasksrun_broken' ),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasks_web_broken_desc' )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dashboard_tasksrun_broken',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasksrun_broken' ),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_tasks_not_enough_desc' )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
|
||||
if ( !\IPS\Settings::i()->site_online AND \IPS\Settings::i()->task_use_cron == 'normal' AND !\IPS\CIC )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dasbhoard_tasks_site_offline',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack('dasbhoard_tasks_site_offline'),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack('dasbhoard_tasks_site_offline_desc')
|
||||
);
|
||||
}
|
||||
|
||||
/* Check MySQL and PHP min versions */
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$mysqlVersion = \IPS\Db::i()->server_info;
|
||||
$requirements = json_decode( file_get_contents( \IPS\ROOT_PATH . '/applications/core/data/requirements.json' ), TRUE );
|
||||
|
||||
if ( version_compare( $phpVersion, $requirements['php']['recommended'] ) < 0 )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dashboard_recommended_php_version',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack('dashboard_recommended_php_version'),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'requirements_php_version_advice', FALSE, array( 'sprintf' => array( $phpVersion, $requirements['php']['recommended'] ) ) )
|
||||
);
|
||||
}
|
||||
|
||||
if ( version_compare( $mysqlVersion, $requirements['mysql']['recommended'] ) < 0 AND !mb_strpos( $mysqlVersion, "MariaDB" ) )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dasbhoard_required_mysql_version',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack('dasbhoard_required_mysql_version'),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'requirements_mysql_version_advice', FALSE, array( 'sprintf' => array( $mysqlVersion, $requirements['mysql']['recommended'] ) ) )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/* Don't do this for IN_DEV on localhost */
|
||||
//
|
||||
|
||||
/* If there have been more than 10 datastore failures in the last hour, or if an instant test fails, show a message */
|
||||
if( !\IPS\Data\Store::i()->test() OR \IPS\Db::i()->select( 'COUNT(*)', 'core_log', array( '`category`=? AND `time`>?', 'datastore', \IPS\DateTime::create()->sub( new \DateInterval( 'PT1H' ) )->getTimestamp() ) )->first() >= 10 )
|
||||
{
|
||||
/* Have we just recently updated the configuration? If so, ignore this warning for 24 hours */
|
||||
if( \IPS\Settings::i()->last_data_store_update < \IPS\DateTime::create()->sub( new \DateInterval( 'PT24H' ) )->getTimestamp() )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dashboard_datastore_broken',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_datastore_broken' ),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_datastore_broken_desc' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( \IPS\CIC )
|
||||
{
|
||||
try
|
||||
{
|
||||
$cicEmails = \IPS\Data\Cache::i()->getWithExpire( 'cicEmailUsage', TRUE );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
preg_match( '/^\/var\/www\/html\/(.+?)(?:\/|$)/i', \IPS\ROOT_PATH, $matches );
|
||||
|
||||
try
|
||||
{
|
||||
$cicEmails = \IPS\Http\Url::external( "http://ips-cic-email.invisioncic.com/blocked.php?account={$matches[1]}" )->request()->get()->decodeJson();
|
||||
}
|
||||
catch( \Exception $e )
|
||||
{
|
||||
/* Request failed, so assume okay and try again in an hour */
|
||||
$cicEmails = array( 'status' => 'OKAY', 'time' => time() );
|
||||
}
|
||||
|
||||
\IPS\Data\Cache::i()->storeWithExpire( 'cicEmailUsage', $cicEmails, \IPS\DateTime::create()->add( new \DateInterval( 'PT1H' ) ), true );
|
||||
}
|
||||
|
||||
if ( isset( $cicEmails['status'] ) AND $cicEmails['status'] == 'BLOCKED' )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dashboard_cic_email_quota',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_cic_email_quota' ),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_cic_email_quota_desc' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* Cache Check */
|
||||
if ( \IPS\CACHE_METHOD AND \IPS\CACHE_METHOD != 'None' AND \IPS\Data\Cache::i() instanceof \IPS\Data\Cache\None )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'dashboard_invalid_cachesetup',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_invalid_cachesetup' ),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( 'dashboard_invalid_cachesetup_desc' )
|
||||
);
|
||||
}
|
||||
|
||||
/* Temporary thing for to show a warning if Facebook login is enabled but site doesn't use https */
|
||||
if ( \IPS\Login\Handler::findMethod( 'IPS\Login\Handler\OAuth2\Facebook' ) and mb_substr( \IPS\Settings::i()->base_url, 0, 8 ) !== 'https://' )
|
||||
{
|
||||
$warnings[] = array(
|
||||
'key' => 'facebook_https',
|
||||
'title' => \IPS\Member::loggedIn()->language()->addToStack( time() < mktime( 0, 0, 0, 10, 6, 2018 ) ? 'facebook_https_warning_title' : 'facebook_https_warning_title2' ),
|
||||
'description' => \IPS\Member::loggedIn()->language()->addToStack( \IPS\CIC ? 'facebook_https_warning_desc_cic' : 'facebook_https_warning_desc' )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/* Get new core update available data */
|
||||
$update = \IPS\Application::load( 'core' )->availableUpgrade( TRUE );
|
||||
|
||||
/* Determine if there are any new features to show */
|
||||
$latestFeatureId = \IPS\Application::load( 'core' )->newFeature();
|
||||
$features = array();
|
||||
|
||||
try
|
||||
{
|
||||
$latestSeenFeature = \IPS\Db::i()->select( 'feature_id', 'core_members_feature_seen', array( 'member_id=?', \IPS\Member::loggedIn()->member_id ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
$latestSeenFeature = 0;
|
||||
}
|
||||
|
||||
if( $latestFeatureId AND ( !$latestSeenFeature OR $latestSeenFeature < $latestFeatureId ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$features = json_encode( \IPS\Http\Url::ips('newFeatures')->setQueryString( array( 'since' => (int) $latestSeenFeature ) )->request()->get()->decodeJson() );
|
||||
|
||||
/* Reset our last feature ID information so this doesn't show on subsequent page loads */
|
||||
\IPS\Db::i()->replace( 'core_members_feature_seen', array( 'member_id' => \IPS\Member::loggedIn()->member_id, 'feature_id' => $latestFeatureId ) );
|
||||
}
|
||||
catch( \RuntimeException $e ){}
|
||||
}
|
||||
|
||||
/* Don't show warnings we've hidden */
|
||||
if ( isset( \IPS\Request::i()->cookie['acpWarnings_mute'] ) )
|
||||
{
|
||||
$keys = explode( ',', \IPS\Request::i()->cookie['acpWarnings_mute'] );
|
||||
foreach( $warnings as $index => $data )
|
||||
{
|
||||
if ( isset( $data['key'] ) and in_array( $data['key'], $keys ) )
|
||||
{
|
||||
unset( $warnings[ $index ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('dashboard');
|
||||
\IPS\Output::i()->customHeader = \IPS\Theme::i()->getTemplate( 'dashboard' )->dashboardHeader( $info, $blocks );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'dashboard' )->dashboard( $update, $features, $toShow, $blocks, $info, $bulletins, $warnings );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'dashboard' )->dashboard( $toShow, $blocks, $info );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -419,9 +82,21 @@ class _dashboard extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function whatsNew()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
\IPS\Member::loggedIn()->members_bitoptions['has_new_acp_features'] = TRUE;
|
||||
\IPS\Member::loggedIn()->save();
|
||||
|
||||
\IPS\Db::i()->delete( 'core_members_feature_seen', array( 'member_id=?', \IPS\Member::loggedIn()->member_id ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=overview&controller=dashboard" ) );
|
||||
if( \IPS\Member::loggedIn()->hasAcpRestriction( \IPS\Application::load( 'core' ), \IPS\Application\Module::get( 'core', 'overview' ), 'view_dashboard' ) )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=overview&controller=dashboard" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "" ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -503,6 +178,8 @@ class _dashboard extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
public function update()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
if( \IPS\Settings::i()->acp_dashboard_blocks )
|
||||
{
|
||||
$blocks = json_decode( \IPS\Settings::i()->acp_dashboard_blocks, TRUE );
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace IPS\core\modules\admin\overview;
|
||||
|
||||
/* 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;
|
||||
@@ -23,14 +23,9 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
class _files extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
parent::execute();
|
||||
}
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Manage Attachment Types
|
||||
@@ -93,14 +88,14 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
if ( $row['attach_is_image'] and $table->filter === 'images' )
|
||||
{
|
||||
$url = \IPS\Http\Url::external( \IPS\File::get( 'core_Attachment', $row['attach_location'] )->url )->makeSafeForAcp( TRUE );
|
||||
$url = \IPS\Http\Url::external( \IPS\File::get( 'core_Attachment', $row['attach_location'] )->url );
|
||||
return "<a href='{$url}' target='_blank' rel='noopener'><img src='{$url}' style='max-height:200px'></a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = \IPS\Http\Url::external( \IPS\Settings::i()->base_url . "applications/core/interface/file/attachment.php" )->setQueryString( 'id', $row['attach_id'] )->makeSafeForAcp( FALSE );
|
||||
$url = \IPS\Http\Url::external( \IPS\Settings::i()->base_url . "applications/core/interface/file/attachment.php" )->setQueryString( 'id', $row['attach_id'] );
|
||||
$val = htmlentities( $val, ENT_DISALLOWED, 'UTF-8', FALSE );
|
||||
return "<a href='{$url}' target='_blank' rel='noopener'>{$val}</a>";
|
||||
return "<a href='{$url}' target='_blank' rel='noreferrer'>{$val}</a>";
|
||||
}
|
||||
},
|
||||
'attach_filesize' => function( $val )
|
||||
@@ -138,7 +133,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<a href='" . \IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=edit&id=' . $val ) . "'>" . htmlentities( \IPS\Member::load( $val )->name, ENT_DISALLOWED, 'UTF-8', FALSE ) . '</a>';
|
||||
return "<a href='" . \IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=view&id=' . $val ) . "'>" . htmlentities( \IPS\Member::load( $val )->name, ENT_DISALLOWED, 'UTF-8', FALSE ) . '</a>';
|
||||
|
||||
}
|
||||
}
|
||||
@@ -191,7 +186,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
$loadedExtensions = array();
|
||||
$locations = array();
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_attachments_map', array( 'attachment_id=?', intval( \IPS\Request::i()->id ) ) ) as $map )
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_attachments_map', array( 'attachment_id=?', \intval( \IPS\Request::i()->id ) ) ) as $map )
|
||||
{
|
||||
if ( !isset( $loadedExtensions[ $map['location_key'] ] ) )
|
||||
{
|
||||
@@ -207,7 +202,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
catch ( \OutOfRangeException $e ){ }
|
||||
}
|
||||
|
||||
if ( isset( $loadedExtensions[ $map['location_key'] ] ) )
|
||||
if ( isset( $loadedExtensions[ $map['location_key'] ] ) AND method_exists( $loadedExtensions[ $map['location_key'] ], 'attachmentLookup' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -311,7 +306,8 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
$configurations = array();
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_file_storage' ) as $row )
|
||||
{
|
||||
$classname = 'IPS\File\\' . $row['method'];
|
||||
$handlers = \IPS\File::storageHandlers( $row );
|
||||
$classname = $handlers[ $row['method'] ];
|
||||
$configurations[ $row['id'] ] = $classname::displayName( json_decode( $row['configuration'], TRUE ) );
|
||||
}
|
||||
|
||||
@@ -319,12 +315,12 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
$form->addMessage( 'filestorage_move_info' );
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'FileStorage', FALSE, NULL, NULL, TRUE ) as $name => $obj )
|
||||
{
|
||||
$disabled = ( isset( $settings[ "filestorage__{$name}" ] ) and is_array( $settings[ "filestorage__{$name}" ] ) ) ? TRUE : FALSE;
|
||||
$disabled = ( isset( $settings[ "filestorage__{$name}" ] ) and \is_array( $settings[ "filestorage__{$name}" ] ) ) ? TRUE : FALSE;
|
||||
$value = NULL;
|
||||
|
||||
if ( isset( $settings[ "filestorage__{$name}" ] ) )
|
||||
{
|
||||
if ( is_array( $settings[ "filestorage__{$name}" ] ) )
|
||||
if ( \is_array( $settings[ "filestorage__{$name}" ] ) )
|
||||
{
|
||||
$copyOfSettings = $settings[ "filestorage__{$name}" ];
|
||||
$value = array_shift( $copyOfSettings );
|
||||
@@ -335,73 +331,91 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'filestorage__' . $name, (int) $value, TRUE, array( 'options' => $configurations, 'disabled' => $disabled ) ) );
|
||||
$toggles = array();
|
||||
|
||||
foreach( $configurations as $id => $title )
|
||||
{
|
||||
if( $id != $value )
|
||||
{
|
||||
$toggles[ $id ] = array( 'filestorage_move' );
|
||||
}
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'filestorage__' . $name, (int) $value, TRUE, array( 'options' => $configurations, 'disabled' => $disabled, 'toggles' => $toggles ) ) );
|
||||
|
||||
if ( $disabled )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words[ 'filestorage__' . $name . '_warning' ] = \IPS\Member::loggedIn()->language()->addToStack( 'file_storage_move_in_progress' );
|
||||
}
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'filestorage_move', TRUE, FALSE, array(), NULL, NULL, NULL, 'filestorage_move' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$rebuild = FALSE;
|
||||
|
||||
/* Queue theme first */
|
||||
if( isset( $values['filestorage__core_Theme'] ) and $settings['filestorage__core_Theme'] != $values['filestorage__core_Theme'] )
|
||||
{
|
||||
$rebuild = TRUE;
|
||||
$extension = new \IPS\core\extensions\core\FileStorage\Theme;
|
||||
|
||||
\IPS\Task::queue( 'core', 'MoveFiles', array( 'storageExtension' => 'filestorage__core_Theme', 'oldConfiguration' => $settings[ 'filestorage__core_Theme' ], 'newConfiguration' => $values[ 'filestorage__core_Theme' ], 'count' => $extension->count() ), 1 );
|
||||
|
||||
/* Add to allowed storage methods so when moving files, we can accept old config or new config if move is in progress. Important: order is array(x, y) x is the new location (pos 0), y is the old location (pos 1)*/
|
||||
$values['filestorage__core_Theme'] = array( $values['filestorage__core_Theme'], $settings['filestorage__core_Theme'] );
|
||||
}
|
||||
foreach ( $values as $k => $v )
|
||||
if( isset( $values['filestorage_move'] ) AND $values['filestorage_move'] )
|
||||
{
|
||||
if ( isset( $settings[$k] ) AND !is_array( $settings[$k] ) )
|
||||
{
|
||||
if ( $settings[ $k ] != $v and $k != 'filestorage__core_Theme' )
|
||||
{
|
||||
/* Do we need to move files at all? */
|
||||
$configurations = \IPS\File::getConfigurations();
|
||||
$exploded = explode( '_', $k );
|
||||
$classname = "IPS\\{$exploded[2]}\\extensions\\core\\FileStorage\\{$exploded[3]}";
|
||||
$extension = new $classname;
|
||||
$currentClass = \IPS\File::getClass( intval( $settings[ $k ] ) );
|
||||
$newClass = \IPS\File::getClass( intval( $v ) );
|
||||
|
||||
if ( ( isset( $configurations[ $v ] ) and isset( $configurations[ $settings[ $k ] ] ) ) and ( get_class( $currentClass ) == get_class( $newClass ) ) and ! $newClass::moveCheck( $newClass->configuration, $currentClass->configuration ) )
|
||||
{
|
||||
$rebuild = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$rebuild = TRUE;
|
||||
}
|
||||
$rebuild = FALSE;
|
||||
|
||||
if ( $rebuild )
|
||||
/* Queue theme first */
|
||||
if( isset( $values['filestorage__core_Theme'] ) and $settings['filestorage__core_Theme'] != $values['filestorage__core_Theme'] )
|
||||
{
|
||||
$rebuild = TRUE;
|
||||
$extension = new \IPS\core\extensions\core\FileStorage\Theme;
|
||||
|
||||
\IPS\Task::queue( 'core', 'MoveFiles', array( 'storageExtension' => 'filestorage__core_Theme', 'oldConfiguration' => $settings[ 'filestorage__core_Theme' ], 'newConfiguration' => $values[ 'filestorage__core_Theme' ], 'count' => $extension->count() ), 1 );
|
||||
|
||||
/* Add to allowed storage methods so when moving files, we can accept old config or new config if move is in progress. Important: order is array(x, y) x is the new location (pos 0), y is the old location (pos 1)*/
|
||||
$values['filestorage__core_Theme'] = array( $values['filestorage__core_Theme'], $settings['filestorage__core_Theme'] );
|
||||
}
|
||||
$totalCount = 0;
|
||||
foreach ( $values as $k => $v )
|
||||
{
|
||||
if ( isset( $settings[$k] ) AND !\is_array( $settings[$k] ) )
|
||||
{
|
||||
if ( $settings[ $k ] != $v and $k != 'filestorage__core_Theme' AND $k != 'filestorage_move' )
|
||||
{
|
||||
$count = $extension->count();
|
||||
/* Do we need to move files at all? */
|
||||
$configurations = \IPS\File::getConfigurations();
|
||||
$exploded = explode( '_', $k );
|
||||
$classname = "IPS\\{$exploded[2]}\\extensions\\core\\FileStorage\\{$exploded[3]}";
|
||||
$extension = new $classname;
|
||||
$currentClass = \IPS\File::getClass( \intval( $settings[ $k ] ) );
|
||||
$newClass = \IPS\File::getClass( \intval( $v ) );
|
||||
|
||||
if ( $count )
|
||||
if ( ( isset( $configurations[ $v ] ) and isset( $configurations[ $settings[ $k ] ] ) ) and ( \get_class( $currentClass ) == \get_class( $newClass ) ) and ! $newClass::moveCheck( $newClass->configuration, $currentClass->configuration ) )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'MoveFiles', array( 'storageExtension' => $k, 'oldConfiguration' => $settings[ $k ], 'newConfiguration' => $values[ $k ], 'count' => $count ), 2 );
|
||||
$rebuild = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$rebuild = TRUE;
|
||||
}
|
||||
|
||||
if ( $rebuild )
|
||||
{
|
||||
$count = $extension->count();
|
||||
|
||||
/* Add to allowed storage methods so when moving files, we can accept old config or new config if move is in progress. Important: order is array(x, y) x is the new location (pos 0), y is the old location (pos 1)*/
|
||||
$values[ $k ] = array( $v, $settings[ $k ] );
|
||||
if ( $count )
|
||||
{
|
||||
$totalCount += $count;
|
||||
\IPS\Task::queue( 'core', 'MoveFiles', array( 'storageExtension' => $k, 'oldConfiguration' => $settings[ $k ], 'newConfiguration' => $values[ $k ], 'count' => $count ), 2 );
|
||||
|
||||
/* Add to allowed storage methods so when moving files, we can accept old config or new config if move is in progress. Important: order is array(x, y) x is the new location (pos 0), y is the old location (pos 1)*/
|
||||
$values[ $k ] = array( $v, $settings[ $k ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( $rebuild )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'DeleteMovedFiles', array( 'delete' => true, 'count' => $totalCount ), 5, array( 'delete' ) ); /* We use a key in the data array just to trigger the code that deletes duplicate tasks */
|
||||
}
|
||||
}
|
||||
|
||||
if( $rebuild )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'DeleteMovedFiles', array( 'delete' => true ), 5, array( 'delete' ) ); /* We use a key in the data array just to trigger the code that deletes duplicate tasks */
|
||||
}
|
||||
|
||||
|
||||
/* Update the settings */
|
||||
\IPS\Settings::i()->changeValues( array( 'upload_settings' => json_encode( $values ) ) );
|
||||
|
||||
/* Clear guest page caches */
|
||||
@@ -422,7 +436,8 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
$table->noSort = array( 'filestorage_method' );
|
||||
$table->parsers = array( 'filestorage_method' => function( $val, $row )
|
||||
{
|
||||
$classname = 'IPS\File\\' . $row['method'];
|
||||
$handlers = \IPS\File::storageHandlers( $row );
|
||||
$classname = $handlers[ $row['method'] ];
|
||||
return $classname::displayName( json_decode( $row['configuration'], TRUE ) );
|
||||
} );
|
||||
|
||||
@@ -448,7 +463,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
'delete' => array(
|
||||
'icon' => 'times-circle',
|
||||
'title' => 'delete',
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=overview&controller=files&do=configurationForm&id={$row['id']}&delete=1" )
|
||||
'link' => \IPS\Http\Url::internal( "app=core&module=overview&controller=files&do=configurationForm&id={$row['id']}&delete=1" )->csrf()
|
||||
),
|
||||
);
|
||||
};
|
||||
@@ -487,7 +502,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
protected function fileLogSettings()
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'file_log_pruning', \IPS\Settings::i()->file_log_pruning, FALSE, array( 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), \IPS\Member::loggedIn()->language()->addToStack('days'), 'file_log_pruning' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'file_log_pruning', \IPS\Settings::i()->file_log_pruning, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::DAYS, 'unlimited' => 0, 'unlimitedLang' => 'never' ), NULL, \IPS\Member::loggedIn()->language()->addToStack('after'), NULL, 'file_log_pruning' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
@@ -515,10 +530,10 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
$current = \IPS\Db::i()->select( '*', 'core_file_storage', array( 'id=?', intval( \IPS\Request::i()->id ) ) )->first();
|
||||
$current = \IPS\Db::i()->select( '*', 'core_file_storage', array( 'id=?', \intval( \IPS\Request::i()->id ) ) )->first();
|
||||
$currentHandlerSettings = json_decode( $current['configuration'], TRUE );
|
||||
|
||||
if ( in_array( intval( \IPS\Request::i()->id ), json_decode( \IPS\Settings::i()->upload_settings, TRUE ) ) )
|
||||
if ( \in_array( \intval( \IPS\Request::i()->id ), array_filter( json_decode( \IPS\Settings::i()->upload_settings, TRUE ), function( $key ){ return $key != 'filestorage_move'; }, ARRAY_FILTER_USE_KEY ) ) )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->delete ) )
|
||||
{
|
||||
@@ -546,7 +561,9 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( isset( \IPS\Request::i()->delete ) )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_file_storage', array( 'id=?', intval( \IPS\Request::i()->id ) ) );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
\IPS\Db::i()->delete( 'core_file_storage', array( 'id=?', \intval( \IPS\Request::i()->id ) ) );
|
||||
unset( \IPS\Data\Store::i()->storageConfigurations );
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__files_config_removed', array() );
|
||||
@@ -564,54 +581,36 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
$handlers = array();
|
||||
$handlerSettings = array();
|
||||
$toggles = array();
|
||||
foreach ( new \DirectoryIterator( \IPS\ROOT_PATH . '/system/File' ) as $f )
|
||||
foreach ( \IPS\File::storageHandlers( $current ) as $key => $class )
|
||||
{
|
||||
if ( !$f->isDot() and mb_substr( $f, -4 ) === '.php' and $f != 'File.php' and $f != 'Iterator.php' and $f != 'Exception.php' )
|
||||
{
|
||||
$key = mb_substr( $f, 0, -4 );
|
||||
|
||||
if ( \IPS\CIC and $key === 'FileSystem' )
|
||||
$handlers[ $key ] = 'filehandler__' . $key;
|
||||
foreach ( $class::settings( $currentHandlerSettings ) as $k => $v )
|
||||
{
|
||||
if ( \is_array( $v ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Hide FTP option from form unless it's already in use */
|
||||
if ( ( $key === 'Ftp' AND isset( $current['method'] ) AND $current['method'] !== 'Ftp' ) OR ( $key === 'Ftp' AND !isset( $current['method'] ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$handlers[ $key ] = 'filehandler__' . $key;
|
||||
|
||||
$class = 'IPS\File\\' . $key;
|
||||
foreach ( $class::settings( $currentHandlerSettings ) as $k => $v )
|
||||
{
|
||||
if ( is_array( $v ) )
|
||||
$settingClass = '\IPS\Helpers\Form\\' . $v['type'];
|
||||
|
||||
$default = isset( $currentHandlerSettings[ $k ] ) ? str_replace( '{root}', \IPS\ROOT_PATH, $currentHandlerSettings[ $k ] ) : NULL;
|
||||
if ( isset( $v['default'] ) and !$default )
|
||||
{
|
||||
$settingClass = '\IPS\Helpers\Form\\' . $v['type'];
|
||||
|
||||
$default = isset( $currentHandlerSettings[ $k ] ) ? str_replace( '{root}', \IPS\ROOT_PATH, $currentHandlerSettings[ $k ] ) : NULL;
|
||||
if ( isset( $v['default'] ) and !$default )
|
||||
{
|
||||
$default = str_replace( '{root}', \IPS\ROOT_PATH, $v['default'] );
|
||||
}
|
||||
|
||||
$handlerSettings[ $key ][ $k ] = new $settingClass( "filehandler__{$key}_{$k}", $default, FALSE, isset( $v['options'] ) ? $v['options'] : array(), isset( $v['validate'] ) ? $v['validate'] : NULL, isset( $v['prefix'] ) ? $v['prefix'] : NULL, isset( $v['suffix'] ) ? $v['suffix'] : NULL, "{$key}_{$k}" );
|
||||
$default = str_replace( '{root}', \IPS\ROOT_PATH, $v['default'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$settingClass = '\IPS\Helpers\Form\\' . $v;
|
||||
$handlerSettings[ $key ][ $k ] = new $settingClass( "filehandler__{$key}_{$k}", isset( $currentHandlerSettings[ $k ] ) ? $currentHandlerSettings[ $k ] : NULL, FALSE, array(), NULL, NULL, NULL, "{$key}_{$k}" );
|
||||
}
|
||||
$toggles[ $key ][ $k ] = "{$key}_{$k}";
|
||||
|
||||
$handlerSettings[ $key ][ $k ] = new $settingClass( "filehandler__{$key}_{$k}", $default, FALSE, isset( $v['options'] ) ? $v['options'] : array(), isset( $v['validate'] ) ? $v['validate'] : NULL, isset( $v['prefix'] ) ? $v['prefix'] : NULL, isset( $v['suffix'] ) ? $v['suffix'] : NULL, "{$key}_{$k}" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$settingClass = '\IPS\Helpers\Form\\' . $v;
|
||||
$handlerSettings[ $key ][ $k ] = new $settingClass( "filehandler__{$key}_{$k}", isset( $currentHandlerSettings[ $k ] ) ? $currentHandlerSettings[ $k ] : NULL, FALSE, array(), NULL, NULL, NULL, "{$key}_{$k}" );
|
||||
}
|
||||
$toggles[ $key ][ $k ] = "{$key}_{$k}";
|
||||
}
|
||||
}
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->hiddenValues['configurationId'] = isset( \IPS\Request::i()->id ) ? \IPS\Request::i()->id : 0;
|
||||
if ( isset( \IPS\Request::i()->id ) AND in_array( intval( \IPS\Request::i()->id ), json_decode( \IPS\Settings::i()->upload_settings, TRUE ) ) and $current['method'] !== 'FileSystem')
|
||||
if ( isset( \IPS\Request::i()->id ) AND \in_array( \intval( \IPS\Request::i()->id ), json_decode( \IPS\Settings::i()->upload_settings, TRUE ) ) and $current['method'] !== 'FileSystem')
|
||||
{
|
||||
$form->addMessage( 'files_edit_existing_and_used', 'ipsMessage ipsMessage_info' );
|
||||
}
|
||||
@@ -643,7 +642,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
$classname = 'IPS\File\\' . $values['filestorage_method'];
|
||||
$classname = \IPS\File::storageHandlers( $current )[ $values['filestorage_method'] ];
|
||||
if ( method_exists( $classname, 'testSettings' ) )
|
||||
{
|
||||
$classname::testSettings( $currentHandlerSettings );
|
||||
@@ -695,9 +694,13 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
) );
|
||||
unset( \IPS\Data\Store::i()->storageConfigurations );
|
||||
|
||||
/* Log the storage addition */
|
||||
\IPS\Session::i()->log( 'acplogs__files_config_added' );
|
||||
|
||||
if ( $createNewAndMove )
|
||||
{
|
||||
$settings = json_decode( \IPS\Settings::i()->upload_settings, TRUE );
|
||||
$totalCount = 0;
|
||||
foreach ( $settings as $k => $v )
|
||||
{
|
||||
if ( $v == $current['id'] )
|
||||
@@ -712,8 +715,9 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
if( \IPS\Application::appIsEnabled( $exploded[2] ) AND class_exists( $classname ) )
|
||||
{
|
||||
$extension = new $classname;
|
||||
|
||||
\IPS\Task::queue( 'core', 'MoveFiles', array( 'storageExtension' => $k, 'oldConfiguration' => $v, 'newConfiguration' => $insertId, 'count' => $extension->count() ), 2 );
|
||||
$count = $extension->count();
|
||||
$totalCount += $count;
|
||||
\IPS\Task::queue( 'core', 'MoveFiles', array( 'storageExtension' => $k, 'oldConfiguration' => $v, 'newConfiguration' => $insertId, 'count' => $count ), 2 );
|
||||
}
|
||||
|
||||
$settings[ $k ] = $insertId;
|
||||
@@ -731,7 +735,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $values['filestorage_move'] )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'DeleteMovedFiles', array( 'delete' => true ), 5, array( 'delete' ) ); /* We use a key in the data array just to trigger the code that deletes duplicate tasks */
|
||||
\IPS\Task::queue( 'core', 'DeleteMovedFiles', array( 'delete' => true, 'count' => $totalCount ), 5, array( 'delete' ) ); /* We use a key in the data array just to trigger the code that deletes duplicate tasks */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -743,6 +747,9 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $current !== NULL and ! $createNewAndMove )
|
||||
{
|
||||
/* Log the storage change */
|
||||
\IPS\Session::i()->log( 'acplogs__files_config_changed' );
|
||||
|
||||
$classname::getClass( $current['id'] )->settingsUpdated();
|
||||
}
|
||||
|
||||
@@ -772,7 +779,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
$current = \IPS\Db::i()->select( '*', 'core_file_storage', array( 'id=?', intval( \IPS\Request::i()->id ) ) )->first();
|
||||
$current = \IPS\Db::i()->select( '*', 'core_file_storage', array( 'id=?', \intval( \IPS\Request::i()->id ) ) )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
{
|
||||
@@ -782,7 +789,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
$currentConf = json_decode( $current['configuration'], TRUE );
|
||||
$needsMoving = FALSE;
|
||||
|
||||
if ( in_array( intval( \IPS\Request::i()->id ), json_decode( \IPS\Settings::i()->upload_settings, TRUE ) ) )
|
||||
if ( \in_array( \intval( \IPS\Request::i()->id ), json_decode( \IPS\Settings::i()->upload_settings, TRUE ) ) )
|
||||
{
|
||||
foreach ( $currentConf as $k => $v )
|
||||
{
|
||||
@@ -794,7 +801,8 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
$classname = 'IPS\File\\' . $current['method'];
|
||||
$handlers = \IPS\File::storageHandlers( $current );
|
||||
$classname = $handlers[ $current['method'] ];
|
||||
|
||||
/* Do we really need to create and move? */
|
||||
$needsMoving = $classname::moveCheck( $currentHandlerSettings, $currentConf );
|
||||
@@ -810,7 +818,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function configurationLog()
|
||||
{
|
||||
$method = \IPS\Db::i()->select( '*', 'core_file_storage', array( 'id=?', intval( \IPS\Request::i()->id ) ) )->first();
|
||||
$method = \IPS\Db::i()->select( '*', 'core_file_storage', array( 'id=?', \intval( \IPS\Request::i()->id ) ) )->first();
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'file_config_log', NULL, array( 'sprintf' => array( $method['method'] ) ) );
|
||||
|
||||
/* Create the table */
|
||||
@@ -859,6 +867,8 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function orphaned()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_file_storage', NULL, 'id' ) as $row )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'FindOrphanedFiles', array( 'configurationId' => $row['id'] ), 4, array( 'configurationId' ) );
|
||||
@@ -878,7 +888,7 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
if( !isset( \IPS\Request::i()->multimod ) OR !is_array( \IPS\Request::i()->multimod ) OR !count( \IPS\Request::i()->multimod ) )
|
||||
if( !isset( \IPS\Request::i()->multimod ) OR !\is_array( \IPS\Request::i()->multimod ) OR !\count( \IPS\Request::i()->multimod ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'nothing_mm_selected', '2C158/6', 403, '' );
|
||||
}
|
||||
@@ -897,6 +907,12 @@ class _files extends \IPS\Dispatcher\Controller
|
||||
|
||||
\IPS\Db::i()->delete( 'core_attachments', \IPS\Db::i()->in( 'attach_id', array_keys( \IPS\Request::i()->multimod ) ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=overview&controller=files" ), 'deleted' );
|
||||
$url = \IPS\Http\Url::internal( "app=core&module=overview&controller=files" );
|
||||
|
||||
if( \IPS\Request::i()->listResort )
|
||||
{
|
||||
$url = $url->setQueryString( array( 'listResort' => 1, 'sortby' => \IPS\Request::i()->sortby, 'sortdirection' => \IPS\Request::i()->sortdirection ) )->csrf();
|
||||
}
|
||||
\IPS\Output::i()->redirect( $url, 'deleted' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief ACP Notification Center
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 21 June 2018
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\overview;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ACP Notification Center
|
||||
*/
|
||||
class _notifications extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Show notifications
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$notifications = \IPS\core\AdminNotification::notifications();
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() and !isset( \IPS\Request::i()->_table ) )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'data' => \IPS\Theme::i()->getTemplate('notifications')->popupList( $notifications ), 'count' => \count( $notifications ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('acp_notifications');
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'system/notifications.css', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('notifications')->index( $notifications );
|
||||
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
'settings' => array(
|
||||
'title' => 'notification_options',
|
||||
'icon' => 'cog',
|
||||
'link' => \IPS\Http\Url::internal( 'app=core&module=overview&controller=notifications&do=settings' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss a notification
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function dismiss()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
\IPS\core\AdminNotification::dismissNotification( \IPS\Request::i()->id );
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( array( 'status' => 'OK' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification Settings
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function settings()
|
||||
{
|
||||
$preferences = iterator_to_array( \IPS\Db::i()->select( '*', 'core_acp_notifications_preferences', array( '`member`=?', \IPS\Member::loggedIn()->member_id ) )->setKeyField('type') );
|
||||
|
||||
$matrix = new \IPS\Helpers\Form\Matrix;
|
||||
$matrix->langPrefix = 'acp_notifications_';
|
||||
$matrix->manageable = FALSE;
|
||||
$matrix->columns = array(
|
||||
'name' => function( $key, $value, $data )
|
||||
{
|
||||
return $value;
|
||||
},
|
||||
'view' => function( $key, $value, $data )
|
||||
{
|
||||
return new \IPS\Helpers\Form\YesNo( $key, $data['maybeOptional'] ? $value : TRUE, FALSE, array( 'disabled' => !$data['maybeOptional'] ) );
|
||||
},
|
||||
'email' => function( $key, $value, $data )
|
||||
{
|
||||
if ( $data['customEmail'] )
|
||||
{
|
||||
return $data['customEmail'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$options = $data['mayRecur'] ? array(
|
||||
'never' => 'acp_notifications_email_never',
|
||||
'once' => 'acp_notifications_email_once',
|
||||
'always' => 'acp_notifications_email_always',
|
||||
) : array(
|
||||
'never' => 'acp_notifications_email_never',
|
||||
'once' => 'acp_notifications_email_yes',
|
||||
);
|
||||
|
||||
return new \IPS\Helpers\Form\Select( $key, $value, FALSE, array( 'options' => $options, 'class' => 'ipsField_medium' ) );
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
$rows = array();
|
||||
foreach ( \IPS\Application::allExtensions( 'core', 'AdminNotifications', TRUE, NULL, NULL, FALSE ) as $ext )
|
||||
{
|
||||
if ( $ext::permissionCheck( \IPS\Member::loggedIn() ) )
|
||||
{
|
||||
$exploded = explode( '\\', $ext );
|
||||
$key = "{$exploded[1]}_{$exploded[5]}";
|
||||
|
||||
$rows[ $ext::$group ]['priority'] = $ext::$groupPriority;
|
||||
$rows[ $ext::$group ]['rows'][ $ext ] = array(
|
||||
'name' => $ext::settingsTitle(),
|
||||
'view' => isset( $preferences[ $key ]['view'] ) ? $preferences[ $key ]['view'] : $ext::defaultValue(),
|
||||
'email' => isset( $preferences[ $key ]['email'] ) ? $preferences[ $key ]['email'] : 'never',
|
||||
'maybeOptional' => $ext::mayBeOptional(),
|
||||
'mayRecur' => $ext::mayRecur(),
|
||||
'customEmail' => $ext::customEmailConfigurationSetting( "{$ext}[email]", isset( $preferences[ $key ]['email'] ) ? $preferences[ $key ]['email'] : NULL ),
|
||||
'priority' => $ext::$itemPriority,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
uasort( $rows, function( $a, $b ) {
|
||||
return $a['priority'] - $b['priority'];
|
||||
});
|
||||
|
||||
foreach ( $rows as $group => $data )
|
||||
{
|
||||
$matrix->rows[] = \IPS\Member::loggedIn()->language()->addToStack("acp_notification_group_{$group}");
|
||||
|
||||
uasort( $data['rows'], function( $a, $b ) {
|
||||
return $a['priority'] - $b['priority'];
|
||||
});
|
||||
|
||||
foreach ( $data['rows'] as $ext => $row )
|
||||
{
|
||||
$matrix->rows[ $ext ] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $values = $matrix->values() )
|
||||
{
|
||||
foreach ( $values as $ext => $_values )
|
||||
{
|
||||
$exploded = explode( '\\', $ext );
|
||||
$key = "{$exploded[1]}_{$exploded[5]}";
|
||||
|
||||
$v = \IPS\Request::i()->$ext;
|
||||
|
||||
\IPS\Db::i()->insert( 'core_acp_notifications_preferences', array(
|
||||
'member' => \IPS\Member::loggedIn()->member_id,
|
||||
'type' => $key,
|
||||
'view' => $ext::mayBeOptional() ? $_values['view'] : TRUE,
|
||||
'email' => isset( $v['email'] ) ? $v['email'] : 'never',
|
||||
), TRUE );
|
||||
}
|
||||
|
||||
if( isset( \IPS\Data\Store::i()->acpNotificationIds ) )
|
||||
{
|
||||
$notificationCache = \IPS\Data\Store::i()->acpNotificationIds;
|
||||
unset( $notificationCache[ \IPS\Member::loggedIn()->member_id ] );
|
||||
\IPS\Data\Store::i()->acpNotificationIds = $notificationCache;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('notification_options');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('forms')->blurb( 'acp_notifications_settings_blurb' ) . $matrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recheck configuration errors
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configurationErrorChecks()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\core\extensions\core\AdminNotifications\ConfigurationError::runChecksAndSendNotifications();
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete orig_ database tables
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function removeOrigTables()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$tables = \IPS\Db::i()->getTables( 'orig_' . \IPS\Db::i()->prefix );
|
||||
\IPS\Task::queue( 'core', 'CleanupOrigTables', array( 'originalCount' => \count( $tables ) ), 5 );
|
||||
|
||||
\IPS\core\AdminNotification::remove( 'core', 'ConfigurationError', 'origTables' );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=notifications' ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Initial installation onboarding
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 12 Feb 2020
|
||||
*/
|
||||
|
||||
namespace IPS\core\modules\admin\overview;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial installation onboarding
|
||||
*/
|
||||
class _onboard extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'dashboard/onboard.css', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_dashboard.js', 'core', 'admin' ) );
|
||||
|
||||
return parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Welcome page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initial()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Settings::i()->changeValues( array( 'onboard_complete' => 1 ) ); // Set the flag that we've hit this page so that it doesn't keep trying to redirect us back
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('onboard_pagetitle');
|
||||
\IPS\Output::i()->showTitle = FALSE;
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'dashboard' )->onboardWelcome();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dismiss()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Email::buildFromTemplate( 'core', 'onboard_reminder', array(), \IPS\Email::TYPE_TRANSACTIONAL )->send( \IPS\Member::loggedIn() );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=dashboard' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Remind me later
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function remind()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Settings::i()->changeValues( array( 'onboard_complete' => \IPS\DateTime::ts( time() )->add( new \DateInterval( 'PT20M' ) )->getTimestamp() ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=dashboard' ), 'onboard_will_remind' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a form allowing the admin to configure some common settings after an initial installation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Create the form and add our message to it */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class = "ipsForm_vertical";
|
||||
|
||||
$form->addTab( 'onboard_tab_identity' );
|
||||
|
||||
/* Super basic configuration options */
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'board_name', \IPS\Settings::i()->board_name, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Address( 'site_address', \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->site_address ), FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'site_social_profiles', \IPS\Settings::i()->site_social_profiles ? json_decode( \IPS\Settings::i()->site_social_profiles, true ) : array(), FALSE, array( 'stackFieldType' => '\IPS\core\Form\SocialProfiles', 'maxItems' => 50, 'key' => array( 'placeholder' => 'http://example.com', 'size' => 20 ) ) ) );
|
||||
|
||||
$form->addTab( 'onboard_tab_appearance' );
|
||||
|
||||
/* If we do not have an email logo and none of our themes have a logo, show the logo field */
|
||||
$hasCustomLogo = FALSE;
|
||||
|
||||
foreach( \IPS\Theme::themes() as $theme )
|
||||
{
|
||||
if( $theme->logo_front )
|
||||
{
|
||||
$hasCustomLogo = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !\IPS\Settings::i()->email_logo AND !$hasCustomLogo )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'initial_logo', NULL, FALSE, array( 'image' => true, 'storageExtension' => 'core_Theme' ) ) );
|
||||
}
|
||||
|
||||
/* Generic favicon - easy enough */
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'icons_favicon', \IPS\Settings::i()->icons_favicon ? \IPS\File::get( 'core_Icons', \IPS\Settings::i()->icons_favicon ) : NULL, FALSE, array( 'obscure' => false, 'allowedFileTypes' => array( 'ico', 'png', 'gif', 'jpeg', 'jpg', 'jpe' ), 'storageExtension' => 'core_Icons' ) ) );
|
||||
|
||||
/* Homescreen icons - we accept one upload and create the images we need */
|
||||
$homeScreen = json_decode( \IPS\Settings::i()->icons_homescreen, TRUE ) ?? array();
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'icons_homescreen', ( isset( $homeScreen['original'] ) ) ? \IPS\File::get( 'core_Icons', $homeScreen['original'] ) : NULL, FALSE, array( 'image' => true, 'storageExtension' => 'core_Icons' ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Color( 'email_color', \IPS\Settings::i()->email_color, TRUE ) );
|
||||
|
||||
/* These options are only for non-cic */
|
||||
if( !\IPS\CIC )
|
||||
{
|
||||
/* Get the task setting */
|
||||
$form->addTab( 'onboard_tab_tasks' );
|
||||
\IPS\core\modules\admin\settings\advanced::taskSetting( $form );
|
||||
|
||||
/* Get the htaccess mod_Rewrite setting */
|
||||
$form->addTab( 'onboard_tab_furls' );
|
||||
\IPS\core\modules\admin\promotion\seo::htaccessSetting( $form );
|
||||
}
|
||||
|
||||
/* Add the terms/privacy policy/etc. */
|
||||
$form->addTab( 'onboard_tab_privacyterms' );
|
||||
\IPS\core\modules\admin\settings\terms::buildForm( $form );
|
||||
|
||||
/* Add dismiss and remind me later buttons */
|
||||
if( \IPS\Request::i()->initial )
|
||||
{
|
||||
$form->addButton( 'onboard_remind_later', 'submit', NULL, 'ipsButton ipsButton_secondary', array( 'name' => 'remind', 'value' => 1, 'csrfKey' => \IPS\Session::i()->csrfKey ) );
|
||||
$form->addButton( 'dismiss', 'submit', NULL, 'ipsButton ipsButton_secondary', array( 'name' => 'dismiss', 'value' => 1, 'csrfKey' => \IPS\Session::i()->csrfKey ) );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* If we dismissed, do that but also send an email */
|
||||
if( isset( \IPS\Request::i()->dismiss ) AND \IPS\Request::i()->dismiss == 1 )
|
||||
{
|
||||
\IPS\Email::buildFromTemplate( 'core', 'onboard_reminder', array(), \IPS\Email::TYPE_TRANSACTIONAL )->send( \IPS\Member::loggedIn() );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=dashboard' ) );
|
||||
}
|
||||
|
||||
/* If we said to remind us later, set the flag and redirect */
|
||||
if( isset( \IPS\Request::i()->remind ) AND \IPS\Request::i()->remind == 1 )
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( 'onboard_complete' => \IPS\DateTime::ts( time() )->add( new \DateInterval( 'PT20M' ) )->getTimestamp() ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=dashboard' ), 'onboard_will_remind' );
|
||||
}
|
||||
|
||||
array_walk( $values['site_social_profiles'], function( &$value ){
|
||||
$value['key'] = (string) $value['key'];
|
||||
});
|
||||
$values['site_social_profiles'] = json_encode( array_filter( $values['site_social_profiles'], function( $value ) {
|
||||
return (bool) $value['key'];
|
||||
} ) );
|
||||
|
||||
$values['site_address'] = json_encode( $values['site_address'] );
|
||||
$values['icons_favicon'] = (string) $values['icons_favicon'];
|
||||
|
||||
$values = \IPS\core\modules\admin\customization\icons::processApplicationIcon( $values );
|
||||
$values = \IPS\core\modules\admin\settings\terms::processForm( $values );
|
||||
|
||||
/* If a logo was uploaded, do stuff with it... */
|
||||
if( isset( $values['initial_logo'] ) )
|
||||
{
|
||||
$values['email_logo'] = (string) $values['initial_logo'];
|
||||
|
||||
/* Do this once for efficiency */
|
||||
$image = \IPS\Image::create( $values['initial_logo']->contents() );
|
||||
$width = $image->width;
|
||||
$height = $image->height;
|
||||
unset( $image );
|
||||
|
||||
foreach( \IPS\Theme::themes() as $theme )
|
||||
{
|
||||
$logoUrl = (string) \IPS\File::create( 'core_Theme', $values['initial_logo']->originalFilename, $values['initial_logo']->contents(), NULL, TRUE );
|
||||
|
||||
$theme->saveSet( array( 'logo' => array( 'front' => array( 'url' => $logoUrl, 'width' => $width, 'height' => $height ) ) ) );
|
||||
}
|
||||
|
||||
unset( $values['initial_logo'] );
|
||||
}
|
||||
elseif( array_key_exists( 'initial_logo', $values ) )
|
||||
{
|
||||
unset( $values['initial_logo'] );
|
||||
}
|
||||
|
||||
$form->saveAsSettings( $values );
|
||||
|
||||
/* Clear create menu caches */
|
||||
\IPS\Member::clearCreateMenu();
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
/* Clear data stores */
|
||||
unset(
|
||||
\IPS\Data\Store::i()->manifest,
|
||||
\IPS\Data\Store::i()->iebrowserconfig,
|
||||
\IPS\Data\Store::i()->frontNavigation
|
||||
);
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__onboard_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=onboard&do=next' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('onboard_pagetitle_basic');
|
||||
\IPS\Output::i()->output .= $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'dashboard' ), 'onboardForm' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'settings/general.css', 'core', 'admin' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a confirmation screen with "next steps"
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function next()
|
||||
{
|
||||
\IPS\Output::i()->showTitle = FALSE;
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('onboard_pagetitle');
|
||||
|
||||
/* Add Emoji - We can't put this directly in the template since those without utf8mb4 will have issues */
|
||||
\IPS\Member::loggedIn()->language()->words['onboard_complete'] .= ' 🎉';
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'dashboard' )->onboard();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user