1
0
Fork 0

add dop event & fix event edit

This commit is contained in:
rabuzarus 2017-03-16 20:15:25 +01:00
parent 6fdc219143
commit 8ae8465d48
5 changed files with 136 additions and 95 deletions

View file

@ -612,7 +612,14 @@ function process_events($arr) {
$is_first = ($d !== $last_date); $is_first = ($d !== $last_date);
$last_date = $d; $last_date = $d;
// Show edit and drop actions only if the user is the owner of the event and the event
// is a real event (no bithdays)
if (local_user() && local_user() == $rr['uid'] && $rr['type'] == 'event') {
$edit = ((! $rr['cid']) ? array(App::get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null); $edit = ((! $rr['cid']) ? array(App::get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null);
$drop = array(App::get_baseurl().'/events/drop/'.$rr['id'],t('Delete event'),'','');
}
$title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8')); $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
if(! $title) { if(! $title) {
list($title, $_trash) = explode("<br",bbcode($rr['desc']),2); list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);
@ -631,6 +638,8 @@ function process_events($arr) {
'j' => $j, 'j' => $j,
'd' => $d, 'd' => $d,
'edit' => $edit,
'drop' => $drop,
'is_first'=>$is_first, 'is_first'=>$is_first,
'item'=>$rr, 'item'=>$rr,
'html'=>$html, 'html'=>$html,

View file

@ -54,8 +54,7 @@ function events_post(App $a) {
if ($start_text) { if ($start_text) {
$start = $start_text; $start = $start_text;
} } else {
else {
$start = sprintf('%d-%d-%d %d:%d:0', $startyear, $startmonth, $startday, $starthour, $startminute); $start = sprintf('%d-%d-%d %d:%d:0', $startyear, $startmonth, $startday, $starthour, $startminute);
} }
@ -65,8 +64,7 @@ function events_post(App $a) {
if ($finish_text) { if ($finish_text) {
$finish = $finish_text; $finish = $finish_text;
} } else {
else {
$finish = sprintf('%d-%d-%d %d:%d:0', $finishyear, $finishmonth, $finishday, $finishhour, $finishminute); $finish = sprintf('%d-%d-%d %d:%d:0', $finishyear, $finishmonth, $finishday, $finishhour, $finishminute);
} }
@ -75,8 +73,7 @@ function events_post(App $a) {
if (! $nofinish) { if (! $nofinish) {
$finish = datetime_convert(date_default_timezone_get(), 'UTC',$finish); $finish = datetime_convert(date_default_timezone_get(), 'UTC',$finish);
} }
} } else {
else {
$start = datetime_convert('UTC', 'UTC', $start); $start = datetime_convert('UTC', 'UTC', $start);
if (! $nofinish) { if (! $nofinish) {
$finish = datetime_convert('UTC', 'UTC', $finish); $finish = datetime_convert('UTC', 'UTC', $finish);
@ -116,13 +113,14 @@ function events_post(App $a) {
$share = ((intval($_POST['share'])) ? intval($_POST['share']) : 0); $share = ((intval($_POST['share'])) ? intval($_POST['share']) : 0);
$c = q("select id from contact where uid = %d and self = 1 limit 1", $c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
intval(local_user()) intval(local_user())
); );
if(count($c)) if (count($c)) {
$self = $c[0]['id']; $self = $c[0]['id'];
else } else {
$self = 0; $self = 0;
}
if ($share) { if ($share) {
@ -132,19 +130,16 @@ function events_post(App $a) {
$str_contact_deny = perms2str($_POST['contact_deny']); $str_contact_deny = perms2str($_POST['contact_deny']);
// Undo the pseudo-contact of self, since there are real contacts now // Undo the pseudo-contact of self, since there are real contacts now
if( strpos($str_contact_allow, '<' . $self . '>') !== false ) if ( strpos($str_contact_allow, '<' . $self . '>') !== false ) {
{
$str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow); $str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow);
} }
// Make sure to set the `private` field as true. This is necessary to // 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 // have the posts show up correctly in Diaspora if an event is created
// as visible only to self at first, but then edited to display to others. // as visible only to self at first, but then edited to display to others.
if( strlen($str_group_allow) or strlen($str_contact_allow) or strlen($str_group_deny) or strlen($str_contact_deny) ) if (strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) {
{
$private_event = true; $private_event = true;
} }
} } else {
else {
// Note: do not set `private` field for self-only events. It will // Note: do not set `private` field for self-only events. It will
// keep even you from seeing them! // keep even you from seeing them!
$str_contact_allow = '<' . $self . '>'; $str_contact_allow = '<' . $self . '>';
@ -181,8 +176,9 @@ function events_post(App $a) {
$item_id = event_store($datarray); $item_id = event_store($datarray);
if(! $cid) if (! $cid) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "event", $item_id); proc_run(PRIORITY_HIGH, "include/notifier.php", "event", $item_id);
}
goaway($_SESSION['return_url']); goaway($_SESSION['return_url']);
} }
@ -201,14 +197,14 @@ function events_content(App $a) {
} }
if (($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) { 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", $r = q("UPDATE `event` SET `ignore` = 1 WHERE `id` = %d AND `uid` = %d",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
} }
if (($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) { if (($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) {
$r = q("update event set ignore = 0 where id = %d and uid = %d", $r = q("UPDATE `event` SET `ignore` = 0 WHERE `id` = %d AND `uid` = %d",
intval($a->argv[2]), intval($a->argv[2]),
intval(local_user()) intval(local_user())
); );
@ -236,10 +232,11 @@ function events_content(App $a) {
'$baseurl' => App::get_baseurl(), '$baseurl' => App::get_baseurl(),
)); ));
$o =""; $o ='';
// tabs // tabs
if ($a->theme_events_in_profile) if ($a->theme_events_in_profile) {
$tabs = profile_tabs($a, True); $tabs = profile_tabs($a, true);
}
@ -253,6 +250,10 @@ function events_content(App $a) {
$mode = 'edit'; $mode = 'edit';
$event_id = intval($a->argv[2]); $event_id = intval($a->argv[2]);
} }
if($a->argc > 2 && $a->argv[1] == 'drop') {
$mode = 'drop';
$event_id = intval($a->argv[2]);
}
if ($a->argv[1] === 'new') { if ($a->argv[1] === 'new') {
$mode = 'new'; $mode = 'new';
$event_id = 0; $event_id = 0;
@ -267,7 +268,6 @@ function events_content(App $a) {
// The view mode part is similiar to /mod/cal.php // The view mode part is similiar to /mod/cal.php
if ($mode == 'view') { if ($mode == 'view') {
$thisyear = datetime_convert('UTC', date_default_timezone_get(),'now', 'Y'); $thisyear = datetime_convert('UTC', date_default_timezone_get(),'now', 'Y');
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm'); $thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
if (! $y) { if (! $y) {
@ -295,9 +295,9 @@ function events_content(App $a) {
} }
$prevyear = $y; $prevyear = $y;
if($m > 1) if ($m > 1) {
$prevmonth = $m - 1; $prevmonth = $m - 1;
else { } else {
$prevmonth = 12; $prevmonth = 12;
$prevyear --; $prevyear --;
} }
@ -356,18 +356,14 @@ function events_content(App $a) {
} }
if ($a->argv[1] === 'json'){ if ($a->argv[1] === 'json'){
echo json_encode($events); killme(); echo json_encode($events);
killme();
} }
// links: array('href', 'text', 'extra css classes', 'title')
if (x($_GET,'id')){ if (x($_GET,'id')){
$tpl = get_markup_template("event.tpl"); $tpl = get_markup_template("event.tpl");
} else { } else {
// if (get_config('experimentals','new_calendar')==1){
$tpl = get_markup_template("events_js.tpl"); $tpl = get_markup_template("events_js.tpl");
// } else {
// $tpl = get_markup_template("events.tpl");
// }
} }
// Get rid of dashes in key names, Smarty3 can't handle them // Get rid of dashes in key names, Smarty3 can't handle them
@ -386,20 +382,24 @@ function events_content(App $a) {
'$title' => t('Events'), '$title' => t('Events'),
'$view' => t('View'), '$view' => t('View'),
'$new_event' => array(App::get_baseurl() . '/events/new', t('Create New Event'), '', ''), '$new_event' => array(App::get_baseurl() . '/events/new', t('Create New Event'), '', ''),
'$previous' => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''), '$previous' => array(App::get_baseurl() . '/events/$prevyear/$prevmonth', t('Previous'), '', ''),
'$next' => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''), '$next' => array(App::get_baseurl() . '/events/$nextyear/$nextmonth', t('Next'), '', ''),
'$calendar' => cal($y, $m, $links, ' eventcal'), '$calendar' => cal($y, $m, $links, ' eventcal'),
'$events' => $events, '$events' => $events,
"today" => t("today"), '$today' => t('today'),
"month" => t("month"), '$month' => t('month'),
"week" => t("week"), '$week' => t('week'),
"day" => t("day"), '$day' => t('day'),
"list" => t("list"), '$list' => t('list'),
)); ));
if (x($_GET,'id')){ echo $o; killme(); } if (x($_GET,'id')) {
echo $o;
killme();
}
return $o; return $o;
@ -439,21 +439,24 @@ function events_content(App $a) {
$uri = ((x($orig_event)) ? $orig_event['uri'] : ''); $uri = ((x($orig_event)) ? $orig_event['uri'] : '');
if(! x($orig_event)) if (! x($orig_event)) {
$sh_checked = ''; $sh_checked = '';
else } 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'] === '<' . local_user() . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' );
}
if($cid OR ($mode !== 'new')) if ($cid OR ($mode !== 'new')) {
$sh_checked .= ' disabled="disabled" '; $sh_checked .= ' disabled="disabled" ';
}
$sdt = ((x($orig_event)) ? $orig_event['start'] : 'now'); $sdt = ((x($orig_event)) ? $orig_event['start'] : 'now');
$fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now'); $fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now');
$tz = date_default_timezone_get(); $tz = date_default_timezone_get();
if(x($orig_event)) if (x($orig_event)) {
$tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC'); $tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
}
$syear = datetime_convert('UTC', $tz, $sdt, 'Y'); $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
$smonth = datetime_convert('UTC', $tz, $sdt, 'm'); $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
@ -470,13 +473,15 @@ function events_content(App $a) {
$fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0); $fminute = ((x($orig_event)) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0);
$f = get_config('system','event_input_format'); $f = get_config('system','event_input_format');
if(! $f) if (! $f) {
$f = 'ymd'; $f = 'ymd';
}
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
if ($mode === 'new') if ($mode === 'new') {
$acl = (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user))); $acl = (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user)));
}
$tpl = get_markup_template('event_form.tpl'); $tpl = get_markup_template('event_form.tpl');
@ -511,12 +516,34 @@ function events_content(App $a) {
'$preview' => t('Preview'), '$preview' => t('Preview'),
'$acl' => $acl, '$acl' => $acl,
'$submit' => t('Submit'), '$submit' => t('Submit'),
'$basic' => t("Basic"), '$basic' => t('Basic'),
'$advanced' => t("Advanced"), '$advanced' => t('Advanced'),
'$permissions' => t('Permissions'), '$permissions' => t('Permissions'),
)); ));
return $o; return $o;
} }
// Remove an event from the calendar and its related items
if ($mode === 'drop' && $event_id) {
$del = 0;
$event_params = array('event_id' => ($event_id));
$ev = event_by_id(local_user(), $event_params);
// Delete only real events (no birthdays)
if (dbm::is_result($ev) && $ev[0]['type'] == 'event') {
$del = drop_item($ev[0]['itemid'], false);
}
if ($del == 0) {
notice( t('Failed to remove event' ) . EOL);
} else {
info( t('Event removed') . EOL);
}
goaway(App::get_baseurl() . '/events');
}
} }

View file

@ -6,6 +6,7 @@
{{$event.html}} {{$event.html}}
{{if $event.item.plink}}<a href="{{$event.plink.0}}" title="{{$event.plink.1}}" target="_blank" class="plink-event-link icon s22 remote-link"></a>{{/if}} {{if $event.item.plink}}<a href="{{$event.plink.0}}" title="{{$event.plink.1}}" target="_blank" class="plink-event-link icon s22 remote-link"></a>{{/if}}
{{if $event.edit}}<a href="{{$event.edit.0}}" title="{{$event.edit.1}}" class="edit-event-link icon s22 pencil"></a>{{/if}} {{if $event.edit}}<a href="{{$event.edit.0}}" title="{{$event.edit.1}}" class="edit-event-link icon s22 pencil"></a>{{/if}}
{{if $event.drop}}<a href="{{$event.drop.0}}" onclick="return confirmDelete();" title="{{$event.drop.1}}" class="drop-event-link icon s22 delete"></a>{{/if}}
</div> </div>
<div class="clear"></div> <div class="clear"></div>
{{/foreach}} {{/foreach}}

View file

@ -2193,6 +2193,9 @@ ul li:hover .contact-wrapper a.contact-action-link:hover {
#event-edit-form-wrapper #event-edit-time { #event-edit-form-wrapper #event-edit-time {
padding: 10px 0; padding: 10px 0;
} }
.event-buttons .plink-event-link {
margin-left: 20px;
}
/* Profiles Page */ /* Profiles Page */
.profile-listing-table { .profile-listing-table {
display: table; display: table;

View file

@ -17,8 +17,9 @@
</div> </div>
<div class="event-buttons pull-right"> <div class="event-buttons pull-right">
{{if $event.item.plink}}<a href="{{$event.plink.0}}" title="{{$event.plink.1}}" class="btn "><i class="fa fa-external-link" aria-hidden="true"></i></a>{{/if}} {{if $event.edit}}<a onclick="eventEdit('{{$event.edit.0}}')" title="{{$event.edit.1}}" class="edit-event-link btn"><i class="fa fa-pencil" aria-hidden="true"></i></a>{{/if}}
{{if $event.edit}}<a onclick="eventEdit('{{$event.edit.0}}')" title="{{$event.edit.1}}" class="btn"><i class="fa fa-pencil" aria-hidden="true"></i></a>{{/if}} {{if $event.drop}}<a href="{{$event.drop.0}}" onclick="return confirmDelete();" title="{{$event.drop.1}}" class="drop-event-link btn"><i class="fa fa-trash-o" aria-hidden="true"></i></a>{{/if}}
{{if $event.item.plink}}<a href="{{$event.plink.0}}" title="{{$event.plink.1}}" class="plink-event-link btn "><i class="fa fa-external-link" aria-hidden="true"></i></a>{{/if}}
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>