Skip to content
Snippets Groups Projects
Commit 547058c5 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

expirycheck: Add Twig templates

parent 91a70d0d
No related branches found
No related tags found
No related merge requests found
...@@ -16,50 +16,6 @@ ...@@ -16,50 +16,6 @@
* @package SimpleSAMLphp * @package SimpleSAMLphp
*/ */
# netid will expire today
if ($this->data['daysleft'] == 0) {
$this->data['header'] = $this->t('{expirycheck:expwarning:warning_header_today}', array(
'%NETID%' => htmlspecialchars($this->data['netId'])
));
$warning = $this->t('{expirycheck:expwarning:warning_today}', array(
'%NETID%' => htmlspecialchars($this->data['netId'])
));
}
# netid will expire in one day
elseif ($this->data['daysleft'] == 1) {
$this->data['header'] = $this->t('{expirycheck:expwarning:warning_header}', array(
'%NETID%' => htmlspecialchars($this->data['netId']),
'%DAYS%' => $this->t('{expirycheck:expwarning:day}'),
'%DAYSLEFT%' => htmlspecialchars($this->data['daysleft']),
));
$warning = $this->t('{expirycheck:expwarning:warning}', array(
'%NETID%' => htmlspecialchars($this->data['netId']),
'%DAYS%' => $this->t('{expirycheck:expwarning:day}'),
'%DAYSLEFT%' => htmlspecialchars($this->data['daysleft']),
));
}
# netid will expire in next <daysleft> days
else {
$this->data['header'] = $this->t('{expirycheck:expwarning:warning_header}', array(
'%NETID%' => htmlspecialchars($this->data['netId']),
'%DAYS%' => $this->t('{expirycheck:expwarning:days}'),
'%DAYSLEFT%' => htmlspecialchars($this->data['daysleft']),
));
$warning = $this->t('{expirycheck:expwarning:warning}', array(
'%NETID%' => htmlspecialchars($this->data['netId']),
'%DAYS%' => $this->t('{expirycheck:expwarning:days}'),
'%DAYSLEFT%' => htmlspecialchars($this->data['daysleft']),
));
}
$this->data['autofocus'] = 'yesbutton'; $this->data['autofocus'] = 'yesbutton';
$this->includeAtTemplateBase('includes/header.php'); $this->includeAtTemplateBase('includes/header.php');
......
{% set pagetitle = 'SimpleSAMLphp'|trans %}
{% extends "base.twig" %}
{% block content %}
<form style="display: inline; margin: 0px; padding: 0px" action="{{ yesTarget|escape('html') }}">
{% for name, value in yesData %}
<input type="hidden" name="{{ name|escape('html') }}" value="{{ value|escape('html') }}" />
{% endfor %}
<h3>{{ warning }}</h3>
<p>{{ '{expirycheck:expwarning:expiry_date_text}'|trans }} {{ expireOnDate }}</p>
<input type="submit" name="yes" id="yesbutton" value="{{ '{expirycheck:expwarning:btn_continue}'|trans }}" />
</form>
{% endblock %}
{% set pagetitle = 'SimpleSAMLphp'|trans %}
{% extends "base.twig" %}
{% block content %}
<h2>{{ '{expirycheck:expwarning:access_denied}'|trans }})</h2>
<p>{{ '{expirycheck:expwarning:no_access_to}'|trans({'%NETID%': netId}, "app") }}</p>
<p>{{ '{expirycheck:expwarning:expiry_date_text}'|trans }} <b>{{ expireOnDate }}</b></p>
<p>{{ '{expirycheck:expwarning:contact_home}'|trans }}</p>
{% endblock %}
...@@ -9,22 +9,61 @@ ...@@ -9,22 +9,61 @@
SimpleSAML\Logger::info('expirycheck - User has been warned that NetID is near to expirational date.'); SimpleSAML\Logger::info('expirycheck - User has been warned that NetID is near to expirational date.');
if (!array_key_exists('StateId', $_REQUEST)) { if (!array_key_exists('StateId', $_REQUEST)) {
throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.'); throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
} }
$id = $_REQUEST['StateId']; $id = $_REQUEST['StateId'];
$state = SimpleSAML_Auth_State::loadState($id, 'expirywarning:about2expire'); $state = SimpleSAML_Auth_State::loadState($id, 'expirywarning:about2expire');
if (array_key_exists('yes', $_REQUEST)) { if (array_key_exists('yes', $_REQUEST)) {
// The user has pressed the yes-button // The user has pressed the yes-button
SimpleSAML_Auth_ProcessingChain::resumeProcessing($state); SimpleSAML_Auth_ProcessingChain::resumeProcessing($state);
} }
$globalConfig = SimpleSAML_Configuration::getInstance(); $globalConfig = SimpleSAML_Configuration::getInstance();
$daysleft = $state['daysleft'];
$t = new SimpleSAML_XHTML_Template($globalConfig, 'expirycheck:about2expire.php'); $t = new SimpleSAML_XHTML_Template($globalConfig, 'expirycheck:about2expire.php');
$t->data['autofocus'] = 'yesbutton';
$t->data['yesTarget'] = SimpleSAML\Module::getModuleURL('expirycheck/about2expire.php'); $t->data['yesTarget'] = SimpleSAML\Module::getModuleURL('expirycheck/about2expire.php');
$t->data['yesData'] = array('StateId' => $id); $t->data['yesData'] = array('StateId' => $id);
$t->data['daysleft'] = $state['daysleft']; $t->data['warning'] = $warning;
$t->data['expireOnDate'] = $state['expireOnDate']; $t->data['expireOnDate'] = $state['expireOnDate'];
$t->data['netId'] = $state['netId']; $t->data['netId'] = $state['netId'];
if ($daysleft == 0) {
# netid will expire today
$this->data['header'] = $this->t('{expirycheck:expwarning:warning_header_today}', array(
'%NETID%' => htmlspecialchars($this->data['netId'])
));
$this->data['warning'] = $this->t('{expirycheck:expwarning:warning_today}', array(
'%NETID%' => htmlspecialchars($this->data['netId'])
));
} elseif ($daysleft == 1) {
# netid will expire in one day
$this->data['header'] = $this->t('{expirycheck:expwarning:warning_header}', array(
'%NETID%' => htmlspecialchars($this->data['netId']),
'%DAYS%' => $this->t('{expirycheck:expwarning:day}'),
'%DAYSLEFT%' => htmlspecialchars($daysleft),
));
$this->data['warning'] = $this->t('{expirycheck:expwarning:warning}', array(
'%NETID%' => htmlspecialchars($this->data['netId']),
'%DAYS%' => $this->t('{expirycheck:expwarning:day}'),
'%DAYSLEFT%' => htmlspecialchars($daysleft),
));
} else {
# netid will expire in next <daysleft> days
$this->data['header'] = $this->t('{expirycheck:expwarning:warning_header}', array(
'%NETID%' => htmlspecialchars($this->data['netId']),
'%DAYS%' => $this->t('{expirycheck:expwarning:days}'),
'%DAYSLEFT%' => htmlspecialchars($daysleft),
));
$this->data['warning'] = $this->t('{expirycheck:expwarning:warning}', array(
'%NETID%' => htmlspecialchars($this->data['netId']),
'%DAYS%' => $this->t('{expirycheck:expwarning:days}'),
'%DAYSLEFT%' => htmlspecialchars($daysleft),
));
}
$t->show(); $t->show();
...@@ -9,13 +9,14 @@ ...@@ -9,13 +9,14 @@
SimpleSAML\Logger::info('expirycheck - User has been warned that NetID is near to expirational date.'); SimpleSAML\Logger::info('expirycheck - User has been warned that NetID is near to expirational date.');
if (!array_key_exists('StateId', $_REQUEST)) { if (!array_key_exists('StateId', $_REQUEST)) {
throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.'); throw new SimpleSAML_Error_BadRequest('Missing required StateId query parameter.');
} }
$state = SimpleSAML_Auth_State::loadState($_REQUEST['StateId'], 'expirywarning:expired'); $state = SimpleSAML_Auth_State::loadState($_REQUEST['StateId'], 'expirywarning:expired');
$globalConfig = SimpleSAML_Configuration::getInstance(); $globalConfig = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($globalConfig, 'expirycheck:expired.php'); $t = new SimpleSAML_XHTML_Template($globalConfig, 'expirycheck:expired.php');
$t->data['expireOnDate'] = $state['expireOnDate']; $t->data['header'] = $this->t('{expirycheck:expwarning:access_denied}');
$t->data['netId'] = $state['netId']; $t->data['expireOnDate'] = htmlspecialchars($state['expireOnDate']);
$t->data['netId'] = htmlspecialchars($state['netId']);
$t->show(); $t->show();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment