From fed4ab5614b0bc82458eaa58b638adf5245a14fa Mon Sep 17 00:00:00 2001 From: Charlotte Sacre Date: Wed, 19 Jul 2023 11:01:12 -0400 Subject: [PATCH 1/5] issue_tracker - remove inactive users from drop down --- modules/issue_tracker/php/edit.class.inc | 7 ++++--- modules/issue_tracker/php/issue_tracker.class.inc | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/issue_tracker/php/edit.class.inc b/modules/issue_tracker/php/edit.class.inc index 448dac4997b..e09275d361f 100644 --- a/modules/issue_tracker/php/edit.class.inc +++ b/modules/issue_tracker/php/edit.class.inc @@ -66,7 +66,7 @@ class Edit extends \NDB_Page implements ETagCalculator $inactive_users = []; if ($user->hasPermission('access_all_profiles')) { $assignee_expanded = $db->pselect( - "SELECT Real_name, UserID FROM users", + "SELECT Real_name, UserID FROM users WHERE Active='Y'", [] ); @@ -84,7 +84,8 @@ class Edit extends \NDB_Page implements ETagCalculator $assignee_expanded = $db->pselect( "SELECT DISTINCT u.Real_name, u.UserID FROM users u LEFT JOIN user_psc_rel upr ON (upr.UserID=u.ID) - WHERE FIND_IN_SET(upr.CenterID,:CenterID) OR (upr.CenterID=:DCC)", + WHERE FIND_IN_SET(upr.CenterID,:CenterID) OR (upr.CenterID=:DCC) + AND Active='Y'", [ 'CenterID' => $CenterID, 'DCC' => $DCCID, @@ -113,7 +114,7 @@ class Edit extends \NDB_Page implements ETagCalculator $otherWatchers = []; $potential_watchers_expanded = $db->pselect( - "SELECT Real_name, UserID FROM users", + "SELECT Real_name, UserID FROM users WHERE Active='Y'", [] ); foreach ($potential_watchers_expanded as $w_row) { diff --git a/modules/issue_tracker/php/issue_tracker.class.inc b/modules/issue_tracker/php/issue_tracker.class.inc index 20de6785fae..379052802b8 100644 --- a/modules/issue_tracker/php/issue_tracker.class.inc +++ b/modules/issue_tracker/php/issue_tracker.class.inc @@ -115,7 +115,7 @@ class Issue_Tracker extends \NDB_Menu_Filter_Form //reporters $reporters = []; $reporter_expanded = $db->pselect( - "SELECT u.UserID, + "SELECT DISTINCT u.UserID, u.Real_name FROM issues i INNER JOIN users u @@ -129,7 +129,7 @@ class Issue_Tracker extends \NDB_Menu_Filter_Form //assignees $assignees = []; $assignee_expanded = $db->pselect( - "SELECT u.UserID, + "SELECT DISTINCT u.UserID, u.Real_name FROM issues i INNER JOIN users u From 3f8a04682043a7afc9de85bc66c1b938a26af4c6 Mon Sep 17 00:00:00 2001 From: charlottesce <75381352+charlottesce@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:18:09 -0400 Subject: [PATCH 2/5] issue_tracker - add Pending_approval=N --- modules/issue_tracker/php/edit.class.inc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/issue_tracker/php/edit.class.inc b/modules/issue_tracker/php/edit.class.inc index e09275d361f..efd7ce0750f 100644 --- a/modules/issue_tracker/php/edit.class.inc +++ b/modules/issue_tracker/php/edit.class.inc @@ -66,7 +66,8 @@ class Edit extends \NDB_Page implements ETagCalculator $inactive_users = []; if ($user->hasPermission('access_all_profiles')) { $assignee_expanded = $db->pselect( - "SELECT Real_name, UserID FROM users WHERE Active='Y'", + "SELECT Real_name, UserID FROM users + WHERE Active='Y' AND Pending_approval='N'", [] ); @@ -85,7 +86,7 @@ class Edit extends \NDB_Page implements ETagCalculator "SELECT DISTINCT u.Real_name, u.UserID FROM users u LEFT JOIN user_psc_rel upr ON (upr.UserID=u.ID) WHERE FIND_IN_SET(upr.CenterID,:CenterID) OR (upr.CenterID=:DCC) - AND Active='Y'", + AND Active='Y' AND Pending_approval='N'", [ 'CenterID' => $CenterID, 'DCC' => $DCCID, @@ -114,7 +115,8 @@ class Edit extends \NDB_Page implements ETagCalculator $otherWatchers = []; $potential_watchers_expanded = $db->pselect( - "SELECT Real_name, UserID FROM users WHERE Active='Y'", + "SELECT Real_name, UserID FROM users + WHERE Active='Y' AND Pending_approval='N'", [] ); foreach ($potential_watchers_expanded as $w_row) { From 77dcce8f9d1fe635dcff59647111fb968dfdf9ac Mon Sep 17 00:00:00 2001 From: Charlotte Sacre Date: Thu, 10 Aug 2023 19:22:27 -0400 Subject: [PATCH 3/5] issue_tracker - add current assignees & watchers in dropdown --- modules/issue_tracker/php/edit.class.inc | 32 +++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/modules/issue_tracker/php/edit.class.inc b/modules/issue_tracker/php/edit.class.inc index efd7ce0750f..08239a1e31a 100644 --- a/modules/issue_tracker/php/edit.class.inc +++ b/modules/issue_tracker/php/edit.class.inc @@ -200,11 +200,28 @@ class Edit extends \NDB_Page implements ETagCalculator 'userID' => $user->getUsername(), ] ); + + // Add current assignee in assignees dropdown even if not active + if (!isset($assignees[$issueData['assignee']])) { + $assignees[$issueData['assignee']] = $db->pselectOne( + "SELECT Real_name FROM users + WHERE UserID=:userID", + [ + 'userID' => $issueData['assignee'] + ] + ); + } + + $othersWatching = $this->getWatching($issueID); + // add current watchers to others watching, even if not active + $otherWatchers = array_merge($otherWatchers, $othersWatching); + unset($otherWatchers[$user->getUserName()]); + $issueData['watching'] = $isWatching === null ? 'No' : 'Yes'; $issueData['commentHistory'] = $this->getComments($issueID); $issueData['attachments'] = $attachments; $issueData['whoami'] = $user->getUsername(); - $issueData['othersWatching'] = $this->getWatching($issueID); + $issueData['othersWatching'] = array_keys($othersWatching); // We need to unescape the string here: // React is escaping the string in the template @@ -343,20 +360,23 @@ class Edit extends \NDB_Page implements ETagCalculator * * @param int $issueID the relevant issue * - * @return array those who are watching + * @return array [Real_name => userID] of + * those who are watching */ function getWatching(int $issueID): array { $db = $this->loris->getDatabaseConnection(); $watching = $db->pselect( - "SELECT userID from issues_watching WHERE issueID=:issueID", + "SELECT Real_name, UserID from users + WHERE UserID IN + (SELECT UserID FROM issues_watching WHERE issueID=:issueID)", ['issueID' => $issueID] ); $whoIsWatching = []; foreach ($watching as $watcher) { - $whoIsWatching[] = $watcher['userID']; + $whoIsWatching[$watcher['UserID']] = $watcher['Real_name']; } return $whoIsWatching; } @@ -826,13 +846,13 @@ class Edit extends \NDB_Page implements ETagCalculator /** * Puts updated fields into the issues_comments table. * - * @param string $comment new issue comment + * @param ?string $comment new issue comment * @param int $issueID the issue ID * @param \User $user the user * * @return void */ - function updateComments(string $comment, int $issueID, \User $user) + function updateComments(?string $comment, int $issueID, \User $user) { $db = $this->loris->getDatabaseConnection(); if (isset($comment) && $comment != "null") { From 5e61a91dc80f2a36657d2484daefa20609314821 Mon Sep 17 00:00:00 2001 From: Charlotte Sacre Date: Thu, 10 Aug 2023 19:23:34 -0400 Subject: [PATCH 4/5] issue_tracker - add breadcrumbs edit class --- modules/issue_tracker/php/issue.class.inc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/issue_tracker/php/issue.class.inc b/modules/issue_tracker/php/issue.class.inc index 2b3c5fb5734..bddea1c9660 100644 --- a/modules/issue_tracker/php/issue.class.inc +++ b/modules/issue_tracker/php/issue.class.inc @@ -159,4 +159,21 @@ class Issue extends \NDB_Form // the ajax/EditIssue.php hack. return parent::handle($request); } + + /** + * Generate a breadcrumb trail for this page. + * + * @return \LORIS\BreadcrumbTrail + */ + public function getBreadcrumbs(): \LORIS\BreadcrumbTrail + { + $label = ucwords(str_replace('_', ' ', $this->name)); + return new \LORIS\BreadcrumbTrail( + new \LORIS\Breadcrumb($label, "/$this->name"), + new \LORIS\Breadcrumb( + 'Issue', + "/issue_tracker/issue/$this->issueID" + ) + ); + } } From 4fb88a4c451295018c2f8c98229ee5b7f73759a6 Mon Sep 17 00:00:00 2001 From: Charlotte Sacre Date: Thu, 10 Aug 2023 19:25:49 -0400 Subject: [PATCH 5/5] issue_tracker - phpcbf --- modules/issue_tracker/php/edit.class.inc | 18 +++++++++--------- modules/issue_tracker/php/issue.class.inc | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/issue_tracker/php/edit.class.inc b/modules/issue_tracker/php/edit.class.inc index 08239a1e31a..0dc32331396 100644 --- a/modules/issue_tracker/php/edit.class.inc +++ b/modules/issue_tracker/php/edit.class.inc @@ -192,7 +192,7 @@ class Edit extends \NDB_Page implements ETagCalculator ->withDataFrom($provisioner) ->toArray($user); - $isWatching = $db->pselectOne( + $isWatching = $db->pselectOne( "SELECT userID, issueID FROM issues_watching WHERE issueID=:issueID AND userID=:userID", [ @@ -201,23 +201,23 @@ class Edit extends \NDB_Page implements ETagCalculator ] ); - // Add current assignee in assignees dropdown even if not active + // Add current assignee in assignees dropdown even if not active if (!isset($assignees[$issueData['assignee']])) { $assignees[$issueData['assignee']] = $db->pselectOne( "SELECT Real_name FROM users - WHERE UserID=:userID", + WHERE UserID=:userID", [ - 'userID' => $issueData['assignee'] + 'userID' => $issueData['assignee'] ] ); } - + $othersWatching = $this->getWatching($issueID); // add current watchers to others watching, even if not active $otherWatchers = array_merge($otherWatchers, $othersWatching); unset($otherWatchers[$user->getUserName()]); - $issueData['watching'] = $isWatching === null ? 'No' : 'Yes'; + $issueData['watching'] = $isWatching === null ? 'No' : 'Yes'; $issueData['commentHistory'] = $this->getComments($issueID); $issueData['attachments'] = $attachments; $issueData['whoami'] = $user->getUsername(); @@ -360,7 +360,7 @@ class Edit extends \NDB_Page implements ETagCalculator * * @param int $issueID the relevant issue * - * @return array [Real_name => userID] of + * @return array [Real_name => userID] of * those who are watching */ function getWatching(int $issueID): array @@ -847,8 +847,8 @@ class Edit extends \NDB_Page implements ETagCalculator * Puts updated fields into the issues_comments table. * * @param ?string $comment new issue comment - * @param int $issueID the issue ID - * @param \User $user the user + * @param int $issueID the issue ID + * @param \User $user the user * * @return void */ diff --git a/modules/issue_tracker/php/issue.class.inc b/modules/issue_tracker/php/issue.class.inc index bddea1c9660..6f1239370fd 100644 --- a/modules/issue_tracker/php/issue.class.inc +++ b/modules/issue_tracker/php/issue.class.inc @@ -159,7 +159,7 @@ class Issue extends \NDB_Form // the ajax/EditIssue.php hack. return parent::handle($request); } - + /** * Generate a breadcrumb trail for this page. *