]> git.mxchange.org Git - friendica-addons.git/blob - cal/cal.php
cal: added user config
[friendica-addons.git] / cal / cal.php
1 <?php
2 /********************************************************************
3  * Name: Calendar Export
4  * Description: This addon exports the public events of your users as calendar files
5  * Version: 0.1
6  * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
7  * License: MIT
8  * ******************************************************************/
9
10
11 function cal_install()
12 {
13     register_hook('plugin_settings', 'addon/cal/cal.php', 'cal_addon_settings');
14     register_hook('plugin_settings_post', 'addon/cal/cal.php', 'cal_addon_settings_post');
15 }
16 function cal_uninstall()
17 {
18     unregister_hook('plugin_settings', 'addon/cal/cal.php', 'cal_addon_settings');
19     unregister_hook('plugin_settings_post', 'addon/cal/cal.php', 'cal_addon_settings_post');
20 }
21 function cal_module()
22 {
23 }
24 /*  pathes
25  *  /cal/$user/export/$format
26  */
27 function cal_content()
28 {
29     $a = get_app();
30     $o = "";
31     if ($a->argc == 1) {
32         $o = "<p>".t('Some text to explain what this does.')."</p>";
33     } elseif ($a->argc==4) {
34         $username = $a->argv[1];
35         $do = $a->argv[2];
36         $format = $a->argv[3];
37         $o = "<p>".$do." calendar for ".$username." as ".$format." file.</p>";
38     } else {
39         $o = "<p>".t('Wrong number of parameters')."</p>";
40     }
41     return $o;
42 }
43
44 function cal_addon_settings_post ( &$a, &$b  )
45 {
46     if (! local_user())
47         return;
48
49     if (!x($_POST,'cal-submit'))
50         return;
51
52     set_pconfig(local_user(),'cal','enable',intval($_POST['cal-enable']));
53 }
54 function cal_addon_settings ( &$a, &$s  )
55 {
56     if (! local_user())
57         return;
58
59     $enabled = get_pconfig(local_user(), 'cal', 'enable');
60     $checked = (($enabled) ? ' checked="checked" ' : '');
61     $url = $a->get_baseurl().'/cal/'.$a->user['nickname'].'/export/ical';
62
63     $s .= '<h3>'.t('Export Events').'</h3>';
64     $s .= '<p>'.t('If this is enabled, you public events will be available at').' <strong>'.$url.'</strong></p>';
65     $s .= '<div id="cal-enable-wrapper">';
66     $s .= '<label id="cal-enable-label" for="cal-checkbox">'. t('Enable calendar export') .'</label>';
67     $s .= '<input id="cal-checkbox" type="checkbox" name="cal-enable" value="1" ' . $checked . '/>';
68     $s .= '</div><div class="clear"></div>';
69     $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="cal-submit" class="settings-submit" value="' . t('Submit') . '" /></div>'; 
70     $s .= '</div><div class="clear"></div>';
71
72 }
73
74 ?>