\PluginFusioninventoryToolbox

Manage the functions used in many classes.

Summary

Methods
Properties
Constants
logIfExtradebug()
gzdecode()
appendSimplexml()
cleanXML()
formatXML()
writeXML()
addAuth()
addGet()
addWalk()
getIPforDevice()
checkLock()
displaySerializedValues()
sendSerializedInventory()
sendXML()
fetchAssocByTable()
formatJson()
showHours()
getHourMinute()
isAllowurlfopen()
executeAsFusioninventoryUser()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

logIfExtradebug()

logIfExtradebug(string  $file, string  $message) 

Log if extra debug enabled

Parameters

string $file
string $message

gzdecode()

gzdecode(string  $data, string  $filename = '', string  $error = '', null|integer  $maxlength = NULL) : null|false|string

Fonction get on http://www.php.net/manual/en/function.gzdecode.php#82930 used to uncompress gzip string

Parameters

string $data
string $filename
string $error
null|integer $maxlength

Returns

null|false|string

appendSimplexml()

appendSimplexml(object  $simplexml_to, object  $simplexml_from) 

Merge 2 simpleXML objects

Parameters

object $simplexml_to

simplexml instance source

object $simplexml_from

simplexml instance destination

cleanXML()

cleanXML(object  $xml) : object

Clean XML, ie convert to be insert without problem into MySQL database

Parameters

object $xml

SimpleXMLElement instance

Returns

object —

SimpleXMLElement instance

formatXML()

formatXML(object  $xml) : string

Format XML, ie indent it for pretty printing

Parameters

object $xml

simplexml instance

Returns

string

writeXML()

writeXML(integer  $items_id, string  $xml, string  $itemtype) 

Write XML in a folder from an inventory by agent

Parameters

integer $items_id

id of the unmanaged device

string $xml

xml informations (with XML structure)

string $itemtype

addAuth()

addAuth(object  $p_sxml_node, integer  $p_id) 

Add AUTHENTICATION string to XML node

Parameters

object $p_sxml_node

XML node to authenticate

integer $p_id

Authenticate id

addGet()

addGet(object  $p_sxml_node, string  $p_object, string  $p_oid, string  $p_link, string  $p_vlan) 

Add GET oids to XML node 'GET'

Parameters

object $p_sxml_node
string $p_object
string $p_oid
string $p_link
string $p_vlan

addWalk()

addWalk(object  $p_sxml_node, string  $p_object, string  $p_oid, string  $p_link, string  $p_vlan) 

Add WALK (multiple oids) oids to XML node 'WALK'

Parameters

object $p_sxml_node
string $p_object
string $p_oid
string $p_link
string $p_vlan

getIPforDevice()

getIPforDevice(string  $itemtype, integer  $items_id) : array

Get IP for device

Parameters

string $itemtype
integer $items_id

Returns

array

checkLock()

checkLock(array  $data, array  $db_data, array  $a_lockable = array()) : array

Check lock

Parameters

array $data
array $db_data
array $a_lockable

Returns

array

displaySerializedValues()

displaySerializedValues(array  $array) 

Display data from serialized inventory field

Parameters

array $array

sendSerializedInventory()

sendSerializedInventory(integer  $items_id, string  $itemtype) 

Send serialized inventory to user browser (to download)

Parameters

integer $items_id
string $itemtype

sendXML()

sendXML(integer  $items_id, string  $itemtype) 

Send the XML (last inventory) to user browser (to download)

Parameters

integer $items_id
string $itemtype

fetchAssocByTable()

fetchAssocByTable(object  $mysql_result) : array

This function fetch rows from a MySQL result in an array with each table as a key

example: $query = "SELECT table_a.,table_b. ". "FROM table_b ". "LEFT JOIN table_a ON table_a.id = table_b.linked_id"; $result = mysqli_query( $query ); print_r( fetchTableAssoc( $result ) )

output: $results = Array ( [0] => Array ( [table_a] => Array ( [id] => 1 ) [table_b] => Array ( [id] => 2 [linked_id] => 1 ) ) ... )

Parameters

object $mysql_result

Returns

array

formatJson()

formatJson(string  $json) : string

Format a json in a pretty json

Parameters

string $json

Returns

string

showHours()

showHours(string  $name, array  $options = array()) : string

Dropdown for display hours

Parameters

string $name
array $options

Returns

string —

unique html element id

getHourMinute()

getHourMinute(integer  $seconds) : string

Get hour:minute from number of seconds

Parameters

integer $seconds

Returns

string

isAllowurlfopen()

isAllowurlfopen(integer  $wakecomputer) : boolean

Get information if allow_url_fopen is activated and display message if not

Parameters

integer $wakecomputer

(1 if it's for wakeonlan, 0 if it's for task)

Returns

boolean

executeAsFusioninventoryUser()

executeAsFusioninventoryUser(string|array  $function, array  $args = array()) : string

Execute a function as Fusioninventory user

Parameters

string|array $function
array $args

Returns

string —

the normaly returned value from executed callable