Author Topic: [SOLVED] Item Request: Change another user's display name  (Read 6379 times)

Offline Lew_Cipher

[SOLVED] Item Request: Change another user's display name
« on: March 14, 2007, 07:04:14 am »
I'd like to request an item that would allow a member to change another user's display name (much like the item that allows you to change a title).


Offline feeble

Re: Item Request: Change another user's display name
« Reply #1 on: March 14, 2007, 07:56:45 am »
should be easy enough to other the  Change Other's Title item.

have you thought about trying this one your self?

would be a cool way to learn a little php? and mysql?

Offline Lew_Cipher

Re: Item Request: Change another user's display name
« Reply #2 on: March 14, 2007, 10:33:50 am »
should be easy enough to other the  Change Other's Title item.

have you thought about trying this one your self?

would be a cool way to learn a little php? and mysql?

I've actually considered trying this one but I'm so afraid of screwing up my board. I considered setting up a dummy board for trying. Really,
my biggest deterrent is that my board is just a hobby and I have an outdoors job so I can't play around to learn in my spare time at work. Plus 3 kids... My time is sooo limited.


Offline feeble

Re: Item Request: Change another user's display name
« Reply #3 on: March 14, 2007, 02:58:47 pm »
lol i hear you, not enough time in the day

php can be a hobby but, and yeah you could setup a dummy board. always good practice.

if you decide to have a go and get stuck, feel free to ask any questions.

Offline Max

Re: Item Request: Change another user's display name
« Reply #4 on: March 16, 2007, 09:37:31 am »

Its not that hard really, with a bit of sql knowledge...

Alto the "Find Member" option dosent work, it will pop up the window but it dosent save the name in the User's name input box!  :-\

Code: [Select]
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007)                          $ *
* $Id:: ChangeOtherTitle.php 79 2007-01-18 08:26:55Z daniel15                   $ *
* Software by:                DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by:     DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at:  http://www.dansoftaustralia.net/                    *
*                                                                                 *
* Forum software by:          Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version of the license can always be found at                        *
* http://www.simplemachines.org.                                                  *
**********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');

class 
item_ChangeOtherDisplayName extends itemTemplate
{
function getItemDetails()
{
$this->authorName 'Max';
$this->authorWeb 'http://TheGaff.net/Forums';
$this->authorEmail ='webmaster@thegaff.net';

$this->name 'Change Other Member\'s Display Name';
$this->desc 'Change someone else\'s Display Name';
$this->price 300;

$this->require_input true;
$this->can_use_item true;
}

function getUseInput()
{
global $context$scripturl$settings$txt;
return 'User\'s name: <input type="text" name="username" size="50" />
<a href="' 
$scripturl '?action=findmember;input=username;quote=0;sesc=' $context['session_id'] . '" onclick="return reqWin(this.href, 350, 400);"><img src="' $settings['images_url'] . '/icons/assist.gif" border="0" alt="' $txt['find_members'] . '" /> Find Member</a><br />
New Display Name: <input type="text" name="newdisplayname" size="50" />'
;
}

function onUse()
{
global $db_prefix;

if (!isset($_POST['username']))
die('ERROR: Please enter a username!');
if (!isset($_POST['newdisplayname']))
die('ERROR: Please enter a new display name!');

// This code from PersonalMessage.php5. It trims the " characters off the membername posted, 
// and then puts all names into an array
$_POST['username'] = strtr($_POST['username'], array('\\"' => '"'));
preg_match_all('~"([^"]+)"~'$_POST['username'], $matches);
$userArray array_unique(array_merge($matches[1], explode(','preg_replace('~"([^"]+)"~'''$_POST['username']))));

// We only want the first memberName found
$user $userArray[0];

$result db_query("
UPDATE 
{$db_prefix}members
SET realName = '
{$_POST['newdisplayname']}'
WHERE memberName = '
$user'"__FILE____LINE__);
return 'Successfully changed ' $user '\'s Personal name to ' $_POST['newdisplayname'];
}

}

?>

Offline Lew_Cipher

Re: Item Request: Change another user's display name
« Reply #5 on: March 16, 2007, 11:10:59 am »

Its not that hard really, with a bit of sql knowledge...

Alto the "Find Member" option dosent work, it will pop up the window but it dosent save the name in the User's name input box!  :-\

Code: [Select]
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007)                          $ *
* $Id:: ChangeOtherTitle.php 79 2007-01-18 08:26:55Z daniel15                   $ *
* Software by:                DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by:     DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at:  http://www.dansoftaustralia.net/                    *
*                                                                                 *
* Forum software by:          Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version of the license can always be found at                        *
* http://www.simplemachines.org.                                                  *
**********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');

class 
item_ChangeOtherDisplayName extends itemTemplate
{
function getItemDetails()
{
$this->authorName 'Max';
$this->authorWeb 'http://TheGaff.net/Forums';
$this->authorEmail ='webmaster@thegaff.net';

$this->name 'Change Other Member\'s Display Name';
$this->desc 'Change someone else\'s Display Name';
$this->price 300;

$this->require_input true;
$this->can_use_item true;
}

function getUseInput()
{
global $context$scripturl$settings$txt;
return 'User\'s name: <input type="text" name="username" size="50" />
<a href="' 
$scripturl '?action=findmember;input=username;quote=0;sesc=' $context['session_id'] . '" onclick="return reqWin(this.href, 350, 400);"><img src="' $settings['images_url'] . '/icons/assist.gif" border="0" alt="' $txt['find_members'] . '" /> Find Member</a><br />
New Display Name: <input type="text" name="newdisplayname" size="50" />'
;
}

function onUse()
{
global $db_prefix;

if (!isset($_POST['username']))
die('ERROR: Please enter a username!');
if (!isset($_POST['newdisplayname']))
die('ERROR: Please enter a new display name!');

// This code from PersonalMessage.php5. It trims the " characters off the membername posted, 
// and then puts all names into an array
$_POST['username'] = strtr($_POST['username'], array('\\"' => '"'));
preg_match_all('~"([^"]+)"~'$_POST['username'], $matches);
$userArray array_unique(array_merge($matches[1], explode(','preg_replace('~"([^"]+)"~'''$_POST['username']))));

// We only want the first memberName found
$user $userArray[0];

$result db_query("
UPDATE 
{$db_prefix}members
SET realName = '
{$_POST['newdisplayname']}'
WHERE memberName = '
$user'"__FILE____LINE__);
return 'Successfully changed ' $user '\'s Personal name to ' $_POST['newdisplayname'];
}

}

?>


Thanks! I uploaded it to my items folder, set permissions to 755 and tried to make an item in the Shop admin. I got this error on the Sop admin page where you create & customize your items (the one with the drop down menu).

ERROR: Could not create instance of 'ChangeOthersDisplayName' item!

Any ideas?


EDIT: Nothing in the board's error log on this.
« Last Edit: March 16, 2007, 11:39:08 am by Lew_Cipher »

Offline Max

Re: Item Request: Change another user's display name
« Reply #6 on: March 16, 2007, 11:51:03 am »
Hmmm it may not be named right?...

Do you have it named  "ChangeOtherMessage.php" in Sources\shop\items & permissions set to 755???

Offline xfollowthereaperx

Re: Item Request: Change another user's display name
« Reply #7 on: March 16, 2007, 02:17:51 pm »
I found an error, there might be others

Name it ChangeOtherMessage.php

Code: [Select]
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007)                          $ *
* $Id:: ChangeOtherTitle.php 79 2007-01-18 08:26:55Z daniel15                   $ *
* Software by:                DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by:     DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at:  http://www.dansoftaustralia.net/                    *
*                                                                                 *
* Forum software by:          Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version of the license can always be found at                        *
* http://www.simplemachines.org.                                                  *
**********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');

class 
item_ChangeOtherMessage extends itemTemplate
{
function getItemDetails()
{
$this->authorName 'Max';
$this->authorWeb 'http://TheGaff.net/Forums';
$this->authorEmail ='webmaster@thegaff.net';

$this->name 'Change Other Member\'s Display Name';
$this->desc 'Change someone else\'s Display Name';
$this->price 300;

$this->require_input true;
$this->can_use_item true;
}

function getUseInput()
{
global $context$scripturl$settings$txt;
return 'User\'s name: <input type="text" name="username" size="50" />
<a href="' 
$scripturl '?action=findmember;input=username;quote=0;sesc=' $context['session_id'] . '" onclick="return reqWin(this.href, 350, 400);"><img src="' $settings['images_url'] . '/icons/assist.gif" border="0" alt="' $txt['find_members'] . '" /> Find Member</a><br />
New Display Name: <input type="text" name="newdisplayname" size="50" />'
;
}

function onUse()
{
global $db_prefix;

if (!isset($_POST['username']))
die('ERROR: Please enter a username!');
if (!isset($_POST['newdisplayname']))
die('ERROR: Please enter a new display name!');

// This code from PersonalMessage.php5. It trims the " characters off the membername posted, 
// and then puts all names into an array
$_POST['username'] = strtr($_POST['username'], array('\\"' => '"'));
preg_match_all('~"([^"]+)"~'$_POST['username'], $matches);
$userArray array_unique(array_merge($matches[1], explode(','preg_replace('~"([^"]+)"~'''$_POST['username']))));

// We only want the first memberName found
$user $userArray[0];

$result db_query("
UPDATE 
{$db_prefix}members
SET realName = '
{$_POST['newdisplayname']}'
WHERE memberName = '
$user'"__FILE____LINE__);
return 'Successfully changed ' $user '\'s Personal name to ' $_POST['newdisplayname'];
}

}

?>

Offline Lew_Cipher

Re: Item Request: Change another user's display name
« Reply #8 on: March 17, 2007, 07:12:46 am »
It works!!!!!! 

Thank you!!!!!


If I can ever do anything for you, lemme know!!

Thank you again!


Offline dry3210

Re: [SOLVED] Item Request: Change another user's display name
« Reply #9 on: October 25, 2007, 08:30:00 am »
Any ideas how to get the "search member" thing to work right?
« Last Edit: October 25, 2007, 11:27:48 am by dry3210 »

Offline Daethian

Re: [SOLVED] Item Request: Change another user's display name
« Reply #10 on: January 06, 2009, 10:44:45 am »
How do you add this as a new item? It doesn't show in the pull down box after I placed the file on the server.