From 332cb64b713143e803ac6e2dc1e33d9ad420dedb Mon Sep 17 00:00:00 2001 From: "Florian Aders (EleRas)" Date: Sat, 7 Feb 2015 10:41:42 +0100 Subject: [PATCH] Group file-commands for easier processing in ConfigDaemon Signed-off-by: Florian Aders (EleRas) --- lib/classes/config/class.ConfigDaemon.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/classes/config/class.ConfigDaemon.php b/lib/classes/config/class.ConfigDaemon.php index 5e6a8406..22784194 100644 --- a/lib/classes/config/class.ConfigDaemon.php +++ b/lib/classes/config/class.ConfigDaemon.php @@ -280,10 +280,10 @@ class ConfigDaemon { $return = array(); // Check if the original file should be backupped - // @TODO: Maybe have a backup - space somewhere? + // @TODO: Maybe have a backup - location somewhere central? // @TODO: Use IO - class if (array_key_exists('backup', $attributes)) { - $return[] = array('type' => 'command', 'content' => 'mv "' . $this->_parseContent($attributes['name']) . '" "' . $this->_parseContent($attributes['name']) . '.frx.bak"', 'file' => $this->_parseContent($attributes['name'])); + $return[] = array('type' => 'command', 'content' => 'mv "' . $this->_parseContent($attributes['name']) . '" "' . $this->_parseContent($attributes['name']) . '.frx.bak"'); } // Now the content of the file can be written @@ -295,12 +295,17 @@ class ConfigDaemon { // Let's check if the mode of the file should be changed if (array_key_exists('chmod', $attributes)) { - $return[] = array('type' => 'command', 'content' => 'chmod ' . $attributes['chmod'] . ' "' . $this->_parseContent($attributes['name']) . '"', 'file' => $this->_parseContent($attributes['name'])); + $return[] = array('type' => 'command', 'content' => 'chmod ' . $attributes['chmod'] . ' "' . $this->_parseContent($attributes['name']) . '"'); } // Let's check if the owner of the file should be changed if (array_key_exists('chown', $attributes)) { - $return[] = array('type' => 'command', 'content' => 'chown ' . $attributes['chown'] . ' "' . $this->_parseContent($attributes['name']) . '"', 'file' => $this->_parseContent($attributes['name'])); + $return[] = array('type' => 'command', 'content' => 'chown ' . $attributes['chown'] . ' "' . $this->_parseContent($attributes['name']) . '"'); + } + + // If we have more than 1 element, we want to group this stuff for easier processing later + if (count($return) > 1) { + $return = array('type' => 'file', 'subcommands' => $return, 'name' => $this->_parseContent($attributes['name'])); } if ($visibility > 0) {