2 /********************************************************************
3 * Name: Calendar Export
4 * Description: This addon exports the public events of your users as calendar files
6 * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
8 * ******************************************************************/
11 function cal_install()
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');
16 function cal_uninstall()
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');
25 * /cal/$user/export/$format
27 function cal_content()
32 $o = "<p>".t('Some text to explain what this does.')."</p>";
33 } elseif ($a->argc==4) {
34 $username = $a->argv[1];
36 $format = $a->argv[3];
37 $o = "<p>".$do." calendar for ".$username." as ".$format." file.</p>";
39 $o = "<p>".t('Wrong number of parameters')."</p>";
44 function cal_addon_settings_post ( &$a, &$b )
49 if (!x($_POST,'cal-submit'))
52 set_pconfig(local_user(),'cal','enable',intval($_POST['cal-enable']));
54 function cal_addon_settings ( &$a, &$s )
59 $enabled = get_pconfig(local_user(), 'cal', 'enable');
60 $checked = (($enabled) ? ' checked="checked" ' : '');
61 $url = $a->get_baseurl().'/cal/'.$a->user['nickname'].'/export/ical';
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>';