4 * Description: Thread email comment notifications on Gmail and anonymise them
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
12 use Friendica\Core\Hook;
13 use Friendica\Core\Logger;
14 use Friendica\Core\Renderer;
16 use Friendica\Model\Notification;
18 function gnot_install() {
20 Hook::register('addon_settings', 'addon/gnot/gnot.php', 'gnot_settings');
21 Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
22 Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
24 Logger::notice("installed gnot");
29 * Callback from the settings post function.
30 * $post contains the $_POST array.
31 * We will make sure we've got a valid user account
32 * and if so set our configuration setting for this person.
36 function gnot_settings_post($a,$post) {
37 if(! local_user() || empty($_POST['gnot-submit']))
40 DI::pConfig()->set(local_user(),'gnot','enable',intval($_POST['gnot']));
46 * Called from the Addon Setting form.
47 * Add our own settings info to the page.
53 function gnot_settings(App &$a, array &$data)
59 $gnot = intval(DI::pConfig()->get(local_user(), 'gnot', 'enable'));
61 $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/gnot/');
62 $html = Renderer::replaceMacros($t, [
63 '$text' => DI::l10n()->t("Allows threading of email comment notifications on Gmail and anonymising the subject line."),
64 '$enabled' => ['gnot', DI::l10n()->t('Enable this addon?'), $gnot],
69 'title' => DI::l10n()->t('Gnot Settings'),
75 function gnot_enotify_mail(&$a,&$b) {
76 if((! $b['uid']) || (! intval(DI::pConfig()->get($b['uid'], 'gnot','enable'))))
78 if($b['type'] == Notification\Type::COMMENT)
79 $b['subject'] = DI::l10n()->t('[Friendica:Notify] Comment to conversation #%d', $b['parent']);