Skip to content
Snippets Groups Projects
Commit e81d09b8 authored by Olav Morken's avatar Olav Morken
Browse files

consent: Add support for hiding the values of some attributes.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1853 44740490-163a-0410-bde0-09ae8108e29a
parent 23b26ddb
No related branches found
No related tags found
No related merge requests found
...@@ -172,6 +172,12 @@ $lang = array( ...@@ -172,6 +172,12 @@ $lang = array(
'pt' => 'Mostrar atributos', 'pt' => 'Mostrar atributos',
'tr' => 'Özellikleri göster', 'tr' => 'Özellikleri göster',
), ),
'show_attribute' => array (
'no' => 'Vis',
'nn' => 'Vis',
'da' => 'Vis',
'en' => 'Show',
),
'login' => array ( 'login' => array (
'no' => 'innlogging', 'no' => 'innlogging',
'nn' => 'Logg inn', 'nn' => 'Logg inn',
......
...@@ -72,6 +72,14 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt ...@@ -72,6 +72,14 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt
private $store; private $store;
/**
* List of attributes where the value should be hidden by default.
*
* @var array
*/
private $hiddenAttributes;
/** /**
* Initialize consent filter. * Initialize consent filter.
* *
...@@ -111,7 +119,12 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt ...@@ -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()); 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 ...@@ -179,6 +192,7 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt
$state['consent:focus'] = $this->focus; $state['consent:focus'] = $this->focus;
$state['consent:checked'] = $this->checked; $state['consent:checked'] = $this->checked;
$state['consent:hiddenAttributes'] = $this->hiddenAttributes;
/* User interaction nessesary. Throw exception on isPassive request */ /* User interaction nessesary. Throw exception on isPassive request */
if (isset($state['isPassive']) && $state['isPassive'] == TRUE) { if (isset($state['isPassive']) && $state['isPassive'] == TRUE) {
......
...@@ -23,6 +23,7 @@ assert('is_array($this->data["yesData"])'); ...@@ -23,6 +23,7 @@ assert('is_array($this->data["yesData"])');
assert('is_string($this->data["noTarget"])'); assert('is_string($this->data["noTarget"])');
assert('is_array($this->data["noData"])'); assert('is_array($this->data["noData"])');
assert('is_array($this->data["attributes"])'); assert('is_array($this->data["attributes"])');
assert('is_array($this->data["hiddenAttributes"])');
assert('$this->data["sppp"] === FALSE || is_string($this->data["sppp"])'); assert('$this->data["sppp"] === FALSE || is_string($this->data["sppp"])');
...@@ -49,7 +50,6 @@ if (array_key_exists('name', $this->data['dstMetadata'])) { ...@@ -49,7 +50,6 @@ if (array_key_exists('name', $this->data['dstMetadata'])) {
$attributes = $this->data['attributes']; $attributes = $this->data['attributes'];
$this->data['header'] = $this->t('{consent:consent:consent_header}'); $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"; $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) { ...@@ -120,7 +120,7 @@ function present_attributes($t, $attributes, $nameParent) {
if(strlen($nameParent) > 0){ if(strlen($nameParent) > 0){
$parentStr = strtolower($nameParent) . '_'; $parentStr = strtolower($nameParent) . '_';
$str = '<table class="attributes"' . $summary . ' >'; $str = '<table class="attributes" ' . $summary . '>';
}else{ }else{
$parentStr = ''; $parentStr = '';
$str = '<table id="table_with_attributes" class="attributes" '. $summary .'>'; $str = '<table id="table_with_attributes" class="attributes" '. $summary .'>';
...@@ -142,7 +142,18 @@ function present_attributes($t, $attributes, $nameParent) { ...@@ -142,7 +142,18 @@ function present_attributes($t, $attributes, $nameParent) {
} }
} else { } else {
// Insert values directly // 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) { if (sizeof($value) > 1) {
// We hawe several values // We hawe several values
$str .= '<ul>'; $str .= '<ul>';
...@@ -162,7 +173,18 @@ function present_attributes($t, $attributes, $nameParent) { ...@@ -162,7 +173,18 @@ function present_attributes($t, $attributes, $nameParent) {
$str .= htmlspecialchars($value[0]); $str .= htmlspecialchars($value[0]);
} }
} // end of if multivalue } // 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 else: not child table
} // end foreach } // end foreach
$str .= isset($attributes)? '</table>':''; $str .= isset($attributes)? '</table>':'';
......
...@@ -144,6 +144,11 @@ if (array_key_exists('consent:store', $state)) { ...@@ -144,6 +144,11 @@ if (array_key_exists('consent:store', $state)) {
} else { } else {
$t->data['usestorage'] = FALSE; $t->data['usestorage'] = FALSE;
} }
if (array_key_exists('consent:hiddenAttributes', $state)) {
$t->data['hiddenAttributes'] = $state['consent:hiddenAttributes'];
} else {
$t->data['hiddenAttributes'] = array();
}
$t->show(); $t->show();
exit; exit;
......
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