Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

@@ -225,6 +225,22 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
return static::$database;
}
/**
* Test to see if this is a valid container ID
*
* @param int $id Container ID
* @reply boolean
*/
public static function isValidContainerId( $id )
{
if ( static::$containerIds === NULL )
{
static::$containerIds = iterator_to_array( \IPS\Db::i()->select( 'category_id', static::$databaseTable, array( array( 'category_database_id=?', static::$customDatabaseId ) ) ) );
}
return in_array( $id, static::$containerIds );
}
/**
* Fetch All Root Nodes
@@ -308,7 +324,7 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public function get_fields()
{
return $this->_data['fields'] === '*' ? '*' : json_decode( $this->_data['fields'], TRUE );
return ( $this->_data['fields'] === '*' OR $this->_data['fields'] === NULL ) ? '*' : json_decode( $this->_data['fields'], TRUE );
}
/**
@@ -363,7 +379,7 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
public function form( &$form )
{
/* Build form */
$form->addtab( 'content_content_form_tab__config' );
$form->addTab( 'content_content_form_tab__config' );
$form->add( new \IPS\Helpers\Form\Translatable( 'category_name', NULL, TRUE, array(
'app' => 'cms',
@@ -477,7 +493,7 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
if ( \IPS\Application::appIsEnabled( 'forums' ) )
{
$form->addtab( 'content_content_form_tab__forum' );
$form->addTab( 'content_content_form_tab__forum' );
$form->add( new \IPS\Helpers\Form\YesNo( 'category_forum_override', ( $this->id ? $this->forum_override : NULL ), FALSE, array(
'togglesOn' => array(
@@ -523,11 +539,11 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
$form->addTab( 'content_content_form_header__fields' );
$cats = $this->id ? $this->fields : '*';
$options = array();
$fieldClass = 'IPS\cms\Fields' . \IPS\Request::i()->database_id;
$database = \IPS\cms\Databases::load( \IPS\Request::i()->database_id );
$cats = $this->id ? ( $this->fields === NULL ? '*' : $this->fields ) : '*';
$options = array();
$fieldClass = 'IPS\cms\Fields' . \IPS\Request::i()->database_id;
$database = \IPS\cms\Databases::load( \IPS\Request::i()->database_id );
foreach( $fieldClass::data( NULL, NULL, $fieldClass::FIELD_SKIP_TITLE_CONTENT ) as $field )
{
if ( $field->id !== $database->field_title AND $field->id !== $database->field_content )
@@ -793,7 +809,39 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
* @brief FURL changed
*/
protected $_updatePaths = FALSE;
/**
* Disabled permissions
* Allow node classes to define permissions that are unselectable in the permission matrix
*
* @return array array( {group_id} => array( 'read', 'view', 'perm_7' );
*/
public function disabledPermissions()
{
$database = \IPS\cms\Databases::load( $this->database_id );
$dbPerms = $database->permissions();
$disabled = array();
foreach( array( 'view', 2, 3, 4, 5, 6, 7 ) as $perm )
{
/* Remove unticked database permissions */
if ( $dbPerms['perm_' . $perm ] != '*' )
{
$db = explode( ',', $dbPerms['perm_' . $perm ] );
foreach ( \IPS\Member\Group::groups() as $group )
{
if ( ! in_array( $group->g_id, $db ) )
{
$disabled[ $group->g_id ][] = $perm;
}
}
}
}
return $disabled;
}
/**
* Get permissions
*
@@ -936,6 +984,36 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
return $this->_url;
}
/**
* Get URL from index data
*
* @param array $indexData Data from the search index
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
* @param array|NULL $containerData Basic data about the author. Only includes columns returned by container::basicDataColumns()
* @return \IPS\Http\Url
*/
public static function urlFromIndexData( $indexData, $itemData, $containerData )
{
$recordClass = $indexData['index_class'];
if ( in_array( 'IPS\Content\Comment', class_parents( $recordClass ) ) )
{
$recordClass = $recordClass::$itemClass;
}
if ( $recordClass::$pagePath === NULL )
{
$recordClass::$pagePath = \IPS\Db::i()->select( array( 'page_full_path' ), 'cms_pages', array( 'page_id=?', $recordClass::database()->page_id ) )->first();
}
if ( $recordClass::database()->use_categories )
{
return \IPS\Http\Url::internal( "app=cms&module=pages&controller=page&path=" . $recordClass::$pagePath . '/' . $itemData['extra'], 'front', 'content_page_path', $itemData['extra'] );
}
else
{
return \IPS\Http\Url::internal( "app=cms&module=pages&controller=page&path=" . $recordClass::$pagePath, 'front', 'content_page_path', '' );
}
}
/**
* Get title of category
@@ -1233,7 +1311,7 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
{
$this->last_record_date = $comment->mapped('date');
$this->last_record_member = intval( $comment->author()->member_id );
$this->last_record_name = $comment->author()->member_id ? $comment->author()->name : $comment->mapped('author_name');
$this->last_record_name = $comment->author()->member_id ? $comment->author()->name : NULL;
$this->last_record_seo_name = \IPS\Http\Url::seoTitle( $this->last_poster_name );
$this->last_title = $comment->item()->mapped('title');
$this->last_seo_title = \IPS\Http\Url::seoTitle( $this->last_title );
@@ -1243,8 +1321,8 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
{
$this->last_record_date = static::$latestRecordAdded->record_saved;
$this->last_record_member = static::$latestRecordAdded->member_id;
$this->last_record_name = static::$latestRecordAdded->record_last_comment_name;
$this->last_record_seo_name = static::$latestRecordAdded->record_last_comment_seo;
$this->last_record_name = static::$latestRecordAdded->member_id ? static::$latestRecordAdded->record_last_comment_name : NULL;
$this->last_record_seo_name = static::$latestRecordAdded->member_id ? static::$latestRecordAdded->record_last_comment_seo : NULL;
$this->last_title = static::$latestRecordAdded->_title;
$this->last_seo_title = \IPS\Http\Url::seoTitle( static::$latestRecordAdded->_title );
$this->last_record_id = static::$latestRecordAdded->_id;