In-My-Opinion.org

»PhpBB mod (freeware): Persistent Avatars + Avatar Toplist«







Yay!

My new mod is up. Download it at


What can it do? It is actually several mods in 1:
• Sticky avatars (= persistent avatar = AAA = Avatar Always Attached): If a user uploads an avatar then his/her old posts still show the old one as you can see in this thread: IMO → The Sticky Avatar Thread and Avatar Show-Off
• Users can rate avatars. Users can comment avatars. (Sign up as a user here at in-my-opinion.org and browse any thread to see how it works)
• A toplist of avatars is created showing user's comments and ratings. See demo at in-my-opinion.org… and at
• A new function will be added to your admin area: If an avatar has been uploaded twice (or more times) (by the same user or by different users) then you (as an admin) can unite them, so they get shown only 1 time in the toplist
• An overview of all avatars of your forum can be generated. See demo at in-my-opinion.org…



posted by knn

in-my-opinion.org -> Technology, Computers, Science, Internet -> Software by the admin -> phpBB mod (freeware): Persistent Avatars + Avatar Toplist

Avatar Suite problems



I cannot get my voting options to show up. It keeps saying "Did Any one vote yet?" not sure whats going on

posted by Brasdrake
  



And? Did anybody vote yet? If noone voted yet, then the toplist isn't generated

posted by knn
  

How would they vote?



there is no place to vote

posted by Brasdrake
  



The only two thing i see on my forum related to your Mod is the ACP Unite file and the "Top Avatars" option in the header. I tried to EASYMOD it but had a few difficulties. Had to rename the file admin_unite_double_avatars.php to admin_delete_double_avatars.php because that's the only way it would work. would this cause my problem?

posted by Brasdrake
  



Brasdrake:
there is no place to vote

If the mod is installed correctly then voting buttons should appear under each avatar in each thread.

Just like in this forum here.

There are already several forums that implemented this mod and already generated toplists.
Brasdrake:
Had to rename the file admin_unite_double_avatars.php to admin_delete_double_avatars.php because that's the only way it would work.

Oh, yeah. Thanks. That error only applied during installation. I have fixed it now.


posted by knn
  

Permissions?



Could my permissions be screwed up? Even as the Admin I cannot see the voting panel. where would I set this for your Mod?

posted by Brasdrake
  



Brasdrake:
Could my permissions be screwed up?

No has nothing to do with permissions.
Brasdrake:
Even as the Admin I cannot see the voting panel.

Voting panel? You mean the voting buttons.
Brasdrake:
where would I set this for your Mod?

To enable the voting buttons under each avatar you need to change viewtopic.php as written in the installation .txt file. But that should have been installed automatically since you used EasyMod.

Just check whether your viewtopic.php has the lines that are mentioned in the .txt file.


posted by knn
  



Yes the language is all there. I am confused as every why the buttons are not

posted by Brasdrake
  



Hmmm everything just magically appeared now, I set a few Forum permissions, not sure if that did it, oh well I am shutting up now US prisoner

posted by Brasdrake
  



Great modification. One thing I am trying to solve, I have the "Forum AI" bot installed and now it doesn't post/show and avatar for the bot? Are you familiar with that mod and what modification is needed to show the bot's avatar(s)?

Thanks

posted by LaZeR
  



LaZeR:
I have the "Forum AI" bot installed and now it doesn't post/show and avatar for the bot? Are you familiar with that mod

I am not familiar with that bot, but that "missing avatar phenomenon" usually happens if the mod uses its own routines to submit a post instead of phpbb's "function submit_post()".

This usually happens to circumvent one of phpbb's limitations: That a user cannot post something within seconds of another post (to fight accidental double-posts). But in case of bots this doesn't make sense.

To make missing avatars visible simply re-run (or run for the first time if you haven't run it yet) "avatarsuite_sql_installation.php"


posted by knn
  



Yea the problem is just with the bots routine. It is a seperate section added to functions_post which I need to figure out how to add something to make it act to post the avatar in the post field. I've played around with it with no luck yet. Any clues? Here is the snippet of code added for the bot:

//
// Post IAI's response to database
//
function iai_submit_post($mode, &$iai_id, &$forum_id, &$topic_id, &$iai_post_id, &$topic_type, $bbcode_on, $html_on, $smilies_on, $attach_sig, &$bbcode_uid, &$iai_username, &$iai_subject, &$iai_message)
{
    global
$board_config, $lang, $db, $phpbb_root_path, $phpEx;
        
    
//Stores user's IP since IAI has none. Can be changed as wished.
    
global $user_ip;

    
$current_time = time();

    
$sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, post_username, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig) VALUES ($topic_id, $forum_id, $iai_id, '$iai_username', $current_time, '$user_ip', $bbcode_on, $html_on, $smilies_on, $attach_sig)";
    if ( !(
$result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
    {
        
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }

    
$iai_post_id = $db->sql_nextid();

    
$sql = "INSERT INTO " . POSTS_TEXT_TABLE . " (post_id, post_subject, bbcode_uid, post_text) VALUES ($iai_post_id, '$iai_subject', '$bbcode_uid', '$iai_message')";
    if ( !(
$result = $db->sql_query($sql)) )
    {
        
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }

    
add_search_words($iai_post_id, stripslashes($iai_message), stripslashes($iai_subject));

    return
false;
}
//
// Update Stats for IAI: must be run AFTER update_post_stats() for original post
//
function iai_update_post_stats(&$forum_id, &$topic_id, &$iai_post_id, &$iai_id)
{
    global
$db;

    
//This simply runs the 3 db updating functions (only used for IAI replies).

    
$sql = "UPDATE " . FORUMS_TABLE . "
        SET forum_posts = forum_posts + 1, forum_last_post_id = $iai_post_id
        WHERE forum_id = $forum_id"
;
    if ( !(
$result = $db->sql_query($sql)) )
    {
        
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }

    
$sql = "UPDATE " . TOPICS_TABLE . "
        SET topic_last_post_id = $iai_post_id, topic_replies = topic_replies + 1
        WHERE topic_id = $topic_id"
;
    if ( !(
$result = $db->sql_query($sql)) )
    {
        
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }

    
// Comment out the next 7 lines if you don't want user posts to be updated (it will annoy some users otherwise).
    
$sql = "UPDATE " . USERS_TABLE . "
        SET user_posts = user_posts + 1
        WHERE user_id = $iai_id"
;
    if ( !(
$result = $db->sql_query($sql, END_TRANSACTION)) )
    {
        
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }

    return;
}
//
// Allows bot to send pms requiring only subject, message and user_id of user it is being sent to.
// I've made it an easy to use function so you can adapt it to use in many situations on your site
// an example is in the welcome message system which is included with this package. The function
// also sends emails (if $send_email set) and does all the inbox checking stuff that normal pms do.
//
function iai_send_pm($user_to_id, $iai_subject, $iai_message, $send_email)
{
    global
$board_config, $lang, $db, $phpbb_root_path, $phpEx;

    
$sql = "SELECT *
        FROM "
. USERS_TABLE . "
        WHERE user_id = "
. $user_to_id . "
        AND user_id <> "
. ANONYMOUS;
    if ( !(
$result = $db->sql_query($sql)) )
    {
        
message_die(GENERAL_ERROR, 'Tried obtaining data for a non-existent user', '', __LINE__, __FILE__, $sql);
    }
    
$usertodata = $db->sql_fetchrow($result);

    
// prepare IAI message (IAI may have used html, smilies etc...)
    
$bbcode_uid = make_bbcode_uid();
    
$iai_message = str_replace("'", "''", $iai_message);

    
// This is to fix up some of the bad formatting which comes out of the AI
    
if(empty($iai_message))
    {
        
$iai_message = "Thank you.";
    }
    
$iai_message = prepare_message(trim($iai_message), 0, 1, 1, $bbcode_uid);

    
$msg_time = time();

    
// Do inbox limit stuff
    
$sql = "SELECT COUNT(privmsgs_id) AS inbox_items, MIN(privmsgs_date) AS oldest_post_time
        FROM "
. PRIVMSGS_TABLE . "
        WHERE ( privmsgs_type = "
. PRIVMSGS_NEW_MAIL . "
            OR privmsgs_type = "
. PRIVMSGS_READ_MAIL . "  
            OR privmsgs_type = "
. PRIVMSGS_UNREAD_MAIL . " )
            AND privmsgs_to_userid = "
. $usertodata['user_id'];
    if ( !(
$result = $db->sql_query($sql)) )
    {
        
message_die(GENERAL_MESSAGE, $lang['No_such_user']);
    }

    
$sql_priority = ( SQL_LAYER == 'mysql' ) ? 'LOW_PRIORITY' : '';

    if (
$inbox_info = $db->sql_fetchrow($result) )
    {
        if (
$inbox_info['inbox_items'] >= $board_config['max_inbox_privmsgs'] )
        {
            
$sql = "DELETE $sql_priority FROM " . PRIVMSGS_TABLE . "
                WHERE ( privmsgs_type = "
. PRIVMSGS_NEW_MAIL . "
                    OR privmsgs_type = "
. PRIVMSGS_READ_MAIL . "
                    OR privmsgs_type = "
. PRIVMSGS_UNREAD_MAIL . "  )
                    AND privmsgs_date = "
. $inbox_info['oldest_post_time'] . "
                    AND privmsgs_to_userid = "
. $usertodata['user_id'];
            if ( !
$db->sql_query($sql) )
            {
                
message_die(GENERAL_ERROR, 'Could not delete your oldest privmsgs', '', __LINE__, __FILE__, $sql);
            }
        }
    }

    
$sql_info = "INSERT INTO " . PRIVMSGS_TABLE . " (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_ip, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig)
        VALUES ("
. PRIVMSGS_NEW_MAIL . ", '" . str_replace("\'", "''", $iai_subject) . "', " . $board_config['iai_userid'] . ", " . $usertodata['user_id'] . ", $msg_time, '$user_ip', 0, 1, 1, 1)";

    if ( !(
$result = $db->sql_query($sql_info, BEGIN_TRANSACTION)) )
    {
        
message_die(GENERAL_ERROR, "Could not insert private message sent info.", "", __LINE__, __FILE__, $sql_info);
    }

    
$privmsg_sent_id = $db->sql_nextid();

    
$sql = "INSERT INTO " . PRIVMSGS_TEXT_TABLE . " (privmsgs_text_id, privmsgs_bbcode_uid, privmsgs_text)
        VALUES ($privmsg_sent_id, '"
. $bbcode_uid . "', '" . str_replace("\'", "''", $iai_message) . "')";

    if ( !
$db->sql_query($sql, END_TRANSACTION) )
    {
        
message_die(GENERAL_ERROR, "Could not insert/update private message sent text.", "", __LINE__, __FILE__, $sql_info);
    }

    
// Add to the users new pm counter
    
$sql = "UPDATE " . USERS_TABLE . "
        SET user_new_privmsg = user_new_privmsg + 1, user_last_privmsg = "
. time() . "  
        WHERE user_id = "
. $usertodata['user_id'];
    if ( !
$status = $db->sql_query($sql) )
    {
        
message_die(GENERAL_ERROR, 'Could not update private message new/read status for user', '', __LINE__, __FILE__, $sql);
    }

    
// now send email if all the usual conditions & $send_email is set
    
if ( $send_email && $usertodata['user_notify_pm'] && !empty($usertodata['user_email']) && $usertodata['user_active'] )
    {
        
$email_headers = 'From: ' . $board_config['board_email'] . "\nReturn-Path: " . $board_config['board_email'] . "\r\n";

        
$script_name = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path']));
        
$script_name = ( $script_name != '' ) ? $script_name . '/privmsg.'.$phpEx : 'privmsg.'.$phpEx;
        
$server_name = trim($board_config['server_name']);
        
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
        
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';

        include(
$phpbb_root_path . 'includes/emailer.'.$phpEx);
        
$emailer = new emailer($board_config['smtp_delivery']);
            
        
$emailer->use_template('privmsg_notify', $usertodata['user_lang']);
        
$emailer->extra_headers($email_headers);
        
$emailer->email_address($usertodata['user_email']);
        
$emailer->set_subject(); //$lang['Notification_subject']
            
        
$emailer->assign_vars(array(
            
'USERNAME' => $usertodata['username'],
            
'SITENAME' => $board_config['sitename'],
            
'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . $board_config['board_email_sig']),

            
'U_INBOX' => $server_protocol . $server_name . $server_port . $script_name . '?folder=inbox')
        );

        
$emailer->send();
        
$emailer->reset();
    }

    return;




posted by LaZeR
  



You would have to replace the content of "function iai_submit_post()" by a call to "submit_post()" and then edit "function submit_post()" to override the "Flood control" for the user IAI.

posted by knn
  



White laugh Cool I think I have it with this bit I made Thumb Up

//BEGIN MY EDIT TO ADD BOT STICKY AVATAR

    
$sql = "SELECT user_avatar
        FROM "
. USERS_TABLE . "
        WHERE user_id = "
. $iai_id . "
        AND user_id <> "
. ANONYMOUS;
    if ( !(
$result = $db->sql_query($sql)) )
    {
        
message_die(GENERAL_ERROR, 'Tried obtaining data for a non-existent user', '', __LINE__, __FILE__, $sql);
    }

    if (
$row = $db->sql_fetchrow($result))
    {
        
$iai_avatar = $row['user_avatar'];
    }

    
$sql =     ' UPDATE '.POSTS_TABLE.'
         SET user_avatar = "'
.$iai_avatar.'",'.'    user_avatar_type = "1"'.'
         WHERE post_id = "'
.$iai_post_id.'"'.'';
    if ( !(
$result = $db->sql_query($sql, END_TRANSACTION)) )
    {
        
message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
    }

//END MY EDIT TO ADD BOT STICKY AVATAR




posted by LaZeR
  



Goto page
1, 2, 3, 4, 5, 6  Next

Reply to topic
Goto page
1, 2, 3, 4, 5, 6  Next






RegisterRegister
Log inLog in
The time now is 22 August 2008, 04:20
php B.B.