Example #1
0
 /**
  * Checks that directories are writeable
  *
  * Checks the 'plugin' prefix class variable
  * to ensure that the plugin path, and all
  * subpaths, are writeable by the system.
  *
  * Also ensures that templates are available for
  * all actions, plugins, etc
  *
  * @param CakeAdmin $admin
  * @return mixed boolean true if successful, string error message otherwise
  * @todo test me
  */
 function checkBuild($admin)
 {
     $this->handler();
     $this->handler->cd(APP);
     $contents = $this->handler->read();
     if (!in_array('plugins', $contents[0])) {
         return __("Missing Plugin directory", true);
     }
     $this->handler->cd(APP . 'plugins');
     $contents = $this->handler->read();
     $path = APP . 'plugins' . DS . $admin->plugin;
     // Recover if the required plugin directory is missing
     if (!in_array($admin->plugin, $contents[0])) {
         $this->handler->create($path);
     }
     $contents = $this->handler->read();
     if (!in_array($admin->plugin, $contents[0])) {
         return sprintf(__("Unable to create path: %s", true), $path);
     }
     // Check all the required MVC directories
     $required = array('controllers', 'models', 'views');
     $this->handler->cd($path);
     $content = $this->handler->read();
     foreach ($required as $directory) {
         if (!in_array($directory, $content[0])) {
             $this->handler->create($path . DS . $directory);
         }
         $content = $this->handler->read();
         if (!in_array($directory, $content[0])) {
             return sprintf(__('Missing directory: %s', true), $directory);
         }
     }
     // Check that the directories and files are writeable by shell
     foreach ($required as $directory) {
         if (!$this->handler->chmod($path . DS . $directory)) {
             return sprintf(__('Directory not writeable: %s', true), $directory);
         }
     }
     return true;
 }
Example #2
0
 /**
  * Checks that directories are writeable
  *
  * Checks the 'plugin' prefix class variable
  * to ensure that the plugin path, and all
  * subpaths, are writeable by the system.
  *
  * Also ensures that templates are available for
  * all actions, plugins, etc
  *
  * @param CakeAdmin $admin
  * @return mixed boolean true if successful, string error message otherwise
  * @todo test me
  */
 public function _checkBuild($admin)
 {
     $this->_handler();
     $this->handler->cd(APP);
     $contents = $this->handler->read();
     if (!in_array('Plugin', $contents[0])) {
         return __("Missing Plugin directory");
     }
     $this->handler->cd(APP . 'Plugin');
     $contents = $this->handler->read();
     $path = APP . 'Plugin' . DS . Inflector::camelize($admin->plugin);
     // Recover if the required plugin directory is missing
     if (!in_array($admin->plugin, $contents[0])) {
         $this->handler->create($path);
     }
     $contents = $this->handler->read();
     if (!in_array(Inflector::camelize($admin->plugin), $contents[0])) {
         return __("Unable to create path: %s", $path);
     }
     // Check all the required MVC directories
     $required = array('Controller', 'Model', 'View');
     $this->handler->cd($path);
     $content = $this->handler->read();
     foreach ($required as $directory) {
         if (!in_array($directory, $content[0])) {
             $this->handler->create($path . DS . $directory);
         }
         $content = $this->handler->read();
         if (!in_array($directory, $content[0])) {
             return __('Missing directory: %s', $directory);
         }
     }
     // Check that the directories and files are writeable by shell
     foreach ($required as $directory) {
         if (!$this->handler->chmod($path . DS . $directory)) {
             return __('Directory not writeable: %s', $directory);
         }
     }
     return true;
 }