* $Author:: $ *
* -------------------------------------------------------------------- *
* Copyright (c) 2003 - 2009 by Roland Haeder *
- * Copyright (c) 2009, 2010 by Mailer Developer Team *
- * For more information visit: http://www.mxchange.org *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team *
+ * 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 *
}
// Add description as navigation point
-addMenuDescription('member', __FILE__);
+addYouAreHereLink('member', __FILE__);
if ((!isExtensionActive('nickname')) && (!isAdmin())) {
- loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('nickname'));
+ displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=nickname%}');
return;
} // END - if
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
- $PATTERN = '[' . getConfig('nickname_pattern') . ']{' . getConfig('nickname_len') . ',}';
- if (isInString($PATTERN, 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__);
+ $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `nickname`='%s' AND `userid` != %s LIMIT 1",
+ 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
- loadTemplate('admin_settings_saved', false, $content);
+ 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
// Load Template
- loadTemplate('member_nickname_form', false, getNickname(getMemberId()));
+ loadTemplate('member_nickname_form');
}
// [EOF]