X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fogroups%2Fclass_ogroup.inc;h=6d51281be825dd86dd73c3b1f3c93f870af80187;hb=0eebfd3829749fcdcc5d9995ca9675d99f81888a;hp=22111b073ab29748e54a666b69ac5d0a1ac6db38;hpb=1b507d1b0d7ba749673286294c4b4457f2e4cacd;p=gosa.git diff --git a/plugins/admin/ogroups/class_ogroup.inc b/plugins/admin/ogroups/class_ogroup.inc index 22111b073..6d51281be 100644 --- a/plugins/admin/ogroups/class_ogroup.inc +++ b/plugins/admin/ogroups/class_ogroup.inc @@ -32,7 +32,7 @@ class ogroup extends plugin var $group_dialog= FALSE; /* attribute list for save action */ - var $attributes= array("cn", "description", "gosaGroupObjects"); + var $attributes= array("cn", "description", "gosaGroupObjects","member"); var $objectclasses= array("top", "gosaGroupOfNames"); function ogroup ($config, $dn= NULL) @@ -40,6 +40,8 @@ class ogroup extends plugin plugin::plugin ($config, $dn); $this->orig_dn= $dn; + $this->member = array(); + /* Load member objects */ if (isset($this->attrs['member'])){ foreach ($this->attrs['member'] as $key => $value){ @@ -79,43 +81,47 @@ class ogroup extends plugin } register_global("ogfilter", $ogfilter); - if(isset($_SESSION['ogroupfilter']['depselect'])){ - $this->base = $_SESSION['ogroupfilter']['depselect']; + if(isset($_SESSION['CurrentMainBase'])){ + $this->base = $_SESSION['CurrentMainBase']; } - /* set permissions */ - $ui= get_userinfo(); - $acl= get_permissions ($ui->dn, $ui->subtreeACL); - $this->acl= get_module_permission($acl, "ogroup", $ui->dn); - - /* Load member data */ $this->reload(); } - function AddDelMembership(){ - /* Delete objects from group */ - if (isset($_POST['delete_membership']) && isset($_POST['members'])){ - foreach ($_POST['members'] as $value){ - $this->objects["$value"]= $this->memberList[$value]; - unset ($this->memberList["$value"]); - unset ($this->member["$value"]); - uasort ($this->objects, 'sort_list'); - reset ($this->objects); - } + function AddDelMembership($NewMember = false){ + + if($NewMember){ + $this->memberList[$NewMember]= $this->allobjects[$NewMember]; + $this->member[$NewMember]= $NewMember; + unset ($this->objects[$NewMember]); + uasort ($this->memberList, 'sort_list'); + reset ($this->memberList); $this->reload(); - } + }else{ + /* Delete objects from group */ + if (isset($_POST['delete_membership']) && isset($_POST['members'])){ + foreach ($_POST['members'] as $value){ + $this->objects["$value"]= $this->memberList[$value]; + unset ($this->memberList["$value"]); + unset ($this->member["$value"]); + uasort ($this->objects, 'sort_list'); + reset ($this->objects); + } + $this->reload(); + } - /* Add objects to group */ - if (isset($_POST['add_object_finish']) && isset($_POST['objects'])){ - foreach ($_POST['objects'] as $value){ - $this->memberList["$value"]= $this->objects[$value]; - $this->member["$value"]= $value; - unset ($this->objects[$value]); - uasort ($this->memberList, 'sort_list'); - reset ($this->memberList); + /* Add objects to group */ + if (isset($_POST['add_object_finish']) && isset($_POST['objects'])){ + foreach ($_POST['objects'] as $value){ + $this->memberList["$value"]= $this->objects[$value]; + $this->member["$value"]= $value; + unset ($this->objects[$value]); + uasort ($this->memberList, 'sort_list'); + reset ($this->memberList); + } + $this->reload(); } - $this->reload(); } } @@ -164,6 +170,52 @@ class ogroup extends plugin /* Load templating engine */ $smarty= get_smarty(); + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translation){ + $smarty->assign($name."ACL",$this->getacl($name)); + } + + /* Create base acls */ + $baseACL = $this->getacl("base",(!is_object($this->parent) && !isset($_SESSION['edit']))); + if(!$this->acl_is_moveable()) { + $baseACL = preg_replace("/w/","",$baseACL); + } + $smarty->assign("baseACL", $baseACL); + + + /* Get bases */ + $ui = get_userinfo(); + $check = $ui->get_module_departments("ogroups"); + $bases = array(); + foreach($check as $dn_allowed){ + $bases[$dn_allowed] = $this->config->idepartments[$dn_allowed]; + } + + /* Base select dialog */ + $once = true; + foreach($_POST as $name => $value){ + if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){ + $once = false; + $this->dialog = new baseSelectDialog($this->config,$this,$bases); + $this->dialog->setCurrentBase($this->base); + } + } + + /* Dialog handling */ + if(is_object($this->dialog) && $this->acl_is_moveable()){ + /* 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()); + } + } + /* Add objects? */ if (isset($_POST["edit_membership"])){ $this->group_dialog= TRUE; @@ -230,8 +282,7 @@ class ogroup extends plugin } /* Bases / Departments */ - - if (isset($_POST['base'])){ + if ((isset($_POST['base'])) && ($this->acl_is_moveable())){ $this->base= $_POST['base']; } @@ -264,7 +315,7 @@ class ogroup extends plugin } /* Assign variables */ - $smarty->assign("bases", $this->config->idepartments); + $smarty->assign("bases", $bases); $smarty->assign("base_select", $this->base); $smarty->assign("department", $this->department); $smarty->assign("members", $this->convert_list($this->memberList)); @@ -275,12 +326,6 @@ class ogroup extends plugin /* Fields */ foreach ($this->attributes as $val){ $smarty->assign("$val", $this->$val); - $smarty->assign("$val"."ACL", chkacl($this->acl, "$val")); - } - - /* Assign ACL's */ - foreach (array("base", "members") as $val){ - $smarty->assign("$val"."ACL", chkacl($this->acl, "$val")); } return ($smarty->fetch (get_template_path('generic.tpl', TRUE))); @@ -293,11 +338,7 @@ class ogroup extends plugin /* Save additional values for possible next step */ if (isset($_POST['ogroupedit'])){ plugin::save_object(); - - if (chkacl ($this->acl, "base") == "" && isset($_POST["base"])){ - $this->base= $_POST["base"]; - } - + } } @@ -468,7 +509,7 @@ class ogroup extends plugin /* It has failed, add entry with type flag I (Invalid)*/ if ($ldap->error != "success"){ - $this->memberList[$dn]= array('text' => _("Non existing dn: ")."$dn","type" => "I"); + $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".@LDAP::fix($dn),"type" => "I"); } else { @@ -592,7 +633,8 @@ class ogroup extends plugin function check() { - $message= array(); + /* Call common method to give check the hook */ + $message= plugin::check(); /* Permissions for that base? */ if ($this->base != ""){ @@ -604,22 +646,19 @@ class ogroup extends plugin $ldap = $this->config->get_ldap_link(); if($this->dn != $new_dn){ - $ldap->cat ($new_dn); + $ldap->cat ($new_dn, array('dn')); } if($ldap->count() !=0){ $message[]= _("There is already an object with this cn."); } - $ui= get_userinfo(); - $acl= get_permissions ($new_dn, $ui->subtreeACL); - $acl= get_module_permission($acl, "group", $new_dn); - if (chkacl($acl, "create") != ""){ + if ($this->orig_dn == "new" && !$this->acl_is_createable()){ $message[]= _("You have no permissions to create a group on this 'Base'."); } /* must: cn */ - if ($this->cn == "" && chkacl ($this->acl, "cn") == ""){ + if ($this->cn == "" && $this->acl_is_writeable("cn")){ $message[]= "The required field 'Name' is not set."; } @@ -638,8 +677,9 @@ class ogroup extends plugin plugin::save(); /* Move members to target array */ + $this->attrs['member'] =array(); foreach ($this->member as $key => $desc){ - $this->attrs['member'][]= $key; + $this->attrs['member'][]= @LDAP::fix($key); } $ldap= $this->config->get_ldap_link(); @@ -651,7 +691,7 @@ class ogroup extends plugin /* Save data. Using 'modify' implies that the entry is already present, use 'add' for new entries. So do a check first... */ - $ldap->cat ($this->dn); + $ldap->cat ($this->dn, array('dn')); if ($ldap->fetch()){ /* Modify needs array() to remove values :-( */ if (!count ($this->member)){ @@ -666,13 +706,14 @@ class ogroup extends plugin /* Write back to ldap */ $ldap->cd($this->dn); + $this->cleanup(); $ldap->$mode($this->attrs); /* Trigger post signal */ $this->handle_post_events($mode); $ret= 0; - if (show_ldap_error($ldap->get_error())){ + if (show_ldap_error($ldap->get_error(), sprintf(_("Saving of object group/generic with dn '%s' failed."),$this->dn))){ $ret= 1; } @@ -685,12 +726,46 @@ class ogroup extends plugin $ldap= $this->config->get_ldap_link(); $ldap->rmdir($this->dn); - show_ldap_error($ldap->get_error()); + show_ldap_error($ldap->get_error(), sprintf(_("Removing of object group/generic with dn '%s' failed."),$this->dn)); /* Trigger remove signal */ $this->handle_post_events("remove"); } + function getCopyDialog() + { + $str = ""; + $str .= _("Group name"); + $str .= " "; + return($str); + } + + function saveCopyDialog() + { + if(isset($_POST['cn'])){ + $this->cn = $_POST['cn']; + } + } + + + function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("Object group generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("administration"), + "plCategory" => array("ogroups" => array("description" => _("Object groups"), + "objectClass" => "gosaGroupOfNames")), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "base" => _("Base"), + "description" => _("Description"), + "member" => _("Member")) + )); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: