diff --git a/gosa-plugins/goto/admin/devices/class_deviceManagement.inc b/gosa-plugins/goto/admin/devices/class_deviceManagement.inc
index bec0f50c111bb9747ecd82da18a59061bbbab87d..9560b34a3de0954b42c3e8785d735640f8c3a512 100644 (file)
{
/* Definitions */
- var $plHeadline = "Devices";
- var $plDescription = "Manage devices";
+ var $plHeadline = "Hotplug devices";
+ var $plDescription = "Manage hotplug devices";
/* Dialog attributes */
var $ui = NULL;
var $CopyPasteHandler = NULL;
var $start_pasting_copied_objects;
var $dn ="";
+ var $dns = array();
function deviceManagement(&$config, $dn= NULL)
{
/* These vars will be stored if you try to open a locked device,
to be able to perform your last requests after showing a warning message */
- session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^device_edit_/",
+ session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^device_edit_/","/^menu_action/",
"/^device_del_/","/^item_selected/","/^remove_multiple_devices/"));
$smarty = get_smarty(); // Smarty instance
/* Cancel dialogs */
if (isset($_POST['edit_cancel']) && is_object($this->devicetabs)){
- del_lock ($this->devicetabs->dn);
- unset ($this->devicetabs);
+ $this->remove_lock();
$this->devicetabs= NULL;
session::un_set('objectinfo');
}
if (count($message) == 0){
/* Save data data to ldap */
-# $this->devicetabs->set_release($this->DivListDevices->selectedRelease);
$this->devicetabs->save();
if (!isset($_POST['edit_apply'])){
+
/* device type has been saved successfully, remove lock from LDAP. */
if ($this->dn != "new"){
- del_lock ($this->dn);
+ $this->remove_lock();
}
unset ($this->devicetabs);
$this->devicetabs= NULL;
session::un_set('objectinfo');
+ }else{
+
+ /* Reinitialize tab */
+ if($this->devicetabs instanceof tabs){
+ $this->devicetabs->re_init();
+ }
}
} else {
/* Ok. There seem to be errors regarding to the tab data,
show message and continue as usual. */
- msgDialog::displayChecks($message);
+ msg_dialog::displayChecks($message);
}
}
if(count($ids)){
+ /* collect entries */
+ $this->dns = array();
foreach($ids as $id){
- $dn = $this->devices[$id]['dn'];
- if (($user= get_lock($dn)) != ""){
- return(gen_locked_message ($user, $dn));
- }
- $this->dns[$id] = $dn;
+ $this->dns[$id] = $this->devices[$id]['dn'];
+ }
+
+ /* Check locks */
+ if ($user= get_multiple_locks($this->dns)){
+ return(gen_locked_message($user,$this->dns));
}
- $dns_names = "<br><pre>";
+ $dns_names = array();
foreach($this->dns as $dn){
- add_lock ($dn, $this->ui->dn);
- $dns_names .= $dn."\n";
+ $dns_names[] =@LDAP::fix($dn);
}
- $dns_names .="</pre>";
+ add_lock ($this->dns, $this->ui->dn);
/* Lock the current entry, so nobody will edit it during deletion */
- if (count($this->dns) == 1){
- $smarty->assign("intro", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names)));
- } else {
- $smarty->assign("intro", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names)));
- }
+ $smarty->assign("intro", msgPool::deleteInfo($dns_names),_("device"));
$smarty->assign("multiple", true);
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
}
} else {
/* Normally this shouldn't be reached, send some extra
logs to notify the administrator */
- print_red (_("You are not allowed to delete this device type!"));
+ msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
new log("security","devices/".get_class($this),$dn,array(),"Tried to trick deletion.");
}
- /* Remove lock file after successfull deletion */
- del_lock ($dn);
- unset($this->dns[$key]);
}
+
+ /* Remove lock file after successfull deletion */
+ $this->remove_lock();
+ $this->dns = array();
}
/* Remove lock */
if(isset($_POST['delete_multiple_device_cancel'])){
- foreach($this->dns as $key => $dn){
- del_lock ($dn);
- unset($this->dns[$key]);
- }
+
+ /* Remove lock file after successfull deletion */
+ $this->remove_lock();
+ $this->dns = array();
}
/* Lock the current entry, so nobody will edit it during deletion */
add_lock ($this->dn, $this->ui->dn);
$smarty= get_smarty();
- $smarty->assign("intro", sprintf(_("You're about to delete the device '%s'."), @LDAP::fix($this->dn)));
+ $smarty->assign("intro", msgPool::deleteInfo(@LDAP::fix($this->dn),_("device")));
$smarty->assign("multiple", false);
return($smarty->fetch (get_template_path('remove.tpl', TRUE)));
} else {
/* Obviously the user isn't allowed to delete. Show message and
clean session. */
- print_red (_("You are not allowed to delete this device!"));
+ msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
}
}
/* Normally this shouldn't be reached, send some extra
logs to notify the administrator */
- print_red (_("You are not allowed to delete this device!"));
+ msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
new log("security","devices/".get_class($this),$dn,array(),"Tried to trick deletion.");
}
/* Remove lock file after successfull deletion */
- del_lock ($this->dn);
+ $this->remove_lock();
+ $this->dns = array();
}
/* Delete device canceled? */
if (isset($_POST['delete_cancel'])){
- del_lock ($this->dn);
+ $this->remove_lock();
session::un_set('objectinfo');
- }
+ }
/* Show tab dialog if object is present */
if (($this->devicetabs) && (isset($this->devicetabs->config))){
/* Don't show buttons if tab dialog requests this */
if (!$this->devicetabs->by_object[$this->devicetabs->current]->dialog){
$display.= "<p style=\"text-align:right\">\n";
- $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
+ $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
$display.= " \n";
if ($this->dn != "new"){
- $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+ $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
$display.= " \n";
}
- $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+ $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
$display.= "</p>";
}
return ($display);
function save_object() {
$this->DivListDevices->save_object();
+ if(is_object($this->CopyPasteHandler)){
+ $this->CopyPasteHandler->save_object();
+ }
}
}
/* Get results and create index */
- $res= get_sub_list($Filter,"devices",get_ou('deviceou'), $base, array("cn","description","dn","objectClass"), $Flags);
+ $res= get_sub_list($Filter,"devices",get_ou('deviceou'), $base, array("cn","gotoHotplugDevice","description","dn","objectClass"), $Flags);
$tmp2 = array();
foreach ($res as $val){
+ if (!isset($val['description']) && isset($val['gotoHotplugDevice'][0])) {
+ $dsc= preg_replace("/\|.*$/", "", $val['gotoHotplugDevice'][0]);
+ if ($dsc != ""){
+ $val['description']= array("count" => 1, 0 => $dsc);
+ }
+ }
$tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn'];
$tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val;
}
function remove_lock()
{
- if (isset($this->devicetabs->dn)){
- del_lock ($this->devicetabs->dn);
+ if (isset($this->dn) && !empty($this->dn)){
+ del_lock ($this->dn);
+ }
+ if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
+ del_lock ($this->dns);
}
}