Added (unfinished) a way to edit forced ads, rwritten many XML templates
[mailer.git] / inc / modules / admin / admin-inc.php
index a3f48e84807e750c7f283eb3606d99ae961abf23..e96285a86b54f800033f0906ea96f65b2153ac4e 100644 (file)
@@ -875,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
 
@@ -893,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
@@ -1115,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
@@ -1321,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($columnArray);
 
        // 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) {