FAP CUSTOMIZATION - Update pic_username when a user changes username


Subject: FAP CUSTOMIZATION - Update pic_username when a user changes username
I don't know whether it was intended to be like this but whenever a user changes his/her username, the pic_username of all their picture prior to the name change stays the same, i.e. when you do a search in the album on the username, it may not find all the pictures of that user... (Anyone know where else pic_username is used other then search?)

I did the following to update the pic_username whenever the user changes their username or an admin does...

It seems to be working but grateful if the more advanced coders could cast an eye over this :)

Cheers


Code: [Download] [Hide] [Select]
#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_register.php
#
#-----[ FIND ]------------------------------------------
#
// We remove all stored login keys since the password has been updated
// and change the current one (if applicable)
if ( !empty($passwd_sql) )
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$sql = "UPDATE " . ALBUM_TABLE . "
SET pic_username = '" . str_replace("'", "''", $username) . "'
WHERE " . ALBUM_TABLE . ".pic_user_id = $user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update album table', '', __LINE__, __FILE__, $sql);
}

#
#-----[ OPEN ]------------------------------------------
#
admin/admin_users.php
#
#-----[ FIND ]------------------------------------------
#
//
// Update entry in DB
//
if( !$error )
{

#
#-----[ AFTER, ADD ]------------------------------------------
#
$sql = "UPDATE " . ALBUM_TABLE . "
SET pic_username = '" . str_replace("'", "''", $username) . "'
WHERE " . ALBUM_TABLE . ".pic_user_id = $user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update album table', '', __LINE__, __FILE__, $sql);
}

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------

Profile PM  
Subject: Re: Update pic_username when a user changes username
Actually, I would have thought that pic_username would only be used for guests ... same as post_username is used.
Evidently that is not the case, but perhaps it needs to be :roll:

Profile PM  

Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Generation Time: 0.2407s (PHP: 7% SQL: 93%)
SQL queries: 12 - Debug Off - GZIP Enabled