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

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

21
class recoveryConfig extends simplePlugin
22
{
23
  var $objectclasses  = array('fdPasswordRecoveryConf');
24

25
  static function plInfo()
26
  {
27
    return array(
28
      'plShortName'     => _('Password recovery'),
29
30
      'plDescription'   => _('Settings for the password recovery feature'),
      'plObjectType'    => array('configuration'),
31

32
      'plProvidedAcls'  => parent::generatePlProvidedAcls(static::getAttributesInfo())
33
    );
34
35
  }

36
  static function getAttributesInfo ()
37
  {
38
    return array (
39
      'settings' => array (
40
41
42
43
        'name'      => _('Password recovery settings'),
        'class'     => array ('alone'),
        'template'  => get_template_path('simpleplugin_section_alone.tpl'),
        'attrs'     => array (
44
45
          new BooleanAttribute (
            _('Activate password recovery'),
46
            _('Whether to activate or not password recovery feature'),
47
            'fdPasswordRecoveryActivated',
48
49
50
51
52
            FALSE
          ),
          new MailAttribute (
            _('Sender email address'),
            _('Email address from which mails will be sent'),
53
            'fdPasswordRecoveryEmail',
54
            TRUE,
55
56
57
58
59
            'to.be@chang.ed'
          ),
          new IntAttribute (
            _('Link validity (minutes)'),
            _('Number of minutes before a recovery link expires'),
60
            'fdPasswordRecoveryValidity',
61
            TRUE,
62
63
64
65
66
            0, FALSE, 10
          ),
          new StringAttribute (
            _('Salt for tokens'),
            _('Just a security measure, you can put anything in there, even random characters'),
67
            'fdPasswordRecoverySalt',
68
            TRUE,
69
            "SomethingSecretAndVeryLong"
70
71
72
73
          ),
          new BooleanAttribute (
            _('Allow the use of alternate addresses'),
            _('Users will also be able to enter one of theirs alternate addresses to recover their password'),
74
            'fdPasswordRecoveryUseAlternate',
75
76
            FALSE
          ),
77
78
79
80
81
82
83
84
        )
      ),
      'first_email' => array (
        'name' => _('First email'),
        'attrs' => array (
          new StringAttribute (
            _('Subject'),
            _('Subject of the first email'),
85
            'fdPasswordRecoveryMailSubject',
86
            TRUE,
87
88
89
90
91
            _("[FusionDirectory] Password recovery link")
          ),
          new TextAreaAttribute (
            _('Body (first %s is login, second is link)'),
            _('Body of the first email, sent when the user ask for a new password. Use %s for the login and the recovery link.'),
92
            'fdPasswordRecoveryMailBody',
93
            TRUE,
94
            _("Hello,\n\nHere is your information: \n - Login : %s\n - Link : %s\n\nThis link is only valid for 10 minutes.")
95
96
97
98
99
100
101
102
103
          )
        )
      ),
      'second_email' => array (
        'name' => _('Second email'),
        'attrs' => array (
          new StringAttribute (
            _('Subject'),
            _('Subject of the second email'),
104
            'fdPasswordRecoveryMail2Subject',
105
            TRUE,
106
107
108
109
110
            _("[FusionDirectory] Password recovery successful")
          ),
          new TextAreaAttribute (
            _('Body (%s is login)'),
            _('Body of the second email, sent to confirm the password has been changed. Use %s for the user login.'),
111
            'fdPasswordRecoveryMail2Body',
112
            TRUE,
113
114
115
116
117
           _("Hello,\n\nYour password has been changed.\nYour login is still %s.")
          )
        )
      )
    );
118
119
  }

120
  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
121
  {
122
    global $config;
123
124
    // Check if token branch is here
    $ldap = $config->get_ldap_link();
125
    $tokenBranch = get_ou('recoveryTokenRDN').get_ou('fusiondirectoryRDN').$config->current['BASE'];
126
127
128
129
130
    $ldap->cat($tokenBranch, array('dn'));
    if (!$ldap->count()) {
      $ldap->cd($config->current['BASE']);
      $ldap->create_missing_trees($tokenBranch);
      if (!$ldap->success()) {
131
132
133
134
135
        msg_dialog::display(
          _('LDAP error'),
          msgPool::ldaperror($ldap->get_error(), $tokenBranch, LDAP_MOD, get_class()),
          LDAP_ERROR
        );
136
      }
137
      fusiondirectory_log('Created token branch '.$tokenBranch);
138
    }
139

140
    parent::__construct($dn, $object, $parent, $mainTab);
141
142

    $this->attributesAccess['fdPasswordRecoveryActivated']->setManagedAttributes(
143
144
145
      array(
        'disable' => array(
          FALSE => array(
146
147
148
            'fdPasswordRecoveryEmail','fdPasswordRecoveryValidity','fdPasswordRecoverySalt',
            'fdPasswordRecoveryMailSubject','fdPasswordRecoveryMailBody',
            'fdPasswordRecoveryMail2Subject','fdPasswordRecoveryMail2Body'
149
150
151
          )
        )
      )
152
    );
153
154
155
  }
}
?>