]> git.mxchange.org Git - friendica-addons.git/blob - snautofollow/snautofollow.php
2d953d5b371b7da8f8ef73cf424a16da53c7609c
[friendica-addons.git] / snautofollow / snautofollow.php
1 <?php
2 /**
3  * Name: Snautofollow
4  * Description: Automatic follow/friend of statusnet people who mention/follow you
5  * Version: 1.0
6  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
7  * Status: Unsupported
8  */
9
10
11 function snautofollow_install() {
12
13         register_hook('connector_settings', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings');
14         register_hook('connector_settings_post', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings_post');
15
16 }
17
18
19 function snautofollow_uninstall() {
20         unregister_hook('connector_settings', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings');
21         unregister_hook('connector_settings_post', 'addon/snautofollow/snautofollow.php', 'snautofollow_settings_post');
22
23 }
24
25
26 function snautofollow_settings_post($a,$post) {
27         if(! local_user() || (! x($_POST,'snautofollow-submit')))
28                 return;
29
30         set_pconfig(local_user(),'system','ostatus_autofriend',intval($_POST['snautofollow']));
31         info( t('StatusNet AutoFollow settings updated.') . EOL);
32 }
33
34 function snautofollow_settings(&$a,&$s) {
35
36         if(! local_user())
37                 return;
38
39         /* Add our stylesheet to the page so we can make our settings look nice */
40
41         $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/snautofollow/snautofollow.css' . '" media="all" />' . "\r\n";
42
43         /* Get the current state of our config variable */
44
45         $snautofollow = get_pconfig(local_user(),'system','ostatus_autofriend');
46         if($snautofollow === false)
47                 $snautofollow = false;
48
49         $snautofollow_checked = (($snautofollow) ? ' checked="checked" ' : '');
50
51
52         /* Add some HTML to the existing form */
53
54         $s .= '<span id="settings_snautofollow_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_snautofollow_expanded\'); openClose(\'settings_snautofollow_inflated\');">';
55         $s .= '<h3>' . t('StatusNet AutoFollow') . '</h3>';
56         $s .= '</span>';
57         $s .= '<div id="settings_snautofollow_expanded" class="settings-block" style="display: none;">';
58         $s .= '<span class="fakelink" onclick="openClose(\'settings_snautofollow_expanded\'); openClose(\'settings_snautofollow_inflated\');">';
59         $s .= '<h3>' . t('StatusNet AutoFollow') . '</h3>';
60         $s .= '</span>';
61
62         $s .= '<div id="snautofollow-wrapper">';
63         $s .= '<label id="snautofollow-label" for="snautofollow-checkbox">' . t('Automatically follow any StatusNet followers/mentioners') . '</label>';
64         $s .= '<input id="snautofollow-checkbox" type="checkbox" name="snautofollow" value="1" ' . $snautofollow_checked . '/>';
65         $s .= '</div><div class="clear"></div>';
66
67         /* provide a submit button */
68
69         $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="snautofollow-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
70
71 }