From: <gem...@li...> - 2011-11-03 13:10:21
|
Revision: 171 http://gemstracker.svn.sourceforge.net/gemstracker/?rev=171&view=rev Author: matijsdejong Date: 2011-11-03 13:10:10 +0000 (Thu, 03 Nov 2011) Log Message: ----------- #31 continued: stored of has can now be set on project level (by overruling RespondentModel.php) Modified Paths: -------------- trunk/library/classes/Gems/Model/RespondentModel.php trunk/library/classes/GemsEscort.php Modified: trunk/library/classes/Gems/Model/RespondentModel.php =================================================================== --- trunk/library/classes/Gems/Model/RespondentModel.php 2011-11-03 13:08:54 UTC (rev 170) +++ trunk/library/classes/Gems/Model/RespondentModel.php 2011-11-03 13:10:10 UTC (rev 171) @@ -50,8 +50,25 @@ */ class Gems_Model_RespondentModel extends Gems_Model_HiddenOrganizationModel { - protected $hashBsn = true; + const SSN_HASH = 0; + const SSN_HIDE = 1; + const SSN_OPEN = 2; + /** + * Determines how the social security number is stored. + * + * Can be changed is derived classes. + * + * @var int One of the SSN_ constants + */ + public $hashSsn = self::SSN_HASH; + + /** + * + * @var Gems_Project_ProjectSettings + */ + protected $project; + public function __construct() { // gems__respondents MUST be first table for INSERTS!! @@ -67,9 +84,9 @@ $this->setOnSave('gr2o_opened_by', GemsEscort::getInstance()->session->user_id); $this->setSaveOnChange('gr2o_opened_by'); - if ($this->hashBsn) { + if (self::SSN_HASH === $this->hashSsn) { $this->setSaveWhenNotNull('grs_ssn'); - $this->setOnSave('grs_ssn', array($this, 'formatBSN')); + $this->setOnSave('grs_ssn', array($this, 'formatSSN')); } } @@ -93,17 +110,21 @@ return $filter; } - public function formatBSN($name, $value, $new = false) + /** + * Return a hashed version of the input value. + * + * @param string $name Optional name, is here for ModelAbstract setOnSave compatibility + * @param string $value The value to hash. + * @param boolean $new Optional is new, is here for ModelAbstract setOnSave compatibility + * @return string The salted hash as a 32-character hexadecimal number. + */ + public function formatSSN($name, $value, $new = false) { - return md5($value); + if ($value) { + return $this->project->getValueHash($value); + } } - public function addPhysicians() - { - $this->addLeftTable('gems__staff', array('gr2o_id_physician' => 'gsf_id_user')); - return $this; - } - public function copyKeys($reset = false) { $keys = $this->_getKeysFor('gems__respondent2org'); Modified: trunk/library/classes/GemsEscort.php =================================================================== --- trunk/library/classes/GemsEscort.php 2011-11-03 13:08:54 UTC (rev 170) +++ trunk/library/classes/GemsEscort.php 2011-11-03 13:10:10 UTC (rev 171) @@ -1308,7 +1308,7 @@ } /** - * Return a hashed of the string. + * Return a hashed version of the input value. * * @param string $name Optional name, is here for ModelAbstract setOnSave compatibility * @param string $value The value to hash. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |