summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorHakan Sandell <sandell.hakan@gmail.com>2011-09-10 15:03:11 +0200
committerHakan Sandell <sandell.hakan@gmail.com>2011-09-10 15:03:11 +0200
commit4645e48889676e072a61645e5c6f0664dd5d906c (patch)
treef04d80f5f401a0d6b954b4b759ca04a317ab87bf /inc
parent48e46d886a3fbb772a8a64be7ff642ccd7613701 (diff)
downloadrpg-4645e48889676e072a61645e5c6f0664dd5d906c.tar.gz
rpg-4645e48889676e072a61645e5c6f0664dd5d906c.tar.bz2
Now using io_savefile with locking and added header
when saving plugin.local
Diffstat (limited to 'inc')
-rw-r--r--inc/plugincontroller.class.php48
1 files changed, 22 insertions, 26 deletions
diff --git a/inc/plugincontroller.class.php b/inc/plugincontroller.class.php
index 632814d3c..3ad0676d7 100644
--- a/inc/plugincontroller.class.php
+++ b/inc/plugincontroller.class.php
@@ -176,37 +176,33 @@ class Doku_Plugin_Controller {
function getCascade() {
return $this->plugin_cascade;
}
+
/**
* Save the current list of plugins
*/
function saveList() {
- if(!empty($this->tmp_plugins)) {
- //quick check to ensure rewrite is necessary
- if($this->tmp_plugins != $this->tmp_bak) {
- //Rebuild local for better check and saving
- $local_plugins = $this->rebuildLocal();
- //only write if the list has changed
- if($local_plugins != $this->plugin_cascade['local']) {
- $file = $this->last_local_config_file;
- $out = "<?php\n";
- foreach ($local_plugins as $plugin => $value) {
- $out .= "\$plugins['$plugin'] = $value;\n";
- }
- // backup current file (remove any existing backup)
- if (@file_exists($file)) {
- if (@file_exists($file.'.bak')) @unlink($file.'.bak');
- if (!io_rename($file, $file.'.bak')) return false;
- }
- //check if can open for writing, else restore
- if (!$fh = @fopen($file, 'wb')) {
- io_rename($file.'.bak', $file);// problem opening, restore the backup
- return false;
- }
- @fwrite($fh, $out);
- fclose($fh);
- return true;
- }
+ global $conf;
+
+ if (empty($this->tmp_plugins)) return false;
+ if ($this->tmp_plugins == $this->tmp_bak) return false;
+
+ // Rebuild list of local settings
+ $local_plugins = $this->rebuildLocal();
+ if($local_plugins != $this->plugin_cascade['local']) {
+ $file = $this->last_local_config_file;
+ $out = "<?php\n/*\n * Local plugin enable/disable settings\n * Auto-generated through plugin/extension manager\n */\n";
+ foreach ($local_plugins as $plugin => $value) {
+ $out .= "\$plugins['$plugin'] = $value;\n";
+ }
+ // backup current file (remove any existing backup)
+ if (@file_exists($file)) {
+ $backup = $file.'.bak';
+ if (@file_exists($backup)) @unlink($backup);
+ if (!@copy($file,$backup)) return false;
+ if ($conf['fperm']) chmod($backup, $conf['fperm']);
}
+ //check if can open for writing, else restore
+ return io_saveFile($file,$out);
}
return false;
}