Version 4.6.0
This commit is contained in:
1 parent
f79dcf067a
commit
517a5e1f70
2036 files changed
+110041
-26162
No files matched your search
@@ -492,9 +492,16 @@ EOF;
|
||||
'app' => 'cms',
|
||||
'key' => ( $this->id ? "content_block_name_" . $this->id . '_desc' : NULL )
|
||||
) ) );
|
||||
|
||||
$nodeContainer = $this->id ? $this->category :
|
||||
( \IPS\Request::i()->parent ?: \IPS\cms\Blocks\Container::load( ( $block_type == 'custom' ? 'block_custom' : 'block_plugins' ), 'container_key' )->id );
|
||||
|
||||
try
|
||||
{
|
||||
$nodeContainer = $this->id ? $this->category :
|
||||
( \IPS\Request::i()->parent ?: \IPS\cms\Blocks\Container::load( ( $block_type == 'custom' ? 'block_custom' : 'block_plugins' ), 'container_key' )->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$nodeContainer = NULL;
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'block_category', $nodeContainer, TRUE, array(
|
||||
'class' => '\IPS\cms\Blocks\Container',
|
||||
'subnodes' => false
|
||||
@@ -728,6 +735,9 @@ EOF;
|
||||
\IPS\File::claimAttachments( ( $this->id ) ? 'block-content-' . $this->id : 'block-content-new', $this->id );
|
||||
}
|
||||
|
||||
$this->type = \IPS\Request::i()->block_type;
|
||||
$values['type'] = $this->type;
|
||||
|
||||
if ( ! $this->id )
|
||||
{
|
||||
$this->active = 1;
|
||||
@@ -752,9 +762,6 @@ EOF;
|
||||
unset ( $values['block_description'] );
|
||||
}
|
||||
|
||||
$this->type = \IPS\Request::i()->block_type;
|
||||
$values['type'] = $this->type;
|
||||
|
||||
if( isset( $values['block_key'] ) )
|
||||
{
|
||||
if ( ! $values['block_key'] )
|
||||
@@ -883,6 +890,17 @@ EOF;
|
||||
/* We're using a copy */
|
||||
if ( isset( $values['block_save_as_template'] ) AND $values['block_save_as_template'] )
|
||||
{
|
||||
$templateArray = array(
|
||||
'desc' => null,
|
||||
'content' => $values['block_content'],
|
||||
'location' => 'block',
|
||||
'group' => \IPS\Request::i()->block_plugin,
|
||||
'container' => null,
|
||||
'rel_id' => 0,
|
||||
'user_created' => 1,
|
||||
'user_edited' => 0,
|
||||
);
|
||||
|
||||
if ( $values['block_template_id'] == '_default_' )
|
||||
{
|
||||
/* Find it from the normal template system */
|
||||
@@ -893,19 +911,9 @@ EOF;
|
||||
$templateBits = \IPS\Theme::master()->getRawTemplates( $location['app'], $location['location'], $location['group'], \IPS\Theme::RETURN_ALL );
|
||||
$templateBit = $templateBits[ $location['app'] ][ $location['location'] ][ $location['group'] ][ $location['name'] ];
|
||||
|
||||
$templateArray = array(
|
||||
'key' => 'template_' . $templateBit['template_name'] . '.' . mt_rand(),
|
||||
'title' => str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['block_save_as_template_name'] ? $values['block_save_as_template_name'] : $templateBit['template_name'] . '_' . \IPS\Member::loggedIn()->language()->get('copy_noun') ) ),
|
||||
'desc' => null,
|
||||
'content' => $values['block_content'],
|
||||
'location' => 'block',
|
||||
'group' => \IPS\Request::i()->block_plugin,
|
||||
'container' => null,
|
||||
'rel_id' => 0,
|
||||
'user_created' => 1,
|
||||
'user_edited' => 0,
|
||||
'params' => $templateBit['template_data']
|
||||
);
|
||||
$templateArray['key'] = 'template_' . $templateBit['template_name'] . '.' . mt_rand();
|
||||
$templateArray['title'] = str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['block_save_as_template_name'] ? $values['block_save_as_template_name'] : $templateBit['template_name'] . '_' . \IPS\Member::loggedIn()->language()->get('copy_noun') ) );
|
||||
$templateArray['params'] = $templateBit['template_data'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -913,19 +921,9 @@ EOF;
|
||||
{
|
||||
$template = \IPS\cms\Templates::load( $values['block_template_id'] );
|
||||
|
||||
$templateArray = array(
|
||||
'key' => 'template_' . $template->name . '.' . mt_rand(),
|
||||
'title' => str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['block_save_as_template_name'] ? $values['block_save_as_template_name'] : $template->name . '_' . \IPS\Member::loggedIn()->language()->get('copy_noun') ) ),
|
||||
'desc' => null,
|
||||
'content' => $values['block_content'],
|
||||
'location' => 'block',
|
||||
'group' => \IPS\Request::i()->block_plugin,
|
||||
'container' => null,
|
||||
'rel_id' => 0,
|
||||
'user_created' => 1,
|
||||
'user_edited' => 0,
|
||||
'params' => $template->params
|
||||
);
|
||||
$templateArray['key'] = 'template_' . $template->name . '.' . mt_rand();
|
||||
$templateArray['title'] = str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['block_save_as_template_name'] ? $values['block_save_as_template_name'] : $template->name . '_' . \IPS\Member::loggedIn()->language()->get('copy_noun') ) );
|
||||
$templateArray['params'] = $template->params;
|
||||
}
|
||||
catch( \OutOfRangeException $ex )
|
||||
{
|
||||
@@ -933,6 +931,12 @@ EOF;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure template name is unique within the group */
|
||||
if( \IPS\Db::i()->select( 'COUNT(*)', 'cms_templates', array( 'template_title=? and template_location=? and template_group=?', $templateArray['title'], $templateArray['location'], $templateArray['group'] ) )->first() )
|
||||
{
|
||||
$templateArray['title'] = $templateArray['title'] . '_' . time();
|
||||
}
|
||||
|
||||
/* Save */
|
||||
$newTemplate = \IPS\cms\Templates::add( $templateArray );
|
||||
|
||||
@@ -1036,41 +1040,12 @@ EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Duplicate
|
||||
* [Node] Does the currently logged in user have permission to copy this node?
|
||||
*
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function __clone()
|
||||
public function canCopy()
|
||||
{
|
||||
parent::__clone();
|
||||
|
||||
if( $this->skipCloneDuplication === TRUE )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Copy language bits to make them unique */
|
||||
$config = $this->_plugin_config;
|
||||
$wordKey = 'widget_title_' . md5( mt_rand() );
|
||||
|
||||
if ( isset( $config['language_key'] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_sys_lang_words', array( 'word_key=?', $config['language_key'] ) ) as $row )
|
||||
{
|
||||
unset( $row['word_id'] );
|
||||
$row['word_key'] = $wordKey;
|
||||
\IPS\Db::i()->insert( 'core_sys_lang_words', $row );
|
||||
}
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
|
||||
$config['language_key'] = $wordKey;
|
||||
$this->plugin_config = json_encode( $config );
|
||||
}
|
||||
|
||||
$this->key .= '_' . mt_rand();
|
||||
$this->save();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,8 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
use \IPS\Node\Statistics;
|
||||
|
||||
/**
|
||||
* @brief Multiton Store
|
||||
*/
|
||||
@@ -487,7 +489,8 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_allow_rating', $this->allow_rating, FALSE, array(), NULL, NULL, NULL, 'category_allow_rating' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_has_perms', $this->has_perms, FALSE, array(), NULL, NULL, NULL, 'category_has_perms' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'category_can_view_others', $this->id ? $this->can_view_others : TRUE, FALSE, array(), NULL, NULL, NULL, 'category_can_view_others' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'allow_anonymous', $this->id ? $this->allow_anonymous : FALSE, FALSE, array() ) );
|
||||
|
||||
$form->addHeader('cms_categories_header_display');
|
||||
$templatesList = array( 0 => \IPS\Member::loggedIn()->language()->addToStack('cms_categories_use_database') );
|
||||
$templatesDisplay = array( 0 => \IPS\Member::loggedIn()->language()->addToStack('cms_categories_use_database') );
|
||||
@@ -1537,15 +1540,17 @@ class _Categories extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
* Get last comment time
|
||||
*
|
||||
* @note This should return the last comment time for this node only, not for children nodes
|
||||
* @param \IPS\Member|NULL $member MemberObject
|
||||
* @return \IPS\DateTime|NULL
|
||||
*/
|
||||
public function getLastCommentTime()
|
||||
public function getLastCommentTime( \IPS\Member $member = NULL )
|
||||
{
|
||||
if( !$this->can_view_others and !\IPS\Member::loggedIn()->modPermission( 'can_content_view_others_records' ) )
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
if( !$this->can_view_others and !$member->modPermission( 'can_content_view_others_records' ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$select = \IPS\Db::i()->select('record_last_comment', 'cms_custom_database_' . $this->database_id, array("record_future_date=0 AND category_id=? AND record_approved=1 AND member_id=?", $this->id, \IPS\Member::loggedIn()->member_id), 'record_last_comment DESC', 1 )->first();
|
||||
$select = \IPS\Db::i()->select('record_last_comment', 'cms_custom_database_' . $this->database_id, array("record_future_date=0 AND category_id=? AND record_approved=1 AND member_id=?", $this->id, $member->member_id ), 'record_last_comment DESC', 1 )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -1040,6 +1040,11 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
*/
|
||||
public static function validateUnique( $val, $field, $record )
|
||||
{
|
||||
if ( $val === '' )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$database = \IPS\cms\Databases::load( static::$customDatabaseId );
|
||||
|
||||
if( $field->type == 'Member' AND $val instanceof \IPS\Member )
|
||||
@@ -1311,9 +1316,10 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
*
|
||||
* @param mixed $value The value
|
||||
* @param bool $showSensitiveInformation If TRUE, potentially sensitive data (like passwords) will be displayed - otherwise will be blanked out
|
||||
* @param string $separator Used to separate items when displaying a field with multiple values.
|
||||
* @return string
|
||||
*/
|
||||
public function displayValue( $value=NULL, $showSensitiveInformation=FALSE )
|
||||
public function displayValue( $value=NULL, $showSensitiveInformation=FALSE, $separator=NULL )
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( static::$customDatabaseId );
|
||||
|
||||
@@ -2307,8 +2313,17 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
case 'Text':
|
||||
case 'Url':
|
||||
case 'Checkbox':
|
||||
$columnDefinition['type'] = 'VARCHAR';
|
||||
$columnDefinition['length'] = 255;
|
||||
if ( !isset( $values['field_max_length'] ) OR !$values['field_max_length'] )
|
||||
{
|
||||
$columnDefinition['type'] = 'MEDIUMTEXT';
|
||||
unset( $columnDefinition['length'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$columnDefinition['type'] = 'VARCHAR';
|
||||
$columnDefinition['length'] = 255;
|
||||
}
|
||||
|
||||
$values['field_extra'] = '';
|
||||
break;
|
||||
default:
|
||||
@@ -2316,9 +2331,21 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! empty( $values['field_max_length'] ) AND empty( $columnDefinition['length'] ) )
|
||||
if ( ! empty( $values['field_max_length'] ) )
|
||||
{
|
||||
$columnDefinition['length'] = $values['field_max_length'];
|
||||
if( $values['field_max_length'] > 255 )
|
||||
{
|
||||
$columnDefinition['type'] = 'MEDIUMTEXT';
|
||||
|
||||
if( isset( $columnDefinition['length'] ) )
|
||||
{
|
||||
unset( $columnDefinition['length'] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$columnDefinition['length'] = $values['field_max_length'];
|
||||
}
|
||||
}
|
||||
else if ( empty( $columnDefinition['length'] ) )
|
||||
{
|
||||
@@ -2797,7 +2824,7 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
*/
|
||||
public function delete( $skipDrop=FALSE )
|
||||
{
|
||||
static::$contentDatabaseTable = 'cms_custom_database_' . static::$customDatabaseId;
|
||||
static::$contentDatabaseTable = NULL; // This ensures the parent class doesn't try to drop the column regardless
|
||||
static::$cache = array();
|
||||
|
||||
/* Remove reciprocal map data */
|
||||
@@ -2810,17 +2837,36 @@ class _Fields extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
if( $this->type == 'Upload' )
|
||||
{
|
||||
\IPS\Db::i()->dropIndex( static::$contentDatabaseTable, "field_{$this->id}" );
|
||||
}
|
||||
catch ( \IPS\Db\Exception $e ) {}
|
||||
/* 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=?', $this->id ) ),
|
||||
'deleteRows' => TRUE,
|
||||
), 4 );
|
||||
|
||||
try
|
||||
/* Delete records */
|
||||
\IPS\Task::queue( 'core', 'FileCleanup', array(
|
||||
'table' => 'cms_custom_database_' . static::$customDatabaseId,
|
||||
'column' => 'field_' . $this->id,
|
||||
'storageExtension' => 'cms_Records',
|
||||
'primaryId' => 'primary_id_field',
|
||||
'dropColumn' => 'field_' . $this->id,
|
||||
'dropColumnTable' => 'cms_custom_database_' . static::$customDatabaseId,
|
||||
'multipleFiles' => $this->is_multiple
|
||||
), 4 );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Db::i()->dropColumn( static::$contentDatabaseTable, "field_{$this->id}" );
|
||||
try
|
||||
{
|
||||
\IPS\Db::i()->dropColumn( static::$contentDatabaseTable, "field_{$this->id}" );
|
||||
}
|
||||
catch( \IPS\Db\Exception $e ) { }
|
||||
}
|
||||
catch( \IPS\Db\Exception $e ) { }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -240,9 +240,9 @@ class _Folder extends \IPS\Node\Model
|
||||
|
||||
try
|
||||
{
|
||||
$test = \IPS\cms\Pages\Folder::load( \IPS\Http\Url\Friendly::seoTitle( $val ), 'folder_name' );
|
||||
$test = \IPS\cms\Pages\Folder::load( ( $val === '.well-known' ) ? $val : \IPS\Http\Url\Friendly::seoTitle( $val ), 'folder_name' );
|
||||
|
||||
if ( ! empty( \IPS\Request::i()->id ) and $test->id != \IPS\Request::i()->id )
|
||||
if ( empty( \IPS\Request::i()->id ) or $test->id != \IPS\Request::i()->id )
|
||||
{
|
||||
throw new \InvalidArgumentException('content_folder_name_in_use');
|
||||
}
|
||||
@@ -250,7 +250,7 @@ class _Folder extends \IPS\Node\Model
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
/* If we hit here, we don't have an existing folder by that name so check for a collision */
|
||||
if ( \IPS\Request::i()->folder_parent_id == 0 AND \IPS\cms\Pages\Page::isFurlCollision( \IPS\Http\Url\Friendly::seoTitle( $val ) ) )
|
||||
if ( \IPS\Request::i()->folder_parent_id == 0 AND \IPS\cms\Pages\Page::isFurlCollision( ( $val === '.well-known' ) ? $val : \IPS\Http\Url\Friendly::seoTitle( $val ) ) )
|
||||
{
|
||||
throw new \InvalidArgumentException('content_folder_name_furl_collision');
|
||||
}
|
||||
@@ -300,7 +300,15 @@ class _Folder extends \IPS\Node\Model
|
||||
|
||||
if( isset( $values['folder_name'] ) )
|
||||
{
|
||||
$values['name'] = \IPS\Http\Url\Friendly::seoTitle( $values['folder_name'] );
|
||||
/* If the folder name is explicitly .well-known, allow that as it will allow sites on CiC to use Apple Pay */
|
||||
if ( $values['folder_name'] === '.well-known' )
|
||||
{
|
||||
$values['name'] = $values['folder_name'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$values['name'] = \IPS\Http\Url\Friendly::seoTitle( $values['folder_name'] );
|
||||
}
|
||||
unset( $values['folder_name'] );
|
||||
}
|
||||
|
||||
|
||||
@@ -59,11 +59,6 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
*/
|
||||
protected static $multitonMap = array();
|
||||
|
||||
/**
|
||||
* @brief [Node] Parent ID Database Column
|
||||
*/
|
||||
public static $databaseColumnParent = 'folder_id';
|
||||
|
||||
/**
|
||||
* @brief [Node] Parent Node ID Database Column
|
||||
*/
|
||||
@@ -954,17 +949,6 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
return \IPS\Data\Store::i()->pages_page_urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns (and builds if required) the pages id => url datastore
|
||||
*
|
||||
* @return array
|
||||
* @deprecated
|
||||
*/
|
||||
public static function getPageUrlStore()
|
||||
{
|
||||
return static::getStore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get page path, returning stripped path and current page number
|
||||
*
|
||||
@@ -1550,7 +1534,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
'options' => array( 0 => 'menu_manager_access_type_inherit', 1 => 'menu_manager_access_type_override' ),
|
||||
'toggles' => array( 1 => array( 'menu_manager_access' ) )
|
||||
), NULL, NULL, NULL, 'menu_manager_access_type' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'menu_manager_access', '*', NULL, array( 'multiple' => TRUE, 'options' => $groups, 'unlimited' => '*', 'unlimitedLang' => 'everyone' ), NULL, NULL, NULL, 'menu_manager_access' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'menu_manager_access', '*', NULL, array( 'multiple' => TRUE, 'options' => $groups, 'unlimited' => '*', 'unlimitedLang' => 'everyone', 'impliedUnlimited' => TRUE ), NULL, NULL, NULL, 'menu_manager_access' ) );
|
||||
}
|
||||
|
||||
if ( $pageType === 'builder' )
|
||||
@@ -2318,6 +2302,8 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb['module'] = array( $this->url(), $this->_title );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->pageName = $this->full_path;
|
||||
|
||||
if ( isset( \IPS\Settings::i()->cms_error_page ) and \IPS\Settings::i()->cms_error_page and \IPS\Settings::i()->cms_error_page == $this->id )
|
||||
{
|
||||
|
||||
@@ -123,7 +123,7 @@ class _PageItem extends \IPS\Content\Item implements \IPS\Content\Searchable
|
||||
* @param array $reactions Reaction Data
|
||||
* @return string
|
||||
*/
|
||||
public static function searchResult( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $iPostedIn, $view, $asItem, $canIgnoreComments=FALSE, $template=NULL, $reactions=array() )
|
||||
public static function searchResult( array $indexData, array $authorData, array $itemData, ?array $containerData, array $reputationData, $reviewRating, $iPostedIn, $view, $asItem, $canIgnoreComments=FALSE, $template=NULL, $reactions=array() )
|
||||
{
|
||||
$indexData['index_title'] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_page_' . $indexData['index_item_id'] );
|
||||
return parent::searchResult( $indexData, $authorData, $itemData, $containerData, $reputationData, $reviewRating, $iPostedIn, $view, $asItem, $canIgnoreComments, $template, $reactions );
|
||||
@@ -168,7 +168,39 @@ class _PageItem extends \IPS\Content\Item implements \IPS\Content\Searchable
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->content;
|
||||
/* Remove {tags="foo"} */
|
||||
$this->content = preg_replace( '#\{([a-z]+?=([\'"]).+?\\2 ?+)}#', '', $this->content );
|
||||
|
||||
/* Convert {{}} logic into html tags */
|
||||
$this->content = preg_replace( '#{{(if|foreach)([^{]+?)}}#', '<ips$1 data="$2">', $this->content );
|
||||
$this->content = preg_replace( '#{{end(if|foreach)}}#', '</ips$1>', $this->content );
|
||||
|
||||
/* Remove custom PHP {{$foo = $this->test();}} */
|
||||
$this->content = preg_replace( '#{{(.+?)}}#', '', $this->content );
|
||||
|
||||
$source = new \IPS\Xml\DOMDocument( '1.0', 'UTF-8' );
|
||||
$source->loadHTML( \IPS\Xml\DOMDocument::wrapHtml( $this->content ) );
|
||||
|
||||
/* And then remove the HTML logic */
|
||||
$domElemsToRemove = array();
|
||||
foreach ( $source->getElementsByTagname('ipsif') as $domElement )
|
||||
{
|
||||
$domElemsToRemove[] = $domElement;
|
||||
}
|
||||
|
||||
foreach ( $source->getElementsByTagname('ipsforeach') as $domElement )
|
||||
{
|
||||
$domElemsToRemove[] = $domElement;
|
||||
}
|
||||
|
||||
foreach( $domElemsToRemove as $domElement )
|
||||
{
|
||||
$domElement->parentNode->removeChild($domElement);
|
||||
}
|
||||
|
||||
$content = \IPS\Text\DOMParser::getDocumentBodyContents( $source );
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
/**
|
||||
* Post Model
|
||||
*/
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Shareable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Shareable, \IPS\Content\Searchable, \IPS\Content\Embeddable, \IPS\Content\Anonymous
|
||||
{
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
@@ -76,6 +76,7 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
'edit_member_id' => 'edit_member_id',
|
||||
'edit_reason' => 'edit_reason',
|
||||
'approved' => 'approved',
|
||||
'is_anon' => 'is_anon'
|
||||
# 'first' => 'new_topic'
|
||||
);
|
||||
|
||||
@@ -133,9 +134,18 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
* @param \IPS\Member $member The memner
|
||||
* @return int
|
||||
*/
|
||||
public static function memberPostCount( \IPS\Member $member )
|
||||
public static function memberPostCount( \IPS\Member $member, bool $includeNonPostCountIncreasing = FALSE, bool $includeHiddenAndPendingApproval = TRUE )
|
||||
{
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', static::$databaseTable, array( 'comment_database_id=? AND comment_user=?', static::$customDatabaseId, $member->member_id ) )->first();
|
||||
$where = [];
|
||||
$where[] = [ 'comment_database_id=?', static::$customDatabaseId ];
|
||||
$where[] = [ 'comment_user=?', $member->member_id ];
|
||||
|
||||
if ( !$includeHiddenAndPendingApproval )
|
||||
{
|
||||
$where[] = [ 'comment_approved=1' ];
|
||||
}
|
||||
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', static::$databaseTable, $where )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,7 +201,7 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
* @param array $reactions Reaction Data
|
||||
* @return string
|
||||
*/
|
||||
public static function searchResult( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $iPostedIn, $view, $asItem, $canIgnoreComments=FALSE, $template=NULL, $reactions=array() )
|
||||
public static function searchResult( array $indexData, array $authorData, array $itemData, ?array $containerData, array $reputationData, $reviewRating, $iPostedIn, $view, $asItem, $canIgnoreComments=FALSE, $template=NULL, $reactions=array() )
|
||||
{
|
||||
/* Ensure that the comment title is formatted correctly */
|
||||
try
|
||||
|
||||
@@ -71,6 +71,11 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
*/
|
||||
public static $icon = 'comment';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'post';
|
||||
|
||||
/**
|
||||
* @brief [Content\Comment] Comment Template
|
||||
*/
|
||||
@@ -199,13 +204,14 @@ class _CommentTopicSync extends \IPS\cms\Records\Comment
|
||||
/**
|
||||
* Post count for member
|
||||
*
|
||||
* @param \IPS\Member $member The memner
|
||||
* @param \IPS\Member $member The member
|
||||
* @param bool $includeNonPostCountIncreasing If FALSE, will skip any posts which would not cause the user's post count to increase
|
||||
* @param bool $includeHiddenAndPendingApproval If FALSE, will skip any hidden posts, or posts pending approval
|
||||
* @return int
|
||||
* @note We explicitely return 0 because any posts will be counted via the forums application inherently already
|
||||
*/
|
||||
public static function memberPostCount( \IPS\Member $member )
|
||||
public static function memberPostCount( \IPS\Member $member, bool $includeNonPostCountIncreasing = FALSE, bool $includeHiddenAndPendingApproval = TRUE )
|
||||
{
|
||||
return 0;
|
||||
return 0; // We explicitely return 0 because any posts will be counted via the forums application inherently already
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,8 @@ class _Records extends \IPS\Content\Item implements
|
||||
\IPS\Content\Searchable,
|
||||
\IPS\Content\FuturePublishing,
|
||||
\IPS\Content\Embeddable,
|
||||
\IPS\Content\MetaData
|
||||
\IPS\Content\MetaData,
|
||||
\IPS\Content\Anonymous
|
||||
{
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
|
||||
@@ -403,12 +404,20 @@ class _Records extends \IPS\Content\Item implements
|
||||
* Definite Article
|
||||
*
|
||||
* @param \IPS\Lang|NULL $lang The language to use, or NULL for the language of the currently logged in member
|
||||
* @param integer|boolean $count Number of items. If not false, pluralized version of phrase will be used.
|
||||
* @return string
|
||||
*/
|
||||
public function definiteArticle( \IPS\Lang $lang = NULL )
|
||||
public function definiteArticle( \IPS\Lang $lang = NULL, $count = FALSE )
|
||||
{
|
||||
$lang = $lang ?: \IPS\Member::loggedIn()->language();
|
||||
return $lang->addToStack( 'content_db_lang_sl_' . static::$customDatabaseId, FALSE );
|
||||
if( $count === TRUE || ( \is_int( $count ) && $count > 1 ) )
|
||||
{
|
||||
return $lang->addToStack( 'content_db_lang_pl_' . static::$customDatabaseId, FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
return $lang->addToStack( 'content_db_lang_sl_' . static::$customDatabaseId, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,12 +426,20 @@ class _Records extends \IPS\Content\Item implements
|
||||
* @param array $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param \IPS\Lang|NULL $lang The language to use, or NULL for the language of the currently logged in member
|
||||
* @param array $options Options to pass to \IPS\Lang::addToStack
|
||||
* @param integer|boolean $count Number of items. If not false, pluralized version of phrase will be used.
|
||||
* @return string
|
||||
*/
|
||||
public static function _definiteArticle( array $containerData = NULL, \IPS\Lang $lang = NULL, $options = array() )
|
||||
public static function _definiteArticle( array $containerData = NULL, \IPS\Lang $lang = NULL, $options = array(), $count = FALSE )
|
||||
{
|
||||
$lang = $lang ?: \IPS\Member::loggedIn()->language();
|
||||
return $lang->addToStack( 'content_db_lang_sl_' . static::$customDatabaseId, FALSE, $options );
|
||||
if( $count === TRUE || ( \is_int( $count ) && $count > 1 ) )
|
||||
{
|
||||
return $lang->addToStack( 'content_db_lang_pl_' . static::$customDatabaseId, FALSE, $options );
|
||||
}
|
||||
else
|
||||
{
|
||||
return $lang->addToStack( 'content_db_lang_sl_' . static::$customDatabaseId, FALSE, $options );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -558,7 +575,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( $fieldsClass::fixedFieldFormShow( 'record_publish_date' ) AND ( \IPS\Member::loggedIn()->modPermission( "can_future_publish_content" ) or \IPS\Member::loggedIn()->modPermission( "can_future_publish_" . static::$title ) ) )
|
||||
{
|
||||
$formElements['record_publish_date'] = $elements['date'];
|
||||
@@ -569,7 +586,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
$fixedFieldSettings = static::database()->fixed_field_settings;
|
||||
$dims = TRUE;
|
||||
|
||||
if ( isset( $fixedFieldSettings['record_image']['image_dims'] ) )
|
||||
if ( isset( $fixedFieldSettings['record_image']['image_dims'] ) AND $fixedFieldSettings['record_image']['image_dims'][0] AND $fixedFieldSettings['record_image']['image_dims'][1] )
|
||||
{
|
||||
$dims = array( 'maxWidth' => $fixedFieldSettings['record_image']['image_dims'][0], 'maxHeight' => $fixedFieldSettings['record_image']['image_dims'][1] );
|
||||
}
|
||||
@@ -601,6 +618,12 @@ class _Records extends \IPS\Content\Item implements
|
||||
'unlimitedLang' => 'record_datetime_noval'
|
||||
), NULL, NULL, NULL, 'record_comment_cutoff' );
|
||||
}
|
||||
|
||||
/* Post Anonymously */
|
||||
if ( $container and $container->canPostAnonymously( $container::ANON_ITEMS ) )
|
||||
{
|
||||
$formElements['post_anonymously'] = new \IPS\Helpers\Form\YesNo( 'post_anonymously', ( $item ) ? $item->isAnonymous() : FALSE , FALSE, array( 'label' => \IPS\Member::loggedIn()->language()->addToStack( 'post_anonymously_suffix' ) ), NULL, NULL, NULL, 'post_anonymously' );
|
||||
}
|
||||
|
||||
if ( static::modPermission( 'lock', NULL, $container ) )
|
||||
{
|
||||
@@ -957,6 +980,8 @@ class _Records extends \IPS\Content\Item implements
|
||||
static::$customFields = $fieldsClass::fields( $customValues, ( $this->_new ? 'add' : 'edit' ), $container, 0, ( $this->_new ? NULL : $this ) );
|
||||
}
|
||||
|
||||
$seen = [];
|
||||
|
||||
foreach( static::$customFields as $key => $field )
|
||||
{
|
||||
$seen[] = $key;
|
||||
@@ -986,7 +1011,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
/* If we're using decimals, then the database field is set to DECIMALS, so we cannot using stringValue() */
|
||||
else if ( isset( $customValues[ $field->name ] ) and \get_class( $field ) == 'IPS\Helpers\Form\Number' and ( isset( $field->options['decimals'] ) and $field->options['decimals'] > 0 ) )
|
||||
{
|
||||
$this->$key = $field->value;
|
||||
$this->$key = ( $field->value === '' ) ? NULL : $field->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1144,29 +1169,10 @@ class _Records extends \IPS\Content\Item implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( $row->can( ( $isNew ? 'add' : 'edit' ) ) and $row->type == 'Item' )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'cms_database_fields_reciprocal_map', array( 'map_origin_database_id=? and map_field_id=? and map_origin_item_id=?', static::$customDatabaseId, $row->id, $this->_id ) );
|
||||
|
||||
$field = 'field_' . $row->id;
|
||||
$extra = $row->extra;
|
||||
if ( $this->$field and ! empty( $extra['database'] ) )
|
||||
{
|
||||
foreach( explode( ',', $this->$field ) as $foreignId )
|
||||
{
|
||||
if ( $foreignId )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'cms_database_fields_reciprocal_map', array(
|
||||
'map_origin_database_id' => static::$customDatabaseId,
|
||||
'map_foreign_database_id' => $extra['database'],
|
||||
'map_origin_item_id' => $this->$idColumn,
|
||||
'map_foreign_item_id' => $foreignId,
|
||||
'map_field_id' => $row->id
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
$field = $this->processItemFieldData( $row );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1229,7 +1235,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
switch( $pref )
|
||||
{
|
||||
case 'unread':
|
||||
$action = 'getNewComment';
|
||||
$action = \IPS\Member::loggedIn()->member_id ? 'getNewComment' : NULL;
|
||||
break;
|
||||
|
||||
case 'last':
|
||||
@@ -1241,6 +1247,10 @@ class _Records extends \IPS\Content\Item implements
|
||||
break;
|
||||
}
|
||||
}
|
||||
elseif( !\IPS\Member::loggedIn()->member_id AND $action == 'getNewComment' )
|
||||
{
|
||||
$action = NULL;
|
||||
}
|
||||
|
||||
if ( ! $this->recordPage )
|
||||
{
|
||||
@@ -1352,7 +1362,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
* @param string $view 'expanded' or 'condensed'
|
||||
* @return callable
|
||||
*/
|
||||
public static function searchResultSnippet( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $view )
|
||||
public static function searchResultSnippet( array $indexData, array $authorData, array $itemData, ?array $containerData, array $reputationData, $reviewRating, $view )
|
||||
{
|
||||
/* We want the custom template only for expanded view or if we have a record image */
|
||||
|
||||
@@ -1384,7 +1394,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
switch( $pref )
|
||||
{
|
||||
case 'unread':
|
||||
$action = 'getNewComment';
|
||||
$action = \IPS\Member::loggedIn()->member_id ? 'getNewComment' : NULL;
|
||||
break;
|
||||
|
||||
case 'last':
|
||||
@@ -1396,6 +1406,10 @@ class _Records extends \IPS\Content\Item implements
|
||||
break;
|
||||
}
|
||||
}
|
||||
elseif( !\IPS\Member::loggedIn()->member_id AND $action == 'getNewComment' )
|
||||
{
|
||||
$action = NULL;
|
||||
}
|
||||
|
||||
if ( static::$pagePath === NULL )
|
||||
{
|
||||
@@ -2339,6 +2353,11 @@ class _Records extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static $skipTopicCreation = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Are we creating a record? Ignore topic syncs until we are done if so.
|
||||
*/
|
||||
protected static $creatingRecord = FALSE;
|
||||
|
||||
/**
|
||||
* Create from form
|
||||
*
|
||||
@@ -2349,7 +2368,9 @@ class _Records extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function createFromForm( $values, \IPS\Node\Model $container = NULL, $sendNotification = TRUE )
|
||||
{
|
||||
static::$creatingRecord = TRUE;
|
||||
$record = parent::createFromForm( $values, $container, $sendNotification );
|
||||
static::$creatingRecord = FALSE;
|
||||
|
||||
if ( !static::$skipTopicCreation and \IPS\Application::appIsEnabled('forums') and $record->_forum_record and $record->_forum_forum and ! $record->hidden() and ! $record->record_future_date )
|
||||
{
|
||||
@@ -2383,6 +2404,38 @@ class _Records extends \IPS\Content\Item implements
|
||||
parent::processAfterEdit( $values );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the reciprocal field data
|
||||
*
|
||||
* @param mixed $row
|
||||
* @return string
|
||||
*/
|
||||
public function processItemFieldData( \IPS\cms\Fields $row ): string
|
||||
{
|
||||
$idColumn = static::$databaseColumnId;
|
||||
\IPS\Db::i()->delete( 'cms_database_fields_reciprocal_map', array('map_origin_database_id=? and map_field_id=? and map_origin_item_id=?', static::$customDatabaseId, $row->id, $this->_id) );
|
||||
|
||||
$field = 'field_' . $row->id;
|
||||
$extra = $row->extra;
|
||||
if ( $this->$field and !empty( $extra['database'] ) )
|
||||
{
|
||||
foreach ( explode( ',', $this->$field ) as $foreignId )
|
||||
{
|
||||
if ( $foreignId )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'cms_database_fields_reciprocal_map', array(
|
||||
'map_origin_database_id' => static::$customDatabaseId,
|
||||
'map_foreign_database_id' => $extra['database'],
|
||||
'map_origin_item_id' => $this->$idColumn,
|
||||
'map_foreign_item_id' => $foreignId,
|
||||
'map_field_id' => $row->id
|
||||
) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to execute when tags are edited
|
||||
*
|
||||
@@ -2434,9 +2487,26 @@ class _Records extends \IPS\Content\Item implements
|
||||
$post = \IPS\forums\Topic\Post::create( $topic, $comment, FALSE, ( isset( $values['guest_name'] ) ? $values['guest_name'] : NULL ) );
|
||||
|
||||
$commentClass = 'IPS\cms\Records\CommentTopicSync' . static::$customDatabaseId;
|
||||
|
||||
$idColumn = static::$databaseColumnId;
|
||||
$autoSaveKey = 'reply-' . static::$application . '/' . static::$module . '-' . $this->$idColumn;
|
||||
|
||||
/* First we have to update the attachment location key */
|
||||
\IPS\Db::i()->update( 'core_attachments_map', array( 'location_key' => 'forums_Forums' ), array( 'temp=?', md5( $autoSaveKey ) ) );
|
||||
|
||||
/* Then "claim" the attachments */
|
||||
$parameters = array_merge( array( $autoSaveKey ), $post->attachmentIds() );
|
||||
\IPS\File::claimAttachments( ...$parameters );
|
||||
|
||||
$topic->markRead();
|
||||
|
||||
/* Post anonymously */
|
||||
if( isset( $values[ 'post_anonymously' ] ) )
|
||||
{
|
||||
$post->setAnonymous( $values[ 'post_anonymously' ] );
|
||||
$this->syncRecordFromTopic( $topic );
|
||||
}
|
||||
|
||||
return $commentClass::load( $post->pid );
|
||||
|
||||
}
|
||||
@@ -2587,11 +2657,6 @@ class _Records extends \IPS\Content\Item implements
|
||||
return parent::lastCommenter();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Map of topic links we've already checked
|
||||
*/
|
||||
protected static $topicLinkMap = array();
|
||||
|
||||
/**
|
||||
* Is this topic linked to a record?
|
||||
*
|
||||
@@ -2600,33 +2665,13 @@ class _Records extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function topicIsLinked( $topic )
|
||||
{
|
||||
if( isset( static::$topicLinkMap[ $topic->tid ] ) )
|
||||
{
|
||||
return static::$topicLinkMap[ $topic->tid ];
|
||||
}
|
||||
|
||||
foreach( \IPS\cms\Databases::databases() as $database )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $database->forum_record and $database->forum_forum == $topic->container()->_id )
|
||||
{
|
||||
$class = '\IPS\cms\Records' . $database->id;
|
||||
$record = $class::load( $topic->tid, 'record_topicid' );
|
||||
|
||||
if ( $record->_forum_record )
|
||||
{
|
||||
static::$topicLinkMap[ $topic->tid ] = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
}
|
||||
|
||||
static::$topicLinkMap[ $topic->tid ] = FALSE;
|
||||
|
||||
return static::$topicLinkMap[ $topic->tid ];
|
||||
return ( static::getLinkedRecord( $topic ) === NULL ) ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Cached linked record checks to prevent duplicate queries
|
||||
*/
|
||||
protected static $linkedRecordLookup = array();
|
||||
|
||||
/**
|
||||
* Is this topic linked to a record?
|
||||
@@ -2636,6 +2681,13 @@ class _Records extends \IPS\Content\Item implements
|
||||
*/
|
||||
public static function getLinkedRecord( $topic )
|
||||
{
|
||||
if( array_key_exists( $topic->tid, static::$linkedRecordLookup ) )
|
||||
{
|
||||
return static::$linkedRecordLookup[ $topic->tid ];
|
||||
}
|
||||
|
||||
static::$linkedRecordLookup[ $topic->tid ] = NULL;
|
||||
|
||||
foreach( \IPS\cms\Databases::databases() as $database )
|
||||
{
|
||||
try
|
||||
@@ -2647,14 +2699,14 @@ class _Records extends \IPS\Content\Item implements
|
||||
|
||||
if ( $record->_forum_record )
|
||||
{
|
||||
return $record;
|
||||
static::$linkedRecordLookup[ $topic->tid ] = $record;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return static::$linkedRecordLookup[ $topic->tid ];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2693,6 +2745,12 @@ class _Records extends \IPS\Content\Item implements
|
||||
throw new \UnexpectedValueException('content_record_no_forum_app_for_topic');
|
||||
}
|
||||
|
||||
/* If we're in the middle of creating a record, don't sync the topic yet */
|
||||
if( static::$creatingRecord === TRUE )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fetch the forum */
|
||||
try
|
||||
{
|
||||
@@ -2784,8 +2842,20 @@ class _Records extends \IPS\Content\Item implements
|
||||
|
||||
$topic->topic_firstpost = $post->pid;
|
||||
$topic->save();
|
||||
|
||||
if( $this->isAnonymous() )
|
||||
{
|
||||
$topic->setAnonymous( TRUE, $this->author );
|
||||
$post->setAnonymous( TRUE, $this->author );
|
||||
}
|
||||
|
||||
$topic->markRead();
|
||||
|
||||
/* Send notifications */
|
||||
if ( !$topic->isFutureDate() AND !$topic->hidden() )
|
||||
{
|
||||
$topic->sendNotifications();
|
||||
}
|
||||
|
||||
/* Update file */
|
||||
$this->record_topicid = $topic->tid;
|
||||
@@ -2945,7 +3015,6 @@ class _Records extends \IPS\Content\Item implements
|
||||
}
|
||||
|
||||
/* Remove Record Image And Record Thumb Image */
|
||||
|
||||
if ( $this->record_image )
|
||||
{
|
||||
try
|
||||
@@ -2964,6 +3033,34 @@ class _Records extends \IPS\Content\Item implements
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
|
||||
/* Clean up any other uploaded files */
|
||||
$fieldsClass = '\IPS\cms\Fields' . static::$customDatabaseId;
|
||||
foreach( $fieldsClass::roots( NULL ) as $id => $field )
|
||||
{
|
||||
if( $field->type == 'Upload' )
|
||||
{
|
||||
$fieldName = 'field_' . $field->id;
|
||||
|
||||
if ( $this->$fieldName )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'cms_Records', $this->$fieldName )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
|
||||
/* Delete thumbnails */
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_database_fields_thumbnails', array( array( 'thumb_field_id=? AND thumb_record_id=?', $field->id, $this->primary_id_field ) ) ) as $thumb )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'cms_Records', $thumb['thumb_location'] )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove any reciprocal linking */
|
||||
\IPS\Db::i()->delete( 'cms_database_fields_reciprocal_map', array( 'map_origin_database_id=? and map_origin_item_id=?', static::database()->id, $this->_id ) );
|
||||
@@ -3378,7 +3475,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
* @param string $exclude Predetermined array of member IDs to exclude
|
||||
* @return void
|
||||
*/
|
||||
public function setFieldQuoteAndMentionExcludes( array $exclude = array() ): void
|
||||
public function setFieldQuoteAndMentionExcludes( array $exclude = array() )
|
||||
{
|
||||
$className = 'IPS\cms\Fields' . static::$customDatabaseId;
|
||||
foreach( $className::data() AS $field )
|
||||
@@ -3558,6 +3655,26 @@ class _Records extends \IPS\Content\Item implements
|
||||
return $this->deleteLogPermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Online List Permissions
|
||||
*
|
||||
* @return string Comma-delimited values or '*'
|
||||
* @li Number indicates a group
|
||||
* @li Number prepended by "m" indicates a member
|
||||
* @li Number prepended by "s" indicates a social group
|
||||
*/
|
||||
public function onlineListPermissions()
|
||||
{
|
||||
/* If search is disabled for this database, we want to use the page/category permissions
|
||||
instead of falling back to searchIndexPermissions */
|
||||
if( ! static::database()->search )
|
||||
{
|
||||
return $this->container()->readPermissionMergeWithPage();
|
||||
}
|
||||
|
||||
return parent::onlineListPermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
@@ -3579,13 +3696,23 @@ class _Records extends \IPS\Content\Item implements
|
||||
* @apiresponse bool hidden Event is hidden
|
||||
* @apiresponse bool pinned Event is pinned
|
||||
* @apiresponse bool featured Event is featured
|
||||
* @apiresponse string url URL
|
||||
* @apiresponse string|NULL url URL, or NULL if the database has not been embedded onto a page
|
||||
* @apiresponse float rating Average Rating
|
||||
* @apiresponse string image Record Image
|
||||
* @apiresponse \IPS\forums\Topic topic The topic
|
||||
*/
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
/* You can have a database that is not embedded onto a page */
|
||||
try
|
||||
{
|
||||
$url = (string) $this->url();
|
||||
}
|
||||
catch( \LogicException $e )
|
||||
{
|
||||
$url = NULL;
|
||||
}
|
||||
|
||||
return array(
|
||||
'id' => $this->primary_id_field,
|
||||
'title' => $this->_title,
|
||||
@@ -3603,7 +3730,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
'hidden' => (bool) $this->hidden(),
|
||||
'pinned' => (bool) $this->mapped('pinned'),
|
||||
'featured' => (bool) $this->mapped('featured'),
|
||||
'url' => (string) $this->url(),
|
||||
'url' => $url,
|
||||
'rating' => $this->averageRating(),
|
||||
'image' => $this->record_image ? (string) \IPS\File::get( 'cms_Records', $this->record_image )->url : null,
|
||||
'topic' => $this->topicid ? $this->topic()->apiOutput( $authorizedMember ) : NULL,
|
||||
@@ -3730,10 +3857,10 @@ class _Records extends \IPS\Content\Item implements
|
||||
/**
|
||||
* Get a count of the database table
|
||||
*
|
||||
*
|
||||
* @return int
|
||||
* @param bool $approximate Accept an approximate result if the table is large (approximate results are faster on large tables)
|
||||
* @return int
|
||||
*/
|
||||
public static function databaseTableCount()
|
||||
public static function databaseTableCount( bool $approximate=FALSE ): int
|
||||
{
|
||||
if ( static::$databaseTable == NULL )
|
||||
{
|
||||
@@ -3741,7 +3868,7 @@ class _Records extends \IPS\Content\Item implements
|
||||
}
|
||||
else
|
||||
{
|
||||
return parent::databaseTableCount();
|
||||
return parent::databaseTableCount( $approximate );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -600,6 +600,8 @@ class _Templates extends \IPS\Patterns\ActiveRecord
|
||||
$form->addMessage( 'cms_templates_export_description_app', 'ipsMessage ipsMessage_general' );
|
||||
}
|
||||
|
||||
$templates = [];
|
||||
|
||||
foreach( \IPS\cms\Templates::getTemplates( \IPS\cms\Templates::RETURN_DATABASE_ONLY + \IPS\cms\Templates::RETURN_ALL ) as $template )
|
||||
{
|
||||
$title = \IPS\cms\Templates::readableGroupName( $template->group );
|
||||
@@ -816,15 +818,15 @@ class _Templates extends \IPS\Patterns\ActiveRecord
|
||||
public static function importUserTemplateXml( string $filePath=NULL, string $fileContents=NULL ):? \IPS\Http\Url\Internal
|
||||
{
|
||||
/* Open XML file */
|
||||
$xml = new \IPS\Xml\XMLReader;
|
||||
|
||||
if( $filePath )
|
||||
{
|
||||
$xml->open( $filePath );
|
||||
$xml = \IPS\Xml\XMLReader::safeOpen( $filePath );
|
||||
}
|
||||
elseif( $fileContents )
|
||||
{
|
||||
if( !$xml->xml( $fileContents ) )
|
||||
$xml = new \IPS\Xml\XMLReader;
|
||||
|
||||
if( !$xml->xml( $fileContents, NULL, LIBXML_NONET ) )
|
||||
{
|
||||
throw \UnexpectedValueException('bad_xml_string');
|
||||
}
|
||||
@@ -1027,8 +1029,7 @@ class _Templates extends \IPS\Patterns\ActiveRecord
|
||||
}
|
||||
|
||||
/* Open XML file */
|
||||
$xml = new \IPS\Xml\XMLReader;
|
||||
$xml->open( $file );
|
||||
$xml = \IPS\Xml\XMLReader::safeOpen( $file );
|
||||
$xml->read();
|
||||
|
||||
while( $xml->read() )
|
||||
@@ -1162,6 +1163,16 @@ class _Templates extends \IPS\Patterns\ActiveRecord
|
||||
if ( isset( static::$multitons[ $this->id ] ) )
|
||||
{
|
||||
unset( static::$multitons[ $this->id ] );
|
||||
|
||||
if( isset( static::$multitonMap['template_id'][ $this->id ] ) )
|
||||
{
|
||||
unset( static::$multitonMap['template_id'][ $this->id ] );
|
||||
}
|
||||
|
||||
if( isset( static::$multitonMap['template_key'][ $this->key ] ) )
|
||||
{
|
||||
unset( static::$multitonMap['template_key'][ $this->key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1173,6 +1184,16 @@ class _Templates extends \IPS\Patterns\ActiveRecord
|
||||
if ( isset( static::$multitons[ $this->id ] ) )
|
||||
{
|
||||
unset( static::$multitons[ $this->id ] );
|
||||
|
||||
if( isset( static::$multitonMap['template_id'][ $this->id ] ) )
|
||||
{
|
||||
unset( static::$multitonMap['template_id'][ $this->id ] );
|
||||
}
|
||||
|
||||
if( isset( static::$multitonMap['template_key'][ $this->key ] ) )
|
||||
{
|
||||
unset( static::$multitonMap['template_key'][ $this->key ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user