Code

24863ac16eb744738e38fdaea9bd1db22f7c90e1
[gosa.git] / include / class_plugin.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2003  Cajus Pollmeier
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
21 /*! \brief   The plugin base class
22   \author  Cajus Pollmeier <pollmeier@gonicus.de>
23   \version 2.00
24   \date    24.07.2003
26   This is the base class for all plugins. It can be used standalone or
27   can be included by the tabs class. All management should be done 
28   within this class. Extend your plugins from this class.
29  */
31 class plugin
32 {
33   /*!
34     \brief Reference to parent object
36     This variable is used when the plugin is included in tabs
37     and keeps reference to the tab class. Communication to other
38     tabs is possible by 'name'. So the 'fax' plugin can ask the
39     'userinfo' plugin for the fax number.
41     \sa tab
42    */
43   var $parent= NULL;
45   /*!
46     \brief Configuration container
48     Access to global configuration
49    */
50   var $config= NULL;
52   /*!
53     \brief Mark plugin as account
55     Defines whether this plugin is defined as an account or not.
56     This has consequences for the plugin to be saved from tab
57     mode. If it is set to 'FALSE' the tab will call the delete
58     function, else the save function. Should be set to 'TRUE' if
59     the construtor detects a valid LDAP object.
61     \sa plugin::plugin()
62    */
63   var $is_account= FALSE;
64   var $initially_was_account= FALSE;
66   /*!
67     \brief Mark plugin as template
69     Defines whether we are creating a template or a normal object.
70     Has conseqences on the way execute() shows the formular and how
71     save() puts the data to LDAP.
73     \sa plugin::save() plugin::execute()
74    */
75   var $is_template= FALSE;
76   var $ignore_account= FALSE;
77   var $is_modified= FALSE;
79   /*!
80     \brief Represent temporary LDAP data
82     This is only used internally.
83    */
84   var $attrs= array();
86   /* Keep set of conflicting plugins */
87   var $conflicts= array();
89   /* Save unit tags */
90   var $gosaUnitTag= "";
92   /*!
93     \brief Used standard values
95     dn
96    */
97   var $dn= "";
98   var $uid= "";
99   var $sn= "";
100   var $givenName= "";
101   var $acl= "*none*";
102   var $dialog= FALSE;
103   var $snapDialog = NULL;
105   /* attribute list for save action */
106   var $attributes= array();
107   var $objectclasses= array();
108   var $is_new= TRUE;
109   var $saved_attributes= array();
111   var $acl_base= "";
112   var $acl_category= "";
114   /* Plugin identifier */
115   var $plHeadline= "";
116   var $plDescription= "";
118   /*! \brief plugin constructor
120     If 'dn' is set, the node loads the given 'dn' from LDAP
122     \param dn Distinguished name to initialize plugin from
123     \sa plugin()
124    */
125   function plugin ($config, $dn= NULL)
126   {
127     /* Configuration is fine, allways */
128     $this->config= $config;     
129     $this->dn= $dn;
131     /* Handle new accounts, don't read information from LDAP */
132     if ($dn == "new"){
133       return;
134     }
136     /* Save current dn as acl_base */
137     $this->acl_base= $dn;
139     /* Get LDAP descriptor */
140     $ldap= $this->config->get_ldap_link();
141     if ($dn != NULL){
143       /* Load data to 'attrs' and save 'dn' */
144       $ldap->cat ($dn);
145       $this->attrs= $ldap->fetch();
147       /* Copy needed attributes */
148       foreach ($this->attributes as $val){
149         $found= array_key_ics($val, $this->attrs);
150         if ($found != ""){
151           $this->$val= $this->attrs["$found"][0];
152         }
153       }
155       /* gosaUnitTag loading... */
156       if (isset($this->attrs['gosaUnitTag'][0])){
157         $this->gosaUnitTag= $this->attrs['gosaUnitTag'][0];
158       }
160       /* Set the template flag according to the existence of objectClass
161          gosaUserTemplate */
162       if (isset($this->attrs['objectClass'])){
163         if (in_array ("gosaUserTemplate", $this->attrs['objectClass'])){
164           $this->is_template= TRUE;
165           @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
166               "found", "Template check");
167         }
168       }
170       /* Is Account? */
171       error_reporting(0);
172       $found= TRUE;
173       foreach ($this->objectclasses as $obj){
174         if (preg_match('/top/i', $obj)){
175           continue;
176         }
177         if (!isset($this->attrs['objectClass']) || !in_array_ics ($obj, $this->attrs['objectClass'])){
178           $found= FALSE;
179           break;
180         }
181       }
182       error_reporting(E_ALL);
183       if ($found){
184         $this->is_account= TRUE;
185         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,
186             "found", "Object check");
187       }
189       /* Prepare saved attributes */
190       $this->saved_attributes= $this->attrs;
191       foreach ($this->saved_attributes as $index => $value){
192         if (preg_match('/^[0-9]+$/', $index)){
193           unset($this->saved_attributes[$index]);
194           continue;
195         }
196         if (!in_array($index, $this->attributes) && $index != "objectClass"){
197           unset($this->saved_attributes[$index]);
198           continue;
199         }
200         if ($this->saved_attributes[$index]["count"] == 1){
201           $tmp= $this->saved_attributes[$index][0];
202           unset($this->saved_attributes[$index]);
203           $this->saved_attributes[$index]= $tmp;
204           continue;
205         }
207         unset($this->saved_attributes["$index"]["count"]);
208       }
209     }
211     /* Save initial account state */
212     $this->initially_was_account= $this->is_account;
213   }
215   /*! \brief execute plugin
217     Generates the html output for this node
218    */
219   function execute()
220   {
221     /* This one is empty currently. Fabian - please fill in the docu code */
222     $_SESSION['current_class_for_help'] = get_class($this);
223     /* Reset Lock message POST/GET check array, to prevent perg_match errors*/
224     $_SESSION['LOCK_VARS_TO_USE'] =array();
225   }
227   /*! \brief execute plugin
228      Removes object from parent
229    */
230   function remove_from_parent()
231   {
232     /* include global link_info */
233     $ldap= $this->config->get_ldap_link();
235     /* Get current objectClasses in order to add the required ones */
236     $ldap->cat($this->dn);
237     $tmp= $ldap->fetch ();
238     if (isset($tmp['objectClass'])){
239       $oc= $tmp['objectClass'];
240     } else {
241       $oc= array("count" => 0);
242     }
244     /* Remove objectClasses from entry */
245     $ldap->cd($this->dn);
246     $this->attrs= array();
247     $this->attrs['objectClass']= array();
248     for ($i= 0; $i<$oc["count"]; $i++){
249       if (!in_array_ics($oc[$i], $this->objectclasses)){
250         $this->attrs['objectClass'][]= $oc[$i];
251       }
252     }
254     /* Unset attributes from entry */
255     foreach ($this->attributes as $val){
256       $this->attrs["$val"]= array();
257     }
259     /* Unset account info */
260     $this->is_account= FALSE;
262     /* Do not write in plugin base class, this must be done by
263        children, since there are normally additional attribs,
264        lists, etc. */
265     /*
266        $ldap->modify($this->attrs);
267      */
268   }
271   /* Save data to object */
272   function save_object()
273   {
274     /* Save values to object */
275     foreach ($this->attributes as $val){
276       if ($this->acl_is_writeable($val) && isset ($_POST["$val"])){
277         /* Check for modifications */
278         if (get_magic_quotes_gpc()) {
279           $data= stripcslashes($_POST["$val"]);
280         } else {
281           $data= $this->$val = $_POST["$val"];
282         }
283         if ($this->$val != $data){
284           $this->is_modified= TRUE;
285         }
286     
287         /* Okay, how can I explain this fix ... 
288          * In firefox, disabled option fields aren't selectable ... but in IE you can select these fileds. 
289          * So IE posts these 'unselectable' option, with value = chr(194) 
290          * chr(194) seems to be the &nbsp; in between the ...option>&nbsp;</option.. because there is no value=".." specified in these option fields  
291          * This &nbsp; was added for W3c compliance, but now causes these ... ldap errors ... 
292          * So we set these Fields to ""; a normal empty string, and we can check these values in plugin::check() again ...
293          */
294         if(isset($data[0]) && $data[0] == chr(194)) {
295           $data = "";  
296         }
297         $this->$val= $data;
298         //echo "<font color='blue'>".$val."</font><br>";
299       }else{
300         //echo "<font color='red'>".$val."</font><br>";
301       }
302     }
303   }
306   /* Save data to LDAP, depending on is_account we save or delete */
307   function save()
308   {
309     /* include global link_info */
310     $ldap= $this->config->get_ldap_link();
312     /* Start with empty array */
313     $this->attrs= array();
315     /* Get current objectClasses in order to add the required ones */
316     $ldap->cat($this->dn);
317     
318     $tmp= $ldap->fetch ();
319     
320     if (isset($tmp['objectClass'])){
321       $oc= $tmp["objectClass"];
322       $this->is_new= FALSE;
323     } else {
324       $oc= array("count" => 0);
325       $this->is_new= TRUE;
326     }
328     /* Load (minimum) attributes, add missing ones */
329     $this->attrs['objectClass']= $this->objectclasses;
330     for ($i= 0; $i<$oc["count"]; $i++){
331       if (!in_array_ics($oc[$i], $this->objectclasses)){
332         $this->attrs['objectClass'][]= $oc[$i];
333       }
334     }
336     /* Copy standard attributes */
337     foreach ($this->attributes as $val){
338       if ($this->$val != ""){
339         $this->attrs["$val"]= $this->$val;
340       } elseif (!$this->is_new) {
341         $this->attrs["$val"]= array();
342       }
343     }
345   }
348   function cleanup()
349   {
350     foreach ($this->attrs as $index => $value){
352       /* Convert arrays with one element to non arrays, if the saved
353          attributes are no array, too */
354       if (is_array($this->attrs[$index]) && 
355           count ($this->attrs[$index]) == 1 &&
356           isset($this->saved_attributes[$index]) &&
357           !is_array($this->saved_attributes[$index])){
358           
359         $tmp= $this->attrs[$index][0];
360         $this->attrs[$index]= $tmp;
361       }
363       /* Remove emtpy arrays if they do not differ */
364       if (is_array($this->attrs[$index]) &&
365           count($this->attrs[$index]) == 0 &&
366           !isset($this->saved_attributes[$index])){
367           
368         unset ($this->attrs[$index]);
369         continue;
370       }
372       /* Remove single attributes that do not differ */
373       if (!is_array($this->attrs[$index]) &&
374           isset($this->saved_attributes[$index]) &&
375           !is_array($this->saved_attributes[$index]) &&
376           $this->attrs[$index] == $this->saved_attributes[$index]){
378         unset ($this->attrs[$index]);
379         continue;
380       }
382       /* Remove arrays that do not differ */
383       if (is_array($this->attrs[$index]) && 
384           isset($this->saved_attributes[$index]) &&
385           is_array($this->saved_attributes[$index])){
386           
387         if (!array_differs($this->attrs[$index],$this->saved_attributes[$index])){
388           unset ($this->attrs[$index]);
389           continue;
390         }
391       }
392     }
393   }
395   /* Check formular input */
396   function check()
397   {
398     $message= array();
400     /* Skip if we've no config object */
401     if (!isset($this->config)){
402       return $message;
403     }
405     /* Find hooks entries for this class */
406     $command= search_config($this->config->data['MENU'], get_class($this), "CHECK");
407     if ($command == "" && isset($this->config->data['TABS'])){
408       $command= search_config($this->config->data['TABS'], get_class($this), "CHECK");
409     }
411     if ($command != ""){
413       if (!check_command($command)){
414         $message[]= sprintf(_("Command '%s', specified as CHECK hook for plugin '%s' doesn't seem to exist."), $command,
415                             get_class($this));
416       } else {
418         /* Generate "ldif" for check hook */
419         $ldif= "dn: $this->dn\n";
420         
421         /* ... objectClasses */
422         foreach ($this->objectclasses as $oc){
423           $ldif.= "objectClass: $oc\n";
424         }
425         
426         /* ... attributes */
427         foreach ($this->attributes as $attr){
428           if ($this->$attr == ""){
429             continue;
430           }
431           if (is_array($this->$attr)){
432             foreach ($this->$attr as $val){
433               $ldif.= "$attr: $val\n";
434             }
435           } else {
436               $ldif.= "$attr: ".$this->$attr."\n";
437           }
438         }
440         /* Append empty line */
441         $ldif.= "\n";
443         /* Feed "ldif" into hook and retrieve result*/
444         $descriptorspec = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
445         $fh= proc_open($command, $descriptorspec, $pipes);
446         if (is_resource($fh)) {
447           fwrite ($pipes[0], $ldif);
448           fclose($pipes[0]);
449           
450           $result= stream_get_contents($pipes[1]);
451           if ($result != ""){
452             $message[]= $result;
453           }
454           
455           fclose($pipes[1]);
456           fclose($pipes[2]);
457           proc_close($fh);
458         }
459       }
461     }
463     return ($message);
464   }
466   /* Adapt from template, using 'dn' */
467   function adapt_from_template($dn)
468   {
469     /* Include global link_info */
470     $ldap= $this->config->get_ldap_link();
472     /* Load requested 'dn' to 'attrs' */
473     $ldap->cat ($dn);
474     $this->attrs= $ldap->fetch();
476     /* Walk through attributes */
477     foreach ($this->attributes as $val){
479       if (isset($this->attrs["$val"][0])){
481         /* If attribute is set, replace dynamic parts: 
482            %sn, %givenName and %uid. Fill these in our local variables. */
483         $value= $this->attrs["$val"][0];
485         foreach (array("sn", "givenName", "uid") as $repl){
486           if (preg_match("/%$repl/i", $value)){
487             $value= preg_replace ("/%$repl/i", $this->parent->$repl, $value);
488           }
489         }
490         $this->$val= $value;
491       }
492     }
494     /* Is Account? */
495     $found= TRUE;
496     foreach ($this->objectclasses as $obj){
497       if (preg_match('/top/i', $obj)){
498         continue;
499       }
500       if (!in_array_ics ($obj, $this->attrs['objectClass'])){
501         $found= FALSE;
502         break;
503       }
504     }
505     if ($found){
506       $this->is_account= TRUE;
507     }
508   }
510   /* Indicate whether a password change is needed or not */
511   function password_change_needed()
512   {
513     return FALSE;
514   }
517   /* Show header message for tab dialogs */
518   function show_enable_header($button_text, $text, $disabled= FALSE)
519   {
520     if (($disabled == TRUE) || (!$this->acl_is_createable())){
521       $state= "disabled";
522     } else {
523       $state= "";
524     }
525     $display= "<table summary=\"\" width=\"100%\"><tr>\n<td colspan=2><p><b>$text</b></p>\n";
526     $display.= "<input type=submit value=\"$button_text\" name=\"modify_state\" ".$state.
527       "><p class=\"seperator\">&nbsp;</p></td></tr></table>";
529     return($display);
530   }
533   /* Show header message for tab dialogs */
534   function show_disable_header($button_text, $text, $disabled= FALSE)
535   {
536     if (($disabled == TRUE) || !$this->acl_is_removeable()){
537       $state= "disabled";
538     } else {
539       $state= "";
540     }
541     $display= "<table summary=\"\" width=\"100%\"><tr>\n<td colspan=2><p><b>$text</b></p>\n";
542     $display.= "<input type=submit value=\"$button_text\" name=\"modify_state\" ".$state.
543       "><p class=\"seperator\">&nbsp;</p></td></tr></table>";
545     return($display);
546   }
549   /* Show header message for tab dialogs */
550   function show_header($button_text, $text, $disabled= FALSE)
551   {
552     echo "FIXME: show_header should be replaced by show_disable_header and show_enable_header<br>";
553     if ($disabled == TRUE){
554       $state= "disabled";
555     } else {
556       $state= "";
557     }
558     $display= "<table summary=\"\" width=\"100%\"><tr>\n<td colspan=2><p><b>$text</b></p>\n";
559     $display.= "<input type=submit value=\"$button_text\" name=\"modify_state\" ".
560       ($this->acl_is_createable()?'':'disabled')." ".$state.
561       "><p class=\"seperator\">&nbsp;</p></td></tr></table>";
563     return($display);
564   }
567   function postcreate($add_attrs= array())
568   {
569     /* Find postcreate entries for this class */
570     $command= search_config($this->config->data['MENU'], get_class($this), "POSTCREATE");
571     if ($command == "" && isset($this->config->data['TABS'])){
572       $command= search_config($this->config->data['TABS'], get_class($this), "POSTCREATE");
573     }
575     if ($command != ""){
576       /* Walk through attribute list */
577       foreach ($this->attributes as $attr){
578         if (!is_array($this->$attr)){
579           $command= preg_replace("/%$attr/", $this->$attr, $command);
580         }
581       }
582       $command= preg_replace("/%dn/", $this->dn, $command);
584       /* Additional attributes */
585       foreach ($add_attrs as $name => $value){
586         $command= preg_replace("/%$name/", $value, $command);
587       }
589       if (check_command($command)){
590         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
591             $command, "Execute");
593         exec($command);
594       } else {
595         $message= sprintf(_("Command '%s', specified as POSTCREATE for plugin '%s' doesn't seem to exist."), $command, get_class($this));
596         print_red ($message);
597       }
598     }
599   }
601   function postmodify($add_attrs= array())
602   {
603     /* Find postcreate entries for this class */
604     $command= search_config($this->config->data['MENU'], get_class($this), "POSTMODIFY");
605     if ($command == "" && isset($this->config->data['TABS'])){
606       $command= search_config($this->config->data['TABS'], get_class($this), "POSTMODIFY");
607     }
609     if ($command != ""){
610       /* Walk through attribute list */
611       foreach ($this->attributes as $attr){
612         if (!is_array($this->$attr)){
613           $command= preg_replace("/%$attr/", $this->$attr, $command);
614         }
615       }
616       $command= preg_replace("/%dn/", $this->dn, $command);
618       /* Additional attributes */
619       foreach ($add_attrs as $name => $value){
620         $command= preg_replace("/%$name/", $value, $command);
621       }
623       if (check_command($command)){
624         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
625             $command, "Execute");
627         exec($command);
628       } else {
629         $message= sprintf(_("Command '%s', specified as POSTMODIFY for plugin '%s' doesn't seem to exist."), $command, get_class($this));
630         print_red ($message);
631       }
632     }
633   }
635   function postremove($add_attrs= array())
636   {
637     /* Find postremove entries for this class */
638     $command= search_config($this->config->data['MENU'], get_class($this), "POSTREMOVE");
639     if ($command == "" && isset($this->config->data['TABS'])){
640       $command= search_config($this->config->data['TABS'], get_class($this), "POSTREMOVE");
641     }
643     if ($command != ""){
644       /* Walk through attribute list */
645       foreach ($this->attributes as $attr){
646         if (!is_array($this->$attr)){
647           $command= preg_replace("/%$attr/", $this->$attr, $command);
648         }
649       }
650       $command= preg_replace("/%dn/", $this->dn, $command);
652       /* Additional attributes */
653       foreach ($add_attrs as $name => $value){
654         $command= preg_replace("/%$name/", $value, $command);
655       }
657       if (check_command($command)){
658         @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,
659             $command, "Execute");
661         exec($command);
662       } else {
663         $message= sprintf(_("Command '%s', specified as POSTREMOVE for plugin '%s' doesn't seem to exist."), $command, get_class($this));
664         print_red ($message);
665       }
666     }
667   }
669   /* Create unique DN */
670   function create_unique_dn($attribute, $base)
671   {
672     $ldap= $this->config->get_ldap_link();
673     $base= preg_replace("/^,*/", "", $base);
675     /* Try to use plain entry first */
676     $dn= "$attribute=".$this->$attribute.",$base";
677     $ldap->cat ($dn, array('dn'));
678     if (!$ldap->fetch()){
679       return ($dn);
680     }
682     /* Look for additional attributes */
683     foreach ($this->attributes as $attr){
684       if ($attr == $attribute || $this->$attr == ""){
685         continue;
686       }
688       $dn= "$attribute=".$this->$attribute."+$attr=".$this->$attr.",$base";
689       $ldap->cat ($dn, array('dn'));
690       if (!$ldap->fetch()){
691         return ($dn);
692       }
693     }
695     /* None found */
696     return ("none");
697   }
699   function rebind($ldap, $referral)
700   {
701     $credentials= LDAP::get_credentials($referral, $this->config->current['REFERRAL']);
702     if (ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
703       $this->error = "Success";
704       $this->hascon=true;
705       $this->reconnect= true;
706       return (0);
707     } else {
708       $this->error = "Could not bind to " . $credentials['ADMIN'];
709       return NULL;
710     }
711   }
713   /* This is a workaround function. */
714   function copy($src_dn, $dst_dn)
715   {
716     /* Rename dn in possible object groups */
717     $ldap= $this->config->get_ldap_link();
718     $ldap->search('(&(objectClass=gosaGroupOfNames)(member='.@LDAP::fix($src_dn).'))',
719         array('cn'));
720     while ($attrs= $ldap->fetch()){
721       $og= new ogroup($this->config, $ldap->getDN());
722       unset($og->member[$src_dn]);
723       $og->member[$dst_dn]= $dst_dn;
724       $og->save ();
725     }
727     $ldap->cat($dst_dn);
728     $attrs= $ldap->fetch();
729     if (count($attrs)){
730       trigger_error("Trying to overwrite ".@LDAP::fix($dst_dn).", which already exists.",
731           E_USER_WARNING);
732       return (FALSE);
733     }
735     $ldap->cat($src_dn);
736     $attrs= $ldap->fetch();
737     if (!count($attrs)){
738       trigger_error("Trying to move ".@LDAP::fix($src_dn).", which does not seem to exist.",
739           E_USER_WARNING);
740       return (FALSE);
741     }
743     /* Grummble. This really sucks. PHP ldap doesn't support rdn stuff. */
744     $ds= ldap_connect($this->config->current['SERVER']);
745     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
746     if (function_exists("ldap_set_rebind_proc") && isset($this->config->current['REFERRAL'])) {
747       ldap_set_rebind_proc($ds, array(&$this, "rebind"));
748     }
750     $r=ldap_bind($ds,$this->config->current['ADMIN'], $this->config->current['PASSWORD']);
751     error_reporting (0);
752     $sr=ldap_read($ds, @LDAP::fix($src_dn), "objectClass=*");
754     /* Fill data from LDAP */
755     $new= array();
756     if ($sr) {
757       $ei=ldap_first_entry($ds, $sr);
758       if ($ei) {
759         foreach($attrs as $attr => $val){
760           if ($info = ldap_get_values_len($ds, $ei, $attr)){
761             for ($i= 0; $i<$info['count']; $i++){
762               if ($info['count'] == 1){
763                 $new[$attr]= $info[$i];
764               } else {
765                 $new[$attr][]= $info[$i];
766               }
767             }
768           }
769         }
770       }
771     }
773     /* close conncetion */
774     error_reporting (E_ALL);
775     ldap_unbind($ds);
777     /* Adapt naming attribute */
778     $dst_name= preg_replace("/^([^=]+)=.*$/", "\\1", $dst_dn);
779     $dst_val = preg_replace("/^[^=]+=([^,+]+).*,.*$/", "\\1", $dst_dn);
780     $new[$dst_name]= @LDAP::fix($dst_val);
782     /* Check if this is a department.
783      * If it is a dep. && there is a , override in his ou 
784      *  change \2C to , again, else this entry can't be saved ...
785      */
786     if((isset($new['ou'])) &&( preg_match("/\\,/",$new['ou']))){
787       $new['ou'] = preg_replace("/\\\\,/",",",$new['ou']);
788     }
790     /* Save copy */
791     $ldap->connect();
792     $ldap->cd($this->config->current['BASE']);
793     
794     $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $dst_dn));
796     /* FAIvariable=.../..., cn=.. 
797         could not be saved, because the attribute FAIvariable was different to 
798         the dn FAIvariable=..., cn=... */
799     if(in_array_ics("FAIdebconfInfo",$new['objectClass'])){
800       $new['FAIvariable'] = $ldap->fix($new['FAIvariable']);
801     }
802     $ldap->cd($dst_dn);
803     $ldap->add($new);
805     if ($ldap->error != "Success"){
806       trigger_error("Trying to save $dst_dn failed.",
807           E_USER_WARNING);
808       return(FALSE);
809     }
811     return (TRUE);
812   }
815   function move($src_dn, $dst_dn)
816   {
817     /* Copy source to destination */
818     if (!$this->copy($src_dn, $dst_dn)){
819       return (FALSE);
820     }
822     /* Delete source */
823     $ldap= $this->config->get_ldap_link();
824     $ldap->rmdir($src_dn);
825     if ($ldap->error != "Success"){
826       trigger_error("Trying to delete $src_dn failed.",
827           E_USER_WARNING);
828       return (FALSE);
829     }
831     return (TRUE);
832   }
835   /* Move/Rename complete trees */
836   function recursive_move($src_dn, $dst_dn)
837   {
838     /* Check if the destination entry exists */
839     $ldap= $this->config->get_ldap_link();
841     /* Check if destination exists - abort */
842     $ldap->cat($dst_dn, array('dn'));
843     if ($ldap->fetch()){
844       trigger_error("recursive_move $dst_dn already exists.",
845           E_USER_WARNING);
846       return (FALSE);
847     }
849     /* Perform a search for all objects to be moved */
850     $objects= array();
851     $ldap->cd($src_dn);
852     $ldap->search("(objectClass=*)", array("dn"));
853     while($attrs= $ldap->fetch()){
854       $dn= $attrs['dn'];
855       $objects[$dn]= strlen($dn);
856     }
858     /* Sort objects by indent level */
859     asort($objects);
860     reset($objects);
862     /* Copy objects from small to big indent levels by replacing src_dn by dst_dn */
863     foreach ($objects as $object => $len){
864       $src= $object;
865       $dst= preg_replace("/$src_dn$/", "$dst_dn", $object);
866       if (!$this->copy($src, $dst)){
867         return (FALSE);
868       }
869     }
871     /* Remove src_dn */
872     $ldap->cd($src_dn);
873     $ldap->recursive_remove();
874     return (TRUE);
875   }
878   function handle_post_events($mode, $add_attrs= array())
879   {
880     switch ($mode){
881       case "add":
882         $this->postcreate($add_attrs);
883       break;
885       case "modify":
886         $this->postmodify($add_attrs);
887       break;
889       case "remove":
890         $this->postremove($add_attrs);
891       break;
892     }
893   }
896   function saveCopyDialog(){
897   }
900   function getCopyDialog(){
901     return(array("string"=>"","status"=>""));
902   }
905   function PrepareForCopyPaste($source){
906     $todo = $this->attributes;
907     if(isset($this->CopyPasteVars)){
908       $todo = array_merge($todo,$this->CopyPasteVars);
909     }
910     $todo[] = "is_account";
911     foreach($todo as $var){
912       $this->$var = $source->$var;
913     }
914   }
917   function handle_object_tagging($dn= "", $tag= "", $show= false)
918   {
919     //FIXME: How to optimize this? We have at least two
920     //       LDAP accesses per object. It would be a good
921     //       idea to have it integrated.
923     /* No dn? Self-operation... */
924     if ($dn == ""){
925       $dn= $this->dn;
927       /* No tag? Find it yourself... */
928       if ($tag == ""){
929         $len= strlen($dn);
931         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
932         $relevant= array();
933         foreach ($this->config->adepartments as $key => $ntag){
935           /* This one is bigger than our dn, its not relevant... */
936           if ($len <= strlen($key)){
937             continue;
938           }
940           /* This one matches with the latter part. Break and don't fix this entry */
941           if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){
942             @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
943             $relevant[strlen($key)]= $ntag;
944             continue;
945           }
947         }
949         /* If we've some relevant tags to set, just get the longest one */
950         if (count($relevant)){
951           ksort($relevant);
952           $tmp= array_keys($relevant);
953           $idx= end($tmp);
954           $tag= $relevant[$idx];
955           $this->gosaUnitTag= $tag;
956         }
957       }
958     }
961     /* Set tag? */
962     if ($tag != ""){
963       /* Set objectclass and attribute */
964       $ldap= $this->config->get_ldap_link();
965       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
966       $attrs= $ldap->fetch();
967       if(isset($attrs['gosaUnitTag'][0]) && $attrs['gosaUnitTag'][0] == $tag){
968         if ($show) {
969           echo sprintf(_("Object '%s' is already tagged"), @LDAP::fix($dn))."<br>";
970           flush();
971         }
972         return;
973       }
974       if (count($attrs)){
975         if ($show){
976           echo sprintf(_("Adding tag (%s) to object '%s'"), $tag, @LDAP::fix($dn))."<br>";
977           flush();
978         }
979         $nattrs= array("gosaUnitTag" => $tag);
980         $nattrs['objectClass']= array();
981         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
982           $oc= $attrs['objectClass'][$i];
983           if ($oc != "gosaAdministrativeUnitTag"){
984             $nattrs['objectClass'][]= $oc;
985           }
986         }
987         $nattrs['objectClass'][]= "gosaAdministrativeUnitTag";
988         $ldap->cd($dn);
989         $ldap->modify($nattrs);
990         show_ldap_error($ldap->get_error(), sprintf(_("Handle object tagging with dn '%s' failed."),$dn));
991       } else {
992         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not tagging ($tag) $dn - seems to have moved away", "Tagging");
993       }
995     } else {
996       /* Remove objectclass and attribute */
997       $ldap= $this->config->get_ldap_link();
998       $ldap->cat($dn, array('gosaUnitTag', 'objectClass'));
999       $attrs= $ldap->fetch();
1000       if (isset($attrs['objectClass']) && !in_array_ics("gosaAdministrativeUnitTag", $attrs['objectClass'])){
1001         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "$dn is not tagged", "Tagging");
1002         return;
1003       }
1004       if (count($attrs)){
1005         if ($show){
1006           echo sprintf(_("Removing tag from object '%s'"), @LDAP::fix($dn))."<br>";
1007           flush();
1008         }
1009         $nattrs= array("gosaUnitTag" => array());
1010         $nattrs['objectClass']= array();
1011         for ($i= 0; $i<$attrs['objectClass']['count']; $i++){
1012           $oc= $attrs['objectClass'][$i];
1013           if ($oc != "gosaAdministrativeUnitTag"){
1014             $nattrs['objectClass'][]= $oc;
1015           }
1016         }
1017         $ldap->cd($dn);
1018         $ldap->modify($nattrs);
1019         show_ldap_error($ldap->get_error(), sprintf(_("Handle object tagging with dn '%s' failed."),$dn));
1020       } else {
1021         @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "Not removing tag ($tag) $dn - seems to have moved away", "Tagging");
1022       }
1023     }
1025   }
1028   /* Add possibility to stop remove process */
1029   function allow_remove()
1030   {
1031     $reason= "";
1032     return $reason;
1033   }
1036   /* Create a snapshot of the current object */
1037   function create_snapshot($type= "snapshot", $description= array())
1038   {
1040     /* Check if snapshot functionality is enabled */
1041     if(!$this->snapshotEnabled()){
1042       return;
1043     }
1045     /* Get configuration from gosa.conf */
1046     $tmp = $this->config->current;
1048     /* Create lokal ldap connection */
1049     $ldap= $this->config->get_ldap_link();
1050     $ldap->cd($this->config->current['BASE']);
1052     /* check if there are special server configurations for snapshots */
1053     if(!isset($tmp['SNAPSHOT_SERVER'])){
1055       /* Source and destination server are both the same, just copy source to dest obj */
1056       $ldap_to      = $ldap;
1057       $snapldapbase = $this->config->current['BASE'];
1059     }else{
1060       $server         = $tmp['SNAPSHOT_SERVER'];
1061       $user           = $tmp['SNAPSHOT_USER'];
1062       $password       = $tmp['SNAPSHOT_PASSWORD'];
1063       $snapldapbase   = $tmp['SNAPSHOT_LDAP_BASE'];
1065       $ldap_to        = new LDAP($user,$password, $server);
1066       $ldap_to -> cd($snapldapbase);
1067       show_ldap_error($ldap->get_error(), sprintf(_("Saving object snapshot with dn '%s' failed."),$snapldapbase));
1068     }
1070     /* check if the dn exists */ 
1071     if ($ldap->dn_exists($this->dn)){
1073       /* Extract seconds & mysecs, they are used as entry index */
1074       list($usec, $sec)= explode(" ", microtime());
1076       /* Collect some infos */
1077       $base           = $this->config->current['BASE'];
1078       $snap_base      = $tmp['SNAPSHOT_BASE'];
1079       $base_of_object = preg_replace ('/^[^,]+,/i', '', $this->dn);
1080       $new_base       = preg_replace("/".normalizePreg($base)."$/","",$base_of_object).$snap_base;
1082       /* Create object */
1083 #$data             = preg_replace('/^dn:.*\n/', '', $ldap->gen_ldif($this->dn,"(!(objectClass=gosaDepartment))"));
1084       $data             = $ldap->gen_ldif($this->dn,"(&(!(objectClass=gosaDepartment))(!(objectClass=FAIclass)))");
1085       $newName          = preg_replace("/\./", "", $sec."-".$usec);
1086       $target= array();
1087       $target['objectClass']            = array("top", "gosaSnapshotObject");
1088       $target['gosaSnapshotData']       = gzcompress($data, 6);
1089       $target['gosaSnapshotType']       = $type;
1090       $target['gosaSnapshotDN']         = $this->dn;
1091       $target['description']            = $description;
1092       $target['gosaSnapshotTimestamp']  = $newName;
1094       /* Insert the new snapshot 
1095          But we have to check first, if the given gosaSnapshotTimestamp
1096          is already used, in this case we should increment this value till there is 
1097          an unused value. */ 
1098       $new_dn                           = "gosaSnapshotTimestamp=".$newName.",".$new_base;
1099       $ldap_to->cat($new_dn);
1100       while($ldap_to->count()){
1101         $ldap_to->cat($new_dn);
1102         $newName = preg_replace("/\./", "", $sec."-".($usec++));
1103         $new_dn                           = "gosaSnapshotTimestamp=".$newName.",".$new_base;
1104         $target['gosaSnapshotTimestamp']  = $newName;
1105       } 
1107       /* Inset this new snapshot */
1108       $ldap_to->cd($snapldapbase);
1109       $ldap_to->create_missing_trees($new_base);
1110       $ldap_to->cd($new_dn);
1111       $ldap_to->add($target);
1113       show_ldap_error($ldap->get_error(), sprintf(_("Saving object snapshot with dn '%s' failed."),$new_base));
1114       show_ldap_error($ldap_to->get_error(), sprintf(_("Saving object snapshot with dn '%s' failed."),$new_base));
1115     }
1116   }
1118   function remove_snapshot($dn)
1119   {
1120 echo "FIXME: remove_snapshot uses old acl's<br>";
1121     $ui   = get_userinfo();
1122     $acl  = get_permissions ($dn, $ui->subtreeACL);
1123     $acl  = get_module_permission($acl, "snapshot", $dn);
1125     if (chkacl($this->acl, "delete") == ""){
1126       $ldap = $this->config->get_ldap_link();
1127       $ldap->cd($this->config->current['BASE']);
1128       $ldap->rmdir_recursive($dn);
1129     }else{
1130       print_red (_("You are not allowed to delete this snapshot!"));
1131     }
1132   }
1135   /* returns true if snapshots are enabled, and false if it is disalbed
1136      There will also be some errors psoted, if the configuration failed */
1137   function snapshotEnabled()
1138   {
1139     $tmp = $this->config->current;
1140     if(isset($tmp['ENABLE_SNAPSHOT'])){
1141       if (preg_match("/^true$/i", $tmp['ENABLE_SNAPSHOT']) || preg_match("/yes/i", $tmp['ENABLE_SNAPSHOT'])){
1143         /* Check if the snapshot_base is defined */
1144         if(!isset($tmp['SNAPSHOT_BASE'])){
1145           print_red(sprintf(_("The snapshot functionality is enabled, but the required variable '%s' is not configured in your gosa.conf."),$missing));
1146           return(FALSE);
1147         }
1149         /* check if there are special server configurations for snapshots */
1150         if(isset($tmp['SNAPSHOT_SERVER'])){
1152           /* check if all required vars are available to create a new ldap connection */
1153           $missing = "";
1154           foreach(array("SNAPSHOT_SERVER","SNAPSHOT_USER","SNAPSHOT_PASSWORD","SNAPSHOT_LDAP_BASE") as $var){
1155             if(!isset($tmp[$var])){
1156               $missing .= $var." ";
1157               print_red(sprintf(_("The snapshot functionality is enabled, but the required variable(s) '%s' is not configured in your gosa.conf."),$missing));
1158               return(FALSE);
1159             }
1160           }
1161         }
1162         return(TRUE);
1163       }
1164     }
1165     return(FALSE);
1166   }
1169   /* Return available snapshots for the given base 
1170    */
1171   function Available_SnapsShots($dn,$raw = false)
1172   {
1173     if(!$this->snapshotEnabled()) return(array());
1175     /* Create an additional ldap object which
1176        points to our ldap snapshot server */
1177     $ldap= $this->config->get_ldap_link();
1178     $ldap->cd($this->config->current['BASE']);
1179     $tmp = $this->config->current;
1181     /* check if there are special server configurations for snapshots */
1182     if(isset($tmp['SNAPSHOT_SERVER'])){
1183       $server       = $tmp['SNAPSHOT_SERVER'];
1184       $user         = $tmp['SNAPSHOT_USER'];
1185       $password     = $tmp['SNAPSHOT_PASSWORD'];
1186       $snapldapbase = $tmp['SNAPSHOT_LDAP_BASE'];
1187       $ldap_to      = new LDAP($user,$password, $server);
1188       $ldap_to -> cd ($snapldapbase);
1189       show_ldap_error($ldap->get_error(), sprintf(_("Method get available snapshots with dn '%s' failed."),$this->dn));
1190     }else{
1191       $ldap_to    = $ldap;
1192     }
1194     /* Prepare bases and some other infos */
1195     $base           = $this->config->current['BASE'];
1196     $snap_base      = $tmp['SNAPSHOT_BASE'];
1197     $base_of_object = preg_replace ('/^[^,]+,/i', '', $dn);
1198     $new_base       = preg_replace("/".normalizePreg($base)."$/","",$base_of_object).$snap_base;
1199     $tmp            = array(); 
1201     /* Fetch all objects with  gosaSnapshotDN=$dn */
1202     $ldap_to->cd($new_base);
1203     $ldap_to->ls("(&(objectClass=gosaSnapshotObject)(gosaSnapshotDN=".$dn."))",$new_base,
1204         array("gosaSnapshotType","gosaSnapshotTimestamp","gosaSnapshotDN","description")); 
1206     /* Put results into a list and add description if missing */
1207     while($entry = $ldap_to->fetch()){ 
1208       if(!isset($entry['description'][0])){
1209         $entry['description'][0]  = "";
1210       }
1211       $tmp[] = $entry; 
1212     }
1214     /* Return the raw array, or format the result */
1215     if($raw){
1216       return($tmp);
1217     }else{  
1218       $tmp2 = array();
1219       foreach($tmp as $entry){
1220         $tmp2[base64_encode($entry['dn'])] = $entry['description'][0]; 
1221       }
1222     }
1223     return($tmp2);
1224   }
1227   function getAllDeletedSnapshots($base_of_object,$raw = false)
1228   {
1229     if(!$this->snapshotEnabled()) return(array());
1231     /* Create an additional ldap object which
1232        points to our ldap snapshot server */
1233     $ldap= $this->config->get_ldap_link();
1234     $ldap->cd($this->config->current['BASE']);
1235     $tmp = $this->config->current;
1237     /* check if there are special server configurations for snapshots */
1238     if(isset($tmp['SNAPSHOT_SERVER'])){
1239       $server       = $tmp['SNAPSHOT_SERVER'];
1240       $user         = $tmp['SNAPSHOT_USER'];
1241       $password     = $tmp['SNAPSHOT_PASSWORD'];
1242       $snapldapbase = $tmp['SNAPSHOT_LDAP_BASE'];
1243       $ldap_to      = new LDAP($user,$password, $server);
1244       $ldap_to->cd ($snapldapbase);
1245       show_ldap_error($ldap->get_error(), sprintf(_("Method get deleted snapshots with dn '%s' failed."),$this->dn));
1246     }else{
1247       $ldap_to    = $ldap;
1248     }
1250     /* Prepare bases */ 
1251     $base           = $this->config->current['BASE'];
1252     $snap_base      = $tmp['SNAPSHOT_BASE'];
1253     $new_base       = preg_replace("/".normalizePreg($base)."$/","",$base_of_object).$snap_base;
1255     /* Fetch all objects and check if they do not exist anymore */
1256     $ui = get_userinfo();
1257     $tmp = array();
1258     $ldap_to->cd($new_base);
1259     $ldap_to->ls("(objectClass=gosaSnapshotObject)",$new_base,array("gosaSnapshotType","gosaSnapshotTimestamp","gosaSnapshotDN","description"));
1260     while($entry = $ldap_to->fetch()){
1262       $chk =  str_replace($new_base,"",$entry['dn']);
1263       if(preg_match("/,ou=/",$chk)) continue;
1265       if(!isset($entry['description'][0])){
1266         $entry['description'][0]  = "";
1267       }
1268       $tmp[] = $entry; 
1269     }
1271     /* Check if entry still exists */
1272     foreach($tmp as $key => $entry){
1273       $ldap->cat($entry['gosaSnapshotDN'][0]);
1274       if($ldap->count()){
1275         unset($tmp[$key]);
1276       }
1277     }
1279     /* Format result as requested */
1280     if($raw) {
1281       return($tmp);
1282     }else{
1283       $tmp2 = array();
1284       foreach($tmp as $key => $entry){
1285         $tmp2[base64_encode($entry['dn'])] = $entry['description'][0]; 
1286       }
1287     }
1288     return($tmp2);
1289   } 
1292   /* Restore selected snapshot */
1293   function restore_snapshot($dn)
1294   {
1295     if(!$this->snapshotEnabled()) return(array());
1297     $ldap= $this->config->get_ldap_link();
1298     $ldap->cd($this->config->current['BASE']);
1299     $tmp = $this->config->current;
1301     /* check if there are special server configurations for snapshots */
1302     if(isset($tmp['SNAPSHOT_SERVER'])){
1303       $server       = $tmp['SNAPSHOT_SERVER'];
1304       $user         = $tmp['SNAPSHOT_USER'];
1305       $password     = $tmp['SNAPSHOT_PASSWORD'];
1306       $snapldapbase = $tmp['SNAPSHOT_LDAP_BASE'];
1307       $ldap_to      = new LDAP($user,$password, $server);
1308       $ldap_to->cd ($snapldapbase);
1309       show_ldap_error($ldap->get_error(), sprintf(_("Restore snapshot with dn '%s' failed."),$snapldapbase));
1310     }else{
1311       $ldap_to    = $ldap;
1312     }
1314     /* Get the snapshot */ 
1315     $ldap_to->cat($dn);
1316     $restoreObject = $ldap_to->fetch();
1318     /* Prepare import string */
1319     $data  = gzuncompress($ldap_to->get_attribute($dn,'gosaSnapshotData'));
1321     /* Import the given data */
1322     $ldap->import_complete_ldif($data,$err,false,false);
1323     show_ldap_error($ldap->get_error(), sprintf(_("Restore snapshot with dn '%s' failed."),$dn));
1324   }
1327   function showSnapshotDialog($base,$baseSuffixe)
1328   {
1329     $once = true;
1330     foreach($_POST as $name => $value){
1332       /* Create a new snapshot, display a dialog */
1333       if(preg_match("/^CreateSnapShotDialog_/",$name) && $once){
1334         $once = false;
1335         $entry = preg_replace("/^CreateSnapShotDialog_/","",$name);
1336         $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
1337         $this->snapDialog = new SnapShotDialog($this->config,$entry,$this);
1338       }
1340       /* Restore a snapshot, display a dialog with all snapshots of the current object */
1341       if(preg_match("/^RestoreSnapShotDialog_/",$name) && $once){
1342         $once = false;
1343         $entry = preg_replace("/^RestoreSnapShotDialog_/","",$name);
1344         $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
1345         $this->snapDialog = new SnapShotDialog($this->config,$entry,$this);
1346         $this->snapDialog->display_restore_dialog = true;
1347       }
1349       /* Restore one of the already deleted objects */
1350       if(preg_match("/^RestoreDeletedSnapShot_/",$name) && $once){
1351         $once = false;
1352         $this->snapDialog = new SnapShotDialog($this->config,$baseSuffixe,$this);
1353         $this->snapDialog->display_restore_dialog      = true;
1354         $this->snapDialog->display_all_removed_objects  = true;
1355       }
1357       /* Restore selected snapshot */
1358       if(preg_match("/^RestoreSnapShot_/",$name) && $once){
1359         $once = false;
1360         $entry = preg_replace("/^RestoreSnapShot_/","",$name);
1361         $entry = base64_decode(trim(preg_replace("/_[xy]$/","",$entry)));
1362         if(!empty($entry)){
1363           $this->restore_snapshot($entry);
1364           $this->snapDialog = NULL;
1365         }
1366       }
1367     }
1369     /* Create a new snapshot requested, check
1370        the given attributes and create the snapshot*/
1371     if(isset($_POST['CreateSnapshot'])){
1372       $this->snapDialog->save_object();
1373       $msgs = $this->snapDialog->check();
1374       if(count($msgs)){
1375         foreach($msgs as $msg){
1376           print_red($msg);
1377         }
1378       }else{
1379         $this->dn =  $this->snapDialog->dn;
1380         $this->create_snapshot("snapshot",$this->snapDialog->CurrentDescription);
1381         $this->snapDialog = NULL;
1382       }
1383     }
1385     /* Restore is requested, restore the object with the posted dn .*/
1386     if((isset($_POST['RestoreSnapshot'])) && (isset($_POST['SnapShot']))){
1387     }
1389     if(isset($_POST['CancelSnapshot'])){
1390       $this->snapDialog = NULL;
1391     }
1393     if($this->snapDialog){
1394       $this->snapDialog->save_object();
1395       return($this->snapDialog->execute());
1396     }
1397   }
1400   function plInfo()
1401   {
1402     return array();
1403   }
1406   function set_acl_base($base)
1407   {
1408     $this->acl_base= $base;
1409   }
1412   function set_acl_category($category)
1413   {
1414     $this->acl_category= "$category/";
1415   }
1418   function acl_is_writeable($attribute,$skip_write = FALSE)
1419   {
1420     $ui= get_userinfo();
1421     return preg_match('/w/', $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), $attribute, $skip_write));
1422   }
1425   function acl_is_readable($attribute)
1426   {
1427     $ui= get_userinfo();
1428     return preg_match('/r/', $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), $attribute));
1429   }
1432   function acl_is_createable()
1433   {
1434     $ui= get_userinfo();
1435     return preg_match('/c/', $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), '0'));
1436   }
1439   function acl_is_removeable()
1440   {
1441     $ui= get_userinfo();
1442     return preg_match('/d/', $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), '0'));
1443   }
1446   function acl_is_moveable()
1447   {
1448     $ui= get_userinfo();
1449     return preg_match('/m/', $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), '0'));
1450   }
1453   function acl_have_any_permissions()
1454   {
1455   }
1458   function getacl($attribute,$skip_write= FALSE)
1459   {
1460     $ui= get_userinfo();
1461     return  $ui->get_permissions($this->acl_base, $this->acl_category.get_class($this), $attribute,$skip_write);
1462   }
1466 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1467 ?>