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", "macAddress"));
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'];
529 if(isset($attrs['macAddress'][0])){
530 $this->objcache[$attrs["dn"]]['macAddress'] = $attrs['macAddress'][0];
531 }else{
532 $this->objcache[$attrs["dn"]]['macAddress'] = "";
533 }
535 if(isset($attrs['uid'])){
536 $this->objcache[$attrs["dn"]]['uid'] = $attrs['uid'];
537 }
539 /* Fill array */
540 if (isset($attrs["description"][0])){
541 $this->objects[$attrs["dn"]]= array("text" => "$name [".$attrs["description"][0]."]", "type" => "$type");
542 } else {
543 $this->objects[$attrs["dn"]]= array("text" => "$name", "type" => "$type");
544 }
546 $this->memberList[$dn]= $this->objects[$attrs["dn"]];
547 }
548 }
549 uasort ($this->memberList, 'sort_list');
550 reset ($this->memberList);
552 /* Assemble types of currently combined objects */
553 $objectTypes= "";
554 foreach ($this->memberList as $dn => $desc){
556 /* Invalid object? */
557 if ($desc['type'] == 'I'){
558 continue;
559 }
561 /* Fine. Add to list. */
562 if (!preg_match('/'.$desc['type'].'/', $objectTypes)){
563 $objectTypes.= $desc['type'];
564 }
565 }
566 $this->gosaGroupObjects= "[$objectTypes]";
567 }
570 function convert_list($input)
571 {
572 $temp= "";
573 $conv= array( "U" => "select_user.png",
574 "G" => "select_groups.png",
575 "A" => "select_application.png",
576 "D" => "select_department.png",
577 "S" => "select_server.png",
578 "W" => "select_workstation.png",
579 "O" => "select_winstation.png",
580 "T" => "select_terminal.png",
581 "F" => "select_phone.png",
582 "I" => "flag.png",
583 "P" => "select_printer.png");
585 foreach ($input as $key => $value){
586 /* Generate output */
587 $temp.= "<option title='".addslashes( $key)."' value=\"$key\" class=\"select\" style=\"background-image:url('".get_template_path("images/".$conv[$value['type']])."');\">".$value['text']."</option>\n";
588 }
590 return ($temp);
591 }
594 function getObjectType($attrs)
595 {
596 $type= "I";
598 foreach(array( "U" => "gosaAccount",
599 "G" => "posixGroup",
600 "A" => "gosaApplication",
601 "D" => "gosaDepartment",
602 "S" => "goServer",
603 "W" => "gotoWorkstation",
604 "O" => "opsiClient",
605 "T" => "gotoTerminal",
606 "F" => "goFonHardware",
607 "P" => "gotoPrinter") as $index => $class){
608 if (in_array($class, $attrs['objectClass'])){
609 $type= $index;
610 break;
611 }
612 }
614 return ($type);
615 }
618 function getObjectName($attrs)
619 {
620 /* Person? */
621 $name ="";
622 if (in_array('gosaAccount', $attrs['objectClass'])){
623 if(isset($attrs['sn']) && isset($attrs['givenName'])){
624 $name= $attrs['sn'][0].", ".$attrs['givenName'][0];
625 } else {
626 $name= $attrs['uid'][0];
627 }
628 } else {
629 if(isset($attrs["cn"][0])) {
630 $name= $attrs['cn'][0];
631 } else {
632 $name= $attrs['ou'][0];
633 }
634 }
636 return ($name);
637 }
640 function check()
641 {
642 /* Call common method to give check the hook */
643 $message= plugin::check();
645 /* Permissions for that base? */
646 if ($this->base != ""){
647 $new_dn= 'cn='.$this->cn.','.get_ou('ogroupou').$this->base;
648 } else {
649 $new_dn= $this->dn;
650 }
653 $ldap = $this->config->get_ldap_link();
654 if($this->dn != $new_dn){
655 $ldap->cat ($new_dn, array('dn'));
656 }
658 if($ldap->count() !=0){
659 $message[]= msgPool::duplicated(_("Name"));
660 }
662 /* Set new acl base */
663 if($this->dn == "new") {
664 $this->set_acl_base($this->base);
665 }
667 /* must: cn */
668 if ($this->cn == ""){
669 $message[]= msgPool::required(_("Name"));
670 }
672 /* To many different object types? */
673 if (strlen($this->gosaGroupObjects) > 4){
674 $message[]= _("You can combine two different object types at maximum, only!");
675 }
677 return ($message);
678 }
681 /* Save to LDAP */
682 function save()
683 {
684 plugin::save();
686 /* Move members to target array */
687 $this->attrs['member'] =array();
688 foreach ($this->member as $key => $desc){
689 $this->attrs['member'][]= @LDAP::fix($key);
690 }
692 $ldap= $this->config->get_ldap_link();
694 /* New accounts need proper 'dn', propagate it to remaining objects */
695 if ($this->dn == 'new'){
696 $this->dn= 'cn='.$this->cn.','.get_ou('ogroupou').$this->base;
697 }
699 /* Save data. Using 'modify' implies that the entry is already present, use 'add' for
700 new entries. So do a check first... */
701 $ldap->cat ($this->dn, array('dn'));
702 if ($ldap->fetch()){
703 /* Modify needs array() to remove values :-( */
704 if (!count ($this->member)){
705 $this->attrs['member']= array();
706 }
707 $mode= "modify";
709 } else {
710 $mode= "add";
711 $ldap->cd($this->config->current['BASE']);
712 $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
713 }
715 /* Write back to ldap */
716 $ldap->cd($this->dn);
717 $this->cleanup();
718 $ldap->$mode($this->attrs);
720 if($mode == "add"){
721 new log("create","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
722 }else{
723 new log("modify","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
724 }
726 /* Trigger post signal */
727 $this->handle_post_events($mode);
729 $ret= 0;
730 if (!$ldap->success()){
731 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
732 $ret= 1;
733 }
735 return ($ret);
736 }
738 function remove_from_parent()
739 {
740 plugin::remove_from_parent();
742 $ldap= $this->config->get_ldap_link();
743 $ldap->rmdir($this->dn);
744 if (!$ldap->success()){
745 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
746 }
748 new log("remove","ogroups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
750 /* Trigger remove signal */
751 $this->handle_post_events("remove");
752 }
755 function PrepareForCopyPaste($source)
756 {
757 /* Update available object types */
758 if(isset($source['gosaGroupObjects'][0])){
759 $this->gosaGroupObjects = $source['gosaGroupObjects'][0];
760 }
762 /* Reload tabs */
763 $this->parent->reload($this->gosaGroupObjects );
765 /* Reload plugins */
766 foreach($this->parent->by_object as $name => $class ){
767 if(get_class($this) != $name) {
768 $this->parent->by_object[$name]->PrepareForCopyPaste($source);
769 }
770 }
772 /* Load member objects */
773 if (isset($source['member'])){
774 foreach ($source['member'] as $key => $value){
775 if ("$key" != "count"){
776 $value= @LDAP::convert($value);
777 $this->member["$value"]= "$value";
778 }
779 }
780 }
782 }
785 function getCopyDialog()
786 {
787 $smarty = get_smarty();
788 $smarty->assign("cn", $this->cn);
789 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
790 $ret = array();
791 $ret['string'] = $str;
792 $ret['status'] = "";
793 return($ret);
794 }
796 function saveCopyDialog()
797 {
798 if(isset($_POST['cn'])){
799 $this->cn = $_POST['cn'];
800 }
801 }
804 static function plInfo()
805 {
806 return (array(
807 "plShortName" => _("Generic"),
808 "plDescription" => _("Object group generic"),
809 "plSelfModify" => FALSE,
810 "plDepends" => array(),
811 "plPriority" => 1,
812 "plSection" => array("administration"),
813 "plCategory" => array("ogroups" => array("description" => _("Object groups"),
814 "objectClass" => "gosaGroupOfNames")),
815 "plProvidedAcls"=> array(
816 "cn" => _("Name"),
817 "base" => _("Base"),
818 "description" => _("Description"),
819 "member" => _("Member"))
820 ));
821 }
822 }
824 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
825 ?>