summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 73b6bba)
raw | patch | inline | side by side (parent: 73b6bba)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 11 Jun 2008 08:41:24 +0000 (08:41 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 11 Jun 2008 08:41:24 +0000 (08:41 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11283 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-core/setup/class_setupStep_Migrate.inc | patch | blob | history | |
gosa-core/setup/setup_migrate.tpl | patch | blob | history |
diff --git a/gosa-core/setup/class_setupStep_Migrate.inc b/gosa-core/setup/class_setupStep_Migrate.inc
index e43d1a15c435a0fbd4f0580fa27f3dc0880f0f04..18526239a3b4339e26d3d156846fc9217d22716d 100644 (file)
var $outside_groups = array();
var $outside_groups_dialog = FALSE;
+ /* Device migration */
+ var $device_dialog = FALSE;
+ var $device = array();
+
/* Win-Workstations outside to reserved ou */
var $outside_winstations = array();
var $outside_winstations_dialog = FALSE;
$this->checks['gidNumber_usage']['STATUS_MSG']= "";
$this->checks['gidNumber_usage']['ERROR_MSG'] = "";
$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();
}
return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
}
+
+ /*************
+ * Device migration
+ *************/
+
+ if($this->device_dialog) {
+ $this->check_device_posts();
+ }
+
+ if(isset($_POST['device_dialog_cancel'])){
+ $this->device_dialog = FALSE;
+ $this->show_details = FALSE;
+ $this->dialog = FALSE;
+ }
+
+ if(isset($_POST['device_dialog_whats_done'])){
+ $this->show_details= TRUE;
+ }
+
+ if(isset($_POST['device_dialog_refresh'])){
+ $this->show_details= FALSE;
+ }
+
+ if(isset($_POST['migrate_devices'])){
+ $this->migrate_usb_devices();
+# $this->dialog = FALSE;
+ # $this->show_details = FALSE;
+ # $this->device_dialog = FALSE;
+ # $this->initialize_checks();
+ }
+
+ if(isset($_POST['device_dialog'])){
+ $this->device_dialog = TRUE;
+ $this->dialog = TRUE;
+ }
+
+ if($this->device_dialog){
+ $smarty = get_smarty();
+ $smarty->assign("method","devices");
+ $smarty->assign("devices",$this->device);
+ $smarty->assign("device_details", $this->show_details);
+ return($smarty->fetch(get_template_path("setup_migrate.tpl",TRUE,dirname(__FILE__))));
+ }
+
$smarty = get_smarty();
$smarty->assign("checks",$this->checks);
$smarty->assign("method","default");
}
}
-
+
/* Cleanup ldap result to be able to write it be to ldap */
function cleanup_array($attrs)
{
}
return($attrs);
}
+
+
+ function check_device_posts()
+ {
+ foreach($this->device as $key => $device){
+ if(isset($_POST["migrate_".$key])){
+ $this->device[$key]['DETAILS'] =TRUE;
+ }else{
+ $this->device[$key]['DETAILS'] =FALSE;
+ }
+ }
+ }
+
+
+ function check_usb_devices ()
+ {
+ /* Establish ldap connection */
+ $cv = $this->parent->captured_values;
+ $ldap_l = new LDAP($cv['admin'],
+ $cv['password'],
+ $cv['connection'],
+ FALSE,
+ $cv['tls']);
+
+ $ldap = new ldapMultiplexer($ldap_l);
+ $ldap->cd($cv['base']);
+ $res = $ldap->search("(&(|(objectClass=posixAccount)(objectClass=posixGroup))(gotoHotplugDevice=*))",
+ array("cn","gotoHotplugDevice","gosaUnitTag"));
+
+ if(!$res){
+ $this->checks['old_style_devices']['STATUS'] = FALSE;
+ $this->checks['old_style_devices']['STATUS_MSG']= _("LDAP query failed");
+ $this->checks['old_style_devices']['ERROR_MSG'] = _("Possibly the 'root object' is missing.");
+ return;
+ }
+
+
+ /* If adding failed, tell the user */
+ if($ldap->count()){
+
+ $this->device = array();
+ while($attrs = $ldap->fetch()){
+
+ for ($j= 0; $j < $attrs['gotoHotplugDevice']['count']; $j++){
+
+ $after = "";
+ $current= "";
+
+ $entry= $attrs['gotoHotplugDevice'][$j];
+
+ @list($name,$desc,$serial,$vendor,$product) = explode('|', $entry);
+
+ $add = 1;
+ $new_name = $name;
+ while(isset($dest[$new_name])){
+ $new_name = $name."_".$add;
+ $add ++;
+ }
+ $name = $new_name;
+ $newdn= "cn=$name,ou=devices,".preg_replace('/^[^,]+,/', '', $attrs['dn']);
+
+ if (!isset($dest[$name])){
+ $dest[$name]= $newdn;
+
+ $current.= "dn: ".$attrs['dn']."\n";
+
+ for ($c= 0; $c < $attrs['gotoHotplugDevice']['count']; $c++){
+ if($c == $j){
+ $current.= "<b>gotoHotplugDevice: ".$attrs['gotoHotplugDevice'][$c]."</b>\n";
+ }else{
+ $current.= "gotoHotplugDevice: ".$attrs['gotoHotplugDevice'][$c]."\n";
+ }
+ }
+
+ $after.= "dn: $newdn\n";
+ $after.= "changetype: add\n";
+ $after.= "objectClass: top\n";
+ $after.= "objectClass: gotoDevice\n";
+ if (isset($attrs['gosaunittag'][0])){
+ $after.= "objectClass: gosaAdminiafter\n";
+ $after.= "gosaUnitTag: ".$attrs['gosaunittag'][0]."\n";
+ }
+ $after.= "cn: $name\n";
+ $after.= "gotoHotplugDevice: $desc|$serial|$vendor|$product\n\n";
+
+ $this->device[] = array(
+ 'CURRENT' => $current,
+ 'AFTER' => $after,
+ 'OLD_DEVICE' => $entry,
+ 'DN' => $attrs['dn'],
+ 'NEW_DN' => $newdn,
+ 'DEVICE_NAME' => $name,
+ 'DETAILS' => FALSE);
+ }
+ }
+ }
+
+ $this->checks['old_style_devices']['STATUS'] = FALSE;
+ $this->checks['old_style_devices']['STATUS_MSG']= _("Failed");
+ $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")."'>";
+ }else{
+ $this->checks['old_style_devices']['STATUS'] = TRUE;
+ $this->checks['old_style_devices']['STATUS_MSG']= _("Ok");
+ $this->checks['old_style_devices']['ERROR_MSG'] = "";
+ }
+ }
+
+ function migrate_usb_devices ()
+ {
+ /* Establish ldap connection */
+ $cv = $this->parent->captured_values;
+ $ldap_l = new LDAP($cv['admin'],
+ $cv['password'],
+ $cv['connection'],
+ FALSE,
+ $cv['tls']);
+
+ $ldap = new ldapMultiplexer($ldap_l);
+
+ /* Walk through migrateable devices and initiate migration for all
+ devices that are checked (DETAILS==TRUE)
+ */
+ foreach($this->device as $key => $device){
+ if($device['DETAILS']){
+
+ /* Get source object and verify that the specified device is a
+ member attribute of it.
+ */
+ $ldap->cd($cv['base']);
+ $ldap->cat($device['DN']);
+ $attrs = $ldap->fetch();
+ if(in_array($device['OLD_DEVICE'],$attrs['gotoHotplugDevice'])){
+
+ /* Create new hotplug device object 'gotoDevice'
+ */
+ @list($name,$desc,$serial,$vendor,$product) = explode('|', $device['OLD_DEVICE']);
+ $newdn = $device['NEW_DN'];
+ $new_attr = array();
+ $new_attr['cn'] = $device['DEVICE_NAME'];
+ $new_attr['objectClass'] = array('top','gotoDevice');
+ $new_attr['gotoHotplugDevice'] = "$desc|$serial|$vendor|$product";
+
+ /* Add new object
+ */
+ $ldap->cd($cv['base']);
+ $ldap->create_missing_trees(preg_replace("/^[^,]+,/","",$newdn));
+ $ldap->cd($newdn);
+ $ldap->add($new_attr);
+ if(!$ldap->success()){
+ msg_dialog::display(_("LDAP error"),
+ sprintf(_("Ldap add failed for %s with error %s"),
+ "<b>".LDAP::fix($newdn)."</b>",
+ "<br><br><i>".$ldap->get_error()."</i>"), ERROR_DIALOG);
+ }else{
+ $update['gotoHotplugDevice'] = array();
+ for($i = 0 ; $i < $attrs['gotoHotplugDevice']['count'] ; $i++){
+ if($attrs['gotoHotplugDevice'][$i] == $device['OLD_DEVICE']){
+ continue;
+ }
+ $update['gotoHotplugDevice'][] = $attrs['gotoHotplugDevice'][$i];
+ }
+
+ $ldap->cd($device['DN']);
+ $ldap->modify($update);
+ $ldap->cat($device['DN'],array("gotoHotplugDevice"));
+ if(!$ldap->success()){
+ msg_dialog::display(_("LDAP error"),
+ sprintf(_("Ldap update failed for %s with error %s"),
+ "<b>".LDAP::fix($device['DN'])."</b>",
+ "<br><br><i>".$ldap->get_error()."</b>"), ERROR_DIALOG);
+ }else{
+ unset($this->device[$key]);
+ }
+ }
+ }
+ }
+ }
+ }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 2c5f523999f64cf93cb1e571017fb5eb571fd100..1c255e04dd1a1f327fa377301183b0e3eb5dc6c3 100644 (file)
{t}Password (again){/t}:
</td>
<td>
+
<input type='password' value='{$new_user_password2}' name='new_user_password2'><br>
</td>
</tr>
<input type='submit' name='users_visible_migrate_close' value='{t}Cancel{/t}'>
</div>
+
+
+ {elseif $method == "devices"}
+
+
+ <h2>User devices</h2>
+
+ <p>{t}The listed devices are currenlty invisble in the GOsa interface. If you want to change this for a couple of devices, just select them and use the 'Migrate' button below.{/t}</p>
+ <p>{t}If you want to know what will be done when migrating the selected entries, use the 'Show changes' button to see the LDIF.{/t}</p>
+ {foreach from=$devices item=item key=key}
+ <input type='checkbox' name='migrate_{$key}' id='migrate_{$key}' {if $item.DETAILS} checked {/if}>
+ <b>{$item.DEVICE_NAME}</b>
+ - {$item.DN}
+
+ {if $item.DETAILS && $device_details}
+ <div class="step2_entry_container_info">
+ <b>{t}Current{/t}</b>
+ <pre>{$item.CURRENT}</pre>
+
+
+ <b>{t}After migration{/t}</b>
+ <pre>{$item.AFTER}</pre>
+ </div>
+ {/if}
+ <br>
+ {/foreach}
+ <input type='checkbox' id='toggle_calue' onClick="toggle_all_('^migrate_','toggle_calue')">
+ {t}Select all{/t}
+
+ <br>
+
+ {if $device_details}
+ <input type='submit' name='device_dialog_refresh' value='{t}Hide changes{/t}'>
+ <input type='submit' name='dummy_11' value='{t}Refresh{/t}'>
+ {else}
+ <input type='submit' name='device_dialog_whats_done' value='{t}Show changes{/t}'>
+ {/if}
+
+ <p class='seperator'> </p>
+
+ <div style='width:99%; text-align:right; padding-top:5px;'>
+ <input type='submit' name='migrate_devices' value='{t}Apply{/t}'>
+
+ <input type='submit' name='device_dialog_cancel' value='{t}Cancel{/t}'>
+ </div>
{/if}
</div>
</div>