Version 5.0.0 beta 9
This commit is contained in:
1 parent
214f649f1d
commit
56979f8ee8
202 files changed
+4403
-1123
No files matched your search
@@ -14,6 +14,7 @@ namespace IPS\cms\Blocks;
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Application;
|
||||
use IPS\cms\Pages\Page;
|
||||
@@ -37,6 +38,7 @@ use IPS\Node\Model;
|
||||
use IPS\Node\Permissions;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecord;
|
||||
use IPS\Platform\Bridge;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget;
|
||||
@@ -242,6 +244,20 @@ class Block extends Model implements Permissions
|
||||
if ( ! isset( Store::i()->$functionName ) )
|
||||
{
|
||||
$content = $block->content;
|
||||
|
||||
if( $block->getConfig('editor') == 'php' )
|
||||
{
|
||||
/* If PHP blocks are disabled, stop here */
|
||||
if( !Bridge::i()->featureIsEnabled( 'phpblocks' ) )
|
||||
{
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
eval( $content );
|
||||
$content = ob_get_clean();
|
||||
}
|
||||
|
||||
Store::i()->$functionName = Theme::compileTemplate( $content, $functionName );
|
||||
}
|
||||
|
||||
@@ -515,6 +531,12 @@ EOF;
|
||||
$block_editor = ( isset( Request::i()->block_editor ) ) ? Request::i()->block_editor : ( $this->id ? $this->getConfig('editor') : null );
|
||||
$block_plugin = ( isset( Request::i()->block_plugin ) ) ? Request::i()->block_plugin : ( $this->id ? $this->plugin : null );
|
||||
|
||||
/* Double check that we didn't force the PHP blocks */
|
||||
if( $block_editor == 'php' and !Bridge::i()->featureIsEnabled( 'phpblocks' ) )
|
||||
{
|
||||
$block_editor = 'html';
|
||||
}
|
||||
|
||||
/* Build form */
|
||||
$form->addTab( 'content_block_form_tab__details' );
|
||||
$form->add( new Translatable( 'block_name', NULL, TRUE, array(
|
||||
@@ -692,7 +714,21 @@ EOF;
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->add( new Codemirror( 'block_content', htmlentities( (string) $this->content, ENT_DISALLOWED, 'UTF-8' ), FALSE, array( 'tagSource' => Url::internal( "app=cms&module=pages&controller=blocks&do=loadTags" ), "codeModeAllowedLanguages" => ["ipsphtml"]), function($val ) {
|
||||
$form->add( new Codemirror( 'block_content', htmlentities( (string) $this->content, ENT_DISALLOWED, 'UTF-8' ), FALSE, array( 'tagSource' => Url::internal( "app=cms&module=pages&controller=blocks&do=loadTags" ), "codeModeAllowedLanguages" => ( $block_editor == 'php' ) ? [ "php"] : ["ipsphtml"] ), function( $val ) use( $block_editor ) {
|
||||
if( $block_editor == 'php' )
|
||||
{
|
||||
try
|
||||
{
|
||||
ob_start();
|
||||
@eval( $val );
|
||||
ob_get_clean();
|
||||
}
|
||||
catch ( ParseError|Exception $e )
|
||||
{
|
||||
throw new DomainException( $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( mb_strpos( $val, '{block="' . Request::i()->block_key . '"}' ) !== FALSE )
|
||||
{
|
||||
throw new DomainException('block_content_recursive_error');
|
||||
|
||||
@@ -18,6 +18,7 @@ use ErrorException;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Application;
|
||||
use IPS\Application\Module;
|
||||
use IPS\cms\Databases;
|
||||
use IPS\cms\extensions\core\FrontNavigation\Pages;
|
||||
use IPS\cms\Templates;
|
||||
@@ -1690,6 +1691,32 @@ class Page extends Model implements Permissions
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check permissions
|
||||
*
|
||||
* @param mixed $permission A key which has a value in static::$permissionMap['view'] matching a column ID in core_permission_index
|
||||
* @param Group|Member|null $member The member or group to check (NULL for currently logged in member)
|
||||
* @param bool $considerPostBeforeRegistering If TRUE, and $member is a guest, will return TRUE if "Post Before Registering" feature is enabled
|
||||
* @return bool
|
||||
* @throws OutOfBoundsException If $permission does not exist in static::$permissionMap
|
||||
*/
|
||||
public function can( mixed $permission, Group|Member $member=NULL, bool $considerPostBeforeRegistering = TRUE ): bool
|
||||
{
|
||||
/* If this is a database page, check the Database module permissions.
|
||||
The Dispatcher thinks we are in the Pages module and so the permission check is done on the
|
||||
wrong module. */
|
||||
if( ( Dispatcher::hasInstance() AND Dispatcher::i()->controllerLocation == 'front' ) and $database = $this->getDatabase() )
|
||||
{
|
||||
$member = $member ?: Member::loggedIn();
|
||||
if( !$member->canAccessModule( Module::get( 'cms', 'database' ) ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return parent::can( $permission, $member, $considerPostBeforeRegistering );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Database from the page
|
||||
*
|
||||
@@ -1984,7 +2011,7 @@ class Page extends Model implements Permissions
|
||||
*/
|
||||
public function getSortableName() : string
|
||||
{
|
||||
return $this->seo_name;
|
||||
return $this->seo_name ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3804,7 +3804,17 @@ class Records extends Item implements
|
||||
*/
|
||||
public function getForumId() : int
|
||||
{
|
||||
return $this->_forum_forum;
|
||||
return ( $this->useForumComments() ) ? $this->_forum_forum : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the topic sync is enabled
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isTopicSyncEnabled() : bool
|
||||
{
|
||||
return $this->useForumComments();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user