Skip to content

Commit

Permalink
[bvl_feedback][dashboard] Add project/site specs to widget (#7848)
Browse files Browse the repository at this point in the history
This changes the getWidget code so that a user only sees behavioural feedback notifications relevant to their own sites (unless they have the access all sites permission) / projects.
  • Loading branch information
CamilleBeau committed Dec 13, 2022
1 parent d7b61b4 commit fa666f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ changes in the following format: PR #1234***
- Rename subproject to Cohort (PR #7817)
- Create new CohortData and CohortController classes to use as data access model
and transfer object (PR #7817)
-
- BVL Feedback widget only shows notifications for the users sites / projects (PR #7848)

#### Bug Fixes
- placeholder
Expand Down
23 changes: 19 additions & 4 deletions modules/bvl_feedback/php/module.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,31 @@ class Module extends \Module

$last_login = $user->getLastLogin($DB);

$bvl_feedback = $DB->pselect(
"SELECT fbt.Name, fbe.Testdate, fbe.Comment, fbth.FieldName,
// Base query
$query = "SELECT fbt.Name, fbe.Testdate, fbe.Comment, fbth.FieldName,
fbth.CommentID, fbth.SessionID, fbth.CandID, fbth.Feedback_level
FROM feedback_bvl_entry fbe
JOIN feedback_bvl_thread fbth USING (FeedbackID)
JOIN feedback_bvl_type fbt USING (Feedback_type)
WHERE fbth.Status='opened' AND fbth.Active='Y'
ORDER BY Testdate DESC LIMIT 4",
JOIN session s ON s.ID=fbth.SessionID
WHERE fbth.Status='opened' AND fbth.Active='Y'";

// Add centerID restriction if needed
if (!$user->hasPermission('access_all_profiles')) {
$site_arr = implode(",", $user->getCenterIDs());
$query .= " AND s.CenterID IN ({$site_arr}) ";
}

// Add project restriction & order BY
$project_arr = implode(",", $user->getProjectIDs());
$query .= " AND s.ProjectID IN ({$project_arr})
ORDER BY Testdate DESC LIMIT 4";

$bvl_feedback = $DB->pselect(
$query,
[]
);

$frontend_feedback = [];
foreach ($bvl_feedback as $row) {
if (new \DateTime($row['Testdate']) > $last_login) {
Expand Down

0 comments on commit fa666f5

Please # to comment.