Skip to main content
Topic: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation (Read 22702 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #15

I am releasing a beta #2 package and welcome any comment and feedback.

The new package is attached in the OP.
Last Edit: February 12, 2017, 05:41:17 pm by ahrasis

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #16

Cool! :D
Bugs creator.
Features destroyer.
Template killer.

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #17

Another contribution :hatsoff:

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #18

There are some fixes after the latest release involving Profile.controller.php (missing $db = database(); ) and Stats.subs.php (missing p).

In the earlier, find:
Code: [Select]
		// SubForums
global $modSettings;
if(isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]))
{
$result = $db->query('', '
SELECT COUNT(id_msg)
FROM {db_prefix}messages
WHERE id_member = {int:id_mem}{subforums_see_board:id_board}',
array('id_mem' => $memID)
);
list($tmp) = $db->fetch_row($result);
$db->free_result($result);
$context['num_posts'] = comma_format($tmp);
}
Change it to:
Code: [Select]
		// SubForums
global $modSettings;
if(isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]))
{
$db = database();
$result = $db->query('', '
SELECT COUNT(id_msg)
FROM {db_prefix}messages
WHERE id_member = {int:id_mem}{subforums_see_board:id_board}',
array('id_mem' => $memID)
);
list($tmp) = $db->fetch_row($result);
$db->free_result($result);
$context['num_posts'] = comma_format($tmp);
}

In the later, find:
Code: [Select]
	// Number polls voted in.
// SubForums
$result = $db->query('distinct_poll_votes', '
SELECT COUNT(DISTINCT id_poll)
FROM {db_prefix}log_polls AS p
LEFT JOIN {db_prefix}topics as t ON (p.id_poll = t.id_poll)
WHERE id_member = {int:current_member}{subforums_see_board:t-id_board}',
And change it to:

Code: [Select]
	// Number polls voted in.
// SubForums
$result = $db->query('distinct_poll_votes', '
SELECT COUNT(DISTINCT p.id_poll)
FROM {db_prefix}log_polls AS p
LEFT JOIN {db_prefix}topics as t ON (p.id_poll = t.id_poll)
WHERE id_member = {int:current_member}{subforums_see_board:t-id_board}',
Last Edit: February 12, 2017, 05:41:31 pm by ahrasis

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #19

One more thing which is missing in the later (missing c),
Code: [Select]
 // SubForums
 global $modSettings;
 $result = $db->query('', '
 SELECT COUNT(*)
 FROM {db_prefix}categories'. (isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]) ? '
 WHERE FIND_IN_SET(c.id_cat, {string:cats}) != 0' : ''),
 array(
 'cats' => isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]) ? $modSettings['subforums'][$_SERVER['SERVER_NAME']]['cats'] : ''
 )
 );
 list ($num_categories) = $db->fetch_row($result);
 $db->free_result($result);

Change to:
Code: [Select]
 // SubForums
 global $modSettings;
 $result = $db->query('', '
 SELECT COUNT(*)
 FROM {db_prefix}categories as c'. (isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]) ? '
 WHERE FIND_IN_SET(c.id_cat, {string:cats}) != 0' : ''),
 array(
 'cats' => isset($modSettings['subforums'][$_SERVER['SERVER_NAME']]) ? $modSettings['subforums'][$_SERVER['SERVER_NAME']]['cats'] : ''
 )
 );
 list ($num_categories) = $db->fetch_row($result);
 $db->free_result($result);
Last Edit: February 12, 2017, 05:41:42 pm by ahrasis

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #20

Are these changes included in the latest downloadable version ?   Are there any known bugs left to fix ?  Thanks; this mod is extremely useful for me !

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #21

Beta2 is the latest package. I haven't got time to see through it though it should be working just fine. Do update any bugs that you found in this topic so that I can see to it when I got some spare time.
Last Edit: February 12, 2017, 05:42:08 pm by ahrasis

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #22

Firstly, this mod is not 100% hook as mentioned in the addon site, as there are several manual modifications done. Secondly, there are still some bugs that need fixing though no one complains about them in here.

Since I have some times to go through this, I will try to release beta 3 version soon. I wish I can made this mod fully hook when a more stable version is released later.

The last thing to do, if possible, will be working with simple portal so that each sub forums may have its own portal pages and blocks. This is something I need to learn more later.
Last Edit: February 12, 2017, 05:41:58 pm by ahrasis

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #23

Modifications in replies #18 and #19 will be added in Beta 3 since I realized that I didn't package them together in Beta 2.

In addition to that I will add some fix to font awesome that is not shown properly due to cross domains limitation. The fix is as follows, I hope, which should covers both ssl and non ssl combination, if any.

Firstly, do find in default index.template.php:
Code: [Select]
<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0" />';

Then, replace it with:
Code: [Select]
<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0" />
 <link rel="stylesheet" type="text/css" href="http://' .  $_SERVER['SERVER_NAME'] . '/themes/default/css/font-awesome.min.css" id="font-awesome.css" />';

</head>

I wish I can understand where ElkArte controls all its url so that one change can really change and fix all subforums url. Right now we still see default url as well as subforums url, which is not good for many things especially ssl.

Edited: Earlier suggested place would negate any changes made by mods using $context['html_headers'] so the changes are made accordingly. This change need to be made only on the related theme. This will be fixed when issue with combined css is solved.
Last Edit: February 12, 2017, 05:42:28 pm by ahrasis

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #24

I will make a final test before releasing the Beta 3 package that covers combination of SSL and non SSL domain. This can be seen e.g. in https://www.sch.my and subforums under it http://elkarte.sch.my.

Rewriting this mod will be my main quest on once this mod is considered stable for ElkArte.

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #25

Beta 3 is now available and attached in the first post. Can't find any bugs so far but if you find one, do share.

I will concentrate in making it a fully hook addon, if possible, later on.

And thank you for testing this addon.

 

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #26

If I got it right, the subforums are defined based on the categories?
A possible improvement (not sure if needed or not, just throwing around an idea that crossed my mind) would be to add a column to "boards" with the "sub-forum" id and filter the boards with that.
Bugs creator.
Features destroyer.
Template killer.

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #27

A good idea. This way, same category(ies) will hide board(s) that is meant for specific url (domain or subdomain) only. I will try to see its implementation side.
Last Edit: February 12, 2017, 05:42:59 pm by ahrasis

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #28

There is a minor change affecting this mod in Who.subs.php but those who are updating using patch file via package manager is not affected.

But those who overwrite or are using a clean installed Elkarte v 1.0.9 yet wish to use this addon, pending a new package for this addon, in subforuminst.xml (install folder) find:
Code: [Select]
foreach ($url_list as $k => $url)
{
// Get the request parameters..
$actions = @unserialize($url[0]);
if ($actions === false)
continue;

Replace it with:
Code: [Select]
foreach ($url_list as $k => $url)
{
// Get the request parameters..
$actions = Util::unserialize($url[0]);
if ($actions === false)
continue;

This is only to make sure the necessary changes are in place but I haven't tested it for bugs. So, if you are using it, do it at your own risk. Do report if there is any bugs.
Last Edit: February 12, 2017, 05:43:08 pm by ahrasis

Re: Multi Tenancy - Multi Forums Via Various Domains In A Single Installation

Reply #29

Hey,

Thanks for great addon.
I'm using Split Forum Mod by dougiefresh, but I'm going to migate on ElkArte.
I just installed your addon, but it's not working for me. I setted the subforum on example.forum.net/subforum, but I have 404 error there.