Hi Dan,
No, you don't need to create an installer for the logic_hook.
You just have to:
1. create the file custom/modules/<ModuleName>/logic_hooks.php
2. Add inside this file the enough array to call the method in the Logic Hook Class
3. Create the Class
4. Create the method will be called by logic_hook. This method will perform the custom logic.
An example of the Logic Hook Class:
PHP Code:
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class UserHook {
function setSearchFields(&$focus, $event, $arguments) {
global $current_user;
if($focus->id == $current_user->id && isset($_REQUEST['action'])) {
if($_REQUEST['module'] == 'UP2_placements') {
//cleaning the template HTML every time
//this is necessary in non-Developer mode because of the custom code in the check-boxes
require_once('modules/Administration/QuickRepairAndRebuild.php');
$selected_actions = Array(0 => 'clearTpls');
$modules = Array(0 => 'UP2_placements');
$RepairAndClear = new RepairAndClear();
$RepairAndClear->repairAndClearAll($selected_actions, $modules, $autoexecute=false, $show_output=false);
//end this is necessary in non-Developer mode because of the custom code in the check-boxes
}
if($_REQUEST['action'] == 'AdDeliveryImportView') {
$this->setAdDeliveryImportSearchFields();
} else if($_REQUEST['action'] == 'SelectInventoryView') {
$this->setSelectInventorySearchFields();
} else if($_REQUEST['action'] == 'MonthEndValidationView') {
$this->setMonthEndValidationSearchFields();
}
}
}
}
Best regards.
Bookmarks