![Very Happy :D](./images/smilies/icon_biggrin.gif)
![Very Happy :D](./images/smilies/icon_biggrin.gif)
And sometimes there are a few people who would go on being highly inventive and take bad/improper nick.
so I wrote this small command that the admin can use to force a nick name change.
The command goes like this: /forcenick old_badnick new_freshnick
Hope it helps and feel free to tailor it to your needs.
- Code: Select all
<?php
//FileName: forcenick.class.php
//- - - - - - - - - - - - -
//Desc: Changes the nick of an user. Can be used by an Admin only.
//Author: Shah Chandon
//Date: Jul 2009
//-------------------------------------------------------------------------------
require_once(dirname(__FILE__)."/../pfccommand.class.php");
class pfcCommand_forcenick extends pfcCommand
{
var $usage = "/forcenick {old_nickname} {new_nickname}";
function run(&$xml_reponse, $p)
{
$clientid = $p["clientid"];
$param = $p["param"];
$params = $p["params"];
$sender = $p["sender"];
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();
$ct =& pfcContainer::Instance();
$oldnick = isset($params[0]) ? $params[0] : '';
$newnick = isset($params[1]) ? $params[1] : '';
$admin_nick = $ct->getNickname($u->nickid);
$isadmin = $ct->getUserMeta($u->nickid, 'isadmin');
if (!$isadmin)
{
$cmdp = $p;
$cmdp["param"] = _pfc("Must be an Admin");
$cmd =& pfcCommand::Factory("error");
$cmd->run($xml_reponse, $cmdp);
return;
}
$oldnickid = $ct->getNickId($oldnick);
$targetisadmin = $ct->getUserMeta($oldnickid, 'isadmin');
if($targetisadmin)
{
//cannot kick and admin -- error
$cmdp = $p;
$cmdp["param"] = _pfc("Cannot change an ADMIN");
$cmdp["param"] .= " (Whats going on!! Why Are you trying to CHANGE an ADMIN NICK??!!)";
$cmd =& pfcCommand::Factory("error");
$cmd->run($xml_reponse, $cmdp);
return;
}
if ($newnick == '' || $oldnick== '')
{
// error
$cmdp = $p;
$cmdp["param"] = _pfc("Missing parameter");
$cmdp["param"] .= " (".$this->usage.")";
$cmd =& pfcCommand::Factory("error");
$cmd->run($xml_reponse, $cmdp);
return;
}
$cmdstr = 'nick';
$cmdp = array();
$cmdp['params'][] = $newnick;
$cmdp['param'] = $newnick;
$cmdp['forced']=$admin_nick;
//$cmdp['params'][] = ''; // blank password
pfcCommand::AppendCmdToPlay($oldnickid, $cmdstr, $cmdp);
}
}
?>