127948767ca4ee4eb83bdd5682e0107cc6e8104d
1 <?php
2 /*
3 * This code is part of GOsa (http://www.gosa-project.org)
4 * Copyright (C) 2003-2008 GONICUS GmbH
5 *
6 * ID: $$Id$$
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
23 /* Sort multidimensional arrays for key 'text' */
24 function sort_list($val1, $val2)
25 {
26 $v1= strtolower($val1['text']);
27 $v2= strtolower($val2['text']);
28 if ($v1 > $v2){
29 return 1;
30 }
31 if ($v1 < $v2){
32 return -1;
33 }
34 return 0;
35 }
38 class ogroup extends plugin
39 {
40 /* Variables */
41 var $cn= "";
42 var $description= "";
43 var $base= "";
44 var $gosaGroupObjects= "";
45 var $department= "";
46 var $objects= array();
47 var $objcache= array();
48 var $memberList= array();
49 var $member= array();
50 var $orig_dn= "";
51 var $group_dialog= FALSE;
52 var $view_logged = FALSE;
54 /* attribute list for save action */
55 var $attributes= array("cn", "description", "gosaGroupObjects","member");
56 var $objectclasses= array("top", "gosaGroupOfNames");
58 function ogroup (&$config, $dn= NULL)
59 {
60 plugin::plugin ($config, $dn);
61 $this->orig_dn= $dn;
63 $this->member = array();
65 /* Load member objects */
66 if (isset($this->attrs['member'])){
67 foreach ($this->attrs['member'] as $key => $value){
68 if ("$key" != "count"){
69 $value= @LDAP::convert($value);
70 $this->member["$value"]= "$value";
71 }
72 }
73 }
74 $this->is_account= TRUE;
76 /* Get global filter config */
77 if (!session::is_set("ogfilter")){
78 $ui= get_userinfo();
79 $base= get_base_from_people($ui->dn);
80 $ogfilter= array( "dselect" => $base,
81 "regex" => "*");
82 session::set("ogfilter", $ogfilter);
83 }
84 $ogfilter= session::get('ogfilter');
86 /* Adjust flags */
87 foreach( array( "U" => "accounts",
88 "G" => "groups",
89 "A" => "applications",
90 "D" => "departments",
91 "S" => "servers",
92 "W" => "workstations",
93 "O" => "winstations",
94 "T" => "terminals",
95 "F" => "phones",
96 "_" => "subtrees",
97 "P" => "printers") as $key => $val){
99 if (preg_match("/$key/", $this->gosaGroupObjects)){
100 $ogfilter[$val]= "checked";
101 } else {
102 $ogfilter[$val]= "";
103 }
104 }
105 session::set("ogfilter", $ogfilter);
107 if(session::is_set('CurrentMainBase')){
108 $this->base = session::get('CurrentMainBase');
109 }
111 /* Set base */
112 if ($this->dn == "new"){
113 $this->base = session::get('CurrentMainBase');
114 } else {
115 $this->base= preg_replace("/^[^,]+,".normalizePreg(get_ou("ogroupou"))."/","",$this->dn);
116 }
118 /* Load member data */
119 $this->reload();
120 }
122 function AddDelMembership($NewMember = false){
124 if($NewMember){
126 /* Add member and force reload */
127 $this->member[$NewMember]= $NewMember;
128 $this->reload();
130 $this->memberList[$NewMember]= $this->objcache[$NewMember];
131 unset ($this->objects[$NewMember]);
132 uasort ($this->memberList, 'sort_list');
133 reset ($this->memberList);
134 }else{
135 /* Delete objects from group */
136 if (isset($_POST['delete_membership']) && isset($_POST['members'])){
137 foreach ($_POST['members'] as $value){
138 $this->objects["$value"]= $this->memberList[$value];
139 unset ($this->memberList["$value"]);
140 unset ($this->member["$value"]);
141 uasort ($this->objects, 'sort_list');
142 reset ($this->objects);
143 }
144 $this->reload();
145 }
147 /* Add objects to group */
148 if (isset($_POST['add_object_finish']) && isset($_POST['objects'])){
150 $tmp = "";
151 foreach($this->memberList as $obj){
152 $tmp .= $obj['type'];
153 }
154 $skipped = FALSE;
155 foreach ($_POST['objects'] as $value){
156 if(preg_match("/T/",$tmp) && $this->objects[$value]['type'] == "W"){
157 $skipped =TRUE;
158 }elseif(preg_match("/W/",$tmp) && $this->objects[$value]['type'] == "T"){
159 $skipped =TRUE;
160 }else{
161 $this->memberList["$value"]= $this->objects[$value];
162 $this->member["$value"]= $value;
163 unset ($this->objects[$value]);
164 uasort ($this->memberList, 'sort_list');
165 reset ($this->memberList);
166 }
167 }
168 if($skipped){
169 msg_dialog::display(_("Information"), _("You cannot combine terminals and workstations in one object group!"), INFO_DIALOG);
170 }
171 $this->reload();
172 }
173 }
174 }
176 function execute()
177 {
178 /* Call parent execute */
179 plugin::execute();
181 if(!$this->view_logged){
182 $this->view_logged = TRUE;
183 new log("view","ogroups/".get_class($this),$this->dn);
184 }
187 /* Do we represent a valid group? */
188 if (!$this->is_account){
189 $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
190 msgPool::noValidExtension("object group")."</b>";
191 return ($display);
192 }
195 /* Load templating engine */
196 $smarty= get_smarty();
198 $tmp = $this->plInfo();
199 foreach($tmp['plProvidedAcls'] as $name => $translation){
200 $smarty->assign($name."ACL",$this->getacl($name));
201 }
203 /* Base select dialog */
204 $once = true;
205 foreach($_POST as $name => $value){
206 if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){
207 $once = false;
208 $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases());
209 $this->dialog->setCurrentBase($this->base);
210 }
211 }
213 /* Dialog handling */
214 if(is_object($this->dialog) && $this->acl_is_moveable()){
215 /* Must be called before save_object */
216 $this->dialog->save_object();
218 if($this->dialog->isClosed()){
219 $this->dialog = false;
220 }elseif($this->dialog->isSelected()){
222 /* A new base was selected, check if it is a valid one */
223 $tmp = $this->get_allowed_bases();
224 if(isset($tmp[$this->dialog->isSelected()])){
225 $this->base = $this->dialog->isSelected();
226 }
227 $this->dialog= false;
228 }else{
229 return($this->dialog->execute());
230 }
231 }
233 /* Add objects? */
234 if (isset($_POST["edit_membership"])){
235 $this->group_dialog= TRUE;
236 $this->dialog= TRUE;
237 }
239 /* Add objects finished? */
240 if (isset($_POST["add_object_finish"]) || isset($_POST["add_object_cancel"])){
241 $this->group_dialog= FALSE;
242 $this->dialog= FALSE;
243 }
245 /* Manage object add dialog */
246 if ($this->group_dialog){
248 /* Save data */
249 $ogfilter= session::get("ogfilter");
250 foreach( array("dselect", "regex") as $type){
251 if (isset($_POST[$type])){
252 $ogfilter[$type]= $_POST[$type];
253 }
254 }
255 if (isset($_POST['dselect'])){
256 foreach( array("accounts", "groups", "applications", "departments",
257 "servers", "workstations", "winstations", "terminals", "printers","subtrees",
258 "phones") as $type){
260 if (isset($_POST[$type])) {
261 $ogfilter[$type]= "checked";
262 } else {
263 $ogfilter[$type]= "";
264 }
265 }
266 }
267 if (isset($_GET['search'])){
268 $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
269 if ($s == "**"){
270 $s= "*";
271 }
272 $ogfilter['regex']= $s;
273 }
274 session::set("ogfilter", $ogfilter);
275 $this->reload();
277 /* Calculate actual groups */
278 $smarty->assign("objects", $this->convert_list($this->objects));
280 /* Show dialog */
281 $smarty->assign("search_image", get_template_path('images/search.png'));
282 $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
283 $smarty->assign("tree_image", get_template_path('images/tree.png'));
284 $smarty->assign("deplist", $this->config->idepartments);
285 $smarty->assign("alphabet", generate_alphabet());
286 foreach( array("dselect", "regex", "subtrees") as $type){
287 $smarty->assign("$type", $ogfilter[$type]);
288 }
289 $smarty->assign("hint", print_sizelimit_warning());
290 $smarty->assign("apply", apply_filter());
292 /* Build up checkboxes
293 */
294 $ar = array(
295 "departments" => array(
296 "T" => msgPool::selectToView(_("departments")),
297 "C" => (isset($ogfilter['departments']) && ($ogfilter['departments'])),
298 "L" => sprintf(_("Show %s"),_("departments"))),
299 "accounts" => array(
300 "T" => msgPool::selectToView(_("people")),
301 "C" => (isset($ogfilter['accounts']) && ($ogfilter['accounts'])),
302 "L" => sprintf(_("Show %s"),_("people"))),
303 "groups"=> array(
304 "T" => msgPool::selectToView(_("groups")),
305 "C" => (isset($ogfilter['groups']) && ($ogfilter['groups'])),
306 "L" => sprintf(_("Show %s"),_("groups"))),
307 "applications"=> array(
308 "T" => msgPool::selectToView(_("applications")),
309 "C" => (isset($ogfilter['applications']) && ($ogfilter['applications'])),
310 "L" => sprintf(_("Show %s"),_("applications"))),
311 "servers"=> array(
312 "T" => msgPool::selectToView(_("servers")),
313 "C" => (isset($ogfilter['servers']) && ($ogfilter['servers'])),
314 "L" => sprintf(_("Show %s"),_("servers"))),
315 "workstations"=> array(
316 "T" => msgPool::selectToView(_("workstations")),
317 "C" => (isset($ogfilter['workstations']) && ($ogfilter['workstations'])),
318 "L" => sprintf(_("Show %s"),_("workstations"))),
319 "terminals"=> array(
320 "T" => msgPool::selectToView(_("terminals")),
321 "C" => (isset($ogfilter['terminals']) && ($ogfilter['terminals'])),
322 "L" => sprintf(_("Show %s"),_("terminals"))),
323 "printers"=> array(
324 "T" => msgPool::selectToView(_("printer")),
325 "C" => (isset($ogfilter['printers']) && ($ogfilter['printers'])),
326 "L" => sprintf(_("Show %s"),_("printers"))),
327 "phones"=> array(
328 "T" => msgPool::selectToView(_("phones")),
329 "C" => (isset($ogfilter['phones']) && ($ogfilter['phones'])),
330 "L" => sprintf(_("Show %s"),_("phones"))));
331 $smarty->assign("checkboxes",$ar);
332 $display= $smarty->fetch (get_template_path('ogroup_objects.tpl', TRUE, dirname(__FILE__)));
333 return ($display);
334 }
336 /* Bases / Departments */
337 if ((isset($_POST['base'])) && ($this->acl_is_moveable())){
338 $this->base= $_POST['base'];
339 }
341 /* Assemble combine string */
342 if ($this->gosaGroupObjects == "[]"){
343 $smarty->assign("combinedObjects", _("none"));
344 } elseif (strlen($this->gosaGroupObjects) > 4){
345 $smarty->assign("combinedObjects", "<font color=red>"._("too many different objects!")."</font>");
346 } else {
347 $conv= array( "U" => _("users"),
348 "G" => _("groups"),
349 "A" => _("applications"),
350 "D" => _("departments"),
351 "S" => _("servers"),
352 "W" => _("workstations"),
353 "O" => _("winstations"),
354 "T" => _("terminals"),
355 "F" => _("phones"),
356 "P" => _("printers"));
358 $type= preg_replace('/[\[\]]/', '', $this->gosaGroupObjects);
359 $p1= $conv[$type[0]];
360 error_reporting(0);
361 if (isset($type[1]) && preg_match('/[UGADSFOWTP]/', $type[1])){
362 $p2= $conv[$type[1]];
363 $smarty->assign("combinedObjects", sprintf("'%s' and '%s'", $p1, $p2));
364 } else {
365 $smarty->assign("combinedObjects", "$p1");
366 }
367 error_reporting(E_ALL | E_STRICT);
368 }
370 /* Assign variables */
371 $smarty->assign("bases", $this->get_allowed_bases());
372 $smarty->assign("base_select", $this->base);
373 $smarty->assign("department", $this->department);
374 $smarty->assign("members", $this->convert_list($this->memberList));
376 /* Objects have to be tuned... */
377 $smarty->assign("objects", $this->convert_list($this->objects));
379 /* Fields */
380 foreach ($this->attributes as $val){
381 $smarty->assign("$val", $this->$val);
382 }
384 return ($smarty->fetch (get_template_path('generic.tpl', TRUE)));
385 }
388 /* Save data to object */
389 function save_object()
390 {
391 /* Save additional values for possible next step */
392 if (isset($_POST['ogroupedit'])){
394 /* Create a base backup and reset the
395 base directly after calling plugin::save_object();
396 Base will be set seperatly a few lines below */
397 $base_tmp = $this->base;
398 plugin::save_object();
399 $this->base = $base_tmp;
401 /* Save base, since this is no LDAP attribute */
402 $tmp = $this->get_allowed_bases();
403 if(isset($_POST['base'])){
404 if(isset($tmp[$_POST['base']])){
405 $this->base= $_POST['base'];
406 }
407 }
408 }
409 }
412 /* (Re-)Load objects */
413 function reload()
414 {
415 /*###########
416 Variable initialisation
417 ###########*/
419 $this->objects = array();
420 $this->ui = get_userinfo();
421 $filter = "";
422 $objectClasses = array();
424 $ogfilter = session::get("ogfilter");
425 $regex = $ogfilter['regex'];
427 $ldap= $this->config->get_ldap_link();
428 $ldap->cd ($ogfilter['dselect']);
431 /*###########
432 Generate Filter
433 ###########*/
435 $p_f= array("accounts" => array("CLASS"=>"gosaAccount" ,"DN"=> get_people_ou() ,"ACL" => "users"),
436 "groups" => array("CLASS"=>"posixGroup" ,"DN"=> get_groups_ou('ogroupou') ,"ACL" => "groups"),
437 "applications" => array("CLASS"=>"gosaApplication","DN"=> get_ou('applicationou') ,"ACL" => "application"),
438 "departments" => array("CLASS"=>"gosaDepartment" ,"DN"=> "" ,"ACL" => "department"),
439 "servers" => array("CLASS"=>"goServer" ,"DN"=> get_ou('serverou') ,"ACL" => "server"),
440 "workstations" => array("CLASS"=>"gotoWorkstation","DN"=> get_ou('workstationou') ,"ACL" => "workstation"),
441 "winstations" => array("CLASS"=>"opsiClient", "DN"=> get_ou('WINSTATIONS') ,"ACL" => "winstation"),
442 "terminals" => array("CLASS"=>"gotoTerminal" ,"DN"=> get_ou('terminalou') ,"ACL" => "terminal"),
443 "printers" => array("CLASS"=>"gotoPrinter" ,"DN"=> get_ou('printerou') ,"ACL" => "printer"),
444 "phones" => array("CLASS"=>"goFonHardware" ,"DN"=> get_ou('phoneou') ,"ACL" => "phone"));
447 /*###########
448 Perform search for selected objectClasses & regex to fill list with objects
449 ###########*/
451 $Get_list_flags = 0;
452 if($ogfilter['subtrees'] == "checked"){
453 $Get_list_flags |= GL_SUBSEARCH;
454 }
456 foreach($p_f as $post_name => $data){
458 if($ogfilter[$post_name] == "checked"){
460 if($ogfilter['subtrees']){
461 $base = $ogfilter['dselect'];
462 }else{
463 $base = $data['DN'].$ogfilter['dselect'];
464 }
466 $filter = "(&(objectClass=".$data['CLASS'].")(|(uid=$regex)(cn=$regex)(ou=$regex)))";
467 $res = get_list($filter, $data['ACL'] , $base,
468 array("description", "objectClass", "sn", "givenName", "uid","ou","cn"),$Get_list_flags);
470 /* fetch results and append them to the list */
471 foreach($res as $attrs){
473 $type= $this->getObjectType($attrs);
474 $name= $this->getObjectName($attrs);
476 /* Fill array */
477 if (isset($attrs["description"][0])){
478 $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type");
479 } elseif (isset($attrs["uid"][0])) {
480 $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type");
481 } else {
482 $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
483 }
484 }
485 }
486 }
487 uasort ($this->objects, 'sort_list');
488 reset ($this->objects);
491 /*###########
492 Build member list and try to detect obsolete entries
493 ###########*/
495 $this->memberList = array();
497 /* Walk through all single member entry */
498 foreach($this->member as $dn){
500 /* The dn for the current member can't be resolved
501 it seams that this entry was removed
502 */
503 /* Try to resolv the entry again, if it still fails, display error msg */
504 $ldap->cat($dn, array("cn", "sn", "givenName", "ou", "description", "objectClass"));
506 /* It has failed, add entry with type flag I (Invalid)*/
507 if (!$ldap->success()){
508 $this->memberList[$dn]= array('text' => _("Non existing dn:")." ".@LDAP::fix($dn),"type" => "I");
510 } else {
512 /* Append this entry to our all object list */
514 /* Fetch object */
515 $attrs= $ldap->fetch();
517 $type= $this->getObjectType($attrs);
518 $name= $this->getObjectName($attrs);
520 if (isset($attrs["description"][0])){
521 $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type");
522 } elseif (isset($attrs["uid"][0])) {
523 $this->objcache[$attrs["dn"]]= array("text" => "$name [".$attrs["uid"][0]."]", "type" => "$type");
524 } else {
525 $this->objcache[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
526 }
527 $this->objcache[$attrs["dn"]]['objectClass'] = $attrs['objectClass'];
528 if(isset($attrs['uid'])){
529 $this->objcache[$attrs["dn"]]['uid'] = $attrs['uid'];
530 }
532 /* Fill array */
533 if (isset($attrs["description"][0])){
534 $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type");
535 } else {
536 $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
537 }
539 $this->memberList[$dn]= $this->objects[$attrs["dn"]];
540 }
541 }
542 uasort ($this->memberList, 'sort_list');
543 reset ($this->memberList);
545 /* Assemble types of currently combined objects */
546 $objectTypes= "";
547 foreach ($this->memberList as $dn => $desc){
549 /* Invalid object? */
550 if ($desc['type'] == 'I'){
551 continue;
552 }
554 /* Fine. Add to list. */
555 if (!preg_match('/'.$desc['type'].'/', $objectTypes)){
556 $objectTypes.= $desc['type'];
557 }
558 }
559 $this->gosaGroupObjects= "[$objectTypes]";
560 }
563 function convert_list($input)
564 {
565 $temp= "";
566 $conv= array( "U" => "select_user.png",
567 "G" => "select_groups.png",
568 "A" => "select_application.png",
569 "D" => "select_department.png",
570 "S" => "select_server.png",
571 "W" => "select_workstation.png",
572 "O" => "select_winstation.png",
573 "T" => "select_terminal.png",
574 "F" => "select_phone.png",
575 "I" => "flag.png",
576 "P" => "select_printer.png");
578 foreach ($input as $key => $value){
579 /* Generate output */
580 $temp.= "<option title='".addslashes( $key)."' value=\"$key\" class=\"select\" style=\"background-image:url('".get_template_path("images/".$conv[$value['type']])."');\">".$value['text']."</option>\n";
581 }
583 return ($temp);
584 }
587 function getObjectType($attrs)
588 {
589 $type= "I";
591 foreach(array( "U" => "gosaAccount",
592 "G" => "posixGroup",
593 "A" => "gosaApplication",
594 "D" => "gosaDepartment",
595 "S" => "goServer",
596 "W" => "gotoWorkstation",
597 "O" => "opsiClient",
598 "T" => "gotoTerminal",
599 "F" => "goFonHardware",
600 "P" => "gotoPrinter") as $index => $class){
601 if (in_array($class, $attrs['objectClass'])){
602 $type= $index;
603 break;
604 }
605 }
607 return ($type);
608 }
611 function getObjectName($attrs)
612 {
613 /* Person? */
614 $name ="";
615 if (in_array('gosaAccount', $attrs['objectClass'])){
616 if(isset($attrs['sn']) && isset($attrs['givenName'])){
617 $name= $attrs['sn'][0].", ".$attrs['givenName'][0];
618 } else {
619 $name= $attrs['uid'][0];
620 }
621 } else {
622 if(isset($attrs["cn"][0])) {
623 $name= $attrs['cn'][0];
624 } else {
625 $name= $attrs['ou'][0];
626 }
627 }
629 return ($name);
630 }
633 function check()
634 {
635 /* Call common method to give check the hook */
636 $message= plugin::check();
638 /* Permissions for that base? */
639 if ($this->base != ""){
640 $new_dn= 'cn='.$this->cn.','.get_ou('ogroupou').$this->base;
641 } else {
642 $new_dn= $this->dn;
643 }
646 $ldap = $this->config->get_ldap_link();
647 if($this->dn != $new_dn){
648 $ldap->cat ($new_dn, array('dn'));
649 }
651 if($ldap->count() !=0){
652 $message[]= msgPool::duplicated(_("Name"));
653 }
655 /* Set new acl base */
656 if($this->dn == "new") {
657 $this->set_acl_base($this->base);
658 }
660 /* must: cn */
661 if ($this->cn == ""){
662 $message[]= msgPool::required(_("Name"));
663 }
665 /* To many different object types? */
666 if (strlen($this->gosaGroupObjects) > 4){
667 $message[]= _("You can combine two different object types at maximum, only!");
668 }
670 return ($message);
671 }
674 /* Save to LDAP */
675 function save()
676 {
677 plugin::save();
679 /* Move members to target array */
680 $this->attrs['member'] =array();
681 foreach ($this->member as $key => $desc){
682 $this->attrs['member'][]= @LDAP::fix($key);
683 }
685 $ldap= $this->config->get_ldap_link();
687 /* New accounts need proper 'dn', propagate it to remaining objects */
688 if ($this->dn == 'new'){
689 $this->dn= 'cn='.$this->cn.','.get_ou('ogroupou').$this->base;
690 }
692 /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
693 new entries. So do a check first... */
694 $ldap->cat ($this->dn, array('dn'));
695 if ($ldap->fetch()){
696 /* Modify needs array() to remove values :-( */
697 if (!count ($this->member)){
698 $this->attrs['member']= array();
699 }
700 $mode= "modify";
702 } else {
703 $mode= "add";
704 $ldap->cd($this->config->current['BASE']);
705 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
706 }
708 /* Write back to ldap */
709 $ldap->cd($this->dn);
710 $this->cleanup();
711 $ldap->$mode($this->attrs);
713 if($mode == "add"){
714 new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
715 }else{
716 new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
717 }
719 /* Trigger post signal */
720 $this->handle_post_events($mode);
722 $ret= 0;
723 if (!$ldap->success()){
724 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
725 $ret= 1;
726 }
728 return ($ret);
729 }
731 function remove_from_parent()
732 {
733 plugin::remove_from_parent();
735 $ldap= $this->config->get_ldap_link();
736 $ldap->rmdir($this->dn);
737 if (!$ldap->success()){
738 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
739 }
741 new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
743 /* Trigger remove signal */
744 $this->handle_post_events("remove");
745 }
748 function PrepareForCopyPaste($source)
749 {
750 /* Update available object types */
751 if(isset($source['gosaGroupObjects'][0])){
752 $this->gosaGroupObjects = $source['gosaGroupObjects'][0];
753 }
755 /* Reload tabs */
756 $this->parent->reload($this->gosaGroupObjects );
758 /* Reload plugins */
759 foreach($this->parent->by_object as $name => $class ){
760 if(get_class($this) != $name) {
761 $this->parent->by_object[$name]->PrepareForCopyPaste($source);
762 }
763 }
765 /* Load member objects */
766 if (isset($source['member'])){
767 foreach ($source['member'] as $key => $value){
768 if ("$key" != "count"){
769 $value= @LDAP::convert($value);
770 $this->member["$value"]= "$value";
771 }
772 }
773 }
775 }
778 function getCopyDialog()
779 {
780 $smarty = get_smarty();
781 $smarty->assign("cn", $this->cn);
782 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
783 $ret = array();
784 $ret['string'] = $str;
785 $ret['status'] = "";
786 return($ret);
787 }
789 function saveCopyDialog()
790 {
791 if(isset($_POST['cn'])){
792 $this->cn = $_POST['cn'];
793 }
794 }
797 static function plInfo()
798 {
799 return (array(
800 "plShortName" => _("Generic"),
801 "plDescription" => _("Object group generic"),
802 "plSelfModify" => FALSE,
803 "plDepends" => array(),
804 "plPriority" => 1,
805 "plSection" => array("administration"),
806 "plCategory" => array("ogroups" => array("description" => _("Object groups"),
807 "objectClass" => "gosaGroupOfNames")),
808 "plProvidedAcls"=> array(
809 "cn" => _("Name"),
810 "base" => _("Base"),
811 "description" => _("Description"),
812 "member" => _("Member"))
813 ));
814 }
815 }
817 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
818 ?>