"Eins ist toll", "zwei" => "Zwei ist noch besser"); /* attribute list for save action */ var $ignore_account = TRUE; var $attributes = array("ID","name","ref","location","type","FK_glpi_enterprise","tech_num","deleted","comments","alarm"); var $objectclasses = array("whatever"); var $printer_type = 0; var $additional_printer= array(); var $needToCatch = true; var $parent = NULL; var $ID = ""; var $name = ""; var $ref = ""; var $location = ""; var $type = ""; var $FK_glpi_enterprise = ""; var $tech_num = ""; var $deleted = ""; var $comments = ""; var $alarm = ""; var $cur_dialog = false; var $edit_type =false; function glpiPrinterCartridgesEdit ($config, $dn,$printer_type,$values = NULL ) { plugin::plugin ($config, $dn); $ui= get_userinfo(); $acl= get_permissions ($this->dn, $ui->subtreeACL); $this->acl= get_module_permission($acl, "component", $this->dn); foreach($this->attributes as $val){ if(isset($values[$val])){ $this->$val = $values[$val]; }else{ $this->$val = ""; } } $this->needToCatch = true; $this->printer_type = $printer_type; } function remove_from_parent() { if($this->ID > 0){ $this->parent->handle->removeCartridgeDropdownType($this->ID); } } function execute() { /* Call parent execute */ plugin::execute(); /* Fill templating stuff */ $smarty= get_smarty(); $display= ""; /* Get all currently used/supported printer types for this cartridge type */ if($this->needToCatch){ $this->needToCatch = false; if(!empty($this->type)){ $this->additional_printer= $this->parent->handle->getSupportedPrinterTypeIDsForCartridge($this->ID); } } /* Printer type management */ if(isset($_POST['edit_type_cartridge'])){ $this->dialog = true; $this->edit_type=true; } /* This closes the printer type editing dialog */ if(isset($_POST['close_edit_type_cartridge'])){ $this->edit_type=false; $this->dialog = false; } /* This appends a new printer to our sytem types */ if((isset($_POST['add_cartridge_type']))&&(!empty($_POST['cartridge_type_string']))){ print "Add"; $this->parent->handle->addCartridgeDropdownType($_POST['cartridge_type_string']); } /* Remove selected type from our printer types list */ if((isset($_POST['del_cartridge_type']))&&(!empty($_POST['select_type_cartridge']))){ $used = $this->parent->handle->getUsedDropdownTypes($_POST['select_type_cartridge']); if(!count($used)){ $this->parent->handle->removeCartridgeDropdownType($_POST['select_type_cartridge']); }else{ print_red(_("Can't delete this entry, it is still in use.")); } } /* Rename selected printer type to given string */ /* Update*/ if((isset($_POST['rename_cartridge_type']))&&(!empty($_POST['select_type_cartridge']))&&(!empty($_POST['cartridge_type_string']))){ $this->parent->handle->updateCartridgeDropdownType($_POST['cartridge_type_string'],$_POST['select_type_cartridge']); } /* 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("PrinterTypes", $this->parent->handle->getCartridgeTypes()); $smarty->assign("PrinterTypeKeys", array_flip($this->parent->handle->getCartridgeTypes())); $display= $smarty->fetch(get_template_path('glpi_edit_cartridge_type.tpl', TRUE)); return($display); } /* Assign attributes */ foreach($this->attributes as $attr){ $smarty->assign($attr,$this->$attr); $smarty->assign($attr."ACL",chkacl($this->acl,$attr)); } /* Selecte technical responsible person */ if(isset($_POST['SelectCartridgeTechPerson'])){ $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_cartridge_tech_num"); } /* Abort user selection */ $smarty->assign("AbortSelectUser","SelectCartridgeUserCancel"); $smarty->assign("SaveSelectUser" ,"user_cartridge_tech_num"); if(isset($_POST['SelectCartridgeUserCancel'])){ $this->dialog = false; $this->addUser =""; $this->cur_dialog = false; } /* Start ldap, and get all glpiUsers */ $ldap = $this->config->get_ldap_link(); $users = ($this->parent->handle->getUsers()); /* Technical responsible/contact person selected */ if(isset($_GET['act'])&&($_GET['act']=="user_cartridge_tech_num")){ /* Get posted id */ $id = base64_decode($_GET['id']); /* Check if user is already created in glpi database */ if(!in_array($id,$users)){ /* If this user doesn't exists in glpi db, we must create him */ $atr = $ldap->fetch($ldap->cat($id)); $tmp = array(); $use = array( "cn" =>"name", "mail" =>"email", "telephoneNumber" =>"phone"); /* Create array */ foreach($use as $gosa => $glpi){ if(isset($atr[$gosa])){ $tmp[$glpi]= $atr[$gosa][0]; } } /* Add this user */ $this->parent->handle->addUser($tmp,$id); } /* Re-read users */ $users = ($this->parent->handle->getUsers()); /* Get user */ $tmp = array_flip($users); $id=$tmp[$id]; /* Close dialog and use this user */ $this->tech_num = $id; $this->cur_dialog = false; $this->dialog= false; } /* Execute dialog*/ if($this->cur_dialog){ $this->cur_dialog->save_object(); $this->dialog=true; $this->cur_dialog->parent = &$this; return($this->cur_dialog->execute()); }else{ $this->dialog= false; } /* Create matrix with all possible printer types */ $matrix = "
".$type." | "; }else{ /* Cehck checkbox */ $check = ""; if(isset($this->additional_printer[$key])){ $check = " checked "; } $matrix.= "".$type." | "; } } /* Complete table row, to avoid html errors */ if($spalt >0){ while($spalt >0){ $spalt -- ; $matrix .=""; } } $matrix .= " |