[BETA] Topic Tag Prefixes MOD 0.1.0

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!
Scam Warning
Locked
User avatar
Highway of Life
Former Team Member
Posts: 6048
Joined: Wed Feb 02, 2005 5:41 pm
Location: Seattle, WA
Name: David Lewis
Contact:

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by Highway of Life »

JAMEEL225 wrote:hello dear

i have install this mod

its showing this error

and not apearing topic tak in new post and reply

plz help me

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/functions_topic_tags.php on line 118: array_keys() [function.array-keys]: The first argument should be an array
[phpBB Debug] PHP Notice: in file /includes/functions_topic_tags.php on line 118: array_combine() expects parameter 1 to be array, null given
Look at the very first post of this topic for a solution.
The phpBB Weekly Podcast - Discussing the developments of phpBB4 and beyond.

New to phpBB3? Want to learn about programing?
Visit phpBB Academy at StarTrekGuide to learn how.
JAMEEL225
Registered User
Posts: 70
Joined: Sun Mar 25, 2007 7:01 pm

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by JAMEEL225 »

salam dear

i have got it

thanks for help
User avatar
cedarrapidsboy
Registered User
Posts: 35
Joined: Thu Sep 29, 2005 9:45 pm

Re: [BETA] Topic Tag Prefixes MOD 0.1.0 - State Flow

Post by cedarrapidsboy »

As I mentioned in my previous post regarding sorting a forum based on topic tags, I wanted to find a way to enforce a state flow from one tag to another when replies are made to a topic. This is particularly useful in an incident management system... in fact, I can only think of it being useful for such a purpose. So, I investigated the possibility and did it. I'm posting the modification here... but know that THESE CHANGES WILL ALTER THE ORIGINAL FUNCTIONALITY of Topic Tag Prefixes MOD 0.1.0.

Image

The following changes implement a state flow:
  • All new incidents start as [New] state
  • When moderator replies to new topic, it gets put into [Open] state, all other replies stay in [New] state
  • When the author replies to an incident in the [Pending: Awaiting Customer Input] state, the incident is transitioned to [Open], all other replies leave it in [Pending*]
  • When the Moderator replies to an incident in the [Pending: Awaiting 3rd Party] state, the incident is transitioned to [Open], all other replies leave it in [Pending*]
  • When anyone replies to an incident in the [Resolved] state, it get transitioned to the [Open] state.
Limitations:
  • States are "recommended" to moderators, but the moderator can choose any state for their reply (this is the only way a ticket can enter [Pending*] or [Resolved]).
  • States are enforced for authors... their reply will result in the transition as described above.
  • Any user who is not the author, and not a moderator/admin, can not change the state of the topic.
How it works:
The forum enforces the above state flow by providing the author only one option, determined by the state flow, in her state (topic tags) selection box. With no other states to choose from, the reply process puts the incident into the recommended state.

In the case of moderators (and admins), the state selection box contains all states, but the recommended state is the one that is initially selected. The moderator must then manually change the selection to alter the recommended flow (or to move the ticket to a pending or resolved state).

File: includes/functions_topic_tags.php
(implemented in rev 3097)
Around line 10, add:

Code: Select all

$topic_tag_ids = array(
    '[New]'                           => 14,
    '[Open]'                          => 15,
    '[Pending: Awaiting Customer]'    => 16,
    '[Pending: Awaiting 3rd Party]'   => 17,
    '[Resolved]'                      => 18);
The actual labels and int values may be different. See your forum db's topic_tags table for the actual values.

Around line 194, to remove the "No Tag" option, change:

Code: Select all

    $mod_list = ($in_mcp) ? array() : (($in_posting) ? '<option value="topic_tag_0">' . $user->lang['NO_TAG'] . "</option>\n" : '');
to:

Code: Select all

    //$mod_list = ($in_mcp) ? array() : (($in_posting) ? '<option value="topic_tag_0">' . $user->lang['NO_TAG'] . "</option>\n" : '');
    $mod_list = array();
Around line 199, change:

Code: Select all

    while ($row = $db->sql_fetchrow($result))
    {
        if (!$in_mcp)
        {
            $selected = ((int) $current_tag == $row['topic_tag_id']) ? ' selected="selected"' : '';
            $mod_list .= '<option value="topic_tag_' . $row['topic_tag_id'] . '"' . $selected . '>' . sprintf($user->lang['TAG_AS'], strip_tags(html_entity_decode($row['topic_tag_name']))) . '</option>' . "\n";
        }
        else
        {
            $mod_list['topic_tag_' . $row['topic_tag_id']] = $row['topic_tag_name'];
        }
    }
to:

Code: Select all

    while ($row = $db->sql_fetchrow($result))
    {
        if (!$in_mcp)
        {
            //if this is not a moderator and not an administrator, then set just one option, the $current_tag
            if (!$auth->acl_get('m_', $forum_id) && !$auth->acl_get('a_', $forum_id))
            {
                if ($current_tag == $row['topic_tag_id'])
                {
                    $mod_list = '<option value="topic_tag_' . $row['topic_tag_id'] . '" selected="selected">' . sprintf($user->lang['TAG_AS'], strip_tags(html_entity_decode($row['topic_tag_name']))) . '</option>' . "\n";
                }
            }
            else
            {
                $selected = ((int) $current_tag == $row['topic_tag_id']) ? ' selected="selected"' : '';
                $mod_list .= '<option value="topic_tag_' . $row['topic_tag_id'] . '"' . $selected . '>' . sprintf($user->lang['TAG_AS'], strip_tags(html_entity_decode($row['topic_tag_name']))) . '</option>' . "\n";
            }
        }
        else
        {
            $mod_list['topic_tag_' . $row['topic_tag_id']] = $row['topic_tag_name'];
        }
    }
Around line 261, add:

Code: Select all

    global $topic_tag_ids;
Around 265, change:

Code: Select all

    $current_tag = ($mode == 'post') ? 0 : $post_data['topic_tag_id'];
to:

Code: Select all

    //Set topic tag for post
    //This is more of a suggestion than an enforcement
    $current_tag = $post_data['topic_tag_id'];
    if ($mode == 'post')
    {
        $current_tag = $topic_tag_ids['[New]'];
    }
    //stateflow for incident replies
    //for moderators (m_) and admins (a_), this doesn't enforce, only populates the suggested state
    //for non-moderators, it does enforce as topic_tags_list populates the state selection with only one value
    if ($mode == 'reply')
    {
        switch ($current_tag){
            case $topic_tag_ids['[New]']:
                if ($auth->acl_get('m_', $forum_id) || $auth->acl_get('a_', $forum_id)){
                    $current_tag = $topic_tag_ids['[Open]'];
                }
                break;
            case $topic_tag_ids['[Pending: Awaiting Customer]']:
                if ($post_data['topic_poster'] == $user->data['user_id']){
                    $current_tag = $topic_tag_ids['[Open]'];
                }
                break;
            case $topic_tag_ids['[Pending: Awaiting 3rd Party]']:
                if ($auth->acl_get('m_', $forum_id) || $auth->acl_get('a_', $forum_id)){
                    $current_tag = $topic_tag_ids['[Open]'];
                }
                break;
            case $topic_tag_ids['[Resolved]']:
                $current_tag = $topic_tag_ids['[Open]'];
                break;
        }
    }
Again, check your topic_tags table for the actual topic tag names (i.e. [Pending:Awaiting 3rd Party])

For all of the above to work, your topic_tags table (in the db) should resemble the following:

Code: Select all

14,[New],0,0,1
15,[Open],0,0,1
16,[Pending: Awaiting Customer],0,0,1
17,[Pending: Awaiting 3rd Party],0,0,1
18,[Resolved],0,0,1
If you change the names of the states or the topic tag id #'s, you'll have to alter the code accordingly.

Again, this is a very specific modification to Topic Tags to support some incident management state flow. If you use this, be sure to back-up your original topic tags code. I doubt you'll receive any kind of support for this code in this forum (neither from myself nor the larger community).
Forke
Registered User
Posts: 102
Joined: Fri Feb 08, 2008 6:03 am

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by Forke »

That is amazing, cedarrapidsboy, I'm truly impressed by the idea. I don't need it for my particular forum, but I know it will be useful for a lot of people.

I think it could be a mod of its own, really.

What I would really appreciate, and also many of the users of this MOD, is the possibility to apply forum specific tags instead of global tags. That is the esential limitation of this MOD.

Like I said, cedarrapidsboy, great work. I'm glad this MOD is still alive.
My first validated mod!
Adaptive Quick Search
User avatar
cedarrapidsboy
Registered User
Posts: 35
Joined: Thu Sep 29, 2005 9:45 pm

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by cedarrapidsboy »

Thanks for the kind words. I realize this change is pretty niche. Even so, I am interested if anyone tries it and gets it to work. I tried to record how I made the changes... but as part of an in-development system, it is possible I missed a pre-requisite.
XxXYonIXxX
Registered User
Posts: 38
Joined: Sun Apr 13, 2008 9:59 am

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by XxXYonIXxX »

Great Mod!
Thavk ;)
User avatar
cedarrapidsboy
Registered User
Posts: 35
Joined: Thu Sep 29, 2005 9:45 pm

Re: [BETA] Topic Tag ... Add tags to search results

Post by cedarrapidsboy »

If you're crazy enough to try to use phpBB3 and the topic tags MOD as a light weight incident management system... you're going to want a quick way to see all of your topics, and what *state* (topic tag) they are in. Unfortunately, Topic Tags 0.1.0 does not show topic tags in search results, neither for post results nor topic results.

Working from Highway's code in viewforum.php, I've added topic tags functionality to search.php. Unfortunately, the coding conventions between the two files is not identical, so the exact same code couldn't be used, but the general idea is what was needed.

I've tried to make the following mod (to the mod) as concise and simple as possible. Again, I am by no means a PHP or MySQL expert. For me, this would have been impossible without the solid code base from Highway.

Add the following functions to "includes/functions_topic_tags.php":

Code: Select all

/*
 * Appends topic tag to topic title.
 * Uses topic_tags_title(), it includes an extra SQL query to get the search result's parent forum
 * 
 * @param array $row		ref: search result from search.php
 * @param array $forum_id	ref: search result's parent forum_id from search.php
 */
function topic_tags_search_title(&$row, $forum_id)
{
	global $db, $config;

	if ($config['topic_tags_version'])
	{
		$sql = "SELECT *
			FROM " . FORUMS_TABLE . " " .
			"WHERE forum_id = $forum_id";
		$result = $db->sql_query($sql);
		$forum_data = $db->sql_fetchrow($result);
		$db->sql_freeresult($result);
		topic_tags_title($row, $forum_data['forum_topic_tags']);
	}	
}

Code: Select all

/**
 * Function to left join the topic tags to the search results query (post mode)
 *
 * @param array $sql_string	ref: SQL query string used in search.php
 */
function get_posts_search_topic_tags(&$sql_string)
{
	global $config;

	if ($config['topic_tags_version'])
	{
		//add topic tags field selects
		$sql_string = preg_replace('/(\s+FROM)/', ", tg.topic_tag_name, tg.topic_tag_colour\\1", $sql_string);
		//add left join of topic tags table
		$sql_string = preg_replace('/(\s+)(WHERE)/', "\\1\tLEFT JOIN " . TOPIC_TAGS_TABLE . " tg ON (tg.topic_tag_id = t.topic_tag_id)\\1\\2", $sql_string, 1);
	}
}

Code: Select all

/**
 * Function to left join the topic tags to the search results query (topic mode)
 *
 * @param array $sql_from	ref: SQL FROM query string used in search.php
 * @param array $sql_select	ref: SQL SELECT query string used in search.php
 */
function get_topics_search_topic_tags(&$sql_from, &$sql_select)
{
	global $config;

	if ($config['topic_tags_version'])
	{
		//add left join of topic tags table
		$sql_from .= 'LEFT JOIN ' . TOPIC_TAGS_TABLE . ' tg ON (tg.topic_tag_id = t.topic_tag_id)';
		//add topic tags field selects
		$sql_select .= ', tg.topic_tag_name, tg.topic_tag_colour';
	}
}
Now, some edits to "search.php"
Find:

Code: Select all

			$sql = 'SELECT p.*, f.forum_id, f.forum_name, t.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_colour
				FROM ' . POSTS_TABLE . ' p
					LEFT JOIN ' . TOPICS_TABLE . ' t ON (p.topic_id = t.topic_id)
					LEFT JOIN ' . FORUMS_TABLE . ' f ON (p.forum_id = f.forum_id)
					LEFT JOIN ' . USERS_TABLE . " u ON (p.poster_id = u.user_id)
				WHERE $sql_where";
Add the following on a new line AFTER:

Code: Select all

			//Added for Topic Tags MOD - customized
			//Modify the sql query to include topic tag information for the posts' parent topics
			get_posts_search_topic_tags($sql);
			//Added for Topic Tags MOD - customized
Find:

Code: Select all

			$sql_from = TOPICS_TABLE . ' t
				LEFT JOIN ' . FORUMS_TABLE . ' f ON (f.forum_id = t.forum_id)
				' . (($sort_key == 'a') ? ' LEFT JOIN ' . USERS_TABLE . ' u ON (u.user_id = t.topic_poster) ' : '');
			$sql_select = 't.*, f.forum_id, f.forum_name';
Add the following on a new line AFTER:

Code: Select all

			// Added for Topic Tags MOD - customized
			//append to the sql query to include topic tag information for the topics
			get_topics_search_topic_tags($sql_from, $sql_select);
			// Added for Topic Tags MOD - customized
Find:

Code: Select all

			$topic_title = censor_text($row['topic_title']);
Add following on a new line BEFORE:

Code: Select all

			// Added for Topic Tags MOD - customized
			topic_tags_search_title($row, $forum_id);
			// Added for Topic Tags MOD - customized
So, three additions to search.php and three additions to topic_tags_functions.php, and you got your topic tags in the search results. Not bad.

Please post your mileage. We'll be making great use of this added little feature, especially with the "View your posts" button.
Forke
Registered User
Posts: 102
Joined: Fri Feb 08, 2008 6:03 am

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by Forke »

Cedar, once again I have to thank you! The modification works great, and its one of the things I've been waiting since I installed this also great MOD.

:D!!!

Now that I have this installed, I'll try to to display ONLY topics with X tag following your advice. I probably wont be able to do it, but... trying is harmless. If you could give me some clues on how to do it, It'll be great.
My first validated mod!
Adaptive Quick Search
User avatar
cedarrapidsboy
Registered User
Posts: 35
Joined: Thu Sep 29, 2005 9:45 pm

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by cedarrapidsboy »

The easiest is to utilize "sorting" to group the 'X' tags. But, not entirely what you want.

Don't hold your breath, but I have already had that request from colleagues that use the system. So, I'll probably be looking into that in the near future. But, I'm not above utilizing any contributions to this thread! ;)

The big challenge here (for me) is the added UI element(s) needed to provide the user with a selection box for the tags. Where to put it, and how to do it... no idea. All the clues are in Highway's code, and other MODs... I simply haven't needed UI additions up to this point.

I would start by looking into how phpBB3 implements the sort box, then look at the code we did here to put the topic tags in the sort box. Then, the trick, to associate that "filter" box with a function to re-run the search, filtering all unwanted tags. I suppose that filter box shouldn't just go at the bottom of the search results page, but also in the advanced search UI.

If you tackle it, good luck! I'll be watching for updates.
User avatar
Highway of Life
Former Team Member
Posts: 6048
Joined: Wed Feb 02, 2005 5:41 pm
Location: Seattle, WA
Name: David Lewis
Contact:

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by Highway of Life »

Thanks for the code/modifications, cedarrapidsboy! :D
I have added a link to your post in the Q/A of the first post. :)
The phpBB Weekly Podcast - Discussing the developments of phpBB4 and beyond.

New to phpBB3? Want to learn about programing?
Visit phpBB Academy at StarTrekGuide to learn how.
XxXYonIXxX
Registered User
Posts: 38
Joined: Sun Apr 13, 2008 9:59 am

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by XxXYonIXxX »

I have a problem :cry:
after the installation, i want to make a some tag(in Hebrew language).
but, i see the tag in question mark(???????) - what i need to change to fix thet problem?!

Picture:
Image

and, where i can change the color of the Tags?!

Thank ;)
Yoni.
Forke
Registered User
Posts: 102
Joined: Fri Feb 08, 2008 6:03 am

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by Forke »

cedarrapidsboy wrote:The easiest is to utilize "sorting" to group the 'X' tags. But, not entirely what you want.

Don't hold your breath, but I have already had that request from colleagues that use the system. So, I'll probably be looking into that in the near future. But, I'm not above utilizing any contributions to this thread! ;)

The big challenge here (for me) is the added UI element(s) needed to provide the user with a selection box for the tags. Where to put it, and how to do it... no idea. All the clues are in Highway's code, and other MODs... I simply haven't needed UI additions up to this point.

I would start by looking into how phpBB3 implements the sort box, then look at the code we did here to put the topic tags in the sort box. Then, the trick, to associate that "filter" box with a function to re-run the search, filtering all unwanted tags. I suppose that filter box shouldn't just go at the bottom of the search results page, but also in the advanced search UI.

If you tackle it, good luck! I'll be watching for updates.
Well.. i couldn't tackle it. I understand the logic behind your advices, but I just don't have the necessary skills to do it :P

I'll countinue to keep an eye on your updates!
My first validated mod!
Adaptive Quick Search
User avatar
*Christian*
I've Been Banned!
Posts: 884
Joined: Sat Nov 03, 2007 1:35 pm
Location: Location, Location.

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by *Christian* »

Well, i'm having a tad of trouble with this.

I've uploaded all included files, and done the file edits. I've also enabled topic tags in forum management on the forums i want to add, however i'm slightly confused as to where i set the permissions :?

Also getting the following error at the top of the page when trying to enter Moderator Control Panel ->

Code: Select all

[phpBB Debug] PHP Notice: in file /includes/functions_topic_tags.php on line 118: array_keys() [function.array-keys]: The first argument should be an array
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 472: array_values() [function.array-values]: The argument should be an array

Warning: Cannot modify header information - headers already sent by (output started at /home/power100/public_html/community/includes/functions.php:2956) in /home/power100/public_html/community/includes/functions.php on line 3526

Warning: Cannot modify header information - headers already sent by (output started at /home/power100/public_html/community/includes/functions.php:2956) in /home/power100/public_html/community/includes/functions.php on line 3528

Warning: Cannot modify header information - headers already sent by (output started at /home/power100/public_html/community/includes/functions.php:2956) in /home/power100/public_html/community/includes/functions.php on line 3529

Warning: Cannot modify header information - headers already sent by (output started at /home/power100/public_html/community/includes/functions.php:2956) in /home/power100/public_html/community/includes/functions.php on line 3530

Code: Select all

You are not authorised to access this area.
I am on my Administrator account
Proud owner of Bertie 3.0
:: No support via PM or IM ::
User avatar
Highway of Life
Former Team Member
Posts: 6048
Joined: Wed Feb 02, 2005 5:41 pm
Location: Seattle, WA
Name: David Lewis
Contact:

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by Highway of Life »

Ah, hey Christian.

See the first post for a Patch/Fix to this issue. :)
The phpBB Weekly Podcast - Discussing the developments of phpBB4 and beyond.

New to phpBB3? Want to learn about programing?
Visit phpBB Academy at StarTrekGuide to learn how.
XxXYonIXxX
Registered User
Posts: 38
Joined: Sun Apr 13, 2008 9:59 am

Re: [BETA] Topic Tag Prefixes MOD 0.1.0

Post by XxXYonIXxX »

Anybody?
:|
Locked

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