Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
+65
-15
@@ -116,6 +116,50 @@ class _Plugin extends \IPS\Node\Model
|
||||
|
||||
return self::$multitons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enabled plugins
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function enabledPlugins()
|
||||
{
|
||||
$plugins = static::plugins();
|
||||
$enabled = array();
|
||||
|
||||
foreach( $plugins as $key => $plugin )
|
||||
{
|
||||
if( $plugin->enabled )
|
||||
{
|
||||
$enabled[ $key ] = $plugin;
|
||||
}
|
||||
}
|
||||
|
||||
return $enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin from the file path
|
||||
*
|
||||
* @param string $path Path to a file for the plugin
|
||||
* @return \IPS\Plugin
|
||||
* @throws \OutOfRangeException
|
||||
*/
|
||||
public static function getPluginFromPath( $path )
|
||||
{
|
||||
if( preg_match( "/\/plugins\/(.+?)\//", $path, $matches ) )
|
||||
{
|
||||
foreach( static::plugins() as $plugin )
|
||||
{
|
||||
if( $plugin->location == $matches[1] )
|
||||
{
|
||||
return $plugin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Does the currently logged in user have permission to add aa root node?
|
||||
@@ -190,7 +234,7 @@ class _Plugin extends \IPS\Node\Model
|
||||
{
|
||||
if ( !$this->_id AND isset( $values['plugin_location'] ) )
|
||||
{
|
||||
$values['plugin_location'] = $values['plugin_location'] ?: ( 'p' . mb_substr( md5( uniqid() ), 0, 10 ) );
|
||||
$values['plugin_location'] = $values['plugin_location'] ?: ( 'p' . mb_substr( md5( mt_rand() ), 0, 10 ) );
|
||||
|
||||
@\mkdir( \IPS\ROOT_PATH . "/plugins/{$values['plugin_location']}" );
|
||||
\file_put_contents( \IPS\ROOT_PATH . "/plugins/{$values['plugin_location']}/index.html", '' );
|
||||
@@ -457,6 +501,8 @@ CODE;
|
||||
\IPS\Db::i()->update( 'core_theme_css', array( 'css_hidden' => !$enabled ), array( 'css_plugin=?', $this->id ) );
|
||||
\IPS\Theme::deleteCompiledCss( 'core', 'front', 'custom' );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => (bool) $enabled ), array( "plugin=?", $this->id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -488,22 +534,26 @@ CODE;
|
||||
require_once \IPS\ROOT_PATH . '/plugins/' . $this->location . '/uninstall.php';
|
||||
}
|
||||
|
||||
$iterator = new \RecursiveDirectoryIterator( \IPS\ROOT_PATH . '/plugins/' . $this->location, \FilesystemIterator::SKIP_DOTS );
|
||||
foreach ( new \RecursiveIteratorIterator( $iterator, \RecursiveIteratorIterator::CHILD_FIRST ) as $file )
|
||||
{
|
||||
if ( $file->isDir() )
|
||||
try
|
||||
{
|
||||
$iterator = new \RecursiveDirectoryIterator( \IPS\ROOT_PATH . '/plugins/' . $this->location, \FilesystemIterator::SKIP_DOTS );
|
||||
foreach ( new \RecursiveIteratorIterator( $iterator, \RecursiveIteratorIterator::CHILD_FIRST ) as $file )
|
||||
{
|
||||
@rmdir( $file->getPathname() );
|
||||
if ( $file->isDir() )
|
||||
{
|
||||
@rmdir( $file->getPathname() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@unlink( $file->getPathname() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@unlink( $file->getPathname() );
|
||||
}
|
||||
$dir = \IPS\ROOT_PATH . '/plugins/' . $this->location;
|
||||
$handle = opendir( $dir );
|
||||
closedir ( $handle );
|
||||
@rmdir( $dir );
|
||||
}
|
||||
$dir = \IPS\ROOT_PATH . '/plugins/' . $this->location;
|
||||
$handle = opendir( $dir );
|
||||
closedir ( $handle );
|
||||
@rmdir( $dir );
|
||||
catch( \UnexpectedValueException $e ){}
|
||||
}
|
||||
|
||||
/* Delete stuff */
|
||||
@@ -544,7 +594,7 @@ CODE;
|
||||
}
|
||||
}
|
||||
|
||||
unset( \IPS\Data\Store::i()->settings );
|
||||
\IPS\Settings::i()->clearCache();
|
||||
|
||||
/* Write the data file */
|
||||
\IPS\Plugin\Hook::writeDataFile();
|
||||
|
||||
Reference in new issue
Block a user