26

Re: Rating Script Extension Code

These are the three files that this rating extension has
(plus there is a folder "/stars/" with the images)
include/rate.php
rate.js
manifest.xml
(links lead to my forum - just so that not all the code is cluttering this post!)

I would appreciate anyone (dev, etc) taking a hard look at it -  as I can't get it to work yet.

Main trouble being:

1. uninstall section in manifest.xml  aswell as unsure about install manifest.xml

2. hooks are working for placing in header but only show "ratings" text, instead of showing the gif of stars rating

any feedback welcome
PS: if anyone can make this work for $ - just give me a price and satisfaction guarantee big_smile

still haven't given up this thing. need it! want it! smile

27

Re: Rating Script Extension Code

If you create_table('categories'), then you drop_table('categories') smile

28

Re: Rating Script Extension Code

    <uninstall><![CDATA[
    // Uninstallation code
        if ($forum_db->field_exists('o_ratings_category'))
        $forum_db->drop_field('o_ratings_category');
           
        if ($forum_db->table_exists('ratings'))
        $forum_db->drop_table('ratings');
    ]]></uninstall>

something like that then? replace categories with ratings in my case

29

Re: Rating Script Extension Code

o_ratings_category is an option, right?:

$query = array(
    'DELETE'    => 'config',
    'WHERE'        => 'conf_name in (\'o_ratings_category\')',
);
$forum_db->query_build($query) or error(__FILE__, __LINE__);

30 (edited by KeyDog 2009-01-04 21:04)

Re: Rating Script Extension Code

    <install>
     <![CDATA[
                // Adding SQL statement / creating table /installation code
            $schema = array(
                'FIELDS'        => array(
                        'id'            => array(
                        'datatype'        => 'SERIAL',
                        'allow_null'    => false
                    ),
                    'cat_name'        => array(
                        'datatype'        => 'VARCHAR(80)',
                        'allow_null'    => false,
                        'default'        => '\'o_ratings_category\''
                    ),
                    'disp_position'    => array(
                        'datatype'        => 'INT(10)',
                        'allow_null'    => false,
                        'default'        => '0'
                    )
                ),
                'PRIMARY KEY'    => array('id')
            );
            $forum_db->create_table('ratings', $schema);        
        ]]>  
    </install>

well that depends; I have PRIMARY KEY   ip , page      that need to be added
that is kind of my question, how to add those properly...

see in include/rate.php afterwards I use

function rate()
{
    $star_value = forum_htmlencode($_GET['r']);
    $page       = forum_htmlencode($_GET['p']);
    $ip         = $_SERVER['REMOTE_ADDR'];
   
    //Add to database
    $query = array(
        'INSERT'    => 'ip, rating, page',
        'INTO'        => DB_TABLE,
        'VALUES'    => $ip.', '.$star_value.', '.$page
    );
    $forum_db->query_build($query) or error(__FILE__, __LINE__);
    $ref = $_SERVER['HTTP_REFERER'];
    redirect($ref, 'Redirecting, Please wait &hellip;');
}

 

thats where I'm coming from....

EDIT: changed it to this now

        <install>
       <![CDATA[
                // Adding SQL statement / creating table /installation code
       if(!$forum_db->table_exists('ratings'))
       {
            $schema = array(
                'FIELDS'        => array(
                        'id'            => array(
                        'datatype'        => 'SERIAL',
                        'allow_null'    => false
                    ),
                    'cat_name'        => array(
                        'datatype'        => 'VARCHAR(80)',
                        'allow_null'    => false,
                        'default'        => '\'o_ratings_category\''
                    ),
                    'disp_position'    => array(
                        'datatype'        => 'INT(10)',
                        'allow_null'    => false,
                        'default'        => '0'
                    )
                ),
                'PRIMARY KEY'    => array('id')
            );
            $forum_db->create_table('ratings', $schema);
       }        
        ]]>  
    </install>
     <uninstall><![CDATA[
        // Uninstallation code
           $forum_db->query('DELETE FROM '.$forum_db->prefix.'config WHERE conf_name = "o_ratings_category");
        $forum_db->drop_table('ratings');
    ]]></uninstall>

but I need advice on how to get consistency between  manifest.xml and include/rate.php !

31

Re: Rating Script Extension Code

You should use the query builder for the uninstaller code... never use direct queries, there could be cross-database type issues.

You need this?

'ip' => array('datatype' => 'VARCHAR(15)', 'allow_null' => false)
'rating' => array('datatype' => 'TINYINT(1)', 'allow_null' => false)

32

Re: Rating Script Extension Code

yes that looks like what my install part of manifest.xml needs...
rating , page and ip i believe need to be in install part