Skip to content

Commit

Permalink
Dev: Central participant management should not allow sorting on encry…
Browse files Browse the repository at this point in the history
…pted values (#3797)
  • Loading branch information
kevin-foster-uk committed Mar 22, 2024
1 parent fb9c151 commit 63bbc0a
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions application/models/Participant.php
Expand Up @@ -327,13 +327,13 @@ public function getColumns()
'htmlOptions' => ['class' => 'ls-sticky-column'],
],
[
"name" => 'lastname'
"name" => 'lastname',
],
[
"name" => 'firstname'
"name" => 'firstname',
],
[
"name" => 'email'
"name" => 'email',
],
[
"name" => 'language',
Expand Down Expand Up @@ -417,6 +417,15 @@ public function getColumns()
*/
public function search()
{
$encryptedAttributes = $this->getParticipantsEncryptionOptions();
$encryptedAttributesColums = isset($encryptedAttributes) && isset($encryptedAttributes['columns'])
? $encryptedAttributes['columns']
: [];
$encryptedAttributesColums = array_filter($encryptedAttributesColums, function ($column) {
return $column === 'Y';
});
$encryptedAttributesColums = array_keys($encryptedAttributesColums);

$sort = new CSort();
$sort->defaultOrder = 'lastname';
$sortAttributes = array(
Expand Down Expand Up @@ -455,6 +464,14 @@ public function search()
);
$this->decryptEncryptAttributes('encrypt');

if (!empty($encryptedAttributesColums)) {
foreach ($encryptedAttributesColums as $encryptedColum) {
if (isset($sortAttributes[$encryptedColum])) {
unset($sortAttributes[$encryptedColum]);
}
}
}

$criteria = new CDbCriteria();
$criteria->join = 'LEFT JOIN {{users}} as owner on uid=owner_uid LEFT JOIN {{participant_shares}} AS shares ON t.participant_id = shares.participant_id AND (shares.share_uid = ' . Yii::app()->user->id . ' OR shares.share_uid = -1)';
$criteria->compare('t.participant_id', $this->participant_id, true, 'AND', true);
Expand Down

0 comments on commit 63bbc0a

Please sign in to comment.