]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/admin-inc.php
Naming convention applied to language strings, new API function added:
[mailer.git] / inc / modules / admin / admin-inc.php
index 914622a461b6ea7edb2b6a54fd1b1ea298295451..7638b2fc067c98e0dd2b0ae7e9fa1ba180398ac4 100644 (file)
@@ -77,29 +77,36 @@ function ifAdminLoginDataIsValid ($adminLogin, $adminPassword) {
        // First of all, no admin login is found
        $ret = '404';
 
-       // Then we need to lookup the login name by getting the admin hash
-       $adminHash = getAdminHash($adminLogin);
-
-       // If this is fine, we can continue
-       if ($adminHash != '-1') {
-               // Get admin id and set it as current
-               setCurrentAdminId(getAdminId($adminLogin));
-
-               // Now, we need to encode the password in the same way the one is encoded in database
-               $testHash = generateHash($adminPassword, $adminHash);
-
-               // If they both match, the login data is valid
-               if ($testHash == $adminHash) {
-                       // All fine
-                       $ret = 'done';
-               } else {
-                       // Set status
-                       $ret = 'pass';
-               }
+       // Get admin id from login
+       $adminId = getAdminId($adminLogin);
+
+       // Continue only with found admin ids
+       if ($adminId > 0) {
+               // Then we need to lookup the login name by getting the admin hash
+               $adminHash = getAdminHash($adminId);
+
+               // If this is fine, we can continue
+               if ($adminHash != '-1') {
+                       // Get admin id and set it as current
+                       setCurrentAdminId($adminId);
+
+                       // Now, we need to encode the password in the same way the one is encoded in database
+                       $testHash = generateHash($adminPassword, $adminHash);
+
+                       // If they both match, the login data is valid
+                       if ($testHash == $adminHash) {
+                               // All fine
+                               $ret = 'done';
+                       } else {
+                               // Set status
+                               $ret = 'password';
+                       }
+               } // END - if
        } // END - if
 
        // Prepare data array
        $data = array(
+               'id'         => $adminId,
                'login'      => $adminLogin,
                'plain_pass' => $adminPassword,
                'pass_hash'  => $adminHash
@@ -124,7 +131,7 @@ function ifAdminCookiesAreValid ($adminLogin, $passHash) {
        if ($adminHash != '-1') {
                // Now, we need to encode the password in the same way the one is encoded in database
                $testHash = encodeHashForCookie($adminHash);
-               //* DEBUG: */ outputHtml('adminLogin='.$adminLogin.',<br />passHash='.$passHash.',<br />adminHash='.$adminHash.',<br />testHash='.$testHash.'<br />');
+               //* DEBUG: */ debugOutput('adminLogin=' . $adminLogin . ',passHash='.$passHash.',adminHash='.$adminHash.',testHash='.$testHash);
 
                // If they both match, the login data is valid
                if ($testHash == $passHash) {
@@ -132,12 +139,12 @@ function ifAdminCookiesAreValid ($adminLogin, $passHash) {
                        $ret = 'done';
                } else {
                        // Set status
-                       $ret = 'pass';
+                       $ret = 'password';
                }
        } // END - if
 
        // Return status
-       //* DEBUG: */ outputHtml('ret='.$ret);
+       //* DEBUG: */ debugOutput('ret='.$ret);
        return $ret;
 }
 
@@ -146,7 +153,7 @@ function doAdminAction () {
        // Get default what
        $what = getWhat();
 
-       //* DEBUG: */ outputHtml(__LINE__.'*'.$what.'/'.getModule().'/'.getAction().'/'.getWhat().'*<br />');
+       //* DEBUG: */ debugOutput(__LINE__.'*'.$what.'/'.getModule().'/'.getAction().'/'.getWhat().'*');
 
        // Remove any spaces from variable
        if (empty($what)) {
@@ -161,7 +168,7 @@ function doAdminAction () {
        $action = getActionFromModuleWhat(getModule(), $what);
 
        // Define admin login name and id number
-       $content['login'] = getSession('admin_login');
+       $content['login'] = getAdminLogin(getSession('admin_id'));
        $content['id']    = getCurrentAdminId();
 
        // Preload templates
@@ -249,11 +256,11 @@ ORDER BY
        `id` DESC", __FUNCTION__, __LINE__);
 
        // Do we have entries?
-       if (SQL_NUMROWS($result_main) > 0) {
+       if (!SQL_HASZERONUMS($result_main)) {
                $OUT .= '<ul class="admin_menu_main">';
                // @TODO Rewrite this to $content = SQL_FETCHARRAY()
                while (list($menu, $title, $descr) = SQL_FETCHROW($result_main)) {
-                       if ((isExtensionActive('admins')) && (getExtensionVersion('admins') > '0.2.0')) {
+                       if (isExtensionInstalledAndNewer('admins', '0.2.0')) {
                                $ACL = adminsCheckAdminAcl($menu, '');
                        } else {
                                // @TODO ACL is 'allow'... hmmm
@@ -282,7 +289,7 @@ ORDER BY
                                                $OUT .= '[<a href="{%url=modules.php?module=admin&amp;action=' . $menu . '%}">';
                                        }
                                } else {
-                                       $OUT .= '<em style="cursor:help" class="admin_note" title="{--MENU_ACTION_404--}">';
+                                       $OUT .= '<em style="cursor:help" class="notice" title="{%message,MENU_ACTION_404=' . $menu . '}">';
                                }
 
                                $OUT .= $title;
@@ -315,17 +322,17 @@ ORDER BY
                                        array($menu), __FUNCTION__, __LINE__);
 
                                // Remember the count for later checks
-                               setAdminMenuHasEntries($menu, ((SQL_NUMROWS($result_what) > 0) && ($action == $menu)));
+                               setAdminMenuHasEntries($menu, ((!SQL_HASZERONUMS($result_what)) && ($action == $menu)));
 
                                // Do we have entries?
-                               if ((ifAdminMenuHasEntries($menu)) && (SQL_NUMROWS($result_what) > 0)) {
+                               if ((ifAdminMenuHasEntries($menu)) && (!SQL_HASZERONUMS($result_what))) {
                                        $GLOBALS['menu']['description'] = array();
                                        $GLOBALS['menu']['title'] = array(); $SUB = true;
                                        $OUT .= '<li class="admin_menu_sub"><ul class="admin_menu_sub">';
                                        // @TODO Rewrite this to $content = SQL_FETCHARRAY()
                                        while (list($what_sub, $title_what, $desc_what) = SQL_FETCHROW($result_what)) {
                                                // Check for access level
-                                               if ((isExtensionActive('admins')) && (getExtensionVersion('admins') > '0.2.0')) {
+                                               if (isExtensionInstalledAndNewer('admins', '0.2.0')) {
                                                        $ACL = adminsCheckAdminAcl('', $what_sub);
                                                } else {
                                                        // @TODO ACL is 'allow'... hmmm
@@ -352,7 +359,7 @@ ORDER BY
                                                                        $OUT .= '[<a href="{%url=modules.php?module=admin&amp;what=' . $what_sub . '%}">';
                                                                }
                                                        } else {
-                                                               $OUT .= '<em style="cursor:help" class="admin_note" title="{--MENU_WHAT_404--}">';
+                                                               $OUT .= '<em style="cursor:help" class="notice" title="{%message,MENU_WHAT_404=' . $what_sub . '%}">';
                                                        }
 
                                                        $OUT .= $title_what;
@@ -394,7 +401,7 @@ ORDER BY
 }
 
 // Create member selection box
-function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=false, $field='userid') {
+function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $none = false, $field = 'userid') {
        // Output selection form with all confirmed user accounts listed
        $result = SQL_QUERY("SELECT `userid`, `surname`, `family` FROM `{?_MYSQL_PREFIX?}_user_data` ORDER BY `userid` ASC", __FUNCTION__, __LINE__);
 
@@ -406,7 +413,7 @@ function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=fal
         elseif ($none === true) $OUT = '      <option value="0">{--SELECT_NONE--}</option>';
 
        while ($content = SQL_FETCHARRAY($result)) {
-               $OUT .= '      <option value="' . bigintval($content['userid']) . '"';
+               $OUT .= '<option value="' . bigintval($content['userid']) . '"';
                if ($def == $content['userid']) $OUT .= ' selected="selected"';
                $OUT .= '>' . $content['surname'] . ' ' . $content['family'] . ' (' . bigintval($content['userid']) . ')</option>';
        } // END - while
@@ -416,14 +423,14 @@ function addMemberSelectionBox ($def=0, $add_all=false, $return=false, $none=fal
 
        if ($return === false) {
                // Remeber options in constant
-               $content['member_selection'] = $OUT;
+               $content['form_selection'] = $OUT;
                $content['what']             = getWhat();
 
                // Load template
-               loadTemplate('admin_member_selection_box', false, $content);
+               loadTemplate('admin_form_selection_box', false, $content);
        } else {
                // Return content in selection frame
-               return '<select class="admin_select" name="' . $field . '" size="1">' . $OUT . '</select>';
+               return '<select class="form_select" name="' . handleFieldWithBraces($field) . '" size="1">' . $OUT . '</select>';
        }
 }
 
@@ -434,27 +441,29 @@ function adminMenuSelectionBox_DEPRECATED ($mode, $default = '', $defid = '') {
        $what = "`what` != ''";
        if ($mode == 'action') $what = "(`what`='' OR `what` IS NULL) AND `action` !='login'";
 
-       $result = SQL_QUERY_ESC("SELECT %s, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
+       $result = SQL_QUERY_ESC("SELECT `%s` AS `menu`, `title` FROM `{?_MYSQL_PREFIX?}_admin_menu` WHERE ".$what." ORDER BY `sort` ASC",
                array($mode), __FUNCTION__, __LINE__);
-       if (SQL_NUMROWS($result) > 0) {
+       if (!SQL_HASZERONUMS($result)) {
                // Load menu as selection
-               $OUT = "<select name=\"".$mode."_menu";
-               if ((!empty($defid)) || ($defid == '0')) $OUT .= "[".$defid."]";
-               $OUT .= "\" size=\"1\" class=\"admin_select\">
-       <option value=\"\">{--SELECT_NONE--}</option>\n";
-               // @TODO Try to rewrite this to $content = SQL_FETCHARRAY(). Please look some lines above for the dynamic query
-               while (list($menu, $title) = SQL_FETCHROW($result)) {
-                       $OUT .= "  <option value=\"".$menu."\"";
-                       if ((!empty($default)) && ($default == $menu)) $OUT .= ' selected="selected"';
-                       $OUT .= ">".$title."</option>\n";
+               $OUT = '<select name="' . $mode . '_menu';
+               if ((!empty($defid)) || ($defid == '0')) $OUT .= '[' . $defid . ']';
+               $OUT .= '" size="1" class="form_select">
+       <option value="">{--SELECT_NONE--}</option>';
+               // Load all entries
+               while ($content = SQL_FETCHARRAY($result)) {
+                       $OUT .= '<option value="' . $content['menu'] . '"';
+                       if ((!empty($default)) && ($default == $content['menu'])) $OUT .= ' selected="selected"';
+                       $OUT .= '>' . $content['title'] . '</option>';
                } // END - while
 
                // Free memory
                SQL_FREERESULT($result);
-               $OUT .= "</select>\n";
+
+               // Add closing select-tag
+               $OUT .= '</select>';
        } else {
                // No menus???
-               $OUT = getMessage('ADMIN_PROBLEM_NO_MENU');
+               $OUT = '{--ADMIN_PROBLEM_NO_MENU--}';
        }
 
        // Return output
@@ -568,7 +577,7 @@ function adminSaveSettings (&$postData, $tableName = '_config', $whereStatement
        rebuildCache('config', 'config');
 
        // Settings saved, so display message?
-       if ($displayMessage === true) loadTemplate('admin_settings_saved', false, getMessage('SETTINGS_SAVED'));
+       if ($displayMessage === true) loadTemplate('admin_settings_saved', false, '{--SETTINGS_SAVED--}');
 
        // Return affected rows
        return $affected;
@@ -580,13 +589,12 @@ function adminAddMenuSelectionBox ($menu, $type, $name, $default = '') {
        $menuArray = getArrayFromDirectory(sprintf("inc/modules/%s/", $menu), '', false, false);
 
        // Init the selection box
-       $OUT = "<select name=\"".$name."\" class=\"admin_select\" size=\"1\">
-       <option value=\"\">{--IS_TOP_MENU--}</option>\n";
+       $OUT = '<select name="' . $name . '" class="form_select" size="1"><option value="">{--ADMIN_IS_TOP_MENU--}</option>';
 
        // Walk through all files
        foreach ($menuArray as $file) {
                // Is this a PHP script?
-               if ((!isDirectory($file)) && (strpos($file, "".$type.'-') > -1) && (strpos($file, '.php') > 0)) {
+               if ((!isDirectory($file)) && (strpos($file, '' . $type . '-') > -1) && (strpos($file, '.php') > 0)) {
                        // Then test if the file is readable
                        $test = sprintf("inc/modules/%s/%s", $menu, $file);
 
@@ -598,16 +606,16 @@ function adminAddMenuSelectionBox ($menu, $type, $name, $default = '') {
 
                                // Is that part different from the overview?
                                if ($part != 'overview') {
-                                       $OUT .= "       <option value=\"".$part."\"";
+                                       $OUT .= '<option value="' . $part . '"';
                                        if ($part == $default) $OUT .= ' selected="selected"';
-                                       $OUT .= ">".$part."</option>\n";
+                                       $OUT .= '>' . $part . '</option>';
                                } // END - if
                        } // END - if
                } // END - if
        } // END - foreach
 
        // Close selection box
-       $OUT .= "</select>\n";
+       $OUT .= '</select>';
 
        // Return contents
        return $OUT;
@@ -615,7 +623,7 @@ 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 == '') && ($userid > 0)) {
+       if (($title == '') && (isValidUserId($userid))) {
                // Set userid as title
                $title = $userid;
        } elseif ($userid == 0) {
@@ -654,7 +662,7 @@ function adminGetMenuMode () {
                incrementStatsEntry('cache_hits');
        } elseif (isExtensionInstalledAndNewer('admins', '0.6.7')) {
                // Load from database when version of 'admins' is enough
-               $result = SQL_QUERY_ESC("SELECT la_mode FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
+               $result = SQL_QUERY_ESC("SELECT `la_mode` FROM `{?_MYSQL_PREFIX?}_admins` WHERE `id`=%s LIMIT 1",
                        array($adminId), __FUNCTION__, __LINE__);
 
                // Do we have an entry?
@@ -714,12 +722,12 @@ function adminChangeActivationStatus ($IDs, $table, $row, $idRow = 'id') {
                loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_STATUS_CHANGED'), $cnt, count($IDs)));
        } else {
                // Nothing selected!
-               loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NOTHING_SELECTED_CHANGE'));
+               loadTemplate('admin_settings_saved', false, '{--ADMIN_NOTHING_SELECTED_CHANGE--}');
        }
 }
 
 // Send mails for del/edit/lock build modes
-function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '') {
+function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $userid = 'userid') {
        // Default subject is the subject part
        $subject = $subjectPart;
 
@@ -730,10 +738,7 @@ function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '') {
        } // END - if
 
        // Is the raw userid set?
-       if (postRequestParameter('userid_raw', $id) > 0) {
-               // Generate subject
-               $subjectLine = getMessage('MEMBER_'.strtoupper($subject).'_'.strtoupper($table).'_SUBJECT');
-
+       if (postRequestParameter($userid, $id) > 0) {
                // Load email template
                if (!empty($subjectPart)) {
                        $mail = loadEmailTemplate('member_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content);
@@ -742,23 +747,23 @@ function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '') {
                }
 
                // Send email out
-               sendEmail(postRequestParameter('userid_raw', $id), $subjectLine, $mail);
+               sendEmail(postRequestParameter($userid, $id), strtoupper('{--MEMBER_' . $subject . '_' . $table . '_SUBJECT--}'), $mail);
        } // END - if
 
        // Generate subject
-       $subjectLine = getMessage('ADMIN_'.strtoupper($subject).'_'.strtoupper($table).'_SUBJECT');
+       $subject = strtoupper('{--ADMIN_' . $subject . '_' . $table . '_SUBJECT--}');
 
        // Send admin notification out
        if (!empty($subjectPart)) {
-               sendAdminNotification($subjectLine, 'admin_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content, postRequestParameter('userid_raw', $id));
+               sendAdminNotification($subject, 'admin_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content, postRequestParameter($userid, $id));
        } else {
-               sendAdminNotification($subjectLine, 'admin_' . $mode . '_' . $table, $content, postRequestParameter('userid_raw', $id));
+               sendAdminNotification($subject, 'admin_' . $mode . '_' . $table, $content, postRequestParameter($userid, $id));
        }
 }
 
 // Build a special template list
-function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn) {
-       $OUT = ''; $SW = 2;
+function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $userid = 'userid') {
+       $OUT = '';
 
        // "Walk" through all entries
        foreach ($IDs as $id => $selected) {
@@ -779,27 +784,30 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions,
                                $idx = array_search($key, $columns, true);
 
                                // Do we have a userid?
-                               if ($key == 'userid') {
+                               if ($key == $userIdColumn) {
                                        // Add it again as raw id
-                                       $content['userid'] = bigintval($value);
+                                       $content[$userIdColumn] = bigintval($value);
+                                       $content[$userIdColumn . '_raw'] = $content[$userIdColumn];
+                               } // END - if
+
+                               // If the key matches the idColumn variable, we need to temporary remember it
+                               //* DEBUG: */ debugOutput('key=' . $key . ',idColumn=' . $idColumn . ',value=' . $value);
+                               if ($key == $idColumn) {
+                                       // Found, so remember it
+                                       $GLOBALS['admin_list_builder_id_value'] = $value;
                                } // END - if
 
                                // Handle the call in external function
+                               //* DEBUG: */ debugOutput('key=' . $key . ',fucntion=' . $filterFunctions[$idx] . ',value=' . $value);
                                $content[$key] = handleExtraValues($filterFunctions[$idx], $value, $extraValues[$idx]);
                        } // END - foreach
 
-                       // Add color switching
-                       $content['sw'] = $SW;
-
                        // Then list it
                        $OUT .= loadTemplate(sprintf("admin_%s_%s_row",
-                       $listType,
-                       $table
-                       ), true, $content
+                               $listType,
+                               $table
+                               ), true, $content
                        );
-
-                       // Switch color
-                       $SW = 3 - $SW;
                } // END - if
 
                // Free the result
@@ -815,7 +823,7 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions,
 }
 
 // Change status of "build" list
-function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray) {
+function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $statusArray, $userid = 'userid') {
        // All valid entries? (We hope so here!)
        if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues)) && (count($statusArray) > 0)) {
                // "Walk" through all entries
@@ -824,7 +832,7 @@ function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFuncti
                        $sql = sprintf("UPDATE `{?_MYSQL_PREFIX?}_%s` SET", SQL_ESCAPE($table));
 
                        // Load data of entry
-                       $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s=%s LIMIT 1",
+                       $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
                                array($table, $idColumn, $id), __FUNCTION__, __LINE__);
 
                        // Fetch the data
@@ -852,16 +860,19 @@ function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFuncti
                                        } // END - if
                                } elseif (isset($content[$column])) {
                                        // Unfinished!
-                                       app_die(__FUNCTION__, __LINE__, ":UNFINISHED: id={$id}/{$column}[".gettype($statusInfo)."] = {$content[$column]}");
+                                       debug_report_bug(__FUNCTION__, __LINE__, ':UNFINISHED: id=' . $id . ',column=' . $column . '[' . gettype($statusInfo) . '] = ' . $content[$column]);
                                }
                        } // END - foreach
 
                        // Add other columns as well
                        foreach (postRequestArray() as $key => $entries) {
+                               // Debug message
+                               logDebugMessage(__FUNCTION__, __LINE__, 'Found entry: ' . $key);
+
                                // Skip id, raw userid and 'do_$mode'
-                               if (!in_array($key, array($idColumn, 'userid_raw', ('do_'.$mode)))) {
+                               if (!in_array($key, array($idColumn, $userid, ('do_' . $mode)))) {
                                        // Are there brackets () at the end?
-                                       if (substr($entries[$id], -2, 2) == "()") {
+                                       if (substr($entries[$id], -2, 2) == '()') {
                                                // Direct SQL command found
                                                $sql .= sprintf(" %s=%s,", SQL_ESCAPE($key), SQL_ESCAPE($entries[$id]));
                                        } else {
@@ -871,7 +882,10 @@ function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFuncti
                                                // Add entry
                                                $content[$key] = $entries[$id];
                                        }
-                               } // END - if
+                               } else {
+                                       // Skipped entry
+                                       logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: ' . $key);
+                               }
                        } // END - foreach
 
                        // Finish SQL statement
@@ -898,22 +912,26 @@ function adminBuilderStatusHandler ($mode, $IDs, $table, $columns, $filterFuncti
 }
 
 // Delete rows by given id numbers
-function adminDeleteEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $deleteNow=false, $idColumn='id', $userIdColumn='userid') {
+function adminDeleteEntriesConfirm ($IDs, $table, $columns = array(), $filterFunctions = array(), $extraValues = array(), $deleteNow = false, $idColumn = 'id', $userIdColumn = 'userid', $userid = 'userid') {
        // All valid entries? (We hope so here!)
        if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
                // Shall we delete here or list for deletion?
                if ($deleteNow === true) {
                        // The base SQL command:
-                       $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s IN (%s)";
+                       $sql = "DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s` IN (%s)";
 
                        // Delete them all
                        $idList = '';
                        foreach ($IDs as $id => $sel) {
                                // Is there a userid?
-                               if (isPostRequestParameterSet('userid_raw', $id)) {
+                               if (isPostRequestParameterSet($userid, $id)) {
                                        // Load all data from that id
-                                       $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE %s=%s LIMIT 1",
-                                       array($table, $idColumn, $id), __FUNCTION__, __LINE__);
+                                       $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`=%s LIMIT 1",
+                                               array(
+                                                       $table,
+                                                       $idColumn,
+                                                       $id
+                                               ), __FUNCTION__, __LINE__);
 
                                        // Fetch the data
                                        $content = SQL_FETCHARRAY($result);
@@ -930,12 +948,12 @@ function adminDeleteEntriesConfirm ($IDs, $table, $columns=array(), $filterFunct
                        } // END - foreach
 
                        // Run the query
-                       SQL_QUERY($sql, array($table, $idColumn, substr($idList, 0, -1)), __FUNCTION__, __LINE__);
+                       SQL_QUERY_ESC($sql, array($table, $idColumn, substr($idList, 0, -1)), __FUNCTION__, __LINE__);
 
                        // Was this fine?
                        if (SQL_AFFECTEDROWS() == count($IDs)) {
                                // All deleted
-                               loadTemplate('admin_settings_saved', false, getMessage('ADMIN_ALL_ENTRIES_REMOVED'));
+                               loadTemplate('admin_settings_saved', false, '{--ADMIN_ALL_ENTRIES_REMOVED--}');
                        } else {
                                // Some are still there :(
                                loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_SOME_ENTRIES_NOT_DELETED'), SQL_AFFECTEDROWS(), count($IDs)));
@@ -948,7 +966,7 @@ function adminDeleteEntriesConfirm ($IDs, $table, $columns=array(), $filterFunct
 }
 
 // Edit rows by given id numbers
-function adminEditEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctions=array(), $extraValues=array(), $editNow=false, $idColumn='id', $userIdColumn='userid') {
+function adminEditEntriesConfirm ($IDs, $table, $columns = array(), $filterFunctions = array(), $extraValues = array(), $editNow = false, $idColumn = 'id', $userIdColumn = 'userid', $userid = 'userid') {
        // All valid entries? (We hope so here!)
        if ((is_array($IDs)) && (count($IDs) > 0) && (count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
                // Shall we change here or list for editing?
@@ -965,7 +983,7 @@ function adminEditEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctio
                                );
                                foreach (postRequestArray() as $key => $entries) {
                                        // Skip raw userid which is always invalid
-                                       if ($key == 'userid_raw') {
+                                       if ($key == $userid) {
                                                // Continue with next field
                                                continue;
                                        } // END - if
@@ -983,8 +1001,8 @@ function adminEditEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctio
 
                                                // Then add this value
                                                $sql .= sprintf(" `%s`='%s',",
-                                               SQL_ESCAPE($key),
-                                               SQL_ESCAPE($entries[$id])
+                                                       SQL_ESCAPE($key),
+                                                       SQL_ESCAPE($entries[$id])
                                                );
                                        } elseif (($key != $idColumn) && (!is_array($entries))) {
                                                // Add normal entries as well!
@@ -1024,7 +1042,7 @@ function adminEditEntriesConfirm ($IDs, $table, $columns=array(), $filterFunctio
                        // Was this fine?
                        if ($affected == count($IDs)) {
                                // All deleted
-                               loadTemplate('admin_settings_saved', false, getMessage('ADMIN_ALL_ENTRIES_EDITED'));
+                               loadTemplate('admin_settings_saved', false, '{--ADMIN_ALL_ENTRIES_EDITED--}');
                        } else {
                                // Some are still there :(
                                loadTemplate('admin_settings_saved', false, sprintf(getMessage('ADMIN_SOME_ENTRIES_NOT_EDITED'), $affected, count($IDs)));
@@ -1093,7 +1111,7 @@ function sendAdminPasswordResetLink ($email) {
        // Is there an account?
        if (SQL_HASZERONUMS($result)) {
                // No account found!
-               return getMessage('ADMIN_NO_LOGIN_WITH_EMAIL');
+               return '{--ADMIN_NO_LOGIN_WITH_EMAIL--}';
        } // END - if
 
        // Load all data
@@ -1103,20 +1121,20 @@ function sendAdminPasswordResetLink ($email) {
        SQL_FREERESULT($result);
 
        // Generate hash for reset link
-       $content['hash'] = generateHash(getConfig('URL') . ':' . $content['id'] . ':' . $content['login'] . ':' . $content['password'], substr($content['password'], 10));
+       $content['hash'] = generateHash(getUrl() . ':' . $content['id'] . ':' . $content['login'] . ':' . $content['password'], substr($content['password'], 10));
 
        // Remove some data
        unset($content['id']);
        unset($content['password']);
 
        // Prepare email
-       $mailText = loadEmailTemplate('admin_reset_password', $content);
+       $mailText = loadEmailTemplate('form_reset_password', $content);
 
        // Send it out
-       sendEmail($email, getMessage('ADMIN_RESET_PASS_LINK_SUBJ'), $mailText);
+       sendEmail($email, '{--ADMIN_RESET_PASS_LINK_SUBJECT--}', $mailText);
 
        // Prepare output
-       return getMessage('ADMIN_RESET_LINK_SENT');
+       return '{--ADMIN_RESET_LINK_SENT--}';
 }
 
 // Validate hash and login for password reset
@@ -1134,7 +1152,7 @@ function adminResetValidateHashLogin ($hash, $login) {
                $content = SQL_FETCHARRAY($result);
 
                // Generate hash again
-               $hashFromData = generateHash(getConfig('URL') . ':' . $content['id'] . ':' . $login . ':' . $content['password'], substr($content['password'], 10));
+               $hashFromData = generateHash(getUrl() . ':' . $content['id'] . ':' . $login . ':' . $content['password'], substr($content['password'], 10));
 
                // Does both match?
                $valid = ($hash == $hashFromData);
@@ -1157,10 +1175,10 @@ function doResetAdminPassword ($login, $password) {
                array($passHash, $login), __FUNCTION__, __LINE__);
 
        // Run filters
-       runFilterChain('post_admin_reset_pass', array('login' => $login, 'hash' => $passHash));
+       runFilterChain('post_form_reset_pass', array('login' => $login, 'hash' => $passHash));
 
        // Return output
-       return getMessage('ADMIN_PASSWORD_RESET_DONE');
+       return '{--ADMIN_PASSWORD_RESET_DONE--}';
 }
 
 // Solves a task by given id number
@@ -1186,7 +1204,7 @@ function adminUpdateTaskData ($id, $row, $data) {
        // Is the id not set, then we need a backtrace here... :(
        if ($id <= 0) {
                // Initiate backtrace
-               debug_report_bug(sprintf("id is invalid: %s. row=%s, data=%s",
+               debug_report_bug(__FUNCTION__, __LINE__, sprintf("id is invalid: %s. row=%s, data=%s",
                        $id,
                        $row,
                        $data
@@ -1226,7 +1244,7 @@ function setAdminMenuHasEntries ($action, $hasEntries) {
 // Creates a link to the user's admin-profile
 function adminCreateUserLink ($userid) {
        // Is the userid set correctly?
-       if ($userid > 0) {
+       if (isValidUserId($userid)) {
                // Create a link to that profile
                return '{%url=modules.php?module=admin&amp;what=list_user&amp;userid=' . bigintval($userid) . '%}';
        } // END - if
@@ -1238,7 +1256,7 @@ function adminCreateUserLink ($userid) {
 // Generate a "link" for the given admin id (admin_id)
 function generateAdminLink ($adminId) {
        // No assigned admin is default
-       $adminLink = '<span class="admin_note">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>';
+       $adminLink = '<span class="notice">{--ADMIN_NO_ADMIN_ASSIGNED--}</span>';
 
        // Zero? = Not assigned
        if (bigintval($adminId) > 0) {
@@ -1253,11 +1271,11 @@ function generateAdminLink ($adminId) {
                                $adminLink = '<a href="' . generateEmailLink(getAdminEmail($adminId), 'admins') . '" title="{--ADMIN_CONTACT_LINK_TITLE--}">' . $login . '</a>';
                        } else {
                                // Extension not found
-                               $adminLink = getMaskedMessage('EXTENSION_PROBLEM_NOT_INSTALLED', 'admins');
+                               $adminLink = getMaskedMessage('ADMIN_TASK_ROW_EXTENSION_NOT_INSTALLED', 'admins');
                        }
                } else {
                        // Maybe deleted?
-                       $adminLink = '<div class="admin_note">' . getMaskedMessage('ADMIN_ID_404', $adminId) . '</div>';
+                       $adminLink = '<div class="notice">' . getMaskedMessage('ADMIN_ID_404', $adminId) . '</div>';
                }
        } // END - if
 
@@ -1326,12 +1344,89 @@ function doVerifyExpertSettings () {
        // Output message for other status than ask/agreed
        if (($return != 'ask') && ($return != 'agreed')) {
                // Output message
-               loadTemplate('admin_settings_saved', false, getMessage('ADMIN_EXPERT_SETTINGS_STATUS_' . strtoupper($return)));
+               loadTemplate('admin_settings_saved', false, '{--ADMIN_EXPERT_SETTINGS_STATUS_' . strtoupper($return) . '--}');
        } // END - if
 
        // Return status
        return $return;
 }
 
+// Generate link to unconfirmed mails for admin
+function generateUnconfirmedAdminLink ($id, $unconfirmed, $type = 'bid') {
+       // Init output
+       $OUT = $unconfirmed;
+
+       // Do we have unconfirmed mails?
+       if ($unconfirmed > 0) {
+               // Add link to list_unconfirmed what-file
+               $OUT = '<a href="{%url=modules.php?module=admin&amp;what=list_unconfirmed&amp;' . $type . '=' . $id . '%}">' . translateComma($unconfirmed) . '</a>';
+       } // END - if
+
+       // Return it
+       return $OUT;
+}
+
+// Generates a navigation row for listing emails
+function addEmailNavigation ($numPages, $offset, $show_form, $colspan, $return=false) {
+       // Don't do anything if $numPages is 1
+       if ($numPages == 1) {
+               // Abort here with empty content
+               return '';
+       } // END - if
+
+       $TOP = '';
+       if ($show_form === false) {
+               $TOP = ' top';
+       } // END - if
+
+       $NAV = '';
+       for ($page = 1; $page <= $numPages; $page++) {
+               // Is the page currently selected or shall we generate a link to it?
+               if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
+                       // Is currently selected, so only highlight it
+                       $NAV .= '<strong>-';
+               } else {
+                       // Open anchor tag and add base URL
+                       $NAV .= '<a href="{%url=modules.php?module=admin&amp;what=' . getWhat() . '&amp;page=' . $page . '&amp;offset=' . $offset;
+
+                       // Add userid when we shall show all mails from a single member
+                       if ((isGetRequestParameterSet('userid')) && (isValidUserId(getRequestParameter('userid')))) $NAV .= '&amp;userid=' . bigintval(getRequestParameter('userid'));
+
+                       // Close open anchor tag
+                       $NAV .= '%}">';
+               }
+               $NAV .= $page;
+               if (($page == getRequestParameter('page')) || ((!isGetRequestParameterSet('page')) && ($page == 1))) {
+                       // Is currently selected, so only highlight it
+                       $NAV .= '-</strong>';
+               } else {
+                       // Close anchor tag
+                       $NAV .= '</a>';
+               }
+
+               // Add seperator if we have not yet reached total pages
+               if ($page < $numPages) {
+                       // Add it
+                       $NAV .= '|';
+               } // END - if
+       } // END - for
+
+       // Define constants only once
+       $content['nav']  = $NAV;
+       $content['span'] = $colspan;
+       $content['top']  = $TOP;
+
+       // Load navigation template
+       $OUT = loadTemplate('admin_email_nav_row', true, $content);
+
+       if ($return === true) {
+               // Return generated HTML-Code
+               return $OUT;
+       } else {
+               // Output HTML-Code
+               outputHtml($OUT);
+       }
+}
+
 // [EOF]
 ?>