From: garvinhicking Date: Wed, 5 Oct 2005 09:48:54 +0000 (+0000) Subject: Fix spartacus upgrade problems and chmod issues. X-Git-Tag: 0.9~90 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=21a7ab6f8abf2ec25b3c785d4eadeb180fae0112;p=s9y.git Fix spartacus upgrade problems and chmod issues. --- diff --git a/docs/NEWS b/docs/NEWS index be4a6a0..b033908 100644 --- 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) diff --git a/include/admin/plugins.inc.php b/include/admin/plugins.inc.php index 4332a34..f04c806 100644 --- a/include/admin/plugins.inc.php +++ b/include/admin/plugins.inc.php @@ -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']); diff --git a/include/plugin_api.inc.php b/include/plugin_api.inc.php index 2b1bb8a..58b024c 100644 --- a/include/plugin_api.inc.php +++ b/include/plugin_api.inc.php @@ -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'], diff --git a/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php b/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php index 5c2c7c7..ae03c43 100644 --- a/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php +++ b/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php @@ -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 = '&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' => '&serendipity[spartacus_upgrade]=true', + 'baseURI' => '&serendipity[spartacus_fetch]=' . $type ); return true;