Version 4.7.23

This commit is contained in:
Neo committed 2025-12-19 16:21:27 -08:00
1 parent 7124a02564
commit 25ddeb65d6
1791 files changed
+76990 -44452

No files matched your search

+76 -2
View File
@@ -173,6 +173,7 @@ class _records extends \IPS\Content\Api\ItemController
* @apiparam int pinned 1/0 indicating if the record should be pinned
* @apiparam int featured 1/0 indicating if the record should be featured
* @apiparam bool anonymous If 1, the item will be posted anonymously.
* @apiparam object image An object with two properties to use as the record image. 'name' for the filename, and 'contents' for the image contents, Base64 Encoded.
* @throws 2T306/4 INVALID_DATABASE The database ID does not exist
* @throws 1T306/5 NO_CATEGORY The category ID does not exist
* @throws 1T306/6 NO_AUTHOR The author ID does not exist
@@ -239,7 +240,7 @@ class _records extends \IPS\Content\Api\ItemController
}
else
{
if ( \IPS\Request::i()->author === 0 )
if ( (int) \IPS\Request::i()->author === 0 )
{
$author = new \IPS\Member;
$author->name = \IPS\Request::i()->author_name;
@@ -298,6 +299,7 @@ class _records extends \IPS\Content\Api\ItemController
* @apiparam int pinned 1/0 indicating if the record should be pinned
* @apiparam int featured 1/0 indicating if the record should be featured
* @apiparam bool anonymous If 1, the item will be posted anonymously.
* @apiparam object image An object with two properties to use as the record image. 'name' for the filename, and 'contents' for the image contents, Base64 Encoded.
* @throws 2T306/9 INVALID_DATABASE The database ID does not exist
* @throws 2T306/6 INVALID_ID The record ID is invalid or the authorized user does not have permission to view it
* @throws 1T306/7 NO_CATEGORY The category ID does not exist or the authorized user does not have permission to post in it
@@ -412,11 +414,34 @@ class _records extends \IPS\Content\Api\ItemController
*/
protected function _createOrUpdate( \IPS\Content\Item $item, $type='add' )
{
$thumbImages = array();
$thumbImages = [];
$linkedFields = [];
/* Set field values */
if ( isset( \IPS\Request::i()->fields ) )
{
$fieldsClass = str_replace( 'Records', 'Fields', \get_class( $item ) );
/* Store a revision before we change any values */
if ( $type == 'edit' AND $item::database()->revisions )
{
$revision = new \IPS\cms\Records\Revisions;
$revision->database_id = $item::$customDatabaseId;
$revision->record_id = $item->_id;
$revision->data = $item->fieldValues( TRUE );
if ( $this->member )
{
$memberId = $this->member->member_id;
}
else
{
$memberId = $item->author()->member_id;
}
$revision->member_id = $memberId;
$revision->save();
}
foreach ( $fieldsClass::data() as $key => $field )
{
if ( isset( \IPS\Request::i()->fields[ $field->id ] ) )
@@ -510,6 +535,10 @@ class _records extends \IPS\Content\Api\ItemController
}
$value = implode( ',', $urls );
}
if ( $field->type === 'Item' )
{
$linkedFields[] = $field;
}
$item->$key = $value;
}
@@ -528,6 +557,45 @@ class _records extends \IPS\Content\Api\ItemController
{
$item->record_updated = $item->record_saved;
}
if ( isset( \IPS\Request::i()->image ) AND isset( \IPS\Request::i()->image['name'] ) AND isset( \IPS\Request::i()->image['contents'] ) )
{
try
{
$image = \IPS\File::create( 'cms_Records', \IPS\Request::i()->image['name'], base64_decode( \IPS\Request::i()->image['contents'] ) );
$image->save();
$fixedFieldSettings = $item::database()->fixed_field_settings;
if ( isset( $fixedFieldSettings['record_image']['thumb_dims'] ) )
{
$thumb = $image->thumbnail( 'cms_Records', $fixedFieldSettings[ 'record_image' ][ 'thumb_dims' ][ 0 ], $fixedFieldSettings[ 'record_image' ][ 'thumb_dims' ][ 1 ] );
}
else
{
$thumb = $image->thumbnail( 'cms_Records' );
}
$thumb->save();
try
{
if ( $item->record_image )
{
\IPS\File::get( 'cms_Records', $item->record_image )->delete();
}
if ( $item->record_image_thumb )
{
\IPS\File::get( 'cms_Records', $item->record_image_thumb )->delete();
}
}
catch( \Throwable ) { }
$item->record_image = (string) $image;
$item->record_image_thumb = (string) $thumb;
}
catch( \Throwable $e ) { }
}
if( $type == 'add' AND ( !$item->_title OR !$item->_content ) )
{
@@ -560,6 +628,12 @@ class _records extends \IPS\Content\Api\ItemController
) );
}
/* Process Linked Fields */
foreach( $linkedFields as $field )
{
$item->processItemFieldData( $field );
}
/* Pass up */
return $item;
}