Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

@@ -61,9 +61,9 @@ class _databases extends \IPS\Node\Controller
);
$table->mainColumn = 'database_name';
$table->quickSearch = 'word_custom';
$table->quickSearch = 'database_name';
$table->sortBy = $table->sortBy ?: 'word_custom';
$table->sortBy = $table->sortBy ?: 'database_name';
$table->sortDirection = $table->sortDirection ?: 'asc';
/* Parsers */
@@ -121,15 +121,19 @@ class _databases extends \IPS\Node\Controller
return \IPS\Db::i()->select( 'SUM(category_records)', 'cms_database_categories', array( 'category_database_id=?', $row['database_id'] ) )->first();
}
);
/* Buttons */
\IPS\Output::i()->sidebar['actions']['add'] = array(
'primary' => true,
'title' => 'add',
'icon' => 'plus',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=add' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_database_add') )
);
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'databases', 'databases_add' ) )
{
/* Buttons */
\IPS\Output::i()->sidebar['actions']['add'] = array(
'primary' => true,
'title' => 'add',
'icon' => 'plus',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=add' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_database_add') )
);
}
/*if ( \IPS\Application::appIsEnabled('forums') )
{
@@ -225,6 +229,8 @@ class _databases extends \IPS\Node\Controller
*/
public function add()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'databases_add' );
$form = new \IPS\Helpers\Form( 'form', 'next' );
$form->addTab( 'cms_database_add_new' );
@@ -259,6 +265,8 @@ class _databases extends \IPS\Node\Controller
*/
public function import()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'databases_add' );
if ( !file_exists( \IPS\Request::i()->file ) or md5_file( \IPS\Request::i()->file ) !== \IPS\Request::i()->key )
{
\IPS\Output::i()->error( 'generic_error', '3T259/3', 403, '' );
@@ -284,7 +292,7 @@ class _databases extends \IPS\Node\Controller
if ( !is_array( $data ) )
{
$database = new \IPS\cms\Databases;
$database->key = uniqid();
$database->key = mt_rand();
$database->save();
/* Set default perms, these will be editable post DB import */
@@ -488,7 +496,13 @@ class _databases extends \IPS\Node\Controller
$attrs[ $k ] = ( $tryJson ) ? $tryJson : (string) $v;
}
/* Check to ensure we have the same field type, if not default to text so data is retained (buildHelper also does this */
if ( ! class_exists( '\IPS\cms\Fields\\' . mb_ucfirst( $attrs['field_type'] ) ) and ! class_exists( '\IPS\Helpers\Form\\' . mb_ucfirst( $attrs['field_type'] ) ) )
{
$attrs['field_type'] = 'Text';
}
$attrs['_skip_formatting'] = TRUE;
$originalFieldId = $attrs['field_id'];
@@ -761,23 +775,34 @@ class _databases extends \IPS\Node\Controller
}
}
}
unset( \IPS\Data\Store::i()->db_import_cat_map );
unset( \IPS\Data\Store::i()->db_import_cat_parent_map );
unset( \IPS\Data\Store::i()->db_import_field_map );
}
$databaseId = \IPS\Data\Store::i()->db_import_db_id;
unset( \IPS\Data\Store::i()->db_import_db_id );
$database = \IPS\cms\Databases::load( $databaseId );
/* SORT IT OUT! */
if ( isset( \IPS\Data\Store::i()->db_import_field_map ) )
{
$map = \IPS\Data\Store::i()->db_import_field_map;
$sortId = intval( mb_substr( $database->field_sort, 6 ) );
if ( isset( $map[ $sortId ] ) )
{
$database->field_sort = 'field_' . $map[ $sortId ];
$database->save();
}
}
foreach( array( 'template_listing', 'template_display', 'template_categories', 'template_form', 'template_featured' ) as $name )
{
\IPS\cms\Templates::fixTemplateTags( $database->$name );
}
unset( \IPS\Data\Store::i()->db_import_db_id );
unset( \IPS\Data\Store::i()->db_import_cat_map );
unset( \IPS\Data\Store::i()->db_import_cat_parent_map );
unset( \IPS\Data\Store::i()->db_import_field_map );
@unlink( \IPS\Request::i()->file );
/* Done */
@@ -1147,6 +1172,24 @@ class _databases extends \IPS\Node\Controller
}
}
/**
* Resynchronise article comment counts
*
* @return void
*/
public function rebuildCommentCounts()
{
if ( isset( \IPS\Request::i()->process ) )
{
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\cms\Records' . \IPS\Request::i()->id ), 3, array( 'class' ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=form&id=' . \IPS\Request::i()->id ), 'database_rebuild_added' );
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'databases', 'cms', 'admin' )->rebuildCommentCounts( \IPS\Request::i()->id );
}
}
/**
* Add/Edit
*
@@ -1178,7 +1221,7 @@ class _databases extends \IPS\Node\Controller
{
$new = TRUE;
$current = new \IPS\cms\Databases;
$current->key = uniqid(); # This is modified below to use a proper key
$current->key = mt_rand(); # This is modified below to use a proper key
$current->featured_settings = NULL;
$current->fixed_field_perms = NULL;
$current->save();
@@ -1203,7 +1246,7 @@ class _databases extends \IPS\Node\Controller
{
if ( is_array( $values['database_name'] ) )
{
$keyToUse = uniqid();
$keyToUse = mt_rand();
foreach( $values['database_name'] as $langId => $word )
{
if ( ! empty( $word ) )
@@ -1228,7 +1271,7 @@ class _databases extends \IPS\Node\Controller
/* It's taken... */
if ( $current->id != $database->id )
{
$current->key .= '_' . uniqid();
$current->key .= '_' . mt_rand();
}
}
catch( \OutOfRangeException $ex )
@@ -1415,7 +1458,7 @@ class _databases extends \IPS\Node\Controller
{
\IPS\Db::i()->insert( 'cms_page_widget_areas', array(
'area_page_id' => $newPage->id,
'area_widgets' => json_encode( array( array( 'app' => 'cms', 'key' => 'Database', 'unique' => uniqid(), 'configuration' => array( 'database' => $current->id ) ) ) ),
'area_widgets' => json_encode( array( array( 'app' => 'cms', 'key' => 'Database', 'unique' => mt_rand(), 'configuration' => array( 'database' => $current->id ) ) ) ),
'area_area' => 'col1',
'area_orientation' => 'horizontal'
) );
@@ -1771,7 +1814,11 @@ class _databases extends \IPS\Node\Controller
if ( $current )
{
$rebuildUrl = \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&id=' . $current->id . '&do=rebuildTopicContent' );
\IPS\Member::loggedIn()->language()->words['database_forum_record_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__desc' ) . ' ' . \IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__rebuild', NULL, array( 'sprintf' => array( $rebuildUrl ) ) );
$rebuildUrlCounts = \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&id=' . $current->id . '&do=rebuildCommentCounts' );
\IPS\Member::loggedIn()->language()->words['database_forum_record_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__desc' ) . ' ' .
\IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__rebuild', NULL, array( 'sprintf' => array( $rebuildUrl ) ) ) . ' ' .
\IPS\Member::loggedIn()->language()->addToStack( 'database_forum_comments__rebuild', NULL, array( 'sprintf' => array( $rebuildUrlCounts ) ) );
}
else
{
@@ -1824,7 +1871,7 @@ class _databases extends \IPS\Node\Controller
/* Overwrite field */
$field = new \IPS\Helpers\Form\Translatable( 'page_name', FALSE, NULL, array( 'app' => 'cms', 'key' => NULL, 'maxLength' => 64 ), function( $val )
{
if ( empty( $val ) AND \IPS\Request::i()->database_create_page === 'new' )
if ( !trim( $val[ \IPS\Lang::defaultLanguage() ] ) AND \IPS\Request::i()->database_create_page === 'new' )
{
throw new \DomainException('form_required');
}
@@ -144,26 +144,35 @@ class _records extends \IPS\Dispatcher\Controller
/* Buttons */
$table->rowButtons = function( $row )
{
return array(
'edit' => array(
'title' => 'edit',
'icon' => 'pencil',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&database_id=' . \IPS\Request::i()->database_id . '&id=' . $row['primary_id_field'] . '&do=form' ),
'data' => array()
),
'move' => array(
$return = array();
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'databases', 'records_edit' ) )
{
$return['edit'] = array(
'title' => 'edit',
'icon' => 'pencil',
'link' => \IPS\Http\Url::internal('app=cms&module=databases&controller=records&database_id=' . \IPS\Request::i()->database_id . '&id=' . $row['primary_id_field'] . '&do=form'),
'data' => array()
);
}
$return['move'] = array(
'title' => 'move',
'icon' => 'arrow-right',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&database_id=' . \IPS\Request::i()->database_id . '&do=select&move=' . $row['primary_id_field'] ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('database_select_category' ) )
),
'delete' => array(
);
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'databases', 'records_delete' ) )
{
$return['delete'] = array(
'title' => 'delete',
'icon' => 'times-circle',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&database_id=' . \IPS\Request::i()->database_id . '&id=' . $row['primary_id_field'] . '&do=delete' ),
'data' => array( 'delete' => '' )
),
);
);
}
return $return;
};
$table->parsers = array(
@@ -244,7 +253,7 @@ class _records extends \IPS\Dispatcher\Controller
}
catch( \OutofRangeException $ex )
{
\IPS\Output::i()->error( 'no_permission', '2T253/1', 403, '' );
\IPS\Output::i()->error( 'no_module_permission', '2T253/1', 403, '' );
}
/* Clear guest page caches */
@@ -323,6 +332,8 @@ class _records extends \IPS\Dispatcher\Controller
*/
public function form()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'records_edit' );
$database = \IPS\cms\Databases::load( \IPS\Request::i()->database_id );
$title = \IPS\Member::loggedIn()->language()->addToStack('content_record_db_title', TRUE, array( 'sprintf' => array( $database->_title ) ) );
@@ -450,7 +461,7 @@ class _records extends \IPS\Dispatcher\Controller
/* Claim attachments */
foreach( $fieldClass::data() as $key => $field )
{
if ( ucfirst( $field->type ) === 'Editor' )
if ( mb_ucfirst( $field->type ) === 'Editor' )
{
\IPS\File::claimAttachments( 'RecordField_'. $field->id , $current->id, NULL, 'RecordField_'. $field->id, FALSE );
}