From: Roland Häder Date: Tue, 9 Oct 2012 20:55:48 +0000 (+0000) Subject: Extension ext-nickname continued: X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=4264b4f73e06a6b957330a9972efe600a8ff4ab5 Extension ext-nickname continued: - Listing of member's nickname history and deletion basicly finished - Some other improvements - TODOs.txt updated --- diff --git a/.gitattributes b/.gitattributes index 94f1970bd2..0f4f5c5780 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1502,6 +1502,8 @@ templates/de/html/admin/admin_list_network_vcheck_params.tpl svneol=native#text/ templates/de/html/admin/admin_list_network_vcheck_params_row.tpl svneol=native#text/plain templates/de/html/admin/admin_list_networks.tpl svneol=native#text/plain templates/de/html/admin/admin_list_networks_row.tpl svneol=native#text/plain +templates/de/html/admin/admin_list_nickname_history.tpl svneol=native#text/plain +templates/de/html/admin/admin_list_nickname_history_row.tpl svneol=native#text/plain templates/de/html/admin/admin_list_notify_emails.tpl svneol=native#text/plain templates/de/html/admin/admin_list_notify_emails_row.tpl svneol=native#text/plain templates/de/html/admin/admin_list_online.tpl svneol=native#text/plain diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index a93a44a6a7..cea6b771cb 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -169,9 +169,9 @@ ./inc/modules/order.php:78: // @TODO Unused: 2,4 ./inc/mysql-manager.php:1437: // @TODO Rewrite these lines to a filter ./inc/mysql-manager.php:1461: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1717: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1916: // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided -./inc/mysql-manager.php:2029: // @TODO Used generic 'userid' here +./inc/mysql-manager.php:1767: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1966: // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided +./inc/mysql-manager.php:2079: // @TODO Used generic 'userid' here ./inc/mysql-manager.php:398: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:44:// @TODO Can we cache this? ./inc/purge/purge-inact.php:55: // @TODO Rewrite these if() blocks to a filter diff --git a/inc/expression-functions.php b/inc/expression-functions.php index f8e823d9bc..c8f1bfdf76 100644 --- a/inc/expression-functions.php +++ b/inc/expression-functions.php @@ -211,6 +211,7 @@ function doExpressionPipe ($data) { } // END - if // Replace the config entry + //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'replacer=' . $replacer); $code = replaceExpressionCode($data, $replacer); // Return replaced code @@ -332,8 +333,18 @@ function doExpressionMath ($data) { // Expression call-back for GET request function doExpressionGet ($data) { - // Construct the replacer - $replacer = '{%pipe,getRequestElement=' . $data['value'] . '%}'; + // Construct the replacer: + // - GET request element + $replacer = '{%pipe,getRequestElement'; + + // Add more call-back functions? + if (!empty($data['callback'])) { + // - Okay, add them + $replacer .= ',' . $data['callback']; + } // END - if + + // - Finalize replacer + $replacer .= '=' . $data['value'] . '%}'; // Replace the code $code = replaceExpressionCode($data, $replacer); @@ -344,8 +355,18 @@ function doExpressionGet ($data) { // Expression call-back for POST request function doExpressionPost ($data) { - // Construct the replacer - $replacer = '{%pipe,postRequestElement=' . $data['value'] . '%}'; + // Construct the replacer: + // - POST request element + $replacer = '{%pipe,postRequestElement'; + + // Add more call-back functions? + if (!empty($data['callback'])) { + // - Okay, add them + $replacer .= ',' . $data['callback']; + } // END - if + + // - Finalize replacer + $replacer .= '=' . $data['value'] . '%}'; // Replace the code $code = replaceExpressionCode($data, $replacer); @@ -356,8 +377,18 @@ function doExpressionPost ($data) { // Expression call-back for session data function doExpressionSession ($data) { - // Construct the replacer - $replacer = '{%pipe,getSession=' . $data['value'] . '%}'; + // Construct the replacer: + // - Session element + $replacer = '{%pipe,getSession'; + + // Add more call-back functions? + if (!empty($data['callback'])) { + // - Okay, add them + $replacer .= ',' . $data['callback']; + } // END - if + + // - Finalize replacer + $replacer .= '=' . $data['value'] . '%}'; // Debug message //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'value=' . $data['value'] . ',replacer=' . $replacer); diff --git a/inc/language/de.php b/inc/language/de.php index 1dab156233..310c76f79c 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -1331,6 +1331,13 @@ addMessages(array( // Member - submit buttons 'MEMBER_ACTION_EDIT_SUBMIT' => "Editieren", 'MEMBER_ACTION_DELETE_SUBMIT' => "Löschen", + + // Admin - history entries - generic + 'ADMIN_HISTORY_VALUE' => "Historie-Eintrag", + 'ADMIN_HISTORY_ENTRY_ADDED' => "Eintrag hinzugefügt", + 'ADMIN_HISTORY_ENTRY_LAST_USED' => "Zuletzt verwendet", + 'ADMIN_ACTION_DELETE_HISTORY_SUBMIT' => "Alle Historie-Einträge löschen", + 'ADMIN_LIST_HISTORY_NOTICE' => "Vorsicht: Mit Klick auf {----} werden die Historie-Einträge sofort bereinigt, ohne zusätzliche Sicherheitsabfrage.", )); // Description of all months diff --git a/inc/language/nickname_de.php b/inc/language/nickname_de.php index ed02ab9ef2..c3ff2b938b 100644 --- a/inc/language/nickname_de.php +++ b/inc/language/nickname_de.php @@ -42,22 +42,30 @@ if (!defined('__SECURITY')) { // Language definitions addMessages(array( + // Admin - configuration + 'ADMIN_CONFIG_NICKNAME_TITLE' => "Einstellungen am Nicknamen", + 'ADMIN_CONFIG_NICKNAME_MIN_LENGTH' => "Minimale Länge", + 'ADMIN_CONFIG_NICKNAME_PATTERN' => "Pattern für isInString()-Befehl", + 'ADMIN_CONFIG_NICKNAME_CHARACTERS' => "Zeichenfolge für Sprachdatei", + + // Admin - nickname history + 'ADMIN_LIST_NICKNAME_HISTORY_TITLE' => "Alle verwendeten Nicknames des Mitgliedes {%get,generateUserProfileLink=userid%}", + + // Member 'MEMBER_NICKNAME_CHANGE_NICKNAME_TITLE' => "Einstellen Ihres Nicknames", 'MEMBER_NICKNAME_CHANGE_NICKNAME_INTRO' => "Stellen Sie hier einen Nicknamen ein, der anstelle Ihrer Mitglied-Id angezeigt wird! Dieser darf nur unten aufgeführte Zeichen enthalten und sollte nicht kürzer als {?nickname_len?} Zeichen sein.", 'MEMBER_NICKNAME_ENTER_NICKNAME' => "Nickname eingeben", 'MEMBER_NICKNAME_CHANGE_SUBMIT' => "Nickname ändern", 'MEMBER_NICKNAME_ALREADY_IN_USE' => "Der von Ihnen eingegebene Nickname wird bereits verwendet.", 'MEMBER_NICKNAME_SAVED' => "Nickname wurde gespeichert.", - 'GUEST_ENTER_LOGIN_NICKNAME' => "Nickname o. Mitglieds-Id", 'MEMBER_NICKNAME_ALLOWED_CHARS' => "Erlaubte Zeichen:", 'MEMBER_NICKNAME_IS_INVALID' => "Ungültige Zeichen im Nicknamen gefunden oder ist zu kurz.", 'MEMBER_NICKNAME_YOUR_REFERRAL_LINK' => "Ihr Nickname-Reflink", 'MEMBER_NO_NICKNAME_SET' => "Sie haben noch keinen Nickname eingerichtet! Damit können Sie sich alternativ zur Mitglied-Id einloggen.", 'MEMBER_PLEASE_CLICK_NICKNAME_FORM' => "Hier können Sie sich nun einen einrichten...", - 'ADMIN_CONFIG_NICKNAME_TITLE' => "Einstellungen am Nicknamen", - 'ADMIN_CONFIG_NICKNAME_MIN_LENGTH' => "Minimale Länge", - 'ADMIN_CONFIG_NICKNAME_PATTERN' => "Pattern für isInString()-Befehl", - 'ADMIN_CONFIG_NICKNAME_CHARACTERS' => "Zeichenfolge für Sprachdatei", + + // Guest + 'GUEST_ENTER_LOGIN_NICKNAME' => "Nickname o. Mitglieds-Id", )); // [EOF] diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 827a66f46e..2e47837431 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -700,34 +700,47 @@ function adminAddMenuSelectionBox ($menu, $type, $name, $default = '') { } // Creates a user-profile link for the admin. This function can also be used for many other purposes -function generateUserProfileLink ($userid, $title = '', $what = 'list_user') { - if (($title == '') && (isValidUserId($userid))) { - // Set userid as title - $title = $userid; - } elseif (!isValidUserId($userid)) { - // User id zero is invalid - return '' . convertNullToZero($userid) . ''; - } - - if (($title == '0') && ($what == 'list_refs')) { - // Return title again - return $title; - } elseif (!empty($title)) { - // Not empty, so skip next one - } elseif (isExtensionActive('nickname')) { - // Get nickname - $nick = getNickname($userid); - - // Is it not empty, use it as title else the userid - if (!empty($nick)) { - $title = $nick . '(' . $userid . ')'; - } else { +function generateUserProfileLink ($userid, $title = '', $what = '') { + // Is there cache? + if (!isset($GLOBALS[__FUNCTION__][$userid][$title . '_' . $what])) { + // Is title empty and valid userid? + if (($title == '') && (isValidUserId($userid))) { + // Set userid as title $title = $userid; + } elseif (!isValidUserId($userid)) { + // User id zero is invalid + return '' . convertNullToZero($userid) . ''; } - } - // Return link - return '[' . $title . ']'; + // Is what set? + if (empty($what)) { + // Then get it + $what = getWhat(); + } // END - if + + if (($title == '0') && ($what == 'list_refs')) { + // Return title again + return $title; + } elseif (!empty($title)) { + // Not empty, so skip next one + } elseif (isExtensionActive('nickname')) { + // Get nickname + $nick = getNickname($userid); + + // Is it not empty, use it as title else the userid + if (!empty($nick)) { + $title = $nick . '(' . $userid . ')'; + } else { + $title = $userid; + } + } + + // Set it in cache + $GLOBALS[__FUNCTION__][$userid][$title . '_' . $what] = '[' . $title . ']'; + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__][$userid][$title . '_' . $what]; } // Check "logical-area-mode" @@ -952,7 +965,7 @@ function adminDeleteEntriesConfirm ($tableName, $columns = array(), $filterFunct // Shall we delete here or list for deletion? if ($deleteNow[0] === true) { // Call generic function - $affected = doGenericDeleteEntriesConfirm($tableName, $columns, $filterFunctions, $extraValues, $timeColumns, $editNow, $idColumn, $userIdColumn, $rawUserId, $cacheFiles); + $affected = doGenericDeleteEntriesConfirm($tableName, $columns, $filterFunctions, $extraValues, $deleteNow, $idColumn, $userIdColumn, $rawUserId, $cacheFiles); // Was this fine? if ($affected == countPostSelection($idColumn[0])) { diff --git a/inc/modules/admin/what-list_nickname.php b/inc/modules/admin/what-list_nickname.php index 8d4cada317..e9788a830e 100644 --- a/inc/modules/admin/what-list_nickname.php +++ b/inc/modules/admin/what-list_nickname.php @@ -45,6 +45,12 @@ addYouAreHereLink('admin', __FILE__); // Check if 'userid' is set if (isGetRequestElementSet('userid')) { + // Delete entries? + if (isFormSent('do_delete')) { + // Remove entries from database + showEntriesByXmlCallback('admin_delete_do_nickname_history'); + } // END - if + // List all entries per user showEntriesByXmlCallback('admin_list_nickname_history', array( 'userid' => bigintval(getRequestElement('userid')) diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index b4b635d87b..691fbd4cba 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1465,7 +1465,7 @@ LIMIT 1", } // END - if // Add reason and translate points - $data['text'] = $reason; + $data['text'] = $reason; // Now a mail to the user and that's all... $message = loadEmailTemplate('member_user_deleted', $data, $userid); @@ -1523,7 +1523,14 @@ function generateCategoryOptionsList ($mode, $userid = NULL) { ); // Get categories - $result = SQL_QUERY('SELECT `id`,`cat` FROM `{?_MYSQL_PREFIX?}_cats`' . $whereStatement . ' ORDER BY `sort` ASC', + $result = SQL_QUERY('SELECT + `id`, + `cat` +FROM + `{?_MYSQL_PREFIX?}_cats` +' . $whereStatement . ' +ORDER BY + `sort` ASC', __FUNCTION__, __LINE__); // Are there entries? @@ -1596,13 +1603,34 @@ function addBonusMailToQueue ($subject, $text, $receiverList, $points, $seconds, // HTML extension active? if (isExtensionActive('html_mail')) { - // Determine if we have HTML mode active - $HTML = convertBooleanToYesNo($mode == 'html'); - // Add HTML mail - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus` -(`subject`,`text`,`receivers`,`points`,`time`,`data_type`,`timestamp`,`url`,`cat_id`,`target_send`,`mails_sent`,`html_msg`) -VALUES ('%s','%s','%s',%s,%s,'NEW', UNIX_TIMESTAMP(),'%s',%s,%s,%s,'%s')", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus` ( + `subject`, + `text`, + `receivers`, + `points`, + `time`, + `data_type`, + `timestamp`, + `url`, + `cat_id`, + `target_send`, + `mails_sent`, + `html_msg` +) VALUES ( + '%s', + %s', + '%s', + %s, + %s, + 'NEW', + UNIX_TIMESTAMP(), + '%s', + %s, + %s, + %s, + '%s' +)", array( $subject, $text, @@ -1613,13 +1641,35 @@ VALUES ('%s','%s','%s',%s,%s,'NEW', UNIX_TIMESTAMP(),'%s',%s,%s,%s,'%s')", bigintval($categoryId), $target, bigintval($receiver), - $HTML + convertBooleanToYesNo($mode == 'html') ), __FUNCTION__, __LINE__); } else { // Add regular mail - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus` -(`subject`,`text`,`receivers`,`points`,`time`,`data_type`,`timestamp`,`url`,`cat_id`,`target_send`,`mails_sent`) -VALUES ('%s','%s','%s',%s,%s,'NEW', UNIX_TIMESTAMP(),'%s',%s,%s,%s)", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus` ( + `subject`, + `text`, + `receivers`, + `points`, + `time`, + `data_type`, + `timestamp`, + `url`, + `cat_id`, + `target_send`, + `mails_sent` +) VALUES ( + '%s', + '%s', + '%s', + %s, + %s, + 'NEW', + UNIX_TIMESTAMP(), + '%s', + %s, + %s, + %s +)", array( $subject, $text, @@ -2170,14 +2220,22 @@ function doGenericDeleteEntriesConfirm ($tableName, $columns = array(), $filterF $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s` IN (%s)"; // Is a user id provided? + //* BUG: */ die('
'.print_r($rawUserId,true).'
'.print_r($userIdColumn,true).'
'); if ((isset($rawUserId[0])) && (isPostRequestElementSet($rawUserId[0])) && (isset($userIdColumn[0]))) { // Add user id as well $sql .= ' AND `' . $userIdColumn[0] . '`=' . bigintval(postRequestElement($rawUserId[0])); } // END - if // Delete them all + //* BUG: */ die($sql.'
'.print_r($idColumn,true).'
'); $idList = ''; foreach (postRequestElement($idColumn[0]) as $id => $sel) { + // Is id zero? + if ($id == '0') { + // Then skip this + continue; + } // END - if + // Is there a userid? if (isPostRequestElementSet($userIdColumn[0])) { // Load all data from that id @@ -2203,7 +2261,12 @@ function doGenericDeleteEntriesConfirm ($tableName, $columns = array(), $filterF } // END - foreach // Run the query - SQL_QUERY_ESC($sql, array($tableName[0], $idColumn[0], substr($idList, 0, -1)), __FUNCTION__, __LINE__); + SQL_QUERY_ESC($sql, + array( + $tableName[0], + $idColumn[0], + convertNullToZero(substr($idList, 0, -1)) + ), __FUNCTION__, __LINE__); // Return affected rows return SQL_AFFECTEDROWS(); diff --git a/templates/de/html/admin/admin_list_nickname_history.tpl b/templates/de/html/admin/admin_list_nickname_history.tpl new file mode 100644 index 0000000000..ad0eff86d5 --- /dev/null +++ b/templates/de/html/admin/admin_list_nickname_history.tpl @@ -0,0 +1,30 @@ +
+
+ + + + + + + + + + + +$content + + + +
+ {--ADMIN_LIST_NICKNAME_HISTORY_TITLE--} +
{--ID_SELECT--}{--_USERID--}{--ADMIN_HISTORY_VALUE--}{--ADMIN_HISTORY_ENTRY_ADDED--}{--ADMIN_HISTORY_ENTRY_LAST_USED--}
+
+
+ +
+ {--ADMIN_LIST_HISTORY_NOTICE--} +
diff --git a/templates/de/html/admin/admin_list_nickname_history_row.tpl b/templates/de/html/admin/admin_list_nickname_history_row.tpl new file mode 100644 index 0000000000..924243c57e --- /dev/null +++ b/templates/de/html/admin/admin_list_nickname_history_row.tpl @@ -0,0 +1,17 @@ + + + $content[history_id] + + + {%pipe,generateUserProfileLink=$content[history_userid]%} + + + $content[history_value] + + + $content[history_added] + + + $content[history_last_used] + + diff --git a/templates/xml/admin/admin_delete_do_nickname_history.xml b/templates/xml/admin/admin_delete_do_nickname_history.xml new file mode 100644 index 0000000000..3af9abc605 --- /dev/null +++ b/templates/xml/admin/admin_delete_do_nickname_history.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/xml/admin/admin_list_nickname_history.xml b/templates/xml/admin/admin_list_nickname_history.xml index 01f74798af..68deb5eb22 100644 --- a/templates/xml/admin/admin_list_nickname_history.xml +++ b/templates/xml/admin/admin_list_nickname_history.xml @@ -64,6 +64,7 @@ MA 02110-1301 USA always be set), alias (again can be left empty) and SQL function (can also be left empty) which shall be applied on the column. //--> +