Version 4.6.0

This commit is contained in:
Neo committed 2025-12-19 05:55:31 -08:00
1 parent f79dcf067a
commit 517a5e1f70
2036 files changed
+110041 -26162

No files matched your search

+112 -15
View File
@@ -112,6 +112,11 @@ class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public static $modalForms = FALSE;
/**
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
*/
public static $titleLangPrefix = 'content_db_';
/**
* [Brief] Bump on edit only
*/
@@ -480,6 +485,9 @@ class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions
'perm_3' => '*'
), array( 'perm_id=?', $perms['perm_id']) );
/* Save the db now to save custom field ids */
$database->save();
/* Create a category */
$categoryClass = '\IPS\cms\Categories' . $database->id;
$category = new $categoryClass;
@@ -927,26 +935,66 @@ class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions
$cat->delete();
}
$fileFields = array( 'record_image', 'record_image_thumb' );
$isMultiple = false;
foreach( $fieldsClass::roots( NULL ) as $id => $field )
{
$field->delete( TRUE );
if( $field->type == 'Upload' )
{
$fileFields[] = 'field_' . $field->id;
/* Delete thumbnails */
\IPS\Task::queue( 'core', 'FileCleanup', array(
'table' => 'cms_database_fields_thumbnails',
'column' => 'thumb_location',
'storageExtension' => 'cms_Records',
'where' => array( array( 'thumb_field_id=?', $field->id ) ),
'deleteRows' => TRUE
), 4 );
if( $field->is_multiple )
{
$isMultiple = TRUE;
}
}
}
/* Delete comments */
\IPS\Db::i()->delete( 'cms_database_comments', array( 'comment_database_id=?', $this->id ) );
\IPS\Db::i()->delete( 'cms_database_reviews', array( 'review_database_id=?', $this->id ) );
/* Delete from view counter */
\IPS\Db::i()->delete( 'core_view_updates', array( 'classname=? ', 'IPS\cms\Records' . $this->id ) );
/* Delete records */
\IPS\Db::i()->dropTable( 'cms_custom_database_' . $this->id, TRUE );
\IPS\Task::queue( 'core', 'FileCleanup', array(
'table' => 'cms_custom_database_' . $this->id,
'column' => $fileFields,
'storageExtension' => 'cms_Records',
'primaryId' => 'primary_id_field',
'dropTable' => 'cms_custom_database_' . $this->id,
'multipleFiles' => $isMultiple
), 4 );
/* Delete revisions */
\IPS\Db::i()->delete( 'cms_database_revisions', array( 'revision_database_id=?', $this->id ) );
/* Remove any reciprocal linking */
\IPS\Db::i()->delete( 'cms_database_fields_reciprocal_map', array( 'map_foreign_database_id=? or map_origin_database_id=?', $this->id, $this->id ) );
/* Remove any fields in other databases associated to this DB */
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields', array( 'field_type=?', 'Item' ) ) as $fieldData )
{
$fieldClass = '\IPS\cms\Fields' . $fieldData['field_database_id'];
if ($field = $fieldClass::load($fieldData['field_id']) AND isset( $field->extra['database'] ) and $field->extra['database'] AND $field->extra['database'] == $this->id )
{
$field->delete();
}
}
/* Delete notifications */
$memberIds = array();
@@ -963,6 +1011,8 @@ class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions
/* remove deletion log */
\IPS\Db::i()->delete( 'core_deletion_log', array( 'dellog_content_class=?', 'IPS\cms\Records' . $this->id ) );
\IPS\Db::i()->delete( 'core_deletion_log', array( 'dellog_content_class=?', 'IPS\cms\Records\Comment' . $this->id ) );
\IPS\Db::i()->delete( 'core_deletion_log', array( 'dellog_content_class=?', 'IPS\cms\Records\Review' . $this->id ) );
/* remove metadata */
\IPS\Db::i()->delete( 'core_content_meta', array( "meta_class=? ", 'IPS\cms\Records' . $this->id ) );
@@ -972,6 +1022,12 @@ class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions
\IPS\Member::load( $member )->recountNotifications();
}
/* Remove rss imports */
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'core_rss_import', array( 'rss_import_class=?', 'IPS\cms\Records' . $this->id ) ), 'IPS\core\Rss\Import' ) as $import )
{
$import->delete();
}
/* Remove from search */
\IPS\Content\Search\Index::i()->removeClassFromSearchIndex( 'IPS\cms\Records' . $this->id );
\IPS\Content\Search\Index::i()->removeClassFromSearchIndex( 'IPS\cms\Records\Comment' . $this->id );
@@ -1096,7 +1152,7 @@ class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions
}
/**
* Determines if any fields from other databases are linking to items in this database via the Relational field
* Determines if any fields from other databases are crosslinking to items in this database via the Relational field
*
* @param int $databaseId The ID of the database
* @return boolean
@@ -1136,7 +1192,59 @@ class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions
{
foreach( $fields as $fieldid => $data )
{
if ( $data['database'] == $databaseId and $data['crosslink'] )
if ( $data['database'] == $databaseId and !empty( $data['crosslink'] ) )
{
return TRUE;
}
}
}
}
return FALSE;
}
/**
* Determines if any fields from other databases are linking to items in this database via the Relational field
*
* @param int $databaseId The ID of the database
* @return boolean
*/
public static function isUsedAsReciprocalField( int $databaseId ) : bool
{
if ( isset( \IPS\Data\Store::i()->database_reciprocal_links ) )
{
$values = \IPS\Data\Store::i()->database_reciprocal_links;
}
else
{
$values = array();
foreach( static::databases() as $database )
{
$fieldsClass = 'IPS\cms\Fields' . $database->_id;
foreach( $fieldsClass::data() as $field )
{
if ( $field->type === 'Item' )
{
$extra = $field->extra;
if ( ! empty( $extra['database'] ) )
{
$values[ $database->_id ][] = $extra;
}
}
}
\IPS\Data\Store::i()->database_reciprocal_links = $values;
}
}
if ( \is_array( $values ) )
{
foreach( $values as $id => $fields )
{
foreach( $fields as $fieldid => $data )
{
if ( $data['database'] == $databaseId )
{
return TRUE;
}
@@ -1173,17 +1281,6 @@ class _Databases extends \IPS\Node\Model implements \IPS\Node\Permissions
}
}
/**
* Returns database data from the store
*
* @return array
* @deprecated
*/
public static function getDatabaseDataFromStore()
{
return static::getStore();
}
/**
* Get output for API
*