Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -0,0 +1,49 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class cms_hook_Forum extends _HOOK_CLASS_
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* [Node] Get buttons to display in tree
|
||||
*
|
||||
* @param string $url Base URL
|
||||
* @param bool $subnode Is this a subnode?
|
||||
* @return array
|
||||
*/
|
||||
public function getButtons( $url, $subnode=FALSE )
|
||||
{
|
||||
$buttons = parent::getButtons( $url, $subnode );
|
||||
|
||||
if ( isset( $buttons['delete'] ) AND $this->isUsedByCms() )
|
||||
{
|
||||
unset( $buttons['delete']['data'] );
|
||||
}
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Forum used by any cms category for record/comment topics?
|
||||
*
|
||||
@return bool|\IPS\cms\Databases
|
||||
*/
|
||||
public function isUsedByCms()
|
||||
{
|
||||
foreach ( \IPS\cms\Databases::databases() as $database )
|
||||
{
|
||||
if ( $database->forum_record and $database->forum_forum and $database->forum_forum == $this->id )
|
||||
{
|
||||
return $database;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,9 +32,9 @@ class cms_hook_FriendlyUrl extends _HOOK_CLASS_
|
||||
public static function createFriendlyUrlFromComponents( $components, $potentialFurl )
|
||||
{
|
||||
/* If the normal URL handling has it, or this is the root page, use normal handling, unless Pages is the default app, in which case we'll fallback to it */
|
||||
if ( $return = call_user_func_array( 'parent::createFriendlyUrlFromComponents', func_get_args() ) or !$potentialFurl )
|
||||
if ( $return = parent::createFriendlyUrlFromComponents( $components, $potentialFurl ) or !$potentialFurl )
|
||||
{
|
||||
if ( !\IPS\Application::load('cms')->default )
|
||||
if ( !\IPS\Application::load('cms')->default OR $potentialFurl )
|
||||
{
|
||||
return $return;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class cms_hook_FriendlyUrl extends _HOOK_CLASS_
|
||||
return static::friendlyUrlFromComponent( $protocol, $friendlyUrlComponent, $queryString )->setFriendlyUrlData( $seoTemplate, $seoTitles, array( 'path' => $friendlyUrlComponent ), $friendlyUrlComponent );
|
||||
}
|
||||
|
||||
return call_user_func_array( 'parent::friendlyUrlFromQueryString', func_get_args() );
|
||||
return parent::friendlyUrlFromQueryString( $queryString, $seoTemplate, $seoTitles, $protocol );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ class cms_hook_FriendlyUrl extends _HOOK_CLASS_
|
||||
return $this;
|
||||
}
|
||||
|
||||
return call_user_func_array( 'parent::setFriendlyUrlData', func_get_args() );
|
||||
return parent::setFriendlyUrlData( $seoTemplate, $seoTitles, $matchedParams, $friendlyUrlComponent );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,11 +25,18 @@ class cms_hook_Output extends _HOOK_CLASS_
|
||||
{
|
||||
parent::error( $message, $code, $httpStatusCode, $adminMessage, $httpHeaders, $extra, $faultyAppOrHookId );
|
||||
}
|
||||
|
||||
/* If we just logged out, we don't want to show a "no permission" error */
|
||||
|
||||
/* When we log out, the user is taken back to the page they were just on. If this is producing a "no permission" error, redirect them to the index instead */
|
||||
if ( isset( \IPS\Request::i()->_fromLogout ) )
|
||||
{
|
||||
$this->redirect( \IPS\Http\Url::internal('')->stripQueryString()->setQueryString( '_fromLogout', 1 ) );
|
||||
// _fromLogout=1 indicates that they came from log out. To make sure that we don't cause an infinite redirect (which
|
||||
// would happen if guests cannot view the index page) we need to change _fromLogout, but we can't unset it because _fromLogout={anything}
|
||||
// will clear the autosave content on next load (by Javascript), which we need to do on log out for security reasons... so, _fromLogout=2
|
||||
// is used here which will clear the autosave, but *not* redirect them again
|
||||
if ( \IPS\Request::i()->_fromLogout != 2 )
|
||||
{
|
||||
$this->redirect( \IPS\Http\Url::internal('')->stripQueryString()->setQueryString( '_fromLogout', 2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* If we're in an external script, just show a simple message */
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class cms_hook_Parser extends _HOOK_CLASS_
|
||||
{
|
||||
/**
|
||||
* Get URL bases (whout schema) that we'll allow iframes from
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function allowedIFrameBases()
|
||||
{
|
||||
$return = parent::allowedIFrameBases();
|
||||
|
||||
/* If the CMS root URL is not inside the IPS4 directory, then embeds will fails as the src will not be allowed */
|
||||
if ( \IPS\Settings::i()->cms_root_page_url )
|
||||
{
|
||||
$pages = iterator_to_array( \IPS\Db::i()->select( 'database_page_id', 'cms_databases', array( 'database_page_id > 0' ) ) );
|
||||
|
||||
foreach ( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'cms_pages', array( \IPS\Db::i()->in( 'page_id', $pages ) ) ), 'IPS\cms\Pages\Page' ) as $page )
|
||||
{
|
||||
$return[] = str_replace( array( 'http://', 'https://' ), '', $page->url() );
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,5 @@ class cms_hook_Post extends _HOOK_CLASS_
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class cms_hook_Topic extends _HOOK_CLASS_
|
||||
* @throws \OutOfRangeException|\InvalidArgumentException|\RuntimeException
|
||||
*/
|
||||
public function modAction( $action, \IPS\Member $member = NULL, $reason = NULL, $immediately = FALSE )
|
||||
{
|
||||
{
|
||||
if ( $action === 'delete' )
|
||||
{
|
||||
/* We used to restrict by forum ID but if you move a topic to a new forum then the forum ID will no longer match */
|
||||
@@ -59,7 +59,10 @@ class cms_hook_Topic extends _HOOK_CLASS_
|
||||
catch( \Exception $ex ) { }
|
||||
}
|
||||
}
|
||||
else if ( $action === 'lock' or $action === 'unlock' )
|
||||
|
||||
parent::modAction( $action, $member, $reason, $immediately );
|
||||
|
||||
if ( $action === 'lock' or $action === 'unlock' )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_databases', array( 'database_forum_record=? AND database_forum_comments=?', 1, 1 ) ) as $database )
|
||||
{
|
||||
@@ -73,10 +76,22 @@ class cms_hook_Topic extends _HOOK_CLASS_
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can merge?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canMerge( $member=NULL )
|
||||
{
|
||||
if ( \IPS\cms\Records::topicIsLinked( $this ) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return parent::modAction( $action, $member, $reason, $immediately );
|
||||
return parent::canMerge( $member );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class cms_hook_forums extends _HOOK_CLASS_
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function delete()
|
||||
{
|
||||
/* Load forum and verify that it is not used for comments */
|
||||
$nodeClass = $this->nodeClass;
|
||||
if ( \IPS\Request::i()->subnode )
|
||||
{
|
||||
$nodeClass = $nodeClass::$subnodeClass;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$node = call_user_func( "{$nodeClass}::load", \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S101/J', 404, '' );
|
||||
}
|
||||
|
||||
/* Is any database synced with this forum? */
|
||||
if ( $db = $node->isUsedByCms() )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['cms_forum_used'] = sprintf( \IPS\Member::loggedIn()->language()->get('cms_forum_used'), $db->recordWord( 1 ) );
|
||||
|
||||
\IPS\Output::i()->error( 'cms_forum_used', '1T371/1', 403, '' );
|
||||
}
|
||||
|
||||
return call_user_func_array( 'parent::delete', func_get_args() );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user