aboutsummaryrefslogtreecommitdiffstats
path: root/mod/events.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-01-15 20:13:25 -0800
committerfriendica <info@friendica.com>2013-01-15 20:13:25 -0800
commitddd8a0e062964cc18a7ef54828019ee28e63175b (patch)
treec86901191690ddddaa861c0d5cce4d8f845030cb /mod/events.php
parent275fa6e1d26b4ce3090719c9b9d913ef1f2091a1 (diff)
downloadvolse-hubzilla-ddd8a0e062964cc18a7ef54828019ee28e63175b.tar.gz
volse-hubzilla-ddd8a0e062964cc18a7ef54828019ee28e63175b.tar.bz2
volse-hubzilla-ddd8a0e062964cc18a7ef54828019ee28e63175b.zip
still some bugs but events are happening again.
Diffstat (limited to 'mod/events.php')
-rwxr-xr-xmod/events.php77
1 files changed, 35 insertions, 42 deletions
diff --git a/mod/events.php b/mod/events.php
index 0002bf11c..9bcad1f87 100755
--- a/mod/events.php
+++ b/mod/events.php
@@ -69,14 +69,7 @@ function events_post(&$a) {
$share = ((intval($_POST['share'])) ? intval($_POST['share']) : 0);
- $c = q("select id from contact where uid = %d and self = 1 limit 1",
- intval(local_user())
- );
- if(count($c))
- $self = $c[0]['id'];
- else
- $self = 0;
-
+ $channel = $a->get_channel();
if($share) {
$str_group_allow = perms2str($_POST['group_allow']);
@@ -85,9 +78,9 @@ function events_post(&$a) {
$str_contact_deny = perms2str($_POST['contact_deny']);
// Undo the pseudo-contact of self, since there are real contacts now
- if( strpos($str_contact_allow, '<' . $self . '>') !== false )
+ if( strpos($str_contact_allow, '<' . $channel['channel_hash'] . '>') !== false )
{
- $str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow);
+ $str_contact_allow = str_replace('<' . $channel['channel_hash'] . '>', '', $str_contact_allow);
}
// Make sure to set the `private` field as true. This is necessary to
// have the posts show up correctly in Diaspora if an event is created
@@ -100,13 +93,12 @@ function events_post(&$a) {
else {
// Note: do not set `private` field for self-only events. It will
// keep even you from seeing them!
- $str_contact_allow = '<' . $self . '>';
+ $str_contact_allow = '<' . $channel['channel_hash'] . '>';
$str_group_allow = $str_contact_deny = $str_group_deny = '';
}
$datarray = array();
- $datarray['hash'] = random_string();
$datarray['start'] = $start;
$datarray['finish'] = $finish;
$datarray['summary'] = $summary;
@@ -115,8 +107,9 @@ function events_post(&$a) {
$datarray['type'] = $type;
$datarray['adjust'] = $adjust;
$datarray['nofinish'] = $nofinish;
- $datarray['uid'] = $uid;
- $datarray['cid'] = $cid;
+ $datarray['uid'] = local_user();
+ $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;
@@ -142,16 +135,16 @@ function events_content(&$a) {
return;
}
- if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
+ if((argc() > 2) && (argv(1) === 'ignore') && intval(argv(2))) {
$r = q("update event set ignore = 1 where id = %d and uid = %d limit 1",
- intval($a->argv[2]),
+ intval(argv(2)),
intval(local_user())
);
}
- if(($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) {
+ if((argc() > 2) && (argv(1) === 'unignore') && intval(argv(2))) {
$r = q("update event set ignore = 0 where id = %d and uid = %d limit 1",
- intval($a->argv[2]),
+ intval(argv(2)),
intval(local_user())
);
}
@@ -171,19 +164,19 @@ function events_content(&$a) {
$m = 0;
$ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0);
- if($a->argc > 1) {
- if($a->argc > 2 && $a->argv[1] == 'event') {
+ if(argc() > 1) {
+ if(argc() > 2 && argv(1) == 'event') {
$mode = 'edit';
- $event_id = intval($a->argv[2]);
+ $event_id = argv(2);
}
- if($a->argv[1] === 'new') {
+ if(argv(1) === 'new') {
$mode = 'new';
- $event_id = 0;
+ $event_id = '';
}
- if($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
+ if(argc() > 2 && intval(argv(1)) && intval(argv(2))) {
$mode = 'view';
- $y = intval($a->argv[1]);
- $m = intval($a->argv[2]);
+ $y = intval(argv(1));
+ $m = intval(argv(2));
}
}
@@ -225,7 +218,7 @@ function events_content(&$a) {
$finish = sprintf('%d-%d-%d %d:%d:%d',$y,$m,$dim,23,59,59);
- if ($a->argv[1] === 'json'){
+ if (argv(1) === 'json'){
if (x($_GET,'start')) $start = date("Y-m-d h:i:s", $_GET['start']);
if (x($_GET,'end')) $finish = date("Y-m-d h:i:s", $_GET['end']);
}
@@ -238,12 +231,12 @@ function events_content(&$a) {
if (x($_GET,'id')){
- $r = q("SELECT event.*, item.* from event left join item on event.id = item.resource_id where resource_type = 'event' and event.uid = %d and event.id = %d limit 1",
+ $r = q("SELECT * from event left join item on resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d limit 1",
intval(local_user()),
intval($_GET['id'])
);
} else {
- $r = q("SELECT event.*, item.* from event left join item on event.id = item.resource_id
+ $r = q("SELECT * from event left join item on event_hash = resource_id
where resource_type = 'event' and event.uid = %d and event.ignore = %d
AND (( `adjust` = 0 AND `finish` >= '%s' AND `start` <= '%s' )
OR ( `adjust` = 1 AND `finish` >= '%s' AND `start` <= '%s' )) ",
@@ -297,7 +290,7 @@ function events_content(&$a) {
$last_date = $d;
// FIXME
- $edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null);
+ $edit = (($rr['item_flags'] & ITEM_WALL) ? array($a->get_baseurl().'/events/event/'.$rr['event_hash'],t('Edit event'),'','') : null);
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
if(! $title) {
list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);
@@ -308,6 +301,7 @@ function events_content(&$a) {
$rr['location'] = bbcode($rr['location']);
$events[] = array(
'id'=>$rr['id'],
+ 'hash' => $rr['event_hash'],
'start'=> $start,
'end' => $end,
'allDay' => false,
@@ -333,12 +327,9 @@ function events_content(&$a) {
// links: array('href', 'text', 'extra css classes', 'title')
if (x($_GET,'id')){
$tpl = get_markup_template("event.tpl");
- } else {
-// if (get_config('experimentals','new_calendar')==1){
- $tpl = get_markup_template("events-js.tpl");
-// } else {
-// $tpl = get_markup_template("events.tpl");
-// }
+ }
+ else {
+ $tpl = get_markup_template("events-js.tpl");
}
$o = replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(),
@@ -361,14 +352,16 @@ function events_content(&$a) {
}
if($mode === 'edit' && $event_id) {
- $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($event_id),
+ $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($event_id),
intval(local_user())
);
if(count($r))
$orig_event = $r[0];
}
+ $channel = $a->get_channel();
+
if($mode === 'edit' || $mode === 'new') {
$n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : '');
@@ -377,14 +370,13 @@ function events_content(&$a) {
$d_orig = ((x($orig_event)) ? $orig_event['desc'] : '');
$l_orig = ((x($orig_event)) ? $orig_event['location'] : '');
$eid = ((x($orig_event)) ? $orig_event['id'] : 0);
- $cid = ((x($orig_event)) ? $orig_event['cid'] : 0);
+ $event_xchan = ((x($orig_event)) ? $orig_event['event_xchan'] : $channel['channel_hash']);
$uri = ((x($orig_event)) ? $orig_event['uri'] : '');
-
if(! x($orig_event))
$sh_checked = '';
else
- $sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' );
+ $sh_checked = (($orig_event['allow_cid'] === '<' . $channel['channel_hash'] . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' );
if($cid)
$sh_checked .= ' disabled="disabled" ';
@@ -426,7 +418,7 @@ function events_content(&$a) {
$o .= replace_macros($tpl,array(
'$post' => $a->get_baseurl() . '/events',
'$eid' => $eid,
- '$cid' => $cid,
+ '$xchan' => $event_xchan,
'$uri' => $uri,
'$title' => t('Event details'),
@@ -450,6 +442,7 @@ function events_content(&$a) {
'$t_orig' => $t_orig,
'$sh_text' => t('Share this event'),
'$sh_checked' => $sh_checked,
+// FIXME
'$acl' => (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user),false)),
'$submit' => t('Submit')