Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

@@ -2,9 +2,9 @@
/**
* @brief File Settings
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 06 May 2013
* @version SVN_VERSION_NUMBER
*/
@@ -61,6 +61,7 @@ class _files extends \IPS\Dispatcher\Controller
);
}
/* @todo - This needs fixing but has been temporarily been disabled
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'core', 'overview', 'orphaned_files' ) )
{
\IPS\Output::i()->sidebar['actions']['orphaned'] = array(
@@ -69,7 +70,7 @@ class _files extends \IPS\Dispatcher\Controller
'title' => 'orphaned_files',
'data' => array( 'confirm' => '', 'confirmMessage' => \IPS\Member::loggedIn()->language()->addToStack('orphaned_files_confirm') )
);
}
}*/
$table = new \IPS\Helpers\Table\Db( 'core_attachments', \IPS\Http\Url::internal( 'app=core&module=overview&controller=files' ) );
$table->filters = array(
@@ -127,7 +128,15 @@ class _files extends \IPS\Dispatcher\Controller
},
'attach_member_id' => function( $val )
{
return "<a href='" . \IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=edit&id=' . $val ) . "'>" . htmlentities( \IPS\Member::load( $val )->name, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '</a>';
if ( $val == 0 )
{
return \IPS\Member::load( $val )->name;
}
else
{
return "<a href='" . \IPS\Http\Url::internal( 'app=core&module=members&controller=members&do=edit&id=' . $val ) . "'>" . htmlentities( \IPS\Member::load( $val )->name, \IPS\HTMLENTITIES, 'UTF-8', FALSE ) . '</a>';
}
}
);
$table->advancedSearch = array(
@@ -216,6 +225,9 @@ class _files extends \IPS\Dispatcher\Controller
public function delete()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'files_delete' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
try
{
@@ -249,9 +261,9 @@ class _files extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form;
$form->add( new \IPS\Helpers\Form\Radio( 'image_suite', \IPS\Settings::i()->image_suite, TRUE, array(
$form->add( new \IPS\Helpers\Form\Radio( 'image_suite', class_exists( 'Imagick', FALSE ) ? \IPS\Settings::i()->image_suite : 'gd', TRUE, array(
'options' => array( 'gd' => 'imagesuite_gd', 'imagemagick' => 'imagesuite_imagemagick' ),
'toggles' => array( 'imagemagick' => array(), 'gd' => array( 'image_jpg_quality', 'image_png_quality_gd' ) ),
'toggles' => array( 'imagemagick' => array( 'image_jpg_quality' ), 'gd' => array( 'image_jpg_quality', 'image_png_quality_gd' ) ),
'disabled'=> class_exists( 'Imagick', FALSE ) ? array() : array( 'imagemagick' )
) ) );
@@ -314,8 +326,8 @@ class _files extends \IPS\Dispatcher\Controller
$value = $settings[ "filestorage__{$name}" ];
}
}
$form->add( new \IPS\Helpers\Form\Select( 'filestorage__' . $name, $value, TRUE, array( 'options' => $configurations, 'disabled' => $disabled ) ) );
$form->add( new \IPS\Helpers\Form\Select( 'filestorage__' . $name, (int) $value, TRUE, array( 'options' => $configurations, 'disabled' => $disabled ) ) );
if ( $disabled )
{
@@ -344,19 +356,34 @@ class _files extends \IPS\Dispatcher\Controller
{
if ( $settings[ $k ] != $v and $k != 'filestorage__core_Theme' )
{
$rebuild = TRUE;
/* 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;
$count = $extension->count();
$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 )
{
\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 ] );
}
}
}
}
@@ -421,6 +448,16 @@ class _files extends \IPS\Dispatcher\Controller
$activeTabContents = $table;
}
/* Add a button for settings */
\IPS\Output::i()->sidebar['actions'] = array(
'settings' => array(
'title' => 'settings',
'icon' => 'cog',
'link' => \IPS\Http\Url::internal( 'app=core&module=overview&controller=files&do=fileLogSettings' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('settings') )
),
);
/* Display */
if ( \IPS\Request::i()->isAjax() and !isset( \IPS\Request::i()->ajaxValidate ) )
@@ -434,6 +471,27 @@ class _files extends \IPS\Dispatcher\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->tabs( array( 'settings' => 'filestorage_settings', 'configurations' => 'filestorage_configurations' ), $activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=core&module=overview&controller=files&do=settings" ) );
}
}
/**
* Settings
*
* @return void
*/
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' ) );
if ( $values = $form->values() )
{
$form->saveAsSettings();
\IPS\Session::i()->log( 'acplog__filelog_settings' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=files&do=settings' ), 'saved' );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('filelog_settings');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('global')->block( 'filelog_settings', $form, FALSE );
}
/**
* Add/Edit Configuration
@@ -563,7 +621,7 @@ class _files extends \IPS\Dispatcher\Controller
{
foreach ( $toggles[ $values['filestorage_method'] ] as $k => $v )
{
$currentHandlerSettings[ $k ] = str_replace( \IPS\ROOT_PATH, '{root}', $values[ 'filehandler__' . $v ] );
$currentHandlerSettings[ $k ] = ( \IPS\ROOT_PATH !== '/' ) ? str_replace( \IPS\ROOT_PATH, '{root}', $values[ 'filehandler__' . $v ] ) : $values[ 'filehandler__' . $v ];
}
}
@@ -572,6 +630,37 @@ class _files extends \IPS\Dispatcher\Controller
{
$classname::testSettings( $currentHandlerSettings );
}
$existingWithSameConfig = false;
/* Make sure there are no other configurations that are exactly the same */
foreach( \IPS\Db::i()->select( '*', 'core_file_storage', array( 'method=?', $values['filestorage_method'] ) ) as $existing )
{
if ( $current and $current['id'] == $existing['id'] )
{
continue;
}
$existingWithSameConfig = true;
$existingConfiguration = json_decode( $existing['configuration'], true );
foreach( $existingConfiguration as $k => $v )
{
$v = str_replace( \IPS\ROOT_PATH, '{root}', $v );
if ( array_key_exists( $k, $currentHandlerSettings ) )
{
if ( $v != $currentHandlerSettings[ $k ] )
{
$existingWithSameConfig = false;
}
}
}
}
if ( $existingWithSameConfig )
{
/* Let's not allow this to be saved as someone can start a move to the same location, which will end up deleting the files */
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'file_config_is_the_same_as_existing', FALSE ) );
}
/* Do we really need to create and move? */
if ( $current AND $createNewAndMove )