openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit bda68b2f810a4c5606a6a77104cf0fb6b7cb9afe
parent 6b54e7e601d83b572b2dd7a56be82c10d9ab468c
Author: dankert <devnull@localhost>
Date:   Sat, 25 Dec 2004 23:11:03 +0100

Erweiterung/Korrektur der Kennwortaenderung

Diffstat:
actionClasses/MainmenuAction.class.php | 11+++++++++--
actionClasses/UserAction.class.php | 62+++++++++++++++++++++++++++++++++++---------------------------
themes/default/pages/html/user/profile.tpl.php | 13++++++-------
themes/default/pages/html/user/pw.tpl.php | 6++++++
4 files changed, 56 insertions(+), 36 deletions(-)

diff --git a/actionClasses/MainmenuAction.class.php b/actionClasses/MainmenuAction.class.php @@ -20,7 +20,10 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // --------------------------------------------------------------------------- // $Log$ -// Revision 1.14 2004-12-19 18:09:05 dankert +// Revision 1.15 2004-12-25 22:11:03 dankert +// Erweiterung/Korrektur der Kennwortaenderung +// +// Revision 1.14 2004/12/19 18:09:05 dankert // Korrektur Gruppen-Men? // // Revision 1.13 2004/12/19 18:06:41 dankert @@ -178,7 +181,11 @@ class MainmenuAction extends Action { $this->addSubaction('edit' ); $this->addSubaction('groups' ); - $this->addSubaction('pw' ); + + // Kennwortaenderung ist nur sinnvoll, wenn kein LDAP verwendet wird + if ( empty($user->ldap_dn) ) + $this->addSubaction('pw' ); + $this->addSubaction('rights' ); } diff --git a/actionClasses/UserAction.class.php b/actionClasses/UserAction.class.php @@ -104,19 +104,46 @@ class UserAction extends Action function pwchange() { - if ( $this->getRequestVar('password1') != '' && - $this->getRequestVar('password1') == $this->getRequestVar('password2') ) + global $conf; + + $pw1 = $this->getRequestVar('password1'); + $pw2 = $this->getRequestVar('password2'); + + // Zufaelliges Kennwort erzeugen + if ( $this->hasRequestVar('random') && $this->hasRequestVar('mail') ) { - $this->user->setPassword( $this->getRequestVar('password1') ); + $pw1 = substr( md5(microtime().session_id()),0,intval($conf['security']['random_password_length']) ); + $pw2 = $pw1; + } + + + // Wenn Kennwoerter identisch und lang genug + if ( $pw1 == $pw2 && + strlen($pw1)>=intval($conf['security']['min_password_length']) ) + { + $this->user->setPassword($pw1); // Kennwort setzen // E-Mail mit dem neuen Kennwort an Benutzer senden - if ( $this->hasRequestVar('mail') && !empty($this->user->mail) ) + if ( $this->hasRequestVar('mail') && !empty($this->user->mail) && $conf['mail']['enabled'] ) { + $header = 'X-Mailer: '.OR_TITLE.' '.OR_VERSION; + if ( !empty($conf['mail']['from']) ) + $header .= "\nFrom: ".$conf['mail']['from']; + // Text der E-Mail zusammenfuegen - $text = wordwrap(lang('USER_MAIL_PREFIX'),70,"\n")."\n\n".$this->getRequestVar('password1')."\n\n".wordwrap(lang('USER_MAIL_SUFFFIX'),70,"\n"); + $text = "\n".wordwrap(str_replace(';',"\n",lang('USER_MAIL_TEXT_PREFIX')),70,"\n")."\n\n"; + $text .= $pw1."\n\n"; + $text .= wordwrap(str_replace(';',"\n",lang('USER_MAIL_TEXT_SUFFIX')),70,"\n"); + + // Signatur anhaengen (sofern konfiguriert) + if ( !empty($conf['mail']['signature']) ) + { + $text .= "\n\n-- \n"; + $text .= str_replace(';',"\n",$conf['mail']['signature']); + } // Mail versenden - mail($this->user->mail,lang('USER_MAIL_SUBJECT'),$text); + mail($this->user->mail,lang('USER_MAIL_SUBJECT'),$text,$header); } $this->addNotice('user',$this->user->name,'SAVED','ok'); @@ -125,27 +152,6 @@ class UserAction extends Action $this->callSubAction('edit'); } -// function delright() -// { -// if ($SESS['user']['is_admin'] != '1') die('weah'); -// -// $user->delRight( $this->getRequestVar('aclid') ); -// -// // Berechtigungen anzeigen -// $this->callSubAction('rights'); -// } -// -// -// function addright() -// { -// global $REQ; -// if ($SESS['user']['is_admin'] != '1') die('go away hacker'); -// -// $user->addRight( $REQ ); -// -// // Berechtigungen anzeigen -// $this->callSubAction('rights'); -// } function listing() @@ -193,6 +199,8 @@ class UserAction extends Action */ function pw() { + $this->setTemplateVar('mail',$this->user->mail); + $this->forward('user_pw'); } diff --git a/themes/default/pages/html/user/profile.tpl.php b/themes/default/pages/html/user/profile.tpl.php @@ -39,13 +39,12 @@ </tr> <?php } ?> -<?php if (!isset($use_ldap)) - { ?> - <?php include( $tpl_dir.'table_close.tpl.php'); ?> </form> + +<?php if ( empty($ldap_dn) ) { ?> <?php echo Html::form('profile','pwchange',$userid) ?> <?php @@ -66,15 +65,15 @@ <td width="50%" class="f2"><?php echo lang('user_new_password_repeat') ?></a></td> <td width="50%" class="f2"><input type="password" name="password2"></td> </tr> -<?php } ?> - <tr> - <td class="act" colspan="2"><input type="submit" class="submit" value="<?php echo lang('GLOBAL_SAVE') ?>"></td> - </tr> +<tr> + <td class="act" colspan="2"><input type="submit" class="submit" value="<?php echo lang('GLOBAL_SAVE') ?>"></td> +</tr> <?php include( $tpl_dir.'table_close.tpl.php') ?> </form> +<?php } ?> </center> <?php Html::focusField('fullname') ?> diff --git a/themes/default/pages/html/user/pw.tpl.php b/themes/default/pages/html/user/pw.tpl.php @@ -18,11 +18,17 @@ <td width="50%" class="f2"><?php echo lang('USER_new_password_repeat') ?></a></td> <td width="50%" class="f2"><input type="password" name="password2"></td> </tr> +<?php if (!empty($mail)) { ?> <tr> <td width="50%" class="f2"><?php echo lang('user_mail_new_password') ?></a></td> <td width="50%" class="f2"><?php echo Html::checkBox('mail',false,true) ?></td> </tr> <tr> +<td width="50%" class="f2"><?php echo lang('user_random_password') ?></a></td> +<td width="50%" class="f2"><?php echo Html::checkBox('random',false,true) ?></td> +</tr> +<?php } ?> +<tr> <td class="act" colspan="2"><input type="submit" class="submit" value="<?php echo lang('GLOBAL_SAVE') ?>"></td> </tr> </table>