4 * Description: Thread email comment notifications on Gmail and anonymise them
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
12 function gnot_install() {
14 register_hook('plugin_settings', 'addon/gnot/gnot.php', 'gnot_settings');
15 register_hook('plugin_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
16 register_hook('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
18 logger("installed gnot");
22 function gnot_uninstall() {
24 unregister_hook('plugin_settings', 'addon/gnot/gnot.php', 'gnot_settings');
25 unregister_hook('plugin_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post');
26 unregister_hook('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail');
29 logger("removed gnot");
36 * Callback from the settings post function.
37 * $post contains the $_POST array.
38 * We will make sure we've got a valid user account
39 * and if so set our configuration setting for this person.
43 function gnot_settings_post($a,$post) {
44 if(! local_user() || (! x($_POST,'gnot-submit')))
47 set_pconfig(local_user(),'gnot','enable',intval($_POST['gnot']));
48 info( t('Gnot settings updated.') . EOL);
54 * Called from the Plugin Setting form.
55 * Add our own settings info to the page.
61 function gnot_settings(&$a,&$s) {
66 /* Add our stylesheet to the page so we can make our settings look nice */
68 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/gnot/gnot.css' . '" media="all" />' . "\r\n";
70 /* Get the current state of our config variable */
72 $gnot = intval(get_pconfig(local_user(),'gnot','enable'));
74 $gnot_checked = (($gnot) ? ' checked="checked" ' : '' );
76 /* Add some HTML to the existing form */
78 $s .= '<div class="settings-block">';
79 $s .= '<h3>' . t('Gnot Settings') . '</h3>';
80 $s .= '<div id="gnot-wrapper">';
81 $s .= '<div id="gnot-desc">' . t("Allows threading of email comment notifications on Gmail and anonymising the subject line.") . '</div>';
82 $s .= '<label id="gnot-label" for="gnot">' . t('Enable this plugin/addon?') . '</label>';
83 $s .= '<input id="gnot-input" type="checkbox" name="gnot" value="1"'. $gnot_checked . '/>';
84 $s .= '</div><div class="clear"></div>';
86 /* provide a submit button */
88 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="gnot-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
93 function gnot_enotify_mail(&$a,&$b) {
94 if((! $b['uid']) || (! intval(get_pconfig($b['uid'], 'gnot','enable'))))
96 if($b['type'] == NOTIFY_COMMENT)
97 $b['subject'] = sprintf( t('[Friendica:Notify] Comment to conversation #%d'), $b['parent']);