* @copyright 2004 by http://wombat.exit0.net * @package wombatSite * @subpackage install */ /** * make tool: set permissions to config folder * * using the administration interface to maintain pages * requires to load and save pages in the configuration * subfolder pages * * Also to protect non editable files, those permissions * won't be changed * * @version 1.0.0 * @package wombatSite * @subpackage install */ class wbMaker_ConfigPermission extends wbMaker { /** * information * * @access private * @var array $_info */ var $_info = array( 'maker' => 'ConfigPermission', 'state' => 'new', 'brief' => 'Set proper file permissions to page configuration.', 'msg' => '' ); /** * Location of pages * * relative to baseDir * * @access private * @var string $_confDir */ var $_confDir = 'conf/pages'; /** * location of cache files * * @access private * @var string $_baseDir */ var $_baseDir; /** * patConfiguration * * @access private * @var object $_conf */ var $_conf; /** * bring birth! * * @access public * @return boolean $result true on success */ function __construct() { umask( 0000 ); $this->_baseDir = wbFactory::getParam( 'baseDir' ); $this->_confDir = wbFactory::getParam( 'configDir' ) . '/pages'; $this->_conf =& wbFactory::singleton( 'patConfiguration' ); } /** * php4 constructor wrapper * * @access public * @see __construct() */ function wbMaker_ConfigPermission() { $this->__construct(); } /** * run... * * @access public * @return boolean true on success, false if any target has failed (or patError object on error!) */ function make() { $base = $this->_baseDir . '/' . $this->_confDir; // create base folder if( !is_dir( $base ) ) { $this->_info['state'] = 'failed'; $this->_info['msg'] = 'Could not find configuration directory "'. $base .'"!'; return false; } // make pages folder writeable $res = @chmod( $base, 0777 ); if( !$res ) { $this->_info['state'] = 'failed'; $this->_info['msg'] = 'Could not change permissions of "'. $base .'"!'; return false; } $dir = dir( $base ); if( !$dir ) { $this->_info['state'] = 'failed'; $this->_info['msg'] = 'Could open directory "'. $base .'" for reading!'; return false; } // change permissions of existing files - only if necessary $count = 0; while( false !== ( $entry = $dir->read() ) ) { // skip hidden files and folders if( $entry[0] == '.' ) { continue; } list( $page, $ext ) = explode( '.', $entry ); if( $ext !== 'xml' ) { patErrorManager::raiseNotice( 'wbMaker:ConfigPermission:1', 'Unexpected file found!', 'Found file "' . $entry . '"! does not match extension: ".xml"!' ); continue; } // load page config $this->_conf->loadConfig( '/pages/' . $entry ); $conf = $this->_conf->getConfigValue( 'page' ); $this->_conf->clearConfigValue(); if( $conf['edit'] || $conf['delete'] ) { wbDebugger::addMsg( 'Make', 'Changed permission of page: "'. $page .'"', 'ConfigPermission' ); @chmod( $base . '/' . $entry, 0666 ); ++$count; } } $this->_info['msg'] = 'Adjusted permissions of '. $count .' pages.'; return true; } } ?>