Created
November 5, 2014 02:20
-
-
Save betobaz/d3557ed54afb8851d285 to your computer and use it in GitHub Desktop.
SugarCRM Notifications like facebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ActivitiesLogicHookCustom{ | |
public function notifyActivity($bean, $event, $arguments){ | |
if($bean->module_name == 'Activities'){ | |
global $current_user; | |
$data = json_decode($bean->data); | |
$message = preg_replace('/(\@)\[\w+\:[a-f0-9-]{36}\:([\w ]+)\]/u', '$1$2', $data->value); | |
foreach($data->tags as $tag){ | |
if($tag->module == 'Users'){ | |
$notification = BeanFactory::newBean('Notifications'); | |
$notification->name = $current_user->user_name . ' mentioned you in an activity'; | |
$notification->description = $message; | |
$notification->assigned_user_id = $tag->id; | |
$notification->save(); | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$hook_version = 1; | |
$hook_array = Array(); | |
$hook_array['after_save'] = Array(); | |
$hook_array['after_save'][] = Array(1,'Notify activity','custom/modules/Activities/ActivitiesLogicHookCustom.php','ActivitiesLogicHookCustom','notifyActivity',); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should move your custom_modules_logic_hooks.php to
custom/Extension/modules/Activities/Ext/LogicHooks/notify.php