Revision: 1853
Author: olavmrk
Date: Wed Oct 14 00:44:45 2009
Log: consent: Add support for hiding the values of some attributes.
http://code.google.com/p/simplesamlphp/source/detail?r=1853

Modified:
  /trunk/modules/consent/dictionaries/consent.php
  /trunk/modules/consent/lib/Auth/Process/Consent.php
  /trunk/modules/consent/templates/consentform.php
  /trunk/modules/consent/www/getconsent.php

=======================================
--- /trunk/modules/consent/dictionaries/consent.php     Tue Aug 25 04:11:50 2009
+++ /trunk/modules/consent/dictionaries/consent.php     Wed Oct 14 00:44:45 2009
@@ -172,6 +172,12 @@
                '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',
=======================================
--- /trunk/modules/consent/lib/Auth/Process/Consent.php Sun Jul 12 23:18:56  
2009
+++ /trunk/modules/consent/lib/Auth/Process/Consent.php Wed Oct 14 00:44:45  
2009
@@ -72,6 +72,14 @@
        private $store;


+       /**
+        * List of attributes where the value should be hidden by default.
+        *
+        * @var array
+        */
+       private $hiddenAttributes;
+
+
        /**
         * Initialize consent filter.
         *
@@ -111,7 +119,12 @@
                                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 @@

                $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) {
=======================================
--- /trunk/modules/consent/templates/consentform.php    Thu Apr 30 12:48:48  
2009
+++ /trunk/modules/consent/templates/consentform.php    Wed Oct 14 00:44:45  
2009
@@ -23,6 +23,7 @@
  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 @@

  $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 @@

        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 @@
                        }
                } 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 @@
                                        $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>':'';
=======================================
--- /trunk/modules/consent/www/getconsent.php   Tue Mar 17 01:21:51 2009
+++ /trunk/modules/consent/www/getconsent.php   Wed Oct 14 00:44:45 2009
@@ -144,6 +144,11 @@
  } 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;

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/simplesamlphp-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to