Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Catalog System
Author Message
TomNook08
Member


Posts: 52
Joined: Mar 2009
Reputation: 0
MyBux: 0
Post: #21
RE: Catalog System
Ok Will do. Thanks for helping me :D

By the way I have been looking at some more advanced PHP tutorials which have been helping me also

I'm an Animal Crossing Fanatic!!!
(Nintendo's Famous Game)
03-13-2009 11:30 PM
Nickman
Manager



Posts: 1,449
Joined: May 2008
Reputation: 30
MyBux: 62
Post: #22
RE: Catalog System
Nice



Playstation Forums | Hoodrat Arcade | Tech news at a glance | BestVidz.net | AdminSpace: Where admins talk | Download'en
03-14-2009 02:11 AM


TomNook08
Member


Posts: 52
Joined: Mar 2009
Reputation: 0
MyBux: 0
Post: #23
RE: Catalog System
New Problem!
When you click deactivate it doesn't remove anything from the MySQL DB and it doesn't remove the templates from MYBB and it keeps showing deactivate instead of activate...

Here is my current code:
PHP Code:
<?php
/**
 *    Plugin Copyright
 *    TomNook08 of MyBBSource  
 */

if(!defined("IN_MYBB")) {
    die(
"This file cannot be accessed directly.");
}
//Add Your Hooks
$plugins->add_hook("member_profile_end""catalog");

//REQUIRED
function catalog_info()
{
    return array(
        
'name'            => 'Catalog',
        
'description'    => 'Adds Items from the Animal Crossing games to the users profile.',
        
'website'        => 'http://www.mybbsource.com',
        
'author'        => 'TomNook08',
        
'authorsite'    => 'mailto:[email protected]',
        
'version'        => 'Beta 1',
        
'guid'             => '',
        
'compatibility'     =>    '1404',

    );
}

function 
catalog_activate() {
   global 
$db;
       
    
$catalog_group = array(
        
'gid'            => 0,
        
'name'            => 'catalogadmin',
        
'title'            => 'Catalog Admin',
        
'description'    => 'Settings For The Catalog System.',
        
'disporder'        => $rows+1,
        
'isdefault'        => '0',
    );

    
$db->insert_query('settinggroups'$catalog_group);
    
$gid $db->insert_id();

    
$catalog_setting_1 = array(
        
'sid'            => '0',
        
'name'            => 'enablecatalog',
        
'title'            => 'Enable Catalog System?',
        
'description'    => 'If set to off, no one will get a catalog',
        
'optionscode'    => 'onoff',
        
'value'            => 'on',
        
'disporder'        => 0,
        
'gid'            => intval($gid),
    );

    
$catalog_setting_2 = array(
        
'sid'            => '0',
        
'name'            => 'showwhichgames',
        
'title'            => 'Show Which Game',
        
'description'    => 'Set to 1 to show only ACGC items, 2 to show only ACWW items, 3 to show ACCF/LGTTC items, or 0 for all 3 games',
        
'optionscode'    => 'text',
        
'value'            => '0',
        
'disporder'        => 1,
        
'gid'            => intval($gid),
    );
    
$catalog_setting_3 = array(

        
'sid'            => '0',
        
'name'            => 'adminitems',
        
'title'            => 'Admin Remove Items?',
        
'description'    => 'Do you want admins to be able to remove items?',
        
'optionscode'    => 'onoff',
        
'value'            => 'off',
        
'disporder'        => 2,
        
'gid'            => intval($gid),
    );
    
$db->query("CREATE TABLE `".TABLE_PREFIX."catalog` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`memberid` INT NOT NULL)"
);
    
$db->insert_query('settings'$catalog_setting_1);
    
$db->insert_query('settings'$catalog_setting_2);
    
$db->insert_query('settings'$catalog_setting_3);
    require 
MYBB_ROOT."/inc/adminfunctions_templates.php";
    
find_replace_templatesets("member_profile"'#{\$signature}#'"{\$signature}\n{\$member_catalog}");
    
$template = array(
        
"title"        => "member_catalog",
        
"template"    => "<head>
<title>{\$mybb->settings[\'bbname\']} - Catalog</title>
{\$headerinclude}
</head>
<body>
    {\$header}
    <table border=\"0\" cellspacing=\"{\$theme[\'borderwidth\']}\" cellpadding=\"{\$theme[\'tablespace\']}\" class=\"tborder\" style=\"clear: both;\">
        <tr>
            <td class=\"thead\"><strong>My Catalog</strong></td>
        </tr>
        <tr>
            <td class=\"trow1\">{\$catalog}</td>
        </tr>
    </table>
    {\$footer}
</body>
</html>
"
,
        
"sid"        => -1
    
);
    
$db->insert_query("templates"$template);
//stuff to do on activation of the plugin
}
function 
catalog_deactivate()
{
global 
$db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='catalogadmin'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN(
        'enablecatalog',
        'showwhichgames',
        'adminitems',
    )"
);
    
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='member_catalog'");
    
$db->query("DROP TABLE ".TABLE_PREFIX."member_catalog");
    require 
MYBB_ROOT."/inc/adminfunctions_templates.php";
    
find_replace_templatesets("member_profile"'#{\$member_catalog}(\r?)(\n?)#'''0);
}

function 
catalog() {
    global 
$memprofile,$mybb,$theme,$db,$templates,$catalog;
        
$enable=$mybb->settings['enablecatalog'];
    if (
$enable != 'on')
    {
        return;
    }
}
//DO SOMETHING WHEN THE HOOK IS CALLED
?>

I'm an Animal Crossing Fanatic!!!
(Nintendo's Famous Game)
03-14-2009 03:11 AM
Nickman
Manager



Posts: 1,449
Joined: May 2008
Reputation: 30
MyBux: 62
Post: #24
RE: Catalog System
Ok, well I don't know the exact problem, but I'm gonna point out some issues with the code...

PHP Code:
function catalog_info()
{
    return array(
        
'name'            => 'Catalog',
        
'description'    => 'Adds Items from the Animal Crossing games to the users profile.',
        
'website'        => 'http://www.mybbsource.com',
        
'author'        => 'TomNook08',
        
'authorsite'    => 'mailto:[email protected]',
        
'version'        => 'Beta 1',
        
'guid'             => '',
        
'compatibility'     =>    '1404',

    );
}

function 
catalog_activate() {
   global 
$db;
       
    
$catalog_group = array(
        
'gid'            => 0,
        
'name'            => 'catalogadmin',
        
'title'            => 'Catalog Admin',
        
'description'    => 'Settings For The Catalog System.',
        
'disporder'        => $rows+1,
        
'isdefault'        => '0',
    ); 

Where is $rows being set?
PHP Code:
    $catalog_setting_3 = array(

        
'sid'            => '0',
        
'name'            => 'adminitems',
        
'title'            => 'Admin Remove Items?',
        
'description'    => 'Do you want admins to be able to remove items?',
        
'optionscode'    => 'onoff',
        
'value'            => 'off',
        
'disporder'        => 2,
        
'gid'            => intval($gid),
    ); 
On and off, and yes and no both use 1 and 0's. So yes = 1, no=0, on=1,off=0.
PHP Code:
    function catalog_deactivate()
{
global 
$db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='catalogadmin'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN(
        'enablecatalog',
        'showwhichgames',
        'adminitems',
    )"
); 

You have an extra comma after adminitems.

PHP Code:
function catalog() {
    global 
$memprofile,$mybb,$theme,$db,$templates,$catalog;
        
$enable=$mybb->settings['enablecatalog'];
    if (
$enable != 'on')
    {
        return;
    }
}
//DO SOMETHING WHEN THE HOOK IS CALLED
?>

Again, the settings are 1,0. So it should be
PHP Code:
if ($enable != 0



Playstation Forums | Hoodrat Arcade | Tech news at a glance | BestVidz.net | AdminSpace: Where admins talk | Download'en
03-14-2009 04:21 AM


TomNook08
Member


Posts: 52
Joined: Mar 2009
Reputation: 0
MyBux: 0
Post: #25
RE: Catalog System
Oh I see :) and for some reason I can't remember PHP codes as well as HTML :P
By the way I can't figure out how come it isn't showing a new table in the profile... I use this hook

Code:
member_profile_end
Shouldn't that make a new table?

Also:
I want the user to add items to their profile via a custom User CP page,..How would I create the custom User CP page

I'm an Animal Crossing Fanatic!!!
(Nintendo's Famous Game)
(This post was last modified: 03-14-2009 05:17 AM by TomNook08.)
03-14-2009 04:39 AM
 




New to MyBBSource?Need Assistance?
  • Mark Forums Read
  • View Forum Staff
  • Looking for a MyBB Host?

  



Theme created by AK-47. Find more great themes and skins at K! Dezign R1s.net