1 (edited by Riklaunim 2006-09-21 22:05)

Topic: Some updates to some extensions

I'm migrating jakilinux.org forum (phpBB) and after the migration I had to install some hacks. Some of them needs some updates to work:

Private Messaging System 1.2.2
I had to alter the SQL in install_mod.php to create table on MySQL 5:

default:
    
                $sql = 'CREATE TABLE '.$db->prefix."messages (
                        id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
                        owner int(10) NOT NULL DEFAULT 0,
                        subject VARCHAR(120) NOT NULL DEFAULT '',
                        message TEXT,
                        sender VARCHAR(120) NOT NULL DEFAULT '',
                        sender_id int(10) NOT NULL DEFAULT 0,
                        posted INT(10) NOT NULL DEFAULT 0,
                        sender_ip VARCHAR(120),
                        smileys TINYINT DEFAULT '1',
                        status TINYINT DEFAULT '0',
                        showed TINYINT DEFAULT '0',
                        PRIMARY KEY (id)
                        ) TYPE=MyISAM;";

easy Poll 1.1.3
from the readme:

#---------[ 9. FIND (line:113) ]---------------------------------------------------
#

$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'];

#
#---------[ 10. REPLACE WITH ]---------------------------------------------------
#

$sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to, question 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'];

#
#---------[ 11. FIND (line:117) ]---------------------------------------------------
#

    // 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;

    }
}

#
#---------[ 12. REPLACE WITH ]---------------------------------------------------
#

    // 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.question 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.question 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.question 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, t.question, p.poster_id ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$start_from.', '.$pun_user['disp_topics'];
            break;

    }
}

Old queries, to make it work add "question" and "t.question" to the current queries.

If I spot something more I'll post it smile

My site [PHP, Python, Linux]

Re: Some updates to some extensions

Polish lang for polls (utf-8 compatible font required to see special chars)

<?php
// Language definitions used in viewforum.php
$lang_polls = array(
'Poll'    =>    'Ankieta',
'New poll'    =>    'Stwórz now? ankiet?',
'New poll legend multiselect'    =>    'Ustaw informacje (ankieta wielokrotnego wyboru)',
'New poll legend yesno'    =>    'Ustaw informacje (ankieta wielokrotnego wyboru tak/nie)',
'New poll legend'    =>    'Ustaw informacje',
'Multiselect'    =>    'Ankieta wielokrotnego wyboru',
'Yesno'    =>    'Ankieta wielokrotnego wyboru tak/nie',
'Regular'    =>    'Zwyk?a Ankieta',
'Question'    =>    'Pytanie',
'Option'    =>    'Opcja',
'Optional'    =>    '(Opcjonalne)',
'Yes'    =>    'Warto?? logicznego Tak (Zgadzam si?, tak itp.)',
'Null vote'    =>    'Pusty g?os',
'Poll preview'    =>    'Podgl?d Ankiety',
'No'    =>    'Warto?? logicznego Nie',
'Create new poll' => 'Stwórz Ankiet?',
'Poll select'    =>    'Wybierz typ ankiety',
'Already voted'    =>    'Ju? g?osowa?e? w tej ankiecie',
'Vote success'    =>    'Twój g?os zosta? zapisany',
'Empty option'            =>    'Ankieta ma pust? opcj?.',
'No options'            =>    'Ankieta musi zawiera? opcje.',
'Low options'            =>    'Ankieta musi zawiera? wi?cej ni? jedn? opcj?.',
'No question'            =>    'Ankieta musi zawiera? pytanie.',
'Too long question'        =>    'Pytanie nie mo?e zawiera? wi?cej ni? 70 znaków.',
'No yes'            =>    'Ta ankieta musi zawiera? warto?? (Tak).',
'Too long yes'        =>    '(Tak) warto?? nie mo?e by? wi?ksza ni? 35 znaków.',
'No no'            =>    'Ta ankieta musi zawiera? warto?? (nie).',
'Too long no'        =>    '(Nie) warto?? nie mo?e by? wi?ksza ni? 35 znaków.',
'No message'            =>    'Podaj wiadomo??.',
'Too long message'        =>    'Post mo?e maksymalnie zajmowa? 64KB.'
);
My site [PHP, Python, Linux]