2006-01-01 16:30:05 +00:00
|
|
|
<?php
|
2017-03-16 18:44:01 +00:00
|
|
|
use \LAM\TYPES\TypeManager;
|
2006-01-01 16:30:05 +00:00
|
|
|
/*
|
|
|
|
$Id$
|
|
|
|
|
2009-10-27 18:47:12 +00:00
|
|
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
2017-03-16 18:44:01 +00:00
|
|
|
Copyright (C) 2005 - 2017 Roland Gruber
|
2006-01-01 16:30:05 +00:00
|
|
|
|
|
|
|
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; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The account type for group accounts (e.g. Unix and Samba).
|
|
|
|
*
|
|
|
|
* @package types
|
|
|
|
* @author Roland Gruber
|
2007-05-26 18:42:08 +00:00
|
|
|
* @author Ludek Finstrle
|
2006-01-01 16:30:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The account type for group accounts (e.g. Unix and Samba).
|
2006-02-07 16:05:37 +00:00
|
|
|
*
|
|
|
|
* @package types
|
2006-01-01 16:30:05 +00:00
|
|
|
*/
|
|
|
|
class group extends baseType {
|
2016-11-14 18:37:39 +00:00
|
|
|
|
2009-02-18 19:15:56 +00:00
|
|
|
/**
|
|
|
|
* Constructs a new group type object.
|
2017-04-26 16:22:05 +00:00
|
|
|
*
|
|
|
|
* @param ConfiguredType $type configuration
|
2009-02-18 19:15:56 +00:00
|
|
|
*/
|
2017-04-26 16:22:05 +00:00
|
|
|
public function __construct($type) {
|
|
|
|
parent::__construct($type);
|
2009-02-18 19:15:56 +00:00
|
|
|
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another group');
|
|
|
|
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to group list');
|
2017-04-26 17:01:57 +00:00
|
|
|
if ($this->getType() != null) {
|
|
|
|
$modules = $this->getType()->getModules();
|
2014-01-18 11:38:38 +00:00
|
|
|
if (in_array('organizationalRole', $modules)) {
|
|
|
|
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another role');
|
|
|
|
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to role list');
|
|
|
|
}
|
|
|
|
}
|
2009-02-18 19:15:56 +00:00
|
|
|
}
|
2016-11-14 18:37:39 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Returns the alias name of this account type.
|
|
|
|
*
|
|
|
|
* @return string alias name
|
|
|
|
*/
|
|
|
|
function getAlias() {
|
2017-04-26 17:01:57 +00:00
|
|
|
if ($this->getType() != null) {
|
|
|
|
$modules = $this->getType()->getModules();
|
2014-01-18 11:38:38 +00:00
|
|
|
if (in_array('organizationalRole', $modules)) {
|
|
|
|
return _('Roles');
|
|
|
|
}
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
return _("Groups");
|
|
|
|
}
|
2016-11-14 18:37:39 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Returns the description of this account type.
|
|
|
|
*
|
|
|
|
* @return string description
|
|
|
|
*/
|
|
|
|
function getDescription() {
|
|
|
|
return _("Group accounts (e.g. Unix and Samba)");
|
|
|
|
}
|
2016-11-14 18:37:39 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Returns the class name for the list object.
|
|
|
|
*
|
|
|
|
* @return string class name
|
|
|
|
*/
|
|
|
|
function getListClassName() {
|
|
|
|
return "lamGroupList";
|
|
|
|
}
|
2016-11-14 18:37:39 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Returns the default attribute list for this account type.
|
|
|
|
*
|
|
|
|
* @return string attribute list
|
|
|
|
*/
|
|
|
|
function getDefaultListAttributes() {
|
|
|
|
return "#cn;#gidNumber;#memberUID;#description";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a list of attributes which have a translated description.
|
|
|
|
* This is used for the head row in the list view.
|
|
|
|
*
|
|
|
|
* @return array list of descriptions
|
|
|
|
*/
|
|
|
|
function getListAttributeDescriptions() {
|
2014-01-18 11:38:38 +00:00
|
|
|
$return = array (
|
2006-01-01 16:30:05 +00:00
|
|
|
"cn" => _("Group name"),
|
2016-11-14 18:37:39 +00:00
|
|
|
"description" => _("Group description"),
|
|
|
|
"displayName" => _("Display name"),
|
2006-01-01 16:30:05 +00:00
|
|
|
"gidnumber" => _("GID number"),
|
|
|
|
"member" => _("Group member DNs"),
|
2016-11-14 18:37:39 +00:00
|
|
|
"memberuid" => _("Group members"),
|
2014-01-18 11:38:38 +00:00
|
|
|
"roleOccupant" => _("Role member DNs"),
|
2016-11-14 18:37:39 +00:00
|
|
|
"uniqueMember" => _("Group member DNs"),
|
2017-12-22 10:56:03 +00:00
|
|
|
"memberUrl" => _("Entries"),
|
2014-01-18 11:38:38 +00:00
|
|
|
);
|
2017-04-26 17:01:57 +00:00
|
|
|
if ($this->getType() != null) {
|
|
|
|
$modules = $this->getType()->getModules();
|
2014-02-06 17:29:04 +00:00
|
|
|
if (in_array('organizationalRole', $modules)) {
|
|
|
|
$return['cn'] = _('Role name');
|
|
|
|
}
|
2014-01-18 11:38:38 +00:00
|
|
|
}
|
|
|
|
return $return;
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
|
2010-12-14 21:16:21 +00:00
|
|
|
/**
|
|
|
|
* Returns the the title text for the title bar on the new/edit page.
|
|
|
|
*
|
2012-04-07 16:40:34 +00:00
|
|
|
* @param accountContainer $container account container
|
2010-12-14 21:16:21 +00:00
|
|
|
* @return String title text
|
|
|
|
*/
|
2012-04-07 16:40:34 +00:00
|
|
|
public function getTitleBarTitle($container) {
|
|
|
|
// get attributes
|
|
|
|
$attributes = null;
|
|
|
|
if ($container->getAccountModule('posixGroup') != null) {
|
|
|
|
$attributes = $container->getAccountModule('posixGroup')->getAttributes();
|
|
|
|
}
|
|
|
|
elseif ($container->getAccountModule('rfc2307bisPosixGroup') != null) {
|
|
|
|
$attributes = $container->getAccountModule('rfc2307bisPosixGroup')->getAttributes();
|
|
|
|
}
|
2013-03-29 10:21:03 +00:00
|
|
|
elseif ($container->getAccountModule('windowsGroup') != null) {
|
|
|
|
$attributes = $container->getAccountModule('windowsGroup')->getAttributes();
|
|
|
|
}
|
2012-04-07 16:40:34 +00:00
|
|
|
$gonAttributes = null;
|
|
|
|
if ($container->getAccountModule('groupOfNames') != null) {
|
|
|
|
$gonAttributes = $container->getAccountModule('groupOfNames')->getAttributes();
|
|
|
|
}
|
|
|
|
elseif ($container->getAccountModule('groupOfUniqueNames') != null) {
|
|
|
|
$gonAttributes = $container->getAccountModule('groupOfUniqueNames')->getAttributes();
|
2010-12-14 21:16:21 +00:00
|
|
|
}
|
2014-01-18 11:38:38 +00:00
|
|
|
elseif ($container->getAccountModule('organizationalRole') != null) {
|
|
|
|
$gonAttributes = $container->getAccountModule('organizationalRole')->getAttributes();
|
|
|
|
}
|
2010-12-14 21:16:21 +00:00
|
|
|
// check if a group name is set
|
|
|
|
if (isset($attributes['gid'][0])) {
|
|
|
|
return htmlspecialchars($attributes['gid'][0]);
|
|
|
|
}
|
|
|
|
// check if a common name is set
|
|
|
|
if (isset($attributes['cn'][0])) {
|
|
|
|
return htmlspecialchars($attributes['cn'][0]);
|
|
|
|
}
|
2012-04-07 16:40:34 +00:00
|
|
|
if (isset($gonAttributes['cn'][0])) {
|
|
|
|
return htmlspecialchars($gonAttributes['cn'][0]);
|
|
|
|
}
|
|
|
|
// new entry
|
|
|
|
if ($container->isNewAccount) {
|
|
|
|
return _("New group");
|
|
|
|
}
|
2010-12-14 21:16:21 +00:00
|
|
|
// fall back to default
|
2012-04-07 16:40:34 +00:00
|
|
|
return parent::getTitleBarTitle($container);
|
2010-12-14 21:16:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the the title text for the title bar on the new/edit page.
|
|
|
|
*
|
2012-04-07 16:40:34 +00:00
|
|
|
* @param accountContainer $container account container
|
2010-12-14 21:16:21 +00:00
|
|
|
* @return String title text
|
|
|
|
*/
|
2012-04-07 16:40:34 +00:00
|
|
|
public function getTitleBarSubtitle($container) {
|
|
|
|
// get attributes
|
|
|
|
$attributes = null;
|
|
|
|
if ($container->getAccountModule('posixGroup') != null) {
|
|
|
|
$attributes = $container->getAccountModule('posixGroup')->getAttributes();
|
|
|
|
}
|
|
|
|
elseif ($container->getAccountModule('rfc2307bisPosixGroup') != null) {
|
|
|
|
$attributes = $container->getAccountModule('rfc2307bisPosixGroup')->getAttributes();
|
2013-03-29 10:21:03 +00:00
|
|
|
}
|
|
|
|
elseif ($container->getAccountModule('windowsGroup') != null) {
|
|
|
|
$attributes = $container->getAccountModule('windowsGroup')->getAttributes();
|
2012-04-07 16:40:34 +00:00
|
|
|
}
|
|
|
|
$gonAttributes = null;
|
|
|
|
if ($container->getAccountModule('groupOfNames') != null) {
|
|
|
|
$gonAttributes = $container->getAccountModule('groupOfNames')->getAttributes();
|
|
|
|
}
|
|
|
|
elseif ($container->getAccountModule('groupOfUniqueNames') != null) {
|
|
|
|
$gonAttributes = $container->getAccountModule('groupOfUniqueNames')->getAttributes();
|
2010-12-14 21:16:21 +00:00
|
|
|
}
|
2014-01-18 11:38:38 +00:00
|
|
|
elseif ($container->getAccountModule('organizationalRole') != null) {
|
|
|
|
$gonAttributes = $container->getAccountModule('organizationalRole')->getAttributes();
|
|
|
|
}
|
2010-12-14 21:16:21 +00:00
|
|
|
// check if an description can be shown
|
2012-04-07 16:40:34 +00:00
|
|
|
if (($attributes != null) && isset($attributes['description'][0])) {
|
|
|
|
return htmlspecialchars($attributes['description'][0]);
|
2010-12-14 21:16:21 +00:00
|
|
|
}
|
2012-04-07 16:40:34 +00:00
|
|
|
if (($gonAttributes != null) && isset($gonAttributes['description'][0])) {
|
|
|
|
return htmlspecialchars($gonAttributes['description'][0]);
|
2010-12-14 21:16:21 +00:00
|
|
|
}
|
2012-04-07 16:40:34 +00:00
|
|
|
return null;
|
2010-12-14 21:16:21 +00:00
|
|
|
}
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates the list view.
|
|
|
|
*
|
|
|
|
* @package lists
|
|
|
|
* @author Roland Gruber
|
2016-11-14 18:37:39 +00:00
|
|
|
*
|
2006-01-01 16:30:05 +00:00
|
|
|
*/
|
|
|
|
class lamGroupList extends lamList {
|
|
|
|
|
2007-05-26 18:42:08 +00:00
|
|
|
/** Controls if include primary group members into group memebers */
|
2007-11-11 14:01:16 +00:00
|
|
|
private $use_primary = false;
|
2007-05-26 18:42:08 +00:00
|
|
|
/** Primary group members hash */
|
2007-10-13 17:28:37 +00:00
|
|
|
private $primary_hash = array();
|
2007-05-26 18:42:08 +00:00
|
|
|
/** Controls if primary group members needs refresh */
|
2007-10-13 17:28:37 +00:00
|
|
|
private $refresh_primary = false;
|
2007-11-11 14:01:16 +00:00
|
|
|
/** ID for config option */
|
|
|
|
const TRANS_PRIMARY_OPTION_NAME = "LG_TP";
|
2008-03-27 19:54:01 +00:00
|
|
|
/** specifies if primary group members are visible */
|
|
|
|
private $include_primary = false;
|
2014-01-18 09:56:29 +00:00
|
|
|
/** LDAP suffix of membership types */
|
|
|
|
private $suffixList = array();
|
2016-11-14 18:37:39 +00:00
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param string $type account type
|
|
|
|
* @return lamList list object
|
|
|
|
*/
|
2007-12-28 16:08:56 +00:00
|
|
|
function __construct($type) {
|
|
|
|
parent::__construct($type);
|
2006-01-01 16:30:05 +00:00
|
|
|
$this->labels = array(
|
2012-02-09 17:08:39 +00:00
|
|
|
'nav' => _("Group count: %s"),
|
2006-01-01 16:30:05 +00:00
|
|
|
'error_noneFound' => _("No groups found!"),
|
|
|
|
'newEntry' => _("New group"),
|
2012-02-05 19:03:25 +00:00
|
|
|
'deleteEntry' => _("Delete selected groups"));
|
2017-04-26 17:01:57 +00:00
|
|
|
$modules = $this->type->getModules();
|
2014-01-18 11:38:38 +00:00
|
|
|
if (in_array('organizationalRole', $modules)) {
|
|
|
|
$this->labels = array(
|
|
|
|
'nav' => _("Role count: %s"),
|
|
|
|
'error_noneFound' => _("No roles found!"),
|
|
|
|
'newEntry' => _("New role"),
|
|
|
|
'deleteEntry' => _("Delete selected roles"));
|
|
|
|
}
|
2014-01-18 09:56:29 +00:00
|
|
|
// build suffix list for account types
|
2017-03-16 18:44:01 +00:00
|
|
|
$typeManager = new TypeManager();
|
|
|
|
$scopes = array('user', 'gon', 'group');
|
|
|
|
$types = $typeManager->getConfiguredTypesForScopes($scopes);
|
2014-01-18 09:56:29 +00:00
|
|
|
foreach ($types as $type) {
|
2017-03-16 18:44:01 +00:00
|
|
|
$suffix = $type->getSuffix();
|
2014-01-18 09:56:29 +00:00
|
|
|
// stop if suffixes are not unique
|
|
|
|
if (isset($this->suffixList[$suffix])) {
|
|
|
|
$this->suffixList = array();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!empty($suffix)) {
|
2017-03-16 18:44:01 +00:00
|
|
|
$this->suffixList[$suffix] = $type->getId();
|
2014-01-18 09:56:29 +00:00
|
|
|
}
|
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2016-11-14 18:37:39 +00:00
|
|
|
|
2007-05-26 18:42:08 +00:00
|
|
|
/**
|
|
|
|
* Sets some internal parameters.
|
|
|
|
*/
|
|
|
|
function listGetParams() {
|
|
|
|
parent::listGetParams();
|
|
|
|
// generate list primary group memebers
|
|
|
|
// after parent::listGetParams is $this->refresh set to correct value
|
2007-11-11 14:01:16 +00:00
|
|
|
if ($this->include_primary && !$this->refresh && ($this->refresh_primary || (sizeof($this->primary_hash) == 0)))
|
2007-05-26 18:42:08 +00:00
|
|
|
$this->groupRefreshPrimary();
|
|
|
|
}
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
/**
|
2007-02-17 16:26:08 +00:00
|
|
|
* Prints the content of a cell in the account list for a given LDAP entry and attribute.
|
|
|
|
*
|
|
|
|
* @param array $entry LDAP attributes
|
|
|
|
* @param string $attribute attribute name
|
|
|
|
*/
|
|
|
|
function listPrintTableCellContent(&$entry, &$attribute) {
|
|
|
|
if ($attribute == "memberuid") {
|
2007-05-26 18:42:08 +00:00
|
|
|
// $gid is used for linking primary group memebers
|
|
|
|
$gid = -1;
|
|
|
|
$use_primary = false;
|
|
|
|
if ($this->include_primary == "on") {
|
|
|
|
// Get the gid number
|
|
|
|
if (isset($entry['gidnumber']) && is_array($entry['gidnumber'])) {
|
|
|
|
$gid = $entry['gidnumber'][0];
|
|
|
|
}
|
|
|
|
$use_primary = (($gid >= 0) && (sizeof($this->primary_hash) > 0) &&
|
|
|
|
isset($this->primary_hash[$gid]) && is_array($this->primary_hash[$gid]) &&
|
|
|
|
(sizeof($this->primary_hash[$gid]) > 0));
|
|
|
|
}
|
2009-12-19 16:07:10 +00:00
|
|
|
if (!$use_primary) {
|
2007-05-26 18:42:08 +00:00
|
|
|
if (!isset($entry[$attribute]) || !is_array($entry[$attribute]) || (sizeof($entry[$attribute]) < 1)) return;
|
|
|
|
// sort array
|
|
|
|
sort($entry[$attribute]);
|
|
|
|
}
|
2007-02-17 16:26:08 +00:00
|
|
|
// make a link for each member of the group
|
|
|
|
$linklist = array();
|
2007-05-26 18:42:08 +00:00
|
|
|
if ($use_primary) {
|
|
|
|
$primary_hash = $this->primary_hash[$gid];
|
|
|
|
// merge primary members into secondary ones
|
|
|
|
$primaryvals = array_flip(array_values($primary_hash));
|
|
|
|
// test if group has some secondary members
|
|
|
|
if (isset($entry[$attribute])) {
|
|
|
|
$attr = array_merge($primary_hash,$entry[$attribute]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$attr = $primary_hash;
|
|
|
|
}
|
|
|
|
// sort array
|
|
|
|
sort($attr);
|
|
|
|
|
|
|
|
// make a link for each member of the group
|
|
|
|
for ($d = 0; $d < sizeof($attr); $d++) {
|
|
|
|
$user = $attr[$d]; // user name
|
2013-01-01 20:46:28 +00:00
|
|
|
if (isAccountTypeHidden('user')) {
|
|
|
|
$linklist[$d] = $user;
|
|
|
|
}
|
|
|
|
elseif (isset($primaryvals[$user])) {
|
2007-05-26 18:42:08 +00:00
|
|
|
$linklist[$d] = "<b><a href=\"userlink.php?user='" . $user . "' \">" . $user . "</a></b>";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$linklist[$d] = "<a href=\"userlink.php?user='" . $user . "' \">" . $user . "</a>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// make a link for each member of the group
|
|
|
|
for ($d = 0; $d < sizeof($entry[$attribute]); $d++) {
|
|
|
|
$user = $entry[$attribute][$d]; // user name
|
2013-01-01 20:46:28 +00:00
|
|
|
if (!isAccountTypeHidden('user')) {
|
|
|
|
$linklist[$d] = "<a href=\"userlink.php?user='" . $user . "' \">" . $user . "</a>";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$linklist[$d] = $user;
|
|
|
|
}
|
2007-05-26 18:42:08 +00:00
|
|
|
}
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
2007-02-17 16:26:08 +00:00
|
|
|
echo implode("; ", $linklist);
|
|
|
|
}
|
2014-01-18 09:56:29 +00:00
|
|
|
// pretty print member DNs
|
2014-03-08 09:13:21 +00:00
|
|
|
elseif (in_array_ignore_case($attribute, array('member', 'uniqueMember', 'owner', 'roleOccupant')) && !empty($entry[$attribute])) {
|
2014-01-18 09:56:29 +00:00
|
|
|
echo '<div class="rightToLeftText">';
|
|
|
|
$values = $entry[$attribute];
|
|
|
|
if (!empty($values)) {
|
|
|
|
usort($values, 'compareDN');
|
|
|
|
}
|
|
|
|
$count = sizeof($values);
|
|
|
|
for ($i = 0; $i < $count; $i++) {
|
|
|
|
$replaced = false;
|
|
|
|
foreach ($this->suffixList as $suffix => $type) {
|
|
|
|
if (stripos($values[$i], $suffix) > 0) {
|
|
|
|
if (!isAccountTypeHidden($type)) {
|
|
|
|
$values[$i] = '<a href="../account/edit.php?type=' . $type . '&DN=\'' . $values[$i] . '\'">' . getAbstractDN($values[$i]) . '</a>';
|
|
|
|
$replaced = true;
|
2014-06-02 20:57:43 +00:00
|
|
|
break;
|
2014-01-18 09:56:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!$replaced) {
|
|
|
|
$values[$i] = getAbstractDN($values[$i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo implode('<br>', $values);
|
|
|
|
echo '</div>';
|
|
|
|
}
|
2007-02-17 16:26:08 +00:00
|
|
|
// print all other attributes
|
|
|
|
else {
|
|
|
|
parent::listPrintTableCellContent($entry, $attribute);
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
}
|
2007-02-17 16:26:08 +00:00
|
|
|
|
2007-05-26 18:42:08 +00:00
|
|
|
/**
|
|
|
|
* Rereads the entries from LDAP.
|
|
|
|
*/
|
|
|
|
function listRefreshData() {
|
|
|
|
parent::listRefreshData();
|
2007-11-11 14:01:16 +00:00
|
|
|
if ($this->include_primary) {
|
2007-05-26 18:42:08 +00:00
|
|
|
$this->groupRefreshPrimary();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Refreshes the primary group members list.
|
|
|
|
*/
|
|
|
|
function groupRefreshPrimary() {
|
|
|
|
$this->refresh_primary = false;
|
|
|
|
// return unless some entries
|
|
|
|
if (sizeof($this->entries) <= 0) return;
|
|
|
|
|
|
|
|
$scope = "user";
|
|
|
|
// configure search filter
|
|
|
|
$module_filter = get_ldap_filter($scope); // basic filter is provided by modules
|
|
|
|
$attrs = array( "uid" );
|
|
|
|
for ($i = 0; $i < sizeof($this->entries); $i++) {
|
2014-11-29 17:40:39 +00:00
|
|
|
if (empty($this->entries[$i]['gidnumber'][0])) {
|
|
|
|
continue;
|
|
|
|
}
|
2007-05-26 18:42:08 +00:00
|
|
|
$gid = $this->entries[$i]['gidnumber'][0];
|
|
|
|
$filter = "(&(&" . $module_filter . ")(gidNumber=" . $gid . "))";
|
2010-02-06 11:52:48 +00:00
|
|
|
$entries = searchLDAPByFilter($filter, $attrs, array($scope));
|
|
|
|
for ($j = 0; $j < sizeof($entries); $j++) {
|
|
|
|
$this->primary_hash[$gid][$j] = $entries[$j]['uid'][0];
|
2007-05-26 18:42:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-11-11 14:01:16 +00:00
|
|
|
* Returns a list of possible configuration options.
|
|
|
|
*
|
|
|
|
* @return array list of lamListOption objects
|
2007-05-26 18:42:08 +00:00
|
|
|
*/
|
2007-11-11 14:01:16 +00:00
|
|
|
protected function listGetAllConfigOptions() {
|
2007-12-09 10:45:04 +00:00
|
|
|
$options = parent::listGetAllConfigOptions();
|
|
|
|
$options[] = new lamBooleanListOption(_('Show primary group members as normal group members'), self::TRANS_PRIMARY_OPTION_NAME);
|
|
|
|
return $options;
|
2007-05-26 18:42:08 +00:00
|
|
|
}
|
2007-11-11 14:01:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the configuration options changed.
|
|
|
|
*/
|
|
|
|
protected function listConfigurationChanged() {
|
2007-12-09 10:45:04 +00:00
|
|
|
parent::listConfigurationChanged();
|
2007-11-11 14:01:16 +00:00
|
|
|
$tpOption = $this->listGetConfigOptionByID(self::TRANS_PRIMARY_OPTION_NAME);
|
|
|
|
$use_primary = $this->include_primary;
|
|
|
|
$this->include_primary = $tpOption->isSelected();
|
|
|
|
if (!$use_primary && $this->include_primary) {
|
|
|
|
$this->refresh_primary = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-01 16:30:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|