+ User* target = ServerInstance->FindNick(parameters[0]);
+
+ /* Do local sanity checks and bails */
+ if (IS_LOCAL(user))
+ {
+ if (target && target->server->IsULine())
+ {
+ user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a U-lined client");
+ return CMD_FAILURE;
+ }
+
+ if ((!target) || (target->registered != REG_ALL))
+ {
+ user->WriteNotice("*** No such nickname: '" + parameters[0] + "'");
+ return CMD_FAILURE;
+ }
+
+ if (!ServerInstance->IsNick(parameters[1]))
+ {
+ user->WriteNotice("*** Invalid nickname: '" + parameters[1] + "'");
+ return CMD_FAILURE;
+ }
+ }
+
+ /* Have we hit target's server yet? */
+ if (target && IS_LOCAL(target))
+ {
+ std::string oldnick = user->nick;
+ std::string newnick = target->nick;
+ if (target->ChangeNick(parameters[1]))
+ {
+ ServerInstance->SNO->WriteGlobalSno('a', oldnick+" used SANICK to change "+newnick+" to "+parameters[1]);
+ }
+ else
+ {
+ ServerInstance->SNO->WriteGlobalSno('a', oldnick+" failed SANICK (from "+newnick+" to "+parameters[1]+")");
+ }
+ }
+
+ return CMD_SUCCESS;