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

@@ -0,0 +1,94 @@
<?php
/**
* @brief File Storage Extension: Categories
* @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
* @subpackage Pages
* @since 18 Dec 2023
*/
namespace IPS\cms\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
use IPS\Db;
use IPS\Extensions\FileStorageAbstract;
use IPS\File;
use OutOfRangeException;
use UnderflowException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* File Storage Extension: Categories
*/
class Categories extends FileStorageAbstract
{
/**
* Count stored files
*
* @return int
*/
public function count(): int
{
return (int) Db::i()->select( 'count(category_id)', 'cms_database_categories', 'category_image is not null' )->first();
}
/**
* Move stored files
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|NULL $oldConfiguration Old storage configuration ID
* @throws UnderflowException When file record doesn't exist. Indicating there are no more files to move
* @return void
*/
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
{
$row = Db::i()->select( 'category_id,category_image', 'cms_database_categories', 'category_image is not null', 'category_id', array( $offset, 1 ) )->first();
try
{
$file = File::get( $oldConfiguration ?: 'cms_Categories', $row['category_image'] )->move( $storageConfiguration );
if( (string) $file != $row['category_image'] )
{
Db::i()->update( 'cms_database_categories', [ 'category_image' => (string) $file ], [ 'category_id=?', $row['category_id']] );
}
}
catch( OutOfRangeException ){}
}
/**
* Check if a file is valid
*
* @param File|string $file The file path to check
* @return bool
*/
public function isValidFile( File|string $file ): bool
{
return (bool) Db::i()->select( 'count(category_id)', 'cms_database_categories', [ 'category_image=?', (string) $file ] )->first();
}
/**
* Delete all stored files
*
* @return void
*/
public function delete() : void
{
foreach( Db::i()->select( 'category_image', 'cms_database_categories', 'category_image is not null', 'category_id' ) as $image )
{
try
{
File::get( 'cms_Categories', $image )->delete();
}
catch( OutOfRangeException ){}
}
}
}
@@ -12,25 +12,33 @@
namespace IPS\cms\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\Db;
use IPS\Extensions\FileStorageAbstract;
use IPS\File;
use UnderflowException;
use function defined;
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;
}
/**
* File Storage Extension: CMS Media
*/
class _Media
class Media extends FileStorageAbstract
{
/**
* Count stored files
*
* @return int
*/
public function count()
public function count(): int
{
return \IPS\Db::i()->select( 'COUNT(*)', 'cms_media' )->first();
return Db::i()->select( 'COUNT(*)', 'cms_media' )->first();
}
/**
@@ -39,59 +47,43 @@ class _Media
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|NULL $oldConfiguration Old storage configuration ID
* @throws \UnderflowException When file record doesn't exist. Indicating there are no more files to move
* @return void|int An offset integer to use on the next cycle, or nothing
* @throws UnderflowException When file record doesn't exist. Indicating there are no more files to move
* @return void An offset integer to use on the next cycle, or nothing
*/
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
{
$media = \IPS\Db::i()->select( '*', 'cms_media', array(), 'media_id', array( $offset, 1 ) )->first();
$media = Db::i()->select( '*', 'cms_media', array(), 'media_id', array( $offset, 1 ) )->first();
try
{
$file = \IPS\File::get( $oldConfiguration ?: 'cms_Media', $media['media_file_object'] )->move( $storageConfiguration );
$file = File::get( $oldConfiguration ?: 'cms_Media', $media['media_file_object'] )->move( $storageConfiguration );
if ( (string) $file != $media['media_file_object'] )
{
\IPS\Db::i()->update( 'cms_media', array( 'media_file_object' => (string) $file ), array( 'media_id=?', $media['media_id'] ) );
Db::i()->update( 'cms_media', array( 'media_file_object' => (string) $file ), array( 'media_id=?', $media['media_id'] ) );
}
}
catch( \Exception $e )
catch( Exception $e )
{
/* Any issues are logged */
}
}
/**
* Fix all URLs
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @return void
*/
public function fixUrls( $offset )
{
$media = \IPS\Db::i()->select( '*', 'cms_media', array(), 'media_id', array( $offset, 1 ) )->first();
if ( $new = \IPS\File::repairUrl( $media['media_file_object'] ) )
{
\IPS\Db::i()->update( 'cms_media', array( 'media_file_object' => $new ), array( 'media_id=?', $media['media_id'] ) );
}
}
/**
* Check if a file is valid
*
* @param string $file The file path to check
* @param File|string $file The file path to check
* @return bool
*/
public function isValidFile( $file )
public function isValidFile( File|string $file ): bool
{
try
{
$media = \IPS\Db::i()->select( '*', 'cms_media', array( 'media_file_object=?', (string) $file ) )->first();
$media = Db::i()->select( '*', 'cms_media', array( 'media_file_object=?', (string) $file ) )->first();
return TRUE;
}
catch ( \UnderflowException $e )
catch ( UnderflowException $e )
{
return FALSE;
}
@@ -102,15 +94,15 @@ class _Media
*
* @return void
*/
public function delete()
public function delete() : void
{
foreach( \IPS\Db::i()->select( '*', 'cms_media', 'media_file_object IS NOT NULL' ) as $item )
foreach( Db::i()->select( '*', 'cms_media', 'media_file_object IS NOT NULL' ) as $item )
{
try
{
\IPS\File::get( 'cms_Media', $item['media_file_object'] )->delete();
File::get( 'cms_Media', $item['media_file_object'] )->delete();
}
catch( \Exception $e ){}
catch( Exception $e ){}
}
}
}
@@ -12,23 +12,32 @@
namespace IPS\cms\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\cms\Pages\Page;
use IPS\Db;
use IPS\Db\Exception;
use IPS\Extensions\FileStorageAbstract;
use IPS\File;
use UnderflowException;
use function defined;
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;
}
/**
* File Storage Extension: CMS Pages
*/
class _Pages
class Pages extends FileStorageAbstract
{
/**
* Count stored files
*
* @return int
*/
public function count()
public function count(): int
{
return 1; # Number of steps needed to clear/move files
}
@@ -39,48 +48,34 @@ class _Pages
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|NULL $oldConfiguration Old storage configuration ID
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
* @throws Underflowexception When file record doesn't exist. Indicating there are no more files to move
* @return void
*/
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
{
/* Just remove page object data so it will rebuild on the next iteration */
\IPS\cms\Pages\Page::deleteCachedIncludes( NULL, $oldConfiguration );
Page::deleteCachedIncludes( NULL, $oldConfiguration );
throw new \UnderflowException;
}
/**
* Fix all URLs
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @return void
*/
public function fixUrls( $offset )
{
/* Just remove page object data so it will rebuild on the next iteration */
\IPS\cms\Pages\Page::deleteCachedIncludes();
throw new \UnderflowException;
throw new UnderflowException;
}
/**
* Check if a file is valid
*
* @param string $file The file path to check
* @param File|string $file The file path to check
* @return bool
*/
public function isValidFile( $file )
public function isValidFile( File|string $file ): bool
{
$bits = explode( '/', (string) $file );
$name = array_pop( $bits );
try
{
foreach( \IPS\Db::i()->select( '*', 'cms_templates', array( "template_file_object LIKE '%" . \IPS\Db::i()->escape_string( $name ) . "%'") ) as $template )
foreach( Db::i()->select( '*', 'cms_templates', array( "template_file_object LIKE '%" . Db::i()->escape_string( $name ) . "%'") ) as $template )
{
$fileObject = \IPS\File::get( 'core_Theme', $template['template_file_object'] );
$fileObject = File::get( 'core_Theme', $template['template_file_object'] );
if( $fileObject->url == (string) $file )
{
@@ -90,7 +85,7 @@ class _Pages
return FALSE;
}
catch( \IPS\Db\Exception $e )
catch( Exception $e )
{
return FALSE;
}
@@ -101,8 +96,8 @@ class _Pages
*
* @return void
*/
public function delete()
public function delete() : void
{
\IPS\cms\Pages\Page::deleteCachedIncludes();
Page::deleteCachedIncludes();
}
}
@@ -0,0 +1,94 @@
<?php
/**
* @brief File Storage Extension: PagesImages
* @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
* @subpackage Pages
* @since 15 Dec 2023
*/
namespace IPS\cms\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
use Exception;
use IPS\Db;
use IPS\Extensions\FileStorageAbstract;
use IPS\File;
use UnderflowException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* File Storage Extension: PagesImages
*/
class PagesImages extends FileStorageAbstract
{
/**
* Count stored files
*
* @return int
*/
public function count(): int
{
return (int) Db::i()->select( 'COUNT(page_id)', 'cms_pages', 'page_meta_image is not null' )->first();
}
/**
* Move stored files
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|NULL $oldConfiguration Old storage configuration ID
* @throws UnderflowException When file record doesn't exist. Indicating there are no more files to move
* @return void
*/
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
{
$row = Db::i()->select( 'page_id,page_meta_image', 'cms_pages', 'page_meta_image is not null', 'page_id', [ $offset, 1 ] )->first();
try
{
$file = File::get( $oldConfiguration ?: 'cms_PagesImages', $row['page_meta_image'] )->move( $storageConfiguration );
if( (string) $file != $row['page_meta_image'] )
{
Db::i()->update( 'cms_pages', [ 'page_meta_image' => (string) $file ], [ 'page_id=?', $row['page_id'] ] );
}
}
catch( Exception ){}
}
/**
* Check if a file is valid
*
* @param File|string $file The file path to check
* @return bool
*/
public function isValidFile( File|string $file ): bool
{
return (bool) Db::i()->select( 'count(page_id)', 'cms_pages', [ 'page_meta_image=?', (string) $file ] )->first();
}
/**
* Delete all stored files
*
* @return void
*/
public function delete() : void
{
foreach( Db::i()->select( 'page_meta_image', 'cms_pages', 'page_meta_image is not null', 'page_id' ) as $image )
{
try
{
File::get( 'cms_PagesImages', $image )->delete();
}
catch( Exception ){}
}
}
}
@@ -12,33 +12,45 @@
namespace IPS\cms\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\cms\Databases;
use IPS\Data\Store;
use IPS\Db;
use IPS\Extensions\FileStorageAbstract;
use IPS\File;
use UnderflowException;
use function count;
use function defined;
use function is_array;
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;
}
/**
* File Storage Extension: Records
*/
class _Records
class Records extends FileStorageAbstract
{
/**
* Count stored files
*
* @return int
*/
public function count()
public function count(): int
{
$count = 0;
$fields = array();
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'LOWER(field_type)=\'upload\'' ) ) as $field )
foreach( Db::i()->select( '*', 'cms_database_fields', array( 'LOWER(field_type)=\'upload\'' ) ) as $field )
{
$fields[ $field['field_database_id'] ][] = $field['field_id'];
}
foreach( \IPS\cms\Databases::databases() as $id => $db )
foreach( Databases::databases() as $id => $db )
{
$where = array( 'record_image IS NOT NULL' );
@@ -50,7 +62,7 @@ class _Records
}
}
$count += \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $id, implode( ' OR ', $where ) )->first();
$count += Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $id, implode( ' OR ', $where ) )->first();
}
return $count;
@@ -62,29 +74,29 @@ class _Records
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|NULL $oldConfiguration Old storage configuration ID
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
* @throws Underflowexception When file record doesn't exist. Indicating there are no more files to move
* @return void
*/
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
{
if ( ! isset( \IPS\Data\Store::i()->cms_files_move_data ) )
if ( ! isset( Store::i()->cms_files_move_data ) )
{
foreach( \IPS\cms\Databases::databases() as $id => $database )
foreach( Databases::databases() as $id => $database )
{
$data[ $id ] = 0;
}
\IPS\Data\Store::i()->cms_files_move_data = $data;
Store::i()->cms_files_move_data = $data;
}
$data = \IPS\Data\Store::i()->cms_files_move_data;
if ( !is_countable( $data ) OR ! \count( $data ) )
$data = Store::i()->cms_files_move_data;
if ( ! is_countable( $data ) OR ! count( $data ) )
{
/* all done */
unset( \IPS\Data\Store::i()->cms_files_move_data );
unset( Store::i()->cms_files_move_data );
throw new \UnderflowException;
throw new UnderflowException;
}
reset( $data );
@@ -93,7 +105,7 @@ class _Records
$done = 0;
$fields = array( 'record_image', 'record_image_thumb' );
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_database_id=? AND LOWER(field_type)=\'upload\'', $databaseId ) ) as $field )
foreach( Db::i()->select( '*', 'cms_database_fields', array( 'field_database_id=? AND LOWER(field_type)=\'upload\'', $databaseId ) ) as $field )
{
$fields[] = 'field_' . $field['field_id'];
}
@@ -107,7 +119,7 @@ class _Records
$where = array( implode( ' OR ', $conditions ) );
foreach( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, $where, 'primary_id_field ASC', array( $realOffset, 1 ) ) as $row )
foreach( Db::i()->select( '*', 'cms_custom_database_' . $databaseId, $where, 'primary_id_field ASC', array( $realOffset, 1 ) ) as $row )
{
foreach( $fields as $field )
{
@@ -122,7 +134,6 @@ class _Records
$files = array( $row[ $field ] );
}
$finished = array();
$save = FALSE;
$fixed = FALSE;
@@ -130,7 +141,7 @@ class _Records
{
try
{
$check = \IPS\File::get( $oldConfiguration ?: 'cms_Records', $file )->move( $storageConfiguration );
$check = File::get( $oldConfiguration ?: 'cms_Records', $file )->move( $storageConfiguration );
if ( (string) $file != $check )
{
@@ -142,7 +153,7 @@ class _Records
$save[] = $file;
}
}
catch( \Exception $e )
catch( Exception $e )
{
$save[] = $file;
}
@@ -150,7 +161,7 @@ class _Records
if ( $fixed )
{
\IPS\Db::i()->update( 'cms_custom_database_' . $databaseId, array( $field => implode( ',', $save ) ), array( 'primary_id_field=?', $row['primary_id_field'] ) );
Db::i()->update( 'cms_custom_database_' . $databaseId, array( $field => implode( ',', $save ) ), array( 'primary_id_field=?', $row['primary_id_field'] ) );
}
}
}
@@ -168,169 +179,48 @@ class _Records
unset( $data[ $databaseId ] );
}
if ( ! \count( $data ) )
if ( ! count( $data ) )
{
if ( isset( \IPS\Data\Store::i()->cms_files_move_data ) )
if ( isset( Store::i()->cms_files_move_data ) )
{
unset( \IPS\Data\Store::i()->cms_files_move_data );
unset( Store::i()->cms_files_move_data );
}
throw new \Underflowexception;
throw new Underflowexception;
}
else
{
\IPS\Data\Store::i()->cms_files_move_data = $data;
}
}
/**
* Fix all URLs
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @return void
*/
public function fixUrls( $offset )
{
if ( ! isset( \IPS\Data\Store::i()->cms_files_repair_data ) )
{
foreach( \IPS\cms\Databases::databases() as $id => $database )
{
$data[ $id ] = 0;
}
\IPS\Data\Store::i()->cms_files_repair_data = $data;
}
$data = \IPS\Data\Store::i()->cms_files_repair_data;
if ( ! \count( $data ) )
{
/* all done */
unset( \IPS\Data\Store::i()->cms_files_repair_data );
throw new \UnderflowException;
}
reset( $data );
$databaseId = key( $data );
$realOffset = $data[ $databaseId ];
$done = 0;
$fields = array( 'record_image', 'record_image_thumb' );
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_database_id=? AND LOWER(field_type)=\'upload\'', $databaseId ) ) as $field )
{
$fields[] = 'field_' . $field['field_id'];
}
$conditions = array();
foreach( $fields as $field )
{
$conditions[] = $field . ' IS NOT NULL';
}
$where = array( implode( ' OR ', $conditions ) );
foreach( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, $where, 'primary_id_field ASC', array( $realOffset, 1 ) ) as $row )
{
foreach( $fields as $field )
{
if ( isset( $row[ $field ] ) and ! empty( $row[ $field ] ) )
{
if ( mb_strstr( $row[ $field ], ',' ) )
{
$files = explode( ',', $row[ $field ] );
}
else
{
$files = array( $row[ $field ] );
}
$finished = array();
$save = FALSE;
foreach( $files as $file )
{
try
{
if ( $new = \IPS\File::repairUrl( $file ) )
{
$fixed = TRUE;
$save[] = $new;
}
else
{
$save[] = $file;
}
}
catch( \Exception $e )
{
$save[] = $file;
}
}
if ( $fixed )
{
\IPS\Db::i()->update( 'cms_custom_database_' . $databaseId, array( $field => implode( ',', $save ) ), array( 'primary_id_field=?', $row['primary_id_field'] ) );
}
}
}
$done++;
}
if ( $done )
{
$data[ $databaseId ] = $realOffset + 1;
}
else
{
/* Assume all done */
unset( $data[ $databaseId ] );
}
if ( ! \count( $data ) )
{
if ( isset( \IPS\Data\Store::i()->cms_files_repair_data ) )
{
unset( \IPS\Data\Store::i()->cms_files_repair_data );
}
throw new \Underflowexception;
}
else
{
\IPS\Data\Store::i()->cms_files_repair_data = $data;
Store::i()->cms_files_move_data = $data;
}
}
/**
* Check if a file is valid
*
* @param string $file The file path to check
* @param File|string $file The file path to check
* @return bool
*/
public function isValidFile( $file )
public function isValidFile( File|string $file ): bool
{
try
{
foreach( \IPS\cms\Databases::databases() as $id => $db )
foreach( Databases::databases() as $id => $db )
{
$theFile = \IPS\Db::i()->select( '*', 'cms_custom_database_' . $id, array( 'record_image=? OR record_image_thumb=?', (string) $file, (string) $file ) )->first();
$theFile = Db::i()->select( '*', 'cms_custom_database_' . $id, array( 'record_image=? OR record_image_thumb=?', (string) $file, (string) $file ) )->first();
return TRUE;
}
}
catch ( \UnderflowException $e )
catch ( UnderflowException $e )
{
/* Gather all the upload fields */
$fields = array();
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'LOWER(field_type)=\'upload\'' ) ) as $field )
foreach( Db::i()->select( '*', 'cms_database_fields', array( 'LOWER(field_type)=\'upload\'' ) ) as $field )
{
$fields[ $field['field_database_id'] ][] = $field['field_id'];
}
if ( \is_array( $fields ) )
if ( is_array( $fields ) )
{
foreach( $fields as $databaseId => $data )
{
@@ -338,11 +228,11 @@ class _Records
{
try
{
$record = \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, 'field_' . $fieldId . " LIKE '%" . (string) $file . "%'" )->first();
$record = Db::i()->select( '*', 'cms_custom_database_' . $databaseId, 'field_' . $fieldId . " LIKE '%" . (string) $file . "%'" )->first();
return TRUE;
}
catch ( \UnderflowException $e )
catch ( UnderflowException $e )
{
/* Might be in another field */
}
@@ -360,12 +250,12 @@ class _Records
*
* @return void
*/
public function delete()
public function delete() : void
{
foreach( \IPS\cms\Databases::databases() as $databaseId => $database )
foreach( Databases::databases() as $databaseId => $database )
{
$fields = array( 'record_image', 'record_image_thumb' );
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_database_id=? AND LOWER(field_type)=\'upload\'', $databaseId ) ) as $field )
foreach( Db::i()->select( '*', 'cms_database_fields', array( 'field_database_id=? AND LOWER(field_type)=\'upload\'', $databaseId ) ) as $field )
{
$fields[] = 'field_' . $field['field_id'];
}
@@ -377,13 +267,13 @@ class _Records
$where[] = array( $field . ' IS NOT NULL' );
}
foreach( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $databaseId, $where, 'primary_id_field ASC' ) as $row )
foreach( Db::i()->select( '*', 'cms_custom_database_' . $databaseId, $where, 'primary_id_field ASC' ) as $row )
{
foreach( $fields as $field )
{
if ( isset( $row[ $field ] ) and ! empty( $row[ $field ] ) )
{
$file = \IPS\File::get( 'cms_Records', $row[ $field ] )->delete();
File::get( 'cms_Records', $row[ $field ] )->delete();
}
}
}