File: class_trustSelect.inc

package info (click to toggle)
fusiondirectory 1.0.8.2-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 28,984 kB
  • sloc: php: 74,645; xml: 3,645; perl: 1,555; pascal: 705; sh: 135; sql: 45; makefile: 19
file content (169 lines) | stat: -rw-r--r-- 5,039 bytes parent folder | download | duplicates (2)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php

/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  Copyright (C) 2003  Cajus Pollmeier
  Copyright (C) 2011-2013  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 trustSelect extends management
{

  protected $skipFooter = TRUE;
  protected $skipHeader = TRUE;

  function __construct($config, $ui)
  {
    $this->config = $config;
    $this->ui     = $ui;

    $this->storagePoints = array(get_ou("workstationRDN"),get_ou("terminalRDN"),get_ou("serverRDN"),get_ou("sambaMachineAccountRDN"),);

    $filter = new filter(get_template_path("trust-filter.xml", TRUE, dirname(__FILE__)));
    $filter->setObjectStorage($this->storagePoints);
    $this->setFilter($filter);

    // Build headpage
    $headpage = new listing(get_template_path("trust-list.xml", TRUE, dirname(__FILE__)));
    $headpage->registerElementFilter("filterProperties", "groupManagement::filterProperties");
    $headpage->setFilter($filter);
    parent::__construct($config, $ui, "groups", $headpage);
  }


  static function filterProperties($row, $classes)
  {
    $result = "";

    $map = array(
        "posixGroup" =>
        array(
          "image"   => "plugins/groups/images/groups.png",
          "plugin"  => "group",
          "alt"     => _("Posix"),
          "title"   => _("Edit posix properties")
          ),

        "gosaMailAccount" =>
        array(
          "image"   => "plugins/groups/images/mail.png",
          "plugin"  => "mailgroup",
          "alt"     => _("Mail"),
          "title"   => _("Edit mail properties")
          ),

        "sambaGroupMapping" =>
        array(
          "image"   => "plugins/groups/images/samba.png",
          "plugin"  => "group",
          "alt"     => _("Samba"),
          "title"   => _("Edit samba properties")
          ),

        "goFonPickupGroup" =>
          array(
              "image"   => "plugins/groups/images/asterisk.png",
              "plugin"  => "group",
              "alt"     => _("Phone"),
              "title"   => _("Edit phone properties")
              ),

        "gotoMenuGroup" =>
          array(
              "image"   => "plugins/groups/images/menu.png",
              "plugin"  => "appgroup",
              "alt"     => _("Menu"),
              "title"   => _("Edit start menu properties")
              ),

        "gotoEnvironment" =>
          array(
              "image"   => "plugins/groups/images/environment.png",
              "plugin"  => "environment",
              "alt"     => _("Environment"),
              "title"   => _("Edit environment properties")
              )
          );


    // Walk thru map
    foreach ($map as $oc => $properties) {
      if (in_array_ics($oc, $classes)) {
        $result .= "<input class='center' type='image' src='".$properties['image']."' ".
          "alt='".$properties['alt']."' title='".$properties['title'].
                 "' name='listing_edit_".$properties['plugin']."_$row' style='padding:1px'>";
      } else {
        $result .= "<img src='images/empty.png' alt=' ' class='center' style='padding:1px'>";
      }
    }
    return $result;
  }
}

class TrustSelectDialog
{
  private $trustSelect;
  private $trustsAttribute;

  function __construct ($simplePlugin, $trustsAttribute)
  {
    $this->trustsAttribute  = $trustsAttribute;
    $this->trustSelect      = new trustSelect($simplePlugin->config, get_userinfo());
  }

  function execute ()
  {
    if (isset($_POST['add_ws_cancel'])) {
      return FALSE;
    }
    if (isset($_POST['add_ws_finish'])) {
      $systems = $this->trustSelect->detectPostActions();
      if (isset($systems['targets'])) {
        $headpage = $this->trustSelect->getHeadpage();
        foreach ($systems['targets'] as $dn) {
          $attrs = $headpage->getEntry($dn);

          $this->trustsAttribute->addValue($dn, $attrs);
        }
      }
      return FALSE;
    }
    session::set('filterBlacklist', $this->trustsAttribute->getFilterBlackList());
    return $this->trustSelect->execute();
  }
}

class TrustsAttribute extends DialogAttribute
{
  protected $dialogClass = "TrustSelectDialog";

  function addValue ($dn, $entry)
  {
    $value = $entry['cn'][0];
    if (!in_array($value, $this->value)) {
      $this->value[]    = $value;
    }
  }

  function getFilterBlackList ()
  {
    return array('cn' => $this->getValue());
  }
}


?>