Skip to content
Snippets Groups Projects
Commit b13d323b authored by Uma's avatar Uma
Browse files

Merge branch 'Relation_EventHandlers' into 'master'

Fixes #213 #216 Supported vtiger evenhandler for Relating entites

See merge request !567
parents 748c93ac a3901e82
No related branches found
No related tags found
No related merge requests found
......@@ -1632,11 +1632,18 @@ function DeleteEntity($module,$return_module,$focus,$record,$return_id) {
* Function to related two records of different entity types
*/
function relateEntities($focus, $sourceModule, $sourceRecordId, $destinationModule, $destinationRecordIds) {
$db = PearDatabase::getInstance();
$em = new VTEventsManager($db);
$data = array('sourceModule'=>$sourceModule, 'sourceRecordId'=>$sourceRecordId,
'destinationModule'=>$destinationModule,'destinationRecordIds'=>$destinationRecordIds);
$em->triggerEvent("vtiger.entity.beforerelate", $data);
if(!is_array($destinationRecordIds)) $destinationRecordIds = Array($destinationRecordIds);
foreach($destinationRecordIds as $destinationRecordId) {
$focus->save_related_module($sourceModule, $sourceRecordId, $destinationModule, $destinationRecordId);
$focus->trackLinkedInfo($sourceModule, $sourceRecordId, $destinationModule, $destinationRecordId);
}
$em->triggerEvent("vtiger.entity.afterrelate", $data);
}
/**
......
......@@ -137,4 +137,12 @@ if (defined('VTIGER_UPGRADE')) {
createUserSharingPrivilegesfile($userId);
}
echo "Re-calculated user privilege and sharing privileges files";
//Adding beforeRelate and afterRelate event handlers
$em = new VTEventsManager($db);
$em->registerHandler('vtiger.entity.beforerelate', 'modules/Vtiger/handlers/RelateEntitesHandler.php', 'RelateEntitesHandler');
echo '<br>Succecssfully added before relate handler<br>';
$em->registerHandler('vtiger.entity.afterrelate', 'modules/Vtiger/handlers/RelateEntitesHandler.php', 'RelateEntitesHandler');
echo '<br>Succecssfully added before relate handler<br>';
}
\ No newline at end of file
<?php
/* +**********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
* ***********************************************************************************/
require_once 'include/events/VTEventHandler.inc';
class RelateEntitesHandler extends VTEventHandler {
function handleEvent($eventName, $entityData) {
global $log;
$log->debug("Entering function RelateEntitesHandler ($eventName)");
if ($eventName == 'vtiger.entity.beforerelate') {
$log->debug("Calling function triggerBeforeRelationsHandler ($eventName)");
$this->triggerBeforeRelationsHandler($entityData);
} else if ($eventName == 'vtiger.entity.afterrelate') {
$log->debug("Calling function triggerAfterRelationHandler ($eventName)");
$this->triggerAfterRelationHandler($entityData);
}
}
public function triggerBeforeRelationsHandler($entityData) {
return true;
}
public function triggerAfterRelationHandler($entityData) {
return true;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment