From 9a73d71101aff35e4f27a9e5f4fa2cad612779ce Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sat, 13 Nov 2010 09:38:27 +0000 Subject: [PATCH] Established new hooks class convention. --- CHANGELOG.txt | 30 ++++++++++++++++++++++++++- includes/hooks.inc | 2 +- includes/session.inc | 5 ++++- lang/new_language_template/locale.inc | 4 +++- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 40081010..e915fb21 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,34 @@ Legend: ! -> Note $ -> Affected files +13-Nov-2010 Janusz Dobrowolski ++ New hooks system added +$ /includes/hooks.inc (new) + /includes/session.inc + /lang/new_language_template/locale.inc +! Old hooks converted to new hooks API +$ /gl/includes/db/gl_db_rates.inc + /includes/ui/ui_view.inc + /reporting/rep709.php ++ Added transaction db_write/db_void hooks +$ /gl/includes/db/gl_db_banking.inc + /inventory/includes/db/items_adjust_db.inc + /inventory/includes/db/items_transfer_db.inc + /manufacturing/includes/db/work_order_issues_db.inc + /manufacturing/includes/db/work_order_produce_items_db.inc + /manufacturing/includes/db/work_orders_db.inc + /manufacturing/includes/db/work_orders_quick_db.inc + /purchasing/po_entry_items.php + /purchasing/includes/db/grn_db.inc + /purchasing/includes/db/invoice_db.inc + /purchasing/includes/db/po_db.inc + /purchasing/includes/db/supp_payment_db.inc + /sales/includes/db/payment_db.inc + /sales/includes/db/sales_credit_db.inc + /sales/includes/db/sales_delivery_db.inc + /sales/includes/db/sales_invoice_db.inc + /sales/includes/db/sales_order_db.inc + 12-Nov-2010 Janusz Dobrowolski # Added missing due date on direct purchase invoice. $ /purchasing/po_entry_items.php @@ -31,7 +59,7 @@ $ /purchasing/po_entry_items.php $ /inventory/manage/items.php # Fixed a couple of edition ui bugs $ /gl/manage/gl_quick_entries.php -+ Added db_close() for optional use ++ Added db_close() for optional use $ /includes/db/connect_db.inc 11-Nov-2010 Janusz Dobrowolski diff --git a/includes/hooks.inc b/includes/hooks.inc index 91ab8427..079d834a 100644 --- a/includes/hooks.inc +++ b/includes/hooks.inc @@ -9,7 +9,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -class Hook{ +class hooks { // // Price in words. $doc_type is set to document type and can be used to suppress // price in words printing for selected document types. diff --git a/includes/session.inc b/includes/session.inc index 72ff7cdb..612957ae 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -213,7 +213,10 @@ $Hooks = array(); if (file_exists($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc")) { include_once($path_to_root . "/lang/".$_SESSION['language']->code."/locale.inc"); - $Hooks[] = new Hooks(); + $code = $_SESSION['language']->code; + $hook_class = 'hooks_'.$code; + $Hooks[$code] = new $hook_class; + unset($code, $hook_class); } include_once($path_to_root . "/includes/access_levels.inc"); diff --git a/lang/new_language_template/locale.inc b/lang/new_language_template/locale.inc index ad1e5d88..3e3a7c4e 100644 --- a/lang/new_language_template/locale.inc +++ b/lang/new_language_template/locale.inc @@ -14,8 +14,10 @@ If your locale needs special functionality provided by hook functions copy this file to respective lang/xx_XX directory and edit templates below. You can safely remove not used function templates. + + Name it after language code e.g. hooks_en_US */ -class Hooks { +class hooks_xx_XX extends hooks { /* // // Price in words. $doc_type is set to document type and can be used to suppress -- 2.30.2