Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Application;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
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' );
|
||||
exit;
|
||||
@@ -111,18 +111,8 @@ class _Module extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
if( static::$modules === NULL )
|
||||
{
|
||||
if ( isset( \IPS\Data\Store::i()->modules ) )
|
||||
{
|
||||
$rows = \IPS\Data\Store::i()->modules;
|
||||
}
|
||||
else
|
||||
{
|
||||
$rows = iterator_to_array( \IPS\Db::i()->select( '*', 'core_modules', NULL, 'sys_module_position' )->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id=core_modules.sys_module_id", 'core', 'module' ) ) );
|
||||
\IPS\Data\Store::i()->modules = $rows;
|
||||
}
|
||||
|
||||
static::$modules = array();
|
||||
foreach ( $rows as $row )
|
||||
foreach ( static::getStore() as $row )
|
||||
{
|
||||
static::$modules[ $row['sys_module_application'] ][ $row['sys_module_area'] ][ $row['sys_module_key'] ] = static::constructFromData( $row );
|
||||
}
|
||||
@@ -130,6 +120,22 @@ class _Module extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
|
||||
return static::$modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data store
|
||||
*
|
||||
* @return array
|
||||
* @note Note that all records are returned, even disabled report rules. Enable status needs to be checked in userland code when appropriate.
|
||||
*/
|
||||
public static function getStore()
|
||||
{
|
||||
if ( !isset( \IPS\Data\Store::i()->modules ) )
|
||||
{
|
||||
\IPS\Data\Store::i()->modules = iterator_to_array( \IPS\Db::i()->select( '*', 'core_modules', NULL, 'sys_module_position' )->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id=core_modules.sys_module_id", 'core', 'module' ) ) );
|
||||
}
|
||||
|
||||
return \IPS\Data\Store::i()->modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a module
|
||||
@@ -193,7 +199,7 @@ class _Module extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
try
|
||||
{
|
||||
$module = static::load( $matches[2], 'sys_module_key', count( $where ) ? array_merge( array( array( 'sys_module_application=? and sys_module_area=?', $matches[1], 'front' ) ), array( $where ) ) : array( array( 'sys_module_application=?', $matches[1] ) ) );
|
||||
$module = static::load( $matches[2], 'sys_module_key', \count( $where ) ? array_merge( array( array( 'sys_module_application=? and sys_module_area=?', $matches[1], 'front' ) ), array( $where ) ) : array( array( 'sys_module_application=?', $matches[1] ) ) );
|
||||
$return[ $module->_id ] = $module;
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
@@ -243,7 +249,7 @@ class _Module extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$buttons['default'] = array(
|
||||
'icon' => $this->default ? 'star' : 'star-o',
|
||||
'title' => 'make_default_module',
|
||||
'link' => $url . "&do=setDefaultModule&id={$this->_id}&default=1",
|
||||
'link' => $url->csrf() . "&do=setDefaultModule&id={$this->_id}&default=1",
|
||||
);
|
||||
|
||||
return $buttons;
|
||||
@@ -370,8 +376,12 @@ class _Module extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
public function save( $skipMember=FALSE )
|
||||
{
|
||||
$new = $this->_new;
|
||||
|
||||
$this->_skipClearingMenuCache = $skipMember;
|
||||
|
||||
parent::save();
|
||||
|
||||
$this->_skipClearingMenuCache = FALSE;
|
||||
|
||||
if ( $new )
|
||||
{
|
||||
@@ -384,24 +394,32 @@ class _Module extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
'perm_view' => '*',
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear caches */
|
||||
if( !$skipMember )
|
||||
/**
|
||||
* @brief [ActiveRecord] Caches
|
||||
* @note Defined cache keys will be cleared automatically as needed
|
||||
*/
|
||||
protected $caches = array( 'modules' );
|
||||
|
||||
/**
|
||||
* @brief Skip clearing create menu cache
|
||||
*/
|
||||
protected $_skipClearingMenuCache = FALSE;
|
||||
|
||||
/**
|
||||
* Clear any defined caches
|
||||
*
|
||||
* @param bool $removeMultiton Should the multiton record also be removed?
|
||||
* @return void
|
||||
*/
|
||||
public function clearCaches( $removeMultiton=FALSE )
|
||||
{
|
||||
parent::clearCaches( $removeMultiton );
|
||||
|
||||
if( $this->_skipClearingMenuCache === FALSE )
|
||||
{
|
||||
\IPS\Member::clearCreateMenu();
|
||||
}
|
||||
unset( \IPS\Data\Store::i()->modules );
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Delete the theme set
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
parent::delete();
|
||||
\IPS\Member::clearCreateMenu();
|
||||
unset( \IPS\Data\Store::i()->modules );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user