+//
+// FrontAccounting extension modules integration.
+// This file is included in session.inc even before session is started,
+// and includes hooks.php connector files from all installed extensions.
+// To make hooks active install_hooks() have to be called after interface
+// language is set.
+//
+// To find how various hooks are processed look into respective hook_* functions below.
+//
+class hooks {
+ var $module_name; // extension module name.
+
+ //
+ // Helper for updating databases with extension scheme
+ //
+ // $comp can be company number, -1 for all,
+ // $updates - table of filename => array(table, field, property)
+ // $check_only - don't update database, check table/field/property existence only
+ //
+ function update_databases($comp, $updates, $check_only=false)
+ {
+ global $db_connections, $path_to_root;
+
+ if ($comp == -1)
+ $conn = $db_connections;
+ else
+ $conn = array( $comp => $db_connections[$comp]);
+ $result = true;
+
+ foreach($conn as $comp => $con) {
+ set_global_connection($comp);
+ foreach($updates as $file => $update) {
+ $table = @$update[0];
+ $field = @$update[1];
+ $properties = @$update[2];
+
+ $ok = check_table($con['tbpref'], $table, $field, $properties) == 0;
+
+ if (!$check_only && !$ok) {
+ $ok = db_import($path_to_root.'/modules/'.$this->module_name.'/sql/'.$file,
+ $con);
+ }
+ $result &= $ok;
+ if (!$result)
+ break;
+ }
+ db_close();
+ if (!$result)
+ break;
+ }
+ set_global_connection(0); // return to siteadmin account
+
+ return $result;
+ }
+ //
+ // Install additional tabs provided by extension
+ //
+ function install_tabs($app)
+ {
+// $app->add_application(new example_class); // add menu tab defined by example_class
+ }
+ //
+ // Install additonal menu options provided by extension
+ //
+ function install_options($app)
+ {
+// global $path_to_root;
+//
+// switch($app->id) {
+// case 'orders':
+// $app->add_rapp_function( 0, _("&Example option"),
+// $path_to_root.'/modules/example/example.php?', 'SA_OPEN');
+// }
+ }
+
+ function install_access()
+ {
+// $security_areas['SA_EXAMPLE'] = array(SS_EXAMPLE|100, _("Example security area."));
+//
+// $security_sections = array(SS_EXAMPLE => _("Example module implementation"));
+//
+// return array($security_areas, $security_sections);
+ }
+
+ //
+ // Invoked for all modules before page header is displayed
+ //
+ function pre_header($fun_args)
+ {
+ }
+ //
+ // Invoked for all modules before page footer is displayed
+ //
+ function pre_footer($fun_args)
+ {
+ }
+