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

Removed config attribute from all plugins, using global var instead

Conflicts:
	dhcp/admin/dhcp/class_dhcpConfiguration.inc
	dhcp/admin/systems/services/dhcp/class_serviceDHCP.inc
	fusioninventory/admin/systems/fusioninventory/class_fiInventory.inc
	kolab2/admin/systems/services/kolab2/class_serviceKolab.inc
	ppolicy/personal/ppolicy/class_ppolicyAccount.inc
	systems/admin/systems/class_printGeneric.inc
	systems/admin/systems/class_systemManagement.inc
	systems/admin/systems/class_terminalGeneric.inc
	systems/admin/systems/class_terminalStartup.inc
parent b21608c8
......@@ -24,15 +24,16 @@ class serviceApache extends simpleService
{
var $objectclasses = array("whatever");
function __construct ($config, $dn = NULL, $parent = NULL)
function __construct ($unused, $dn = NULL, $parent = NULL)
{
parent::__construct ($config, $dn, $parent, array());
global $config;
parent::__construct ($unused, $dn, $parent, array());
if (($dn != 'new') && ($dn != NULL)) {
$dn_without_base = preg_replace("/,".preg_quote($this->config->current['BASE'], '/')."$/", "", $this->dn);
$dn_without_base = preg_replace("/,".preg_quote($config->current['BASE'], '/')."$/", "", $this->dn);
$this->vhostList = new serviceApacheVhostManagement($this->config, get_userinfo(), $dn_without_base);
$this->vhostList = new serviceApacheVhostManagement(NULL, get_userinfo(), $dn_without_base);
/* If there is at least one entry in this -> types, we have apache vhosts enabled */
......
......@@ -32,13 +32,13 @@ class serviceApacheVhostManagement extends management
protected $aclPlugin = "serviceApacheVhostEdit";
protected $objectName = "serviceApacheVhostEdit";
function __construct ($config, $ui, $storagePoint = NULL)
function __construct ($unused, $ui, $storagePoint = NULL)
{
$this->config = $config;
global $config;
$this->ui = $ui;
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$storagePoint,"Storage point");
session::set('serviceApacheVhostEditDN',$storagePoint.','.$this->config->current['BASE']);
session::set('serviceApacheVhostEditDN',$storagePoint.','.$config->current['BASE']);
if (!empty($storagePoint)) {
$this->storagePoints = array($storagePoint);
} else {
......@@ -54,7 +54,7 @@ class serviceApacheVhostManagement extends management
$headpage = new listing(get_template_path("serviceApacheVhostEdit-list.xml", TRUE, dirname(__FILE__)));
$headpage->setFilter($filter);
parent::__construct($config, $ui, "serviceApacheVhostEdit", $headpage);
parent::__construct($unused, $ui, "serviceApacheVhostEdit", $headpage);
/* We don't want the normal footer, we have our own at the end of the tpl file,
* that allow us to differenciate plugin saving from service saving */
......
......@@ -113,9 +113,9 @@ class application extends simplePlugin
);
}
function __construct (&$config, $dn = NULL, $object = NULL)
function __construct ($unused, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
parent::__construct($unused, $dn, $object);
$this->attributesAccess['cn']->setUnique(TRUE);
......
......@@ -82,9 +82,9 @@ class webApplication extends simplePlugin
);
}
function __construct (&$config, $dn = NULL, $object = NULL)
function __construct ($unused, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
parent::__construct($unused, $dn, $object);
}
}
?>
......@@ -55,9 +55,9 @@ class applicationRights extends simplePlugin
);
}
function __construct (&$config, $dn = NULL, $object = NULL)
function __construct ($unused, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
parent::__construct($unused, $dn, $object);
$apps = objects::ls('application');
$apps = array_merge($apps, objects::ls('webApplication'));
......
......@@ -51,12 +51,12 @@ class argonautQueue extends simpleManagement
);
}
function __construct(&$config, $ui)
function __construct($unused, $ui)
{
$this->filterXMLPath = get_template_path('deploy-filter.xml', TRUE, dirname(__FILE__));
$this->listXMLPath = get_template_path('deploy-list.xml', TRUE, dirname(__FILE__));
parent::__construct($config, $ui);
parent::__construct($unused, $ui);
$this->o_queue = new supportDaemon();
$this->acl_base = $config->current['BASE'];
......@@ -80,7 +80,7 @@ class argonautQueue extends simpleManagement
function importEvents()
{
$this->dialogObject = new argonautImportFile($this->config, $this);
$this->dialogObject = new argonautImportFile(NULL, $this);
}
/*! \brief Queue selected objects to be removed.
......@@ -206,7 +206,7 @@ class argonautQueue extends simpleManagement
$entry = $tmp['EVENT'];
$attrsWrapper = new stdClass();
$attrsWrapper->attrs = $entry;
$this->dialogObject = new faiLogView($this->config, '', $attrsWrapper, $this);
$this->dialogObject = new faiLogView(NULL, '', $attrsWrapper, $this);
}
}
......
......@@ -60,9 +60,10 @@ class ArgonautServiceNameAttribute extends CompositeAttribute
function loadServiceNames ()
{
global $config;
$this->attributes = array();
// Get services tabs list from config
$services = $this->plugin->config->data['TABS']['SERVERSERVICE'];
$services = $config->data['TABS']['SERVERSERVICE'];
// Add fake "folder" tab at the beginning
$services = array_merge(array(array('CLASS' => 'folder')), $services);
......@@ -177,9 +178,9 @@ class argonautClient extends simplePlugin
);
}
function __construct(&$config, $dn = NULL, $object = NULL)
function __construct($unused, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
parent::__construct($unused, $dn, $object);
$this->attributesAccess['argonautClientProtocol']->setManagedAttributes(
array(
'disable' => array (
......
......@@ -75,9 +75,10 @@ class argonautFuseConfig extends simpleService
);
}
function __construct(&$config, $dn, $object = NULL, $attributesInfo = NULL)
function __construct($unused, $dn, $object = NULL, $attributesInfo = NULL)
{
parent::__construct($config, $dn, $object, $attributesInfo);
global $config;
parent::__construct($unused, $dn, $object, $attributesInfo);
/* Load modules */
$this->plugin = array();
......
......@@ -65,8 +65,8 @@ class argonautFuseFAIConfig extends simplePlugin
);
}
function __construct(&$config, $dn, $object = NULL, $attributesInfo = NULL)
function __construct($unused, $dn, $object = NULL, $attributesInfo = NULL)
{
parent::__construct($config, $dn, $object, $attributesInfo);
parent::__construct($unused, $dn, $object, $attributesInfo);
}
}
......@@ -56,8 +56,8 @@ class argonautFuseLTSPConfig extends simplePlugin
);
}
function __construct(&$config, $dn, $object = NULL, $attributesInfo = NULL)
function __construct($unused, $dn, $object = NULL, $attributesInfo = NULL)
{
parent::__construct($config, $dn, $object, $attributesInfo);
parent::__construct($unused, $dn, $object, $attributesInfo);
}
}
......@@ -71,8 +71,8 @@ class argonautFuseOPSIConfig extends simplePlugin
);
}
function __construct(&$config, $dn, $object = NULL, $attributesInfo = NULL)
function __construct($unused, $dn, $object = NULL, $attributesInfo = NULL)
{
parent::__construct($config, $dn, $object, $attributesInfo);
parent::__construct($unused, $dn, $object, $attributesInfo);
}
}
......@@ -127,9 +127,9 @@ class argonautServer extends simpleService
);
}
function __construct(&$config, $dn = NULL, $object = NULL)
function __construct($unused, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
parent::__construct($unused, $dn, $object);
if ($this->argonautServerToken == '') {
$this->argonautServerToken = md5(mt_rand());
}
......
......@@ -36,7 +36,6 @@ class supportDaemon
private $host_error = "";
private $http_options = array();
private $ssl_options = array();
private $config;
private $s_error = "";
private $b_error = FALSE;
......@@ -51,11 +50,11 @@ class supportDaemon
*/
public function __construct()
{
$this->config = session::global_get('config');
global $config;
/* This should only be the case if we call this from setup.
__autoload()
*/
if (!is_object($this->config)) {
if (!is_object($config)) {
return;
}
$argonautHost = $this->get_argonaut_host();
......@@ -63,7 +62,7 @@ class supportDaemon
if ($argonautHost != "") {
// load from config, store statically
$this->s_host = $argonautHost;
$this->logdir = $this->config->get_cfg_value("faiLogsDir");
$this->logdir = $config->get_cfg_value("faiLogsDir");
if ($this->logdir == "") {
$this->logdir = FAI_LOG_DIR;
}
......@@ -75,8 +74,9 @@ class supportDaemon
*/
public function get_argonaut_host()
{
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
global $config;
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
$ldap->search(
"(objectClass=argonautServer)",
array(
......@@ -93,12 +93,12 @@ class supportDaemon
);
if ($ldap_infos['argonautProtocol'][0] == 'https') {
$this->ssl_options = array(
'cafile' => $this->config->get_cfg_value('SslCaCertPath'),
'cafile' => $config->get_cfg_value('SslCaCertPath'),
'peer_name' => $ldap_infos['argonautCertCN'][0],
'verify_peer' => TRUE,
'verify_peer_name' => TRUE,
);
$sshaMethod = new passwordMethodssha($this->config);
$sshaMethod = new passwordMethodssha();
$this->http_options['header'] = 'Authorization: Basic '.base64_encode('fd:'.$sshaMethod->generate_hash($ldap_infos['argonautServerToken'][0]));
};
}
......@@ -295,6 +295,7 @@ class supportDaemon
*/
private function format_entries($entries)
{
global $config;
timezone::get_default_timezone();
$entries_r = array();
foreach ($entries as &$entry) {
......@@ -302,8 +303,8 @@ class supportDaemon
$entry_r['MACADDRESS'] = $entry['target'];
// TODO : do an ldap search only if we haven't done it for the same mac before
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
$ldap->search('(macAddress='.$entry_r['MACADDRESS'].')', array('cn'));
if ($ldap_infos = $ldap->fetch()) {
$entry_r['PLAINNAME'] = $ldap_infos['cn'][0];
......
......@@ -67,9 +67,9 @@ class nisObject extends simplePlugin
);
}
function __construct(&$config, $dn = NULL, $object = NULL)
function __construct($unused, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
parent::__construct($unused, $dn, $object);
$this->attributesAccess['nisMapName']->setChoices($this->getMountPoints());
}
......@@ -81,7 +81,8 @@ class nisObject extends simplePlugin
function getMountPoints ()
{
$ldap = $this->config->get_ldap_link();
global $config;
$ldap = $config->get_ldap_link();
$ldap->cd(get_ou('autofsRDN').$this->base);
$ldap->search('(objectClass=nisMap)', array('nisMapName'));
$nisMaps = array();
......
......@@ -142,9 +142,9 @@ class userCertificates extends simplePlugin
);
}
function __construct (&$config, $dn = NULL, $object = NULL)
function __construct ($unused, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
parent::__construct($unused, $dn, $object);
}
}
?>
......@@ -95,9 +95,9 @@ class communityOrganization extends simplePlugin
);
}
function __construct(&$config, $dn = NULL, $object = NULL)
function __construct($unused, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
parent::__construct($unused, $dn, $object);
}
}
?>
......@@ -56,9 +56,9 @@ class communityProject extends communityOrganization
);
}
function __construct(&$config, $dn = NULL, $object = NULL)
function __construct($unused, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
parent::__construct($unused, $dn, $object);
}
}
?>
......@@ -39,9 +39,9 @@ class serviceCyrus extends simpleService
* \brief Constructor of the freeradiusAccount
* It will build the select groups choices
*/
function __construct(&$config, $dn = NULL, $object = NULL)
function __construct($unused, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
parent::__construct($unused, $dn, $object);
}
/*!
......
......@@ -50,6 +50,7 @@ class mailMethodCyrus extends mailMethod
public function connect()
{
global $config;
mailMethod::connect();
if (!count($this->ServerList)) {
......@@ -80,7 +81,7 @@ class mailMethodCyrus extends mailMethod
/* Setting connect timeout to 10 seconds,
else the FusionDirectory UI may freeze for 60 seconds.
(PHP default is 'default_socket_timeout = 60') */
$timeout = $this->config->get_cfg_value("imapTimeout", 10);
$timeout = $config->get_cfg_value("imapTimeout", 10);
@DEBUG (DEBUG_MAIL, __LINE__, __FUNCTION__, __FILE__, $timeout,
"<b>IMAP: Setting imap connect timeout to</b> (seconds)");
imap_timeout(1, $timeout);
......@@ -260,6 +261,7 @@ class mailMethodCyrus extends mailMethod
public function updateMailbox()
{
global $config;
mailMethod::updateMailbox();
if (!$this->is_connected() || !$this->imap_handle) {
......@@ -280,7 +282,7 @@ class mailMethodCyrus extends mailMethod
}
/* Autocreate configured default folders */
$folders = $this->config->get_cfg_value("cyrusAutocreateFolders", NULL);
$folders = $config->get_cfg_value("cyrusAutocreateFolders", NULL);
if ($folders !== NULL) {
$cyrus_delim = ($this->cyrusUseSlashes?"/":".");
......@@ -303,6 +305,7 @@ class mailMethodCyrus extends mailMethod
public function deleteMailbox()
{
global $config;
mailMethod::deleteMailbox();
if (!$this->is_connected() || !$this->imap_handle) {
......@@ -315,7 +318,7 @@ class mailMethodCyrus extends mailMethod
$cfg = $this->ServerList[$this->parent->gosaMailServer];
@imap_setacl ($this->imap_handle, $this->account_id, $cfg["admin"], "lrswipcda");
if ($this->config->get_cfg_value("cyrusDeleteMailbox", "TRUE") == "TRUE") {
if ($config->get_cfg_value("cyrusDeleteMailbox", "TRUE") == "TRUE") {
if (!imap_deletemailbox($this->imap_handle, $cfg["connect"].$this->account_id)) {
$this->error = imap_last_error();
return FALSE;
......@@ -624,8 +627,9 @@ class mailMethodCyrus extends mailMethod
$sieve->sieve_logout();
}
static public function get_server_list($config)
static public function get_server_list()
{
global $config;
$serverList = array();
$ldap = $config->get_ldap_link();
......
......@@ -36,10 +36,11 @@ class DebconfEntriesAttribute extends CompositeAttribute
function loadEntries ()
{
global $config;
$this->attributes = array();
/* Load template */
$ldap = $this->plugin->config->get_ldap_link();
$ldap = $config->get_ldap_link();
$ou = $this->plugin->attributesAccess['ou']->getValue();
$ldap->cd("ou=templates,".$this->plugin->dn);
$ldap->search("(objectClass=debConfDbEntry)");
......@@ -76,7 +77,8 @@ class DebconfEntriesAttribute extends CompositeAttribute
function saveInLdap()
{
$ldap = $this->plugin->config->get_ldap_link();
global $config;
$ldap = $config->get_ldap_link();
foreach ($this->attributes as $cn => $attribute) {
$dn = "cn=$cn,ou=questions,".$this->plugin->dn;
$ldap->cat($dn, array("objectClass"));
......@@ -109,13 +111,14 @@ class DebconfImportAttribute extends FileAttribute
*/
function readFile($handle)
{
global $config;
$matches = array();
$str = fread($handle, 1024);
strpos($str, "dn:");
$tmp = str_replace ("\n", "", $str); // removing breaklines
$tmp = str_replace (" ", "", $tmp); // removing spaces
if (preg_match( "/dn:.*,ou=templates,ou=([^,=]+),".get_ou("debconfRDN").
$this->plugin->config->current['BASE']."/",
$config->current['BASE']."/",
$tmp, $matches) > 0) { // searching for dn: containing the template name
$this->plugin->attributesAccess['ou']->setPostValue($matches[1]);
$this->plugin->attributesAccess['ou']->setValue($matches[1]);
......@@ -126,7 +129,7 @@ class DebconfImportAttribute extends FileAttribute
}
@fclose($handle);
$ldap = $this->plugin->config->get_ldap_link();
$ldap = $config->get_ldap_link();
try {
$ldap->import_complete_ldif($str, FALSE, FALSE);
$this->plugin->initially_was_account = TRUE;
......@@ -136,17 +139,18 @@ class DebconfImportAttribute extends FileAttribute
} else {
msg_dialog::display(_("LDIF error"), "Could not found template name in the ldif ".
"was expecting ou=<b>name</b>,ou=templates,".
get_ou("debconfRDN").$this->plugin->config->current['BASE'],
get_ou("debconfRDN").$config->current['BASE'],
ERROR_DIALOG);
}
}
function renderFormInput()
{
global $config;
return sprintf(_("In order to import a debconf file, please run the following command : <br/>".
"<i>debconf2ldif.pl -b ou=<b>name</b>,%s -k <b>filename</b> > template.ldif </i><br/>".
"With <b>filename</b> the file name, and <b>name</b> the desired name for the template.<br/>"),
get_ou("debconfRDN").$this->plugin->config->current['BASE']).parent::renderFormInput();
get_ou("debconfRDN").$config->current['BASE']).parent::renderFormInput();
}
}
......@@ -193,9 +197,9 @@ class debconfProfileGeneric extends simplePlugin
);
}
public function __construct(&$config, $dn = NULL, $object = NULL)
public function __construct($unused, $dn = NULL, $object = NULL)
{
parent::__construct($config, $dn, $object);
parent::__construct($unused, $dn, $object);
$this->attributesAccess['ou']->setUnique(TRUE);
if (count($this->attributesAccess['debconfEntries']->attributes) == 0) {
......
Markdown is supported
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