Commit 45960521 by Scott

Fix URLs for user pages and login/logout links

We cannot get the id/username from the display name, so we have to
display usernames instead.
parent 87f9efc8
...@@ -220,7 +220,7 @@ if (qa_db_connection(false) !== null && !@$pass_failure_from_install) { ...@@ -220,7 +220,7 @@ if (qa_db_connection(false) !== null && !@$pass_failure_from_install) {
} }
elseif (defined('QA_FINAL_JOOMLA_INTEGRATE_PATH')) { elseif (defined('QA_FINAL_JOOMLA_INTEGRATE_PATH')) {
$jconfig = new JConfig(); $jconfig = new JConfig();
$errorhtml .= "\n\nWhen you click below, your Question2Answer site will be set up to integrate with the users of your Joomla! site <a href=\"../\" target=\"_blank\">".$jconfig->sitename."</a>. To complete the process, you will need to create a ensure that the QAIntegration plugin in Joomla is configured and enabled, and you will need to create a menu entry or a link in your Joomla site pointing to the URL for your Q2A installation. Please consult the online documentation for more information."; $errorhtml .= "\n\nWhen you click below, your Question2Answer site will be set up to integrate with the users of your Joomla! site <a href=\"../\" target=\"_blank\">".$jconfig->sitename."</a>. It's also recommended to install the Joomla QAIntegration plugin for additional user-access control. Please consult the online documentation for more information.";
} }
else { else {
$errorhtml .= "\n\nWhen you click below, your Question2Answer site will be set up to integrate with your existing user database and management. Users will be referenced with database column type ".qa_html(qa_get_mysql_user_column_type()).". Please consult the online documentation for more information."; $errorhtml .= "\n\nWhen you click below, your Question2Answer site will be set up to integrate with your existing user database and management. Users will be referenced with database column type ".qa_html(qa_get_mysql_user_column_type()).". Please consult the online documentation for more information.";
......
...@@ -36,8 +36,9 @@ function qa_get_login_links($relative_url_prefix, $redirect_back_to_url) ...@@ -36,8 +36,9 @@ function qa_get_login_links($relative_url_prefix, $redirect_back_to_url)
{ {
$jhelper = new qa_joomla_helper(); $jhelper = new qa_joomla_helper();
$config_urls = $jhelper->trigger_get_urls_event(); $config_urls = $jhelper->trigger_get_urls_event();
return array( return array(
'login' => $config_urls['login'].'&return='.urlencode(base64_encode($redirect_back_to_url)), 'login' => $config_urls['login'],
'register' => $config_urls['reg'], 'register' => $config_urls['reg'],
'logout' => $config_urls['logout'] 'logout' => $config_urls['logout']
); );
...@@ -67,7 +68,7 @@ function qa_get_logged_in_user() ...@@ -67,7 +68,7 @@ function qa_get_logged_in_user()
return array( return array(
'userid' => $user->id, 'userid' => $user->id,
'publicusername' => $user->name.($teamGroup ? " ({$teamGroup})" : ''), 'publicusername' => $user->username,
'email' => $user->email, 'email' => $user->email,
'level' => $level, 'level' => $level,
); );
...@@ -108,7 +109,7 @@ function qa_get_public_from_userids($userids) ...@@ -108,7 +109,7 @@ function qa_get_public_from_userids($userids)
foreach($userids as $userID) { foreach($userids as $userID) {
$user = $jhelper->get_user($userID); $user = $jhelper->get_user($userID);
$teamGroup = $jhelper->trigger_team_group_event($user); $teamGroup = $jhelper->trigger_team_group_event($user);
$output[$userID] = $user->name.($teamGroup ? " ({$teamGroup})" : ''); $output[$userID] = $user->username;
} }
} }
return $output; return $output;
......
...@@ -112,9 +112,8 @@ class qa_joomla_helper { ...@@ -112,9 +112,8 @@ class qa_joomla_helper {
/** /**
* Implements the same methods as a Joomla plugin would implement, but called locally within Q2A. * Implements the same methods as a Joomla plugin would implement, but called locally within Q2A.
* This is intended as a set of default actions in case no Joomla plugin has been installed. * This is intended as a set of default actions in case no Joomla plugin has been installed. It's
* (Installing a Joomla plugin is recommended however, as there is a lot more flexibility that way) * recommended to install the Joomla QAIntegration plugin for additional user-access control.
* Note that the implementation of these methods is not the same as it would be in a Joomla plugin, so please don't use it to crib from to create one! Use the actual Joomla Q2A Integration plugin instead.
*/ */
class qa_joomla_default_integration class qa_joomla_default_integration
{ {
...@@ -123,11 +122,16 @@ class qa_joomla_default_integration ...@@ -123,11 +122,16 @@ class qa_joomla_default_integration
*/ */
public static function onGetURLs() public static function onGetURLs()
{ {
$login = 'index.php?option=com_users&view=login';
$logout = 'index.php?option=com_users&task=user.logout&'.JSession::getFormToken().'=1&return='.urlencode(base64_encode('index.php'));
$reg = 'index.php?option=com_users&view=registration';
return array( return array(
'login' => JRoute::_('index.php?option=com_users&view=login'), // undo Joomla's escaping of characters since Q2A also escapes
'logout' => JRoute::_('index.php?option=com_users&view=login&layout=logout'), 'login' => htmlspecialchars_decode(JRoute::_($login)),
'reg' => JRoute::_('index.php?option=com_users&view=registration'), 'logout' => htmlspecialchars_decode(JRoute::_($logout)),
'denied' => '/', 'reg' => htmlspecialchars_decode(JRoute::_($reg)),
'denied' => htmlspecialchars_decode(JRoute::_('index.php')),
); );
} }
......
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