Merge pull request #1966 from annando/1510-event-guid

Issue 1561: Deleting events (And some other event stuff)
This commit is contained in:
Tobias Diekershoff 2015-10-17 12:51:09 +02:00
commit d640128dc9
7 changed files with 120 additions and 57 deletions

View File

@ -1210,7 +1210,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
// start which is always required). Allow desc with a missing summary for compatibility.
if((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) {
$sub = format_event_html($ev);
$sub = format_event_html($ev, $simplehtml);
$Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text);
$Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",'',$Text);

View File

@ -210,6 +210,18 @@ function timesel($format, $h, $m, $id='timepicker') {
if(! function_exists('datetimesel')) {
function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) {
$a = get_app();
// First day of the week (0 = Sunday)
$firstDay = get_pconfig(local_user(),'system','first_day_of_week');
if ($firstDay === false) $firstDay=0;
$lang = substr(get_browser_language(), 0, 2);
// Check if the detected language is supported by the picker
if (!in_array($lang, array("ar", "ro", "id", "bg", "fa", "ru", "uk", "en", "el", "de", "nl", "tr", "fr", "es", "th", "pl", "pt", "ch", "se", "kr", "it", "da", "no", "ja", "vi", "sl", "cs", "hu")))
$lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
$o = '';
$dateformat = '';
if($pickdate) $dateformat .= 'Y-m-d';
@ -224,6 +236,7 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
if(!$pickdate) $pickers .= ',datepicker: false';
if(!$picktime) $pickers .= ',timepicker: false';
$extra_js = '';
$pickers .= ",dayOfWeekStart: ".$firstDay.",lang:'".$lang."'";
if($minfrom != '')
$extra_js .= "\$('#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
if($maxfrom != '')
@ -236,7 +249,9 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
$readable_format = str_replace('i','MM',$readable_format);
$o .= "<div class='date'><input type='text' placeholder='$readable_format' name='$id' id='$id' $input_text />";
$o .= '</div>';
$o .= "<script type='text/javascript'>\$(function () {var picker = \$('#$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})</script>";
$o .= "<script type='text/javascript'>";
$o .= "\$(function () {var picker = \$('#$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})";
$o .= "</script>";
return $o;
}}

View File

@ -2421,6 +2421,7 @@ function diaspora_profile($importer,$xml,$msg) {
$birthday = str_replace('1000','1901',$birthday);
if ($birthday != "")
$birthday = datetime_convert('UTC','UTC',$birthday,'Y-m-d');
// this is to prevent multiple birthday notifications in a single year

View File

@ -3,7 +3,7 @@
require_once('include/bbcode.php');
require_once('include/map.php');
function format_event_html($ev) {
function format_event_html($ev, $simple = false) {
@ -12,6 +12,32 @@ function format_event_html($ev) {
$bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM
$event_start = (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['start'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['start'] , $bd_format)));
$event_end = (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['finish'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['finish'] , $bd_format )));
if ($simple) {
$o = "<h3>".bbcode($ev['summary'])."</h3>";
$o .= "<p>".bbcode($ev['desc'])."</p>";
$o .= "<h4>".t('Starts:')."</h4><p>".$event_start."</p>";
if(! $ev['nofinish'])
$o .= "<h4>".t('Finishes:')."</h4><p>".$event_end."</p>";
if(strlen($ev['location']))
$o .= "<h4>".t('Location:')."</h4><p>".$ev['location']."</p>";
return $o;
}
$o = '<div class="vevent">' . "\r\n";
@ -21,21 +47,13 @@ function format_event_html($ev) {
$o .= '<p class="event-start">' . t('Starts:') . ' <abbr class="dtstart" title="'
. datetime_convert('UTC','UTC',$ev['start'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['start'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['start'] , $bd_format)))
. '" >'.$event_start
. '</abbr></p>' . "\r\n";
if(! $ev['nofinish'])
$o .= '<p class="event-end" >' . t('Finishes:') . ' <abbr class="dtend" title="'
. datetime_convert('UTC','UTC',$ev['finish'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['finish'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['finish'] , $bd_format )))
. '" >'.$event_end
. '</abbr></p>' . "\r\n";
if(strlen($ev['location'])){
@ -204,7 +222,13 @@ function ev_compare($a,$b) {
return strcmp($date_a,$date_b);
}
function event_delete($event_id) {
if ($event_id == 0)
return;
q("DELETE FROM `event` WHERE `id` = %d", intval($event_id));
logger("Deleted event ".$event_id, LOGGER_DEBUG);
}
function event_store($arr) {
@ -362,6 +386,7 @@ function event_store($arr) {
$item_arr['contact-id'] = $arr['cid'];
$item_arr['uri'] = $arr['uri'];
$item_arr['parent-uri'] = $arr['uri'];
$item_arr['guid'] = $arr['guid'];
$item_arr['type'] = 'activity';
$item_arr['wall'] = (($arr['cid']) ? 0 : 1);
$item_arr['contact-id'] = $contact['id'];

View File

@ -2558,6 +2558,11 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if(! $item['deleted'])
logger('consume_feed: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
logger("Deleting event ".$item['event-id'], LOGGER_DEBUG);
event_delete($item['event-id']);
}
if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item['object'],false);
$xt = parse_xml_string($item['target'],false);
@ -2849,11 +2854,12 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if((x($datarray,'object-type')) && ($datarray['object-type'] === ACTIVITY_OBJ_EVENT)) {
$ev = bbtoevent($datarray['body']);
if(x($ev,'desc') && x($ev,'start')) {
if((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) {
$ev['uid'] = $importer['uid'];
$ev['uri'] = $item_id;
$ev['edited'] = $datarray['edited'];
$ev['private'] = $datarray['private'];
$ev['guid'] = $datarray['guid'];
if(is_array($contact))
$ev['cid'] = $contact['id'];
@ -3543,6 +3549,11 @@ function local_delivery($importer,$data) {
logger('local_delivery: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG);
if($item['object-type'] === ACTIVITY_OBJ_EVENT) {
logger("Deleting event ".$item['event-id'], LOGGER_DEBUG);
event_delete($item['event-id']);
}
if(($item['verb'] === ACTIVITY_TAG) && ($item['object-type'] === ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item['object'],false);
$xt = parse_xml_string($item['target'],false);
@ -4073,12 +4084,13 @@ function local_delivery($importer,$data) {
if((x($datarray,'object-type')) && ($datarray['object-type'] === ACTIVITY_OBJ_EVENT)) {
$ev = bbtoevent($datarray['body']);
if(x($ev,'desc') && x($ev,'start')) {
if((x($ev,'desc') || x($ev,'summary')) && x($ev,'start')) {
$ev['cid'] = $importer['id'];
$ev['uid'] = $importer['uid'];
$ev['uri'] = $item_id;
$ev['edited'] = $datarray['edited'];
$ev['private'] = $datarray['private'];
$ev['guid'] = $datarray['guid'];
$r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id),

View File

@ -154,6 +154,7 @@ function events_post(&$a) {
if(! $cid)
proc_run('php',"include/notifier.php","event","$item_id");
goaway($_SESSION['return_url']);
}
@ -165,6 +166,9 @@ function events_content(&$a) {
return;
}
if($a->argc == 1)
$_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) {
$r = q("update event set ignore = 1 where id = %d and uid = %d",
intval($a->argv[2]),
@ -505,7 +509,7 @@ function events_content(&$a) {
else
$sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' );
if($cid)
if($cid OR ($mode !== 'new'))
$sh_checked .= ' disabled="disabled" ';
@ -536,6 +540,9 @@ function events_content(&$a) {
require_once('include/acl_selectors.php');
if ($mode === 'new')
$acl = (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user)));
$tpl = get_markup_template('event_form.tpl');
$o .= replace_macros($tpl,array(
@ -563,7 +570,7 @@ function events_content(&$a) {
'$sh_text' => t('Share this event'),
'$sh_checked' => $sh_checked,
'$preview' => t('Preview'),
'$acl' => (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user))),
'$acl' => $acl,
'$submit' => t('Submit')
));

View File

@ -117,9 +117,12 @@ class Item extends BaseObject {
? t('Private Message')
: false);
$shareable = ((($conv->get_profile_owner() == local_user()) && ($item['private'] != 1)) ? true : false);
if(local_user() && link_compare($a->contact['url'],$item['author-link']))
$edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
if(local_user() && link_compare($a->contact['url'],$item['author-link'])) {
if ($item["event-id"] != 0)
$edpost = array($a->get_baseurl($ssl_state)."/events/event/".$item['event-id'], t("Edit"));
else
$edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
} else
$edpost = false;
if(($this->get_data_value('uid') == local_user()) || $this->is_visiting())
$dropping = true;