]> git.mjollnir.org Git - s9y.git/commitdiff
Allow spartacus plugin to configure which repositories to connect to
authorgarvinhicking <garvinhicking>
Sun, 14 Jan 2007 16:21:08 +0000 (16:21 +0000)
committergarvinhicking <garvinhicking>
Sun, 14 Jan 2007 16:21:08 +0000 (16:21 +0000)
docs/NEWS
plugins/serendipity_event_spartacus/lang_en.inc.php
plugins/serendipity_event_spartacus/serendipity_event_spartacus.php

index 82dc87a28f79fdef72b878d42356106eefec51a4..e712fd5680fe2b563a2ad06463c85503345453b7 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,9 @@
 Version 1.2 ()
 ------------------------------------------------------------------------
 
+    * Update Spartacus plugin to allow configuring whether to fetch
+      Themes or Plugins, or only one/none of them (garvinhicking)
+   
     * Remove "View" option for drafted entries in the "Edit entries"
       section and replace with a "Preview" option. (garvinhicking)
 
index 1657c22926fbe17ea5346ae75c38bf0204454e40..3d6158bfe69f9685ab840b146210f2c2bbbbd080 100644 (file)
@@ -37,3 +37,6 @@
 @define('PLUGIN_EVENT_SPARTACUS_TRYCURL', 'Trying to use cURL library as fallback...');
 @define('PLUGIN_EVENT_SPARTACUS_CURLFAIL', 'cURL library returned a failure, too.');
 @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
index ddb950c2dcaa9d99361e47ab78c995421e7c2aaa..1c05c84e7efedac1cfd570233c6cc8129817d3d9 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.11');
+        $propbag->add('version',       '2.12');
         $propbag->add('requirements',  array(
             'serendipity' => '0.9',
             'smarty'      => '2.6.7',
@@ -56,7 +56,7 @@ class serendipity_event_spartacus extends serendipity_event
             'backend_pluginlisting_header_upgrade' => true
         ));
         $propbag->add('groups', array('BACKEND_FEATURES'));
-        $propbag->add('configuration', array('mirror_xml', 'mirror_files', 'chown', 'chmod_files', 'chmod_dir'));
+        $propbag->add('configuration', array('enable_plugins', 'enable_themes', 'mirror_xml', 'mirror_files', 'chown', 'chmod_files', 'chmod_dir'));
     }
 
     function generate_content(&$title) {
@@ -130,6 +130,20 @@ class serendipity_event_spartacus extends serendipity_event
         global $serendipity;
 
         switch($name) {
+            case 'enable_plugins':
+                $propbag->add('type',        'string');
+                $propbag->add('name',        PLUGIN_EVENT_SPARTACUS_ENABLE_PLUGINS);
+                $propbag->add('description', '');
+                $propbag->add('default',     'false');
+                break;
+
+            case 'enable_themes':
+                $propbag->add('type',        'string');
+                $propbag->add('name',        PLUGIN_EVENT_SPARTACUS_ENABLE_THEMES);
+                $propbag->add('description', '');
+                $propbag->add('default',     'true');
+                break;
+
             case 'chmod_files':
                 $propbag->add('type',        'string');
                 $propbag->add('name',        PLUGIN_EVENT_SPARTACUS_CHMOD);
@@ -839,10 +853,12 @@ class serendipity_event_spartacus extends serendipity_event
         if (isset($hooks[$event])) {
             switch($event) {
                 case 'backend_pluginlisting_header':
-                    echo '<br /><div id="upgrade_notice" class="serendipityAdminMsgSuccess">';
-                    echo '<a href="?serendipity[adminModule]=plugins&amp;serendipity[adminAction]=addnew&amp;serendipity[only_group]=UPGRADE" class="serendipityIconLink upgrade_sidebar"><img src="' . serendipity_getTemplateFile('admin/img/upgrade_now.png') . '" style="border: 0px none ; vertical-align: middle; display: inline;" alt="" />' . PLUGIN_EVENT_SPARTACUS_CHECK_SIDEBAR . '</a> &nbsp; ';
-                    echo '<a href="?serendipity[adminModule]=plugins&amp;serendipity[adminAction]=addnew&amp;serendipity[only_group]=UPGRADE&amp;serendipity[type]=event" class="serendipityIconLink upgrade_event"><img src="' . serendipity_getTemplateFile('admin/img/upgrade_now.png') . '" style="border: 0px none ; vertical-align: middle; display: inline;" alt="" />' . PLUGIN_EVENT_SPARTACUS_CHECK_EVENT . '</a> ';
-                    echo '</div>';
+                    if (serendipity_db_bool($this->get_config('enable_plugins'))) {
+                        echo '<br /><div id="upgrade_notice" class="serendipityAdminMsgSuccess">';
+                        echo '<a href="?serendipity[adminModule]=plugins&amp;serendipity[adminAction]=addnew&amp;serendipity[only_group]=UPGRADE" class="serendipityIconLink upgrade_sidebar"><img src="' . serendipity_getTemplateFile('admin/img/upgrade_now.png') . '" style="border: 0px none ; vertical-align: middle; display: inline;" alt="" />' . PLUGIN_EVENT_SPARTACUS_CHECK_SIDEBAR . '</a> &nbsp; ';
+                        echo '<a href="?serendipity[adminModule]=plugins&amp;serendipity[adminAction]=addnew&amp;serendipity[only_group]=UPGRADE&amp;serendipity[type]=event" class="serendipityIconLink upgrade_event"><img src="' . serendipity_getTemplateFile('admin/img/upgrade_now.png') . '" style="border: 0px none ; vertical-align: middle; display: inline;" alt="" />' . PLUGIN_EVENT_SPARTACUS_CHECK_EVENT . '</a> ';
+                        echo '</div>';
+                    }
 
                     return true;
                     break;
@@ -854,50 +870,58 @@ class serendipity_event_spartacus extends serendipity_event
                     break;
 
                 case 'backend_templates_fetchlist':
-                    $eventData = $this->buildTemplateList($this->fetchOnline('template', true), 'template');
+                    if (serendipity_db_bool($this->get_config('enable_themes'))) {
+                        $eventData = $this->buildTemplateList($this->fetchOnline('template', true), 'template');
+                    }
 
                     return true;
                     break;
 
                 case 'backend_templates_fetchtemplate':
-                    if (!empty($eventData['GET']['spartacus_fetch'])) {
-                        $this->download(
-                            $this->fetchOnline('template', true),
-                            $eventData['GET']['theme'],
-                            'templates'
-                        );
+                    if (serendipity_db_bool($this->get_config('enable_themes'))) {
+                        if (!empty($eventData['GET']['spartacus_fetch'])) {
+                            $this->download(
+                                $this->fetchOnline('template', true),
+                                $eventData['GET']['theme'],
+                                'templates'
+                            );
+                        }
                     }
 
                     return false;
                     break;
 
                 case 'backend_plugins_fetchlist':
-                    $type = (isset($serendipity['GET']['type']) ? $serendipity['GET']['type'] : 'sidebar');
-
-                    $eventData = array(
-                       'pluginstack' => $this->buildList($this->fetchOnline($type), $type),
-                       'errorstack'  => array(),
-                       'upgradeURI'  => '&amp;serendipity[spartacus_upgrade]=true',
-                       'baseURI'     => '&amp;serendipity[spartacus_fetch]=' . $type
-                    );
+                    if (serendipity_db_bool($this->get_config('enable_plugins'))) {
+                        $type = (isset($serendipity['GET']['type']) ? $serendipity['GET']['type'] : 'sidebar');
+
+                        $eventData = array(
+                           'pluginstack' => $this->buildList($this->fetchOnline($type), $type),
+                           'errorstack'  => array(),
+                           'upgradeURI'  => '&amp;serendipity[spartacus_upgrade]=true',
+                           'baseURI'     => '&amp;serendipity[spartacus_fetch]=' . $type
+                        );
+                    }
 
                     return true;
                     break;
 
                 case 'backend_plugins_fetchplugin':
-                    if (!empty($eventData['GET']['spartacus_fetch'])) {
-                        $baseDir = $this->download($this->fetchOnline($eventData['GET']['spartacus_fetch'], true), $eventData['GET']['install_plugin']);
-
-                        if ($baseDir === false) {
-                            $eventData['install'] = false;
-                        } elseif (!empty($baseDir)) {
-                            $eventData['GET']['pluginPath'] = $baseDir;
-                        } else {
-                            $eventData['GET']['pluginPath'] = $eventData['GET']['install_plugin'];
-                        }
+                    if (serendipity_db_bool($this->get_config('enable_plugins'))) {
+                        if (!empty($eventData['GET']['spartacus_fetch'])) {
+                            $baseDir = $this->download($this->fetchOnline($eventData['GET']['spartacus_fetch'], true), $eventData['GET']['install_plugin']);
+
+                            if ($baseDir === false) {
+                                $eventData['install'] = false;
+                            } elseif (!empty($baseDir)) {
+                                $eventData['GET']['pluginPath'] = $baseDir;
+                            } else {
+                                $eventData['GET']['pluginPath'] = $eventData['GET']['install_plugin'];
+                            }
 
-                        if ($eventData['GET']['spartacus_upgrade']) {
-                            $eventData['install'] = false;
+                            if ($eventData['GET']['spartacus_upgrade']) {
+                                $eventData['install'] = false;
+                            }
                         }
                     }