]> git.mjollnir.org Git - s9y.git/commitdiff
Fix spartacus upgrade problems and chmod issues.
authorgarvinhicking <garvinhicking>
Wed, 5 Oct 2005 09:48:54 +0000 (09:48 +0000)
committergarvinhicking <garvinhicking>
Wed, 5 Oct 2005 09:48:54 +0000 (09:48 +0000)
docs/NEWS
include/admin/plugins.inc.php
include/plugin_api.inc.php
plugins/serendipity_event_spartacus/serendipity_event_spartacus.php

index be4a6a0eb5304fdc46fbc587a5bb30cb1ea0e0bd..b0339085db1f39b17b7dd66ea25dd6ca3d3634f3 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,8 @@
 Version 0.9-beta2 ()
 ------------------------------------------------------------------------
 
+    * Fix spartacus plugin to be able to upgrade plugins (garvinhicking)
+
     * Fix track exits plugin to redirect to the right URL when no URL-ID
       was found. (garvinhicking)
 
index 4332a349f9789cc7e140ca1ee2fd6b65c98e6120..f04c80636dfaf5808af537a513de9f9ce5b40c8d 100644 (file)
@@ -580,7 +580,14 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
             // Object is returned when a plugin could not be cached.
             $bag = new serendipity_property_bag;
             $plugin->introspect($bag);
-            $props = serendipity_plugin_api::setPluginInfo($plugin, $pluginFile, $bag, $class_data);
+
+            // If a foreign plugin is upgradable, keep the new version number.
+            if (isset($foreignPlugins['pluginstack'][$class_data['name']]) && $foreignPlugins['pluginstack'][$class_data['name']]['upgradable']) {
+                $class_data['upgrade_version'] = $foreignPlugins['pluginstack'][$class_data['name']]['upgrade_version'];
+            }
+
+            $props = serendipity_plugin_api::setPluginInfo($plugin, $pluginFile, $bag, $class_data, 'local', $foreignPlugins);
+
             $counter++;
         } elseif (is_array($plugin)) {
             // Array is returned if a plugin could be fetched from info cache
@@ -590,6 +597,11 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
         }
         
         if (is_array($props)) {
+            if (version_compare($props['version'], $props['upgrade_version'], '<')) {
+                $props['upgradable']      = true;
+                $props['customURI']      .= $foreignPlugins['baseURI'] . $foreignPlugins['upgradeURI'];
+            }
+
             $props['installable']  = !($props['stackable'] === false && in_array($class_data['true_name'], $plugins));
             $props['requirements'] = unserialize($props['requirements']);
 
index 2b1bb8a30158fcef30f8d302f9a8e0ea2293994e..58b024cbe1857e08926f87f7d0dcde4536ab7e8c 100644 (file)
@@ -483,7 +483,7 @@ class serendipity_plugin_api {
                 'description'     => $bag->get('description'),
                 'author'          => $bag->get('author'),
                 'version'         => $bag->get('version'),
-                'upgrade_version' => $bag->get('version'),
+                'upgrade_version' => isset($class_data['upgrade_version']) ? $class_data['upgrade_version'] : $bag->get('version'),
                 'requirements'    => serialize($bag->get('requirements')),
                 'website'         => $bag->get('website'),
                 'plugin_class'    => $class_data['name'],
index 5c2c7c75acd25367c43e1c92c27a195ade40a449..ae03c4358d13eba8f2003f9a957b1d7e70995fef 100644 (file)
@@ -28,7 +28,9 @@ if (file_exists($probelang)) {
 @define('PLUGIN_EVENT_SPARTACUS_CHOWN', 'Owner of downloaded files');
 @define('PLUGIN_EVENT_SPARTACUS_CHOWN_DESC', 'Here you can enter the (FTP/Shell) owner (like "nobody") of files downloaded by Spartacus. If empty, no changes are made to the ownership.');
 @define('PLUGIN_EVENT_SPARTACUS_CHMOD', 'Permissions downloaded files');
-@define('PLUGIN_EVENT_SPARTACUS_CHMOD_DESC', 'Here you can enter the octal mode (like "0777") of the file permissions for Spartacus files.(FTP/Shell) owner of files downloaded by Spartacus. If empty, the default permission mask of the system are used. Note that not all servers allow changing/setting permissions. Pay attention that the applied permissions allow reading and writing for the webserver user. Else spartacus/Serendipity cannot overwrite existing files.');
+@define('PLUGIN_EVENT_SPARTACUS_CHMOD_DESC', 'Here you can enter the octal mode (like "0777") of the file permissions for files (FTP/Shell) downloaded by Spartacus. If empty, the default permission mask of the system are used. Note that not all servers allow changing/setting permissions. Pay attention that the applied permissions allow reading and writing for the webserver user. Else spartacus/Serendipity cannot overwrite existing files.');
+@define('PLUGIN_EVENT_SPARTACUS_CHMOD_DIR', 'Permissions downloaded directories');
+@define('PLUGIN_EVENT_SPARTACUS_CHMOD_DIR_DESC', 'Here you can enter the octal mode (like "0777") of the directory permissions for directories (FTP/Shell) downloaded by Spartacus. If empty, the default permission mask of the system are used. Note that not all servers allow changing/setting permissions. Pay attention that the applied permissions allow reading and writing for the webserver user. Else spartacus/Serendipity cannot overwrite existing directories.');
 
 class serendipity_event_spartacus extends serendipity_event
 {
@@ -48,7 +50,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.3');
+        $propbag->add('version',       '2.4');
         $propbag->add('requirements',  array(
             'serendipity' => '0.9',
             'smarty'      => '2.6.7',
@@ -62,7 +64,7 @@ class serendipity_event_spartacus extends serendipity_event
             'backend_templates_fetchtemplate'    => true
         ));
         $propbag->add('groups', array('BACKEND_FEATURES'));
-        $propbag->add('configuration', array('mirror_xml', 'mirror_files', 'chown', 'chmod'));
+        $propbag->add('configuration', array('mirror_xml', 'mirror_files', 'chown', 'chmod_files', 'chmod_dir'));
     }
 
     function generate_content(&$title) {
@@ -128,13 +130,20 @@ class serendipity_event_spartacus extends serendipity_event
         global $serendipity;
 
         switch($name) {
-            case 'chmod':
+            case 'chmod_files':
                 $propbag->add('type',        'string');
                 $propbag->add('name',        PLUGIN_EVENT_SPARTACUS_CHMOD);
                 $propbag->add('description', PLUGIN_EVENT_SPARTACUS_CHMOD_DESC);
                 $propbag->add('default',     '');
                 break;
 
+            case 'chmod_dir':
+                $propbag->add('type',        'string');
+                $propbag->add('name',        PLUGIN_EVENT_SPARTACUS_CHMOD_DIR);
+                $propbag->add('description', PLUGIN_EVENT_SPARTACUS_CHMOD_DIR_DESC);
+                $propbag->add('default',     '');
+                break;
+
             case 'chown':
                 $propbag->add('type',        'string');
                 $propbag->add('name',        PLUGIN_EVENT_SPARTACUS_CHOWN);
@@ -224,14 +233,16 @@ class serendipity_event_spartacus extends serendipity_event
 
     // Apply file permission settings.
     function fileperm($stack, $is_dir) {
-        $chmod = octdec($this->get_config('chmod'));
-        $chown = $this->get_config('chown');
+        $chmod_dir   = intval($this->get_config('chmod_dir'), 8);
+        $chmod_files = intval($this->get_config('chmod_files'), 8);
+        $chown       = $this->get_config('chown');
 
-        if (!empty($chmod) && function_exists('chmod')) {
-            @chmod($stack, $chmod);
-            if ($is_dir) {
-                @chmod($stack, 'ug+x'); // Always ensure directory traversal.
-            }
+        if ($is_dir && !empty($chmod_dir) && function_exists('chmod')) {
+            @chmod($stack, $chmod_dir); // Always ensure directory traversal.
+        }
+
+        if (!$is_dir && !empty($chmod_files) && function_exists('chmod')) {
+            @chmod($stack, $chmod_files); // Always ensure directory traversal.
         }
 
         if (!empty($chown) && function_exists('chown')) {
@@ -468,7 +479,7 @@ class serendipity_event_spartacus extends serendipity_event
                     $installable = false;
                 } elseif (version_compare($bag->get('version'), $data['version'], '<')) {
                     $data['upgradable']      = true;
-                    $data['upgrade_version'] = $pluginstack[$i]['version'];
+                    $data['upgrade_version'] = $data['version'];
                     $data['version']         = $bag->get('version');
                     $upgradeLink             = '&amp;serendipity[spartacus_upgrade]=true';
                 }
@@ -748,7 +759,9 @@ class serendipity_event_spartacus extends serendipity_event
 
                     $eventData = array(
                        'pluginstack' => $this->buildList($this->fetchOnline($type), $type),
-                       'errorstack'  => array()
+                       'errorstack'  => array(),
+                       'upgradeURI'  => '&amp;serendipity[spartacus_upgrade]=true',
+                       'baseURI'     => '&amp;serendipity[spartacus_fetch]=' . $type
                     );
 
                     return true;