diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc
index d1689a4f2104f9589dc805e34d1a9944ec4d2748..9aecbccdff2cb3d39578dc59596a449b74e37625 100644 (file)
var $last_dep_sorting= "invalid";
var $departments= array();
var $last_dep_sorting= "invalid";
var $departments= array();
+ var $must_be_tagged = false;
+
/* attribute list for save action */
var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress",
"telephoneNumber", "facsimileTelephoneNumber", "gosaUnitTag");
/* attribute list for save action */
var $attributes= array("ou", "description", "businessCategory", "st", "l", "postalAddress",
"telephoneNumber", "facsimileTelephoneNumber", "gosaUnitTag");
$smarty->assign("$val", $this->$val);
$smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
}
$smarty->assign("$val", $this->$val);
$smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
}
+ $smarty->assign("baseACL", chkacl($this->acl,"base"));
$smarty->assign("base_select", $this->base);
/* Set admin unit flag */
$smarty->assign("base_select", $this->base);
/* Set admin unit flag */
$smarty->assign("unitTag", "");
}
$smarty->assign("unitTag"."ACL", chkacl($this->acl, "unitTag"));
$smarty->assign("unitTag", "");
}
$smarty->assign("unitTag"."ACL", chkacl($this->acl, "unitTag"));
-
+
return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
}
return($smarty->fetch (get_template_path('generic.tpl', TRUE)));
}
}
}
}
}
-
function remove_from_parent()
{
$ldap= $this->config->get_ldap_link();
$ldap->cd ($this->dn);
$ldap->recursive_remove();
function remove_from_parent()
{
$ldap= $this->config->get_ldap_link();
$ldap->cd ($this->dn);
$ldap->recursive_remove();
+ show_ldap_error($ldap->get_error(), _("Removing department failed"));
/* Optionally execute a command after we're done */
$this->handle_post_events('remove');
}
/* Optionally execute a command after we're done */
$this->handle_post_events('remove');
}
+ function must_be_tagged()
+ {
+ return $this->must_be_tagged;
+ }
+
+ function am_i_moved()
+ {
+ return $this->rec_cpy;
+ }
+
/* Save data to object */
function save_object()
/* Save data to object */
function save_object()
$message= plugin::check();
/* Permissions for that base? */
$message= plugin::check();
/* Permissions for that base? */
- // $this->dn= "ou=$this->ou,".$this->base;
if (chkacl($this->acl, "create") != ""){
$message[]= _("You have no permissions to create a department on this 'Base'.");
}
/* Check for presence of this department */
$ldap= $this->config->get_ldap_link();
if (chkacl($this->acl, "create") != ""){
$message[]= _("You have no permissions to create a department on this 'Base'.");
}
/* Check for presence of this department */
$ldap= $this->config->get_ldap_link();
- $attrs= $ldap->cat ($this->dn);
- if ($this->orig_dn == "new" && !($attrs === FALSE)){
+ $ldap->ls ("(&(ou=".$this->ou.")(objectClass=organizationalUnit))", $this->base, array('dn'));
+ if ($this->orig_dn == "new" && $ldap->count()){
$message[]= _("Department with that 'Name' already exists.");
} elseif ($this->orig_dn != $this->dn && !($attrs === FALSE)){
$message[]= _("Department with that 'Name' already exists.");
$message[]= _("Department with that 'Name' already exists.");
} elseif ($this->orig_dn != $this->dn && !($attrs === FALSE)){
$message[]= _("Department with that 'Name' already exists.");
$message[]= _("Required field 'Description' is not set.");
}
$message[]= _("Required field 'Description' is not set.");
}
- /* Validate and modify - or: spaghetti rules! */
- if ($this->ou == "incoming"){
- $message[]= _("The field 'Name' contains the reserved word 'incoming'.".
- " Please choose another name.");
- }
- if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
+ if(is_department_name_reserved($this->ou,$this->base)){
+ $message[]= sprintf(_("The field 'Name' contains the reserved word '%s'. Please choose another name."),$this->ou);
+ }
+
+ if (preg_match ('/["+>\\\\]/', $this->ou)){
$message[]= _("The field 'Name' contains invalid characters.");
}
if (!is_phone_nr($this->telephoneNumber)){
$message[]= _("The field 'Name' contains invalid characters.");
}
if (!is_phone_nr($this->telephoneNumber)){
/* Add tag objects if needed */
if ($this->is_administrational_unit){
/* Add tag objects if needed */
if ($this->is_administrational_unit){
- $this->objectclasses[]= "gosaAdministrativeUnit";
+ if(!in_array_ics("gosaAdministrativeUnit",$this->objectclasses)){
+ $this->objectclasses[]= "gosaAdministrativeUnit";
+ $this->gosaUnitTag= "";
+ }
+
if ($this->gosaUnitTag == ""){
/* It's unlikely, but check if already used... */
if ($this->gosaUnitTag == ""){
/* It's unlikely, but check if already used... */
$tmp= array();
/* Remove gosaAdministrativeUnit from this plugin */
$tmp= array();
/* Remove gosaAdministrativeUnit from this plugin */
+ $has_unit_tag= false;
foreach($this->attrs['objectClass'] as $oc){
if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
$tmp[]= $oc;
}
foreach($this->attrs['objectClass'] as $oc){
if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
$tmp[]= $oc;
}
+ if (preg_match("/^gosaAdministrativeUnitTag$/i", $oc)){
+ $has_unit_tag= true;
+ }
}
$this->attrs['objectClass']= $tmp;
}
$this->attrs['objectClass']= $tmp;
- $this->attrs['gosaUnitTag']= array();
+
+ if(!$has_unit_tag && isset($this->attrs['gosaUnitTag'])){
+ $this->attrs['gosaUnitTag']= array();
+ }
}
}
-
+
/* Write back to ldap */
$ldap= $this->config->get_ldap_link();
/* Write back to ldap */
$ldap= $this->config->get_ldap_link();
- $ldap->cat($this->dn);
+ $ldap->cat($this->dn, array('dn'));
$a= $ldap->fetch();
$ldap->cd($this->dn);
$a= $ldap->fetch();
$ldap->cd($this->dn);
-
+
if (count($a)){
$this->cleanup();
$ldap->modify ($this->attrs);
if (count($a)){
$this->cleanup();
$ldap->modify ($this->attrs);
$ldap->add($this->attrs);
$this->handle_post_events('add');
}
$ldap->add($this->attrs);
$this->handle_post_events('add');
}
- show_ldap_error($ldap->get_error());
-
- if ($this->is_administrational_unit){
- $this->tag_objects();
- } else {
- $this->untag_objects();
- }
-
- /* Optionally execute a command after we're done */
+ show_ldap_error($ldap->get_error(), _("Saving department failed"));
+
+ /* The parameter forces only to set must_be_tagged, and don't touch any objects
+ This will be done later */
+ $this->tag_objects(true);
+
+ /* Fix tagging if needed */
+ if (!$this->is_administrational_unit){
+ $this->handle_object_tagging();
+ }
+
+ /* Optionally execute a command after we're done */
$this->postcreate();
$this->postcreate();
+ return(true);
}
}
+ function ShowMoveFrame()
+ {
+ $smarty = get_smarty();
+ $smarty->assign("src","?plug=".$_GET['plug']."&PerformRecMove");
+ $smarty->assign("message","As soon as the move operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog.");
+ $display= $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE));
+ return($display);
+ }
+
+ function ShowTagFrame()
+ {
+ $smarty = get_smarty();
+ $smarty->assign("src","?plug=".$_GET['plug']."&TagDepartment");
+ $smarty->assign("message","As soon as the tag operation has finished, you can scroll down to end of the page and press the 'Continue' button to continue with the department management dialog.");
+ $display= $smarty->fetch(get_template_path("dep_iframe.tpl",TRUE));
+ return($display);
+ }
+
/* Tag objects to have the gosaAdministrativeUnitTag */
/* Tag objects to have the gosaAdministrativeUnitTag */
- function tag_objects()
+ function tag_objects($OnlySetTagFlag = false)
{
{
- echo "<pre>Performing Tag:";
+ if(!$OnlySetTagFlag){
+ $smarty= get_smarty();
+
+ /* Print out html introduction */
+ echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+ <html>
+ <head>
+ <title></title>
+ <style type="text/css">@import url("themes/default/style.css");</style>
+ <script language="javascript" src="include/focus.js" type="text/javascript"></script>
+ </head>
+ <body style="background-image:none;margin:3px;color:black" id="body" >
+ ';
+
+ echo "<h3>".sprintf(_("Tagging '%s'."),"<i>".@LDAP::fix($this->dn)."</i>")."</h3>";
+ }
+
+ $add= $this->is_administrational_unit;
+ $len= strlen($this->dn);
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
$ldap= $this->config->get_ldap_link();
$ldap->cd($this->dn);
- $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
- $this->gosaUnitTag.')))', array('dn'));
+ if ($add){
+ $ldap->search('(!(&(objectClass=gosaAdministrativeUnitTag)(gosaUnitTag='.
+ $this->gosaUnitTag.')))', array('dn'));
+ } else {
+ $ldap->search('objectClass=gosaAdministrativeUnitTag', array('dn'));
+ }
+
while ($attrs= $ldap->fetch()){
while ($attrs= $ldap->fetch()){
- //FIXME: check if this is below another administrative
- // unit
- echo "Fix: ".$attrs['dn']."\n";
+
+ /* Skip self */
+ if ($attrs['dn'] == $this->dn){
+ continue;
+ }
+
+ /* Check for confilicting administrative units */
+ $fix= true;
+ foreach ($this->config->adepartments as $key => $tag){
+ /* This one is shorter than our dn, its not relevant... */
+ if ($len >= strlen($key)){
+ continue;
+ }
+
+ /* This one matches with the latter part. Break and don't fix this entry */
+ if (preg_match('/(^|,)'.normalizePreg($key).'$/', $attrs['dn'])){
+ $fix= false;
+ break;
+ }
+ }
+
+ /* Fix entry if needed */
+ if ($fix){
+ if($OnlySetTagFlag){
+ $this->must_be_tagged =true;
+ return;
+ }
+ $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
+ echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
+ }
}
}
- echo "</pre>";
+ if(!$OnlySetTagFlag){
+ echo '<p class="seperator"> </p>';
+ echo "<div style='width:100%;text-align:right;'><form name='form' method='post' action='?plug=".$_GET['plug']."' target='_parent'>
+ <br><input type='submit' name='back' value='"._("Continue")."'>
+ </form></div>";
+ }
}
}
- /* Remove the gosaAdministrativeUnitTag from objects */
- function untag_objects()
- {
- echo "Performing Untag:";
- }
/* Move/Rename complete trees */
function recursive_move($src_dn, $dst_dn,$force = false)
{
/* Move/Rename complete trees */
function recursive_move($src_dn, $dst_dn,$force = false)
{
+ /* If force == false prepare to recursive move this object from src to dst
+ on the next call. */
if(!$force){
if(!$force){
-
$this->rec_cpy = true;
$this->rec_src = $src_dn;
$this->rec_dst = $dst_dn;
$this->rec_cpy = true;
$this->rec_src = $src_dn;
$this->rec_dst = $dst_dn;
-
- $smarty = get_smarty();
-
- $smarty->assign("src","?plug=".$_GET['plug']."&PerformRecMove");
-
- $display= $smarty->fetch(get_template_path("recursive_move.tpl",TRUE));
- return($display);
- exit();
}else{
}else{
+
+ /* If this is called, but not wanted, abort */
if(!$this->rec_cpy){
return;
}
if(!$this->rec_cpy){
return;
}
/* Print header to have styles included */
$smarty= get_smarty();
/* Print header to have styles included */
$smarty= get_smarty();
- echo "<!-- headers.tpl-->".$smarty->fetch(get_template_path('headers.tpl'));
- echo "<body style='background-image:none;margin:3px;color:black'>";
- echo "<h3>".sprintf(_("Moving %s to %s"),"<i>".$src_dn."</i>","<i>".$dst_dn."</i>")."</h3>";
+ /* Print out html introduction */
+ echo ' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+ <html>
+ <head>
+ <title></title>
+ <style type="text/css">@import url("themes/default/style.css");</style>
+ <script language="javascript" src="include/focus.js" type="text/javascript"></script>
+ </head>
+ <body style="background: none; margin:4px;" id="body" >
+ ';
+ echo "<h3>".sprintf(_("Moving '%s' to '%s'"),"<i>".@LDAP::fix($src_dn)."</i>","<i>".@LDAP::fix($dst_dn)."</i>")."</h3>";
/* Check if the destination entry exists */
$ldap= $this->config->get_ldap_link();
/* Check if destination exists - abort */
/* Check if the destination entry exists */
$ldap= $this->config->get_ldap_link();
/* Check if destination exists - abort */
- $ldap->cat($dst_dn);
+ $ldap->cat($dst_dn, array('dn'));
if ($ldap->fetch()){
if ($ldap->fetch()){
- trigger_error("Recursive_move $dst_dn already exists.",
+ trigger_error("Recursive_move ".@LDAP::fix($dst_dn)." already exists.",
E_USER_WARNING);
E_USER_WARNING);
- echo "Recursive_move :$dst_dn already exists.<br>";
+ echo sprintf("Recursive_move: '%s' already exists", @LDAP::fix($dst_dn))."<br>";
return (FALSE);
}
return (FALSE);
}
-
+
/* Perform a search for all objects to be moved */
$objects= array();
$ldap->cd($src_dn);
/* Perform a search for all objects to be moved */
$objects= array();
$ldap->cd($src_dn);
/* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
foreach ($objects as $object => $len){
/* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
foreach ($objects as $object => $len){
-
-
$src= str_replace("\\","\\\\",$object);
$dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
$dst= str_replace($src_dn,$dst_dn,$object);
$src= str_replace("\\","\\\\",$object);
$dst= preg_replace("/".str_replace("\\","\\\\",$src_dn)."$/", "$dst_dn", $object);
$dst= str_replace($src_dn,$dst_dn,$object);
- echo "<b>"._("Object").":</b> $src<br>";
-
- if (!$this->copy($src, $dst)){
- echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),$src)."</font>";
+ echo "<b>"._("Object").":</b> ".@LDAP::fix($src)."<br>";
+
+ if (!$this->copy($src, $dst)){
+ echo "<font color='#FF0000'><br>".sprintf(_("FAILED to copy %s, aborting operation"),@LDAP::fix($src))."</font>";
return (FALSE);
}
return (FALSE);
}
+ echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
flush();
}
flush();
}
<br><input type='submit' name='back' value='"._("Continue")."'>
</form></div>";
<br><input type='submit' name='back' value='"._("Continue")."'>
</form></div>";
+ echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
echo "</body></html>";
echo "</body></html>";
-
+
return (TRUE);
}
}
return (TRUE);
}
}
-
- function am_i_moved()
- {
- return $this->rec_cpy;
- }
-
}
}
-
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
?>