Commit 2e901247 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

updated view access so it works with groups that have been marked as deleted

parent 0e9fa764
......@@ -229,12 +229,13 @@ function activity_get_viewaccess_users($view, $owner, $type) {
WHERE u.view = ?
UNION SELECT m.member
FROM {group_member} m
JOIN {view_access_group} g ON g.group = m.group
WHERE g.view = ? AND (g.tutoronly = ? OR m.tutor = ?)
JOIN {view_access_group} vg ON vg.group = m.group
JOIN {group} g ON (g.id = vg.group AND g.deleted = 0)
WHERE vg.view = ? AND (vg.tutoronly = ? OR m.tutor = ?)
UNION SELECT g.owner
FROM {group} g
JOIN {view_access_group} ag ON ag.group = g.id
WHERE ag.view = ?
WHERE ag.view = ? AND g.deleted = 0
) AS userlist
JOIN {usr} u ON u.id = userlist.userid
LEFT JOIN {usr_activity_preference} p ON p.usr = u.id
......
......@@ -1282,7 +1282,7 @@ function can_view_view($view_id, $user_id=null) {
a.view
FROM
{view_access_group} a
INNER JOIN {group} g ON a.group = g.id
INNER JOIN {group} g ON (a.group = g.id AND g.deleted = ?)
INNER JOIN {group_member} m ON g.id=m.group
WHERE
a.view = ?
......@@ -1290,7 +1290,7 @@ function can_view_view($view_id, $user_id=null) {
AND ( a.stopdate > ? OR a.stopdate IS NULL )
AND ( ( m.member = ? AND (a.tutoronly = 0 OR m.tutor = 1 ) ) OR g.owner = ?)
LIMIT 1',
array( $view_id, $dbnow, $dbnow, $user_id, $user_id )
array(0, $view_id, $dbnow, $dbnow, $user_id, $user_id )
)
) {
//log_debug('Yes - View is available to a specific group');
......@@ -1431,12 +1431,13 @@ function get_views($users, $userlooking=null, $limit=5) {
{view} v
INNER JOIN {view_access_group} a ON v.id=a.view
INNER JOIN {group_member} m ON m.group=a.group AND m.member=?
INNER JOIN {group} g ON (g.id = a.group AND g.deleted = ?)
WHERE
v.owner IN (' . join(',',array_map('db_quote', array_keys($users))) . ')
AND ( v.startdate IS NULL OR v.startdate < ? )
AND ( v.stopdate IS NULL OR v.stopdate > ? )
',
array($userlooking, $dbnow, $dbnow)
array($userlooking, 1, $dbnow, $dbnow)
)
) {
foreach ($results as &$row) {
......
......@@ -263,7 +263,8 @@ class View {
WHERE view = ?
UNION
SELECT 'group', \"group\", tutoronly, startdate, stopdate FROM {view_access_group}
WHERE view = ?", array($this->id, $this->id));
INNER JOIN {group} g ON (\"group\" = g.id AND g.deleted = ?)
WHERE view = ?", array($this->id, 0, $this->id));
if ($extradata) {
foreach ($extradata as &$extraitem) {
$extraitem = (array)$extraitem;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment