X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fmodules%2Fadmin%2Fwhat-lock_user.php;h=bf998d8863acf4d0b97d7d1a335b13dfe86e7492;hb=eb301334eb0960dd060cc0d59e6021260a41f835;hp=d382ea2f68b91125517ee251dbcbbcc24aed16b3;hpb=97dbb1a1f2f9e582132bb81c12895503e78e7a59;p=mailer.git diff --git a/inc/modules/admin/what-lock_user.php b/inc/modules/admin/what-lock_user.php index d382ea2f68..bf998d8863 100644 --- a/inc/modules/admin/what-lock_user.php +++ b/inc/modules/admin/what-lock_user.php @@ -10,9 +10,14 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Mitglieder sperren * * -------------------------------------------------------------------- * - * * + * $Revision:: $ * + * $Date:: $ * + * $Tag:: 0.2.1-FINAL $ * + * $Author:: $ * + * Needs to be in all Files and every File needs "svn propset * + * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * - * Copyright (c) 2003 - 2008 by Roland Haeder * + * Copyright (c) 2003 - 2009 by Roland Haeder * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -32,152 +37,161 @@ ************************************************************************/ // Some security stuff... -if ((!defined('__SECURITY')) || (!IS_ADMIN())) { - $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; - require($INC); -} +if ((!defined('__SECURITY')) || (!isAdmin())) { + die(); +} // END - if // Add description as navigation point -ADD_DESCR("admin", __FILE__); +addMenuDescription('admin', __FILE__); -if (!empty($_GET['u_id'])) -{ - $result_user = SQL_QUERY_ESC("SELECT status, gender, surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", - array(bigintval($_GET['u_id'])), __FILE__, __LINE__); +// Is a userid set? +if (isGetRequestElementSet('userid')) { + // Load user's data + $result_user = SQL_QUERY_ESC("SELECT status, gender, surname, family, email FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1", + array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__); $ACT = false; - if (SQL_NUMROWS($result_user) == 1) - { + if (SQL_NUMROWS($result_user) == 1) { // User found - list($status, $gender, $sname, $fname, $email) = SQL_FETCHROW($result_user); + list($status, $gender, $surname, $family, $email) = SQL_FETCHROW($result_user); + + // Free result SQL_FREERESULT($result_user); - if (empty($_GET['u_id'])) - { - // Output selection form with all confirmed user accounts listed - ADD_MEMBER_SELECTION_BOX(); - } elseif (!empty($_POST['lock'])) { + + // Is a lock reason set? + if ((isPostRequestElementSet('lock')) && ($status != 'LOCKED')) { // Ok, lock the account! - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='LOCKED' WHERE userid=%s LIMIT 1", - array(bigintval($_GET['u_id'])), __FILE__, __LINE__); - if (SQL_AFFECTEDROWS() == 1) - { + if (getExtensionVersion('user') >= '0.3.5') { + // Lock with reason + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED',lock_reason='%s',lock_timestamp=NOW() WHERE `userid`=%s LIMIT 1", + array(postRequestElement('reason'), bigintval(getRequestElement('userid'))), __FILE__, __LINE__); + } else { + // Lock with no lock reason saved + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='LOCKED' WHERE `userid`=%s LIMIT 1", + array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__); + } + + // Entry updated? + if (SQL_AFFECTEDROWS() == 1) { // Send an email to the user! In later version you can optionally switch this feature off - $msg = LOAD_EMAIL_TEMPLATE("lock-user", array('text' => $_POST['reason']), bigintval($_GET['u_id'])); + $message = loadEmailTemplate('lock-user', array('text' => postRequestElement('reason')), bigintval(getRequestElement('userid'))); // Send away... - SEND_EMAIL(bigintval($_GET['u_id']), ADMIN_LOCKED_SUBJ, $msg); - } + sendEmail(bigintval(getRequestElement('userid')), ADMIN_LOCKED_SUBJ, $message); + } // END - if // Prepare message - $MSG = USER_ACCOUNT_LOCKED_1.$_GET['u_id'].USER_ACCOUNT_LOCKED_2; + $message = sprintf(getMessage('USER_ACCOUNT_LOCKED'), getRequestElement('userid')); $ACT = true; - } elseif (!empty($_POST['unlock'])) { + } elseif ((isPostRequestElementSet(('unlock'))) && ($status == 'LOCKED')) { // Ok, unlock the account! - $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET status='CONFIRMED' WHERE userid=%s LIMIT 1", - array(bigintval($_GET['u_id'])), __FILE__, __LINE__); - if (SQL_AFFECTEDROWS() == 1) - { + if (getExtensionVersion('user') >= '0.3.5') { + // Reset lock reason as well + SQL_QUERY_ESC("UPDATE + `{?_MYSQL_PREFIX?}_user_data` +SET + `status`='CONFIRMED', + `lock_reason`='', + `lock_timestamp`='0000-00-00 00:00' +WHERE + `userid`=%s +LIMIT 1", + array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__); + } else { + // No lock reason to reset + SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `status`='CONFIRMED' WHERE `userid`=%s LIMIT 1", + array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__); + } + + // Entry updated? + if (SQL_AFFECTEDROWS() == 1) { // Send an email to the user! In later version you can optionally switch this feature off - $msg = LOAD_EMAIL_TEMPLATE("unlock-user", array('text' => $_POST['reason']), bigintval($_GET['u_id'])); + $message = loadEmailTemplate('unlock-user', array('text' => postRequestElement('reason')), bigintval(getRequestElement('userid'))); // Send away... - SEND_EMAIL(bigintval($_GET['u_id']), ADMIN_UNLOCKED_SUBJ, $msg); - if (EXT_IS_ACTIVE("rallye")) - { - RALLYE_AUTOADD_USER($_GET['u_id']); - } - } + sendEmail(bigintval(getRequestElement('userid')), getMessage('ADMIN_UNLOCKED_SUBJ'), $message); + if (isExtensionActive('rallye')) { + addUserToReferalRallye(getRequestElement('userid')); + } // END - if + } // END - if // Prepare message - $MSG = USER_ACCOUNT_UNLOCKED_1.$_GET['u_id'].USER_ACCOUNT_UNLOCKED_2; + $message = sprintf(getMessage('USER_ACCOUNT_UNLOCKED'), getRequestElement('userid')); $ACT = true; - } - elseif (isset($_POST['del'])) - { + } elseif (isPostRequestElementSet('del')) { // Delete the account $ACT = true; - require_once(PATH."inc/modules/admin/what-del_user.php"); - } - elseif (!empty($_POST['no'])) - { + loadIncludeOnce('inc/modules/admin/what-del_user.php'); + } elseif (isPostRequestElementSet('no')) { // Do not lock him... - $URL = URL."/modules.php?module=admin&what=list_user&u_id=".$_GET['u_id']; - } - else - { - $result = SQL_QUERY_ESC("SELECT email, surname, family FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", - array(bigintval($_GET['u_id'])), __FILE__, __LINE__); - if (SQL_NUMROWS($result) == 1) - { - // Load data - list ($email, $sname, $fname) = SQL_FETCHROW($result); - SQL_FREERESULT($result); + $URL = adminCreateUserLink(getRequestElement('userid')); + } else { + // Load user data we need + $result = SQL_QUERY_ESC("SELECT `email`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1", + array(bigintval(getRequestElement('userid'))), __FILE__, __LINE__); - // Transfer data to constants for the template - define('__EMAIL', CREATE_EMAIL_LINK($email, "user_data")); - define('__SNAME', $sname); - define('__FNAME', $fname); - define('__UID' , $_GET['u_id']); + // Entry found? + if (SQL_NUMROWS($result) == 1) { + // Load data + $DATA = SQL_FETCHARRAY($result); // Transfer data to constants for the template - define('__UID_VALUE', $_GET['u_id']); + // @TODO Rewrite these all constants + $content['email'] = generateEmailLink($DATA['email'], 'user_data'); + $content['surname'] = $DATA['surname']; + $content['fname'] = $DATA['family']; + $content['userid'] = bigintval(getRequestElement('userid')); // Realy want to lock? - switch ($status) - { - case "CONFIRMED": // Yes, lock him down... ;-) - define('__OK_VALUE' , "lock"); - define('__HEADER_VALUE', ADMIN_HEADER_LOCK_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_LOCK_ACCOUNT_2); - define('__TEXT_VALUE' , ADMIN_TEXT_LOCK_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_LOCK_ACCOUNT_2); - break; - - case "LOCKED": // Unlock the user - define('__OK_VALUE' , "unlock"); - define('__HEADER_VALUE', ADMIN_HEADER_UNLOCK_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_UNLOCK_ACCOUNT_2); - define('__TEXT_VALUE' , ADMIN_TEXT_UNLOCK_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_UNLOCK_ACCOUNT_2); - break; - - case "UNCONFIRMED": // Unconfirmed accounts cannot be unlocked! - define('__OK_VALUE' , "del"); - define('__HEADER_VALUE', ADMIN_HEADER_DEL_ACCOUNT_1.__UID_VALUE.ADMIN_HEADER_DEL_ACCOUNT_2); - define('__TEXT_VALUE' , ADMIN_TEXT_DEL_ACCOUNT_1.__UID_VALUE.ADMIN_TEXT_DEL_ACCOUNT_2); - break; + switch ($status) { + case 'CONFIRMED': // Yes, lock him down... ;-) + $content['ok'] = 'lock'; + $content['header'] = sprintf(getMessage('ADMIN_HEADER_LOCK_ACCOUNT'), $content['userid']); + $content['text'] = sprintf(getMessage('ADMIN_TEXT_LOCK_ACCOUNT'), $content['userid']); + break; + + case 'LOCKED': // Unlock the user + $content['ok'] = $lock; + $content['header'] = sprintf(getMessage('ADMIN_HEADER_UNLOCK_ACCOUNT'), $content['userid']); + $content['text'] = sprintf(getMessage('ADMIN_TEXT_UNLOCK_ACCOUNT'), $content['userid']); + break; + + case 'UNCONFIRMED': // Unconfirmed accounts cannot be unlocked! + $content['ok'] = 'del'; + $content['header'] = sprintf(getMessage('ADMIN_HEADER_DEL_ACCOUNT'), $content['userid']); + $content['text'] = sprintf(getMessage('ADMIN_TEXT_DEL_ACCOUNT'), $content['userid']); + break; } // Output form - LOAD_TEMPLATE("admin_lock_user"); - } - else - { + loadTemplate('admin_lock_user', false, $content); + } else { // Account does not exists! - OUTPUT_HTML("".ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2.""); + loadTemplate('admin_settings_saved', false, "