Code

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