[Vtigercrm-developers] What is the best practice to create Extensions Store compatible vtiger 6.1 custom module?

Salim salimcmd at gmail.com
Mon Jul 14 09:15:45 GMT 2014


How about running a Workflow with Custom Function?.

https://wiki.vtiger.com/index.php/Invoke_Custom_Function


On 14 July 2014 14:37, SIAM Translations <info at siam-translations.com> wrote:

> Got impression that extension store will be interesting place to surf :-)
>
> Andrew
>
>
>
> On Mon, Jul 14, 2014 at 3:47 PM, Holbok István <holbok at gmail.com> wrote:
>
>>  Dear Vtiger Team,
>>
>> I am in the vtiger custom module development and there is an interesting
>> question:
>>
>> This Custom module is related to the (standard) Contacts module and when
>> some fields were changed in the Contacts module record, accordingly some
>> change should be done in the related Custom module record.
>>
>> It is easy to manage with the following:
>> (1) Register an Eventhandler for the Contacts module (note: there is not
>> any event registered for the Contacts module in the standard install of
>> vtiger 6.1. SVN 14164)
>>
>> Vtiger_Event::register(
>>      'Contacts','vtiger.entity.aftersave',
>>      'ContactsHandler','modules/Contacts/ContactsHandler.php'
>> );
>> Vtiger_Event::register(
>>     'Contacts','vtiger.entity.beforesave',
>>     'ContactsHandler','modules/Contacts/ContactsHandler.php'
>> );
>>
>> This action can be done during postinstall action of the Custom module.
>>
>> And
>> (2) Append the already existing 'modules/Contacts/ContactsHandler.php'
>> file with the following class:
>> class ContactsHandler extends VTEventHandler {
>>      function handleEvent($eventName, $data) {
>>              if($eventName == 'vtiger.entity.beforesave') {
>>                      // Entity is about to be saved, take required action
>>              }
>>              if($eventName == 'vtiger.entity.aftersave') {
>>                      // Entity has been saved, take next action
>>              }
>>      }
>> }
>>
>> This will work without any doubt but in this way I have to modify a core
>> file: 'modules/Contacts/ContactsHandler.php' and it could make some
>> troubles for the Estension Store Custom module.
>>
>> *The Question is:* To avoid modifying core files, will it work, if I
>> will put the custom Contacts handler into Custom module directory?
>>
>> The step 1, registering the eventhandler file in an other place:
>> Vtiger_Event::register(
>>      'Contacts','vtiger.entity.aftersave',
>>      'Contacts*Custommodule*Handler','modules/*Custommodule*/Contacts
>> *Custommodule*Handler.php'
>> );
>> Vtiger_Event::register(
>>     'Contacts','vtiger.entity.beforesave',
>>     'Contacts*Custommodule*Handler','modules/*Custommodule*/Contacts
>> *Custommodule*Handler.php'
>> );
>>
>> The step 2, create a handler file in the Custommodule directory:
>>
>> modules/*Custommodule*/Contacts*Custommodule*Handler.php
>> <?php class Contacts*Custommodule*Handler extends VTEventHandler {
>>      function handleEvent($eventName, $data) {
>>              if($eventName == 'vtiger.entity.beforesave') {
>>                      // Entity is about to be saved, take required action
>>                     // Some code to handle Contacts related actions in
>> the related module.
>>              }
>>              if($eventName == 'vtiger.entity.aftersave') {
>>                      // Entity has been saved, take next action
>>                     // Some code to handle Contacts related actions in
>> the related module.
>>              }
>>      }
>> }
>> ?>
>>
>> Summary: Can I register an event handler with any name in any place?
>> Will it triggered on a proper time?
>>
>> Kindest regards:
>> István
>>
>> --
>> üdvözlettel:
>>
>> *Holbok István*
>>
>> +3670-342-0900
>> *e-mail:* holbok at gmail.com
>> *SkyPe:* holboki
>>
>>
>> _______________________________________________
>> http://www.vtiger.com/
>>
>
>
> _______________________________________________
> http://www.vtiger.com/
>



-- 
Muhammed Abdul Salim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20140714/8572e539/attachment-0001.html>


More information about the vtigercrm-developers mailing list