1
1
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);
$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);
$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'));
if(! $title) {
list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);
@ -631,6 +638,8 @@ function process_events($arr) {
'j' => $j,
'd' => $d,
'edit' => $edit,
'drop' => $drop,
'is_first'=>$is_first,
'item'=>$rr,
'html'=>$html,

View file

@ -54,8 +54,7 @@ function events_post(App $a) {
if ($start_text) {
$start = $start_text;
}
else {
} else {
$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) {
$finish = $finish_text;
}
else {
} else {
$finish = sprintf('%d-%d-%d %d:%d:0', $finishyear, $finishmonth, $finishday, $finishhour, $finishminute);
}
@ -75,8 +73,7 @@ function events_post(App $a) {
if (! $nofinish) {
$finish = datetime_convert(date_default_timezone_get(), 'UTC',$finish);
}
}
else {
} else {
$start = datetime_convert('UTC', 'UTC', $start);
if (! $nofinish) {
$finish = datetime_convert('UTC', 'UTC', $finish);
@ -116,13 +113,14 @@ function events_post(App $a) {
$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())
);
if(count($c))
if (count($c)) {
$self = $c[0]['id'];
else
} else {
$self = 0;
}
if ($share) {
@ -132,19 +130,16 @@ function events_post(App $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, '<' . $self . '>') !== false ) {
$str_contact_allow = str_replace('<' . $self . '>', '', $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
// 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;
}
}
else {
} else {
// Note: do not set `private` field for self-only events. It will
// keep even you from seeing them!
$str_contact_allow = '<' . $self . '>';
@ -181,8 +176,9 @@ function events_post(App $a) {
$item_id = event_store($datarray);
if(! $cid)
if (! $cid) {
proc_run(PRIORITY_HIGH, "include/notifier.php", "event", $item_id);
}
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])) {
$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(local_user())
);
}
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(local_user())
);
@ -236,10 +232,11 @@ function events_content(App $a) {
'$baseurl' => App::get_baseurl(),
));
$o ="";
$o ='';
// tabs
if ($a->theme_events_in_profile)
$tabs = profile_tabs($a, True);
if ($a->theme_events_in_profile) {
$tabs = profile_tabs($a, true);
}
@ -253,6 +250,10 @@ function events_content(App $a) {
$mode = 'edit';
$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') {
$mode = 'new';
$event_id = 0;
@ -267,7 +268,6 @@ function events_content(App $a) {
// The view mode part is similiar to /mod/cal.php
if ($mode == 'view') {
$thisyear = datetime_convert('UTC', date_default_timezone_get(),'now', 'Y');
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
if (! $y) {
@ -295,9 +295,9 @@ function events_content(App $a) {
}
$prevyear = $y;
if($m > 1)
if ($m > 1) {
$prevmonth = $m - 1;
else {
} else {
$prevmonth = 12;
$prevyear --;
}
@ -356,18 +356,14 @@ function events_content(App $a) {
}
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')){
$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");
// }
}
// Get rid of dashes in key names, Smarty3 can't handle them
@ -386,20 +382,24 @@ function events_content(App $a) {
'$title' => t('Events'),
'$view' => t('View'),
'$new_event' => array(App::get_baseurl() . '/events/new', t('Create New Event'), '', ''),
'$previous' => array(App::get_baseurl()."/events/$prevyear/$prevmonth",t('Previous'),'',''),
'$next' => array(App::get_baseurl()."/events/$nextyear/$nextmonth",t('Next'),'',''),
'$previous' => array(App::get_baseurl() . '/events/$prevyear/$prevmonth', t('Previous'), '', ''),
'$next' => array(App::get_baseurl() . '/events/$nextyear/$nextmonth', t('Next'), '', ''),
'$calendar' => cal($y, $m, $links, ' eventcal'),
'$events' => $events,
"today" => t("today"),
"month" => t("month"),
"week" => t("week"),
"day" => t("day"),
"list" => t("list"),
'$today' => t('today'),
'$month' => t('month'),
'$week' => t('week'),
'$day' => t('day'),
'$list' => t('list'),
));
if (x($_GET,'id')){ echo $o; killme(); }
if (x($_GET,'id')) {
echo $o;
killme();
}
return $o;
@ -439,21 +439,24 @@ function events_content(App $a) {
$uri = ((x($orig_event)) ? $orig_event['uri'] : '');
if(! x($orig_event))
if (! x($orig_event)) {
$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" ' );
}
if($cid OR ($mode !== 'new'))
if ($cid OR ($mode !== 'new')) {
$sh_checked .= ' disabled="disabled" ';
}
$sdt = ((x($orig_event)) ? $orig_event['start'] : 'now');
$fdt = ((x($orig_event)) ? $orig_event['finish'] : 'now');
$tz = date_default_timezone_get();
if(x($orig_event))
if (x($orig_event)) {
$tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
}
$syear = datetime_convert('UTC', $tz, $sdt, 'Y');
$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);
$f = get_config('system','event_input_format');
if(! $f)
if (! $f) {
$f = 'ymd';
}
require_once('include/acl_selectors.php');
if ($mode === 'new')
if ($mode === 'new') {
$acl = (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user)));
}
$tpl = get_markup_template('event_form.tpl');
@ -511,12 +516,34 @@ function events_content(App $a) {
'$preview' => t('Preview'),
'$acl' => $acl,
'$submit' => t('Submit'),
'$basic' => t("Basic"),
'$advanced' => t("Advanced"),
'$basic' => t('Basic'),
'$advanced' => t('Advanced'),
'$permissions' => t('Permissions'),
));
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}}
{{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.drop}}<a href="{{$event.drop.0}}" onclick="return confirmDelete();" title="{{$event.drop.1}}" class="drop-event-link icon s22 delete"></a>{{/if}}
</div>
<div class="clear"></div>
{{/foreach}}

View file

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

View file

@ -17,8 +17,9 @@
</div>
<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="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="edit-event-link 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 class="clear"></div>
</div>