Skip to content
This repository has been archived by the owner on Sep 19, 2022. It is now read-only.

Commit

Permalink
Refactor (#5)
Browse files Browse the repository at this point in the history
* Refactored

* Refactored

* Refactored

* Refactored

* Refactored

* Refactored

* Refactored

* Refactored

* Refactored

* Refactored
  • Loading branch information
Dominik František Bučík authored May 27, 2021
1 parent e857dff commit dbaacd2
Show file tree
Hide file tree
Showing 18 changed files with 435 additions and 81 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"require": {
"simplesamlphp/composer-module-installer": "~1.0",
"simplesamlphp/simplesamlphp": "~1.17",
"cesnet/simplesamlphp-module-perun": "~4.0"
"cesnet/simplesamlphp-module-perun": "~5.0"
}
}
174 changes: 174 additions & 0 deletions templates/pwd_reset_bbmri-tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<?php
/**
* @author Pavel Vyskocil <[email protected]>
*/


use SimpleSAML\Configuration;

$config = Configuration::getInstance();

if (!isset($_POST['passwordResetOk'])) {
$_POST['passwordResetOk'] = false;
}

/**
* Support the htmlinject hook, which allows modules to change header, pre and post body on all pages.
*/
$this->data['htmlinject'] = array(
'htmlContentPre' => array(),
'htmlContentPost' => array(),
'htmlContentHead' => array(),
);


$jquery = array();
if (array_key_exists('jquery', $this->data)) $jquery = $this->data['jquery'];

if (array_key_exists('pageid', $this->data)) {
$hookinfo = array(
'pre' => &$this->data['htmlinject']['htmlContentPre'],
'post' => &$this->data['htmlinject']['htmlContentPost'],
'head' => &$this->data['htmlinject']['htmlContentHead'],
'jquery' => &$jquery,
'page' => $this->data['pageid']
);

SimpleSAML\Module::callHooks('htmlinject', $hookinfo);
}

header('X-Frame-Options: SAMEORIGIN');

?><!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0" />
<script type="text/javascript" src="/<?php echo $this->data['baseurlpath']; ?>resources/script.js"></script>
<title>LS Hostel</title>

<link rel="stylesheet" type="text/css" href="/<?php echo $this->data['baseurlpath']; ?>resources/default.css" />
<link rel="icon" type="image/icon" href="/<?php echo $this->data['baseurlpath']; ?>resources/icons/favicon.ico" />

<?php


if(!empty($this->data['htmlinject']['htmlContentHead'])) {
foreach($this->data['htmlinject']['htmlContentHead'] AS $c) {
echo $c;
}
}


if ($this->isLanguageRTL()) {
?>
<link rel="stylesheet" type="text/css" href="/<?php echo $this->data['baseurlpath']; ?>resources/default-rtl.css" />
<?php
}
?>

<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/bootstrap/css/bootstrap.min.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/css/lshostel-bbmri.css'); ?>" />

<meta name="robots" content="noindex, nofollow" />


<?php
if(array_key_exists('head', $this->data)) {
echo '<!-- head -->' . $this->data['head'] . '<!-- /head -->';
}
?>
</head>
<?php
$onLoad = '';
if(array_key_exists('autofocus', $this->data)) {
$onLoad .= 'SimpleSAML_focus(\'' . $this->data['autofocus'] . '\');';
}
if (isset($this->data['onLoad'])) {
$onLoad .= $this->data['onLoad'];
}

if($onLoad !== '') {
$onLoad = ' onload="' . $onLoad . '"';
}
?>
<body<?php echo $onLoad; ?>>


<div id="wrap">

<div id="content">
<div class="row pl-0 pr-0">
<div class="col-sm-6 logo-wrap col-align--center">
<img src="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/img/lshostel_256.png'); ?>" alt="Life Science Hostel logo">
</div>
<div class="col-sm-6">
<?php
echo "<h1> " . $this->t('{lshostel:pwd_reset:header}') . "</h1>";
$userName = "";
if (isset($_POST['username'])) {
$userName = $_POST['username'];
try {
if (!$_POST['passwordResetOk']) {
sendPasswordResetEmail($userName);
$_POST['passwordResetOk'] = true;
unset($_POST['username']);
}
?>
<div class="alert alert-success" >
<p>
<span class="glyphicon glyphicon-exclamation-sign" style="float:left; font-size: 38px; margin-right: 10px;"></span>
<strong><?php echo $this->t('{lshostel:pwd_reset:ok_header}');?></strong>
</p>
<p><?php echo $this->t('{lshostel:pwd_reset:ok_text}');?></p>
</div>

<?php
} catch (\Exception $exception) {
?>
<div class="alert alert-danger" >
<span class="glyphicon glyphicon-exclamation-sign" style="float:left; font-size: 38px; margin-right: 10px;"></span>
<strong><?php echo $this->t('{lshostel:pwd_reset:err_header}');?></strong>
<p><?php echo $this->t('{lshostel:pwd_reset:err_text_part1}');?></p>
<p><?php echo $this->t('{lshostel:pwd_reset:err_text_part2}');?>
<a href="<?php echo $config->getString('technicalcontact_email'); ?>"><?php echo $this->t('{lshostel:pwd_reset:support}');?></a>.
</p>
</div>

<?php
}
}

if (!$_POST['passwordResetOk']) {
?>

<p><?php echo $this->t('{lshostel:pwd_reset:text}'); ?></p>

<br>

<form action="" method="post" name="passwd_reset" class="form-horizontal">
<div class="form-group">
<label class="sr-only" for="inlineFormInputGroup"><?php echo $this->t('{{lshostel:pwd_reset:email}'); ?></label>
<div class="input-group mb-2">
<span class="input-group-addon" id="basic-addon1">@</span>
<input id="username" type="email" name="username" class="form-control" value="<?php echo $userName; ?>" placeholder="Email" aria-describedby="basic-addon1"/>
</div>
</div>

<div class="form-group">
<button class="btn btn-success btn-block" type="submit">
<?php echo $this->t('{lshostel:pwd_reset:submit}'); ?>
</button>
</div>
</form>

<?php
}
?>
</div>

<?php



$this->includeAtTemplateBase('includes/footer.php');
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
?>

<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/bootstrap/css/bootstrap.min.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/css/lshostel.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/css/lshostel-bbmri.css'); ?>" />

<meta name="robots" content="noindex, nofollow" />

Expand Down Expand Up @@ -196,7 +196,7 @@
<?php echo $this->t('{lshostel:lshostel:register_acc_hostel}') ?>
</a>
|
<a class="btn btn-link" href="<?php echo SimpleSAML\Module::getModuleURL("lshostel/pwd_reset.php");?>">
<a class="btn btn-link" href="<?php echo SimpleSAML\Module::getModuleURL("lshostel/pwd_reset_bbmri.php");?>">
<?php echo $this->t('{lshostel:lshostel:forgot_password}') ?>
</a>
</div>
Expand Down
33 changes: 33 additions & 0 deletions themes/lshostel-bbmri/default/includes/footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
if(!empty($this->data['htmlinject']['htmlContentPost'])) {
foreach($this->data['htmlinject']['htmlContentPost'] AS $c) {
echo $c;
}
}
?>
</div>
</div>
</div>

<div id="footer">

<div style="margin: 0px auto; max-width: 1000px;" class="clearfix">

<div style="float: left;">
<img src="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/img/BBMRI-ERIC-gateway-for-health_216.png') ?>">
</div>

<div style="float: left;">
<p>BBMRI-ERIC, Neue Stiftingtalstrasse 2/B/6, 8010 Graz, Austria
&nbsp; &nbsp; +43 316 34 99 17-0 &nbsp;
<a href="mailto:[email protected]">[email protected]</a>
</p>
<p>Copyright © BBMRI-ERIC <?php echo date("Y"); ?> </p>
</div>
</div>

</div>

</body>
</html>

Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,19 @@
}
}




if ($this->isLanguageRTL()) {
?>
<link rel="stylesheet" type="text/css" href="/<?php echo $this->data['baseurlpath']; ?>resources/default-rtl.css" />
<?php
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/bootstrap/css/bootstrap.min.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/css/lshostel.css'); ?>" />

<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/bootstrap/css/bootstrap.min.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/css/lshostel-bbmri.css'); ?>" />

<meta name="robots" content="noindex, nofollow" />


Expand All @@ -118,24 +123,20 @@
}
?>
<body<?php echo $onLoad; ?>>

<div id="wrap">

<div id="header">
<img src="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/img/lshostel_256.png'); ?>" alt="Life Science Hostel logo">
<img src="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/img/lshostel_256.png'); ?>"
alt="Life Science Hostel logo">
<h1>
<?php
echo (isset($this->data['header']) ? $this->data['header'] : 'Life Science Hostel');
?>
</h1>
</div>

<div id="content">

<?php

if(!empty($this->data['htmlinject']['htmlContentPre'])) {
foreach($this->data['htmlinject']['htmlContentPre'] AS $c) {
echo $c;
}
}
<?php
if(!empty($this->data['htmlinject']['htmlContentPre'])) {
foreach($this->data['htmlinject']['htmlContentPre'] AS $c) {
echo $c;
}
}
File renamed without changes.
10 changes: 9 additions & 1 deletion themes/lshostel/core/loginuserpass.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?php

use SimpleSAML\Configuration;

const CONFIG_FILE_NAME = 'module_lshostel.php';
const REGISTER_LINK = 'register_link';

$conf = Configuration::getConfig(CONFIG_FILE_NAME);
$register_link = $conf->getString(REGISTER_LINK);

if (strlen($this->data['username']) > 0) {
$this->data['autofocus'] = 'password';
} else {
Expand Down Expand Up @@ -184,7 +192,7 @@
</button>
</div>
<div class="form-group text-center">
<a class="btn btn-link" href="https://perun.bbmri-eric.eu/non/registrar/?vo=lifescience_hostel">
<a class="btn btn-link" href="<?php echo $register_link ?>">
<?php echo $this->t('{lshostel:lshostel:register_acc_hostel}') ?>
</a>
|
Expand Down
20 changes: 9 additions & 11 deletions themes/lshostel/default/includes/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@
<div id="footer">

<div style="margin: 0px auto; max-width: 1000px;">
<div class="row">

<div style="float: left;">
<img src="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/img/BBMRI-ERIC-gateway-for-health_216.png') ?>">
</div>

<div style="float: left;">
<p>BBMRI-ERIC, Neue Stiftingtalstrasse 2/B/6, 8010 Graz, Austria
&nbsp; &nbsp; +43 316 34 99 17-0 &nbsp;
<a href="mailto:[email protected]">[email protected]</a>
</p>
<p>Copyright © BBMRI-ERIC <?php echo date("Y"); ?> </p>
</div>

<div id="eu" class="col-md-6">
<p>This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 654248.</p>
</div>
<div class="col-md-6">
<p><a href="mailto:[email protected]">CONTACT</a></p>
</div>
</div>
</div>

</div>
Expand Down
16 changes: 3 additions & 13 deletions themes/lshostel/default/includes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,14 @@
}
}




if ($this->isLanguageRTL()) {
?>
<link rel="stylesheet" type="text/css" href="/<?php echo $this->data['baseurlpath']; ?>resources/default-rtl.css" />
<?php
}
?>

<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/bootstrap/css/bootstrap.min.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/css/lshostel.css'); ?>" />

<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/bootstrap/css/bootstrap.min.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/css/lshostel.css'); ?>" />
<meta name="robots" content="noindex, nofollow" />


Expand All @@ -124,24 +119,19 @@
?>
<body<?php echo $onLoad; ?>>



<div id="wrap">

<div id="header">
<img src="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/img/lshostel_256.png'); ?>" alt="Life Science Hostel logo">
<img src="<?php echo SimpleSAML\Module::getModuleUrl('lshostel/res/img/lshostel_256.png'); ?>" alt="Life Science Hostel logo">
<h1>
<?php
echo (isset($this->data['header']) ? $this->data['header'] : 'Life Science Hostel');
?>
</h1>
</div>


<div id="content">



<?php

if(!empty($this->data['htmlinject']['htmlContentPre'])) {
Expand Down
Loading

0 comments on commit dbaacd2

Please sign in to comment.