From a0065835a6bae8e0f3d4cb3a425d5bab3a5c5892 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 13 Oct 2020 10:28:09 -0600 Subject: [PATCH] Update infolog & projectmanager on client when you add a timesheet entry --- infolog/inc/class.infolog_hooks.inc.php | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/infolog/inc/class.infolog_hooks.inc.php b/infolog/inc/class.infolog_hooks.inc.php index 02aa0c94ae..a1cd42fd56 100644 --- a/infolog/inc/class.infolog_hooks.inc.php +++ b/infolog/inc/class.infolog_hooks.inc.php @@ -11,6 +11,7 @@ */ use EGroupware\Api; +use EGroupware\Api\Hooks; use EGroupware\Api\Link; use EGroupware\Api\Framework; use EGroupware\Api\Egw; @@ -72,11 +73,41 @@ class infolog_hooks ), 'edit_id' => 'info_id', 'edit_popup' => '760x570', + 'notify' => self::class.'::link_notify', 'merge' => true, 'push_data' => self::class.'::prepareEventPush' ); } + /** + * Get notified about changes to linked entries + * + * 'type' => $type, + * 'id' => $notify_id, + * 'target_app' => $target_app, + * 'target_id' => $target_id, + * 'link_id' => $link_id, + * 'data' => $data, + */ + static public function link_notify($data) + { + switch($data['target_app']) + { + case 'timesheet': + // Something changed with a timesheet linked to an infolog. Trigger update in place to update times. + $bo = new infolog_bo(); + $push_data = $bo->read($data['id']); + Hooks::process([ + 'location' => 'notify-all', + 'type' => 'update-in-place', + 'app' => 'infolog', + 'id' => $data['id'], + 'data' => $push_data, + ], null, true); + break; + } + } + /** * Prepare entry to be pushed via Link::notify_update() *