From f4737ea725de62440c8bf58a7b4d7b187268fe93 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Tue, 19 May 2009 15:15:01 +0000 Subject: [PATCH] Added hook support for localized functions. --- gl/includes/db/gl_db_rates.inc | 14 +++++++++++++- gl/manage/exchange_rates.php | 3 ++- includes/session.inc | 6 ++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gl/includes/db/gl_db_rates.inc b/gl/includes/db/gl_db_rates.inc index 0c9ae686..fa5926b6 100644 --- a/gl/includes/db/gl_db_rates.inc +++ b/gl/includes/db/gl_db_rates.inc @@ -69,7 +69,19 @@ function delete_exchange_rate($rate_id) db_query($sql, "could not delete exchange rate $rate_id"); } -//--------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// Retrieve exchange rate as of date $date from external source (usually inet) +// +function retrieve_exrate($curr_b, $date) +{ + global $Hooks; + + if (method_exists($Hooks, 'retrieve_exrate')) + return $Hooks->retrieve_exrate($curr_b, $date); + else + return get_ecb_rate($curr_b); +} +//----------------------------------------------------------------------------- function get_ecb_rate($curr_b) { diff --git a/gl/manage/exchange_rates.php b/gl/manage/exchange_rates.php index 2592b0cc..528b4203 100644 --- a/gl/manage/exchange_rates.php +++ b/gl/manage/exchange_rates.php @@ -128,7 +128,8 @@ function display_rate_edit() } if (isset($_POST['get_rate'])) { - $_POST['BuyRate'] = exrate_format(get_ecb_rate($_POST['curr_abrev'])); + $_POST['BuyRate'] = + exrate_format(retrieve_exrate($_POST['curr_abrev'], $_POST['date_'])); $Ajax->activate('BuyRate'); } small_amount_row(_("Exchange Rate:"), 'BuyRate', null, '', diff --git a/includes/session.inc b/includes/session.inc index 236d90e2..f8d8c1e6 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -125,6 +125,12 @@ if (!isset($_SESSION['languages'])) language::set_language($_SESSION['language']->code); +// include $Hooks object if locale file exists +if(@include_once($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc")) +{ + $Hooks = new Hooks(); +} + include_once($path_to_root . "/config.php"); include_once($path_to_root . "/includes/main.inc"); -- 2.30.2