Skip to content
Snippets Groups Projects
Commit 86d85d91 authored by Claudiu Cristea's avatar Claudiu Cristea
Browse files

ISAICP-9282: Don't show reports on user profile.

parent be38a2fb
No related branches found
No related tags found
2 merge requests!205Update ephemeral with develop,!204Release 2.1.0
......@@ -28,7 +28,7 @@ default_value:
weight: 1
region: top
enabled: 1
query_presets: ''
query_presets: 'entity_bundle|assessment_report|<>'
limit: 12
show_archived: all
default_value_callback: ''
......
......@@ -123,6 +123,10 @@ Feature: Assessments
When I visit "/collection/assessments"
Then I should not see "Assessment report #"
# Make sure assessment reports are not leaking in the user profile page.
When I visit "/user"
Then I should not see "Assessment report #"
Given I mark all emails as read
And I am logged in as Regular
# After approval, the submission cannot be edite anymore.
......
......@@ -81,3 +81,36 @@ function joinup_assessment_deploy_200101(): void {
$collection->skip_notification = TRUE;
$collection->save();
}
/**
* Update user content listing.
*/
function joinup_assessment_deploy_200102(?array &$sandbox = NULL): string {
$db = \Drupal::database();
if (!isset($sandbox['data'])) {
$sandbox['data'] = $db->select('user__field_user_content', 'u')
->fields('u', ['entity_id', 'field_user_content_value'])
->execute()
->fetchAll(\PDO::FETCH_NUM);
$sandbox['total'] = count($sandbox['data']);
$sandbox['processed'] = 0;
}
$data = array_splice($sandbox['data'], 0, 100);
foreach ($data as [$uid, $listing]) {
$listing = unserialize($listing, ['allowed_classes' => FALSE]);
// Append to potential existing value.
$query = trim($listing['query_presets'] ?? '') . "\nentity_bundle|assessment_report|<>";
$listing['query_presets'] = trim($query);
$db->update('user__field_user_content')
->fields(['field_user_content_value' => serialize($listing)])
->condition('entity_id', $uid)
->execute();
$sandbox['processed']++;
};
$sandbox['#finished'] = (int) empty($sandbox['data']);
return "{$sandbox['processed']} out of {$sandbox['total']} users processed";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment