Commit b4aa1e4c by Scott

Fix redirects for guest users, login error, already-defined constant

parent c59dc181
...@@ -51,16 +51,11 @@ function qa_get_logged_in_user() ...@@ -51,16 +51,11 @@ function qa_get_logged_in_user()
if($user) { if($user) {
if($user->guest || $user->block) { if($user->guest || $user->block) {
header('location:'.$config_urls['denied']); return null;
die;
} }
$access = $jhelper->trigger_access_event($user); $access = $jhelper->trigger_access_event($user);
if(!$access['view']) { //must be in a group that has the view level set at least.
header('location:'.$config_urls['denied']);
die;
}
$level = QA_USER_LEVEL_BASIC; $level = QA_USER_LEVEL_BASIC;
if($access['post']) {$level = QA_USER_LEVEL_APPROVED;} if($access['post']) {$level = QA_USER_LEVEL_APPROVED;}
if($access['edit']) {$level = QA_USER_LEVEL_EDITOR;} if($access['edit']) {$level = QA_USER_LEVEL_EDITOR;}
......
...@@ -48,7 +48,11 @@ class qa_joomla_helper { ...@@ -48,7 +48,11 @@ class qa_joomla_helper {
private function load_joomla_app() private function load_joomla_app()
{ {
define( '_JEXEC', 1 ); //This will define the _JEXEC constant that will allow us to access the rest of the Joomla framework // This will define the _JEXEC constant that will allow us to access the rest of the Joomla framework
if (!defined('_JEXEC')) {
define('_JEXEC', 1);
}
require_once(JPATH_BASE.'/includes/defines.php' ); require_once(JPATH_BASE.'/includes/defines.php' );
require_once(JPATH_BASE.'/includes/framework.php' ); require_once(JPATH_BASE.'/includes/framework.php' );
// Instantiate the application. // Instantiate the application.
...@@ -69,7 +73,7 @@ class qa_joomla_helper { ...@@ -69,7 +73,7 @@ class qa_joomla_helper {
public function get_userid($username) public function get_userid($username)
{ {
JUserHelper::getUserId($username); return JUserHelper::getUserId($username);
} }
function trigger_access_event($user) function trigger_access_event($user)
...@@ -142,7 +146,7 @@ class qa_joomla_default_integration ...@@ -142,7 +146,7 @@ class qa_joomla_default_integration
list($user) = $args; list($user) = $args;
return array( return array(
'view' => !($user->guest || $user->block), 'view' => true,
'post' => !($user->guest || $user->block), 'post' => !($user->guest || $user->block),
'edit' => $user->authorise('core.edit'), 'edit' => $user->authorise('core.edit'),
'mod' => $user->authorise('core.edit.state'), 'mod' => $user->authorise('core.edit.state'),
......
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