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;
15 use Friendica\Core\Session;
17 use Friendica\Model\Notification;
19 function gnot_install()
21 Hook::register('addon_settings', 'addon/gnot/gnot.php', 'gnot_settings');
22 Hook::register('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
23 Hook::register('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
25 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.
34 function gnot_settings_post(App $a, $post) {
35 if(! Session::getLocalUser() || empty($_POST['gnot-submit']))
38 DI::pConfig()->set(Session::getLocalUser(),'gnot','enable',intval($_POST['gnot']));
42 * Called from the Addon Setting form.
43 * Add our own settings info to the page.
45 function gnot_settings(App &$a, array &$data)
47 if (!Session::getLocalUser()) {
51 $gnot = intval(DI::pConfig()->get(Session::getLocalUser(), 'gnot', 'enable'));
53 $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/gnot/');
54 $html = Renderer::replaceMacros($t, [
55 '$text' => DI::l10n()->t("Allows threading of email comment notifications on Gmail and anonymising the subject line."),
56 '$enabled' => ['gnot', DI::l10n()->t('Enable this addon?'), $gnot],
61 'title' => DI::l10n()->t('Gnot Settings'),
66 function gnot_enotify_mail(App $a, array &$b)
68 if ((!$b['uid']) || (! intval(DI::pConfig()->get($b['uid'], 'gnot','enable')))) {
72 if ($b['type'] == Notification\Type::COMMENT) {
73 $b['subject'] = DI::l10n()->t('[Friendica:Notify] Comment to conversation #%d', $b['parent']);