diff --git a/plugins/admin/systems/class_glpiPrinterAccount.inc b/plugins/admin/systems/class_glpiPrinterAccount.inc
index 59da4baf45669e3bba068a8ff830f3f5ebe79627..e44e000bdcb35166616d6cbd5edb83ed6ebf0c9e 100644 (file)
var $contact = ""; // Empty
var $deleted = "N"; // Deleted entries should have this set to Y
var $contact = ""; // Empty
var $deleted = "N"; // Deleted entries should have this set to Y
+ var $rename = false;
+ var $select_type ;
+
var $editManufacturer = false;
/* Not necessary, cause we use mysql databse */
var $editManufacturer = false;
/* Not necessary, cause we use mysql databse */
/* Contructor
Sets default values and checks if we already have an existing glpi account
*/
/* Contructor
Sets default values and checks if we already have an existing glpi account
*/
- function glpiPrinterAccount ($config, $dn= NULL)
+ function glpiPrinterAccount ($config, $dn= NULL, $parent= NULL)
{
{
- plugin::plugin ($config, $dn);
+ plugin::plugin ($config, $dn, $parent);
$this->ui= get_userinfo();
$this->is_account = false;
$this->ui= get_userinfo();
$this->is_account = false;
/* Show tab dialog headers */
if ($this->is_account){
/* Show tab dialog headers */
if ($this->is_account){
- $display= $this->show_header(_("Remove inventory service"),
+ $display= $this->show_header(_("Remove inventory"),
_("This server has inventory features enabled. You can disable them by clicking below."));
} else {
_("This server has inventory features enabled. You can disable them by clicking below."));
} else {
- $display= $this->show_header(_("Add inventory service"),
+ $display= $this->show_header(_("Add inventory"),
_("This server has inventory features disabled. You can enable them by clicking below."));
return ($display);
}
_("This server has inventory features disabled. You can enable them by clicking below."));
return ($display);
}
* Dialog
*/
* Dialog
*/
+ /* Rename was requested */
+ if(isset($_POST['Rename_PType_OK'])){
+ $tmp = $this->handle->getPrinterTypes();
+ $allok = true;
+ foreach($tmp as $id => $name){
+ if(trim($name) == trim($_POST['string'])){
+ $allok = false;
+ }
+ }
+ if($allok){
+ $this->handle->updatePrinterType($_POST['string'],$this->select_type);
+ $this->rename = false;
+ }else{
+ print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['string']));
+ }
+ }
+
+ /* abort rename
+ */
+ if(isset($_POST['Rename_Cancel'])){
+ $this->rename = false;
+ }
+
/* Printer type management
*/
if(isset($_POST['edit_type'])){
/* Printer type management
*/
if(isset($_POST['edit_type'])){
/* Rename selected printer type to given string
*/
/* Rename selected printer type to given string
*/
- if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))&&(!empty($_POST['type_string']))){
+ if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename)){
+ $this->rename = true;
+
+ $smarty->assign("Method","rename");
+
$tmp = $this->handle->getPrinterTypes();
$tmp = $this->handle->getPrinterTypes();
- $allok = true;
- foreach($tmp as $id => $name){
- if(trim($name) == trim($_POST['type_string'])){
- $allok = false;
- }
- }
- if($allok){
- $this->handle->updatePrinterType($_POST['type_string'],$_POST['select_type']);
- }else{
- print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['type_string']));
+
+ if(isset($_POST['select_type'])){
+ $this->select_type = $_POST['select_type'];
+ }
+ $smarty->assign("string",$tmp[$this->select_type]);
+ if(isset($_POST['string'])){
+ $smarty->assign("string",$_POST['string']);
}
}
- }
+
+ $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE));
+ return($display);
+ }
/* Someone wants to edit the printer types ...
So, lets open a new dialog which provides some buttons to edit the types
*/
if($this->edit_type){
/* Someone wants to edit the printer types ...
So, lets open a new dialog which provides some buttons to edit the types
*/
if($this->edit_type){
+ $smarty->assign("Method","edit");
$smarty->assign("PrinterTypes", $this->handle->getPrinterTypes());
$smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes()));
$display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE));
$smarty->assign("PrinterTypes", $this->handle->getPrinterTypes());
$smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes()));
$display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE));
if(!in_array($id,$users)){
/* If this user doesn't exists in glpi db, we must create him */
if(!in_array($id,$users)){
/* If this user doesn't exists in glpi db, we must create him */
- $atr = $ldap->fetch($ldap->cat($id));
+ $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
+ $atr = $ldap->fetch();
$tmp = array();
$use = array( "cn" =>"name",
"mail" =>"email",
$tmp = array();
$use = array( "cn" =>"name",
"mail" =>"email",
* Assign contact and technical responsible person
*/
if(isset($users[$this->contact_num])){
* Assign contact and technical responsible person
*/
if(isset($users[$this->contact_num])){
- $tr = $ldap->fetch($ldap->cat($users[$this->contact_num]));
+ $ldap->cat($users[$this->contact_num], array('givenName', 'sn', 'uid'));
+ $tr = $ldap->fetch();
$str = "";
if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
$str = "";
if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
Assign name ... to smarty, if set
*/
if(isset($users[$this->tech_num])){
Assign name ... to smarty, if set
*/
if(isset($users[$this->tech_num])){
- $tr = $ldap->fetch($ldap->cat($users[$this->tech_num]));
+ $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid'));
+ $tr = $ldap->fetch();
$str = "";
if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
$str = "";
if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; }
if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; }
/* Check supplied data */
function check()
{
/* Check supplied data */
function check()
{
- $message= array();
+ /* Call common method to give check the hook */
+ $message= plugin::check();
// if($this->TechnicalResponsible == ""){
// $message[] = _("Please select a technical responsible person for this entry.");
// if($this->TechnicalResponsible == ""){
// $message[] = _("Please select a technical responsible person for this entry.");