- $o = "<p>".t('Some text to explain what this does.')."</p>";
+ $o .= "<h3>".t('Event Export')."</h3><p>".t('You can download public events from: ').$a->get_baseurl()."/cal/username/export/ical</p>";
} elseif ($a->argc==4) {
+ // get the parameters from the request we just received
$username = $a->argv[1];
$do = $a->argv[2];
$format = $a->argv[3];
- $o = "<p>".$do." calendar for ".$username." as ".$format." file.</p>";
+ // check that there is a user matching the requested profile
+ $r = q("SELECT uid FROM user WHERE nickname='".$username."' LIMIT 1;");
+ if (count($r))
+ {
+ $uid = $r[0]['uid'];
+ } else {
+ killme();
+ }
+ // if we shall do anything other then export, end here
+ if (! $do == 'export' )
+ killme();
+ // check if the user allows us to share the profile
+ $enable = get_pconfig( $uid, 'cal', 'enable');
+ if (! $enable == 1) {
+ info(t('The user does not export the calendar.'));
+ return;
+ }
+ // we are allowed to show events
+ // get the timezone the user is in
+ $r = q("SELECT timezone FROM user WHERE uid=".$uid." LIMIT 1;");
+ if (count($r))
+ $timezone = $r[0]['timezone'];
+ // does the user who requests happen to be the owner of the events
+ // requested? then show all of your events, otherwise only those that
+ // don't have limitations set in allow_cid and allow_gid
+ if (local_user() == $uid) {
+ $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location` FROM `event` WHERE `uid`=".$uid.";");
+ } else {
+ $r = q("SELECT `start`, `finish`, `adjust`, `summary`, `desc`, `location` FROM `event` WHERE `allow_cid`='' and `allow_gid`='' and `uid`='".$uid."';");
+ }
+ // we have the events that are available for the requestor
+ // now format the output according to the requested format