Version 5.0.0 release

This commit is contained in:
Neo committed 2025-12-19 18:37:58 -08:00
1 parent 90e8c7e903
commit a3a4a9ccbd
651 files changed
+7275 -9481

No files matched your search

@@ -0,0 +1,175 @@
<?php
/**
* @brief Community Enhancements
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @since 23 Jan 2025
*/
namespace IPS\core\extensions\core\CommunityEnhancements;
/* To prevent PHP errors (extending class does not exist) revealing path */
use DomainException;
use IPS\Extensions\CommunityEnhancementsAbstract;
use IPS\Email\Outgoing\Postmark as PostmarkHandler;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Password;
use IPS\Helpers\Form\YesNo;
use IPS\Http\Url;
use IPS\Member as Member;
use IPS\Output;
use IPS\Theme;
use IPS\Session;
use IPS\Settings;
use LogicException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Community Enhancement
*/
class Postmark extends CommunityEnhancementsAbstract
{
/**
* @brief Enhancement is enabled?
*/
public bool $enabled = FALSE;
/**
* @brief IPS-provided enhancement?
*/
public bool $ips = FALSE;
/**
* @brief Enhancement has configuration options?
*/
public bool $hasOptions = TRUE;
/**
* @brief Icon data
*/
public string $icon = "postmark.png";
/**
* Constructor
*
* @return void
*/
public function __construct()
{
$this->enabled = !empty( Settings::i()->postmark_server_api_key );
}
/**
* Edit
*
* @return void
*/
public function edit() : void
{
$form = new Form;
$form->addHeader('postmark_settings');
$form->add( new Password( 'postmark_server_api_key', Settings::i()->postmark_server_api_key, TRUE, suffix: Member::loggedIn()->language()->addToStack( 'postmark_server_api_key_suffix' ) ) );
$form->add( new YesNo( 'postmark_track_opens', Settings::i()->postmark_track_opens, FALSE ) );
if( !empty( Settings::i()->postmark_server_api_key ) )
{
$postmark = new PostmarkHandler( Settings::i()->postmark_server_api_key );
$currentSetting = json_decode( Settings::i()->postmark_streams, TRUE );
$streams = $descriptions = [];
foreach( $postmark->api('message-streams')['MessageStreams'] as $stream )
{
if( $stream['MessageStreamType'] == 'Inbound' ) continue;
$streams[ $stream['ID'] ] = $stream['Name'];
$descriptions[ $stream['ID'] ] = '<br>'.$stream['Description'];
}
$form->addHeader('postmark_message_streams');
$form->addMessage( 'postmark_message_description');
$form->addMessage( 'postmark_stream_choose');
$form->add( new Form\Radio( 'postmark_transactional_stream', $currentSetting['transactional'], true, [ 'options' => $streams, 'descriptions' => $descriptions, 'parse' => 'normal' ] ) );
$form->add( new Form\Radio( 'postmark_bulk_stream', $currentSetting['bulk'], true, [ 'options' => $streams, 'descriptions' => $descriptions, 'parse' => 'normal' ] ) );
}
if ( $values = $form->values() )
{
try
{
$this->testSettings( $values );
}
catch ( \Exception $e )
{
Output::i()->error( $e->getMessage(), '2C438/1', 500 );
}
if( isset( $values['postmark_bulk_stream'] ) )
{
$values['postmark_streams'] = json_encode( [ 'bulk' => $values['postmark_bulk_stream'], 'transactional' => $values['postmark_transactional_stream'] ] );
unset( $values['postmark_bulk_stream'], $values['postmark_transactional_stream'] );
}
$form->saveAsSettings( $values );
Session::i()->log( 'acplog__enhancements_edited', array( 'enhancements__core_Postmark' => TRUE ) );
Output::i()->inlineMessage = Member::loggedIn()->language()->addToStack( 'saved' );
}
Output::i()->sidebar['actions'] = array(
'help' => array(
'title' => 'learn_more',
'icon' => 'question-circle',
'link' => Url::ips( 'docs/postmark_api_key' ),
'target' => '_blank'
),
);
Output::i()->output = $form;
}
/**
* Enable/Disable
*
* @param $enabled bool Enable/Disable
* @return void
* @throws DomainException
*/
public function toggle( bool $enabled ) : void
{
/* If we're disabling, just disable */
if ( !$enabled )
{
Settings::i()->changeValues( array( 'postmark_server_api_key' => '' ) );
}
else
{
/* We need an API key. */
throw new DomainException;
}
}
/**
* Test Settings
*
* @return void
* @throws DomainException
*/
protected function testSettings( array $values ) : void
{
/* Test Postmark settings */
$postmark = new PostmarkHandler( $values['postmark_server_api_key'] );
$server = $postmark->api('server');
if( $server === null OR !empty( $server['ErrorCode'] ) )
{
throw new DomainException( Member::loggedIn()->language()->addToStack( 'postmark_api_error', false, [ 'sprintf' => [ (string) $server['ErrorCode'], $server['Message'] ] ] ) );
}
}
}
@@ -60,6 +60,20 @@ class SendGrid extends CommunityEnhancementsAbstract
* @brief Icon data
*/
public string $icon = "sendgrid.png";
/**
* Can we use this? - SendGrid is only available for those that have used it previously, new installs do not have access
*
* @return bool
*/
public static function isAvailable(): bool
{
if( Settings::i()->sendgrid_deprecated )
{
return FALSE;
}
return TRUE;
}
/**
* Constructor
@@ -68,7 +82,7 @@ class SendGrid extends CommunityEnhancementsAbstract
*/
public function __construct()
{
$this->enabled = ( Settings::i()->sendgrid_api_key && Settings::i()->sendgrid_use_for );
$this->enabled = ( static::isAvailable() && Settings::i()->sendgrid_api_key && Settings::i()->sendgrid_use_for );
}
/**
@@ -106,11 +120,6 @@ class SendGrid extends CommunityEnhancementsAbstract
Output::i()->error( $e->getMessage(), '2C339/1' );
}
if( $values['sendgrid_use_for'] > 0 )
{
$values['sparkpost_use_for'] = 0;
}
$form->saveAsSettings( $values );
Session::i()->log( 'acplog__enhancements_edited', array( 'enhancements__core_SendGrid' => TRUE ) );
Output::i()->inlineMessage = Member::loggedIn()->language()->addToStack('saved');
@@ -146,7 +155,7 @@ class SendGrid extends CommunityEnhancementsAbstract
/* Otherwise if we already have an API key, just toggle bulk mail on */
if( $enabled && Settings::i()->sendgrid_api_key )
{
Settings::i()->changeValues( array( 'sendgrid_use_for' => 1, 'sparkpost_use_for' => 0 ) );
Settings::i()->changeValues( array( 'sendgrid_use_for' => 1 ) );
}
else
{
@@ -14,6 +14,7 @@ namespace IPS\core\extensions\core\MemberACPProfileBlocks;
use DomainException;
use IPS\core\MemberACPProfile\Block;
use IPS\Data\Store;
use IPS\Db;
use IPS\Dispatcher;
use IPS\Helpers\Form;
@@ -132,6 +133,9 @@ class Groups extends Block
$this->member->member_group_id = $values['group'];
$this->member->mgroup_others = implode( ',', $values['secondary_groups'] );
$this->member->save();
/* Reset the assignment options cache as it stores member_ids for member level and group level moderators */
unset( Store::i()->assignmentOptions );
Session::i()->log( 'acplog__members_edited_groups', array( $this->member->name => FALSE ) );
@@ -108,10 +108,10 @@ class Content extends ModeratorPermissionsAbstract
* After change
*
* @param array $moderator The moderator
* @param array $changed Values that were changed
* @param array|string $changed Values that were changed
* @return void
*/
public function onChange( array $moderator, array $changed ) : void
public function onChange( array $moderator, array|string $changed ) : void
{
}