X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fmember%2Fwhat-nickname.php;h=1fa6fecb3fb021067b775587e521c5f1191feba5;hb=da3f62b080afe57e4817cc7bb8b366534503e479;hp=96df72550de1d131110fe80980629711184ddf1d;hpb=82cbb1b75e0091b6333fefd045903329b234b9fb;p=mailer.git diff --git a/inc/modules/member/what-nickname.php b/inc/modules/member/what-nickname.php index 96df72550d..1fa6fecb3f 100644 --- a/inc/modules/member/what-nickname.php +++ b/inc/modules/member/what-nickname.php @@ -17,7 +17,7 @@ * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * * Copyright (c) 2009 - 2011 by Mailer Developer Team * - * For more information visit: http://www.mxchange.org * + * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -46,7 +46,7 @@ if (!defined('__SECURITY')) { addYouAreHereLink('member', __FILE__); if ((!isExtensionActive('nickname')) && (!isAdmin())) { - displayMessage(generateExtensionInactiveNotInstalledMessage('nickname')); + displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=nickname%}'); return; } // END - if @@ -54,37 +54,51 @@ $isValid = false; if (isFormSent()) { // Nickname was submitted so let's check if it is not already in use - if (isPostRequestParameterSet('nickname')) { + if (isPostRequestElementSet('nickname')) { // Check if nickname is valid - if (preg_match('/[' . getConfig('nickname_pattern') . ']{' . getConfig('nickname_len') . ',}/', postRequestParameter('nickname'), $array)) { + if (preg_match('/[' . getConfig('nickname_pattern') . ']{' . getConfig('nickname_len') . ',}/', postRequestElement('nickname'), $array)) { // Entered nickname is valid? - $isValid = ($array[0] == postRequestParameter('nickname')); + $isValid = (($array[0] == postRequestElement('nickname')) && (isNicknameUsed(postRequestElement('nickname')))); } // END - if } // END - if } // END - if if ($isValid === true) { + // Nickname already in use which is the default + $content = '{--MEMBER_NICKNAME_ALREADY_IN_USE--}'; + // Look for nickname in database (we only need just one entry so don't worry about the "LIMIT 1" !) $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `nickname`='%s' AND `userid` != %s LIMIT 1", - array(postRequestParameter('nickname'), getMemberId()), __FILE__, __LINE__); + array(postRequestElement('nickname'), getMemberId()), __FILE__, __LINE__); + + // Is it not in use? if (SQL_HASZERONUMS($result)) { // Nickname not in use, so set it now SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `nickname`='%s' WHERE `userid`=%s LIMIT 1", - array(postRequestParameter('nickname'), getMemberId()), __FILE__, __LINE__); + array(postRequestElement('nickname'), getMemberId()), __FILE__, __LINE__); + + // Prepare array + $filterData = array( + 'history_subject' => 'NICKNAME_CHANGED', + 'history_userid' => getMemberId(), + 'history_value' => postRequestElement('nickname') + ); + + // Run filter chain + runFilterChain('add_history_entry', $filterData); + + // Change message $content = '{--MEMBER_NICKNAME_SAVED--}'; - } else { - // Free result - SQL_FREERESULT($result); + } // END - if - // Nickname already in use! - $content = '{--MEMBER_NICKNAME_ALREADY_IN_USE--}'; - } + // Free result + SQL_FREERESULT($result); // Load template displayMessage($content); } else { // Do we have already submit the form? - if (isPostRequestParameterSet('nickname')) { + if (isPostRequestElementSet('nickname')) { loadTemplate('admin_settings_unsaved', false, '{--MEMBER_NICKNAME_IS_INVALID--}'); } // END - if