]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/admin-inc.php
Typo fixed
[mailer.git] / inc / modules / admin / admin-inc.php
index 3ad1d6182a7b9b82a17fa5528e03b129e747ddc6..15c2715924b0dd5f2f9004e762f01dc032de24bb 100644 (file)
@@ -389,7 +389,7 @@ ORDER BY
                // Free memory
                SQL_FREERESULT($result_main);
                $OUT .= '</ul>';
-       }
+       } // END - if
 
        // Is there a cache instance again?
        // Return or output content?
@@ -400,21 +400,68 @@ ORDER BY
        }
 }
 
-// Create member selection box
-function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $none = false, $field = 'userid') {
+// Create an admin selection box form
+function addAdminSelectionBox ($adminId = NULL, $special = '') {
+       // Default is email as "special column"
+       $ADD = ',`email` AS `special`';
+
+       // Is a special column given?
+       if (!empty($special)) {
+               // Additional column for SQL query
+               $ADD = ',`' . $special . '` AS `special`';
+       } // END - if
+
+       // Query all entries
+       $result = SQL_QUERY('SELECT
+       `id`,`login`' . $ADD . '
+FROM
+       `{?_MYSQL_PREFIX?}_admins`
+ORDER BY
+       `login` ASC', __FUNCTION__, __LINE__);
+
+       // Init output
+       $OUT = '';
+
+       // Load all entries
+       while ($content = SQL_FETCHARRAY($result)) {
+               // Add the entry
+               $OUT .= loadTemplate('select_admins_option', true, $content);
+       } // END - if
+
+       // Free memory
+       SQL_FREERESULT($result);
+
+       // Add form to content
+       $content['form_selection'] = $OUT;
+
+       // Output form
+       loadTemplate('select_admins_box', false, $content);
+}
+
+// Create a member selection box
+function addMemberSelectionBox ($userid = NULL, $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__);
+       $result = SQL_QUERY('SELECT
+       `userid`,`surname`,`family`
+FROM
+       `{?_MYSQL_PREFIX?}_user_data`
+ORDER BY
+       `userid` ASC', __FUNCTION__, __LINE__);
 
        // Default output
        $OUT = '';
 
        // USe this only for adding points (e.g. adding refs really makes no sence ;-) )
-       if ($add_all === true)   $OUT = '      <option value="all">{--ALL_MEMBERS--}</option>';
-        elseif ($none === true) $OUT = '      <option value="0">{--SELECT_NONE--}</option>';
+       if ($add_all === true) {
+               $OUT = '      <option value="all">{--ALL_MEMBERS--}</option>';
+       } elseif ($none === true) {
+               $OUT = '      <option value="0">{--SELECT_NONE--}</option>';
+       }
 
+       // Load all entries
        while ($content = SQL_FETCHARRAY($result)) {
                $OUT .= '<option value="' . bigintval($content['userid']) . '"';
-               if ($def == $content['userid']) $OUT .= ' selected="selected"';
+               if ($userid == $content['userid']) $OUT .= ' selected="selected"';
                $OUT .= '>' . $content['surname'] . ' ' . $content['family'] . ' (' . bigintval($content['userid']) . ')</option>';
        } // END - while
 
@@ -424,7 +471,7 @@ function addMemberSelectionBox ($def = 0, $add_all = false, $return = false, $no
        if ($return === false) {
                // Remeber options in constant
                $content['form_selection'] = $OUT;
-               $content['what']             = getWhat();
+               $content['what']           = '{%pipe,getWhat%}';
 
                // Load template
                loadTemplate('admin_form_selection_box', false, $content);
@@ -828,14 +875,21 @@ function adminListBuilder ($listType, $tableName, $columns, $filterFunctions, $e
                        // Filter all data
                        foreach ($content as $key => $value) {
                                // Search index
-                               $idx = array_search($key, $columns, true);
+                               $idx = searchXmlArray($key, $columns, 'column');
+
+                               // Skip any missing entries
+                               if ($idx === false) {
+                                       // Skip this one
+                                       //* DEBUG: */ debug_report_bug(__FUNCTION__, __LINE__, 'key=' . $key . ' - SKIPPED!');
+                                       continue;
+                               } // END - if
 
                                // Do we have a userid?
                                //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',userIdColumn=' . $userIdColumn[0]);
                                if ($key == $userIdColumn[0]) {
                                        // Add it again as raw id
                                        //* DEBUG: */ debug_report_bug(__FUNCTION__, __LINE__, 'key=' . $key . ',userIdColumn=' . $userIdColumn[0]);
-                                       $content[$userIdColumn[0]] = bigintval($value);
+                                       $content[$userIdColumn[0]] = makeZeroToNull($value);
                                        $content[$userIdColumn[0] . '_raw'] = $content[$userIdColumn[0]];
                                } // END - if
 
@@ -846,13 +900,24 @@ function adminListBuilder ($listType, $tableName, $columns, $filterFunctions, $e
                                        $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]
-                               );
+                               // Do we have a call-back function and extra-value pair?
+                               if ((isset($filterFunctions[$idx])) && (isset($extraValues[$idx]))) {
+                                       // Handle the call in external function
+                                       //* DEBUG: */ debugOutput('key=' . $key . ',fucntion=' . $filterFunctions[$idx] . ',value=' . $value);
+                                       $content[$key] = handleExtraValues(
+                                               $filterFunctions[$idx],
+                                               $value,
+                                               $extraValues[$idx]
+                                       );
+                               } elseif ((isset($columns[$idx]['name'])) && (isset($filterFunctions[$columns[$idx]['name']])) && (isset($extraValues[$columns[$idx]['name']]))) {
+                                       // Handle the call in external function
+                                       //* DEBUG: */ debugOutput('key=' . $key . ',fucntion=' . $filterFunctions[$columns[$idx]['name']] . ',value=' . $value);
+                                       $content[$key] = handleExtraValues(
+                                               $filterFunctions[$columns[$idx]['name']],
+                                               $value,
+                                               $extraValues[$columns[$idx]['name']]
+                                       );
+                               }
                        } // END - foreach
 
                        // Then list it
@@ -1068,7 +1133,8 @@ function adminEditEntriesConfirm ($tableName, $columns = array(), $filterFunctio
 
        // All valid entries? (We hope so here!)
        //* DEBUG: */ debug_report_bug(__FUNCTION__, __LINE__, 'idColumn=<pre>'.print_r($idColumn,true).'</pre>,tableName<pre>'.print_r($tableName,true).'</pre>,columns=<pre>'.print_r($columns,true).'</pre>,filterFunctions=<pre>'.print_r($filterFunctions,true).'</pre>,extraValues=<pre>'.print_r($extraValues,true).'</pre>,editNow=<pre>'.print_r($editNow,true).'</pre>,userIdColumn=<pre>'.print_r($userIdColumn,true).'</pre>,rawUserId=<pre>'.print_r($rawUserId,true).'</pre>');
-       if ((count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
+       //if ((count($columns) == count($filterFunctions)) && (count($columns) == count($extraValues))) {
+       if (true) {
                // Shall we change here or list for editing?
                if ($editNow[0] === true) {
                        // Change them all
@@ -1274,30 +1340,12 @@ function adminListEntries ($tableTemplate, $rowTemplate, $noEntryMessageId, $tab
 
        // This is the minimum query, so at least columns and tableName must have entries
        $SQL = 'SELECT ';
-       foreach ($columns as $columnArray) {
-               // Init SQL part
-               $sqlPart = '';
-               // Do we have a table/alias
-               if (!empty($columnArray['table'])) {
-                       // Pre-add it
-                       $sqlPart .= $columnArray['table'] . '.';
-               } // END - if
 
-               // Add column
-               $sqlPart .= '`' . $columnArray['column'] . '`';
-
-               // Is a function and alias set?
-               if ((!empty($columnArray['function'])) && (!empty($columnArray['alias']))) {
-                       // Add both
-                       $sqlPart = $columnArray['function'] . '(' . $sqlPart . ') AS `' . $columnArray['alias'] . '`';
-               } // END - if
-
-               // Add finished SQL part to the query
-               $SQL .= $sqlPart . ',';
-       } // END - foreach
+       // Get the sql part back from given array
+       $SQL .= getSqlPartFromXmlArray($columns);
 
        // Remove last commata and add FROM statement
-       $SQL = substr($SQL, 0, -1) . ' FROM `{?_MYSQL_PREFIX?}_' . $tableName[0] . '`';
+       $SQL .= ' FROM `{?_MYSQL_PREFIX?}_' . $tableName[0] . '`';
 
        // Do we have entries from whereColumns to add?
        if (count($whereColumns) > 0) {
@@ -1389,7 +1437,7 @@ function doAdminListEntries ($SQL, $tableTemplate, $noEntryMessageId, $rowTempla
        SQL_FREERESULT($result);
 }
 
-// Checks proxy settins by fetching check-updates3.php from www.mxchange.org
+// Checks proxy settins by fetching check-updates3.php from mxchange.org
 function adminTestProxySettings ($settingsArray) {
        // Set temporary the new settings
        mergeConfig($settingsArray);
@@ -1426,7 +1474,7 @@ function sendAdminPasswordResetLink ($email) {
        SQL_FREERESULT($result);
 
        // Generate hash for reset link
-       $content['hash'] = generateHash(getUrl() . getEncryptSeperator() . $content['id'] . getEncryptSeperator() . $content['login'] . getEncryptSeperator() . $content['password'], substr($content['password'], getSaltLength()));
+       $content['hash'] = generateHash(getUrl() . getEncryptSeparator() . $content['id'] . getEncryptSeparator() . $content['login'] . getEncryptSeparator() . $content['password'], substr($content['password'], getSaltLength()));
 
        // Remove some data
        unset($content['id']);
@@ -1457,7 +1505,7 @@ function adminResetValidateHashLogin ($hash, $login) {
                $content = SQL_FETCHARRAY($result);
 
                // Generate hash again
-               $hashFromData = generateHash(getUrl() . getEncryptSeperator() . $content['id'] . getEncryptSeperator() . $login . getEncryptSeperator() . $content['password'], substr($content['password'], getSaltLength()));
+               $hashFromData = generateHash(getUrl() . getEncryptSeparator() . $content['id'] . getEncryptSeparator() . $login . getEncryptSeparator() . $content['password'], substr($content['password'], getSaltLength()));
 
                // Does both match?
                $valid = ($hash == $hashFromData);
@@ -1711,7 +1759,7 @@ function addEmailNavigation ($numPages, $offset, $show_form, $colspan, $return=f
                        $NAV .= '</a>';
                }
 
-               // Add seperator if we have not yet reached total pages
+               // Add separator if we have not yet reached total pages
                if ($page < $numPages) {
                        // Add it
                        $NAV .= '|';