From: Roland Häder Date: Sat, 9 Jul 2011 03:35:11 +0000 (+0000) Subject: XML parser introduced, ext-surfbar rewritten, more EL code: X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=9197694ce183b69384a385a6c4a5e16988c7fb09 XML parser introduced, ext-surfbar rewritten, more EL code: - XML parser functions (see xml-functions.php) introduced which shall make it much easier in adding list/edit/delete/foo forms to the script by a XML rather than tons of hard-to-debug code or large call parameters - Extension ext-surfbar: Edit/delete/lock/unlock/undelete of URLs is now rewritten to make usage of above XML parser - For same extension, new translateFooToBar() wrappers has been introduced in EL code. - TODOs.txt updated --- diff --git a/.gitattributes b/.gitattributes index f58a98d396..35cdfce18e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -89,6 +89,7 @@ inc/cache/.htaccess svneol=native#text/plain inc/cache/_compiled/.htaccess svneol=native#text/plain inc/cache/_compiled/emails/.htaccess svneol=native#text/plain inc/cache/_compiled/html/.htaccess svneol=native#text/plain +inc/callback-functions.php svneol=native#text/plain inc/classes/.htaccess svneol=native#text/plain inc/classes/cachesystem.class.php svneol=native#text/plain inc/classes/rdf.class.php svneol=native#text/plain @@ -400,6 +401,7 @@ inc/modules/admin/action-country.php svneol=native#text/plain inc/modules/admin/action-coupon.php svneol=native#text/plain inc/modules/admin/action-doubler.php svneol=native#text/plain inc/modules/admin/action-email.php svneol=native#text/plain +inc/modules/admin/action-grade.php svneol=native#text/plain inc/modules/admin/action-holiday.php svneol=native#text/plain inc/modules/admin/action-login.php svneol=native#text/plain inc/modules/admin/action-logout.php svneol=native#text/plain @@ -1129,6 +1131,8 @@ templates/de/html/admin/admin_delete_payouts_row.tpl svneol=native#text/plain templates/de/html/admin/admin_delete_reflevel.tpl svneol=native#text/plain templates/de/html/admin/admin_delete_reflevel_row.tpl svneol=native#text/plain templates/de/html/admin/admin_delete_sponsor.tpl svneol=native#text/plain +templates/de/html/admin/admin_delete_surfbar_urls.tpl svneol=native#text/plain +templates/de/html/admin/admin_delete_surfbar_urls_row.tpl svneol=native#text/plain templates/de/html/admin/admin_delete_transfer_row.tpl svneol=native#text/plain templates/de/html/admin/admin_delete_user.tpl svneol=native#text/plain templates/de/html/admin/admin_edit_admin_menu.tpl svneol=native#text/plain diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index e3d4d8ea59..8032ea823a 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -36,12 +36,12 @@ ./inc/extensions/ext-network.php:93: // @TODO network_type_handle is an internal name and needs documentation ./inc/extensions/ext-newsletter.php:218: // @TODO Move these into configuration ./inc/extensions/ext-order.php:358: // @TODO This should be moved out to inc/daily/ -./inc/extensions/ext-rallye.php:329: // @TODO Move this code into a hook -./inc/extensions/ext-rallye.php:92: // @TODO Fix config_rallye_prices to list_rallye_prices +./inc/extensions/ext-rallye.php:331: // @TODO Move this code into a hook +./inc/extensions/ext-rallye.php:94: // @TODO Fix config_rallye_prices to list_rallye_prices ./inc/extensions/ext-yoomedia.php:121: // @TODO Can this be moved into a database table? ./inc/extensions/ext-yoomedia.php:54:// @TODO Only deprecated when 'ext-network' is ready! setExtensionDeprecated('Y'); ./inc/extensions-functions.php:155: // @TODO Do we still need this? setExtensionUpdateNotes(''); -./inc/extensions-functions.php:1939:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' +./inc/extensions-functions.php:1944:// @TODO This should be rewrittten to allow, more development states, e.g. 'planing','alpha','beta','beta2','stable' ./inc/extensions-functions.php:425:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) ) ./inc/extensions-functions.php:562: // @TODO Extension is loaded, what next? ./inc/filter/bonus_filter.php:56: // @TODO This query isn't right, it will only update if the user was for a longer time away! @@ -80,10 +80,10 @@ ./inc/libs/register_functions.php:367: // @TODO Wether the registration bonus should only be added to user directly or through referal system should be configurable ./inc/libs/sponsor_functions.php:159: // @TODO Rewrite this to API function ./inc/libs/sponsor_functions.php:430: // @TODO Rewrite this to API function -./inc/libs/surfbar_functions.php:1026: // @TODO Try to rewrite the following unset() -./inc/libs/surfbar_functions.php:1541: // @TODO This can be somehow rewritten -./inc/libs/surfbar_functions.php:710:// @TODO Can't we use our new expression language instead of this ugly code? -./inc/libs/surfbar_functions.php:951: // @TODO Invalid salt should be refused +./inc/libs/surfbar_functions.php:1072: // @TODO Try to rewrite the following unset() +./inc/libs/surfbar_functions.php:1587: // @TODO This can be somehow rewritten +./inc/libs/surfbar_functions.php:708:// @TODO Can't we use our new expression language instead of this ugly code? +./inc/libs/surfbar_functions.php:997: // @TODO Invalid salt should be refused ./inc/libs/task_functions.php:240: // @TODO These can be rewritten to filter ./inc/libs/task_functions.php:51:// @TODO Move all extension-dependent queries into filters ./inc/libs/theme_functions.php:93: // @TODO Can't this be rewritten to an API function? @@ -305,11 +305,15 @@ ./templates/de/html/admin/admin_config_payouts_del.tpl:1: ./templates/de/html/admin/admin_config_payouts_edit_row.tpl:1: ./templates/de/html/admin/admin_config_payouts_edit.tpl:1: +./templates/de/html/admin/admin_del_surfbar_urls_row.tpl:1: +./templates/de/html/admin/admin_del_surfbar_urls.tpl:1: ./templates/de/html/admin/admin_list_cats_404.tpl:1: ./templates/de/html/admin/admin_list_chk_reg_row.tpl:1: ./templates/de/html/admin/admin_list_chk_reg.tpl:1: ./templates/de/html/admin/admin_reset_pass_done.tpl:1: ./templates/de/html/admin/admin_send_reset_link.tpl:1: +./templates/xml/admin/admin_del_do_surfbar_urls.xml:1: +./templates/xml/admin/admin_del_show_surfbar_urls.xml:1: ### ### template-warnings.log follows: ### ### Warning: Not parsing JavaScript templates/de/html/js/js_order_send.tpl. Warning: Not parsing JavaScript templates/de/html/js/js_cookies_disabled.tpl. diff --git a/inc/callback-functions.php b/inc/callback-functions.php new file mode 100644 index 0000000000..98f19e24b2 --- /dev/null +++ b/inc/callback-functions.php @@ -0,0 +1,586 @@ + 0) { + // Please don't add any attributes to foo-list nodes + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes)); + } // END - if + + // Add an empty list + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['column_list'] = array(); +} + +// Handles the XML node 'database-column-list-entry' +function doXmlDatabaseColumnListEntry ($resource, $attributes) { + // There are three attributes, by default + if (count($attributes) != 3) { + // Not the right count + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes)); + } elseif (!isset($attributes['NAME'])) { + // 'NAME' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.'); + } 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['VALUE'])) { + // 'VALUE' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.'); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) { + // Not valid/verifyable + debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['column_list'])) { + // doXmlAdminCallbackFunction is missing + debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/database-column-list not included around this node. Please fix your XML.'); + } + + // Add the entry to the list + addXmlValueToCallbackAttributes('column_list', $attributes); +} + +// Handles the XML node 'callback-function-list' +function doXmlCallbackFunctionList ($resource, $attributes) { + // There should be no attributes + if (count($attributes) > 0) { + // Please don't add any attributes to foo-list nodes + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes)); + } // END - if + + // Add an empty list + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['callback_list'] = array(); +} + +// Handles the XML node 'callback-function-list-entry' +function doXmlCallbackFunctionListEntry ($resource, $attributes) { + // There are three attributes, by default + if (count($attributes) != 3) { + // Not the right count + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes)); + } elseif (!isset($attributes['NAME'])) { + // 'NAME' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.'); + } 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['VALUE'])) { + // 'VALUE' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.'); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) { + // Not valid/verifyable + debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['callback_list'])) { + // doXmlAdminCallbackFunction is missing + debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/callback-function-list not included around this node. Please fix your XML.'); + } + + // Add the entry to the list + addXmlValueToCallbackAttributes('callback_list', $attributes); +} + +// Handles the XML node 'extra-parameter-list' +function doXmlExtraParameterList ($resource, $attributes) { + // There should be no attributes + if (count($attributes) > 0) { + // Please don't add any attributes to foo-list nodes + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes)); + } // END - if + + // Add an empty list + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['extra_list'] = array(); +} + +// Handles the XML node 'extra-parameter-list-entry' +function doXmlExtraParameterListEntry ($resource, $attributes) { + // There are three attributes, by default + if (count($attributes) != 3) { + // Not the right count + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes)); + } elseif (!isset($attributes['NAME'])) { + // 'NAME' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.'); + } 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['VALUE'])) { + // 'VALUE' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.'); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) { + // Not valid/verifyable + debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['extra_list'])) { + // doXmlAdminCallbackFunction is missing + debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/extra-parameter-list not included around this node. Please fix your XML.'); + } + + // Add the entry to the list + addXmlValueToCallbackAttributes('extra_list', $attributes); +} + +// Handles the XML node 'extra-parameter-member-list' +function doXmlExtraParameterMemberList ($resource, $attributes) { + // There should be no attributes + if (count($attributes) > 0) { + // Please don't add any attributes to foo-list nodes + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes)); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['extra_list']['member_list'])) { + // This list should be created already + debug_report_bug(__FUNCTION__, __LINE__, 'member_list should be already created.'); + } +} + +// Handles the XML node 'extra-parameter-member-list-entry' +function doXmlExtraParameterMemberListEntry ($resource, $attributes) { + // There are three attributes, by default + if (count($attributes) != 3) { + // Not the right count + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes)); + } elseif (!isset($attributes['NAME'])) { + // 'NAME' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.'); + } 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['VALUE'])) { + // 'VALUE' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.'); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) { + // Not valid/verifyable + debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['extra_list']['member_list'])) { + // doXmlAdminCallbackFunction is missing + debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/extra-parameter-list/member-list not included around this node. Please fix your XML.'); + } + + // Add the entry to the list + addXmlValueToCallbackAttributes('extra_list', $attributes, 'member_list'); +} + +// Handles the XML node 'status-change-column' +function doXmlStatusChangeColumn ($resource, $attributes) { + // There are three attributes, by default + if (count($attributes) != 3) { + // Not the right count + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes)); + } elseif (!isset($attributes['NAME'])) { + // 'NAME' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.'); + } 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['VALUE'])) { + // 'VALUE' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.'); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) { + // Not valid/verifyable + debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) { + // doXmlAdminCallbackFunction is missing + debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.'); + } + + // Add the entry to the list + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['status_list'][$attributes['VALUE']] = array(); +} + +// Handles the XML node 'status-change-list' +function doXmlStatusChangeList ($resource, $attributes) { + // There should be no attributes + if (count($attributes) > 0) { + // Please don't add any attributes to foo-list nodes + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 0 attributes because this is a foo-list node, got ' . count($attributes)); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['status_list'])) { + // doXmlAdminCallbackFunction is missing + debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/status-list not included around this node. Please fix your XML.'); + } +} + +// Handles the XML node 'status-change-list-entry' +function doXmlStatusChangeListEntry ($resource, $attributes) { + // There are for attributes, by default + if (count($attributes) != 4) { + // Not the right count + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 4 attributes, got ' . count($attributes)); + } elseif (!isset($attributes['NAME'])) { + // 'NAME' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.'); + } 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['VALUE'])) { + // 'VALUE' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.'); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['OLD'])) { + // Not valid/verifyable + debug_report_bug(__FUNCTION__, __LINE__, 'Attribute OLD does not validate. TYPE=' . $attributes['TYPE'] . ',OLD=' . $attributes['OLD']); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) { + // Not valid/verifyable + debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['status_list'])) { + // doXmlAdminCallbackFunction is missing + debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function/extra-parameter-list/member-list not included around this node. Please fix your XML.'); + } + + // Add the entry to the list + addXmlValueToCallbackAttributes('status_list', $attributes, $attributes['NAME'], 'OLD'); +} + +// Handles the XML node 'enable-modify-entries' +function doXmlEnableModifyEntries ($resource, $attributes) { + // There are three attributes, by default + if (count($attributes) != 3) { + // Not the right count + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes)); + } elseif (!isset($attributes['NAME'])) { + // 'NAME' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.'); + } 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['VALUE'])) { + // 'VALUE' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.'); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) { + // Not valid/verifyable + debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) { + // doXmlAdminCallbackFunction is missing + debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.'); + } + + // Add the entry to the array + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['enable_modify_entries'] = convertStringToBoolean($attributes['VALUE']); +} + +// Handles the XML node 'table-id-column' +function doXmlTableIdColumn ($resource, $attributes) { + // There are three attributes, by default + if (count($attributes) != 3) { + // Not the right count + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes)); + } elseif (!isset($attributes['NAME'])) { + // 'NAME' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.'); + } 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['VALUE'])) { + // 'VALUE' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.'); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) { + // Not valid/verifyable + debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) { + // doXmlAdminCallbackFunction is missing + debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.'); + } + + // Add the entry to the array + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['table_id_column'] = $attributes['VALUE']; +} + +// Handles the XML node 'table-userid-column' +function doXmlTableUseridColumn ($resource, $attributes) { + // There are three attributes, by default + if (count($attributes) != 3) { + // Not the right count + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes)); + } elseif (!isset($attributes['NAME'])) { + // 'NAME' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.'); + } 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['VALUE'])) { + // 'VALUE' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.'); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) { + // Not valid/verifyable + debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) { + // doXmlAdminCallbackFunction is missing + debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.'); + } + + // Add the entry to the array + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['table_userid_column'] = $attributes['VALUE']; +} + +// Handles the XML node 'raw-userid-column-key' +function doXmlRawUseridColumnKey ($resource, $attributes) { + // There are three attributes, by default + if (count($attributes) != 3) { + // Not the right count + debug_report_bug(__FUNCTION__, __LINE__, 'Expected 3 attributes, got ' . count($attributes)); + } elseif (!isset($attributes['NAME'])) { + // 'NAME' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute NAME not found.'); + } 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['VALUE'])) { + // 'VALUE' not found + debug_report_bug(__FUNCTION__, __LINE__, 'Required attribute VALUE not found.'); + } elseif (!isXmlValueValid($attributes['TYPE'], $attributes['VALUE'])) { + // Not valid/verifyable + debug_report_bug(__FUNCTION__, __LINE__, 'Attribute VALUE does not validate. TYPE=' . $attributes['TYPE'] . ',VALUE=' . $attributes['VALUE']); + } elseif (!isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'])) { + // doXmlAdminCallbackFunction is missing + debug_report_bug(__FUNCTION__, __LINE__, 'Required XML node admin-callback-function not included around this node. Please fix your XML.'); + } + + // Add the entry to the array + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction']['raw_userid_column_key'] = $attributes['VALUE']; +} + +// ---------------------------------------------------------------------------- +// XML type validation +// ---------------------------------------------------------------------------- + +// Checks for string without any added extra data +function isXmlTypeString ($value) { + // Just let SQL_ESCAPE() do the job + return ($value == SQL_ESCAPE($value)); +} + +// Fake-check for array type +function isXmlTypeArray ($value) { + // This value is always a string + return (is_string($value)); +} + +// Check for boolean type +function isXmlTypeBool ($value) { + // Trim value + $value = trim($value); + + // This value is always a string + return (($value == 'true') || ($value == 'false')); +} + +// ---------------------------------------------------------------------------- +// Private XML functions +// ---------------------------------------------------------------------------- + +// Adds given attribut to element +function addXmlValueToCallbackAttributes ($element, $attributes, $extraKey = '', $key = '') { + if ($attributes['TYPE'] == 'array') { + // Another nested array + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'TYPE=ARRAY, element=' . $element); + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$attributes['VALUE'] . '_list'] = array(); + } elseif (!empty($extraKey)) { + // Is it bool? + if ($attributes['TYPE'] == 'bool') { + // Then convert VALUE + $attributes['VALUE'] = convertStringToBoolean($attributes['VALUE']); + } // END - if + + // Sub-array (one level only) + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE='.$attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE']); + if (trim($attributes['NAME']) == '') { + // Numerical index + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE='.$attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NUMERICAL!'); + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$extraKey][] = $attributes['VALUE']; + } elseif (!empty($key)) { + // Use from $key + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE='.$attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - KEY! (key=' . $attributes[$key] . ')'); + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$extraKey][$attributes[$key]] = $attributes['VALUE']; + } else { + // Use from NAME + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',extraKey=' . $extraKey . ',TYPE='.$attributes['TYPE'].',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE'] . ' - NAME! (name=' . $attributes['NAME'] . ')'); + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$extraKey][$attributes['NAME']] = $attributes['VALUE']; + } + } elseif (trim($attributes['NAME']) == '') { + // Numerical index + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE']); + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][] = $attributes['VALUE']; + } elseif (isset($GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$attributes['NAME']])) { + // Already created + debug_report_bug(__FUNCTION__, __LINE__, 'NAME=' . $attributes['NAME'] . ' already addded to ' . $element . '.'); + } else { + // Use from NAME + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element=' . $element . ',NAME=' . $attributes['NAME'] . ',VALUE[' . gettype($attributes['VALUE']) . ']=' . $attributes['VALUE']); + $GLOBALS['__XML_ARGUMENTS']['doXmlAdminCallbackFunction'][$element][$attributes['NAME']] = $attributes['VALUE']; + } +} + +// ---------------------------------------------------------------------------- +// Execute call-back functions +// ---------------------------------------------------------------------------- + +// Execute function for doXmlAdminCallbackFunction() +function doXmlAdminCallbackFunctionExecute ($function, $args) { + // Prepare 'id_index' + $args['id_index'] = postRequestParameter($args['id_index']); + + // Just call it + //* DEBUG: */ die('
'.print_r($args, true).'
'); + call_user_func_array($function, $args); +} + +// [EOF] +?> diff --git a/inc/config-global.php b/inc/config-global.php index a2becbbc33..1b40b2c937 100644 --- a/inc/config-global.php +++ b/inc/config-global.php @@ -60,7 +60,7 @@ error_reporting(E_ALL | E_STRICT); $path = str_replace("\\", '/', substr(dirname(__FILE__), 0, -3)); // Some very important function includes -foreach (array('config', 'wrapper', 'template', 'module', 'inc', 'stats', 'http') as $inc) { +foreach (array('config', 'wrapper', 'template', 'module', 'inc', 'stats', 'http', 'xml', 'callback') as $inc) { include($path . 'inc/' . $inc . '-functions.php'); } // END - foreach diff --git a/inc/extensions/ext-grade.php b/inc/extensions/ext-grade.php index 2ce287dd61..21fc8de95d 100644 --- a/inc/extensions/ext-grade.php +++ b/inc/extensions/ext-grade.php @@ -128,10 +128,14 @@ INDEX (`grade_id`)", case 'activate': // Do stuff when admin activates this extension // SQL commands to run + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `locked`='N', `visible`='Y' WHERE `what`='grade' LIMIT 1"); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `locked`='N', `visible`='Y' WHERE `what`='grade' LIMIT 1"); break; case 'deactivate': // Do stuff when admin deactivates this extension // SQL commands to run + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `locked`='Y', `visible`='N' WHERE `what`='grade' LIMIT 1"); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `locked`='Y', `visible`='N' WHERE `what`='grade' LIMIT 1"); break; case 'update': // Update an extension diff --git a/inc/functions.php b/inc/functions.php index ba6ccc3710..e2fdb65381 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2300,7 +2300,7 @@ function detectMultiBytePrefix ($str) { } // Searches the given array for a sub-string match and returns all found keys in an array -function getArrayKeysFromSubStrArray ($heystack, array $needles, $offset = 0) { +function getArrayKeysFromSubStrArray ($heystack, $needles, $offset = 0) { // Init array for all found keys $keys = array(); @@ -2391,6 +2391,21 @@ function translateTaskType ($taskType) { return $message; } +// "Translates" 'true' to true and 'false' to false +function convertStringToBoolean ($str) { + // Trim it lower-case for validation + $str = trim(strtolower($str)); + + // Is it valid? + if (!in_array($str, array('true', 'false'))) { + // Not valid! + debug_report_bug(__FUNCTION__, __LINE__, 'str=' . $str . ' is not true/false'); + } // END - if + + // Return it + return (($str == 'true') ? true : false); +} + //----------------------------------------------------------------------------- // Automatically re-created functions, all taken from user comments on www.php.net //----------------------------------------------------------------------------- diff --git a/inc/http-functions.php b/inc/http-functions.php index 5e7aefa571..3b9a630eef 100644 --- a/inc/http-functions.php +++ b/inc/http-functions.php @@ -115,7 +115,7 @@ function sendGetRequest ($baseUrl, $data = array(), $removeHeader = false) { } // Send a POST request -function sendPostRequest ($baseUrl, array $postData, $removeHeader = false) { +function sendPostRequest ($baseUrl, $postData, $removeHeader = false) { // Extract host name from script $host = extractHostnameFromUrl($baseUrl); @@ -369,7 +369,7 @@ function setupProxyTunnel ($host, $port, $resource) { } // Check array for chuncked encoding -function unchunkHttpResponse (array $response) { +function unchunkHttpResponse ($response) { // Default is not chunked $isChunked = false; @@ -405,7 +405,7 @@ function unchunkHttpResponse (array $response) { } // Removes HTTP header lines from a response array (e.g. output from sendRequest() ) -function removeHttpHeaderFromResponse (array $response) { +function removeHttpHeaderFromResponse ($response) { // Save headers for later usage $GLOBALS['http_headers'] = array(); diff --git a/inc/language/de.php b/inc/language/de.php index 886d79ea0a..df6f8d80ea 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -1170,6 +1170,9 @@ addMessages(array( 'ADMIN_CONFIG_GUEST_STATS_MODULES_NOTE' => "Zeigt Klicks in den 10 am häufigsten angeklickten Gast- und Mitgliedsmodulen an.", 'ADMIN_CONFIG_GUEST_STATS_INACTIVE' => "Gast-Statistik deaktivieren", 'ADMIN_CONFIG_GUEST_STATS_INACTIVE_NOTE' => "Deaktiviert die Gast-Statistiken komplett.", + + // XML related strings + 'XML_TEMPLATE_404' => "XML-Template %s "Konfiguration der Surfbar", 'ADMIN_CONFIG_SURFBAR_STATIC_REWARD' => "Statische Vergütung:", 'ADMIN_CONFIG_SURFBAR_STATIC_COSTS' => "Statische Kosten:", @@ -74,12 +75,12 @@ addMessages(array( 'ADMIN_CONFIG_SURFBAR_GUEST_LOGIN_FORM_Y' => "Loginformular angzeigen.", 'ADMIN_CONFIG_SURFBAR_GUEST_LOGIN_FORM_N' => "Zur Startseite weiterleiten.", -// Admin non-config titles + // Admin non-config titles 'ADMIN_SURFBAR_STATS_TITLE' => "Mitglieder-Statistik der Surfbar", 'ADMIN_SURFBAR_URL_STATS_TITLE' => "URL-bezogene Statistik der Surfbar", 'ADMIN_LIST_SURFBAR_ACTIONS_TITLE' => "Mitglieder-Aktionen der Surfbar auflisten", -// General admin text + // General admin text 'ADMIN_SURFBAR_NO_URLS_FOUND' => "Es konnten keine URLs in der Surfbar gefunden werden.", 'ADMIN_SURFBAR_REWARD' => "Vergütung", 'ADMIN_SURFBAR_COSTS' => "Kosten", @@ -118,7 +119,7 @@ addMessages(array( 'ADMIN_LIST_SURFBAR_ACTIONS_NOTE' => "Hinweise: Sie sollten zur Sicherheit Ihres {?mt_word2?} den neuen Status nie auf {--SURFBAR_URL_STATUS_ACTIVE--} z.B. bei der Mitgliedaktion {--MEMBER_SURFBAR_ACTION_UNPAUSE_SUBMIT--} einstellen.", 'ADMIN_SURFBAR_URL' => "Gebuchte URL", -// Admin titles + // Admin titles 'ADMIN_SURFBAR_UNLOCK_URLS_TITLE' => "Surfbar - URLs freihschalten/ablehnen", 'ADMIN_SURFBAR_LIST_URLS_TITLE' => "Surfbar - URLs aufisten", 'ADMIN_SURFBAR_DELETE_URLS_TITLE' => "Surfbar - URLs entfernen", @@ -126,10 +127,10 @@ addMessages(array( 'ADMIN_SURFBAR_LOCK_URLS_TITLE' => "Surfbar - URLs sperren/entsperren", 'ADMIN_SURFBAR_UNDELETE_URLS_TITLE' => "Surfbar - gelöschte URLs wiederherstellen", -// Member titles + // Member titles 'MEMBER_SURFBAR_LIST_TITLE' => "Ihre URLs in der Surfbar verwalten", -// General member text + // General member text 'MEMBER_SURFBAR_URL_ADDED' => "URL hinzugefügt und wartet auf Freischaltung.", 'MEMBER_SURFBAR_URL_NOT_ADDED' => "URL konnte nicht hinzugefügt werden, da ein Fehler vorliegt.", 'MEMBER_SURFBAR_ADD_URL' => "URL in Surfbar buchen", @@ -147,7 +148,7 @@ addMessages(array( 'MEMBER_SURFBAR_ACTION_FAILED' => "Ausgewählte Aktion konnte nicht vollständig ausgeführt werden.", 'MEMBER_SURFBAR_UNLIMITED_VIEWS' => "Unbegrenzt", -// Subject lines for admins + // Subject lines for admins 'ADMIN_SURFBAR_NOTIFY_URL_UNLOCK_SUBJECT' => "[Surfbar:] URL hinzugefügt durch Admin", 'ADMIN_SURFBAR_NOTIFY_URL_REG_SUBJECT' => "[Surfbar:] Mitgliedsbuchung einer URL", 'ADMIN_SURFBAR_NOTIFY_URL_MIGRATE_SUBJECT' => "[Surfbar:] Migrierung einer Mailbuchung", @@ -171,13 +172,13 @@ addMessages(array( 'ADMIN_SURFBAR_NOTIFY_URL_MIGRATED_PENDING_SUBJECT' => "[Surfbar:] Mitglied hat migrierte URL gebucht", 'ADMIN_SURFBAR_NOTIFY_DEFAULT_SUBJECT' => "Problem in Surfbar-Betreff (%s)", -// Auto-generated admin subject lines + // Auto-generated admin subject lines 'ADMIN_DELETE_SURFBAR_URLS_SUBJECT' => "[Surfbar:] URL entfernt", 'ADMIN_EDIT_SURFBAR_URLS_SUBJECT' => "[Surfbar:] URL geändert", 'ADMIN_ACTIVE_SURFBAR_URLS_SUBJECT' => "[Surfbar:] Freigabe einer URL", 'ADMIN_LOCKED_SURFBAR_URLS_SUBJECT' => "[Surfbar:] Sperrung einer URL", -// Subject lines for members + // Subject lines for members 'MEMBER_SURFBAR_NOTIFY_URL_UNLOCK_SUBJECT' => "[Surfbar:] Ihre URL wurde aufgenommen", 'MEMBER_SURFBAR_NOTIFY_URL_REG_SUBJECT' => "[Surfbar:] Ihre URL wartet auf Freischaltung", 'MEMBER_SURFBAR_NOTIFY_URL_MIGRATE_SUBJECT' => "[Surfbar:] Ihre URL aus der Mailbuchung wurde migriert", @@ -202,13 +203,13 @@ addMessages(array( 'MEMBER_SURFBAR_NOTIFY_DEFAULT_SUBJECT' => "[Fehler:] Bitte leiten Sie diese Mail an uns weiter!", 'MEMBER_SURFBAR_NOTIFY_LOW_POINTS_SUBJECT' => "[Surfbar:] Ihr {?POINTS?}-Stand ist sehr niedrig!", -// Auto-generated member subject lines + // Auto-generated member subject lines 'MEMBER_DELETE_SURFBAR_URLS_SUBJECT' => "[Surfbar:] Ihre URL wurde entfernt", 'MEMBER_EDIT_SURFBAR_URLS_SUBJECT' => "[Surfbar:] Änderung Ihrer URL durch Admin", 'MEMBER_LOCKED_SURFBAR_URLS_SUBJECT' => "[Surfbar:] Sperrung Ihrer URL, bitte AGBs beachten.", 'MEMBER_ACTIVE_SURFBAR_URLS_SUBJECT' => "[Surfbar:] Freigabe Ihrer URL", -// URL status + // URL status 'SURFBAR_URL_STATUS_ACTIVE' => "Freigegeben", 'SURFBAR_URL_STATUS_LOCKED' => "Gesperrt", 'SURFBAR_URL_STATUS_PENDING' => "Wartend", @@ -219,7 +220,8 @@ addMessages(array( 'SURFBAR_URL_STATUS_MIGRATED' => "Migriert", 'SURFBAR_URL_STATUS_NONE' => "Nicht geändert", -// Member actions - submit buttons + // Member actions - submit buttons + 'MEMBER_SURFBAR_ACTION_UNKNOWN_SUBMIT' => "Unbekannt (%s)", 'MEMBER_SURFBAR_ACTION_RETREAT_SUBMIT' => "Zurücknehmen", 'MEMBER_SURFBAR_ACTION_FRAMETEST_SUBMIT' => "Framkiller-Test", 'MEMBER_SURFBAR_ACTION_EDIT_SUBMIT' => "Ändern", @@ -229,11 +231,12 @@ addMessages(array( 'MEMBER_SURFBAR_ACTION_PAUSE_SUBMIT' => "Anhalten", 'MEMBER_SURFBAR_ACTION_UNPAUSE_SUBMIT' => "Fortfahren", -// Member actions - "now" submit buttons + // Member actions - "now" submit buttons 'MEMBER_SURFBAR_ACTION_DELETE_NOW_SUBMIT' => "Jetzt löschen", 'MEMBER_SURFBAR_ACTION_EDIT_NOW_SUBMIT' => "Jetzt ändern", -// Member actions - button titles + // Member actions - button titles + 'MEMBER_SURFBAR_ACTION_UNKNOWN_TITLE' => "Es wurde eine unbekannte Mitgliedsaktion '%s' erkannt. Bitte melden Sie dies an den Support.", 'MEMBER_SURFBAR_ACTION_RETREAT_TITLE' => "Nehmen Sie hiermit Ihre Buchung wieder zurück, falls Sie diese doch nicht bewerben wollten.", 'MEMBER_SURFBAR_ACTION_FRAMETEST_TITLE' => "Testen Sie die Seite auf Framekiller hin, diese sind in unserer Surfbar grundsätzlich nicht gestattet.", 'MEMBER_SURFBAR_ACTION_EDIT_TITLE' => "Ändern Sie hier Ihre URL, wenn diese nicht stimmen sollte. Allerdings wird Ihre URL dann auf Freischaltung wartend gesetzt, damit wir sie vor Aufnahme nochmals kontrollieren können.", @@ -243,12 +246,12 @@ addMessages(array( 'MEMBER_SURFBAR_ACTION_PAUSE_TITLE' => "Halten Sie die URL in der Surfbar kurz an, wenn sie gerade nicht erreichbar ist. Dies geschieht nicht automatisch.", 'MEMBER_SURFBAR_ACTION_UNPAUSE_TITLE' => "Lassen Sie die URL in der Surfbar weiterlaufen, wenn Sie dies möchten. Wir müssen die URL jedoch erneut freigeben.", -// Internal errors + // Internal errors 'MEMBER_SURFBAR_EXECUTE_ACTION_404' => "Auszuführende Funktion %s nicht gefunden.", 'ADMIN_SURFBAR_NOTIFY_SUBJECT_404' => "Admin-Betreffzeile %s nicht gefunden.", 'MEMBER_SURFBAR_NOTIFY_SUBJECT_404' => "Mitglieder-Betreffzeile %s nicht gefunden.", -// Guest texts + // Guest texts 'GUEST_SURFBAR_LOGIN_HEADER' => "Login zur Surfbar:", )); diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index bb4c68d4a1..1a1ff0e53e 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -199,9 +199,7 @@ function SURFBAR_MEMBER_ACTIONS ($urlId, $status) { $OUT .= loadTemplate('member_surfbar_list_form', true, array( 'width' => $width, 'id' => bigintval($urlId), - 'action' => strtolower($action), - 'title' => '{--MEMBER_SURFBAR_ACTION_' . strtoupper($action) . '_TITLE--}', - 'submit' => '{--MEMBER_SURFBAR_ACTION_' . strtoupper($action) . '_SUBMIT--}', + 'action' => strtolower($action) )); } // END - foreach @@ -734,8 +732,56 @@ function translateSurfbarLimit ($limit) { // Translate the URL status function translateSurfbarUrlStatus ($status) { - // Return result - return sprintf("{--SURFBAR_URL_STATUS_%s--}", strtoupper($status)); + // NULL must be handled carfefully + if (is_null($status)) { + // Is NULL, so return other language string + return '{--SURFBAR_URL_STATUS_NONE--}'; + } else { + // Return regular result + return sprintf("{--SURFBAR_URL_STATUS_%s--}", strtoupper($status)); + } +} + +// Translates the given action into a link title for members +function translateMemberSurfbarActionToTitle ($action) { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__][$action])) { + // Construct default return string (unknown + $GLOBALS[__FUNCTION__][$action] = '{%message,MEMBER_SURFBAR_ACTION_UNKNOWN_TITLE=' . $action . '%}'; + + // ... and the id's name + $messageId = 'MEMBER_SURFBAR_ACTION_' . strtoupper($action) . '_TITLE'; + + // Is the id there? + if (isMessageIdValid($messageId)) { + // Then use it + $GLOBALS[__FUNCTION__][$action] = '{--' . $messageId . '--}'; + } // END - if + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__][$action]; +} + +// Translates the given action into a submit button for members +function translateMemberSurfbarActionToSubmit ($action) { + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__][$action])) { + // Construct default return string (unknown + $GLOBALS[__FUNCTION__][$action] = '{%message,MEMBER_SURFBAR_ACTION_UNKNOWN_SUBMIT=' . $action . '%}'; + + // ... and the id's name + $messageId = 'MEMBER_SURFBAR_ACTION_' . strtoupper($action) . '_SUBMIT'; + + // Is the id there? + if (isMessageIdValid($messageId)) { + // Then use it + $GLOBALS[__FUNCTION__][$action] = '{--' . $messageId . '--}'; + } // END - if + } // END - if + + // Return cache + return $GLOBALS[__FUNCTION__][$action]; } // Determine reward diff --git a/inc/modules/admin/action-grade.php b/inc/modules/admin/action-grade.php new file mode 100644 index 0000000000..8a0e540c2f --- /dev/null +++ b/inc/modules/admin/action-grade.php @@ -0,0 +1,56 @@ + diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 083e290725..867c30f34f 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -751,7 +751,7 @@ function adminChangeActivationStatus ($IDs, $table, $row, $idRow = 'id') { } // Send mails for del/edit/lock build modes -function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $userid = 'userid') { +function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $userIdColumn = 'userid') { // Default subject is the subject part $subject = $subjectPart; @@ -762,7 +762,7 @@ function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $ } // END - if // Is the raw userid set? - if (postRequestParameter($useridColumn, $id) > 0) { + if (postRequestParameter($userIdColumn, $id) > 0) { // Load email template if (!empty($subjectPart)) { $mail = loadEmailTemplate('member_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content); @@ -771,7 +771,7 @@ function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $ } // Send email out - sendEmail(postRequestParameter($useridColumn, $id), strtoupper('{--MEMBER_' . $subject . '_' . $table . '_SUBJECT--}'), $mail); + sendEmail(postRequestParameter($userIdColumn, $id), strtoupper('{--MEMBER_' . $subject . '_' . $table . '_SUBJECT--}'), $mail); } // END - if // Generate subject @@ -779,9 +779,9 @@ function sendAdminBuildMails ($mode, $table, $content, $id, $subjectPart = '', $ // Send admin notification out if (!empty($subjectPart)) { - sendAdminNotification($subject, 'admin_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content, postRequestParameter($useridColumn, $id)); + sendAdminNotification($subject, 'admin_' . $mode . '_' . strtolower($subjectPart) . '_' . $table, $content, postRequestParameter($userIdColumn, $id)); } else { - sendAdminNotification($subject, 'admin_' . $mode . '_' . $table, $content, postRequestParameter($useridColumn, $id)); + sendAdminNotification($subject, 'admin_' . $mode . '_' . $table, $content, postRequestParameter($userIdColumn, $id)); } } @@ -823,7 +823,11 @@ function adminListBuilder ($listType, $IDs, $table, $columns, $filterFunctions, // Handle the call in external function //* DEBUG: */ debugOutput('key=' . $key . ',fucntion=' . $filterFunctions[$idx] . ',value=' . $value); - $content[$key] = handleExtraValues($filterFunctions[$idx], $value, $extraValues[$idx]); + $content[$key] = handleExtraValues( + $filterFunctions[$idx], + $value, + $extraValues[$idx] + ); } // END - foreach // Then list it @@ -1075,7 +1079,10 @@ function adminEditEntriesConfirm ($IDs, $table, $columns = array(), $filterFunct // List for editing adminListBuilder('edit', $IDs, $table, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn); } - } // END - if + } else { + // Maybe some invalid parameters + debug_report_bug(__FUNCTION__, __LINE__, 'IDs[]=' . gettype($IDs) . ',table=' . $table . ',columns[]=' . gettype($columns) . ',filterFunctions[]=' . gettype($filterFunctions) . ',extraValues[]=' . gettype($extraValues) . ',idColumn=' . $idColumn . ',userIdColumn=' . $userIdColumn . ' - INVALID!'); + } } // Un-/lock rows by given id numbers diff --git a/inc/modules/admin/what-list_surfbar_actions.php b/inc/modules/admin/what-list_surfbar_actions.php index 195a01acb5..ff95f1c494 100644 --- a/inc/modules/admin/what-list_surfbar_actions.php +++ b/inc/modules/admin/what-list_surfbar_actions.php @@ -61,16 +61,7 @@ if (!SQL_HASZERONUMS($result)) { $OUT = ''; while ($content = SQL_FETCHARRAY($result)) { // "Translate" some data - $content['actions_action'] = sprintf("{--MEMBER_SURFBAR_ACTION_%s_SUBMIT--}", strtoupper($content['actions_action'])); - - // New status set? - if (!is_null($content['actions_new_status'])) { - // Translate it - $content['actions_new_status'] = translateSurfbarUrlStatus($content['actions_new_status']); - } else { - // "Do nothing" status - $content['actions_new_status'] = '{--SURFBAR_URL_STATUS_NONE--}'; - } + $content['actions_action'] = '{--MEMBER_SURFBAR_ACTION_' . strtoupper($content['actions_action']) . '_SUBMIT--}', ; // Load row template $OUT .= loadTemplate('admin_list_surfbar_actions_row', true, $content); diff --git a/inc/modules/admin/what-list_surfbar_urls.php b/inc/modules/admin/what-list_surfbar_urls.php index ba8a6daa2f..fe6a839e8b 100644 --- a/inc/modules/admin/what-list_surfbar_urls.php +++ b/inc/modules/admin/what-list_surfbar_urls.php @@ -67,116 +67,31 @@ if (isFormSent('edit')) { showEntriesByXmlCallback('admin_edit_do_surfbar_urls'); } elseif (isFormSent('delete')) { // Show entries for deletion - showEntriesByXmlCallback('admin_del_show_surfbar_urls'); + showEntriesByXmlCallback('admin_delete_show_surfbar_urls'); // Do not show the list of URLs after this template $show = false; } elseif (isFormSent('do_delete')) { // Remove entries from database - showEntriesByXmlCallback('admin_del_do_surfbar_urls'); + showEntriesByXmlCallback('admin_delete_do_surfbar_urls'); } elseif (isFormSent('lock')) { // Un-/lock selected URLs. This does not work for pending URLs - adminLockEntriesConfirm( - postRequestParameter('url_id'), - 'surfbar_urls', - array( - 'url_id', - 'url_userid', - 'url', - 'url_registered', - 'url_status' - ), - array( - 'bigintval', - 'generateUserProfileLink', - 'generateFrametesterUrl', - '', - 'translateSurfbarUrlStatus' - ), - array( - '', - '', - '', - '', - '' - ), - false, - 'url_id', - 'url_userid', - 'url_userid' - ); + showEntriesByXmlCallback('admin_lock_show_surfbar_urls'); // Do not show the list of URLs after this template $show = false; } elseif (isFormSent('do_lock')) { // Un-/lock selected URLs. This does not work for pending URLs - adminLockEntriesConfirm( - postRequestParameter('url_id'), - 'surfbar_urls', - array(), - array(), - array(), - array( - 'url_status' => array( - 'ACTIVE' => 'LOCKED', - 'LOCKED' => 'ACTIVE' - ) - ), - true, - 'url_id', - 'url_userid', - 'url_userid' - ); + showEntriesByXmlCallback('admin_lock_do_surfbar_urls'); } elseif (isFormSent('undelete')) { // Undelete selected URLs. This does only work for deleted URLs... ;-) - adminUndeleteEntriesConfirm( - postRequestParameter('url_id'), - 'surfbar_urls', - array( - 'url_id', - 'url_userid', - 'url', - 'url_registered', - 'url_status' - ), - array( - 'bigintval', - 'generateUserProfileLink', - 'generateFrametesterUrl', - '', - 'translateSurfbarUrlStatus' - ), - array( - '', - '', - '', - '', - '' - ), - false, - 'url_id', - 'url_userid', - 'url_userid' - ); + showEntriesByXmlCallback('admin_undelete_show_surfbar_urls'); + + // Do not show the list of URLs after this template $show = false; } elseif (isFormSent('do_undelete')) { // Undelete selected URLs. This does only work for deleted URLs... ;-) - adminUndeleteEntriesConfirm( - postRequestParameter('url_id'), - 'surfbar_urls', - array(), - array(), - array(), - array( - 'url_status' => array( - 'DELETED' => 'ACTIVE' - ) - ), - true, - 'url_id', - 'url_userid', - 'url_userid' - ); + showEntriesByXmlCallback('admin_undelete_del_surfbar_urls'); } // Show entries? @@ -187,7 +102,11 @@ if ($show === false) { // List all URLs $result = SQL_QUERY("SELECT - `url_id`, `url_userid`, `url`, `url_views_total`, `url_status`, + `url_id`, + `url_userid`, + `url`, + `url_views_total`, + `url_status`, UNIX_TIMESTAMP(`url_registered`) AS `url_registered`, UNIX_TIMESTAMP(`url_last_locked`) AS `url_last_locked`, `url_lock_reason` @@ -201,9 +120,9 @@ if (!SQL_HASZERONUMS($result)) { // List all URLs $OUT = ''; while ($content = SQL_FETCHARRAY($result)) { - // "Translate"/add content - $content['url_registered'] = generateDateTime($content['url_registered'], 2); - $content['url_last_locked'] = generateDateTime($content['url_last_locked'], 2); + // "Translate" content + $content['url_registered'] = generateDateTime($content['url_registered'], '2'); + $content['url_last_locked'] = generateDateTime($content['url_last_locked'], '2'); // Load row template $OUT .= loadTemplate('admin_list_surfbar_urls_row', true, $content); diff --git a/inc/modules/member/what-surfbar_list.php b/inc/modules/member/what-surfbar_list.php index 6d17f2560f..cd377c7036 100644 --- a/inc/modules/member/what-surfbar_list.php +++ b/inc/modules/member/what-surfbar_list.php @@ -75,13 +75,13 @@ if ((isFormSent()) && (isPostRequestParameterSet('action')) && (isPostRequestPar // Include link to stats $content['views_total'] = '[{%pipe,translateComma=' . $content['views_total'] . '%}]'; } // END - if - $content['url_registered'] = generateDateTime($content['url_registered'], 2); - $content['url_last_locked'] = generateDateTime($content['url_last_locked'], 2); + $content['url_registered'] = generateDateTime($content['url_registered'], '2'); + $content['url_last_locked'] = generateDateTime($content['url_last_locked'], '2'); $content['actions'] = SURFBAR_MEMBER_ACTIONS($content['id'], $content['url_status']); // Load row template $OUT .= loadTemplate('member_surfbar_list_row', true, $content); - } // END - if + } // END - foreach // Load main template loadTemplate('member_surfbar_list', false, $OUT); diff --git a/inc/template-functions.php b/inc/template-functions.php index 4cf5587975..eeba4db76c 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -1611,7 +1611,7 @@ function sendModeMails ($mod, $modes) { } // Generates a 'selection box' from given array -function generateSelectionBoxFromArray (array $options, $name, $optionValue, $optionContent = '', $extraName = '') { +function generateSelectionBoxFromArray ($options, $name, $optionValue, $optionContent = '', $extraName = '') { // Start the output $OUT = ' - - - - - - + diff --git a/templates/de/html/admin/admin_del_surfbar_urls_row.tpl b/templates/de/html/admin/admin_del_surfbar_urls_row.tpl index 55c0060e68..11f5d85d80 100644 --- a/templates/de/html/admin/admin_del_surfbar_urls_row.tpl +++ b/templates/de/html/admin/admin_del_surfbar_urls_row.tpl @@ -1,13 +1 @@ - - - - - $content[url_userid] - - - {--ADMIN_TEST_URL--} - - - $content[url_registered] - - + diff --git a/templates/de/html/admin/admin_delete_surfbar_urls.tpl b/templates/de/html/admin/admin_delete_surfbar_urls.tpl new file mode 100644 index 0000000000..6a054adce1 --- /dev/null +++ b/templates/de/html/admin/admin_delete_surfbar_urls.tpl @@ -0,0 +1,23 @@ +
+
+ + + + + + + + + +$content + + + +
+ {--ADMIN_SURFBAR_DELETE_URLS_TITLE--} +
{--_USERID--}{--ADMIN_TEST_URL--}{--ADMIN_SURFBAR_REGISTERED--}
+
+
diff --git a/templates/de/html/admin/admin_delete_surfbar_urls_row.tpl b/templates/de/html/admin/admin_delete_surfbar_urls_row.tpl new file mode 100644 index 0000000000..55c0060e68 --- /dev/null +++ b/templates/de/html/admin/admin_delete_surfbar_urls_row.tpl @@ -0,0 +1,13 @@ + + + + + $content[url_userid] + + + {--ADMIN_TEST_URL--} + + + $content[url_registered] + + diff --git a/templates/de/html/admin/admin_list_surfbar_actions_row.tpl b/templates/de/html/admin/admin_list_surfbar_actions_row.tpl index f2dead389e..cf9d4659c1 100644 --- a/templates/de/html/admin/admin_list_surfbar_actions_row.tpl +++ b/templates/de/html/admin/admin_list_surfbar_actions_row.tpl @@ -9,6 +9,6 @@ $content[actions_action] - $content[actions_new_status] + {%pipe,translateSurfbarUrlStatus=$content[actions_new_status]%} diff --git a/templates/de/html/member/member_surfbar_list_form.tpl b/templates/de/html/member/member_surfbar_list_form.tpl index 98574d1ab7..ce51f43919 100644 --- a/templates/de/html/member/member_surfbar_list_form.tpl +++ b/templates/de/html/member/member_surfbar_list_form.tpl @@ -2,6 +2,6 @@
- +
diff --git a/templates/de/html/surfbar/surfbar_frame_top.tpl b/templates/de/html/surfbar/surfbar_frame_top.tpl index f73f4fa6e9..96f2278405 100644 --- a/templates/de/html/surfbar/surfbar_frame_top.tpl +++ b/templates/de/html/surfbar/surfbar_frame_top.tpl @@ -3,25 +3,25 @@
- »$content[xxx] {?POINTS?} in - $content[xxx] - Sekunden« - »X von - X im Reload« + »$content[xxx] {?POINTS?} in + $content[xxx] + Sekunden« + »X von + X im Reload«
- »Aktuelle Seite in neuem - Fenster öffnen« - [{--MEMBER_SURFBAR_ACTION_PAUSE_SUBMIT--}|Loginbereich|Ausloggen|Schliessen] + »Aktuelle Seite in neuem + Fenster öffnen« + [{--MEMBER_SURFBAR_ACTION_PAUSE_SUBMIT--}|Loginbereich|Ausloggen|Schliessen]
- »{?MAIN_TITLE?} ist für den Inhalt nicht verantwortlich!« + »{?MAIN_TITLE?} ist für den Inhalt nicht verantwortlich!«
diff --git a/templates/xml/admin/admin_del_do_surfbar_urls.xml b/templates/xml/admin/admin_del_do_surfbar_urls.xml index 044d5d5c38..11f5d85d80 100644 --- a/templates/xml/admin/admin_del_do_surfbar_urls.xml +++ b/templates/xml/admin/admin_del_do_surfbar_urls.xml @@ -1,83 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/templates/xml/admin/admin_del_show_surfbar_urls.xml b/templates/xml/admin/admin_del_show_surfbar_urls.xml index d413c32efa..11f5d85d80 100644 --- a/templates/xml/admin/admin_del_show_surfbar_urls.xml +++ b/templates/xml/admin/admin_del_show_surfbar_urls.xml @@ -1,111 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/templates/xml/admin/admin_delete_do_surfbar_urls.xml b/templates/xml/admin/admin_delete_do_surfbar_urls.xml new file mode 100644 index 0000000000..6a53141ec2 --- /dev/null +++ b/templates/xml/admin/admin_delete_do_surfbar_urls.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/xml/admin/admin_delete_show_surfbar_urls.xml b/templates/xml/admin/admin_delete_show_surfbar_urls.xml new file mode 100644 index 0000000000..6e324806bd --- /dev/null +++ b/templates/xml/admin/admin_delete_show_surfbar_urls.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/xml/admin/admin_edit_do_surfbar_urls.xml b/templates/xml/admin/admin_edit_do_surfbar_urls.xml index 368590c0b7..92ecc82f38 100644 --- a/templates/xml/admin/admin_edit_do_surfbar_urls.xml +++ b/templates/xml/admin/admin_edit_do_surfbar_urls.xml @@ -34,11 +34,11 @@ MA 02110-1301 USA - + - + - + - + - + - + diff --git a/templates/xml/admin/admin_edit_show_surfbar_urls.xml b/templates/xml/admin/admin_edit_show_surfbar_urls.xml index e2d1f7e6de..7ab4786f24 100644 --- a/templates/xml/admin/admin_edit_show_surfbar_urls.xml +++ b/templates/xml/admin/admin_edit_show_surfbar_urls.xml @@ -34,11 +34,11 @@ MA 02110-1301 USA - + - + - + - + - - + + - + - + - + - + diff --git a/templates/xml/admin/admin_lock_do_surfbar_urls.xml b/templates/xml/admin/admin_lock_do_surfbar_urls.xml new file mode 100644 index 0000000000..f1dd0125a3 --- /dev/null +++ b/templates/xml/admin/admin_lock_do_surfbar_urls.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/xml/admin/admin_lock_show_surfbar_urls.xml b/templates/xml/admin/admin_lock_show_surfbar_urls.xml new file mode 100644 index 0000000000..490c69de9b --- /dev/null +++ b/templates/xml/admin/admin_lock_show_surfbar_urls.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/xml/admin/admin_undelete_do_surfbar_urls.xml b/templates/xml/admin/admin_undelete_do_surfbar_urls.xml new file mode 100644 index 0000000000..0fdb6b68dc --- /dev/null +++ b/templates/xml/admin/admin_undelete_do_surfbar_urls.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/xml/admin/admin_undelete_show_surfbar_urls.xml b/templates/xml/admin/admin_undelete_show_surfbar_urls.xml new file mode 100644 index 0000000000..d0f0f3a99c --- /dev/null +++ b/templates/xml/admin/admin_undelete_show_surfbar_urls.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/xml/admin_data_template.xml b/templates/xml/admin_data_template.xml index 632b23c288..c517d7ac23 100644 --- a/templates/xml/admin_data_template.xml +++ b/templates/xml/admin_data_template.xml @@ -31,16 +31,17 @@ MA 02110-1301 USA - + - + - + - + - + - + - + - +