diff --git a/modules/consent/dictionaries/consent.php b/modules/consent/dictionaries/consent.php index 20614be8bd8341d2d2f2288c825d39396190c86b..41f55ae69a41ac0164353eda11529662cd238260 100644 --- a/modules/consent/dictionaries/consent.php +++ b/modules/consent/dictionaries/consent.php @@ -172,6 +172,12 @@ $lang = array( 'pt' => 'Mostrar atributos', 'tr' => 'Özellikleri göster', ), + 'show_attribute' => array ( + 'no' => 'Vis', + 'nn' => 'Vis', + 'da' => 'Vis', + 'en' => 'Show', + ), 'login' => array ( 'no' => 'innlogging', 'nn' => 'Logg inn', diff --git a/modules/consent/lib/Auth/Process/Consent.php b/modules/consent/lib/Auth/Process/Consent.php index 820b78fb8960935c8dee53d2529a02773a4a611f..7763565fcf64f516c0cb0be28d9f8dc06fc0ab3d 100644 --- a/modules/consent/lib/Auth/Process/Consent.php +++ b/modules/consent/lib/Auth/Process/Consent.php @@ -72,6 +72,14 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt private $store; + /** + * List of attributes where the value should be hidden by default. + * + * @var array + */ + private $hiddenAttributes; + + /** * Initialize consent filter. * @@ -111,7 +119,12 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt SimpleSAML_Logger::error('Consent - constructor() : Could not create consent storage: ' . $e->getMessage()); } } - + + if (array_key_exists('hiddenAttributes', $config)) { + $this->hiddenAttributes = $config['hiddenAttributes']; + } else { + $this->hiddenAttributes = array(); + } } @@ -179,6 +192,7 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt $state['consent:focus'] = $this->focus; $state['consent:checked'] = $this->checked; + $state['consent:hiddenAttributes'] = $this->hiddenAttributes; /* User interaction nessesary. Throw exception on isPassive request */ if (isset($state['isPassive']) && $state['isPassive'] == TRUE) { diff --git a/modules/consent/templates/consentform.php b/modules/consent/templates/consentform.php index 1de9a13007b36764b9e873fd00ce8c51e5319314..eb36ed7665b89127fe6676cc0567c69d2c7a50ac 100644 --- a/modules/consent/templates/consentform.php +++ b/modules/consent/templates/consentform.php @@ -23,6 +23,7 @@ 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"])'); @@ -49,7 +50,6 @@ if (array_key_exists('name', $this->data['dstMetadata'])) { $attributes = $this->data['attributes']; - $this->data['header'] = $this->t('{consent:consent:consent_header}'); $this->data['head'] = '<link rel="stylesheet" type="text/css" href="/' . $this->data['baseurlpath'] . 'module.php/consent/style.css" />' . "\n"; @@ -120,7 +120,7 @@ function present_attributes($t, $attributes, $nameParent) { if(strlen($nameParent) > 0){ $parentStr = strtolower($nameParent) . '_'; - $str = '<table class="attributes"' . $summary . ' >'; + $str = '<table class="attributes" ' . $summary . '>'; }else{ $parentStr = ''; $str = '<table id="table_with_attributes" class="attributes" '. $summary .'>'; @@ -142,7 +142,18 @@ function present_attributes($t, $attributes, $nameParent) { } } else { // Insert values directly - $str .= "\n" . '<tr class="' . $alternate[($i++ % 2)] . '"><td><span class="attrname">' . htmlspecialchars($name) . '</span><div class="attrvalue">'; + + $str .= "\n" . '<tr class="' . $alternate[($i++ % 2)] . '"><td><span class="attrname">' . htmlspecialchars($name) . '</span>'; + + $isHidden = in_array($nameraw, $t->data['hiddenAttributes'], TRUE); + if ($isHidden) { + $hiddenId = SimpleSAML_Utilities::generateID(); + + $str .= '<div class="attrvalue" style="display: none;" id="hidden_' . $hiddenId . '">'; + } else { + $str .= '<div class="attrvalue">'; + } + if (sizeof($value) > 1) { // We hawe several values $str .= '<ul>'; @@ -162,7 +173,18 @@ function present_attributes($t, $attributes, $nameParent) { $str .= htmlspecialchars($value[0]); } } // end of if multivalue - $str .= '</div></td></tr>'; + $str .= '</div>'; + + if ($isHidden) { + $str .= '<div class="attrvalue consent_showattribute" id="visible_' . $hiddenId . '">'; + $str .= '... ('; + $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_' . $hiddenId . '\'); SimpleSAML_hide(\'visible_' . $hiddenId . '\');">'; + $str .= $t->t('{consent:consent:show_attribute}'); + $str .= '</a>)'; + $str .= '</div>'; + } + + $str .= '</td></tr>'; } // end else: not child table } // end foreach $str .= isset($attributes)? '</table>':''; diff --git a/modules/consent/www/getconsent.php b/modules/consent/www/getconsent.php index 98399310526fa9708c413b76630f9d818358a18d..d600f09363e3a23c60abc76e1849234894805582 100644 --- a/modules/consent/www/getconsent.php +++ b/modules/consent/www/getconsent.php @@ -144,6 +144,11 @@ if (array_key_exists('consent:store', $state)) { } else { $t->data['usestorage'] = FALSE; } +if (array_key_exists('consent:hiddenAttributes', $state)) { + $t->data['hiddenAttributes'] = $state['consent:hiddenAttributes']; +} else { + $t->data['hiddenAttributes'] = array(); +} $t->show(); exit;