testing new event code
This commit is contained in:
parent
22ed5b1d03
commit
832cbbec15
@ -201,7 +201,7 @@ class Item extends BaseObject {
|
||||
}
|
||||
|
||||
$has_event = false;
|
||||
if(activity_compare($item['obj_type'],ACTIVITY_OBJ_EVENT) && $conv->get_profile_owner() == local_user())
|
||||
if(($item['obj_type'] === ACTIVITY_OBJ_EVENT) && $conv->get_profile_owner() == local_user())
|
||||
$has_event = true;
|
||||
|
||||
if($this->is_commentable()) {
|
||||
|
@ -135,6 +135,8 @@ function event_store_event($arr) {
|
||||
$arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
|
||||
$arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : '');
|
||||
|
||||
|
||||
|
||||
// Existing event being modified
|
||||
|
||||
if($arr['id'] || $arr['event_hash']) {
|
||||
@ -154,6 +156,7 @@ function event_store_event($arr) {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if(! $r)
|
||||
return false;
|
||||
|
||||
@ -205,9 +208,6 @@ function event_store_event($arr) {
|
||||
|
||||
$hash = random_string();
|
||||
|
||||
if(! $arr['mid'])
|
||||
$arr['mid'] = item_message_id();
|
||||
|
||||
|
||||
$r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary,description,location,type,
|
||||
adjust,nofinish,allow_cid,allow_gid,deny_cid,deny_gid)
|
||||
@ -261,13 +261,14 @@ function event_addtocal($item_id, $uid) {
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
|
||||
if((! $r) || (! activity_match($r[0]['obj_type'],ACTIVITY_OBJ_EVENT)))
|
||||
if((! $r) || ($r[0]['obj_type'] !== ACTIVITY_OBJ_EVENT))
|
||||
return false;
|
||||
|
||||
$item = $r[0];
|
||||
|
||||
$ev = bbtoevent($r[0]['body']);
|
||||
if(x($ev,'description') && x($ev,'start')) {
|
||||
|
||||
if(x($ev,'summary') && x($ev,'start')) {
|
||||
$ev['event_xchan'] = $item['author_xchan'];
|
||||
$ev['uid'] = $channel['channel_id'];
|
||||
$ev['account'] = $channel['channel_account_id'];
|
||||
@ -284,6 +285,7 @@ function event_addtocal($item_id, $uid) {
|
||||
$event = event_store_event($ev);
|
||||
if($event) {
|
||||
$r = q("update item set resource_id = '%s', resource_type = 'event' where id = %d and uid = %d limit 1",
|
||||
dbesc($event['event_hash']),
|
||||
intval($item['id']),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
@ -317,7 +319,7 @@ function event_store_item($arr,$event) {
|
||||
}
|
||||
|
||||
$r = q("SELECT * FROM item left join xchan on author_xchan = xchan_hash WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1",
|
||||
dbesc($event['hash']),
|
||||
dbesc($event['event_hash']),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
|
||||
@ -386,6 +388,10 @@ function event_store_item($arr,$event) {
|
||||
$item_arr['item_flags'] = $item_flags;
|
||||
}
|
||||
|
||||
if(! $arr['mid'])
|
||||
$arr['mid'] = item_message_id();
|
||||
|
||||
|
||||
$item_arr['uid'] = $arr['uid'];
|
||||
$item_arr['author_xchan'] = $arr['event_xchan'];
|
||||
$item_arr['mid'] = $arr['mid'];
|
||||
|
@ -1,56 +0,0 @@
|
||||
<?php /** @file */
|
||||
|
||||
|
||||
function addtocal_init(&$a) {
|
||||
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
if(argc() > 1) {
|
||||
$post_id = intval(argv(1));
|
||||
|
||||
$r = q("select * from item where id = %d and uid = %d limit 1",
|
||||
intval($post_id),
|
||||
intval(local_user())
|
||||
);
|
||||
|
||||
if(! $r)
|
||||
return;
|
||||
}
|
||||
|
||||
$arr = $r[0];
|
||||
$channel = $a->get_channel();
|
||||
|
||||
if(! $channel)
|
||||
return;
|
||||
|
||||
// for events, extract the event info and create an event linked to an item
|
||||
|
||||
if((x($arr,'obj_type')) && (activity_match($arr['obj_type'],ACTIVITY_OBJ_EVENT))) {
|
||||
|
||||
require_once('include/event.php');
|
||||
$ev = bbtoevent($arr['body']);
|
||||
|
||||
if(x($ev,'description') && x($ev,'start')) {
|
||||
$ev['event_xchan'] = $arr['author_xchan'];
|
||||
$ev['uid'] = $channel['channel_id'];
|
||||
$ev['account'] = $channel['channel_account_id'];
|
||||
$ev['edited'] = $arr['edited'];
|
||||
$ev['mid'] = $arr['mid'];
|
||||
$ev['private'] = $arr['item_private'];
|
||||
|
||||
// is this an edit?
|
||||
|
||||
$r = q("SELECT resource_id FROM item where mid = '%s' and uid = %d and resource_type = 'event' limit 1",
|
||||
dbesc($arr['mid']),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
if($r) {
|
||||
$ev['event_hash'] = $r[0]['resource_id'];
|
||||
}
|
||||
|
||||
$xyz = event_store($ev);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -301,7 +301,7 @@ function enableOnUser(){
|
||||
}
|
||||
|
||||
function itemAddToCal(id) {
|
||||
$.get('{{$baseurl}}/event/add/' + id);
|
||||
$.get('{{$baseurl}}/events/add/' + id);
|
||||
if(timer) clearTimeout(timer);
|
||||
timer = setTimeout(NavUpdate,1000);
|
||||
}
|
||||
|
Reference in New Issue
Block a user