1e2a378d3SGreg Roach<?php 2e2a378d3SGreg Roachnamespace Fisharebest\Webtrees; 3e2a378d3SGreg Roach 4e2a378d3SGreg Roach/** 5e2a378d3SGreg Roach * webtrees: online genealogy 6e2a378d3SGreg Roach * Copyright (C) 2015 webtrees development team 7e2a378d3SGreg Roach * This program is free software: you can redistribute it and/or modify 8e2a378d3SGreg Roach * it under the terms of the GNU General Public License as published by 9e2a378d3SGreg Roach * the Free Software Foundation, either version 3 of the License, or 10e2a378d3SGreg Roach * (at your option) any later version. 11e2a378d3SGreg Roach * This program is distributed in the hope that it will be useful, 12e2a378d3SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 13e2a378d3SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14e2a378d3SGreg Roach * GNU General Public License for more details. 15e2a378d3SGreg Roach * You should have received a copy of the GNU General Public License 16e2a378d3SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 17e2a378d3SGreg Roach */ 18e2a378d3SGreg Roach 19e2a378d3SGreg Roach/** 20e2a378d3SGreg Roach * Class LoginBlockModule 21e2a378d3SGreg Roach */ 22e2a378d3SGreg Roachclass LoginBlockModule extends AbstractModule implements ModuleBlockInterface { 23e2a378d3SGreg Roach /** {@inheritdoc} */ 24e2a378d3SGreg Roach public function getTitle() { 25e2a378d3SGreg Roach return /* I18N: Name of a module */ I18N::translate('Login'); 26e2a378d3SGreg Roach } 27e2a378d3SGreg Roach 28e2a378d3SGreg Roach /** {@inheritdoc} */ 29e2a378d3SGreg Roach public function getDescription() { 30e2a378d3SGreg Roach return /* I18N: Description of the “Login” module */ I18N::translate('An alternative way to login and logout.'); 31e2a378d3SGreg Roach } 32e2a378d3SGreg Roach 33e2a378d3SGreg Roach /** {@inheritdoc} */ 34e2a378d3SGreg Roach public function getBlock($block_id, $template = true, $cfg = null) { 35e2a378d3SGreg Roach global $controller; 36e2a378d3SGreg Roach $id = $this->getName() . $block_id; 37e2a378d3SGreg Roach $class = $this->getName() . '_block'; 38e2a378d3SGreg Roach $controller->addInlineJavascript(' 39e2a378d3SGreg Roach jQuery("#new_passwd").hide(); 40e2a378d3SGreg Roach jQuery("#passwd_click").click(function() { 41e2a378d3SGreg Roach jQuery("#new_passwd").slideToggle(100, function() { 42e2a378d3SGreg Roach jQuery("#new_passwd_username").focus(); 43e2a378d3SGreg Roach }); 44e2a378d3SGreg Roach return false; 45e2a378d3SGreg Roach }); 46e2a378d3SGreg Roach '); 47e2a378d3SGreg Roach 48e2a378d3SGreg Roach if (Auth::check()) { 49e2a378d3SGreg Roach $title = I18N::translate('Logout'); 50e2a378d3SGreg Roach $content = '<div class="center"><form method="post" action="../../logout.php" name="logoutform" onsubmit="return true;">'; 51e2a378d3SGreg Roach $content .= '<br><a href="../../edituser.php" class="name2">' . I18N::translate('Logged in as ') . ' ' . Auth::user()->getRealNameHtml() . '</a><br><br>'; 52e2a378d3SGreg Roach $content .= '<input type="submit" value="' . I18N::translate('Logout') . '">'; 53e2a378d3SGreg Roach 54e2a378d3SGreg Roach $content .= '<br><br></form></div>'; 55e2a378d3SGreg Roach } else { 56e2a378d3SGreg Roach $title = I18N::translate('Login'); 57e2a378d3SGreg Roach $content = '<div id="login-box"> 58*309092efSGreg Roach <form id="login-form" name="login-form" method="post" action="'. WT_LOGIN_URL . '" onsubmit="d=new Date(); this.timediff.value=-60*d.getTimezoneOffset();"> 59e2a378d3SGreg Roach <input type="hidden" name="action" value="login"> 60e2a378d3SGreg Roach <input type="hidden" name="timediff" value="">'; 61e2a378d3SGreg Roach $content .= '<div> 62e2a378d3SGreg Roach <label for="username">'. I18N::translate('Username') . 63e2a378d3SGreg Roach '<input type="text" id="username" name="username" class="formField"> 64e2a378d3SGreg Roach </label> 65e2a378d3SGreg Roach </div> 66e2a378d3SGreg Roach <div> 67e2a378d3SGreg Roach <label for="password">'. I18N::translate('Password') . 68e2a378d3SGreg Roach '<input type="password" id="password" name="password" class="formField"> 69e2a378d3SGreg Roach </label> 70e2a378d3SGreg Roach </div> 71e2a378d3SGreg Roach <div> 72e2a378d3SGreg Roach <input type="submit" value="'. I18N::translate('Login') . '"> 73e2a378d3SGreg Roach </div> 74e2a378d3SGreg Roach <div> 75e2a378d3SGreg Roach <a href="#" id="passwd_click">'. I18N::translate('Request new password') . '</a> 76e2a378d3SGreg Roach </div>'; 77e2a378d3SGreg Roach if (Site::getPreference('USE_REGISTRATION_MODULE')) { 78e2a378d3SGreg Roach $content .= '<div><a href="' . WT_LOGIN_URL . '?action=register">' . I18N::translate('Request new user account') . '</a></div>'; 79e2a378d3SGreg Roach } 80e2a378d3SGreg Roach $content .= '</form>'; // close "login-form" 81e2a378d3SGreg Roach 82e2a378d3SGreg Roach // hidden New Password block 83e2a378d3SGreg Roach $content .= '<div id="new_passwd"> 84e2a378d3SGreg Roach <form id="new_passwd_form" name="new_passwd_form" action="'.WT_LOGIN_URL . '" method="post"> 85e2a378d3SGreg Roach <input type="hidden" name="time" value=""> 86e2a378d3SGreg Roach <input type="hidden" name="action" value="requestpw"> 87e2a378d3SGreg Roach <h4>'. I18N::translate('Lost password request') . '</h4> 88e2a378d3SGreg Roach <div> 89e2a378d3SGreg Roach <label for="new_passwd_username">'. I18N::translate('Username or email address') . 90e2a378d3SGreg Roach '<input type="text" id="new_passwd_username" name="new_passwd_username" value=""> 91e2a378d3SGreg Roach </label> 92e2a378d3SGreg Roach </div> 93e2a378d3SGreg Roach <div><input type="submit" value="'. I18N::translate('continue') . '"></div> 94e2a378d3SGreg Roach </form> 95e2a378d3SGreg Roach </div>'; //"new_passwd" 96e2a378d3SGreg Roach $content .= '</div>'; //"login-box" 97e2a378d3SGreg Roach } 98e2a378d3SGreg Roach 99e2a378d3SGreg Roach if ($template) { 100e2a378d3SGreg Roach return Theme::theme()->formatBlock($id, $title, $class, $content); 101e2a378d3SGreg Roach } else { 102e2a378d3SGreg Roach return $content; 103e2a378d3SGreg Roach } 104e2a378d3SGreg Roach } 105e2a378d3SGreg Roach 106e2a378d3SGreg Roach /** {@inheritdoc} */ 107e2a378d3SGreg Roach public function loadAjax() { 108e2a378d3SGreg Roach return false; 109e2a378d3SGreg Roach } 110e2a378d3SGreg Roach 111e2a378d3SGreg Roach /** {@inheritdoc} */ 112e2a378d3SGreg Roach public function isUserBlock() { 113e2a378d3SGreg Roach return true; 114e2a378d3SGreg Roach } 115e2a378d3SGreg Roach 116e2a378d3SGreg Roach /** {@inheritdoc} */ 117e2a378d3SGreg Roach public function isGedcomBlock() { 118e2a378d3SGreg Roach return true; 119e2a378d3SGreg Roach } 120e2a378d3SGreg Roach 121e2a378d3SGreg Roach /** {@inheritdoc} */ 122e2a378d3SGreg Roach public function configureBlock($block_id) { 123e2a378d3SGreg Roach } 124e2a378d3SGreg Roach} 125