News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Split Forum Mod

Started by dougiefresh, May 27, 2014, 07:55:49 AM

Previous topic - Next topic

dougiefresh

Uploaded v1.16 - November 19th, 2014
o Fixed a few security issues within database queries in the mod.
o Fixed some query variable type-casting issues within the mod.
o Modified Edit Category UI so that SubForum selection box is on top of the form.
o Modified Recent Posts code so that it is limited to the subforum it is displaying for.
o Fixed compatibility with Pretty URLs mod...
o Fixed both the SSI bug report and undefined array element report in Load.php by SauloA...
o Fixed a small bug for Manage Board UI.

I've changed the minimum requirement for upgrading from v1.3 to v1.12, since that is the first version that will uninstall completely on ALL systems....  The Manage Board UI still doesn't work right for some reason, but there were plenty of other good reasons (to me, IMO) to release this version, as you can read in the release notice....

Colin

"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

SauloA

I have upgraded to v1.16 and everything is working fantastically.  You are the man dougiefresh.  Thank You!

dougiefresh

Uploaded v1.17 - November 21th, 2014
o Fixed template-breaking typo in Sources/ManageBoards.php
o Fixed Modify Boards UI to work correctly without Alias Boards mod installed...
o Fixed Modify Boards UI moving boards to bottom when making no position changes...
o Fixed undefined variable error within the Edit Categories UI...

This update makes me wish I had waited on the v1.16 release a few more days.....  The Modify Boards UI works correctly now.

DenDen60

Ok I have tried to install V1.17 over V1.14 I got an error message. Should I install V 1.15 and 1.16 first?

dougiefresh

Quote from: Denis Pageau on November 21, 2014, 04:28:06 PM
Ok I have tried to install V1.17 over V1.14 I got an error message. Should I install V 1.15 and 1.16 first?
Without more information, I'm going to assume the "error message" you got is related to your server's inability to deal with multiple upgrade files correctly.  So you have two options: (1) install v1.15, then v1.16, then v1.17 --- OR --- (2) uninstall v1.14 and install v1.17.

I seem to recall making this statement (which is pretty applicable to this situation, as well):
Quote from: dougiefresh on November 02, 2014, 03:26:43 PM
You definitely will be able to upgrade from v1.14 to v1.15.  But upgradability is included from version 1.3 (or 1.4) upwards...  If you can't upgrade, then you will have to uninstall your current version, then install the new version.

DenDen60

Sorry I should have added the errors.

10.     Execute Modification     ./Sources/Load.php     Test failed
1.     Replace     ./Sources/Load.php     Test failed
6.     Replace     ./Sources/Load.php     Test failed
29.     Execute Modification     ./Themes/default/ManageBoards.template.php     Test failed
1.     Replace     ./Themes/default/ManageBoards.template.php     Test failed

I unistalled v.1.14 and installed 1.17 and beside an error in one of the theme, everything went ok.

Thanks

dougiefresh

Uploaded v1.18 - November 24th, 2014
o Fixed install issue involving SimplePortal's block admin template...
o Moved Forum => Subforums menu beneath Boards in Admin menu.

SauloA

I'm getting the following error when I click on the "Boards" link in the admin area:

Template Parse Error!
There was a problem loading the /Themes/default/ManageBoards.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.
syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)


It won't allow me to make adjustments to my boards.

Other than that everything is working well with the mod.

Also, you can get the mod to pass the session information to a subdomain and that works fine, but how do I get the session to another the main domain.  For example, the mod allows me to make a subdomain URL for a separate forum (forum.secondmywebsite.com), but how do I tie that session in the subdomain to the main domain (mysecondwebsite.com)?

DenDen60

Hi DougieFresh,

I got this error, but I imagine that it is because I don't use simpleportal.

1.Execute Codeadd_remove_hook.php

2.Adapt Databasedb_install.php

3.Execute Modification./Themes/default/PortalAdminBlocks.template.phpFile not found

4.Extract File./Sources/Subs-ManageSplitForums.php

I installed it anyway and it installed correctly. At least at first glance.

Greygal

#290
As you seem to be keen to have few conflicts as possible with other mods, I thought I'd share the following with you.  All the "My code..." bits are how my code read before the changes I made to install_source.xml below.

When I attempted to install this mod, these are the issues I had:

Line 5.2 File ./Sources/Display.php conflicted with "Event Reminder Mod for SMF2   2.31" modifications:

Code ("Find") Select

FROM {db_prefix}calendar AS cal
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = cal.id_member)
WHERE cal.id_topic = {int:current_topic}
ORDER BY start_date',
array(
'current_topic' => $topic,

Code ("Replace") Select

FROM {db_prefix}calendar AS cal
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = cal.id_member)
WHERE cal.id_topic = {int:current_topic}
AND cal.forumid = {int:forumid}
ORDER BY start_date',
array(
'current_topic' => $topic,
'forumid' => (int) $forumid,


This line conflicted with a prior replace made by the Calendar Events Reminder mod.  Here is my Display.php code as it is:

Code ("My Display.php code") Select

FROM {db_prefix}calendar AS cal
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = cal.id_member)
LEFT JOIN {db_prefix}hcb_reminders as h ON ((cal.id_event = h.id_event) AND (h.id_member = \'' . $user_info['id'] . '\'))

WHERE cal.id_topic = {int:current_topic}
ORDER BY start_date',
array(
'current_topic' => $topic,


As the bottom four lines are unique in the ./Sources/Display.php file, and identical in both the searched-for version and the Calendar Event Reminders-modified version, I simply edited this part of the install script to only search for the below four lines.

Code ("Change the FIND to just these lines") Select

WHERE cal.id_topic = {int:current_topic}
ORDER BY start_date',
array(
'current_topic' => $topic,

Code ("Change the REPLACE to just these lines") Select

WHERE cal.id_topic = {int:current_topic}
AND cal.forumid = {int:forumid}
ORDER BY start_date',
array(
'current_topic' => $topic,
'forumid' => (int) $forumid,






Line 15.2 File ./Sources/Post.php conflicted with "Event Registration Mod for SMF2   v2.26" modifications:

Code ("Find") Select

// Get the current event information.
$request = $smcFunc['db_query']('', '
SELECT
id_member, title, MONTH(start_date) AS month, DAYOFMONTH(start_date) AS day,
YEAR(start_date) AS year, (TO_DAYS(end_date) - TO_DAYS(start_date)) AS span
FROM {db_prefix}calendar
WHERE id_event = {int:id_event}
LIMIT 1',
array(
'id_event' => $context['event']['id'],

Code ("Replace") Select

// Get the current event information.
$request = $smcFunc['db_query']('', '
SELECT
id_member, title, MONTH(start_date) AS month, DAYOFMONTH(start_date) AS day,
YEAR(start_date) AS year, (TO_DAYS(end_date) - TO_DAYS(start_date)) AS span
FROM {db_prefix}calendar
WHERE id_event = {int:id_event}
AND forumid = {int:forumid}
LIMIT 1',
array(
'id_event' => $context['event']['id'],
'forumid' => (int) $forumid,



Here is the relevant code section in my post.php file:

Code ("My ./Sources/Post.php code") Select

// Get the current event information.
$request = $smcFunc['db_query']('', '
SELECT
id_member, title, MONTH(start_date) AS month, DAYOFMONTH(start_date) AS day,
YEAR(start_date) AS year, (TO_DAYS(end_date) - TO_DAYS(start_date)) AS span, hcc_max_attendants, hcc_confirm, hcc_days_closed, hcc_terms_conds, hcc_groups, hcc_sub_ids, hcc_reg_sub_ids, hcc_add_comment, hcc_see_comment, hcc_max_register
FROM {db_prefix}calendar
WHERE id_event = {int:id_event}
LIMIT 1',
array(
'id_event' => $context['event']['id'],


Similar solution to fix the conflict here.  In this case, the last six lines of the original FIND are unique in the ./Sources/Post.php file:

Code ("Change the FIND to just these lines") Select

FROM {db_prefix}calendar
WHERE id_event = {int:id_event}
LIMIT 1',
array(
'id_event' => $context['event']['id'],

Code ("Change the REPLACE to just these lines") Select

FROM {db_prefix}calendar
WHERE id_event = {int:id_event}
AND forumid = {int:forumid}
LIMIT 1',
array(
'id_event' => $context['event']['id'],
'forumid' => (int) $forumid,





Line 15.6 File ./Sources/Post.php conflicted with "Event Registration Mod for SMF2   v2.26" modifications:

Code ("Find") Select

UPDATE {db_prefix}calendar
SET end_date = {date:end_date},
start_date = {date:start_date},
title = {string:title}
WHERE id_event = {int:id_event}',
array(

Code ("Replace") Select

UPDATE {db_prefix}calendar
SET end_date = {date:end_date},
start_date = {date:start_date},
title = {string:title}
WHERE id_event = {int:id_event}
AND forumid = {int:forumid}',
array(
'forumid' => (int) $forumid,



My ./Sources/post.php code for this bit is:
Code ("My Post.php Code") Select

UPDATE {db_prefix}calendar
SET end_date = {date:end_date},
start_date = {date:start_date},
title = {string:title},hcc_max_attendants = {int:hcc_max_attendants}, hcc_confirm={int:hcc_confirm}, hcc_days_closed={int:hcc_days_closed}, hcc_terms_conds={string:hcc_terms_conds},hcc_groups={string:hcc_groups},hcc_sub_ids={string:hcc_sub_ids},hcc_reg_sub_ids={string:hcc_reg_sub_ids}, hcc_add_comment={int:hcc_add_comment}, hcc_see_comment={int:hcc_see_comment}, hcc_max_register={int:hcc_max_register}

WHERE id_event = {int:id_event}',
array(


Took me a bit to figure out a good unique-in-the-file FIND for this one :)

Code ("Change the FIND to just these lines") Select

WHERE id_event = {int:id_event}',
array(
'end_date'

Code ("Change the REPLACE to just these lines") Select

WHERE id_event = {int:id_event}
AND forumid = {int:forumid}',
array(
'forumid' => (int) $forumid,
'end_date'





There are a few other places where the Event Registration mod is conflicting, which I'll itemize in next post shortly.  I'll also attach my modified install_source.xml file once I've finished.

Thanks for a terrific mod!

GG

Greygal

Line 28.5 File ./Sources/Subs-Calendar.php conflicted with "Event Registration Mod for SMF2   v2.26" modifications:


Code ("Find") Select

'start_date' => 'date', 'end_date' => 'date',
),
array(
$eventOptions['board'], $eventOptions['topic'], $eventOptions['title'], $eventOptions['member'],
$eventOptions['start_date'], $eventOptions['end_date'],

Code ("Replace") Select

'start_date' => 'date', 'end_date' => 'date', 'forumid' => 'int',
),
array(
$eventOptions['board'], $eventOptions['topic'], $eventOptions['title'], $eventOptions['member'],
$eventOptions['start_date'], $eventOptions['end_date'], $forumid,


My ./Sources/Subs-Calendar.php of this section reads as follows:

Code ("My Subs-Calendar.php code") Select

'start_date' => 'date', 'end_date' => 'date', 'hcc_max_attendants'=> 'int', 'hcc_confirm'=>'int', 'hcc_days_closed'=>'int', 'hcc_terms_conds'=>'string', 'hcc_groups'=>'string', 'hcc_sub_ids'=>'string', 'hcc_reg_sub_ids'=>'string', 'hcc_add_comment'=>'int', 'hcc_see_comment'=>'int', 'hcc_max_register'=>'int',
),
array(
$eventOptions['board'], $eventOptions['topic'], $eventOptions['title'], $eventOptions['member'],
$eventOptions['start_date'], $eventOptions['end_date'],


I broke this up into two operations, the first dealing with the change that occurrs in just the first line, then the second dealing with the change to the array at the end.

I replaced the following code in install_source.xml as follows:

Code ("Original install_source.xml code") Select

<operation>
<search position="replace"><![CDATA['start_date' => 'date', 'end_date' => 'date',
),
array(
$eventOptions['board'], $eventOptions['topic'], $eventOptions['title'], $eventOptions['member'],
$eventOptions['start_date'], $eventOptions['end_date'],]]></search>
<add><![CDATA['start_date' => 'date', 'end_date' => 'date', 'forumid' => 'int',
),
array(
$eventOptions['board'], $eventOptions['topic'], $eventOptions['title'], $eventOptions['member'],
$eventOptions['start_date'], $eventOptions['end_date'], $forumid,]]></add>
</operation>

Code ("Original install_source.xml code broken up into two operations as follows") Select

<operation>
<search position="replace"><![CDATA['start_date' => 'date', 'end_date' => 'date',]]></search>
<add><![CDATA['start_date' => 'date', 'end_date' => 'date', 'forumid' => 'int',]]></add>
</operation>
<operation>
<search position="replace"><![CDATA[array(
$eventOptions['board'], $eventOptions['topic'], $eventOptions['title'], $eventOptions['member'],
$eventOptions['start_date'], $eventOptions['end_date'],]]></search>
<add><![CDATA[array(
$eventOptions['board'], $eventOptions['topic'], $eventOptions['title'], $eventOptions['member'],
$eventOptions['start_date'], $eventOptions['end_date'], $forumid,]]></add>
</operation>

Greygal

#292
Line 28.7 File .Sources/Subs-Calendar.php conflicted with "Event Registration Mod for SMF2   v2.26" modifications.  "Event Registration Mod" sure is a pesky little mod, eh?  But my members use it beyond belief, and despite the time I spent on modifying your code to work with it, it was still less time and less risky than touching the Event Registration mod, at least for me :)

Original find/replace modification code is:
Code ("Find") Select

id_topic = {int:id_topic}
WHERE id_event = {int:id_event}',
array(

Code ("Replace") Select

id_topic = {int:id_topic}
WHERE id_event = {int:id_event}
AND forumid = {int:forumid}',
array(
'forumid' => (int) $forumid,


The relevant section of my .Sources/Subs-Calendar.php file is as follows:

Code ("My Subs-Calendar.php code") Select

id_topic = {int:id_topic}
, hcc_max_attendants = {int:hcc_max_attendants}
, hcc_confirm = {int:hcc_confirm}
, hcc_days_closed = {int:hcc_days_closed}
, hcc_terms_conds = {string:hcc_terms_conds}
, hcc_groups = {string:hcc_groups}
, hcc_sub_ids = {string:hcc_sub_ids}
, hcc_reg_sub_ids = {string:hcc_reg_sub_ids}
, hcc_add_comment = {int:hcc_add_comment}
, hcc_see_comment = {int:hcc_see_comment}
, hcc_max_register = {int:hcc_max_register}

WHERE id_event = {int:id_event}',
array(


I changed the install_source.xml as follows:

Code ("Original install_source.xml code") Select

<operation>
<search position="replace"><![CDATA[id_topic = {int:id_topic}
WHERE id_event = {int:id_event}',
array(]]></search>
<add><![CDATA[id_topic = {int:id_topic}
WHERE id_event = {int:id_event}
AND forumid = {int:forumid}',
array(
'forumid' => (int) $forumid,]]></add>
</operation>

Code ("Original install_source.xml code changed as follows") Select

<operation>
<search position="replace"><![CDATA[WHERE id_event = {int:id_event}',
array(
'start_date']]></search>
<add><![CDATA[WHERE id_event = {int:id_event}
AND forumid = {int:forumid}',
array(
'forumid' => (int) $forumid,
'start_date']]></add>
</operation>


Edit: Fixed minor type/syntax error, forgot to remove the ', after WHERE id_event = {int:id_event} oops :)

Greygal

#293
Line 36.19 File ./Themes/default/ManageBoards.template.php has a small typo in it, that I wouldn't have thought would have mattered much but it throws it out as a "Test failed(Ignore Errors)"

On the lines that read:

foreach ($boards as $board)
echo '
<option', !isset($context['board']['is_new']) && in_array($board['id'], $context['board']['alias_child']) ? ' selected="selected"' : '', ' value="', $board['id'], '">', $board['name'], '</option>';


You need one less tab character before the "foreach" and "echo '" line.





I've attached my install_source.xml file to this post, with the above-mentioned changes I made so that it is now compatible with both the "Event Registration Mod for SMF2" (version 2.26) and the "Event Reminder Mod for SMF2"  (version  2.31) mods (note this mod is called "Calendar Event Reminder" in the mods database, but displays as "Event Reminder Mod" on the admin page once installed).

The changes I made should work whether or not either or both of these mods are installed.

I hope it is of help to you and/or someone else, and if not, that's okay, too :)

Whoops, forgot to mention, I'm using the latest 2.09 release :)

Thanks again for all your hard work on this fabulous mod!  It's the answer to my dreams!  I'm in the middle of merging 14 small forums into my one big most-popular forum, and this mod will allow me to continue to provide my members with the various "specialized" forums they have grown to love and adore yet save my sanity in now only having to deal with one primary forum, user database, etc.  This has been a pretty big - and much-procrastinated! - project, but thanks to your mod, I'm likely gaining 10 or more hours of my life back a week!

Keep up the awesome work!

GG

edit: attached corrected xml, small typo :)

dougiefresh

#294
@Greygal: WOW!!!  That is some major work you just did!  And you even included instructions on how to fix this compatibility issue!  Very impressive!  Thank you, I'll be sure to include these changes in the next version of the mod!  You are going to be credited in the readme with these changes in the mod, as well....

One question, though: What version of the mod are you including the changes from?  The v1.18 install_source.xml has a "1.17" version number attached to it, so I don't want to overwrite it and end up reverting the code a version....

Never mind, I made the changes myself.....  Thanks again!

Quote from: Denis Pageau on November 26, 2014, 11:40:04 AM
Hi DougieFresh,

I got this error, but I imagine that it is because I don't use simpleportal.

1.Execute Codeadd_remove_hook.php

2.Adapt Databasedb_install.php

3.Execute Modification./Themes/default/PortalAdminBlocks.template.phpFile not found

4.Extract File./Sources/Subs-ManageSplitForums.php

I installed it anyway and it installed correctly. At least at first glance.
If you don't have Simple Portal installed, you don't need the modifications that go into that file.  Easy-peasy....

EDIT: Whoops, fixed the upgrade_1.18.xml to make the package manager skip that operation if the file isn't present.  Thanks for reporting that bug!

dougiefresh

#295
Quote from: SauloA on November 25, 2014, 08:25:59 PM
I'm getting the following error when I click on the "Boards" link in the admin area:

Template Parse Error!
There was a problem loading the /Themes/default/ManageBoards.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.
syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)


It won't allow me to make adjustments to my boards.

Other than that everything is working well with the mod.
Let me research this issue.  I think I solved that particular error in v1.18, but I'll test it again....  What version of the mod are you running?  v1.17 ?

Quote from: SauloA on November 25, 2014, 08:25:59 PM
Also, you can get the mod to pass the session information to a subdomain and that works fine, but how do I get the session to another the main domain.  For example, the mod allows me to make a subdomain URL for a separate forum (forum.secondmywebsite.com), but how do I tie that session in the subdomain to the main domain (mysecondwebsite.com)?
That is a REALLY good question.  I'll have to do some research to figure out the answer to this one.....

EDIT: The session ID is stored in a cookie, and each cookie is associated with a domain name.  PHP code can't read the cookies from another domain, the BROWSER won't let it.  So we would have to write up an entirely new way to allow the forum to get that information....

Arantor

You can cross *subdomains* with cookies by way of the 'use subdomain independent cookies' option in Admin > Configuration > Server Settings > Cookies and Sessions.

This allows a cookie for my.domain.com to be access from domain.com and also from example.domain.com - it binds it to the entire domain rather than a subset of it. But cross-domain cookies are voodoo.

Greygal

:blush: and thank YOU, Dougie, for all the work you did putting this together, and being so on-the-ball with support of it!  More than glad to help!

I got "lucky" with this compatibility issue, in that the mod that was causing the conflict (the event registration mod) made its modifications with great consistency.  Makes it a lot easier to adapt around it :)

The "easy" solution would have been to just uninstall the Event Registration mod, then install the Split Forum mod, then reinstall the Event Registration mod.  But I didn't want to risk something breaking even worse that way, and besides, it wasn't a complicated fix, just a bit tedious :)

Meanwhile, I've got it up and running, but I think I didn't set up my subforum correctly.  The second forum is correctly displaying just the categories I want it to display.  But when I log into my second forum, it logs me in then redirects me to the first forum, which is kind of defeating the purpose of having two different front ends :)  Off hand, can you think of what I may have done wrong?  Both forums are on unique domain names, but the same server.


dougiefresh

Quote from: Greygal on November 27, 2014, 08:42:06 PM
Meanwhile, I've got it up and running, but I think I didn't set up my subforum correctly.  The second forum is correctly displaying just the categories I want it to display.  But when I log into my second forum, it logs me in then redirects me to the first forum, which is kind of defeating the purpose of having two different front ends :)  Off hand, can you think of what I may have done wrong?  Both forums are on unique domain names, but the same server.
What mods do you have installed?  Cause I can't think of anything in my mod that would cause that.....

Greygal

Quote from: dougiefresh on November 28, 2014, 03:57:25 AM
Quote from: Greygal on November 27, 2014, 08:42:06 PM
Meanwhile, I've got it up and running, but I think I didn't set up my subforum correctly.  The second forum is correctly displaying just the categories I want it to display.  But when I log into my second forum, it logs me in then redirects me to the first forum, which is kind of defeating the purpose of having two different front ends :)  Off hand, can you think of what I may have done wrong?  Both forums are on unique domain names, but the same server.
What mods do you have installed?  Cause I can't think of anything in my mod that would cause that.....

Not sure what I screwed up :)  I ended up deleting that subforum I created, then created a new one. 

Now, when I go to the new subforum, I see it, but whenever I try to click on the board I created or login, I get a 404 error. 

The main forum is at http://www.affirmativealliance.com and I am trying to create a subforum off of it to http://www.redemption-road.com

This is the URL to the test subforum I created: http://www.redemption-road.com/newforum/forum1/

The error I get when I try to login is:

Bad Request

Your browser sent a request that this server could not understand.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


Any ideas what I screwed up?




Advertisement: