Code

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