Code

Added mechanisms to disable/deactivate plugins if requirements are not fulfilled.
[gosa.git] / gosa-core / include / class_configRegistry.inc
1 <?php
3 class configRegistry{
5     public $config = NULL;
6     public $properties = array();
7     public $ldapStoredProperties = array(); 
8     public $fileStoredProperties = array(); 
9     public $classToName = array(); 
11     public $status = 'none';
13     // Excludes property values defined in ldap 
14     public $ignoreLdapProperties = FALSE;
16     // Contains all classes with plInfo
17     public $classesWithInfo = array();
18     public $pluginRequirements  = array();
19     public $categoryToClass  = array();
21     public $objectClasses = array();
23     public $detectedSchemaIssues = array();
24     public $schemaCheckFailed = FALSE;
25     public $schemaCheckFinished = FALSE;
26     public $pluginsDeactivated = array();
28     function __construct($config)
29     {
30         $this->config = &$config;
32         // Detect classes that have a plInfo method 
33         global $class_mapping;
34         foreach ($class_mapping as $cname => $path){
35             $cmethods = get_class_methods($cname);
36             if (is_array($cmethods) && in_array_ics('plInfo',$cmethods)){
38                 // Get plugin definitions
39                 $def = call_user_func(array($cname, 'plInfo'));;
41                 // Register Post Events (postmodfiy,postcreate,postremove,checkhook)
42                 if(count($def)){
43                     $this->classesWithInfo[$cname] = $def;
44                 }
45             }
46         }
48         // (Re)Load properties
49         $this->reload();
50     }
52     
53     function schemaCheckFinished()
54     {
55         return($this->schemaCheckFinished);
56     }
59     function validateSchemata($force = FALSE, $disableIncompatiblePlugins = FALSE)
60     {
61         // We can check the schemata only with a valid LDAP connection
62         if(empty($this->config->current['CONFIG'])){
63             return(TRUE); 
64         }
66         // Don't do things twice unless forced
67         if($this->schemaCheckFinished && !$force) return($this->schemaCheckFailed); 
69         // Prepare result array
70         $this->detectedSchemaIssues = array();
71         $this->detectedSchemaIssues['missing'] = array();
72         $this->detectedSchemaIssues['versionMismatch'] = array();
74         // Clear last results 
75         $this->pluginsDeactivated = array();
77         // Read objectClasses from ldap
78         if(!count($this->objectClasses)){
79             $ldap = $this->config->get_ldap_link();
80             $ldap->cd($this->config->current['BASE']);
81             $this->objectClasses = $ldap->get_objectclasses();
82         }
84         // Collect required schema infos
85         $this->pluginRequirements = array('ldapSchema' => array());
86         $this->categoryToClass = array();
87         foreach($this->classesWithInfo as $cname => $defs){
88             if(isset($defs['plRequirements'])){
89                 $this->pluginRequirements[$cname] = $defs['plRequirements'];
90             }
91         }
93         // Check schema requirements now        $missing = $invalid = array();
94         foreach($this->pluginRequirements as $cname => $requirements){
96             // Check LDAP schema requirements for this plugins
97             $failure = FALSE;
98             if(isset($requirements['ldapSchema'])){
99                 foreach($requirements['ldapSchema'] as $oc => $version){
100                     if(1 || !$this->ocAvailable($oc)){
101                         $this->detectedSchemaIssues['missing'][] = $oc;
102                         $this->schemaCheckFailed = TRUE;
103                         $failure = TRUE;
104                     }elseif(!empty($version)){
105                         $currentVersion = $this->getObjectClassVersion($oc);
106                         if(!empty($currentVersion) && !$this->ocVersionMatch($version, $currentVersion)){
107                             if($currentVersion == -1){
108                                 $currentVersion = _("unknown");
109                             }
110                             $this->detectedSchemaIssues['versionMismatch'] = 
111                                 sprintf(_("%s has version %s but %s required!"), bold($oc),bold($currentVersion),bold($version));
112                             $this->schemaCheckFailed = TRUE;
113                             $failure = TRUE;
114                         }
115                     }
116                 }
117             }
119             // Display corresponding plugins now 
120             if($disableIncompatiblePlugins && $failure && isset($requirements['onFailureDisablePlugin'])){
121                 foreach($requirements['onFailureDisablePlugin'] as $name){
122                     $this->pluginsDeactivated[$name] = $name;
123                 } 
124             }
125         }
126         $this->schemaCheckFinished =TRUE;
127         session::un_set('plist');
128         return(!$this->schemaCheckFailed);
129     }
131     
132     function getDisabledPlugins()
133     {
134         return($this->pluginsDeactivated);
135     }
137         
138     function displayErrors()
139     {
140         if(count($this->detectedSchemaIssues['missing'])){
141             msg_dialog::display(_("Schema validation error"), 
142                     _("The following objectClasses are missing:").
143                     "<div class='scrollContainer' style='height:100px'>".
144                     msgPool::buildList($this->detectedSchemaIssues['missing']).
145                     "</div>",
146                     ERROR_DIALOG);
147         }    
148         if(count($this->detectedSchemaIssues['versionMismatch'])){
149             msg_dialog::display(_("Schema validation error"), 
150                     _("The following objectClasses do not match the version requirements:").
151                     "<div class='scrollContainer' style='height:100px'>".
152                     msgPool::buildList($this->detectedSchemaIssues['versionMismatch']).
153                     "</div>",
154                     ERROR_DIALOG);
155         }    
156     }
159     function ocVersionMatch($required, $installed)
160     {
161         $operator = preg_replace('/^([=<>]*).*$/',"\\1",$required);
162         $required = preg_replace('/^[=<>]*(.*)$/',"\\1",$required);
163         return(version_compare($installed,$required, $operator)); 
164     }
166     
167     function getObjectClassVersion($oc)
168     {
169         if(!isset($this->objectClasses[$oc])){
170             return(NULL);
171         }else{
172             $version = -1; // unknown
173             if(preg_match("/(v[^)]*)/", $this->objectClasses[$oc]['DESC'])){
174                 $version = preg_replace('/^.*\(v([^)]*)\).*$/',"\\1", $this->objectClasses[$oc]['DESC']);
175             }
176         }
177         return($version);
178     }
179     
181     // check wheter an objectClass is installed or not.
182     function ocAvailable($name)
183     {
184         return(isset($this->objectClasses[$name]));
185     }
188     function reload($force = FALSE)
189     {
190         // Do not reload the properties everytime, once we have  
191         //  everything loaded and registrered skip the reload.
192         // Status is 'finished' once we had a ldap connection (logged in)
193         if(!$force && $this->status == 'finished') return;
195         // Reset everything
196         $this->ldapStoredProperties = array();
197         $this->fileStoredProperties = array();
198         $this->properties = array();
199         $this->mapByName = array();
201         // Search for config flags defined in the config file (TAB section)
202         foreach($this->config->data['TABS'] as $tabname => $tabdefs){
203             foreach($tabdefs as $info){
205                 // Check if the info is valid
206                 if(isset($info['NAME']) && isset($info['CLASS'])){
208                     // Check if there is nore than just the plugin definition
209                     if(count($info) > 2){
210                         foreach($info as $name => $value){
211                             
212                             if(!in_array($name, array('CLASS','NAME'))){
213                                 $class= $info['CLASS'];    
214                                 $this->fileStoredProperties[$class][strtolower($name)] = $value;
215                             }
216                         }
217                     }
218                 }
219             }
220         }
222         // Search for config flags defined in the config file (MENU section)
223         foreach($this->config->data['MENU'] as $section => $entries){
224             foreach($entries as $entry){
225                 if(count($entry) > 2 && isset($entry['CLASS'])){
226                     $class = $entry['CLASS'];
227                     foreach($entry as $name => $value){
228                         if(!in_array($name, array('CLASS','ACL'))){
229                             $this->fileStoredProperties[strtolower($class)][strtolower($name)] = $value;
230                         }
231                     }
232                 }
233             }
234         }
236         // Search for config flags defined in the config file (MAIN section)
237         foreach($this->config->data['MAIN'] as $name => $value){
238             $this->fileStoredProperties['core'][strtolower($name)] = $value;
239         }
241         // Search for config flags defined in the config file (Current LOCATION section)
242         if(isset($this->config->current)){
243             foreach($this->config->current as $name => $value){
244                 $this->fileStoredProperties['core'][strtolower($name)] = $value;
245             }
246         }
248         // Skip searching for LDAP defined properties if 'ignoreLdapProperties' is set to 'true'
249         //  in the config. 
250         $this->ignoreLdapProperties = FALSE;
251         if(isset($this->fileStoredProperties['core'][strtolower('ignoreLdapProperties')]) && 
252             preg_match("/(true|on)/i", $this->fileStoredProperties['core'][strtolower('ignoreLdapProperties')])){
253             $this->ignoreLdapProperties = TRUE;
254         }
256         // Search for all config flags defined in the LDAP - BUT only if we ARE logged in. 
257         if(!empty($this->config->current['CONFIG'])){
258             $ldap = $this->config->get_ldap_link();
259             $ldap->cd($this->config->current['CONFIG']);
260             $ldap->search('(&(objectClass=gosaConfig)(gosaSetting=*))', array('cn','gosaSetting'));
261             while($attrs = $ldap->fetch()){
262                 $class = $attrs['cn'][0];
263                 for($i=0; $i<$attrs['gosaSetting']['count']; $i++){
264                     list($name,$value) = preg_split("/:/",$attrs['gosaSetting'][$i],2);
265                     $this->ldapStoredProperties[$class][$name] = $value;
266                 }
267             }
268             $this->status = 'finished';
269         }
271         // Register plugin properties.
272         foreach ($this->classesWithInfo as $cname => $def){
274             // Detect class name
275             $name = $cname;
276             $name = (isset($def['plShortName'])) ? $def['plShortName'] : $cname;
277             $name = (isset($def['plDescription'])) ? $def['plDescription'] : $cname;
279             // Register post events
280             $this->classToName[$cname] = $name;
281             $data = array('name' => 'postcreate','type' => 'command');
282             $this->register($cname, $data);    
283             $data = array('name' => 'postremove','type' => 'command');
284             $this->register($cname, $data);    
285             $data = array('name' => 'postmodify','type' => 'command');
286             $this->register($cname, $data);    
287             $data = array('name' => 'check', 'type' => 'command');
288             $this->register($cname, $data);    
290             // Register properties 
291             if(isset($def['plProperties'])){
292                 foreach($def['plProperties'] as $property){
293                     $this->register($cname, $property);
294                 }
295             }
296         }
297     }
299     function register($class,$data)
300     {
301         $id = count($this->properties);
302         $this->properties[$id] = new gosaProperty($this,$class,$data);
303         $p = strtolower("{$class}::{$data['name']}");
304         $this->mapByName[$p] = $id;
305     }
307     public function getAllProperties()
308     {
309         return($this->properties);
310     }
312     function propertyExists($class,$name)
313     {       
314         $p = strtolower("{$class}::{$name}");
315         return(isset($this->mapByName[$p]));
316     }
318     private function getId($class,$name)
319     {
320         $p = strtolower("{$class}::{$name}");
321         if(!isset($this->mapByName[$p])){
322             return(-1);
323         }       
324         return($this->mapByName[$p]);    
325     }
327     function getProperty($class,$name)
328     {
329         if($this->propertyExists($class,$name)){
330             return($this->properties[$this->getId($class,$name)]);
331         }
332         return(NULL); 
333     }
335     function getPropertyValue($class,$name)
336     {   
337         if($this->propertyExists($class,$name)){
338             $tmp = $this->getProperty($class,$name);
339             return($tmp->getValue());
340         }
341         return("");
342     }
344     function setPropertyValue($class,$name, $value)
345     {   
346         if($this->propertyExists($class,$name)){
347             $tmp = $this->getProperty($class,$name);
348             return($tmp->setValue($value));
349         }
350         return("");
351     }
353     function saveChanges()
354     {
355         $migrate = array();
356         foreach($this->properties as $prop){
358             // Is this property modified
359             if(in_array($prop->getStatus(),array('modified','removed'))){
361                 // Check if we've to migrate something before we can make the changes effective. 
362                 if($prop->migrationRequired()){
363                     $migrate[] = $prop;
364                 }else{
365                     $prop->save();
366                 }
367             }
368         }
369         return($migrate);
370     }
374 class gosaProperty
376     protected $name = "";
377     protected $class = "";
378     protected $value = "";
379     protected $tmp_value = "";  // Used when modified but not saved 
380     protected $type = "string";
381     protected $default = "";
382     protected $defaults = "";
383     protected $description = "";
384     protected $check = "";
385     protected $migrate = "";
386     protected $mandatory = FALSE;
387     protected $group = "default";
388     protected $parent = NULL;
389     protected $data = array();
391     protected $migrationClass = NULL;
393     /*!  The current property status
394      *     'ldap'       Property is stored in ldap 
395      *     'file'       Property is stored in the config file
396      *     'undefined'  Property is currently not stored anywhere
397      *     'modified'   Property has been modified (should be saved)
398      */
399     protected $status = 'undefined';
401     protected $attributes = array('name','type','default','description','check',
402             'migrate','mandatory','group','defaults');
407     function __construct($parent,$classname,$data)
408     {
409         // Set some basic infos 
410         $this->parent = &$parent;
411         $this->class = $classname;
412         $this->data  = $data;
414         // Get all relevant information from the data array (comes from plInfo)    
415         foreach($this->attributes as $aName){
416             if(isset($data[$aName])){
417                 $this->$aName = $data[$aName];
418             }
419         }      
421         // Initialize with the current value
422         $this->_restoreCurrentValue(); 
424     }
426     function migrationRequired()
427     {
428         // Instantiate migration class 
429         if(!empty($this->migrate) && $this->migrationClass == NULL){
430             if(!class_available($this->migrate)){
431                 trigger_error("Cannot start migration for gosaProperty::'{$this->getName()}' class not found ({$this->migrate})!");
432             }else{
433                 $class = $this->migrate;
434                 $tmp = new $class($this->parent->config,$this);
435                 if(! $tmp instanceof propertyMigration){ 
436                     trigger_error("Cannot start migration for gosaProperty::'{$this->getName()}' doesn't implement propertyMigration!");
437                 }else{
438                     $this->migrationClass = $tmp;
439                 }
440             }
441         }
442         if(empty($this->migrate) || $this->migrationClass == NULL){
443             return(FALSE);
444         }
445         return($this->migrationClass->checkForIssues());
446     }
448     function getMigrationClass()
449     {
450         return($this->migrationClass);
451     }
453     function check()
454     {
455         $val = $this->getValue(TRUE);
456         $return = TRUE;
457         if($this->mandatory && empty($val)){
458             $return = FALSE;
459         }
461         $check = $this->getCheck();
462         if(!empty($val) && !empty($check)){
463             $res = call_user_func(preg_split("/::/", $this->check),$messages=TRUE, $this->class,$this->name,$val, $this->type);
464             if(!$res){
465                 $return = FALSE;
466             }
467         }
468         return($return);
469     }
471     static function isBool($message,$class,$name,$value, $type)
472     {
473         $match = in_array($value,array('true','false',''));
475         // Display the reason for failing this check.         
476         if($message && ! $match){
477             msg_dialog::display(_("Warning"), 
478                     sprintf(_("The value '%s' specified for '%s:%s' is invalid. A bool value is required here!"), 
479                         bold($value),bold($class),bold($name)), 
480                     WARNING_DIALOG);
481         }
482     
483         return($match);
484     }
486     static function isString($message,$class,$name,$value, $type)
487     {
488         $match = TRUE;
489     
490         // Display the reason for failing this check.         
491         if($message && ! $match){
492             msg_dialog::display(_("Warning"), 
493                     sprintf(_("The value '%s' specified for '%s:%s' is invalid. A string value is required here!"), 
494                         bold($value),bold($class),bold($name)), 
495                     WARNING_DIALOG);
496         }
498         return($match);
499     }
501     static function isInteger($message,$class,$name,$value, $type)
502     {
503         $match = is_numeric($value) && !preg_match("/[^0-9]/", $value);
505         // Display the reason for failing this check.         
506         if($message && ! $match){
507             msg_dialog::display(_("Warning"), 
508                     sprintf(_("The value '%s' specified for '%s:%s' is invalid. A numeric value is required here!"), 
509                         bold($value),bold($class),bold($name)), 
510                     WARNING_DIALOG);
511         }
513         return($match);
514     }
516     static function isPath($message,$class,$name,$value, $type)
517     {
518         $match = preg_match("#^(/[^/]*/){1}#", $value);
519     
520         // Display the reason for failing this check.         
521         if($message && ! $match){
522             msg_dialog::display(_("Warning"), 
523                     sprintf(_("The path '%s' specified for '%s:%s' is invalid!"), 
524                         bold($value),bold($class),bold($name)), 
525                     WARNING_DIALOG);
526         }
528         return($match);
529     }
531     static function isReadablePath($message,$class,$name,$value, $type)
532     {
533         $match = !empty($value)&&is_dir($value)&&is_writeable($value);
534    
535         // Display the reason for failing this check.         
536         if($message && ! $match){
537             if(!is_dir($value)){
538                 msg_dialog::display(_("Warning"), 
539                         sprintf(_("The folder '%s' specified for '%s:%s' does not exists!"), 
540                             bold($value),bold($class),bold($name)), 
541                         WARNING_DIALOG);
542             }elseif(!is_readable($value)){
543                 msg_dialog::display(_("Warning"), 
544                         sprintf(_("The folder '%s' specified for '%s:%s' cannot be used for reading!"), 
545                             bold($value),bold($class),bold($name)), 
546                         WARNING_DIALOG);
547             }
548         }
550         return($match);
551     }
553     static function isWriteablePath($message,$class,$name,$value, $type)
554     {
555         $match = !empty($value)&&is_dir($value)&&is_writeable($value);
556    
557         // Display the reason for failing this check.         
558         if($message && ! $match){
559             if(!is_dir($value)){
560                 msg_dialog::display(_("Warning"), 
561                         sprintf(_("The folder '%s' specified for '%s:%s' does not exists!"), 
562                             bold($value),bold($class),bold($name)), 
563                         WARNING_DIALOG);
564             }elseif(!is_writeable($value)){
565                 msg_dialog::display(_("Warning"), 
566                         sprintf(_("The folder '%s' specified for '%s:%s' cannot be used for writing!"), 
567                             bold($value),bold($class),bold($name)), 
568                         WARNING_DIALOG);
569             }
570         }
572         return($match);
573     }
575     static function isReadableFile($message,$class,$name,$value, $type)
576     {
577         $match = !empty($value) && is_readable($value) && is_file($value);
579         // Display the reason for failing this check.         
580         if($message && ! $match){
581                 
582             if(!is_file($value)){
583                 msg_dialog::display(_("Warning"), 
584                         sprintf(_("The file '%s' specified for '%s:%s' does not exists!"), 
585                             bold($value),bold($class),bold($name)), 
586                         WARNING_DIALOG);
587             }elseif(!is_readable($value)){
588                 msg_dialog::display(_("Warning"), 
589                         sprintf(_("The file '%s' specified for '%s:%s' cannot be read!"), 
590                             bold($value),bold($class),bold($name)), 
591                         WARNING_DIALOG);
592             }
593         }
595         return($match);
596     }
598     static function isCommand($message,$class,$name,$value, $type)
599     {
600         $match = TRUE;
602         // Display the reason for failing this check.         
603         if($message && ! $match){
604             msg_dialog::display(_("Warning"), 
605                     sprintf(_("The command '%s' specified for '%s:%s' is invalid!"), 
606                         bold($value),bold($class),bold($name)), 
607                     WARNING_DIALOG);
608         }
609         
610         return($match);
611     }
613     static function isDn($message,$class,$name,$value, $type)
614     {
615         $match = preg_match("/^([a-z]*=[^=,]*,)*[^=]*=[^=]*$/i", $value);
617         // Display the reason for failing this check.         
618         if($message && ! $match){
619             msg_dialog::display(_("Warning"), 
620                     sprintf(_("The dn '%s' specified for '%s:%s' is invalid!"), 
621                         bold($value),bold($class),bold($name)), 
622                     WARNING_DIALOG);
623         }
624         
625         return($match);
626     }
628     static function isRdn($message,$class,$name,$value, $type)
629     {
630         $match = preg_match("/^([a-z]*=[^=,]*,)*[^=]*=[^=,]*,?$/i", $value);
632         // Display the reason for failing this check.         
633         if($message && ! $match){
634             msg_dialog::display(_("Warning"), 
635                     sprintf(_("The rdn '%s' specified for '%s:%s' is invalid!"), 
636                         bold($value),bold($class),bold($name)), 
637                     WARNING_DIALOG);
638         }
639         
640         return($match);
641     }
643     private function _restoreCurrentValue()
644     {
645         // First check for values in the LDAP Database.
646         if(isset($this->parent->ldapStoredProperties[$this->class][$this->name])){
647             $this->setStatus('ldap');
648             $this->value = $this->parent->ldapStoredProperties[$this->class][$this->name];
649             return;
650         }
652         // Second check for values in the config file.
653         if(isset($this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)])){
654             $this->setStatus('file');
655             $this->value = $this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)];
656             return;
657         }
659         // If there still wasn't found anything then fallback to the default.
660         if($this->getStatus() == 'undefined'){
661             $this->value = $this->getDefault();
662         }
663     }
665     function getMigrate() { return($this->migrate); }
666     function getCheck() { return($this->check); }
667     function getName() { return($this->name); }
668     function getClass() { return($this->class); }
669     function getGroup() { return($this->group); }
670     function getType() { return($this->type); }
671     function getDescription() { return($this->description); }
672     function getDefault() { return($this->default); }
673     function getDefaults() { return($this->defaults); }
674     function getStatus() { return($this->status); }
675     function isMandatory() { return($this->mandatory); }
677     function setValue($str) 
678     {
679         if(in_array($this->getStatus(), array('modified'))){
680             $this->tmp_value = $str; 
681         }elseif($this->value != $str){
682             $this->setStatus('modified'); 
683             $this->tmp_value = $str; 
684         }
685     }
687     function getValue($temporary = FALSE) 
688     { 
689         if($temporary){
690             if(in_array($this->getStatus(), array('modified','removed'))){
691                 return($this->tmp_value); 
692             }else{
693                 return($this->value); 
694             }
695         }else{ 
697             // Do not return ldap values if we've to ignore them.
698             if($this->parent->ignoreLdapProperties){
699                 if(isset($this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)])){
700                     return($this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)]);
701                 }else{
702                     return($this->getDefault());
703                 }
704             }else{
705                 return($this->value); 
706             }
707         }
708     }
710     function restoreDefault() 
711     {
712         if(in_array($this->getStatus(),array('ldap'))){
713             $this->setStatus('removed'); 
715             // Second check for values in the config file.
716             if(isset($this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)])){
717                 $this->tmp_value = $this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)];
718             }else{
719                 $this->tmp_value = $this->getDefault();
720             }
721         }
722     }
724     function save()
725     {
726         if($this->getStatus() == 'modified'){
727             $ldap = $this->parent->config->get_ldap_link();
728             $ldap->cd($this->parent->config->current['BASE']);
729             $dn = "cn={$this->class},".$this->parent->config->current['CONFIG'];
730             $ldap->cat($dn);
731             if(!$ldap->count()){
732                 $ldap->cd($dn);
733                 $data = array(
734                         'cn' => $this->class, 
735                         'objectClass' => array('top','gosaConfig'),
736                         'gosaSetting' => $this->name.":".$this->tmp_value);
738                 $ldap->add($data);
739                 if(!$ldap->success()){
740                     echo $ldap->get_error();
741                 }
743             }else{
744                 $attrs = $ldap->fetch();
745                 $data = array();
746                 $found = false;
747                 if(isset($attrs['gosaSetting']['count'])){
748                     for($i = 0;$i<$attrs['gosaSetting']['count']; $i ++){
749                         $set = $attrs['gosaSetting'][$i];
750                         if(preg_match("/^{$this->name}:/", $set)){
751                             $set = "{$this->name}:{$this->tmp_value}";
752                             $found = true;
753                         }
754                         $data['gosaSetting'][] = $set;
755                     }
756                 }
757                 if(!$found) $data['gosaSetting'][] = "{$this->name}:{$this->tmp_value}";
758                 $ldap->cd($dn);
759                 $ldap->modify($data);
760                 if(!$ldap->success()){
761                     echo $ldap->get_error();
762                 }
763             }
764             $this->value = $this->tmp_value;
765             $this->setStatus('ldap'); 
766         }elseif($this->getStatus() == 'removed'){
767             $ldap = $this->parent->config->get_ldap_link();
768             $ldap->cd($this->parent->config->current['BASE']);
769             $dn = "cn={$this->class},".$this->parent->config->current['CONFIG'];
770             $ldap->cat($dn);
771             $attrs = $ldap->fetch();
772             $data = array('gosaSetting' => array());
773             for($i = 0;$i<$attrs['gosaSetting']['count']; $i ++){
774                 $set = $attrs['gosaSetting'][$i];
775                 if(preg_match("/^{$this->name}:/", $set)){
776                     continue;
777                 }
778                 $data['gosaSetting'][] = $set;
779             }
780             $ldap->cd($dn);
781             $ldap->modify($data);
782             if(!$ldap->success()){
783                 echo $ldap->get_error();
784             }
785             $this->_restoreCurrentValue();
786         }
787     }
789     private function setStatus($state) 
790     {
791         if(!in_array($state, array('ldap','file','undefined','modified','removed'))) {
792             trigger_error("Unknown property status given '{$state}' for {$this->class}:{$this->name}!");
793         }else{
794             $this->status = $state; 
795         }
796     }
798     function isValid() 
799     { 
800         return(TRUE);    
801     }
806 interface propertyMigration
808     function __construct($config,$property);
812 ?>