From deb7ed70de356d0c0dce4d03f9f3ab965ecf6e4e Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 30 Nov 2009 00:27:02 -0700 Subject: [PATCH] Initial work --- gollem/clipboard.php | 3 +- gollem/edit.php | 3 +- gollem/lib/Api.php | 60 ++---------- gollem/lib/Application.php | 121 +++++++++++++++++++++++ gollem/lib/Auth.php | 232 +++++++++++++++++++++++++++++++++++++++++++++ gollem/lib/Gollem.php | 56 ----------- gollem/lib/Session.php | 193 ------------------------------------- gollem/lib/base.load.php | 25 ----- gollem/lib/base.php | 57 ----------- gollem/manager.php | 3 +- gollem/permissions.php | 3 +- gollem/quota.php | 3 +- gollem/selectlist.php | 4 +- gollem/test.php | 4 +- gollem/view.php | 4 +- 15 files changed, 377 insertions(+), 394 deletions(-) delete mode 100644 gollem/lib/Session.php delete mode 100644 gollem/lib/base.load.php delete mode 100644 gollem/lib/base.php diff --git a/gollem/clipboard.php b/gollem/clipboard.php index 3a884aa5b..060a3baa4 100644 --- a/gollem/clipboard.php +++ b/gollem/clipboard.php @@ -11,7 +11,8 @@ * @package Gollem */ -require_once dirname(__FILE__) . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +new Gollem_Application(array('init' => true)); $dir = Horde_Util::getFormData('dir'); diff --git a/gollem/edit.php b/gollem/edit.php index 26ea1e881..9f630ea7f 100644 --- a/gollem/edit.php +++ b/gollem/edit.php @@ -11,7 +11,8 @@ * @package Gollem */ -require_once dirname(__FILE__) . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +new Gollem_Application(array('init' => true)); $actionID = Horde_Util::getFormData('actionID'); $driver = Horde_Util::getFormData('driver'); diff --git a/gollem/lib/Api.php b/gollem/lib/Api.php index ea0e53da6..842bcf7e0 100644 --- a/gollem/lib/Api.php +++ b/gollem/lib/Api.php @@ -26,11 +26,6 @@ class Gollem_Api extends Horde_Registry_Api */ public function browse($path = '', $properties = array()) { - $GLOBALS['gollem_authentication'] = 'none'; - require_once dirname(__FILE__) . '/base.php'; - require GOLLEM_BASE . '/config/backends.php'; - require GOLLEM_BASE . '/config/credentials.php'; - $path = Gollem::stripAPIPath($path); // Default properties. @@ -148,14 +143,6 @@ class Gollem_Api extends Horde_Registry_Api */ public function put($path, $content, $content_type) { - // Gollem does not handle authentication - $GLOBALS['gollem_authentication'] = 'none'; - - // Include Gollem base libraries - require_once dirname(__FILE__) . '/base.php'; - require GOLLEM_BASE . '/config/backends.php'; - require GOLLEM_BASE . '/config/credentials.php'; - // Clean off the irrelevant portions of the path $path = Gollem::stripAPIPath($path); @@ -207,14 +194,6 @@ class Gollem_Api extends Horde_Registry_Api */ public function mkcol($path) { - // Gollem does not handle authentication - $GLOBALS['gollem_authentication'] = 'none'; - - // Include Gollem base libraries - require_once dirname(__FILE__) . '/base.php'; - require GOLLEM_BASE . '/config/backends.php'; - require GOLLEM_BASE . '/config/credentials.php'; - // Clean off the irrelevant portions of the path $path = Gollem::stripAPIPath($path); @@ -268,14 +247,6 @@ class Gollem_Api extends Horde_Registry_Api */ public function move($path, $dest) { - // Gollem does not handle authentication - $GLOBALS['gollem_authentication'] = 'none'; - - // Include Gollem base libraries - require_once dirname(__FILE__) . '/base.php'; - require GOLLEM_BASE . '/config/backends.php'; - require GOLLEM_BASE . '/config/credentials.php'; - // Clean off the irrelevant portions of the path $path = Gollem::stripAPIPath($path); $dest = Gollem::stripAPIPath($dest); @@ -342,14 +313,6 @@ class Gollem_Api extends Horde_Registry_Api */ public function path_delete($path) { - // Gollem does not handle authentication - $GLOBALS['gollem_authentication'] = 'none'; - - // Include Gollem base libraries - require_once dirname(__FILE__) . '/base.php'; - require GOLLEM_BASE . '/config/backends.php'; - require GOLLEM_BASE . '/config/credentials.php'; - // Clean off the irrelevant portions of the path $path = Gollem::stripAPIPath($path); @@ -410,8 +373,6 @@ class Gollem_Api extends Horde_Registry_Api */ public function getViewLink($dir, $file, $backend = '') { - require_once dirname(__FILE__) . '/base.php'; - if (empty($backend)) { $backend = Gollem::getPreferredBackend(); } @@ -453,7 +414,7 @@ class Gollem_Api extends Horde_Registry_Api * @return string The URL string. */ public function selectlistLink($link_text, $link_style, $formid, - $icon = false, $selectid = '') + $icon = false, $selectid = '') { $link = Horde::link('#', $link_text, $link_style, '_blank', Horde::popupJs(Horde::applicationUrl('selectlist.php'), array('params' => array('formid' => $formid, 'cacheid' => $selectid), 'height' => 500, 'width' => 300, 'urlencode' => true)) . 'return false;'); if ($icon) { @@ -475,14 +436,15 @@ class Gollem_Api extends Horde_Registry_Api { if (!isset($_SESSION['gollem']['selectlist'][$selectid]['files'])) { return null; - } else { - $list = array(); - foreach ($_SESSION['gollem']['selectlist'][$selectid]['files'] as $val) { - list($dir, $filename) = explode('|', $val); - $list[] = array($dir => $filename); - } - return $list; } + + $list = array(); + foreach ($_SESSION['gollem']['selectlist'][$selectid]['files'] as $val) { + list($dir, $filename) = explode('|', $val); + $list[] = array($dir => $filename); + } + + return $list; } /** @@ -495,8 +457,6 @@ class Gollem_Api extends Horde_Registry_Api */ public function returnFromSelectlist($selectid, $index) { - require_once dirname(__FILE__) . '/base.php'; - if (!isset($_SESSION['gollem']['selectlist'][$selectid]['files'][$index])) { return null; } @@ -517,8 +477,6 @@ class Gollem_Api extends Horde_Registry_Api */ public function setSelectlist($selectid = '', $files = array()) { - require_once dirname(__FILE__) . '/base.php'; - if (empty($selectid)) { $selectid = uniqid(mt_rand(), true); } diff --git a/gollem/lib/Application.php b/gollem/lib/Application.php index 7d0f7b356..02d05650d 100644 --- a/gollem/lib/Application.php +++ b/gollem/lib/Application.php @@ -1,4 +1,23 @@ + * 'init' - (boolean|array) If true, perform application init. If an + * array, perform application init and pass the array to init(). + * + */ + public function __construct($args = array()) + { + if (!empty($args['init'])) { + $this->init(is_array($args['init']) ? $args['init'] : array()); + } + } + + /** + * Gollem base initialization. + * + * Global variables defined: + * $gollem_backends - A link to the current list of available backends + * $gollem_be - A link to the current backend parameters in the session + * $gollem_vfs - A link to the current VFS object for the active backend + * + * @param array $args Optional arguments: + *
+     * 'authentication' - (string) The type of authentication to use:
+     *   'horde' - Only use horde authentication
+     *   'none'  - Do not authenticate
+     *   [DEFAULT] - Authenticate to backend; on no auth redirect to
+     *               login screen
+     * 'nocompress' - (boolean) Controls whether the page should be
+     *                compressed.
+     * 'session_control' - (string) Sets special session control limitations:
+     *   'readonly' - Start session readonly
+     *   [DEFAULT] - Start read/write session
+     * 
+ */ + public function init($args = array()) + { + $args = array_merge(array( + 'authentication' => null, + 'nocompress' => false, + 'session_control' => null + ), $args); + + self::$authType = $args['authentication']; + self::$noCompress = $args['nocompress']; + + // Registry. + $s_ctrl = 0; + switch ($args['session_control']) { + case 'readonly': + $s_ctrl = Horde_Registry::SESSION_READONLY; + break; + } + + $GLOBALS['registry'] = Horde_Registry::singleton($s_ctrl); + + try { + $GLOBALS['registry']->pushApp('gollem', array('check_perms' => ($args['authentication'] != 'none'), 'logintasks' => true)); + } catch (Horde_Exception $e) { + Horde_Auth::authenticateFailure('gollem', $e); + } + + if (!defined('GOLLEM_TEMPLATES')) { + define('GOLLEM_TEMPLATES', $GLOBALS['registry']->get('templates')); + } + + // Notification system. + $notification = Horde_Notification::singleton(); + $notification->attach('status'); + + // Start compression. + if (!self::$noCompress) { + Horde::compressOutput(); + } + + // Set the global $gollem_be variable to the current backend's + // parameters. + $GLOBALS['gollem_be'] = empty($_SESSION['gollem']['backend_key']) + ? null + : $_SESSION['gollem']['backends'][$_SESSION['gollem']['backend_key']]; + + // Load the backend list. + Gollem::loadBackendList(); + } + + /** * Returns a list of available permissions. * * @return array An array describing all available permissions. diff --git a/gollem/lib/Auth.php b/gollem/lib/Auth.php index 9444be8a3..595d8df36 100644 --- a/gollem/lib/Auth.php +++ b/gollem/lib/Auth.php @@ -102,4 +102,236 @@ class Gollem_Auth } } + /** + * Check Gollem authentication and change to the currently active + * directory. Redirects to login page on authentication/session failure. + * + * @param string $mode The authentication mode we are using. + * @param boolean $redirect Redirect to the logout page if authentication + * is unsuccessful? + * + * @return boolean True on success, false on failure. + */ + static public function checkAuthentication($mode = null, $redirect = true) + { + $auth_gollem = new Gollem_Auth(); + $reason = $auth_gollem->authenticate(); + + if ($reason !== true) { + if ($redirect) { + if ($mode = 'selectlist') { + $url = Horde_Util::addParameter($GLOBALS['registry']->get('webroot', 'gollem') . '/login.php', 'selectlist_login', 1, false); + } else { + $url = Horde_Auth::addLogoutParameters(self::logoutUrl()); + } + $url = Horde_Util::addParameter($url, 'url', Horde::selfUrl(true, true, true), false); + header('Location: ' . $url); + exit; + } else { + return false; + } + } + + return true; + } + + /** + * Can we log in without a login screen for the requested backend key? + * + * @param string $key The backend key to check. Defaults to + * self::getPreferredBackend(). + * @param boolean $force If true, check the backend key even if there is + * more than one backend. + * + * @return boolean True if autologin possible, false if not. + */ + static public function canAutoLogin($key = null, $force = false) + { + $auto_server = self::getPreferredBackend(); + if ($key === null) { + $key = $auto_server; + } + + return (((count($auto_server) == 1) || $force) && + Horde_Auth::getAuth() && + empty($GLOBALS['gollem_backends'][$key]['loginparams']) && + !empty($GLOBALS['gollem_backends'][$key]['hordeauth'])); + } + + /** + * Take information posted from a login attempt and try setting up + * an initial Gollem session. Handle Horde authentication, if + * required, and only do enough work to see if the user can log + * in. This function should only be called once, when the user first logs + * into Gollem. + * + * Creates the $gollem session variable with the following entries: + * 'backend_key' -- The current backend + * 'be_list' -- The cached list of available backends + * 'selectlist' -- Stores file selections from the API call + * + * Each backend is stored by its name in the 'backends' array. Each + * backend contains the following entries: + * 'attributes' -- See config/backends.php + * 'autologin' -- Whether this backend supports autologin + * 'clipboard' -- The clipboard for the current backend + * 'createhome' -- See config/backends.php + * 'dir' -- The current directory + * 'driver' -- See config/backends.php + * 'filter' -- See config/backends.php + * 'home' -- The user's home directory + * 'hordeauth' -- See config/backends.php + * 'hostspec' -- See config/backends.php + * 'label' -- The label to use + * 'name' -- See config/backends.php + * 'params' -- See config/backends.php + * 'preferred' -- See config/backends.php + * 'root' -- The root directory + * + * @param string $key The backend key to initialize. + * @param string $user The username to use for authentication. + * @param string $pass The password to use for authentication. + * @param array $args Any additional parameters the backend needs. + * + * @return boolean True on success, false on failure. + */ + function createSession($key, $user = null, $pass = null, $args = array()) + { + global $conf; + + /* Make sure we have a key and that it is valid. */ + if (empty($key) || (substr($key, 0, 1) == '_')) { + return false; + } + + /* We might need to override some of the defaults with + * environment-wide settings. Do NOT use the global $backends + * variable as it may not exist. */ + require GOLLEM_BASE . '/config/backends.php'; + if (empty($backends[$key])) { + $entry = sprintf('Invalid server key from client [%s]', $_SERVER['REMOTE_ADDR']); + Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO); + return false; + } + + /* Create gollem session object if it doesn't already exist. */ + if (!isset($_SESSION['gollem'])) { + $_SESSION['gollem'] = array(); + $_SESSION['gollem']['backends'] = array(); + $_SESSION['gollem']['selectlist'] = array(); + } + $_SESSION['gollem']['backends'][$key] = $backends[$key]; + $GLOBALS['gollem_be'] = &$_SESSION['gollem']['backends'][$key]; + $ptr = &$_SESSION['gollem']['backends'][$key]; + $ptr['params'] = array_merge($ptr['params'], $args); + + /* Set the current backend as active. */ + $_SESSION['gollem']['backend_key'] = $key; + + /* Set username now. Don't set the current username if the backend + * already has a username defined. */ + if (empty($ptr['params']['username'])) { + $ptr['params']['username'] = ($user === null) ? Horde_Auth::getBareAuth() : $user; + } + + /* Set password now. The password should always be encrypted within + * the session. */ + if (!empty($ptr['params']['password'])) { + $pass = $ptr['params']['password']; + } + if ($pass === null) { + $ptr['params']['password'] = null; + } else { + $ptr['params']['password'] = Horde_Secret::write(Horde_Secret::getKey('gollem'), $pass); + } + + /* Try to authenticate with the given information. */ + $auth_gollem = new Gollem_Auth(); + if ($auth_gollem->authenticate(null, null, true) !== true) { + unset($_SESSION['gollem']['backends'][$key]); + $_SESSION['gollem']['backend_key'] = null; + return false; + } + + // Make sure we have a 'root' parameter. + if (empty($ptr['root'])) { + $ptr['root'] = '/'; + } + $ptr['root'] = Horde_Util::realPath($ptr['root']); + + // Make sure we have a 'home' parameter. + if (empty($ptr['home'])) { + $ptr['home'] = (!empty($ptr['params']['home'])) ? $ptr['params']['home'] : $GLOBALS['gollem_vfs']->getCurrentDirectory(); + if (empty($ptr['home'])) { + $ptr['home'] = $ptr['root']; + } + } + + // Make sure the home parameter lives under root if it is a relative + // directory. + if (strpos($ptr['home'], '/') !== 0) { + $ptr['home'] = $ptr['root'] . '/' . $ptr['home']; + } + $ptr['home'] = Horde_Util::realPath($ptr['home']); + $ptr['dir'] = $ptr['home']; + + // Verify that home is below root. + if (!Gollem::verifyDir($ptr['home'])) { + $error_msg = 'Backend Configuration Error: Home directory not below root.'; + $auth_gollem->gollemSetAuthErrorMsg($error_msg); + Horde::logMessage(PEAR::raiseError($error_msg), __FILE__, __LINE__, PEAR_LOG_ERR); + unset($_SESSION['gollem']['backends'][$key]); + $_SESSION['gollem']['backend_key'] = null; + return false; + } + + /* Create the home directory if it doesn't already exist. */ + if (($ptr['home'] != '/') && !empty($ptr['createhome'])) { + $pos = strrpos($ptr['home'], '/'); + $cr_dir = substr($ptr['home'], 0, $pos); + $cr_file = substr($ptr['home'], $pos + 1); + if (!$GLOBALS['gollem_vfs']->exists($cr_dir, $cr_file)) { + $res = Gollem::createFolder($cr_dir, $cr_file); + if (is_a($res, 'PEAR_Error')) { + $error_msg = 'Backend Configuration Error: Could not create home directory ' . $ptr['home'] . '.'; + $auth_gollem->gollemSetAuthErrorMsg($error_msg); + Horde::logMessage(PEAR::raiseError($error_msg), __FILE__, __LINE__, PEAR_LOG_ERR); + unset($_SESSION['gollem']['backends'][$key]); + $_SESSION['gollem']['backend_key'] = null; + return false; + } + } + } + + /* Does this driver support autologin? */ + $ptr['autologin'] = Gollem::canAutoLogin(true); + + /* Cache the backend_list in the session. */ + if (empty($_SESSION['gollem']['be_list'])) { + Gollem::loadBackendList(); + $_SESSION['gollem']['be_list'] = $GLOBALS['gollem_backends']; + } + + /* Initialize clipboard. */ + if (!isset($_SESSION['gollem']['clipboard'])) { + $_SESSION['gollem']['clipboard'] = array(); + } + + /* Call Gollem::changeDir() to make sure the label is set. */ + Gollem::changeDir(); + + return true; + } + + /** + * Change the currently active backend. + * + * @param string $key The ID of the backend to set as active. + */ + function changeBackend($key) + { + $_SESSION['gollem']['backend_key'] = $key; + $GLOBALS['gollem_be'] = &$_SESSION['gollem']['backends'][$key]; + } + } diff --git a/gollem/lib/Gollem.php b/gollem/lib/Gollem.php index 14272fe17..ebe4acd3f 100644 --- a/gollem/lib/Gollem.php +++ b/gollem/lib/Gollem.php @@ -24,62 +24,6 @@ class Gollem const SORT_DESCEND = 1; /** - * Check Gollem authentication and change to the currently active - * directory. Redirects to login page on authentication/session failure. - * - * @param string $mode The authentication mode we are using. - * @param boolean $redirect Redirect to the logout page if authentication - * is unsuccessful? - * - * @return boolean True on success, false on failure. - */ - static public function checkAuthentication($mode = null, $redirect = true) - { - $auth_gollem = new Gollem_Auth(); - $reason = $auth_gollem->authenticate(); - - if ($reason !== true) { - if ($redirect) { - if ($mode = 'selectlist') { - $url = Horde_Util::addParameter($GLOBALS['registry']->get('webroot', 'gollem') . '/login.php', 'selectlist_login', 1, false); - } else { - $url = Horde_Auth::addLogoutParameters(self::logoutUrl()); - } - $url = Horde_Util::addParameter($url, 'url', Horde::selfUrl(true, true, true), false); - header('Location: ' . $url); - exit; - } else { - return false; - } - } - - return true; - } - - /** - * Can we log in without a login screen for the requested backend key? - * - * @param string $key The backend key to check. Defaults to - * self::getPreferredBackend(). - * @param boolean $force If true, check the backend key even if there is - * more than one backend. - * - * @return boolean True if autologin possible, false if not. - */ - static public function canAutoLogin($key = null, $force = false) - { - $auto_server = self::getPreferredBackend(); - if ($key === null) { - $key = $auto_server; - } - - return (((count($auto_server) == 1) || $force) && - Horde_Auth::getAuth() && - empty($GLOBALS['gollem_backends'][$key]['loginparams']) && - !empty($GLOBALS['gollem_backends'][$key]['hordeauth'])); - } - - /** * Changes the current directory of the Gollem session to the supplied * value. * diff --git a/gollem/lib/Session.php b/gollem/lib/Session.php deleted file mode 100644 index aff7a04c1..000000000 --- a/gollem/lib/Session.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @author Max Kalika - * @author Michael Slusarz - * @package Gollem - */ -class Gollem_Session { - - /** - * Take information posted from a login attempt and try setting up - * an initial Gollem session. Handle Horde authentication, if - * required, and only do enough work to see if the user can log - * in. This function should only be called once, when the user first logs - * into Gollem. - * - * Creates the $gollem session variable with the following entries: - * 'backend_key' -- The current backend - * 'be_list' -- The cached list of available backends - * 'selectlist' -- Stores file selections from the API call - * - * Each backend is stored by its name in the 'backends' array. Each - * backend contains the following entries: - * 'attributes' -- See config/backends.php - * 'autologin' -- Whether this backend supports autologin - * 'clipboard' -- The clipboard for the current backend - * 'createhome' -- See config/backends.php - * 'dir' -- The current directory - * 'driver' -- See config/backends.php - * 'filter' -- See config/backends.php - * 'home' -- The user's home directory - * 'hordeauth' -- See config/backends.php - * 'hostspec' -- See config/backends.php - * 'label' -- The label to use - * 'name' -- See config/backends.php - * 'params' -- See config/backends.php - * 'preferred' -- See config/backends.php - * 'root' -- The root directory - * - * @param string $key The backend key to initialize. - * @param string $user The username to use for authentication. - * @param string $pass The password to use for authentication. - * @param array $args Any additional parameters the backend needs. - * - * @return boolean True on success, false on failure. - */ - function createSession($key, $user = null, $pass = null, $args = array()) - { - global $conf; - - /* Make sure we have a key and that it is valid. */ - if (empty($key) || (substr($key, 0, 1) == '_')) { - return false; - } - - /* We might need to override some of the defaults with - * environment-wide settings. Do NOT use the global $backends - * variable as it may not exist. */ - require GOLLEM_BASE . '/config/backends.php'; - if (empty($backends[$key])) { - $entry = sprintf('Invalid server key from client [%s]', $_SERVER['REMOTE_ADDR']); - Horde::logMessage($entry, __FILE__, __LINE__, PEAR_LOG_INFO); - return false; - } - - /* Create gollem session object if it doesn't already exist. */ - if (!isset($_SESSION['gollem'])) { - $_SESSION['gollem'] = array(); - $_SESSION['gollem']['backends'] = array(); - $_SESSION['gollem']['selectlist'] = array(); - } - $_SESSION['gollem']['backends'][$key] = $backends[$key]; - $GLOBALS['gollem_be'] = &$_SESSION['gollem']['backends'][$key]; - $ptr = &$_SESSION['gollem']['backends'][$key]; - $ptr['params'] = array_merge($ptr['params'], $args); - - /* Set the current backend as active. */ - $_SESSION['gollem']['backend_key'] = $key; - - /* Set username now. Don't set the current username if the backend - * already has a username defined. */ - if (empty($ptr['params']['username'])) { - $ptr['params']['username'] = ($user === null) ? Horde_Auth::getBareAuth() : $user; - } - - /* Set password now. The password should always be encrypted within - * the session. */ - if (!empty($ptr['params']['password'])) { - $pass = $ptr['params']['password']; - } - if ($pass === null) { - $ptr['params']['password'] = null; - } else { - $ptr['params']['password'] = Horde_Secret::write(Horde_Secret::getKey('gollem'), $pass); - } - - /* Try to authenticate with the given information. */ - $auth_gollem = new Gollem_Auth(); - if ($auth_gollem->authenticate(null, null, true) !== true) { - unset($_SESSION['gollem']['backends'][$key]); - $_SESSION['gollem']['backend_key'] = null; - return false; - } - - // Make sure we have a 'root' parameter. - if (empty($ptr['root'])) { - $ptr['root'] = '/'; - } - $ptr['root'] = Horde_Util::realPath($ptr['root']); - - // Make sure we have a 'home' parameter. - if (empty($ptr['home'])) { - $ptr['home'] = (!empty($ptr['params']['home'])) ? $ptr['params']['home'] : $GLOBALS['gollem_vfs']->getCurrentDirectory(); - if (empty($ptr['home'])) { - $ptr['home'] = $ptr['root']; - } - } - - // Make sure the home parameter lives under root if it is a relative - // directory. - if (strpos($ptr['home'], '/') !== 0) { - $ptr['home'] = $ptr['root'] . '/' . $ptr['home']; - } - $ptr['home'] = Horde_Util::realPath($ptr['home']); - $ptr['dir'] = $ptr['home']; - - // Verify that home is below root. - if (!Gollem::verifyDir($ptr['home'])) { - $error_msg = 'Backend Configuration Error: Home directory not below root.'; - $auth_gollem->gollemSetAuthErrorMsg($error_msg); - Horde::logMessage(PEAR::raiseError($error_msg), __FILE__, __LINE__, PEAR_LOG_ERR); - unset($_SESSION['gollem']['backends'][$key]); - $_SESSION['gollem']['backend_key'] = null; - return false; - } - - /* Create the home directory if it doesn't already exist. */ - if (($ptr['home'] != '/') && !empty($ptr['createhome'])) { - $pos = strrpos($ptr['home'], '/'); - $cr_dir = substr($ptr['home'], 0, $pos); - $cr_file = substr($ptr['home'], $pos + 1); - if (!$GLOBALS['gollem_vfs']->exists($cr_dir, $cr_file)) { - $res = Gollem::createFolder($cr_dir, $cr_file); - if (is_a($res, 'PEAR_Error')) { - $error_msg = 'Backend Configuration Error: Could not create home directory ' . $ptr['home'] . '.'; - $auth_gollem->gollemSetAuthErrorMsg($error_msg); - Horde::logMessage(PEAR::raiseError($error_msg), __FILE__, __LINE__, PEAR_LOG_ERR); - unset($_SESSION['gollem']['backends'][$key]); - $_SESSION['gollem']['backend_key'] = null; - return false; - } - } - } - - /* Does this driver support autologin? */ - $ptr['autologin'] = Gollem::canAutoLogin(true); - - /* Cache the backend_list in the session. */ - if (empty($_SESSION['gollem']['be_list'])) { - Gollem::loadBackendList(); - $_SESSION['gollem']['be_list'] = $GLOBALS['gollem_backends']; - } - - /* Initialize clipboard. */ - if (!isset($_SESSION['gollem']['clipboard'])) { - $_SESSION['gollem']['clipboard'] = array(); - } - - /* Call Gollem::changeDir() to make sure the label is set. */ - Gollem::changeDir(); - - return true; - } - - /** - * Change the currently active backend. - * - * @param string $key The ID of the backend to set as active. - */ - function changeBackend($key) - { - $_SESSION['gollem']['backend_key'] = $key; - $GLOBALS['gollem_be'] = &$_SESSION['gollem']['backends'][$key]; - } - -} diff --git a/gollem/lib/base.load.php b/gollem/lib/base.load.php deleted file mode 100644 index d6fcbe5c8..000000000 --- a/gollem/lib/base.load.php +++ /dev/null @@ -1,25 +0,0 @@ -pushApp('gollem', array('check_perms' => (Horde_Util::nonInputVar('gollem_authentication') != 'none'), 'logintasks' => true)); -} catch (Horde_Exception $e) { - Horde_Auth::authenticateFailure('gollem', $e); -} -$conf = &$GLOBALS['conf']; -define('GOLLEM_TEMPLATES', $registry->get('templates')); - -// Notification system. -$notification = Horde_Notification::singleton(); -$notification->attach('status'); - -// Start compression. -Horde::compressOutput(); - -// Set the global $gollem_be variable to the current backend's parameters. -if (empty($_SESSION['gollem']['backend_key'])) { - $GLOBALS['gollem_be'] = null; -} else { - $GLOBALS['gollem_be'] = &$_SESSION['gollem']['backends'][$_SESSION['gollem']['backend_key']]; -} - -// Load the backend list. -Gollem::loadBackendList(); diff --git a/gollem/manager.php b/gollem/manager.php index de8986d3a..8b0de7285 100644 --- a/gollem/manager.php +++ b/gollem/manager.php @@ -13,7 +13,8 @@ * @package Gollem */ -require_once dirname(__FILE__) . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +new Gollem_Application(array('init' => true)); $actionID = Horde_Util::getFormData('actionID'); $backkey = $_SESSION['gollem']['backend_key']; diff --git a/gollem/permissions.php b/gollem/permissions.php index 8166455af..3a9cd1207 100644 --- a/gollem/permissions.php +++ b/gollem/permissions.php @@ -8,7 +8,8 @@ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. */ -require_once dirname(__FILE__) . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +new Gollem_Application(array('init' => true)); if (!Horde_Auth::isAdmin()) { Horde::authenticationFailureRedirect('gollem'); diff --git a/gollem/quota.php b/gollem/quota.php index 00b1afa2c..12e6732d4 100644 --- a/gollem/quota.php +++ b/gollem/quota.php @@ -10,7 +10,8 @@ * @author Michael Slusarz */ -require_once dirname(__FILE__) . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +new Gollem_Application(array('init' => true)); /* Is this a popup window? */ $isPopup = $browser->hasFeature('javascript'); diff --git a/gollem/selectlist.php b/gollem/selectlist.php index a0430c9cc..21915b7ca 100644 --- a/gollem/selectlist.php +++ b/gollem/selectlist.php @@ -8,8 +8,8 @@ * @author Michael Slusarz */ -$gollem_authentication = 'selectlist'; -require_once dirname(__FILE__) . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +new IMP_Application(array('init' => array('authentication' => 'selectlist')); /* Set directory. */ if (is_a($result = Gollem::changeDir(), 'PEAR_Error')) { diff --git a/gollem/test.php b/gollem/test.php index 40a6202f4..371496b88 100644 --- a/gollem/test.php +++ b/gollem/test.php @@ -11,8 +11,7 @@ */ /* Include Horde's core.php file. */ -require_once dirname(__FILE__) . '/lib/base.load.php'; -require_once '../lib/core.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; /* We should have loaded the String class, from the Horde_Util package, in core.php. If Horde_String:: isn't defined, then we're not @@ -33,7 +32,6 @@ $horde_test = new Horde_Test(); /* Gollem version. */ $module = 'Gollem'; -require_once dirname(__FILE__) . '/lib/Application.php'; $app = new Gollem_Application(); $module_version = $app->version; diff --git a/gollem/view.php b/gollem/view.php index 86aa6c6c9..a3e0bc429 100644 --- a/gollem/view.php +++ b/gollem/view.php @@ -11,8 +11,8 @@ * @author Chuck Hagenbuch */ -$gollem_session_control = 'readonly'; -require_once dirname(__FILE__) . '/lib/base.php'; +require_once dirname(__FILE__) . '/lib/Application.php'; +new IMP_Application(array('init' => array('session_control' => 'readonly')); $actionID = Horde_Util::getFormData('actionID'); $driver = Horde_Util::getFormData('driver'); -- 2.11.0