class_groupManagement.inc 5.81 KB
Newer Older
1
2
3
4
<?php
/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  Copyright (C) 2003  Cajus Pollmeier
5
  Copyright (C) 2011-2015  FusionDirectory
6
7
8
9
10
11
12
13
14
15
16
17
18

  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
19
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20
21
*/

22
class groupManagement extends simpleManagement
23
{
24
  protected $objectTypes  = array('ogroup', 'role', 'group');
25
26

  protected $autoFilter = FALSE;
27

28
29
30
  static function plInfo()
  {
    return array(
31
32
33
      'plShortName'   => _('Groups and roles'),
      'plDescription' => _('Manage groups and roles'),
      'plIcon'        => 'geticon.php?context=types&icon=resource-group&size=48',
34
      'plSection'     => 'accounts',
35
      'plManages'     => array('ogroup', 'group', 'role'),
36
      'plPriority'    => 20,
37

38
      'plProvidedAcls' => array()
39
40
41
    );
  }

42
  function __construct($config, $ui)
43
  {
44
45
    $this->filterXMLPath  = get_template_path('group-filter.xml', TRUE, dirname(__FILE__));
    $this->listXMLPath    = get_template_path('group-list.xml', TRUE, dirname(__FILE__));
46

47
    parent::__construct($config, $ui);
48
    $this->headpage->registerElementFilter('filterProperties', 'groupManagement::filterProperties');
49
50
  }

51
  static function filterProperties($row, $dn, $gosaGroupObjects = NULL)
52
  {
53
54
55
    if (!empty($gosaGroupObjects)) {
      return self::filterGroupObjects($row, $gosaGroupObjects);
    }
56
57
58
59
60
61
62
63
64
65
66
67
    global $config;
    static $grouptabs = array();
    if (empty($grouptabs)) {
      foreach ($config->data['TABS']['GROUPTABS'] as $plug) {
        if ($plug['CLASS'] == 'group') {
          continue;
        }
        if (class_available($plug['CLASS'])) {
          $name = $plug['CLASS'];

          $grouptabs[$name] = new $name($config, $dn);
        }
68
69
70
      }
    }

71
72
73
    // Load information if needed
    $ldap = $config->get_ldap_link();
    $ldap->cat($dn);
74
    $result = "<input class='center' type='image' src='geticon.php?context=types&amp;icon=user-group&amp;size=16' ".
75
                       "alt='"._('Posix')."' title='"._('Edit posix properties')."' ".
76
77
                       "name='listing_edit_tab_group_$row' style='padding:1px'/>";
    if ($attrs = $ldap->fetch()) {
78
      if (objects::isOfType($attrs, 'role')) {
79
        return '<input class="center" type="image" src="geticon.php?context=types&amp;icon=role&amp;size=16" '.
80
81
                 'alt="'._('Role').'" title="'._('Edit role properties').'" '.
                 'name="listing_edit_'.$row.'" style="padding:1px"/>';
82
      }
83
84
85
86
      foreach ($grouptabs as $class => $grouptab) {
        if ($grouptab->is_this_account($attrs)) {
          $infos = pluglist::pluginInfos($class);
          if (isset($infos['plSmallIcon'])) {
87
            $result .= "<input class='center' type='image' src='".htmlentities($infos['plSmallIcon'], ENT_COMPAT, 'UTF-8')."' ".
88
89
90
                       "alt='".$infos['plShortName']."' title='".$infos['plShortName']."' ".
                       "name='listing_edit_tab_".$class."_$row' style='padding:1px'/>";
          } else {
91
            @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $infos['plShortName']." ($class)", 'No icon for');
92
93
94
95
          }
        } else {
          $result .= "<img src='images/empty.png' alt=' ' class='center optional $class' style='padding:1px'>";
        }
96
97
      }
    }
98

99
100
    return $result;
  }
101

102
103
104
105
106
107
108
109
110
  static function filterGroupObjects($row, $gosaGroupObjects)
  {
    $types  = preg_replace("/[^a-z]/i", "", $gosaGroupObjects[0]);
    $result = "";
    for ($i = 0; $i < strlen($types); $i++) {
      if ($types[$i] == 'I') {
        continue;
      }
      $info   = objects::infos(ogroup::$objectTypes[$types[$i]]);
111
      $result .= '<img class="center" src="'.htmlentities($info['icon'], ENT_COMPAT, 'UTF-8').'" '.
112
113
114
115
116
117
118
119
        'alt="'.$info['name'].'" title="'.$info['name'].'" style="padding:1px"/>';
    }
    if ($result == "") {
      return '&nbsp;';
    }
    return $result;
  }

120
121
122
123
  function renderList()
  {
    $smarty = get_smarty();
    $filters = array(
124
125
126
127
128
      array('id'  => 'USER',        'label'  => _('Show user groups')),
      array('id'  => 'PRIMARY',     'label'  => _('Show primary groups')),
      array('id'  => 'ROLE',        'label'  => _('Show organizational roles')),
      array('id'  => 'APPLICATION', 'label'  => _('Show application groups')),
      array('id'  => 'DEPARTMENT',  'label'  => _('Show department groups')),
129
    );
130
131
132
133
134
135
    if (class_available('mailAccount')) {
      $filters[]= array('id'  => 'MAIL',        'label'  => _('Show mail groups'));
    }
    if (class_available('sambaAccount')) {
      $filters[]= array('id'  => 'SAMBA',       'label'  => _('Show samba groups'));
    }
136
137
138
139
140
141
142
143
144
145
146
147
148
    if (class_available('systemManagement')) {
      $filters = array_merge(
        $filters,
        array(
          array('id'  => 'SERVER',      'label'  => _('Show server groups')),
          array('id'  => 'WORKSTATION', 'label'  => _('Show workstation groups')),
          array('id'  => 'WINDOWS',     'label'  => _('Show windows groups')),
          array('id'  => 'TERMINAL',    'label'  => _('Show terminal groups')),
          array('id'  => 'PRINTER',     'label'  => _('Show printer groups')),
          array('id'  => 'PHONE',       'label'  => _('Show phone groups')),
        )
      );
    }
149
150
151
    $smarty->assign('objectFilters', $filters);
    return management::renderList();
  }
152
}
153
?>