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,10 @@
/**
* @brief Fields Model
* @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
* @subpackage Content
* @since 8 April 2014
* @version SVN_VERSION_NUMBER
*/
@@ -45,7 +46,7 @@ class _categories extends \IPS\Node\Controller
$nodeClass = $this->nodeClass;
$childLang = \IPS\Member::loggedIn()->language()->addToStack( $nodeClass::$nodeTitle . '_add_child' );
$nodeClass::$nodeTitle = \IPS\Member::loggedIn()->language()->addToStack('content_cat_db_title', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( \IPS\Request::i()->database_id)->_title ) ) );
$nodeClass::$nodeTitle = \IPS\Member::loggedIn()->language()->addToStack('content_cat_db_title', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( \IPS\Request::i()->database_id )->_title ) ) );
\IPS\Member::loggedIn()->language()->words[ $nodeClass::$nodeTitle . '_add_child' ] = $childLang;
parent::execute();
}
@@ -70,4 +71,26 @@ class _categories extends \IPS\Node\Controller
return $rows;
}
/**
* Function to execute after nodes are reordered. Do nothing by default but plugins can extend.
*
* @param array $order The new ordering that was saved
* @return void
* @note Pages needs to readjust category_full_path values when a category is moved to a different category
*/
protected function _afterReorder( $order )
{
$categoryClass = $this->nodeClass;
foreach( $order as $parent => $nodes )
{
foreach ( $nodes as $id => $position )
{
$categoryClass::resetPath( $id );
}
}
return parent::_afterReorder( $order );
}
}
@@ -2,9 +2,10 @@
/**
* @brief Databases Model
* @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
* @subpackage Content
* @since 31 March 2014
* @version SVN_VERSION_NUMBER
*/
@@ -176,7 +177,7 @@ class _databases extends \IPS\Node\Controller
);
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'fields', 'fields_manage' ) )
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'fields', 'cms_fields_manage' ) )
{
$return['fields'] = array(
'title' => 'content_database_manage_fields',
@@ -204,7 +205,7 @@ class _databases extends \IPS\Node\Controller
'title' => 'delete',
'icon' => 'times-circle',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=delete&id=' . $row['database_id'] ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('delete') )
'data' => array( 'delete' => '' )
);
}
@@ -242,7 +243,7 @@ class _databases extends \IPS\Node\Controller
move_uploaded_file( $values['cms_database_import'], $tempFile );
/* Initate a redirector */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=import&file=' . urlencode( $tempFile ) . '&key=' . md5_file( $tempFile ) ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=import' )->setQueryString( array( 'file' => $tempFile, 'key' => md5_file( $tempFile ) ) ) );
}
else
{
@@ -266,15 +267,16 @@ class _databases extends \IPS\Node\Controller
}
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect(
\IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=import&file=' . urlencode( \IPS\Request::i()->file ) . '&key=' . \IPS\Request::i()->key ),
\IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=import' )->setQueryString( array( 'file' => \IPS\Request::i()->file, 'key' => \IPS\Request::i()->key ) ),
function( $data )
{
/* Open XML file */
$xml = new \XMLReader;
$xml = new \IPS\Xml\XMLReader;
$xml->open( \IPS\Request::i()->file );
if ( ! @$xml->read() )
{
@unlink( \IPS\Request::i()->file );
\IPS\Output::i()->error( 'xml_upload_invalid', '2C163/1', 403, '' );
}
@@ -371,8 +373,8 @@ class _databases extends \IPS\Node\Controller
\IPS\Lang::saveCustom( 'cms', "content_db_" . $database->id, $name );
\IPS\Lang::saveCustom( 'cms', "content_db_" . $database->id . '_desc', $desc );
\IPS\Lang::saveCustom( 'cms', "digest_area_records" . $database->id, $langs['content_db_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_categories" . $database->id, $langs['content_db_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_cms_records" . $database->id, $langs['content_db_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_cms_categories" . $database->id, $langs['content_db_lang_pu'] );
$menu = array();
@@ -420,29 +422,36 @@ class _databases extends \IPS\Node\Controller
$xml->read();
$next = NULL;
$areas = array( 'field', 'category', 'template' );
if ( $data['next'] )
{
while ( $xml->read() )
{
if( ! in_array( $xml->name, $areas ) OR $xml->nodeType != \XMLReader::ELEMENT )
{
continue;
}
$i++;
if ( $data['done'] )
{
if ( $i - 1 < $data['done'] )
{
$xml->next();
continue;
}
}
$doneSomething = false;
if ( $xml->name == $data['next'] )
{
$i++;
if ( $data['done'] )
{
if ( $i - 1 < $data['done'] )
{
$xml->next();
continue;
}
}
$data['done']++;
$areaName = $xml->name;
$node = new \SimpleXMLElement( $xml->readOuterXML() );
/* Import */
switch ( $areaName )
{
@@ -481,6 +490,8 @@ class _databases extends \IPS\Node\Controller
$attrs[ $k ] = ( $tryJson ) ? $tryJson : (string) $v;
}
$attrs['_skip_formatting'] = TRUE;
$originalFieldId = $attrs['field_id'];
unset( $attrs['field_id'] );
@@ -529,6 +540,7 @@ class _databases extends \IPS\Node\Controller
\IPS\Lang::saveCustom( 'cms', "content_field_" . $obj->id . '_validation_error', $attrs['field_validator_error'] );
}
$next = 'category';
$doneSomething = true;
break;
case 'category':
@@ -603,6 +615,7 @@ class _databases extends \IPS\Node\Controller
\IPS\Db::i()->update( 'core_permission_index', array_merge( $perms, array( 'perm_id' => $existingPerms['perm_id'], 'perm_type_id' => $category->id ) ), array( 'perm_id=?', $existingPerms['perm_id'] ) );
$next = 'template';
$doneSomething = true;
break;
case 'template':
@@ -621,84 +634,44 @@ class _databases extends \IPS\Node\Controller
$attrs[ $k ] = ( $tryJson ) ? $tryJson : (string) $v;
}
$add = FALSE;
$updateDb = FALSE;
if ( isset( $attrs['template_title'] ) and isset( $attrs['template_location'] ) and isset( $attrs['template_group'] ) )
$obj = new \IPS\cms\Templates;
$obj->location = $attrs['template_location'];
$obj->group = $attrs['template_group'];
$obj->title = $attrs['template_title'];
$obj->params = $attrs['template_params'];
$obj->content = $attrs['template_content'];
$obj->original_group = $attrs['template_original_group'];
$obj->user_created = 1;
$obj->user_edited = 1;
$obj->desc = '';
if ( $attrs['template_group'] !== 'template_form' )
{
/* Got this template? */
if ( isset( $templates['cms']['database'][ $attrs['template_location'] ][ $attrs['template_group'] ] ) )
$obj->group .= '_' . $database->id;
foreach( array( 'template_listing', 'template_display', 'template_categories', 'template_form', 'template_featured' ) as $name )
{
/* Compare with version stored in DB and don't bother importing unless we need to */
if ( $templates['cms']['database'][ $attrs['template_location'] ][ $attrs['template_group'] ]['template_content'] != $attrs['template_content'] )
if ( $database->$name == $attrs['template_group'] )
{
$updateDb = TRUE;
$add = TRUE;
}
}
else
{
$add = TRUE;
$updateDb = TRUE;
}
if ( $add )
{
$obj = new \IPS\cms\Templates;
$obj->location = $attrs['template_location'];
$obj->group = $attrs['template_group'];
$obj->title = $attrs['template_title'];
$obj->params = $attrs['template_params'];
$obj->content = $attrs['template_content'];
$obj->original_group = $attrs['template_original_group'];
$obj->user_created = 1;
$obj->user_edited = 1;
$obj->desc = '';
$obj->save();
$obj->key = 'database_' . \IPS\Http\Url::seoTitle( $obj->group ) . '_' . \IPS\Http\Url::seoTitle( $obj->title ) . '_' . $obj->id;
$obj->save();
$templateArea = NULL;
if ( $updateDb )
{
if ( $obj->group !== 'template_form' )
{
foreach( array( 'template_listing', 'template_display', 'template_categories', 'template_form', 'template_featured' ) as $name )
{
if ( $database->$name == $obj->group )
{
$templateArea = $name;
}
}
if ( $templateArea )
{
/* Template group has same name as existing */
$obj->group .= '_' . $database->_id;
$obj->save();
$database->$templateArea = $obj->group;
$database->save();
}
}
else if ( $database->template_form === $obj->title )
{
$templateArea = $obj->title;
if ( $templateArea )
{
/* Template group has same name as existing */
$obj->title .= '_' . $database->_id;
$obj->save();
$database->$templateArea = $obj->title;
$database->save();
}
}
$database->$name = $obj->group;
$database->save();
}
}
}
else
{
$obj->title .= '_' . $database->_id;
$database->template_form = $obj->title;
$database->save();
}
$obj->save();
$obj->key = 'database_' . \IPS\Http\Url\Friendly::seoTitle( $obj->group ) . '_' . \IPS\Http\Url\Friendly::seoTitle( $obj->title ) . '_' . $obj->id;
$obj->save();
$doneSomething = true;
$next = NULL;
break;
}
@@ -712,13 +685,35 @@ class _databases extends \IPS\Node\Controller
}
else
{
/* Did we do anything? if not, skip to the next section */
if ( ! $doneSomething )
{
switch ( $data['next'] )
{
case 'field':
$data['next'] = 'category';
break;
case 'category':
$data['next'] = 'template';
break;
case 'template':
$data['next'] = null;
break;
}
if ( $data['next'] )
{
return array( $data, \IPS\Member::loggedIn()->language()->addToStack('cms_db_import_progress', FALSE, array( 'sprintf' => array( \ucfirst( $data['next'] ) ) ) ) );
}
}
$xml->next();
}
}
/* Done */
$data['next'] = $next;
$data['done'] = 0;
return array( $data, \IPS\Member::loggedIn()->language()->addToStack('cms_db_import_progress', FALSE, array( 'sprintf' => array( \ucfirst( $data['next'] ) ) ) ) );
}
else
@@ -752,7 +747,16 @@ class _databases extends \IPS\Node\Controller
$databaseId = \IPS\Data\Store::i()->db_import_db_id;
unset( \IPS\Data\Store::i()->db_import_db_id );
$database = \IPS\cms\Databases::load( $databaseId );
foreach( array( 'template_listing', 'template_display', 'template_categories', 'template_form', 'template_featured' ) as $name )
{
\IPS\cms\Templates::fixTemplateTags( $database->$name );
}
@unlink( \IPS\Request::i()->file );
/* Done */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=permissions&id=' . $databaseId ) );
}
@@ -784,6 +788,9 @@ class _databases extends \IPS\Node\Controller
}
else
{
/* We need to know the database schema to prevent non-standard columns from add-ons being added to the XML (which then causes the import to fail) */
$schema = json_decode( \file_get_contents( \IPS\ROOT_PATH . '/applications/cms/data/schema.json' ), TRUE );
/* Init */
$xml = new \XMLWriter;
$xml->openMemory();
@@ -857,8 +864,9 @@ class _databases extends \IPS\Node\Controller
$xml->endElement();
/* Custom fields */
$textFields = array( 'field_extra', 'field_default_value', 'field_name', 'field_description', 'field_display_json', 'field_validator_error' );
$removeFields = array( 'field_database_id' );
$textFields = array( 'field_extra', 'field_default_value', 'field_name', 'field_description', 'field_display_json', 'field_validator_error' );
$removeFields = array( 'field_database_id' );
$fieldSchema = $schema['cms_database_fields'];
foreach ( \IPS\Db::i()->select( 'f.*, w.word_custom as field_name, w2.word_custom as field_description, w3.word_custom as field_validator_error, p.*', array('cms_database_fields', 'f'), array( 'field_database_id=?', $database->id ) )
->join( array( 'core_sys_lang_words', 'w' ), "w.word_key=CONCAT( 'content_field_', f.field_id ) and w.lang_id=" . \IPS\Lang::defaultLanguage() )
->join( array( 'core_sys_lang_words', 'w2' ), "w2.word_key=CONCAT( 'content_field_', f.field_id, '_desc' ) and w2.lang_id=" . \IPS\Lang::defaultLanguage() )
@@ -871,7 +879,7 @@ class _databases extends \IPS\Node\Controller
foreach( $row as $k => $v )
{
if ( ! in_array( $k, $removeFields ) AND ! in_array( $k, $textFields ) )
if ( array_key_exists( $k, $fieldSchema['columns'] ) AND ! in_array( $k, $removeFields ) AND ! in_array( $k, $textFields ) )
{
$xml->startAttribute( $k );
$xml->text( $v );
@@ -906,6 +914,7 @@ class _databases extends \IPS\Node\Controller
$removeFields = array( 'category_database_id', 'category_last_record_id', 'category_last_record_date', 'category_last_record_member', 'category_last_record_name', 'category_last_record_seo_name', 'category_records', 'category_record_comments',
'category_record_comments_queued', 'category_rss_cache', 'category_rss_cached', 'category_rss_exclude', 'category_forum_override', 'category_forum_record', 'category_forum_comments', 'category_forum_delete', 'category_forum_suffix', 'category_forum_prefix',
'category_forum_forum', 'category_full_path', 'category_last_title', 'category_last_seo_title');
$categorySchema = $schema['cms_database_categories'];
foreach ( \IPS\Db::i()->select( 'c.*, w.word_custom as category_name, w2.word_custom as category_description, p.*', array('cms_database_categories', 'c'), array( 'category_database_id=?', $database->id ) )
->join( array( 'core_sys_lang_words', 'w' ), "w.word_key=CONCAT( 'content_cat_name_', c.category_id ) and w.lang_id=" . \IPS\Lang::defaultLanguage() )
->join( array( 'core_sys_lang_words', 'w2' ), "w2.word_key=CONCAT( 'content_cat_name_', c.category_id, '_desc' ) and w2.lang_id=" . \IPS\Lang::defaultLanguage() )
@@ -917,7 +926,7 @@ class _databases extends \IPS\Node\Controller
foreach( $row as $k => $v )
{
if ( ! in_array( $k, $removeFields ) AND ! in_array( $k, $textFields ) )
if ( array_key_exists( $k, $categorySchema['columns'] ) AND ! in_array( $k, $removeFields ) AND ! in_array( $k, $textFields ) )
{
$xml->startAttribute( $k );
$xml->text( $v );
@@ -1035,6 +1044,10 @@ class _databases extends \IPS\Node\Controller
{
\IPS\Dispatcher::i()->checkAcpPermission( 'databases_delete' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
/* Load the database */
try
{
$database = \IPS\cms\Databases::load( \IPS\Request::i()->id );
@@ -1043,27 +1056,16 @@ class _databases extends \IPS\Node\Controller
{
\IPS\Output::i()->error( 'cms_database_not_exist', '3T259/2', 403, '' );
}
$form = new \IPS\Helpers\Form( 'form', 'delete' );
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack('content_delete_db_confirm'), 'ipsMessage ipsMessage_warning' );
$form->add( new \IPS\Helpers\Form\YesNo( 'content_delete_db', 0, FALSE, array(), NULL, NULL, NULL, 'content_delete_db' ) );
if ( $values = $form->values() )
{
if ( $values['content_delete_db'] == 1 )
{
\IPS\Session::i()->log( 'acplogs__cms_deleted_database', array( 'content_db_' . $database->id => TRUE ) );
$database->delete();
/* Delete the database and clear the 'create' menu cache */
$database->delete();
\IPS\Member::clearCreateMenu();
\IPS\Member::clearCreateMenu();
}
/* Log the deletion */
\IPS\Session::i()->log( 'acplogs__cms_deleted_database', array( 'content_db_' . $database->id => TRUE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases' ), 'deleted' );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'delete', $form, FALSE );
/* Send the user back to the list */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases' ), 'deleted' );
}
/**
@@ -1104,6 +1106,24 @@ class _databases extends \IPS\Node\Controller
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cms_pages_settings');
}
/**
* Resynchronise topic content dialog
*
* @return void
*/
public function rebuildTopicContent()
{
if ( isset( \IPS\Request::i()->process ) )
{
\IPS\Task::queue( 'cms', 'ResyncTopicContent', array( 'databaseId' => \IPS\Request::i()->id ), 3, array( 'databaseId' ) );
\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' )->rebuildTopics( \IPS\Request::i()->id );
}
}
/**
* Add/Edit
*
@@ -1135,7 +1155,13 @@ class _databases extends \IPS\Node\Controller
'key' => ( $current ? "content_db_" . $current->id . "_desc" : NULL ),
'textArea' => true
) ) );
$disabled = FALSE;
if ( $current and $current->use_categories and $current->numberOfCategories() > 1 )
{
$disabled = TRUE;
}
$form->add( new \IPS\Helpers\Form\Radio( 'database_use_categories' , $current ? $current->use_categories : 1, FALSE, array(
'options' => array(
1 => 'database_use_categories_yes',
@@ -1143,11 +1169,27 @@ class _databases extends \IPS\Node\Controller
),
'toggles' => array(
1 => array( 'database_template_categories' ),
0 => array( 'category_allow_rating' )
0 => array( 'category_allow_rating', 'category_can_view_others' )
),
'disabled' => $disabled
) ) );
if ( $disabled === TRUE )
{
$form->hiddenValues['database_use_categories_impossible'] = TRUE;
\IPS\Member::loggedIn()->language()->words['database_use_categories_warning'] = \IPS\Member::loggedIn()->language()->addToStack( 'database_use_categories_impossible', NULL, array( 'sprintf' => array( $current->numberOfCategories() ) ) );
}
$form->add( new \IPS\Helpers\Form\Radio( 'database_use_as_page_title' , $current ? $current->use_as_page_title : 1, FALSE, array(
'options' => array(
1 => 'database_use_as_page_title_yes',
0 => 'database_use_as_page_title_no'
)
) ) );
\IPS\Member::loggedIn()->language()->words['category_can_view_others_desc'] = \IPS\Member::loggedIn()->language()->addToStack('category_can_view_others_database_desc');
$form->add( new \IPS\Helpers\Form\YesNo( 'category_allow_rating', ( $category !== NULL and $category->allow_rating ) ? TRUE : FALSE, FALSE, array(), NULL, NULL, NULL, 'category_allow_rating' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'category_can_view_others', ( $category !== NULL ) ? $category->can_view_others : TRUE, FALSE, array(), NULL, NULL, NULL, 'category_can_view_others' ) );
$templatesCat = NULL;
$templatesList = NULL;
@@ -1198,8 +1240,8 @@ class _databases extends \IPS\Node\Controller
'primary_id_field' => 'database_field__id',
'member_id' => 'database_field__member',
'record_publish_date' => 'database_field__saved',
'record_last_comment' => 'database_field__updated',
'rating_real' => 'database_field__rating'
'record_last_comment' => ( $current and $current->_comment_bump === \IPS\cms\Databases::BUMP_ON_EDIT ) ? 'database_field__edited' : 'database_field__updated',
'record_rating' => 'database_field__rating'
);
if ( $current )
@@ -1412,7 +1454,17 @@ class _databases extends \IPS\Node\Controller
{
$form->addMessage( 'cms_no_db_page_no_forum_link', 'ipsMessage ipsMessage_info' );
}
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 ) ) );
}
else
{
\IPS\Member::loggedIn()->language()->words['database_forum_record_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__desc' );
}
$form->add( new \IPS\Helpers\Form\YesNo( 'database_forum_record', $current ? $current->forum_record : FALSE, FALSE, array( 'togglesOn' => array(
'database_forum_comments',
'database_forum_forum',
@@ -1457,7 +1509,7 @@ class _databases extends \IPS\Node\Controller
if ( $name === 'page_name' )
{
/* Overwrite field */
$field = new \IPS\Helpers\Form\Text( 'page_name', FALSE, NULL, array( 'maxLength' => 64 ), function( $val )
$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' )
{
@@ -1551,11 +1603,21 @@ class _databases extends \IPS\Node\Controller
{
if ( is_array( $values['database_name'] ) )
{
$current->key = \IPS\Http\Url::seoTitle( $values['database_name'][ key( $values['database_name'] ) ] );
$keyToUse = uniqid();
foreach( $values['database_name'] as $langId => $word )
{
if ( ! empty( $word ) )
{
$keyToUse = $word;
break;
}
}
$current->key = \IPS\Http\Url\Friendly::seoTitle( $keyToUse );
}
else
{
$current->key = \IPS\Http\Url::seoTitle( $values['database_name'] );
$current->key = \IPS\Http\Url\Friendly::seoTitle( $values['database_name'] );
}
/* Now test it */
@@ -1597,12 +1659,11 @@ class _databases extends \IPS\Node\Controller
\IPS\Lang::saveCustom( 'cms', "content_db_lang_pu_" . $current->id, $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "content_db_lang_ia_" . $current->id, $values['database_lang_ia'] );
\IPS\Lang::saveCustom( 'cms', "content_db_lang_sl_" . $current->id . '_pl', $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_records" . $current->id, $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_categories" . $current->id, $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_cms_records" . $current->id, $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_cms_categories" . $current->id, $values['database_lang_pu'] );
$menu = array();
foreach( \IPS\Lang::languages() as $id => $lang )
foreach( \IPS\Lang::getEnabledLanguages() as $id => $lang )
{
$menu[ $lang->_id ] = \sprintf( $lang->get('cms_create_menu_records_x'), $values['database_lang_su'][ $lang->_id ], $values['database_name'][ $lang->_id ] );
}
@@ -1619,17 +1680,7 @@ class _databases extends \IPS\Node\Controller
$current->template_form = $values['database_template_form'];
$current->template_featured = $values['database_template_featured'];
$current->cat_index_type = $values['database_cat_index_type'];
/* Make sure we have a default category */
$current->default_category = $current->_default_category;
if ( ! $current->use_categories )
{
$class = '\IPS\cms\Categories' . $current->id;
$category = $class::load( $current->get__default_category() );
$category->allow_rating = $values['category_allow_rating'];
$category->save();
}
$current->use_as_page_title = $values['database_use_as_page_title'];
$current->all_editable = (int) $values['database_all_editable'];
$current->revisions = (int) $values['database_revisions'];
@@ -1721,8 +1772,21 @@ class _databases extends \IPS\Node\Controller
}
$current->fixed_field_perms = $fixedFields;
$current->use_categories = $values['database_use_categories'];
$current->save();
/* Make sure we have a default category */
$current->default_category = $current->_default_category;
if ( ! $current->use_categories )
{
$class = '\IPS\cms\Categories' . $current->id;
$category = $class::load( $current->get__default_category() );
$category->allow_rating = $values['category_allow_rating'];
$category->can_view_others = $values['category_can_view_others'];
$category->save();
}
if ( $new )
{
@@ -1743,6 +1807,7 @@ class _databases extends \IPS\Node\Controller
$pageValues['page_content'] = '{database="' . $current->id . '"}';
$pageValues['page_template'] = '';
}
$pageValues['page_folder_id'] = $pageValues['page_folder_id'] ?: 0;
$newPage = \IPS\cms\Pages\Page::createFromForm( $pageValues, 'html' );
@@ -1755,6 +1820,9 @@ class _databases extends \IPS\Node\Controller
'area_orientation' => 'horizontal'
) );
}
$current->page_id = $newPage->id;
$current->save();
}
}
else
@@ -2,9 +2,10 @@
/**
* @brief Fields Model
* @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
* @subpackage Content
* @since 31 March 2014
* @version SVN_VERSION_NUMBER
*/
@@ -39,7 +40,7 @@ class _fields extends \IPS\Node\Controller
$this->nodeClass = '\IPS\cms\Fields' . \IPS\Request::i()->database_id;
\IPS\Dispatcher::i()->checkAcpPermission( 'fields_manage' );
\IPS\Dispatcher::i()->checkAcpPermission( 'cms_fields_manage' );
parent::execute();
}
@@ -50,6 +51,12 @@ class _fields extends \IPS\Node\Controller
*/
protected function manage()
{
/* If we lose the database id because of a log in, do something more useful than an uncaught exception */
if ( ! isset( \IPS\Request::i()->database_id ) )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=databases" ) );
}
parent::manage();
$url = \IPS\Http\Url::internal( "app=cms&module=databases&controller=fields&database_id=" . \IPS\Request::i()->database_id );
@@ -66,9 +73,10 @@ class _fields extends \IPS\Node\Controller
function() use ( $fixed, $url )
{
$rows = array();
foreach( $fixed as $field => $data )
{
$description = ( $field === 'record_publish_date' ) ? \IPS\Member::loggedIn()->language()->addToStack( 'content_fields_fixed_record_publish_date_desc' ) : NULL;
$rows[ $field ] = \IPS\Theme::i()->getTemplate( 'trees', 'core' )->row( $url, $field, \IPS\Member::loggedIn()->language()->addToStack( 'content_fields_fixed_'. $field ), FALSE, array(
'permission' => array(
'icon' => 'lock',
@@ -76,7 +84,7 @@ class _fields extends \IPS\Node\Controller
'link' => $url->setQueryString( array( 'field' => $field, 'do' => 'fixedPermissions' ) ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack( 'content_fields_fixed_'. $field ) )
)
), NULL, NULL, NULL, NULL, ( empty( $data['visible'] ) ? FALSE : TRUE ) );
), $description, NULL, NULL, NULL, ( empty( $data['visible'] ) ? FALSE : TRUE ) );
}
return $rows;
@@ -2,9 +2,10 @@
/**
* @brief Records Model
* @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
* @subpackage Content
* @since 8 April 2014
* @version SVN_VERSION_NUMBER
*/
@@ -183,7 +184,8 @@ class _records extends \IPS\Dispatcher\Controller
try
{
$class = '\IPS\cms\Categories' . $database->id;
return $class::load( $val )->_title;
return \IPS\Theme::i()->getTemplate( 'records', 'cms', 'admin' )->category( $class::load( $val ) );
}
catch( \OutOfRangeException $e )
{
@@ -210,6 +212,13 @@ class _records extends \IPS\Dispatcher\Controller
);
}
\IPS\Output::i()->sidebar['actions']['databasepermissions'] = array(
'title' => 'cms_database_permissions',
'icon' => 'lock',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=permissions&id=' . $database->_id ),
'data' => NULL
);
/* Reset languages */
\IPS\Member::loggedIn()->language()->words[ $table->langPrefix . $database->field_title ] = \IPS\Member::loggedIn()->language()->addToStack($table->langPrefix . 'title');
@@ -226,7 +235,10 @@ class _records extends \IPS\Dispatcher\Controller
public function delete()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'records_delete' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
$recordClass = '\IPS\cms\Records' . \IPS\Request::i()->database_id;
try
@@ -270,7 +282,7 @@ class _records extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form( 'select_category', 'continue' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Node( 'category', $category, TRUE, array(
'url' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&do=select&database_id=' . \IPS\Request::i()->database_id . ( $move ) ? '&move=' . $move : '' ),
'url' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&do=select&database_id=' . \IPS\Request::i()->database_id . ( ( $move ) ? '&move=' . $move : '' ) ),
'class' => $catClass,
'multiple' => false,
'permissionCheck' => function( $node )
@@ -293,8 +305,7 @@ class _records extends \IPS\Dispatcher\Controller
{
if ( $move and $record )
{
$record->category_id = $values['category']->id;
$record->save();
$record->move( $values['category'] );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&database_id=' . \IPS\Request::i()->database_id ), 'completed' );
}
@@ -332,7 +343,7 @@ class _records extends \IPS\Dispatcher\Controller
$fieldsClass = 'IPS\cms\Fields' . \IPS\Request::i()->database_id;
$catClass = 'IPS\cms\Categories' . \IPS\Request::i()->database_id;
$container = ( $current ) ? $catClass::load( $current->category_id ) : ( isset( \IPS\Request::i()->category_id ) ? $catClass::load( \IPS\Request::i()->category_id ) : NULL );
$customFields = $fieldsClass::fields( $customValues, 'view', $container );
$customFields = $fieldsClass::fields( $customValues, 'view', $container, 0, $current );
$manuallyHandledFields = array( 'record_publish_date', 'record_expiry_date', 'record_allow_comments', 'record_comment_cutoff', 'record_meta_keywords', 'record_meta_description' );
$form = new \IPS\Helpers\Form();
@@ -452,7 +463,7 @@ class _records extends \IPS\Dispatcher\Controller
/* Other data */
$current->record_meta_keywords = $values['record_meta_keywords'];
$current->record_meta_description = $values['record_meta_description'];
$changeAuthor = FALSE;
if ( ! empty( \IPS\Request::i()->id ) )
{
@@ -469,6 +480,11 @@ class _records extends \IPS\Dispatcher\Controller
$values['record_member_id'] = \IPS\Member::loggedIn();
$changeAuthor = TRUE;
}
else if ( $values['record_author_choice'] === 'me' )
{
$values['record_member_id'] = \IPS\Member::loggedIn();
$changeAuthor = TRUE;
}
else if ( $values['record_author_choice'] === 'notme' and ! empty( $values['record_member_id'] ) )
{
$changeAuthor = TRUE;
@@ -526,4 +542,27 @@ class _records extends \IPS\Dispatcher\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( $current ? $title : 'add', $form, FALSE );
\IPS\Output::i()->title = $title;
}
/**
* Display the category tree
*
* @return void
*/
public function categoryTree()
{
$class = '\IPS\cms\Categories' . \IPS\Request::i()->database_id;
try
{
$category = $class::load( \IPS\Request::i()->id );
$parents = iterator_to_array( $category->parents() );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack('content_tree_title'), \IPS\Theme::i()->getTemplate( 'records', 'cms', 'admin' )->categoryTree( $category, $parents ), FALSE );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('content_tree_title');
}
catch( \Exception $ex )
{
}
}
}