Table of Contents Previous Next

Sugar Developer Guide

Version 5.1


Chapter 4 Customizing Sugar : Business Logic Hooks : Packaging Custom Logic Hooks

Packaging Custom Logic Hooks
There are no directives in the manifest.php file to safely install business logic hooks. You have to do it via the pre_install or post_install scripts. To do this, create a top-level directory in your installer called 'scripts' and in that directory place a file called pre_install.php.
A pre_install file could look like this:
<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
function pre_install() {
   require_once('include/utils.php');
   check_logic_hook_file("Accounts", "after_retrieve", array(1, "update_description",
"include/FCKEditor/updateDescription.php", "updateDescription",
"updateDescription"));
}
?>
The check_logic_hook_file() command is looking for three things. First is the module that you want this hook to affect, in this case "Accounts". The second is the hook itself, in this case "after_retrieve". The third part is an array which mirrors the $hook_array like this:
o
o
o
o
o
Of course you can call the check_logic_hook_file() command as many times as you want. The logic behind the command check to make sure that your hook isn't already set and if it is then it replaces it, making it pretty upgrade-safe. If you have any questions about installing logic hooks look for me in the forums.

Table of Contents Previous Next

Copyright 2004-2008 SugarCRM Inc.
Product License