Commit e9c9814c authored by Côme Chilliet's avatar Côme Chilliet

Merge branch '6099-displayheader-is-protected-but-accessed-from-outside' into '1.4-dev'

Resolve "$displayHeader is protected but accessed from outside"

See merge request fusiondirectory/fd!777
parents e6339fb8 4e01ed51
......@@ -81,7 +81,7 @@ class template
$tempTabObject->setActiveTabs($this->tabObject);
$this->attributes = [];
foreach ($this->tabObject->by_object as $class => $tab) {
if ($tab->is_account || $tab->ignore_account) {
if ($tab->isActive()) {
$this->attributes[$class] = [];
$attrs = array_unique(array_merge($tab->getRequiredAttributes(), $this->needed));
foreach (array_keys($tab->attributesAccess) as $attr) {
......@@ -312,7 +312,7 @@ class template
$this->tabObject = objects::open($targetdn, $this->type);
unset($this->attrs['objectClass']['count']);
foreach ($this->tabObject->by_object as $class => $plugin) {
if ($plugin->is_account || $plugin->ignore_account) {
if ($plugin->isActive()) {
$this->attrs['objectClass'] = $plugin->mergeObjectClasses($this->attrs['objectClass']);
}
}
......
......@@ -26,9 +26,9 @@
class multiPlugin extends simplePlugin
{
/* attribute list for save action */
var $objectclasses = [];
var $ignore_account = TRUE;
var $plugin = [];
var $objectclasses = [];
protected $ignore_account = TRUE;
var $plugin = [];
var $tabClass = '';
......@@ -137,7 +137,7 @@ class multiPlugin extends simplePlugin
$message = parent::check();
foreach ($this->plugin as &$plug) {
if ($plug->is_account || $plug->ignore_account) {
if ($plug->isActive()) {
$tmp = $plug->check();
$message = array_merge($message, $tmp);
}
......@@ -172,7 +172,7 @@ class multiPlugin extends simplePlugin
/* Save objects */
foreach ($this->plugin as &$plug) {
$plug->dn = $this->dn;
if ($plug->is_account || $plug->ignore_account) {
if ($plug->isActive()) {
$result = $plug->save();
} else {
$result = $plug->remove(FALSE);
......
......@@ -51,7 +51,7 @@ class simplePlugin implements SimpleTab
*/
public $is_account = FALSE;
public $initially_was_account = FALSE;
public $ignore_account = FALSE;
protected $ignore_account = FALSE;
public $acl_category = '';
......@@ -780,6 +780,22 @@ class simplePlugin implements SimpleTab
return $display;
}
/*!
* \brief Test whether a tab is active
*/
public function isActive (): bool
{
return ($this->is_account || $this->ignore_account);
}
/*!
* \brief Test whether a tab can be deactivated
*/
public function isActivatable (): bool
{
return $this->displayHeader;
}
/*! \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)
......
......@@ -152,7 +152,7 @@ class simpleTabs
function setActiveTabs (&$tabObject)
{
foreach ($this->by_object as $class => $plugin) {
if ($plugin->is_account || $plugin->ignore_account) {
if ($plugin->isActive()) {
$tabObject->by_object[$class]->is_account = $plugin->is_account;
}
}
......@@ -289,13 +289,13 @@ class simpleTabs
$cssClasses = $style[$index];
/* Take care about notifications */
if ($this->plNotify[$class] && ($obj->is_account || $obj->ignore_account)) {
if ($this->plNotify[$class] && $obj->isActive()) {
$cssClasses .= ' tab-notify';
}
if ($disabled) {
$cssClasses .= ' tab-disabled';
}
if (!$obj->is_account && !$obj->ignore_account) {
if (!$obj->isActive()) {
$cssClasses .= ' tab-inactive';
}
......@@ -365,7 +365,7 @@ class simpleTabs
/* Check all plugins */
foreach ($this->by_object as $key => $obj) {
$this->plNotify[$key] = FALSE;
if (($obj->is_account || $obj->ignore_account) && (!$obj->is_template)) {
if ($obj->isActive() && (!$obj->is_template)) {
logging::debug(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $key, "Checking");
$msg = $obj->check();
......@@ -386,8 +386,6 @@ class simpleTabs
/*
* \brief Save object in the tab
*
* \param boolean $ignore_account false
*/
function save ()
{
......@@ -434,7 +432,7 @@ class simpleTabs
$obj->dn = $this->dn;
if ($obj->is_account || $obj->ignore_account) {
if ($obj->isActive()) {
$result = $obj->save();
} else {
$result = $obj->remove(FALSE);
......@@ -550,7 +548,7 @@ class simpleTabs
/* Return tab or service if activated, FALSE otherwise */
function getTabOrServiceObject ($tab)
{
if (isset($this->by_object[$tab]) && ($this->by_object[$tab]->is_account || $this->by_object[$tab]->ignore_account)) {
if (isset($this->by_object[$tab]) && $this->by_object[$tab]->isActive()) {
return $this->by_object[$tab];
} elseif (is_subclass_of($tab, 'simpleService') && isset($this->by_object['servicesManagement'])) {
return $this->by_object['servicesManagement']->getServiceObject($tab);
......
......@@ -32,7 +32,6 @@ interface SimpleTab
/*
* Public vars expected as well by classes implementing this interface:
* bool $is_account
* bool $ignore_account
* string $dn
* bool $is_template
* string $_template_cn (only for main tab of templates)
......@@ -152,4 +151,14 @@ interface SimpleTab
* Used by simplePlugin::callHook
*/
public function fillHookAttrs (array &$addAttrs);
/*!
* \brief Test whether a tab is active
*/
public function isActive (): bool;
/*!
* \brief Test whether a tab can be deactivated
*/
public function isActivatable (): bool;
}
......@@ -166,7 +166,7 @@ class ogrouptabs extends simpleTabs_noSpecial
{
$tabObject->loadTabs($this->groupObjects);
foreach ($this->by_object as $class => $plugin) {
if ($plugin->is_account || $plugin->ignore_account) {
if ($plugin->isActive()) {
$tabObject->by_object[$class]->is_account = $plugin->is_account;
}
}
......
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