From c4ba9d8db4284aca678ecbc4f4e9b7f1c8a22a2c Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 28 Apr 2006 13:38:16 +0000 Subject: [PATCH] * Fixes for department handling and comma characters * Includes debugging output, currently * Needs schema update git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3168 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../departments/class_departmentGeneric.inc | 65 ++++++++++++++++--- plugins/admin/departments/generic.tpl | 2 +- plugins/admin/departments/tabs_department.inc | 3 +- 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc index 97bc429ef..d1689a4f2 100644 --- a/plugins/admin/departments/class_departmentGeneric.inc +++ b/plugins/admin/departments/class_departmentGeneric.inc @@ -44,7 +44,7 @@ class department extends plugin /* attribute list for save action */ var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress", - "telephoneNumber", "facsimileTelephoneNumber"); + "telephoneNumber", "facsimileTelephoneNumber", "gosaUnitTag"); var $objectclasses= array("top", "gosaDepartment", "organizationalUnit"); function department ($config, $dn) @@ -75,7 +75,7 @@ class department extends plugin $this->acl= get_module_permission($acl, "department", $ui->dn); /* Is administrational Unit? */ - if ($dn != "new" && in_array_ics('gosaAdministrationalUnit', $this->attrs['objectClass'])){ + if ($dn != "new" && in_array_ics('gosaAdministrativeUnit', $this->attrs['objectClass'])){ $this->is_administrational_unit= true; } } @@ -245,16 +245,51 @@ class department extends plugin /* Save to LDAP */ function save() { + $ldap= $this->config->get_ldap_link(); + /* Add tag objects if needed */ if ($this->is_administrational_unit){ - $this->objectclasses[]= "gosaAdministrationalUnit"; - $this->attributes[]= "gosaUnitTag"; - } else { - plugin::handle_object_tagging(); + $this->objectclasses[]= "gosaAdministrativeUnit"; + if ($this->gosaUnitTag == ""){ + + /* It's unlikely, but check if already used... */ + $try= 5; + $ldap->cd($this->config->current['BASE']); + while ($try--){ + + /* Generate microtime stamp as tag */ + list($usec, $sec)= explode(" ", microtime()); + $time_stamp= preg_replace("/\./", "", $sec.$usec); + + $ldap->search("(&(objectClass=gosaAdministrativeUnit)(gosaUnitTag=$time_stamp))",array("gosaUnitTag")); + if ($ldap->count() == 0){ + break; + } + } + if($try == 0) { + print_red(_("Fatal error: Can't find an unused tag to mark the administrative unit!")); + return; + } + $this->gosaUnitTag= preg_replace("/\./", "", $sec.$usec); + } } plugin::save(); + /* Remove tag information if needed */ + if (!$this->is_administrational_unit){ + $tmp= array(); + + /* Remove gosaAdministrativeUnit from this plugin */ + foreach($this->attrs['objectClass'] as $oc){ + if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){ + $tmp[]= $oc; + } + } + $this->attrs['objectClass']= $tmp; + $this->attrs['gosaUnitTag']= array(); + } + /* Write back to ldap */ $ldap= $this->config->get_ldap_link(); $ldap->cat($this->dn); @@ -283,16 +318,26 @@ class department extends plugin } - /* Tag objects to have the gosaAdministrationalUnitTag */ + /* Tag objects to have the gosaAdministrativeUnitTag */ function tag_objects() { - echo "Tag"; + echo "
Performing Tag:";
+		$ldap= $this->config->get_ldap_link();
+		$ldap->cd($this->dn);
+		$ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
+				$this->gosaUnitTag.')))', array('dn'));
+		while ($attrs= $ldap->fetch()){
+			//FIXME: check if this is below another administrative
+			//       unit
+			echo "Fix: ".$attrs['dn']."\n";
+		}
+		echo "
"; } - /* Remove the gosaAdministrationalUnitTag from objects */ + /* Remove the gosaAdministrativeUnitTag from objects */ function untag_objects() { - echo "Untag"; + echo "Performing Untag:"; } /* Move/Rename complete trees */ diff --git a/plugins/admin/departments/generic.tpl b/plugins/admin/departments/generic.tpl index 620c971dd..45392db44 100644 --- a/plugins/admin/departments/generic.tpl +++ b/plugins/admin/departments/generic.tpl @@ -74,7 +74,7 @@ diff --git a/plugins/admin/departments/tabs_department.inc b/plugins/admin/departments/tabs_department.inc index 4e8e318af..fb93bcf4b 100644 --- a/plugins/admin/departments/tabs_department.inc +++ b/plugins/admin/departments/tabs_department.inc @@ -20,7 +20,8 @@ class deptabs extends tabs { if(!$justsave){ $baseobject= $this->by_object['department']; - $new_dn= 'ou='.preg_replace('/,/', '\\\\2C', $baseobject->ou).','.$baseobject->base; + $ou= preg_replace('/,/', '\,', $baseobject->ou); + $new_dn= @LDAP::convert('ou='.$ou.','.$baseobject->base); $disp =""; if ($this->dn != $new_dn && $this->dn != "new"){ -- 2.30.2
-

{t}Administrational settings{/t}

+

{t}Administrative settings{/t}