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,57 @@
|
||||
namespace IPS\nexus\Customer;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\CustomField as SystemCustomField;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Login;
|
||||
use IPS\Member\ProfileStep;
|
||||
use IPS\Settings;
|
||||
use IPS\Widget;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom Profile Field Node
|
||||
*/
|
||||
class _CustomField extends \IPS\CustomField
|
||||
class CustomField extends SystemCustomField
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'nexus_customer_fields';
|
||||
public static ?string $databaseTable = 'nexus_customer_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 = 'nexus_ccfield';
|
||||
protected static string $langKey = 'nexus_ccfield';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Content database table
|
||||
*/
|
||||
protected static $contentDatabaseTable = 'nexus_customers';
|
||||
protected static string $contentDatabaseTable = 'nexus_customers';
|
||||
|
||||
/**
|
||||
* @brief [Node] ACP Restrictions
|
||||
@@ -69,7 +80,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' => 'nexus',
|
||||
'module' => 'customers',
|
||||
'prefix' => 'customer_fields_'
|
||||
@@ -78,17 +89,17 @@ class _CustomField extends \IPS\CustomField
|
||||
/**
|
||||
* @brief [Node] Node Title
|
||||
*/
|
||||
public static $nodeTitle = 'nexus_customer_fields';
|
||||
public static string $nodeTitle = 'nexus_customer_fields';
|
||||
|
||||
/**
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
|
||||
*/
|
||||
public static $titleLangPrefix = 'nexus_ccfield_';
|
||||
public static ?string $titleLangPrefix = 'nexus_ccfield_';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
public static array $databaseColumnMap = array(
|
||||
'content' => 'extra',
|
||||
'not_null' => 'reg_require'
|
||||
);
|
||||
@@ -96,34 +107,34 @@ class _CustomField extends \IPS\CustomField
|
||||
/**
|
||||
* @brief [CustomField] Editor Options
|
||||
*/
|
||||
public static $editorOptions = array( 'app' => 'nexus', 'key' => 'Customer' );
|
||||
public static array $editorOptions = array( 'app' => 'nexus', 'key' => 'Customer' );
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Upload Storage Extension
|
||||
*/
|
||||
public static $uploadStorageExtension = 'nexus_Customer';
|
||||
public static string $uploadStorageExtension = 'nexus_Customer';
|
||||
|
||||
/**
|
||||
* [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 );
|
||||
|
||||
if ( \IPS\Login::registrationType() == 'full' )
|
||||
if ( Login::registrationType() == 'full' )
|
||||
{
|
||||
/* Quick register is disabled */
|
||||
$form->addHeader( 'customer_field_registration' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'f_reg_show', $this->reg_show ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'f_reg_require', $this->reg_require ) );
|
||||
$form->add( new YesNo( 'f_reg_show', $this->reg_show ) );
|
||||
$form->add( new YesNo( 'f_reg_require', $this->reg_require ) );
|
||||
}
|
||||
|
||||
$form->addHeader( 'customer_field_purchase' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'f_purchase_show', $this->purchase_show ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'f_purchase_require', $this->purchase_require ) );
|
||||
$form->add( new YesNo( 'f_purchase_show', $this->purchase_show ) );
|
||||
$form->add( new YesNo( 'f_purchase_require', $this->purchase_require ) );
|
||||
|
||||
unset( $form->elements[''][1] );
|
||||
unset( $form->elements['']['pf_not_null'] );
|
||||
@@ -141,50 +152,39 @@ class _CustomField extends \IPS\CustomField
|
||||
* @param array $values Values from the form
|
||||
* @return void
|
||||
*/
|
||||
public function postSaveForm( $values )
|
||||
public function postSaveForm( array $values ) : void
|
||||
{
|
||||
if ( !$this->column )
|
||||
{
|
||||
$this->column = "field_{$this->id}";
|
||||
$this->save();
|
||||
}
|
||||
|
||||
parent::postSaveForm( $values );
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Save Changed Columns
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
public function save(): void
|
||||
{
|
||||
parent::save();
|
||||
\IPS\Widget::deleteCaches( 'donations', 'nexus' );
|
||||
static::recountCustomerFields();
|
||||
Widget::deleteCaches( 'donations', 'nexus' );
|
||||
}
|
||||
|
||||
/**
|
||||
* [ActiveRecord] Delete
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete(): void
|
||||
{
|
||||
parent::delete();
|
||||
static::recountCustomerFields();
|
||||
|
||||
/* Do we need to do stuff with profile steps? */
|
||||
\IPS\Member\ProfileStep::resync();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recount card storage gateays
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected static function recountCustomerFields()
|
||||
{
|
||||
$count = \count( static::roots() );
|
||||
\IPS\Settings::i()->changeValues( array( 'customer_fields' => $count ) );
|
||||
ProfileStep::resync();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,7 +193,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
|
||||
{
|
||||
$values['allow_attachments'] = $values['pf_allow_attachments'];
|
||||
unset( $values['pf_allow_attachments'] );
|
||||
|
||||
Reference in new issue
Block a user