*/ // config path must be defined if (!defined('CONFIG_PATH')) die('CONFIG_PATH is not defined!'); /** * Authorization providers management class responsible for restoring * the default settings. Deletes local plugin cofiguration. * * @author Aoi Karasu */ class fa_restore extends fa_manage { /** * Creates the class instance bound with the admin plugin and an authorization provider. * * @param objref $manager object reference to the admin plugin * @param string $cmd name of the command to handle * @param string $provid (optional) an authorization provider id */ function __construct(&$manager, $cmd, $provid='') { parent::__construct(&$manager, $cmd, $provid); } /** * Performs the restore defaults action by deleting the local plugin config files. */ function process_restore() { global $ID; if ($this->_deleteDir(CONFIG_PATH)) { $location = wl($ID).'?do='.$_REQUEST['do'].'&page='.$_REQUEST['page']; header('Location: '.$location); } return ''; } /** * Deletes a directory tree. * * @param string $dirPath directory path to delete */ function _deleteDir($dirPath) { if (! is_dir($dirPath)) { return false; } if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { $dirPath .= '/'; } $files = glob($dirPath . '*', GLOB_MARK); foreach ($files as $file) { if (is_dir($file)) { self::deleteDir($file); } else { unlink($file); } } rmdir($dirPath); return true; } } /* fa_restore */ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */