aboutsummaryrefslogtreecommitdiffstats
path: root/mod/events.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/events.php')
-rwxr-xr-xmod/events.php125
1 files changed, 71 insertions, 54 deletions
diff --git a/mod/events.php b/mod/events.php
index 9c94d433d..9120f8713 100755
--- a/mod/events.php
+++ b/mod/events.php
@@ -8,7 +8,7 @@ require_once('include/items.php');
function events_post(&$a) {
- logger('post: ' . print_r($_REQUEST,true));
+ logger('post: ' . print_r($_REQUEST,true), LOGGER_DATA);
if(! local_channel())
return;
@@ -41,16 +41,11 @@ function events_post(&$a) {
$categories = escape_tags(trim($_POST['category']));
-
-
// only allow editing your own events.
if(($xchan) && ($xchan !== get_observer_hash()))
return;
- // The default setting for the `private` field in event_store() is false, so mirror that
- $private_event = false;
-
if($start_text) {
$start = $start_text;
}
@@ -89,14 +84,14 @@ function events_post(&$a) {
$summary = escape_tags(trim($_POST['summary']));
$desc = escape_tags(trim($_POST['desc']));
$location = escape_tags(trim($_POST['location']));
- $type = 'event';
+ $type = escape_tags(trim($_POST['type']));
require_once('include/text.php');
linkify_tags($a, $desc, local_channel());
linkify_tags($a, $location, local_channel());
$action = ($event_hash == '') ? 'new' : "event/" . $event_hash;
- $onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish";
+ $onerror_url = $a->get_baseurl() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish&type=$type";
if(strcmp($finish,$start) < 0 && !$nofinish) {
notice( t('Event can not end before it has started.') . EOL);
if(intval($_REQUEST['preview'])) {
@@ -119,6 +114,8 @@ function events_post(&$a) {
$channel = $a->get_channel();
+ $acl = new AccessList(false);
+
if($event_id) {
$x = q("select * from event where id = %d and uid = %d limit 1",
intval($event_id),
@@ -132,44 +129,33 @@ function events_post(&$a) {
}
return;
}
+
+ $acl->set($x[0]);
+
+ $created = $x[0]['created'];
+ $edited = datetime_convert();
+
if($x[0]['allow_cid'] === '<' . $channel['channel_hash'] . '>'
&& $x[0]['allow_gid'] === '' && $x[0]['deny_cid'] === '' && $x[0]['deny_gid'] === '') {
$share = false;
}
else {
$share = true;
- $str_group_allow = $x[0]['allow_gid'];
- $str_contact_allow = $x[0]['allow_cid'];
- $str_group_deny = $x[0]['deny_gid'];
- $str_contact_deny = $x[0]['deny_cid'];
-
- if(strlen($str_group_allow) || strlen($str_contact_allow)
- || strlen($str_group_deny) || strlen($str_contact_deny)) {
- $private_event = true;
- }
}
}
else {
+ $created = $edited = datetime_convert();
if($share) {
- $str_group_allow = perms2str($_POST['group_allow']);
- $str_contact_allow = perms2str($_POST['contact_allow']);
- $str_group_deny = perms2str($_POST['group_deny']);
- $str_contact_deny = perms2str($_POST['contact_deny']);
-
- if(strlen($str_group_allow) || strlen($str_contact_allow)
- || strlen($str_group_deny) || strlen($str_contact_deny)) {
- $private_event = true;
- }
+ $acl->set_from_array($_POST);
}
else {
- $str_contact_allow = '<' . $channel['channel_hash'] . '>';
- $str_group_allow = $str_contact_deny = $str_group_deny = '';
- $private_event = true;
+ $acl->set(array('allow_cid' => '<' . $channel['channel_hash'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => ''));
}
}
$post_tags = array();
$channel = $a->get_channel();
+ $ac = $acl->get();
if(strlen($categories)) {
$cats = explode(',',$categories);
@@ -196,11 +182,11 @@ function events_post(&$a) {
$datarray['uid'] = local_channel();
$datarray['account'] = get_account_id();
$datarray['event_xchan'] = $channel['channel_hash'];
- $datarray['allow_cid'] = $str_contact_allow;
- $datarray['allow_gid'] = $str_group_allow;
- $datarray['deny_cid'] = $str_contact_deny;
- $datarray['deny_gid'] = $str_group_deny;
- $datarray['private'] = (($private_event) ? 1 : 0);
+ $datarray['allow_cid'] = $ac['allow_cid'];
+ $datarray['allow_gid'] = $ac['allow_gid'];
+ $datarray['deny_cid'] = $ac['deny_cid'];
+ $datarray['deny_gid'] = $ac['deny_gid'];
+ $datarray['private'] = (($acl->is_private()) ? 1 : 0);
$datarray['id'] = $event_id;
$datarray['created'] = $created;
$datarray['edited'] = $edited;
@@ -228,6 +214,27 @@ function events_post(&$a) {
function events_content(&$a) {
+ if(argc() > 2 && argv(1) == 'ical') {
+ $event_id = argv(2);
+
+ require_once('include/security.php');
+ $sql_extra = permissions_sql(local_channel());
+
+ $r = q("select * from event where event_hash = '%s' $sql_extra limit 1",
+ dbesc($event_id)
+ );
+ if($r) {
+ header('Content-type: text/calendar');
+ header('content-disposition: attachment; filename="' . t('event') . '-' . $event_id . '.ics"' );
+ echo ical_wrapper($r);
+ killme();
+ }
+ else {
+ notice( t('Event not found.') . EOL );
+ return;
+ }
+ }
+
if(! local_channel()) {
notice( t('Permission denied.') . EOL);
return;
@@ -306,6 +313,10 @@ function events_content(&$a) {
killme();
}
+
+
+
+
if($mode == 'view') {
@@ -366,8 +377,18 @@ function events_content(&$a) {
intval(local_channel()),
intval($_GET['id'])
);
- } else {
-
+ } elseif($export) {
+ $r = q("SELECT * from event where uid = %d
+ AND (( `adjust` = 0 AND ( `finish` >= '%s' or nofinish = 1 ) AND `start` <= '%s' )
+ OR ( `adjust` = 1 AND ( `finish` >= '%s' or nofinish = 1 ) AND `start` <= '%s' )) ",
+ intval(local_channel()),
+ dbesc($start),
+ dbesc($finish),
+ dbesc($adjust_start),
+ dbesc($adjust_finish)
+ );
+ }
+ else {
// fixed an issue with "nofinish" events not showing up in the calendar.
// There's still an issue if the finish date crosses the end of month.
// Noting this for now - it will need to be fixed here and in Friendica.
@@ -384,17 +405,19 @@ function events_content(&$a) {
dbesc($adjust_start),
dbesc($adjust_finish)
);
-
}
+
$links = array();
- if($r) {
+ if($r && ! $export) {
xchan_query($r);
$r = fetch_post_tags($r,true);
$r = sort_by_date($r);
+ }
+ if($r) {
foreach($r as $rr) {
$j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'j') : datetime_convert('UTC','UTC',$rr['start'],'j'));
if(! x($links,$j))
@@ -402,7 +425,6 @@ function events_content(&$a) {
}
}
-
$events=array();
$last_date = '';
@@ -427,8 +449,9 @@ function events_content(&$a) {
$is_first = ($d !== $last_date);
$last_date = $d;
-// FIXME
- $edit = (($rr['item_flags'] & ITEM_WALL) ? array($a->get_baseurl().'/events/event/'.$rr['event_hash'],t('Edit event'),'','') : null);
+
+ $edit = (intval($rr['item_wall']) ? array($a->get_baseurl().'/events/event/'.$rr['event_hash'],t('Edit event'),'','') : null);
+
$drop = array($a->get_baseurl().'/events/drop/'.$rr['event_hash'],t('Delete event'),'','');
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
@@ -546,9 +569,7 @@ function events_content(&$a) {
if(x($_REQUEST,'location')) $orig_event['location'] = $_REQUEST['location'];
if(x($_REQUEST,'start')) $orig_event['start'] = $_REQUEST['start'];
if(x($_REQUEST,'finish')) $orig_event['finish'] = $_REQUEST['finish'];
- }
-
- if($mode === 'edit' || $mode === 'new') {
+ if(x($_REQUEST,'type')) $orig_event['type'] = $_REQUEST['type'];
$n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : '');
$a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : '');
@@ -567,9 +588,6 @@ function events_content(&$a) {
if($orig_event['event_xchan'])
$sh_checked .= ' disabled="disabled" ';
-
-
-
$sdt = ((x($orig_event)) ? $orig_event['start'] : 'now');
$fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now');
@@ -595,6 +613,7 @@ function events_content(&$a) {
$fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0);
$ftext = datetime_convert('UTC',$tz,$fdt);
$ftext = substr($ftext,0,14) . "00:00";
+ $type = ((x($orig_event)) ? $orig_event['type'] : 'event');
$f = get_config('system','event_input_format');
if(! $f)
@@ -622,18 +641,16 @@ function events_content(&$a) {
require_once('include/acl_selectors.php');
- $perm_defaults = array(
- 'allow_cid' => $channel['channel_allow_cid'],
- 'allow_gid' => $channel['channel_allow_gid'],
- 'deny_cid' => $channel['channel_deny_cid'],
- 'deny_gid' => $channel['channel_deny_gid']
- );
+ $acl = new AccessList($channel);
+ $perm_defaults = $acl->get();
+
$tpl = get_markup_template('event_form.tpl');
$o .= replace_macros($tpl,array(
'$post' => $a->get_baseurl() . '/events',
'$eid' => $eid,
+ '$type' => $type,
'$xchan' => $event_xchan,
'$mid' => $mid,
'$event_hash' => $event_id,
@@ -646,7 +663,7 @@ function events_content(&$a) {
'$s_text' => t('Event Starts:'),
'$stext' => $stext,
'$ftext' => $ftext,
- '$required' => ' <span class="required" title="' . t('Required') . '">*</span>',
+ '$required' => '<span class="required" title="' . t('Required') . '">*</span>',
'$ModalCANCEL' => t('Cancel'),
'$ModalOK' => t('OK'),
'$s_dsel' => datetimesel($f,new DateTime(),DateTime::createFromFormat('Y',$syear+5),DateTime::createFromFormat('Y-m-d H:i',"$syear-$smonth-$sday $shour:$sminute"),'start_text',true,true,'','',true),