+ adminListBuilder('undelete', $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn);
+ }
+ } // END - if
+}
+
+// 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] = postRequestElement($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--}');
+ }
+}
+
+// List all given rows (callback function from XML)
+function adminListEntries ($tableTemplate, $rowTemplate, $noEntryMessageId, $tableName, $columns, $whereColumns, $orderByColumns, $callbackColumns, $extraParameters = array()) {
+ // 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,tableTemplate=' . $tableTemplate . ',rowTemplate=' . $rowTemplate);
+ } elseif (count($columns) == 0) {
+ // No columns specified
+ debug_report_bug(__FUNCTION__, __LINE__, 'columns is not given. Please fix your XML,tableTemplate=' . $tableTemplate . ',rowTemplate=' . $rowTemplate . ',tableName[0]=' . $tableName[0]);
+ }
+
+ // This is the minimum query, so at least columns and tableName must have entries
+ $SQL = 'SELECT ';
+
+ // Get the sql part back from given array
+ $SQL .= getSqlPartFromXmlArray($columns);
+
+ // Remove last commata and add FROM statement
+ $SQL .= ' FROM `{?_MYSQL_PREFIX?}_' . $tableName[0] . '`';
+
+ // Do we have entries from whereColumns to add?
+ if (count($whereColumns) > 0) {
+ // Then add these as well
+ if (count($whereColumns) == 1) {
+ // One entry found
+ $SQL .= ' WHERE ';
+
+ // Table/alias included?
+ if (!empty($whereColumns[0]['table'])) {
+ // Add it as well
+ $SQL .= $whereColumns[0]['table'] . '.';
+ } // END - if
+
+ // Add the rest
+ $SQL .= '`' . $whereColumns[0]['column'] . '`' . $whereColumns[0]['condition'] . "'" . $whereColumns[0]['look_for'] . "'";
+ } else {
+ // More than one entry -> Unsupported
+ debug_report_bug(__FUNCTION__, __LINE__, 'More than one WHERE statement found. This is currently not supported.');