mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #41055
[Bug 1667799] A change has been merged
Reviewed: https://reviews.mahara.org/7492
Committed: https://git.mahara.org/mahara/mahara/commit/0edbc6fd2b89ff355d0f9ee01fafdadcd4348d37
Submitter: Robert Lyon (robertl@xxxxxxxxxxxxxxx)
Branch: master
commit 0edbc6fd2b89ff355d0f9ee01fafdadcd4348d37
Author: Cecilia Vela Gurovic <ceciliavg@xxxxxxxxxxxxxxx>
Date: Mon Feb 27 17:31:31 2017 +1300
Bug 1667799: Added function to find group information by id
Replaced most calls to DB to request group
basic information, for get_group_by_id() method
in group library
behatnotneeded
Change-Id: Ie03520a6c7a364ead63ccedaff07118a5928348e
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1667799
Title:
Need a get_group_by_id() function
Status in Mahara:
Fix Committed
Bug description:
Unlike view/collection etc 'group' functions are not in a class.
And so there is no easy function to find group information by id.
Instead we do a db query each time we want to find some group
information and by the looks of the code we are not consistent each
time, eg:
$group = get_record('group', 'id', $id, 'deleted', 0);
vs.
$group = get_record('group', 'id', $id);
At current count there is over 40 places where we fetch group by id
via direct db call.
It would be useful to have all those places fetch the info via
function. That way we can have consistency across the system and also
allow for the replying with additional information such as roles and
whether one can edit or not, eg:
get_group_by_id($id, $includedeleted = true, $getroles = false, $canedit = false) {
if ($includedeletd) {
$group = get_record('group', 'id', $groupid, 'deleted', 0);
}
else {
$group = get_record('group', 'id', $groupid);
}
if (empty($group)) {
return false;
}
if ($getroles) {
$group->roles = group_user_access($group->id);
}
if ($canedit) {
$group->canedit = $role && group_role_can_edit_views($group, $group->roles);
}
return $group;
}
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1667799/+subscriptions
References