Commit f92ce405 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '6039-update-the-system-plugin' into '1.4-dev'

Resolve "update the system plugin"

See merge request fusiondirectory/fd-plugins!699
parents 7f668b4c a12f0708
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2003 Cajus Pollmeier
Copyright (C) 2011-2020 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class interfacesManagement extends management implements SimpleTab
{
protected $skipCpHandler = TRUE;
public static $skipSnapshots = TRUE;
public static $skipTemplates = TRUE;
protected $skipConfiguration = TRUE;
/* Vars needed for simpleTabs */
public $is_account = TRUE;
public $ignore_account = TRUE;
public $dn;
public $is_template = FALSE;
public $parent = NULL;
public $acl_category = '';
protected $current = '';
protected $backup = NULL;
var $read_only = FALSE;
var $acl;
var $cn;
public static $columns = [
['ObjectTypeColumn', []],
['LinkColumn', ['attributes' => 'nameAttr', 'label' => 'Name']],
['Column', ['attributes' => 'macAddress', 'label' => 'Mac']],
['Column', ['attributes' => 'fdNetworkInterfaceVlanId', 'label' => 'VLAN id']],
['Column', ['attributes' => 'fdNetworkInterfaceVlanTag', 'label' => 'VLAN tag']],
['Column', ['attributes' => 'fdNetworkInterfaceSubnetDN', 'label' => 'Subnet']],
['IpColumn', ['attributes' => 'ipHostNumber', 'label' => 'IP']],
['ActionsColumn', ['label' => 'Actions']],
];
static function plInfo (): array
{
return [
'plShortName' => _('Interfaces'),
'plDescription' => _('Edit the network interfaces of a system'),
'plIcon' => 'geticon.php?context=applications&icon=network&size=48',
'plSmallIcon' => 'geticon.php?context=applications&icon=network&size=16',
'plObjectType' => ['server','workstation','terminal','printer','component','phone','mobilePhone'],
'plPriority' => 2,
'plProvidedAcls' => []
];
}
function __construct (string $dn, $object, $parent = NULL)
{
global $config;
$this->dn = $dn;
if (isset($object->attrs)) {
$this->attrs = $object->attrs;
}
$this->parent = $parent;
parent::__construct(['networkInterface'], []);
}
protected function setUpListing ()
{
/* Set baseMode to FALSE */
$this->listing = new managementListing($this, FALSE);
$this->listing->setBase($this->dn);
}
function openTabObject ($object)
{
parent::openTabObject($object);
$this->tabObject->getBaseObject()->base = $this->dn;
}
/*! \brief No checks here.
*/
public function check (): array
{
return [];
}
/*! \brief Keep posted form values in opened dialogs
*/
function save_object ()
{
// save_object of the dialog is called in management::execute
}
public function remove (bool $fulldelete = FALSE): array
{
$errors = [];
return $errors;
}
public function save (): array
{
$errors = [];
return $errors;
}
/*! \brief Prepare active services to be copied.
*/
public function resetCopyInfos ()
{
$this->dn = 'new';
}
/*! \brief Forward plugin acls
*/
public function set_acl_category (string $category)
{
$this->acl_category = $category;
}
public function setTemplate (bool $bool)
{
}
public function getRequiredAttributes (): array
{
return [];
}
public function adapt_from_template (array $attrs, array $skip = [])
{
}
/*!
* \brief Can we delete the object
*
* Only used on main tab
*
* \param string $base
*/
public function acl_is_removeable (string $base = NULL): bool
{
return TRUE;
}
/*!
* \brief Sets whether the opened objet has an edit button
*
* \param bool $needEditMode
*/
public function setNeedEditMode (bool $needEditMode)
{
}
/*!
* \brief Is there a modal dialog opened
*/
public function is_modal_dialog (): bool
{
return $this->dialogOpened();
}
/*!
* \brief Returns TRUE if this attribute should be asked in the creation by template dialog
*/
public function showInTemplate (string $attr, array $templateAttrs): bool
{
return FALSE;
}
/*!
* \brief Deserialize values
*/
public function deserializeValues (array $values, bool $checkAcl = TRUE)
{
}
public function aclHasPermissions (): bool
{
return FALSE;
}
/*!
* \brief Get the acl permissions for an attribute or the plugin itself
*/
public function aclGetPermissions ($attribute = '0', string $base = NULL, bool $skipWrite = FALSE): string
{
return '';
}
/*!
* \brief Merge in objectClasses needed by this tab
*
* Used by prepare_save and template::apply
*/
public function mergeObjectClasses (array $oc): array
{
return $oc;
}
/*!
* \brief Fill attributes which may be used in hooks
*
* Used by simplePlugin::callHook
*/
public function fillHookAttrs (array &$addAttrs)
{
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org)
Copyright (C) 2019-2020 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class networkInterface extends simplePlugin
{
public $base;
public static function plInfo (): array
{
return [
'plShortName' => _('Interface'),
'plDescription' => _('Network interface'),
'plObjectClass' => ['fdNetworkInterface'],
'plObjectType' => ['networkInterface' => [
'name' => _('Network interface'),
'ou' => '',
'icon' => 'geticon.php?context=category&icon=network&size=16',
]],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo())
];
}
static function getAttributesInfo (): array
{
return [
'main' => [
'name' => _('General information'),
'attrs' => [
new HostNameAttribute(
_('Name'), _('Interface name'),
'cn', TRUE
),
new MacAddressAttribute(
_('Mac address'), _('Mac address of this system'),
'macAddress', FALSE
),
new SelectAttribute(
_('VLAN'), _('VLAN'),
'fdNetworkInterfaceVlanId', FALSE
),
new StringAttribute(
_('VLAN tag'), _('VLAN tag'),
'fdNetworkInterfaceVlanTag', FALSE
),
new ObjectSelectAttribute(
_('Subnet'), _('Subnet'),
'fdNetworkInterfaceSubnetDN', FALSE,
'ipamSubnet'
),
new SetAttribute(
new IPAttribute(
_('IP address'), _('IP addresses this system uses (v4 or v6)'),
'ipHostNumber', FALSE
)
),
]
],
];
}
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
global $config;
parent::__construct($dn, $object, $parent, $mainTab);
$vlans = objects::ls('ipamVlan', ['fdIpamVlanInnerId' => 1,'cn' => 1]);
$this->attributesAccess['fdNetworkInterfaceVlanId']->setChoices(array_column($vlans, 'fdIpamVlanInnerId'), array_column($vlans, 'cn'));
}
}
...@@ -71,6 +71,24 @@ attributetype ( 1.3.6.1.4.1.38414.78.11.2 NAME 'fdIpamVlanQinQId' ...@@ -71,6 +71,24 @@ attributetype ( 1.3.6.1.4.1.38414.78.11.2 NAME 'fdIpamVlanQinQId'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE ) SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.38414.78.12.1 NAME 'fdNetworkInterfaceVlanId'
DESC 'FusionDirectory - Network interface VLAN Inner Id'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.38414.78.12.2 NAME 'fdNetworkInterfaceVlanTag'
DESC 'FusionDirectory - Network interface VLAN tag'
EQUALITY caseExactIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.38414.78.12.3 NAME 'fdNetworkInterfaceSubnetDN'
DESC 'FusionDirectory - Network interface subnet DN'
EQUALITY distinguishedNameMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.12
SINGLE-VALUE )
# Objectclasses # Objectclasses
objectclass ( 1.3.6.1.4.1.38414.78.2.1 NAME 'fdIpamSubnet' objectclass ( 1.3.6.1.4.1.38414.78.2.1 NAME 'fdIpamSubnet'
...@@ -91,3 +109,13 @@ objectclass ( 1.3.6.1.4.1.38414.78.2.2 NAME 'fdIpamVlan' ...@@ -91,3 +109,13 @@ objectclass ( 1.3.6.1.4.1.38414.78.2.2 NAME 'fdIpamVlan'
fdIpamActive $ fdIpamActive $
fdIpamVlanInnerId $ fdIpamVlanQinQId $ fdIpamApplicant fdIpamVlanInnerId $ fdIpamVlanQinQId $ fdIpamApplicant
) ) ) )
objectclass ( 1.3.6.1.4.1.38414.78.2.3 NAME 'fdNetworkInterface'
DESC 'FusionDirectory - Network interface object'
MUST ( cn )
MAY (
macAddress $
fdNetworkInterfaceVlanId $ fdNetworkInterfaceVlanTag $
fdNetworkInterfaceSubnetDN $
ipHostNumber
) )
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