Skip to content

Commit

Permalink
Merge branch 'release-3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
olgabrani committed Sep 20, 2019
2 parents ed6ee4e + a1addca commit b8d70fc
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 178 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ Temporary Items
*.swo
**/css
**/.sass-cache
**/*.un~
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v3.0.0](https://github.com/rciam/simplesamlphp-module-themevanilla/compare/v2.3.1...v3.0.0) - 2019-09-20

### Added
- Add languages (Xhosa, Zulu, Afrikaans).

### Changed
- Rename disco-tpl.php->disco.tpl.php as needed by simplesamlphp>1.14.
- Update translation functionality as needed by simplesamlphp>1.14.

## [v2.3.1](https://github.com/rciam/simplesamlphp-module-themevanilla/compare/v2.3.0...v2.3.1) - 2019-09-12

### Fixed
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,19 @@ To modify the cookie banner and cookie policy page, you must edit the following
and to modify the table in cookie policy page:
`<path-to-simplesamlphp>/config/module_themevanilla.php`.

## Compatibility Note

If you want to use the theme with **SimpleSAMLphp version greater than 1.14**, you
need to rename the template of the discopower module:
```
themes/ssp/discopower/disco-tpl.php -> themes/ssp/discopower/disco.tpl.php
```

## About SimpleSAMLphp themes

You can read more about themes in a SimpleSAMLphp installation from the
[official documentation](https://simplesamlphp.org/docs/stable/simplesamlphp-theming).

## Compatibility matrix

This table matches the theme version with the supported SimpleSAMLphp version.

| Theme | SimpleSAMLphp |
|:------:|:--------------:|
| v2.3.1 | v1.14 |
| v3.0.0 | v1.17 |

## License

Expand Down
2 changes: 1 addition & 1 deletion templates/policy.tpl.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$themeConfig = SimpleSAML_Configuration::getConfig('module_themevanilla.php');
$themeConfig = SimpleSAML\Configuration::getConfig('module_themevanilla.php');
$cookies = $themeConfig->getValue('cookiePolicy');
$this->data['header'] = (strpos($this->t('{themevanilla:policy:page_title}'), 'not translated') === FALSE ? $this->t('{themevanilla:policy:page_title}') : '');
$this->includeAtTemplateBase('includes/header.php');
Expand Down
172 changes: 71 additions & 101 deletions themes/ssp/consent/consentform.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,84 +19,64 @@
* Template form for giving consent.
*
* Parameters:
* - 'srcMetadata': Metadata/configuration for the source.
* - 'dstMetadata': Metadata/configuration for the destination.
* - 'yesTarget': Target URL for the yes-button. This URL will receive a POST request.
* - 'yesData': Parameters which should be included in the yes-request.
* - 'noTarget': Target URL for the no-button. This URL will receive a GET request.
* - 'noData': Parameters which should be included in the no-request.
* - 'attributes': The attributes which are about to be released.
* - 'sppp': URL to the privacy policy of the destination, or FALSE.
*
* @package SimpleSAMLphp
*/
assert('is_array($this->data["srcMetadata"])');
assert('is_array($this->data["dstMetadata"])');
assert('is_string($this->data["yesTarget"])');
assert('is_array($this->data["yesData"])');
assert('is_string($this->data["noTarget"])');
assert('is_array($this->data["noData"])');
assert('is_array($this->data["attributes"])');
assert('is_array($this->data["hiddenAttributes"])');
assert('$this->data["sppp"] === false || is_string($this->data["sppp"])');
assert(is_string($this->data['yesTarget']));
assert(is_string($this->data['noTarget']));
assert($this->data['sppp'] === false || is_string($this->data['sppp']));

// Needed for present_attributes_ssp()
$globalConfig = \SimpleSAML\Configuration::getInstance();
$t = new \SimpleSAML\XHTML\Template($globalConfig, 'consent:consentform.php');

// Parse parameters
if (array_key_exists('name', $this->data['srcMetadata'])) {
$srcName = $this->data['srcMetadata']['name'];
} elseif (array_key_exists('OrganizationDisplayName', $this->data['srcMetadata'])) {
$srcName = $this->data['srcMetadata']['OrganizationDisplayName'];
} else {
$srcName = $this->data['srcMetadata']['entityid'];
}
$dstName = $this->data['dstName'];
$srcName = $this->data['srcName'];

if (is_array($srcName)) {
$srcName = $this->t($srcName);
}
$id = $_REQUEST['StateId'];
$state = \SimpleSAML\Auth\State::loadState($id, 'consent:request');

if (array_key_exists('name', $this->data['dstMetadata'])) {
$dstName = $this->data['dstMetadata']['name'];
} elseif (array_key_exists('OrganizationDisplayName', $this->data['dstMetadata'])) {
$dstName = $this->data['dstMetadata']['OrganizationDisplayName'];
if (array_key_exists('consent:hiddenAttributes', $state)) {
$t->data['hiddenAttributes'] = $state['consent:hiddenAttributes'];
} else {
$dstName = $this->data['dstMetadata']['entityid'];
}

if (is_array($dstName)) {
$dstName = $this->t($dstName);
$t->data['hiddenAttributes'] = [];
}

$srcName = htmlspecialchars($srcName);
$dstName = htmlspecialchars($dstName);

$attributes = $this->data['attributes'];

$this->data['header'] = $this->t('{consent:consent:consent_header}');
$this->data['jquery'] = array('core' => TRUE);

$this->includeAtTemplateBase('includes/header.php');
?>
<h2 class="text-center"><?php echo $this->data['consent_accept']; ?></h2>
<div class="row js-spread">
<div class="col-sm-12 ssp-content-group js-spread">

<?php
echo $this->data['attributes_html'] = present_attributes_ssp($t, $attributes, '');

<?php
if ($this->data['sppp'] !== false) {
echo "<p>" . htmlspecialchars($this->t('{consent:consent:consent_privacypolicy}')) . " ";
echo "<a target='_blank' href='" . htmlspecialchars($this->data['sppp']) . "'>" . $dstName . "</a>";
echo "</p>";
}

/**
* Recursive attribute array listing function
*
* @param SimpleSAML_XHTML_Template $t Template object
* @param \SimpleSAML\XHTML\Template $t Template object
* @param array $attributes Attributes to be presented
* @param string $nameParent Name of parent element
*
* @return string HTML representation of the attributes
*/
function present_attributes($t, $attributes, $nameParent)
function present_attributes_ssp($t, $attributes, $nameParent)
{
$alternate = array('ssp-table--tr__odd', 'ssp-table--tr__even');
$translator = $t->getTranslator();

$alternate = ['ssp-table--tr__odd', 'ssp-table--tr__even'];
$i = 0;
$summary = 'summary="' . $t->t('{consent:consent:table_summary}') . '"';
$summary = 'summary="'.$translator->t('{consent:consent:table_summary}').'"';

if (strlen($nameParent) > 0) {
$parentStr = strtolower($nameParent) . '_';
Expand All @@ -108,49 +88,48 @@ function present_attributes($t, $attributes, $nameParent)

foreach ($attributes as $name => $value) {
$nameraw = $name;
$name = $t->getAttributeTranslation($parentStr . $nameraw);
$name = $translator->getAttributeTranslation($parentStr.$nameraw);

if (preg_match('/^child_/', $nameraw)) {
// insert child table
$parentName = preg_replace('/^child_/', '', $nameraw);
foreach ($value as $child) {
$str .= "\n" . '<tr class="odd ssp--table--tr__odd"><td>' .
present_attributes($t, $child, $parentName) . '</td></tr>';
$str .= "\n" . '<tr class="odd ssp--table--tr__odd"><td>'.
present_attributes_ssp($t, $child, $parentName) . '</td></tr>';
}
} else {
// insert values directly

$str .= "\n" . '<tr class="' . $alternate[($i++ % 2)] .
'"><td><div class="attrname ssp-table--attrname">' . htmlspecialchars($name) . '</div>';


$isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true);
if ($isHidden) {
$hiddenId = SimpleSAML\Utils\Random::generateID();

$hiddenId = \SimpleSAML\Utils\Random::generateID();
$str .= '<div class="attrvalue ssp-table--attrvalue" style="display: none;" id="hidden_' . $hiddenId . '">';
} else {
$str .= '<div class="attrvalue ssp-table--attrvalue">';
}

if (sizeof($value) > 1) {
// we hawe several values
// we have several values
$str .= '<ul class="list-unstyled ssp-table--attrvalue--list">';
foreach ($value as $listitem) {
if ($nameraw === 'jpegPhoto') {
$str .= '<li class="ssp-table--attrvalue--list--item"><img src="data:image/jpeg;base64,' .
htmlspecialchars($listitem) .
'" alt="User photo" /></li>';
htmlspecialchars($listitem).'" alt="User photo" /></li>';
} else {
$str .= '<li class="ssp-table--attrvalue--list--item">' . htmlspecialchars($listitem) . '</li>';
}
}
$str .= '</ul>';

} elseif (isset($value[0])) {
// we hawe only one value
// we have only one value
if ($nameraw === 'jpegPhoto') {
$str .= '<img src="data:image/jpeg;base64,' .
htmlspecialchars($value[0]) .
'" alt="User photo" />';
$str .= '<img src="data:image/jpeg;base64,'.
htmlspecialchars($value[0]).'" alt="User photo" />';
} else {
$str .= htmlspecialchars($value[0]);
}
Expand All @@ -168,64 +147,55 @@ function present_attributes($t, $attributes, $nameParent)
}

$str .= '</td></tr>';
} // end else: not child table
} // end foreach
} // end else: not child table
} // end foreach
$str .= isset($attributes)? '</table></div>':'';
return $str;
}

echo '<h2 class="text-center">' .
$this->t(
'{consent:consent:consent_accept}',
array( 'SPNAME' => $dstName, 'IDPNAME' => $srcName)).
'</h2>
<div class="row js-spread">
<div class="col-sm-12 ssp-content-group js-spread">';
?>

<?php
echo present_attributes($this, $attributes, '');
?>
<div class="ssp-btns-container">
<form style="display: inline-block"
action="<?php echo htmlspecialchars($this->data['yesTarget']); ?>">
<p class"ssp-btns-container--checkbox>

<?php
if ($this->data['usestorage']) {
$checked = ($this->data['checked'] ? 'checked="checked"' : '');
echo '<input type="checkbox" name="saveconsent" ' . $checked .
' value="1" /> ' . $this->t('{consent:consent:remember}');
}

// Embed hidden fields...
foreach ($this->data['yesData'] as $name => $value) {
echo '<input type="hidden" name="' . htmlspecialchars($name) .
'" value="' . htmlspecialchars($value) . '" />';
if (isset($this->data['consent_purpose'])) {
echo '<p>'.$this->data['consent_purpose'].'</p>';
}
?>
</p>
<button type="submit" name="yes" class=" ssp-btn btn ssp-btn__action ssp-btns-container--btn__left text-uppercase" id="yesbutton">
<?php echo htmlspecialchars($this->t('{consent:consent:yes}')) ?>
</button>
</form>

<form style="display: inline-block;" action="<?php echo htmlspecialchars($this->data['noTarget']); ?>"
method="get">

<div class="ssp-btns-container">
<form id="consent_yes" action="<?php echo htmlspecialchars($this->data['yesTarget']); ?>" style="display:inline-block;">
<p class="ssp-btns-container--checkbox">
<?php
foreach ($this->data['noData'] as $name => $value) {
echo('<input type="hidden" name="' . htmlspecialchars($name) .
'" value="' . htmlspecialchars($value) . '" />');
}
if ($this->data['usestorage']) {
$checked = ($this->data['checked'] ? 'checked="checked"' : '');
echo '<input type="checkbox" name="saveconsent" '.$checked.
' value="1" /> '.$this->t('{consent:consent:remember}');
} // Embed hidden fields...
?>
<button type="submit" class="ssp-btn ssp-btn__secondary btn ssp-btns-container--btn__right text-uppercase" name="no" id="nobutton">
<?php echo htmlspecialchars($this->t('{consent:consent:no}')) ?>
</button>
<input type="hidden" name="StateId" value="<?php echo htmlspecialchars($this->data['stateId']); ?>" />
</p>
<button type="submit" name="yes" class="ssp-btn btn ssp-btn__action ssp-btns-container--btn__left text-uppercase" id="yesbutton">
<?php echo htmlspecialchars($this->t('{consent:consent:yes}')) ?>
</button>
</form>

<form id="consent_no" action="<?php echo htmlspecialchars($this->data['noTarget']); ?>" style="display:inline-block;">
<input type="hidden" name="StateId" value="<?php echo htmlspecialchars($this->data['stateId']); ?>" />
<button type="submit" class="ssp-btn ssp-btn__secondary btn ssp-btns-container--btn__right text-uppercase" name="no" id="nobutton">
<?php echo htmlspecialchars($this->t('{consent:consent:no}')) ?>
</button>
</form>
</div> <!-- /ssp-btns-container -->
</div> <!--/ssp-btns-container-->
</div> <!-- /ssp-content-group -->
</div> <!-- /row -->

<?php
if ($this->data['sppp'] !== false) {
echo "<p>".htmlspecialchars($this->t('{consent:consent:consent_privacypolicy}'))." ";
echo '<a target="_blank" href="'.htmlspecialchars($this->data['sppp']).'">'.$dstName."</a>";
echo "</p>";
}



$this->includeAtTemplateBase('includes/footer.php');
?>
1 change: 1 addition & 0 deletions themes/ssp/consent/logout_completed.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

$this->data['header'] = $this->t('{logout:title}');
$this->data['jquery'] = array('core' => TRUE);
$this->includeAtTemplateBase('includes/header.php');

echo('<h2>' . $this->data['header'] . '</h2>');
Expand Down
27 changes: 8 additions & 19 deletions themes/ssp/consent/noconsent.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
<?php

if (array_key_exists('name', $this->data['dstMetadata'])) {
$dstName = $this->data['dstMetadata']['name'];
} elseif (array_key_exists('OrganizationDisplayName', $this->data['dstMetadata'])) {
$dstName = $this->data['dstMetadata']['OrganizationDisplayName'];
} else {
$dstName = $this->data['dstMetadata']['entityid'];
}
if (is_array($dstName)) {
$dstName = $this->t($dstName);
}
$dstName = htmlspecialchars($dstName);


$this->data['header'] = $this->t('{consent:consent:noconsent_title}');;
$this->data['header'] = $this->t('{consent:consent:noconsent_title}');
$this->data['jquery'] = array('core' => TRUE);

$this->includeAtTemplateBase('includes/header.php');

echo '<h3>' . $this->data['header'] . '</h3>';
echo '<p>' . $this->t('{consent:consent:noconsent_text}', array('SPNAME' => $dstName)) . '</p>';
echo '<h3>'.$this->data['header'].'</h3>';
echo '<p>'.$this->data['noconsent_text'].'</p>';

echo '<div class="ssp-btns-container">';
if ($this->data['resumeFrom']) {
echo('<a href="' . htmlspecialchars($this->data['resumeFrom']) . '" class="ssp-btn btn ssp-btn__action ssp-btns-container--btn__left text-uppercase">');
echo('<a href="'.htmlspecialchars($this->data['resumeFrom']).'" class="ssp-btn btn ssp-btn__action ssp-btns-container--btn__left text-uppercase">');
echo($this->t('{consent:consent:noconsent_return}'));
echo('</a>');
}

if ($this->data['aboutService']) {
echo('<a href="' . htmlspecialchars($this->data['aboutService']) . '" class="ssp-btn btn text-uppercase">');
echo('<a href="'.htmlspecialchars($this->data['aboutService']).'" class="ssp-btn btn text-uppercase" >');
echo($this->t('{consent:consent:noconsent_goto_about}'));
echo('</a>');
}
echo('<a href="' . htmlspecialchars($this->data['logoutLink']) . '" class="ssp-btn btn ssp-btn__warning text-uppercase ssp-btns-container--btn__right">' . $this->t('{consent:consent:abort}', array('SPNAME' => $dstName)) . '</a>');

echo('<a href="'.htmlspecialchars($this->data['logoutLink']).'" class="ssp-btn btn ssp-btn__warning text-uppercase ssp-btns-container--btn__right">'.$this->data['noconsent_abort'].'</a>');
echo '</div>'; //ssp-btns-container

$this->includeAtTemplateBase('includes/footer.php');
2 changes: 2 additions & 0 deletions themes/ssp/core/no_state.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

echo('<h2>' . $this->t('{core:no_state:suggestions}') . '</h2>');
echo('<ul class="list-unstyled">');
echo '<li>' . $this->t('{core:no_state:suggestion_badlink}') . '</li>';
echo('<li>' . $this->t('{core:no_state:suggestion_goback}') . '</li>');
echo('<li>' . $this->t('{core:no_state:suggestion_closebrowser}') . '</li>');
echo('</ul>');

echo('<h3>' . $this->t('{core:no_state:causes}') . '</h3>');
echo('<ul class="list-unstyled">');
echo '<li>' . $this->t('{core:no_state:cause_badlink}') . '</li>';
echo('<li>' . $this->t('{core:no_state:cause_backforward}') . '</li>');
echo('<li>' . $this->t('{core:no_state:cause_openbrowser}') . '</li>');
echo('<li>' . $this->t('{core:no_state:cause_nocookie}') . '</li>');
Expand Down
Loading

0 comments on commit b8d70fc

Please sign in to comment.