class_SudoSystemsAttribute.inc 2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)

  Copyright (C) 2003  Cajus Pollmeier
  Copyright (C) 2011-2019  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 SudoSystemsAttribute extends SystemsAttribute
{
  function renderButtons ()
  {
    $id = $this->getHtmlId();
    $buttons  = $this->renderInputField(
      'submit', 'add'.$id.'_ALL',
30
      [
31
32
        'value'           => 'ALL',
        'formnovalidate'  => 'formnovalidate'
33
      ]
34
35
36
37
    );
    return $buttons.parent::renderButtons();
  }

38
  public function htmlIds (): array
39
40
41
42
43
44
45
46
47
48
49
50
  {
    $id = $this->getHtmlId();
    $ids = parent::htmlIds();
    $ids[] = 'add'.$id.'_ALL';
    return $ids;
  }

  function loadPostValue ()
  {
    parent::loadPostValue();
    if ($this->isVisible()) {
      if (isset($_POST['add'.$this->getHtmlId().'_ALL'])) {
51
52
53
        $this->value    = ['ALL'];
        $this->displays = ['ALL'];
        $this->types    = [FALSE];
54
55
56
57
      }
    }
  }

58
  function addValue (string $dn, $entry = NULL)
59
60
  {
    if (isset($this->value[0]) && ($this->value[0] === 'ALL')) {
61
      $this->removeValue(0);
62
    }
63
    parent::addValue($dn, $entry);
64
  }
65
66
67
68
69
70
71
72
73
74

  protected function fillDisplayValue ($i)
  {
    if ($this->value[$i] === 'ALL') {
      $this->displays[$i] = 'ALL';
      $this->types[$i]    = FALSE;
    } else {
      parent::fillDisplayValue($i);
    }
  }
75
}