Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -128,7 +128,7 @@ class _Rank extends \IPS\Node\Model
|
||||
{
|
||||
if ( $this->icon )
|
||||
{
|
||||
return \IPS\File::get( 'core_Badges', $this->icon );
|
||||
return \IPS\File::get( 'core_Ranks', $this->icon );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -197,9 +197,12 @@ class _Rank extends \IPS\Node\Model
|
||||
*/
|
||||
public function form( &$form )
|
||||
{
|
||||
/* Allow SVGs without the obscure hash removing the file extension */
|
||||
\IPS\File::$safeFileExtensions[] = 'svg';
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'member_ranks_word_custom', NULL, TRUE, array( 'app' => 'core', 'key' => ( $this->id ? "core_member_rank_{$this->id}" : NULL ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'member_ranks_points', $this->points ?: 0, TRUE, array( 'min' => 0 ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'member_ranks_icon', $this->icon ? \IPS\File::get( 'core_Badges', $this->icon ) : NULL, TRUE, array( 'obscure' => FALSE, 'allowedFileTypes' => array_merge( \IPS\Image::$imageExtensions, ['svg'] ), 'checkImage' => TRUE, 'storageExtension' => 'core_Badges' ), function( $val ) {
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'member_ranks_icon', $this->icon ? \IPS\File::get( 'core_Ranks', $this->icon ) : NULL, TRUE, array( 'obscure' => TRUE, 'allowedFileTypes' => array_merge( \IPS\Image::supportedExtensions(), ['svg'] ), 'checkImage' => TRUE, 'storageExtension' => 'core_Ranks' ), function( $val ) {
|
||||
if( !$val )
|
||||
{
|
||||
throw new \DomainException('achievements_bad_image');
|
||||
@@ -285,8 +288,8 @@ class _Rank extends \IPS\Node\Model
|
||||
{
|
||||
try
|
||||
{
|
||||
$image = \IPS\File::get( 'core_Badges', $oldImage );
|
||||
$newImage = \IPS\File::create( 'core_Badges', $image->originalFilename, $image->contents() );
|
||||
$image = \IPS\File::get( 'core_Ranks', $oldImage );
|
||||
$newImage = \IPS\File::create( 'core_Ranks', $image->originalFilename, $image->contents() );
|
||||
$this->icon = (string) $newImage;
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
@@ -309,7 +312,7 @@ class _Rank extends \IPS\Node\Model
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'core_Badges', $this->icon )->delete();
|
||||
\IPS\File::get( 'core_Ranks', $this->icon )->delete();
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
}
|
||||
@@ -332,7 +335,7 @@ class _Rank extends \IPS\Node\Model
|
||||
return array(
|
||||
'id' => $this->id,
|
||||
'name' => $this->_title,
|
||||
'icon' => $this->icon ? $this->_icon->url : $this->_icon,
|
||||
'icon' => $this->icon ? (string) $this->_icon->url : $this->_icon,
|
||||
'points' => $this->points
|
||||
);
|
||||
}
|
||||
@@ -419,7 +422,7 @@ class _Rank extends \IPS\Node\Model
|
||||
|
||||
if ( ! empty( $insert['icon_name'] ) and ! empty( $insert['icon_data'] ) )
|
||||
{
|
||||
$insert['icon'] = (string) \IPS\File::create( 'core_Badges', $insert['icon_name'], $insert['icon_data'], NULL, TRUE, NULL, FALSE );
|
||||
$insert['icon'] = (string) \IPS\File::create( 'core_Ranks', $insert['icon_name'], $insert['icon_data'], NULL, TRUE, NULL, FALSE );
|
||||
|
||||
unset( $insert['icon_name'] );
|
||||
unset( $insert['icon_data'] );
|
||||
|
||||
Reference in new issue
Block a user