https://www.icyphoenix.com/viewtopic.php?f=26&t=1489
-----------------------------------
lefty74
Mon 02 Apr, 2007 19:33

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 linenumbers=false]#
#-----[ 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 ]------------------------------------------
[/code]


-----------------------------------
Artie
Wed 04 Apr, 2007 03:43

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:


