Verified Commit 5d55120b authored by Côme Chilliet's avatar Côme Chilliet
Browse files

feat(ipam) Sync System fields with interfaces IP and Macs

issue #6039
parent a12f0708
...@@ -46,7 +46,6 @@ class interfacesManagement extends management implements SimpleTab ...@@ -46,7 +46,6 @@ class interfacesManagement extends management implements SimpleTab
var $cn; var $cn;
public static $columns = [ public static $columns = [
['ObjectTypeColumn', []],
['LinkColumn', ['attributes' => 'nameAttr', 'label' => 'Name']], ['LinkColumn', ['attributes' => 'nameAttr', 'label' => 'Name']],
['Column', ['attributes' => 'macAddress', 'label' => 'Mac']], ['Column', ['attributes' => 'macAddress', 'label' => 'Mac']],
['Column', ['attributes' => 'fdNetworkInterfaceVlanId', 'label' => 'VLAN id']], ['Column', ['attributes' => 'fdNetworkInterfaceVlanId', 'label' => 'VLAN id']],
...@@ -81,6 +80,8 @@ class interfacesManagement extends management implements SimpleTab ...@@ -81,6 +80,8 @@ class interfacesManagement extends management implements SimpleTab
$this->parent = $parent; $this->parent = $parent;
parent::__construct(['networkInterface'], []); parent::__construct(['networkInterface'], []);
$this->parent->getBaseObject()->setNetworkAttributesReadOnly(TRUE);
} }
protected function setUpListing () protected function setUpListing ()
...@@ -108,18 +109,32 @@ class interfacesManagement extends management implements SimpleTab ...@@ -108,18 +109,32 @@ class interfacesManagement extends management implements SimpleTab
function save_object () function save_object ()
{ {
// save_object of the dialog is called in management::execute // save_object of the dialog is called in management::execute
/* Sync base tab fields with interfaces */
$entryIterator = $this->listing->getIterator();
$macAddress = [];
$ipHostNumber = [];
foreach ($entryIterator as $entry) {
if (!empty($entry['macAddress'])) {
array_push($macAddress, ...$entry['macAddress']);
}
if (!empty($entry['ipHostNumber'])) {
array_push($ipHostNumber, ...$entry['ipHostNumber']);
}
}
$this->parent->getBaseObject()->macAddress = array_values(array_unique($macAddress));
$this->parent->getBaseObject()->ipHostNumber = array_values(array_unique($ipHostNumber));
} }
public function remove (bool $fulldelete = FALSE): array public function remove (bool $fulldelete = FALSE): array
{ {
$errors = []; return [];
return $errors;
} }
public function save (): array public function save (): array
{ {
$errors = []; return [];
return $errors;
} }
/*! \brief Prepare active services to be copied. /*! \brief Prepare active services to be copied.
......
...@@ -32,7 +32,8 @@ class networkInterface extends simplePlugin ...@@ -32,7 +32,8 @@ class networkInterface extends simplePlugin
'plObjectType' => ['networkInterface' => [ 'plObjectType' => ['networkInterface' => [
'name' => _('Network interface'), 'name' => _('Network interface'),
'ou' => '', 'ou' => '',
'icon' => 'geticon.php?context=category&icon=network&size=16', 'icon' => 'images/empty.png',
'tabClass' => 'simpleTabs_noSpecial',
]], ]],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo()) 'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
*/ */
class ipHostPlugin extends simplePlugin class ipHostPlugin extends simplePlugin
{ {
protected $networkAttributesReadOnly = FALSE;
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE) function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{ {
global $config; global $config;
...@@ -51,4 +53,21 @@ class ipHostPlugin extends simplePlugin ...@@ -51,4 +53,21 @@ class ipHostPlugin extends simplePlugin
} }
return parent::mergeObjectClasses($objectclasses); return parent::mergeObjectClasses($objectclasses);
} }
public function setNetworkAttributesReadOnly (bool $networkAttributesReadOnly)
{
$this->networkAttributesReadOnly = $networkAttributesReadOnly;
}
public function attrIsWriteable ($attr): bool
{
if (!is_object($attr)) {
$attr = $this->attributesAccess[$attr];
}
if ($this->networkAttributesReadOnly && in_array($attr->getLdapName(), ['ipHostNumber','macAddress'])) {
return FALSE;
} else {
return parent::attrIsWriteable($attr);
}
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment