diff --git a/gosa-core/setup/class_setupStep_Migrate.inc b/gosa-core/setup/class_setupStep_Migrate.inc
index e5679fd5b26e905b2a629988ea0a2f2c626c8a60..9de097644c1a9d0bb6c1eb4940a77f1c7b0346be 100644 (file)
{
var $languages = array();
var $attributes = array();
- var $header_image = "images/monitoring.png";
+ var $header_image = "images/setup/migrate.png";
var $checks = array();
/* Department migration attributes */
$this->checks['permissions']['STATUS'] = FALSE;
$this->checks['permissions']['STATUS_MSG']= "";
$this->checks['permissions']['ERROR_MSG'] = "";
-// $this->check_ldap_permissions();
+ $this->check_ldap_permissions();
$this->checks['deps_visible']['TITLE'] = _("Checking for invisible departments");
$this->checks['deps_visible']['STATUS'] = FALSE;
$this->checks['deps_visible']['STATUS_MSG']= "";
-// $this->checks['deps_visible']['ERROR_MSG'] = "";
+ $this->checks['deps_visible']['ERROR_MSG'] = "";
$this->checks['users_visible']['TITLE'] = _("Checking for invisible users");
$this->checks['users_visible']['STATUS'] = FALSE;
$this->checks['users_visible']['STATUS_MSG']= "";
$this->checks['users_visible']['ERROR_MSG'] = "";
-// $this->check_gosaAccounts();
+ $this->check_gosaAccounts();
$this->checks['acls']['TITLE'] = _("Checking for super administrator");
$this->checks['acls']['STATUS'] = FALSE;
$this->checks['acls']['STATUS_MSG']= "";
$this->checks['acls']['ERROR_MSG'] = "";
-// $this->check_administrativeAccount();
+ $this->check_administrativeAccount();
$this->checks['outside_users']['TITLE'] = _("Checking for users outside the people tree");
$this->checks['outside_users']['STATUS'] = FALSE;
$this->checks['outside_users']['STATUS_MSG']= "";
$this->checks['outside_users']['ERROR_MSG'] = "";
-// $this->search_outside_users();
+ $this->search_outside_users();
$this->checks['outside_groups']['TITLE'] = _("Checking for groups outside the groups tree");
$this->checks['outside_groups']['STATUS'] = FALSE;
$this->checks['outside_groups']['STATUS_MSG']= "";
$this->checks['outside_groups']['ERROR_MSG'] = "";
-// $this->search_outside_groups();
-// $this->check_organizationalUnits();
+ $this->search_outside_groups();
+ $this->check_organizationalUnits();
$this->checks['outside_winstations']['TITLE'] = _("Checking for windows workstations outside the winstation tree");
$this->checks['outside_winstations']['STATUS'] = FALSE;
$this->checks['outside_winstations']['STATUS_MSG']= "";
$this->checks['outside_winstations']['ERROR_MSG'] = "";
-// $this->search_outside_winstations();
+ $this->search_outside_winstations();
$this->checks['uidNumber_usage']['TITLE'] = _("Checking for duplicated UID numbers");
$this->checks['uidNumber_usage']['STATUS'] = FALSE;
$this->checks['uidNumber_usage']['STATUS_MSG']= "";
$this->checks['uidNumber_usage']['ERROR_MSG'] = "";
-// $this->check_uidNumber();
+ $this->check_uidNumber();
$this->checks['gidNumber_usage']['TITLE'] = _("Checking for duplicate GID numbers");
$this->checks['gidNumber_usage']['STATUS'] = FALSE;
$this->checks['gidNumber_usage']['STATUS_MSG']= "";
$this->checks['gidNumber_usage']['ERROR_MSG'] = "";
-// $this->check_gidNumber();
+ $this->check_gidNumber();
$this->checks['old_style_devices']['TITLE'] = _("Checking for old style USB devices");
$this->checks['old_style_devices']['STATUS'] = FALSE;
$this->checks['old_style_devices']['STATUS_MSG']= "";
$this->checks['old_style_devices']['ERROR_MSG'] = "";
-// $this->check_usb_devices();
+ $this->check_usb_devices();
$this->checks['old_style_services']['TITLE'] = _("Checking for old services that have to be migrated");
$this->checks['old_style_services']['STATUS'] = FALSE;
$this->checks['old_style_services']['STATUS_MSG']= "";
$this->checks['old_style_services']['ERROR_MSG'] = "";
-// $this->check_services();
+ $this->check_services();
$this->checks['old_style_menus']['TITLE'] = _("Checking for old style application menus");
$this->checks['old_style_menus']['STATUS'] = FALSE;
/* Get winstation ou */
if($cv['generic_settings']['wws_ou_active']) {
- $winstation_ou = $cv['generic_settings']['ws_ou'];
+ $winstation_ou = $cv['generic_settings']['wws_ou'];
}else{
$winstation_ou = "ou=winstations";
}
{
$pw1 = $pw2 = "";
$uid = "";
+
+ /* On first call check for rid/sid base */
+ $cv = $this->parent->captured_values;
+ $ldap_l = new LDAP($cv['admin'],
+ $cv['password'],
+ $cv['connection'],
+ FALSE,
+ $cv['tls']);
+
+ $ldap = new ldapMultiplexer($ldap_l);
if(isset($_POST['new_user_uid'])){
$uid = $_POST['new_user_uid'];
$pw2 = $_POST['new_user_password2'];
}
+
+ $ldap->cd($cv['base']);
+ $ldap->search("(uid=".$uid.")");
+ if($ldap->count()){
+ msg_dialog::display(_("Input error"),msgPool::duplicated(_("Uid")), ERROR_DIALOG);
+ return false;
+ }
+
if(empty($pw1) || empty($pw2) | ($pw1 != $pw2)){
msg_dialog::display(_("Password error"), _("Provided passwords do not match!"), ERROR_DIALOG);
return false;
msg_dialog::display(_("Input error"), _("Specify a valid user ID!"), ERROR_DIALOG);
return false;
}
-
- /* On first call check for rid/sid base */
- $cv = $this->parent->captured_values;
- $ldap_l = new LDAP($cv['admin'],
- $cv['password'],
- $cv['connection'],
- FALSE,
- $cv['tls']);
-
- $ldap = new ldapMultiplexer($ldap_l);
-
+
+
/* Get current base attributes */
$ldap->cd($cv['base']);
}
if(isset($_POST['migrate_services'])){
- $this->migrate_usb_services();
+ $this->migrate_services();
# $this->dialog = FALSE;
# $this->show_details = FALSE;
# $this->service_dialog = FALSE;
}
if(isset($_POST['migrate_menus'])){
- $this->migrate_usb_menus();
+ $this->migrate_menus();
# $this->dialog = FALSE;
# $this->show_details = FALSE;
# $this->menu_dialog = FALSE;
/* Get winstation ou */
if($cv['generic_settings']['wws_ou_active']) {
- $winstation_ou = $cv['generic_settings']['ws_ou'];
+ $winstation_ou = $cv['generic_settings']['wws_ou'];
}else{
$winstation_ou = "ou=winstations";
}
}
+ /*! \brief Act in posts from the device migration dialog
+ */
function check_device_posts()
{
foreach($this->device as $key => $device){
}
+ /*! \brief Check for old style (gosa-2.5) devices.
+ Save readable informations and a list of migratable devices
+ in $this->devices.
+ */
function check_usb_devices ()
{
/* Establish ldap connection */
}
$this->checks['old_style_devices']['STATUS'] = FALSE;
- $this->checks['old_style_devices']['STATUS_MSG']= _("Failed");
+ $this->checks['old_style_devices']['STATUS_MSG']= "<font style='color:#F0A500'>"._("Warning")."</font>";
$this->checks['old_style_devices']['ERROR_MSG'] =
sprintf(_("There are %s devices that need to be migrated."),count($this->device)).
"<input type='submit' name='device_dialog' value='"._("Migrate")."'>";
}
}
+
+ /*! \brief Migrate all selected devices.
+ Execute all required ldap actions to migrate the
+ selected devices.
+ */
function migrate_usb_devices ()
{
/* Establish ldap connection */
$ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$newdn));
$ldap->cd($newdn);
$ldap->add($new_attr);
+
+ /* Throw an error message if the action failed.
+ */
if(!$ldap->success()){
msg_dialog::display(_("LDAP error"),
- sprintf(_("Ldap add failed for %s with error %s"),
+ sprintf(_("Adding '%s' to the LDAP failed: %s"),
"<b>".LDAP::fix($newdn)."</b>",
"<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
}else{
+
+ /* Remove old style device definition from source object.
+ */
$update['gotoHotplugDevice'] = array();
for($i = 0 ; $i < $attrs['gotoHotplugDevice']['count'] ; $i++){
if($attrs['gotoHotplugDevice'][$i] == $device['OLD_DEVICE']){
$ldap->cat($device['DN'],array("gotoHotplugDevice"));
if(!$ldap->success()){
msg_dialog::display(_("LDAP error"),
- sprintf(_("Ldap update failed for %s with error %s"),
+ sprintf(_("Updating '%s' failed: %s"),
"<b>".LDAP::fix($device['DN'])."</b>",
"<br><br><i>".$ldap->get_error()."</b>"), ERROR_DIALOG);
}else{
}
}
}
+ $this->check_usb_devices();
}
-
+ /*! \brief Check for old style (gosa-2.5) services that have to be migrated
+ to be useable in gosa-2.6.
+ All required changes are stored in $this->service, also some
+ readable informations describing the actions required
+ to migrate the service
+ */
function check_services()
{
/* Establish ldap connection */
*/
if(count($this->service)){
$this->checks['old_style_services']['STATUS'] = FALSE;
- $this->checks['old_style_services']['STATUS_MSG']= _("Failed");
+ $this->checks['old_style_services']['STATUS_MSG']= "<font style='color:#F0A500'>"._("Warning")."</font>";
$this->checks['old_style_services']['ERROR_MSG'] =
sprintf(_("There are %s services that need to be migrated."),
count($this->service)).
}
- function migrate_usb_services()
+
+ /*! \brief Migrate selected services.
+ This function executes the commands collected by the
+ service_check() function.
+ */
+ function migrate_services()
{
/* Establish ldap connection
*/
*/
if(!$ldap->success()){
msg_dialog::display(_("LDAP error"),
- sprintf(_("Ldap update failed for %s with error %s"),
+ sprintf(_("Updating '%s' failed: %s"),
"<b>".LDAP::fix($service['DN'])."</b>",
"<br><br><i>".$ldap->get_error()."</b>"), ERROR_DIALOG);
}else{
}
}
}
+
+ /* Update the service migration status
+ */
+ $this->check_services();
}
+ /*! \brief Ensure that posts made on the service migration dialog
+ are processed.
+ */
function check_service_posts()
{
foreach($this->service as $key => $service){
}
+ /*! \brief This function checks the given ldap for old style (gosa-2.5)
+ menu entries and will prepare a list of actions that are required
+ to migrate them to gosa-2.6.
+ All required actions and some readable informations are stored in
+ $this->menu.
+ */
function check_menus()
{
-
- $start = microtime(1);
-
/* Establish ldap connection
*/
$cv = $this->parent->captured_values;
return;
}
-
- $releases = array();
- while($attrs = $ldap->fetch()){
- if(preg_match("/,ou=fai,/",$attrs['dn']) && in_array("organizationalUnit",$attrs['objectClass'])){
- $tmp = split("\,",$attrs['dn']);
- $fai_base = preg_replace("/,ou=fai,.*$/","",$attrs['dn']);
- $releases[convert_department_dn($fai_base,$cv['base'])] = $attrs['dn'];
- }
- }
-
-
+ /* Create application -> parameter mapping, used later to detect
+ which configured parameter belongs to which application entry.
+ */
$amap= array();
+ $todo = array();
$ldap->cd($cv['base']);
$ldap->search("(objectClass=gosaApplication)", array("cn", "gosaApplicationParameter"));
while($info = $ldap->fetch()){
}
}
- /* Search for all groups */
+ /* Search for all groups that have an old style application menu configured.
+ */
+ $appgroups = array();
$ldap->cd($cv['base']);
$ldap->search("(&(objectClass=gosaApplicationGroup)(objectClass=posixGroup)(FAIrelease=*))",
array("gosaMemberApplication","gosaApplicationParameter","FAIrelease","objectClass","gosaUnitTag"));
- $appgroups = array();
/* Create readable prefix for "What will be done" infos
*/
- $s_add = "<i>"._("add")."</i>\t";
- $s_del = "<i>"._("remove")."</i>\t";
+ $s_add = "<i>"._("Add")."</i>\t";
+ $s_del = "<i>"._("Remove")."</i>\t";
/* Walk through all found old-style menu configurations.
-Prepare ldap update list $data
}
}
- /* Create release dn part.
- eg. "sisa/1.0.0" => "ou=1.0.0,ou=siga,"
+ /* Create release container for each release/subrelease.
+ eg. "sisa/1.0.0":
+ . "ou=siga, ..."
+ . "ou=1.0.0,ou=siga, .."
*/
$release = "";
$r = $info['FAIrelease'][0];
$z = split("/",$r);
foreach($z as $part){
- if(empty($part)){
- echo __LINE__; exit();
- }else{
+ if(!empty($part)){
$release = "ou=".$part.",".$release;
/* Append release department information to "What will be done" info
}
$after .= $s_add."ou: $part\n";
- /* Appen release data to ldap actions
+ /* Append release data to ldap actions
*/
$d = array();
$d['objectClass'] = array("top","FAIbranch","organizationalUnit");
*/
$current .= $s_del."gosaMemberApplication: ".$info['gosaMemberApplication'][$i]."\n";
- /* Append ldap update action to remove the old menu entry
+ /* Append ldap update action to remove the old menu entry attributes
*/
unset($info['objectClass']['count']);
$d = array();
if(isset($info['FAIrelease'])){
$d['FAIrelease'] = array();
}
-
$d['objectClass'] = array_remove_entries(array("gosaApplicationGroup","FAIreleaseTag"),$info['objectClass']);
$data['MODIFY'][$info['dn']] = $d;
}
- /* Append missing menu entry to "What is done info"
+ /* Append missing menu entry for "What is done info".
*/
- if(empty($name)){
- echo __LINE__; exit();
- }else{
+ if(!empty($name)){
$after .= "\n";
$after .= $s_add."dn: cn=$name,$location_dn$release_dn\n";
$after .= $s_add."objectClass: gotoMenuEntry\n";
$after .= $s_add."cn: $name\n";
$after .= $s_add."gosaApplicationPriority: $priority\n";
- /* Create ldap entry
+ /* Create ldap entry
*/
$d= array();
$d['objectClass'] = array("gotoMenuEntry");
}
}
}
-
+
+ /* Updated todo list
+ */
$todo[] = array(
"DETAILS" => FALSE,
"DN" => $info['dn'],
"TODO" => $data
);
}
+
+ /* Remember checks.
+ */
$this->menu = $todo;
/* Check if we were able to query the ldap server
if(count($this->menu)){
$this->checks['old_style_menus']['STATUS'] = FALSE;
$this->checks['old_style_menus']['STATUS_MSG']= "<font style='color:#F0A500'>"._("Warning")."</font>";
- $this->checks['old_style_menus']['ERROR_MSG'] = sprintf(_("There are %s application menus which have to be converted."),
+ $this->checks['old_style_menus']['ERROR_MSG'] = sprintf(_("There are %s application menus which have to be migrated."),
count($this->menu))."<input type='submit' name='menu_dialog' value='"._("Migrate")."'>";
}else{
$this->checks['old_style_menus']['STATUS'] = TRUE;
$this->checks['old_style_menus']['STATUS_MSG']= _("Ok");
$this->checks['old_style_menus']['ERROR_MSG'] = "";
-
}
}
+
+ /*! \brief Handle posts for the menu_dialog
+ Ensure that checked checkboxes stay checked.
+ */
function check_menu_posts()
{
foreach($this->menu as $key => $menu){
}
}
- function migrate_usb_menus()
+
+ /*! \brief This function updates old-style application menus to
+ valid 2.6 application menus.
+ All selected menus will be converted (DETAILS = TRUE).
+ The ldap actions collected by check_menus() will be executed.
+ */
+ function migrate_menus()
{
/* Establish ldap connection
$cv['tls']);
$ldap = new ldapMultiplexer($ldap_l);
-
- /* First detect all release names
- */
$ldap->cd($cv['base']);
+ /* Walk through menus and detect selected menu
+ */
foreach($this->menu as $key => $menu){
if($menu['DETAILS']) {
+ /* Excute all LDAP-ADD actions
+ */
$success = TRUE;
foreach($menu['TODO']['ADD'] as $dn => $data){
$ldap->cd($cv['base']);
- $base = preg_replace("/^[^,]+,/","",$dn);
- if(!$ldap->dn_exists($base)){
- echo "FEHLER !!! ES FEHLT : ".$base."<br>";
- }elseif(!$ldap->dn_exists($dn)){
+ if(!$ldap->dn_exists($dn)){
$ldap->cd($dn);
$ldap->add($data);
if (!$ldap->success()){
}
}
+ /* Execute all LDAP-MODIFY actions
+ */
foreach($menu['TODO']['MODIFY'] as $dn => $data){
- if(!$ldap->dn_exists($dn)){
- echo "FEHLER !!! ES FEHLT : ".$dn."<br>";
- }else{
+ $ldap->cd($cv['base']);
+ if($ldap->dn_exists($dn)){
$ldap->cd($dn);
$ldap->modify($data);
if (!$ldap->success()){
}
}
}
+
+ /* If every action was successful, remove this entry from the list
+ */
if($success){
unset($this->menu[$key]);
}
}
}
+
+ /* Udpate migration status for application menus
+ */
$this->check_menus();
}
}