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

Commit 9562382

Browse files
melangerDominik František Bučík
authored andcommitted
edit consent template (#74)
Modified consent page
1 parent 73acdff commit 9562382

File tree

4 files changed

+159
-61
lines changed

4 files changed

+159
-61
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
33

44
## [Unreleased]
55
#### Changed
6+
- Updated consent page
7+
- Consent page is shown as a list instead of a teble
8+
- Changes in dictionary
9+
- Change the width for keys(col-sm-5) and values(col-sm-7)
610
- Added filterAttributes option to ProxyFilter for filtering out based on user attribute values
711

812
## [v3.4.1]
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
{
22
"remember": {
3-
"en": "Do not ask again",
4-
"cs": "Příště se již neptat"
3+
"en": "Remember my approval",
4+
"cs": "Zapamatovat souhlas"
55
},
66
"consent_attributes_header": {
7-
"en":"Information that will be sent to SPNAME",
8-
"cs":"Atributy, které budou zaslány službě SPNAME"
7+
"en": "Information sent to SPNAME",
8+
"cs": "Atributy pro službu SPNAME"
99
},
1010
"forwardedscopedaffiliation": {
11-
"en": "Home organization affiliation",
12-
"cs": "Vztah k domovské(ým) organizaci(cím)"
11+
"en": "Home organization affiliation",
12+
"cs": "Vztah k domovské(ým) organizaci(cím)"
1313
},
1414
"edupersonscopedaffiliation": {
15-
"en": "Community affiliation",
16-
"cs": "Vztah k AAI"
15+
"en": "Community affiliation",
16+
"cs": "Vztah k AAI"
1717
},
1818
"loa":{
19-
"en": "Level of Assurance",
20-
"cs": "Úroveň jistoty"
19+
"en": "Level of Assurance",
20+
"cs": "Úroveň jistoty"
2121
},
2222
"edupersonuniqueid":{
23-
"en": "Person’s unique Id",
24-
"cs": "Unikátní identifikátor osoby"
23+
"en": "Person’s unique Id",
24+
"cs": "Unikátní identifikátor osoby"
2525
},
2626
"edupersonprincipalname":{
27-
"en": "Person’s principal name",
28-
"cs": "Identifikátor osoby v organizaci"
27+
"en": "Person’s principal name",
28+
"cs": "Identifikátor osoby v organizaci"
2929
},
3030
"forwardedpersonprincipalnames":{
31-
"en": "Person’s principal names from home organization(s)",
32-
"cs": "Identifikátor(y) osoby z domovské(ých) organizace(cí)"
31+
"en": "Person’s principal names from home organization(s)",
32+
"cs": "Identifikátor(y) osoby z domovské(ých) organizace(cí)"
3333
},
3434
"displayname": {
35-
"en": "Person's name",
36-
"cs": "Jméno uživatele"
35+
"en": "Person's name",
36+
"cs": "Jméno uživatele"
3737
}
3838
}

themes/perun/consent/consentform.php

Lines changed: 101 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,81 @@
2828
assert('is_array($this->data["hiddenAttributes"])');
2929
assert('$this->data["sppp"] === false || is_string($this->data["sppp"])');
3030

31+
if (!isset($this->data['label-col'])) {
32+
$this->data['label-col'] = 5;
33+
}
34+
35+
function present_attributes_photo_or_value($nameraw, $listitem)
36+
{
37+
if ($nameraw === 'jpegPhoto') {
38+
return '<img src="data:image/jpeg;base64,' . htmlspecialchars($listitem) . '" alt="User photo" />';
39+
} else {
40+
return htmlspecialchars($listitem);
41+
}
42+
}
43+
44+
function perun_present_attributes($t, $attributes, $nameParent, $labelCol = 5)
45+
{
46+
$translator = $t->getTranslator();
47+
48+
if (strlen($nameParent) > 0) {
49+
$parentStr = strtolower($nameParent).'_';
50+
$str = '<ul class="perun-attributes">';
51+
} else {
52+
$parentStr = '';
53+
$str = '<ul id="perun-table_with_attributes" class="perun-attributes">';
54+
}
55+
56+
foreach ($attributes as $name => $value) {
57+
$nameraw = $name;
58+
$name = $translator->getAttributeTranslation($parentStr.$nameraw);
59+
60+
if (preg_match('/^child_/', $nameraw)) {
61+
// insert child table
62+
throw new Exception('Unsupported');
63+
} else {
64+
// insert values directly
65+
$str .= "\n".'<li>'
66+
. '<div class="row"><div class="col-sm-' . $labelCol
67+
. '"><h2 class="perun-attrname h4">'
68+
. htmlspecialchars(str_replace("domovksé", "domovské", $name)).'</h2></div>';
69+
70+
$str .= '<div class="perun-attrcontainer col-sm-' . (12-$labelCol) . '">';
71+
$isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true);
72+
if ($isHidden) {
73+
$hiddenId = \SimpleSAML\Utils\Random::generateID();
74+
$str .= '<span class="perun-attrvalue hidden" id="hidden_'.$hiddenId.'">';
75+
} else {
76+
$str .= '<span class="perun-attrvalue">';
77+
}
78+
79+
if (count($value) > 0) {
80+
$str .= '<ul class="perun-attrlist">';
81+
foreach ($value as $listitem) {
82+
$str .= '<li>' . present_attributes_photo_or_value($nameraw, $listitem) . '</li>';
83+
}
84+
$str .= '</ul>';
85+
}
86+
$str .= '</span>';
87+
88+
if ($isHidden) {
89+
$str .= '<div class="perun-attrvalue consent_showattribute" id="visible_'.$hiddenId.'">';
90+
$str .= '&#8230; ';
91+
$str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_'.$hiddenId;
92+
$str .= '\'); SimpleSAML_hide(\'visible_'.$hiddenId.'\');">';
93+
$str .= $t->t('{consent:consent:show_attribute}');
94+
$str .= '</a>';
95+
$str .= '</div>';
96+
}
97+
98+
$str .= '</div><!-- .perun-attrcontainer --></div><!-- .row --></li>';
99+
} // end else: not child table
100+
} // end foreach
101+
$str .= isset($attributes) ? '</ul>' : '';
102+
return $str;
103+
}
104+
105+
31106
// Parse parameters
32107
if (array_key_exists('name', $this->data['srcMetadata'])) {
33108
$srcName = $this->data['srcMetadata']['name'];
@@ -60,7 +135,10 @@
60135

61136
$this->data['header'] = $this->t('{consent:consent:consent_header}');
62137

63-
$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="' .
138+
if (!isset($this->data['head'])) {
139+
$this->data['head'] = '';
140+
}
141+
$this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' .
64142
Module::getModuleUrl('consent/assets/css/consent.css') . '" />';
65143
$this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' .
66144
Module::getModuleUrl('perun/res/css/consent.css') . '" />';
@@ -88,46 +166,50 @@
88166
echo "</p>";
89167
}
90168

91-
echo '<h3 id="attributeheader">' .
169+
echo '<h1 id="attributeheader">' .
92170
$this->t(
93171
'{perun:consent:consent_attributes_header}',
94172
['SPNAME' => $dstName, 'IDPNAME' => $srcName]
95173
) .
96-
'</h3>';
174+
'</h1>';
97175

98-
echo present_attributes($this, $attributes, '');
176+
echo perun_present_attributes($this, $attributes, '', $this->data['label-col']);
99177

100178
?>
179+
<div class="row" id="saveconsentcontainer">
180+
<div class="col-xs-12">
181+
<?php
182+
if ($this->data['usestorage']) {
183+
$checked = ($this->data['checked'] ? 'checked="checked"' : '');
184+
echo '<div class="checkbox">
185+
<input type="checkbox" form="yesform" name="saveconsent" id="saveconsent" value="1" /> '
186+
. '<label for="saveconsent">' . $this->t('{perun:consent:remember}') . '</label>
187+
</div>';
188+
}
189+
?>
190+
</div>
191+
</div>
101192

102193
<div class="row">
103-
<div class="col-xs-6">
194+
<div class="col-sm-6">
104195

105-
<form action="<?php echo htmlspecialchars($this->data['yesTarget']); ?>">
196+
<form action="<?php echo htmlspecialchars($this->data['yesTarget']); ?>" id="yesform">
106197
<?php
107-
if ($this->data['usestorage']) {
108-
$checked = ($this->data['checked'] ? 'checked="checked"' : '');
109-
echo '<div class="checkbox">
110-
<label>
111-
<input type="checkbox" name="saveconsent" value="1" /> ' . $this->t('{perun:consent:remember}') . '
112-
</label>
113-
</div>';
114-
}
115-
116198
// Embed hidden fields...
117199
foreach ($this->data['yesData'] as $name => $value) {
118200
echo '<input type="hidden" name="' . htmlspecialchars($name) .
119201
'" value="' . htmlspecialchars($value) . '" />';
120202
}
121203
?>
122204

123-
<button type="submit" name="yes" class="btn btn-lg btn-success btn-block" id="yesbutton">
124-
<?php echo htmlspecialchars($this->t('{consent:consent:yes}')) ?>
205+
<button type="submit" name="yes" class="btn btn-lg btn-primary btn-success btn-block" id="yesbutton">
206+
<span><?php echo htmlspecialchars($this->t('{consent:consent:yes}')) ?></span>
125207
</button>
126208

127209
</form>
128210

129211
</div>
130-
<div class="col-xs-6">
212+
<div class="col-sm-6">
131213

132214
<form action="<?php echo htmlspecialchars($this->data['noTarget']); ?>">
133215

@@ -138,7 +220,7 @@
138220
}
139221
?>
140222
<button type="submit" class="btn btn-lg btn-default btn-block btn-no" name="no" id="nobutton">
141-
<?php echo htmlspecialchars($this->t('{consent:consent:no}')) ?>
223+
<span><?php echo htmlspecialchars($this->t('{consent:consent:no}')) ?></span>
142224
</button>
143225

144226
</form>

www/res/css/consent.css

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,55 @@
1-
h3#attributeheader {
2-
margin: 0em 0em 0.5em 0em;
1+
#perun-table_with_attributes > :nth-child(odd) {
2+
background-color: #DFDFDF;
33
}
44

5-
table.attributes {
6-
border: inherit;
7-
margin-bottom: 20px;
5+
#perun-table_with_attributes, #perun-table_with_attributes ul, #perun-table_with_attributes .perun-attrname, #perun-table_with_attributes li {
6+
margin: 0;
7+
padding: 0;
88
}
99

10-
table.attributes tr td {
11-
border-bottom: inherit;
10+
#perun-table_with_attributes > li {
11+
clear: both;
12+
overflow: hidden;
13+
padding: 0.8em 0.5em;
1214
}
1315

14-
table#table_with_attributes .attrvalue {
15-
padding-left: 2em;
16-
margin: 0.2em 0 0.1em 0;
16+
#perun-table_with_attributes li {
17+
margin-left: 15px;
18+
list-style-type: disc;
1719
}
1820

19-
.btn:hover {
20-
background-image: none;
21+
#perun-table_with_attributes > li {
22+
list-style-type: none;
2123
}
2224

23-
.btn-no {
24-
margin-top: 40px;
25+
#perun-table_with_attributes li:only-child {
26+
list-style-type: none;
27+
margin-left: 0;
2528
}
2629

27-
.checkbox input[type=checkbox], .checkbox-inline input[type=checkbox], .radio input[type=radio], .radio-inline input[type=radio] {
28-
position: absolute;
29-
margin-left: -20px;
30+
#perun-table_with_attributes {
31+
margin-bottom: 2em;
32+
margin-left: -15px;
33+
margin-right: -15px;
3034
}
3135

32-
.checkbox-tight label.form-check-label {
33-
font-weight: 500;
36+
#saveconsentcontainer {
37+
margin-bottom: 1em;
3438
}
3539

36-
.table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
37-
border-top: none;
38-
border-bottom: 1px solid #ddd;
40+
#saveconsent {
41+
position: static;
42+
margin-left: 0;
3943
}
4044

41-
#table_with_attributes {
42-
border: none;
45+
#perun-table_with_attributes .perun-attrname {
46+
border-bottom: 0;
47+
}
48+
49+
.perun-attrcontainer {
50+
overflow-wrap: break-word;
51+
}
52+
53+
#yesbutton, #nobutton {
54+
margin-top: 1em;
4355
}

0 commit comments

Comments
 (0)