Commit 9617d11e authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '5854-improve-stand-alone-page-support' into '1.4-dev'

Resolve "Improve stand-alone page support"

See merge request fusiondirectory/fd!400
Showing with 36 additions and 27 deletions
+36 -27
......@@ -21,6 +21,7 @@
/* base class for passwordRecovery and such classes handling requests on their own */
class standAlonePage {
protected $directories;
protected $directory;
protected $activated;
protected $interactive;
......@@ -38,45 +39,43 @@ class standAlonePage {
session::start();
$config = $this->loadConfig();
session::global_set('config', $config);
/* Generate server list */
$servers = array();
$this->directories = array();
foreach ($config->data['LOCATIONS'] as $key => $ignored) {
$servers[$key] = $key;
$this->directories[$key] = $key;
}
if (isset($_POST['server']) && isset($servers[$_POST['server']])) {
$ui = new userinfoNoAuth(get_class($this));
session::global_set('ui', $ui);
static::init();
}
function checkDirectoryChooser()
{
global $config;
$olddirectory = $this->directory;
if (isset($_POST['server']) && isset($this->directories[$_POST['server']])) {
$this->directory = validate($_POST['server']);
} elseif (isset($_GET['directory']) && isset($servers[$_GET['directory']])) {
} elseif (isset($_GET['directory']) && isset($this->directories[$_GET['directory']])) {
$this->directory = validate($_GET['directory']);
} else {
} elseif (empty($this->directory)) {
$this->directory = $config->data['MAIN']['DEFAULT'];
if (!isset($servers[$this->directory])) {
$this->directory = key($servers);
if (!isset($this->directories[$this->directory])) {
$this->directory = key($this->directories);
}
}
/* Set config to selected one */
$config->set_current($this->directory);
session::global_set('config', $config);
if ($this->directory != $olddirectory) {
/* Set config to selected one */
$config->set_current($this->directory);
$this->activated = $this->readLdapConfig();
$ui = new userinfoNoAuth(get_class($this));
session::global_set('ui', $ui);
static::init();
if ($this->interactive) {
$smarty = get_smarty();
if (count($servers) > 1) {
$smarty->assign('show_directory_chooser', TRUE);
$smarty->assign('server_options', $servers);
$smarty->assign('server_id', $this->directory);
} else {
$smarty->assign('show_directory_chooser', FALSE);
}
$this->activated = $this->readLdapConfig();
}
}
......@@ -84,6 +83,8 @@ class standAlonePage {
{
global $config, $ssl, $ui;
static::checkDirectoryChooser();
reset_errors();
static::securityHeaders();
......@@ -159,6 +160,14 @@ class standAlonePage {
$smarty->assign('must', '<span class="must">*</span>');
$smarty->assign('usePrototype', 'FALSE');
$smarty->assign('CSRFtoken', CSRFProtection::getToken());
if (count($this->directories) > 1) {
$smarty->assign('show_directory_chooser', TRUE);
$smarty->assign('server_options', $this->directories);
$smarty->assign('server_id', $this->directory);
} else {
$smarty->assign('show_directory_chooser', FALSE);
}
}
function assignSmartyVars()
......@@ -222,7 +231,7 @@ class standAlonePage {
$pageURL = $protocol.'://';
$pageURL .= $host;
if ($port != '80') {
if ((($protocol == 'http') && ($port != '80')) || (($protocol == 'https') && ($port != '443'))) {
$pageURL .= ':'.$port;
}
if (empty($_SERVER['PATH_INFO'])) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment