Skip to content

Commit

Permalink
config : adding specific right for access control
Browse files Browse the repository at this point in the history
  • Loading branch information
ericferon committed Jun 18, 2023
1 parent 920e66c commit ec2112a
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 60 deletions.
5 changes: 5 additions & 0 deletions dataflows.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
<author>Eric Feron</author>
</authors>
<versions>
<version>
<num>3.0.5</num>
<compatibility>~10.0.0</compatibility>
<download_url>https://github.com/ericferon/glpi-dataflows/releases/download/v3.0.5/dataflows-v3.0.5.tar.gz</download_url>
</version>
<version>
<num>3.0.4</num>
<compatibility>~10.0.0</compatibility>
Expand Down
46 changes: 19 additions & 27 deletions inc/configdf.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,12 @@
class PluginDataflowsConfigdf extends CommonDBTM {

public $dohistory=true;
static $rightname = "plugin_archibp";
static $rightname = "plugin_dataflows_configuration";
protected $usenotepad = true;

static function getTypeName($nb=0) {

return __('Configbp', 'archibp');
}

public static function canCreate() {
return Session::haveRight(static::$rightname, UPDATE);
}

public static function canView() {
return Session::haveRight(static::$rightname, READ);
return __('Dataflows Config', 'dataflows');
}

// search fields from GLPI 9.3 on
Expand Down Expand Up @@ -104,7 +96,7 @@ function rawSearchOptions() {
'id' => '11',
'table' => $this->getTable(),
'field' => 'row',
'name' => __('Row', 'archibp'),
'name' => __('Row', 'dataflows'),
'datatype' => 'text'
];

Expand All @@ -120,7 +112,7 @@ function rawSearchOptions() {
'id' => '13',
'table' => $this->getTable(),
'field' => 'is_linked',
'name' => __('Is linked to another class', 'archibp'),
'name' => __('Is linked to another class', 'dataflows'),
'datatype' => 'bool'
];

Expand All @@ -136,15 +128,15 @@ function rawSearchOptions() {
'id' => '15',
'table' => $this->getTable(),
'field' => 'nosearch',
'name' => __('Massive action allowed ?', 'archibp'),
'name' => __('Massive action allowed ?', 'dataflows'),
'datatype' => 'bool'
];

$tab[] = [
'id' => '16',
'table' => $this->getTable(),
'field' => 'forcegroupby',
'name' => __('Force group by ?', 'archibp'),
'name' => __('Force group by ?', 'dataflows'),
'datatype' => 'bool'
];

Expand Down Expand Up @@ -193,79 +185,79 @@ function showForm ($ID, $options=[]) {

echo "<tr class='tab_bg_1'>";
//field group
echo "<td>".__('Field group', 'archibp').": </td>";
echo "<td>".__('Field group', 'dataflows').": </td>";
echo "<td>";
Dropdown::show('PluginDataflowsConfigdfFieldgroup', ['value' => $this->fields['plugin_dataflows_configdffieldgroups_id']]);
echo "</td>";
//row
echo "<td>".__('Row', 'archibp')."</td>";
echo "<td>".__('Row', 'dataflows')."</td>";
echo "<td>";
echo Html::input('row',['value' => $this->fields['row'], 'id' => "row", 'size' => 2]);
echo "</td>";
//horizontal alignment
echo "<td>".__('Hor.alignment', 'archibp')."</td>";
echo "<td>".__('Hor.alignment', 'dataflows')."</td>";
echo "<td>";
Dropdown::show('PluginDataflowsConfigdfHalign', ['value' => $this->fields['plugin_dataflows_configdfhaligns_id']]);
echo "</td>";
echo "</tr>";

echo "<tr class='tab_bg_1'>";
//db field type
echo "<td>".__('DB Field Type', 'archibp').": </td>";
echo "<td>".__('DB Field Type', 'dataflows').": </td>";
echo "<td>";
Dropdown::show('PluginDataflowsConfigdfDbfieldtype', ['value' => $this->fields['plugin_dataflows_configdfdbfieldtypes_id']]);
echo "</td>";
//search datatype
echo "<td>".__('Search Data Type', 'archibp').": </td>";
echo "<td>".__('Search Data Type', 'dataflows').": </td>";
echo "<td>";
Dropdown::show('PluginDataflowsConfigdfDatatype', ['value' => $this->fields['plugin_dataflows_configdfdatatypes_id']]);
echo "</td>";
//readonly
echo "<td>".__('Is read-only ?', 'archibp').": </td>";
echo "<td>".__('Is read-only ?', 'dataflows').": </td>";
echo "<td>";
Dropdown::showYesNo('is_readonly',$this->fields['is_readonly']);
echo "</td>";
echo "</tr>";

echo "<tr class='tab_bg_1'>";
//nosearch
echo "<td>".__('Search allowed ?', 'archibp').": </td>";
echo "<td>".__('Search allowed ?', 'dataflows').": </td>";
echo "<td>";
Dropdown::showYesNo('nosearch',$this->fields['nosearch']);
echo "</td>";
//massiveaction
echo "<td>".__('Massive action allowed ?', 'archibp')."</td>";
echo "<td>".__('Massive action allowed ?', 'dataflows')."</td>";
echo "<td>";
Dropdown::showYesNo('massiveaction',$this->fields['massiveaction']);
echo "</td>";
//forcegroupby
echo "<td>".__('Force group by ?', 'archibp')."</td>";
echo "<td>".__('Force group by ?', 'dataflows')."</td>";
echo "<td>";
Dropdown::showYesNo('forcegroupby',$this->fields['forcegroupby']);
echo "</td>";
echo "</tr>";

echo "<tr class='tab_bg_1'>";
//islinked
echo "<td>".__('Is linked to another class ?', 'archibp').": </td>";
echo "<td>".__('Is linked to another class ?', 'dataflows').": </td>";
echo "<td>";
Dropdown::showYesNo('is_linked',$this->fields['is_linked']);
echo "</td>";
//linked table
echo "<td>".__('Linked class', 'archibp')."</td>";
echo "<td>".__('Linked class', 'dataflows')."</td>";
echo "<td>";
Dropdown::show('PluginDataflowsConfigdfLink', ['value' => $this->fields['plugin_dataflows_configdflinks_id']]);
echo "</td>";
//link field
echo "<td>".__('Linked by field', 'archibp')."</td>";
echo "<td>".__('Linked by field', 'dataflows')."</td>";
echo "<td>";
echo Html::input('linkfield',['value' => $this->fields['linkfield'], 'id' => "linkfield"]);
echo "</td>";
echo "</tr>";

echo "<tr class='tab_bg_1'>";
//join parameters
echo "<td>".__('Join parameters', 'archibp')."</td>";
echo "<td>".__('Join parameters', 'dataflows')."</td>";
echo "<td colspan='5'>";
echo Html::input('joinparams',['value' => $this->fields['joinparams'], 'id' => "joinparams"]);
echo "</td>";
Expand Down
2 changes: 1 addition & 1 deletion inc/configdfdatatype.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class PluginDataflowsConfigdfDatatype extends CommonDropdown {

static $rightname = "plugin_archibp";
static $rightname = "plugin_dataflows_configuration";
var $can_be_translated = true;

static function getTypeName($nb=0) {
Expand Down
2 changes: 1 addition & 1 deletion inc/configdfdbfieldtype.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class PluginDataflowsConfigdfDbfieldtype extends CommonDropdown {

static $rightname = "plugin_archibp";
static $rightname = "plugin_dataflows_configuration";
var $can_be_translated = true;

static function getTypeName($nb=0) {
Expand Down
12 changes: 6 additions & 6 deletions inc/configdffieldgroup.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class PluginDataflowsConfigdfFieldgroup extends CommonDropdown {

static $rightname = "plugin_archibp";
static $rightname = "plugin_dataflows_configuration";
var $can_be_translated = true;

static function getTypeName($nb=0) {
Expand All @@ -43,32 +43,32 @@ public function getAdditionalFields() {
[
'name' => 'sortorder',
'type' => 'text',
'label' => __('Sort order', 'archibp'),
'label' => __('Sort order', 'dataflows'),
'list' => false
],
[
'name' => 'is_visible',
'type' => 'bool',
'label' => __('Is visible on opening', 'archibp'),
'label' => __('Is visible on opening', 'dataflows'),
'list' => false
]
];
}

function rawSearchOptions() {
$opt = CommonDropdown::rawSearchOptions();
// $sopt['common'] = __("App structures", "archibp");
// $sopt['common'] = __("App structures", "dataflows");

$opt[2400]['id'] = 2400;
$opt[2400]['table'] = $this->getTable();
$opt[2400]['field'] = 'sortorder';
$opt[2400]['name'] = __('Sort order', 'archibp');
$opt[2400]['name'] = __('Sort order', 'dataflows');
$opt[2400]['datatype'] = 'text';

$opt[2401]['id'] = 2401;
$opt[2401]['table'] = $this->getTable();
$opt[2401]['field'] = 'is_visible';
$opt[2401]['name'] = __('Is visible on opening', 'archibp');
$opt[2401]['name'] = __('Is visible on opening', 'dataflows');
$opt[2401]['datatype'] = 'bool';

return $opt;
Expand Down
2 changes: 1 addition & 1 deletion inc/configdfhalign.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class PluginDataflowsConfigdfHalign extends CommonDropdown {

static $rightname = "plugin_archibp";
static $rightname = "plugin_dataflows_configuration";
var $can_be_translated = true;

static function getTypeName($nb=0) {
Expand Down
22 changes: 11 additions & 11 deletions inc/configdflink.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class PluginDataflowsConfigdfLink extends CommonDropdown {

static $rightname = "plugin_archibp";
static $rightname = "plugin_dataflows_configuration";
var $can_be_translated = true;

static function getTypeName($nb=0) {
Expand All @@ -42,61 +42,61 @@ public function getAdditionalFields() {
[
'name' => 'has_dropdown',
'type' => 'bool',
'label' => __('Has own dropdown', 'archibp'),
'label' => __('Has own dropdown', 'dataflows'),
'list' => false
],
[
'name' => 'is_entity_limited',
'type' => 'bool',
'label' => __('Is limited by entity', 'archibp'),
'label' => __('Is limited by entity', 'dataflows'),
'list' => false
],
[
'name' => 'is_tree_dropdown',
'type' => 'bool',
'label' => __('Is hierarchical dropdown', 'archibp'),
'label' => __('Is hierarchical dropdown', 'dataflows'),
'list' => false
],
[
'name' => 'as_view_on',
'type' => 'text',
'label' => __('As view on table', 'archibp'),
'label' => __('As view on table', 'dataflows'),
'list' => false
],
[
'name' => 'viewlimit',
'type' => 'text',
'label' => __('View limited by WHERE clause', 'archibp'),
'label' => __('View limited by WHERE clause', 'dataflows'),
'list' => false
]
];
}
function rawSearchOptions() {
$opt = CommonDropdown::rawSearchOptions();
// $sopt['common'] = __("App structures", "archibp");
// $sopt['common'] = __("App structures", "dataflows");

$opt[2400]['id'] = 2400;
$opt[2400]['table'] = $this->getTable();
$opt[2400]['field'] = 'has_dropdown';
$opt[2400]['name'] = __('Has own dropdown', 'archibp');
$opt[2400]['name'] = __('Has own dropdown', 'dataflows');
$opt[2400]['datatype'] = 'boolean';

$opt[2401]['id'] = 2401;
$opt[2401]['table'] = $this->getTable();
$opt[2401]['field'] = 'is_entity_limited';
$opt[2401]['name'] = __('Is limited by entity', 'archibp');
$opt[2401]['name'] = __('Is limited by entity', 'dataflows');
$opt[2401]['datatype'] = 'boolean';

$opt[2402]['id'] = 2402;
$opt[2402]['table'] = $this->getTable();
$opt[2402]['field'] = 'is_tree_dropdown';
$opt[2402]['name'] = __('Is hierarchical dropdown', 'archibp');
$opt[2402]['name'] = __('Is hierarchical dropdown', 'dataflows');
$opt[2402]['datatype'] = 'boolean';

$opt[2403]['id'] = 2403;
$opt[2403]['table'] = $this->getTable();
$opt[2403]['field'] = 'as_view_on';
$opt[2403]['name'] = __('As view on table', 'archibp');
$opt[2403]['name'] = __('As view on table', 'dataflows');
$opt[2403]['datatype'] = 'text';

return $opt;
Expand Down
6 changes: 3 additions & 3 deletions inc/configdfmenu.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
--------------------------------------------------------------------------
*/
class PluginDataflowsConfigdfMenu extends CommonGLPI {
static $rightname = 'plugin_dataflows';
static $rightname = 'plugin_dataflows_configuration';

static function getMenuName() {
return _n('Dataflows configuration', 'Dataflows configuration', 2, 'dataflows');
Expand Down Expand Up @@ -53,8 +53,8 @@ static function removeRightsFromSession() {
if (isset($_SESSION['glpimenu']['configdf']['types']['PluginDataflowsConfigdfMenu'])) {
unset($_SESSION['glpimenu']['configdf']['types']['PluginDataflowsConfigdfMenu']);
}
if (isset($_SESSION['glpimenu']['configdf']['content']['pluginarchibpconfigbpmenu'])) {
unset($_SESSION['glpimenu']['configdf']['content']['pluginarchibpconfigbpmenu']);
if (isset($_SESSION['glpimenu']['configdf']['content']['plugindataflowsconfigdfmenu'])) {
unset($_SESSION['glpimenu']['configdf']['content']['plugindataflowsconfigdfmenu']);
}
}
}
Loading

0 comments on commit ec2112a

Please sign in to comment.