Menu
SuiteCRM Pull Request Party hosted by SalesAgility
Welcome, Guest
Username: Password: Remember me

TOPIC: can Application hook use module hook events?

can Application hook use module hook events? 6 days 21 hours ago #86886

  • dayalv
  • dayalv's Avatar
Dear All,

I need to track each and every module.
to have a global customization we need to use Application logic hooks .am i right?
so is that possible to use module logic hook events such as[before_save],[after_save], etc.. in application logic hook?. so that i can customize save operation once,, which will have impact on all modules save operation..
please guide me on this..

your help is much appreciated.
thanks in advance
The administrator has disabled public write access.

can Application hook use module hook events? 6 days 5 hours ago #86894

  • ashish@outrightcrm.com
  • ashish@outrightcrm.com's Avatar
  • Offline
  • SuiteCRM Is My Life
  • CTO at outright Systems
  • Posts: 328
  • Thank you received: 32
  • Karma: 4
Yes, It should work.
Location will be custom/modules/logic_hooks.php.

Keep in mind few things before doing it.

1) They will trigger in all modules, so better to keep them bind into a modules array like this
$used_modules = array();
$used_modules[] ='Leads';
$used_modules[]='Accounts';

2) in application level hooks, there is only 2 acceptable parameters at hook class method, so $bean is not available, only $event and $arguments are available.

So ideally avoid application-level hooks mixing with module level hooks, until you are not looking to spent hours and bind code strictly.
Last Edit: 3 days 19 hours ago by pgr. Reason: add code tags
The administrator has disabled public write access.

can Application hook use module hook events? 3 days 20 hours ago #87043

  • dayalv
  • dayalv's Avatar
  • Offline
  • New Member
  • Posts: 6
  • Karma: 0
Thank you ashish ,

i dont understand $used_modules=array();

where i need to implement this .. please give the guidance. your help is much appreciated.
The administrator has disabled public write access.

can Application hook use module hook events? 3 days 19 hours ago #87045

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10450
  • Thank you received: 1558
  • Karma: 358
@ashish please remember to use the forum's code tags when posting PHP, otherwise brackets will disappear. Thanks :)

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.
The following user(s) said Thank You: ashish@outrightcrm.com

can Application hook use module hook events? 23 hours 36 minutes ago #87123

  • dayalv
  • dayalv's Avatar
  • Offline
  • New Member
  • Posts: 6
  • Karma: 0
Hi Ashish..

could you please tell me where to implement the $used_modules=array();
The administrator has disabled public write access.

can Application hook use module hook events? 23 hours 33 minutes ago #87124

  • ashish@outrightcrm.com
  • ashish@outrightcrm.com's Avatar
  • Offline
  • SuiteCRM Is My Life
  • CTO at outright Systems
  • Posts: 328
  • Thank you received: 32
  • Karma: 4
just after starting hook function..
function abc_hook($event,$args){
$used_modules = array();
$used_modules[] ='Leads';
$used_modules[]='Accounts'

if(!in_array($_REQUEST['module'],$used_modules)){
return false;
}
}

This way , it will work only for Leads and Accounts , for example.

Otherwise It is going to used in whole application ie in all modules , even save changes on studio, which is definitely you will not want.
The administrator has disabled public write access.
The following user(s) said Thank You: dayalv

can Application hook use module hook events? 22 hours 39 minutes ago #87126

  • dayalv
  • dayalv's Avatar
  • Offline
  • New Member
  • Posts: 6
  • Karma: 0
Thank you Ashish,

i understand it now. and it works .. thanks again.. you saved the day..
The administrator has disabled public write access.
Time to create page: 0.054 seconds
Powered by Kunena Forum