]> git.mxchange.org Git - friendica-addons.git/commitdiff
autofollow StatusNet mentions/follows
authorfriendica <info@friendica.com>
Fri, 8 Jun 2012 03:45:29 +0000 (20:45 -0700)
committerfriendica <info@friendica.com>
Fri, 8 Jun 2012 03:45:29 +0000 (20:45 -0700)
snautofollow.tgz [new file with mode: 0644]
snautofollow/snautofollow.css [new file with mode: 0644]
snautofollow/snautofollow.php [new file with mode: 0644]

diff --git a/snautofollow.tgz b/snautofollow.tgz
new file mode 100644 (file)
index 0000000..57e6db7
Binary files /dev/null and b/snautofollow.tgz differ
diff --git a/snautofollow/snautofollow.css b/snautofollow/snautofollow.css
new file mode 100644 (file)
index 0000000..243ecaa
--- /dev/null
@@ -0,0 +1,14 @@
+
+
+
+#snautofollow-label {
+       float: left;
+       width: 200px;
+       margin-bottom: 25px;
+}
+
+#snautofollow-checkbox {
+       float: left;
+}
+
+
diff --git a/snautofollow/snautofollow.php b/snautofollow/snautofollow.php
new file mode 100644 (file)
index 0000000..2efc212
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Name: Snautofollow
+ * Description: Automatic follow/friend of statusnet people who mention/follow you
+ * Version: 1.0
+ * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
+ * 
+ *
+ */
+
+
+function snautofollow_install() {
+
+       register_hook('connector_settings', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings');
+       register_hook('connector_settings_post', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings_post');
+
+}
+
+
+function snautofollow_uninstall() {
+       unregister_hook('connector_settings', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings');
+       unregister_hook('connector_settings_post', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings_post');
+
+}
+
+
+function snautofollow_settings_post($a,$post) {
+       if(! local_user() || (! x($_POST,'snautofollow-submit')))
+               return;
+
+       set_pconfig(local_user(),'system','ostatus_autofriend',intval($_POST['snautofollow']));
+       info( t('StatusNet AutoFollow settings updated.') . EOL);
+}
+
+function snautofollow_settings(&$a,&$s) {
+
+       if(! local_user())
+               return;
+
+       /* Add our stylesheet to the page so we can make our settings look nice */
+
+       $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/snautofollow/snautofollow.css' . '" media="all" />' . "\r\n";
+
+       /* Get the current state of our config variable */
+
+       $snautofollow = get_pconfig(local_user(),'system','ostatus_autofriend');
+       if($snautofollow === false)
+               $snautofollow = false;
+
+       $snautofollow_checked = (($snautofollow) ? ' checked="checked" ' : '');
+
+       
+       /* Add some HTML to the existing form */
+
+       $s .= '<div class="settings-block">';
+       $s .= '<h3>' . t('StatusNet AutoFollow Settings') . '</h3>';
+       $s .= '<div id="snautofollow-wrapper">';
+       $s .= '<label id="snautofollow-label" for="snautofollow-checkbox">' . t('Automatically follow any StatusNet followers/mentioners') . '</label>';
+       $s .= '<input id="snautofollow-checkbox" type="checkbox" name="snautofollow" value="1" ' . $snautofollow_checked . '/>';
+       $s .= '</div><div class="clear"></div>';
+
+       /* provide a submit button */
+
+       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="snautofollow-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
+
+}