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

:sparkles: feat(management) Allow management classes to hide scope checkbox

FAI management has baseMode on but does want a fixed scope, so added a
 way to do that.

issue #5980
Showing with 20 additions and 9 deletions
+20 -9
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<hr/> <hr/>
{if $BASEMODE} {if $SHOWSCOPE}
<label for="SCOPE"> <label for="SCOPE">
<input type="checkbox" id="SCOPE" name="SCOPE" value="1" <input type="checkbox" id="SCOPE" name="SCOPE" value="1"
{if ($SCOPE == 'sub')}checked="checked"{/if}/> {if ($SCOPE == 'sub')}checked="checked"{/if}/>
......
<?php <?php
/* /*
This code is part of FusionDirectory (http://www.fusiondirectory.org/) This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2017-2018 FusionDirectory
Copyright (C) 2017-2019 FusionDirectory
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -33,21 +34,19 @@ class managementFilter ...@@ -33,21 +34,19 @@ class managementFilter
protected $filterElements = []; protected $filterElements = [];
protected $fixedScope;
/* The management class */ /* The management class */
public $parent; public $parent;
public $pid; public $pid;
/*
* Each objectType has its filters
* */
/*! /*!
* \brief Create a management filter * \brief Create a management filter
* *
* \param string $parent management instance * \param string $parent management instance
*/ */
function __construct (management $parent) function __construct (management $parent, bool $fixedScope = NULL)
{ {
global $config; global $config;
...@@ -66,6 +65,8 @@ class managementFilter ...@@ -66,6 +65,8 @@ class managementFilter
$this->filterElements = [ $this->filterElements = [
new TabFilterElement($this), new TabFilterElement($this),
]; ];
$this->fixedScope = $fixedScope;
} }
function setScope (string $scope) function setScope (string $scope)
...@@ -73,6 +74,14 @@ class managementFilter ...@@ -73,6 +74,14 @@ class managementFilter
$this->scope = $scope; $this->scope = $scope;
} }
protected function showScope (): bool
{
if ($this->fixedScope !== NULL) {
return !$this->fixedScope;
}
return $this->parent->listing->getBaseMode();
}
function addElement (FilterElement $element) function addElement (FilterElement $element)
{ {
$this->filterElements[] = $element; $this->filterElements[] = $element;
...@@ -91,7 +100,9 @@ class managementFilter ...@@ -91,7 +100,9 @@ class managementFilter
$this->showTemplates = isset($_POST['filter_type_TEMPLATE']); $this->showTemplates = isset($_POST['filter_type_TEMPLATE']);
$this->scope = (isset($_POST['SCOPE']) ? 'sub' : 'one'); if ($this->showScope()) {
$this->scope = (isset($_POST['SCOPE']) ? 'sub' : 'one');
}
$this->search = (isset($_POST['SEARCH']) ? $_POST['SEARCH'] : ''); $this->search = (isset($_POST['SEARCH']) ? $_POST['SEARCH'] : '');
...@@ -122,7 +133,7 @@ class managementFilter ...@@ -122,7 +133,7 @@ class managementFilter
$smarty = get_smarty(); $smarty = get_smarty();
$smarty->assign('SCOPE', $this->scope); $smarty->assign('SCOPE', $this->scope);
$smarty->assign('BASEMODE', $this->parent->listing->getBaseMode()); $smarty->assign('SHOWSCOPE', $this->showScope());
$smarty->assign('FILTER_PID', $this->pid); $smarty->assign('FILTER_PID', $this->pid);
$smarty->assign('SEARCH', $this->search); $smarty->assign('SEARCH', $this->search);
$smarty->assign('TYPES', $this->types); $smarty->assign('TYPES', $this->types);
......
Supports Markdown
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