diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php index 167f1d2..981a0de 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php @@ -113,18 +113,17 @@ class PermissionsTask extends AbstractTask public function run() { $command = ''; - $recursive = $this->recursive ? '-R' : ''; if ($this->paths && $this->owner) { - $command .= 'chown '. $recursive .' ' . $this->owner . ' ' . $this->getPathsForCmd() . ';'; + $command .= 'chown '. $this->getOptionsForCmd() .' ' . $this->owner . ' ' . $this->getPathsForCmd() . ';'; } if ($this->paths && $this->group) { - $command .= 'chgrp '. $recursive .' ' . $this->group . ' ' . $this->getPathsForCmd() . ';'; + $command .= 'chgrp '. $this->getOptionsForCmd() .' ' . $this->group . ' ' . $this->getPathsForCmd() . ';'; } if ($this->paths && $this->rights) { - $command .= 'chmod '. $recursive .' ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; + $command .= 'chmod '. $this->getOptionsForCmd() .' ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; } $result = $this->runCommand($command); @@ -132,6 +131,27 @@ class PermissionsTask extends AbstractTask return $result; } + /** + * Returns the options for the commands to run. Only supports -R for now. + * + * @return string + */ + protected function getOptionsForCmd() + { + $optionsForCmd = ''; + $options = array( + 'R' => $this->recursive + ); + + foreach($options as $option => $apply) { + if ($apply == true) { + $optionsForCmd .= $option; + } + } + + return $optionsForCmd ? '-' . $optionsForCmd : ''; + } + /** * Transforms paths array to a string separated by 1 space in order to use * it in a command line.