index 29e8840407e5939715e251d16936ae9336ba17c0..e33b2ec613feebaad84cdcd40bb6e3b1060ac42f 100644 (file)
var $acl_base= "";
var $acl_category= "";
var $acl_base= "";
var $acl_category= "";
- /* Plugin identifier */
- var $plHeadline= "";
- var $plDescription= "";
-
/* This can be set to render the tabulators in another stylesheet */
var $pl_notify= FALSE;
/* This can be set to render the tabulators in another stylesheet */
var $pl_notify= FALSE;
unset($this->saved_attributes[$index]);
continue;
}
unset($this->saved_attributes[$index]);
continue;
}
- if ($this->saved_attributes[$index]["count"] == 1){
+ if (isset($this->saved_attributes[$index][0]) || $this->saved_attributes[$index]["count"] == 1){
$tmp= $this->saved_attributes[$index][0];
unset($this->saved_attributes[$index]);
$this->saved_attributes[$index]= $tmp;
$tmp= $this->saved_attributes[$index][0];
unset($this->saved_attributes[$index]);
$this->saved_attributes[$index]= $tmp;
$data = "";
}
$this->$val= $data;
$data = "";
}
$this->$val= $data;
- //echo "<font color='blue'>".$val."</font><br>";
- }else{
- //echo "<font color='red'>".$val."</font><br>";
}
}
}
}
}
}
}
}
}
}
+ /* Handle tagging */
+ $this->tag_attrs(&$this->attrs);
}
}
{
/* Rename dn in possible object groups */
$ldap= $this->config->get_ldap_link();
{
/* Rename dn in possible object groups */
$ldap= $this->config->get_ldap_link();
- $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.@LDAP::preapre4filter($src_dn).'))',
+ $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.@LDAP::prepare4filter($src_dn).'))',
array('cn'));
while ($attrs= $ldap->fetch()){
$og= new ogroup($this->config, $ldap->getDN());
array('cn'));
while ($attrs= $ldap->fetch()){
$og= new ogroup($this->config, $ldap->getDN());
function move($src_dn, $dst_dn)
{
function move($src_dn, $dst_dn)
{
+ /* Do not copy if only upper- lowercase has changed */
+ if(strtolower($src_dn) == strtolower($dst_dn)){
+ return(TRUE);
+ }
+
/* Copy source to destination */
if (!$this->copy($src_dn, $dst_dn)){
return (FALSE);
/* Copy source to destination */
if (!$this->copy($src_dn, $dst_dn)){
return (FALSE);
$tmp = $source[$var][$i];
}
$this->$var = $tmp;
$tmp = $source[$var][$i];
}
$this->$var = $tmp;
-# echo $var."=".$tmp."<br>";
}else{
$this->$var = $source[$var][0];
}else{
$this->$var = $source[$var][0];
-# echo $var."=".$source[$var][0]."<br>";
}
}else{
$this->$var= $source[$var];
}
}else{
$this->$var= $source[$var];
-# echo $var."=".$source[$var]."<br>";
}
}
}
}
}
}
}
}
-
- function handle_object_tagging($dn= "", $tag= "", $show= false)
+ function tag_attrs($at, $dn= "", $tag= "", $show= false)
{
{
- //FIXME: How to optimize this? We have at least two
- // LDAP accesses per object. It would be a good
- // idea to have it integrated.
-
/* No dn? Self-operation... */
if ($dn == ""){
$dn= $this->dn;
/* No dn? Self-operation... */
if ($dn == ""){
$dn= $this->dn;
}
}
}
}
+ /* Remove tags that may already be here... */
+ remove_objectClass("gosaAdministrativeUnitTag", &$at);
+ if (isset($at['gosaUnitTag'])){
+ unset($at['gosaUnitTag']);
+ }
/* Set tag? */
if ($tag != ""){
/* Set tag? */
if ($tag != ""){
- /* Set objectclass and attribute */
- $ldap= $this->config->get_ldap_link();
- $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
- $attrs= $ldap->fetch();
- if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
- if ($show) {
- echo sprintf(_("Object '%s' is already tagged"), @LDAP::fix($dn))."<br>";
- flush();
- }
- return;
- }
- if (count($attrs)){
- if ($show){
- echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."<br>";
- flush();
- }
- $nattrs= array("gosaUnitTag" => $tag);
- $nattrs['objectClass']= array();
- for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
- $oc= $attrs['objectClass'][$i];
- if ($oc != "gosaAdministrativeUnitTag"){
- $nattrs['objectClass'][]= $oc;
- }
- }
- $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
- $ldap->cd($dn);
- $ldap->modify($nattrs);
- show_ldap_error($ldap->get_error(), sprintf(_("Handle object tagging with dn '%s' failed."),$dn));
- } else {
- @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
- }
-
- } else {
- /* Remove objectclass and attribute */
- $ldap= $this->config->get_ldap_link();
- $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
- $attrs= $ldap->fetch();
- if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
- @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
- return;
- }
- if (count($attrs)){
- if ($show){
- echo sprintf(_("Removing tag from object '%s'"), @LDAP::fix($dn))."<br>";
- flush();
- }
- $nattrs= array("gosaUnitTag" => array());
- $nattrs['objectClass']= array();
- for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
- $oc= $attrs['objectClass'][$i];
- if ($oc != "gosaAdministrativeUnitTag"){
- $nattrs['objectClass'][]= $oc;
- }
- }
- $ldap->cd($dn);
- $ldap->modify($nattrs);
- show_ldap_error($ldap->get_error(), sprintf(_("Handle object tagging with dn '%s' failed."),$dn));
- } else {
- @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
- }
+ add_objectClass("gosaAdministrativeUnitTag", &$at);
+ $at['gosaUnitTag']= $tag;
}
}
-
}
}
if(isset($this->base) && isset($this->config->idepartments[$this->base])){
$deps[$this->base] = $this->config->idepartments[$this->base];
}else{
if(isset($this->base) && isset($this->config->idepartments[$this->base])){
$deps[$this->base] = $this->config->idepartments[$this->base];
}else{
- echo "No default base found. ".$this->base."<br> ";
+ trigger_error("No default base found in class ".get_class($this).". ".$this->base);
}
}
-
return($deps);
}
return($deps);
}
+
/* This function modifies object acls too, if an object is moved.
* $old_dn specifies the actually used dn
* $new_dn specifies the destiantion dn
/* This function modifies object acls too, if an object is moved.
* $old_dn specifies the actually used dn
* $new_dn specifies the destiantion dn
/* Acls for this object must be adjusted */
if($found){
/* Acls for this object must be adjusted */
if($found){
- if($output_changes){
- echo "<font color='green'>".
- _("Changing ACL dn")." : <br> -"._("from")." <b> ".
- $old_dn.
- "</b><br> -"._("to")." <b>".
- $new_dn.
- "</b></font><br>";
- }
+ $debug_info= _("Changing ACL dn")." : <br> -"._("from")." <b> ".
+ $old_dn."</b><br> -"._("to")." <b>".$new_dn."</b><br>";
+ @DEBUG (DEBUG_ACL, __LINE__, __FUNCTION__, __FILE__,$debug_info,"ACL");
+
$update[$attrs['dn']] =array();
foreach($acls as $acl){
$update[$attrs['dn']]['gosaAclEntry'][] = $acl;
$update[$attrs['dn']] =array();
foreach($acls as $acl){
$update[$attrs['dn']]['gosaAclEntry'][] = $acl;