summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e65b9ee)
raw | patch | inline | side by side (parent: e65b9ee)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 12 May 2010 09:13:47 +0000 (09:13 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 12 May 2010 09:13:47 +0000 (09:13 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18375 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/include/class_configRegistry.inc | patch | blob | history | |
gosa-core/include/class_core.inc | patch | blob | history | |
gosa-core/include/class_migrate_userRDN.inc | [new file with mode: 0644] | patch | blob |
gosa-core/plugins/addons/configViewer/class_configViewer.inc | patch | blob | history | |
gosa-core/plugins/addons/configViewer/migrate.tpl | [new file with mode: 0644] | patch | blob |
diff --git a/gosa-core/include/class_configRegistry.inc b/gosa-core/include/class_configRegistry.inc
index ea80efa573e8ed4068391eca325deabcae59bd87..fb78771d4361503c9a73ffbdaa2c7b0f68f7f34c 100644 (file)
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);
}
}
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
protected $attributes = array('name','type','default','description','check',
'migrate','mandatory','group','defaults');
+
+
+
function __construct($parent,$classname,$data)
{
// Set some basic infos
// 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()
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']);
}
}
+
+
+interface propertyMigration
+{
+ function __construct($property);
+}
+
+
?>
index 3df7083c4a4a07d6789de1f9bd09d74af9b6c271..e88f55ca95e652ce2b44a6f5d2f7ad97d87ca3a7 100644 (file)
"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),
"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),
"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
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+
+class migrate_userRDN implements propertyMigration
+{
+ private $property = NULL;
+
+ function __construct($property)
+ {
+ $this->property = &$property;
+ }
+
+ function checkForIssues()
+ {
+ return(TRUE);
+ }
+
+ function execute()
+ {
+ return("<input type='submit'>");
+ }
+
+ 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 02d3b73f8de8869e1ac3ad36815f39d5ba17ebef..9e3c39e654de63c58970e61f0025d9ec9e8f3175 100644 (file)
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;
$this->dialogObject = new commandVerifier($this->config,$prop);
}
}
-
if(isset($_POST['commandVerifier_save'])){
$this->dialogObject->save();
$this->closeDialogs();
$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());
}
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
--- /dev/null
@@ -0,0 +1,13 @@
+<h3>{t}Property migration assistent{/t}</h3>
+
+{t}Migration steps left{/t}: {$leftSteps}
+
+<hr>
+
+{$content}
+
+<hr>
+<div class="plugin-actions">
+ <button name='propertyMigrate_save'>{msgPool type='okButton'}</button>
+ <button name='propertyMigrate_cancel'>{msgPool type='cancelButton'}</button>
+</div>