Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -1,4 +1,5 @@
<?php
/**
* @brief Custom Fields
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
@@ -12,41 +13,55 @@
namespace IPS\nexus\modules\front\clients;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Dispatcher\Controller;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Text;
use IPS\Helpers\Form\Upload;
use IPS\Http\Url;
use IPS\Member;
use IPS\MFA\MFAHandler;
use IPS\nexus\Customer;
use IPS\nexus\Customer\CustomField;
use IPS\Output;
use IPS\Theme;
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 Fields
*/
class _info extends \IPS\Dispatcher\Controller
class info extends Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
if ( !\IPS\Member::loggedIn()->member_id )
if ( !Member::loggedIn()->member_id )
{
\IPS\Output::i()->error( 'no_module_permission_guest', '2X242/1', 403, '' );
Output::i()->error( 'no_module_permission_guest', '2X242/1', 403, '' );
}
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo' ), \IPS\Member::loggedIn()->language()->addToStack('client_info') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('client_info');
\IPS\Output::i()->sidebar['enabled'] = FALSE;
Output::i()->breadcrumb[] = array( Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo' ), Member::loggedIn()->language()->addToStack('client_info') );
Output::i()->title = Member::loggedIn()->language()->addToStack('client_info');
Output::i()->sidebar['enabled'] = FALSE;
if ( $output = \IPS\MFA\MFAHandler::accessToArea( 'nexus', 'BillingInfo', \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo' ) ) )
if ( $output = MFAHandler::accessToArea( 'nexus', 'BillingInfo', Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo' ) ) )
{
$form = new \IPS\Helpers\Form;
$form = new Form;
foreach( $this->_buildInfoForm( TRUE ) AS $formElement )
{
$form->add( $formElement );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->info( $form ) . $output;
Output::i()->output = Theme::i()->getTemplate('clients')->info( $form ) . $output;
return;
}
@@ -58,9 +73,9 @@ class _info extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
$form = new \IPS\Helpers\Form;
$form = new Form;
foreach( $this->_buildInfoForm() AS $formElement )
{
$form->add( $formElement );
@@ -73,24 +88,25 @@ class _info extends \IPS\Dispatcher\Controller
{
if ( isset( $values[ $nameField ] ) )
{
if ( $values[ $nameField ] != \IPS\nexus\Customer::loggedIn()->$nameField )
if ( $values[ $nameField ] != Customer::loggedIn()->$nameField )
{
/* We only need to log this once, so do it if it isn't set */
if ( !isset( $changes['name'] ) )
{
$changes['name'] = \IPS\nexus\Customer::loggedIn()->cm_name;
$changes['name'] = Customer::loggedIn()->cm_name;
}
\IPS\nexus\Customer::loggedIn()->$nameField = $values[ $nameField ];
Customer::loggedIn()->$nameField = $values[ $nameField ];
}
}
}
foreach ( \IPS\nexus\Customer\CustomField::roots() as $field )
foreach ( CustomField::roots() as $field )
{
/* @var CustomField $field */
$column = $field->column;
$helper = $field->buildHelper();
if ( $helper instanceof \IPS\Helpers\Form\Upload )
if ( $helper instanceof Upload )
{
$valueToSave = (string) $values["nexus_ccfield_{$field->id}"];
}
@@ -98,26 +114,26 @@ class _info extends \IPS\Dispatcher\Controller
{
$valueToSave = $helper::stringValue( $values["nexus_ccfield_{$field->id}"] );
}
if ( \IPS\nexus\Customer::loggedIn()->$column != $valueToSave )
if ( Customer::loggedIn()->$column != $valueToSave )
{
$changes['other'][] = array( 'name' => 'nexus_ccfield_' . $field->id, 'value' => $field->displayValue( $valueToSave ), 'old' => $field->displayValue( \IPS\nexus\Customer::loggedIn()->$column ) );
\IPS\nexus\Customer::loggedIn()->$column = $valueToSave;
$changes['other'][] = array( 'name' => 'nexus_ccfield_' . $field->id, 'value' => $field->displayValue( $valueToSave ), 'old' => $field->displayValue( Customer::loggedIn()->$column ) );
Customer::loggedIn()->$column = $valueToSave;
}
if ( $field->type === 'Editor' )
{
$field->claimAttachments( \IPS\nexus\Customer::loggedIn()->member_id );
$field->claimAttachments( Customer::loggedIn()->member_id );
}
}
if ( !empty( $changes ) )
{
\IPS\nexus\Customer::loggedIn()->log( 'info', $changes );
Customer::loggedIn()->log( 'info', $changes );
}
\IPS\nexus\Customer::loggedIn()->save();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo' ) );
Customer::loggedIn()->save();
Output::i()->redirect( Url::internal( 'app=nexus&module=clients&controller=info', 'front', 'clientsinfo' ) );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('clients')->info( $form );
Output::i()->output = Theme::i()->getTemplate('clients')->info( $form );
}
/**
@@ -126,19 +142,20 @@ class _info extends \IPS\Dispatcher\Controller
* @param bool $protected If TRUE, current values will be blanked out
* @return array
*/
protected function _buildInfoForm( $protected = FALSE )
protected function _buildInfoForm( bool $protected = FALSE ) : array
{
$formElements = array();
$formElements['cm_first_name'] = new \IPS\Helpers\Form\Text( 'cm_first_name', $protected ? NULL : \IPS\nexus\Customer::loggedIn()->cm_first_name, TRUE );
$formElements['cm_last_name'] = new \IPS\Helpers\Form\Text( 'cm_last_name', $protected ? NULL : \IPS\nexus\Customer::loggedIn()->cm_last_name, TRUE );
foreach ( \IPS\nexus\Customer\CustomField::roots() as $field )
$formElements['cm_first_name'] = new Text( 'cm_first_name', $protected ? NULL : Customer::loggedIn()->cm_first_name, TRUE );
$formElements['cm_last_name'] = new Text( 'cm_last_name', $protected ? NULL : Customer::loggedIn()->cm_last_name, TRUE );
foreach ( CustomField::roots() as $field )
{
/* @var CustomField $field */
$column = $field->column;
if ( $field->type === 'Editor' )
{
$field::$editorOptions = array_merge( $field::$editorOptions, array( 'attachIds' => array( \IPS\nexus\Customer::loggedIn()->member_id ) ) );
$field::$editorOptions = array_merge( $field::$editorOptions, array( 'attachIds' => array( Customer::loggedIn()->member_id ) ) );
}
$formElements[ $column ] = $field->buildHelper( $protected ? NULL : \IPS\nexus\Customer::loggedIn()->$column );
$formElements[ $column ] = $field->buildHelper( $protected ? NULL : Customer::loggedIn()->$column );
}
return $formElements;