Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unauthorised links and article authorisation fix #2545

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function authorised($authorised = true)
$user = \JFactory::getUser();
$groups = $user->getAuthorisedViewLevels();

return $this->where('a.access', 'IN', $groups);
return $this;
}

public function extension($extension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,24 @@ public function authorised($authorised = true)
$nullDate = $this->db->quote($this->db->getNullDate());
$nowDate = $this->db->quote(\JFactory::getDate()->toSql());

$groups = $user->getAuthorisedViewLevels();
$comma_separated_groups = implode(",", $groups);

// Filter by start and end dates.
if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) {
$this->query
->where("(a.publish_up = {$nullDate} OR a.publish_up <= {$nowDate})")
->where("(a.publish_down = {$nullDate} OR a.publish_down >= {$nowDate})")
->where("a.state >= 1")
->where("(a.access IN ({$comma_separated_groups}) OR
( CASE WHEN JSON_UNQUOTE(JSON_EXTRACT(attribs, '$.show_noauth' )) IS NULL OR JSON_UNQUOTE(JSON_EXTRACT(attribs, '$.show_noauth' )) ='' THEN
JSON_UNQUOTE((select JSON_EXTRACT(params, '$.show_noauth') FROM #__extensions where element='com_content'))
ELSE JSON_UNQUOTE(JSON_EXTRACT(attribs, '$.show_noauth')) END) =1)")
;
}

$groups = $user->getAuthorisedViewLevels();

$this->query->join('INNER', '#__categories AS c ON c.id = a.catid');

return $this->where('a.access', 'IN', $groups)->where('c.access', 'IN', $groups);
$this->query->join('INNER', '#__categories AS c ON c.id = a.catid');
return $this;
}

protected function addToGroup($key, $ids, $include = true)
Expand Down