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 170 171 172
|
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
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 recoveryConfig extends simplePlugin
{
var $mainTab = TRUE;
var $displayHeader = FALSE;
/* This plugin only writes its objectClass */
var $objectclasses = array("recoveryConfig");
var $StatusFlag = "";
/* Return plugin informations for acl handling */
static function plInfo()
{
return array(
"plShortName" => _("Password recovery"),
"plDescription" => _("Settings for the password recovery feature"),
"plIcon" => "plugins/password/images/iconRecovery.png",
"plSelfModify" => FALSE,
"plSection" => "addons",
"plPriority" => 9,
"plCategory" => array("configuration"),
"plProvidedAcls" => parent::generatePlProvidedAcls(self::getAttributesInfo())
);
}
/*!
* \brief The main function : information about attributes
*/
static function getAttributesInfo ()
{
return array (
'settings' => array (
'name' => _('Password recovery settings'),
'attrs' => array (
new BooleanAttribute (
_('Activate password recovery'),
_('Weither to activate or not password recovery feature'),
'passwordRecoveryActivated',
FALSE
),
new MailAttribute (
_('Sender email address'),
_('Email address from which mails will be sent'),
'passwordRecoveryEmail',
TRUE,
'to.be@chang.ed'
),
new IntAttribute (
_('Link validity (minutes)'),
_('Number of minutes before a recovery link expires'),
'passwordRecoveryValidity',
TRUE,
0, FALSE, 10
),
new StringAttribute (
_('Salt for tokens'),
_('Just a security measure, you can put anything in there, even random characters'),
'passwordRecoverySalt',
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'),
'passwordRecoveryUseAlternate',
FALSE
),
)
),
'first_email' => array (
'name' => _('First email'),
'attrs' => array (
new StringAttribute (
_('Subject'),
_('Subject of the first email'),
'passwordRecoveryMailSubject',
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.'),
'passwordRecoveryMailBody',
TRUE,
_("Hello,\n\nHere are your informations : \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'),
'passwordRecoveryMail2Subject',
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.'),
'passwordRecoveryMail2Body',
TRUE,
_("Hello,\n\nYour password has been changed.\nYour login is still %s.")
)
)
)
);
}
function __construct(&$config, $dn = NULL, $object = NULL)
{
// Check if token branch is here
$ldap = $config->get_ldap_link();
$tokenBranch = get_ou("tokenRDN").$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($config, $dn, $object);
$this->attributesInfo['settings']['attrs']['passwordRecoveryActivated']->setManagedAttributes(
array(
'disable' => array(
FALSE => array(
'passwordRecoveryEmail','passwordRecoveryValidity','passwordRecoverySalt',
'passwordRecoveryMailSubject','passwordRecoveryMailBody',
'passwordRecoveryMail2Subject','passwordRecoveryMail2Body'
)
)
)
);
}
function execute()
{
$smarty = get_smarty();
parent::execute();
if ($this->displayPlugin) {
return $this->header.$smarty->fetch(get_template_path('recoveryConfig.tpl', TRUE, dirname(__FILE__)));
} else {
return $this->header;
}
}
}
?>
|