#166 Configuration by module (and module categories)

SVN:trunk[629]
This commit is contained in:
Romain Quetiez
2010-07-26 16:29:52 +00:00
parent c9a573e39f
commit 05c9b10546
18 changed files with 316 additions and 23 deletions

View File

@@ -60,6 +60,8 @@ class Config
protected $m_aAddons;
protected $m_aDictionaries;
protected $m_aModuleSettings;
protected $m_sDBHost;
protected $m_sDBUser;
protected $m_sDBPwd;
@@ -119,7 +121,6 @@ class Config
'../core/event.class.inc.php',
'../core/action.class.inc.php',
'../core/trigger.class.inc.php',
'../addons/authentication/authent.local.inc.php',
);
$this->m_aDataModels = array();
$this->m_aAddons = array(
@@ -148,6 +149,9 @@ class Config
$this->m_iFastReloadInterval = DEFAULT_FAST_RELOAD_INTERVAL;
$this->m_bSecureConnectionRequired = DEFAULT_SECURE_CONNECTION_REQUIRED;
$this->m_sDefaultLanguage = 'EN US';
$this->m_aModuleSettings = array();
if ($bLoadConfig)
{
$this->Load($sConfigFile);
@@ -240,6 +244,8 @@ class Config
$this->m_iFastReloadInterval = isset($MySettings['fast_reload_interval']) ? trim($MySettings['fast_reload_interval']) : DEFAULT_FAST_RELOAD_INTERVAL;
$this->m_bSecureConnectionRequired = isset($MySettings['secure_connection_required']) ? trim($MySettings['secure_connection_required']) : DEFAULT_SECURE_CONNECTION_REQUIRED;
$this->m_aModuleSettings = isset($MyModuleSettings) ? $MyModuleSettings : array();
$this->m_sDefaultLanguage = isset($MySettings['default_language']) ? trim($MySettings['default_language']) : 'EN US';
}
@@ -263,6 +269,20 @@ class Config
}
}
public function GetModuleSetting($sModule, $sProperty, $defaultvalue = null)
{
if (isset($this->m_aModuleSettings[$sModule][$sProperty]))
{
return $this->m_aModuleSettings[$sModule][$sProperty];
}
return $defaultvalue;
}
public function SetModuleSetting($sModule, $sProperty, $value)
{
$this->m_aModuleSettings[$sModule][$sProperty] = $value;
}
public function GetAppModules()
{
return $this->m_aAppModules;
@@ -497,6 +517,20 @@ class Config
fwrite($hFile, "\t'secure_connection_required' => ".($this->m_bSecureConnectionRequired ? 'true' : 'false').",\n");
fwrite($hFile, "\t'default_language' => '{$this->m_sDefaultLanguage}',\n");
fwrite($hFile, ");\n");
fwrite($hFile, "\n");
fwrite($hFile, "\$MyModuleSettings = array(\n");
foreach ($this->m_aModuleSettings as $sModule => $aProperties)
{
fwrite($hFile, "\t'$sModule' => array (\n");
foreach ($aProperties as $sProperty => $value)
{
$sExport = var_export($value, true);
fwrite($hFile, "\t\t'$sProperty' => $sExport,\n");
}
fwrite($hFile, "\t),\n");
}
fwrite($hFile, ");\n");
fwrite($hFile, "\n/**\n");
fwrite($hFile, " *\n");

View File

@@ -188,6 +188,8 @@ abstract class MetaModel
}
}
private static $m_oConfig = null;
private static $m_bTraceQueries = true;
private static $m_aQueriesLog = array();
@@ -3110,18 +3112,18 @@ abstract class MetaModel
public static function LoadConfig($sConfigFile)
{
$oConfig = new Config($sConfigFile);
self::$m_oConfig = new Config($sConfigFile);
// Set log ASAP
if ($oConfig->GetLogGlobal())
if (self::$m_oConfig->GetLogGlobal())
{
if ($oConfig->GetLogIssue())
if (self::$m_oConfig->GetLogIssue())
{
self::$m_bLogIssue = true;
IssueLog::Enable('../error.log');
}
self::$m_bLogNotification = $oConfig->GetLogNotification();
self::$m_bLogWebService = $oConfig->GetLogWebService();
self::$m_bLogNotification = self::$m_oConfig->GetLogNotification();
self::$m_bLogWebService = self::$m_oConfig->GetLogWebService();
}
else
{
@@ -3132,35 +3134,35 @@ abstract class MetaModel
// Note: load the dictionary as soon as possible, because it might be
// needed when some error occur
foreach ($oConfig->GetDictionaries() as $sModule => $sToInclude)
foreach (self::$m_oConfig->GetDictionaries() as $sModule => $sToInclude)
{
self::Plugin($sConfigFile, 'dictionaries', $sToInclude);
}
// Set the language... after the dictionaries have been loaded!
Dict::SetDefaultLanguage($oConfig->GetDefaultLanguage());
Dict::SetDefaultLanguage(self::$m_oConfig->GetDefaultLanguage());
// Romain: this is the only way I've found to cope with the fact that
// classes have to be derived from cmdbabstract (to be editable in the UI)
require_once('../application/cmdbabstract.class.inc.php');
foreach ($oConfig->GetAppModules() as $sModule => $sToInclude)
foreach (self::$m_oConfig->GetAppModules() as $sModule => $sToInclude)
{
self::Plugin($sConfigFile, 'application', $sToInclude);
}
foreach ($oConfig->GetDataModels() as $sModule => $sToInclude)
foreach (self::$m_oConfig->GetDataModels() as $sModule => $sToInclude)
{
self::Plugin($sConfigFile, 'business', $sToInclude);
}
foreach ($oConfig->GetAddons() as $sModule => $sToInclude)
foreach (self::$m_oConfig->GetAddons() as $sModule => $sToInclude)
{
self::Plugin($sConfigFile, 'addons', $sToInclude);
}
$sServer = $oConfig->GetDBHost();
$sUser = $oConfig->GetDBUser();
$sPwd = $oConfig->GetDBPwd();
$sSource = $oConfig->GetDBName();
$sTablePrefix = $oConfig->GetDBSubname();
$sServer = self::$m_oConfig->GetDBHost();
$sUser = self::$m_oConfig->GetDBUser();
$sPwd = self::$m_oConfig->GetDBPwd();
$sSource = self::$m_oConfig->GetDBName();
$sTablePrefix = self::$m_oConfig->GetDBSubname();
// The include have been included, let's browse the existing classes and
// develop some data based on the proposed model
@@ -3172,6 +3174,11 @@ abstract class MetaModel
CMDBSource::Init($sServer, $sUser, $sPwd); // do not select the DB (could not exist)
}
public static function GetModuleSetting($sModule, $sProperty, $defaultvalue = null)
{
return self::$m_oConfig->GetModuleSetting($sModule, $sProperty, $defaultvalue);
}
protected static $m_aPlugins = array();
public static function RegisterPlugin($sType, $sName, $aInitCallSpec = array())
{

View File

@@ -0,0 +1,37 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Localized data
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
// Dictionnay conventions
// Class:<class_name>
// Class:<class_name>+
// Class:<class_name>/Attribute:<attribute_code>
// Class:<class_name>/Attribute:<attribute_code>+
// Class:<class_name>/Attribute:<attribute_code>/Value:<value>
// Class:<class_name>/Attribute:<attribute_code>/Value:<value>+
// Class:<class_name>/Stimulus:<stimulus_code>
// Class:<class_name>/Stimulus:<stimulus_code>+
?>

View File

@@ -15,7 +15,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Authent Null Password
* Authent LDAP
* User authentication Module, no password at all!
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
@@ -25,7 +25,7 @@
*/
class UserNullPassword extends User
class UserLDAP extends User
{
public static function Init()
{
@@ -36,7 +36,6 @@ class UserNullPassword extends User
"name_attcode" => "login",
"state_attcode" => "",
"reconc_keys" => array(),
//"db_table" => "aaaaaaanullpassword",
"db_table" => "",
"db_key_field" => "id",
"db_finalclass_field" => "",
@@ -55,12 +54,29 @@ class UserNullPassword extends User
public function CheckCredentials($sPassword)
{
return true;
$aLDAPConfig['host'] = MetaModel::GetModuleSetting('authent-ldap', 'host', 'localhost');
$aLDAPConfig['port'] = MetaModel::GetModuleSetting('authent-ldap', 'port', 389);
$aLDAPConfig['basedn'] = MetaModel::GetModuleSetting('authent-ldap', 'basedn', 'dc=net');
$ds = @ldap_connect($aLDAPConfig['host'], $aLDAPConfig['port']);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
$sDN = "uid=".$this->Get('login').",ou=people,".$aLDAPConfig['basedn'];
if ($bind = @ldap_bind($ds, $sDN, $sPassword))
{
return true;
}
else
{
return false;
}
}
public function TrustWebServerContext()
{
return true;
return false;
}
public function CanChangePassword()
@@ -70,7 +86,7 @@ class UserNullPassword extends User
public function ChangePassword($sOldPassword, $sNewPassword)
{
return true;
return false;
}
}

View File

@@ -0,0 +1,50 @@
<?php
SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'authent-ldap',
array(
// Identification
//
'label' => 'User authentication based on LDAP',
'category' => 'authentication',
// Setup
//
'dependencies' => array(
),
'mandatory' => false,
'visible' => true,
// Components
//
'datamodel' => array(
'model.authent-ldap.php',
),
'dictionary' => array(
'en.dict.authent-ldap.php',
),
'data.struct' => array(
//'data.struct.authent-ldap.xml',
),
'data.sample' => array(
//'data.sample.authent-ldap.xml',
),
// Documentation
//
'doc.manual_setup' => '',
'doc.more_information' => '',
// Default settings
//
'settings' => array(
'host' => '192.168.10.164',
'port' => 389,
'basedn' => 'dc=leconcorde,dc=net',
),
)
);
?>

View File

@@ -0,0 +1,37 @@
<?php
// Copyright (C) 2010 Combodo SARL
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/**
* Localized data
*
* @author Erwan Taloc <erwan.taloc@combodo.com>
* @author Romain Quetiez <romain.quetiez@combodo.com>
* @author Denis Flaven <denis.flaven@combodo.com>
* @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
*/
// Dictionnay conventions
// Class:<class_name>
// Class:<class_name>+
// Class:<class_name>/Attribute:<attribute_code>
// Class:<class_name>/Attribute:<attribute_code>+
// Class:<class_name>/Attribute:<attribute_code>/Value:<value>
// Class:<class_name>/Attribute:<attribute_code>/Value:<value>+
// Class:<class_name>/Stimulus:<stimulus_code>
// Class:<class_name>/Stimulus:<stimulus_code>+
?>

View File

@@ -0,0 +1,47 @@
<?php
SetupWebPage::AddModule(
__FILE__, // Path to the current file, all other file names are relative to the directory containing this file
'authent-local',
array(
// Identification
//
'label' => 'User authentication based on the local DB',
'category' => 'authentication',
// Setup
//
'dependencies' => array(
),
'mandatory' => true,
'visible' => true,
// Components
//
'datamodel' => array(
'model.authent-local.php',
),
'dictionary' => array(
'en.dict.authent-local.php',
),
'data.struct' => array(
//'data.struct.authent-local.xml',
),
'data.sample' => array(
//'data.sample.authent-local.xml',
),
// Documentation
//
'doc.manual_setup' => '',
'doc.more_information' => '',
// Default settings
//
'settings' => array(
),
)
);
?>

View File

@@ -8,6 +8,7 @@ SetupWebPage::AddModule(
// Identification
//
'label' => 'iTop Basic Model',
'category' => 'business',
// Setup
//
@@ -35,6 +36,11 @@ SetupWebPage::AddModule(
//
'doc.manual_setup' => '/doc/xxx/yyy.htm',
'doc.more_information' => '/doc/xxx/yyy.htm',
// Default settings
//
'settings' => array(
),
)
);

View File

@@ -8,6 +8,7 @@ SetupWebPage::AddModule(
// Identification
//
'label' => 'Change Management',
'category' => 'business',
// Setup
//
@@ -38,6 +39,11 @@ SetupWebPage::AddModule(
//
'doc.manual_setup' => '',
'doc.more_information' => '/doc/itop-documentation.htm#ChangeMgmt',
// Default settings
//
'settings' => array(
),
)
);

View File

@@ -8,6 +8,7 @@ SetupWebPage::AddModule(
// Identification
//
'label' => 'Configuration Management (CMDB)',
'category' => 'business',
// Setup
//
@@ -49,6 +50,11 @@ SetupWebPage::AddModule(
//
'doc.manual_setup' => '', // No manual installation required
'doc.more_information' => '/doc/itop-documentation.htm#ConfigMgmt',
// Default settings
//
'settings' => array(
),
)
);

View File

@@ -8,6 +8,7 @@ SetupWebPage::AddModule(
// Identification
//
'label' => 'Incident Management',
'category' => 'business',
// Setup
//
@@ -39,6 +40,11 @@ SetupWebPage::AddModule(
//
'doc.manual_setup' => '',
'doc.more_information' => '/doc/itop-documentation.htm#IncidentMgmt',
// Default settings
//
'settings' => array(
),
)
);

View File

@@ -8,6 +8,7 @@ SetupWebPage::AddModule(
// Identification
//
'label' => 'Known Errors Database',
'category' => 'business',
// Setup
//
@@ -38,6 +39,11 @@ SetupWebPage::AddModule(
//
'doc.manual_setup' => '', // No manual installation instructions
'doc.more_information' => '/doc/itop-documentation.htm#KnownErrorsDB',
// Default settings
//
'settings' => array(
),
)
);

View File

@@ -8,6 +8,7 @@ SetupWebPage::AddModule(
// Identification
//
'label' => 'Problem Management',
'category' => 'business',
// Setup
//
@@ -38,6 +39,11 @@ SetupWebPage::AddModule(
//
'doc.manual_setup' => '', // No manual installation instructions
'doc.more_information' => '/doc/itop-documentation.htm#ProblemMgmt',
// Default settings
//
'settings' => array(
),
)
);

View File

@@ -8,6 +8,7 @@ SetupWebPage::AddModule(
// Identification
//
'label' => 'User request management (Service Desk)',
'category' => 'business',
// Setup
//
@@ -38,6 +39,11 @@ SetupWebPage::AddModule(
//
'doc.manual_setup' => '',
'doc.more_information' => '/doc/itop-documentation.htm#RequestMgmt',
// Default settings
//
'settings' => array(
),
)
);

View File

@@ -8,6 +8,7 @@ SetupWebPage::AddModule(
// Identification
//
'label' => 'Service Management (services, SLAs, contracts)',
'category' => 'business',
// Setup
//
@@ -43,6 +44,11 @@ SetupWebPage::AddModule(
//
'doc.manual_setup' => '', // No manual installation instructions
'doc.more_information' => '/doc/itop-documentation.htm#ServiceMgmt',
// Default settings
//
'settings' => array(
),
)
);

View File

@@ -8,6 +8,7 @@ SetupWebPage::AddModule(
// Identification
//
'label' => 'Tickets - prerequisite for ticket modules',
'category' => 'business',
// Setup
//
@@ -35,6 +36,11 @@ SetupWebPage::AddModule(
//
'doc.manual_setup' => '',
'doc.more_information' => '',
// Default settings
//
'settings' => array(
),
)
);

View File

@@ -568,6 +568,10 @@ function BuildConfig(SetupWebpage $oP, Config &$oConfig, $aParamValues)
$oP->log('Installed iTop module: '. $sModuleId);
$aDataModels = array_unique(array_merge($aDataModels, $aAvailableModules[$sModuleId]['datamodel']));
$sDictionaries = array_unique(array_merge($sDictionaries, $aAvailableModules[$sModuleId]['dictionary']));
foreach($aAvailableModules[$sModuleId]['settings'] as $sProperty => $value)
{
$oConfig->SetModuleSetting($sModuleId, $sProperty, $value);
}
}
$oConfig->SetAddOns($aAddOns);
$oConfig->SetAppModules($aAppModules);
@@ -790,7 +794,13 @@ function ModulesSelection(SetupWebPage $oP, $aParamValues, $iCurrentStep, $oConf
$sClass = ($aModule['mandatory']) ? 'class="read-only"' : '';
$sChecked = ($aModule['mandatory'] || in_array($sModuleId, $aSelectedModules) ) ? 'checked' : '';
$sMoreInfo = (!empty($aModule['doc.more_information'])) ? "<a href=\"{$aModule['doc.more_information']}\" target=\"_blank\">more info</a>": '';
if ($aModule['visible'])
if ($aModule['category'] == 'authentication')
{
// For now authentication modules are always on and hidden
$oP->add("<input type=\"hidden\" id=\"module[$index]\" name=\"module[$index]\" value=\"$sModuleId\">\n");
$index++;
}
elseif ($aModule['visible'])
{
$oP->add("<p><input type=\"checkbox\" $sClass $sChecked id=\"module[$index]\" name=\"module[$index]\" value=\"$sModuleId\"><label $sClass for=\"module[$index]\"> {$aModule['label']}</label> $sMoreInfo</p>\n");
$index++;
@@ -799,6 +809,7 @@ function ModulesSelection(SetupWebPage $oP, $aParamValues, $iCurrentStep, $oConf
{
// For now hidden modules are always on !
$oP->add("<input type=\"hidden\" id=\"module[$index]\" name=\"module[$index]\" value=\"$sModuleId\">\n");
$index++;
}
}
$oP->add("</div>");