File: class_recoveryConfig.inc

package info (click to toggle)
fusiondirectory 1.0.19-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 32,060 kB
  • sloc: php: 47,469; pascal: 2,993; perl: 2,431; xml: 1,822; sh: 136; makefile: 19
file content (152 lines) | stat: -rw-r--r-- 5,480 bytes parent folder | download
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
<?php
/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  Copyright (C) 2011-2016  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 recoveryConfig extends simplePlugin
{
  var $objectclasses  = array('fdPasswordRecoveryConf');

  static function plInfo()
  {
    return array(
      'plShortName'     => _('Password recovery'),
      'plDescription'   => _('Settings for the password recovery feature'),
      'plObjectType'    => array('configuration'),

      'plProvidedAcls'  => parent::generatePlProvidedAcls(static::getAttributesInfo())
    );
  }

  static function getAttributesInfo ()
  {
    return array (
      'settings' => array (
        'name'      => _('Password recovery settings'),
        'class'     => array ('alone'),
        'template'  => get_template_path('simpleplugin_section_alone.tpl'),
        'attrs'     => array (
          new BooleanAttribute (
            _('Activate password recovery'),
            _('Whether to activate or not password recovery feature'),
            'fdPasswordRecoveryActivated',
            FALSE
          ),
          new MailAttribute (
            _('Sender email address'),
            _('Email address from which mails will be sent'),
            'fdPasswordRecoveryEmail',
            TRUE,
            'to.be@chang.ed'
          ),
          new IntAttribute (
            _('Link validity (minutes)'),
            _('Number of minutes before a recovery link expires'),
            'fdPasswordRecoveryValidity',
            TRUE,
            0, FALSE, 10
          ),
          new StringAttribute (
            _('Salt for tokens'),
            _('Just a security measure, you can put anything in there, even random characters'),
            'fdPasswordRecoverySalt',
            TRUE,
            "SomethingSecretAndVeryLong"
          ),
          new BooleanAttribute (
            _('Allow the use of alternate addresses'),
            _('Users will also be able to enter one of theirs alternate addresses to recover their password'),
            'fdPasswordRecoveryUseAlternate',
            FALSE
          ),
        )
      ),
      'first_email' => array (
        'name' => _('First email'),
        'attrs' => array (
          new StringAttribute (
            _('Subject'),
            _('Subject of the first email'),
            'fdPasswordRecoveryMailSubject',
            TRUE,
            _("[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.'),
            'fdPasswordRecoveryMailBody',
            TRUE,
            _("Hello,\n\nHere is your information: \n - Login : %s\n - Link : %s\n\nThis link is only valid for 10 minutes.")
          )
        )
      ),
      'second_email' => array (
        'name' => _('Second email'),
        'attrs' => array (
          new StringAttribute (
            _('Subject'),
            _('Subject of the second email'),
            'fdPasswordRecoveryMail2Subject',
            TRUE,
            _("[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.'),
            'fdPasswordRecoveryMail2Body',
            TRUE,
           _("Hello,\n\nYour password has been changed.\nYour login is still %s.")
          )
        )
      )
    );
  }

  function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
  {
    global $config;
    // Check if token branch is here
    $ldap = $config->get_ldap_link();
    $tokenBranch = get_ou('recoveryTokenRDN').get_ou('fusiondirectoryRDN').$config->current['BASE'];
    $ldap->cat($tokenBranch, array('dn'));
    if (!$ldap->count()) {
      $ldap->cd($config->current['BASE']);
      $ldap->create_missing_trees($tokenBranch);
      if (!$ldap->success()) {
        $display = msgPool::ldaperror($ldap->get_error(),
                                  $tokenBranch, LDAP_MOD, get_class());
      }
      fusiondirectory_log("Created token branch ".$tokenBranch);
    }

    parent::__construct($dn, $object, $parent, $mainTab);

    $this->attributesAccess['fdPasswordRecoveryActivated']->setManagedAttributes(
      array(
        'disable' => array(
          FALSE => array(
            'fdPasswordRecoveryEmail','fdPasswordRecoveryValidity','fdPasswordRecoverySalt',
            'fdPasswordRecoveryMailSubject','fdPasswordRecoveryMailBody',
            'fdPasswordRecoveryMail2Subject','fdPasswordRecoveryMail2Body'
          )
        )
      )
    );
  }
}
?>