From 9e0c6bc13dff774a47949f1761109cf0ab73d499 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 1 Jun 2007 17:25:07 +0000 Subject: [PATCH] fixed group refreshing (1719168) --- lam/lib/types/user.inc | 50 +++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/lam/lib/types/user.inc b/lam/lib/types/user.inc index 4c9cd971..44ea6bc8 100644 --- a/lam/lib/types/user.inc +++ b/lam/lib/types/user.inc @@ -137,22 +137,46 @@ class lamUserList extends lamList { if (isset($_POST['apply_trans_primary'])) { $this->trans_primary = $_POST['trans_primary']; } + } + + /** + * Sets some internal parameters. + */ + function listGetParams() { + parent::listGetParams(); // generate hash table for group translation - if ($this->trans_primary == "on" && ($this->refresh || (sizeof($this->trans_primary_hash) == 0))) { - $this->trans_primary_hash = array(); - $grp_suffix = $_SESSION['config']->get_Suffix('group'); - $filter = "objectClass=posixGroup"; - $attrs = array("cn", "gidNumber"); - $sr = @ldap_search($_SESSION["ldap"]->server(), $grp_suffix, $filter, $attrs); - if ($sr) { - $info = @ldap_get_entries($_SESSION["ldap"]->server(), $sr); - unset($info['count']); // delete count entry - for ($i = 0; $i < sizeof($info); $i++) { - $this->trans_primary_hash[$info[$i]['gidnumber'][0]] = $info[$i]['cn'][0]; - } - } + if ($this->trans_primary == "on" && !$this->refresh && (sizeof($this->trans_primary_hash) == 0)) { + $this->refreshPrimaryGroupTranslation(); + } + } + + /** + * Rereads the entries from LDAP. + */ + function listRefreshData() { + parent::listRefreshData(); + if ($this->trans_primary == "on") { + $this->refreshPrimaryGroupTranslation(); } } + + /** + * Refreshes the GID to group name cache. + */ + function refreshPrimaryGroupTranslation() { + $this->trans_primary_hash = array(); + $grp_suffix = $_SESSION['config']->get_Suffix('group'); + $filter = "objectClass=posixGroup"; + $attrs = array("cn", "gidNumber"); + $sr = @ldap_search($_SESSION["ldap"]->server(), $grp_suffix, $filter, $attrs); + if ($sr) { + $info = @ldap_get_entries($_SESSION["ldap"]->server(), $sr); + unset($info['count']); // delete count entry + for ($i = 0; $i < sizeof($info); $i++) { + $this->trans_primary_hash[$info[$i]['gidnumber'][0]] = $info[$i]['cn'][0]; + } + } + } /** * Prints the content of a cell in the account list for a given LDAP entry and attribute.