Merge pull request #943 from dawnbreak/master
Fixed two wrong variable usages in event.php.
This commit is contained in:
commit
4df7a22ff5
@ -1,6 +1,14 @@
|
|||||||
<?php /** @file */
|
<?php
|
||||||
|
/**
|
||||||
|
* @file include/event.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns an event as HTML
|
||||||
|
*
|
||||||
|
* @param array $ev
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function format_event_html($ev) {
|
function format_event_html($ev) {
|
||||||
|
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
@ -12,7 +20,6 @@ function format_event_html($ev) {
|
|||||||
|
|
||||||
$o = '<div class="vevent">' . "\r\n";
|
$o = '<div class="vevent">' . "\r\n";
|
||||||
|
|
||||||
|
|
||||||
$o .= '<p class="summary event-summary">' . bbcode($ev['summary']) . '</p>' . "\r\n";
|
$o .= '<p class="summary event-summary">' . bbcode($ev['summary']) . '</p>' . "\r\n";
|
||||||
|
|
||||||
$o .= '<p class="description event-description">' . bbcode($ev['description']) . '</p>' . "\r\n";
|
$o .= '<p class="description event-description">' . bbcode($ev['description']) . '</p>' . "\r\n";
|
||||||
@ -42,11 +49,11 @@ function format_event_html($ev) {
|
|||||||
. '</span></p>' . "\r\n";
|
. '</span></p>' . "\r\n";
|
||||||
|
|
||||||
$o .= '</div>' . "\r\n";
|
$o .= '</div>' . "\r\n";
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function ical_wrapper($ev) {
|
function ical_wrapper($ev) {
|
||||||
|
|
||||||
if(! ((is_array($ev)) && count($ev)))
|
if(! ((is_array($ev)) && count($ev)))
|
||||||
@ -84,13 +91,15 @@ function format_event_ical($ev) {
|
|||||||
if($ev['description'])
|
if($ev['description'])
|
||||||
$o .= "\nDESCRIPTION:" . format_ical_text($ev['description']);
|
$o .= "\nDESCRIPTION:" . format_ical_text($ev['description']);
|
||||||
$o .= "\nEND:VEVENT\n";
|
$o .= "\nEND:VEVENT\n";
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
function format_ical_text($s) {
|
|
||||||
|
|
||||||
|
function format_ical_text($s) {
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
require_once('include/html2plain.php');
|
require_once('include/html2plain.php');
|
||||||
|
|
||||||
return(wordwrap(html2plain(bbcode($s)),72,"\n ",true));
|
return(wordwrap(html2plain(bbcode($s)),72,"\n ",true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,16 +126,16 @@ function format_event_bbcode($ev) {
|
|||||||
if($ev['adjust'])
|
if($ev['adjust'])
|
||||||
$o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]';
|
$o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]';
|
||||||
|
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function bbtovcal($s) {
|
function bbtovcal($s) {
|
||||||
$o = '';
|
$o = '';
|
||||||
$ev = bbtoevent($s);
|
$ev = bbtoevent($s);
|
||||||
if($ev['description'])
|
if($ev['description'])
|
||||||
$o = format_event_html($ev);
|
$o = format_event_html($ev);
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,18 +163,32 @@ function bbtoevent($s) {
|
|||||||
if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match))
|
if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match))
|
||||||
$ev['adjust'] = $match[1];
|
$ev['adjust'] = $match[1];
|
||||||
$ev['nofinish'] = (((x($ev, 'start') && $ev['start']) && (!x($ev, 'finish') || !$ev['finish'])) ? 1 : 0);
|
$ev['nofinish'] = (((x($ev, 'start') && $ev['start']) && (!x($ev, 'finish') || !$ev['finish'])) ? 1 : 0);
|
||||||
return $ev;
|
|
||||||
|
|
||||||
|
return $ev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sorts the given array of events by date.
|
||||||
|
*
|
||||||
|
* @see ev_compare()
|
||||||
|
* @param array $arr
|
||||||
|
* @return sorted array
|
||||||
|
*/
|
||||||
function sort_by_date($arr) {
|
function sort_by_date($arr) {
|
||||||
if (is_array($arr))
|
if (is_array($arr))
|
||||||
usort($arr, 'ev_compare');
|
usort($arr, 'ev_compare');
|
||||||
|
|
||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Compare function for events.
|
||||||
|
*
|
||||||
|
* @see sort_by_date()
|
||||||
|
* @param array $a
|
||||||
|
* @param array $b
|
||||||
|
* @return number return values like strcmp()
|
||||||
|
*/
|
||||||
function ev_compare($a, $b) {
|
function ev_compare($a, $b) {
|
||||||
|
|
||||||
$date_a = (($a['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$a['start']) : $a['start']);
|
$date_a = (($a['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$a['start']) : $a['start']);
|
||||||
@ -185,8 +208,6 @@ function event_store_event($arr) {
|
|||||||
$arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
|
$arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
|
||||||
$arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : '');
|
$arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : '');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Existing event being modified
|
// Existing event being modified
|
||||||
|
|
||||||
if($arr['id'] || $arr['event_hash']) {
|
if($arr['id'] || $arr['event_hash']) {
|
||||||
@ -206,7 +227,6 @@ function event_store_event($arr) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(! $r)
|
if(! $r)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -251,14 +271,12 @@ function event_store_event($arr) {
|
|||||||
intval($r[0]['id']),
|
intval($r[0]['id']),
|
||||||
intval($arr['uid'])
|
intval($arr['uid'])
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
// New event. Store it.
|
// New event. Store it.
|
||||||
|
|
||||||
$hash = random_string();
|
$hash = random_string();
|
||||||
|
|
||||||
|
|
||||||
$r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary,description,location,type,
|
$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)
|
adjust,nofinish,allow_cid,allow_gid,deny_cid,deny_gid)
|
||||||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
|
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
|
||||||
@ -280,7 +298,6 @@ function event_store_event($arr) {
|
|||||||
dbesc($arr['allow_gid']),
|
dbesc($arr['allow_gid']),
|
||||||
dbesc($arr['deny_cid']),
|
dbesc($arr['deny_cid']),
|
||||||
dbesc($arr['deny_gid'])
|
dbesc($arr['deny_gid'])
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +309,6 @@ function event_store_event($arr) {
|
|||||||
return $r[0];
|
return $r[0];
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function event_addtocal($item_id, $uid) {
|
function event_addtocal($item_id, $uid) {
|
||||||
@ -339,22 +355,21 @@ function event_addtocal($item_id, $uid) {
|
|||||||
intval($item['id']),
|
intval($item['id']),
|
||||||
intval($channel['channel_id'])
|
intval($channel['channel_id'])
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function event_store_item($arr, $event) {
|
function event_store_item($arr, $event) {
|
||||||
|
|
||||||
require_once('include/datetime.php');
|
require_once('include/datetime.php');
|
||||||
require_once('include/items.php');
|
require_once('include/items.php');
|
||||||
require_once('include/bbcode.php');
|
require_once('include/bbcode.php');
|
||||||
|
|
||||||
$a = get_app();
|
|
||||||
|
|
||||||
$item = null;
|
$item = null;
|
||||||
|
|
||||||
if($arr['mid'] && $arr['uid']) {
|
if($arr['mid'] && $arr['uid']) {
|
||||||
@ -370,11 +385,11 @@ function event_store_item($arr,$event) {
|
|||||||
|
|
||||||
$item_arr = array();
|
$item_arr = array();
|
||||||
$prefix = '';
|
$prefix = '';
|
||||||
$birthday = false;
|
// $birthday = false;
|
||||||
|
|
||||||
if($event['type'] === 'birthday') {
|
if($event['type'] === 'birthday') {
|
||||||
$prefix = t('This event has been added to your calendar.');
|
$prefix = t('This event has been added to your calendar.');
|
||||||
$birthday = true;
|
// $birthday = true;
|
||||||
|
|
||||||
// The event is created on your own site by the system, but appears to belong
|
// The event is created on your own site by the system, but appears to belong
|
||||||
// to the birthday person. It also isn't propagated - so we need to prevent
|
// to the birthday person. It also isn't propagated - so we need to prevent
|
||||||
@ -391,7 +406,7 @@ function event_store_item($arr,$event) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
$obj = json_encode(array(
|
$object = json_encode(array(
|
||||||
'type' => ACTIVITY_OBJ_EVENT,
|
'type' => ACTIVITY_OBJ_EVENT,
|
||||||
'id' => z_root() . '/event/' . $r[0]['resource_id'],
|
'id' => z_root() . '/event/' . $r[0]['resource_id'],
|
||||||
'title' => $arr['summary'],
|
'title' => $arr['summary'],
|
||||||
@ -424,8 +439,7 @@ function event_store_item($arr,$event) {
|
|||||||
intval($arr['uid'])
|
intval($arr['uid'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
q("delete from term where oid = %d and otype = %d",
|
||||||
$s = q("delete from term where oid = %d and otype = %d",
|
|
||||||
intval($r[0]['id']),
|
intval($r[0]['id']),
|
||||||
intval(TERM_OBJ_POST)
|
intval(TERM_OBJ_POST)
|
||||||
);
|
);
|
||||||
@ -446,18 +460,16 @@ function event_store_item($arr,$event) {
|
|||||||
|
|
||||||
$item_id = $r[0]['id'];
|
$item_id = $r[0]['id'];
|
||||||
call_hooks('event_updated', $event['id']);
|
call_hooks('event_updated', $event['id']);
|
||||||
|
|
||||||
return $item_id;
|
return $item_id;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
$z = q("select * from channel where channel_id = %d limit 1",
|
$z = q("select * from channel where channel_id = %d limit 1",
|
||||||
intval($arr['uid'])
|
intval($arr['uid'])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0);
|
$private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0);
|
||||||
|
|
||||||
|
|
||||||
if($item) {
|
if($item) {
|
||||||
$item_arr['id'] = $item['id'];
|
$item_arr['id'] = $item['id'];
|
||||||
}
|
}
|
||||||
@ -470,7 +482,6 @@ function event_store_item($arr,$event) {
|
|||||||
$item_flags |= ITEM_ORIGIN;
|
$item_flags |= ITEM_ORIGIN;
|
||||||
}
|
}
|
||||||
$item_arr['item_flags'] = $item_flags;
|
$item_arr['item_flags'] = $item_flags;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! $arr['mid'])
|
if(! $arr['mid'])
|
||||||
@ -482,7 +493,6 @@ function event_store_item($arr,$event) {
|
|||||||
$item_arr['mid'] = $arr['mid'];
|
$item_arr['mid'] = $arr['mid'];
|
||||||
$item_arr['parent_mid'] = $arr['mid'];
|
$item_arr['parent_mid'] = $arr['mid'];
|
||||||
|
|
||||||
|
|
||||||
$item_arr['owner_xchan'] = (($wall) ? $z[0]['channel_hash'] : $arr['event_xchan']);
|
$item_arr['owner_xchan'] = (($wall) ? $z[0]['channel_hash'] : $arr['event_xchan']);
|
||||||
$item_arr['author_xchan'] = $arr['event_xchan'];
|
$item_arr['author_xchan'] = $arr['event_xchan'];
|
||||||
$item_arr['title'] = $arr['summary'];
|
$item_arr['title'] = $arr['summary'];
|
||||||
@ -493,7 +503,6 @@ function event_store_item($arr,$event) {
|
|||||||
$item_arr['item_private'] = $private;
|
$item_arr['item_private'] = $private;
|
||||||
$item_arr['verb'] = ACTIVITY_POST;
|
$item_arr['verb'] = ACTIVITY_POST;
|
||||||
|
|
||||||
|
|
||||||
if(array_key_exists('term', $arr))
|
if(array_key_exists('term', $arr))
|
||||||
$item_arr['term'] = $arr['term'];
|
$item_arr['term'] = $arr['term'];
|
||||||
|
|
||||||
@ -512,15 +521,13 @@ function event_store_item($arr,$event) {
|
|||||||
else
|
else
|
||||||
$item_arr['plink'] = z_root() . '/display/' . $item_arr['mid'];
|
$item_arr['plink'] = z_root() . '/display/' . $item_arr['mid'];
|
||||||
|
|
||||||
|
|
||||||
$x = q("select * from xchan where xchan_hash = '%s' limit 1",
|
$x = q("select * from xchan where xchan_hash = '%s' limit 1",
|
||||||
dbesc($arr['event_xchan'])
|
dbesc($arr['event_xchan'])
|
||||||
);
|
);
|
||||||
if($x) {
|
if($x) {
|
||||||
|
|
||||||
$item_arr['object'] = json_encode(array(
|
$item_arr['object'] = json_encode(array(
|
||||||
'type' => ACTIVITY_OBJ_EVENT,
|
'type' => ACTIVITY_OBJ_EVENT,
|
||||||
'id' => z_root() . '/event/' . $hash,
|
'id' => z_root() . '/event/' . $event['event_hash'],
|
||||||
'title' => $arr['summary'],
|
'title' => $arr['summary'],
|
||||||
'content' => format_event_bbcode($arr),
|
'content' => format_event_bbcode($arr),
|
||||||
'author' => array(
|
'author' => array(
|
||||||
@ -539,7 +546,7 @@ function event_store_item($arr,$event) {
|
|||||||
|
|
||||||
$item_id = $res['item_id'];
|
$item_id = $res['item_id'];
|
||||||
|
|
||||||
call_hooks("event_created", $event['id']);
|
call_hooks('event_created', $event['id']);
|
||||||
|
|
||||||
return $item_id;
|
return $item_id;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user