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,35 +12,61 @@ namespace IPS\core\modules\admin\overview;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\core\modules\admin\moderation\spam;
|
||||
use DateInterval;
|
||||
use IPS\core\modules\admin\promotion\seo;
|
||||
use IPS\core\modules\admin\settings\advanced;
|
||||
use IPS\core\modules\admin\settings\terms;
|
||||
use IPS\core\modules\admin\settings\webapp;
|
||||
use IPS\Data\Store;
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\File;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Address;
|
||||
use IPS\Helpers\Form\Color;
|
||||
use IPS\Helpers\Form\Email;
|
||||
use IPS\Helpers\Form\Stack;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\Upload;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Image;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use const IPS\CIC;
|
||||
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial installation onboarding
|
||||
*/
|
||||
class _onboard extends \IPS\Dispatcher\Controller
|
||||
class onboard extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'dashboard/onboard.css', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_dashboard.js', 'core', 'admin' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'dashboard/onboard.css', 'core', 'admin' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'admin_dashboard.js', 'core', 'admin' ) );
|
||||
|
||||
return parent::execute();
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,15 +74,15 @@ class _onboard extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function initial()
|
||||
public function initial() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Settings::i()->changeValues( array( 'onboard_complete' => 1 ) ); // Set the flag that we've hit this page so that it doesn't keep trying to redirect us back
|
||||
Session::i()->csrfCheck();
|
||||
Settings::i()->changeValues( array( 'onboard_complete' => 1 ) ); // Set the flag that we've hit this page so that it doesn't keep trying to redirect us back
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('onboard_pagetitle');
|
||||
\IPS\Output::i()->showTitle = FALSE;
|
||||
\IPS\Output::i()->bypassCsrfKeyCheck = TRUE;
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'dashboard' )->onboardWelcome();
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('onboard_pagetitle');
|
||||
Output::i()->showTitle = FALSE;
|
||||
Output::i()->bypassCsrfKeyCheck = TRUE;
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'dashboard' )->onboardWelcome();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,11 +90,11 @@ class _onboard extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dismiss()
|
||||
public function dismiss() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Email::buildFromTemplate( 'core', 'onboard_reminder', array(), \IPS\Email::TYPE_TRANSACTIONAL )->send( \IPS\Member::loggedIn() );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=dashboard' ) );
|
||||
Session::i()->csrfCheck();
|
||||
\IPS\Email::buildFromTemplate( 'core', 'onboard_reminder', array(), \IPS\Email::TYPE_TRANSACTIONAL )->send( Member::loggedIn() );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=overview&controller=dashboard' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,36 +102,36 @@ class _onboard extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function remind()
|
||||
public function remind() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Settings::i()->changeValues( array( 'onboard_complete' => \IPS\DateTime::ts( time() )->add( new \DateInterval( 'PT20M' ) )->getTimestamp() ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=dashboard' ), 'onboard_will_remind' );
|
||||
Session::i()->csrfCheck();
|
||||
Settings::i()->changeValues( array( 'onboard_complete' => DateTime::ts( time() )->add( new DateInterval( 'PT20M' ) )->getTimestamp() ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=overview&controller=dashboard' ), 'onboard_will_remind' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the form values
|
||||
*
|
||||
* @param $values
|
||||
* @param \IPS\Helpers\Form $form
|
||||
* @param array $values
|
||||
* @param Form $form
|
||||
* @return void
|
||||
*/
|
||||
public function handleForm( $values, \IPS\Helpers\Form $form )
|
||||
public function handleForm( array $values, Form $form ) : void
|
||||
{
|
||||
/* If we dismissed, do that but also send an email */
|
||||
if( isset( \IPS\Request::i()->dismiss ) and \IPS\Request::i()->dismiss == 1 )
|
||||
if( isset( Request::i()->dismiss ) and Request::i()->dismiss == 1 )
|
||||
{
|
||||
\IPS\Email::buildFromTemplate( 'core', 'onboard_reminder', array(), \IPS\Email::TYPE_TRANSACTIONAL )->send( \IPS\Member::loggedIn() );
|
||||
\IPS\Email::buildFromTemplate( 'core', 'onboard_reminder', array(), \IPS\Email::TYPE_TRANSACTIONAL )->send( Member::loggedIn() );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=dashboard' ) );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=overview&controller=dashboard' ) );
|
||||
}
|
||||
|
||||
/* If we said to remind us later, set the flag and redirect */
|
||||
if( isset( \IPS\Request::i()->remind ) and \IPS\Request::i()->remind == 1 )
|
||||
if( isset( Request::i()->remind ) and Request::i()->remind == 1 )
|
||||
{
|
||||
\IPS\Settings::i()->changeValues( array( 'onboard_complete'=>\IPS\DateTime::ts( time() )->add( new \DateInterval( 'PT20M' ) )->getTimestamp() ) );
|
||||
Settings::i()->changeValues( array( 'onboard_complete'=> DateTime::ts( time() )->add( new DateInterval( 'PT20M' ) )->getTimestamp() ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=dashboard' ), 'onboard_will_remind' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=overview&controller=dashboard' ), 'onboard_will_remind' );
|
||||
}
|
||||
|
||||
array_walk( $values[ 'site_social_profiles' ], function( &$value ){
|
||||
@@ -118,8 +144,8 @@ class _onboard extends \IPS\Dispatcher\Controller
|
||||
$values[ 'site_address' ] = json_encode( $values[ 'site_address' ] );
|
||||
$values[ 'icons_favicon' ] = (string) $values[ 'icons_favicon' ];
|
||||
|
||||
$values=\IPS\core\modules\admin\settings\webapp::processApplicationIcon( $values );
|
||||
$values=\IPS\core\modules\admin\settings\terms::processForm( $values );
|
||||
$values= webapp::processApplicationIcon( $values );
|
||||
$values= terms::processForm( $values );
|
||||
|
||||
/* If a logo was uploaded, do stuff with it... */
|
||||
if( isset( $values[ 'initial_logo' ] ) )
|
||||
@@ -127,14 +153,14 @@ class _onboard extends \IPS\Dispatcher\Controller
|
||||
$values[ 'email_logo' ]=(string)$values[ 'initial_logo' ];
|
||||
|
||||
/* Do this once for efficiency */
|
||||
$image=\IPS\Image::create( $values[ 'initial_logo' ]->contents() );
|
||||
$image= Image::create( $values[ 'initial_logo' ]->contents() );
|
||||
$width=$image->width;
|
||||
$height=$image->height;
|
||||
unset( $image );
|
||||
|
||||
foreach( \IPS\Theme::themes() as $theme )
|
||||
foreach( Theme::themes() as $theme )
|
||||
{
|
||||
$logoUrl=(string)\IPS\File::create( 'core_Theme', $values[ 'initial_logo' ]->originalFilename, $values[ 'initial_logo' ]->contents(), NULL, TRUE );
|
||||
$logoUrl=(string)File::create( 'core_Theme', $values[ 'initial_logo' ]->originalFilename, $values[ 'initial_logo' ]->contents(), NULL, TRUE );
|
||||
|
||||
$theme->saveSet( array( 'logo'=>array( 'front'=>array( 'url'=>$logoUrl, 'width'=>$width, 'height'=>$height ) ) ) );
|
||||
}
|
||||
@@ -152,30 +178,30 @@ class _onboard extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Returns the onboarding form
|
||||
*
|
||||
* @return \IPS\Helpers\Form
|
||||
* @return Form
|
||||
*/
|
||||
public function getForm(): \IPS\Helpers\Form
|
||||
public function getForm(): Form
|
||||
{
|
||||
/* Create the form and add our message to it */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class = "ipsForm_vertical";
|
||||
$form = new Form;
|
||||
$form->class = "ipsForm--vertical ipsForm--onboard";
|
||||
|
||||
$form->addTab( 'onboard_tab_identity' );
|
||||
|
||||
/* Super basic configuration options */
|
||||
$form->add( new \IPS\Helpers\Form\Text( 'board_name', \IPS\Settings::i()->board_name, TRUE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Address( 'site_address', \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->site_address ), FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\Stack( 'site_social_profiles', \IPS\Settings::i()->site_social_profiles ? json_decode( \IPS\Settings::i()->site_social_profiles, true ) : array(), FALSE, array( 'stackFieldType' => '\IPS\core\Form\SocialProfiles', 'maxItems' => 50, 'key' => array( 'placeholder' => 'http://example.com', 'size' => 20 ) ) ) );
|
||||
$form->add( new Text( 'board_name', Settings::i()->board_name, TRUE ) );
|
||||
$form->add( new Address( 'site_address', GeoLocation::buildFromJson( Settings::i()->site_address ), FALSE ) );
|
||||
$form->add( new Stack( 'site_social_profiles', Settings::i()->site_social_profiles ? json_decode( Settings::i()->site_social_profiles, true ) : array(), FALSE, array( 'stackFieldType' => '\IPS\core\Form\SocialProfiles', 'maxItems' => 50, 'key' => array( 'placeholder' => 'https://example.com', 'size' => 20 ) ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'email_out', \IPS\Settings::i()->email_out, TRUE, array(), NULL, NULL, NULL, 'email_out' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Email( 'email_in', \IPS\Settings::i()->email_in, TRUE ) );
|
||||
$form->add( new Email( 'email_out', Settings::i()->email_out, TRUE, array(), NULL, NULL, NULL, 'email_out' ) );
|
||||
$form->add( new Email( 'email_in', Settings::i()->email_in, TRUE ) );
|
||||
|
||||
$form->addTab( 'onboard_tab_appearance' );
|
||||
|
||||
/* If we do not have an email logo and none of our themes have a logo, show the logo field */
|
||||
$hasCustomLogo = FALSE;
|
||||
|
||||
foreach( \IPS\Theme::themes() as $theme )
|
||||
foreach( Theme::themes() as $theme )
|
||||
{
|
||||
if( $theme->logo_front )
|
||||
{
|
||||
@@ -184,45 +210,41 @@ class _onboard extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
if( !\IPS\Settings::i()->email_logo and !$hasCustomLogo )
|
||||
if( !Settings::i()->email_logo and !$hasCustomLogo )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'initial_logo', NULL, FALSE, array( 'image' => true, 'storageExtension' => 'core_Theme' ) ) );
|
||||
$form->add( new Upload( 'initial_logo', NULL, FALSE, array( 'image' => true, 'storageExtension' => 'core_Theme' ) ) );
|
||||
}
|
||||
|
||||
/* Generic favicon - easy enough */
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'icons_favicon', \IPS\Settings::i()->icons_favicon ? \IPS\File::get( 'core_Icons', \IPS\Settings::i()->icons_favicon ) : NULL, FALSE, array( 'obscure' => false, 'allowedFileTypes' => array( 'ico', 'png', 'gif', 'jpeg', 'jpg', 'jpe' ), 'storageExtension' => 'core_Icons' ) ) );
|
||||
$form->add( new Upload( 'icons_favicon', Settings::i()->icons_favicon ? File::get( 'core_Icons', Settings::i()->icons_favicon ) : NULL, FALSE, array( 'obscure' => false, 'allowedFileTypes' => array( 'ico', 'png', 'gif', 'jpeg', 'jpg', 'jpe' ), 'storageExtension' => 'core_Icons' ) ) );
|
||||
|
||||
/* Homescreen icons - we accept one upload and create the images we need */
|
||||
$homeScreen = json_decode( \IPS\Settings::i()->icons_homescreen, TRUE ) ?? array();
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'icons_homescreen', ( isset( $homeScreen[ 'original' ] ) ) ? \IPS\File::get( 'core_Icons', $homeScreen[ 'original' ] ) : NULL, FALSE, array( 'image' => true, 'storageExtension' => 'core_Icons' ) ) );
|
||||
$homeScreen = json_decode( Settings::i()->icons_homescreen, TRUE ) ?? array();
|
||||
$form->add( new Upload( 'icons_homescreen', ( isset( $homeScreen[ 'original' ] ) ) ? File::get( 'core_Icons', $homeScreen[ 'original' ] ) : NULL, FALSE, array( 'image' => true, 'storageExtension' => 'core_Icons' ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Color( 'email_color', \IPS\Settings::i()->email_color, TRUE ) );
|
||||
$form->add( new Color( 'email_color', Settings::i()->email_color, TRUE ) );
|
||||
|
||||
/* These options are only for non-cic */
|
||||
if( !\IPS\CIC )
|
||||
if( !CIC )
|
||||
{
|
||||
/* Get the task setting */
|
||||
$form->addTab( 'onboard_tab_tasks' );
|
||||
\IPS\core\modules\admin\settings\advanced::taskSetting( $form );
|
||||
advanced::taskSetting( $form );
|
||||
|
||||
/* Get the htaccess mod_Rewrite setting */
|
||||
$form->addTab( 'onboard_tab_furls' );
|
||||
\IPS\core\modules\admin\promotion\seo::htaccessSetting( $form );
|
||||
|
||||
/* Add captcha. */
|
||||
$form->addTab( 'onboard_tab_spamprevention' );
|
||||
spam::captchaForm( $form );
|
||||
seo::htaccessSetting( $form );
|
||||
}
|
||||
|
||||
/* Add the terms/privacy policy/etc. */
|
||||
$form->addTab( 'onboard_tab_privacyterms' );
|
||||
\IPS\core\modules\admin\settings\terms::buildForm( $form );
|
||||
terms::buildForm( $form );
|
||||
|
||||
/* Add dismiss and remind me later buttons */
|
||||
if( \IPS\Request::i()->initial )
|
||||
if( Request::i()->initial )
|
||||
{
|
||||
$form->addButton( 'onboard_remind_later', 'submit', NULL, 'ipsButton ipsButton_secondary', array( 'name' => 'remind', 'value' => 1, 'csrfKey' => \IPS\Session::i()->csrfKey ) );
|
||||
$form->addButton( 'dismiss', 'submit', NULL, 'ipsButton ipsButton_secondary', array( 'name' => 'dismiss', 'value' => 1, 'csrfKey' => \IPS\Session::i()->csrfKey ) );
|
||||
$form->addButton( 'onboard_remind_later', 'submit', NULL, 'ipsButton ipsButton--secondary', array( 'name' => 'remind', 'value' => 1, 'csrfKey' => Session::i()->csrfKey ) );
|
||||
$form->addButton( 'dismiss', 'submit', NULL, 'ipsButton ipsButton--secondary', array( 'name' => 'dismiss', 'value' => 1, 'csrfKey' => Session::i()->csrfKey ) );
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
@@ -232,7 +254,7 @@ class _onboard extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$form = $this->getForm();
|
||||
|
||||
@@ -240,26 +262,20 @@ class _onboard extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$this->handleForm( $values, $form );
|
||||
|
||||
/* Clear create menu caches */
|
||||
\IPS\Member::clearCreateMenu();
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
/* Clear data stores */
|
||||
unset(
|
||||
\IPS\Data\Store::i()->manifest,
|
||||
\IPS\Data\Store::i()->iebrowserconfig,
|
||||
\IPS\Data\Store::i()->frontNavigation
|
||||
Store::i()->manifest,
|
||||
Store::i()->iebrowserconfig,
|
||||
Store::i()->frontNavigation
|
||||
);
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__onboard_settings' );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=overview&controller=onboard&do=next' ), 'saved' );
|
||||
Session::i()->log( 'acplogs__onboard_settings' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=overview&controller=onboard&do=next' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('onboard_pagetitle_basic');
|
||||
\IPS\Output::i()->output .= $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'dashboard' ), 'onboardForm' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'settings/general.css', 'core', 'admin' ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('onboard_pagetitle_basic');
|
||||
Output::i()->output .= $form->customTemplate( array( Theme::i()->getTemplate( 'dashboard' ), 'onboardForm' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'settings/general.css', 'core', 'admin' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,14 +283,14 @@ class _onboard extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function next()
|
||||
protected function next() : void
|
||||
{
|
||||
\IPS\Output::i()->showTitle = FALSE;
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('onboard_pagetitle');
|
||||
Output::i()->showTitle = FALSE;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('onboard_pagetitle');
|
||||
|
||||
/* Add Emoji - We can't put this directly in the template since those without utf8mb4 will have issues */
|
||||
\IPS\Member::loggedIn()->language()->words['onboard_complete'] .= ' 🎉';
|
||||
Member::loggedIn()->language()->words['onboard_complete'] .= ' 🎉';
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'dashboard' )->onboard();
|
||||
Output::i()->output = Theme::i()->getTemplate( 'dashboard' )->onboard();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user