[BETA] Topic Type MOD (Latest: 1.1.2)

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
User avatar
GPHemsley
Registered User
Posts: 1475
Joined: Fri Apr 18, 2003 3:12 am
Location: Long Beach, NY
Name: Gordon Hemsley
Contact:

Post by GPHemsley »

Carpe Diem wrote: Would you cut this out and be happy instead?? So everybody here is supposed to jump on all your mods without blinking and praise you for them?!

OK, OK, I'll be happy... You shouldn't force people like that. :P
Carpe Diem wrote: I meant no disrespect asking that question, was just curious since I did not understand what you meant.. your "tone" when replying was pretty harsh.. take it easy m8.

I made it little because I knew it sounded mean. It's hard to express true attitude in just text.
Carpe Diem wrote: I just tested and installed another mod of yours (topic title shows when posting) and that was another mod I really needed and I praised you for it as well. You do great job.

Thank you. ;)
Carpe Diem wrote: The reason I still have not installed your mod on my testboard is due to lack of time. This one takes a lot of modifying to files and also I want to see whether other mods already installed go well with eachother before I actcully go and install more complicated mods... so that's why.

That's fine. I was just making a point that you were the first one to post a reply, but then you never answered until now....
Carpe Diem wrote: So please treat others with the same respect they treat you. Or else no one would care about your mods at all. Saying "I need the publicity" is a very childish way of promoting yourself or your mods IMHO. That brings down your already great job which you're doing, and believe it or not, your work is appreciated a lot.

Woah, calm down there, buddy. No need to go giving people ideas. ;)

Solem
Registered User
Posts: 7
Joined: Wed Mar 19, 2003 7:43 pm

Post by Solem »

GPHemsley

The "special" messages went under the stickys but i wanted that them acted normaly it didnt help a lot so if somebody have any other ideia...

Solem

wGEric
Former Team Member
Posts: 8805
Joined: Sun Oct 13, 2002 3:01 am
Location: Friday
Name: Eric Faerber
Contact:

Post by wGEric »

This is a good start to this mod but I don't think it is worth it until you can add, edit, delete types in the Admin Panel. I was looking at it and it doesn't look like you can do that yet.
Eric

User avatar
GPHemsley
Registered User
Posts: 1475
Joined: Fri Apr 18, 2003 3:12 am
Location: Long Beach, NY
Name: Gordon Hemsley
Contact:

Post by GPHemsley »

No, you can't edit them yet, but don't worry. ;) I'm working on it right now... It's causing a little problem, but it's because I'm taking code from other files and editing them..... I must be forgetting to edit certain things. I'm doing OK, though. :D

miraclewhipkey
Registered User
Posts: 71
Joined: Sun May 04, 2003 5:28 pm
Location: Mesa, AZ
Contact:

Post by miraclewhipkey »

This MOD will be very helpful to me. I have a calendar app that I built before I started adding a forum, and it works exactly how I want it to, so I don't want to switch to one of the phpBB integrated calendars. I want to add a feature that will automatically add a topic to a particular forum when a user adds an event to the calendar.

The calendar is about local music, and the events are announcements of concerts. So the event title they enter for the concert will be used for the topic title on the forum. The event details will be the post details. I'm sharing the user db with the forum. I will have a special post type with a special icon for those topics entered automatically via the calendar. I may have to tweak some of your code so that this special calendar post type can't be made outside of the calendar, but your MOD will save me tons of time.

cheers,
Clay
We are the music makers, and we are the dreamers of dreams.

netclectic
Former Team Member
Posts: 4439
Joined: Wed Mar 13, 2002 3:08 pm
Location: Omnipresent
Contact:

Post by netclectic »

miraclewhipkey wrote: This MOD will be very helpful to me. I have a calendar app that I built before I started adding a forum, and it works exactly how I want it to, so I don't want to switch to one of the phpBB integrated calendars. I want to add a feature that will automatically add a topic to a particular forum when a user adds an event to the calendar.

You may also be interested in this - [FUNCTION] Insert Post


On a side note, i thought this was make quite good use of this mod - A FAQ that would included in each forum
Defend the game:
Image

miraclewhipkey
Registered User
Posts: 71
Joined: Sun May 04, 2003 5:28 pm
Location: Mesa, AZ
Contact:

Post by miraclewhipkey »

thanks, netclectic. that will also be a huge timesaver.
We are the music makers, and we are the dreamers of dreams.

miraclewhipkey
Registered User
Posts: 71
Joined: Sun May 04, 2003 5:28 pm
Location: Mesa, AZ
Contact:

Post by miraclewhipkey »

I have installed this mod and its great. :D

When a user posts an event on my calendar, it creates a post in the shows forum that matches it. That topic gets a special icon now. Thanks!

Couple support questions though:

1. The topic title does not have the type prepended. It should say "Calendar: blah blah blah post title". But instead it just says "blah blah blah post title". Can you point me to where that would be affected?

2. I don't want these post types to act like Sticky. I really only want the special markings, and otherwise I want them to display in order of recent replies like normal posts. What would I change to do that?

thanks...
We are the music makers, and we are the dreamers of dreams.

User avatar
GPHemsley
Registered User
Posts: 1475
Joined: Fri Apr 18, 2003 3:12 am
Location: Long Beach, NY
Name: Gordon Hemsley
Contact:

Post by GPHemsley »

For Solem and miraclewhipkey, try this:

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
includes/constants.php

#
#-----[ FIND ]------------------------------------------
#
// Begin New Post Type MOD
define('POST_SPECIAL', 4);
// End New Post Type MOD
#
#-----[ REPLACE WITH]------------------------------------------
#
// Begin New Post Type MOD
define('POST_SPECIAL', -1);
// End New Post Type MOD
Let me know what happens....

miraclewhipkey
Registered User
Posts: 71
Joined: Sun May 04, 2003 5:28 pm
Location: Mesa, AZ
Contact:

Post by miraclewhipkey »

That seemed to turn it back into a normal post. With normal post icon.

edit:
Side note - I figured out why it wasn't adding the post type name in front of the topic title. I think I missed that step in the instruction file. :o

I think the key to the behavior is somewhere in viewforum.php. I'm looking for it, too.

************

edit 2:
The new post type actually seems to take priority over Sticky. It only stays on top on the first page like Sticky, but it gets listed on top of Sticky.

***********

edit 3:
OK. I changed it back to -1, and also changed the topic_type to -1 in the database, and that does work... sort of. It now makes it the lowest priority, which means that normal posts will always appear above the special post types. I also noticed your thread asking how sticky topics work, and I understand now that there is no way with the current script to make special topics and normal topics mingle together.

Here's my idea for a solution: this query determines the order of all topics besides announcements ->

Code: Select all

//
// Grab all the basic data (all topics except announcements)
// for this forum
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time 
	FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
	WHERE t.forum_id = $forum_id
		AND t.topic_poster = u.user_id
		AND p.post_id = t.topic_first_post_id
		AND p2.post_id = t.topic_last_post_id
		AND u2.user_id = p2.poster_id 
		AND t.topic_type <> " . POST_ANNOUNCE . " 
		$limit_topics_time
	ORDER BY t.topic_type DESC, t.topic_last_post_id DESC 
	LIMIT $start, ".$board_config['topics_per_page'];
As long as it is sorting them by topic_type, we will always have this problem. I think we may need to create another field in this DB table that we will only use for sorting. Maybe something like "topic_order_type". That way all special posts could be allowed to share the same sort id number but still get marked differently than normal posts. .... I'll take a break for now, and maybe dig in some more tomorrow.
We are the music makers, and we are the dreamers of dreams.

User avatar
GPHemsley
Registered User
Posts: 1475
Joined: Fri Apr 18, 2003 3:12 am
Location: Long Beach, NY
Name: Gordon Hemsley
Contact:

Post by GPHemsley »

Well, I did change that code to sort by topic_order_type... Unfortunately I can't find where topic_type is defined and then specified, so I can't duplicate it with topic_order_type... I think I've narrowed it down to the following files:

- posting.php
- common.php
- functions_post.php
- constants.php

Here's the edited code:

Code: Select all

//
// Grab all the basic data (all topics except announcements)
// for this forum
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time 
	FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
	WHERE t.forum_id = $forum_id
		AND t.topic_poster = u.user_id
		AND p.post_id = t.topic_first_post_id
		AND p2.post_id = t.topic_last_post_id
		AND u2.user_id = p2.poster_id 
		AND t.topic_order_type <> " . POST_ANNOUNCE . " 
		$limit_topics_time
	ORDER BY t.topic_order_type DESC, t.topic_last_post_id DESC 
	LIMIT $start, ".$board_config['topics_per_page'];

miraclewhipkey
Registered User
Posts: 71
Joined: Sun May 04, 2003 5:28 pm
Location: Mesa, AZ
Contact:

Post by miraclewhipkey »

I have it! It took quite a few tweaks, but it works.

After applying the original mod (downloaded from the original post), these are the files I changed:

posting.php
viewforum.php
modcp.php
includes/functions_post.php

and one database change:

Code: Select all

ALTER TABLE `phpbb_topics` ADD `topic_order_type` TINYINT( 2 ) UNSIGNEDDEFAULT '2' NOT NULL ;
changes to functions_post.php, find this:

Code: Select all

function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length)
replace with this:

Code: Select all

function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id, &$topic_type, &$topic_order_type, &$bbcode_on, &$html_on, &$smilies_on, &$attach_sig, &$bbcode_uid, &$post_username, &$post_subject, &$post_message, &$poll_title, &$poll_options, &$poll_length)
find this:

Code: Select all

$sql  = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type, topic_vote = $topic_vote WHERE topic_id = $topic_id";
replace with this:

Code: Select all

$sql  = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote, topic_order_type) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote, '$topic_order_type')" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type, topic_vote = $topic_vote WHERE topic_id = $topic_id";
changes to posting.php:
find this

Code: Select all

//
// Set topic type
//
$topic_type = ( !empty($HTTP_POST_VARS['topictype']) ) ? intval($HTTP_POST_VARS['topictype']) : POST_NORMAL;
and after that add this see note at the bottom about this part

Code: Select all

//
//Set topic order type
//
if ( $topic_type == POST_ANNOUNCE )
{
	$topic_order_type = 0;
}
else if ( $topic_type == POST_STICKY )
{
	$topic_order_type = 1;
}
else
{
	$topic_order_type = 2;
}
in the same file, find this:

Code: Select all

submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\'", "''", $username), str_replace("\'", "''", $subject), str_replace("\'", "''", $message), str_replace("\'", "''", $poll_title), $poll_options, $poll_length);
replace with this:

Code: Select all

submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_type, &$topic_order_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, $bbcode_uid, str_replace("\'", "''", $username), str_replace("\'", "''", $subject), str_replace("\'", "''", $message), str_replace("\'", "''", $poll_title), $poll_options, $poll_length);
changes to viewforum.php, find this:

Code: Select all

$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time 
	FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
	WHERE t.forum_id = $forum_id
		AND t.topic_poster = u.user_id
		AND p.post_id = t.topic_first_post_id
		AND p2.post_id = t.topic_last_post_id
		AND u2.user_id = p2.poster_id 
		AND t.topic_type <> " . POST_ANNOUNCE . " 
		$limit_topics_time
	ORDER BY t.topic_type DESC, t.topic_last_post_id DESC 
	LIMIT $start, ".$board_config['topics_per_page'];
replace with this:

Code: Select all

$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time 
	FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
	WHERE t.forum_id = $forum_id
		AND t.topic_poster = u.user_id
		AND p.post_id = t.topic_first_post_id
		AND p2.post_id = t.topic_last_post_id
		AND u2.user_id = p2.poster_id 
		AND t.topic_type <> " . POST_ANNOUNCE . " 
		$limit_topics_time
	ORDER BY t.topic_order_type ASC, t.topic_last_post_id DESC 
	LIMIT $start, ".$board_config['topics_per_page'];
changes to modcp.php, find this:

Code: Select all

$sql = "SELECT t.*, u.username, u.user_id, p.post_time
			FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
			WHERE t.forum_id = $forum_id
				AND t.topic_poster = u.user_id
				AND p.post_id = t.topic_last_post_id
			ORDER BY t.topic_type DESC, p.post_time DESC
			LIMIT $start, " . $board_config['topics_per_page'];
replace with this:

Code: Select all

$sql = "SELECT t.*, u.username, u.user_id, p.post_time
			FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
			WHERE t.forum_id = $forum_id
				AND t.topic_poster = u.user_id
				AND p.post_id = t.topic_last_post_id
			ORDER BY t.topic_order_type ASC, p.post_time DESC
			LIMIT $start, " . $board_config['topics_per_page'];
I think that was everything. It works great for me now. When a post is made, it gives it an extra id number which is only used for sorting on the forum view pages (viewforum and modcp), that way the topic type id will still be available for other uses. When the topic type is ANNOUNCE, it gets a 0, STICKY gets a 1, and everything else that you want to act normal will get a 2. 2 is also the default for the database field.

If you wanted to add more topic types in the future, that do have priority over normal posts, you would only have to modify the statement on posting.php and throw in an extra if else condition. Just keep in mind that the lower the number, the higher priority. You can now change the sort order in that one area without having to alter any other files at all. Note: this will not affect announcment priority, as that is determined seperately from all the rest.

cheers,
Clay
We are the music makers, and we are the dreamers of dreams.

User avatar
GPHemsley
Registered User
Posts: 1475
Joined: Fri Apr 18, 2003 3:12 am
Location: Long Beach, NY
Name: Gordon Hemsley
Contact:

Post by GPHemsley »

miraclewhipkey wrote: and after that add this see note at the bottom about this part

Code: Select all

//
//Set topic order type
//
if ( $topic_type == POST_ANNOUNCE )
{
	$topic_order_type = 0;
}
else if ( $topic_type == POST_STICKY )
{
	$topic_order_type = 1;
}
else
{
	$topic_order_type = 2;
}

Geez, I was so close.... I had most of that figured out, but it was this above if statement that I never thought of. Good job! I'll run some checks on it and then I'll release it with credit to you. Thanks!

mrskippy
Registered User
Posts: 30
Joined: Mon Jun 02, 2003 9:38 pm

Post by mrskippy »

[edit=netclectic] huge code block removed

User avatar
GPHemsley
Registered User
Posts: 1475
Joined: Fri Apr 18, 2003 3:12 am
Location: Long Beach, NY
Name: Gordon Hemsley
Contact:

Post by GPHemsley »

OK, could you please just shorten that post... it's extremely long... I know what the problem is... I'll fix it next release... (If I remember... ;) :roll:)

Post Reply

Return to “[2.0.x] MODs in Development”