1 (edited by Ju 2005-06-11 15:13)

Topic: [Mod] Topic resolved or not

Sorry for my english.

Exemple : CtrlAltSuppr.com

MOD (translate by Ludo, thx !) :
This is a post status indicator which aims at showing if the problem exposed in the topic is solved or not. The topic creator got a link with 'mark this topic as solved' which changes the colour of the post status indicator. After having marked a topic as solved it's also possible to clic on 'mark topic as unsolved' in order to inform that finally the problem is not solved. This functions are accessible to admin and moderators. You have the possibility to choose on which forum this mod is applied.

SOURCE :

SQL (change **** by your table extension or drop) :

ALTER TABLE ****topics ADD resolu TINYINT(1) DEFAULT 1

/******* VIEWFORUM.PHP *******/

Line 112, REPLACE :

    // Without "the dot"
    $sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
}
else
{
    // With "the dot"
    switch ($db_type)
    {
        case 'mysql':
        case 'mysqli':
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
            break;

        case 'sqlite':
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
            break;

        default:
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
            break;

Per :

    // Without "the dot"
    $sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to, resolu FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
}
else
{
    // With "the dot"
    switch ($db_type)
    {
        case 'mysql':
        case 'mysqli':
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.resolu FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
            break;

        case 'sqlite':
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.resolu FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.id IN(SELECT id FROM '.$db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'].') GROUP BY t.id ORDER BY t.sticky DESC, t.last_post DESC';
            break;

        default:
            $sql = 'SELECT p.poster_id AS has_posted, t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, t.resolu FROM '.$db->prefix.'topics AS t LEFT JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.poster_id='.$pun_user['id'].' WHERE t.forum_id='.$id.' GROUP BY t.id, t.subject, t.poster, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
            break;

Line 165, after :

        if ($cur_topic['moved_to'] != 0)
            $subject = $lang_forum['Moved'].': <a href="viewtopic.php?id='.$cur_topic['moved_to'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
        else if ($cur_topic['closed'] == '0')
            $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
        else
        {
            $subject = '<a href="viewtopic.php?id='.$cur_topic['id'].'">'.pun_htmlspecialchars($cur_topic['subject']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_topic['poster']).'</span>';
            $icon_text = $lang_common['Closed icon'];
            $item_status = 'iclosed';
        }

Add :

            // ICON ETAT
            $forums_icon = array(3,2,17,18,16); // Numbers of the forums concerned (also in viewtopic.php and search.php)
            if(array_search($id,$forums_icon) !== false && $cur_topic['sticky']!='1' && $cur_topic['moved_to']==null) {
                switch($cur_topic['resolu']) {
                    case 0 :
                        $iconetat_src = 'nop';
                        $iconetat_title = 'Topic not-resolved !';
                        $iconetat_alt = '0';
                        break;
                    case 1 :
                        $iconetat_src = 'new';
                        $iconetat_title = 'New topic';
                        $iconetat_alt = '1';
                        break;
                    case 2 :
                        $iconetat_src = 'ok';
                        $iconetat_title = 'Topic resolved';
                        $iconetat_alt = '2';
                        break;
                    default :
                        $iconetat_src = 'new';
                        $iconetat_title = 'New topic';
                        $iconetat_alt = '1';
                        break;
                } $iconetat = '<img class="iconetat" src="img/icon_'.$iconetat_src.'.gif" alt="'.$iconetat_alt.'" title="'.$iconetat_title.'" /> ';
            } else $iconetat='';

Line 211, after :

                            <div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo trim($icon_text) ?></div></div>

Add :

                            <?php if(isset($iconetat)) echo $iconetat ?>

/******* VIEWTOPIC.PHP *******/

Line 96, replace :

// Fetch some info about the topic
if (!$pun_user['is_guest'])
    $result = $db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
else
    $result = $db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());

Per :

// Fetch some info about the topic
if (!$pun_user['is_guest'])
    $result = $db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, t.resolu, t.poster, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
else
    $result = $db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, t.resolu, t.poster, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());

Line 162, after :

    $subscraction = '<div class="clearer"></div>'."\n";

Add :

// ICON ETAT
$forums_icon = array(3,2,17,18,16); // Numbers of the forums concerned (also in viewforum.php and search.php)
if(array_search($cur_topic['forum_id'],$forums_icon) !== false && $cur_topic['sticky']!='1') {
    $poster_name = mysql_fetch_row($db->query('SELECT username FROM '.$db->prefix.'users WHERE id="'.$pun_user['id'].'"'));
    if($cur_topic['poster'] == $poster_name[0] || $is_admmod === true)
        define('PUN_ICONETAT',1);
    else
        define('PUN_ICONETAT',0);
    if(PUN_ICONETAT == 1) {
        if(isset($_GET['etat']) && ($_GET['etat']==0 || $_GET['etat'] ==2)) {
            $db->query('UPDATE '.$db->prefix.'topics SET resolu='.$_GET['etat'].' WHERE id="'.$id.'"');
            $cur_topic['resolu'] = $_GET['etat'];
        }
    }
    switch($cur_topic['resolu']) {
        case 0 :
            $iconetat_txt = '<strong style="color:#C80815;font-weight:bold">(Not resolved)</strong>';
            $iconetat_change_txt = '<br /> ( <a href="?id='.$id.'&etat=2" style="color:#F00">Mark topic as resolved</a> )';
            break;
        case 1 :
            $iconetat_txt = '';
            $iconetat_change_txt = '<br /> ( <a href="?id='.$id.'&etat=2" style="color:#F00">Mark topic as resolved</a> )';
            break;
        case 2 :
            $iconetat_txt = '<strong style="color:#2c831b;font-weight:bold">(Resolved)</strong>';
            $iconetat_change_txt = '<br /> ( <a href="?id='.$id.'&etat=0" style="color:#F00">Mark topic as not-resolved</a> )';
            break;
        default :
            $iconetat_txt = '';
            $iconetat_change_txt = '<br /> ( <a href="?id='.$id.'&etat=2" style="color:#F00">Mark topic as resolved</a> )';
            break;
    }
    if(PUN_ICONETAT == 0)
        $iconetat_change_txt = '';
}

Line 172, replace :

        <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li> » <a href="viewforum.php?id=<?php echo $cur_topic['forum_id'] ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li> » <?php echo pun_htmlspecialchars($cur_topic['subject']) ?></li></ul>

Per :

        <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li> » <a href="viewforum.php?id=<?php echo $cur_topic['forum_id'] ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li> » <?php echo pun_htmlspecialchars($cur_topic['subject']) ?><?php if(isset($iconetat_txt)) echo $iconetat_txt ?> <?php if(isset($iconetat_change_txt)) echo $iconetat_change_txt ?></li></ul>

/******* SEARCH.PHP *******/

Line 456, replace :

            $substr_sql = ($db_type != 'sqlite') ? 'SUBSTRING' : 'SUBSTR';
            $sql = 'SELECT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.$substr_sql.'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE p.id IN('.$search_results.') ORDER BY '.$sort_by_sql;
        }
        else
            $sql = 'SELECT t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE t.id IN('.$search_results.') GROUP BY t.id, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id'.$group_by_sql.' ORDER BY '.$sort_by_sql;

Per :

            $substr_sql = ($db_type != 'sqlite') ? 'SUBSTRING' : 'SUBSTR';
            $sql = 'SELECT p.id AS pid, p.poster AS pposter, p.posted AS pposted, p.poster_id, '.$substr_sql.'(p.message, 1, 1000) AS message, t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.forum_id, t.resolu FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE p.id IN('.$search_results.') ORDER BY '.$sort_by_sql;
        }
        else
            $sql = 'SELECT t.id AS tid, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id, t.resolu FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id WHERE t.id IN('.$search_results.') GROUP BY t.id, t.poster, t.subject, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.forum_id'.$group_by_sql.' ORDER BY '.$sort_by_sql;

Line 642, after :

                    $subject .= '  '.(!empty($subject_new_posts) ? $subject_new_posts : '');
                    $subject .= !empty($subject_multipage) ? ' '.$subject_multipage : '';
                }

Add :

                // ICON ETAT
                @reset($forum_list);
                while (list(, $temp) = @each($forum_list)) {
                    if($temp[0] == $search_set[$i]['forum_id']) {
                        $forums_icon = array(3,2,17,18,16); // Numbers of the forums concerned (also in viewforum.php and viewtopic.php)
                        if(array_search($temp[0],$forums_icon) !== false) {
                            switch($search_set[$i]['resolu']) {
                                case 0 :
                                    $iconetat_src = 'nop';
                                    $iconetat_title = 'Topic not resolved !';
                                    $iconetat_alt = '0';
                                    break;
                                case 1 :
                                    $iconetat_src = 'new';
                                    $iconetat_title = 'New topic';
                                    $iconetat_alt = '1';
                                    break;
                                case 2 :
                                    $iconetat_src = 'ok';
                                    $iconetat_title = 'Topic resolved';
                                    $iconetat_alt = '2';
                                    break;
                                default :
                                    $iconetat_src = 'new';
                                    $iconetat_title = 'New topic';
                                    $iconetat_alt = '1';
                                    break;
                            } $iconetat = '<img class="iconetat" src="img/icon_'.$iconetat_src.'.gif" alt="'.$iconetat_alt.'" title="'.$iconetat_title.'" />';
                        } else $iconetat = '';
                    }
                }

Line 642, after :

                            <div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo trim($icon_text) ?></div></div>

Add :

                            <?php if(isset($iconetat)) echo $iconetat ?>

/******* STYLE/OXYGEN.CSS *******/
(or other theme)

At the end, add :

IMG.iconetat {
    FLOAT: left;
    MARGIN-TOP: 0.1em;
    MARGIN-LEFT: 0.5em;
    MARGIN-RIGHT: 0.5em;
    DISPLAY: block;
    BORDER-WIDTH: 0;
}

IMAGES :
img/icon_new.gif
img/icon_ok.gif
img/icon_nop.gif

2

Re: [Mod] Topic resolved or not

Translation:

This is a post status indicator which aims at showing if the problem exposed in the topic is solved or not. The topic creator got a link with 'mark this topic as solved' which changes the colour of the post status indicator. After having marked a topic as solved it's also possible to clic on 'mark topic as unsolved' in order to inform that finally the problem is not solved. This functions are accessible to admin and moderators. You have the possibility to choose on which forum this mod is applied.

Re: [Mod] Topic resolved or not

cool, i was going to writing something similar for the support forum at mypunbb smile

edit: i just started installing this i think your missing some bits from viewforum.php? like the $forums_icon = array(3,2,17,18,16);

edit2: when a topic is new it says mark as non-resolved when i click that it marks it as resolved hmm

4

Re: [Mod] Topic resolved or not

Wow, I was just about to search/ask for a mod like that one... smile Very nice mod, and useful.

- ext -

5 (edited by Ju 2005-06-11 15:02)

Re: [Mod] Topic resolved or not

Connorhd wrote:

edit: i just started installing this i think your missing some bits from viewforum.php? like the $forums_icon = array(3,2,17,18,16);

Heu, I don't understand...
3,2,17,18,16 are numbers (id) of forums concerned by this mod.

Connorhd wrote:

edit2: when a topic is new it says mark as non-resolved when i click that it marks it as resolved hmm

?
This mod was installed on PunBB.fr without problems...

SORRY, I was mistaken while translating !!!

CORRECTION (modified in my first post!) :
In viewtopic.php, after the line ~162 :

switch($cur_topic['resolu']) {
        case 0 :
            $iconetat_txt = '<strong style="color:#C80815;font-weight:bold">(Not resolved)</strong>';
            $iconetat_change_txt = '<br /> ( <a href="?id='.$id.'&etat=2" style="color:#F00">Mark topic as resolved</a> )';
            break;
        case 1 :
            $iconetat_txt = '';
            $iconetat_change_txt = '<br /> ( <a href="?id='.$id.'&etat=2" style="color:#F00">Mark topic as resolved</a> )';
            break;
        case 2 :
            $iconetat_txt = '<strong style="color:#2c831b;font-weight:bold">(Resolved)</strong>';
            $iconetat_change_txt = '<br /> ( <a href="?id='.$id.'&etat=0" style="color:#F00">Mark topic as not-resolved</a> )';
            break;

I edited my first post !

Re: [Mod] Topic resolved or not

Ju wrote:
Connorhd wrote:

edit: i just started installing this i think your missing some bits from viewforum.php? like the $forums_icon = array(3,2,17,18,16);

Heu, I don't understand...
3,2,17,18,16 are numbers (id) of forums concerned by this mod.

you must have edited your post because that is fixed now

           // ICON ETAT
            $forums_icon = array(3,2,17,18,16); // Numbers of the forums concerned (alsa in viewtopic.php and search.php)
            if(array_search($id,$forums_icon) !== false && $cur_topic['sticky']!='1' && $cur_topic['moved_to']==null) {

was missing before

7

Re: [Mod] Topic resolved or not

Connorhd wrote:
Ju wrote:
Connorhd wrote:

edit: i just started installing this i think your missing some bits from viewforum.php? like the $forums_icon = array(3,2,17,18,16);

Heu, I don't understand...
3,2,17,18,16 are numbers (id) of forums concerned by this mod.

you must have edited your post because that is fixed now

           // ICON ETAT
            $forums_icon = array(3,2,17,18,16); // Numbers of the forums concerned (alsa in viewtopic.php and search.php)
            if(array_search($id,$forums_icon) !== false && $cur_topic['sticky']!='1' && $cur_topic['moved_to']==null) {

was missing before

Heu, yes, it's possible...

It's good now ??

8

Re: [Mod] Topic resolved or not

Connorhd ?

Re: [Mod] Topic resolved or not

i dunno i finished installing it before you edited your first post, i just edited it to do what i wanted

Re: [Mod] Topic resolved or not

Cool smile

"Programming is like sex: one mistake and you have to support it for the rest of your life."

11 (edited by sypie 2009-09-22 21:38)

Re: [Mod] Topic resolved or not

Maybe a very late question about this modification. But i got an error when i copied and pasted everything like written above.

The error i got is

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/virtual/site23/fst/var/www/html/viewtopic.php on line 167

The line in the script is:

    $poster_name = mysql_fetch_row($db->query('SELECT username FROM '.$db->prefix.'users WHERE id="'.$pun_user['id'].'"'));


EDIT: Problem solved: mysql_fetch_row changed into $db-> fetch_row.

Now i have to solve the problem with an  in the topic title.