./inc/mails/doubler_mails.php:53:// @TODO Can this be rewritten to a filter?
./inc/module-functions.php:267: // @TODO Nothing helped???
./inc/module-functions.php:308: // @TODO Rewrite this to a filter
-./inc/modules/admin/admin-inc.php:1159: // @TODO WHERE is not yet supported
-./inc/modules/admin/admin-inc.php:1213: // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided
+./inc/modules/admin/admin-inc.php:1227: // @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided
./inc/modules/admin/admin-inc.php:171: // @TODO This and the next getCurrentAdminId() call might be moved into the templates?
./inc/modules/admin/admin-inc.php:242: // @TODO This can be rewritten into a filter
./inc/modules/admin/admin-inc.php:274: // @TODO Rewrite this to $content = SQL_FETCHARRAY()
$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['where_select_list'] = array();
}
+// Handles the XML node 'where-select-from-list-entry'
+function doXmlWhereSelectFromListEntry ($resource, $attributes) {
+ // There are five attributes, by default
+ if (count($attributes) != 5) {
+ // Not the right count
+ debug_report_bug(__FUNCTION__, __LINE__, 'Expected 5 attributes, got ' . count($attributes));
+ } elseif (!isset($attributes['TYPE'])) {
+ // 'TYPE' not found
+ debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
+ } elseif (!isset($attributes['TABLE'])) {
+ // 'TABLE' not found
+ debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TABLE not found.');
+ } elseif (!isset($attributes['VALUE'])) {
+ // 'VALUE' not found
+ debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
+ } elseif (!isset($attributes['CONDITION'])) {
+ // 'CONDITION' not found
+ debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute CONDITION not found.');
+ } elseif (!isset($attributes['LOOK-FOR'])) {
+ // 'LOOK-FOR' not found
+ debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute LOOK-FOR not found.');
+ } elseif (!isInvalidXmlType($attributes['TYPE'])) {
+ // No valid type
+ debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
+ } elseif ((trim($attributes['TABLE']) != '') && (!isXmlValueValid($attributes['TYPE'], $attributes['TABLE']))) {
+ // 'TABLE' not valid/verifyable
+ debug_report_bug(__FUNCTION__, __LINE__, 'Attribute TABLE does not validate. TABLE=' . $attributes['TABLE']);
+ } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) {
+ // 'VALUE' not valid/verifyable
+ debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. VALUE=' . $attributes['VALUE']);
+ } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['CONDITION'])) {
+ // 'CONDITION' not valid/verifyable
+ debug_report_bug(__FUNCTION__, __LINE__, 'Attribute CONDITION does not validate. CONDITION=' . $attributes['CONDITION']);
+ } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['LOOK-FOR'])) {
+ // 'LOOK-FOR' not valid/verifyable
+ debug_report_bug(__FUNCTION__, __LINE__, 'Attribute LOOK-FOR does not validate. LOOK-FOR=' . $attributes['LOOK-FOR']);
+ } elseif (!isXmlConditionValid($attributes['CONDITION'])) {
+ // 'CONDITION' is not known
+ debug_report_bug(__FUNCTION__, __LINE__, 'Attribute CONDITION is not valid. LOOK-FOR=' . $attributes['CONDITION']);
+ } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction']['data_column_list'])) {
+ // doXmlCallbackFunction is missing
+ debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node callback-function/data-column-list not included around this node. Please fix your XML.');
+ }
+
+ // Add the entry to the array
+ addXmlValueToCallbackAttributes('where_select_list', $attributes);
+}
+
// Handles the XML node 'order-by-list'
function doXmlOrderByList ($resource, $attributes) {
// There should be no attributes
} elseif (!isset($attributes['TYPE'])) {
// 'TYPE' not found
debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TYPE not found.');
- } elseif (!isInvalidXmlType($attributes['TYPE'])) {
- // No valid type
- debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
} elseif (!isset($attributes['TABLE'])) {
// 'TABLE' not found
debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute TABLE not found.');
} elseif (!isset($attributes['VALUE'])) {
// 'VALUE' not found
debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.');
+ } elseif (!isInvalidXmlType($attributes['TYPE'])) {
+ // No valid type
+ debug_report_bug(__FUNCTION__, __LINE__, 'TYPE is not valid, got: ' . $attributes['TYPE']);
} elseif (!isXmlValueValid($attributes['TYPE'], $attributes['ORDER'])) {
// 'ORDER' not valid/verifyable
debug_report_bug(__FUNCTION__, __LINE__, 'Attribute ORDER does not validate. ORDER=' . $attributes['ORDER']);
/* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ' - ANALYSING...');
if (trim($attributes['NAME']) == '') {
// Numerical index
- /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NUMERICAL!');
+ /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NUMERICAL!');
$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][] = $attributes['VALUE'];
} elseif (!empty($key)) {
// Use from $key
- /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - KEY! (key=' . $attributes[$key] . ')');
+ /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - KEY! (key=' . $attributes[$key] . ')');
$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][$attributes[$key]] = $attributes['VALUE'];
} else {
// Use from NAME
- /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NAME! (NAME=' . $attributes['NAME'] . ')');
+ /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NAME! (NAME=' . $attributes['NAME'] . ')');
$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$extraKey][$attributes['NAME']] = $attributes['VALUE'];
}
} elseif ((isset($attributes['FUNCTION'])) && (isset($attributes['ALIAS']))) {
);
// Add the entry
- /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'].',ALIAS[' . gettype($attributes['ALIAS']) . ']=' . $attributes['ALIAS'] . ',FUNCTION[' . gettype($attributes['FUNCTION']) . ']=' . $attributes['FUNCTION'] . ' - FUNCTION! (VALUE=' . $attributes['VALUE'] . ')');
+ /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',ALIAS[' . gettype($attributes['ALIAS']) . ']=' . $attributes['ALIAS'] . ',FUNCTION[' . gettype($attributes['FUNCTION']) . ']=' . $attributes['FUNCTION'] . ' - FUNCTION! (VALUE=' . $attributes['VALUE'] . ')');
+ $GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][] = $array;
+ } elseif ((isset($attributes['CONDITION'])) && (isset($attributes['LOOK-FOR']))) {
+ // CONDITION/LOOK-FOR detected
+ // Init array
+ $array = array(
+ 'column' => trim($attributes['VALUE']),
+ 'table' => trim($attributes['TABLE']),
+ 'condition' => convertXmlContion(trim($attributes['CONDITION'])),
+ 'look_for' => trim($attributes['LOOK-FOR'])
+ );
+
+ /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',CONDITION[' . gettype($attributes['CONDITION']) . ']=' . $attributes['CONDITION'] . ',LOOK-FOR[' . gettype($attributes['LOOK-FOR']) . ']=' . $attributes['LOOK-FOR'] . ' - CONDITION! (VALUE=' . $attributes['VALUE'] . ')');
$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][] = $array;
} elseif (isset($attributes['CALLBACK'])) {
// CALLBACK/VALUE detected
- /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'].',CALLBACK[' . gettype($attributes['CALLBACK']) . ']=' . $attributes['CALLBACK'] . ' - CALLBACK! (VALUE=' . $attributes['VALUE'] . ')');
+ /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',CALLBACK[' . gettype($attributes['CALLBACK']) . ']=' . $attributes['CALLBACK'] . ' - CALLBACK! (VALUE=' . $attributes['VALUE'] . ')');
$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['VALUE']] = $attributes['CALLBACK'];
} elseif (isset($attributes['ORDER'])) {
// ORDER/TABLE detected
- /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'].',ORDER[' . gettype($attributes['ORDER']) . ']=' . $attributes['ORDER'] . ' - ORDER! (VALUE=' . $attributes['VALUE'] . ')');
+ /* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE=' . $attributes['TYPE'] . ',ORDER[' . gettype($attributes['ORDER']) . ']=' . $attributes['ORDER'] . ' - ORDER! (VALUE=' . $attributes['VALUE'] . ')');
$GLOBALS['__XML_ARGUMENTS']['doXmlCallbackFunction'][$element][$attributes['ORDER']][$attributes['TABLE']] = $attributes['VALUE'];
} elseif (isset($attributes['COLUMN'])) {
// COLUMN/VALUE detected
// Do we have entries from whereColumns to add?
if (count($whereColumns) > 0) {
// Then add these as well
- // @TODO WHERE is not yet supported
- debug_report_bug(__FUNCTION__, __LINE__, 'Unfinished area, please report your XML to the forums or bug tracker. tableTemplate=' . $tableTemplate . ',rowTemplate=' . $rowTemplate . ',tableName[0]=' . $tableName[0]);
+ 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.');
+ }
} // END - if
// Do we have entries from orderByColumns to add?
}
// Do the listing of entries
-function doAdminListEntries($SQL, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters = array()) {
+function doAdminListEntries ($SQL, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters = array()) {
// Run the SQL query
$result = SQL_QUERY($SQL, __FUNCTION__, __LINE__);
}
}
-// List all URLs
-$result = SQL_QUERY("SELECT
- `url_id`,
- `url_userid`,
- `url`,
- UNIX_TIMESTAMP(`url_registered`) AS `url_registered`
-FROM
- `{?_MYSQL_PREFIX?}_surfbar_urls`
-WHERE
- `url_status`='PENDING'
-ORDER BY
- `url_id` ASC", __FILE__, __LINE__);
-
-// Do we have some URLs left?
-if (!SQL_HASZERONUMS($result)) {
- // List all URLs
- $OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
- // "Translate"/add content
- $content['url_registered'] = generateDateTime($content['url_registered'], 2);
-
- // Load row template
- $OUT .= loadTemplate('admin_unlock_surfbar_urls_row', true, $content);
- } // END - while
-
- // Load main template
- loadTemplate('admin_unlock_surfbar_urls', false, $OUT);
-} else {
- // No URLs in surfbar
- displayMessage('{--ADMIN_SURFBAR_NO_URLS_FOUND--}');
-}
-
-// Free result
-SQL_FREERESULT($result);
+// List all pendingURLs
+showEntriesByXmlCallback('admin_unlock_surfbar_urls');
// [EOF]
?>
return (in_array($type, array('string', 'array', 'bool', 'int')));
}
+// Checks if given condition is valid
+function isXmlConditionValid ($condition) {
+ // Trim and make lower-case
+ $condition = trim(strtolower($condition));
+
+ // Is it valid?
+ return (in_array($condition, array('equals')));
+}
+
// Checks if given value is valid/verifyable
function isXmlValueValid ($type, $value) {
// Depends on type, so build a call-back
return call_user_func_array($callbackFunction, array($value));
}
+// Converts given condition into a symbol
+function convertXmlContion ($condition) {
+ // Default is an invalid one
+ $return = '???';
+
+ // Detect the condition again
+ switch ($condition) {
+ case 'EQUALS': // Equals
+ $return = '=';
+ break;
+
+ default: // Unknown condition
+ debug_report_bug(__FUNCTION__, __LINE__, 'Condition ' . $condition . ' is unknown/unsupported.');
+ break;
+ } // END - switch
+
+ // Return it
+ return $return;
+}
+
// [EOF]
?>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+This template provides meta data for unlocking URLs of the surfbar in the admin
+area.
+
+@author Roland Haeder <webmaster@mxchange.org>
+@version 0.2.1-FINAL
+@copyright (c) 2003 - 2009 by Roland Haeder
+@copyright (c) 2009 - 2011 by Mailer Developer Team
+@license GNU GPL 2.0 or any newer version
+@link http://www.mxchange.org
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+MA 02110-1301 USA
+//-->
+<admin-list-data>
+ <!--
+ Call-back function, the extracted data from this XML will then be re-read
+ from that function. The most common function this XML uses is
+ adminListEntries() so mostly you can leave this alone unless you have JOINs.
+ //-->
+ <callback-function type="string" value="adminListEntries" />
+ <!--
+ Now we need information which template should be loaded and which functions
+ shall be called back. So lets start with the main list template. This mostly
+ requires no call-back function.
+ //-->
+ <list-template type="string" value="admin_unlock_surfbar_urls" />
+ <!--
+ The template for all rows, mostly this name has a '_row' suffix and again,
+ no call-back function is usually required.
+ //-->
+ <list-row-template type="string" value="admin_unlock_surfbar_urls_row" />
+ <!--
+ Message id to display if no entry could be found
+ //-->
+ <no-entry-found-message type="string" value="ADMIN_SURFBAR_URLS_404" />
+ <!--
+ The table(s) we shall grab the data from, all as list.
+ //-->
+ <data-tables>
+ <!--
+ A single table entry, with alias and without the configurable
+ _MYSQL_PREFIX. You can specify the table's name or alias later on.
+ //-->
+ <data-table type="string" alias="" value="surfbar_urls" />
+ <!--
+ Columns to perform the SELECT statement on, with alias and name plus which table.
+ //-->
+ <select-data-from-list>
+ <!--
+ A single entry with table name (can be left empty), value (must
+ always be set), alias (again can be left empty) and SQL function
+ (can also be left empty) which shall be applied on the column.
+ //-->
+ <select-data-from-list-entry type="string" table="" value="url_id" alias="" function="" />
+ <select-data-from-list-entry type="string" table="" value="url_userid" alias="" function="" />
+ <select-data-from-list-entry type="string" table="" value="url" alias="" function="" />
+ <select-data-from-list-entry type="string" table="" value="url_registered" alias="url_registered" function="UNIX_TIMESTAMP" />
+ </select-data-from-list>
+ <!--
+ And the column list to perform the WHERE statement on.
+ //-->
+ <where-select-from-list>
+ <!--
+ A single entry to perform the WHERE statement on:
+ - table = table name (or alias)
+ - value = column name
+ - condition = look-up condition
+ - look-for = What to look for
+ //-->
+ <where-select-from-list-entry type="string" table="" value="url_status" condition="EQUALS" look-for="PENDING" />
+ </where-select-from-list>
+ <!--
+ Columns to perform the ORDER BY statement (GROUP BY is not yet supported)
+ //-->
+ <order-by-list>
+ <!--
+ A single entry to perform the ORDER BY statement on, see above WHERE entry for details.
+ //-->
+ <order-by-list-entry type="string" table="" order="url_id" value="ASC" />
+ </order-by-list>
+ </data-tables>
+ <!--
+ List all column names from the 'select-data-from-list' node here, but now
+ with call-back informations. The list must only contain those entries where
+ a call-back function shall be called for.
+ //-->
+ <column-callback-list>
+ <!--
+ Another column, now we need a second parameter here because
+ generateDateTime() expects two parameters (first is always the data
+ from column).
+ //-->
+ <column-callback-list-entry>
+ <!--
+ The actual data, again.
+ //-->
+ <column-callback-data type="string" value="url_registered" callback="generateDateTime" />
+ <!--
+ More parameters, remember that the first parameter is always given
+ and that it is the data from column.
+ //-->
+ <callback-extra-parameter-list>
+ <!--
+ A single parameter, 'type' can be one of 'float', 'int',
+ 'bool', 'string'. 'array' is not yet supported.
+ //-->
+ <callback-extra-parameter-list-entry type="int" column="url_registered" value="2" />
+ </callback-extra-parameter-list>
+ </column-callback-list-entry>
+ </column-callback-list>
+</admin-list-data>
<!--
A single entry to perform the WHERE statement on:
- table = table name (or alias)
- - name = column name
+ - value = column name
- condition = look-up condition
- look-for = What to look for
//-->
- <where-select-from-list-entry type="string" table="dt" name="userid" condition="EQUALS" look-for="$userid" />
+ <where-select-from-list-entry type="string" table="dt" value="userid" condition="EQUALS" look-for="$userid" />
<!--
How the next described column shall be logical linked to the above.
//-->