From 0061cee0828e7dc3ab4ca73fc19d0d6b23d89b0a Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 10 Mar 2005 20:20:00 +0000 Subject: [PATCH] get_Suffix() -> get_Suffix() --- lam/lib/cache.inc | 7 +- lam/lib/config.inc | 94 -------------------------- lam/lib/modules.inc | 2 +- lam/lib/modules/posixGroup.inc | 2 +- lam/lib/modules/sambaGroupMapping.inc | 14 ++-- lam/lib/modules/sambaSamAccount.inc | 12 ++-- lam/templates/config/confmain.php | 16 ++--- lam/templates/config/confsave.php | 8 +-- lam/templates/domain.php | 8 +-- lam/templates/lists/listdomains.php | 4 +- lam/templates/lists/listgroups.php | 4 +- lam/templates/lists/listhosts.php | 4 +- lam/templates/lists/listusers.php | 6 +- lam/templates/lists/userlink.php | 2 +- lam/templates/main.php | 24 +++---- lam/templates/main_header.php | 12 ++-- lam/templates/massBuildAccounts.php | 2 +- lam/templates/masscreate.php | 6 +- lam/templates/ou_edit.php | 16 ++--- lam/templates/profedit/profilepage.php | 2 +- lam/templates/tools.php | 2 +- lam/tests/conf-test.php | 32 ++++----- 22 files changed, 92 insertions(+), 187 deletions(-) diff --git a/lam/lib/cache.inc b/lam/lib/cache.inc index d735ba00..84374484 100644 --- a/lam/lib/cache.inc +++ b/lam/lib/cache.inc @@ -199,7 +199,7 @@ class cache { foreach ($scopes as $scope) { // Get Scope If ($scope != '*') - $suffix = call_user_func(array($_SESSION['config'], 'get_'.ucfirst($scope).'Suffix')); + $suffix = $_SESSION['config']->get_Suffix($scope); else $suffix = ''; // Get Data from ldap $search = $this->attributes[$scope]; @@ -239,9 +239,8 @@ class cache { $allowed_types = array ( 'user', 'group', 'host', '*' ); for ($i=0; $iget_Suffix($allowed_types[$i]); else $suffix = ''; if (substr($suffix, $dn)) $singlescope = $allowed_types[$i]; } @@ -252,7 +251,7 @@ class cache { // Get Scope foreach ($allowed_types as $scope) { if ($scope!='*') { - $suffix = call_user_func(array($_SESSION['config'], 'get_'.ucfirst($scope).'Suffix')); + $suffix = $_SESSION['config']->get_Suffix($scope); if (strpos($dn, $suffix)) $singlescope = $scope; } } diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 587f886c..5b789060 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -443,100 +443,6 @@ class Config { return true; } - /** - * Returns the LDAP suffix where users are saved - * - * @return string the user suffix - */ - function get_UserSuffix() { - return $this->usersuffix; - } - - /** - * Sets the LDAP suffix where users are saved - * - * @param string $value new user suffix - * @return boolean true if $value has correct format - */ - function set_UserSuffix($value) { - if (is_string($value)) { - $this->usersuffix = $value; - } - else return false; - return true; - } - - /** - * returns the LDAP suffix where groups are saved - * - * @return string the group suffix - */ - function get_GroupSuffix() { - return $this->groupsuffix; - } - - /** - * Sets the LDAP suffix where groups are saved - * - * @param string $value new group suffix - * @return boolean true if $value has correct format - */ - function set_GroupSuffix($value) { - if (is_string($value)) { - $this->groupsuffix = $value; - } - else return false; - return true; - } - - /** - * returns the LDAP suffix where hosts are saved - * - * @return string the host suffix - */ - function get_HostSuffix() { - return $this->hostsuffix; - } - - /** - * Sets the LDAP suffix where hosts are saved - * - * @param string $value new host suffix - * @return boolean true if $value has correct format - */ - function set_HostSuffix($value) { - if (! $value) $this->hostsuffix = ""; - elseif (is_string($value)) { - $this->hostsuffix = $value; - } - else return false; - return true; - } - - /** - * Returns the LDAP suffix where domains are saved - * - * @return string the domain suffix - */ - function get_DomainSuffix() { - return $this->domainsuffix; - } - - /** - * Sets the LDAP suffix where domains are saved - * - * @param string $value new domain suffix - * @return boolean true if $value has correct format - */ - function set_DomainSuffix($value) { - if (!$value) $this->domainsuffix = ""; - elseif (is_string($value)) { - $this->domainsuffix = $value; - } - else return false; - return true; - } - /** * Returns the LDAP suffix for the given account type * diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index 3856596a..d93dcb6a 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -720,7 +720,7 @@ class accountContainer { if (count($table)!=0) $return[] = array ( 0 => array ( 'kind' => 'table', 'value' => $table ) ); // loop through all suffixes - $rootsuffix = call_user_func(array($_SESSION['config'], 'get_' . ucfirst($this->type) . 'Suffix')); + $rootsuffix = $_SESSION['config']->get_Suffix($this->type); foreach ($_SESSION['ldap']->search_units($rootsuffix) as $suffix) { if ($this->dn == $suffix) $option_selected = $suffix; $suffixes[] = $suffix; diff --git a/lam/lib/modules/posixGroup.inc b/lam/lib/modules/posixGroup.inc index 3d660199..0d02dedf 100644 --- a/lam/lib/modules/posixGroup.inc +++ b/lam/lib/modules/posixGroup.inc @@ -729,7 +729,7 @@ class posixGroup extends baseModule { $DNs = array_keys($result); for ($i=0; $iget_domainSuffix()); + $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); // Get Domain-SID from group SID $domainSID = substr($result[$DNs[$i]], 0, strrpos($result[$DNs[$i]], "-")); for ($i=0; $iget_domainSuffix()); + $domains = search_domains($_SESSION['config']->get_Suffix('domain')); $nameToSID = array(); // get domain SIDs for ($i = 0; $i < sizeof($domains); $i++) { @@ -144,7 +144,7 @@ class sambaGroupMapping extends baseModule { */ function display_html_attributes(&$post) { // Get Domain SID from name - $sambaDomains = search_domains($_SESSION['config']->get_domainSuffix()); + $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); // Get Domain-SID from group SID if ($this->attributes['sambaSID'][0]!='') $domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-")); @@ -229,7 +229,7 @@ class sambaGroupMapping extends baseModule { // upload fields // search existing Samba 3 domains if ($_SESSION['loggedIn']) { - $domains = search_domains($_SESSION['config']->get_domainSuffix()); + $domains = search_domains($_SESSION['config']->get_Suffix('domain')); $domainNames = array(); for ($i = 0; $i < sizeof($domains); $i++) $domainNames[] = $domains[$i]->name; $return['upload_columns'] = array( @@ -312,7 +312,7 @@ class sambaGroupMapping extends baseModule { function get_profileOptions() { $return = array(); // get list of domains - $sambaDomains = search_domains($_SESSION['config']->get_domainSuffix()); + $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomainNames = array(); for ($i = 0; $i < count($sambaDomains); $i++ ) { // extract names @@ -335,7 +335,7 @@ class sambaGroupMapping extends baseModule { function load_profile($profile) { if (isset($profile['sambaGroupMapping_sambaDomainName'][0])) { // get list of domains - $sambaDomains = search_domains($_SESSION['config']->get_domainSuffix()); + $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); for ($i = 0; $i < sizeof($sambaDomains); $i++) { if ($sambaDomains[$i]->name == $profile['sambaGroupMapping_sambaDomainName'][0]) { $this->attributes['sambaSID'][0] = $sambaDomains[$i]->SID . "-0"; @@ -398,7 +398,7 @@ class sambaGroupMapping extends baseModule { $this->attributes['sambaGroupType'][0] = $this->sambaGroupTypes[$post['sambaGroupType']]; // Get Domain SID from name - $sambaDomains = search_domains($_SESSION['config']->get_domainSuffix()); + $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); for ($i=0; $iname) { $SID = $sambaDomains[$i]->SID; @@ -443,7 +443,7 @@ class sambaGroupMapping extends baseModule { */ function save_attributes() { // Get Domain SID from name - $sambaDomains = search_domains($_SESSION['config']->get_domainSuffix()); + $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); // Get Domain-SID from group SID $domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-")); for ($i=0; $iget_domainSuffix()); + $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); for ($i=0; $iattributes['sambaDomainName'][0] == $sambaDomains[$i]->name) { $SID = $sambaDomains[$i]->SID; @@ -502,7 +502,7 @@ class sambaSamAccount extends baseModule { // Save attributes $this->attributes['sambaDomainName'][0] = $post['sambaDomainName']; // Get Domain SID from name - $sambaDomains = search_domains($_SESSION['config']->get_domainSuffix()); + $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); for ($i=0; $iattributes['sambaDomainName'][0] == $sambaDomains[$i]->name) { $SID = $sambaDomains[$i]->SID; @@ -692,7 +692,7 @@ class sambaSamAccount extends baseModule { */ function display_html_attributes(&$post) { // Get Domain SID from name - $sambaDomains = search_domains($_SESSION['config']->get_domainSuffix()); + $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); for ($i=0; $iname; if ($this->attributes['sambaDomainName'][0] == $sambaDomains[$i]->name) @@ -917,7 +917,7 @@ class sambaSamAccount extends baseModule { 2 => array('kind' => 'help', 'value' => 'workstations') ); // domains - $sambaDomains = search_domains($_SESSION['config']->get_domainSuffix()); + $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomainNames = array(); for ($i = 0; $i < count($sambaDomains); $i++) { $sambaDomainNames[] = $sambaDomains[$i]->name; @@ -930,7 +930,7 @@ class sambaSamAccount extends baseModule { } elseif ($this->get_scope() == 'host') { // domains - $sambaDomains = search_domains($_SESSION['config']->get_domainSuffix()); + $sambaDomains = search_domains($_SESSION['config']->get_Suffix('domain')); $sambaDomainNames = array(); for ($i = 0; $i < count($sambaDomains); $i++) { $sambaDomainNames[] = $sambaDomains[$i]->name; @@ -1011,7 +1011,7 @@ class sambaSamAccount extends baseModule { function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts) { $triggered_messages = array(); // get list of Samba 3 domains - $domains = search_domains($_SESSION['config']->get_DomainSuffix()); + $domains = search_domains($_SESSION['config']->get_Suffix('domain')); // get list of Unix groups and their sambaSID + gidNumber $groups = $_SESSION['cache']->get_cache('cn', 'posixGroup', 'group'); $groups_SID = $_SESSION['cache']->get_cache('sambaSID', 'sambaGroupMapping', 'group'); diff --git a/lam/templates/config/confmain.php b/lam/templates/config/confmain.php index 41fd80b0..02c37a36 100644 --- a/lam/templates/config/confmain.php +++ b/lam/templates/config/confmain.php @@ -119,10 +119,10 @@ if (isset($_GET["modulesback"])) { $conf->set_ServerURL($_SESSION['conf_serverurl']); $conf->set_cacheTimeout($_SESSION['conf_cachetimeout']); $conf->set_Adminstring($_SESSION['conf_admins']); - $conf->set_UserSuffix($_SESSION['conf_suffusers']); - $conf->set_GroupSuffix($_SESSION['conf_suffgroups']); - $conf->set_HostSuffix($_SESSION['conf_suffhosts']); - $conf->set_DomainSuffix($_SESSION['conf_suffdomains']); + $conf->set_Suffix('user', $_SESSION['conf_suffusers']); + $conf->set_Suffix('group', $_SESSION['conf_suffgroups']); + $conf->set_Suffix('host', $_SESSION['conf_suffhosts']); + $conf->set_Suffix('domain', $_SESSION['conf_suffdomains']); $conf->set_Suffix('tree', $_SESSION['conf_sufftree']); $conf->set_userlistAttributes($_SESSION['conf_usrlstattr']); $conf->set_grouplistAttributes($_SESSION['conf_grplstattr']); @@ -170,25 +170,25 @@ echo (" "); // user suffix echo ("". _("UserSuffix") . ": ". - "get_UserSuffix() . "\">\n"); + "get_Suffix('user') . "\">\n"); echo ("" . _("Help") . "\n"); $tabindex++; // group suffix echo ("". _("GroupSuffix") . ": ". - "get_GroupSuffix() . "\">\n"); + "get_Suffix('group') . "\">\n"); echo ("" . _("Help") . "\n"); $tabindex++; // host suffix echo ("". _("HostSuffix") . ": ". - "get_HostSuffix() . "\">\n"); + "get_Suffix('host') . "\">\n"); echo ("" . _("Help") . "\n"); $tabindex++; // domain suffix echo ("". _("DomainSuffix") . " **: ". - "get_DomainSuffix() . "\">\n"); + "get_Suffix('domain') . "\">\n"); echo ("" . _("Help") . "\n"); $tabindex++; // tree suffix diff --git a/lam/templates/config/confsave.php b/lam/templates/config/confsave.php index e60b734f..a71d8a13 100644 --- a/lam/templates/config/confsave.php +++ b/lam/templates/config/confsave.php @@ -103,22 +103,22 @@ if (!$conf->set_Adminstring($admins)) { echo ("\n


" . _("Back to preferences...") . ""); exit; } -if (!$conf->set_UserSuffix($suffusers)) { +if (!$conf->set_Suffix('user', $suffusers)) { echo ("" . _("UserSuffix is invalid!") . ""); echo ("\n


" . _("Back to preferences...") . ""); exit; } -if (!$conf->set_GroupSuffix($suffgroups)) { +if (!$conf->set_Suffix('group', $suffgroups)) { echo ("" . _("GroupSuffix is invalid!") . ""); echo ("\n


" . _("Back to preferences...") . ""); exit; } -if (!$conf->set_HostSuffix($suffhosts)) { +if (!$conf->set_Suffix('host', $suffhosts)) { echo ("" . _("HostSuffix is invalid!") . ""); echo ("\n


" . _("Back to preferences...") . ""); exit; } -if (!$conf->set_DomainSuffix($suffdomains)) { +if (!$conf->set_Suffix('domain', $suffdomains)) { echo ("" . _("DomainSuffix is invalid!") . ""); echo ("\n


" . _("Back to preferences...") . ""); exit; diff --git a/lam/templates/domain.php b/lam/templates/domain.php index 4dd9621a..415f330e 100644 --- a/lam/templates/domain.php +++ b/lam/templates/domain.php @@ -45,9 +45,9 @@ setlanguage(); // add/edit domain if (($_GET['action'] == "edit") || ($_GET['action'] == "new")) { // get list of domains - $domlist = search_domains($_SESSION['config']->get_domainSuffix()); + $domlist = search_domains($_SESSION['config']->get_Suffix('domain')); // get possible suffixes - $domsuff = $_SESSION['ldap']->search_units($_SESSION['config']->get_domainSuffix()); + $domsuff = $_SESSION['ldap']->search_units($_SESSION['config']->get_Suffix('domain')); if ($_GET['action'] == "edit") { // remove "\'" $_GET['DN'] = str_replace("\\", "", $_GET['DN']); @@ -66,7 +66,7 @@ if (($_GET['action'] == "edit") || ($_GET['action'] == "new")) { } else { $domain = new samba3domain(); - $domain_suffix = $_SESSION['config']->get_domainSuffix(); + $domain_suffix = $_SESSION['config']->get_Suffix('domain'); } // display page echo $_SESSION['header']; @@ -233,7 +233,7 @@ elseif ($_POST['sub_save']) { echo "\n"; // check input if ($_POST['add']) { // check for existing domains - $suffix = $_SESSION['config']->get_DomainSuffix(); + $suffix = $_SESSION['config']->get_Suffix('domain'); $server = $_SESSION['ldap']->server; $filter = "(|(sambasid=" . $_POST['dom_SID'] . ")(sambadomainname=" . $_POST['dom_name'] . "))"; $sr = @ldap_search($server, $suffix, $filter, array()); diff --git a/lam/templates/lists/listdomains.php b/lam/templates/lists/listdomains.php index 52ea1664..adea722a 100644 --- a/lam/templates/lists/listdomains.php +++ b/lam/templates/lists/listdomains.php @@ -106,7 +106,7 @@ else $sort = strtolower($attr_array[0]); // check search suffix if (isset($_POST['suffix'])) $suffix = $_POST['suffix']; // new suffix selected via combobox elseif (isset($_SESSION[$scope . '_suffix'])) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session -else $suffix = $_SESSION["config"]->get_DomainSuffix(); // default suffix +else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix $refresh = true; if (isset($_GET['norefresh'])) $refresh = false; @@ -198,7 +198,7 @@ echo ("
\n"); if ($refresh) { // generate list of possible suffixes - $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_DomainSuffix()); + $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope)); } // print combobox with possible sub-DNs diff --git a/lam/templates/lists/listgroups.php b/lam/templates/lists/listgroups.php index 8eb6dae1..5c3c37d0 100644 --- a/lam/templates/lists/listgroups.php +++ b/lam/templates/lists/listgroups.php @@ -108,7 +108,7 @@ else $sort = strtolower($attr_array[0]); // check search suffix if ($_POST['suffix']) $suffix = $_POST['suffix']; // new suffix selected via combobox elseif ($_SESSION[$scope . '_suffix']) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session -else $suffix = $_SESSION["config"]->get_GroupSuffix(); // default suffix +else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix $refresh = true; if (isset($_GET['norefresh'])) $refresh = false; @@ -246,7 +246,7 @@ echo ("
\n"); if ($refresh) { // generate list of possible suffixes - $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_GroupSuffix()); + $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope)); } // print combobox with possible sub-DNs diff --git a/lam/templates/lists/listhosts.php b/lam/templates/lists/listhosts.php index d609ab81..b333f636 100644 --- a/lam/templates/lists/listhosts.php +++ b/lam/templates/lists/listhosts.php @@ -108,7 +108,7 @@ else $sort = strtolower($attr_array[0]); // check search suffix if ($_POST['suffix']) $suffix = $_POST['suffix']; // new suffix selected via combobox elseif ($_SESSION[$scope . '_suffix']) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session -else $suffix = $_SESSION["config"]->get_HostSuffix(); // default suffix +else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix $refresh = true; if (isset($_GET['norefresh'])) $refresh = false; @@ -230,7 +230,7 @@ echo ("
\n"); if ($refresh) { // generate list of possible suffixes - $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_HostSuffix()); + $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope)); } // print combobox with possible sub-DNs diff --git a/lam/templates/lists/listusers.php b/lam/templates/lists/listusers.php index 1126ee43..0e5676f2 100644 --- a/lam/templates/lists/listusers.php +++ b/lam/templates/lists/listusers.php @@ -68,7 +68,7 @@ else $trans_primary_hash = array(); // generate hash table for group translation if ($trans_primary == "on" && ($refresh || (sizeof($trans_primary_hash) == 0))) { $trans_primary_hash = array(); - $grp_suffix = $_SESSION['config']->get_groupSuffix(); + $grp_suffix = $_SESSION['config']->get_Suffix('group'); $filter = "objectClass=posixGroup"; $attrs = array("cn", "gidNumber"); $sr = @ldap_search($_SESSION["ldap"]->server(), $grp_suffix, $filter, $attrs); @@ -137,7 +137,7 @@ else $sort = strtolower($attr_array[0]); // check search suffix if (isset($_POST['suffix'])) $suffix = $_POST['suffix']; // new suffix selected via combobox elseif (isset($_SESSION[$scope . '_suffix'])) $suffix = $_SESSION[$scope . '_suffix']; // old suffix from session -else $suffix = $_SESSION["config"]->get_UserSuffix(); // default suffix +else $suffix = $_SESSION["config"]->get_Suffix($scope); // default suffix // configure search filter for LDAP @@ -277,7 +277,7 @@ if (sizeof($info) != 0) { if ($refresh) { // generate list of possible suffixes - $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_UserSuffix()); + $units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix($scope)); } // print combobox with possible sub-DNs diff --git a/lam/templates/lists/userlink.php b/lam/templates/lists/userlink.php index 53e7bd0d..0f9bd681 100644 --- a/lam/templates/lists/userlink.php +++ b/lam/templates/lists/userlink.php @@ -76,7 +76,7 @@ else { function search_username($name) { $filter = "(uid=$name)"; $attrs = array(); - $sr = @ldap_search($_SESSION['ldap']->server, $_SESSION['config']->get_UserSuffix(), $filter, $attrs); + $sr = @ldap_search($_SESSION['ldap']->server, $_SESSION['config']->get_Suffix('user'), $filter, $attrs); if ($sr) { $info = ldap_get_entries($_SESSION['ldap']->server, $sr); // return only first DN entry diff --git a/lam/templates/main.php b/lam/templates/main.php index 5c1750d9..87694ce6 100644 --- a/lam/templates/main.php +++ b/lam/templates/main.php @@ -41,32 +41,32 @@ $startPage = ""; // check if all suffixes in conf-file exist $conf = $_SESSION['config']; $new_suffs = array(); -if ($conf->get_UserSuffix() && ($conf->get_UserSuffix() != "")) { +if ($conf->get_Suffix('user') && ($conf->get_Suffix('user') != "")) { $startPage = "./lists/listusers.php"; - $info = @ldap_search($_SESSION['ldap']->server, $conf->get_UserSuffix(), "", array()); + $info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('user'), "", array()); $res = @ldap_get_entries($_SESSION['ldap']->server, $info); - if (!$res && !in_array($conf->get_UserSuffix(), $new_suffs)) $new_suffs[] = $conf->get_UserSuffix(); + if (!$res && !in_array($conf->get_Suffix('user'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('user'); } -if ($conf->get_GroupSuffix() && ($conf->get_GroupSuffix() != "")) { +if ($conf->get_Suffix('group') && ($conf->get_Suffix('group') != "")) { if ($startPage == "") { $startPage = "./lists/listgroups.php"; } - $info = @ldap_search($_SESSION['ldap']->server, $conf->get_GroupSuffix(), "", array()); + $info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('group'), "", array()); $res = @ldap_get_entries($_SESSION['ldap']->server, $info); - if (!$res && !in_array($conf->get_GroupSuffix(), $new_suffs)) $new_suffs[] = $conf->get_GroupSuffix(); + if (!$res && !in_array($conf->get_Suffix('group'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('group'); } -if ($conf->get_HostSuffix() && ($conf->get_HostSuffix() != "")) { +if ($conf->get_Suffix('host') && ($conf->get_Suffix('host') != "")) { if ($startPage == "") { $startPage = "./lists/listhosts.php"; } - $info = @ldap_search($_SESSION['ldap']->server, $conf->get_HostSuffix(), "", array()); + $info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('host'), "", array()); $res = @ldap_get_entries($_SESSION['ldap']->server, $info); - if (!$res && !in_array($conf->get_HostSuffix(), $new_suffs)) $new_suffs[] = $conf->get_HostSuffix(); + if (!$res && !in_array($conf->get_Suffix('host'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('host'); } -if ($conf->get_DomainSuffix() && ($conf->get_DomainSuffix() != "")) { - $info = @ldap_search($_SESSION['ldap']->server, $conf->get_DomainSuffix(), "", array()); +if ($conf->get_Suffix('domain') && ($conf->get_Suffix('domain') != "")) { + $info = @ldap_search($_SESSION['ldap']->server, $conf->get_Suffix('domain'), "", array()); $res = @ldap_get_entries($_SESSION['ldap']->server, $info); - if (!$res && !in_array($conf->get_DomainSuffix(), $new_suffs)) $new_suffs[] = $conf->get_DomainSuffix(); + if (!$res && !in_array($conf->get_Suffix('domain'), $new_suffs)) $new_suffs[] = $conf->get_Suffix('domain'); } // get encoding diff --git a/lam/templates/main_header.php b/lam/templates/main_header.php index 31c82a0c..5e0048a9 100644 --- a/lam/templates/main_header.php +++ b/lam/templates/main_header.php @@ -41,9 +41,9 @@ echo $_SESSION['header']; // number of list views (users, groups, ...) $lists = 0; -if ($_SESSION['config']->get_Usersuffix() != "") $lists++; -if ($_SESSION['config']->get_Groupsuffix() != "") $lists++; -if ($_SESSION['config']->get_Hostsuffix() != "") $lists++; +if ($_SESSION['config']->get_Suffix('user') != "") $lists++; +if ($_SESSION['config']->get_Suffix('group') != "") $lists++; +if ($_SESSION['config']->get_Suffix('host') != "") $lists++; if ($_SESSION['config']->get_Suffix('tree') != "") $lists++; ?> @@ -77,13 +77,13 @@ if ($_SESSION['config']->get_Suffix('tree') != "") $lists++; if ($_SESSION['config']->get_Suffix('tree') != "") { echo '' . _("Tree view") . '' . "\n"; } - if ($_SESSION['config']->get_Usersuffix() != "") { + if ($_SESSION['config']->get_Suffix('user') != "") { echo '' . _("Users") . '' . "\n"; } - if ($_SESSION['config']->get_Groupsuffix() != "") { + if ($_SESSION['config']->get_Suffix('group') != "") { echo '' . _("Groups") . '' . "\n"; } - if ($_SESSION['config']->get_Hostsuffix() != "") { + if ($_SESSION['config']->get_Suffix('host') != "") { echo '' . _("Hosts") . '' . "\n"; } ?> diff --git a/lam/templates/massBuildAccounts.php b/lam/templates/massBuildAccounts.php index 54d9f30c..37b7b5c0 100644 --- a/lam/templates/massBuildAccounts.php +++ b/lam/templates/massBuildAccounts.php @@ -165,7 +165,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) { // TODO check against list of possible RDN attributes else { $account_dn = $data[$i][$ids['dn_rdn']] . "=" . $accounts[$i][$data[$i][$ids['dn_rdn']]] . ","; - if ($data[$i][$ids['dn_suffix']] == "") $account_dn = $account_dn . call_user_func(array($_SESSION['config'], "get_" . ucfirst($_POST['scope']) . "Suffix")); + if ($data[$i][$ids['dn_suffix']] == "") $account_dn = $account_dn . $_SESSION['config']->get_Suffix($_POST['scope']); else $account_dn = $account_dn . $data[$i][$ids['dn_suffix']]; $accounts[$i]['dn'] = $account_dn; } diff --git a/lam/templates/masscreate.php b/lam/templates/masscreate.php index e52c7882..a49bb22f 100644 --- a/lam/templates/masscreate.php +++ b/lam/templates/masscreate.php @@ -144,7 +144,7 @@ function showMainPage($scope) { echo "
    \n"; echo "
  • " . _("Identifier") . ": " . "dn_suffix
  • \n"; echo "
  • " . _("Example value") . ": " . "ou=accounts,dc=yourdomain,dc=org
  • \n"; - echo "
  • " . _("Default value") . ": " . call_user_func(array($_SESSION['config'], 'get_' . ucfirst($scope) . 'Suffix')) . "
  • \n"; + echo "
  • " . _("Default value") . ": " . $_SESSION['config']->get_Suffix($scope) . "
  • \n"; echo "
  • \n"; echo "" . _("Help") . "\n"; echo "
  • \n"; @@ -232,10 +232,10 @@ function showMainPage($scope) { echo "\n"; echo "\n"; // DN attributes - $sampleCSV_row[] = "\"" . call_user_func(array($_SESSION['config'], 'get_' . ucfirst($scope) . 'Suffix')) . "\""; + $sampleCSV_row[] = "\"" . $_SESSION['config']->get_Suffix($scope) . "\""; $sampleCSV_row[] = "\"" . array_shift(getRDNAttributes($scope)) . "\""; echo "\n"; - echo call_user_func(array($_SESSION['config'], 'get_' . ucfirst($scope) . 'Suffix')); + echo $_SESSION['config']->get_Suffix($scope); echo "\n"; echo "\n"; echo array_shift(getRDNAttributes($scope)); diff --git a/lam/templates/ou_edit.php b/lam/templates/ou_edit.php index 9f7e0b01..40ba8f2f 100644 --- a/lam/templates/ou_edit.php +++ b/lam/templates/ou_edit.php @@ -330,9 +330,9 @@ function display_main() { echo ("
    \n"); // user OUs - if ($_SESSION["config"]->get_UserSuffix() != "") { + if ($_SESSION["config"]->get_Suffix('user') != "") { // generate lists of possible suffixes - $usr_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_UserSuffix()); + $usr_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('user')); echo ("
    " . _("Users") . "\n"); echo ("\n"); // new OU @@ -367,9 +367,9 @@ function display_main() { } // group OUs - if ($_SESSION["config"]->get_GroupSuffix() != "") { + if ($_SESSION["config"]->get_Suffix('group') != "") { // generate lists of possible suffixes - $grp_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_GroupSuffix()); + $grp_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('group')); echo ("
    " . _("Groups") . "\n"); echo ("
    \n"); // new OU @@ -404,9 +404,9 @@ function display_main() { } // host OUs - if ($_SESSION["config"]->get_HostSuffix() != "") { + if ($_SESSION["config"]->get_Suffix('host') != "") { // generate lists of possible suffixes - $hst_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_HostSuffix()); + $hst_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('host')); echo ("
    " . _("Samba Hosts") . "\n"); echo ("
    \n"); // new OU @@ -441,9 +441,9 @@ function display_main() { } // domain OUs - if ($_SESSION["config"]->get_DomainSuffix() != "") { + if ($_SESSION["config"]->get_Suffix('domain') != "") { // generate lists of possible suffixes - $dom_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_DomainSuffix()); + $dom_units = $_SESSION['ldap']->search_units($_SESSION["config"]->get_Suffix('domain')); echo ("
    " . _("Domains") . "\n"); echo ("
    \n"); // new OU diff --git a/lam/templates/profedit/profilepage.php b/lam/templates/profedit/profilepage.php index 4f390e84..24eddadb 100644 --- a/lam/templates/profedit/profilepage.php +++ b/lam/templates/profedit/profilepage.php @@ -75,7 +75,7 @@ echo ("\n"); // suffix box // get root suffix -$rootsuffix = call_user_func(array($_SESSION['config'], 'get_' . ucfirst($type) . 'Suffix')); +$rootsuffix = $_SESSION['config']->get_Suffix($type); // get subsuffixes $suffixes = array(); foreach ($_SESSION['ldap']->search_units($rootsuffix) as $suffix) { diff --git a/lam/templates/tools.php b/lam/templates/tools.php index 19cc4b65..6a9338ef 100644 --- a/lam/templates/tools.php +++ b/lam/templates/tools.php @@ -56,7 +56,7 @@ $tools[] = array( ); // Samba 3 domains -if ($_SESSION['config']->get_DomainSuffix() && ($_SESSION['config']->get_DomainSuffix() != "")) { +if ($_SESSION['config']->get_Suffix('domain') && ($_SESSION['config']->get_Suffix('domain') != "")) { $tools[] = array( "name" => _("Samba 3 domains"), "description" => _("Manages Samba 3 domain accounts."), diff --git a/lam/tests/conf-test.php b/lam/tests/conf-test.php index cb0eaddb..29997a01 100644 --- a/lam/tests/conf-test.php +++ b/lam/tests/conf-test.php @@ -43,10 +43,10 @@ $ServerURL = $conf->get_ServerURL(); $cachetimeout = $conf->get_cacheTimeout(); $Passwd = $conf->get_Passwd(); $Adminstring = $conf->get_Adminstring(); -$Suff_users = $conf->get_UserSuffix(); -$Suff_groups = $conf->get_GroupSuffix(); -$Suff_hosts = $conf->get_HostSuffix(); -$Suff_domains = $conf->get_DomainSuffix(); +$Suff_users = $conf->get_Suffix('user'); +$Suff_groups = $conf->get_Suffix('group'); +$Suff_hosts = $conf->get_Suffix('host'); +$Suff_domains = $conf->get_Suffix('domain'); $userlistAttributes = $conf->get_userlistAttributes(); $grouplistAttributes = $conf->get_grouplistAttributes(); $hostlistAttributes = $conf->get_hostlistAttributes(); @@ -62,10 +62,10 @@ $conf->set_ServerURL("ldap://123.345.678.123:777"); $conf->set_cacheTimeout("33"); $conf->set_Passwd("123456abcde"); $conf->set_Adminstring("uid=test,o=test,dc=org;uid=root,o=test2,c=de"); -$conf->set_UserSuffix("ou=test,o=test,c=de"); -$conf->set_GroupSuffix("ou=testgrp,o=test,c=de"); -$conf->set_HostSuffix("ou=testhst,o=test,c=de"); -$conf->set_DomainSuffix("ou=testdom,o=test,c=de"); +$conf->set_Suffix('user', "ou=test,o=test,c=de"); +$conf->set_Suffix('group', "ou=testgrp,o=test,c=de"); +$conf->set_Suffix('host', "ou=testhst,o=test,c=de"); +$conf->set_Suffix('domain', "ou=testdom,o=test,c=de"); $conf->set_userlistAttributes("#uid;#cn"); $conf->set_grouplistAttributes("#gidNumber;#cn;#memberUID"); $conf->set_hostlistAttributes("#cn;#uid;#description"); @@ -83,10 +83,10 @@ if ($conf2->get_ServerURL() != "ldap://123.345.678.123:777") echo ("
    get_cacheTimeout() != "33") echo ("
    Saving Cache timeout failed!
    "); if ($conf2->get_Passwd() != "123456abcde") echo ("
    Saving password failed!
    "); if ($conf2->get_Adminstring() != "uid=test,o=test,dc=org;uid=root,o=test2,c=de") echo ("
    Saving admin string failed!
    "); -if ($conf2->get_UserSuffix() != "ou=test,o=test,c=de") echo ("
    Saving user suffix failed!
    "); -if ($conf2->get_GroupSuffix() != "ou=testgrp,o=test,c=de") echo ("
    Saving group suffix failed!
    "); -if ($conf2->get_HostSuffix() != "ou=testhst,o=test,c=de") echo ("
    Saving host suffix failed!
    "); -if ($conf2->get_DomainSuffix() != "ou=testdom,o=test,c=de") echo ("
    Saving domain suffix failed!
    "); +if ($conf2->get_Suffix('user') != "ou=test,o=test,c=de") echo ("
    Saving user suffix failed!
    "); +if ($conf2->get_Suffix('group') != "ou=testgrp,o=test,c=de") echo ("
    Saving group suffix failed!
    "); +if ($conf2->get_Suffix('host') != "ou=testhst,o=test,c=de") echo ("
    Saving host suffix failed!
    "); +if ($conf2->get_Suffix('domain') != "ou=testdom,o=test,c=de") echo ("
    Saving domain suffix failed!
    "); if ($conf2->get_userlistAttributes() != "#uid;#cn") echo ("
    Saving userlistAttributes failed!
    "); if ($conf2->get_grouplistAttributes() != "#gidNumber;#cn;#memberUID") echo ("
    Saving grouplistAttributes failed!
    "); if ($conf2->get_hostlistAttributes() != "#cn;#uid;#description") echo ("
    Saving hostlistAttributes failed!
    "); @@ -103,10 +103,10 @@ $conf2->set_ServerURL($ServerURL); $conf2->set_cacheTimeout($cachetimeout); $conf2->set_Passwd($Passwd); $conf2->set_Adminstring($Adminstring); -$conf2->set_UserSuffix($Suff_users); -$conf2->set_GroupSuffix($Suff_groups); -$conf2->set_HostSuffix($Suff_hosts); -$conf2->set_DomainSuffix($Suff_domains); +$conf2->set_Suffix('user', $Suff_users); +$conf2->set_Suffix('group', $Suff_groups); +$conf2->set_Suffix('host', $Suff_hosts); +$conf2->set_Suffix('domain', $Suff_domains); $conf2->set_userlistAttributes($userlistAttributes); $conf2->set_grouplistAttributes($grouplistAttributes); $conf2->set_hostlistAttributes($hostlistAttributes);