class_setupStepConfig.inc 4.61 KB
Newer Older
1
2
3
4
<?php
/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  Copyright (C) 2007 Fabian Hickert
5
  Copyright (C) 2011-2016  FusionDirectory
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

  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.
*/

22
class setupStepConfig_before_init extends setupStep
23
{
24
  function update_strings ()
25
26
27
28
29
30
  {
    global $config;
    if (!isset($config->current['BASE'])) {
      $config->current['BASE'] = '';
    }
    $infos = configInLdap::plInfo();
31
32
33
34
    $this->header_image   = $infos['plIcon'];
    $this->s_short_name   = $infos['plShortName'];
    $this->s_title        = $infos['plTitle'];
    $this->s_description  = $infos['plDescription'];
35
36
37
  }
}

38
class setupStepConfig extends configInLdap
39
40
41
42
43
44
{
  var $is_active    = FALSE;
  var $is_enabled   = FALSE;
  var $is_completed = FALSE;
  var $header_image;

45
46
  protected $objectclasses = array('fusionDirectoryConf');

47
  static function plInfo (): array
48
49
50
51
  {
    return array();
  }

52
  function __construct ($parent, $cv)
53
54
  {
    global $config;
55
    parent::__construct(CONFIGRDN.$config->current['BASE'], NULL, $parent, TRUE);
56

57
58
59
    $this->attributesInfo['miscellaneous']['class'] = array('invisible');
    $this->attributesInfo['debug']['class'] = array('invisible');

60
61
62
    $this->fdLanguage     = $cv['lang_selected'];
  }

63
  function update_strings ()
64
65
66
67
68
  {
    $infos = parent::plInfo();
    $this->header_image = $infos['plIcon'];
  }

69
  function get_short_name ()
70
71
  {
    $infos = parent::plInfo();
72
    return $infos['plTitle'];
73
74
  }

75
  function get_title ()
76
  {
77
    return $this->get_description();
78
79
  }

80
  function get_description ()
81
82
83
84
85
86
  {
    $infos = parent::plInfo();
    return $infos['plDescription'];
  }

  /* Return attributes handled by this setup step */
87
  function get_attributes ()
88
89
90
91
92
93
94
95
  {
    $tmp = array();
    foreach (array_keys($this->attributesAccess) as $attr) {
      $tmp[$attr] = $this->$attr;
    }
    return $tmp;
  }

96
  function save_object ()
97
98
99
  {
    global $config;
    parent::save_object();
100
    $this->is_completed = FALSE;
101
102
    $tmp = $this->check();
    if (count($tmp) == 0) {
103
104
105
      /* Create root object if missing */
      $ldap = $config->get_ldap_link();
      $ldap->cd($config->current['BASE']);
106
      $ldap->create_missing_trees($config->current['BASE'], FALSE);
107
      if (!$ldap->success()) {
108
109
110
111
112
113
        msg_dialog::display(
          _('LDAP error'),
          msgPool::ldaperror($ldap->get_error(), $config->current['BASE'], 'create_missing_trees', get_class()),
          LDAP_ERROR
        );
        return;
114
      }
115
      /* Save in LDAP */
116
117
118
119
120
      $errors = $this->save();
      if (!empty($errors)) {
        msg_dialog::displayChecks($errors);
        return;
      }
121
122
      /* Reload config from LDAP */
      $config->set_current($config->current['NAME']);
123
      session::global_un_set('plist');
124
      pluglist::load();
125
      $this->is_completed = TRUE;
126
      $this->parent->reBuildConfigStep(TRUE);
127
128
129
    }
  }

130
  function is_active ()
131
132
133
134
  {
    return $this->is_active;
  }

135
  function is_enabled ()
136
137
138
139
  {
    return $this->is_enabled;
  }

140
  function is_completed ()
141
142
143
144
  {
    return $this->is_completed;
  }

145
  function set_active ($value = TRUE)
146
  {
147
    $this->is_active = (bool) $value;
148
149
  }

150
  function set_enabled ($value = TRUE)
151
  {
152
    $this->is_enabled = (bool) $value;
153
154
  }

155
  function set_completed ($value = TRUE)
156
  {
157
    $this->is_completed = (bool) $value;
158
159
160
  }

  /* bypass acl system as there is no user login */
161
  function acl_is_writeable ($attribute, bool $skip_write = FALSE): bool
162
163
164
  {
    return TRUE;
  }
165
  function acl_is_readable ($attribute): bool
166
167
168
  {
    return TRUE;
  }
169
  function acl_is_createable ($base = ""): bool
170
171
172
  {
    return TRUE;
  }
173
  function acl_is_removeable ($base = ""): bool
174
175
176
  {
    return TRUE;
  }
177
  function acl_is_moveable ($base = ""): bool
178
179
180
  {
    return TRUE;
  }
181
  function aclGetPermissions ($attribute = '0', $base = NULL, $skipWrite = FALSE): string
182
183
184
  {
    return 'cmdrw';
  }
185
186

  /* We need static method to work as if we were configInLdap */
187
  static function isAccount ($attrs)
188
189
190
  {
    return configInLdap::isAccount($attrs);
  }
191
192
}
?>