Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,46 +12,58 @@
|
||||
namespace IPS\Member\Club;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use ArrayIterator;
|
||||
use IPS\CustomField as SystemCustomField;
|
||||
use IPS\Data\Store;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Node\Permissions;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clubs Customer Field Node
|
||||
*/
|
||||
class _CustomField extends \IPS\CustomField
|
||||
class CustomField extends SystemCustomField implements Permissions
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'core_clubs_fields';
|
||||
public static ?string $databaseTable = 'core_clubs_fields';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'f_';
|
||||
public static string $databasePrefix = 'f_';
|
||||
|
||||
/**
|
||||
* @brief [Node] Order Database Column
|
||||
*/
|
||||
public static $databaseColumnOrder = 'position';
|
||||
public static ?string $databaseColumnOrder = 'position';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Title/Description lang prefix
|
||||
*/
|
||||
protected static $langKey = 'core_clubfield';
|
||||
protected static string $langKey = 'core_clubfield';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Content database table
|
||||
*/
|
||||
protected static $contentDatabaseTable = 'core_clubs_fieldvalues';
|
||||
protected static string $contentDatabaseTable = 'core_clubs_fieldvalues';
|
||||
|
||||
/**
|
||||
* @brief [Node] ACP Restrictions
|
||||
@@ -69,7 +81,7 @@ class _CustomField extends \IPS\CustomField
|
||||
'prefix' => 'foo_', // [Optional] Rather than specifying each key in the map, you can specify a prefix, and it will automatically look for restrictions with the key "[prefix]_add/edit/permissions/delete"
|
||||
* @endcode
|
||||
*/
|
||||
protected static $restrictions = array(
|
||||
protected static ?array $restrictions = array(
|
||||
'app' => 'core',
|
||||
'module' => 'clubs',
|
||||
'all' => 'fields_manage'
|
||||
@@ -78,17 +90,17 @@ class _CustomField extends \IPS\CustomField
|
||||
/**
|
||||
* @brief [Node] Node Title
|
||||
*/
|
||||
public static $nodeTitle = 'clubs_custom_fields';
|
||||
public static string $nodeTitle = 'clubs_custom_fields';
|
||||
|
||||
/**
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
|
||||
*/
|
||||
public static $titleLangPrefix = 'core_clubfield_';
|
||||
public static ?string $titleLangPrefix = 'core_clubfield_';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
public static array $databaseColumnMap = array(
|
||||
'content' => 'extra',
|
||||
'not_null' => 'required',
|
||||
);
|
||||
@@ -96,7 +108,7 @@ class _CustomField extends \IPS\CustomField
|
||||
/**
|
||||
* @brief [CustomField] Additional Field Toggles
|
||||
*/
|
||||
public static $additionalFieldToggles = array(
|
||||
public static array $additionalFieldToggles = array(
|
||||
'Checkbox' => array( 'f_filterable' ),
|
||||
'CheckboxSet' => array( 'f_filterable' ),
|
||||
'Radio' => array( 'f_filterable' ),
|
||||
@@ -107,38 +119,72 @@ class _CustomField extends \IPS\CustomField
|
||||
/**
|
||||
* @brief [CustomField] Editor Options
|
||||
*/
|
||||
public static $editorOptions = array( 'app' => 'core', 'key' => 'Clubs' );
|
||||
public static array $editorOptions = array( 'app' => 'core', 'key' => 'Clubs' );
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Upload Storage Extension
|
||||
*/
|
||||
public static $uploadStorageExtension = 'core_ClubField';
|
||||
public static string $uploadStorageExtension = 'core_ClubField';
|
||||
|
||||
/**
|
||||
* @brief The map of permission columns
|
||||
*/
|
||||
public static array $permissionMap = array(
|
||||
'view' => 'view',
|
||||
'edit' => 2
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief [Node] App for permission index
|
||||
*/
|
||||
public static ?string $permApp = 'core';
|
||||
|
||||
/**
|
||||
* @brief [Node] Type for permission index
|
||||
*/
|
||||
public static ?string $permType = 'clubfields';
|
||||
|
||||
/**
|
||||
* @brief [Node] Prefix string that is automatically prepended to permission matrix language strings
|
||||
*/
|
||||
public static string $permissionLangPrefix = 'perm_club_field_';
|
||||
|
||||
/**
|
||||
*
|
||||
* [Node] Does the currently logged in user have permission to edit permissions for this node?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canManagePermissions(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get fields
|
||||
*
|
||||
* @return array
|
||||
* @return array|ActiveRecordIterator
|
||||
*/
|
||||
public static function fields()
|
||||
public static function fields(): ActiveRecordIterator|array
|
||||
{
|
||||
if ( !isset( \IPS\Data\Store::i()->clubFields ) )
|
||||
if ( !isset( Store::i()->clubFields ) )
|
||||
{
|
||||
$fields = array();
|
||||
$filterable = FALSE;
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_clubs_fields', NULL, 'f_position' ) as $row )
|
||||
foreach ( Db::i()->select( '*', 'core_clubs_fields', NULL, 'f_position' ) as $row )
|
||||
{
|
||||
$fields[ $row['f_id'] ] = $row;
|
||||
if ( $row['f_filterable'] and \in_array( $row['f_type'], array( 'Checkbox', 'CheckboxSet', 'Radio', 'Select', 'YesNo' ) ) )
|
||||
if ( $row['f_filterable'] and in_array( $row['f_type'], array( 'Checkbox', 'CheckboxSet', 'Radio', 'Select', 'YesNo' ) ) )
|
||||
{
|
||||
$filterable = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->clubFields = array( 'fields' => $fields, 'filterable' => $filterable );
|
||||
Store::i()->clubFields = array( 'fields' => $fields, 'filterable' => $filterable );
|
||||
}
|
||||
|
||||
return new \IPS\Patterns\ActiveRecordIterator( new \ArrayIterator( \IPS\Data\Store::i()->clubFields['fields'] ), 'IPS\Member\Club\CustomField' );
|
||||
return new ActiveRecordIterator( new ArrayIterator( Store::i()->clubFields['fields'] ), 'IPS\Member\Club\CustomField' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,26 +192,26 @@ class _CustomField extends \IPS\CustomField
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function areFilterableFields()
|
||||
public static function areFilterableFields(): bool
|
||||
{
|
||||
if ( !isset( \IPS\Data\Store::i()->clubFields ) )
|
||||
if ( !isset( Store::i()->clubFields ) )
|
||||
{
|
||||
static::fields();
|
||||
}
|
||||
return \IPS\Data\Store::i()->clubFields['filterable'];
|
||||
return Store::i()->clubFields['filterable'];
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Add/Edit Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @param Form $form The form
|
||||
* @return void
|
||||
*/
|
||||
public function form( &$form )
|
||||
public function form( Form &$form ) : void
|
||||
{
|
||||
parent::form( $form );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'f_filterable', (bool) $this->filterable, FALSE, array(), NULL, NULL, NULL, 'f_filterable' ) );
|
||||
$form->add( new YesNo( 'f_filterable', (bool) $this->filterable, FALSE, array(), NULL, NULL, NULL, 'f_filterable' ) );
|
||||
|
||||
unset( $form->elements[''][1] );
|
||||
unset( $form->elements['']['pf_max_input'] );
|
||||
@@ -179,7 +225,7 @@ class _CustomField extends \IPS\CustomField
|
||||
* @brief [ActiveRecord] Caches
|
||||
* @note Defined cache keys will be cleared automatically as needed
|
||||
*/
|
||||
protected $caches = array( 'clubFields' );
|
||||
protected array $caches = array( 'clubFields' );
|
||||
|
||||
/**
|
||||
* [Node] Format form values from add/edit form for save
|
||||
@@ -187,7 +233,7 @@ class _CustomField extends \IPS\CustomField
|
||||
* @param array $values Values from the form
|
||||
* @return array
|
||||
*/
|
||||
public function formatFormValues( $values )
|
||||
public function formatFormValues( array $values ): array
|
||||
{
|
||||
if( array_key_exists( 'pf_allow_attachments', $values ) )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user