4 * Description: Thread email comment notifications on Gmail and anonymise them
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
10 use Friendica\Core\Addon;
11 use Friendica\Core\L10n;
12 use Friendica\Core\PConfig;
14 function gnot_install() {
16 Addon::registerHook('addon_settings', 'addon/gnot/gnot.php', 'gnot_settings');
17 Addon::registerHook('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
18 Addon::registerHook('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
20 logger("installed gnot");
24 function gnot_uninstall() {
26 Addon::unregisterHook('addon_settings', 'addon/gnot/gnot.php', 'gnot_settings');
27 Addon::unregisterHook('addon_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
28 Addon::unregisterHook('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
31 logger("removed gnot");
38 * Callback from the settings post function.
39 * $post contains the $_POST array.
40 * We will make sure we've got a valid user account
41 * and if so set our configuration setting for this person.
45 function gnot_settings_post($a,$post) {
46 if(! local_user() || (! x($_POST,'gnot-submit')))
49 PConfig::set(local_user(),'gnot','enable',intval($_POST['gnot']));
50 info(L10n::t('Gnot settings updated.') . EOL);
56 * Called from the Addon Setting form.
57 * Add our own settings info to the page.
63 function gnot_settings(&$a,&$s) {
68 /* Add our stylesheet to the page so we can make our settings look nice */
70 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/gnot/gnot.css' . '" media="all" />' . "\r\n";
72 /* Get the current state of our config variable */
74 $gnot = intval(PConfig::get(local_user(),'gnot','enable'));
76 $gnot_checked = (($gnot) ? ' checked="checked" ' : '' );
78 /* Add some HTML to the existing form */
80 $s .= '<div class="settings-block">';
81 $s .= '<h3>' . L10n::t('Gnot Settings') . '</h3>';
82 $s .= '<div id="gnot-wrapper">';
83 $s .= '<div id="gnot-desc">' . L10n::t("Allows threading of email comment notifications on Gmail and anonymising the subject line.") . '</div>';
84 $s .= '<label id="gnot-label" for="gnot">' . L10n::t('Enable this addon?') . '</label>';
85 $s .= '<input id="gnot-input" type="checkbox" name="gnot" value="1"'. $gnot_checked . '/>';
86 $s .= '</div><div class="clear"></div>';
88 /* provide a submit button */
90 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="gnot-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';
95 function gnot_enotify_mail(&$a,&$b) {
96 if((! $b['uid']) || (! intval(PConfig::get($b['uid'], 'gnot','enable'))))
98 if($b['type'] == NOTIFY_COMMENT)
99 $b['subject'] = L10n::t('[Friendica:Notify] Comment to conversation #%d', $b['parent']);