function firstRun() { // do the check again, for safety reasons: if ($this->_config['date_lch'] !== null) { $this->_installed = true; return zmgError::throwError('Illegal way of accessing firstRun'); } zmgimport('org.zoomfactory.lib.helpers.zmgFileHelper'); if (zmgFileHelper::exists(ZMG_ABS_PATH . DS . 'etc' . DS . 'app.config.php.bak')) { $this->_installed = true; return zmgError::throwError('Illegal access: component already installed.'); } $messages =& zmgFactory::getMessages(); $html_file = "<html><body bgcolor=\"#FFFFFF\"></body></html>"; //make all the necessary folders writable for ZMG $config_dir = ZMG_ABS_PATH . DS . "etc"; if (!zmgFileHelper::chmodRecursive($config_dir)) { $messages->append('Installation Error!', 'Unable to set directory permissions for: ' . $config_dir); } //make sure the configuration file itself is writable if (!zmgFileHelper::chmodRecursive($config_dir . DS . 'app.config.php')) { $messages->append('Installation Error!', 'Unable to set file permissions for: ' . $config_dir . DS . 'app.config.php'); } $media_dir = zmgEnv::getRootPath() . DS . $this->get('filesystem/mediapath'); if (!is_dir($media_dir)) { if (zmgFileHelper::createDir($media_dir)) { if (!zmgFileHelper::write($media_dir . DS . 'index.html', $html_file)) { $messages->append('Installation Error!', 'Unable to write to file: ' . $media_dir . DS . 'index.html'); } } else { $messages->append('Installation Error!', 'Unable to create directory: ' . $media_dir); } } //backup the original config file that came with the distribution package if (!zmgFileHelper::copy('app.config.php', 'app.config.php.bak', ZMG_ABS_PATH . DS . 'etc')) { $messages->append('Installation Error!', 'Unable to copy file: ' . ZMG_ABS_PATH . DS . 'etc' . DS . 'app.config.php'); } $this->_installed = $this->save(); if ($this->_installed) { $messages->append('Installation Success!', 'Your component is ready to use now.'); } else { $messages->append('Installation Error!', 'Settings could not be saved.'); } return $this->_installed; }
/** * Chmods files and directories recursively to Zoom global permissions. Available from 1.0.0 up. * @param path The starting file or directory (no trailing slash) * @return TRUE=all succeeded FALSE=one or more chmods failed */ function chmod($path) { $config =& zmgFactory::getConfig(); $fileperms = octdec($config->get('filesystem/fileperms')); $dirperms = octdec($config->get('filesystem/dirperms')); if (isset($fileperms) || isset($dirperms)) { return zmgFileHelper::chmodRecursive($path, $fileperms, $dirperms); } return true; }