Skip to content

Commit

Permalink
Refactor reengagement_get_startusers function to use array_filter for…
Browse files Browse the repository at this point in the history
… filtering startcandidates
  • Loading branch information
rajandangi committed Jun 19, 2024
1 parent 1fd61d6 commit f5456b4
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,14 +778,11 @@ function reengagement_get_startusers($reengagement) {
$information = '';

$startusers = $DB->get_records_sql($sql, $params);
foreach ($startusers as $startcandidate) {
// Exclude users who can't see this activity.
if (!$ainfomod->is_available($information, false, $startcandidate->id, $modinfo)) {
unset($startusers[$startcandidate->id]);
}
}
$startcandidates = array_filter($startusers, function ($startcandidate) use ($ainfomod, $information, $modinfo) {
return $ainfomod->is_available($information, false, $startcandidate->id, $modinfo);
});

return $startusers;
return $startcandidates;
}


Expand All @@ -796,7 +793,7 @@ function reengagement_get_startusers($reengagement) {
* @return mixed True if module supports feature, null if doesn't know
*/
function reengagement_supports($feature) {
switch($feature) {
switch ($feature) {
case FEATURE_GROUPS:
return false;
case FEATURE_GROUPINGS:
Expand Down

0 comments on commit f5456b4

Please sign in to comment.