]> git.mjollnir.org Git - s9y.git/commitdiff
Support remove plugin management interface
authorgarvinhicking <garvinhicking>
Tue, 13 Nov 2007 14:47:44 +0000 (14:47 +0000)
committergarvinhicking <garvinhicking>
Tue, 13 Nov 2007 14:47:44 +0000 (14:47 +0000)
docs/NEWS
plugins/serendipity_event_spartacus/lang_en.inc.php
plugins/serendipity_event_spartacus/serendipity_event_spartacus.php

index 39586491a070f2f4e757d1c73dc138af6d6607fb..e2fe0df34172038e53f199bf3e5863774d2c5f62 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 1.3 ()
 ------------------------------------------------------------------------
 
+    * Add spartacus remote management versioning information subpage.
+      (garvinhicking)
+
     * Patch popup-HTML-code insertion javascript to better inter-
       operate with tinymce, xinha or fckeditor. Thanks to 
       Assen Tchorbadjiev.
index 3d6158bfe69f9685ab840b146210f2c2bbbbd080..22e9a6c88a8890a5ec6853e5a8764d7922adcfaf 100644 (file)
@@ -39,4 +39,9 @@
 @define('PLUGIN_EVENT_SPARTACUS_HEALTFIREWALLED', 'It was not possible to download the required files from the Spartacus repository, but the health of our repository was retrievable. This means your provider uses a content-based firewall and does not allow to fetch PHP code over the web by using mod_security or other reverse proxies. You either need to ask your provider to turn this off, or you cannot use the Spartacus plugin and need to download files manually.');
 
 @define('PLUGIN_EVENT_SPARTACUS_ENABLE_PLUGINS', 'Enable the use of Spartacus for fetching plugins?');
-@define('PLUGIN_EVENT_SPARTACUS_ENABLE_THEMES', 'Enable the use of Spartacus for fetching themes?');
\ No newline at end of file
+@define('PLUGIN_EVENT_SPARTACUS_ENABLE_THEMES', 'Enable the use of Spartacus for fetching themes?');
+
+@define('PLUGIN_EVENT_SPARTACUS_ENABLE_REMOTE', 'Enable remote plugin version information');
+@define('PLUGIN_EVENT_SPARTACUS_ENABLE_REMOTE_DESC', 'If enabled, visitors to %s can see the version information of all installed plugins. You might want to protect this URL through custom .htaccess rules for unprivileged access.');
+@define('PLUGIN_EVENT_SPARTACUS_ENABLE_REMOTE_URL', 'Secret key to Remote plugin version information');
+@define('PLUGIN_EVENT_SPARTACUS_ENABLE_REMOTE_URL_DESC', 'Enter a special URI component that people need to know to access your remote management version information output.');
\ No newline at end of file
index 208e0370b8c73aceb64382a0b612c12fbc821102..fa1ae48aa4fdb6a004b4b5aa30deb69548f77767 100644 (file)
@@ -39,7 +39,7 @@ class serendipity_event_spartacus extends serendipity_event
         $propbag->add('description',   PLUGIN_EVENT_SPARTACUS_DESC);
         $propbag->add('stackable',     false);
         $propbag->add('author',        'Garvin Hicking');
-        $propbag->add('version',       '2.14');
+        $propbag->add('version',       '2.15');
         $propbag->add('requirements',  array(
             'serendipity' => '0.9',
             'smarty'      => '2.6.7',
@@ -53,10 +53,12 @@ class serendipity_event_spartacus extends serendipity_event
             'backend_templates_fetchtemplate'    => true,
 
             'backend_pluginlisting_header'         => true,
-            'backend_pluginlisting_header_upgrade' => true
+            'backend_pluginlisting_header_upgrade' => true,
+            
+            'external_plugin'                      => true
         ));
         $propbag->add('groups', array('BACKEND_FEATURES'));
-        $propbag->add('configuration', array('enable_plugins', 'enable_themes', 'mirror_xml', 'mirror_files', 'chown', 'chmod_files', 'chmod_dir'));
+        $propbag->add('configuration', array('enable_plugins', 'enable_themes', 'enable_remote', 'remote_url', 'mirror_xml', 'mirror_files', 'chown', 'chmod_files', 'chmod_dir'));
     }
 
     function generate_content(&$title) {
@@ -144,6 +146,20 @@ class serendipity_event_spartacus extends serendipity_event
                 $propbag->add('default',     'true');
                 break;
 
+            case 'enable_remote':
+                $propbag->add('type',        'boolean');
+                $propbag->add('name',        PLUGIN_EVENT_SPARTACUS_ENABLE_REMOTE);
+                $propbag->add('description', sprintf(PLUGIN_EVENT_SPARTACUS_ENABLE_REMOTE_DESC, $serendipity['baseURL'] . $serendipity['indexFile'] . '?/plugin/' . $this->get_config('remote_url')));
+                $propbag->add('default',     'false');
+                break;
+
+            case 'remote_url':
+                $propbag->add('type',        'string');
+                $propbag->add('name',        PLUGIN_EVENT_SPARTACUS_ENABLE_REMOTE_URL);
+                $propbag->add('description', PLUGIN_EVENT_SPARTACUS_ENABLE_REMOTE_URL_DESC);
+                $propbag->add('default',     'spartacus_remote');
+                break;
+
             case 'chmod_files':
                 $propbag->add('type',        'string');
                 $propbag->add('name',        PLUGIN_EVENT_SPARTACUS_CHMOD);
@@ -853,6 +869,65 @@ class serendipity_event_spartacus extends serendipity_event
 
         if (isset($hooks[$event])) {
             switch($event) {
+                case 'external_plugin':
+                    if (!serendipity_db_bool($this->get_config('enable_remote'))) {
+                        return false;
+                    }
+
+                    if ($eventData == $this->get_config('remote_url')) {
+                        header('Content-Type: text/plain');
+                        $avail   = array();
+                        $install = array();
+                        $meth    = array('event', 'sidebar');
+                        $active  = serendipity_plugin_api::get_installed_plugins();
+
+                        $avail['event']   = $this->buildList($this->fetchOnline('event'), 'event');
+                        $avail['sidebar'] = $this->buildList($this->fetchOnline('sidebar'), 'sidebar');
+                        
+                        $install['event']   = serendipity_plugin_api::enum_plugin_classes(true);
+                        $install['sidebar'] = serendipity_plugin_api::enum_plugin_classes(false);
+                        
+                        foreach($meth AS $method) {
+                            echo "LISTING: $method\n-------------------\n";
+                            foreach ($install[$method] as $class_data) {
+                                $pluginFile = serendipity_plugin_api::probePlugin($class_data['name'], $class_data['classname'], $class_data['pluginPath']);
+                                $plugin     = serendipity_plugin_api::getPluginInfo($pluginFile, $class_data, $method);
+                        
+                                if (is_object($plugin)) {
+                                    // Object is returned when a plugin could not be cached.
+                                    $bag = new serendipity_property_bag;
+                                    $plugin->introspect($bag);
+                        
+                                    // If a foreign plugin is upgradable, keep the new version number.
+                                    if (isset($avail[$method][$class_data['name']]) && $avail[$method][$class_data['name']]['upgradable']) {
+                                        $class_data['upgrade_version'] = $avail[$method][$class_data['name']]['upgrade_version'];
+                                    }
+                                    $props = serendipity_plugin_api::setPluginInfo($plugin, $pluginFile, $bag, $class_data, 'local', $avail[$method]);
+                                    
+                                } elseif (is_array($plugin)) {
+                                    // Array is returned if a plugin could be fetched from info cache
+                                    $props = $plugin;
+                                } else {
+                                    $props = false;
+                                }
+                        
+                                if (is_array($props)) {
+                                    #print_r($props);
+                                    if (version_compare($props['version'], $props['upgrade_version'], '<')) {
+                                        echo "UPGRADE: " . $class_data['name'] . " -- " . $props['upgrade_version'] . "\n";
+                                    } else {
+                                        echo "OK: " . $class_data['name'] . " -- " . $props['version'] . "\n";
+                                    }
+                                } else {
+                                    echo "ERROR: " . $class_data['true_name'] . "\n";
+                                }
+                            }
+                        }
+                    }
+
+                    return true;
+                    break;
+
                 case 'backend_pluginlisting_header':
                     if (serendipity_db_bool($this->get_config('enable_plugins'))) {
                         echo '<br /><div id="upgrade_notice" class="serendipityAdminMsgSuccess">';