Allow $SERVER_NAME$ as a placeholder for the server's name in the application root url. Useful for multiple virtual hosts or test systems using DHCP...

SVN:trunk[1438]
This commit is contained in:
Denis Flaven
2011-08-09 07:57:11 +00:00
parent aa00cd9ae7
commit d2955557bf
2 changed files with 17 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ require_once(APPROOT.'/core/config.class.inc.php');
require_once(APPROOT.'/application/transaction.class.inc.php');
define('ITOP_CONFIG_FILE', APPROOT.'/config-itop.php');
define('SERVER_NAME_PLACEHOLDER', '$SERVER_NAME$');
class FileUploadException extends Exception
{
@@ -365,7 +366,21 @@ class utils
*/
static public function GetAbsoluteUrlAppRoot()
{
return MetaModel::GetConfig()->Get('app_root_url');
$sUrl = MetaModel::GetConfig()->Get('app_root_url');
if (strpos($sUrl, SERVER_NAME_PLACEHOLDER) > -1)
{
if (isset($_SERVER['SERVER_NAME']))
{
$sServerName = $_SERVER['SERVER_NAME'];
}
else
{
// CLI mode ?
$sServerName = php_uname('n');
}
$sUrl = str_replace(SERVER_NAME_PLACEHOLDER, $sServerName, $sUrl);
}
return $sUrl;
}
static public function GetDefaultUrlAppRoot()

View File

@@ -86,7 +86,7 @@ class Config
protected $m_aSettings = array(
'app_root_url' => array(
'type' => 'string',
'description' => 'Root URL used for navigating within the application, or from an email to the application',
'description' => 'Root URL used for navigating within the application, or from an email to the application (you can put $SERVER_NAME$ as a placeholder for the server\'s name)',
'default' => '',
'value' => '',
'source_of_value' => '',