summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4921ca7)
raw | patch | inline | side by side (parent: 4921ca7)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 17 Jan 2008 08:16:08 +0000 (08:16 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 17 Jan 2008 08:16:08 +0000 (08:16 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8424 594d385d-05f5-0310-b6e9-bd551577e9d8
55 files changed:
diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpi.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpi.inc
+++ /dev/null
@@ -1,1777 +0,0 @@
-<?php
-
-
-class glpiDB{
-
- var $user ="";
- var $password ="";
- var $server ="";
- var $db ="";
-
- var $is_connected = 0;
- var $handle = NULL;
-
- var $lasterror ="";
-
- var $deviceMappingGOsaGlpi;
- var $deviceMappingTableNameID;
-
- function glpiDB($server,$user,$pwd,$db){
- $this->server = $server;
- $this->user = $user;
- $this->password = $pwd;
- $this->db = $db;
-
- $this->handle = @mysql_connect($this->server,$this->user,$this->password);
-
- if($this->handle){
- $this->is_connected = true;
- $this->SelectDB($this->db);
- }
- $this->deviceMappingGOsaGlpi = array(
- "glpi_device_case" => "case",
- "glpi_device_control" => "control",
- "glpi_device_drive" => "drive",
- "glpi_device_gfxcard" => "gfxcard",
- "glpi_device_hdd" => "hdd",
- "glpi_device_iface" => "iface",
- "glpi_device_moboard" => "moboard",
- "glpi_device_pci" => "pci",
- "glpi_device_power" => "power",
- "glpi_device_processor" => "processor",
- "glpi_device_ram" => "ram",
- "glpi_monitors" => "monitor",
- "glpi_device_sndcard" => "sndcard");
-
- $this->deviceMappingTableNameID = array( "moboard" => 1,
- "processor" => 2,
- "ram" => 3,
- "hdd" => 4,
- "iface" => 5,
- "drive" => 6,
- "control" => 7,
- "gfxcard" => 8,
- "sndcard" => 9,
- "pci" => 10,
- "case" => 11,
- "power" => 12);
-
-
- }
-
- function SelectDB()
- {
- if($this->is_connected){
- mysql_select_db($this->db,$this->handle);
- }
- }
-
-
- /* This functions checks if the selected computer/network
- device is already available in the db
- */
- function is_account($dn)
- {
- if(!$this->is_connected){
- $this->lasterror ="Can't query anything, if we aren't connected.";
- return(false);
- }else{
- $qry = "SELECT * FROM glpi_computers WHERE name='".$dn."';";
- $res = $this->query($qry);
- if(count($res)==0){
- return(false);
- }else{
- return(true);
- }
- }
- }
-
- /* this function queries everything
- */
- function query($qry)
- {
- if(!$this->is_connected){
- $this->lasterror ="Can't query anything, if we aren't connected.";
- return(false);
- }else{
- $ret =array();
- $res = mysql_query($qry,$this->handle);
-
- while($rs = @mysql_fetch_array($res,MYSQL_ASSOC)){
- $ret[]=$rs;
- }
- return($ret);
- }
- }
-
- /* System types
- Returns all defined system types
- */
- function getSystemTypes()
- {
- if($this->is_connected){
- $ret = array();
- $tmp = ($this->query("SELECT * FROM glpi_type_computers;"));
- foreach($tmp as $t){
- $ret[$t['ID']]=$t['name'];
- }
- asort($ret);
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* System types
- Update a system type
- */
- function updateSystemType($name,$id)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_type_computers WHERE ID=".$id.";");
- if(isset($tmp[0])){
- return($this->query("UPDATE glpi_type_computers SET name='".$name."' WHERE ID=".$id.";"));
- }else{
- echo "can't update not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* System types
- Add one entry to the system types
- */
- function addSystemType($name)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_type_computers WHERE name='".$name."';");
- if(isset($tmp[0])){
- echo "such an entry already exists";
- return(false);
- }else{
- return($this->query("INSERT INTO glpi_type_computers (name) VALUES ('".$name."');"));
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* System types
- Remove one entry from the system types (specified by ID=$id)
- */
- function removeSystemType($id)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_type_computers WHERE ID=".$id.";");
- if(isset($tmp[0])){
- return($this->query("DELETE FROM glpi_type_computers WHERE ID=".$id.";"));
- }else{
- echo "can't remove not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* System type is used */
- function is_systemTypeUsed($ID){
- if($this->is_connected){
- $ret = array();
- $qry="SELECT name,type FROM glpi_computers WHERE type=".$ID." LIMIT 3;";
- $res = $this->query($qry);
- foreach($res as $val){
- $ret[$val['name']] = $val['name'];
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
-
- /* Manufacturer
- Returns all defined manufacturers
- */
- function getEnterprises()
- {
- if($this->is_connected){
- $ret = array();
- $tmp = $this->query("SELECT * FROM glpi_enterprises ORDER BY name;");
- foreach($tmp as $t){
- $ret[$t['ID']]=$t['name'];
- }
-
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Manufacturer
- Returns single manufacturer
- */
- function getEnterprise($id)
- {
- if($this->is_connected){
- $ret = array();
- $tmp = $this->query("SELECT * FROM glpi_enterprises WHERE ID=".$id.";");
- return($tmp);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Manufacturer
- Updates already existing manufacturer
- */
- function updateEnterprise($array,$id)
- {
- if(!is_array($array)){
- echo "updateEnterprisesType: first paraeter must be an array";
- }elseif($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_enterprises WHERE ID='".$id."';");
- if(isset($tmp[0])){
- $atr = array("ID","name","type","address","website","phonenumber","comments","deleted","fax","email");
-
- $v = "";
- foreach($atr as $at){
- if(isset($array[$at])){
- $v .= " ".$at."='".$array[$at]."', ";
- }
- }
- if(empty($v)){
- echo "updateEnterprisesType: no attributes given ";
- return(false);
- }else{
- $v = preg_replace("/, $/","",$v);
- return($this->query("UPDATE glpi_enterprises SET ".$v." WHERE ID='".$id."';"));
- }
- }else{
- echo "can't update not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Manufacturer
- Add new manufacturer
- */
- function addEnterprise($array)
- {
- if(!is_array($array)){
- echo "addUser: first paraeter must be an array";
- }elseif($this->is_connected){
- $atr = array("ID","name","type","address","website","phonenumber","comments","deleted","fax","email");
- $v = "";
- $a = "";
- foreach($atr as $at){
- if(isset($array[$at])){
- $a .= $at.", ";
- $v .= "'".$array[$at]."', ";
- }
- }
- if(empty($v)){
- echo "addUser: no attributes given ";
- return(false);
- }else{
- $a = preg_replace("/, $/","",$a);
- $v = preg_replace("/, $/","",$v);
- return($this->query("INSERT INTO glpi_enterprises (".$a.") VALUES (".$v.");"));
- }
-
- }else{
- echo "not connected";
- return(false);
- }
-
- }
-
- /* Manufacturer
- remove manufacturer
- */
- function removeEnterprise($id)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_enterprises WHERE ID=".$id.";");
- if(isset($tmp[0])){
- return($this->query("DELETE FROM glpi_enterprises WHERE ID=".$id.";"));
- }else{
- echo "can't remove not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Operating systems
- Returns all OSs
- */
- function getOSTypes($keys = false)
- {
- if($this->is_connected){
- $ret = array();
- $tmp=($this->query("SELECT * FROM glpi_dropdown_os ORDER by name;"));
-
- if($keys){
- foreach($tmp as $t){
- $ret[$t['name']]=$t['ID'];
- }
- }else{
- foreach($tmp as $t){
- $ret[$t['ID']]=$t['name'];
- }
- }
- return($ret);
-
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Operating system is used ? */
- function is_osUsed($ID){
- if($this->is_connected){
- $ret = array();
- $qry="SELECT name,type FROM glpi_computers WHERE os=".$ID." LIMIT 3;";
- $res = $this->query($qry);
- foreach($res as $val){
- $ret[$val['name']] = $val['name'];
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
-
- /* Operating systems
- Add a new operating system to the dropdown menus
- */
- function addOS($name)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_dropdown_os WHERE name='".$name."';");
- if(isset($tmp[0])){
- echo "such an entry already exists";
- return(false);
- }else{
- return($this->query("INSERT INTO glpi_dropdown_os (name) VALUES ('".$name."');"));
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Operating systems
- remove one OS entry
- */
- function removeOS_byID($id)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_dropdown_os WHERE ID=".$id.";");
- if(is_array($tmp[0])){
- return($this->query("DELETE FROM glpi_dropdown_os WHERE ID=".$id.";"));
- }else{
- echo "can't remove not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Operating systems
- Update existing OS entry
- */
- function updateOS($name,$id)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_dropdown_os WHERE ID=".$id.";");
- if(isset($tmp[0])){
- return($this->query("UPDATE glpi_dropdown_os SET name='".$name."' WHERE ID=".$id.";"));
- }else{
- echo "can't update not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* This returns all available glpi users
- */
- function getUsers()
- {
- if($this->is_connected){
- $ret = array();
- $tmp = ($this->query("SELECT * FROM glpi_users"));
- foreach($tmp as $user){
- $ret[$user['ID']]=$user['name'];
- }
- return($ret);
-
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* this function adds a new glpi user
- */
- function addUser($array,$dn)
- {
- if(!is_array($array)){
- echo "addUser: first paraeter must be an array";
- }elseif($this->is_connected){
- $array['name']=$dn;
- $atr = array("name","phone","email");
- $v = "";
- $a = "";
- foreach($atr as $at){
- if(isset($array[$at])){
- $a .= $at.", ";
- $v .= "'".$array[$at]."', ";
- }
- }
- if(empty($v)){
- echo "addUser: no attributes given ";
- return(false);
- }else{
- $a = preg_replace("/, $/","",$a);
- $v = preg_replace("/, $/","",$v);
- return($this->query("INSERT INTO glpi_users (".$a.") VALUES (".$v.");"));
- }
-
- }else{
- echo "not connected";
- return(false);
- }
-
- }
-
- /* This function updates a glpi user
- with the given data
- */
- function updateUser($array,$dn)
- {
- if(!is_array($array)){
- echo "updateUser: first paraeter must be an array";
- }elseif($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_users WHERE name='".$dn."';");
- if(isset($tmp[0])){
-
- $atr = array("name","phone","email");
- $v = "";
- foreach($atr as $at){
- if(isset($array[$at])){
- $v .= " ".$at."='".$array[$at]."', ";
- }
- }
- if(empty($v)){
- echo "UpdateUser: no attributes given ";
- return(false);
- }else{
- $v = preg_replace("/, $/","",$v);
- return($this->query("UPDATE glpi_users SET ".$v." WHERE name='".$dn."';"));
- }
- }else{
- echo "can't update not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
-
- }
-
- /* This function returns all available data
- from a specified dn
- */
- function getComputerInformations($name)
- {
- if($this->is_connected){
- $ret = $this->query("SELECT * FROM glpi_computers WHERE name='".$name."';");
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* This fucntions updates an already existing entry
- */
- function updateComputerInformations($array,$name)
- {
- if(!is_array($array)){
- echo "updateComputerInformations: first paraeter must be an array";
- }elseif($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_computers WHERE name='".$name."';");
- if(isset($tmp[0])){
-
- $atr = array( "ID","name","serial","otherserial","contact","contact_num",
- "tech_num","comments","date_mod","os","location","domain","network",
- "model","type","is_template","tplname","FK_glpi_enterprise","deleted");
- $v = "";
- foreach($atr as $at){
- if(isset($array[$at])){
- $v .= " ".$at."='".$array[$at]."', ";
- }
- }
- if(empty($v)){
- echo "updateComputerInformations: no attributes given ";
- return(false);
- }else{
- $v = preg_replace("/, $/","",$v);
- return($this->query("UPDATE glpi_computers SET ".$v." WHERE name='".$name."';"));
- }
- }else{
- echo "can't update not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
-
- }
-
- /* This function adds a new inventory device (computer phone etc)
- */
- function addComputerInformations($array)
- {
- if(!is_array($array)){
- echo "updateComputerInformations: first paraeter must be an array";
- }elseif($this->is_connected){
- $atr = array( "ID","name","serial","otherserial","contact","contact_num",
- "tech_num","comments","date_mod","os","location","domain","network",
- "model","type","is_template","tplname","FK_glpi_enterprise","deleted");
- $v = "";
- $a = "";
- foreach($atr as $at){
- if(isset($array[$at])){
- $a .= $at.", ";
- $v .= "'".$array[$at]."', ";
- }
- }
- if(empty($v)){
- echo "updateComputerInformations: no attributes given ";
- return(false);
- }else{
- $a = preg_replace("/, $/","",$a);
- $v = preg_replace("/, $/","",$v);
- return($this->query("INSERT INTO glpi_computers (".$a.") VALUES (".$v.");"));
- }
-
- }else{
- echo "not connected";
- return(false);
- }
-
- }
-
- /* this functions checks if the given Device
- * already exists
- */
- function deviceExists($attr)
- {
- $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
- if($this->is_connected){
- $arr = array_flip($deviceMappingGOsaGlpi);
-
- $tbl_name = $arr[$attr['device_type']];
- if(!isset($attr['ID'])){
- return(false);
- }else{
- $qry = "SELECT * FROM ".$tbl_name." WHERE ID=".$attr['ID'].";";
- $res = $this->query($qry);
- if(count($res) != 0){
- return(true);
- }
- }
- }else{
- echo "not connected";
- return(false);
- }
-
- return(false);
- }
-
-
- /* Check if given device is used by some accounts
- * (helpfull to avoid removement of used devices)
- */
- function is_deviceUsed($item)
- {
- $deviceMappingGOsaGlpi = array_flip($this->deviceMappingGOsaGlpi);
- $deviceMappingTableNameID = $this->deviceMappingTableNameID;
- if($this->is_connected){
- $tablename = $deviceMappingGOsaGlpi[$item['device_type']];
- $type = $item['device_type'];
-
- $ret = array();
-
- if($type=="monitor"){
- $str = "SELECT c.name FROM glpi_connect_wire as w, glpi_computers as c WHERE w.end1=".$item['ID']." AND w.end2 = c.ID AND w.type=4;";
- }else{
- $str = "SELECT c.name FROM glpi_computer_device as d, glpi_computers as c WHERE d.FK_computers=c.ID AND FK_device=".$item['ID']." AND device_type=".$deviceMappingTableNameID[$type]." ;";
- }
-
- $res = $this->query($str);
-
- foreach($res as $val){
- $ret[$val['name']] = $val['name'];
- }
-
- return($ret);//count($this->query($str)));
- }else{
- echo "not connected";
- return(false);
- }
-
- }
-
-
- /* This functions deletes a specified entry
- * from our device tables
- */
- function deleteDevice($attr)
- {
- $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
- if($this->is_connected){
- $arr = array_flip($deviceMappingGOsaGlpi);
-
- $device_type = $attr['device_type'];
- unset($attr['device_type']);
-
- $tbl_name = $arr[$device_type];
-
- $this->query("DELETE FROM ".$tbl_name." WHERE ID=".$attr['ID'].";");
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* This funtions updated an already existing device
- */
- function updateDevices($attr)
- {
- $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
- if($this->is_connected){
- $arr = array_flip($deviceMappingGOsaGlpi);
-
- $device_type = $attr['device_type'];
- unset($attr['device_type']);
-
- $tbl_name = $arr[$device_type];
-
- $str = "UPDATE ".$tbl_name." SET ";
- foreach($attr as $name => $value){
- $str.=$name."='".$value."', ";
- }
- $str = preg_replace("/, $/","",$str);
- $str .= " WHERE ID=".$attr['ID'].";";
- $this->query($str);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Returns all possible RAM types
- * like SDRAM , DIMM .....
- */
- function getRAMTypes()
- {
- if($this->is_connected){
- $ret = array();
- $tmp = ($this->query("SELECT * FROM glpi_dropdown_ram_type;"));
- foreach($tmp as $t){
- $ret[$t['ID']]=$t['name'];
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Returns all possible HDD connection types
- * like IDE SCSI ...
- */
- function getGlpiDeviceControlTypes()
- {
- if($this->is_connected){
- $ret = array();
- $tmp = ($this->query("SELECT * FROM glpi_dropdown_hdd_type;"));
- foreach($tmp as $t){
- $ret[$t['ID']]=$t['name'];
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Returns all possible gfx card connection types
- * like PCI-X PCI AGP ....
- */
- function getGlpiGfxControlTypes()
- {
- if($this->is_connected){
- $ret = array();
- $tmp = ($this->query("SELECT * FROM glpi_dropdown_hdd_type;"));
- foreach($tmp as $t){
- $ret[$t['ID']]=$t['name'];
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Devices
- Adds a new single device to our db
- */
- function addDevice($attr)
- {
- $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
- if($this->is_connected){
- $arr = array_flip($deviceMappingGOsaGlpi);
-
- $device_type = $attr['device_type'];
- unset($attr['device_type']);
-
- $tbl_name = $arr[$device_type];
- $v = "";
- $a = "";
- foreach($attr as $name => $value){
- $a .= $name.", ";
- $v .= "'".$value."', ";
- }
- if(empty($v)){
- echo "addDevice: no attributes given ";
- return(false);
- }else{
- $a = preg_replace("/, $/","",$a);
- $v = preg_replace("/, $/","",$v);
- return($this->query("INSERT INTO ".$tbl_name." (".$a.") VALUES (".$v.");"));
- }
-
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Return all available devices
- */
- function getDevices()
- {
- $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
- if($this->is_connected){
- $arr = $deviceMappingGOsaGlpi;
-
- $res = array();
- foreach($arr as $glpi => $gosa){
- $qry = "SELECT * FROM ".$glpi.";";
- $ret = $this->query($qry);
- foreach($ret as $id => $entry){
- $entry['device_type'] = $gosa;
-
- if(isset($entry['designation'])){
- $res[$entry['designation']."-".$gosa] = $entry;
- }else{
- $res[$entry['name']."-".$gosa] = $entry;
- }
- }
- }
- return($res);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* This function returns all used devices
- */
- function getUsedDevices($computerID)
- {
- $deviceMappingGOsaGlpi = array_flip($this->deviceMappingGOsaGlpi);
- $deviceMappingTableNameID = $this->deviceMappingTableNameID;
-
- if($this->is_connected){
- $qry = "SELECT * FROM glpi_computer_device WHERE FK_computers=".$computerID.";";
- $res = $this->query($qry);
-
- $ret = array();
- foreach($deviceMappingGOsaGlpi as $GOsa => $glpi){
- $ret[$GOsa] = array();
- }
-
- $tbls = array_flip($deviceMappingTableNameID);
-
- foreach($res as $device){
- $devtype = $tbls[$device['device_type']];
- $tbl_name = $deviceMappingGOsaGlpi[$devtype];
- $qry = ("SELECT * FROM ".$tbl_name." WHERE ID=".$device['FK_device'].";");
- $res2 = $this->query($qry);
- if(count($res2)!=0){
- $ret[$devtype][$res2[0]['designation']]=$res2[0];
- }
-
- $qry = "SELECT * FROM glpi_connect_wire WHERE type=4 AND end2=".$computerID.";";
- $res2 = $this->query($qry);
- foreach($res2 as $monitor){
- $qry = "SELECT * FROM glpi_monitors WHERE ID=".$monitor['end1'].";";
- $res3 = $this->query($qry);
- foreach($res3 as $moni){
- $ret['monitor'][$moni['name']]=$moni;
- }
- }
-
-
-
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* This function removes all given devices from a computer, specified by $id
- In the next step all devices specified by devices will be added.
- */
- function addDevicesToComputer($devices, $id)
- {
- $deviceMappingGOsaGlpi = array_flip($this->deviceMappingGOsaGlpi);
- $deviceMappingTableNameID = $this->deviceMappingTableNameID;
-
- if(($id == "" )||(!is_numeric($id))){
- return (false);
- }
- if($this->is_connected){
- $qry = "DELETE FROM glpi_computer_device WHERE FK_computers=".$id.";";
- $this->query($qry);
-
- foreach($devices as $type => $entries){
- foreach($entries as $entry){
- if($type=="monitor"){
- $str = "INSERT INTO glpi_connect_wire (end1,end2,type)
- VALUES (".$entry['ID'].",".$id.",4);";
- }else{
- $str = "INSERT INTO glpi_computer_device (device_type,FK_device,FK_computers)
- VALUES (".$deviceMappingTableNameID[$type].",".$entry['ID'].",".$id.");";
- }
- $this->query($str);
- }
- }
-
-
- }else{
- echo "not connected";
- return(false);
- }
-
- }
-
- function removeComputerInformations($name)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_computers WHERE name='".$name."';");
- if(isset($tmp[0])){
- $id = $tmp[0]['ID'];
- $this->query("DELETE FROM glpi_connect_wire WHERE end2=".$id.";");
- $this->query("DELETE FROM glpi_computer_device WHERE FK_computers=".$id.";");
- return($this->query("DELETE FROM glpi_computers WHERE ID=".$id.";"));
- }else{
- echo "can't remove not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function is_connected()
- {
- return($this->is_connected);
- }
-
- function addAttachmentsToComputer($attr,$id)
- {
- if(($id == "" )||(!is_numeric($id))){
- return (false);
- }
- if($this->is_connected){
- $qry = "DELETE FROM glpi_doc_device WHERE (FK_device=".$id.") AND (device_type=1);";
- $this->query($qry);
-
- foreach($attr as $aid => $entry){
- $str = "INSERT INTO glpi_doc_device (FK_doc,FK_device,device_type,is_template)
- VALUES
- ($aid,$id,1,'0');";
- $this->query($str);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function getAssignAttachments($id)
- {
-
- if($this->is_connected){
- $qry= "SELECT * FROM glpi_doc_device WHERE (device_type=1) AND (FK_device=".$id.");";
- $ret = $this->query($qry);
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function deleteAttachment($id)
- {
- if($this->is_connected){
- $qry = "DELETE FROM glpi_docs WHERE ID=".$id."";
- $this->query($qry);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function getAttachments()
- {
- $ret = array();
- if($this->is_connected){
- $qry = "SELECT * FROM glpi_docs WHERE name!='';";
- $re = $this->query($qry);
-
- foreach($re as $entry){
- $ret[$entry['ID']]=$entry;
- }
-
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function saveAttachments($attrs,$id = -1)
- {
- if($this->is_connected){
- $atr = array("name","filename","rubrique","mime","date_mod","comment","deleted","link");
- $tmp = array();
- foreach($atr as $at){
- if(isset($attrs[$at])){
- $tmp[$at] = $attrs[$at];
- }
- }
- if(count($tmp)==0){
- return(false);
- }else{
-
- // Add
- if($id == -1){
- $str = "INSERT INTO glpi_docs ";
- $namen = "";
- $values= "";
- foreach($tmp as $name => $value){
- $namen .= $name.", ";
- if(is_numeric($value)){
- $values .= $value.", ";
- }else{
- $values .= "'".$value."', ";
- }
- }
- $values = preg_replace("/, $/","",$values);
- $namen = preg_replace("/, $/","",$namen);
- $str .= "(".$namen.") VALUES (".$values.");";
- }else{
- $str = "UPDATE glpi_docs SET ";
- foreach($tmp as $name => $value){
- $str .= $name."= ";
- if(is_numeric($value)){
- $str .= $value.", ";
- }else{
- $str .= "'".$value."', ";
- }
- }
- $str = preg_replace("/, $/","",$str);
- $str .= " WHERE ID=".$id.";";
- }
- $this->query($str);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
-
- /* Check if given attachment id is used in any Device
- ( - avoid removing of used attachments)
- */
- function is_attachmentUsed($id)
- {
- if($this->is_connected){
- $ret = array();
- $qry = "SELECT t.name FROM glpi_computers as t, glpi_doc_device WHERE t.ID = glpi_doc_device.FK_device AND FK_doc =".$id." LIMIT 3;";
- $res = $this->query($qry);
- foreach($res as $val){
- $ret[$val['name']] = $val['name'];
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
-
- /* Monitor handling
- */
- function getMonitors()
- {
- if($this->is_connected){
- $qry= "SELECT * FROM glpi_monitors;";
- return($this->query($qry));
-
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function updatedMonitor()
- {
- if($this->is_connected){
-// $qry= "SELECT * FROM glpi_monitors;";
-// return($this->query($qry));
-
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function addMonitor()
- {
- if($this->is_connected){
-// $qry= "SELECT * FROM glpi_monitors;";
-// return($this->query($qry));
-
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function removeMonitor($id)
- {
- if($this->is_connected){
- $qry= "DELETE FROM glpi_monitors WHERE ID=".$id.";";
- $this->query($qry);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function getMonitorTypes()
- {
- if($this->is_connected){
- $qry= "SELECT * FROM glpi_type_monitors;";
- return($this->query($qry));
-
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function getLocationTypes()
- {
- if($this->is_connected){
- $qry= "SELECT * FROM glpi_dropdown_locations;";
- return($this->query($qry));
-
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function getStateTypes()
- {
- if($this->is_connected){
- $qry= "SELECT * FROM glpi_dropdown_state;";
- return($this->query($qry));
- }else{
- echo "not connected";
- return(false);
- }
- }
-
-
- /* Printer functions
- */
-
- /* is printer type used ?
- */
- function is_printerTypeUsed($id)
- {
- if($this->is_connected){
- $qry = "SELECT * FROM glpi_printers WHERE type=".$id.";";
- $res = $this->query( $qry);
- $ret =array();
- foreach($res as $entry){
- $ret[$entry['ID']] = $entry['name'];
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* This functions checks if the selected computer/network
- device is already available in the db
- */
- function is_printer_account($dn)
- {
- if(!$this->is_connected){
- $this->lasterror ="Can't query anything, if we aren't connected.";
- return(false);
- }else{
- $qry = "SELECT * FROM glpi_printers WHERE name='".$dn."';";
- $res = $this->query($qry);
- if(count($res)==0){
- return(false);
- }else{
- return(true);
- }
- }
- }
-
- /* This function returns all available data
- from a specified dn
- */
- function getPrinterInformations($name)
- {
- if($this->is_connected){
- $ret = $this->query("SELECT * FROM glpi_printers WHERE name='".$name."';");
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Get Printer attachments
- */
- function getAssignPrinterAttachments($id)
- {
-
- if($this->is_connected){
- $qry= "SELECT * FROM glpi_doc_device WHERE (device_type=3) AND (FK_device=".$id.");";
- $ret = $this->query($qry);
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Printer types
- Returns all defined printer types
- */
- function getPrinterTypes()
- {
- if($this->is_connected){
- $ret = array();
- $tmp = ($this->query("SELECT * FROM glpi_type_printers ORDER BY name; "));
- foreach($tmp as $t){
- $ret[$t['ID']]=$t['name'];
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Add pritner types
- Add one entry to the printer types
- */
- function addPrinterType($name)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_type_printers WHERE name='".$name."';");
- if(isset($tmp[0])){
- //echo "such an entry already exists";
- return(false);
- }else{
- return($this->query("INSERT INTO glpi_type_printers (name) VALUES ('".$name."');"));
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* remove printer types
- Remove one entry from the printer types (specified by ID=$id)
- */
- function removePrinterType($id)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_type_printers WHERE ID=".$id.";");
- if(isset($tmp[0])){
- return($this->query("DELETE FROM glpi_type_printers WHERE ID=".$id.";"));
- }else{
- echo "can't remove not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Update printer types
- Update a printer type
- */
- function updatePrinterType($name,$id)
- {
-
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_type_printers WHERE ID=".$id.";");
- if(isset($tmp[0])){
- return($this->query("UPDATE glpi_type_printers SET name='".$name."' WHERE ID=".$id.";"));
- }else{
- echo "can't update not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
-
- /* This fucntions updates an already existing entry
- */
- function updatePrinterInformations($array,$name)
- {
- if(!is_array($array)){
- echo "updatePrinterInformations: first paraeter must be an array";
- }elseif($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_printers WHERE name='".$name."';");
- if(isset($tmp[0])){
-
- $atr = array( "ID","name","serial","otherserial","contact","contact_num",
- "tech_num","comments","date_mod","location","domain","network","ramSize","flags_serial","flags_par","flags_usb",
- "model","type","is_template","tplname","FK_glpi_enterprise","deleted");
- $v = "";
- foreach($atr as $at){
- if(isset($array[$at])){
- $v .= " ".$at."='".$array[$at]."', ";
- }
- }
- if(empty($v)){
- echo "updateSystemInformations: no attributes given ";
- return(false);
- }else{
- $v = preg_replace("/, $/","",$v);
- return($this->query("UPDATE glpi_printers SET ".$v." WHERE name='".$name."';"));
- }
- }else{
- echo "can't update not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
-
- }
-
- /* This function adds a new inventory settings for printers
- */
- function addPrinterInformations($array)
- {
- if(!is_array($array)){
- echo "updateComputerInformations: first paraeter must be an array";
- }elseif($this->is_connected){
- $atr = array( "ID","name","serial","otherserial","contact","contact_num",
- "tech_num","comments","date_mod","os","location","domain","network","ramSize","flags_serial","flags_par","flags_usb",
- "model","type","is_template","tplname","FK_glpi_enterprise","deleted");
- $v = "";
- $a = "";
- foreach($atr as $at){
- if(isset($array[$at])){
- $a .= $at.", ";
- $v .= "'".$array[$at]."', ";
- }
- }
- if(empty($v)){
- echo "updateComputerInformations: no attributes given ";
- return(false);
- }else{
- $a = preg_replace("/, $/","",$a);
- $v = preg_replace("/, $/","",$v);
- return($this->query("INSERT INTO glpi_printers (".$a.") VALUES (".$v.");"));
- }
-
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* add atachment to given printer */
- function addAttachmentsToPrinter($attr,$id)
- {
- if(($id == "" )||(!is_numeric($id))){
- return (false);
- }
- if($this->is_connected){
- $qry = "DELETE FROM glpi_doc_device WHERE (FK_device=".$id.") AND (device_type=3);";
- $this->query($qry);
-
- foreach($attr as $aid => $entry){
- $str = "INSERT INTO glpi_doc_device (FK_doc,FK_device,device_type,is_template)
- VALUES
- ($aid,$id,3,'0');";
- $this->query($str);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function removePrinterInformations($name)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_printers WHERE name='".$name."';");
- if(isset($tmp[0])){
- $id = $tmp[0]['ID'];
-// $this->query("DELETE FROM glpi_connect_wire WHERE end2=".$id.";");
- $this->query("DELETE FROM glpi_doc_device WHERE FK_device=".$id." AND device_type=3;");
- return($this->query("DELETE FROM glpi_printers WHERE ID=".$id.";"));
- }else{
- echo "can't remove not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
-
- /* Cartridges
- */
- /* return all assigned cartridges */
- function getUsedCartridges($printerID)
- {
- if($this->is_connected){
- $ret = array();
- $qry = "SELECT
- c.date_use as date_use,
- c.ID as ID,
- t.ID as type_ID,
- t.name as name,
- c.FK_glpi_printers as FK_glpi_printers,
- d.name as type_name
- FROM
- glpi_dropdown_cartridge_type as d,
- glpi_cartridges as c,
- glpi_cartridges_type as t
- WHERE c.FK_glpi_cartridges_type = t.ID
- AND t.type = d.ID
- AND c.FK_glpi_printers = ".$printerID.";";
- $res = $this->query($qry);
- foreach($res as $entry){
- $ret[$entry['ID']] = $entry;
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* return all assigned cartridges */
- function getAvailableCartridgeTypes($printerTypeID)
- {
- if($this->is_connected){
- $ret = array();
- $qry= "
- SELECT
- ct.ID as cartridgeID,
- ct.name as cartridgeName,
- pt.ID as printerTypeID,
- pt.name as printerTypeName,
- ct.type as cartridgeTypeID,
- dt.name as cartridgeTypeName
- FROM
- glpi_type_printers as pt,
- glpi_cartridges_type as ct,
- glpi_dropdown_cartridge_type as dt,
- glpi_cartridges_assoc as ac
- WHERE
- ac.FK_glpi_type_printer = pt.ID
- AND ac.FK_glpi_cartridges_type = ct.ID
- AND ct.type=dt.ID
- AND pt.ID=".$printerTypeID.";";
- $res = $this->query($qry);
- foreach($res as $entry){
- $ret[$entry['cartridgeID']] = $entry;
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function removeCartridgeFromPrinter($cartridgeID)
- {
- if($this->is_connected){
- $qry = "DELETE FROM glpi_cartridges WHERE ID=".$cartridgeID.";";
- return($this->query($qry));
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function addCartridgeFromPrinter($printerID,$cartridgeID)
- {
- if($this->is_connected){
- $qry ="INSERT INTO
- glpi_cartridges (FK_glpi_cartridges_type,FK_glpi_printers,date_in,date_use)
- VALUES
- (".$cartridgeID.",".$printerID.",'".date("Y-m-d")."','".date("Y-m-d")."');";
- return($this->query($qry));
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function is_cartridgeTypeUsed($id){
- if($this->is_connected){
- $qry = "SELECT p.ID,p.name as name FROM glpi_cartridges as c,glpi_printers as p WHERE p.ID=c.FK_glpi_printers AND c.FK_glpi_cartridges_type=".$id.";";
- $res = $this->query($qry);
- $ret =array();
- foreach($res as $entry){
- $ret[$entry['ID']] = $entry['name'];
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function getCartridgeTypeInformations($id = "all"){
- if($this->is_connected){
- $ret = array();
- if($id != "all"){
- $qry = "SELECT * FROM glpi_cartridges_type WHERE ID = ".$id.";";
- }else{
- $qry = "SELECT * FROM glpi_cartridges_type;";
- }
-
- $res = ($this->query($qry));
- foreach($res as $entry){
- $ret[$entry['ID']] = $entry;
- }
- return($ret);
-
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function getCartridgeTypes(){
- if($this->is_connected){
- $ret = array();
- $qry = "SELECT * FROM glpi_dropdown_cartridge_type;";
- $res = ($this->query($qry));
- foreach($res as $entry){
- $ret[$entry['ID']] = $entry['name'];
- }
- return($ret);
-
- }else{
- echo "not connected";
- return(false);
- }
- }
-
-
-
- /* check if given manufacturer ID ist still in use.
- The problem is, that nearly every table uses manufacturers ....
- */
- function is_manufacturerUsed($id)
- {
- if($this->is_connected){
- $tables = array();
- foreach($this->deviceMappingGOsaGlpi as $entry => $table){
- $tables[] = $entry;
- }
- $tables[] ="glpi_computers";
- $tables[] ="glpi_cartridges_type";
- $ret = array();
- $i = 3;
- foreach($tables as $tbl){
- if($i <= 0 ) continue;
- $qry = "SELECT * FROM ".$tbl." WHERE FK_glpi_enterprise = ".$id.";";
- $res = $this->query($qry);
- foreach($res as $entry){
- if($i <= 0 ) continue;
- if(isset($entry['designation'])){
- $entry['name'] = $entry['designation'];
- }
- $i --;
- $ret[] = $entry['name'];
- }
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Manufacturer
- Updates already existing manufacturer
- */
- function Add_UpdateCatrigdeType($array,$array_printer_types)
- {
- if(!is_array($array)){
- echo "Add_UpdateCatrigdeType: first paraeter must be an array";
- }elseif($this->is_connected){
-
-
- $atr = array("name","ref","location","type","FK_glpi_enterprise","tech_num","deleted","comments","alarm");
-
- /* Entry was edited */
- if($array['ID']>0){
- $qry = "DELETE FROM glpi_cartridges_assoc WHERE FK_glpi_cartridges_type=".$array['ID'].";";
-
- $v = "";
- foreach($atr as $at){
- if(isset($array[$at])){
- $v .= " ".$at."='".$array[$at]."', ";
- }
- }
- if(empty($v)){
- echo "Add_UpdateCatrigdeType: no attributes given ";
- return(false);
- }else{
- $v = preg_replace("/, $/","",$v);
- $qry = "UPDATE glpi_cartridges_type SET ".$v." WHERE ID='".$array['ID']."';";
- $this->query($qry);
- }
- }else{
-
- /* skip if name is in use*/
- $qry = "SELECT * FROM glpi_cartridges_type WHERE name='".$array['name']."';";
- if(count($this->query($qry))){
- return;
- }
-
- $str = "INSERT INTO glpi_cartridges_type ";
- $namen = "";
- $values= "";
- foreach($array as $name => $value){
- $namen .= $name.", ";
- if(is_numeric($value)){
- $values .= $value.", ";
- }else{
- $values .= "'".$value."', ";
- }
- }
- $values = preg_replace("/, $/","",$values);
- $namen = preg_replace("/, $/","",$namen);
- $str .= "(".$namen.") VALUES (".$values.");";
- $this->query($str);
- $IDs = $this->query("SELECT ID FROM glpi_cartridges_type WHERE name='".$array['name']."';");
- if(count($IDs) > 1){
- echo "internal db error";
- return;
- }
- $array['ID'] = $IDs[0]['ID'];
- }
-
- foreach($array_printer_types as $id){
- $qry = "INSERT INTO glpi_cartridges_assoc
- (FK_glpi_cartridges_type,FK_glpi_type_printer)
- VALUES
- (".$array['ID'].",".$id.")";
-
- $this->query($qry);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function getSupportedPrinterTypeIDsForCartridge($cid)
- {
- if($this->is_connected){
- $ret = array();
- $qry = "SELECT FK_glpi_type_printer FROM glpi_cartridges_assoc WHERE FK_glpi_cartridges_type = ".$cid.";";
- $res = $this->query($qry);
-
- foreach($res as $entry => $value){
- $ret[$value['FK_glpi_type_printer']] = $value['FK_glpi_type_printer'];
- }
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function removeCartridgeType($id){
- if($this->is_connected){
- $qry = "DELETE FROM glpi_cartridges_assoc WHERE FK_glpi_cartridges_type=".$id.";";
- $this->query($qry);
- $qry = "DELETE FROM glpi_cartridges_type WHERE ID=".$id.";";
- return($this->query($qry));
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function getCartridgesWhichUseThisType($id)
- {
- if($this->is_connected){
- $qry = "SELECT * FROM glpi_cartridges WHERE FK_glpi_cartridges_type=".$id.";";
- $ret = $this->query($qry);
- return($ret);
- }else{
- echo "not connected";
- return(false);
- }
- }
-
-
- /* Add pritner types
- Add one entry to the cartridgeType types
- */
- function addCartridgeDropdownType($name)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_dropdown_cartridge_type WHERE name='".$name."';");
- if(isset($tmp[0])){
- //echo "such an entry already exists";
- return(false);
- }else{
- return($this->query("INSERT INTO glpi_dropdown_cartridge_type (name) VALUES ('".$name."');"));
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* remove cartridgeType types
- Remove one entry from the cartridgeType types (specified by ID=$id)
- */
- function removeCartridgeDropdownType($id)
- {
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_dropdown_cartridge_type WHERE ID=".$id.";");
- if(isset($tmp[0])){
- return($this->query("DELETE FROM glpi_dropdown_cartridge_type WHERE ID=".$id.";"));
- }else{
- echo "can't remove not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- /* Update cartridgeType
- Update a cartridgeType
- */
- function updateCartridgeDropdownType($name,$id)
- {
-
- if($this->is_connected){
- $tmp = $this->query("SELECT * FROM glpi_dropdown_cartridge_type WHERE ID=".$id.";");
- if(isset($tmp[0])){
- return($this->query("UPDATE glpi_dropdown_cartridge_type SET name='".$name."' WHERE ID=".$id.";"));
- }else{
- echo "can't update not existing entry";
- return(false);
- }
- }else{
- echo "not connected";
- return(false);
- }
- }
-
- function getUsedDropdownTypes($id=false)
- {
- if($this->is_connected){
- if($id){
- $qry = "SELECT distinct(type) FROM glpi_cartridges_type WHERE type = ".$id.";";
- }else{
- $qry = "SELECT distinct(type) FROM glpi_cartridges_type;";
- }
- return($this->query($qry));
- }else{
- echo "not connected";
- return(false);
- }
- }
-
-}
-//$s = new glpiDB("vserver-01","glpi","tester","glpi");
-//print_r($s->query("SELECT * FROM glpi_computers"));
-//$s->getComputerInformations("1 OR (c.ID<10000)");
-?>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiAccount.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiAccount.inc
+++ /dev/null
@@ -1,806 +0,0 @@
-<?php
-
-class glpiAccount extends plugin
-{
- /* CLI vars */
- var $cli_summary= "Manage server basic objects";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account= FALSE;
- var $attributes= array("ID","name","contact",
- "tech_num","comments","date_mod","os","location","domain","network","contact_num",
- "model","type","is_template","FK_glpi_enterprise","deleted");
-
- var $ID ; // Is set if this entry is edited
- var $name = ""; // This should be the dn of this entry
- var $contact = ""; // Empty
-
- var $comments = ""; // Comment
-
- var $contact_num = ""; // Contact person
- var $tech_num = ""; // Technical responsible person
-
- var $addUser = ""; // This is used to remember if a dialog was opened for tech_num or contact_num
-
- var $date_mod = ""; // Modification timestamp
- var $os = 0; // Operating system
- var $location = 0; // Not used yet
- var $domain = 0; // ? Set to 0
- var $network = 0; // ? Set to 0
-
- var $model = 0; // ? Can't remember this, it isn't used in GOsa
- var $type = 0; // System type id
- var $is_template = 0; // Used as template ?
- var $FK_glpi_enterprise = 0; // Manufacturer id
- var $deleted = "N"; // Deleted entries should have this set to Y
-
- var $renameTypeDialog = false;
- var $renameOSDialog = false;
- var $select_type ;
- var $view_logged = FALSE;
-
- /* Not necessary, cause we use mysql databse */
- var $objectclasses= array("whatever");
-
- /* Used to remember if this was an account (simply: is this an edited entry) */
- var $initially_was_account = false;
-
- /* Remember current dialog */
- var $edit_type = false;
- var $edit_os = false;
-
- var $data;
- var $handle = NULL; // Glpi class handle used to query database
-
- var $cur_dialog = NULL; // This contains the sub dialog handle
-
- var $orig_dn; // To check if dn, has changed
- var $ui; // Some GOsa specific user informations
-
- var $usedDevices = array(); // Which devices are currently selected
- var $usedAttachments = array(); // Used Attachments
-
- /* Contructor
- Sets default values and checks if we already have an existing glpi account
- */
- function glpiAccount (&$config, $dn= NULL, $parent= NULL)
- {
- plugin::plugin ($config, $dn, $parent);
- $this->ui= get_userinfo();
-
- /* Abort class construction, if no db is defined */
- if(!isset($this->config->data['SERVERS']['GLPI'])){
- return;
- }
-
- // Get informations about databse connection
- $this->data = $this->config->data['SERVERS']['GLPI'];
-
- // Abort if mysql extension is missing
- if(!is_callable("mysql_connect")){
- return;
- }
-
- // Create handle of glpi class, and check if database connection is established
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-
- if(!$this->handle->is_connected){
- return;
- }
-
- // If this dn is already used in database, then get all informations for this entry
- if($this->handle->is_account($this->dn)){
- $this->is_account = true;
- $tmp = ($this->handle->getComputerInformations($this->dn));
-
- foreach(array("tech_num","os","FK_glpi_enterprise","type","comments","contact_num") as $attr){
- $this->$attr = $tmp[0][$attr];
- }
- $this->usedDevices = $this->handle->getUsedDevices($tmp[0]['ID']);
- $atts = $this->handle->getAssignAttachments($tmp[0]['ID']);
- foreach($atts as $attachment){
-
- $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc'];
- }
- }else{
- $this->is_account = false;
- }
-
- /* set defaults */
- $this->name = $this->dn;
- $this->orig_dn = $this->dn;
- $this->initially_was_account = $this->is_account;
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","all/".get_class($this),$this->dn);
- }
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- /* Assign smarty defaults
- To avoid undefined indexes, if there is an error with the glpi db
- */
- foreach(array("SystemTypes","SystemTypeKeys","Manufacturers",
- "OSs","TechnicalResponsibles","InstalledDevices","Attachments","AttachmentKeys",
- "OSKeys","OSs","ManufacturerKeys","InstalledDeviceKeys") as $attr){
- $smarty->assign($attr,array());
- }
- foreach(array("type","FK_glpi_enterprise","os","tech_num","comments","contact_num","AttachmentsDiv") as $attr){
- $smarty->assign($attr,"");
- }
-
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation) {
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- /* Check if there is a glpi database server defined
- */
- if(!isset($this->config->data['SERVERS']['GLPI'])){
- print_red(_("There is no server with valid glpi database service."));
- return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
- }
-
- $this->data = $this->config->data['SERVERS']['GLPI'];
-
- /* Check if we can call mysql_connect
- If we can't, there is no the mysql-php extension
- */
- if(!is_callable("mysql_connect")){
- print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
- return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
- }
-
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-
- /* If handle == false, abort
- Seems that the server, username and or password is wrong
- */
- if(!$this->handle->is_connected){
- print_red(_("Can't connect to glpi database, check configuration twice."));
- return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
- }
-
- /* All checks are ok
- Lets handle Posts, templates etc below ...
- */
-
- $users = $this->handle->getUsers();
- $ldap= $this->config->get_ldap_link();
-
- /* Check for Trading button Post
- */
- if(isset($_POST['Trading'])){
- print_red(_("This feature is not implemented yet."));
- }
-
- /* Check for Software button Post
- */
- if(isset($_POST['Software'])){
- print_red(_("This feature is not implemented yet."));
- }
-
- /* Check for Contract button Post
- */
- if(isset($_POST['Contracts'])){
- print_red(_("This feature is not implemented yet."));
- }
-
- /* Add Device was requested, open new dialog
- */
- if((isset($_POST['AddDevice'])) && ($this->acl_is_writeable("Devices"))){
- $this->dialog =true;
- $this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn,$this->usedDevices);
- }
-
- /* Attachment pool was closed with use
- */
- if(isset($_POST['UseAttachment']) && ($this->acl_is_writeable("Attachments"))){
- if(count($this->cur_dialog->check())){
- foreach($this->cur_dialog->check() as $msg){
- print_red($msg);
- }
- }else{
- $this->cur_dialog->save_object();
- $this->usedAttachments = $this->cur_dialog->save();
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
- }
-
- /* Attachment pool was closed with abort
- */
- if(isset($_POST['AbortAttachment'])){
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
-
- /* Open Attachment pool to add/edit Attachments
- */
- if(isset($_POST['AddAttachment']) && ($this->acl_is_writeable("Attachments"))){
- $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
- $this->dialog = true;
- }
-
- /* Remove Attachment fro this tab
- */
- $once = true;
- foreach($_POST as $name => $value){
- if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){
- $once= false;
- $name = preg_replace("/^delAttachment_/","",$name);
- $entry = preg_replace("/_.*$/","",$name);
- if(isset($this->usedAttachments[$entry])){
- unset($this->usedAttachments[$entry]);
- }
- }
- }
- if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && ($this->acl_is_writeable("Attachments"))){
- foreach($_POST['Attachments'] as $entry){
- if(isset($this->usedAttachments[$entry])){
- unset($this->usedAttachments[$entry]);
- }
- }
- }
-
- /* We have selected some devices and pressed use button
- */
- if(isset($_POST['SelectDeviceSave']) && $this->acl_is_writeable("Devices")){
- $this->cur_dialog->save_object();
- $this->usedDevices= ($this->cur_dialog->getSelected());
- $this->cur_dialog = false;
- $this->dialog = false;
- $this->edit_type=false;
- }
-
- /* Aborted Device selction
- */
- if(isset($_POST['SelectDeviceCancel']) && ($this->acl_is_writeable("Devices"))){
- $this->dialog = false;
- $this->cur_dialog = false;
- $this->edit_type=false;
- }
-
- /* System type management
- */
- if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){
- $this->dialog = true;
- $this->edit_type=true;
- }
-
- /* This closes the system type editing dialog
- */
- if(isset($_POST['close_edit_type']) && ($this->acl_is_writeable("type"))){
- $this->edit_type=false;
- $this->dialog = false;
- }
-
- if(isset($_POST['Rename_Cancel'])){
- $this->renameTypeDialog = false;
- $this->renameOSDialog = false;
- }
-
- /* This appends a new system to our sytem types
- */
- if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){
- $attr = $this->handle->getSystemTypes();
- if(in_array(trim($_POST['type_string']),$attr)){
- print_red(_("Adding new sytem type failed, this system type name is already used.")) ;
- }else{
- $this->handle->addSystemType(trim($_POST['type_string']));
- }
- }
-
- /* Remove selected type from our system types list
- */
- if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){
- $tmp = $this->handle->is_systemTypeUsed($_POST['select_type']);
- if(count($tmp)){
- $names = "";
- foreach($tmp as $name){
- $names .= ", ".$name;
- }
- $names = preg_replace("/^, /","",$names);
- $names = trim($names);
- if(count($tmp) == 3){
- $names .= " ...";
- }
- print_red(sprintf(_("You can't delete this system type, it is still in use by these system(s) '%s'"),$names));
- }else{
- $this->handle->removeSystemType($_POST['select_type']);
- }
- }
-
- /* Rename selected system type to given string
- */
- if(isset($_POST['Rename_type_OK'])){
- $attr = $this->handle->getSystemTypes();
- if(in_array(trim($_POST['string']),$attr)){
- print_red(_("Rename failed, this system type name is already used.")) ;
- }else{
- $this->renameTypeDialog = false;
- $this->handle->updateSystemType($_POST['string'],trim($this->select_type));
- }
- }
-
-
- if((isset($_POST['rename_type'])&&(!empty($_POST['select_type'])))||($this->renameTypeDialog)){
- if(isset($_POST['select_type'])){
- $this->select_type = $_POST['select_type'];
- }
- $this->renameTypeDialog = true;
- $tmp = $this->handle->getSystemTypes();
-
- $smarty->assign("string",$tmp[$this->select_type]);
- if(isset($_POST['string'])){
- $smarty->assign("string",$_POST['string']);
- }
- $smarty->assign("Method","rename");
- $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE));
- return($display);
- }
-
-
-
- /* Someone wants to edit the system 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("SystemTypes", $this->handle->getSystemTypes());
- $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
- $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE));
- return($display);
- }
-
- /* System os management
- */
- if(isset($_POST['edit_os']) && $this->acl_is_writeable("os")){
- $this->dialog = true;
- $this->edit_os=true;
- }
-
- /* Close Operating system dialog
- */
- if(isset($_POST['close_edit_os'])){
- $this->edit_os=false;
- $this->dialog = false;
- }
-
- /* Add new os to the db
- */
- if((isset($_POST['add_os']))&&(!empty($_POST['is_string'])) && $this->acl_is_writeable("os")){
- $attr = $this->handle->getOSTypes();
- if(in_array(trim($_POST['is_string']),$attr)){
- print_red(_("Adding new operating system failed, specifed name is already used.")) ;
- }else{
- $this->handle->addOS(trim($_POST['is_string']));
- }
- }
-
- /* Delete selected os from list and db
- */
- if((isset($_POST['del_os']))&&(!empty($_POST['select_os'])) && $this->acl_is_writeable("os")){
- $tmp = $this->handle->is_osUsed($_POST['select_os']);
-
- if(count($tmp)){
-
- $names = "";
- foreach($tmp as $name){
- $names .= ", ".$name;
- }
- $names = preg_replace("/^, /","",$names);
- $names = trim($names);
- if(count($tmp) == 3){
- $names .= " ...";
- }
- print_red(sprintf(_("You can't delete this operating system, it is still in use by these system(s) '%s'"),$names));
-
- }else{
- $this->handle->removeOS_byID($_POST['select_os']);
- }
- }
-
- /* Rename selected os to given string
- */
- if(isset($_POST['Rename_os_OK']) && $this->acl_is_writeable("os")){
- $attr = $this->handle->getOSTypes();
- if(in_array(trim($_POST['string']),$attr)){
- print_red(_("Updating operating system failed, specifed name is already used.")) ;
- }else{
- $this->handle->updateOS($_POST['string'],$this->select_type);
- $this->renameOSDialog = false;
- }
- }
- if((isset($_POST['rename_os'])&&(!empty($_POST['select_os'])))||($this->renameOSDialog)){
- if(isset($_POST['select_os'])){
- $this->select_type = $_POST['select_os'];
- }
- $this->renameOSDialog = true;
- $tmp = $this->handle->getOSTypes();
-
- $smarty->assign("string",$tmp[$this->select_type]);
- if(isset($_POST['string'])){
- $smarty->assign("string",$_POST['string']);
- }
- $smarty->assign("Method","rename");
- $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE));
- return($display);
- }
-
- /* Open dialog to edit os types
- */
- if($this->edit_os){
- $smarty->assign("Method","edit");
- $smarty->assign("OSs", $this->handle->getOSTypes());
- $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes()));
- $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE));
- return($display);
- }
-
-
-
- /* Show dialog to select a new contact person
- * Select a contact person
- */
- if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){
- $this->addUser = "contact";
- $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
- $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category));
- $this->cur_dialog->set_acl_base($this->dn);
-
- }
-
- /* Open dialog which allows to edit the manufacturers
- */
- if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){
- $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
- $this->dialog = true;
- }
-
- /* Close manufacturer editing dialog
- */
- if(isset($_POST['close_edit_manufacturer'])){
- $this->dialog = false;
- $this->cur_dialog = false;
- }
-
- /* Abort user selection
- */
- $smarty->assign("AbortSelectUser","SelectUserCancel");
- if(isset($_POST['SelectUserCancel'])){
- $this->dialog = false;
- $this->addUser ="";
- $this->cur_dialog = false;
- }
-
- /* Selecte technical responsible person
- */
- if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){
- $this->addUser ="tech";
- $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
- $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category));
- $this->cur_dialog->set_acl_base($this->dn);
- }
-
- /* Technical responsible person selected*/
- if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")&&(strlen($_GET['id']) > 100)){
- print_red(sprintf(_("Could not add the given user, the users dn is too long, only 100 characters are allowed here.")));
-
- }elseif(isset($_GET['act'])&&($_GET['act']=="user_tech_num") && strlen($_GET['id'])){
-
-
- /* 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 */
- $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
- $atr = $ldap->fetch();
- $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->handle->addUser($tmp,$id);
- }
-
- /* Re-read users */
- $users = ($this->handle->getUsers());
-
- /* Get user */
- $tmp = array_flip($users);
- $id=$tmp[$id];
-
- /* Use user id, close dialog */
- if($this->addUser == "tech"){
- $this->tech_num = $id;
- }else{
- $this->contact_num = $id;
- }
- $this->cur_dialog = false;
- $this->dialog= false;
- }
-
- /* if( cur_dialog != false || cur_dialog != NULL)
- * There is a dialog which wants to be displayed
- */
- if(isset($this->cur_dialog) && is_object($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;
- }
-
- /* Assign smarty defaults */
- foreach(array("SystemTypes","SystemTypeKeys","Manufacturers","OSs","TechnicalResponsibles","InstalledDevices","Attachments") as $attr){
- $smarty->assign($attr,array());
- }
-
- /* Assign some vars to smarty
- */
- foreach(array("type","FK_glpi_enterprise","os","tech_num","contact_num","Attachments","InstalledDevices") as $attr){
- $smarty->assign($attr,"");
- }
-
- /* Do we need to flip is_account state? */
- if(isset($_POST['modify_state'])){
- if($this->is_account && $this->acl_is_removeable()){
- $this->is_account= FALSE;
- }elseif(!$this->is_account && $this->acl_is_createable()){
- $this->is_account= TRUE;
- }
- }
-
- /* Show tab dialog headers */
- if ($this->is_account){
- $display= $this->show_disable_header(_("Remove inventory"),
- _("This device has inventory informations enabled. You can disable them by clicking below."));
- } else {
- $display= $this->show_enable_header(_("Add inventory"),
- _("This device has inventory informations disabled. You can enable them by clicking below."));
- return ($display);
- }
-
- /* Assign system types
- */
- $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
- $smarty->assign("SystemTypes", $this->handle->getSystemTypes());
- $smarty->assign("type", $this->type);
-
- /* Assign os types
- */
- $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes()));
- $smarty->assign("OSs", $this->handle->getOSTypes());
- $smarty->assign("os", $this->os);
-
- /* Dispaly installed devices */
- $smarty->assign("InstalledDevices" ,$this->getDevices());
- $smarty->assign("InstalledDeviceKeys" ,array_flip($this->getDevices()));
-
- /* Append manufacturers
- */
- $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises()));
- $smarty->assign("Manufacturers", $this->handle->getEnterprises());
- $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
-
- /* Assign used Attachments
- */
-
- $divlist = new divSelectBox("glpiAttachmentsList");
- $divlist-> SetHeight(130);
- $atts = $this->getUsedAttachments(true);
- $downlink = "<a href='get_attachment.php?id=%s' target='_blank'>%s</a>";
- $del_link = "<input type='image' src='images/edittrash.png' name='delAttachment_%s'>";
- foreach($atts as $id => $attachment){
- $divlist->AddEntry
- (
- array(
- array("string"=>$attachment['name']),
- array("string"=>$attachment['mime']),
- array("string"=>sprintf($downlink,$id,$attachment['filename'])),
- array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"),
- )
- );
- }
-
- $smarty->assign("AttachmentsDiv" ,$divlist->DrawList());
- /* Handle contact person
- Assign name ... to smarty, if set
- */
- if(isset($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]." "; }
- if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
- $smarty->assign("contact_num", $str);
- }else{
- $smarty->assign("contact_num", _("N/A"));
- }
-
- /* Handle tech person
- Assign name ... to smarty, if set
- */
- if(isset($users[$this->tech_num])){
- $tr = $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]." "; }
- if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
- $smarty->assign("tech_num", $str);
- }else{
- $smarty->assign("tech_num", _("N/A"));
- }
- $smarty->assign("comments", $this->comments);
-
- $display.= $smarty->fetch(get_template_path('glpi.tpl', TRUE));
- return($display);
- }
-
- function remove_from_parent()
- {
- /* Cancel if there's nothing to do here */
- if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){
- return;
- }
- if(function_exists("mysql_pconnect")){
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
- if($this->initially_was_account){
- $this->handle->removeComputerInformations($this->dn);
- new log("remove","undefined/".get_class($this),$this->dn);
- }
- }else{
- print_red(_("Can't remove glpi account, while mysql extension is missing."));
- new log("remove","undefined/".get_class($this),$this->dn,array(),_("Can't remove glpi account, while mysql extension is missing."));
- }
-
- }
-
- function getDevices(){
- $ret = array();
- foreach($this->usedDevices as $type => $entries){
- foreach($entries as $ent){
- if(isset($ent['designation'])){
- $ret[] = $ent['designation']." [".$type."]";
- }else{
- $ret[] = $ent['name']." [".$type."]";
- }
- }
- }
- return($ret);
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if(!isset($_POST['glpi_tpl_posted'])) {
- return ;
- }
- plugin::save_object();
- }
-
-
- /* Check supplied data */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- // if($this->TechnicalResponsible == ""){
- // $message[] = _("Please select a technical responsible person for this entry.");
- // }
-
- return ($message);
- }
-
-
- /* Save to LDAP */
- function save()
- {
- if($this->is_account){
- $attrs = array();
- $this->date_mod = date("Y-m-d H:i:s");
- foreach($this->attributes as $attr){
- $attrs[$attr] = $this->$attr;
- }
- $attrs['name'] = $this->dn;
- unset($attrs['ID']);
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-
- /* check if we have to update, add */
- if($this->initially_was_account&&$this->is_account){
- $this->handle->updateComputerInformations($attrs,$this->orig_dn);
- new log("modify","undefined/".get_class($this),$this->dn);
- }elseif($this->is_account){
- $this->handle->addComputerInformations($attrs,$this->dn);
- new log("create","undefined/".get_class($this),$this->dn);
- }
- $tmp = $this->handle->getComputerInformations($this->dn);
- $this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']);
- }
- }
-
-
- /* Return used attachments */
- function getUsedAttachments($divlist = false)
- {
- $atts =$this->handle->getAttachments();
- $ret = array();
- foreach($atts as $entry){
- if(in_array($entry['ID'],$this->usedAttachments)){
- if($divlist){
- $ret[$entry['ID']] = $entry;
- }else{
- $cm ="";
- if(isset($entry['comment'])){
- $cm=" [".$entry['comment']."]";
- }
- if(isset($entry['mime'])){
- $cm.=" -".$entry['mime']."";
- }
-
- $ret[$entry['ID']]= $entry['name'].$cm;
- }
- }
- }
- return($ret);
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Glpi"),
- "plDescription" => _("Inventory extension"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 20,
- "plSection" => array("administration"),
- "plCategory" => array("workstation","terminal","component","server","phone") ,
- "plProvidedAcls"=> array(
-
- "tech_num" => _("Technical responsible"),
- "comments" => _("Comment"),
- "os" => _("Operating system"),
- "location" => _("Location"),
- "contact_num" => _("Contact person"),
- "model" => _("Model"),
- "type" => _("Type"),
- "FK_glpi_enterprise" => _("Manufacturer"),
- "Attachments" => _("Attachments"),
- "Devices" => _("Peripheral devices"))
- ));
- }
-
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiAttachmentPool.inc
+++ /dev/null
@@ -1,364 +0,0 @@
-<?php
-
-class glpiAttachmentPool extends plugin
-{
- /* CLI vars */
- var $cli_summary= "Manage server basic objects";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account = TRUE;
- var $attributes = array("name","comment","mime","filename","date_mod");
- var $objectclasses = array("whatever");
-
- var $parent;
- var $edit = false;
- var $entry = false;
- var $date_mod ="";
- var $name ="";
- var $comment ="";
- var $mime ="";
- var $filename ="";
-
- var $Selected = array();
-
- var $delAttach= "";
-
- function glpiAttachmentPool (&$config, $dn= NULL,$used=NULL)
- {
- plugin::plugin ($config, $dn);
- if(!session::is_set('GlpiAttachmentFilter')){
- session::set('GlpiAttachmentFilter',array("filter"=>"*"));
- }
-
- /* Assign used attributes */
- if($used !== NULL){
- $this->Selected = $used;
- }
- }
-
- function execute()
- {
- plugin::execute();
- $attach = $this->parent->handle->getAttachments();
- /* Fill templating stuff */
- $smarty = get_smarty();
- $display = "";
- $only_once = true;
-
- /* walk through all posted objects */
- foreach($_POST as $name => $value){
-
- /* Open dialog to create a new entry */
- if(preg_match("/new_attach/",$name)){
- $this->edit = true;
- $this->entry=array();
-
- /* Set default values */
- foreach($this->attributes as $attr) {
- $this->$attr = "";
- $this->entry[$attr]="";
- }
- }
-
- /* Remove attach*/
- if((preg_match("/^delAttach_/",$name))&&($only_once)){
- $only_once = false;
- $str = preg_replace("/^delAttach_/","",$name);
- $str = base64_decode(preg_replace("/_.*$/","",$str));
-
- /* remove attach from db */
- $this->delAttach = $str;
- $smarty->assign("warning", sprintf(_("You're about to delete the glpi attachment component '%s'."), $attach[$str]['name']));
- return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
- }
-
- /* Start editing entry */
- if((preg_match("/^editAttach_/",$name))&&($only_once)){
- $only_once = false;
- $str = preg_replace("/^editAttach_/","",$name);
- $str = base64_decode(preg_replace("/_.*$/","",$str));
-
- /* Check if we have an attachment with given ID */
- foreach($attach as $att ){
- if($att['ID'] == $str ){
-
- /* Entry was found, show dialog */
- $this->edit = true;
- $this->entry = $att;
-
- foreach($att as $name => $value){
- $this->$name = $value;
- }
- }
- }
- }
- }
-
- if((isset($_POST['delete_glpi_confirm']))&&(isset($attach[$this->delAttach]))){
- if($this->parent->handle->is_attachmentUsed($this->delAttach)){
- $tmp = $this->parent->handle->is_attachmentUsed($this->delAttach);
-
- $names = "";
- foreach($tmp as $name){
- $names .= ", ".$name;
- }
- $names = preg_replace("/^, /","",$names);
- $names = trim($names);
- if(count($tmp) == 3){
- $names .= " ...";
- }
- print_red(sprintf(_("You can't delete this attachment, it is still in use by these system(s) '%s'"),$names));
-
- }else{
- $this->parent->handle->deleteAttachment($this->delAttach);
- @unlink(CONFIG_DIR."/glpi/".$this->filename);
- $attach = $this->parent->handle->getAttachments();
- }
- }
-
- /* Someone tries to upload a file */
- if(($this->edit == true)&&(isset($_POST['upload']))){
- if(!isset($_FILES['filename'])){
- print_red(_("There is no valid file uploaded."));
- }else{
- $FILE = $_FILES['filename'];
- if(!isset($FILE['name'])){
- print_red(_("There is no valid file uploaded."));
- }else{
- if($FILE['error']!=0) {
- print_red(_("Upload wasn't successfull."));
- }else{
- if(!is_dir(CONFIG_DIR."/glpi/")){
- print_red(sprintf(_("Missing directory '%s/glpi/' to store glpi uploads."),CONFIG_DIR));
- }else{
- $filen = CONFIG_DIR."/glpi/".$FILE['name'];
- if(file_exists($filen)){
- print_red(_("There is already a file with the same name uploaded."));
- }else{
- $fh = fopen($filen,"w");
- if(!$fh){
- print_red(sprintf(_("Can't create file '%s'."),$filen));
- }else{
- $str = file_get_contents($FILE['tmp_name']);
- fwrite($fh,$str,strlen($str));
- fclose($fh);
- $this->mime = $FILE['type'];
- $this->filename = $FILE['name'];
- }
- } // File already exists
- }
- } // Check if any error occurred
- } // check if valid filename was uploaded
- } // ende check if file was uploaded
- }// upload post
-
- /* save attachment*/
- if(($this->edit == true)&&(isset($_POST['SaveAttachment']))){
- if(count($this->check())==0){
- $this->date_mod = date("Y-m-d H:i:s");
- $this->save_entry();
- $this->edit= false;
- $this->entry = array();
- $attach = $this->parent->handle->getAttachments();
- }else{
- foreach($this->check() as $msg){
- print_red($msg);
- }
- }
- }
-
- /* Abort editing/adding attachment*/
- if(($this->edit == true)&&(isset($_POST['CancelAttachment']))){
- $this->edit = false;
- $this->entry = array();
- }
-
- /* If edit == true, we have to show a dialog to edit or add an attach
- */
- if($this->edit == true){
- foreach($this->attributes as $attr){
- $smarty->assign($attr,htmlentities(utf8_decode($this->$attr)));
- }
- if(!empty($this->filename)){
- if(is_readable(CONFIG_DIR."/glpi/".$this->filename)){
- $status =_("File is available.");
- }else{
- $status =_("File is not readable, possibly the file is missing.");
- }
- }else{
- $status = _("Currently no file uploaded.");
- }
- $smarty->assign("status",$status);
- return($smarty->fetch(get_template_path('glpiAttachmentEdit.tpl', TRUE)));
- }
-
- /* Create list with checkboxes to select / deselect some attachents */
- $divlist = new divlist("Attachment");
- $divlist->SetPluginMode();
- $divlist->SetHeader(array(
- array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
- array("string" => _("Name")),
- array("string" => _("Mime"),"attach"=>"style='width:200px;'"),
- array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
-
- $divlist->SetSummary(_("This table displays all available attachments."));
- $divlist->SetEntriesPerPage(0);
-
- $editdel = "<input type='image' name='editAttach_%s' src='images/edit.png'>";
- $editdel.= "<input type='image' name='delAttach_%s' src='images/edittrash.png'>";
-
- /* Add all given attachments to divlist
- */
- foreach($attach as $entry){
-
- /* Create display name*/
- if((empty($entry['name']))||(empty($entry['comment']))){
-
- /* In glpi it is possible to add entries without name
- so i've added this block
- */
- if(empty($entry['name'])){
- $str1 = "<i>"._("empty")."</i>";
- }else{
- $str1 = $entry['name'];
- }
-
- if(!empty($entry['comment'])){
- $str1.= " [".$entry['comment']."]";
- }
- }else{
- /* Both attributes given */
- $str1 = $entry['name']." [".$entry['comment']."]";
- }
-
- $edit = str_replace("%s",base64_encode($entry['ID']),$editdel);
- $str2 = $entry['mime']." ";
-
- $chkbox = "<input type='hidden' name='wasOnPage_%s'>".
- "<input type='checkbox' name='useMe_%s' value='%s' %CHECKED%>";
-
- if(in_array($entry['ID'],$this->Selected)){
- $chkbox = preg_replace("/%CHECKED%/"," checked ",$chkbox);
- }else {
- $chkbox = preg_replace("/%CHECKED%/"," ",$chkbox);
- }
- $chkbox = preg_replace("/%s/",$entry['ID'],$chkbox);
- $divlist->AddEntry(array(
- array("string" => $chkbox,
- "attach" => "style='text-align:center;width:20px;'"),
- array("string"=> $str1),
- array("string"=> $str2,"attach"=>"style='width:200px;'"),
- array("string"=> $edit ,"attach" => "style='width:60px;border-right:0px;text-align:right;'")
- ));
-
- }
-
- $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
- " <input class='center' type='image'
- src='images/fai_new_template.png' align='middle' title='"._("Create new attachment")."'
- name='new_attach' alt='"._("New Attachment"). "'> ".
- "</div>";
-
- $GlpiAttachmentFilter = session::get('GlpiAttachmentFilter');
-
- $smarty->assign("attachments", $divlist->DrawList());
- $smarty->assign("attachmenthead", $listhead);
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("infoimage", get_template_path('images/info_small.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("apply", apply_filter());
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("attachment_regex", $GlpiAttachmentFilter['filter']);
-
- $display.= $smarty->fetch(get_template_path('glpiAttachmentPool.tpl', TRUE));
- return($display);
- }
-
- function save()
- {
- return($this->Selected);
- }
-
- /* Adds new or saves edited entries */
- function save_entry()
- {
- if($this->edit){
- $tmp = array();
- foreach($this->attributes as $attr){
- $tmp[$attr] = $this->$attr;
- }
- $id = -1;
- if(isset($this->entry['ID'])){
- $id = $this->entry['ID'];
- }
- $this->parent->handle->saveAttachments($tmp,$id);
- }
- }
-
- function save_object()
- {
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr = $_POST[$attr];
- }
- }
-
- /* Checkboxes are only posted, if they are checked
- * To check if it was deselected, we check if wasOnPage
- * was posted with given name, so we can deselect this entry
- */
-
- foreach($_POST as $name => $value){
- if(preg_match("/wasOnPage_/",$name)){
- $id=preg_replace("/wasOnPage_/","",$name);
- if(isset($_POST["useMe_".$id])){
- $this->Selected[$id]=$id;
- }else{
- if(isset($this->Selected[$id])){
- unset($this->Selected[$id]);
- }
- }
- }
- }
- }
-
- /* Simple check */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- if($this->edit){
-
- /* check if given name is already in use */
- $att = $this->parent->handle->getAttachments();
- $ok = true;
- $this->name=trim($this->name);
-
- foreach($att as $val){
- if(!isset($this->entry['ID'])){
- if($val['name'] == $this->name){
- $ok = false;
- }
- }else{
- if(($val['name'] == $this->name)&&($this->entry['ID'] != $val['ID'])){
- $ok = false;
- }
- }
- }
- if(!$ok){
- $message[] = _("This name is already in use.");
- }
- if(empty($this->name)){
- $message[] = _("Please specify a valid name for this attachment.");
- }
- }
- return($message);
- }
-
-}// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiDeviceManagement.inc
+++ /dev/null
@@ -1,427 +0,0 @@
-<?php
-
-class glpiDeviceManagement extends plugin
-{
- /* CLI vars */
- var $cli_summary= "Manage server basic objects";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account= TRUE;
- var $attributes= array();
- var $objectclasses= array("whatever");
-
- var $devices = array();
- var $ui;
-
- var $parent ;
- var $EditEntry;
- var $editMode =false;
-
- var $DeviceAttrs = array();
- var $AllowedDevices = array();
-
- var $Selected = array();
-
- var $delete = array();
-
- function glpiDeviceManagement (&$config, $dn= NULL,$used=NULL)
- {
- plugin::plugin ($config, $dn);
-
- if(!session::is_set('glpiDeviceRegex')){
- $tmp['device_regex'] = "*";
- session::set('glpiDeviceRegex',$tmp);
- }
- $this->ui = get_userinfo();
-
- if(isset($used)){
- $this->Selected = $used;
- }
-
- /* Specify which vars are allowed for a sepcific type of device */
- $this->DeviceAttrs['case'] = array("designation","format","comment","FK_glpi_enterprise");
- $this->DeviceAttrs['moboard'] = array("designation","chipset","comment","FK_glpi_enterprise");
- $this->DeviceAttrs['processor'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['iface'] = array("designation","bandwidth","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['ram'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default","type");
- $this->DeviceAttrs['hdd'] = array("designation","rpm","interface","cache","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['drive'] = array("designation","speed","interface","is_writer","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['control'] = array("designation","interface","raid","comment","FK_glpi_enterprise");
- $this->DeviceAttrs['gfxcard'] = array("designation","ram","interface","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['sndcard'] = array("designation","type","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['power'] = array("designation","power","comment","FK_glpi_enterprise","atx");
- $this->DeviceAttrs['pci'] = array("designation","comment","FK_glpi_enterprise","specif_default");
- $this->DeviceAttrs['monitor'] = array("name","comments","serial","otherserial","size",
- "flags_micro","flags_speaker","flags_subd","flags_bnc",
- "location","type","FK_glpi_enterprise","is_global","deleted","is_template","tplname");
-
- $this->AllowedDevices=array("case","moboard","sndcard","processor","iface","ram","hdd","drive","control","gfxcard","power","pci","monitor");
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Get all defined devices */
- $this->reload();
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- /* this var is used to ensure that every post is only performed once */
- $only_once = true;
-
- /* Check Post for some actions */
- foreach($_POST as $name => $value){
-
- /* If new_ then we should create an new device */
- if((preg_match("/^new_/",$name))&&($only_once)){
-
- /* don't do this twice */
- $only_once = false;
-
- /*extract device device_type */
- $deviceType = preg_replace("/_.*$/","",preg_replace("/^new_/","",$name));
-
- /* Check if type is allowed, and create empty entry */
- $tmp = array();
- if((!isset($this->DeviceAttrs[$deviceType]))||((!in_array($deviceType,$this->AllowedDevices)))){
- print_red(sprintf(_("Internal Error can't create device of type '%s'"),$deviceType));
- }else{
- foreach($this->DeviceAttrs[$deviceType] as $attr){
- $tmp[$attr] = "";
- }
- $tmp['device_type'] = $deviceType;
- $this->EditEntry = $tmp;
- $this->editMode =true;
- }
- }
- }
-
- /* delete was requested ... show dialog */
- if((isset($_GET['act']))&&($_GET['act']=="del_device")){
- $id = base64_decode($_GET['id']);
- $tmp = $this->devices[$id];
-
- $this->delete = $tmp;
-
- if(isset($tmp['name'])){
- $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['name']));
- }elseif(isset($tmp['designation'])){
- $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['designation']));
- }else{
- print_red(_("Can't detect object name."));
- }
-
- return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
- }
-
- /* Delete entry, but check if this device is in currently in use */
- if(isset($_POST['delete_glpi_confirm'])){
- if(count($this->parent->handle->is_deviceUsed($this->delete))){
-
- $tmp = $this->parent->handle->is_deviceUsed($this->delete);
-
- $names = "";
- foreach($tmp as $name){
- $names .= ", ".$name;
- }
- $names = preg_replace("/^, /","",$names);
- $names = trim($names);
- if(count($tmp) == 3){
- $names .= " ...";
- }
- print_red(sprintf(_("You can't delete this device, it is still in use by these system(s) '%s'"),$names));
- }else{
- $this->parent->handle->deleteDevice($this->delete);
- $this->reload();
- }
- }
-
- /* Open entry for editing if requested */
- if((isset($_GET['act']))&&($_GET['act']=="edit_device")){
- $id = base64_decode($_GET['id']);
- $this->editMode =true;
- $this->EditEntry = $this->devices[$id];
- }
-
- /* Abort editing this entry */
- if(isset($_POST['AbortDeviceChanges'])){
- $this->EditEntry = array();
- $this->editMode = false;
- }
-
- /* Save all changes made on currently selected entry */
- if(isset($_POST['SaveDeviceChanges'])){
-
- /* First check if all changes made are allowed */
- if(count($this->check())==0){
- $this->save();
- $this->editMode = false;
- $this->reload();
- }else{
- foreach($this->check() as $msg){
- print_red($msg);
- }
- }
-
- }
-
- /* Check if we are currently editing something ? */
- if($this->editMode == true){
- return ($this->editDevice($this->EditEntry));
- }
-
- /* ENDE : GET / POST handling
- * Below, only output generation for headpage
- */
-
- $divlist = new divlist("glpi devices");
- $divlist->SetPluginMode();
- $divlist->SetEntriesPerPage(0);
- $divlist->SetHeader(array(
- array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
- array("string" => _("devices"), "attach" => "style=''"),
- array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
-
- $edit = "<a href='?plug=".$_GET['plug']."&act=edit_device&id=%s'>%s</a>";
- $editdel = "<a href='?plug=".$_GET['plug']."&act=edit_device&id=%s'><img src='images/edit.png' alt='"._("Edit")."' border=0></a>";
- $editdel.= "<a href='?plug=".$_GET['plug']."&act=del_device&id=%s'><img src='images/edittrash.png' alt='"._("Delete")."' border=0></a>";
-
- $useDevice = "<input type='hidden' name='wasOnPage_%s' value='%s'><input type='checkbox' value='%s' name='useDevice_%s' %USE%>";
-
- foreach($this->devices as $key=>$user){
-
- if(isset($user['designation'])){
- $str = "designation";
- }else{
- $str = "name";
- }
-
- if(isset($this->Selected[$user['device_type']][$user[$str]])){
- $use = " checked ";
- }else{
- $use ="";
- }
-
- /* Dawn databse struckture ....*/
- if(empty($user['comment']) && isset($user['comments'])) {
- $user['comment'] = $user['comments'];
- }
-
- $field1 = array("string" => preg_replace("/%s/",base64_encode($key),preg_replace("/%USE%/",$use,$useDevice)), "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($edit,base64_encode($key),$user[$str]." [".$user['comment']."]"), "attach" => "style=''");
- $field3 = array("string" => sprintf($editdel,base64_encode($key),base64_encode($key)),
- "attach" => "style='width:60px;border-right:0px;text-align:right;'");
- $divlist->AddEntry(array($field1,$field2,$field3));
-
- }
-
- $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
- " <input class='center' type='image' align='middle'
- src='images/monitor.png' title='"._("New monitor")."' alt='"._("M")."' name='new_monitor'> ".
- " <input class='center' type='image' align='middle'
- src='images/mainboard.png' title='"._("New mainbord")."' alt='"._("MB")."' name='new_moboard'> ".
- " <input class='center' type='image' align='middle'
- src='images/processor.png' title='"._("New processor")."' alt='"._("P")."' name='new_processor'> ".
- " <input class='center' type='image' align='middle'
- src='images/server.png' title='"._("New case")."' alt='"._("C")."' name='new_case'> ".
- " <input class='center' type='image' align='middle'
- src='images/net_hardware.png' title='"._("New network interface")."' alt='"._("NI")."' name='new_iface'> ".
- " <input class='center' type='image' align='middle'
- src='images/memory.png' title='"._("New ram")."' alt='"._("R")."' name='new_ram'> ".
- " <input class='center' type='image' align='middle'
- src='images/fai_partitionTable.png' title='"._("New hard disk")."' alt='"._("HDD")."' name='new_hdd'> ".
- " <input class='center' type='image' align='middle'
- src='images/drives.png' title='"._("New drive")."' alt='"._("D")."' name='new_drive'> ".
- " <input class='center' type='image' align='middle'
- src='images/hardware.png' title='"._("New controller")."' alt='"._("CS")."' name='new_control'> ".
- " <input class='center' type='image' align='middle'
- src='images/gfx_hardware.png' title='"._("New graphics card")."' alt='"._("GC")."' name='new_gfxcard'> ".
- " <input class='center' type='image' align='middle'
- src='images/snd_hardware.png' title='"._("New sound card")."' alt='"._("SC")."' name='new_sndcard'> ".
- " <input class='center' type='image' align='middle'
- src='images/power.png' title='"._("New power supply")."' alt='"._("PS")."' name='new_power'> ".
- " <input class='center' type='image' align='middle'
- src='images/fai_template.png' title='"._("New misc device")."' alt='"._("OC")."' name='new_pci'> ".
- "</div>";
-
- $filter = session::get('glpiDeviceRegex');
- $smarty->assign("devicehead", $listhead);
- $smarty->assign("devices", $divlist->DrawList());
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("infoimage", get_template_path('images/info_small.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("apply", apply_filter());
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("device_regex", $filter['device_regex']);
-
- $display.= $smarty->fetch(get_template_path('glpiDeviceManagement.tpl', TRUE));
- return($display);
- }
-
- /* Save device to glpi database
- * If this is a new device, create a new entry, else update this entry
- */
- function save()
- {
- if($this->parent->handle->deviceExists($this->EditEntry)){
- $this->parent->handle->updateDevices($this->EditEntry);
- }else{
- $this->parent->handle->addDevice($this->EditEntry);
- }
-
- }
-
- /* this only gets all already defined devices */
- function reload()
- {
- $this->devices = $this->parent->handle->getDevices();
- ksort($this->devices);
- }
-
- /* This funtions saves all POST variables.
- The variable must be in the array $this->EditEntry
- */
- function save_object()
- {
- foreach($_POST as $name => $value){
-
- if(preg_match("/wasOnPage_/",$name)){
- $dN = base64_decode($value);
-
- $device = $this->devices[$dN];
- $type = $device['device_type'];
-
- if(isset($device['designation'])){
- $str = "designation";
- }else{
- $str = "name";
- }
-
- if(isset($_POST['useDevice_'.$value])){
- $this->Selected[$type][$device[$str]] = $device;
- }else{
- if(isset($this->Selected[$type][$device[$str]])){
- unset($this->Selected[$type][$device[$str]]);
- }
- }
- }
- }
-
- if(is_array($this->EditEntry)){
- foreach($this->EditEntry as $name => $value){
- if(isset($_POST[$name])){
- $this->EditEntry[$name] = $_POST[$name];
- }
-
- }
- }
- }
-
- /* returns the selected devices */
- function getSelected()
- {
- return($this->Selected);
- }
-
- /* This function checks all created devices.
- If you wan't to use device specific checks,
- use >>if($attr['device_type']=="moboard")<< to create a device type depending check
- */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- $attr = $this->EditEntry;
-
- if(isset($attr['designation'])){
- $str2 = "designation";
- }else{
- $str2 = "name";
- }
- if(empty($attr[$str2])){
- $message[]=(_("You have to specify a valid name for this device."));
- }
-
- /* Avoid same name twice */
- $devices = ($this->parent->handle->getDevices());
- foreach($devices as $dev){
-
- /* Some devices use designation some name for name
- */
- if(isset($dev['designation'])){
- $str = "designation";
- }else{
- $str = "name";
- }
-
- if($dev[$str]==$attr[$str2]){
-
- /* Entries with ['ID'] already exists, and are only edited, if ID is missing we are currently creating a new entry */
- if(isset($attr['ID'])){
- if(!(($dev['ID'] == $attr['ID'])&&($dev['device_type']==$attr['device_type']))){
- $message[] = _("This device name is already in use.");
- }
- }else{
- $message[] = _("This device name is already in use.");
- }
- }
- }
-
- return($message);
- }
-
- /* This functions displays the template for all available devices
- * This function is also used if we create a new device
- */
- function editDevice($entry)
- {
- $smarty = get_smarty();
-
- /* Transfer given data to smarty */
- foreach($this->EditEntry as $name => $value){
- $smarty->assign($name,htmlentities(utf8_decode($value)));
- }
-
- /* Set default select boxes, manufacturers ... */
- $smarty->assign("device_type",$entry['device_type']);
-
- $none = array(0 => _("none"));
- $manufacturer = array_merge($none,$this->parent->handle->getEnterprises());
-
- $ramtypes = $this->parent->handle->getRAMTypes();
-
- $smarty->assign("RAMtypes", $ramtypes);
- $smarty->assign("RAMtypeKeys", array_flip($ramtypes));
-
- $deviceControlTypes = array_merge($none,$this->parent->handle->getGlpiDeviceControlTypes());
-
- $smarty->assign("HDDInterfaceKeys",array_flip($deviceControlTypes));
- $smarty->assign("HDDInterfaces" , $deviceControlTypes);
-
- $gfxControlTypes = array("0"=>_("None"),"AGP"=>"AGP","PCI"=>"PCI","PCI-X"=>"PCI-X","Other"=>_("Other"));
-
- $smarty->assign("GFXInterfaceKeys",array_flip($gfxControlTypes));
- $smarty->assign("GFXInterfaces" , $gfxControlTypes);
-
- $smarty->assign("FK_glpi_enterpriseKeys",array_flip($manufacturer));
- $smarty->assign("FK_glpi_enterprises", $manufacturer);
-
- $smarty->assign("formats",array("Large","Medium","Micro"));
- $smarty->assign("formats",array("Large","Medium","Micro"));
-
- $smarty->assign("formats",array("Large","Medium","Micro"));
- $smarty->assign("formatKeys",array('Grand','Moyen','Micro'));
- return($smarty->fetch(get_template_path('glpi_devices.tpl', TRUE)));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiManufacturer.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiManufacturer.inc
+++ /dev/null
@@ -1,170 +0,0 @@
-<?php
-
-class glpiManufacturer extends plugin
-{
- /* CLI vars */
- var $cli_summary= "Manage server basic objects";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account= TRUE;
- var $attributes= array("name","type","address","website","phonenumber","comments","deleted","fax","email");
- var $objectclasses= array("whatever");
-
- var $ui;
-
- var $editMode = false;
- var $Edit_Add = "edit";
-
- var $name ="";
- var $type ="";
- var $address ="";
- var $website ="";
- var $phonenumber="";
- var $comments ="";
- var $deleted ="";
- var $fax ="";
- var $email ="";
- var $ID =-1;
-
- function glpiManufacturer(&$config, $dn= NULL, $parent= NULL)
- {
- plugin::plugin ($config, $dn, $parent);
- $this->ui = get_userinfo();
- }
-
- function execute()
- {
- plugin::execute();
- $smarty = get_smarty();
- $display = "";
-
- /* Remove enterprise from db */
- if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){
-
- $tmp = $this->parent->handle->is_manufacturerUsed($_POST['manufacturer']);
- if(count($tmp)){
-
- $names = "";
- foreach($tmp as $name){
- $names .= ", ".$name;
- }
- $names = preg_replace("/^, /","",$names);
- $names = trim($names);
- if(count($tmp) == 3){
- $names .= " ...";
- }
- print_red(sprintf(_("You can't delete this manufacturer, it is still in use by these system(s) '%s'"),$names));
- }else{
- $this->parent->handle->removeEnterprise($_POST['manufacturer']);
- }
- }
-
- /* Add new Manufactuer : Open dialog with empty fields */
- if(isset($_POST['add_manu'])){
- $this->editMode = true;
- $this->Edit_Add = "add";
- foreach($this->attributes as $atr){
- $this->$atr = "";
- }
- }
-
- /* Edit existing manuatctuerer data */
- if((isset($_POST['edit_manu']))&&(isset($_POST['manufacturer']))){
- $this->editMode = true;
- $this->Edit_Add = "edit";
- $tmp = $this->parent->handle->getEnterprise($_POST['manufacturer']);
- $tmp = $tmp[0];
- foreach($this->attributes as $atr){
- $this->$atr = "";
- }
- foreach($this->attributes as $atr){
- if(isset($tmp[$atr])){
- $this->$atr = $tmp[$atr];
- }
- }
- $this->ID = $_POST['manufacturer'];
- }
-
- /* close Dialog without saving */
- if(isset($_POST['close_manufacturer'])){
- $this->editMode=false;
- }
-
- /* close dialog an save all changes / adds */
- if(isset($_POST['save_manufacturer'])){
- $tmp = array();
- foreach($this->attributes as $attrs){
- $tmp[$attrs]=$this->$attrs;
- }
-
- $allok = true;
- if(empty($tmp['name'])){
- print_red(_("Please specify a name."));
- $allok = false;
- }
-
- $attr = $this->parent->handle->getEnterprises();
-
- if($this->ID == -1 ){
- if(in_array($tmp['name'],$attr)){
- $allok = false;
- print_red(_("Specified name is already in use, please choose another one."));
- }
- }else{
- unset($attr[$this->ID]);
- if(in_array($tmp['name'],$attr)){
- $allok = false;
- print_red(_("Specified name is already in use, please choose another one."));
- }
- }
-
- /* all checks are ok , so save changes */
- if($allok){
- if($this->Edit_Add == "add"){
- $this->parent->handle->addEnterprise($tmp);
- $this->editMode=false;
- }else{
- $this->parent->handle->updateEnterprise($tmp,$this->ID);
- $this->editMode=false;
- }
- }
- }
-
- /* As long as this war is true, we have to display the edit dialog */
- if($this->editMode == true){
- $this->save_object();
- foreach($this->attributes as $attrs){
- $smarty->assign($attrs,$this->$attrs);
- }
-
- $display.= $smarty->fetch(get_template_path('glpiManufacturerAdd.tpl', TRUE));
- return($display);
- }
-
-
- $smarty->assign("Manus", $this->parent->handle->getEnterprises());
- $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprises()));
- $display.= $smarty->fetch(get_template_path('glpiManufacturer.tpl', TRUE));
- return($display);
- }
-
- /* Save to LDAP */
- function save()
- {
- }
-
- function save_object()
- {
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr = stripslashes($_POST[$attr]);
- }
- }
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterAccount.inc
+++ /dev/null
@@ -1,807 +0,0 @@
-<?php
-
-class glpiPrinterAccount extends plugin
-{
- /* CLI vars */
- var $cli_summary= "Manage server basic objects";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account= FALSE;
- var $attributes= array("ID","name","contact","ramSize","flags_serial","flags_par","flags_usb",
- "tech_num","comments","date_mod","location","domain","network","contact_num","serial","otherserial",
- "type","is_template","FK_glpi_enterprise","deleted");
-
- var $ID ; // Is set if this entry is edited
- var $name = ""; // This should be the dn of this entry
- var $FK_glpi_enterprise = 0; // Manufacturer id
- var $tech_num = ""; // Technical responsible person
- var $contact_num = ""; // Contact person
-
- var $comments = ""; // Comment
-
- var $type = 0; // printer type id
- var $serial = "";
- var $otherserial = "";
- var $ramSize = 0;
- var $flags_serial = false;
- var $flags_par = false;
- var $flags_usb = false;
-
- var $date_mod = ""; // Modification timestamp
-
- var $location = 0; // Not used yet
- var $domain = 0; // ? Set to 0
- var $network = 0; // ? Set to 0
-
- var $is_template = 0; // Used as template ?
- 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 $objectclasses= array("whatever");
-
- /* Used to remember if this was an account (simply: is this an edited entry) */
- var $initially_was_account = false;
-
- /* Remember current dialog */
- var $edit_type = false;
- var $edit_os = false;
-
- var $data;
- var $handle = NULL; // Glpi class handle used to query database
-
- var $cur_dialog = NULL; // This contains the sub dialog handle
-
- var $orig_dn; // To check if dn, has changed
- var $ui; // Some GOsa specific user informations
-
- var $usedDevices = array(); // Which devices are currently selected
- var $usedAttachments = array(); // Used Attachments
- var $usedCartridges = array(); // Used Cartridges
-
- var $view_logged = FALSE;
-
- /* Contructor
- Sets default values and checks if we already have an existing glpi account
- */
- function glpiPrinterAccount (&$config, $dn= NULL, $parent= NULL)
- {
- plugin::plugin ($config, $dn, $parent);
- $this->ui= get_userinfo();
-
- $this->is_account = false;
-
- /* Abort class construction, if no db is defined */
- if(!isset($this->config->data['SERVERS']['GLPI'])){
- return;
- }
-
- // Get informations about databse connection
- $this->data = $this->config->data['SERVERS']['GLPI'];
-
- // Abort if mysql extension is missing
- if(!is_callable("mysql_connect")){
- return;
- }
-
- // Create handle of glpi class, and check if database connection is established
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-
- if(!$this->handle->is_connected){
- return;
- }
-
- // If this dn is already used in database, then get all informations for this entry
- if($this->handle->is_printer_account($this->dn)){
- $this->is_account = true;
- $tmp = ($this->handle->getPrinterInformations($this->dn));
-
- foreach(array("tech_num","FK_glpi_enterprise","type","comments","contact_num","flags_serial","flags_par","flags_usb","ramSize") as $attr){
- $this->$attr = $tmp[0][$attr];
- }
-
- $atts = $this->handle->getAssignPrinterAttachments($tmp[0]['ID']);
- foreach($atts as $attachment){
- $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc'];
- }
-
- $cart= $this->handle->getUsedCartridges($tmp[0]['ID']);
- foreach($cart as $key => $cartridge){
- $this->usedCartridges[$key]=$cartridge;
- $this->usedCartridges[$key]['status']="exists";
- }
-
-
- }else{
- $this->is_account = false;
- }
-
- /* set defaults */
- $this->name = $this->dn;
- $this->orig_dn = $this->dn;
- $this->initially_was_account = $this->is_account;
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","printer/".get_class($this),$this->dn);
- }
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- $smarty->assign("CartridgesACL",$this->getacl("Cartridges"));
-
- /* Assign smarty defaults
- To avoid undefined indexes, if there is an error with the glpi db
- */
- foreach(array("PrinterTypeKeys","PrinterTypes","ManufacturerKeys","Manufacturers",
- "Attachments","AttachmentKeys","CartridgeKeys","Cartridges") as $attr){
- $smarty->assign($attr,array());
- }
- foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","comments","flags_serial","flags_par","flags_usb","AttachmentsDiv") as $attr){
- $smarty->assign($attr,"");
- }
-
- /* Assign acls */
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
-
- /* Check if there is a glpi database server defined
- */
- if(!isset($this->config->data['SERVERS']['GLPI'])){
- print_red(_("There is no server with valid glpi database service."));
- return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
- }
-
- $this->data = $this->config->data['SERVERS']['GLPI'];
-
- /* Check if we can call mysql_connect
- If we can't, there is no the mysql-php extension
- */
- if(!is_callable("mysql_connect")){
- print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
- return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
- }
-
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-
- /* If handle == false, abort
- Seems that the server, username and or password is wrong
- */
- if(!$this->handle->is_connected){
- print_red(_("Can't connect to glpi database, check configuration twice."));
- return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
- }
-
- /* All checks are ok
- Lets handle Posts, templates etc below ...
- */
-
- $users = $this->handle->getUsers();
- $ldap= $this->config->get_ldap_link();
-
-
- /* ##########################################################################
- * Some tab management
- */
-
- /* Do we need to flip is_account state? */
- if(isset($_POST['modify_state'])){
- if($this->is_account && $this->acl_is_removeable()){
- $this->is_account= FALSE;
- }elseif(!$this->is_account && $this->acl_is_createable()){
- $this->is_account= TRUE;
- }
- }
-
- /* Show tab dialog headers */
- if ($this->is_account){
- $display= $this->show_disable_header(_("Remove inventory"),
- _("This server has inventory features enabled. You can disable them by clicking below."));
- } else {
- $display= $this->show_enable_header(_("Add inventory"),
- _("This server has inventory features disabled. You can enable them by clicking below."));
- return ($display);
- }
-
-
- /* ##########################################################################
- * Printer type management
- * Dialog
- */
-
- /* Rename was requested */
- if(isset($_POST['Rename_PType_OK']) && $this->acl_is_writeable("type")){
- $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']) && $this->acl_is_writeable("type")){
- $this->dialog = true;
- $this->edit_type=true;
- }
-
- /* This closes the printer type editing dialog
- */
- if(isset($_POST['close_edit_type'])){
- $this->edit_type=false;
- $this->dialog = false;
- }
-
- /* This appends a new printer to our sytem types
- */
- if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){
-
- $tmp = $this->handle->getPrinterTypes();
- $allok = true;
- foreach($tmp as $id => $name){
- if(trim($name) == trim($_POST['type_string'])){
- $allok = false;
- }
- }
- if($allok){
- $this->handle->addPrinterType($_POST['type_string']);
- }else{
- print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['type_string']));
- }
- }
-
- /* Remove selected type from our printer types list
- */
- if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){
- $tmp = $this->handle->is_printerTypeUsed($_POST['select_type']);
- if(count($tmp)){
- $str = "";
- foreach($tmp as $id => $name){
- $str .= $name.", ";
- }
- $str = preg_replace("/, $/","",$str);
- print_red(sprintf(_("Can't delete printer type, it is still in use by '%s'."),$str));
- }else{
- $this->handle->removePrinterType($_POST['select_type']);
- }
- }
-
- /* Rename selected printer type to given string
- */
- if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename) && $this->acl_is_writeable("type")){
- $this->rename = true;
-
- $smarty->assign("Method","rename");
-
- $tmp = $this->handle->getPrinterTypes();
-
- 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){
- $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));
- return($display);
- }
-
-
- /* ##########################################################################
- * Edit manufacturers
- * Dialog
- */
-
- /* Open dialog which allows to edit the manufacturers
- */
- if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){
- $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
- $this->dialog = true;
- $this->editManufacturer =true;
- }
-
- /* Close manufacturer editing dialog
- */
- if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){
- $this->dialog = false;
- $this->cur_dialog = false;
- $this->editManufacturer=false;
- }
-
-
- /* ##########################################################################
- * Technical responsible person
- * Contact person
- * Dialog
- */
-
- /* Show dialog to select a new contact person
- * Select a contact person
- */
- if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){
- $this->addUser = "contact";
- $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
- }
-
- /* Selecte technical responsible person
- */
- if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){
- $this->addUser ="tech";
- $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
- }
-
- /* Abort user selection
- */
- $smarty->assign("AbortSelectUser","SelectUserCancel");
- if(isset($_POST['SelectUserCancel'])){
- $this->dialog = false;
- $this->addUser ="";
- $this->cur_dialog = false;
- }
-
- /* Technical responsible/contact person selected */
- if(isset($_GET['act'])&&($_GET['act']=="user_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 */
- $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
- $atr = $ldap->fetch();
- $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->handle->addUser($tmp,$id);
- }
-
- /* Re-read users */
- $users = ($this->handle->getUsers());
-
- /* Get user */
- $tmp = array_flip($users);
- $id=$tmp[$id];
-
- /* Use user id, close dialog */
- if($this->addUser == "tech"){
- $this->tech_num = $id;
- }else{
- $this->contact_num = $id;
- }
- $this->cur_dialog = false;
- $this->dialog= false;
- }
-
-
- /* ##########################################################################
- * Handle attachments
- */
-
- /* Attachment pool was closed with use
- */
- if(isset($_POST['UseAttachment']) && $this->acl_is_writeable("Attachments")){
- if(count($this->cur_dialog->check())){
- foreach($this->cur_dialog->check() as $msg){
- print_red($msg);
- }
- }else{
- $this->cur_dialog->save_object();
- $this->usedAttachments = $this->cur_dialog->save();
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
- }
-
- /* Attachment pool was closed with abort
- */
- if(isset($_POST['AbortAttachment'])){
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
-
- /* Open Attachment pool to add/edit Attachments
- */
- if(isset($_POST['AddAttachment']) && $this->acl_is_writeable("Attachments")){
- $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
- $this->dialog = true;
- }
-
- /* Remove Attachment from this tab
- */
- $once = true;
- foreach($_POST as $name => $value){
- if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){
- $once= false;
- $name = preg_replace("/^delAttachment_/","",$name);
- $entry = preg_replace("/_.*$/","",$name);
- if(isset($this->usedAttachments[$entry])){
- unset($this->usedAttachments[$entry]);
- }
- }
- }
- if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && $this->acl_is_writeable("Attachments")){
- if(isset($this->usedAttachments[$_POST['Attachments']])){
- unset($this->usedAttachments[$_POST['Attachments']]);
- }
- }
-
- /* ##########################################################################
- * Printer Cartridge handling
- */
-
- /* Abort cartridge select dialog
- */
- if(isset($_POST['SelectCartridgeCancel'])){
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
-
- /* Get selected cartridges and add them to our list
- */
- if(isset($_POST['SelectCartridgeSave'])){
- $this->cur_dialog->save_object();
- $carts = $this->cur_dialog->save();
- foreach($carts as $cart){
- $cart['status'] = "new";
- $this->usedCartridges[] = $cart;
- }
- $this->cur_dialog = false;
- $this->edit_type = false;
- }
-
- /* Remove cartridge
- */
- if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges'])) && $this->acl_is_writeable("ManageCartridges")){
-
- foreach($_POST['Cartridges'] as $cartID){
-
- if(isset($this->usedCartridges[$cartID])){
- if($this->usedCartridges[$cartID]['status'] == "exists"){
- $this->usedCartridges[$cartID]['status'] = "deleted";
- }else{
- unset($this->usedCartridges[$cartID]);
- }
- }
- }
- }
-
- /* Open Attachment pool to add/edit Attachments
- */
- if(isset($_POST['AddCartridge']) && $this->acl_is_writeable("ManageCartridges")){
- $this->cur_dialog = new glpiPrinterCartridges($this->config,$this->dn,$this->type);
- $this->dialog = true;
- }
-
-
- /* ##########################################################################
- * Draw Dialogs
- */
- /* if( cur_dialog != false || cur_dialog != NULL)
- * There is a dialog which wants to be displayed
- */
- if($this->cur_dialog && is_object($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;
- }
-
-
- /* ##########################################################################
- * Assign listbox / checkbox .... values to smarty
- */
- /* Assign smarty defaults */
- foreach(array("PrinterTypes","PrinterTypeKeys","Manufacturers","TechnicalResponsibles","Attachments","Cartridges") as $attr){
- $smarty->assign($attr,array());
- }
-
- /* Assign some vars to smarty
- */
- foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","flags_serial","flags_par","flags_usb") as $attr){
- $smarty->assign($attr,"");
- }
-
- $smarty->assign("comments", $this->comments);
- $smarty->assign("flags_serial", $this->flags_serial);
- $smarty->assign("flags_par", $this->flags_par);
- $smarty->assign("flags_usb", $this->flags_usb);
-
- /* Assign system types
- */
- $smarty->assign("PrinterTypes", $this->handle->getPrinterTypes());
- $smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes()));
- $smarty->assign("type", $this->type);
-
- /* Append manufacturers
- */
- $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises()));
- $smarty->assign("Manufacturers", $this->handle->getEnterprises());
- $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
-
- /* Assign used Attachments
- */
-
- $divlist = new divSelectBox("glpiAttachmentsList");
- $divlist-> SetHeight(120);
- $atts = $this->getUsedAttachments(true);
- $downlink = "<a href='get_attachment.php?id=%s' target='_blank'>%s</a>";
- $del_link = "<input type='image' src='images/edittrash.png' name='delAttachment_%s'>";
- foreach($atts as $id => $attachment){
- $divlist->AddEntry
- (
- array(
- array("string"=>$attachment['name']),
- array("string"=>$attachment['mime']),
- array("string"=>sprintf($downlink,$id,$attachment['filename'])),
- array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"),
- )
- );
- }
-
- $smarty->assign("AttachmentsDiv" ,$divlist->DrawList());
- $smarty->assign("Attachments", $this->getUsedAttachments());
- $smarty->assign("AttachmentKeys", array_flip($this->getUsedAttachments()));
-
- /* Assign Cartridges
- */
- $smarty->assign("Cartridges", $this->getUsedCartridges());
- $smarty->assign("CartridgeKeys", $this->getUsedCartridges(true));
-
- /* ##########################################################################
- * Assign contact and technical responsible person
- */
- if(isset($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]." "; }
- if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
- $smarty->assign("contact_num", $str);
- }else{
- $smarty->assign("contact_num", _("N/A"));
- }
-
- /* Handle tech person
- Assign name ... to smarty, if set
- */
- if(isset($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]." "; }
- if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
- $smarty->assign("tech_num", $str);
- }else{
- $smarty->assign("tech_num", _("N/A"));
- }
-
- /* If theres a cartridge selected, you can't change the printer type.
- */
- $disp = true;
-
- foreach($this->usedCartridges as $cart){
- if($cart['status'] != "deleted"){
- $disp = false;
- }
- }
- if($disp==false){
- $smarty->assign("typeACL", $this->getacl("type",true));
- }
-
- $display.= $smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE));
- return($display);
- }
-
- function remove_from_parent()
- {
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
- if($this->initially_was_account){
- $this->handle->removePrinterInformations($this->dn);
- new log("remove","printer/".get_class($this),$this->dn);
- }
- }
-
-
- /* Save data to object */
- function save_object()
- {
- if(isset($_POST['glpiPrinterFlagsPosted'])){
- plugin::save_object();
- foreach($this->attributes as $attrs){
- if(isset($_POST[$attrs])){
- $this->$attrs = $_POST[$attrs];
- }
- }
-
- if(isset($_POST['FK_glpi_enterprise']) && $this->acl_is_writeable("FKglpienterprise")){
- $this->FK_glpi_enterprise = $_POST['FK_glpi_enterprise'];
- }
-
- foreach(array("flags_serial","flags_par","flags_usb") as $checkboxes){
- if($this->acl_is_writeable($checkboxes)){
- if(isset($_POST[$checkboxes])){
- $this->$checkboxes = 1;
- }else{
- $this->$checkboxes = 0;
- }
- }
- }
- }
-
- }
-
-
- /* Check supplied data */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- // if($this->TechnicalResponsible == ""){
- // $message[] = _("Please select a technical responsible person for this entry.");
- // }
-
- return ($message);
- }
-
- /* Save to LDAP */
- function save()
- {
- if($this->is_account){
- $attrs = array();
- $this->date_mod = date("Y-m-d H:i:s");
- foreach($this->attributes as $attr){
- $attrs[$attr] = $this->$attr;
- }
- $attrs['name'] = $this->dn;
- unset($attrs['ID']);
- $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
- if($this->initially_was_account&&$this->is_account){
- $this->handle->updatePrinterInformations($attrs,$this->dn);
- new log("modify","printer/".get_class($this),$this->dn);
- }elseif($this->is_account){
- $this->handle->addPrinterInformations($attrs,$this->dn);
- new log("create","printer/".get_class($this),$this->dn);
- }
- $tmp = $this->handle->getPrinterInformations($this->dn);
- $this->handle->addAttachmentsToPrinter($this->usedAttachments,$tmp[0]['ID']);
-
- foreach($this->usedCartridges as $cart){
- if($cart['status'] == "deleted"){
- $this->handle->removeCartridgeFromPrinter($cart['ID']);
- }elseif($cart['status'] == "new"){
- $this->handle->addCartridgeFromPrinter($tmp[0]['ID'],$cart['type_ID']);
- }
- }
- }
- }
-
- /* Return used attachments */
- function getUsedAttachments($divlist = false)
- {
- $atts =$this->handle->getAttachments();
- $ret = array();
- foreach($atts as $entry){
- if(in_array($entry['ID'],$this->usedAttachments)){
- if($divlist){
- $ret[$entry['ID']] = $entry;
- }else{
- $cm ="";
- if(isset($entry['comment'])){
- $cm=" [".$entry['comment']."]";
- }
- if(isset($entry['mime'])){
- $cm.=" -".$entry['mime']."";
- }
-
- $ret[$entry['ID']]= $entry['name'].$cm;
- }
- }
- }
- return($ret);
- }
-
- function getUsedCartridges($flip = false)
- {
- $ret = array();
- foreach($this->usedCartridges as $key => $value){
- if($value['status'] == "deleted") continue;
- if($flip){
- $ret[$key] = $key;
- }else{
- $ret[$key] = $value['name']." [".$value['type_name']."] "._("since")." :".$value['date_use'];
- }
- }
- return($ret);
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Glpi"),
- "plDescription" => _("Printer inventory extension"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 10,
- "plSection" => array("administration"),
- "plCategory" => array("printer"),
-
- "plProvidedAcls"=> array(
- "flags_serial" => _("Supports serial interface"),
- "flags_par" => _("Supports parallel interface"),
- "flags_usb" => _("Supports usb interface"),
- "tech_num" => _("Technical responsible"),
- "comments" => _("Comments"),
- "location" => _("Location"),
- "contact_num" => _("Contact person"),
- "type" => _("Type"),
- "FKglpienterprise" => _("Manufacturer"),
-
- "Attachments" => _("Attachments"),
-
- "ManageCartridges" => _("Cartridge settings"))
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterCartridges.inc
+++ /dev/null
@@ -1,298 +0,0 @@
-<?php
-
-class glpiPrinterCartridges extends plugin
-{
- /* CLI vars */
- var $cli_summary= "Manage server basic objects";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account = TRUE;
- var $attributes = array();
- var $objectclasses = array("whatever");
-
- var $parent = NULL; // Contains parent class, to access glpi db handle
- var $usedCartridges = array(); // IDs of used cartridges for this printer
- var $PrinterType = 0; // Specifies which cartridge types are available
-
- var $cur_dialog = false;
- var $cur_sub_dialog = false;
-
- var $editManufacturer = false;
- var $del = 0;
-
-
- function glpiPrinterCartridges (&$config,$dn,$type)
- {
- plugin::plugin ($config, $dn);
-
- /* Assign some basic settings */
- $this->ui = get_userinfo();
- if(!session::is_set('glpiCartridgeRegex')){
- session::set('glpiCartridgeRegex',"*");
- }
-
- /* Only display cartridges for this type of printer */
- $this->PrinterType = $type;
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
- $display ="";
- $smarty = get_smarty();
- $filter = session::get('glpiCartridgeRegex');
-
- /* Filter settings, remove double* */
- if(isset($_GET['search'])){
- $filter = preg_replace("/\*\**/","*",$_GET['search']."*");
- }elseif(isset($_POST['cartridge_regex'])){
- $filter = preg_replace("/\*\**/","*",$_POST['cartridge_regex']);
- }
- if(empty($filter)) {
- $filter = "*";
- }
- session::set('glpiCartridgeRegex',$filter);
-
- /* Open dialog which allows to edit the manufacturers
- */
- if(isset($_POST['edit_manufacturer_cartridges'])){
- $this->cur_sub_dialog = new glpiManufacturer($this->config,$this->dn);
- $this->dialog = true;
- $this->editManufacturer =true;
- }
-
- /* Close manufacturer editing dialog
- */
- if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){
- $this->dialog = false;
- $this->cur_sub_dialog = false;
- $this->editManufacturer=false;
- }
-
- /* Check poted vars and do the requested job, but only once */
- $only_once = true;
- foreach($_POST as $name => $value){
-
- /* We have to create a new cartridge */
- if(preg_match("/^newcartridge/",$name)&&($only_once)){
- $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType);
- $only_once = false;
- }
- }
-
- /* Edit cartridge */
- if(isset($_GET['act'])&&$_GET['act']=="edit_cartridge"){
- $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id']));
- $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$_GET['id']]);
- }
-
- /* remove cartridge */
- if(isset($_GET['act'])&&$_GET['act']=="del_cartridge"){
- /* remove attach from db */
- $this->del = $_GET['id'];
- $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id']));
- $smarty->assign("warning", sprintf(_("You're about to delete the glpi cartridge type '%s'."), $val[$this->del]['name']));
- return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
- }
-
- if(isset($_POST['delete_cancel'])){
- $this->del = false;
- }
-
- /* Delete this entry */
- if(isset($_POST['delete_glpi_confirm'])&&($this->del)) {
- $tmp = $this->parent->handle->is_cartridgeTypeUsed($this->del);
- if(count($tmp)){
-
- $str = "";
- foreach($tmp as $id => $name){
- $str .= $name.", ";
- }
- $str = preg_replace("/, $/","",$str);
-
- print_red(sprintf(_("You can't delete this cartridge type, it is still in use by this printer(s) '%s'."),$str));
- }else{
- $val = ($this->parent->handle->getCartridgeTypeInformations($this->del));
- $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$this->del]);
- $this->cur_dialog->parent = $this->parent;
- $this->cur_dialog->remove_from_parent();
- $this->cur_dialog= false;
- }
- }
-
- /* Abort edit / add dialog */
- if(isset($_POST['CancelCartridge'])){
- $this->cur_dialog = false;
- }
-
- /* Save changes if check is ok */
- if(isset($_POST['SaveCartridge'])){
- $this->cur_dialog->save_object();
- if(count($this->cur_dialog->check())) {
- foreach($this->cur_dialog->check() as $checks){
- print_red($checks);
- }
- }else{
- $this->cur_dialog->save();
- $this->cur_dialog = false;
- }
- }
-
- /* If we have a dialog open, display it */
- if($this->cur_sub_dialog){
- $this->cur_sub_dialog->parent = $this->parent;
- $this->cur_sub_dialog->save_object();
- return($this->cur_sub_dialog->execute());
- }
- /* If we have a dialog open, display it */
- if($this->cur_dialog){
- $this->cur_dialog->parent = $this->parent;
- $this->cur_dialog->save_object();
- return($this->cur_dialog->execute());
- }
-
- /* Create divlist */
- $divlist = new divlist("glpi devices");
- $divlist->SetPluginMode();
- $divlist->SetEntriesPerPage(0);
- $divlist->SetHeader(array(
- array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
- array("string" => _("Cartridges"), "attach" => "style=''"),
- array("string" => _("Action"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
-
- /* Links for editing,adding.... */
- $edit = "<a href='?plug=".$_GET['plug']."&act=edit_cartridge&id=%s'>%s</a>";
- $editdel = "<a href='?plug=".$_GET['plug']."&act=edit_cartridge&id=%s'><img src='images/edit.png' alt='"._("Edit")."' border=0></a>";
- $editdel.= "<a href='?plug=".$_GET['plug']."&act=del_cartridge&id=%s'><img src='images/edittrash.png' alt='"._("Delete")."' border=0></a>";
-
- /* Checkbox for selection of some cartridges */
- $useCartridge = "<input type='hidden' name='wasOnPage_%s' value='%s'><input type='checkbox' value='%s' name='useCartridge_%s' %CHECKED%>";
-
- /* Add cartridges */
- $cart = $this->getCartridgeTypes();
-
- /* Remove typically error possibilities */
- $f = str_replace("/","\/",$filter);
- $f = str_replace(".","\.",$f);
- $f = str_replace("*",".*",$f);
-
- /* Assign cartridges */
- foreach($cart as $key=>$cartr){
-
- /* Skip if filter doesn't match*/
- if(!preg_match("/^".$f."$/i",$cartr['cartridgeName'])){
- continue;
- }
-
- /* check if this cartridge is selected */
- $chk = "";
- if(isset($this->usedCartridges[$key])){
- $chk = " checked ";
- }
-
- /* Add fields */
- $field1 = array("string" => preg_replace("/%s/",($key),preg_replace("/%CHECKED%/",$chk,$useCartridge)),
- "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($edit,($key),$cartr['cartridgeName']." [".$cartr['cartridgeTypeName']."]"),
- "attach" => "style=''");
- $field3 = array("string" => sprintf($editdel,($key),($key)),
- "attach" => "style='width:60px;border-right:0px;text-align:right;'");
-
- $divlist->AddEntry(array($field1,$field2,$field3));
-
- }
-
- /* Create list header */
- $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
- " <input class='center' type='image' align='middle'
- src='images/zip.png' title='"._("New monitor")."' alt='"._("M")."' name='newcartridge'> ".
- "</div>";
-
- /* Tell smarty some vars */
- $filter = session::get('glpiCartridgeRegex');
- $smarty->assign("devicehead", $listhead);
- $smarty->assign("devices", $divlist->DrawList());
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("infoimage", get_template_path('images/info_small.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("apply", apply_filter());
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("cartridge_regex", $filter);
-
- $display.= $smarty->fetch(get_template_path('glpiPrinterCartridges.tpl', TRUE));
- return($display);
- }
-
- /* Save device to glpi database
- * If this is a new device, create a new entry, else update this entry
- */
- function save()
- {
- $carts = $this->getCartridgeTypes();
- $ret = array();
- foreach($this->usedCartridges as $key){
- $tmp =array();
- $tmp['date_use'] = date("Y-m-d");
- $tmp['ID'] = -1;
- $tmp['type_ID'] = $carts[$key]['cartridgeID'];
- $tmp['name'] = $carts[$key]['cartridgeName'];
- $tmp['FK_glpi_printers']= -1;
- $tmp['type_name'] = $carts[$key]['cartridgeTypeName'];
- $ret[$key] = $tmp;
- }
- return($ret);
- }
-
- /* this only gets all already defined devices */
- function reload()
- {
- $this->devices = $this->parent->handle->getDevices();
- ksort($this->devices);
- }
-
- /* This funtions saves all POST variables.
- The variable must be in the array $this->EditEntry
- */
- function save_object()
- {
- /* Checkbox handling
- * Check which checkbox is selected
- */
- foreach($_POST as $name => $value){
- if(preg_match("/wasOnPage/",$name)){
- $id = preg_replace("/wasOnPage_/","",$name);
- if(isset($_POST['useCartridge_'.$id])){
- $this->usedCartridges[$id]=$id;
- }else{
- unset($this->usedCartridges[$id]);
- }
- }
- }
- }
-
- /* This function cehck all created devices if you wan't to create device specific check
- use >>if($attr['device_type']=="moboard")<< to create a device type depending check
- */
- function check()
- {
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- return($message);
- }
-
- /* Return cartriges for our divlist */
- function getCartridgeTypes()
- {
- $ret = array();
- $ret = $this->parent->handle->getAvailableCartridgeTypes($this->PrinterType);
- return($ret);
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc
+++ /dev/null
@@ -1,337 +0,0 @@
-<?php
-
-class glpiPrinterCartridgesEdit extends plugin
-{
- /* CLI vars */
- var $cli_summary = "Manage server basic objects";
- var $cli_description = "Some longer text\nfor help";
- var $cli_parameters = array("eins" => "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);
- 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);
- }
-
- /* 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 */
- $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
- $atr = $ldap->fetch();
- $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 = "<table summary=''><tr>";
- $types = $this->parent->handle->getPrinterTypes();
-
- /* Specifies number of cols */
- $spalten = 2;
-
- $spalt = $spalten;
- foreach($types as $key => $type){
- $spalt -- ;
-
- /* Create new row, if cols for this row reached $spalten */
- if($spalt < 0) {
- $spalt = $spalten -1;
- $matrix .= "</tr><tr>";
- }
-
- /* Avoid deselecting every checkbox */
- if($key == $this->printer_type){
- $matrix.= "<td><input type='checkbox' name='UsePrinterType_".$key."' disabled checked>".$type."</td>";
- }else{
-
- /* Cehck checkbox */
- $check = "";
- if(isset($this->additional_printer[$key])){
- $check = " checked ";
- }
- $matrix.= "<td><input type='checkbox' name='UsePrinterType_".$key."' ".$check." ><input type='hidden' name='wasOnPage_".$key."' ".$check.">".$type."</td>";
- }
- }
-
- /* Complete table row, to avoid html errors */
- if($spalt >0){
- while($spalt >0){
- $spalt -- ;
- $matrix .="<td> </td>";
- }
- }
-
- $matrix .= "</tr></table>";
-
- /* Append manufacturers
- */
- $smarty->assign("PrinterTypeMatrix", $matrix);
-
- $smarty->assign("ManufacturerKeys", array_flip($this->parent->handle->getEnterprises()));
- $smarty->assign("Manufacturers", $this->parent->handle->getEnterprises());
- $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
-
- $smarty->assign("typeKeys", array_flip($this->parent->handle->getCartridgeTypes()));
- $smarty->assign("types", $this->parent->handle->getCartridgeTypes());
- $smarty->assign("type", $this->type);
-
- /* Handle tech person
- Assign name ... to smarty, if set
- */
- if(isset($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]." "; }
- if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
- $smarty->assign("tech_num", $str);
- }else{
- $smarty->assign("tech_num", _("N/A"));
- }
-
-
- $display.= $smarty->fetch(get_template_path('glpiPrinterCartridgesEdit.tpl', TRUE,dirname(__FILE__)));
- return($display);
- }
-
- /* Check given values */
- function check(){
- /* Call common method to give check the hook */
- $message= plugin::check();
-
- /* Avoid choosing an already used name */
- $types = $this->parent->handle->getCartridgeTypeInformations();
- foreach($types as $type){
- if($type['name'] == $this->name){
- if($type['ID'] != $this->ID){
- $message[]= _("The selected name is already in use.");
- }
- }
- }
- return $message;
- }
-
- /* Save Post data */
- function save_object()
- {
- foreach($this->attributes as $attr){
- if(isset($_POST[$attr])){
- $this->$attr= $_POST[$attr];
- }
- }
-
- /* Get selected checkboxes */
- foreach($_POST as $name => $value){
- if(preg_match("/wasOnPage_/",$name)){
- $id = preg_replace("/wasOnPage_/","",$name);
- if(isset($_POST['UsePrinterType_'.$id])){
- $this->additional_printer[$id]=$id;
- }else{
- if(isset($this->additional_printer[$id])){
- unset($this->additional_printer[$id]);
- }
- }
- }
- }
- }
-
- /* Create / Update database with this new infos */
- function save()
- {
- $tmp = array();
- foreach($this->attributes as $attr){
- $tmp[$attr] = $this-> $attr;
- }
- $types = array();
- $types = $this->additional_printer;
- $types[$this->printer_type]=$this->printer_type;
- $this->parent->handle->Add_UpdateCatrigdeType($tmp,$types);
- }
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_glpiSelectUser.inc b/gosa-core/plugins/admin/systems/services/glpi/class_glpiSelectUser.inc
+++ /dev/null
@@ -1,286 +0,0 @@
-<?php
-
-class glpiSelectUser extends plugin
-{
- /* CLI vars */
- var $cli_summary= "Manage server basic objects";
- var $cli_description= "Some longer text\nfor help";
- var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* attribute list for save action */
- var $ignore_account= TRUE;
- var $attributes= array();
- var $objectclasses= array("whatever");
-
- var $users = array();
- var $departments = array();
-
- var $ui;
-
- var $PostVarName = "";
-
- function glpiSelectUser (&$config, $dn= NULL,$postvar)
- {
- plugin::plugin ($config, $dn);
-
- $this->PostVarName = $postvar;
-
- if(!session::is_set('glpi_user_filter')){
- $tmp['users_regex'] = "*";
- $tmp['base'] = $this->config->current['BASE'];
- session::set('glpi_user_filter',$tmp);
- }
-
- $this->ui = get_userinfo();
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- if(isset($_POST['depselect'])){
- session::set('glpi_user_filter', array('base' => $_POST['depselect']));
- }
-
- $filter = session::get('glpi_user_filter');
-
- /* Filter settings, remove double* */
- if(isset($_GET['search'])){
- $filter['users_regex'] = preg_replace("/\*\**/","*",$_GET['search']."*");
- }elseif(isset($_POST['regex'])){
- $filter['users_regex'] = preg_replace("/\*\**/","*",$_POST['regex']);
- }
- if(empty($filter['users_regex'])) {
- $filter = "*";
- }
-
-
- $s_action="";
- /* Test Posts */
- foreach($_POST as $key => $val){
- // Post for delete
- if(preg_match("/dep_back.*/i",$key)){
- $s_action="back";
- }elseif(preg_match("/user_new.*/",$key)){
- $s_action="new";
- }elseif(preg_match("/dep_home.*/i",$key)){
- $s_action="home";
- }
- }
-
- /* Homebutton is posted */
- if($s_action=="home"){
- $filter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
- $filter['base']=(preg_replace("/^[^,]+,/","",$filter['base']));
- }
-
- if($s_action=="root"){
- $filter['base']=($this->config->current['BASE']);
- }
-
-
- /* If Backbutton is Posted */
- if($s_action=="back"){
- $base_back = preg_replace("/^[^,]+,/","",$filter['base']);
- $base_back = convert_department_dn($base_back);
-
- if(isset($this->config->departments[trim($base_back)])){
- $filter['base']= $this->config->departments[trim($base_back)];
- }else{
- $filter['base']= $this->config->departments["/"];
- }
- }
-
- if((isset($_GET['act']))&&($_GET['act']=="dep_open")){
- $entry = base64_decode($_GET['dep_id']);
- $filter['base']= ($this->config->departments[$entry]);
- }
-
- session::set('glpi_user_filter',$filter);
-
- $this->reload();
-
- /* Fill templating stuff */
- $smarty= get_smarty();
- $display= "";
-
- $divlist = new divlist("glpi users");
- $divlist->SetPluginMode();
- $divlist->SetEntriesPerPage(0);
- $divlist->SetHeader(array(
- array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
- array("string" => _("Users")." / "._("Departments"), "attach" => "style=''"),
- array("string" => _("Use"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
- $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
- foreach($this->departments as $key=> $val){
-
- if(!isset($this->config->departments[trim($key)])){
- $this->config->departments[trim($key)]="";
- }
-
- $non_empty="";
- $keys= str_replace("/","\/",$key);
- foreach($this->config->departments as $keyd=>$vald ){
- if(preg_match("/".$keys."\/.*/",$keyd)){
- $non_empty="full";
- }
- }
-
- $field1 = array("string" => "<img src='images/".$non_empty."folder.png' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
- $field3 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
- $divlist->AddEntry(array($field1,$field2,$field3));
- }
-
- $useruse = "<a href='?plug=".$_GET['plug']."&act=".$this->PostVarName."&id=%s'>%s</a>";
-
- foreach($this->users as $key=>$user){
- $field1 = array("string" => "<img src='images/select_user.png' alt='user' >", "attach" => "style='text-align:center;width:20px;'");
- $field2 = array("string" => sprintf($useruse,base64_encode($key),$user), "attach" => "style=''");
- $field3 = array("string" => sprintf($useruse,base64_encode($key),"<img title='"._("Use")."' border=0 src='images/crossref.png' alt='"._("use")."'>"),
- "attach" => "style='width:60px;border-right:0px;text-align:right;'");
- $divlist->AddEntry(array($field1,$field2,$field3));
-
- }
-
- /* Prepare departments,
- which are shown in the listbox on top of the listbox
- */
-
-
- /* Get all departments within this subtree */
- $glpi_user_filter = session::get('glpi_user_filter');
- $this->base = $glpi_user_filter['base'];
- $options ="";
- $base = $this->config->current['BASE'];
- $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", "users", $base,
- array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
-
- /* Load possible departments */
- $ui= get_userinfo();
- $tdeps= $ui->get_module_departments("users");
- $ids = $this->config->idepartments;
- foreach($deps as $dep){
- if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
- $value = $ids[$dep['dn']];
- if ($this->base == $dep['dn']){
- $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
- } else {
- $options.= "<option value='".$dep['dn']."'>$value</option>";
- }
- }
- }
-
- $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
- " <input class='center' type='image' src='images/list_root.png'
- align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
- " <input class='center' type='image' align='middle'
- src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
- " <input class='center' type='image' align='middle'
- src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
- " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'> ".
-" <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> "._("Base")." ".
- " <select name='depselect' onChange='mainform.submit()' class='center'>$options</select>".
- " <input class='center' type='image' src='images/list_submit.png' align='middle'
- title='"._("Submit department")."' name='submit_department' alt='". _("Submit")."'> ".
- "</div>";
-
-
- $filter = session::get('glpi_user_filter');
- $smarty->assign("usershead", $listhead);
- $smarty->assign("users", $divlist->DrawList());
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
- $smarty->assign("tree_image", get_template_path('images/tree.png'));
- $smarty->assign("infoimage", get_template_path('images/info_small.png'));
- $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
- $smarty->assign("apply", apply_filter());
- $smarty->assign("alphabet", generate_alphabet());
- $smarty->assign("users_regex", $filter['users_regex']);
-
-
- $display.= $smarty->fetch(get_template_path('glpiSelectUser.tpl', TRUE));
- return($display);
- }
-
- /* Save to LDAP */
- function save()
- {
- plugin::save();
-
- /* Optionally execute a command after we're done */
-#$this->handle_post_events($mode);
- }
-
- function reload()
- {
-
- $filter = session::get('glpi_user_filter');
-
- $base = $filter['base'];
- $regex= $filter['users_regex'];
- /* NEW LIST MANAGMENT
- * We also need to search for the departments
- * So we are able to navigate like in konquerer
- */
-
- $res3= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))","users",
- $base, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT);
-
- $this->departments= array();
- $tmp = array();
- foreach ($res3 as $value){
- $tmp[strtolower($value['dn']).$value['dn']]=$value;
- }
- ksort($tmp);
- foreach($tmp as $value){
- if(isset($value["description"][0])){
- $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]";
- }else{
- $this->departments[$value['dn']]= get_sub_department($value['dn']);//$value["description"][0];
- }
- }
-
- /* END NEW LIST MANAGMENT
- */
- $ou = get_people_ou();
-
- $res2= get_list("(&(|(cn=$regex)(sn=$regex))(objectClass=person))", "users",
- $ou.$base, array("cn", "sn", "uid", "givenName", "description"),
- GL_SUBSEARCH | GL_SIZELIMIT);
-
- $tmp = array();
-
- foreach($res2 as $val){
- $str = "";
- if(isset($val['givenName'][0])){
- $str .= $val['givenName'][0];
- }
- if(isset($val['sn'][0])){
- $str .= $val['sn'][0];
- }
- if(isset($val['uid'][0])){
- $str .= $val['uid'][0];
- }
-
- $tmp[$str] = $val;
- }
-
- ksort($tmp);
- $this->users = array();
- foreach($tmp as $value){
- if (isset($value["givenName"][0]) && isset($value["sn"][0])){
- $this->users[$value['dn']]= $value["sn"][0].", ".
- $value["givenName"][0].
- " [".$value["uid"][0]."]";
- } else {
- $this->users[$value["dn"]]= "[".$value["uid"][0]."]";
- }
- }
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/class_goGlpiServer.inc b/gosa-core/plugins/admin/systems/services/glpi/class_goGlpiServer.inc
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php
-
-class goGlpiServer extends goService {
-
- var $cli_summary = "This pluign is used within the ServerService Pluign \nand indicates that this server supports asterisk management.";
- var $cli_description = "Some longer text\nfor help";
- var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
- /* This plugin only writes its objectClass */
- var $objectclasses = array("goGlpiServer");
- var $attributes = array("goGlpiAdmin","goGlpiDatabase","goGlpiPassword");
- var $StatusFlag = "goGlpiServerStatus";
-
- /* This class can't be assigned twice so it conflicts with itsself */
- var $conflicts = array("goGlpiServer");
-
- var $DisplayName = "";
- var $dn = NULL;
- var $cn = "";
- var $acl;
-
- var $goGlpiServerStatus ="";
- var $goGlpiAdmin ="";
- var $goGlpiDatabase ="";
- var $goGlpiPassword ="";
- var $view_logged =FALSE;
-
-
- function goGlpiServer(&$config,$dn)
- {
- goService::goService($config,$dn);
- $this->DisplayName = _("Inventory database");
- }
-
-
- function execute()
- {
- if($this->is_account && !$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","server/".get_class($this),$this->dn);
- }
-
- $smarty = get_smarty();
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- $tmp = $this->plInfo();
- foreach($tmp['plProvidedAcls'] as $name => $translation ){
- $smarty->assign($name."ACL",$this->getacl($name));
- }
- return($smarty->fetch(get_template_path("goGlpiServer.tpl",TRUE,dirname(__FILE__))));
- }
-
-
- function getListEntry()
- {
- $fields = goService::getListEntry();
- $fields['Message'] = _("Inventory database service");
- $fields['AllowEdit'] = true;
- return($fields);
- }
-
- function check()
- {
- $message = plugin::check();
- if(empty($this->goGlpiAdmin)){
- $message[]= _("The attribute user is empty or contains invalid characters.");
- }
- if(empty($this->goGlpiDatabase)){
- $message[]= _("The attribute database is empty or contains invalid characters.");
- }
- return($message);
- }
-
-
- function save_object()
- {
- if(isset($_POST['goGlpiServer_posted'])){
- plugin::save_object();
- }
- }
-
- /* Return plugin informations for acl handling */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Inventory database"),
- "plDescription" => _("Inventory database")." ("._("Services").")" ,
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 93,
- "plSection" => array("administration"),
- "plCategory" => array("server"),
-
- "plProvidedAcls"=> array(
- "start" => _("Start"),
- "stop" => _("Stop"),
- "restart" => _("Restart"),
-
- "goGlpiAdmin" => _("Admin"),
- "goGlpiDatabase" => _("Database"),
- "goGlpiPassword" => _("Password"))
- ));
- }
-
-
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi.tpl
+++ /dev/null
@@ -1,138 +0,0 @@
-<table summary="" style="width:100%;">
- <tr>
- <td style="width:50%;vertical-align:top;" >
- <!--Upper left-->
-
- <h2>{t}Generic{/t}</h2>
- <table summary="" cellpadding=5>
- <tr>
- <td >{t}System type{/t}
- </td>
- <td>
-{render acl=$typeACL}
- <select name="type">
- {html_options values=$SystemTypeKeys output=$SystemTypes selected=$type}
- </select>
-{/render}
-{render acl=$typeACL}
- <input type="submit" value="{t}edit{/t}" name="edit_type">
-{/render}
- </td>
- </tr>
- <tr>
- <td>{t}Operating system{/t}
- </td>
- <td>
-{render acl=$osACL}
- <select name="os">
- {html_options values=$OSKeys output=$OSs selected=$os}
- </select>
-{/render}
-{render acl=$osACL}
- <input type="submit" value="{t}edit{/t}" name="edit_os">
-{/render}
- </td>
- </tr>
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
-{render acl=$FK_glpi_enterpriseACL}
- <select name="FK_glpi_enterprise">
- {html_options values=$ManufacturerKeys output=$Manufacturers selected=$FK_glpi_enterprise}
- </select>
-{/render}
-{render acl=$FK_glpi_enterpriseACL}
- <input type="submit" value="{t}edit{/t}" name="edit_manufacturer">
-{/render}
- </td>
- </tr>
- <!--</table>
- <p class="seperator"> </p>
- <h2>{t}Contacts{/t}</h2>
- <table summary="" width="100%">-->
- <tr>
- <td>
- {t}Contact person{/t}
- </td>
- <td>
- <i>{$contact_num} </i>
-{render acl=$contact_numACL}
- <input type="submit" name="SelectContactPerson" value="{t}Edit{/t}">
-{/render}
- </td>
- </tr>
- <tr>
- <td>{t}Technical responsible{/t}
- </td>
- <td>
- <i>{$tech_num} </i>
-{render acl=$tech_numACL}
- <input type="submit" value="{t}Edit{/t}" name="SelectTechPerson">
-{/render}
- </td>
- </tr>
- </table>
- </td>
- <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
- <!--Upper right-->
- <h2>{t}Comment{/t}</h2>
- <table summary="" width="100%">
- <tr>
- <td valign="top" colspan="2">
-{render acl=$commentsACL}
- <textarea name="comments" style="width:100%;height:180px;">{$comments}</textarea>
-{/render}
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-<p class="seperator" > </p>
-<table summary="" style="width:100%;">
- <tr>
- <td style="width:50%;">
- <h2>{t}Installed devices{/t}</h2>
- <table summary="" width="100%">
- <tr>
- <td>
-{render acl=$DevicesACL}
- <select name="InstalledDevices" style="height:130px;width:100%;" multiple>
- {html_options values=$InstalledDeviceKeys output=$InstalledDevices}
- </select>
-{/render}
-{render acl=$DevicesACL}
- <input name="AddDevice" value="{t}Edit{/t}" type="submit">
-{/render}
- </td>
- </tr>
- </table>
-<!-- <p class="seperator" > </p>
- <input type="submit" value="{t}Trading{/t}" name="Trading">
- <input type="submit" value="{t}Software{/t}" name="Software">
- <input type="submit" value="{t}Contracts{/t}" name="Contracts"> -->
- </td>
- <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
- <h2>{t}Attachments{/t}</h2>
- <table summary="" width="100%">
- <tr>
- <td>
-{render acl=$AttachmentsACL}
- {$AttachmentsDiv}
-{/render}
-{render acl=$AttachmentsACL}
- <input name="AddAttachment" value="{t}Add{/t}" type="submit">
-{/render}
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-<input type="hidden" name="glpi_tpl_posted" value="1">
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('type');
- -->
-</script><p style="text-align:right">
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiAttachmentEdit.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiAttachmentEdit.tpl
+++ /dev/null
@@ -1,78 +0,0 @@
-<br>
-<h2>{t}Attachment{/t}</h2>
-
-<table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top;">
- <table summary="" width="100%">
- <tr>
- <td style="vertical-align:top;">
- {t}Name{/t}
- </td>
- <td>
- <input type="text" value="{$name}" name="name">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">
- {t}Comment{/t}
- </td>
- <td style="vertical-align:top;">
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td style="vertical-align:top;">
- <table summary="" width="100%">
- <tr>
- <td style="vertical-align:top;">
- {t}File{/t}
- </td>
- <td style="vertical-align:top;">
- <input type="file" value="" name="filename"><input type="submit" name="upload" value="{t}Upload{/t}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">
- {t}Status{/t}
- </td>
- <td style="vertical-align:top;">
- {$status}
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">
- {t}Filename{/t}
- </td>
- <td style="vertical-align:top;">
- {$filename}
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">
- {t}Mime-type{/t}
- </td>
- <td style="vertical-align:top;">
- {$mime}
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-
-
-<p class="seperator"> </p>
-<div align="right">
- <p>
- <input type="submit" name="SaveAttachment" value="{t}Save{/t}">
- <input type="submit" name="CancelAttachment" value="{t}Cancel{/t}">
- </p>
-</div>
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('name');
- -->
-</script>
-
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiAttachmentPool.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiAttachmentPool.tpl
+++ /dev/null
@@ -1,54 +0,0 @@
-<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
-<tr>
- <td style="vertical-align:top;width:50%;" >
- <div class="contentboxh" style="height:20px;">
- <p class="contentboxh" style="font-size:12px;">
- {t}List of attachments{/t}
- </p>
- </div>
- <div class="contentboxb">
- {$attachmenthead}
- </div>
- <div style='height:4px;'></div>
- <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
- {$attachments}
- <input type=hidden name="edit_helper">
- </div>
- </td>
- <td style="vertical-align:top;">
- <div class="contentboxh" style="border-bottom:1px solid #B0B0B0;height:20px;">
- <p class="contentboxh" style="font-size:12px;"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
- </div>
- <div class="contentboxb" style="padding:5px;">
- {t}This dialog allow you to attach additional objects (like manuals, guides, etc.) to your currently edited computer.{/t}
- </div>
- <br>
- <div class="contentboxh" style="height:20px;">
- <p class="contentboxh" style="font-size:12px;"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
- </div>
- <div class="contentboxb">
- <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
- {$alphabet}
- </table>
-<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
-<tr>
-<td><LABEL for="regex"><img alt="{t}Display attachments matching{/t}" src="{$search_image}" align=middle></label></td>
-<td width="99%">
-<input type='text' style='width:99%' name='attachment_regex' maxlength='20' value='{$attachment_regex}' title='{t}Regular expression for matching attachment names{/t}' onChange="mainform.submit()">
-</td>
-</tr>
-</table>
- {$apply}
- </div>
- </td>
-</tr>
-</table>
-
-<input type="hidden" name="ignore">
-<p class="seperator"> </p>
-<div align="right">
- <p>
- <input type="submit" name="UseAttachment" value="{t}Use{/t}">
- <input type="submit" name="AbortAttachment" value="{t}Cancel{/t}">
- </p>
-</div>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiDeviceManagement.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiDeviceManagement.tpl
+++ /dev/null
@@ -1,54 +0,0 @@
-<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
-<tr>
- <td style="vertical-align:top;width:50%;" >
- <div class="contentboxh" style="height:20px;">
- <p class="contentboxh" style="font-size:12px;">
- {t}List of devices{/t}
- </p>
- </div>
- <div class="contentboxb">
- {$devicehead}
- </div>
- <div style='height:4px;'></div>
- <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
- {$devices}
- <input type=hidden name="edit_helper">
- </div>
- </td>
- <td style="vertical-align:top;">
- <div class="contentboxh" style="border-bottom:1px solid #B0B0B0;height:20px;padding:0px;">
- <p class="contentboxh" style="font-size:12px;padding:0px;"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
- </div>
- <div class="contentboxb" style="padding:5px;">
- {t}This dialog allows you to attach a device to your currently edited computer.{/t}
- </div>
- <br>
- <div class="contentboxh" style="height:20px;">
- <p class="contentboxh" style="font-size:12px;"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
- </div>
- <div class="contentboxb">
- <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
- {$alphabet}
- </table>
-<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
-<tr>
-<td><LABEL for="regex"><img alt="{t}Display devices matching{/t}" src="{$search_image}" align=middle></label></td>
-<td width="99%">
-<input type='text' style='width:99%' name='device_regex' maxlength='20' value='{$device_regex}' title='{t}Regular expression for matching device names{/t}' onChange="mainform.submit()">
-</td>
-</tr>
-</table>
- {$apply}
- </div>
- </td>
-</tr>
-</table>
-
-<input type="hidden" name="ignore">
-<p class="seperator"> </p>
-<div align="right">
- <p>
- <input type="submit" name="SelectDeviceSave" value="{t}Use{/t}">
- <input type="submit" name="SelectDeviceCancel" value="{t}Cancel{/t}">
- </p>
-</div>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiManufacturer.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiManufacturer.tpl
+++ /dev/null
@@ -1,15 +0,0 @@
-<h2>{t}Manage manufacturers{/t}</h2>
-<select name="manufacturer" style="width:100%;" size="12">
- {html_options values=$ManuKeys output=$Manus}
-</select>
-<br>
-<input name="add_manu" value="{t}Add{/t}" type="submit">
-<input name="edit_manu" value="{t}Edit{/t}" type="submit">
-<input name="remove_manu" value="{t}Remove{/t}" type="submit">
-
-<p class="seperator"> </p>
-<div align="right">
-<p>
- <input name="close_edit_manufacturer" value="{t}Close{/t}" type="submit">
-</p>
-</div>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiManufacturerAdd.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiManufacturerAdd.tpl
+++ /dev/null
@@ -1,89 +0,0 @@
-<h2>{t}Add/Edit manufacturer{/t}</h2>
-<table summary="" width="100%">
- <tr>
- <td width="50%">
- <table summary="">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input type="text" name="name" value="{$name}">
- </td>
- </tr>
- <tr>
- <td>{t}Website{/t}
- </td>
- <td>
- <input type="text" name="website" value="{$website}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Address{/t}
- </td>
- <td>
- <textarea name="address">{$address}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" >
- <tr>
- <td>{t}Phone number{/t}
- </td>
- <td>
- <input type="text" name="phonenumber" value="{$phonenumber}">
- </td>
- </tr>
- <tr>
- <td>{t}Fax{/t}
- </td>
- <td>
- <input type="text" name="fax" value="{$fax}">
- </td>
- </tr>
- <tr>
- <td>{t}Email{/t}
- </td>
- <td>
- <input type="text" name="email" value="{$email}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comments{/t}
- </td>
- <td>
- <textarea name="comments">{$comments}</textarea>
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-
-
-
-
-
-
-
-
-
-
-
-
-
-<br>
-<p class="seperator"> </p>
-<div align="right">
-<p>
- <input name="save_manufacturer" value="{t}Save{/t}" type="submit">
- <input name="close_manufacturer" value="{t}Close{/t}" type="submit">
-</p>
-</div>
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('name');
- -->
-</script>
-
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiPrinter.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiPrinter.tpl
+++ /dev/null
@@ -1,159 +0,0 @@
-<table summary="" style="width:100%;">
- <tr>
- <td style="width:50%;vertical-align: top;">
- <!--Upper left-->
-
- <h2>{t}Generic{/t}</h2>
- <table summary="" cellpadding=5>
- <tr>
- <td width="150">{t}Printer type{/t}
- </td>
- <td>
-{render acl=$typeACL}
- <select name="type" >
- {html_options values=$PrinterTypeKeys output=$PrinterTypes selected=$type}
- </select>
-{/render}
-{render acl=$typeACL}
- <input type="submit" value="{t}edit{/t}" name="edit_type" >
-{/render}
- </td>
- </tr>
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
-{render acl=$FKglpienterpriseACL}
- <select name="FK_glpi_enterprise" >
- {html_options values=$ManufacturerKeys output=$Manufacturers selected=$FK_glpi_enterprise}
- </select>
-{/render}
-{render acl=$FKglpienterpriseACL}
- <input type="submit" value="{t}edit{/t}" name="edit_manufacturer" >
-{/render}
- </td>
- </tr>
- </table>
- </td>
- <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
- <h2>{t}Supported interfaces{/t}</h2>
- <table summary="" width="100%">
- <tr>
- <td width="20">
-{render acl=$flags_serialACL}
- <input type="checkbox" name="flags_serial" {if $flags_serial=="1"} checked {/if} value="1" >
-{/render}
- </td>
- <td>
- {t}Serial{/t}
- </td>
- </tr>
- <tr>
- <td width="20">
-{render acl=$flags_parACL}
- <input type="checkbox" name="flags_par" {if $flags_par=="1"} checked {/if} value="1" >
-{/render}
- </td>
- <td>
- {t}Parallel{/t}
- </td>
- </tr>
- <tr>
- <td width="20">
-{render acl=$flags_usbACL}
- <input type="checkbox" name="flags_usb" {if $flags_usb=="1"} checked {/if} value="1" >
-{/render}
- </td>
- <td>
- {t}USB{/t}
- </td>
- </tr>
- </table>
- <input name="glpiPrinterFlagsPosted" value="1" type="hidden">
- </td>
- </tr>
-</table>
-<p class="seperator" > </p>
-<table summary="" style="width:100%;">
- <tr>
- <td style="width:50%;vertical-align: top;">
- <h2>{t}Contacts{/t}</h2>
- <table summary="" cellpadding=5>
- <tr>
- <td>{t}Technical responsible{/t}
- </td>
- <td>
- <i>{$tech_num} </i>
-{render acl=$tech_numACL}
- <input type="submit" value="{t}Edit{/t}" name="SelectTechPerson" >
-{/render}
- </td>
- </tr>
- <tr>
- <td>
- {t}Contact person{/t}
- </td>
- <td>
- <i>{$contact_num} </i>
-{render acl=$contact_numACL}
- <input type="submit" name="SelectContactPerson" value="{t}Edit{/t}">
-{/render}
-
- </td>
- </tr>
- </table>
- </td>
- <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
- <h2>{t}Attachments{/t}</h2>
- <table summary="" width="100%">
- <tr>
- <td>
-{render acl=$AttachmentsACL}
- {$AttachmentsDiv}
-{/render}
-{render acl=$AttachmentsACL}
- <input name="AddAttachment" value="{t}Add{/t}" type="submit" >
-{/render}
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-<p class="seperator" > </p>
-<table summary="" style="width:100%;">
- <tr>
- <td style="width:50%;vertical-align: top;">
- <h2>{t}Information{/t}</h2>
- <table summary="" width="100%">
- <tr>
- <td width="100%">
-{render acl=$commentsACL}
- <textarea name="comments" style="width:100%;height:100px;" >{$comments}</textarea>
-{/render}
- </td>
- </tr>
- </table>
- </td>
- <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
- <h2>{t}Installed cartridges{/t}</h2>
- <table summary="" width="100%">
- <tr>
- <td>
-{render acl=$CartridgesACL}
- <select name="Cartridges[]" style="height:100px;width:100%;" multiple>
- {html_options values=$CartridgeKeys output=$Cartridges}
- </select>
-{/render}
-{render acl=$CartridgesACL}
- <input name="AddCartridge" value="{t}Add{/t}" type="submit" >
-{/render}
-{render acl=$CartridgesACL}
- <input name="RemoveCartridge" value="{t}Remove{/t}" type="submit" >
-{/render}
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiPrinterCartridges.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiPrinterCartridges.tpl
+++ /dev/null
@@ -1,54 +0,0 @@
-<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
-<tr>
- <td style="vertical-align:top;width:50%;" >
- <div class="contentboxh" style="height:20px;">
- <p class="contentboxh" style="font-size:12px;">
- {t}List of available cartridge type for this type of printer{/t}
- </p>
- </div>
- <div class="contentboxb">
- {$devicehead}
- </div>
- <div style='height:4px;'></div>
- <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
- {$devices}
- <input type=hidden name="edit_helper">
- </div>
- </td>
- <td style="vertical-align:top;">
- <div class="contentboxh" style="border-bottom:1px solid #B0B0B0;height:20px;" >
- <p class="contentboxh" style="font-size:12px;"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
- </div>
- <div class="contentboxb" style="padding:5px;">
- {t}This dialog allows you to create new types of cartridges, and select one or more types for your printer. Cartridge types depends on the printer type you have selected. For each selected cartridge type there will be a new cartridge created, this allows you to select the same cartridge type for more then one printer.{/t}
- </div>
- <br>
- <div class="contentboxh" style="height:20px;">
- <p class="contentboxh" style="font-size:12px;"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
- </div>
- <div class="contentboxb">
- <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
- {$alphabet}
- </table>
-<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
-<tr>
-<td><LABEL for="regex"><img alt="{t}Display cartridge types matching{/t}" src="{$search_image}" align=middle></label></td>
-<td width="99%">
-<input type='text' style='width:99%' name='cartridge_regex' maxlength='20' value='{$cartridge_regex}' title='{t}Regular expression for matching cartridge types{/t}' onChange="mainform.submit()">
-</td>
-</tr>
-</table>
- {$apply}
- </div>
- </td>
-</tr>
-</table>
-
-<input type="hidden" name="ignore">
-<p class="seperator"> </p>
-<div align="right">
- <p>
- <input type="submit" name="SelectCartridgeSave" value="{t}Use{/t}">
- <input type="submit" name="SelectCartridgeCancel" value="{t}Cancel{/t}">
- </p>
-</div>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl
+++ /dev/null
@@ -1,83 +0,0 @@
-<table summary="" title="" style="width: 100%;">
- <tr>
- <td>
- <h2>{t}Generic{/t}</h2>
- <table summary="" title="" width="100%" style="vertical-align:top;">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input type="text" name="name" value="{$name}">
- </td>
- </tr>
- <tr>
- <td>{t}Reference{/t}
- </td>
- <td>
- <input type="text" name="ref" value="{$ref}">
- </td>
- </tr>
- </table>
- <p class="seperator"> </p>
- <h2>{t}Comments{/t}</h2>
- <table summary="" title="" width="100%" style="vertical-align:top;">
- <tr>
- <td>{t}Comment{/t}
- </td>
- <td>
- <textarea name="comments" style="width:100%;">{$comments}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td style="vertical-align:top;border-left: 1px solid rgb(160, 160, 160);padding-right: 5px;">
- <h2>{t}Generic{/t}</h2>
- <table summary="" title="" width="100%" style="vertical-align:top;">
- <tr>
- <td>{t}Type{/t}
- </td>
- <td>
- <select name="type" >
- {html_options values=$typeKeys output=$types selected=$type}
- </select>
- <input type="submit" value="{t}edit{/t}" name="edit_type_cartridge">
- </td>
- </tr>
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$ManufacturerKeys output=$Manufacturers selected=$FK_glpi_enterprise}
- </select>
- <input type="submit" value="{t}edit{/t}" name="edit_manufacturer_cartridges">
- </td>
- </tr>
- <tr>
- <td>{t}Technical responsible{/t}
- </td>
- <td>
- <i>{$tech_num} </i>
- <input type="submit" value="{t}Choose{/t}" name="SelectCartridgeTechPerson">
- </td>
- </tr>
- </table>
- <p class="seperator"> </p>
- {$PrinterTypeMatrix}
- </td>
- </tr>
-</table>
-
-<p class="seperator"> </p>
-<div style="text-align:right;">
- <p>
- <input type="submit" name="SaveCartridge" value="{t}Save{/t}">
- <input type="submit" name="CancelCartridge" value="{t}Cancel{/t}"><br>
- </p>
-</div>
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('name');
- -->
-</script>
-
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpiSelectUser.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpiSelectUser.tpl
+++ /dev/null
@@ -1,53 +0,0 @@
-<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
-<tr>
- <td style="vertical-align:top;width:50%;" >
- <div class="contentboxh" style="height:20px;">
- <p class="contentboxh" style="font-size:12px;">
- {t}List of users{/t}
- </p>
- </div>
- <div class="contentboxb">
- {$usershead}
- </div>
- <div style='height:4px;'></div>
- <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
- {$users}
- <input type=hidden name="edit_helper">
- </div>
- </td>
- <td style="vertical-align:top;">
- <div class="contentboxh" style="border-bottom:1px solid #B0B0B0;height:20px;">
- <p class="contentboxh" style="font-size:12px;"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
- </div>
- <div class="contentboxb" style="padding:5px;">
- {t}This dialog allows you to select a user as technical responsible person.{/t}
- </div>
- <br>
- <div class="contentboxh" style="height:20px;">
- <p class="contentboxh" style="font-size:12px"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
- </div>
- <div class="contentboxb">
- <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
- {$alphabet}
- </table>
-<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
-<tr>
-<td><LABEL for="regex"><img alt="{t}Display users matching{/t}" src="{$search_image}" align=middle></label></td>
-<td width="99%">
-<input type='text' style='width:99%' name='regex' maxlength='20' value='{$users_regex}' title='{t}Regular expression for matching user names{/t}' onChange="mainform.submit()">
-</td>
-</tr>
-</table>
- {$apply}
- </div>
- </td>
-</tr>
-</table>
-
-<input type="hidden" name="ignore">
-<p class="seperator"> </p>
-<div align="right">
- <p>
- <input type="submit" name="{$AbortSelectUser}" value="{t}Cancel{/t}">
-</p>
-</div>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi_devices.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi_devices.tpl
+++ /dev/null
@@ -1,763 +0,0 @@
-{if $device_type=="monitor"}
- <h2><img alt="" align="middle" src="images/monitor.png" class="center"> {t}Add/Edit monitor{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="name" value="{$name}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comments{/t}
- </td>
- <td>
- <textarea name="comments">{$comments}</textarea>
- </td>
- </tr>
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Monitor size{/t}
- </td>
- <td>
- <input name="size" value="{$size}"> {t}Inch{/t}
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Integrated microphone{/t}
- </td>
- <td>
- <input type="radio" name="flags_micro" value="1" {if $flags_micro == "1"}checked {/if}>{t}Yes{/t}
- <input type="radio" name="flags_micro" value="0" {if ($flags_micro == "0")||($flags_micro=="")}checked {/if}>{t}No{/t}
- </td>
- </tr>
- <tr>
- <td>{t}Integrated speakers{/t}
- </td>
- <td>
- <input type="radio" name="flags_speaker" value="1" {if $flags_speaker == "1"}checked {/if}>{t}Yes{/t}
- <input type="radio" name="flags_speaker" value="0" {if ($flags_speaker == "0")||($flags_speaker=="")}checked {/if}>{t}No{/t}
- </td>
- </tr>
- <tr>
- <td>{t}Sub-D{/t}
- </td>
- <td>
- <input type="radio" name="flags_subd" value="1" {if $flags_subd == "1"}checked {/if}>{t}Yes{/t}
- <input type="radio" name="flags_subd" value="0" {if ($flags_subd == "0")||($flags_subd=="")}checked {/if}>{t}No{/t}
- </td>
- </tr>
- <tr>
- <td>{t}BNC{/t}
- </td>
- <td>
- <input type="radio" name="flags_bnc" value="1" {if $flags_bnc == "1"}checked {/if}>{t}Yes{/t}
- <input type="radio" name="flags_bnc" value="0" {if ($flags_bnc == "0")||($flags_bnc=="")}checked {/if}>{t}No{/t}
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Serial number{/t}
- </td>
- <td>
- <input name="serial" value="{$serial}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Additional serial number{/t}
- </td>
- <td>
- <input name="otherserial" value="{$otherserial}">
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-
-
-{elseif $device_type=="pci"}
-
- <h2><img alt="" align="middle" src="images/fai_template.png" class="center"> {t}Add/Edit other device{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-
-{elseif $device_type=="power"}
-
- <h2><img alt="" align="middle" src="images/power.png" class="center"> {t}Add/Edit power supply{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Atx{/t}
- </td>
- <td>
- <input type="radio" name="atx" value="Y" {if ($atx == "Y")||($atx=="")}checked {/if}>{t}Yes{/t}
- <input type="radio" name="atx" value="N" {if $atx == "N"}checked {/if}>{t}No{/t}
- </td>
- </tr>
- <tr>
- <td>{t}Power{/t}
- </td>
- <td>
- <input name="power" value="{$power}">
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-{elseif $device_type=="gfxcard"}
-
- <h2><img alt="" align="middle" src="images/gfx_hardware.png" class="center"> {t}Add/Edit graphic card{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Interface{/t}
- </td>
- <td>
- <select name="interface">
- {html_options values=$GFXInterfaceKeys output=$GFXInterfaces selected=$interface}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Ram{/t}
- </td>
- <td>
- <input name="ram" value="{$ram}">
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-{elseif $device_type=="control"}
-
- <h2><img alt="" align="middle" src="images/hardware.png" class="center"> {t}Add/Edit controller{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Interface{/t}
- </td>
- <td>
- <select name="interface">
- {html_options values=$HDDInterfaceKeys output=$HDDInterfaces selected=$interface}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Size{/t}
- </td>
- <td>
- <input type="radio" name="raid" value="Y" {if ($raid == "Y")||($raid=="")}checked {/if}>{t}Yes{/t}
- <input type="radio" name="raid" value="N" {if $raid == "N"}checked {/if}>{t}No{/t}
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-
-{elseif $device_type=="drive"}
-
- <h2><img alt="" align="middle" src="images/drives.png" class="center"> {t}Add/Edit drive{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Speed{/t}
- </td>
- <td>
- <input type="text" name="speed" value="{$speed}">
- </td>
- </tr>
- <tr>
- <td>{t}Interface{/t}
- </td>
- <td>
- <select name="interface">
- {html_options values=$HDDInterfaceKeys output=$HDDInterfaces selected=$interface}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Writeable{/t}
- </td>
- <td>
- <input type="radio" name="is_writer" value="Y" {if ($is_writer == "Y")||($is_writer=="")}checked {/if}>{t}Yes{/t}
- <input type="radio" name="is_writer" value="N" {if $is_writer == "N"}checked {/if}>{t}No{/t}
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-
-{elseif $device_type=="hdd"}
- <h2><img alt="" align="middle" src="images/fai_partitionTable.png" class="center"> {t}Add/Edit harddisk{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Rpm{/t}
- </td>
- <td>
- <input type="text" name="rpm" value="{$rpm}">
- </td>
- </tr>
- <tr>
- <td>{t}Cache{/t}
- </td>
- <td>
- <input type="text" name="cache" value="{$cache}">
- </td>
- </tr>
- <tr>
- <td>{t}Size{/t}
- </td>
- <td>
- <input type="text" name="specif_default" value="{$specif_default}">
- </td>
- </tr>
- <tr>
- <td>{t}Type{/t}
- </td>
- <td>
- <select name="interface">
- {html_options values=$HDDInterfaceKeys output=$HDDInterfaces selected=$interface}
- </select>
- </td>
- </tr>
-
- </table>
- </td>
- </tr>
- </table>
-
-{elseif $device_type=="ram"}
-
- <h2><img alt="" align="middle" src="images/memory.png" class="center"> {t}Add/Edit memory{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Frequenz{/t}
- </td>
- <td>
- <input type="text" name="frequence" value="{$frequence}">
- </td>
- </tr>
- <tr>
- <td>{t}Size{/t}
- </td>
- <td>
- <input type="text" name="specif_default" value="{$specif_default}">
- </td>
- </tr>
- <tr>
- <td>{t}Type{/t}
- </td>
- <td>
- <select name="type">
- {html_options values=$RAMtypeKeys output=$RAMtypes selected=$type}
- </select>
- </td>
- </tr>
-
- </table>
- </td>
- </tr>
- </table>
-
-{elseif $device_type=="sndcard"}
- <h2><img alt="" align="middle" src="images/snd_hardware.png" class="center"> {t}Add/Edit sound card{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Type{/t}
- </td>
- <td>
- <input type="text" name="type" value="{$type}">
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-{elseif $device_type=="iface"}
- <h2><img alt="" align="middle" src="images/net_hardware.png" class="center"> {t}Add/Edit network interface{/t}</h2>
- <p class="seperator"> </p>
- <br>
-
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}MAC address{/t}
- </td>
- <td>
- <input type="text" name="specif_default" value="{$specif_default}">
- </td>
- </tr>
- <tr>
- <td>{t}Bandwidth{/t}
- </td>
- <td>
- <input type="text" name="bandwidth" value="{$bandwidth}">
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-{elseif $device_type=="processor"}
- <h2><img alt="" align="middle" src="images/processor.png" class="center"> {t}Add/Edit processor{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Frequence{/t}
- </td>
- <td>
- <input type="text" name="frequence" value="{$frequence}">
- </td>
- </tr>
- <tr>
- <td>{t}Default frequence{/t}
- </td>
- <td>
- <input type="text" name="specif_default" value="{$specif_default}">
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-
-{elseif $device_type=="moboard"}
- <h2><img alt="" align="middle" src="images/mainboard.png" class="center"> {t}Add/Edit motherboard{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td>{t}Chipset{/t}
- </td>
- <td>
- <input type="text" name="chipset" value="{$chipset}">
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-{elseif $device_type=="case"}
- <h2><img alt="" align="middle" src="images/server.png" class="center"> {t}Add/Edit computer case{/t}</h2>
- <p class="seperator"> </p>
- <br>
- <table summary="" width="100%">
- <tr>
- <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
- <table summary="" width="100%">
- <tr>
- <td>{t}Name{/t}
- </td>
- <td>
- <input name="designation" value="{$designation}">
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}Comment{/t}
- </td>
- <td>
- <textarea name="comment">{$comment}</textarea>
- </td>
- </tr>
- </table>
- </td>
- <td>
- <table summary="" width="100%">
- <tr>
- <td>{t}Manufacturer{/t}
- </td>
- <td>
- <select name="FK_glpi_enterprise">
- {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
- </select>
- </td>
- </tr>
- <tr>
- <td style="vertical-align:top;">{t}format{/t}
- </td>
- <td>
- <select name="format">
- {html_options values=$formatKeys output=$formats selected=$format}
- </select>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-{/if}
-
-
-<p class="seperator"> </p>
-<div align="right">
- <p>
- <input type="submit" value="{t}Save{/t}" name="SaveDeviceChanges">
- <input type="submit" value="{t}Cancel{/t}" name="AbortDeviceChanges">
- </p>
-</div>
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl
+++ /dev/null
@@ -1,21 +0,0 @@
-<br>
- <select name="select_type_cartridge" size="12" style="width:100%">
- {html_options values=$PrinterTypeKeys output=$PrinterTypes}
- </select><br>
- <input name="cartridge_type_string">
- <input type="submit" name="add_cartridge_type" value="{t}Add{/t}" >
- <input type="submit" name="rename_cartridge_type" value="{t}Rename{/t}" >
- <input type="submit" name="del_cartridge_type" value="{t}Delete{/t}" >
-
-<p class="seperator"> </p>
-<div align="right">
-<p>
-<input name="close_edit_type_cartridge" value="{t}Close{/t}" type="submit">
-</p>
-</div>
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('cartridge_type_string');
- -->
-</script>
-
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_os.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_os.tpl
+++ /dev/null
@@ -1,39 +0,0 @@
-<h2>{t}Manage OS-types{/t}</h2>
-{if $Method == "edit"}
-
- <select name="select_os" size="12" style="width:100%">
- {html_options values=$OSKeys output=$OSs}
- </select><br>
- <input name="is_string">
- <input type="submit" name="add_os" value="{t}Add{/t}" >
- <input type="submit" name="rename_os" value="{t}Rename{/t}" >
- <input type="submit" name="del_os" value="{t}Delete{/t}" >
-
-<p class="seperator"> </p>
-<div align="right">
-<p>
-<input name="close_edit_os" value="{t}Close{/t}" type="submit">
-</p>
-</div>
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('is_string');
- -->
-</script>
-{else}
-{t}Please enter a new name{/t} <input name="string" value="{$string}">
-<p class="seperator"> </p>
- <p>
- <div align="right" style="text-align: right;">
- <input type="submit" name="Rename_os_OK" value="{t}Rename{/t}" >
- <input type="submit" name="Rename_Cancel" value="{t}Cancel{/t}" >
- </div>
- </p>
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('string');
- -->
-</script>
-{/if}
-
-
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_printer_type.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_printer_type.tpl
+++ /dev/null
@@ -1,40 +0,0 @@
-<br>
-{if $Method == "edit"}
- <select name="select_type" size="12" style="width:100%">
- {html_options values=$PrinterTypeKeys output=$PrinterTypes}
- </select><br>
- <input name="type_string">
- <input type="submit" name="add_type" value="{t}Add{/t}" >
- <input type="submit" name="rename_type" value="{t}Rename{/t}" >
- <input type="submit" name="del_type" value="{t}Delete{/t}" >
-
- <p class="seperator"> </p>
- <div align="right">
- <p>
- <input name="close_edit_type" value="{t}Close{/t}" type="submit">
- </p>
- </div>
- <script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('type_string');
- -->
- </script>
-
-{else}
-
- {t}Please enter a new name{/t} <input name="string" value="{$string}">
- <p class="seperator"> </p>
- <p>
- <div align="right" style="text-align: right;">
- <input type="submit" name="Rename_PType_OK" value="{t}Rename{/t}" >
- <input type="submit" name="Rename_Cancel" value="{t}Cancel{/t}" >
- </div>
- </p>
- <script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('string');
- -->
- </script>
-
-{/if}
-
diff --git a/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_type.tpl b/gosa-core/plugins/admin/systems/services/glpi/glpi_edit_type.tpl
+++ /dev/null
@@ -1,37 +0,0 @@
-<h2>{t}Manage System-types{/t}</h2>
-{if $Method == "edit"}
-
- <select name="select_type" size="12" style="width:100%">
- {html_options values=$SystemTypeKeys output=$SystemTypes}
- </select><br>
- <input name="type_string">
- <input type="submit" name="add_type" value="{t}Add{/t}" >
- <input type="submit" name="rename_type" value="{t}Rename{/t}" >
- <input type="submit" name="del_type" value="{t}Delete{/t}" >
-
- <p class="seperator"> </p>
- <div align="right">
- <p>
- <input name="close_edit_type" value="{t}Close{/t}" type="submit">
- </p>
- </div>
- <script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('type_string');
- -->
- </script>
-{else}
-{t}Please enter a new name{/t} <input name="string" value="{$string}">
-<p class="seperator"> </p>
- <p>
- <div align="right" style="text-align: right;">
- <input type="submit" name="Rename_type_OK" value="{t}Rename{/t}" >
- <input type="submit" name="Rename_Cancel" value="{t}Cancel{/t}" >
- </div>
- </p>
- <script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('string');
- -->
- </script>
-{/if}
diff --git a/gosa-core/plugins/admin/systems/services/glpi/goGlpiServer.tpl b/gosa-core/plugins/admin/systems/services/glpi/goGlpiServer.tpl
+++ /dev/null
@@ -1,36 +0,0 @@
-<h2><img class="center" alt="" align="middle" src="images/rightarrow.png" /> {t}GLPI database information{/t}</h2>
- <table summary="">
- <tr>
- <td>{t}Logging DB user{/t}{$must}</td>
- <td>
-{render acl=$goGlpiAdminACL}
- <input name="goGlpiAdmin" id="goGlpiAdmin" size=30 maxlength=60 value="{$goGlpiAdmin}">
-{/render}
- </td>
- </tr>
- <tr>
- <td>{t}Password{/t}</td>
- <td>
-{render acl=$goGlpiPasswordACL}
- <input type="password" name="goGlpiPassword" id="goGlpiPassword" size=30 maxlength=60 value="{$goGlpiPassword}">
-{/render}
- </td>
- </tr>
- <tr>
- <td>{t}Database{/t}{$must}</td>
- <td>
-{render acl=$goGlpiDatabaseACL}
- <input name="goGlpiDatabase" id="goGlpiDatabase" size=30 maxlength=60 value="{$goGlpiDatabase}">
-{/render}
- </td>
- </tr>
- </table>
-
-
-<p class='seperator'> </p>
-<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
- <input type='submit' name='SaveService' value='{t}Save{/t}'>
-
- <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
-</div>
-<input type="hidden" name="goGlpiServer_posted" value="1">
diff --git a/gosa-core/plugins/admin/systems/services/glpi/remove_glpi.tpl b/gosa-core/plugins/admin/systems/services/glpi/remove_glpi.tpl
+++ /dev/null
@@ -1,17 +0,0 @@
-<div style="font-size:18px;">
-<img alt="" src="images/button_cancel.png" align=top> {t}Warning{/t}
-</div>
-<p>
- {$warning}
- {t}Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
-</p>
-
-<p>
- {t}Best thing to do before performing this action would be to save the current contents of your MySql database in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t}
-</p>
-
-<p class="plugbottom">
- <input type=submit name="delete_glpi_confirm" value="{t}Delete{/t}">
-
- <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
-</p>
diff --git a/gosa-core/plugins/personal/connectivity/glpi.tpl b/gosa-core/plugins/personal/connectivity/glpi.tpl
+++ /dev/null
@@ -1 +0,0 @@
-<h2>{if $tabbed eq 1}<input type="checkbox" name="glpi" value="B" {$glpiState} {$glpiACL}>{/if}{t}GLPI account{/t}</h2>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpi.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpi.inc
--- /dev/null
@@ -0,0 +1,1777 @@
+<?php
+
+
+class glpiDB{
+
+ var $user ="";
+ var $password ="";
+ var $server ="";
+ var $db ="";
+
+ var $is_connected = 0;
+ var $handle = NULL;
+
+ var $lasterror ="";
+
+ var $deviceMappingGOsaGlpi;
+ var $deviceMappingTableNameID;
+
+ function glpiDB($server,$user,$pwd,$db){
+ $this->server = $server;
+ $this->user = $user;
+ $this->password = $pwd;
+ $this->db = $db;
+
+ $this->handle = @mysql_connect($this->server,$this->user,$this->password);
+
+ if($this->handle){
+ $this->is_connected = true;
+ $this->SelectDB($this->db);
+ }
+ $this->deviceMappingGOsaGlpi = array(
+ "glpi_device_case" => "case",
+ "glpi_device_control" => "control",
+ "glpi_device_drive" => "drive",
+ "glpi_device_gfxcard" => "gfxcard",
+ "glpi_device_hdd" => "hdd",
+ "glpi_device_iface" => "iface",
+ "glpi_device_moboard" => "moboard",
+ "glpi_device_pci" => "pci",
+ "glpi_device_power" => "power",
+ "glpi_device_processor" => "processor",
+ "glpi_device_ram" => "ram",
+ "glpi_monitors" => "monitor",
+ "glpi_device_sndcard" => "sndcard");
+
+ $this->deviceMappingTableNameID = array( "moboard" => 1,
+ "processor" => 2,
+ "ram" => 3,
+ "hdd" => 4,
+ "iface" => 5,
+ "drive" => 6,
+ "control" => 7,
+ "gfxcard" => 8,
+ "sndcard" => 9,
+ "pci" => 10,
+ "case" => 11,
+ "power" => 12);
+
+
+ }
+
+ function SelectDB()
+ {
+ if($this->is_connected){
+ mysql_select_db($this->db,$this->handle);
+ }
+ }
+
+
+ /* This functions checks if the selected computer/network
+ device is already available in the db
+ */
+ function is_account($dn)
+ {
+ if(!$this->is_connected){
+ $this->lasterror ="Can't query anything, if we aren't connected.";
+ return(false);
+ }else{
+ $qry = "SELECT * FROM glpi_computers WHERE name='".$dn."';";
+ $res = $this->query($qry);
+ if(count($res)==0){
+ return(false);
+ }else{
+ return(true);
+ }
+ }
+ }
+
+ /* this function queries everything
+ */
+ function query($qry)
+ {
+ if(!$this->is_connected){
+ $this->lasterror ="Can't query anything, if we aren't connected.";
+ return(false);
+ }else{
+ $ret =array();
+ $res = mysql_query($qry,$this->handle);
+
+ while($rs = @mysql_fetch_array($res,MYSQL_ASSOC)){
+ $ret[]=$rs;
+ }
+ return($ret);
+ }
+ }
+
+ /* System types
+ Returns all defined system types
+ */
+ function getSystemTypes()
+ {
+ if($this->is_connected){
+ $ret = array();
+ $tmp = ($this->query("SELECT * FROM glpi_type_computers;"));
+ foreach($tmp as $t){
+ $ret[$t['ID']]=$t['name'];
+ }
+ asort($ret);
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* System types
+ Update a system type
+ */
+ function updateSystemType($name,$id)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_type_computers WHERE ID=".$id.";");
+ if(isset($tmp[0])){
+ return($this->query("UPDATE glpi_type_computers SET name='".$name."' WHERE ID=".$id.";"));
+ }else{
+ echo "can't update not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* System types
+ Add one entry to the system types
+ */
+ function addSystemType($name)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_type_computers WHERE name='".$name."';");
+ if(isset($tmp[0])){
+ echo "such an entry already exists";
+ return(false);
+ }else{
+ return($this->query("INSERT INTO glpi_type_computers (name) VALUES ('".$name."');"));
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* System types
+ Remove one entry from the system types (specified by ID=$id)
+ */
+ function removeSystemType($id)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_type_computers WHERE ID=".$id.";");
+ if(isset($tmp[0])){
+ return($this->query("DELETE FROM glpi_type_computers WHERE ID=".$id.";"));
+ }else{
+ echo "can't remove not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* System type is used */
+ function is_systemTypeUsed($ID){
+ if($this->is_connected){
+ $ret = array();
+ $qry="SELECT name,type FROM glpi_computers WHERE type=".$ID." LIMIT 3;";
+ $res = $this->query($qry);
+ foreach($res as $val){
+ $ret[$val['name']] = $val['name'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
+ /* Manufacturer
+ Returns all defined manufacturers
+ */
+ function getEnterprises()
+ {
+ if($this->is_connected){
+ $ret = array();
+ $tmp = $this->query("SELECT * FROM glpi_enterprises ORDER BY name;");
+ foreach($tmp as $t){
+ $ret[$t['ID']]=$t['name'];
+ }
+
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Manufacturer
+ Returns single manufacturer
+ */
+ function getEnterprise($id)
+ {
+ if($this->is_connected){
+ $ret = array();
+ $tmp = $this->query("SELECT * FROM glpi_enterprises WHERE ID=".$id.";");
+ return($tmp);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Manufacturer
+ Updates already existing manufacturer
+ */
+ function updateEnterprise($array,$id)
+ {
+ if(!is_array($array)){
+ echo "updateEnterprisesType: first paraeter must be an array";
+ }elseif($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_enterprises WHERE ID='".$id."';");
+ if(isset($tmp[0])){
+ $atr = array("ID","name","type","address","website","phonenumber","comments","deleted","fax","email");
+
+ $v = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $v .= " ".$at."='".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "updateEnterprisesType: no attributes given ";
+ return(false);
+ }else{
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("UPDATE glpi_enterprises SET ".$v." WHERE ID='".$id."';"));
+ }
+ }else{
+ echo "can't update not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Manufacturer
+ Add new manufacturer
+ */
+ function addEnterprise($array)
+ {
+ if(!is_array($array)){
+ echo "addUser: first paraeter must be an array";
+ }elseif($this->is_connected){
+ $atr = array("ID","name","type","address","website","phonenumber","comments","deleted","fax","email");
+ $v = "";
+ $a = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $a .= $at.", ";
+ $v .= "'".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "addUser: no attributes given ";
+ return(false);
+ }else{
+ $a = preg_replace("/, $/","",$a);
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("INSERT INTO glpi_enterprises (".$a.") VALUES (".$v.");"));
+ }
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+
+ }
+
+ /* Manufacturer
+ remove manufacturer
+ */
+ function removeEnterprise($id)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_enterprises WHERE ID=".$id.";");
+ if(isset($tmp[0])){
+ return($this->query("DELETE FROM glpi_enterprises WHERE ID=".$id.";"));
+ }else{
+ echo "can't remove not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Operating systems
+ Returns all OSs
+ */
+ function getOSTypes($keys = false)
+ {
+ if($this->is_connected){
+ $ret = array();
+ $tmp=($this->query("SELECT * FROM glpi_dropdown_os ORDER by name;"));
+
+ if($keys){
+ foreach($tmp as $t){
+ $ret[$t['name']]=$t['ID'];
+ }
+ }else{
+ foreach($tmp as $t){
+ $ret[$t['ID']]=$t['name'];
+ }
+ }
+ return($ret);
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Operating system is used ? */
+ function is_osUsed($ID){
+ if($this->is_connected){
+ $ret = array();
+ $qry="SELECT name,type FROM glpi_computers WHERE os=".$ID." LIMIT 3;";
+ $res = $this->query($qry);
+ foreach($res as $val){
+ $ret[$val['name']] = $val['name'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
+ /* Operating systems
+ Add a new operating system to the dropdown menus
+ */
+ function addOS($name)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_dropdown_os WHERE name='".$name."';");
+ if(isset($tmp[0])){
+ echo "such an entry already exists";
+ return(false);
+ }else{
+ return($this->query("INSERT INTO glpi_dropdown_os (name) VALUES ('".$name."');"));
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Operating systems
+ remove one OS entry
+ */
+ function removeOS_byID($id)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_dropdown_os WHERE ID=".$id.";");
+ if(is_array($tmp[0])){
+ return($this->query("DELETE FROM glpi_dropdown_os WHERE ID=".$id.";"));
+ }else{
+ echo "can't remove not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Operating systems
+ Update existing OS entry
+ */
+ function updateOS($name,$id)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_dropdown_os WHERE ID=".$id.";");
+ if(isset($tmp[0])){
+ return($this->query("UPDATE glpi_dropdown_os SET name='".$name."' WHERE ID=".$id.";"));
+ }else{
+ echo "can't update not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* This returns all available glpi users
+ */
+ function getUsers()
+ {
+ if($this->is_connected){
+ $ret = array();
+ $tmp = ($this->query("SELECT * FROM glpi_users"));
+ foreach($tmp as $user){
+ $ret[$user['ID']]=$user['name'];
+ }
+ return($ret);
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* this function adds a new glpi user
+ */
+ function addUser($array,$dn)
+ {
+ if(!is_array($array)){
+ echo "addUser: first paraeter must be an array";
+ }elseif($this->is_connected){
+ $array['name']=$dn;
+ $atr = array("name","phone","email");
+ $v = "";
+ $a = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $a .= $at.", ";
+ $v .= "'".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "addUser: no attributes given ";
+ return(false);
+ }else{
+ $a = preg_replace("/, $/","",$a);
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("INSERT INTO glpi_users (".$a.") VALUES (".$v.");"));
+ }
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+
+ }
+
+ /* This function updates a glpi user
+ with the given data
+ */
+ function updateUser($array,$dn)
+ {
+ if(!is_array($array)){
+ echo "updateUser: first paraeter must be an array";
+ }elseif($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_users WHERE name='".$dn."';");
+ if(isset($tmp[0])){
+
+ $atr = array("name","phone","email");
+ $v = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $v .= " ".$at."='".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "UpdateUser: no attributes given ";
+ return(false);
+ }else{
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("UPDATE glpi_users SET ".$v." WHERE name='".$dn."';"));
+ }
+ }else{
+ echo "can't update not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+
+ }
+
+ /* This function returns all available data
+ from a specified dn
+ */
+ function getComputerInformations($name)
+ {
+ if($this->is_connected){
+ $ret = $this->query("SELECT * FROM glpi_computers WHERE name='".$name."';");
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* This fucntions updates an already existing entry
+ */
+ function updateComputerInformations($array,$name)
+ {
+ if(!is_array($array)){
+ echo "updateComputerInformations: first paraeter must be an array";
+ }elseif($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_computers WHERE name='".$name."';");
+ if(isset($tmp[0])){
+
+ $atr = array( "ID","name","serial","otherserial","contact","contact_num",
+ "tech_num","comments","date_mod","os","location","domain","network",
+ "model","type","is_template","tplname","FK_glpi_enterprise","deleted");
+ $v = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $v .= " ".$at."='".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "updateComputerInformations: no attributes given ";
+ return(false);
+ }else{
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("UPDATE glpi_computers SET ".$v." WHERE name='".$name."';"));
+ }
+ }else{
+ echo "can't update not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+
+ }
+
+ /* This function adds a new inventory device (computer phone etc)
+ */
+ function addComputerInformations($array)
+ {
+ if(!is_array($array)){
+ echo "updateComputerInformations: first paraeter must be an array";
+ }elseif($this->is_connected){
+ $atr = array( "ID","name","serial","otherserial","contact","contact_num",
+ "tech_num","comments","date_mod","os","location","domain","network",
+ "model","type","is_template","tplname","FK_glpi_enterprise","deleted");
+ $v = "";
+ $a = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $a .= $at.", ";
+ $v .= "'".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "updateComputerInformations: no attributes given ";
+ return(false);
+ }else{
+ $a = preg_replace("/, $/","",$a);
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("INSERT INTO glpi_computers (".$a.") VALUES (".$v.");"));
+ }
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+
+ }
+
+ /* this functions checks if the given Device
+ * already exists
+ */
+ function deviceExists($attr)
+ {
+ $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
+ if($this->is_connected){
+ $arr = array_flip($deviceMappingGOsaGlpi);
+
+ $tbl_name = $arr[$attr['device_type']];
+ if(!isset($attr['ID'])){
+ return(false);
+ }else{
+ $qry = "SELECT * FROM ".$tbl_name." WHERE ID=".$attr['ID'].";";
+ $res = $this->query($qry);
+ if(count($res) != 0){
+ return(true);
+ }
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+
+ return(false);
+ }
+
+
+ /* Check if given device is used by some accounts
+ * (helpfull to avoid removement of used devices)
+ */
+ function is_deviceUsed($item)
+ {
+ $deviceMappingGOsaGlpi = array_flip($this->deviceMappingGOsaGlpi);
+ $deviceMappingTableNameID = $this->deviceMappingTableNameID;
+ if($this->is_connected){
+ $tablename = $deviceMappingGOsaGlpi[$item['device_type']];
+ $type = $item['device_type'];
+
+ $ret = array();
+
+ if($type=="monitor"){
+ $str = "SELECT c.name FROM glpi_connect_wire as w, glpi_computers as c WHERE w.end1=".$item['ID']." AND w.end2 = c.ID AND w.type=4;";
+ }else{
+ $str = "SELECT c.name FROM glpi_computer_device as d, glpi_computers as c WHERE d.FK_computers=c.ID AND FK_device=".$item['ID']." AND device_type=".$deviceMappingTableNameID[$type]." ;";
+ }
+
+ $res = $this->query($str);
+
+ foreach($res as $val){
+ $ret[$val['name']] = $val['name'];
+ }
+
+ return($ret);//count($this->query($str)));
+ }else{
+ echo "not connected";
+ return(false);
+ }
+
+ }
+
+
+ /* This functions deletes a specified entry
+ * from our device tables
+ */
+ function deleteDevice($attr)
+ {
+ $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
+ if($this->is_connected){
+ $arr = array_flip($deviceMappingGOsaGlpi);
+
+ $device_type = $attr['device_type'];
+ unset($attr['device_type']);
+
+ $tbl_name = $arr[$device_type];
+
+ $this->query("DELETE FROM ".$tbl_name." WHERE ID=".$attr['ID'].";");
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* This funtions updated an already existing device
+ */
+ function updateDevices($attr)
+ {
+ $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
+ if($this->is_connected){
+ $arr = array_flip($deviceMappingGOsaGlpi);
+
+ $device_type = $attr['device_type'];
+ unset($attr['device_type']);
+
+ $tbl_name = $arr[$device_type];
+
+ $str = "UPDATE ".$tbl_name." SET ";
+ foreach($attr as $name => $value){
+ $str.=$name."='".$value."', ";
+ }
+ $str = preg_replace("/, $/","",$str);
+ $str .= " WHERE ID=".$attr['ID'].";";
+ $this->query($str);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Returns all possible RAM types
+ * like SDRAM , DIMM .....
+ */
+ function getRAMTypes()
+ {
+ if($this->is_connected){
+ $ret = array();
+ $tmp = ($this->query("SELECT * FROM glpi_dropdown_ram_type;"));
+ foreach($tmp as $t){
+ $ret[$t['ID']]=$t['name'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Returns all possible HDD connection types
+ * like IDE SCSI ...
+ */
+ function getGlpiDeviceControlTypes()
+ {
+ if($this->is_connected){
+ $ret = array();
+ $tmp = ($this->query("SELECT * FROM glpi_dropdown_hdd_type;"));
+ foreach($tmp as $t){
+ $ret[$t['ID']]=$t['name'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Returns all possible gfx card connection types
+ * like PCI-X PCI AGP ....
+ */
+ function getGlpiGfxControlTypes()
+ {
+ if($this->is_connected){
+ $ret = array();
+ $tmp = ($this->query("SELECT * FROM glpi_dropdown_hdd_type;"));
+ foreach($tmp as $t){
+ $ret[$t['ID']]=$t['name'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Devices
+ Adds a new single device to our db
+ */
+ function addDevice($attr)
+ {
+ $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
+ if($this->is_connected){
+ $arr = array_flip($deviceMappingGOsaGlpi);
+
+ $device_type = $attr['device_type'];
+ unset($attr['device_type']);
+
+ $tbl_name = $arr[$device_type];
+ $v = "";
+ $a = "";
+ foreach($attr as $name => $value){
+ $a .= $name.", ";
+ $v .= "'".$value."', ";
+ }
+ if(empty($v)){
+ echo "addDevice: no attributes given ";
+ return(false);
+ }else{
+ $a = preg_replace("/, $/","",$a);
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("INSERT INTO ".$tbl_name." (".$a.") VALUES (".$v.");"));
+ }
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Return all available devices
+ */
+ function getDevices()
+ {
+ $deviceMappingGOsaGlpi = $this->deviceMappingGOsaGlpi;
+ if($this->is_connected){
+ $arr = $deviceMappingGOsaGlpi;
+
+ $res = array();
+ foreach($arr as $glpi => $gosa){
+ $qry = "SELECT * FROM ".$glpi.";";
+ $ret = $this->query($qry);
+ foreach($ret as $id => $entry){
+ $entry['device_type'] = $gosa;
+
+ if(isset($entry['designation'])){
+ $res[$entry['designation']."-".$gosa] = $entry;
+ }else{
+ $res[$entry['name']."-".$gosa] = $entry;
+ }
+ }
+ }
+ return($res);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* This function returns all used devices
+ */
+ function getUsedDevices($computerID)
+ {
+ $deviceMappingGOsaGlpi = array_flip($this->deviceMappingGOsaGlpi);
+ $deviceMappingTableNameID = $this->deviceMappingTableNameID;
+
+ if($this->is_connected){
+ $qry = "SELECT * FROM glpi_computer_device WHERE FK_computers=".$computerID.";";
+ $res = $this->query($qry);
+
+ $ret = array();
+ foreach($deviceMappingGOsaGlpi as $GOsa => $glpi){
+ $ret[$GOsa] = array();
+ }
+
+ $tbls = array_flip($deviceMappingTableNameID);
+
+ foreach($res as $device){
+ $devtype = $tbls[$device['device_type']];
+ $tbl_name = $deviceMappingGOsaGlpi[$devtype];
+ $qry = ("SELECT * FROM ".$tbl_name." WHERE ID=".$device['FK_device'].";");
+ $res2 = $this->query($qry);
+ if(count($res2)!=0){
+ $ret[$devtype][$res2[0]['designation']]=$res2[0];
+ }
+
+ $qry = "SELECT * FROM glpi_connect_wire WHERE type=4 AND end2=".$computerID.";";
+ $res2 = $this->query($qry);
+ foreach($res2 as $monitor){
+ $qry = "SELECT * FROM glpi_monitors WHERE ID=".$monitor['end1'].";";
+ $res3 = $this->query($qry);
+ foreach($res3 as $moni){
+ $ret['monitor'][$moni['name']]=$moni;
+ }
+ }
+
+
+
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* This function removes all given devices from a computer, specified by $id
+ In the next step all devices specified by devices will be added.
+ */
+ function addDevicesToComputer($devices, $id)
+ {
+ $deviceMappingGOsaGlpi = array_flip($this->deviceMappingGOsaGlpi);
+ $deviceMappingTableNameID = $this->deviceMappingTableNameID;
+
+ if(($id == "" )||(!is_numeric($id))){
+ return (false);
+ }
+ if($this->is_connected){
+ $qry = "DELETE FROM glpi_computer_device WHERE FK_computers=".$id.";";
+ $this->query($qry);
+
+ foreach($devices as $type => $entries){
+ foreach($entries as $entry){
+ if($type=="monitor"){
+ $str = "INSERT INTO glpi_connect_wire (end1,end2,type)
+ VALUES (".$entry['ID'].",".$id.",4);";
+ }else{
+ $str = "INSERT INTO glpi_computer_device (device_type,FK_device,FK_computers)
+ VALUES (".$deviceMappingTableNameID[$type].",".$entry['ID'].",".$id.");";
+ }
+ $this->query($str);
+ }
+ }
+
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+
+ }
+
+ function removeComputerInformations($name)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_computers WHERE name='".$name."';");
+ if(isset($tmp[0])){
+ $id = $tmp[0]['ID'];
+ $this->query("DELETE FROM glpi_connect_wire WHERE end2=".$id.";");
+ $this->query("DELETE FROM glpi_computer_device WHERE FK_computers=".$id.";");
+ return($this->query("DELETE FROM glpi_computers WHERE ID=".$id.";"));
+ }else{
+ echo "can't remove not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function is_connected()
+ {
+ return($this->is_connected);
+ }
+
+ function addAttachmentsToComputer($attr,$id)
+ {
+ if(($id == "" )||(!is_numeric($id))){
+ return (false);
+ }
+ if($this->is_connected){
+ $qry = "DELETE FROM glpi_doc_device WHERE (FK_device=".$id.") AND (device_type=1);";
+ $this->query($qry);
+
+ foreach($attr as $aid => $entry){
+ $str = "INSERT INTO glpi_doc_device (FK_doc,FK_device,device_type,is_template)
+ VALUES
+ ($aid,$id,1,'0');";
+ $this->query($str);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function getAssignAttachments($id)
+ {
+
+ if($this->is_connected){
+ $qry= "SELECT * FROM glpi_doc_device WHERE (device_type=1) AND (FK_device=".$id.");";
+ $ret = $this->query($qry);
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function deleteAttachment($id)
+ {
+ if($this->is_connected){
+ $qry = "DELETE FROM glpi_docs WHERE ID=".$id."";
+ $this->query($qry);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function getAttachments()
+ {
+ $ret = array();
+ if($this->is_connected){
+ $qry = "SELECT * FROM glpi_docs WHERE name!='';";
+ $re = $this->query($qry);
+
+ foreach($re as $entry){
+ $ret[$entry['ID']]=$entry;
+ }
+
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function saveAttachments($attrs,$id = -1)
+ {
+ if($this->is_connected){
+ $atr = array("name","filename","rubrique","mime","date_mod","comment","deleted","link");
+ $tmp = array();
+ foreach($atr as $at){
+ if(isset($attrs[$at])){
+ $tmp[$at] = $attrs[$at];
+ }
+ }
+ if(count($tmp)==0){
+ return(false);
+ }else{
+
+ // Add
+ if($id == -1){
+ $str = "INSERT INTO glpi_docs ";
+ $namen = "";
+ $values= "";
+ foreach($tmp as $name => $value){
+ $namen .= $name.", ";
+ if(is_numeric($value)){
+ $values .= $value.", ";
+ }else{
+ $values .= "'".$value."', ";
+ }
+ }
+ $values = preg_replace("/, $/","",$values);
+ $namen = preg_replace("/, $/","",$namen);
+ $str .= "(".$namen.") VALUES (".$values.");";
+ }else{
+ $str = "UPDATE glpi_docs SET ";
+ foreach($tmp as $name => $value){
+ $str .= $name."= ";
+ if(is_numeric($value)){
+ $str .= $value.", ";
+ }else{
+ $str .= "'".$value."', ";
+ }
+ }
+ $str = preg_replace("/, $/","",$str);
+ $str .= " WHERE ID=".$id.";";
+ }
+ $this->query($str);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
+ /* Check if given attachment id is used in any Device
+ ( - avoid removing of used attachments)
+ */
+ function is_attachmentUsed($id)
+ {
+ if($this->is_connected){
+ $ret = array();
+ $qry = "SELECT t.name FROM glpi_computers as t, glpi_doc_device WHERE t.ID = glpi_doc_device.FK_device AND FK_doc =".$id." LIMIT 3;";
+ $res = $this->query($qry);
+ foreach($res as $val){
+ $ret[$val['name']] = $val['name'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
+ /* Monitor handling
+ */
+ function getMonitors()
+ {
+ if($this->is_connected){
+ $qry= "SELECT * FROM glpi_monitors;";
+ return($this->query($qry));
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function updatedMonitor()
+ {
+ if($this->is_connected){
+// $qry= "SELECT * FROM glpi_monitors;";
+// return($this->query($qry));
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function addMonitor()
+ {
+ if($this->is_connected){
+// $qry= "SELECT * FROM glpi_monitors;";
+// return($this->query($qry));
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function removeMonitor($id)
+ {
+ if($this->is_connected){
+ $qry= "DELETE FROM glpi_monitors WHERE ID=".$id.";";
+ $this->query($qry);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function getMonitorTypes()
+ {
+ if($this->is_connected){
+ $qry= "SELECT * FROM glpi_type_monitors;";
+ return($this->query($qry));
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function getLocationTypes()
+ {
+ if($this->is_connected){
+ $qry= "SELECT * FROM glpi_dropdown_locations;";
+ return($this->query($qry));
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function getStateTypes()
+ {
+ if($this->is_connected){
+ $qry= "SELECT * FROM glpi_dropdown_state;";
+ return($this->query($qry));
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
+ /* Printer functions
+ */
+
+ /* is printer type used ?
+ */
+ function is_printerTypeUsed($id)
+ {
+ if($this->is_connected){
+ $qry = "SELECT * FROM glpi_printers WHERE type=".$id.";";
+ $res = $this->query( $qry);
+ $ret =array();
+ foreach($res as $entry){
+ $ret[$entry['ID']] = $entry['name'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* This functions checks if the selected computer/network
+ device is already available in the db
+ */
+ function is_printer_account($dn)
+ {
+ if(!$this->is_connected){
+ $this->lasterror ="Can't query anything, if we aren't connected.";
+ return(false);
+ }else{
+ $qry = "SELECT * FROM glpi_printers WHERE name='".$dn."';";
+ $res = $this->query($qry);
+ if(count($res)==0){
+ return(false);
+ }else{
+ return(true);
+ }
+ }
+ }
+
+ /* This function returns all available data
+ from a specified dn
+ */
+ function getPrinterInformations($name)
+ {
+ if($this->is_connected){
+ $ret = $this->query("SELECT * FROM glpi_printers WHERE name='".$name."';");
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Get Printer attachments
+ */
+ function getAssignPrinterAttachments($id)
+ {
+
+ if($this->is_connected){
+ $qry= "SELECT * FROM glpi_doc_device WHERE (device_type=3) AND (FK_device=".$id.");";
+ $ret = $this->query($qry);
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Printer types
+ Returns all defined printer types
+ */
+ function getPrinterTypes()
+ {
+ if($this->is_connected){
+ $ret = array();
+ $tmp = ($this->query("SELECT * FROM glpi_type_printers ORDER BY name; "));
+ foreach($tmp as $t){
+ $ret[$t['ID']]=$t['name'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Add pritner types
+ Add one entry to the printer types
+ */
+ function addPrinterType($name)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_type_printers WHERE name='".$name."';");
+ if(isset($tmp[0])){
+ //echo "such an entry already exists";
+ return(false);
+ }else{
+ return($this->query("INSERT INTO glpi_type_printers (name) VALUES ('".$name."');"));
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* remove printer types
+ Remove one entry from the printer types (specified by ID=$id)
+ */
+ function removePrinterType($id)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_type_printers WHERE ID=".$id.";");
+ if(isset($tmp[0])){
+ return($this->query("DELETE FROM glpi_type_printers WHERE ID=".$id.";"));
+ }else{
+ echo "can't remove not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Update printer types
+ Update a printer type
+ */
+ function updatePrinterType($name,$id)
+ {
+
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_type_printers WHERE ID=".$id.";");
+ if(isset($tmp[0])){
+ return($this->query("UPDATE glpi_type_printers SET name='".$name."' WHERE ID=".$id.";"));
+ }else{
+ echo "can't update not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
+ /* This fucntions updates an already existing entry
+ */
+ function updatePrinterInformations($array,$name)
+ {
+ if(!is_array($array)){
+ echo "updatePrinterInformations: first paraeter must be an array";
+ }elseif($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_printers WHERE name='".$name."';");
+ if(isset($tmp[0])){
+
+ $atr = array( "ID","name","serial","otherserial","contact","contact_num",
+ "tech_num","comments","date_mod","location","domain","network","ramSize","flags_serial","flags_par","flags_usb",
+ "model","type","is_template","tplname","FK_glpi_enterprise","deleted");
+ $v = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $v .= " ".$at."='".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "updateSystemInformations: no attributes given ";
+ return(false);
+ }else{
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("UPDATE glpi_printers SET ".$v." WHERE name='".$name."';"));
+ }
+ }else{
+ echo "can't update not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+
+ }
+
+ /* This function adds a new inventory settings for printers
+ */
+ function addPrinterInformations($array)
+ {
+ if(!is_array($array)){
+ echo "updateComputerInformations: first paraeter must be an array";
+ }elseif($this->is_connected){
+ $atr = array( "ID","name","serial","otherserial","contact","contact_num",
+ "tech_num","comments","date_mod","os","location","domain","network","ramSize","flags_serial","flags_par","flags_usb",
+ "model","type","is_template","tplname","FK_glpi_enterprise","deleted");
+ $v = "";
+ $a = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $a .= $at.", ";
+ $v .= "'".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "updateComputerInformations: no attributes given ";
+ return(false);
+ }else{
+ $a = preg_replace("/, $/","",$a);
+ $v = preg_replace("/, $/","",$v);
+ return($this->query("INSERT INTO glpi_printers (".$a.") VALUES (".$v.");"));
+ }
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* add atachment to given printer */
+ function addAttachmentsToPrinter($attr,$id)
+ {
+ if(($id == "" )||(!is_numeric($id))){
+ return (false);
+ }
+ if($this->is_connected){
+ $qry = "DELETE FROM glpi_doc_device WHERE (FK_device=".$id.") AND (device_type=3);";
+ $this->query($qry);
+
+ foreach($attr as $aid => $entry){
+ $str = "INSERT INTO glpi_doc_device (FK_doc,FK_device,device_type,is_template)
+ VALUES
+ ($aid,$id,3,'0');";
+ $this->query($str);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function removePrinterInformations($name)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_printers WHERE name='".$name."';");
+ if(isset($tmp[0])){
+ $id = $tmp[0]['ID'];
+// $this->query("DELETE FROM glpi_connect_wire WHERE end2=".$id.";");
+ $this->query("DELETE FROM glpi_doc_device WHERE FK_device=".$id." AND device_type=3;");
+ return($this->query("DELETE FROM glpi_printers WHERE ID=".$id.";"));
+ }else{
+ echo "can't remove not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
+ /* Cartridges
+ */
+ /* return all assigned cartridges */
+ function getUsedCartridges($printerID)
+ {
+ if($this->is_connected){
+ $ret = array();
+ $qry = "SELECT
+ c.date_use as date_use,
+ c.ID as ID,
+ t.ID as type_ID,
+ t.name as name,
+ c.FK_glpi_printers as FK_glpi_printers,
+ d.name as type_name
+ FROM
+ glpi_dropdown_cartridge_type as d,
+ glpi_cartridges as c,
+ glpi_cartridges_type as t
+ WHERE c.FK_glpi_cartridges_type = t.ID
+ AND t.type = d.ID
+ AND c.FK_glpi_printers = ".$printerID.";";
+ $res = $this->query($qry);
+ foreach($res as $entry){
+ $ret[$entry['ID']] = $entry;
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* return all assigned cartridges */
+ function getAvailableCartridgeTypes($printerTypeID)
+ {
+ if($this->is_connected){
+ $ret = array();
+ $qry= "
+ SELECT
+ ct.ID as cartridgeID,
+ ct.name as cartridgeName,
+ pt.ID as printerTypeID,
+ pt.name as printerTypeName,
+ ct.type as cartridgeTypeID,
+ dt.name as cartridgeTypeName
+ FROM
+ glpi_type_printers as pt,
+ glpi_cartridges_type as ct,
+ glpi_dropdown_cartridge_type as dt,
+ glpi_cartridges_assoc as ac
+ WHERE
+ ac.FK_glpi_type_printer = pt.ID
+ AND ac.FK_glpi_cartridges_type = ct.ID
+ AND ct.type=dt.ID
+ AND pt.ID=".$printerTypeID.";";
+ $res = $this->query($qry);
+ foreach($res as $entry){
+ $ret[$entry['cartridgeID']] = $entry;
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function removeCartridgeFromPrinter($cartridgeID)
+ {
+ if($this->is_connected){
+ $qry = "DELETE FROM glpi_cartridges WHERE ID=".$cartridgeID.";";
+ return($this->query($qry));
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function addCartridgeFromPrinter($printerID,$cartridgeID)
+ {
+ if($this->is_connected){
+ $qry ="INSERT INTO
+ glpi_cartridges (FK_glpi_cartridges_type,FK_glpi_printers,date_in,date_use)
+ VALUES
+ (".$cartridgeID.",".$printerID.",'".date("Y-m-d")."','".date("Y-m-d")."');";
+ return($this->query($qry));
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function is_cartridgeTypeUsed($id){
+ if($this->is_connected){
+ $qry = "SELECT p.ID,p.name as name FROM glpi_cartridges as c,glpi_printers as p WHERE p.ID=c.FK_glpi_printers AND c.FK_glpi_cartridges_type=".$id.";";
+ $res = $this->query($qry);
+ $ret =array();
+ foreach($res as $entry){
+ $ret[$entry['ID']] = $entry['name'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function getCartridgeTypeInformations($id = "all"){
+ if($this->is_connected){
+ $ret = array();
+ if($id != "all"){
+ $qry = "SELECT * FROM glpi_cartridges_type WHERE ID = ".$id.";";
+ }else{
+ $qry = "SELECT * FROM glpi_cartridges_type;";
+ }
+
+ $res = ($this->query($qry));
+ foreach($res as $entry){
+ $ret[$entry['ID']] = $entry;
+ }
+ return($ret);
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function getCartridgeTypes(){
+ if($this->is_connected){
+ $ret = array();
+ $qry = "SELECT * FROM glpi_dropdown_cartridge_type;";
+ $res = ($this->query($qry));
+ foreach($res as $entry){
+ $ret[$entry['ID']] = $entry['name'];
+ }
+ return($ret);
+
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
+
+ /* check if given manufacturer ID ist still in use.
+ The problem is, that nearly every table uses manufacturers ....
+ */
+ function is_manufacturerUsed($id)
+ {
+ if($this->is_connected){
+ $tables = array();
+ foreach($this->deviceMappingGOsaGlpi as $entry => $table){
+ $tables[] = $entry;
+ }
+ $tables[] ="glpi_computers";
+ $tables[] ="glpi_cartridges_type";
+ $ret = array();
+ $i = 3;
+ foreach($tables as $tbl){
+ if($i <= 0 ) continue;
+ $qry = "SELECT * FROM ".$tbl." WHERE FK_glpi_enterprise = ".$id.";";
+ $res = $this->query($qry);
+ foreach($res as $entry){
+ if($i <= 0 ) continue;
+ if(isset($entry['designation'])){
+ $entry['name'] = $entry['designation'];
+ }
+ $i --;
+ $ret[] = $entry['name'];
+ }
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Manufacturer
+ Updates already existing manufacturer
+ */
+ function Add_UpdateCatrigdeType($array,$array_printer_types)
+ {
+ if(!is_array($array)){
+ echo "Add_UpdateCatrigdeType: first paraeter must be an array";
+ }elseif($this->is_connected){
+
+
+ $atr = array("name","ref","location","type","FK_glpi_enterprise","tech_num","deleted","comments","alarm");
+
+ /* Entry was edited */
+ if($array['ID']>0){
+ $qry = "DELETE FROM glpi_cartridges_assoc WHERE FK_glpi_cartridges_type=".$array['ID'].";";
+
+ $v = "";
+ foreach($atr as $at){
+ if(isset($array[$at])){
+ $v .= " ".$at."='".$array[$at]."', ";
+ }
+ }
+ if(empty($v)){
+ echo "Add_UpdateCatrigdeType: no attributes given ";
+ return(false);
+ }else{
+ $v = preg_replace("/, $/","",$v);
+ $qry = "UPDATE glpi_cartridges_type SET ".$v." WHERE ID='".$array['ID']."';";
+ $this->query($qry);
+ }
+ }else{
+
+ /* skip if name is in use*/
+ $qry = "SELECT * FROM glpi_cartridges_type WHERE name='".$array['name']."';";
+ if(count($this->query($qry))){
+ return;
+ }
+
+ $str = "INSERT INTO glpi_cartridges_type ";
+ $namen = "";
+ $values= "";
+ foreach($array as $name => $value){
+ $namen .= $name.", ";
+ if(is_numeric($value)){
+ $values .= $value.", ";
+ }else{
+ $values .= "'".$value."', ";
+ }
+ }
+ $values = preg_replace("/, $/","",$values);
+ $namen = preg_replace("/, $/","",$namen);
+ $str .= "(".$namen.") VALUES (".$values.");";
+ $this->query($str);
+ $IDs = $this->query("SELECT ID FROM glpi_cartridges_type WHERE name='".$array['name']."';");
+ if(count($IDs) > 1){
+ echo "internal db error";
+ return;
+ }
+ $array['ID'] = $IDs[0]['ID'];
+ }
+
+ foreach($array_printer_types as $id){
+ $qry = "INSERT INTO glpi_cartridges_assoc
+ (FK_glpi_cartridges_type,FK_glpi_type_printer)
+ VALUES
+ (".$array['ID'].",".$id.")";
+
+ $this->query($qry);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function getSupportedPrinterTypeIDsForCartridge($cid)
+ {
+ if($this->is_connected){
+ $ret = array();
+ $qry = "SELECT FK_glpi_type_printer FROM glpi_cartridges_assoc WHERE FK_glpi_cartridges_type = ".$cid.";";
+ $res = $this->query($qry);
+
+ foreach($res as $entry => $value){
+ $ret[$value['FK_glpi_type_printer']] = $value['FK_glpi_type_printer'];
+ }
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function removeCartridgeType($id){
+ if($this->is_connected){
+ $qry = "DELETE FROM glpi_cartridges_assoc WHERE FK_glpi_cartridges_type=".$id.";";
+ $this->query($qry);
+ $qry = "DELETE FROM glpi_cartridges_type WHERE ID=".$id.";";
+ return($this->query($qry));
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function getCartridgesWhichUseThisType($id)
+ {
+ if($this->is_connected){
+ $qry = "SELECT * FROM glpi_cartridges WHERE FK_glpi_cartridges_type=".$id.";";
+ $ret = $this->query($qry);
+ return($ret);
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+
+ /* Add pritner types
+ Add one entry to the cartridgeType types
+ */
+ function addCartridgeDropdownType($name)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_dropdown_cartridge_type WHERE name='".$name."';");
+ if(isset($tmp[0])){
+ //echo "such an entry already exists";
+ return(false);
+ }else{
+ return($this->query("INSERT INTO glpi_dropdown_cartridge_type (name) VALUES ('".$name."');"));
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* remove cartridgeType types
+ Remove one entry from the cartridgeType types (specified by ID=$id)
+ */
+ function removeCartridgeDropdownType($id)
+ {
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_dropdown_cartridge_type WHERE ID=".$id.";");
+ if(isset($tmp[0])){
+ return($this->query("DELETE FROM glpi_dropdown_cartridge_type WHERE ID=".$id.";"));
+ }else{
+ echo "can't remove not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ /* Update cartridgeType
+ Update a cartridgeType
+ */
+ function updateCartridgeDropdownType($name,$id)
+ {
+
+ if($this->is_connected){
+ $tmp = $this->query("SELECT * FROM glpi_dropdown_cartridge_type WHERE ID=".$id.";");
+ if(isset($tmp[0])){
+ return($this->query("UPDATE glpi_dropdown_cartridge_type SET name='".$name."' WHERE ID=".$id.";"));
+ }else{
+ echo "can't update not existing entry";
+ return(false);
+ }
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+ function getUsedDropdownTypes($id=false)
+ {
+ if($this->is_connected){
+ if($id){
+ $qry = "SELECT distinct(type) FROM glpi_cartridges_type WHERE type = ".$id.";";
+ }else{
+ $qry = "SELECT distinct(type) FROM glpi_cartridges_type;";
+ }
+ return($this->query($qry));
+ }else{
+ echo "not connected";
+ return(false);
+ }
+ }
+
+}
+//$s = new glpiDB("vserver-01","glpi","tester","glpi");
+//print_r($s->query("SELECT * FROM glpi_computers"));
+//$s->getComputerInformations("1 OR (c.ID<10000)");
+?>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiAccount.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiAccount.inc
--- /dev/null
@@ -0,0 +1,806 @@
+<?php
+
+class glpiAccount extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= FALSE;
+ var $attributes= array("ID","name","contact",
+ "tech_num","comments","date_mod","os","location","domain","network","contact_num",
+ "model","type","is_template","FK_glpi_enterprise","deleted");
+
+ var $ID ; // Is set if this entry is edited
+ var $name = ""; // This should be the dn of this entry
+ var $contact = ""; // Empty
+
+ var $comments = ""; // Comment
+
+ var $contact_num = ""; // Contact person
+ var $tech_num = ""; // Technical responsible person
+
+ var $addUser = ""; // This is used to remember if a dialog was opened for tech_num or contact_num
+
+ var $date_mod = ""; // Modification timestamp
+ var $os = 0; // Operating system
+ var $location = 0; // Not used yet
+ var $domain = 0; // ? Set to 0
+ var $network = 0; // ? Set to 0
+
+ var $model = 0; // ? Can't remember this, it isn't used in GOsa
+ var $type = 0; // System type id
+ var $is_template = 0; // Used as template ?
+ var $FK_glpi_enterprise = 0; // Manufacturer id
+ var $deleted = "N"; // Deleted entries should have this set to Y
+
+ var $renameTypeDialog = false;
+ var $renameOSDialog = false;
+ var $select_type ;
+ var $view_logged = FALSE;
+
+ /* Not necessary, cause we use mysql databse */
+ var $objectclasses= array("whatever");
+
+ /* Used to remember if this was an account (simply: is this an edited entry) */
+ var $initially_was_account = false;
+
+ /* Remember current dialog */
+ var $edit_type = false;
+ var $edit_os = false;
+
+ var $data;
+ var $handle = NULL; // Glpi class handle used to query database
+
+ var $cur_dialog = NULL; // This contains the sub dialog handle
+
+ var $orig_dn; // To check if dn, has changed
+ var $ui; // Some GOsa specific user informations
+
+ var $usedDevices = array(); // Which devices are currently selected
+ var $usedAttachments = array(); // Used Attachments
+
+ /* Contructor
+ Sets default values and checks if we already have an existing glpi account
+ */
+ function glpiAccount (&$config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin ($config, $dn, $parent);
+ $this->ui= get_userinfo();
+
+ /* Abort class construction, if no db is defined */
+ if(!isset($this->config->data['SERVERS']['GLPI'])){
+ return;
+ }
+
+ // Get informations about databse connection
+ $this->data = $this->config->data['SERVERS']['GLPI'];
+
+ // Abort if mysql extension is missing
+ if(!is_callable("mysql_connect")){
+ return;
+ }
+
+ // Create handle of glpi class, and check if database connection is established
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+
+ if(!$this->handle->is_connected){
+ return;
+ }
+
+ // If this dn is already used in database, then get all informations for this entry
+ if($this->handle->is_account($this->dn)){
+ $this->is_account = true;
+ $tmp = ($this->handle->getComputerInformations($this->dn));
+
+ foreach(array("tech_num","os","FK_glpi_enterprise","type","comments","contact_num") as $attr){
+ $this->$attr = $tmp[0][$attr];
+ }
+ $this->usedDevices = $this->handle->getUsedDevices($tmp[0]['ID']);
+ $atts = $this->handle->getAssignAttachments($tmp[0]['ID']);
+ foreach($atts as $attachment){
+
+ $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc'];
+ }
+ }else{
+ $this->is_account = false;
+ }
+
+ /* set defaults */
+ $this->name = $this->dn;
+ $this->orig_dn = $this->dn;
+ $this->initially_was_account = $this->is_account;
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","all/".get_class($this),$this->dn);
+ }
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ /* Assign smarty defaults
+ To avoid undefined indexes, if there is an error with the glpi db
+ */
+ foreach(array("SystemTypes","SystemTypeKeys","Manufacturers",
+ "OSs","TechnicalResponsibles","InstalledDevices","Attachments","AttachmentKeys",
+ "OSKeys","OSs","ManufacturerKeys","InstalledDeviceKeys") as $attr){
+ $smarty->assign($attr,array());
+ }
+ foreach(array("type","FK_glpi_enterprise","os","tech_num","comments","contact_num","AttachmentsDiv") as $attr){
+ $smarty->assign($attr,"");
+ }
+
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation) {
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ /* Check if there is a glpi database server defined
+ */
+ if(!isset($this->config->data['SERVERS']['GLPI'])){
+ print_red(_("There is no server with valid glpi database service."));
+ return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+ }
+
+ $this->data = $this->config->data['SERVERS']['GLPI'];
+
+ /* Check if we can call mysql_connect
+ If we can't, there is no the mysql-php extension
+ */
+ if(!is_callable("mysql_connect")){
+ print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
+ return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+ }
+
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+
+ /* If handle == false, abort
+ Seems that the server, username and or password is wrong
+ */
+ if(!$this->handle->is_connected){
+ print_red(_("Can't connect to glpi database, check configuration twice."));
+ return($smarty->fetch(get_template_path('glpi.tpl', TRUE)));
+ }
+
+ /* All checks are ok
+ Lets handle Posts, templates etc below ...
+ */
+
+ $users = $this->handle->getUsers();
+ $ldap= $this->config->get_ldap_link();
+
+ /* Check for Trading button Post
+ */
+ if(isset($_POST['Trading'])){
+ print_red(_("This feature is not implemented yet."));
+ }
+
+ /* Check for Software button Post
+ */
+ if(isset($_POST['Software'])){
+ print_red(_("This feature is not implemented yet."));
+ }
+
+ /* Check for Contract button Post
+ */
+ if(isset($_POST['Contracts'])){
+ print_red(_("This feature is not implemented yet."));
+ }
+
+ /* Add Device was requested, open new dialog
+ */
+ if((isset($_POST['AddDevice'])) && ($this->acl_is_writeable("Devices"))){
+ $this->dialog =true;
+ $this->cur_dialog = new glpiDeviceManagement($this->config,$this->dn,$this->usedDevices);
+ }
+
+ /* Attachment pool was closed with use
+ */
+ if(isset($_POST['UseAttachment']) && ($this->acl_is_writeable("Attachments"))){
+ if(count($this->cur_dialog->check())){
+ foreach($this->cur_dialog->check() as $msg){
+ print_red($msg);
+ }
+ }else{
+ $this->cur_dialog->save_object();
+ $this->usedAttachments = $this->cur_dialog->save();
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+ }
+
+ /* Attachment pool was closed with abort
+ */
+ if(isset($_POST['AbortAttachment'])){
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+
+ /* Open Attachment pool to add/edit Attachments
+ */
+ if(isset($_POST['AddAttachment']) && ($this->acl_is_writeable("Attachments"))){
+ $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
+ $this->dialog = true;
+ }
+
+ /* Remove Attachment fro this tab
+ */
+ $once = true;
+ foreach($_POST as $name => $value){
+ if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){
+ $once= false;
+ $name = preg_replace("/^delAttachment_/","",$name);
+ $entry = preg_replace("/_.*$/","",$name);
+ if(isset($this->usedAttachments[$entry])){
+ unset($this->usedAttachments[$entry]);
+ }
+ }
+ }
+ if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && ($this->acl_is_writeable("Attachments"))){
+ foreach($_POST['Attachments'] as $entry){
+ if(isset($this->usedAttachments[$entry])){
+ unset($this->usedAttachments[$entry]);
+ }
+ }
+ }
+
+ /* We have selected some devices and pressed use button
+ */
+ if(isset($_POST['SelectDeviceSave']) && $this->acl_is_writeable("Devices")){
+ $this->cur_dialog->save_object();
+ $this->usedDevices= ($this->cur_dialog->getSelected());
+ $this->cur_dialog = false;
+ $this->dialog = false;
+ $this->edit_type=false;
+ }
+
+ /* Aborted Device selction
+ */
+ if(isset($_POST['SelectDeviceCancel']) && ($this->acl_is_writeable("Devices"))){
+ $this->dialog = false;
+ $this->cur_dialog = false;
+ $this->edit_type=false;
+ }
+
+ /* System type management
+ */
+ if(isset($_POST['edit_type']) && $this->acl_is_writeable("type")){
+ $this->dialog = true;
+ $this->edit_type=true;
+ }
+
+ /* This closes the system type editing dialog
+ */
+ if(isset($_POST['close_edit_type']) && ($this->acl_is_writeable("type"))){
+ $this->edit_type=false;
+ $this->dialog = false;
+ }
+
+ if(isset($_POST['Rename_Cancel'])){
+ $this->renameTypeDialog = false;
+ $this->renameOSDialog = false;
+ }
+
+ /* This appends a new system to our sytem types
+ */
+ if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){
+ $attr = $this->handle->getSystemTypes();
+ if(in_array(trim($_POST['type_string']),$attr)){
+ print_red(_("Adding new sytem type failed, this system type name is already used.")) ;
+ }else{
+ $this->handle->addSystemType(trim($_POST['type_string']));
+ }
+ }
+
+ /* Remove selected type from our system types list
+ */
+ if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){
+ $tmp = $this->handle->is_systemTypeUsed($_POST['select_type']);
+ if(count($tmp)){
+ $names = "";
+ foreach($tmp as $name){
+ $names .= ", ".$name;
+ }
+ $names = preg_replace("/^, /","",$names);
+ $names = trim($names);
+ if(count($tmp) == 3){
+ $names .= " ...";
+ }
+ print_red(sprintf(_("You can't delete this system type, it is still in use by these system(s) '%s'"),$names));
+ }else{
+ $this->handle->removeSystemType($_POST['select_type']);
+ }
+ }
+
+ /* Rename selected system type to given string
+ */
+ if(isset($_POST['Rename_type_OK'])){
+ $attr = $this->handle->getSystemTypes();
+ if(in_array(trim($_POST['string']),$attr)){
+ print_red(_("Rename failed, this system type name is already used.")) ;
+ }else{
+ $this->renameTypeDialog = false;
+ $this->handle->updateSystemType($_POST['string'],trim($this->select_type));
+ }
+ }
+
+
+ if((isset($_POST['rename_type'])&&(!empty($_POST['select_type'])))||($this->renameTypeDialog)){
+ if(isset($_POST['select_type'])){
+ $this->select_type = $_POST['select_type'];
+ }
+ $this->renameTypeDialog = true;
+ $tmp = $this->handle->getSystemTypes();
+
+ $smarty->assign("string",$tmp[$this->select_type]);
+ if(isset($_POST['string'])){
+ $smarty->assign("string",$_POST['string']);
+ }
+ $smarty->assign("Method","rename");
+ $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE));
+ return($display);
+ }
+
+
+
+ /* Someone wants to edit the system 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("SystemTypes", $this->handle->getSystemTypes());
+ $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
+ $display= $smarty->fetch(get_template_path('glpi_edit_type.tpl', TRUE));
+ return($display);
+ }
+
+ /* System os management
+ */
+ if(isset($_POST['edit_os']) && $this->acl_is_writeable("os")){
+ $this->dialog = true;
+ $this->edit_os=true;
+ }
+
+ /* Close Operating system dialog
+ */
+ if(isset($_POST['close_edit_os'])){
+ $this->edit_os=false;
+ $this->dialog = false;
+ }
+
+ /* Add new os to the db
+ */
+ if((isset($_POST['add_os']))&&(!empty($_POST['is_string'])) && $this->acl_is_writeable("os")){
+ $attr = $this->handle->getOSTypes();
+ if(in_array(trim($_POST['is_string']),$attr)){
+ print_red(_("Adding new operating system failed, specifed name is already used.")) ;
+ }else{
+ $this->handle->addOS(trim($_POST['is_string']));
+ }
+ }
+
+ /* Delete selected os from list and db
+ */
+ if((isset($_POST['del_os']))&&(!empty($_POST['select_os'])) && $this->acl_is_writeable("os")){
+ $tmp = $this->handle->is_osUsed($_POST['select_os']);
+
+ if(count($tmp)){
+
+ $names = "";
+ foreach($tmp as $name){
+ $names .= ", ".$name;
+ }
+ $names = preg_replace("/^, /","",$names);
+ $names = trim($names);
+ if(count($tmp) == 3){
+ $names .= " ...";
+ }
+ print_red(sprintf(_("You can't delete this operating system, it is still in use by these system(s) '%s'"),$names));
+
+ }else{
+ $this->handle->removeOS_byID($_POST['select_os']);
+ }
+ }
+
+ /* Rename selected os to given string
+ */
+ if(isset($_POST['Rename_os_OK']) && $this->acl_is_writeable("os")){
+ $attr = $this->handle->getOSTypes();
+ if(in_array(trim($_POST['string']),$attr)){
+ print_red(_("Updating operating system failed, specifed name is already used.")) ;
+ }else{
+ $this->handle->updateOS($_POST['string'],$this->select_type);
+ $this->renameOSDialog = false;
+ }
+ }
+ if((isset($_POST['rename_os'])&&(!empty($_POST['select_os'])))||($this->renameOSDialog)){
+ if(isset($_POST['select_os'])){
+ $this->select_type = $_POST['select_os'];
+ }
+ $this->renameOSDialog = true;
+ $tmp = $this->handle->getOSTypes();
+
+ $smarty->assign("string",$tmp[$this->select_type]);
+ if(isset($_POST['string'])){
+ $smarty->assign("string",$_POST['string']);
+ }
+ $smarty->assign("Method","rename");
+ $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE));
+ return($display);
+ }
+
+ /* Open dialog to edit os types
+ */
+ if($this->edit_os){
+ $smarty->assign("Method","edit");
+ $smarty->assign("OSs", $this->handle->getOSTypes());
+ $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes()));
+ $display= $smarty->fetch(get_template_path('glpi_edit_os.tpl', TRUE));
+ return($display);
+ }
+
+
+
+ /* Show dialog to select a new contact person
+ * Select a contact person
+ */
+ if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){
+ $this->addUser = "contact";
+ $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
+ $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category));
+ $this->cur_dialog->set_acl_base($this->dn);
+
+ }
+
+ /* Open dialog which allows to edit the manufacturers
+ */
+ if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){
+ $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
+ $this->dialog = true;
+ }
+
+ /* Close manufacturer editing dialog
+ */
+ if(isset($_POST['close_edit_manufacturer'])){
+ $this->dialog = false;
+ $this->cur_dialog = false;
+ }
+
+ /* Abort user selection
+ */
+ $smarty->assign("AbortSelectUser","SelectUserCancel");
+ if(isset($_POST['SelectUserCancel'])){
+ $this->dialog = false;
+ $this->addUser ="";
+ $this->cur_dialog = false;
+ }
+
+ /* Selecte technical responsible person
+ */
+ if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){
+ $this->addUser ="tech";
+ $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
+ $this->cur_dialog->set_acl_category(preg_replace("/\//","",$this->acl_category));
+ $this->cur_dialog->set_acl_base($this->dn);
+ }
+
+ /* Technical responsible person selected*/
+ if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")&&(strlen($_GET['id']) > 100)){
+ print_red(sprintf(_("Could not add the given user, the users dn is too long, only 100 characters are allowed here.")));
+
+ }elseif(isset($_GET['act'])&&($_GET['act']=="user_tech_num") && strlen($_GET['id'])){
+
+
+ /* 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 */
+ $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
+ $atr = $ldap->fetch();
+ $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->handle->addUser($tmp,$id);
+ }
+
+ /* Re-read users */
+ $users = ($this->handle->getUsers());
+
+ /* Get user */
+ $tmp = array_flip($users);
+ $id=$tmp[$id];
+
+ /* Use user id, close dialog */
+ if($this->addUser == "tech"){
+ $this->tech_num = $id;
+ }else{
+ $this->contact_num = $id;
+ }
+ $this->cur_dialog = false;
+ $this->dialog= false;
+ }
+
+ /* if( cur_dialog != false || cur_dialog != NULL)
+ * There is a dialog which wants to be displayed
+ */
+ if(isset($this->cur_dialog) && is_object($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;
+ }
+
+ /* Assign smarty defaults */
+ foreach(array("SystemTypes","SystemTypeKeys","Manufacturers","OSs","TechnicalResponsibles","InstalledDevices","Attachments") as $attr){
+ $smarty->assign($attr,array());
+ }
+
+ /* Assign some vars to smarty
+ */
+ foreach(array("type","FK_glpi_enterprise","os","tech_num","contact_num","Attachments","InstalledDevices") as $attr){
+ $smarty->assign($attr,"");
+ }
+
+ /* Do we need to flip is_account state? */
+ if(isset($_POST['modify_state'])){
+ if($this->is_account && $this->acl_is_removeable()){
+ $this->is_account= FALSE;
+ }elseif(!$this->is_account && $this->acl_is_createable()){
+ $this->is_account= TRUE;
+ }
+ }
+
+ /* Show tab dialog headers */
+ if ($this->is_account){
+ $display= $this->show_disable_header(_("Remove inventory"),
+ _("This device has inventory informations enabled. You can disable them by clicking below."));
+ } else {
+ $display= $this->show_enable_header(_("Add inventory"),
+ _("This device has inventory informations disabled. You can enable them by clicking below."));
+ return ($display);
+ }
+
+ /* Assign system types
+ */
+ $smarty->assign("SystemTypeKeys", array_flip($this->handle->getSystemTypes()));
+ $smarty->assign("SystemTypes", $this->handle->getSystemTypes());
+ $smarty->assign("type", $this->type);
+
+ /* Assign os types
+ */
+ $smarty->assign("OSKeys", array_flip($this->handle->getOSTypes()));
+ $smarty->assign("OSs", $this->handle->getOSTypes());
+ $smarty->assign("os", $this->os);
+
+ /* Dispaly installed devices */
+ $smarty->assign("InstalledDevices" ,$this->getDevices());
+ $smarty->assign("InstalledDeviceKeys" ,array_flip($this->getDevices()));
+
+ /* Append manufacturers
+ */
+ $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises()));
+ $smarty->assign("Manufacturers", $this->handle->getEnterprises());
+ $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
+
+ /* Assign used Attachments
+ */
+
+ $divlist = new divSelectBox("glpiAttachmentsList");
+ $divlist-> SetHeight(130);
+ $atts = $this->getUsedAttachments(true);
+ $downlink = "<a href='get_attachment.php?id=%s' target='_blank'>%s</a>";
+ $del_link = "<input type='image' src='images/edittrash.png' name='delAttachment_%s'>";
+ foreach($atts as $id => $attachment){
+ $divlist->AddEntry
+ (
+ array(
+ array("string"=>$attachment['name']),
+ array("string"=>$attachment['mime']),
+ array("string"=>sprintf($downlink,$id,$attachment['filename'])),
+ array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"),
+ )
+ );
+ }
+
+ $smarty->assign("AttachmentsDiv" ,$divlist->DrawList());
+ /* Handle contact person
+ Assign name ... to smarty, if set
+ */
+ if(isset($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]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
+ $smarty->assign("contact_num", $str);
+ }else{
+ $smarty->assign("contact_num", _("N/A"));
+ }
+
+ /* Handle tech person
+ Assign name ... to smarty, if set
+ */
+ if(isset($users[$this->tech_num])){
+ $tr = $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]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
+ $smarty->assign("tech_num", $str);
+ }else{
+ $smarty->assign("tech_num", _("N/A"));
+ }
+ $smarty->assign("comments", $this->comments);
+
+ $display.= $smarty->fetch(get_template_path('glpi.tpl', TRUE));
+ return($display);
+ }
+
+ function remove_from_parent()
+ {
+ /* Cancel if there's nothing to do here */
+ if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){
+ return;
+ }
+ if(function_exists("mysql_pconnect")){
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+ if($this->initially_was_account){
+ $this->handle->removeComputerInformations($this->dn);
+ new log("remove","undefined/".get_class($this),$this->dn);
+ }
+ }else{
+ print_red(_("Can't remove glpi account, while mysql extension is missing."));
+ new log("remove","undefined/".get_class($this),$this->dn,array(),_("Can't remove glpi account, while mysql extension is missing."));
+ }
+
+ }
+
+ function getDevices(){
+ $ret = array();
+ foreach($this->usedDevices as $type => $entries){
+ foreach($entries as $ent){
+ if(isset($ent['designation'])){
+ $ret[] = $ent['designation']." [".$type."]";
+ }else{
+ $ret[] = $ent['name']." [".$type."]";
+ }
+ }
+ }
+ return($ret);
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if(!isset($_POST['glpi_tpl_posted'])) {
+ return ;
+ }
+ plugin::save_object();
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ // if($this->TechnicalResponsible == ""){
+ // $message[] = _("Please select a technical responsible person for this entry.");
+ // }
+
+ return ($message);
+ }
+
+
+ /* Save to LDAP */
+ function save()
+ {
+ if($this->is_account){
+ $attrs = array();
+ $this->date_mod = date("Y-m-d H:i:s");
+ foreach($this->attributes as $attr){
+ $attrs[$attr] = $this->$attr;
+ }
+ $attrs['name'] = $this->dn;
+ unset($attrs['ID']);
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+
+ /* check if we have to update, add */
+ if($this->initially_was_account&&$this->is_account){
+ $this->handle->updateComputerInformations($attrs,$this->orig_dn);
+ new log("modify","undefined/".get_class($this),$this->dn);
+ }elseif($this->is_account){
+ $this->handle->addComputerInformations($attrs,$this->dn);
+ new log("create","undefined/".get_class($this),$this->dn);
+ }
+ $tmp = $this->handle->getComputerInformations($this->dn);
+ $this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']);
+ }
+ }
+
+
+ /* Return used attachments */
+ function getUsedAttachments($divlist = false)
+ {
+ $atts =$this->handle->getAttachments();
+ $ret = array();
+ foreach($atts as $entry){
+ if(in_array($entry['ID'],$this->usedAttachments)){
+ if($divlist){
+ $ret[$entry['ID']] = $entry;
+ }else{
+ $cm ="";
+ if(isset($entry['comment'])){
+ $cm=" [".$entry['comment']."]";
+ }
+ if(isset($entry['mime'])){
+ $cm.=" -".$entry['mime']."";
+ }
+
+ $ret[$entry['ID']]= $entry['name'].$cm;
+ }
+ }
+ }
+ return($ret);
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Glpi"),
+ "plDescription" => _("Inventory extension"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 20,
+ "plSection" => array("administration"),
+ "plCategory" => array("workstation","terminal","component","server","phone") ,
+ "plProvidedAcls"=> array(
+
+ "tech_num" => _("Technical responsible"),
+ "comments" => _("Comment"),
+ "os" => _("Operating system"),
+ "location" => _("Location"),
+ "contact_num" => _("Contact person"),
+ "model" => _("Model"),
+ "type" => _("Type"),
+ "FK_glpi_enterprise" => _("Manufacturer"),
+ "Attachments" => _("Attachments"),
+ "Devices" => _("Peripheral devices"))
+ ));
+ }
+
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiAttachmentPool.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiAttachmentPool.inc
--- /dev/null
@@ -0,0 +1,364 @@
+<?php
+
+class glpiAttachmentPool extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array("name","comment","mime","filename","date_mod");
+ var $objectclasses = array("whatever");
+
+ var $parent;
+ var $edit = false;
+ var $entry = false;
+ var $date_mod ="";
+ var $name ="";
+ var $comment ="";
+ var $mime ="";
+ var $filename ="";
+
+ var $Selected = array();
+
+ var $delAttach= "";
+
+ function glpiAttachmentPool (&$config, $dn= NULL,$used=NULL)
+ {
+ plugin::plugin ($config, $dn);
+ if(!session::is_set('GlpiAttachmentFilter')){
+ session::set('GlpiAttachmentFilter',array("filter"=>"*"));
+ }
+
+ /* Assign used attributes */
+ if($used !== NULL){
+ $this->Selected = $used;
+ }
+ }
+
+ function execute()
+ {
+ plugin::execute();
+ $attach = $this->parent->handle->getAttachments();
+ /* Fill templating stuff */
+ $smarty = get_smarty();
+ $display = "";
+ $only_once = true;
+
+ /* walk through all posted objects */
+ foreach($_POST as $name => $value){
+
+ /* Open dialog to create a new entry */
+ if(preg_match("/new_attach/",$name)){
+ $this->edit = true;
+ $this->entry=array();
+
+ /* Set default values */
+ foreach($this->attributes as $attr) {
+ $this->$attr = "";
+ $this->entry[$attr]="";
+ }
+ }
+
+ /* Remove attach*/
+ if((preg_match("/^delAttach_/",$name))&&($only_once)){
+ $only_once = false;
+ $str = preg_replace("/^delAttach_/","",$name);
+ $str = base64_decode(preg_replace("/_.*$/","",$str));
+
+ /* remove attach from db */
+ $this->delAttach = $str;
+ $smarty->assign("warning", sprintf(_("You're about to delete the glpi attachment component '%s'."), $attach[$str]['name']));
+ return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
+ }
+
+ /* Start editing entry */
+ if((preg_match("/^editAttach_/",$name))&&($only_once)){
+ $only_once = false;
+ $str = preg_replace("/^editAttach_/","",$name);
+ $str = base64_decode(preg_replace("/_.*$/","",$str));
+
+ /* Check if we have an attachment with given ID */
+ foreach($attach as $att ){
+ if($att['ID'] == $str ){
+
+ /* Entry was found, show dialog */
+ $this->edit = true;
+ $this->entry = $att;
+
+ foreach($att as $name => $value){
+ $this->$name = $value;
+ }
+ }
+ }
+ }
+ }
+
+ if((isset($_POST['delete_glpi_confirm']))&&(isset($attach[$this->delAttach]))){
+ if($this->parent->handle->is_attachmentUsed($this->delAttach)){
+ $tmp = $this->parent->handle->is_attachmentUsed($this->delAttach);
+
+ $names = "";
+ foreach($tmp as $name){
+ $names .= ", ".$name;
+ }
+ $names = preg_replace("/^, /","",$names);
+ $names = trim($names);
+ if(count($tmp) == 3){
+ $names .= " ...";
+ }
+ print_red(sprintf(_("You can't delete this attachment, it is still in use by these system(s) '%s'"),$names));
+
+ }else{
+ $this->parent->handle->deleteAttachment($this->delAttach);
+ @unlink(CONFIG_DIR."/glpi/".$this->filename);
+ $attach = $this->parent->handle->getAttachments();
+ }
+ }
+
+ /* Someone tries to upload a file */
+ if(($this->edit == true)&&(isset($_POST['upload']))){
+ if(!isset($_FILES['filename'])){
+ print_red(_("There is no valid file uploaded."));
+ }else{
+ $FILE = $_FILES['filename'];
+ if(!isset($FILE['name'])){
+ print_red(_("There is no valid file uploaded."));
+ }else{
+ if($FILE['error']!=0) {
+ print_red(_("Upload wasn't successfull."));
+ }else{
+ if(!is_dir(CONFIG_DIR."/glpi/")){
+ print_red(sprintf(_("Missing directory '%s/glpi/' to store glpi uploads."),CONFIG_DIR));
+ }else{
+ $filen = CONFIG_DIR."/glpi/".$FILE['name'];
+ if(file_exists($filen)){
+ print_red(_("There is already a file with the same name uploaded."));
+ }else{
+ $fh = fopen($filen,"w");
+ if(!$fh){
+ print_red(sprintf(_("Can't create file '%s'."),$filen));
+ }else{
+ $str = file_get_contents($FILE['tmp_name']);
+ fwrite($fh,$str,strlen($str));
+ fclose($fh);
+ $this->mime = $FILE['type'];
+ $this->filename = $FILE['name'];
+ }
+ } // File already exists
+ }
+ } // Check if any error occurred
+ } // check if valid filename was uploaded
+ } // ende check if file was uploaded
+ }// upload post
+
+ /* save attachment*/
+ if(($this->edit == true)&&(isset($_POST['SaveAttachment']))){
+ if(count($this->check())==0){
+ $this->date_mod = date("Y-m-d H:i:s");
+ $this->save_entry();
+ $this->edit= false;
+ $this->entry = array();
+ $attach = $this->parent->handle->getAttachments();
+ }else{
+ foreach($this->check() as $msg){
+ print_red($msg);
+ }
+ }
+ }
+
+ /* Abort editing/adding attachment*/
+ if(($this->edit == true)&&(isset($_POST['CancelAttachment']))){
+ $this->edit = false;
+ $this->entry = array();
+ }
+
+ /* If edit == true, we have to show a dialog to edit or add an attach
+ */
+ if($this->edit == true){
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,htmlentities(utf8_decode($this->$attr)));
+ }
+ if(!empty($this->filename)){
+ if(is_readable(CONFIG_DIR."/glpi/".$this->filename)){
+ $status =_("File is available.");
+ }else{
+ $status =_("File is not readable, possibly the file is missing.");
+ }
+ }else{
+ $status = _("Currently no file uploaded.");
+ }
+ $smarty->assign("status",$status);
+ return($smarty->fetch(get_template_path('glpiAttachmentEdit.tpl', TRUE)));
+ }
+
+ /* Create list with checkboxes to select / deselect some attachents */
+ $divlist = new divlist("Attachment");
+ $divlist->SetPluginMode();
+ $divlist->SetHeader(array(
+ array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
+ array("string" => _("Name")),
+ array("string" => _("Mime"),"attach"=>"style='width:200px;'"),
+ array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
+
+ $divlist->SetSummary(_("This table displays all available attachments."));
+ $divlist->SetEntriesPerPage(0);
+
+ $editdel = "<input type='image' name='editAttach_%s' src='images/edit.png'>";
+ $editdel.= "<input type='image' name='delAttach_%s' src='images/edittrash.png'>";
+
+ /* Add all given attachments to divlist
+ */
+ foreach($attach as $entry){
+
+ /* Create display name*/
+ if((empty($entry['name']))||(empty($entry['comment']))){
+
+ /* In glpi it is possible to add entries without name
+ so i've added this block
+ */
+ if(empty($entry['name'])){
+ $str1 = "<i>"._("empty")."</i>";
+ }else{
+ $str1 = $entry['name'];
+ }
+
+ if(!empty($entry['comment'])){
+ $str1.= " [".$entry['comment']."]";
+ }
+ }else{
+ /* Both attributes given */
+ $str1 = $entry['name']." [".$entry['comment']."]";
+ }
+
+ $edit = str_replace("%s",base64_encode($entry['ID']),$editdel);
+ $str2 = $entry['mime']." ";
+
+ $chkbox = "<input type='hidden' name='wasOnPage_%s'>".
+ "<input type='checkbox' name='useMe_%s' value='%s' %CHECKED%>";
+
+ if(in_array($entry['ID'],$this->Selected)){
+ $chkbox = preg_replace("/%CHECKED%/"," checked ",$chkbox);
+ }else {
+ $chkbox = preg_replace("/%CHECKED%/"," ",$chkbox);
+ }
+ $chkbox = preg_replace("/%s/",$entry['ID'],$chkbox);
+ $divlist->AddEntry(array(
+ array("string" => $chkbox,
+ "attach" => "style='text-align:center;width:20px;'"),
+ array("string"=> $str1),
+ array("string"=> $str2,"attach"=>"style='width:200px;'"),
+ array("string"=> $edit ,"attach" => "style='width:60px;border-right:0px;text-align:right;'")
+ ));
+
+ }
+
+ $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+ " <input class='center' type='image'
+ src='images/fai_new_template.png' align='middle' title='"._("Create new attachment")."'
+ name='new_attach' alt='"._("New Attachment"). "'> ".
+ "</div>";
+
+ $GlpiAttachmentFilter = session::get('GlpiAttachmentFilter');
+
+ $smarty->assign("attachments", $divlist->DrawList());
+ $smarty->assign("attachmenthead", $listhead);
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
+ $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info_small.png'));
+ $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
+ $smarty->assign("apply", apply_filter());
+ $smarty->assign("alphabet", generate_alphabet());
+ $smarty->assign("attachment_regex", $GlpiAttachmentFilter['filter']);
+
+ $display.= $smarty->fetch(get_template_path('glpiAttachmentPool.tpl', TRUE));
+ return($display);
+ }
+
+ function save()
+ {
+ return($this->Selected);
+ }
+
+ /* Adds new or saves edited entries */
+ function save_entry()
+ {
+ if($this->edit){
+ $tmp = array();
+ foreach($this->attributes as $attr){
+ $tmp[$attr] = $this->$attr;
+ }
+ $id = -1;
+ if(isset($this->entry['ID'])){
+ $id = $this->entry['ID'];
+ }
+ $this->parent->handle->saveAttachments($tmp,$id);
+ }
+ }
+
+ function save_object()
+ {
+ foreach($this->attributes as $attr){
+ if(isset($_POST[$attr])){
+ $this->$attr = $_POST[$attr];
+ }
+ }
+
+ /* Checkboxes are only posted, if they are checked
+ * To check if it was deselected, we check if wasOnPage
+ * was posted with given name, so we can deselect this entry
+ */
+
+ foreach($_POST as $name => $value){
+ if(preg_match("/wasOnPage_/",$name)){
+ $id=preg_replace("/wasOnPage_/","",$name);
+ if(isset($_POST["useMe_".$id])){
+ $this->Selected[$id]=$id;
+ }else{
+ if(isset($this->Selected[$id])){
+ unset($this->Selected[$id]);
+ }
+ }
+ }
+ }
+ }
+
+ /* Simple check */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ if($this->edit){
+
+ /* check if given name is already in use */
+ $att = $this->parent->handle->getAttachments();
+ $ok = true;
+ $this->name=trim($this->name);
+
+ foreach($att as $val){
+ if(!isset($this->entry['ID'])){
+ if($val['name'] == $this->name){
+ $ok = false;
+ }
+ }else{
+ if(($val['name'] == $this->name)&&($this->entry['ID'] != $val['ID'])){
+ $ok = false;
+ }
+ }
+ }
+ if(!$ok){
+ $message[] = _("This name is already in use.");
+ }
+ if(empty($this->name)){
+ $message[] = _("Please specify a valid name for this attachment.");
+ }
+ }
+ return($message);
+ }
+
+}// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiDeviceManagement.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiDeviceManagement.inc
--- /dev/null
@@ -0,0 +1,427 @@
+<?php
+
+class glpiDeviceManagement extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= TRUE;
+ var $attributes= array();
+ var $objectclasses= array("whatever");
+
+ var $devices = array();
+ var $ui;
+
+ var $parent ;
+ var $EditEntry;
+ var $editMode =false;
+
+ var $DeviceAttrs = array();
+ var $AllowedDevices = array();
+
+ var $Selected = array();
+
+ var $delete = array();
+
+ function glpiDeviceManagement (&$config, $dn= NULL,$used=NULL)
+ {
+ plugin::plugin ($config, $dn);
+
+ if(!session::is_set('glpiDeviceRegex')){
+ $tmp['device_regex'] = "*";
+ session::set('glpiDeviceRegex',$tmp);
+ }
+ $this->ui = get_userinfo();
+
+ if(isset($used)){
+ $this->Selected = $used;
+ }
+
+ /* Specify which vars are allowed for a sepcific type of device */
+ $this->DeviceAttrs['case'] = array("designation","format","comment","FK_glpi_enterprise");
+ $this->DeviceAttrs['moboard'] = array("designation","chipset","comment","FK_glpi_enterprise");
+ $this->DeviceAttrs['processor'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['iface'] = array("designation","bandwidth","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['ram'] = array("designation","frequence","comment","FK_glpi_enterprise","specif_default","type");
+ $this->DeviceAttrs['hdd'] = array("designation","rpm","interface","cache","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['drive'] = array("designation","speed","interface","is_writer","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['control'] = array("designation","interface","raid","comment","FK_glpi_enterprise");
+ $this->DeviceAttrs['gfxcard'] = array("designation","ram","interface","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['sndcard'] = array("designation","type","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['power'] = array("designation","power","comment","FK_glpi_enterprise","atx");
+ $this->DeviceAttrs['pci'] = array("designation","comment","FK_glpi_enterprise","specif_default");
+ $this->DeviceAttrs['monitor'] = array("name","comments","serial","otherserial","size",
+ "flags_micro","flags_speaker","flags_subd","flags_bnc",
+ "location","type","FK_glpi_enterprise","is_global","deleted","is_template","tplname");
+
+ $this->AllowedDevices=array("case","moboard","sndcard","processor","iface","ram","hdd","drive","control","gfxcard","power","pci","monitor");
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Get all defined devices */
+ $this->reload();
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ /* this var is used to ensure that every post is only performed once */
+ $only_once = true;
+
+ /* Check Post for some actions */
+ foreach($_POST as $name => $value){
+
+ /* If new_ then we should create an new device */
+ if((preg_match("/^new_/",$name))&&($only_once)){
+
+ /* don't do this twice */
+ $only_once = false;
+
+ /*extract device device_type */
+ $deviceType = preg_replace("/_.*$/","",preg_replace("/^new_/","",$name));
+
+ /* Check if type is allowed, and create empty entry */
+ $tmp = array();
+ if((!isset($this->DeviceAttrs[$deviceType]))||((!in_array($deviceType,$this->AllowedDevices)))){
+ print_red(sprintf(_("Internal Error can't create device of type '%s'"),$deviceType));
+ }else{
+ foreach($this->DeviceAttrs[$deviceType] as $attr){
+ $tmp[$attr] = "";
+ }
+ $tmp['device_type'] = $deviceType;
+ $this->EditEntry = $tmp;
+ $this->editMode =true;
+ }
+ }
+ }
+
+ /* delete was requested ... show dialog */
+ if((isset($_GET['act']))&&($_GET['act']=="del_device")){
+ $id = base64_decode($_GET['id']);
+ $tmp = $this->devices[$id];
+
+ $this->delete = $tmp;
+
+ if(isset($tmp['name'])){
+ $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['name']));
+ }elseif(isset($tmp['designation'])){
+ $smarty->assign("warning", sprintf(_("You're about to delete the glpi device '%s'."), $tmp['designation']));
+ }else{
+ print_red(_("Can't detect object name."));
+ }
+
+ return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
+ }
+
+ /* Delete entry, but check if this device is in currently in use */
+ if(isset($_POST['delete_glpi_confirm'])){
+ if(count($this->parent->handle->is_deviceUsed($this->delete))){
+
+ $tmp = $this->parent->handle->is_deviceUsed($this->delete);
+
+ $names = "";
+ foreach($tmp as $name){
+ $names .= ", ".$name;
+ }
+ $names = preg_replace("/^, /","",$names);
+ $names = trim($names);
+ if(count($tmp) == 3){
+ $names .= " ...";
+ }
+ print_red(sprintf(_("You can't delete this device, it is still in use by these system(s) '%s'"),$names));
+ }else{
+ $this->parent->handle->deleteDevice($this->delete);
+ $this->reload();
+ }
+ }
+
+ /* Open entry for editing if requested */
+ if((isset($_GET['act']))&&($_GET['act']=="edit_device")){
+ $id = base64_decode($_GET['id']);
+ $this->editMode =true;
+ $this->EditEntry = $this->devices[$id];
+ }
+
+ /* Abort editing this entry */
+ if(isset($_POST['AbortDeviceChanges'])){
+ $this->EditEntry = array();
+ $this->editMode = false;
+ }
+
+ /* Save all changes made on currently selected entry */
+ if(isset($_POST['SaveDeviceChanges'])){
+
+ /* First check if all changes made are allowed */
+ if(count($this->check())==0){
+ $this->save();
+ $this->editMode = false;
+ $this->reload();
+ }else{
+ foreach($this->check() as $msg){
+ print_red($msg);
+ }
+ }
+
+ }
+
+ /* Check if we are currently editing something ? */
+ if($this->editMode == true){
+ return ($this->editDevice($this->EditEntry));
+ }
+
+ /* ENDE : GET / POST handling
+ * Below, only output generation for headpage
+ */
+
+ $divlist = new divlist("glpi devices");
+ $divlist->SetPluginMode();
+ $divlist->SetEntriesPerPage(0);
+ $divlist->SetHeader(array(
+ array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
+ array("string" => _("devices"), "attach" => "style=''"),
+ array("string" => _("Actions"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
+
+ $edit = "<a href='?plug=".$_GET['plug']."&act=edit_device&id=%s'>%s</a>";
+ $editdel = "<a href='?plug=".$_GET['plug']."&act=edit_device&id=%s'><img src='images/edit.png' alt='"._("Edit")."' border=0></a>";
+ $editdel.= "<a href='?plug=".$_GET['plug']."&act=del_device&id=%s'><img src='images/edittrash.png' alt='"._("Delete")."' border=0></a>";
+
+ $useDevice = "<input type='hidden' name='wasOnPage_%s' value='%s'><input type='checkbox' value='%s' name='useDevice_%s' %USE%>";
+
+ foreach($this->devices as $key=>$user){
+
+ if(isset($user['designation'])){
+ $str = "designation";
+ }else{
+ $str = "name";
+ }
+
+ if(isset($this->Selected[$user['device_type']][$user[$str]])){
+ $use = " checked ";
+ }else{
+ $use ="";
+ }
+
+ /* Dawn databse struckture ....*/
+ if(empty($user['comment']) && isset($user['comments'])) {
+ $user['comment'] = $user['comments'];
+ }
+
+ $field1 = array("string" => preg_replace("/%s/",base64_encode($key),preg_replace("/%USE%/",$use,$useDevice)), "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($edit,base64_encode($key),$user[$str]." [".$user['comment']."]"), "attach" => "style=''");
+ $field3 = array("string" => sprintf($editdel,base64_encode($key),base64_encode($key)),
+ "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+ $divlist->AddEntry(array($field1,$field2,$field3));
+
+ }
+
+ $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+ " <input class='center' type='image' align='middle'
+ src='images/monitor.png' title='"._("New monitor")."' alt='"._("M")."' name='new_monitor'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/mainboard.png' title='"._("New mainbord")."' alt='"._("MB")."' name='new_moboard'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/processor.png' title='"._("New processor")."' alt='"._("P")."' name='new_processor'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/server.png' title='"._("New case")."' alt='"._("C")."' name='new_case'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/net_hardware.png' title='"._("New network interface")."' alt='"._("NI")."' name='new_iface'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/memory.png' title='"._("New ram")."' alt='"._("R")."' name='new_ram'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/fai_partitionTable.png' title='"._("New hard disk")."' alt='"._("HDD")."' name='new_hdd'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/drives.png' title='"._("New drive")."' alt='"._("D")."' name='new_drive'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/hardware.png' title='"._("New controller")."' alt='"._("CS")."' name='new_control'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/gfx_hardware.png' title='"._("New graphics card")."' alt='"._("GC")."' name='new_gfxcard'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/snd_hardware.png' title='"._("New sound card")."' alt='"._("SC")."' name='new_sndcard'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/power.png' title='"._("New power supply")."' alt='"._("PS")."' name='new_power'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/fai_template.png' title='"._("New misc device")."' alt='"._("OC")."' name='new_pci'> ".
+ "</div>";
+
+ $filter = session::get('glpiDeviceRegex');
+ $smarty->assign("devicehead", $listhead);
+ $smarty->assign("devices", $divlist->DrawList());
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
+ $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info_small.png'));
+ $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
+ $smarty->assign("apply", apply_filter());
+ $smarty->assign("alphabet", generate_alphabet());
+ $smarty->assign("device_regex", $filter['device_regex']);
+
+ $display.= $smarty->fetch(get_template_path('glpiDeviceManagement.tpl', TRUE));
+ return($display);
+ }
+
+ /* Save device to glpi database
+ * If this is a new device, create a new entry, else update this entry
+ */
+ function save()
+ {
+ if($this->parent->handle->deviceExists($this->EditEntry)){
+ $this->parent->handle->updateDevices($this->EditEntry);
+ }else{
+ $this->parent->handle->addDevice($this->EditEntry);
+ }
+
+ }
+
+ /* this only gets all already defined devices */
+ function reload()
+ {
+ $this->devices = $this->parent->handle->getDevices();
+ ksort($this->devices);
+ }
+
+ /* This funtions saves all POST variables.
+ The variable must be in the array $this->EditEntry
+ */
+ function save_object()
+ {
+ foreach($_POST as $name => $value){
+
+ if(preg_match("/wasOnPage_/",$name)){
+ $dN = base64_decode($value);
+
+ $device = $this->devices[$dN];
+ $type = $device['device_type'];
+
+ if(isset($device['designation'])){
+ $str = "designation";
+ }else{
+ $str = "name";
+ }
+
+ if(isset($_POST['useDevice_'.$value])){
+ $this->Selected[$type][$device[$str]] = $device;
+ }else{
+ if(isset($this->Selected[$type][$device[$str]])){
+ unset($this->Selected[$type][$device[$str]]);
+ }
+ }
+ }
+ }
+
+ if(is_array($this->EditEntry)){
+ foreach($this->EditEntry as $name => $value){
+ if(isset($_POST[$name])){
+ $this->EditEntry[$name] = $_POST[$name];
+ }
+
+ }
+ }
+ }
+
+ /* returns the selected devices */
+ function getSelected()
+ {
+ return($this->Selected);
+ }
+
+ /* This function checks all created devices.
+ If you wan't to use device specific checks,
+ use >>if($attr['device_type']=="moboard")<< to create a device type depending check
+ */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ $attr = $this->EditEntry;
+
+ if(isset($attr['designation'])){
+ $str2 = "designation";
+ }else{
+ $str2 = "name";
+ }
+ if(empty($attr[$str2])){
+ $message[]=(_("You have to specify a valid name for this device."));
+ }
+
+ /* Avoid same name twice */
+ $devices = ($this->parent->handle->getDevices());
+ foreach($devices as $dev){
+
+ /* Some devices use designation some name for name
+ */
+ if(isset($dev['designation'])){
+ $str = "designation";
+ }else{
+ $str = "name";
+ }
+
+ if($dev[$str]==$attr[$str2]){
+
+ /* Entries with ['ID'] already exists, and are only edited, if ID is missing we are currently creating a new entry */
+ if(isset($attr['ID'])){
+ if(!(($dev['ID'] == $attr['ID'])&&($dev['device_type']==$attr['device_type']))){
+ $message[] = _("This device name is already in use.");
+ }
+ }else{
+ $message[] = _("This device name is already in use.");
+ }
+ }
+ }
+
+ return($message);
+ }
+
+ /* This functions displays the template for all available devices
+ * This function is also used if we create a new device
+ */
+ function editDevice($entry)
+ {
+ $smarty = get_smarty();
+
+ /* Transfer given data to smarty */
+ foreach($this->EditEntry as $name => $value){
+ $smarty->assign($name,htmlentities(utf8_decode($value)));
+ }
+
+ /* Set default select boxes, manufacturers ... */
+ $smarty->assign("device_type",$entry['device_type']);
+
+ $none = array(0 => _("none"));
+ $manufacturer = array_merge($none,$this->parent->handle->getEnterprises());
+
+ $ramtypes = $this->parent->handle->getRAMTypes();
+
+ $smarty->assign("RAMtypes", $ramtypes);
+ $smarty->assign("RAMtypeKeys", array_flip($ramtypes));
+
+ $deviceControlTypes = array_merge($none,$this->parent->handle->getGlpiDeviceControlTypes());
+
+ $smarty->assign("HDDInterfaceKeys",array_flip($deviceControlTypes));
+ $smarty->assign("HDDInterfaces" , $deviceControlTypes);
+
+ $gfxControlTypes = array("0"=>_("None"),"AGP"=>"AGP","PCI"=>"PCI","PCI-X"=>"PCI-X","Other"=>_("Other"));
+
+ $smarty->assign("GFXInterfaceKeys",array_flip($gfxControlTypes));
+ $smarty->assign("GFXInterfaces" , $gfxControlTypes);
+
+ $smarty->assign("FK_glpi_enterpriseKeys",array_flip($manufacturer));
+ $smarty->assign("FK_glpi_enterprises", $manufacturer);
+
+ $smarty->assign("formats",array("Large","Medium","Micro"));
+ $smarty->assign("formats",array("Large","Medium","Micro"));
+
+ $smarty->assign("formats",array("Large","Medium","Micro"));
+ $smarty->assign("formatKeys",array('Grand','Moyen','Micro'));
+ return($smarty->fetch(get_template_path('glpi_devices.tpl', TRUE)));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiManufacturer.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiManufacturer.inc
--- /dev/null
@@ -0,0 +1,170 @@
+<?php
+
+class glpiManufacturer extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= TRUE;
+ var $attributes= array("name","type","address","website","phonenumber","comments","deleted","fax","email");
+ var $objectclasses= array("whatever");
+
+ var $ui;
+
+ var $editMode = false;
+ var $Edit_Add = "edit";
+
+ var $name ="";
+ var $type ="";
+ var $address ="";
+ var $website ="";
+ var $phonenumber="";
+ var $comments ="";
+ var $deleted ="";
+ var $fax ="";
+ var $email ="";
+ var $ID =-1;
+
+ function glpiManufacturer(&$config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin ($config, $dn, $parent);
+ $this->ui = get_userinfo();
+ }
+
+ function execute()
+ {
+ plugin::execute();
+ $smarty = get_smarty();
+ $display = "";
+
+ /* Remove enterprise from db */
+ if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){
+
+ $tmp = $this->parent->handle->is_manufacturerUsed($_POST['manufacturer']);
+ if(count($tmp)){
+
+ $names = "";
+ foreach($tmp as $name){
+ $names .= ", ".$name;
+ }
+ $names = preg_replace("/^, /","",$names);
+ $names = trim($names);
+ if(count($tmp) == 3){
+ $names .= " ...";
+ }
+ print_red(sprintf(_("You can't delete this manufacturer, it is still in use by these system(s) '%s'"),$names));
+ }else{
+ $this->parent->handle->removeEnterprise($_POST['manufacturer']);
+ }
+ }
+
+ /* Add new Manufactuer : Open dialog with empty fields */
+ if(isset($_POST['add_manu'])){
+ $this->editMode = true;
+ $this->Edit_Add = "add";
+ foreach($this->attributes as $atr){
+ $this->$atr = "";
+ }
+ }
+
+ /* Edit existing manuatctuerer data */
+ if((isset($_POST['edit_manu']))&&(isset($_POST['manufacturer']))){
+ $this->editMode = true;
+ $this->Edit_Add = "edit";
+ $tmp = $this->parent->handle->getEnterprise($_POST['manufacturer']);
+ $tmp = $tmp[0];
+ foreach($this->attributes as $atr){
+ $this->$atr = "";
+ }
+ foreach($this->attributes as $atr){
+ if(isset($tmp[$atr])){
+ $this->$atr = $tmp[$atr];
+ }
+ }
+ $this->ID = $_POST['manufacturer'];
+ }
+
+ /* close Dialog without saving */
+ if(isset($_POST['close_manufacturer'])){
+ $this->editMode=false;
+ }
+
+ /* close dialog an save all changes / adds */
+ if(isset($_POST['save_manufacturer'])){
+ $tmp = array();
+ foreach($this->attributes as $attrs){
+ $tmp[$attrs]=$this->$attrs;
+ }
+
+ $allok = true;
+ if(empty($tmp['name'])){
+ print_red(_("Please specify a name."));
+ $allok = false;
+ }
+
+ $attr = $this->parent->handle->getEnterprises();
+
+ if($this->ID == -1 ){
+ if(in_array($tmp['name'],$attr)){
+ $allok = false;
+ print_red(_("Specified name is already in use, please choose another one."));
+ }
+ }else{
+ unset($attr[$this->ID]);
+ if(in_array($tmp['name'],$attr)){
+ $allok = false;
+ print_red(_("Specified name is already in use, please choose another one."));
+ }
+ }
+
+ /* all checks are ok , so save changes */
+ if($allok){
+ if($this->Edit_Add == "add"){
+ $this->parent->handle->addEnterprise($tmp);
+ $this->editMode=false;
+ }else{
+ $this->parent->handle->updateEnterprise($tmp,$this->ID);
+ $this->editMode=false;
+ }
+ }
+ }
+
+ /* As long as this war is true, we have to display the edit dialog */
+ if($this->editMode == true){
+ $this->save_object();
+ foreach($this->attributes as $attrs){
+ $smarty->assign($attrs,$this->$attrs);
+ }
+
+ $display.= $smarty->fetch(get_template_path('glpiManufacturerAdd.tpl', TRUE));
+ return($display);
+ }
+
+
+ $smarty->assign("Manus", $this->parent->handle->getEnterprises());
+ $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprises()));
+ $display.= $smarty->fetch(get_template_path('glpiManufacturer.tpl', TRUE));
+ return($display);
+ }
+
+ /* Save to LDAP */
+ function save()
+ {
+ }
+
+ function save_object()
+ {
+ foreach($this->attributes as $attr){
+ if(isset($_POST[$attr])){
+ $this->$attr = stripslashes($_POST[$attr]);
+ }
+ }
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiPrinterAccount.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiPrinterAccount.inc
--- /dev/null
@@ -0,0 +1,807 @@
+<?php
+
+class glpiPrinterAccount extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= FALSE;
+ var $attributes= array("ID","name","contact","ramSize","flags_serial","flags_par","flags_usb",
+ "tech_num","comments","date_mod","location","domain","network","contact_num","serial","otherserial",
+ "type","is_template","FK_glpi_enterprise","deleted");
+
+ var $ID ; // Is set if this entry is edited
+ var $name = ""; // This should be the dn of this entry
+ var $FK_glpi_enterprise = 0; // Manufacturer id
+ var $tech_num = ""; // Technical responsible person
+ var $contact_num = ""; // Contact person
+
+ var $comments = ""; // Comment
+
+ var $type = 0; // printer type id
+ var $serial = "";
+ var $otherserial = "";
+ var $ramSize = 0;
+ var $flags_serial = false;
+ var $flags_par = false;
+ var $flags_usb = false;
+
+ var $date_mod = ""; // Modification timestamp
+
+ var $location = 0; // Not used yet
+ var $domain = 0; // ? Set to 0
+ var $network = 0; // ? Set to 0
+
+ var $is_template = 0; // Used as template ?
+ 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 $objectclasses= array("whatever");
+
+ /* Used to remember if this was an account (simply: is this an edited entry) */
+ var $initially_was_account = false;
+
+ /* Remember current dialog */
+ var $edit_type = false;
+ var $edit_os = false;
+
+ var $data;
+ var $handle = NULL; // Glpi class handle used to query database
+
+ var $cur_dialog = NULL; // This contains the sub dialog handle
+
+ var $orig_dn; // To check if dn, has changed
+ var $ui; // Some GOsa specific user informations
+
+ var $usedDevices = array(); // Which devices are currently selected
+ var $usedAttachments = array(); // Used Attachments
+ var $usedCartridges = array(); // Used Cartridges
+
+ var $view_logged = FALSE;
+
+ /* Contructor
+ Sets default values and checks if we already have an existing glpi account
+ */
+ function glpiPrinterAccount (&$config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin ($config, $dn, $parent);
+ $this->ui= get_userinfo();
+
+ $this->is_account = false;
+
+ /* Abort class construction, if no db is defined */
+ if(!isset($this->config->data['SERVERS']['GLPI'])){
+ return;
+ }
+
+ // Get informations about databse connection
+ $this->data = $this->config->data['SERVERS']['GLPI'];
+
+ // Abort if mysql extension is missing
+ if(!is_callable("mysql_connect")){
+ return;
+ }
+
+ // Create handle of glpi class, and check if database connection is established
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+
+ if(!$this->handle->is_connected){
+ return;
+ }
+
+ // If this dn is already used in database, then get all informations for this entry
+ if($this->handle->is_printer_account($this->dn)){
+ $this->is_account = true;
+ $tmp = ($this->handle->getPrinterInformations($this->dn));
+
+ foreach(array("tech_num","FK_glpi_enterprise","type","comments","contact_num","flags_serial","flags_par","flags_usb","ramSize") as $attr){
+ $this->$attr = $tmp[0][$attr];
+ }
+
+ $atts = $this->handle->getAssignPrinterAttachments($tmp[0]['ID']);
+ foreach($atts as $attachment){
+ $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc'];
+ }
+
+ $cart= $this->handle->getUsedCartridges($tmp[0]['ID']);
+ foreach($cart as $key => $cartridge){
+ $this->usedCartridges[$key]=$cartridge;
+ $this->usedCartridges[$key]['status']="exists";
+ }
+
+
+ }else{
+ $this->is_account = false;
+ }
+
+ /* set defaults */
+ $this->name = $this->dn;
+ $this->orig_dn = $this->dn;
+ $this->initially_was_account = $this->is_account;
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","printer/".get_class($this),$this->dn);
+ }
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ $smarty->assign("CartridgesACL",$this->getacl("Cartridges"));
+
+ /* Assign smarty defaults
+ To avoid undefined indexes, if there is an error with the glpi db
+ */
+ foreach(array("PrinterTypeKeys","PrinterTypes","ManufacturerKeys","Manufacturers",
+ "Attachments","AttachmentKeys","CartridgeKeys","Cartridges") as $attr){
+ $smarty->assign($attr,array());
+ }
+ foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","comments","flags_serial","flags_par","flags_usb","AttachmentsDiv") as $attr){
+ $smarty->assign($attr,"");
+ }
+
+ /* Assign acls */
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+
+ /* Check if there is a glpi database server defined
+ */
+ if(!isset($this->config->data['SERVERS']['GLPI'])){
+ print_red(_("There is no server with valid glpi database service."));
+ return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
+ }
+
+ $this->data = $this->config->data['SERVERS']['GLPI'];
+
+ /* Check if we can call mysql_connect
+ If we can't, there is no the mysql-php extension
+ */
+ if(!is_callable("mysql_connect")){
+ print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
+ return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
+ }
+
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+
+ /* If handle == false, abort
+ Seems that the server, username and or password is wrong
+ */
+ if(!$this->handle->is_connected){
+ print_red(_("Can't connect to glpi database, check configuration twice."));
+ return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
+ }
+
+ /* All checks are ok
+ Lets handle Posts, templates etc below ...
+ */
+
+ $users = $this->handle->getUsers();
+ $ldap= $this->config->get_ldap_link();
+
+
+ /* ##########################################################################
+ * Some tab management
+ */
+
+ /* Do we need to flip is_account state? */
+ if(isset($_POST['modify_state'])){
+ if($this->is_account && $this->acl_is_removeable()){
+ $this->is_account= FALSE;
+ }elseif(!$this->is_account && $this->acl_is_createable()){
+ $this->is_account= TRUE;
+ }
+ }
+
+ /* Show tab dialog headers */
+ if ($this->is_account){
+ $display= $this->show_disable_header(_("Remove inventory"),
+ _("This server has inventory features enabled. You can disable them by clicking below."));
+ } else {
+ $display= $this->show_enable_header(_("Add inventory"),
+ _("This server has inventory features disabled. You can enable them by clicking below."));
+ return ($display);
+ }
+
+
+ /* ##########################################################################
+ * Printer type management
+ * Dialog
+ */
+
+ /* Rename was requested */
+ if(isset($_POST['Rename_PType_OK']) && $this->acl_is_writeable("type")){
+ $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']) && $this->acl_is_writeable("type")){
+ $this->dialog = true;
+ $this->edit_type=true;
+ }
+
+ /* This closes the printer type editing dialog
+ */
+ if(isset($_POST['close_edit_type'])){
+ $this->edit_type=false;
+ $this->dialog = false;
+ }
+
+ /* This appends a new printer to our sytem types
+ */
+ if((isset($_POST['add_type']))&&(!empty($_POST['type_string'])) && $this->acl_is_writeable("type")){
+
+ $tmp = $this->handle->getPrinterTypes();
+ $allok = true;
+ foreach($tmp as $id => $name){
+ if(trim($name) == trim($_POST['type_string'])){
+ $allok = false;
+ }
+ }
+ if($allok){
+ $this->handle->addPrinterType($_POST['type_string']);
+ }else{
+ print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['type_string']));
+ }
+ }
+
+ /* Remove selected type from our printer types list
+ */
+ if((isset($_POST['del_type']))&&(!empty($_POST['select_type'])) && $this->acl_is_writeable("type")){
+ $tmp = $this->handle->is_printerTypeUsed($_POST['select_type']);
+ if(count($tmp)){
+ $str = "";
+ foreach($tmp as $id => $name){
+ $str .= $name.", ";
+ }
+ $str = preg_replace("/, $/","",$str);
+ print_red(sprintf(_("Can't delete printer type, it is still in use by '%s'."),$str));
+ }else{
+ $this->handle->removePrinterType($_POST['select_type']);
+ }
+ }
+
+ /* Rename selected printer type to given string
+ */
+ if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename) && $this->acl_is_writeable("type")){
+ $this->rename = true;
+
+ $smarty->assign("Method","rename");
+
+ $tmp = $this->handle->getPrinterTypes();
+
+ 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){
+ $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));
+ return($display);
+ }
+
+
+ /* ##########################################################################
+ * Edit manufacturers
+ * Dialog
+ */
+
+ /* Open dialog which allows to edit the manufacturers
+ */
+ if(isset($_POST['edit_manufacturer']) && $this->acl_is_writeable("FK_glpi_enterprise")){
+ $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
+ $this->dialog = true;
+ $this->editManufacturer =true;
+ }
+
+ /* Close manufacturer editing dialog
+ */
+ if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){
+ $this->dialog = false;
+ $this->cur_dialog = false;
+ $this->editManufacturer=false;
+ }
+
+
+ /* ##########################################################################
+ * Technical responsible person
+ * Contact person
+ * Dialog
+ */
+
+ /* Show dialog to select a new contact person
+ * Select a contact person
+ */
+ if(isset($_POST['SelectContactPerson']) && $this->acl_is_writeable("contact_num")){
+ $this->addUser = "contact";
+ $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
+ }
+
+ /* Selecte technical responsible person
+ */
+ if(isset($_POST['SelectTechPerson']) && $this->acl_is_writeable("tech_num")){
+ $this->addUser ="tech";
+ $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
+ }
+
+ /* Abort user selection
+ */
+ $smarty->assign("AbortSelectUser","SelectUserCancel");
+ if(isset($_POST['SelectUserCancel'])){
+ $this->dialog = false;
+ $this->addUser ="";
+ $this->cur_dialog = false;
+ }
+
+ /* Technical responsible/contact person selected */
+ if(isset($_GET['act'])&&($_GET['act']=="user_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 */
+ $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
+ $atr = $ldap->fetch();
+ $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->handle->addUser($tmp,$id);
+ }
+
+ /* Re-read users */
+ $users = ($this->handle->getUsers());
+
+ /* Get user */
+ $tmp = array_flip($users);
+ $id=$tmp[$id];
+
+ /* Use user id, close dialog */
+ if($this->addUser == "tech"){
+ $this->tech_num = $id;
+ }else{
+ $this->contact_num = $id;
+ }
+ $this->cur_dialog = false;
+ $this->dialog= false;
+ }
+
+
+ /* ##########################################################################
+ * Handle attachments
+ */
+
+ /* Attachment pool was closed with use
+ */
+ if(isset($_POST['UseAttachment']) && $this->acl_is_writeable("Attachments")){
+ if(count($this->cur_dialog->check())){
+ foreach($this->cur_dialog->check() as $msg){
+ print_red($msg);
+ }
+ }else{
+ $this->cur_dialog->save_object();
+ $this->usedAttachments = $this->cur_dialog->save();
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+ }
+
+ /* Attachment pool was closed with abort
+ */
+ if(isset($_POST['AbortAttachment'])){
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+
+ /* Open Attachment pool to add/edit Attachments
+ */
+ if(isset($_POST['AddAttachment']) && $this->acl_is_writeable("Attachments")){
+ $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
+ $this->dialog = true;
+ }
+
+ /* Remove Attachment from this tab
+ */
+ $once = true;
+ foreach($_POST as $name => $value){
+ if((preg_match("/^delAttachment_/",$name))&&($once) && $this->acl_is_writeable("Attachments")){
+ $once= false;
+ $name = preg_replace("/^delAttachment_/","",$name);
+ $entry = preg_replace("/_.*$/","",$name);
+ if(isset($this->usedAttachments[$entry])){
+ unset($this->usedAttachments[$entry]);
+ }
+ }
+ }
+ if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments'])) && $this->acl_is_writeable("Attachments")){
+ if(isset($this->usedAttachments[$_POST['Attachments']])){
+ unset($this->usedAttachments[$_POST['Attachments']]);
+ }
+ }
+
+ /* ##########################################################################
+ * Printer Cartridge handling
+ */
+
+ /* Abort cartridge select dialog
+ */
+ if(isset($_POST['SelectCartridgeCancel'])){
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+
+ /* Get selected cartridges and add them to our list
+ */
+ if(isset($_POST['SelectCartridgeSave'])){
+ $this->cur_dialog->save_object();
+ $carts = $this->cur_dialog->save();
+ foreach($carts as $cart){
+ $cart['status'] = "new";
+ $this->usedCartridges[] = $cart;
+ }
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+
+ /* Remove cartridge
+ */
+ if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges'])) && $this->acl_is_writeable("ManageCartridges")){
+
+ foreach($_POST['Cartridges'] as $cartID){
+
+ if(isset($this->usedCartridges[$cartID])){
+ if($this->usedCartridges[$cartID]['status'] == "exists"){
+ $this->usedCartridges[$cartID]['status'] = "deleted";
+ }else{
+ unset($this->usedCartridges[$cartID]);
+ }
+ }
+ }
+ }
+
+ /* Open Attachment pool to add/edit Attachments
+ */
+ if(isset($_POST['AddCartridge']) && $this->acl_is_writeable("ManageCartridges")){
+ $this->cur_dialog = new glpiPrinterCartridges($this->config,$this->dn,$this->type);
+ $this->dialog = true;
+ }
+
+
+ /* ##########################################################################
+ * Draw Dialogs
+ */
+ /* if( cur_dialog != false || cur_dialog != NULL)
+ * There is a dialog which wants to be displayed
+ */
+ if($this->cur_dialog && is_object($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;
+ }
+
+
+ /* ##########################################################################
+ * Assign listbox / checkbox .... values to smarty
+ */
+ /* Assign smarty defaults */
+ foreach(array("PrinterTypes","PrinterTypeKeys","Manufacturers","TechnicalResponsibles","Attachments","Cartridges") as $attr){
+ $smarty->assign($attr,array());
+ }
+
+ /* Assign some vars to smarty
+ */
+ foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","flags_serial","flags_par","flags_usb") as $attr){
+ $smarty->assign($attr,"");
+ }
+
+ $smarty->assign("comments", $this->comments);
+ $smarty->assign("flags_serial", $this->flags_serial);
+ $smarty->assign("flags_par", $this->flags_par);
+ $smarty->assign("flags_usb", $this->flags_usb);
+
+ /* Assign system types
+ */
+ $smarty->assign("PrinterTypes", $this->handle->getPrinterTypes());
+ $smarty->assign("PrinterTypeKeys", array_flip($this->handle->getPrinterTypes()));
+ $smarty->assign("type", $this->type);
+
+ /* Append manufacturers
+ */
+ $smarty->assign("ManufacturerKeys", array_flip($this->handle->getEnterprises()));
+ $smarty->assign("Manufacturers", $this->handle->getEnterprises());
+ $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
+
+ /* Assign used Attachments
+ */
+
+ $divlist = new divSelectBox("glpiAttachmentsList");
+ $divlist-> SetHeight(120);
+ $atts = $this->getUsedAttachments(true);
+ $downlink = "<a href='get_attachment.php?id=%s' target='_blank'>%s</a>";
+ $del_link = "<input type='image' src='images/edittrash.png' name='delAttachment_%s'>";
+ foreach($atts as $id => $attachment){
+ $divlist->AddEntry
+ (
+ array(
+ array("string"=>$attachment['name']),
+ array("string"=>$attachment['mime']),
+ array("string"=>sprintf($downlink,$id,$attachment['filename'])),
+ array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"),
+ )
+ );
+ }
+
+ $smarty->assign("AttachmentsDiv" ,$divlist->DrawList());
+ $smarty->assign("Attachments", $this->getUsedAttachments());
+ $smarty->assign("AttachmentKeys", array_flip($this->getUsedAttachments()));
+
+ /* Assign Cartridges
+ */
+ $smarty->assign("Cartridges", $this->getUsedCartridges());
+ $smarty->assign("CartridgeKeys", $this->getUsedCartridges(true));
+
+ /* ##########################################################################
+ * Assign contact and technical responsible person
+ */
+ if(isset($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]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
+ $smarty->assign("contact_num", $str);
+ }else{
+ $smarty->assign("contact_num", _("N/A"));
+ }
+
+ /* Handle tech person
+ Assign name ... to smarty, if set
+ */
+ if(isset($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]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
+ $smarty->assign("tech_num", $str);
+ }else{
+ $smarty->assign("tech_num", _("N/A"));
+ }
+
+ /* If theres a cartridge selected, you can't change the printer type.
+ */
+ $disp = true;
+
+ foreach($this->usedCartridges as $cart){
+ if($cart['status'] != "deleted"){
+ $disp = false;
+ }
+ }
+ if($disp==false){
+ $smarty->assign("typeACL", $this->getacl("type",true));
+ }
+
+ $display.= $smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE));
+ return($display);
+ }
+
+ function remove_from_parent()
+ {
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+ if($this->initially_was_account){
+ $this->handle->removePrinterInformations($this->dn);
+ new log("remove","printer/".get_class($this),$this->dn);
+ }
+ }
+
+
+ /* Save data to object */
+ function save_object()
+ {
+ if(isset($_POST['glpiPrinterFlagsPosted'])){
+ plugin::save_object();
+ foreach($this->attributes as $attrs){
+ if(isset($_POST[$attrs])){
+ $this->$attrs = $_POST[$attrs];
+ }
+ }
+
+ if(isset($_POST['FK_glpi_enterprise']) && $this->acl_is_writeable("FKglpienterprise")){
+ $this->FK_glpi_enterprise = $_POST['FK_glpi_enterprise'];
+ }
+
+ foreach(array("flags_serial","flags_par","flags_usb") as $checkboxes){
+ if($this->acl_is_writeable($checkboxes)){
+ if(isset($_POST[$checkboxes])){
+ $this->$checkboxes = 1;
+ }else{
+ $this->$checkboxes = 0;
+ }
+ }
+ }
+ }
+
+ }
+
+
+ /* Check supplied data */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ // if($this->TechnicalResponsible == ""){
+ // $message[] = _("Please select a technical responsible person for this entry.");
+ // }
+
+ return ($message);
+ }
+
+ /* Save to LDAP */
+ function save()
+ {
+ if($this->is_account){
+ $attrs = array();
+ $this->date_mod = date("Y-m-d H:i:s");
+ foreach($this->attributes as $attr){
+ $attrs[$attr] = $this->$attr;
+ }
+ $attrs['name'] = $this->dn;
+ unset($attrs['ID']);
+ $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
+ if($this->initially_was_account&&$this->is_account){
+ $this->handle->updatePrinterInformations($attrs,$this->dn);
+ new log("modify","printer/".get_class($this),$this->dn);
+ }elseif($this->is_account){
+ $this->handle->addPrinterInformations($attrs,$this->dn);
+ new log("create","printer/".get_class($this),$this->dn);
+ }
+ $tmp = $this->handle->getPrinterInformations($this->dn);
+ $this->handle->addAttachmentsToPrinter($this->usedAttachments,$tmp[0]['ID']);
+
+ foreach($this->usedCartridges as $cart){
+ if($cart['status'] == "deleted"){
+ $this->handle->removeCartridgeFromPrinter($cart['ID']);
+ }elseif($cart['status'] == "new"){
+ $this->handle->addCartridgeFromPrinter($tmp[0]['ID'],$cart['type_ID']);
+ }
+ }
+ }
+ }
+
+ /* Return used attachments */
+ function getUsedAttachments($divlist = false)
+ {
+ $atts =$this->handle->getAttachments();
+ $ret = array();
+ foreach($atts as $entry){
+ if(in_array($entry['ID'],$this->usedAttachments)){
+ if($divlist){
+ $ret[$entry['ID']] = $entry;
+ }else{
+ $cm ="";
+ if(isset($entry['comment'])){
+ $cm=" [".$entry['comment']."]";
+ }
+ if(isset($entry['mime'])){
+ $cm.=" -".$entry['mime']."";
+ }
+
+ $ret[$entry['ID']]= $entry['name'].$cm;
+ }
+ }
+ }
+ return($ret);
+ }
+
+ function getUsedCartridges($flip = false)
+ {
+ $ret = array();
+ foreach($this->usedCartridges as $key => $value){
+ if($value['status'] == "deleted") continue;
+ if($flip){
+ $ret[$key] = $key;
+ }else{
+ $ret[$key] = $value['name']." [".$value['type_name']."] "._("since")." :".$value['date_use'];
+ }
+ }
+ return($ret);
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Glpi"),
+ "plDescription" => _("Printer inventory extension"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 10,
+ "plSection" => array("administration"),
+ "plCategory" => array("printer"),
+
+ "plProvidedAcls"=> array(
+ "flags_serial" => _("Supports serial interface"),
+ "flags_par" => _("Supports parallel interface"),
+ "flags_usb" => _("Supports usb interface"),
+ "tech_num" => _("Technical responsible"),
+ "comments" => _("Comments"),
+ "location" => _("Location"),
+ "contact_num" => _("Contact person"),
+ "type" => _("Type"),
+ "FKglpienterprise" => _("Manufacturer"),
+
+ "Attachments" => _("Attachments"),
+
+ "ManageCartridges" => _("Cartridge settings"))
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiPrinterCartridges.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiPrinterCartridges.inc
--- /dev/null
@@ -0,0 +1,298 @@
+<?php
+
+class glpiPrinterCartridges extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array();
+ var $objectclasses = array("whatever");
+
+ var $parent = NULL; // Contains parent class, to access glpi db handle
+ var $usedCartridges = array(); // IDs of used cartridges for this printer
+ var $PrinterType = 0; // Specifies which cartridge types are available
+
+ var $cur_dialog = false;
+ var $cur_sub_dialog = false;
+
+ var $editManufacturer = false;
+ var $del = 0;
+
+
+ function glpiPrinterCartridges (&$config,$dn,$type)
+ {
+ plugin::plugin ($config, $dn);
+
+ /* Assign some basic settings */
+ $this->ui = get_userinfo();
+ if(!session::is_set('glpiCartridgeRegex')){
+ session::set('glpiCartridgeRegex',"*");
+ }
+
+ /* Only display cartridges for this type of printer */
+ $this->PrinterType = $type;
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+ $display ="";
+ $smarty = get_smarty();
+ $filter = session::get('glpiCartridgeRegex');
+
+ /* Filter settings, remove double* */
+ if(isset($_GET['search'])){
+ $filter = preg_replace("/\*\**/","*",$_GET['search']."*");
+ }elseif(isset($_POST['cartridge_regex'])){
+ $filter = preg_replace("/\*\**/","*",$_POST['cartridge_regex']);
+ }
+ if(empty($filter)) {
+ $filter = "*";
+ }
+ session::set('glpiCartridgeRegex',$filter);
+
+ /* Open dialog which allows to edit the manufacturers
+ */
+ if(isset($_POST['edit_manufacturer_cartridges'])){
+ $this->cur_sub_dialog = new glpiManufacturer($this->config,$this->dn);
+ $this->dialog = true;
+ $this->editManufacturer =true;
+ }
+
+ /* Close manufacturer editing dialog
+ */
+ if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){
+ $this->dialog = false;
+ $this->cur_sub_dialog = false;
+ $this->editManufacturer=false;
+ }
+
+ /* Check poted vars and do the requested job, but only once */
+ $only_once = true;
+ foreach($_POST as $name => $value){
+
+ /* We have to create a new cartridge */
+ if(preg_match("/^newcartridge/",$name)&&($only_once)){
+ $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType);
+ $only_once = false;
+ }
+ }
+
+ /* Edit cartridge */
+ if(isset($_GET['act'])&&$_GET['act']=="edit_cartridge"){
+ $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id']));
+ $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$_GET['id']]);
+ }
+
+ /* remove cartridge */
+ if(isset($_GET['act'])&&$_GET['act']=="del_cartridge"){
+ /* remove attach from db */
+ $this->del = $_GET['id'];
+ $val = ($this->parent->handle->getCartridgeTypeInformations($_GET['id']));
+ $smarty->assign("warning", sprintf(_("You're about to delete the glpi cartridge type '%s'."), $val[$this->del]['name']));
+ return($smarty->fetch(get_template_path('remove_glpi.tpl', TRUE)));
+ }
+
+ if(isset($_POST['delete_cancel'])){
+ $this->del = false;
+ }
+
+ /* Delete this entry */
+ if(isset($_POST['delete_glpi_confirm'])&&($this->del)) {
+ $tmp = $this->parent->handle->is_cartridgeTypeUsed($this->del);
+ if(count($tmp)){
+
+ $str = "";
+ foreach($tmp as $id => $name){
+ $str .= $name.", ";
+ }
+ $str = preg_replace("/, $/","",$str);
+
+ print_red(sprintf(_("You can't delete this cartridge type, it is still in use by this printer(s) '%s'."),$str));
+ }else{
+ $val = ($this->parent->handle->getCartridgeTypeInformations($this->del));
+ $this->cur_dialog = new glpiPrinterCartridgesEdit($this->config,$this->dn,$this->PrinterType,$val[$this->del]);
+ $this->cur_dialog->parent = $this->parent;
+ $this->cur_dialog->remove_from_parent();
+ $this->cur_dialog= false;
+ }
+ }
+
+ /* Abort edit / add dialog */
+ if(isset($_POST['CancelCartridge'])){
+ $this->cur_dialog = false;
+ }
+
+ /* Save changes if check is ok */
+ if(isset($_POST['SaveCartridge'])){
+ $this->cur_dialog->save_object();
+ if(count($this->cur_dialog->check())) {
+ foreach($this->cur_dialog->check() as $checks){
+ print_red($checks);
+ }
+ }else{
+ $this->cur_dialog->save();
+ $this->cur_dialog = false;
+ }
+ }
+
+ /* If we have a dialog open, display it */
+ if($this->cur_sub_dialog){
+ $this->cur_sub_dialog->parent = $this->parent;
+ $this->cur_sub_dialog->save_object();
+ return($this->cur_sub_dialog->execute());
+ }
+ /* If we have a dialog open, display it */
+ if($this->cur_dialog){
+ $this->cur_dialog->parent = $this->parent;
+ $this->cur_dialog->save_object();
+ return($this->cur_dialog->execute());
+ }
+
+ /* Create divlist */
+ $divlist = new divlist("glpi devices");
+ $divlist->SetPluginMode();
+ $divlist->SetEntriesPerPage(0);
+ $divlist->SetHeader(array(
+ array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
+ array("string" => _("Cartridges"), "attach" => "style=''"),
+ array("string" => _("Action"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
+
+ /* Links for editing,adding.... */
+ $edit = "<a href='?plug=".$_GET['plug']."&act=edit_cartridge&id=%s'>%s</a>";
+ $editdel = "<a href='?plug=".$_GET['plug']."&act=edit_cartridge&id=%s'><img src='images/edit.png' alt='"._("Edit")."' border=0></a>";
+ $editdel.= "<a href='?plug=".$_GET['plug']."&act=del_cartridge&id=%s'><img src='images/edittrash.png' alt='"._("Delete")."' border=0></a>";
+
+ /* Checkbox for selection of some cartridges */
+ $useCartridge = "<input type='hidden' name='wasOnPage_%s' value='%s'><input type='checkbox' value='%s' name='useCartridge_%s' %CHECKED%>";
+
+ /* Add cartridges */
+ $cart = $this->getCartridgeTypes();
+
+ /* Remove typically error possibilities */
+ $f = str_replace("/","\/",$filter);
+ $f = str_replace(".","\.",$f);
+ $f = str_replace("*",".*",$f);
+
+ /* Assign cartridges */
+ foreach($cart as $key=>$cartr){
+
+ /* Skip if filter doesn't match*/
+ if(!preg_match("/^".$f."$/i",$cartr['cartridgeName'])){
+ continue;
+ }
+
+ /* check if this cartridge is selected */
+ $chk = "";
+ if(isset($this->usedCartridges[$key])){
+ $chk = " checked ";
+ }
+
+ /* Add fields */
+ $field1 = array("string" => preg_replace("/%s/",($key),preg_replace("/%CHECKED%/",$chk,$useCartridge)),
+ "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($edit,($key),$cartr['cartridgeName']." [".$cartr['cartridgeTypeName']."]"),
+ "attach" => "style=''");
+ $field3 = array("string" => sprintf($editdel,($key),($key)),
+ "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+
+ $divlist->AddEntry(array($field1,$field2,$field3));
+
+ }
+
+ /* Create list header */
+ $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+ " <input class='center' type='image' align='middle'
+ src='images/zip.png' title='"._("New monitor")."' alt='"._("M")."' name='newcartridge'> ".
+ "</div>";
+
+ /* Tell smarty some vars */
+ $filter = session::get('glpiCartridgeRegex');
+ $smarty->assign("devicehead", $listhead);
+ $smarty->assign("devices", $divlist->DrawList());
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
+ $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info_small.png'));
+ $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
+ $smarty->assign("apply", apply_filter());
+ $smarty->assign("alphabet", generate_alphabet());
+ $smarty->assign("cartridge_regex", $filter);
+
+ $display.= $smarty->fetch(get_template_path('glpiPrinterCartridges.tpl', TRUE));
+ return($display);
+ }
+
+ /* Save device to glpi database
+ * If this is a new device, create a new entry, else update this entry
+ */
+ function save()
+ {
+ $carts = $this->getCartridgeTypes();
+ $ret = array();
+ foreach($this->usedCartridges as $key){
+ $tmp =array();
+ $tmp['date_use'] = date("Y-m-d");
+ $tmp['ID'] = -1;
+ $tmp['type_ID'] = $carts[$key]['cartridgeID'];
+ $tmp['name'] = $carts[$key]['cartridgeName'];
+ $tmp['FK_glpi_printers']= -1;
+ $tmp['type_name'] = $carts[$key]['cartridgeTypeName'];
+ $ret[$key] = $tmp;
+ }
+ return($ret);
+ }
+
+ /* this only gets all already defined devices */
+ function reload()
+ {
+ $this->devices = $this->parent->handle->getDevices();
+ ksort($this->devices);
+ }
+
+ /* This funtions saves all POST variables.
+ The variable must be in the array $this->EditEntry
+ */
+ function save_object()
+ {
+ /* Checkbox handling
+ * Check which checkbox is selected
+ */
+ foreach($_POST as $name => $value){
+ if(preg_match("/wasOnPage/",$name)){
+ $id = preg_replace("/wasOnPage_/","",$name);
+ if(isset($_POST['useCartridge_'.$id])){
+ $this->usedCartridges[$id]=$id;
+ }else{
+ unset($this->usedCartridges[$id]);
+ }
+ }
+ }
+ }
+
+ /* This function cehck all created devices if you wan't to create device specific check
+ use >>if($attr['device_type']=="moboard")<< to create a device type depending check
+ */
+ function check()
+ {
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ return($message);
+ }
+
+ /* Return cartriges for our divlist */
+ function getCartridgeTypes()
+ {
+ $ret = array();
+ $ret = $this->parent->handle->getAvailableCartridgeTypes($this->PrinterType);
+ return($ret);
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiPrinterCartridgesEdit.inc
--- /dev/null
@@ -0,0 +1,337 @@
+<?php
+
+class glpiPrinterCartridgesEdit extends plugin
+{
+ /* CLI vars */
+ var $cli_summary = "Manage server basic objects";
+ var $cli_description = "Some longer text\nfor help";
+ var $cli_parameters = array("eins" => "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);
+ 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);
+ }
+
+ /* 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 */
+ $ldap->cat($id, array('cn', 'mail', 'telephoneNumber'));
+ $atr = $ldap->fetch();
+ $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 = "<table summary=''><tr>";
+ $types = $this->parent->handle->getPrinterTypes();
+
+ /* Specifies number of cols */
+ $spalten = 2;
+
+ $spalt = $spalten;
+ foreach($types as $key => $type){
+ $spalt -- ;
+
+ /* Create new row, if cols for this row reached $spalten */
+ if($spalt < 0) {
+ $spalt = $spalten -1;
+ $matrix .= "</tr><tr>";
+ }
+
+ /* Avoid deselecting every checkbox */
+ if($key == $this->printer_type){
+ $matrix.= "<td><input type='checkbox' name='UsePrinterType_".$key."' disabled checked>".$type."</td>";
+ }else{
+
+ /* Cehck checkbox */
+ $check = "";
+ if(isset($this->additional_printer[$key])){
+ $check = " checked ";
+ }
+ $matrix.= "<td><input type='checkbox' name='UsePrinterType_".$key."' ".$check." ><input type='hidden' name='wasOnPage_".$key."' ".$check.">".$type."</td>";
+ }
+ }
+
+ /* Complete table row, to avoid html errors */
+ if($spalt >0){
+ while($spalt >0){
+ $spalt -- ;
+ $matrix .="<td> </td>";
+ }
+ }
+
+ $matrix .= "</tr></table>";
+
+ /* Append manufacturers
+ */
+ $smarty->assign("PrinterTypeMatrix", $matrix);
+
+ $smarty->assign("ManufacturerKeys", array_flip($this->parent->handle->getEnterprises()));
+ $smarty->assign("Manufacturers", $this->parent->handle->getEnterprises());
+ $smarty->assign("FK_glpi_enterprise", $this->FK_glpi_enterprise);
+
+ $smarty->assign("typeKeys", array_flip($this->parent->handle->getCartridgeTypes()));
+ $smarty->assign("types", $this->parent->handle->getCartridgeTypes());
+ $smarty->assign("type", $this->type);
+
+ /* Handle tech person
+ Assign name ... to smarty, if set
+ */
+ if(isset($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]." "; }
+ if(isset($tr['uid'][0])){ $str .= "[".$tr['uid'][0]."]"; }
+ $smarty->assign("tech_num", $str);
+ }else{
+ $smarty->assign("tech_num", _("N/A"));
+ }
+
+
+ $display.= $smarty->fetch(get_template_path('glpiPrinterCartridgesEdit.tpl', TRUE,dirname(__FILE__)));
+ return($display);
+ }
+
+ /* Check given values */
+ function check(){
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+
+ /* Avoid choosing an already used name */
+ $types = $this->parent->handle->getCartridgeTypeInformations();
+ foreach($types as $type){
+ if($type['name'] == $this->name){
+ if($type['ID'] != $this->ID){
+ $message[]= _("The selected name is already in use.");
+ }
+ }
+ }
+ return $message;
+ }
+
+ /* Save Post data */
+ function save_object()
+ {
+ foreach($this->attributes as $attr){
+ if(isset($_POST[$attr])){
+ $this->$attr= $_POST[$attr];
+ }
+ }
+
+ /* Get selected checkboxes */
+ foreach($_POST as $name => $value){
+ if(preg_match("/wasOnPage_/",$name)){
+ $id = preg_replace("/wasOnPage_/","",$name);
+ if(isset($_POST['UsePrinterType_'.$id])){
+ $this->additional_printer[$id]=$id;
+ }else{
+ if(isset($this->additional_printer[$id])){
+ unset($this->additional_printer[$id]);
+ }
+ }
+ }
+ }
+ }
+
+ /* Create / Update database with this new infos */
+ function save()
+ {
+ $tmp = array();
+ foreach($this->attributes as $attr){
+ $tmp[$attr] = $this-> $attr;
+ }
+ $types = array();
+ $types = $this->additional_printer;
+ $types[$this->printer_type]=$this->printer_type;
+ $this->parent->handle->Add_UpdateCatrigdeType($tmp,$types);
+ }
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiSelectUser.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_glpiSelectUser.inc
--- /dev/null
@@ -0,0 +1,286 @@
+<?php
+
+class glpiSelectUser extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account= TRUE;
+ var $attributes= array();
+ var $objectclasses= array("whatever");
+
+ var $users = array();
+ var $departments = array();
+
+ var $ui;
+
+ var $PostVarName = "";
+
+ function glpiSelectUser (&$config, $dn= NULL,$postvar)
+ {
+ plugin::plugin ($config, $dn);
+
+ $this->PostVarName = $postvar;
+
+ if(!session::is_set('glpi_user_filter')){
+ $tmp['users_regex'] = "*";
+ $tmp['base'] = $this->config->current['BASE'];
+ session::set('glpi_user_filter',$tmp);
+ }
+
+ $this->ui = get_userinfo();
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ if(isset($_POST['depselect'])){
+ session::set('glpi_user_filter', array('base' => $_POST['depselect']));
+ }
+
+ $filter = session::get('glpi_user_filter');
+
+ /* Filter settings, remove double* */
+ if(isset($_GET['search'])){
+ $filter['users_regex'] = preg_replace("/\*\**/","*",$_GET['search']."*");
+ }elseif(isset($_POST['regex'])){
+ $filter['users_regex'] = preg_replace("/\*\**/","*",$_POST['regex']);
+ }
+ if(empty($filter['users_regex'])) {
+ $filter = "*";
+ }
+
+
+ $s_action="";
+ /* Test Posts */
+ foreach($_POST as $key => $val){
+ // Post for delete
+ if(preg_match("/dep_back.*/i",$key)){
+ $s_action="back";
+ }elseif(preg_match("/user_new.*/",$key)){
+ $s_action="new";
+ }elseif(preg_match("/dep_home.*/i",$key)){
+ $s_action="home";
+ }
+ }
+
+ /* Homebutton is posted */
+ if($s_action=="home"){
+ $filter['base']=(preg_replace("/^[^,]+,/","",$this->ui->dn));
+ $filter['base']=(preg_replace("/^[^,]+,/","",$filter['base']));
+ }
+
+ if($s_action=="root"){
+ $filter['base']=($this->config->current['BASE']);
+ }
+
+
+ /* If Backbutton is Posted */
+ if($s_action=="back"){
+ $base_back = preg_replace("/^[^,]+,/","",$filter['base']);
+ $base_back = convert_department_dn($base_back);
+
+ if(isset($this->config->departments[trim($base_back)])){
+ $filter['base']= $this->config->departments[trim($base_back)];
+ }else{
+ $filter['base']= $this->config->departments["/"];
+ }
+ }
+
+ if((isset($_GET['act']))&&($_GET['act']=="dep_open")){
+ $entry = base64_decode($_GET['dep_id']);
+ $filter['base']= ($this->config->departments[$entry]);
+ }
+
+ session::set('glpi_user_filter',$filter);
+
+ $this->reload();
+
+ /* Fill templating stuff */
+ $smarty= get_smarty();
+ $display= "";
+
+ $divlist = new divlist("glpi users");
+ $divlist->SetPluginMode();
+ $divlist->SetEntriesPerPage(0);
+ $divlist->SetHeader(array(
+ array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
+ array("string" => _("Users")." / "._("Departments"), "attach" => "style=''"),
+ array("string" => _("Use"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
+ $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
+ foreach($this->departments as $key=> $val){
+
+ if(!isset($this->config->departments[trim($key)])){
+ $this->config->departments[trim($key)]="";
+ }
+
+ $non_empty="";
+ $keys= str_replace("/","\/",$key);
+ foreach($this->config->departments as $keyd=>$vald ){
+ if(preg_match("/".$keys."\/.*/",$keyd)){
+ $non_empty="full";
+ }
+ }
+
+ $field1 = array("string" => "<img src='images/".$non_empty."folder.png' alt='department'>", "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($linkopen,base64_encode($key),$val), "attach" => "style=''");
+ $field3 = array("string" => " ", "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+ $divlist->AddEntry(array($field1,$field2,$field3));
+ }
+
+ $useruse = "<a href='?plug=".$_GET['plug']."&act=".$this->PostVarName."&id=%s'>%s</a>";
+
+ foreach($this->users as $key=>$user){
+ $field1 = array("string" => "<img src='images/select_user.png' alt='user' >", "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($useruse,base64_encode($key),$user), "attach" => "style=''");
+ $field3 = array("string" => sprintf($useruse,base64_encode($key),"<img title='"._("Use")."' border=0 src='images/crossref.png' alt='"._("use")."'>"),
+ "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+ $divlist->AddEntry(array($field1,$field2,$field3));
+
+ }
+
+ /* Prepare departments,
+ which are shown in the listbox on top of the listbox
+ */
+
+
+ /* Get all departments within this subtree */
+ $glpi_user_filter = session::get('glpi_user_filter');
+ $this->base = $glpi_user_filter['base'];
+ $options ="";
+ $base = $this->config->current['BASE'];
+ $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", "users", $base,
+ array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
+
+ /* Load possible departments */
+ $ui= get_userinfo();
+ $tdeps= $ui->get_module_departments("users");
+ $ids = $this->config->idepartments;
+ foreach($deps as $dep){
+ if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
+ $value = $ids[$dep['dn']];
+ if ($this->base == $dep['dn']){
+ $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
+ } else {
+ $options.= "<option value='".$dep['dn']."'>$value</option>";
+ }
+ }
+ }
+
+ $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+ " <input class='center' type='image' src='images/list_root.png'
+ align='middle' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
+ " <input class='center' type='image' align='middle'
+ src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
+ " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'> ".
+" <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> "._("Base")." ".
+ " <select name='depselect' onChange='mainform.submit()' class='center'>$options</select>".
+ " <input class='center' type='image' src='images/list_submit.png' align='middle'
+ title='"._("Submit department")."' name='submit_department' alt='". _("Submit")."'> ".
+ "</div>";
+
+
+ $filter = session::get('glpi_user_filter');
+ $smarty->assign("usershead", $listhead);
+ $smarty->assign("users", $divlist->DrawList());
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
+ $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info_small.png'));
+ $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
+ $smarty->assign("apply", apply_filter());
+ $smarty->assign("alphabet", generate_alphabet());
+ $smarty->assign("users_regex", $filter['users_regex']);
+
+
+ $display.= $smarty->fetch(get_template_path('glpiSelectUser.tpl', TRUE));
+ return($display);
+ }
+
+ /* Save to LDAP */
+ function save()
+ {
+ plugin::save();
+
+ /* Optionally execute a command after we're done */
+#$this->handle_post_events($mode);
+ }
+
+ function reload()
+ {
+
+ $filter = session::get('glpi_user_filter');
+
+ $base = $filter['base'];
+ $regex= $filter['users_regex'];
+ /* NEW LIST MANAGMENT
+ * We also need to search for the departments
+ * So we are able to navigate like in konquerer
+ */
+
+ $res3= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))","users",
+ $base, array("ou", "description"), GL_SIZELIMIT | GL_CONVERT);
+
+ $this->departments= array();
+ $tmp = array();
+ foreach ($res3 as $value){
+ $tmp[strtolower($value['dn']).$value['dn']]=$value;
+ }
+ ksort($tmp);
+ foreach($tmp as $value){
+ if(isset($value["description"][0])){
+ $this->departments[$value['dn']]= get_sub_department($value['dn'])." - [".$value["description"][0]."]";
+ }else{
+ $this->departments[$value['dn']]= get_sub_department($value['dn']);//$value["description"][0];
+ }
+ }
+
+ /* END NEW LIST MANAGMENT
+ */
+ $ou = get_people_ou();
+
+ $res2= get_list("(&(|(cn=$regex)(sn=$regex))(objectClass=person))", "users",
+ $ou.$base, array("cn", "sn", "uid", "givenName", "description"),
+ GL_SUBSEARCH | GL_SIZELIMIT);
+
+ $tmp = array();
+
+ foreach($res2 as $val){
+ $str = "";
+ if(isset($val['givenName'][0])){
+ $str .= $val['givenName'][0];
+ }
+ if(isset($val['sn'][0])){
+ $str .= $val['sn'][0];
+ }
+ if(isset($val['uid'][0])){
+ $str .= $val['uid'][0];
+ }
+
+ $tmp[$str] = $val;
+ }
+
+ ksort($tmp);
+ $this->users = array();
+ foreach($tmp as $value){
+ if (isset($value["givenName"][0]) && isset($value["sn"][0])){
+ $this->users[$value['dn']]= $value["sn"][0].", ".
+ $value["givenName"][0].
+ " [".$value["uid"][0]."]";
+ } else {
+ $this->users[$value["dn"]]= "[".$value["uid"][0]."]";
+ }
+ }
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/class_goGlpiServer.inc b/gosa-plugins/glpi/admin/systems/services/glpi/class_goGlpiServer.inc
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+
+class goGlpiServer extends goService {
+
+ var $cli_summary = "This pluign is used within the ServerService Pluign \nand indicates that this server supports asterisk management.";
+ var $cli_description = "Some longer text\nfor help";
+ var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* This plugin only writes its objectClass */
+ var $objectclasses = array("goGlpiServer");
+ var $attributes = array("goGlpiAdmin","goGlpiDatabase","goGlpiPassword");
+ var $StatusFlag = "goGlpiServerStatus";
+
+ /* This class can't be assigned twice so it conflicts with itsself */
+ var $conflicts = array("goGlpiServer");
+
+ var $DisplayName = "";
+ var $dn = NULL;
+ var $cn = "";
+ var $acl;
+
+ var $goGlpiServerStatus ="";
+ var $goGlpiAdmin ="";
+ var $goGlpiDatabase ="";
+ var $goGlpiPassword ="";
+ var $view_logged =FALSE;
+
+
+ function goGlpiServer(&$config,$dn)
+ {
+ goService::goService($config,$dn);
+ $this->DisplayName = _("Inventory database");
+ }
+
+
+ function execute()
+ {
+ if($this->is_account && !$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","server/".get_class($this),$this->dn);
+ }
+
+ $smarty = get_smarty();
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,$this->$attr);
+ }
+ $tmp = $this->plInfo();
+ foreach($tmp['plProvidedAcls'] as $name => $translation ){
+ $smarty->assign($name."ACL",$this->getacl($name));
+ }
+ return($smarty->fetch(get_template_path("goGlpiServer.tpl",TRUE,dirname(__FILE__))));
+ }
+
+
+ function getListEntry()
+ {
+ $fields = goService::getListEntry();
+ $fields['Message'] = _("Inventory database service");
+ $fields['AllowEdit'] = true;
+ return($fields);
+ }
+
+ function check()
+ {
+ $message = plugin::check();
+ if(empty($this->goGlpiAdmin)){
+ $message[]= _("The attribute user is empty or contains invalid characters.");
+ }
+ if(empty($this->goGlpiDatabase)){
+ $message[]= _("The attribute database is empty or contains invalid characters.");
+ }
+ return($message);
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['goGlpiServer_posted'])){
+ plugin::save_object();
+ }
+ }
+
+ /* Return plugin informations for acl handling */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Inventory database"),
+ "plDescription" => _("Inventory database")." ("._("Services").")" ,
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 93,
+ "plSection" => array("administration"),
+ "plCategory" => array("server"),
+
+ "plProvidedAcls"=> array(
+ "start" => _("Start"),
+ "stop" => _("Stop"),
+ "restart" => _("Restart"),
+
+ "goGlpiAdmin" => _("Admin"),
+ "goGlpiDatabase" => _("Database"),
+ "goGlpiPassword" => _("Password"))
+ ));
+ }
+
+
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpi.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpi.tpl
--- /dev/null
@@ -0,0 +1,138 @@
+<table summary="" style="width:100%;">
+ <tr>
+ <td style="width:50%;vertical-align:top;" >
+ <!--Upper left-->
+
+ <h2>{t}Generic{/t}</h2>
+ <table summary="" cellpadding=5>
+ <tr>
+ <td >{t}System type{/t}
+ </td>
+ <td>
+{render acl=$typeACL}
+ <select name="type">
+ {html_options values=$SystemTypeKeys output=$SystemTypes selected=$type}
+ </select>
+{/render}
+{render acl=$typeACL}
+ <input type="submit" value="{t}edit{/t}" name="edit_type">
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Operating system{/t}
+ </td>
+ <td>
+{render acl=$osACL}
+ <select name="os">
+ {html_options values=$OSKeys output=$OSs selected=$os}
+ </select>
+{/render}
+{render acl=$osACL}
+ <input type="submit" value="{t}edit{/t}" name="edit_os">
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+{render acl=$FK_glpi_enterpriseACL}
+ <select name="FK_glpi_enterprise">
+ {html_options values=$ManufacturerKeys output=$Manufacturers selected=$FK_glpi_enterprise}
+ </select>
+{/render}
+{render acl=$FK_glpi_enterpriseACL}
+ <input type="submit" value="{t}edit{/t}" name="edit_manufacturer">
+{/render}
+ </td>
+ </tr>
+ <!--</table>
+ <p class="seperator"> </p>
+ <h2>{t}Contacts{/t}</h2>
+ <table summary="" width="100%">-->
+ <tr>
+ <td>
+ {t}Contact person{/t}
+ </td>
+ <td>
+ <i>{$contact_num} </i>
+{render acl=$contact_numACL}
+ <input type="submit" name="SelectContactPerson" value="{t}Edit{/t}">
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Technical responsible{/t}
+ </td>
+ <td>
+ <i>{$tech_num} </i>
+{render acl=$tech_numACL}
+ <input type="submit" value="{t}Edit{/t}" name="SelectTechPerson">
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
+ <!--Upper right-->
+ <h2>{t}Comment{/t}</h2>
+ <table summary="" width="100%">
+ <tr>
+ <td valign="top" colspan="2">
+{render acl=$commentsACL}
+ <textarea name="comments" style="width:100%;height:180px;">{$comments}</textarea>
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+<p class="seperator" > </p>
+<table summary="" style="width:100%;">
+ <tr>
+ <td style="width:50%;">
+ <h2>{t}Installed devices{/t}</h2>
+ <table summary="" width="100%">
+ <tr>
+ <td>
+{render acl=$DevicesACL}
+ <select name="InstalledDevices" style="height:130px;width:100%;" multiple>
+ {html_options values=$InstalledDeviceKeys output=$InstalledDevices}
+ </select>
+{/render}
+{render acl=$DevicesACL}
+ <input name="AddDevice" value="{t}Edit{/t}" type="submit">
+{/render}
+ </td>
+ </tr>
+ </table>
+<!-- <p class="seperator" > </p>
+ <input type="submit" value="{t}Trading{/t}" name="Trading">
+ <input type="submit" value="{t}Software{/t}" name="Software">
+ <input type="submit" value="{t}Contracts{/t}" name="Contracts"> -->
+ </td>
+ <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
+ <h2>{t}Attachments{/t}</h2>
+ <table summary="" width="100%">
+ <tr>
+ <td>
+{render acl=$AttachmentsACL}
+ {$AttachmentsDiv}
+{/render}
+{render acl=$AttachmentsACL}
+ <input name="AddAttachment" value="{t}Add{/t}" type="submit">
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+<input type="hidden" name="glpi_tpl_posted" value="1">
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('type');
+ -->
+</script><p style="text-align:right">
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpiAttachmentEdit.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpiAttachmentEdit.tpl
--- /dev/null
@@ -0,0 +1,78 @@
+<br>
+<h2>{t}Attachment{/t}</h2>
+
+<table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top;">
+ <table summary="" width="100%">
+ <tr>
+ <td style="vertical-align:top;">
+ {t}Name{/t}
+ </td>
+ <td>
+ <input type="text" value="{$name}" name="name">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">
+ {t}Comment{/t}
+ </td>
+ <td style="vertical-align:top;">
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="vertical-align:top;">
+ <table summary="" width="100%">
+ <tr>
+ <td style="vertical-align:top;">
+ {t}File{/t}
+ </td>
+ <td style="vertical-align:top;">
+ <input type="file" value="" name="filename"><input type="submit" name="upload" value="{t}Upload{/t}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">
+ {t}Status{/t}
+ </td>
+ <td style="vertical-align:top;">
+ {$status}
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">
+ {t}Filename{/t}
+ </td>
+ <td style="vertical-align:top;">
+ {$filename}
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">
+ {t}Mime-type{/t}
+ </td>
+ <td style="vertical-align:top;">
+ {$mime}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+
+
+<p class="seperator"> </p>
+<div align="right">
+ <p>
+ <input type="submit" name="SaveAttachment" value="{t}Save{/t}">
+ <input type="submit" name="CancelAttachment" value="{t}Cancel{/t}">
+ </p>
+</div>
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('name');
+ -->
+</script>
+
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpiAttachmentPool.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpiAttachmentPool.tpl
--- /dev/null
@@ -0,0 +1,54 @@
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+<tr>
+ <td style="vertical-align:top;width:50%;" >
+ <div class="contentboxh" style="height:20px;">
+ <p class="contentboxh" style="font-size:12px;">
+ {t}List of attachments{/t}
+ </p>
+ </div>
+ <div class="contentboxb">
+ {$attachmenthead}
+ </div>
+ <div style='height:4px;'></div>
+ <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+ {$attachments}
+ <input type=hidden name="edit_helper">
+ </div>
+ </td>
+ <td style="vertical-align:top;">
+ <div class="contentboxh" style="border-bottom:1px solid #B0B0B0;height:20px;">
+ <p class="contentboxh" style="font-size:12px;"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
+ </div>
+ <div class="contentboxb" style="padding:5px;">
+ {t}This dialog allow you to attach additional objects (like manuals, guides, etc.) to your currently edited computer.{/t}
+ </div>
+ <br>
+ <div class="contentboxh" style="height:20px;">
+ <p class="contentboxh" style="font-size:12px;"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
+ </div>
+ <div class="contentboxb">
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ {$alphabet}
+ </table>
+<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+<tr>
+<td><LABEL for="regex"><img alt="{t}Display attachments matching{/t}" src="{$search_image}" align=middle></label></td>
+<td width="99%">
+<input type='text' style='width:99%' name='attachment_regex' maxlength='20' value='{$attachment_regex}' title='{t}Regular expression for matching attachment names{/t}' onChange="mainform.submit()">
+</td>
+</tr>
+</table>
+ {$apply}
+ </div>
+ </td>
+</tr>
+</table>
+
+<input type="hidden" name="ignore">
+<p class="seperator"> </p>
+<div align="right">
+ <p>
+ <input type="submit" name="UseAttachment" value="{t}Use{/t}">
+ <input type="submit" name="AbortAttachment" value="{t}Cancel{/t}">
+ </p>
+</div>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpiDeviceManagement.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpiDeviceManagement.tpl
--- /dev/null
@@ -0,0 +1,54 @@
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+<tr>
+ <td style="vertical-align:top;width:50%;" >
+ <div class="contentboxh" style="height:20px;">
+ <p class="contentboxh" style="font-size:12px;">
+ {t}List of devices{/t}
+ </p>
+ </div>
+ <div class="contentboxb">
+ {$devicehead}
+ </div>
+ <div style='height:4px;'></div>
+ <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+ {$devices}
+ <input type=hidden name="edit_helper">
+ </div>
+ </td>
+ <td style="vertical-align:top;">
+ <div class="contentboxh" style="border-bottom:1px solid #B0B0B0;height:20px;padding:0px;">
+ <p class="contentboxh" style="font-size:12px;padding:0px;"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
+ </div>
+ <div class="contentboxb" style="padding:5px;">
+ {t}This dialog allows you to attach a device to your currently edited computer.{/t}
+ </div>
+ <br>
+ <div class="contentboxh" style="height:20px;">
+ <p class="contentboxh" style="font-size:12px;"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
+ </div>
+ <div class="contentboxb">
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ {$alphabet}
+ </table>
+<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+<tr>
+<td><LABEL for="regex"><img alt="{t}Display devices matching{/t}" src="{$search_image}" align=middle></label></td>
+<td width="99%">
+<input type='text' style='width:99%' name='device_regex' maxlength='20' value='{$device_regex}' title='{t}Regular expression for matching device names{/t}' onChange="mainform.submit()">
+</td>
+</tr>
+</table>
+ {$apply}
+ </div>
+ </td>
+</tr>
+</table>
+
+<input type="hidden" name="ignore">
+<p class="seperator"> </p>
+<div align="right">
+ <p>
+ <input type="submit" name="SelectDeviceSave" value="{t}Use{/t}">
+ <input type="submit" name="SelectDeviceCancel" value="{t}Cancel{/t}">
+ </p>
+</div>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpiManufacturer.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpiManufacturer.tpl
--- /dev/null
@@ -0,0 +1,15 @@
+<h2>{t}Manage manufacturers{/t}</h2>
+<select name="manufacturer" style="width:100%;" size="12">
+ {html_options values=$ManuKeys output=$Manus}
+</select>
+<br>
+<input name="add_manu" value="{t}Add{/t}" type="submit">
+<input name="edit_manu" value="{t}Edit{/t}" type="submit">
+<input name="remove_manu" value="{t}Remove{/t}" type="submit">
+
+<p class="seperator"> </p>
+<div align="right">
+<p>
+ <input name="close_edit_manufacturer" value="{t}Close{/t}" type="submit">
+</p>
+</div>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpiManufacturerAdd.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpiManufacturerAdd.tpl
--- /dev/null
@@ -0,0 +1,89 @@
+<h2>{t}Add/Edit manufacturer{/t}</h2>
+<table summary="" width="100%">
+ <tr>
+ <td width="50%">
+ <table summary="">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input type="text" name="name" value="{$name}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Website{/t}
+ </td>
+ <td>
+ <input type="text" name="website" value="{$website}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Address{/t}
+ </td>
+ <td>
+ <textarea name="address">{$address}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" >
+ <tr>
+ <td>{t}Phone number{/t}
+ </td>
+ <td>
+ <input type="text" name="phonenumber" value="{$phonenumber}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Fax{/t}
+ </td>
+ <td>
+ <input type="text" name="fax" value="{$fax}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Email{/t}
+ </td>
+ <td>
+ <input type="text" name="email" value="{$email}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comments{/t}
+ </td>
+ <td>
+ <textarea name="comments">{$comments}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+
+
+
+
+
+
+
+
+
+
+
+
+
+<br>
+<p class="seperator"> </p>
+<div align="right">
+<p>
+ <input name="save_manufacturer" value="{t}Save{/t}" type="submit">
+ <input name="close_manufacturer" value="{t}Close{/t}" type="submit">
+</p>
+</div>
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('name');
+ -->
+</script>
+
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpiPrinter.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpiPrinter.tpl
--- /dev/null
@@ -0,0 +1,159 @@
+<table summary="" style="width:100%;">
+ <tr>
+ <td style="width:50%;vertical-align: top;">
+ <!--Upper left-->
+
+ <h2>{t}Generic{/t}</h2>
+ <table summary="" cellpadding=5>
+ <tr>
+ <td width="150">{t}Printer type{/t}
+ </td>
+ <td>
+{render acl=$typeACL}
+ <select name="type" >
+ {html_options values=$PrinterTypeKeys output=$PrinterTypes selected=$type}
+ </select>
+{/render}
+{render acl=$typeACL}
+ <input type="submit" value="{t}edit{/t}" name="edit_type" >
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+{render acl=$FKglpienterpriseACL}
+ <select name="FK_glpi_enterprise" >
+ {html_options values=$ManufacturerKeys output=$Manufacturers selected=$FK_glpi_enterprise}
+ </select>
+{/render}
+{render acl=$FKglpienterpriseACL}
+ <input type="submit" value="{t}edit{/t}" name="edit_manufacturer" >
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
+ <h2>{t}Supported interfaces{/t}</h2>
+ <table summary="" width="100%">
+ <tr>
+ <td width="20">
+{render acl=$flags_serialACL}
+ <input type="checkbox" name="flags_serial" {if $flags_serial=="1"} checked {/if} value="1" >
+{/render}
+ </td>
+ <td>
+ {t}Serial{/t}
+ </td>
+ </tr>
+ <tr>
+ <td width="20">
+{render acl=$flags_parACL}
+ <input type="checkbox" name="flags_par" {if $flags_par=="1"} checked {/if} value="1" >
+{/render}
+ </td>
+ <td>
+ {t}Parallel{/t}
+ </td>
+ </tr>
+ <tr>
+ <td width="20">
+{render acl=$flags_usbACL}
+ <input type="checkbox" name="flags_usb" {if $flags_usb=="1"} checked {/if} value="1" >
+{/render}
+ </td>
+ <td>
+ {t}USB{/t}
+ </td>
+ </tr>
+ </table>
+ <input name="glpiPrinterFlagsPosted" value="1" type="hidden">
+ </td>
+ </tr>
+</table>
+<p class="seperator" > </p>
+<table summary="" style="width:100%;">
+ <tr>
+ <td style="width:50%;vertical-align: top;">
+ <h2>{t}Contacts{/t}</h2>
+ <table summary="" cellpadding=5>
+ <tr>
+ <td>{t}Technical responsible{/t}
+ </td>
+ <td>
+ <i>{$tech_num} </i>
+{render acl=$tech_numACL}
+ <input type="submit" value="{t}Edit{/t}" name="SelectTechPerson" >
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {t}Contact person{/t}
+ </td>
+ <td>
+ <i>{$contact_num} </i>
+{render acl=$contact_numACL}
+ <input type="submit" name="SelectContactPerson" value="{t}Edit{/t}">
+{/render}
+
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
+ <h2>{t}Attachments{/t}</h2>
+ <table summary="" width="100%">
+ <tr>
+ <td>
+{render acl=$AttachmentsACL}
+ {$AttachmentsDiv}
+{/render}
+{render acl=$AttachmentsACL}
+ <input name="AddAttachment" value="{t}Add{/t}" type="submit" >
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+<p class="seperator" > </p>
+<table summary="" style="width:100%;">
+ <tr>
+ <td style="width:50%;vertical-align: top;">
+ <h2>{t}Information{/t}</h2>
+ <table summary="" width="100%">
+ <tr>
+ <td width="100%">
+{render acl=$commentsACL}
+ <textarea name="comments" style="width:100%;height:100px;" >{$comments}</textarea>
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
+ <h2>{t}Installed cartridges{/t}</h2>
+ <table summary="" width="100%">
+ <tr>
+ <td>
+{render acl=$CartridgesACL}
+ <select name="Cartridges[]" style="height:100px;width:100%;" multiple>
+ {html_options values=$CartridgeKeys output=$Cartridges}
+ </select>
+{/render}
+{render acl=$CartridgesACL}
+ <input name="AddCartridge" value="{t}Add{/t}" type="submit" >
+{/render}
+{render acl=$CartridgesACL}
+ <input name="RemoveCartridge" value="{t}Remove{/t}" type="submit" >
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpiPrinterCartridges.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpiPrinterCartridges.tpl
--- /dev/null
@@ -0,0 +1,54 @@
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+<tr>
+ <td style="vertical-align:top;width:50%;" >
+ <div class="contentboxh" style="height:20px;">
+ <p class="contentboxh" style="font-size:12px;">
+ {t}List of available cartridge type for this type of printer{/t}
+ </p>
+ </div>
+ <div class="contentboxb">
+ {$devicehead}
+ </div>
+ <div style='height:4px;'></div>
+ <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+ {$devices}
+ <input type=hidden name="edit_helper">
+ </div>
+ </td>
+ <td style="vertical-align:top;">
+ <div class="contentboxh" style="border-bottom:1px solid #B0B0B0;height:20px;" >
+ <p class="contentboxh" style="font-size:12px;"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
+ </div>
+ <div class="contentboxb" style="padding:5px;">
+ {t}This dialog allows you to create new types of cartridges, and select one or more types for your printer. Cartridge types depends on the printer type you have selected. For each selected cartridge type there will be a new cartridge created, this allows you to select the same cartridge type for more then one printer.{/t}
+ </div>
+ <br>
+ <div class="contentboxh" style="height:20px;">
+ <p class="contentboxh" style="font-size:12px;"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
+ </div>
+ <div class="contentboxb">
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ {$alphabet}
+ </table>
+<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+<tr>
+<td><LABEL for="regex"><img alt="{t}Display cartridge types matching{/t}" src="{$search_image}" align=middle></label></td>
+<td width="99%">
+<input type='text' style='width:99%' name='cartridge_regex' maxlength='20' value='{$cartridge_regex}' title='{t}Regular expression for matching cartridge types{/t}' onChange="mainform.submit()">
+</td>
+</tr>
+</table>
+ {$apply}
+ </div>
+ </td>
+</tr>
+</table>
+
+<input type="hidden" name="ignore">
+<p class="seperator"> </p>
+<div align="right">
+ <p>
+ <input type="submit" name="SelectCartridgeSave" value="{t}Use{/t}">
+ <input type="submit" name="SelectCartridgeCancel" value="{t}Cancel{/t}">
+ </p>
+</div>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpiPrinterCartridgesEdit.tpl
--- /dev/null
@@ -0,0 +1,83 @@
+<table summary="" title="" style="width: 100%;">
+ <tr>
+ <td>
+ <h2>{t}Generic{/t}</h2>
+ <table summary="" title="" width="100%" style="vertical-align:top;">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input type="text" name="name" value="{$name}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Reference{/t}
+ </td>
+ <td>
+ <input type="text" name="ref" value="{$ref}">
+ </td>
+ </tr>
+ </table>
+ <p class="seperator"> </p>
+ <h2>{t}Comments{/t}</h2>
+ <table summary="" title="" width="100%" style="vertical-align:top;">
+ <tr>
+ <td>{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comments" style="width:100%;">{$comments}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="vertical-align:top;border-left: 1px solid rgb(160, 160, 160);padding-right: 5px;">
+ <h2>{t}Generic{/t}</h2>
+ <table summary="" title="" width="100%" style="vertical-align:top;">
+ <tr>
+ <td>{t}Type{/t}
+ </td>
+ <td>
+ <select name="type" >
+ {html_options values=$typeKeys output=$types selected=$type}
+ </select>
+ <input type="submit" value="{t}edit{/t}" name="edit_type_cartridge">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$ManufacturerKeys output=$Manufacturers selected=$FK_glpi_enterprise}
+ </select>
+ <input type="submit" value="{t}edit{/t}" name="edit_manufacturer_cartridges">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Technical responsible{/t}
+ </td>
+ <td>
+ <i>{$tech_num} </i>
+ <input type="submit" value="{t}Choose{/t}" name="SelectCartridgeTechPerson">
+ </td>
+ </tr>
+ </table>
+ <p class="seperator"> </p>
+ {$PrinterTypeMatrix}
+ </td>
+ </tr>
+</table>
+
+<p class="seperator"> </p>
+<div style="text-align:right;">
+ <p>
+ <input type="submit" name="SaveCartridge" value="{t}Save{/t}">
+ <input type="submit" name="CancelCartridge" value="{t}Cancel{/t}"><br>
+ </p>
+</div>
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('name');
+ -->
+</script>
+
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpiSelectUser.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpiSelectUser.tpl
--- /dev/null
@@ -0,0 +1,53 @@
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+<tr>
+ <td style="vertical-align:top;width:50%;" >
+ <div class="contentboxh" style="height:20px;">
+ <p class="contentboxh" style="font-size:12px;">
+ {t}List of users{/t}
+ </p>
+ </div>
+ <div class="contentboxb">
+ {$usershead}
+ </div>
+ <div style='height:4px;'></div>
+ <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+ {$users}
+ <input type=hidden name="edit_helper">
+ </div>
+ </td>
+ <td style="vertical-align:top;">
+ <div class="contentboxh" style="border-bottom:1px solid #B0B0B0;height:20px;">
+ <p class="contentboxh" style="font-size:12px;"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
+ </div>
+ <div class="contentboxb" style="padding:5px;">
+ {t}This dialog allows you to select a user as technical responsible person.{/t}
+ </div>
+ <br>
+ <div class="contentboxh" style="height:20px;">
+ <p class="contentboxh" style="font-size:12px"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
+ </div>
+ <div class="contentboxb">
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ {$alphabet}
+ </table>
+<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+<tr>
+<td><LABEL for="regex"><img alt="{t}Display users matching{/t}" src="{$search_image}" align=middle></label></td>
+<td width="99%">
+<input type='text' style='width:99%' name='regex' maxlength='20' value='{$users_regex}' title='{t}Regular expression for matching user names{/t}' onChange="mainform.submit()">
+</td>
+</tr>
+</table>
+ {$apply}
+ </div>
+ </td>
+</tr>
+</table>
+
+<input type="hidden" name="ignore">
+<p class="seperator"> </p>
+<div align="right">
+ <p>
+ <input type="submit" name="{$AbortSelectUser}" value="{t}Cancel{/t}">
+</p>
+</div>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpi_devices.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpi_devices.tpl
--- /dev/null
@@ -0,0 +1,763 @@
+{if $device_type=="monitor"}
+ <h2><img alt="" align="middle" src="images/monitor.png" class="center"> {t}Add/Edit monitor{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="name" value="{$name}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comments{/t}
+ </td>
+ <td>
+ <textarea name="comments">{$comments}</textarea>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Monitor size{/t}
+ </td>
+ <td>
+ <input name="size" value="{$size}"> {t}Inch{/t}
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Integrated microphone{/t}
+ </td>
+ <td>
+ <input type="radio" name="flags_micro" value="1" {if $flags_micro == "1"}checked {/if}>{t}Yes{/t}
+ <input type="radio" name="flags_micro" value="0" {if ($flags_micro == "0")||($flags_micro=="")}checked {/if}>{t}No{/t}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Integrated speakers{/t}
+ </td>
+ <td>
+ <input type="radio" name="flags_speaker" value="1" {if $flags_speaker == "1"}checked {/if}>{t}Yes{/t}
+ <input type="radio" name="flags_speaker" value="0" {if ($flags_speaker == "0")||($flags_speaker=="")}checked {/if}>{t}No{/t}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Sub-D{/t}
+ </td>
+ <td>
+ <input type="radio" name="flags_subd" value="1" {if $flags_subd == "1"}checked {/if}>{t}Yes{/t}
+ <input type="radio" name="flags_subd" value="0" {if ($flags_subd == "0")||($flags_subd=="")}checked {/if}>{t}No{/t}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}BNC{/t}
+ </td>
+ <td>
+ <input type="radio" name="flags_bnc" value="1" {if $flags_bnc == "1"}checked {/if}>{t}Yes{/t}
+ <input type="radio" name="flags_bnc" value="0" {if ($flags_bnc == "0")||($flags_bnc=="")}checked {/if}>{t}No{/t}
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Serial number{/t}
+ </td>
+ <td>
+ <input name="serial" value="{$serial}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Additional serial number{/t}
+ </td>
+ <td>
+ <input name="otherserial" value="{$otherserial}">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+
+{elseif $device_type=="pci"}
+
+ <h2><img alt="" align="middle" src="images/fai_template.png" class="center"> {t}Add/Edit other device{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+{elseif $device_type=="power"}
+
+ <h2><img alt="" align="middle" src="images/power.png" class="center"> {t}Add/Edit power supply{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Atx{/t}
+ </td>
+ <td>
+ <input type="radio" name="atx" value="Y" {if ($atx == "Y")||($atx=="")}checked {/if}>{t}Yes{/t}
+ <input type="radio" name="atx" value="N" {if $atx == "N"}checked {/if}>{t}No{/t}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Power{/t}
+ </td>
+ <td>
+ <input name="power" value="{$power}">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+{elseif $device_type=="gfxcard"}
+
+ <h2><img alt="" align="middle" src="images/gfx_hardware.png" class="center"> {t}Add/Edit graphic card{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Interface{/t}
+ </td>
+ <td>
+ <select name="interface">
+ {html_options values=$GFXInterfaceKeys output=$GFXInterfaces selected=$interface}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Ram{/t}
+ </td>
+ <td>
+ <input name="ram" value="{$ram}">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+{elseif $device_type=="control"}
+
+ <h2><img alt="" align="middle" src="images/hardware.png" class="center"> {t}Add/Edit controller{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Interface{/t}
+ </td>
+ <td>
+ <select name="interface">
+ {html_options values=$HDDInterfaceKeys output=$HDDInterfaces selected=$interface}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Size{/t}
+ </td>
+ <td>
+ <input type="radio" name="raid" value="Y" {if ($raid == "Y")||($raid=="")}checked {/if}>{t}Yes{/t}
+ <input type="radio" name="raid" value="N" {if $raid == "N"}checked {/if}>{t}No{/t}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+{elseif $device_type=="drive"}
+
+ <h2><img alt="" align="middle" src="images/drives.png" class="center"> {t}Add/Edit drive{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Speed{/t}
+ </td>
+ <td>
+ <input type="text" name="speed" value="{$speed}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Interface{/t}
+ </td>
+ <td>
+ <select name="interface">
+ {html_options values=$HDDInterfaceKeys output=$HDDInterfaces selected=$interface}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Writeable{/t}
+ </td>
+ <td>
+ <input type="radio" name="is_writer" value="Y" {if ($is_writer == "Y")||($is_writer=="")}checked {/if}>{t}Yes{/t}
+ <input type="radio" name="is_writer" value="N" {if $is_writer == "N"}checked {/if}>{t}No{/t}
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+{elseif $device_type=="hdd"}
+ <h2><img alt="" align="middle" src="images/fai_partitionTable.png" class="center"> {t}Add/Edit harddisk{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Rpm{/t}
+ </td>
+ <td>
+ <input type="text" name="rpm" value="{$rpm}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Cache{/t}
+ </td>
+ <td>
+ <input type="text" name="cache" value="{$cache}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Size{/t}
+ </td>
+ <td>
+ <input type="text" name="specif_default" value="{$specif_default}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Type{/t}
+ </td>
+ <td>
+ <select name="interface">
+ {html_options values=$HDDInterfaceKeys output=$HDDInterfaces selected=$interface}
+ </select>
+ </td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+ </table>
+
+{elseif $device_type=="ram"}
+
+ <h2><img alt="" align="middle" src="images/memory.png" class="center"> {t}Add/Edit memory{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Frequenz{/t}
+ </td>
+ <td>
+ <input type="text" name="frequence" value="{$frequence}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Size{/t}
+ </td>
+ <td>
+ <input type="text" name="specif_default" value="{$specif_default}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Type{/t}
+ </td>
+ <td>
+ <select name="type">
+ {html_options values=$RAMtypeKeys output=$RAMtypes selected=$type}
+ </select>
+ </td>
+ </tr>
+
+ </table>
+ </td>
+ </tr>
+ </table>
+
+{elseif $device_type=="sndcard"}
+ <h2><img alt="" align="middle" src="images/snd_hardware.png" class="center"> {t}Add/Edit sound card{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Type{/t}
+ </td>
+ <td>
+ <input type="text" name="type" value="{$type}">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+{elseif $device_type=="iface"}
+ <h2><img alt="" align="middle" src="images/net_hardware.png" class="center"> {t}Add/Edit network interface{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}MAC address{/t}
+ </td>
+ <td>
+ <input type="text" name="specif_default" value="{$specif_default}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Bandwidth{/t}
+ </td>
+ <td>
+ <input type="text" name="bandwidth" value="{$bandwidth}">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+{elseif $device_type=="processor"}
+ <h2><img alt="" align="middle" src="images/processor.png" class="center"> {t}Add/Edit processor{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Frequence{/t}
+ </td>
+ <td>
+ <input type="text" name="frequence" value="{$frequence}">
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Default frequence{/t}
+ </td>
+ <td>
+ <input type="text" name="specif_default" value="{$specif_default}">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+
+{elseif $device_type=="moboard"}
+ <h2><img alt="" align="middle" src="images/mainboard.png" class="center"> {t}Add/Edit motherboard{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Chipset{/t}
+ </td>
+ <td>
+ <input type="text" name="chipset" value="{$chipset}">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+{elseif $device_type=="case"}
+ <h2><img alt="" align="middle" src="images/server.png" class="center"> {t}Add/Edit computer case{/t}</h2>
+ <p class="seperator"> </p>
+ <br>
+ <table summary="" width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top; border-right:1px solid #A0A0A0; padding-right:5px;">
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Name{/t}
+ </td>
+ <td>
+ <input name="designation" value="{$designation}">
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}Comment{/t}
+ </td>
+ <td>
+ <textarea name="comment">{$comment}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <tr>
+ <td>{t}Manufacturer{/t}
+ </td>
+ <td>
+ <select name="FK_glpi_enterprise">
+ {html_options values=$FK_glpi_enterpriseKeys output=$FK_glpi_enterprises selected=$FK_glpi_enterprise}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align:top;">{t}format{/t}
+ </td>
+ <td>
+ <select name="format">
+ {html_options values=$formatKeys output=$formats selected=$format}
+ </select>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+{/if}
+
+
+<p class="seperator"> </p>
+<div align="right">
+ <p>
+ <input type="submit" value="{t}Save{/t}" name="SaveDeviceChanges">
+ <input type="submit" value="{t}Cancel{/t}" name="AbortDeviceChanges">
+ </p>
+</div>
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpi_edit_cartridge_type.tpl
--- /dev/null
@@ -0,0 +1,21 @@
+<br>
+ <select name="select_type_cartridge" size="12" style="width:100%">
+ {html_options values=$PrinterTypeKeys output=$PrinterTypes}
+ </select><br>
+ <input name="cartridge_type_string">
+ <input type="submit" name="add_cartridge_type" value="{t}Add{/t}" >
+ <input type="submit" name="rename_cartridge_type" value="{t}Rename{/t}" >
+ <input type="submit" name="del_cartridge_type" value="{t}Delete{/t}" >
+
+<p class="seperator"> </p>
+<div align="right">
+<p>
+<input name="close_edit_type_cartridge" value="{t}Close{/t}" type="submit">
+</p>
+</div>
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('cartridge_type_string');
+ -->
+</script>
+
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpi_edit_os.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpi_edit_os.tpl
--- /dev/null
@@ -0,0 +1,39 @@
+<h2>{t}Manage OS-types{/t}</h2>
+{if $Method == "edit"}
+
+ <select name="select_os" size="12" style="width:100%">
+ {html_options values=$OSKeys output=$OSs}
+ </select><br>
+ <input name="is_string">
+ <input type="submit" name="add_os" value="{t}Add{/t}" >
+ <input type="submit" name="rename_os" value="{t}Rename{/t}" >
+ <input type="submit" name="del_os" value="{t}Delete{/t}" >
+
+<p class="seperator"> </p>
+<div align="right">
+<p>
+<input name="close_edit_os" value="{t}Close{/t}" type="submit">
+</p>
+</div>
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('is_string');
+ -->
+</script>
+{else}
+{t}Please enter a new name{/t} <input name="string" value="{$string}">
+<p class="seperator"> </p>
+ <p>
+ <div align="right" style="text-align: right;">
+ <input type="submit" name="Rename_os_OK" value="{t}Rename{/t}" >
+ <input type="submit" name="Rename_Cancel" value="{t}Cancel{/t}" >
+ </div>
+ </p>
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('string');
+ -->
+</script>
+{/if}
+
+
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpi_edit_printer_type.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpi_edit_printer_type.tpl
--- /dev/null
@@ -0,0 +1,40 @@
+<br>
+{if $Method == "edit"}
+ <select name="select_type" size="12" style="width:100%">
+ {html_options values=$PrinterTypeKeys output=$PrinterTypes}
+ </select><br>
+ <input name="type_string">
+ <input type="submit" name="add_type" value="{t}Add{/t}" >
+ <input type="submit" name="rename_type" value="{t}Rename{/t}" >
+ <input type="submit" name="del_type" value="{t}Delete{/t}" >
+
+ <p class="seperator"> </p>
+ <div align="right">
+ <p>
+ <input name="close_edit_type" value="{t}Close{/t}" type="submit">
+ </p>
+ </div>
+ <script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('type_string');
+ -->
+ </script>
+
+{else}
+
+ {t}Please enter a new name{/t} <input name="string" value="{$string}">
+ <p class="seperator"> </p>
+ <p>
+ <div align="right" style="text-align: right;">
+ <input type="submit" name="Rename_PType_OK" value="{t}Rename{/t}" >
+ <input type="submit" name="Rename_Cancel" value="{t}Cancel{/t}" >
+ </div>
+ </p>
+ <script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('string');
+ -->
+ </script>
+
+{/if}
+
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/glpi_edit_type.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/glpi_edit_type.tpl
--- /dev/null
@@ -0,0 +1,37 @@
+<h2>{t}Manage System-types{/t}</h2>
+{if $Method == "edit"}
+
+ <select name="select_type" size="12" style="width:100%">
+ {html_options values=$SystemTypeKeys output=$SystemTypes}
+ </select><br>
+ <input name="type_string">
+ <input type="submit" name="add_type" value="{t}Add{/t}" >
+ <input type="submit" name="rename_type" value="{t}Rename{/t}" >
+ <input type="submit" name="del_type" value="{t}Delete{/t}" >
+
+ <p class="seperator"> </p>
+ <div align="right">
+ <p>
+ <input name="close_edit_type" value="{t}Close{/t}" type="submit">
+ </p>
+ </div>
+ <script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('type_string');
+ -->
+ </script>
+{else}
+{t}Please enter a new name{/t} <input name="string" value="{$string}">
+<p class="seperator"> </p>
+ <p>
+ <div align="right" style="text-align: right;">
+ <input type="submit" name="Rename_type_OK" value="{t}Rename{/t}" >
+ <input type="submit" name="Rename_Cancel" value="{t}Cancel{/t}" >
+ </div>
+ </p>
+ <script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('string');
+ -->
+ </script>
+{/if}
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/goGlpiServer.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/goGlpiServer.tpl
--- /dev/null
@@ -0,0 +1,36 @@
+<h2><img class="center" alt="" align="middle" src="images/rightarrow.png" /> {t}GLPI database information{/t}</h2>
+ <table summary="">
+ <tr>
+ <td>{t}Logging DB user{/t}{$must}</td>
+ <td>
+{render acl=$goGlpiAdminACL}
+ <input name="goGlpiAdmin" id="goGlpiAdmin" size=30 maxlength=60 value="{$goGlpiAdmin}">
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Password{/t}</td>
+ <td>
+{render acl=$goGlpiPasswordACL}
+ <input type="password" name="goGlpiPassword" id="goGlpiPassword" size=30 maxlength=60 value="{$goGlpiPassword}">
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Database{/t}{$must}</td>
+ <td>
+{render acl=$goGlpiDatabaseACL}
+ <input name="goGlpiDatabase" id="goGlpiDatabase" size=30 maxlength=60 value="{$goGlpiDatabase}">
+{/render}
+ </td>
+ </tr>
+ </table>
+
+
+<p class='seperator'> </p>
+<div style="width:100%; text-align:right;padding-top:10px;padding-bottom:3px;">
+ <input type='submit' name='SaveService' value='{t}Save{/t}'>
+
+ <input type='submit' name='CancelService' value='{t}Cancel{/t}'>
+</div>
+<input type="hidden" name="goGlpiServer_posted" value="1">
diff --git a/gosa-plugins/glpi/admin/systems/services/glpi/remove_glpi.tpl b/gosa-plugins/glpi/admin/systems/services/glpi/remove_glpi.tpl
--- /dev/null
@@ -0,0 +1,17 @@
+<div style="font-size:18px;">
+<img alt="" src="images/button_cancel.png" align=top> {t}Warning{/t}
+</div>
+<p>
+ {$warning}
+ {t}Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
+</p>
+
+<p>
+ {t}Best thing to do before performing this action would be to save the current contents of your MySql database in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t}
+</p>
+
+<p class="plugbottom">
+ <input type=submit name="delete_glpi_confirm" value="{t}Delete{/t}">
+
+ <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
+</p>