Verified Commit 7c7625eb authored by Côme Chilliet's avatar Côme Chilliet
Browse files

🚑 fix(systems) Improve template support for interfaces

Really basic masks are now working.
askme is not suppported, and ACLs are bypassed for now.

issue #6039
parent ab79110f
......@@ -108,7 +108,7 @@ class interfacesManagement extends management implements SimpleTab
foreach ($entryIterator as $entry) {
if ($this->is_template) {
$this->interfaces[$entry->dn] = objects::create($entry->getTemplatedType());
$this->interfaces[$entry->dn] = objects::createTemplate($entry->getTemplatedType());
$this->filter->resetFromCache($entry->dn, $this->interfaces[$entry->dn]);
} else {
$this->interfaces[$entry->dn] = objects::open($entry->dn, $entry->getTemplatedType());
......@@ -263,6 +263,9 @@ class interfacesManagement extends management implements SimpleTab
} else {
$this->tabObject->getBaseObject()->base = 'new,'.$this->parent->getBaseObject()->base;
}
if ($this->is_template) {
$this->tabObject->setTemplateMode('');
}
}
public function check (): array
......@@ -405,7 +408,23 @@ class interfacesManagement extends management implements SimpleTab
public function adapt_from_template (array $attrs, array $skip = [])
{
trigger_error('Not implemented');
$this->attrs = array_merge($this->attrs, $attrs);
if (isset($this->attrs['networkInterfaces']) && !in_array('networkInterfaces', $skip)) {
unset($this->attrs['networkInterfaces']['count']);
$this->filter->loadTemplateValues($this->attrs['networkInterfaces']);
$this->listing->update();
$entryIterator = $this->listing->getIterator();
$this->interfaces = [];
foreach ($entryIterator as $entry) {
$this->interfaces[$entry->dn] = objects::create($entry->getTemplatedType());
$this->filter->resetFromCache($entry->dn, $this->interfaces[$entry->dn]);
$this->interfaces[$entry->dn]->getBaseObject()->base = $this->dn;
}
}
}
/*!
......@@ -442,7 +461,27 @@ class interfacesManagement extends management implements SimpleTab
*/
public function showInTemplate (string $attr, array $templateAttrs): bool
{
return FALSE;
return TRUE;
}
/*! \brief Check if logged in user have enough right to read this attribute value
*
* \param mixed $attr Attribute object or name (in this case it will be fetched from attributesAccess)
*/
function attrIsReadable ($attr): bool
{
/* FIXME */
  • Take the required action to fix the issue indicated by this "FIXME" comment. 📘

Please register or sign in to reply
return TRUE;
}
/*! \brief Check if logged in user have enough right to write this attribute value
*
* \param mixed $attr Attribute object or name (in this case it will be fetched from attributesAccess)
*/
function attrIsWriteable ($attr): bool
{
/* FIXME */
  • Take the required action to fix the issue indicated by this "FIXME" comment. 📘

Please register or sign in to reply
return TRUE;
}
/*!
......
......@@ -109,6 +109,7 @@ class interfacesManagementFilter extends managementFilter
$values = json_decode($networkInterface, TRUE);
}
$entries[$values['dn']] = new ListingEntry($this->parent->listing, $this->parent->objectTypes[0], $values['dn'], $values, $row++);
$entries[$values['dn']]->aclBase = 'new,'.$this->parent->dn;
}
$this->entriesCache = [$entries, [$this->parent->objectTypes[0] => $row]];
}
......
......@@ -52,6 +52,9 @@ class servicesManagement extends management implements SimpleTab
var $acl;
var $cn;
/* Used by template and webservice */
public $attributesAccess = [];
/* Default columns */
public static $columns = [
['Column', ['attributes' => 'ServiceStatusColumn', 'label' => '!']],
......@@ -620,6 +623,24 @@ class servicesManagement extends management implements SimpleTab
return FALSE;
}
/*! \brief Check if logged in user have enough right to read this attribute value
*
* \param mixed $attr Attribute object or name (in this case it will be fetched from attributesAccess)
*/
function attrIsReadable ($attr): bool
{
return FALSE;
}
/*! \brief Check if logged in user have enough right to write this attribute value
*
* \param mixed $attr Attribute object or name (in this case it will be fetched from attributesAccess)
*/
function attrIsWriteable ($attr): bool
{
return FALSE;
}
/*!
* \brief Deserialize values
*/
......
  • SonarQube analysis reported 4 issues

    • 4 major

    Watch the comments in this conversation to review them.

    2 extra issues

    Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:

    1. Remove this commented out code. 📘
    2. Remove this commented out code. 📘
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