Commit d0e06f68 by Simon Champion

Out-of-the-box Joomla! integration.

parent b7cb859d
...@@ -22,6 +22,7 @@ Q2A is highly customisable with many awesome features: ...@@ -22,6 +22,7 @@ Q2A is highly customisable with many awesome features:
- Private messages and public wall posts. - Private messages and public wall posts.
- Log in via Facebook or others (using plugins). - Log in via Facebook or others (using plugins).
- Out-of-the-box WordPress 3+ integration. - Out-of-the-box WordPress 3+ integration.
- Out-of-the-box Joomla! 3.0+ integration (in conjunction with a Joomla! extension).
- Custom single sign-on support for other sites. - Custom single sign-on support for other sites.
- PHP/MySQL scalable to millions of users and posts. - PHP/MySQL scalable to millions of users and posts.
- Safe from XSS, CSRF and SQL injection attacks. - Safe from XSS, CSRF and SQL injection attacks.
......
...@@ -128,6 +128,17 @@ ...@@ -128,6 +128,17 @@
*/ */
/* /*
Out-of-the-box Joomla! 3.x integration - to integrate with your Joomla! site, define
QA_JOOMLA_INTEGRATE_PATH. as the full path to the Joomla! directory. If your Q2A
site is a subdirectory of your main Joomla site (recommended), you can specify
dirname(__DIR__) rather than the full path.
With this set, you do not need to set the QA_MYSQL_* constants above since these
will be taken from Joomla automatically. See online documentation for more details.
define('QA_JOOMLA_INTEGRATE_PATH', dirname(__DIR__));
*/
/*
Some settings to help optimize your Question2Answer site's performance. Some settings to help optimize your Question2Answer site's performance.
If QA_HTML_COMPRESSION is true, HTML web pages will be output using Gzip compression, if If QA_HTML_COMPRESSION is true, HTML web pages will be output using Gzip compression, if
......
...@@ -56,11 +56,16 @@ ...@@ -56,11 +56,16 @@
// If we're using single sign-on integration (WordPress or otherwise), load PHP file for that // If we're using single sign-on integration (WordPress or otherwise), load PHP file for that
if (defined('QA_FINAL_WORDPRESS_INTEGRATE_PATH')) if (defined('QA_FINAL_WORDPRESS_INTEGRATE_PATH')) {
require_once QA_INCLUDE_DIR.'util/external-users-wp.php'; require_once QA_INCLUDE_DIR.'util/external-users-wp.php';
else }
elseif (defined('QA_FINAL_JOOMLA_INTEGRATE_PATH')) {
//grab the integration file that is included as part of the Joomla plugin (we already confirmed that it exists).
require_once QA_JOOMLA_PLUGIN_SSO_FILE;
}
else {
require_once QA_EXTERNAL_DIR.'qa-external-users.php'; require_once QA_EXTERNAL_DIR.'qa-external-users.php';
}
// Access functions for user information // Access functions for user information
......
...@@ -49,8 +49,14 @@ ...@@ -49,8 +49,14 @@
qa_initialize_php(); qa_initialize_php();
qa_initialize_constants_1(); qa_initialize_constants_1();
if (defined('QA_WORDPRESS_LOAD_FILE')) // if relevant, load WordPress integration in global scope if (defined('QA_WORDPRESS_LOAD_FILE')) {
// if relevant, load WordPress integration in global scope
require_once QA_WORDPRESS_LOAD_FILE; require_once QA_WORDPRESS_LOAD_FILE;
}
elseif (defined('QA_JOOMLA_LOAD_FILE')) {
// if relevant, load Joomla JConfig class into global scope
require_once QA_JOOMLA_LOAD_FILE;
}
qa_initialize_constants_2(); qa_initialize_constants_2();
qa_initialize_modularity(); qa_initialize_modularity();
...@@ -147,7 +153,7 @@ ...@@ -147,7 +153,7 @@
function qa_initialize_constants_1() function qa_initialize_constants_1()
/* /*
First stage of setting up Q2A constants, before (if necessary) loading WordPress integration First stage of setting up Q2A constants, before (if necessary) loading WordPress or Joomla! integration
*/ */
{ {
global $qa_request_map; global $qa_request_map;
...@@ -177,6 +183,16 @@ ...@@ -177,6 +183,16 @@
if (!is_readable(QA_WORDPRESS_LOAD_FILE)) if (!is_readable(QA_WORDPRESS_LOAD_FILE))
qa_fatal_error('Could not find wp-load.php file for WordPress integration - please check QA_WORDPRESS_INTEGRATE_PATH in qa-config.php'); qa_fatal_error('Could not find wp-load.php file for WordPress integration - please check QA_WORDPRESS_INTEGRATE_PATH in qa-config.php');
} }
elseif (defined('QA_JOOMLA_INTEGRATE_PATH') && strlen(QA_JOOMLA_INTEGRATE_PATH)) {
define('QA_FINAL_JOOMLA_INTEGRATE_PATH', QA_JOOMLA_INTEGRATE_PATH.((substr(QA_JOOMLA_INTEGRATE_PATH, -1)=='/') ? '' : '/'));
define('QA_JOOMLA_LOAD_FILE', QA_FINAL_JOOMLA_INTEGRATE_PATH.'configuration.php');
define('QA_JOOMLA_PLUGIN_SSO_FILE', QA_FINAL_JOOMLA_INTEGRATE_PATH.'plugins/q2a/qaintegration/qa-external/qa-external-users.php');
if (!is_readable(QA_JOOMLA_LOAD_FILE))
qa_fatal_error('Could not find configuration.php file for Joomla integration - please check QA_JOOMLA_INTEGRATE_PATH in qa-config.php');
if (!is_readable(QA_JOOMLA_PLUGIN_SSO_FILE))
qa_fatal_error('Could not find Joomla Q2AIntegration plugin - please check that you have installed the plugin into your Joomla system.');
}
// Polyfills // Polyfills
...@@ -221,7 +237,7 @@ ...@@ -221,7 +237,7 @@
function qa_initialize_constants_2() function qa_initialize_constants_2()
/* /*
Second stage of setting up Q2A constants, after (if necessary) loading WordPress integration Second stage of setting up Q2A constants, after (if necessary) loading WordPress or Joomla! integration
*/ */
{ {
...@@ -274,6 +290,14 @@ ...@@ -274,6 +290,14 @@
$_POST=qa_undo_wordpress_quoting($_POST, false); $_POST=qa_undo_wordpress_quoting($_POST, false);
$_SERVER['PHP_SELF']=stripslashes($_SERVER['PHP_SELF']); $_SERVER['PHP_SELF']=stripslashes($_SERVER['PHP_SELF']);
} elseif (defined('QA_FINAL_JOOMLA_INTEGRATE_PATH')) {
// More for Joomla integration
$jconfig = new JConfig();
define('QA_FINAL_MYSQL_HOSTNAME', $jconfig->host);
define('QA_FINAL_MYSQL_USERNAME', $jconfig->user);
define('QA_FINAL_MYSQL_PASSWORD', $jconfig->password);
define('QA_FINAL_MYSQL_DATABASE', $jconfig->db);
define('QA_FINAL_EXTERNAL_USERS', true);
} else { } else {
define('QA_FINAL_MYSQL_HOSTNAME', QA_MYSQL_HOSTNAME); define('QA_FINAL_MYSQL_HOSTNAME', QA_MYSQL_HOSTNAME);
define('QA_FINAL_MYSQL_USERNAME', QA_MYSQL_USERNAME); define('QA_FINAL_MYSQL_USERNAME', QA_MYSQL_USERNAME);
......
...@@ -150,6 +150,15 @@ else { ...@@ -150,6 +150,15 @@ else {
$success .= 'Your Question2Answer database has been created and integrated with your WordPress site.'; $success .= 'Your Question2Answer database has been created and integrated with your WordPress site.';
} }
elseif (defined('QA_FINAL_JOOMLA_INTEGRATE_PATH')) {
require_once QA_INCLUDE_DIR.'db/admin.php';
require_once QA_INCLUDE_DIR.'app/format.php';
$jconfig = new JConfig();
// create link back to Joomla! home page (Joomla doesn't have a 'home' config setting we can use like WP does, so we'll just assume that the Joomla home is the parent of the Q2A site. If it isn't, the user can fix the link for themselves later)
qa_db_page_move(qa_db_page_create($jconfig->sitename, QA_PAGE_FLAGS_EXTERNAL, '../', null, null, null), 'O', 1);
$success .= 'Your Question2Answer database has been created and integrated with your Joomla! site.';
}
else { else {
$success .= 'Your Question2Answer database has been created for external user identity management. Please read the online documentation to complete integration.'; $success .= 'Your Question2Answer database has been created for external user identity management. Please read the online documentation to complete integration.';
} }
...@@ -209,6 +218,10 @@ if (qa_db_connection(false) !== null && !@$pass_failure_from_install) { ...@@ -209,6 +218,10 @@ if (qa_db_connection(false) !== null && !@$pass_failure_from_install) {
if (defined('QA_FINAL_WORDPRESS_INTEGRATE_PATH')) { if (defined('QA_FINAL_WORDPRESS_INTEGRATE_PATH')) {
$errorhtml .= "\n\nWhen you click below, your Question2Answer site will be set up to integrate with the users of your WordPress site <a href=\"".qa_html(get_option('home'))."\" target=\"_blank\">".qa_html(get_option('blogname'))."</a>. 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 WordPress site <a href=\"".qa_html(get_option('home'))."\" target=\"_blank\">".qa_html(get_option('blogname'))."</a>. Please consult the online documentation for more information.";
} }
elseif (defined('QA_FINAL_JOOMLA_INTEGRATE_PATH')) {
$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.";
}
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.";
} }
......
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