Version 5.0.6

This commit is contained in:
Neo committed 2025-12-19 18:55:49 -08:00
1 parent a3a4a9ccbd
commit b89858b2ff
1214 files changed
+92828 -14859

No files matched your search

+22 -18
View File
@@ -15,7 +15,6 @@ namespace IPS\core\Achievements;
use ArrayIterator;
use DomainException;
use Exception;
use IPS\core\CustomBadge;
use IPS\Data\Store;
use IPS\Db;
use IPS\File;
@@ -26,6 +25,7 @@ use IPS\Helpers\Form\Upload;
use IPS\Image;
use IPS\Lang;
use IPS\Member;
use IPS\Node\CustomBadge;
use IPS\Node\Model;
use IPS\Patterns\ActiveRecordIterator;
use IPS\Settings;
@@ -45,6 +45,8 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class Rank extends Model
{
use CustomBadge;
/**
* @brief Database Table
*/
@@ -156,9 +158,9 @@ class Rank extends Model
*/
protected function get__icon(): mixed
{
if ( !$this->rank_use_image )
if ( !$this->rank_use_image and $badge = $this->getRecordBadge() )
{
return CustomBadge::getRecordBadge( $this )->url();
return $badge->file()?->url;
}
if ( $this->icon )
@@ -223,6 +225,18 @@ class Rank extends Model
{
return Member::loggedIn()->language()->addToStack( 'achievements_awards_points', FALSE, [ 'pluralize' => [ $this->points ] ] );
}
/**
* @brief Disable the number overlay for custom badges
*/
public static bool $customBadgeNumberOverlay = false;
/**
* @brief Toggle off these fields when generating a custom badge
*
* @var array|string[]
*/
public static array $customBadgeToggles = [ 'member_ranks_icon' ];
/**
* [Node] Add/Edit Form
@@ -238,8 +252,7 @@ class Rank extends Model
$form->add( new Translatable( 'member_ranks_word_custom', NULL, TRUE, array( 'app' => 'core', 'key' => ( $this->id ? "core_member_rank_{$this->id}" : NULL ) ) ) );
$form->add( new Number( 'member_ranks_points', $this->points ?: 0, TRUE, array( 'min' => 0 ) ) );
$badge = CustomBadge::getRecordBadge( $this );
$badge->addBadgeFieldsToForm( $form, !$this->rank_use_image, ['member_ranks_icon'], 'rank', false );
parent::form( $form );
$form->add( new Upload( 'member_ranks_icon', $this->icon ? File::get( 'core_Ranks', $this->icon ) : NULL, TRUE, array( 'obscure' => TRUE, 'allowedFileTypes' => array_merge( Image::supportedExtensions(), ['svg'] ), 'checkImage' => TRUE, 'storageExtension' => 'core_Ranks' ), function( $val ) {
if( !$val )
@@ -261,8 +274,6 @@ class Rank extends Model
}
}
}, NULL, NULL, 'member_ranks_icon' ) );
parent::form( $form );
}
/**
@@ -289,7 +300,7 @@ class Rank extends Model
{
$values[ mb_substr( $k, 13 ) ] = $v;
}
else if ( $k === 'rank_use_custom' )
else if ( $k === 'custombadge_use_custom' )
{
$values[ 'rank_use_image' ] = !$v;
}
@@ -299,17 +310,10 @@ class Rank extends Model
}
}
/* Generate a custom SVG for this badge if we're not using a custom image */
if( !array_key_exists( 'rank_use_image', $values ) or !$values['rank_use_image'] )
{
CustomBadge::saveRecordBadge( $this, CustomBadge::generateBadgeFromFormValues( $values, 'rank' ) );
}
else
{
CustomBadge::clearCustomBadgeFields( $values, 'rank' );
}
/* If we're using an image, disable the flag for the custom badge */
$values['custombadge_use_custom'] = !( isset( $values['rank_use_image'] ) and $values['rank_use_image'] );
return $values;
return parent::formatFormValues( $values );
}
/**