From b3c417fd1f73cef1c71c0c8c85b31649ff72bf12 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 12 May 2010 09:13:47 +0000 Subject: [PATCH] Added dummy migrate method for userRDN git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18375 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_configRegistry.inc | 60 +++++++++++++++++-- gosa-core/include/class_core.inc | 8 +-- gosa-core/include/class_migrate_userRDN.inc | 34 +++++++++++ .../configViewer/class_configViewer.inc | 40 ++++++++++++- .../plugins/addons/configViewer/migrate.tpl | 13 ++++ 5 files changed, 144 insertions(+), 11 deletions(-) create mode 100644 gosa-core/include/class_migrate_userRDN.inc create mode 100644 gosa-core/plugins/addons/configViewer/migrate.tpl diff --git a/gosa-core/include/class_configRegistry.inc b/gosa-core/include/class_configRegistry.inc index ea80efa57..fb78771d4 100644 --- a/gosa-core/include/class_configRegistry.inc +++ b/gosa-core/include/class_configRegistry.inc @@ -168,10 +168,21 @@ class configRegistry{ function saveChanges() { + $migrate = array(); foreach($this->properties as $prop){ - $prop->save(); + + // Is this property modified + if(in_array($prop->getStatus(),array('modified','removed'))){ + + // Check if we've to migrate something before we can make the changes effective. + if($prop->migrationRequired()){ + $migrate[] = $prop; + }else{ + $prop->save(); + } + } } - $this->reload(TRUE); + return($migrate); } } @@ -193,6 +204,8 @@ class gosaProperty protected $parent = NULL; protected $data = array(); + protected $migrationClass = NULL; + /*! The current property status * 'ldap' Property is stored in ldap * 'file' Property is stored in the config file @@ -204,6 +217,9 @@ class gosaProperty protected $attributes = array('name','type','default','description','check', 'migrate','mandatory','group','defaults'); + + + function __construct($parent,$classname,$data) { // Set some basic infos @@ -220,6 +236,33 @@ class gosaProperty // Initialize with the current value $this->_restoreCurrentValue(); + + // Instantiate migration class + if(!empty($this->migrate)){ + if(!class_available($this->migrate)){ + trigger_error("Cannot start migration for gosaProperty::'{$this->getName()}' class not found ({$this->migrate})!"); + }else{ + $class = $this->migrate; + $tmp = new $class($this); + if(! $tmp instanceof propertyMigration){ + trigger_error("Cannot start migration for gosaProperty::'{$this->getName()}' doesn't implement propertyMigration!"); + } + $this->migrationClass = $tmp; + } + } + } + + function migrationRequired() + { + if(empty($this->migrate) || $this->migrationClass == NULL){ + return(FALSE); + } + return($this->migrationClass->checkForIssues()); + } + + function getMigrationClass() + { + return($this->migrationClass); } function check() @@ -458,8 +501,9 @@ class gosaProperty if(!$ldap->success()){ echo $ldap->get_error(); } - } - $this->_restoreCurrentValue(); + } + $this->value = $this->tmp_value; + $this->setStatus('ldap'); }elseif($this->getStatus() == 'removed'){ $ldap = $this->parent->config->get_ldap_link(); $ldap->cd($this->parent->config->current['BASE']); @@ -498,4 +542,12 @@ class gosaProperty } } + + +interface propertyMigration +{ + function __construct($property); +} + + ?> diff --git a/gosa-core/include/class_core.inc b/gosa-core/include/class_core.inc index 3df7083c4..e88f55ca9 100644 --- a/gosa-core/include/class_core.inc +++ b/gosa-core/include/class_core.inc @@ -446,7 +446,7 @@ DEBUG_SI = 256"), "default" => "ou=people", "description" => "The 'userRDN' statement defines the location where new accounts will be created inside of defined departments. The default is 'ou=people'.", "check" => "gosaProperty::isRdn", - "migrate" => "", + "migrate" => "migrate_userRDN", "group" => "user", "mandatory" => FALSE), @@ -578,7 +578,7 @@ DEBUG_SI = 256"), "default" => "false", "description" => "The 'honourUnitTags' statement enables checking of 'unitTag' attributes when using administrative units. If this is set to 'true' GOsa can only see objects inside the administrative unit a user is logged into.", "check" => "", - "migrate" => "gosaProperty::isBool", + "migrate" => "", "group" => "core", "mandatory" => FALSE), @@ -676,9 +676,9 @@ DEBUG_SI = 256"), "name" => "strictNamingRules", "type" => "bool", "default" => "true", - "description" => "", + "description" => "The 'strictNamingRules' statement enables strict checking of uids and group names. If you need characters like . or - inside of your accounts, set this to 'false'.", "check" => "gosaProperty::isBool", - "migrate" => "The 'strictNamingRules' statement enables strict checking of uids and group names. If you need characters like . or - inside of your accounts, set this to 'false'", + "migrate" => "", "group" => "core", "mandatory" => FALSE), diff --git a/gosa-core/include/class_migrate_userRDN.inc b/gosa-core/include/class_migrate_userRDN.inc new file mode 100644 index 000000000..63815cc21 --- /dev/null +++ b/gosa-core/include/class_migrate_userRDN.inc @@ -0,0 +1,34 @@ +property = &$property; + } + + function checkForIssues() + { + return(TRUE); + } + + function execute() + { + return(""); + } + + function save_object() + { + + } + + function check() + { + return(array()); + } +} + +?> diff --git a/gosa-core/plugins/addons/configViewer/class_configViewer.inc b/gosa-core/plugins/addons/configViewer/class_configViewer.inc index 02d3b73f8..9e3c39e65 100644 --- a/gosa-core/plugins/addons/configViewer/class_configViewer.inc +++ b/gosa-core/plugins/addons/configViewer/class_configViewer.inc @@ -7,6 +7,8 @@ class configViewer extends management var $plDescription= "Configure global and special GOsa settings like hooks and plugin parameters"; var $plIcon = "plugins/configViewer/images/plugin.png"; + var $toBeMigrated = array(); + function __construct($config,$ui) { $this->config = $config; @@ -50,7 +52,6 @@ class configViewer extends management $this->dialogObject = new commandVerifier($this->config,$prop); } } - if(isset($_POST['commandVerifier_save'])){ $this->dialogObject->save(); $this->closeDialogs(); @@ -59,6 +60,36 @@ class configViewer extends management $this->closeDialogs(); } + + // Execute registered management event listeners. + $this->handleActions($this->detectPostActions()); + + + // Handle properties that have to be migrated + if(isset($_POST['propertyMigrate_cancel']) && count($this->toBeMigrated)){ + unset($this->toBeMigrated[0]); + $this->toBeMigrated = array_values($this->toBeMigrated); + } + if(isset($_POST['propertyMigrate_save']) && count($this->toBeMigrated)){ + $first = $this->toBeMigrated[0]->getMigrationClass(); + $first->save_object(); + $msgs = $first->check(); + if(!count($msgs)){ + $this->toBeMigrated[0]->save(); + unset($this->toBeMigrated[0]); + $this->toBeMigrated = array_values($this->toBeMigrated); + } + } + if(count($this->toBeMigrated)){ + $first = $this->toBeMigrated[0]->getMigrationClass(); + $first->save_object(); + $content = $first->execute(); + $smarty = get_smarty(); + $smarty->assign('content', $content); + $smarty->assign('leftSteps', count($this->toBeMigrated)); + return($smarty->fetch(get_template_path('migrate.tpl',TRUE))); + } + return(management::execute()); } @@ -84,14 +115,17 @@ class configViewer extends management function saveProperties() { + // Check if we've misconfigured properties and skip saving in this case. $all = $this->config->configRegistry->getAllProperties(); $valid = TRUE; foreach($all as $prop){ $valid &= $prop->check(); + if(!$valid) break; } - if($valid){ - $this->config->configRegistry->saveChanges(); + // Now save the properties. + if($valid){ + $this->toBeMigrated = $this->config->configRegistry->saveChanges(); } } diff --git a/gosa-core/plugins/addons/configViewer/migrate.tpl b/gosa-core/plugins/addons/configViewer/migrate.tpl new file mode 100644 index 000000000..bd048b95a --- /dev/null +++ b/gosa-core/plugins/addons/configViewer/migrate.tpl @@ -0,0 +1,13 @@ +

{t}Property migration assistent{/t}

+ +{t}Migration steps left{/t}: {$leftSteps} + +
+ +{$content} + +
+
+ + +
-- 2.30.2