From 60342a26ed3e6cf8b4264b233a03b67efe7792ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Sat, 1 Nov 2008 00:12:51 +0000 Subject: [PATCH] Adding support for preselecting the remember box in the consent module git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@966 44740490-163a-0410-bde0-09ae8108e29a --- modules/consent/lib/Auth/Process/Consent.php | 8 ++++++++ modules/consent/templates/default/consentform.php | 9 +++++++-- modules/consent/www/getconsent.php | 6 ++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/modules/consent/lib/Auth/Process/Consent.php b/modules/consent/lib/Auth/Process/Consent.php index 0d2f2c1bd..2b6dbca96 100644 --- a/modules/consent/lib/Auth/Process/Consent.php +++ b/modules/consent/lib/Auth/Process/Consent.php @@ -63,6 +63,8 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt * Whether or not to include attribute values when generates hash */ private $includeValues; + + private $checked; /** * Consent store, if enabled. @@ -87,6 +89,10 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt $this->includeValues = $config['includeValues']; } + if (array_key_exists('checked', $config)) { + $this->checked = $config['checked']; + } + if (array_key_exists('focus', $config)) { $this->focus = $config['focus']; if (!in_array($this->focus, array('yes', 'no'), TRUE)) { @@ -105,6 +111,7 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt SimpleSAML_Logger::error('Consent - constructor() : Could not create consent storage: ' . $e->getMessage()); } } + } @@ -154,6 +161,7 @@ class sspmod_consent_Auth_Process_Consent extends SimpleSAML_Auth_ProcessingFilt } $state['consent:focus'] = $this->focus; + $state['consent:checked'] = $this->checked; /* Save state and redirect. */ $id = SimpleSAML_Auth_State::saveState($state, 'consent:request'); diff --git a/modules/consent/templates/default/consentform.php b/modules/consent/templates/default/consentform.php index 23b399571..9d591f3ad 100644 --- a/modules/consent/templates/default/consentform.php +++ b/modules/consent/templates/default/consentform.php @@ -60,12 +60,13 @@ $attributes = $this->data['attributes']; $this->data['header'] = 'Consent'; /* TODO: translation */ + $this->includeAtTemplateBase('includes/header.php'); + ?> <div id="content"> <p> -<!-- notice:<?php echo $this->t('{consent:consent_notice}'); ?> <strong><?php echo htmlspecialchars($dstName); ?></strong>. --> <?php echo $this->t('{consent:consent_accept}', array( 'IDPNAME' => $srcName, 'SPNAME' => $dstName, @@ -84,11 +85,13 @@ if ($this->data['sppp'] !== FALSE) { <form style="display: inline" action="<?php echo htmlspecialchars($this->data['yesTarget']); ?>"> <input type="submit" name="yes" id="yesbutton" value="<?php echo $this->t('{consent:yes}') ?>" /> <?php + foreach ($this->data['yesData'] as $name => $value) { echo('<input type="hidden" name="' . htmlspecialchars($name) . '" value="' . htmlspecialchars($value) . '" />'); } if ($this->data['usestorage']) { - echo('<input type="checkbox" name="saveconsent" value="1" /> ' . $this->t('{consent:remember}')); + $checked = ($this->data['checked'] ? 'checked="checked"' : ''); + echo('<input type="checkbox" name="saveconsent" ' . $checked . ' value="1" /> ' . $this->t('{consent:remember}')); } ?> </form> @@ -105,6 +108,7 @@ foreach ($this->data['noData'] as $name => $value) { <p> <table class="attributes"> <?php + foreach ($attributes as $name => $value) { $nameTag = '{attributes:attribute_' . strtolower($name) . '}'; if ($this->getTag($nameTag) !== NULL) { @@ -127,5 +131,6 @@ foreach ($attributes as $name => $value) { </p> <?php + $this->includeAtTemplateBase('includes/footer.php'); ?> \ No newline at end of file diff --git a/modules/consent/www/getconsent.php b/modules/consent/www/getconsent.php index d76c51713..ec52c7644 100644 --- a/modules/consent/www/getconsent.php +++ b/modules/consent/www/getconsent.php @@ -50,6 +50,8 @@ $t->data['noTarget'] = SimpleSAML_Module::getModuleURL('consent/noconsent.php'); $t->data['noData'] = array('StateId' => $id); $t->data['attributes'] = $state['Attributes']; +$t->data['checked'] = $state['consent:checked']; + if (array_key_exists('privacypolicy', $state['Destination'])) { $privacypolicy = $state['Destination']['privacypolicy']; } elseif (array_key_exists('privacypolicy', $state['Source'])) { @@ -63,6 +65,8 @@ if($privacypolicy !== FALSE) { } $t->data['sppp'] = $privacypolicy; + + switch ($state['consent:focus']) { case NULL: break; @@ -80,6 +84,8 @@ if (array_key_exists('consent:store', $state)) { $t->data['usestorage'] = FALSE; } + + $t->show(); exit; -- GitLab