class_setupStep_Config.inc 4.12 KB
Newer Older
1
2
3
4
<?php
/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  Copyright (C) 2007 Fabian Hickert
Côme Bernigaud's avatar
Côme Bernigaud committed
5
  Copyright (C) 2011-2015  FusionDirectory
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

  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 Step_Config_before_init extends setupStep
{
  function update_strings()
  {
    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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  }
}

class Step_Config extends configInLdap
{
  var $is_active    = FALSE;
  var $is_enabled   = FALSE;
  var $is_completed = FALSE;
  var $header_image;

  static function plInfo()
  {
    return array();
  }

  function __construct($cv)
  {
    global $config;
    parent::__construct($config, CONFIGRDN.$config->current['BASE']);

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

58
59
60
61
62
63
64
65
66
    $this->fdLanguage     = $cv['lang_selected'];
  }

  function update_strings()
  {
    $infos = parent::plInfo();
    $this->header_image = $infos['plIcon'];
  }

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

73
  function get_title()
74
75
76
77
78
  {
    $infos = parent::plInfo();
    return $infos['plDescription'];
  }

79
  function get_description()
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
  {
    $infos = parent::plInfo();
    return $infos['plDescription'];
  }

  /* Return attributes handled by this setup step */
  function get_attributes()
  {
    $tmp = array();
    foreach (array_keys($this->attributesAccess) as $attr) {
      $tmp[$attr] = $this->$attr;
    }
    return $tmp;
  }

  function save_object()
  {
    global $config;
    parent::save_object();
    $tmp = $this->check();
    if (count($tmp) == 0) {
101
102
103
      /* Create root object if missing */
      $ldap = $config->get_ldap_link();
      $ldap->cd($config->current['BASE']);
104
      $ldap->create_missing_trees($config->current['BASE'], FALSE);
105
106
107
      if (!$ldap->success()) {
        return msgPool::ldaperror($ldap->get_error(), $config->current['BASE'], 'create_missing_trees', get_class());
      }
108
109
110
111
      /* Save in LDAP */
      $this->save();
      /* Reload config from LDAP */
      $config->set_current($config->current['NAME']);
112
113
      session::global_un_set('plist');
      load_plist();
114
      $this->is_completed = TRUE;
115
      $this->parent->reBuildConfigStep(TRUE);
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
170
171
172
173
174
175
176
177
    } else {
      $this->is_completed = FALSE;
    }
  }

  function is_active()
  {
    return $this->is_active;
  }

  function is_enabled()
  {
    return $this->is_enabled;
  }

  function is_completed()
  {
    return $this->is_completed;
  }

  function set_active($value = TRUE)
  {
    $this->is_active = ($value == TRUE);
  }

  function set_enabled($value = TRUE)
  {
    $this->is_enabled = ($value == TRUE);
  }

  function set_completed($value = TRUE)
  {
    $this->is_completed = ($value == TRUE);
  }

  /* bypass acl system as there is no user login */
  function acl_is_writeable($attribute, $skip_write = FALSE)
  {
    return TRUE;
  }
  function acl_is_readable($attribute)
  {
    return TRUE;
  }
  function acl_is_createable($base = "")
  {
    return TRUE;
  }
  function acl_is_removeable($base = "")
  {
    return TRUE;
  }
  function acl_is_moveable($base = "")
  {
    return TRUE;
  }
  function getacl($attribute, $skip_write = FALSE)
  {
    return 'cmdrw';
  }
}
?>