diff --git a/plugins/admin/groups/class_groupGeneric.inc b/plugins/admin/groups/class_groupGeneric.inc
index 2dde3c6ecc37f415ea89c2f9f8e90565186d3386..de07e7d4c1c6487f3bdcf5881e3cb329c23a9a0f 100644 (file)
var $saved_gidNumber= "";
var $oldgroupType= "";
var $orig_dn= "";
+ var $orig_cn= "";
var $has_mailAccount= FALSE;
var $group_dialog= FALSE;
var $nagios_group =FALSE;
+ var $sambaGroupType;
+ var $dialog;
+ var $OnlyShowFirstEntries =200;
+
+ var $allowGroupsWithSameNameInOtherSubtrees = true;
/* attribute list for save action */
- var $attributes= array("cn", "description", "gidNumber");
+ var $attributes= array("cn", "description", "gidNumber","memberUid","sambaGroupType","sambaSID");
var $objectclasses= array("top", "posixGroup");
function group ($config, $dn= NULL)
/* Load attributes depending on the samba version */
$this->samba3= ($config->current['SAMBAVERSION'] == 3);
$this->orig_dn= $dn;
+ $this->orig_cn= $this->cn;
/* Get member list */
if (isset($this->attrs['memberUid'][0])){
}
$gufilter= get_global('gufilter');
+ $gufilter['SubSearchGroup'] = false;
+ $gufilter['dselect'] = $_SESSION['groupfilter']['depselect'];
+
+ register_global('gufilter',$gufilter);
+
/* Bases / Departments */
if(isset($_SESSION['groupfilter']['depselect'])){
$this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn);
}
}
-
+
/* This is always an account */
$this->is_account= TRUE;
$this->reload();
}
- /* Assign templating stuff */
+ /* Base select dialog */
+ $once = true;
+ foreach($_POST as $name => $value){
+ if(preg_match("/^chooseBase/",$name) && $once){
+ $once = false;
+ $this->dialog = new baseSelectDialog($this->config);
+ $this->dialog->setCurrentBase($this->base);
+ }
+ }
+
+ /* Dialog handling */
+ if(is_object($this->dialog)){
+ /* Must be called before save_object */
+ $this->dialog->save_object();
+
+ if($this->dialog->isClosed()){
+ $this->dialog = false;
+ }elseif($this->dialog->isSelected()){
+ $this->base = $this->dialog->isSelected();
+ $this->dialog= false;
+ }else{
+ return($this->dialog->execute());
+ }
+ }
+
+ /* Assign templating stuff */
$smarty= get_smarty();
if ($this->samba3){
$smarty->assign("samba3", "true");
$gufilter[$type]= $_POST[$type];
}
}
+ if(isset($_POST['regex'])){
+ if(isset($_POST['SubSearchGroup'])){
+ $gufilter['SubSearchGroup'] = true;
+ }else{
+ $gufilter['SubSearchGroup'] = false;
+ }
+ }
+
if (isset($_GET['search'])){
$s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
if ($s == "**"){
$smarty->assign("tree_image", get_template_path('images/tree.png'));
$smarty->assign("deplist", $this->config->idepartments);
$smarty->assign("alphabet", generate_alphabet());
- foreach( array("dselect", "regex") as $type){
+ foreach( array("dselect", "regex","SubSearchGroup") as $type){
$smarty->assign("$type", $gufilter[$type]);
}
$smarty->assign("hint", print_sizelimit_warning());
$this->last_sorting= "invalid";
$this->users= array();
$ldap= $this->config->get_ldap_link();
- $gufilter= get_global("gufilter");
- $ldap->cd ($gufilter['dselect']);
- $ldap->ls ("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(!(uid=*$)))",get_people_ou().$gufilter['dselect'],array("uid", "sn", "givenName"));
+ $MaxUser = $this->OnlyShowFirstEntries;
+
+ $gufilter= get_global("gufilter");
+ $ldap->cd ($this->config->current['BASE']);
+ if($gufilter['SubSearchGroup']){
+ $ldap->cd ($gufilter['dselect']);
+ $ldap->search("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(!(uid=*$)))",array("uid", "sn","givenName"));
+ }else{
+ $ldap->cd (get_people_ou().$gufilter['dselect']);
+ $ldap->ls ("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(!(uid=*$)))",get_people_ou().$gufilter['dselect'],array("uid", "sn", "givenName"));
+ }
$this->allusers= array();
- while ($attrs= $ldap->fetch()){
+
+ $i = 0 ;
+ while (($attrs= $ldap->fetch()) && ($i < $MaxUser)){
+ $i ++;
if (isset($attrs["givenName"][0]) && isset($attrs["sn"][0])){
$this->allusers[$attrs["uid"][0]]= $attrs["sn"][0].", ".
- $attrs["givenName"][0].
- " [".$attrs["uid"][0]."]";
+ $attrs["givenName"][0]." [".$attrs["uid"][0]."]";
} else {
$this->allusers[$attrs["uid"][0]]= $attrs['uid'][0];
}
}
+
+ if(($i == $MaxUser)){
+ print_red(sprintf(_("Your search method returned more than '%s' users, only '%s' users are shown.") , $MaxUser,$MaxUser));
+ }
+
natcasesort ($this->allusers);
reset ($this->allusers);
if (isset($this->allusers[$value])){
$this->members[$value]= $this->allusers[$value];
} else {
- $this->members[$value]= "[$value]";
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(objectClass=gosaAccount)(uid=".$value."))",array("uid", "sn","givenName"));
+ $attrs = $ldap->fetch();
+
+ if(!$attrs){
+ $this->members[$value] = _("! unknown id")." [".$value."]";
+ }else{
+
+ if (isset($attrs["givenName"][0]) && isset($attrs["sn"][0])){
+ $this->allusers[$attrs["uid"][0]]= $attrs["sn"][0].", ".
+ $attrs["givenName"][0]." [".$attrs["uid"][0]."]";
+ } else {
+ $this->allusers[$attrs["uid"][0]]= $attrs['uid'][0];
+ }
+ if (isset($this->allusers[$value])){
+ $this->members[$value]= $this->allusers[$value];
+ } else {
+ $this->members[$value] = "[".$value."]";
+ }
+ }
}
}
asort($this->members);
{
/* Save additional values for possible next step */
if (isset($_POST['groupedit'])){
+
+
plugin::save_object();
$this->force_gid= 0;
/* Add samba group functionality */
if ($this->samba3 && $this->smbgroup){
- $this->SID= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'];
- $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'];
+
+ /* Fixed undefined index ...
+ */
+ $this->SID = $this->ridBase = "";
+ if(isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'])){
+ $this->SID = $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'];
+ }else{
+ print_red(sprintf(_("No configured SID found for '%s'."),$this->sambaDomainName));
+ }
+ if(isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'])){
+ $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'];
+ }else{
+ print_red(sprintf(_("No configured RIDBASE found for '%s'."),$this->sambaDomainName));
+ }
$this->attrs['objectClass'][]= 'sambaGroupMapping';
$this->attrs['sambaGroupType']= "2";
/* Write back to ldap */
$ldap->cd($this->dn);
+ $this->cleanup();
$ldap->$mode($this->attrs);
$ret= 0;
$message[]= _("The field 'Name' contains invalid characters. Lowercase, numbers and dashes are allowed.");
}
- /* Check for used 'cn' */
- $ldap= $this->config->get_ldap_link();
- $ldap->cd($this->config->current['BASE']);
- $ldap->search("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",array("cn"));
- if ($ldap->count() != 0){
- /* New entry? */
- if ($this->dn == 'new'){
- $message[]= _("Value specified as 'Name' is already used.");
+ if($this->allowGroupsWithSameNameInOtherSubtrees == true){
+
+ /* Check for used 'cn' */
+ $ldap= $this->config->get_ldap_link();
+ if(($this->cn != $this->orig_cn) || ($this->orig_dn == "new")){
+ $ldap->cd("ou=groups,".$this->base);
+ $ldap->ls("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))","ou=groups,".$this->base,array("cn"));
+ if ($ldap->count() != 0){
+ $message[]= _("Value specified as 'Name' is already used.");
+ }
}
-
- /* Moved? */
- elseif ($new_dn != $this->orig_dn){
- $ldap->fetch();
- if ($ldap->getDN() != $this->orig_dn){
+
+ }else{
+
+ /* Check for used 'cn' */
+ $ldap= $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+ $ldap->search("(&(|(objectClass=gosaGroupOfNames)(objectClass=posixGroup))(cn=$this->cn))",array("cn"));
+ if ($ldap->count() != 0){
+
+ /* New entry? */
+ if ($this->dn == 'new'){
$message[]= _("Value specified as 'Name' is already used.");
}
+
+ /* Moved? */
+ elseif ($new_dn != $this->orig_dn){
+ $ldap->fetch();
+ if ($ldap->getDN() != $this->orig_dn){
+ $message[]= _("Value specified as 'Name' is already used.");
+ }
+ }
}
}
-
+
/* Check ID */
if ($this->force_gid == "1"){
if (!is_id($this->gidNumber)){
}
}
+ function getCopyDialog()
+ {
+ $vars = array("cn");
+
+ if($this ->force_gid){
+ $used = " checked ";
+ $dis = "";
+ }else{
+ $used = "";
+ $dis = " disabled ";
+ }
+
+ $smarty = get_smarty();
+ $smarty->assign("used",$used);
+ $smarty->assign("dis" ,$dis);
+ $smarty->assign("cn" ,$this->cn);
+ $smarty->assign("gidNumber",$this->gidNumber);
+ return($smarty->fetch(get_template_path("paste_generic.tpl",TRUE)));
+ }
+
+ function saveCopyDialog()
+ {
+ if(isset($_POST['cn'])){
+ $this->cn = $_POST['cn'];
+ }
+ if(isset($_POST['force_gid'])){
+ $this->force_gid = 1;
+ $this->gidNumber= $_POST['gidNumber'];
+ }else{
+ $this->force_gid = 0;
+ $this->gidNumber = false;
+ }
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: