Plugin dodający pola do member_profile oraz postbit

PHP/MYSQL  Założony przez  Nexack.

Witam. Napisałem plugin dodający pewne pola do member_profile oraz postbit.

Oto kod:

<?php
if(!defined("IN_MYBB"))
    die(
"This file cannot be accessed directly.");
$plugins->add_hook("member_profile_end""kariera_profile");
$plugins->add_hook("postbit""kariera_postbit");
function 
kariera_info()
{
    return array(
                
'name'                  => 'Kariera Zawodnika',
                
'description'   => 'Kariera zawodnika.',
                
'website'               => 'http://haxball-manager.pl/',
                
'author'                => 'Nexack',
                
'authorsite'    => 'http://haxball-manager.pl/',
                
'version'               => '1.0.0',
                
'guid'                  => '',
                
'compatibility' => '16*'
    
);
}
function 
kariera_install()
{
global 
$db;
    
$posta '<br /><span class="smalltext">Obecny Klub: {$klub}</span>';
    
$profila '<tr><td class="trow2"><strong>Obecny Klub:</strong></td><td class="trow2">{$klub}</td></tr>';

$db->query("INSERT INTO ".TABLE_PREFIX."templates (`title`, `template`, `sid`) VALUES ('profile_kariera', '$profila', '-1');");
$db->query("INSERT INTO ".TABLE_PREFIX."templates (`title`, `template`, `sid`) VALUES ('postbit_kariera', '$posta', '-1');");
}
function 
kariera_uninstall()
{
global 
$db;
    
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='profile_kariera'");
    
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='postbit_kariera'");
}
function 
kariera_deactivate()
{
    global 
$db;
    
$posta '';
    
$profila '';
    
$db->query("INSERT INTO ".TABLE_PREFIX."templates (`title`, `template`, `sid`) VALUES ('profile_kariera', '$profila', '-1');");
    
$db->query("INSERT INTO ".TABLE_PREFIX."templates (`title`, `template`, `sid`) VALUES ('postbit_kariera', '$posta', '-1');");    
}
function 
kariera_activate(){
global 
$db;
    
$posta '<br /><span class="smalltext">Obecny Klub: {$klub}</span>';
    
$profila '<tr><td class="trow2"><strong>Obecny Klub:</strong></td><td class="trow2">{$klub}</td></tr>';
    
$db->query("INSERT INTO ".TABLE_PREFIX."templates (`title`, `template`, `sid`) VALUES ('profile_kariera', '$profila', '-1');");
    
$db->query("INSERT INTO ".TABLE_PREFIX."templates (`title`, `template`, `sid`) VALUES ('postbit_kariera', '$posta', '-1');");
}
function 
kariera_is_installed()
{
    global 
$db;
    
$ch $db->query("SELECT * FROM ".TABLE_PREFIX."templates WHERE title='profile_kariera'");
    
$hc $db->query("SELECT * FROM ".TABLE_PREFIX."templates WHERE title='postbit_kariera'");
    
$ch2 $db->fetch_array($ch);
    
$hc2 $db->fetch_array($hc);
    if(
$ch2['title'] != NULL&&$hc2['title'] != NULL) {
    return 
true;
    }
    else
    {
    return 
false;
    }

}
function 
kariera_profile(){
        global 
$db$klub$templates$memprofile;
        
$klub $memprofile['klub'];
        eval(
"\kariera_profile = \"".$templates->get('kariera_profile')."\";");
    }
    
    
function 
kariera_postbit(&$post)
    {
        global 
$mybb$db$klub$templates$uid;
        
$klub $post['klub'];
        eval(
"\$post['kariera_postbit'] = \"".$templates->get('kariera_postbit')."\";");
    }


?>

Po czym w member_profile dodaje {$profile_kariera)

Jednakże nie wyświetla rekordu z bazy danych. Coś jest tutaj źle? Jest to mój 3 plugin pod MyBB (a pierwszy z dodawaniem pól). Wzorowałem się na pluginie newpoints.
1. Po co dwa razy robisz te same operacje? :) Skoro wrzucasz szablony do bazy, to zrezygnuj z instalacji, lub aktywacji. Nie ma sensu powielać w nich tych samych miejscach.

2. Gdzie masz dodane to pole "klub"? Czy ono na pewno znajduje się w tabeli users? W pluginie nie widać jego dodawania.
Tak, w tabeli users znajduje się pole klub


---
Zauważyłem, że jak dodam ręcznie szablon w szablonach globalnych to i tak nie mogę go wczytać do member_profile.
Np. tworzę szablon "szablon_test" o przykładowej treści "test".
Wpisuję w member_profile: {$szablon_test}, jednakże nie wyświetla jego. ;F
Spójrz na swoje $templates->get.
Takie małe przeoczenie :<

Dzięki Wam za pomoc, już działa ;)



Użytkownicy przeglądający ten wątek:

1 gości