SuiteCRM-Core/public/legacy/modules/Project/ProjectJjwg_MapsLogicHook.php
Clemente Raposo 5aa0daf046 Merge next into suite 8
Merge commit 'de4bf25cb3' into release/8.4.0-beta

# Conflicts:
#	public/legacy/data/SugarBean.php
#	public/legacy/include/Smarty/plugins/function.sugarvar.php
#	public/legacy/include/SugarDateTime.php
#	public/legacy/include/database/MysqliManager.php
#	public/legacy/modules/Alerts/metadata/listviewdefs.php
#	public/legacy/modules/SugarFeed/Dashlets/SugarFeedDashlet/SugarFeedDashlet.php
#	public/legacy/modules/Trackers/metadata/SearchFields.php
#	public/legacy/modules/Trackers/metadata/listviewdefs.php
#	public/legacy/modules/UpgradeWizard/SugarMerge/EditViewMerge.php
#	public/legacy/suitecrm_version.php
2023-07-21 15:22:52 +01:00

70 lines
2.3 KiB
PHP

<?php
// custom/modules/Project/ProjectJjwg_MapsLogicHook.php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
#[\AllowDynamicProperties]
class ProjectJjwg_MapsLogicHook
{
public $jjwg_Maps;
public function __construct()
{
$this->jjwg_Maps = get_module_info('jjwg_Maps');
}
public function updateGeocodeInfo(&$bean, $event, $arguments)
{
// before_save
if ($this->jjwg_Maps->settings['logic_hooks_enabled']) {
$this->jjwg_Maps->updateGeocodeInfo($bean);
}
}
public function updateRelatedMeetingsGeocodeInfo(&$bean, $event, $arguments)
{
// after_save
if ($this->jjwg_Maps->settings['logic_hooks_enabled']) {
$this->jjwg_Maps->updateRelatedMeetingsGeocodeInfo($bean);
}
}
public function addRelationship(&$bean, $event, $arguments)
{
// after_relationship_add
// $arguments['module'], $arguments['related_module'], $arguments['id'] and $arguments['related_id']
$focus = get_module_info($arguments['module']);
if ($this->jjwg_Maps->settings['logic_hooks_enabled']) {
if (!empty($arguments['id'])) {
$focus->retrieve($arguments['id']);
$focus->custom_fields->retrieve();
$this->jjwg_Maps->updateGeocodeInfo($focus, true);
if ($focus->jjwg_maps_address_c != $focus->fetched_row['jjwg_maps_address_c']) {
$focus->save(false);
}
}
}
}
public function deleteRelationship(&$bean, $event, $arguments)
{
// after_relationship_delete
// $arguments['module'], $arguments['related_module'], $arguments['id'] and $arguments['related_id']
if ($this->jjwg_Maps->settings['logic_hooks_enabled']) {
$focus = get_module_info($arguments['module']);
if (!empty($arguments['id'])) {
$focus->retrieve($arguments['id']);
$focus->custom_fields->retrieve();
$this->jjwg_Maps->updateGeocodeInfo($focus, true);
if ($focus->jjwg_maps_address_c != $focus->fetched_row['jjwg_maps_address_c']) {
$focus->save(false);
}
}
}
}
}