sfProjectPermissionsTask.class.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * Fixes symfony directory permissions.
  11. *
  12. * @package symfony
  13. * @subpackage task
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfProjectPermissionsTask.class.php 13423 2008-11-27 13:30:37Z pookey $
  16. */
  17. class sfProjectPermissionsTask extends sfBaseTask
  18. {
  19. /**
  20. * @see sfTask
  21. */
  22. protected function configure()
  23. {
  24. $this->aliases = array('permissions', 'fix-perms');
  25. $this->namespace = 'project';
  26. $this->name = 'permissions';
  27. $this->briefDescription = 'Fixes symfony directory permissions';
  28. $this->detailedDescription = <<<EOF
  29. The [project:permissions|INFO] task fixes directory permissions:
  30. [./symfony project:permissions|INFO]
  31. EOF;
  32. }
  33. /**
  34. * @see sfTask
  35. */
  36. protected function execute($arguments = array(), $options = array())
  37. {
  38. if (file_exists(sfConfig::get('sf_upload_dir')))
  39. {
  40. $this->getFilesystem()->chmod(sfConfig::get('sf_upload_dir'), 0777);
  41. }
  42. $this->getFilesystem()->chmod(sfConfig::get('sf_cache_dir'), 0777);
  43. $this->getFilesystem()->chmod(sfConfig::get('sf_log_dir'), 0777);
  44. $this->getFilesystem()->chmod(sfConfig::get('sf_root_dir').DIRECTORY_SEPARATOR.'symfony', 0777);
  45. $dirs = array(sfConfig::get('sf_cache_dir'), sfConfig::get('sf_upload_dir'), sfConfig::get('sf_log_dir'));
  46. $dirFinder = sfFinder::type('dir');
  47. $fileFinder = sfFinder::type('file');
  48. foreach ($dirs as $dir)
  49. {
  50. $this->getFilesystem()->chmod($dirFinder->in($dir), 0777);
  51. $this->getFilesystem()->chmod($fileFinder->in($dir), 0666);
  52. }
  53. }
  54. }