Skip to content

Commit

Permalink
Change version 9.1.1
Browse files Browse the repository at this point in the history
update xml
  • Loading branch information
amma35 committed Nov 17, 2016
1 parent 0ebc67c commit cc4685a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion addressing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<versions>
<version>
<num>2.4.0</num>
<compatibility>9.1</compatibility>
<compatibility>9.1.1</compatibility>
</version>
<version>
<num>2.3.0</num>
Expand Down
66 changes: 33 additions & 33 deletions inc/reserveip.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
class PluginAddressingReserveip extends CommonDBTM
{
const COMPUTER = 'Computer';
const NETWORK = 'NetworkEquipment';
const PRINTER = 'Printer';
const NETWORK = 'NetworkEquipment';
const PRINTER = 'Printer';

static $rightname = 'plugin_addressing';

Expand Down Expand Up @@ -64,58 +64,58 @@ function reserveip($input = array())

// Find computer
$item = new $input['type']();
$id = 0;
$id = 0;
if (!$item->getFromDBByQuery("WHERE `name`='" . $input["name"] . "' AND `entities_id`=" . $input['entities_id'] . " LIMIT 1")) {
// Add computer
$id = $item->add(array("name" => $input["name"],
"entities_id" => $input['entities_id'],
'states_id' => $input["states_id"],
"comment" => $input['comment']));
$id = $item->add(array("name" => $input["name"],
"entities_id" => $input['entities_id'],
'states_id' => $input["states_id"],
"comment" => $input['comment']));
} else {
$id = $item->getID();
//update item
$item->update(array("id" => $id,
"entities_id" => $input['entities_id'],
'states_id' => $input["states_id"],
"comment" => $input['comment']));
$item->update(array("id" => $id,
"entities_id" => $input['entities_id'],
'states_id' => $input["states_id"],
"comment" => $input['comment']));
}

// Add a new port
if ($id) {
switch ($input['type']) {
case 'NetworkEquipment' :
$newinput = array(
"itemtype" => $input['type'],
"items_id" => $id,
"entities_id" => $_SESSION["glpiactive_entity"],
"name" => self::getPortName($input["ip"]),
"instantiation_type" => "NetworkPortAggregate",
"_create_children" => 1,
"itemtype" => $input['type'],
"items_id" => $id,
"entities_id" => $_SESSION["glpiactive_entity"],
"name" => self::getPortName($input["ip"]),
"instantiation_type" => "NetworkPortAggregate",
"_create_children" => 1,
"NetworkName__ipaddresses" => array("-100" => $input["ip"]),
"mac" => $input["mac"],
"mac" => $input["mac"],
);
break;
case 'Computer':
case 'Printer':
$newinput = array(
"itemtype" => $input['type'],
"items_id" => $id,
"entities_id" => $_SESSION["glpiactive_entity"],
"name" => self::getPortName($input["ip"]),
"instantiation_type" => "NetworkPortEthernet",
"_create_children" => 1,
"itemtype" => $input['type'],
"items_id" => $id,
"entities_id" => $_SESSION["glpiactive_entity"],
"name" => self::getPortName($input["ip"]),
"instantiation_type" => "NetworkPortEthernet",
"_create_children" => 1,
"NetworkName__ipaddresses" => array("-100" => $input["ip"]),
"mac" => $input["mac"],
"mac" => $input["mac"],
);
break;
}

$np = new NetworkPort();
$np = new NetworkPort();
$newID = $np->add($newinput);

Event::log($newID, "networkport", 5, "inventory",
//TRANS: %s is the user login
sprintf(__('%s adds an item'), $_SESSION["glpiname"]));
sprintf(__('%s adds an item'), $_SESSION["glpiname"]));
}
}

Expand All @@ -127,17 +127,17 @@ function reserveip($input = array())
*/
function checkMandatoryFields($input)
{
$msg = array();
$msg = array();
$checkKo = false;

$mandatory_fields = array('name' => __("Object's name", 'addressing'),
'ip' => _n("IP address", "IP addresses", 1));
'ip' => _n("IP address", "IP addresses", 1));

foreach ($input as $key => $value) {
if (isset($mandatory_fields[$key])) {
if ((isset($value) && empty($value)) || !isset($value)) {
$msg[$key] = $mandatory_fields[$key];
$checkKo = true;
$checkKo = true;
}
}
}
Expand Down Expand Up @@ -201,8 +201,8 @@ function showForm($ip, $id_addressing, $randmodal)
<td>" . __("Type") . "</td>
<td>";
Dropdown::showFromArray('type', array(PluginAddressingReserveip::COMPUTER => Computer::getTypeName(),
PluginAddressingReserveip::NETWORK => NetworkEquipment::getTypeName(),
PluginAddressingReserveip::PRINTER => Printer::getTypeName()), array('on_change' => "nameIsThere(\"" . $CFG_GLPI['root_doc'] . "\");"));
PluginAddressingReserveip::NETWORK => NetworkEquipment::getTypeName(),
PluginAddressingReserveip::PRINTER => Printer::getTypeName()), array('on_change' => "nameIsThere(\"" . $CFG_GLPI['root_doc'] . "\");"));
echo "</td><td></td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>
Expand Down Expand Up @@ -239,7 +239,7 @@ function showForm($ip, $id_addressing, $randmodal)
echo "<tr class='tab_bg_1'>
<td colspan='4' class='center'>
<input type='submit' name='add' class='submit' value='" . __("Validate the reservation", 'addressing') . "' "
. "onclick=\"" . Html::jsGetElementbyID("reserveip" . $randmodal) . ".dialog('close');window.location.reload();return true;\"/>
. "onclick=\"" . Html::jsGetElementbyID("reserveip" . $randmodal) . ".dialog('close');window.location.reload();return true;\"/>
</td>
</tr>
</table>";
Expand Down
6 changes: 3 additions & 3 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ function plugin_version_addressing() {
'author' => 'Gilles Portheault, Xavier Caillaud, Remi Collet, Nelly Mahu-Lasson',
'license' => 'GPLv2+',
'homepage' => 'https://github.com/pluginsGLPI/addressing',
'minGlpiVersion' => '0.85');// For compatibility / no install in version < 0.85
'minGlpiVersion' => '9.1.1');// For compatibility / no install in version < 9.1.1
}


// Optional : check prerequisites before install : may print errors or add to message after redirect
function plugin_addressing_check_prerequisites() {

if (version_compare(GLPI_VERSION,'0.85.3','lt') || version_compare(GLPI_VERSION,'9.2','ge')) {
_e('This plugin requires GLPI >= 0.85.3', 'addressing');
if (version_compare(GLPI_VERSION, '9.1.1', 'lt') || version_compare(GLPI_VERSION, '9.2', 'ge')) {
echo "This plugin requires GLPI = 9.1.1";
return false;
}
return true;
Expand Down

0 comments on commit cc4685a

Please sign in to comment.