From: friendica Date: Tue, 28 Feb 2012 01:17:22 +0000 (-0800) Subject: add gnot plugin X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bce0e4f5a0e0d1bd72c5511cb284ee8e334ccd18;p=friendica-addons.git add gnot plugin --- diff --git a/gnot.tgz b/gnot.tgz new file mode 100644 index 00000000..fbf7f267 Binary files /dev/null and b/gnot.tgz differ diff --git a/gnot/gnot.css b/gnot/gnot.css new file mode 100755 index 00000000..ccafdafb --- /dev/null +++ b/gnot/gnot.css @@ -0,0 +1,16 @@ + +#gnot-desc { + margin-bottom: 10px; +} + +#gnot-label { + float: left; + width: 200px; + margin-bottom: 25px; +} + +#gnot { + float: left; +} + + diff --git a/gnot/gnot.php b/gnot/gnot.php new file mode 100755 index 00000000..fd8fdfd9 --- /dev/null +++ b/gnot/gnot.php @@ -0,0 +1,99 @@ + + * + * + */ + + +function gnot_install() { + + register_hook('plugin_settings', 'addon/gnot/gnot.php', 'gnot_settings'); + register_hook('plugin_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post'); + register_hook('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail'); + + logger("installed gnot"); +} + + +function gnot_uninstall() { + + unregister_hook('plugin_settings', 'addon/gnot/gnot.php', 'gnot_settings'); + unregister_hook('plugin_settings_post', 'addon/gnot/gnot.php', 'gnot_settings_post'); + unregister_hook('enotify_mail', 'addon/gnot/gnot.php', 'gnot_enotify_mail'); + + + logger("removed gnot"); +} + + + +/** + * + * Callback from the settings post function. + * $post contains the $_POST array. + * We will make sure we've got a valid user account + * and if so set our configuration setting for this person. + * + */ + +function gnot_settings_post($a,$post) { + if(! local_user() || (! x($_POST,'gnot-submit'))) + return; + + set_pconfig(local_user(),'gnot','enable',intval($_POST['gnot'])); + info( t('Gnot settings updated.') . EOL); +} + + +/** + * + * Called from the Plugin Setting form. + * Add our own settings info to the page. + * + */ + + + +function gnot_settings(&$a,&$s) { + + if(! local_user()) + return; + + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + /* Get the current state of our config variable */ + + $gnot = intval(get_pconfig(local_user(),'gnot','enable')); + + $gnot_checked = (($gnot) ? ' checked="checked" ' : '' ); + + /* Add some HTML to the existing form */ + + $s .= '
'; + $s .= '

' . t('Gnot Settings') . '

'; + $s .= '
'; + $s .= '
' . t("Allows threading of email comment notifications on Gmail and anonymising the subject line.") . '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + /* provide a submit button */ + + $s .= '
'; + +} + + +function gnot_enotify_mail(&$a,&$b) { + if((! $b['uid']) || (! intval(get_pconfig($b['uid'], 'gnot','enable')))) + return; + if($b['type'] == NOTIFY_COMMENT) + $b['subject'] = sprintf( t('[Friendica:Notify] Comment to conversation #%d'), $b['parent']); +} +