+// Adds a given entry to the database
+function adminAddEntries ($tableName, $columns = array(), $filterFunctions = array(), $extraValues = array()) {
+ //* DEBUG: */ die('columns=<pre>'.print_r($columns,true).'</pre>,filterFunctions=<pre>'.print_r($filterFunctions,true).'</pre>,extraValues=<pre>'.print_r($extraValues,true).'</pre>,POST=<pre>'.print_r($_POST,true).'</pre>');
+ // Verify that tableName and columns are not empty
+ if ((!is_array($tableName)) || (count($tableName) != 1)) {
+ // No tableName specified
+ debug_report_bug(__FUNCTION__, __LINE__, 'tableName is not given. Please fix your XML,tableName[]=' . gettype($tableName) . '!=array');
+ } elseif (count($columns) == 0) {
+ // No columns specified
+ debug_report_bug(__FUNCTION__, __LINE__, 'columns is not given. Please fix your XML.');
+ }
+
+ // Init columns and value elements
+ $sqlColumns = array();
+ $sqlValues = array();
+
+ // Add columns and values
+ foreach ($columns as $key=>$columnName) {
+ // Copy entry to final arrays
+ $sqlColumns[$key] = $columnName;
+ $sqlValues[$key] = postRequestParameter($columnName);
+ //* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key='.$key.',columnName='.$columnName.',filterFunctions='.$filterFunctions[$key].',extraValues='.intval(isset($extraValues[$key])).',extraValuesName='.intval(isset($extraValues[$columnName . '_list'])).'<br />');
+
+ // Send data through the filter function if found
+ if ((isset($filterFunctions[$key])) && (isset($extraValues[$key . '_list']))) {
+ // Filter function set!
+ $sqlValues[$key] = call_user_func_array($filterFunctions[$key], merge_array(array($columnName), $extraValues[$key . '_list']));
+ } // END - if
+ } // END - foreach
+
+ // Build the SQL query
+ $SQL = 'INSERT INTO `{?_MYSQL_PREFIX?}_' . $tableName[0] . '` (`' . implode('`, `', $sqlColumns) . "`) VALUES('" . implode("','", $sqlValues) . "')";
+
+ // Run the SQL query
+ SQL_QUERY($SQL, __FUNCTION__, __LINE__);
+
+ // Entry has been added?
+ if (!SQL_HASZEROAFFECTED()) {
+ // Display success message
+ displayMessage('{--ADMIN_ENTRY_ADDED--}');
+ } else {
+ // Display failed message
+ displayMessage('{--ADMIN_ENTRY_NOT_ADDED--}');
+ }
+}
+