]> git.mxchange.org Git - friendica-addons.git/blob - notimeline/notimeline.php
Issue 3873
[friendica-addons.git] / notimeline / notimeline.php
1 <?php
2 /**
3  * Name: Notimeline
4  * Description: Disable "Archives" widget on profile page
5  * Version: 1.0
6  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
7  * 
8  *
9  */
10
11 use Friendica\Core\PConfig;
12
13 function notimeline_install() {
14
15         register_hook('plugin_settings', 'addon/notimeline/notimeline.php', 'notimeline_settings');
16         register_hook('plugin_settings_post', 'addon/notimeline/notimeline.php', 'notimeline_settings_post');
17
18 }
19
20
21 function notimeline_uninstall() {
22         unregister_hook('plugin_settings', 'addon/notimeline/notimeline.php', 'notimeline_settings');
23         unregister_hook('plugin_settings_post', 'addon/notimeline/notimeline.php', 'notimeline_settings_post');
24
25 }
26
27
28 function notimeline_settings_post($a,$post) {
29         if(! local_user() || (! x($_POST,'notimeline-submit')))
30                 return;
31
32         PConfig::set(local_user(),'system','no_wall_archive_widget',intval($_POST['notimeline']));
33         info( t('No Timeline settings updated.') . EOL);
34 }
35
36 function notimeline_settings(&$a,&$s) {
37
38         if(! local_user())
39                 return;
40
41         /* Add our stylesheet to the page so we can make our settings look nice */
42
43         $a->page['htmlhead'] .= '<link rel="stylesheet"  type="text/css" href="' . $a->get_baseurl() . '/addon/notimeline/notimeline.css' . '" media="all" />' . "\r\n";
44
45         /* Get the current state of our config variable */
46
47         $notimeline = PConfig::get(local_user(),'system','no_wall_archive_widget');
48         if($notimeline === false)
49                 $notimeline = false;
50
51         $notimeline_checked = (($notimeline) ? ' checked="checked" ' : '');
52
53         
54         /* Add some HTML to the existing form */
55
56         $s .= '<div class="settings-block">';
57         $s .= '<h3>' . t('No Timeline Settings') . '</h3>';
58         $s .= '<div id="notimeline-wrapper">';
59         $s .= '<label id="notimeline-label" for="notimeline-checkbox">' . t('Disable Archive selector on profile wall') . '</label>';
60         $s .= '<input id="notimeline-checkbox" type="checkbox" name="notimeline" value="1" ' . $notimeline_checked . '/>';
61         $s .= '</div><div class="clear"></div>';
62
63         /* provide a submit button */
64
65         $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="notimeline-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
66
67 }