Version 5.0.6
This commit is contained in:
1 parent
a3a4a9ccbd
commit
b89858b2ff
1214 files changed
+92828
-14859
No files matched your search
+49
-8
@@ -14,7 +14,6 @@ namespace IPS\Node;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Application\Module;
|
||||
use IPS\Content\ClubContainer;
|
||||
use IPS\Content\Comment;
|
||||
@@ -79,6 +78,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
* @mixin Colorize
|
||||
* @mixin Permissions
|
||||
* @mixin Icon
|
||||
* @mixin CustomBadge
|
||||
*/
|
||||
abstract class Model extends ActiveRecord
|
||||
{
|
||||
@@ -2747,7 +2747,7 @@ abstract class Model extends ActiveRecord
|
||||
{
|
||||
$canView = true;
|
||||
}
|
||||
elseif( $container !== null AND in_array( $containerId, $perms[ static::$modPerm ] ) )
|
||||
elseif( $container !== null and !empty( $perms[ static::$modPerm ] ) and in_array( $containerId, $perms[ static::$modPerm ] ) )
|
||||
{
|
||||
$canView = true;
|
||||
}
|
||||
@@ -2817,6 +2817,15 @@ abstract class Model extends ActiveRecord
|
||||
*/
|
||||
public function save(): void
|
||||
{
|
||||
/* Validate the counts, sometimes we inadvertently end up with a count less than 0 */
|
||||
foreach( [ '_items', '_comments', '_reviews', '_unapprovedItems', '_unapprovedComments', '_unapprovedReviews', '_futureItems' ] as $column )
|
||||
{
|
||||
if( $this->$column !== null and $this->$column < 0 )
|
||||
{
|
||||
$this->$column = 0;
|
||||
}
|
||||
}
|
||||
|
||||
parent::save();
|
||||
|
||||
if ( in_array( Permissions::class, class_implements( $this ) ) and $this->_permissions !== NULL and $this->_permissions != $this->_originalPermissions )
|
||||
@@ -3529,6 +3538,15 @@ abstract class Model extends ActiveRecord
|
||||
}
|
||||
catch( OutOfRangeException ){}
|
||||
|
||||
/* Delete custom badges */
|
||||
if( IPS::classUsesTrait( $this, CustomBadge::class ) )
|
||||
{
|
||||
if( $badge = $this->getRecordBadge() )
|
||||
{
|
||||
$badge->delete();
|
||||
}
|
||||
}
|
||||
|
||||
parent::delete();
|
||||
|
||||
Event::fire( 'onDelete', $this );
|
||||
@@ -3644,10 +3662,25 @@ abstract class Model extends ActiveRecord
|
||||
public function form( Form &$form ) : void
|
||||
{
|
||||
/* Now loop through and add all the elements to the form */
|
||||
foreach( UiExtension::i()->run( $this, 'formElements' ) as $element )
|
||||
{
|
||||
$form->add( $element );
|
||||
}
|
||||
if( static::$canBeExtended )
|
||||
{
|
||||
foreach( UiExtension::i()->run( $this, 'formElements' ) as $element )
|
||||
{
|
||||
if( is_object( $element ) )
|
||||
{
|
||||
$form->add( $element );
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->addHtml( $element );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( IPS::classUsesTrait( $this, CustomBadge::class ) )
|
||||
{
|
||||
$this->addBadgeFieldsToForm( $form, $this->getRecordBadge() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3670,9 +3703,17 @@ abstract class Model extends ActiveRecord
|
||||
public function saveForm( array $values ): mixed
|
||||
{
|
||||
/* Loop through each extension and update the values */
|
||||
foreach( UiExtension::i()->getObjectExtensions( $this ) as $extension )
|
||||
if( static::$canBeExtended )
|
||||
{
|
||||
$values = $extension->processForm( $this, $values );
|
||||
foreach( UiExtension::i()->getObjectExtensions( $this ) as $extension )
|
||||
{
|
||||
$values = $extension->processForm( $this, $values );
|
||||
}
|
||||
}
|
||||
|
||||
if( IPS::classUsesTrait( $this, CustomBadge::class ) )
|
||||
{
|
||||
$this->saveRecordBadge( $values );
|
||||
}
|
||||
|
||||
foreach ( $values as $k => $v )
|
||||
|
||||
Reference in new issue
Block a user