Code

Updated spelling
[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(!$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 is 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     {
141         $message = "";
142         if(count($this->detectedSchemaIssues['missing'])){
143             $message.= "<br>".
144                 _("The following object classes are missing:").
145                 "<div class='scrollContainer' style='height:100px'>".
146                 msgPool::buildList($this->detectedSchemaIssues['missing']).
147                 "</div>";
148         }    
149         if(count($this->detectedSchemaIssues['versionMismatch'])){
150             $message.= "<br>".
151                 _("The following object classes are outdated:").
152                 "<div class='scrollContainer' style='height:100px'>".
153                 msgPool::buildList($this->detectedSchemaIssues['versionMismatch']).
154                 "</div>";
155         }    
156         if($message != ""){
157             $message.= "<br>"._("Plugins that require one or more of the object classes above will be disabled until the object classes get updated.");
158  
159             msg_dialog::display(_("Schema validation error"),$message, ERROR_DIALOG);
160         }
161     }
164     function ocVersionMatch($required, $installed)
165     {
166         $operator = preg_replace('/^([=<>]*).*$/',"\\1",$required);
167         $required = preg_replace('/^[=<>]*(.*)$/',"\\1",$required);
168         return(version_compare($installed,$required, $operator)); 
169     }
171     
172     function getObjectClassVersion($oc)
173     {
174         if(!isset($this->objectClasses[$oc])){
175             return(NULL);
176         }else{
177             $version = -1; // unknown
178             if(preg_match("/(v[^)]*)/", $this->objectClasses[$oc]['DESC'])){
179                 $version = preg_replace('/^.*\(v([^)]*)\).*$/',"\\1", $this->objectClasses[$oc]['DESC']);
180             }
181         }
182         return($version);
183     }
184     
186     // check wheter an objectClass is installed or not.
187     function ocAvailable($name)
188     {
189         return(isset($this->objectClasses[$name]));
190     }
193     function reload($force = FALSE)
194     {
195         // Do not reload the properties everytime, once we have  
196         //  everything loaded and registrered skip the reload.
197         // Status is 'finished' once we had a ldap connection (logged in)
198         if(!$force && $this->status == 'finished') return;
200         // Reset everything
201         $this->ldapStoredProperties = array();
202         $this->fileStoredProperties = array();
203         $this->properties = array();
204         $this->mapByName = array();
206         // Search for config flags defined in the config file (TAB section)
207         foreach($this->config->data['TABS'] as $tabname => $tabdefs){
208             foreach($tabdefs as $info){
210                 // Check if the info is valid
211                 if(isset($info['NAME']) && isset($info['CLASS'])){
213                     // Check if there is nore than just the plugin definition
214                     if(count($info) > 2){
215                         foreach($info as $name => $value){
216                             
217                             if(!in_array($name, array('CLASS','NAME'))){
218                                 $class= $info['CLASS'];    
219                                 $this->fileStoredProperties[$class][strtolower($name)] = $value;
220                             }
221                         }
222                     }
223                 }
224             }
225         }
227         // Search for config flags defined in the config file (MENU section)
228         foreach($this->config->data['MENU'] as $section => $entries){
229             foreach($entries as $entry){
230                 if(count($entry) > 2 && isset($entry['CLASS'])){
231                     $class = $entry['CLASS'];
232                     foreach($entry as $name => $value){
233                         if(!in_array($name, array('CLASS','ACL'))){
234                             $this->fileStoredProperties[strtolower($class)][strtolower($name)] = $value;
235                         }
236                     }
237                 }
238             }
239         }
241         // Search for config flags defined in the config file (MAIN section)
242         foreach($this->config->data['MAIN'] as $name => $value){
243             $this->fileStoredProperties['core'][strtolower($name)] = $value;
244         }
246         // Search for config flags defined in the config file (Current LOCATION section)
247         if(isset($this->config->current)){
248             foreach($this->config->current as $name => $value){
249                 $this->fileStoredProperties['core'][strtolower($name)] = $value;
250             }
251         }
253         // Skip searching for LDAP defined properties if 'ignoreLdapProperties' is set to 'true'
254         //  in the config. 
255         $this->ignoreLdapProperties = FALSE;
256         if(isset($this->fileStoredProperties['core'][strtolower('ignoreLdapProperties')]) && 
257             preg_match("/(true|on)/i", $this->fileStoredProperties['core'][strtolower('ignoreLdapProperties')])){
258             $this->ignoreLdapProperties = TRUE;
259         }
261         // Search for all config flags defined in the LDAP - BUT only if we ARE logged in. 
262         if(!empty($this->config->current['CONFIG'])){
263             $ldap = $this->config->get_ldap_link();
264             $ldap->cd($this->config->current['CONFIG']);
265             $ldap->search('(&(objectClass=gosaConfig)(gosaSetting=*))', array('cn','gosaSetting'));
266             while($attrs = $ldap->fetch()){
267                 $class = $attrs['cn'][0];
268                 for($i=0; $i<$attrs['gosaSetting']['count']; $i++){
269                     list($name,$value) = preg_split("/:/",$attrs['gosaSetting'][$i],2);
270                     $this->ldapStoredProperties[$class][$name] = $value;
271                 }
272             }
273             $this->status = 'finished';
274         }
276         // Register plugin properties.
277         foreach ($this->classesWithInfo as $cname => $def){
279             // Detect class name
280             $name = $cname;
281             $name = (isset($def['plShortName'])) ? $def['plShortName'] : $cname;
282             $name = (isset($def['plDescription'])) ? $def['plDescription'] : $cname;
284             // Register post events
285             $this->classToName[$cname] = $name;
286             $data = array('name' => 'postcreate','type' => 'command');
287             $this->register($cname, $data);    
288             $data = array('name' => 'postremove','type' => 'command');
289             $this->register($cname, $data);    
290             $data = array('name' => 'postmodify','type' => 'command');
291             $this->register($cname, $data);    
292             $data = array('name' => 'check', 'type' => 'command');
293             $this->register($cname, $data);    
295             // Register properties 
296             if(isset($def['plProperties'])){
297                 foreach($def['plProperties'] as $property){
298                     $this->register($cname, $property);
299                 }
300             }
301         }
302     }
304     function register($class,$data)
305     {
306         $id = count($this->properties);
307         $this->properties[$id] = new gosaProperty($this,$class,$data);
308         $p = strtolower("{$class}::{$data['name']}");
309         $this->mapByName[$p] = $id;
310     }
312     public function getAllProperties()
313     {
314         return($this->properties);
315     }
317     function propertyExists($class,$name)
318     {       
319         $p = strtolower("{$class}::{$name}");
320         return(isset($this->mapByName[$p]));
321     }
323     private function getId($class,$name)
324     {
325         $p = strtolower("{$class}::{$name}");
326         if(!isset($this->mapByName[$p])){
327             return(-1);
328         }       
329         return($this->mapByName[$p]);    
330     }
332     function getProperty($class,$name)
333     {
334         if($this->propertyExists($class,$name)){
335             return($this->properties[$this->getId($class,$name)]);
336         }
337         return(NULL); 
338     }
340     function getPropertyValue($class,$name)
341     {   
342         if($this->propertyExists($class,$name)){
343             $tmp = $this->getProperty($class,$name);
344             return($tmp->getValue());
345         }
346         return("");
347     }
349     function setPropertyValue($class,$name, $value)
350     {   
351         if($this->propertyExists($class,$name)){
352             $tmp = $this->getProperty($class,$name);
353             return($tmp->setValue($value));
354         }
355         return("");
356     }
358     function saveChanges()
359     {
360         $migrate = array();
361         foreach($this->properties as $prop){
363             // Is this property modified
364             if(in_array($prop->getStatus(),array('modified','removed'))){
366                 // Check if we've to migrate something before we can make the changes effective. 
367                 if($prop->migrationRequired()){
368                     $migrate[] = $prop;
369                 }else{
370                     $prop->save();
371                 }
372             }
373         }
374         return($migrate);
375     }
379 class gosaProperty
381     protected $name = "";
382     protected $class = "";
383     protected $value = "";
384     protected $tmp_value = "";  // Used when modified but not saved 
385     protected $type = "string";
386     protected $default = "";
387     protected $defaults = "";
388     protected $description = "";
389     protected $check = "";
390     protected $migrate = "";
391     protected $mandatory = FALSE;
392     protected $group = "default";
393     protected $parent = NULL;
394     protected $data = array();
396     protected $migrationClass = NULL;
398     /*!  The current property status
399      *     'ldap'       Property is stored in ldap 
400      *     'file'       Property is stored in the config file
401      *     'undefined'  Property is currently not stored anywhere
402      *     'modified'   Property has been modified (should be saved)
403      */
404     protected $status = 'undefined';
406     protected $attributes = array('name','type','default','description','check',
407             'migrate','mandatory','group','defaults');
412     function __construct($parent,$classname,$data)
413     {
414         // Set some basic infos 
415         $this->parent = &$parent;
416         $this->class = $classname;
417         $this->data  = $data;
419         // Get all relevant information from the data array (comes from plInfo)    
420         foreach($this->attributes as $aName){
421             if(isset($data[$aName])){
422                 $this->$aName = $data[$aName];
423             }
424         }      
426         // Initialize with the current value
427         $this->_restoreCurrentValue(); 
429     }
431     function migrationRequired()
432     {
433         // Instantiate migration class 
434         if(!empty($this->migrate) && $this->migrationClass == NULL){
435             if(!class_available($this->migrate)){
436                 trigger_error("Cannot start migration for gosaProperty::'{$this->getName()}' class not found ({$this->migrate})!");
437             }else{
438                 $class = $this->migrate;
439                 $tmp = new $class($this->parent->config,$this);
440                 if(! $tmp instanceof propertyMigration){ 
441                     trigger_error("Cannot start migration for gosaProperty::'{$this->getName()}' doesn't implement propertyMigration!");
442                 }else{
443                     $this->migrationClass = $tmp;
444                 }
445             }
446         }
447         if(empty($this->migrate) || $this->migrationClass == NULL){
448             return(FALSE);
449         }
450         return($this->migrationClass->checkForIssues());
451     }
453     function getMigrationClass()
454     {
455         return($this->migrationClass);
456     }
458     function check()
459     {
460         $val = $this->getValue(TRUE);
461         $return = TRUE;
462         if($this->mandatory && empty($val)){
463             $return = FALSE;
464         }
466         $check = $this->getCheck();
467         if(!empty($val) && !empty($check)){
468             $res = call_user_func(preg_split("/::/", $this->check),$messages=TRUE, $this->class,$this->name,$val, $this->type);
469             if(!$res){
470                 $return = FALSE;
471             }
472         }
473         return($return);
474     }
476     static function isBool($message,$class,$name,$value, $type)
477     {
478         $match = in_array($value,array('true','false',''));
480         // Display the reason for failing this check.         
481         if($message && ! $match){
482             msg_dialog::display(_("Warning"), 
483                     sprintf(_("The value '%s' specified for '%s:%s' is invalid. A bool value is required here!"), 
484                         bold($value),bold($class),bold($name)), 
485                     WARNING_DIALOG);
486         }
487     
488         return($match);
489     }
491     static function isString($message,$class,$name,$value, $type)
492     {
493         $match = TRUE;
494     
495         // Display the reason for failing this check.         
496         if($message && ! $match){
497             msg_dialog::display(_("Warning"), 
498                     sprintf(_("The value '%s' specified for '%s:%s' is invalid. A string value is required here!"), 
499                         bold($value),bold($class),bold($name)), 
500                     WARNING_DIALOG);
501         }
503         return($match);
504     }
506     static function isInteger($message,$class,$name,$value, $type)
507     {
508         $match = is_numeric($value) && !preg_match("/[^0-9]/", $value);
510         // Display the reason for failing this check.         
511         if($message && ! $match){
512             msg_dialog::display(_("Warning"), 
513                     sprintf(_("The value '%s' specified for '%s:%s' is invalid. A numeric value is required here!"), 
514                         bold($value),bold($class),bold($name)), 
515                     WARNING_DIALOG);
516         }
518         return($match);
519     }
521     static function isPath($message,$class,$name,$value, $type)
522     {
523         $match = preg_match("#^(/[^/]*/){1}#", $value);
524     
525         // Display the reason for failing this check.         
526         if($message && ! $match){
527             msg_dialog::display(_("Warning"), 
528                     sprintf(_("The path '%s' specified for '%s:%s' is invalid!"), 
529                         bold($value),bold($class),bold($name)), 
530                     WARNING_DIALOG);
531         }
533         return($match);
534     }
536     static function isReadablePath($message,$class,$name,$value, $type)
537     {
538         $match = !empty($value)&&is_dir($value)&&is_writeable($value);
539    
540         // Display the reason for failing this check.         
541         if($message && ! $match){
542             if(!is_dir($value)){
543                 msg_dialog::display(_("Warning"), 
544                         sprintf(_("The folder '%s' specified for '%s:%s' does not exists!"), 
545                             bold($value),bold($class),bold($name)), 
546                         WARNING_DIALOG);
547             }elseif(!is_readable($value)){
548                 msg_dialog::display(_("Warning"), 
549                         sprintf(_("The folder '%s' specified for '%s:%s' cannot be used for reading!"), 
550                             bold($value),bold($class),bold($name)), 
551                         WARNING_DIALOG);
552             }
553         }
555         return($match);
556     }
558     static function isWriteablePath($message,$class,$name,$value, $type)
559     {
560         $match = !empty($value)&&is_dir($value)&&is_writeable($value);
561    
562         // Display the reason for failing this check.         
563         if($message && ! $match){
564             if(!is_dir($value)){
565                 msg_dialog::display(_("Warning"), 
566                         sprintf(_("The folder '%s' specified for '%s:%s' does not exists!"), 
567                             bold($value),bold($class),bold($name)), 
568                         WARNING_DIALOG);
569             }elseif(!is_writeable($value)){
570                 msg_dialog::display(_("Warning"), 
571                         sprintf(_("The folder '%s' specified for '%s:%s' cannot be used for writing!"), 
572                             bold($value),bold($class),bold($name)), 
573                         WARNING_DIALOG);
574             }
575         }
577         return($match);
578     }
580     static function isReadableFile($message,$class,$name,$value, $type)
581     {
582         $match = !empty($value) && is_readable($value) && is_file($value);
584         // Display the reason for failing this check.         
585         if($message && ! $match){
586                 
587             if(!is_file($value)){
588                 msg_dialog::display(_("Warning"), 
589                         sprintf(_("The file '%s' specified for '%s:%s' does not exists!"), 
590                             bold($value),bold($class),bold($name)), 
591                         WARNING_DIALOG);
592             }elseif(!is_readable($value)){
593                 msg_dialog::display(_("Warning"), 
594                         sprintf(_("The file '%s' specified for '%s:%s' cannot be read!"), 
595                             bold($value),bold($class),bold($name)), 
596                         WARNING_DIALOG);
597             }
598         }
600         return($match);
601     }
603     static function isCommand($message,$class,$name,$value, $type)
604     {
605         $match = TRUE;
607         // Display the reason for failing this check.         
608         if($message && ! $match){
609             msg_dialog::display(_("Warning"), 
610                     sprintf(_("The command '%s' specified for '%s:%s' is invalid!"), 
611                         bold($value),bold($class),bold($name)), 
612                     WARNING_DIALOG);
613         }
614         
615         return($match);
616     }
618     static function isDn($message,$class,$name,$value, $type)
619     {
620         $match = preg_match("/^([a-z]*=[^=,]*,)*[^=]*=[^=]*$/i", $value);
622         // Display the reason for failing this check.         
623         if($message && ! $match){
624             msg_dialog::display(_("Warning"), 
625                     sprintf(_("The dn '%s' specified for '%s:%s' is invalid!"), 
626                         bold($value),bold($class),bold($name)), 
627                     WARNING_DIALOG);
628         }
629         
630         return($match);
631     }
633     static function isRdn($message,$class,$name,$value, $type)
634     {
635         $match = preg_match("/^([a-z]*=[^=,]*,)*[^=]*=[^=,]*,?$/i", $value);
637         // Display the reason for failing this check.         
638         if($message && ! $match){
639             msg_dialog::display(_("Warning"), 
640                     sprintf(_("The rdn '%s' specified for '%s:%s' is invalid!"), 
641                         bold($value),bold($class),bold($name)), 
642                     WARNING_DIALOG);
643         }
644         
645         return($match);
646     }
648     private function _restoreCurrentValue()
649     {
650         // First check for values in the LDAP Database.
651         if(isset($this->parent->ldapStoredProperties[$this->class][$this->name])){
652             $this->setStatus('ldap');
653             $this->value = $this->parent->ldapStoredProperties[$this->class][$this->name];
654             return;
655         }
657         // Second check for values in the config file.
658         if(isset($this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)])){
659             $this->setStatus('file');
660             $this->value = $this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)];
661             return;
662         }
664         // If there still wasn't found anything then fallback to the default.
665         if($this->getStatus() == 'undefined'){
666             $this->value = $this->getDefault();
667         }
668     }
670     function getMigrate() { return($this->migrate); }
671     function getCheck() { return($this->check); }
672     function getName() { return($this->name); }
673     function getClass() { return($this->class); }
674     function getGroup() { return($this->group); }
675     function getType() { return($this->type); }
676     function getDescription() { return($this->description); }
677     function getDefault() { return($this->default); }
678     function getDefaults() { return($this->defaults); }
679     function getStatus() { return($this->status); }
680     function isMandatory() { return($this->mandatory); }
682     function setValue($str) 
683     {
684         if(in_array($this->getStatus(), array('modified'))){
685             $this->tmp_value = $str; 
686         }elseif($this->value != $str){
687             $this->setStatus('modified'); 
688             $this->tmp_value = $str; 
689         }
690     }
692     function getValue($temporary = FALSE) 
693     { 
694         if($temporary){
695             if(in_array($this->getStatus(), array('modified','removed'))){
696                 return($this->tmp_value); 
697             }else{
698                 return($this->value); 
699             }
700         }else{ 
702             // Do not return ldap values if we've to ignore them.
703             if($this->parent->ignoreLdapProperties){
704                 if(isset($this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)])){
705                     return($this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)]);
706                 }else{
707                     return($this->getDefault());
708                 }
709             }else{
710                 return($this->value); 
711             }
712         }
713     }
715     function restoreDefault() 
716     {
717         if(in_array($this->getStatus(),array('ldap'))){
718             $this->setStatus('removed'); 
720             // Second check for values in the config file.
721             if(isset($this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)])){
722                 $this->tmp_value = $this->parent->fileStoredProperties[strtolower($this->class)][strtolower($this->name)];
723             }else{
724                 $this->tmp_value = $this->getDefault();
725             }
726         }
727     }
729     function save()
730     {
731         if($this->getStatus() == 'modified'){
732             $ldap = $this->parent->config->get_ldap_link();
733             $ldap->cd($this->parent->config->current['BASE']);
734             $dn = "cn={$this->class},".$this->parent->config->current['CONFIG'];
735             $ldap->cat($dn);
736             if(!$ldap->count()){
737                 $ldap->cd($dn);
738                 $data = array(
739                         'cn' => $this->class, 
740                         'objectClass' => array('top','gosaConfig'),
741                         'gosaSetting' => $this->name.":".$this->tmp_value);
743                 $ldap->add($data);
744                 if(!$ldap->success()){
745                     echo $ldap->get_error();
746                 }
748             }else{
749                 $attrs = $ldap->fetch();
750                 $data = array();
751                 $found = false;
752                 if(isset($attrs['gosaSetting']['count'])){
753                     for($i = 0;$i<$attrs['gosaSetting']['count']; $i ++){
754                         $set = $attrs['gosaSetting'][$i];
755                         if(preg_match("/^{$this->name}:/", $set)){
756                             $set = "{$this->name}:{$this->tmp_value}";
757                             $found = true;
758                         }
759                         $data['gosaSetting'][] = $set;
760                     }
761                 }
762                 if(!$found) $data['gosaSetting'][] = "{$this->name}:{$this->tmp_value}";
763                 $ldap->cd($dn);
764                 $ldap->modify($data);
765                 if(!$ldap->success()){
766                     echo $ldap->get_error();
767                 }
768             }
769             $this->value = $this->tmp_value;
770             $this->setStatus('ldap'); 
771         }elseif($this->getStatus() == 'removed'){
772             $ldap = $this->parent->config->get_ldap_link();
773             $ldap->cd($this->parent->config->current['BASE']);
774             $dn = "cn={$this->class},".$this->parent->config->current['CONFIG'];
775             $ldap->cat($dn);
776             $attrs = $ldap->fetch();
777             $data = array('gosaSetting' => array());
778             for($i = 0;$i<$attrs['gosaSetting']['count']; $i ++){
779                 $set = $attrs['gosaSetting'][$i];
780                 if(preg_match("/^{$this->name}:/", $set)){
781                     continue;
782                 }
783                 $data['gosaSetting'][] = $set;
784             }
785             $ldap->cd($dn);
786             $ldap->modify($data);
787             if(!$ldap->success()){
788                 echo $ldap->get_error();
789             }
790             $this->_restoreCurrentValue();
791         }
792     }
794     private function setStatus($state) 
795     {
796         if(!in_array($state, array('ldap','file','undefined','modified','removed'))) {
797             trigger_error("Unknown property status given '{$state}' for {$this->class}:{$this->name}!");
798         }else{
799             $this->status = $state; 
800         }
801     }
803     function isValid() 
804     { 
805         return(TRUE);    
806     }
811 interface propertyMigration
813     function __construct($config,$property);
817 ?>