diff --git a/local/config/vufind/EmailProfiles.ini b/local/config/vufind/EmailProfiles.ini index 80e6b70db53d6f61936f4b254d8c131e8eb95782..048eb43f8065d97914baf9736d2b7205bbcf21ed 100644 --- a/local/config/vufind/EmailProfiles.ini +++ b/local/config/vufind/EmailProfiles.ini @@ -12,6 +12,13 @@ ;from_name = "Finc Team" ;subject = "Fehlermeldung für Titel %s (%s)" +;[ResetPassword] +;to = team@finc.info +;to_name = "Finc Team" +;from = team@finc.info +;from_name = "Finc Team" +;subject = "Passwort zurücksetzen für %s %s" + ;[EmailHoldJournal] ;to = team@finc.info ;to_name = "Finc Team" diff --git a/local/languages/de.ini b/local/languages/de.ini index 5319f7c9bb5f273a61a12e1c69b05d0e4fb23710..f68b08b8e0a250baf3d1a0cb6b98cba5fd4f2bb1 100644 --- a/local/languages/de.ini +++ b/local/languages/de.ini @@ -1822,4 +1822,13 @@ sid_51 = "VuB" Tap to close = "Zum Schliessen antippen" ; Holdings Tab accordion -Address-Contact-Hours = "Adresse, Kontakt" \ No newline at end of file +Address-Contact-Hours = "Adresse, Kontakt" + +; resolver link access status +resolver_link_access_denied = "nicht verfügbar" +resolver_link_access_limited = "Im Campusnetz verfügbar" +resolver_link_access_open = "verfügbar" + +; reset password +reset_password_text = "Bitten füllen Sie dieses Formular aus, um Ihr Passwort zurücksetzen zu lassen. Sie erhalten an u.g. Email Adresse eine Benachrichtigung, nachdem wir das Passwort zurückgesetzt haben." +Reset Password = "Passwort zurücksetzen" diff --git a/local/languages/en.ini b/local/languages/en.ini index d5cea1aa0e6d2ad643257ecad9abe407181d9a16..350b2f5a4d8063bde0f9b5a053091e618d510fca 100644 --- a/local/languages/en.ini +++ b/local/languages/en.ini @@ -1762,4 +1762,13 @@ footer_nwb = "Database nwb" Tap to close = "Tap to close" ; Holdings Tab accordion -Address-Contact-Hours = "Address, Contact" \ No newline at end of file +Address-Contact-Hours = "Address, Contact" + +; resolver link access status +resolver_link_access_denied = "not available" +resolver_link_access_limited = "Available in Campus LAN" +resolver_link_access_open = "available" + +; reset password +reset_password_text = "Please complete the form below to reset your password. You will receive an email after we have completed resetting your password." +Reset Password = "Reset Password" diff --git a/module/finc/config/module.config.php b/module/finc/config/module.config.php index fa40e40898715046c941d7989d082fea3581b1e4..b4853129769cc403363d0feae48aef8676eed2c0 100644 --- a/module/finc/config/module.config.php +++ b/module/finc/config/module.config.php @@ -139,7 +139,7 @@ $recordRoutes = [ // Define static routes -- Controller/Action strings $staticRoutes = [ - 'MyResearch/Acquisition', 'dds/Home', 'dds/Email', + 'MyResearch/Acquisition', 'MyResearch/ResetPassword', 'dds/Home', 'dds/Email', 'Record/EblLink' ]; diff --git a/module/finc/src/finc/Controller/MyResearchController.php b/module/finc/src/finc/Controller/MyResearchController.php index 9b5233cc3cf5214fc812df0f475ae61d2ea544a0..fc7f9b71ae32c224f10cb540b5ecb5222d9d5511 100644 --- a/module/finc/src/finc/Controller/MyResearchController.php +++ b/module/finc/src/finc/Controller/MyResearchController.php @@ -208,4 +208,87 @@ class MyResearchController extends \VuFind\Controller\MyResearchController ); } + /** + * Reset password action - Allows the reset password form to appear. + * + * @return \Zend\View\Model\ViewModel + */ + public function resetPasswordAction() + { + // Force login if necessary: + $mailConfig = $this->getServiceLocator() + ->get('VuFind\Config')->get('EmailProfiles'); + + if (isset($mailConfig->ResetPassword)) { + $emailProfile = $mailConfig->ResetPassword; + } else { + throw new MailException('Missing email profile: ResetPassword'); + } + + $view = $this->createViewModel(); + + // Set up reCaptcha + $view->useRecaptcha = $this->recaptcha()->active('email'); + + // Process form submission: + if ($this->formWasSubmitted('submit', $view->useRecaptcha)) { + + $renderer = $this->getViewRenderer(); + + $params['firstname'] = $view->firstname = $this->params()->fromPost('firstname'); + $params['lastname'] = $view->lastname = $this->params()->fromPost('lastname'); + $params['username'] = $view->username = $this->params()->fromPost('username'); + $params['email'] = $view->email = $this->params()->fromPost('email'); + $params['timestamp'] = date('d.m.Y H:i'); + + // Custom template for emails (html-only) + $bodyHtml = $renderer->render( + 'Email/resetpassword-html.phtml', $params + ); + // Custom template for emails (text-only) + $bodyPlain = $renderer->render( + 'Email/resetpassword-plain.phtml', $params + ); + + // Build the subject + $subject = (isset($emailProfile->subject)) + ? sprintf( + $emailProfile->subject, + $params['firstname'], + $params['lastname'] + ) : $this->translate('Reset Password'); + + // Set reply address and name if available + $reply = (isset($params['email'], $params['firstname'], $params['lastname'])) + ? new Address($params['email'], $params['firstname'] . ' ' . $params['lastname']) + : null; + + try { + // Get mailer + $mailer = new Mailer( + $this->getServiceLocator() + ->get('VuFind\Mailer')->getTransport() + ); + + // Send the email + $mailer->sendTextHtml( + new Address($emailProfile->to), + new Address($emailProfile->from), + $reply, + $subject, + $bodyHtml, + $bodyPlain + ); + $this->flashMessenger()->addMessage('email_success', 'success'); + return $this->forwardTo('MyResearch', 'Home'); + } catch (MailException $e) { + $this->flashMessenger()->addMessage($e->getMessage(), 'error'); + } + } + + // Display the template: + $view->setTemplate('Auth/AbstractBase/resetpassword'); + return $view; + } + } diff --git a/themes/finc/templates/Auth/AbstractBase/resetpassword.phtml b/themes/finc/templates/Auth/AbstractBase/resetpassword.phtml new file mode 100644 index 0000000000000000000000000000000000000000..29c1a245f25ef2269ef112815b1ead6b800bdfe2 --- /dev/null +++ b/themes/finc/templates/Auth/AbstractBase/resetpassword.phtml @@ -0,0 +1,44 @@ +<!-- auth - abstractbase - RESETPASSWORD.phtml (custom finc template)--> +<? +// Set page title. +$this->headTitle($this->translate('Reset Password')); +?> +<h2><?=$this->transEsc('Reset Password') ?></h2> +<form method="post" name="resetPasswordForm" action="<?=$this->url('myresearch-resetpassword')?>"> + <?=$this->flashmessages()?> + <p> + <?=$this->translate('reset_password_text')?> + </p> + + <div class="row"> + <label class="small-5 medium-2 columns"><?=$this->transEsc('First Name') ?>:</label> + <div class="small-7 medium-4 columns end"> + <input type="text" name="firstname" required /> + </div> + </div> + <div class="row"> + <label class="small-5 medium-2 columns"><?=$this->transEsc('Last Name') ?>:</label> + <div class="small-7 medium-4 columns end"> + <input type="text" name="lastname" required/> + </div> + </div> + <div class="row"> + <label class="small-5 medium-2 columns"><?=$this->transEsc('Username') ?>:</label> + <div class="small-7 medium-4 columns end"> + <input type="text" name="username" required/> + </div> + </div> + <div class="row"> + <label class="small-5 medium-2 columns"><?=$this->transEsc('Email') ?>:</label> + <div class="small-7 medium-4 columns end"> + <input type="email" name="email" required/> + </div> + </div> + <?=$this->recaptcha()->html($this->useRecaptcha) ?> + <div class="row"> + <div class="medium-10 medium-offset-2 columns"> + <input class="button secondary small" name="submit" type="submit" aria-label="submit form" value="<?=$this->transEsc('recovery_title') ?>"/> + </div> + </div> +</form> +<!-- auth - abstractbase - RESETPASSWORD.phtml (custom finc template) end --> \ No newline at end of file diff --git a/themes/finc/templates/Email/resetpassword-html.phtml b/themes/finc/templates/Email/resetpassword-html.phtml new file mode 100644 index 0000000000000000000000000000000000000000..ed94c043818968b489f23ea21e7003e567e03365 --- /dev/null +++ b/themes/finc/templates/Email/resetpassword-html.phtml @@ -0,0 +1,35 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> +<head> + <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> + <title>Zurücksetzen des Passwortes für Benutzer</title> +</head> +<body style="font-family: Arial, Verdana, sans-serif;"> +<h2 style="padding:10px 0;">Zurücksetzen des Passwortes für Benutzer</h2> +<table width="800" border="0"> + <? if (isset($lastname) && isset($firstname)): ?> + <tr> + <td width="30%">Name:</td> + <td width="70%"><strong><?=$lastname?>, <?=$firstname?></strong></td> + </tr> + <? endif; ?> + <? if (isset($username)): ?> + <tr> + <td width="30%">Benutzernummer:</td> + <td width="70%"><strong><?=$username?></strong></td> + </tr> + <? endif; ?> + <? if (isset($email)): ?> + <tr> + <td width="30%">Email:</td> + <td width="70%"><a href="mailto:<?=$email?>"><?=$email?></a></td> + </tr> + <? endif; ?> + <tr valign="top"> + <td width="100%" colspan="2"> + Zeitpunkt der Anfrage: <?= $timestamp ?> + </td> + </tr> +</table> +</body> +</html> \ No newline at end of file diff --git a/themes/finc/templates/Email/resetpassword-plain.phtml b/themes/finc/templates/Email/resetpassword-plain.phtml new file mode 100644 index 0000000000000000000000000000000000000000..1eecd5711febc47f48cb31dfdf33227d3d8ff2a0 --- /dev/null +++ b/themes/finc/templates/Email/resetpassword-plain.phtml @@ -0,0 +1,19 @@ +== Zurücksetzen des Passwortes für Benutzer == + +<? if (isset($lastname) && isset($firstname)): ?> + +Name: <?=$lastname?>, <?=$firstname?> + +<? endif; ?> +<? if (isset($username)): ?> + +Benutzernummer: <?=$username?> + +<? endif; ?> +<? if (isset($email)): ?> + +Email: <?=$email?> + +<? endif; ?> + +Zeitpunkt der Anfrage: <?= $timestamp ?> \ No newline at end of file