mirror of
https://github.com/friendica/friendica
synced 2024-12-22 23:20:16 +00:00
adhere feedback
This commit is contained in:
parent
f13c91b320
commit
78a8ed6fe7
10 changed files with 76 additions and 87 deletions
|
@ -496,12 +496,45 @@ class Event
|
|||
return array_values($dates2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner array of a given nickname
|
||||
* Additionally, it can check if the owner array is selectable
|
||||
*
|
||||
* @param string $nickname
|
||||
* @param bool $check
|
||||
*
|
||||
* @return array the owner array
|
||||
* @throws NotFoundException The given nickname does not exist
|
||||
* @throws UnauthorizedException The access for the given nickname is restricted
|
||||
*/
|
||||
public static function getOwnerForNickname(string $nickname, bool $check = true): array
|
||||
{
|
||||
$owner = User::getOwnerDataByNick($nickname);
|
||||
if (empty($owner)) {
|
||||
throw new NotFoundException(DI::l10n()->t('User not found.'));
|
||||
}
|
||||
|
||||
if ($check) {
|
||||
$contact_id = DI::userSession()->getRemoteContactID($owner['uid']);
|
||||
|
||||
$remote_contact = $contact_id && DBA::exists('contact', ['id' => $contact_id, 'uid' => $owner['uid']]);
|
||||
|
||||
$is_owner = DI::userSession()->getLocalUserId() == $owner['uid'];
|
||||
|
||||
if ($owner['hidewall'] && !$is_owner && !$remote_contact) {
|
||||
throw new UnauthorizedException(DI::l10n()->t('Access to this profile has been restricted.'));
|
||||
}
|
||||
}
|
||||
|
||||
return $owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an event by its event ID.
|
||||
*
|
||||
* @param int $owner_uid The User ID of the owner of the event
|
||||
* @param int $event_id The ID of the event in the event table
|
||||
* @param string $nickname a possible nickname to search for instead of the own uid
|
||||
* @param int $owner_uid The User ID of the owner of the event
|
||||
* @param int $event_id The ID of the event in the event table
|
||||
* @param string|null $nickname a possible nickname to search for instead of the owner uid
|
||||
* @return array Query result
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
@ -538,39 +571,6 @@ class Event
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the owner array of a given nickname
|
||||
* Additionally, it can check if the owner array is selectable
|
||||
*
|
||||
* @param string $nickname
|
||||
* @param bool $check
|
||||
*
|
||||
* @return array the owner array
|
||||
* @throws NotFoundException The given nickname does not exist
|
||||
* @throws UnauthorizedException The access for the given nickname is restricted
|
||||
*/
|
||||
public static function getOwnerForNickname(string $nickname, bool $check = true): array
|
||||
{
|
||||
$owner = User::getOwnerDataByNick($nickname);
|
||||
if (empty($owner)) {
|
||||
throw new NotFoundException(DI::l10n()->t('User not found.'));
|
||||
}
|
||||
|
||||
if ($check) {
|
||||
$contact_id = DI::userSession()->getRemoteContactID($owner['uid']);
|
||||
|
||||
$remote_contact = $contact_id && DBA::exists('contact', ['id' => $contact_id, 'uid' => $owner['uid']]);
|
||||
|
||||
$is_owner = DI::userSession()->getLocalUserId() == $owner['uid'];
|
||||
|
||||
if ($owner['hidewall'] && !$is_owner && !$remote_contact) {
|
||||
throw new UnauthorizedException(DI::l10n()->t('Access to this profile has been restricted.'));
|
||||
}
|
||||
}
|
||||
|
||||
return $owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all events in a specific time frame.
|
||||
*
|
||||
|
@ -587,7 +587,7 @@ class Event
|
|||
public static function getListByDate(int $owner_uid, string $start = null, string $finish = null, bool $ignore = false, string $nickname = null): array
|
||||
{
|
||||
if (!empty($nickname)) {
|
||||
$owner = static::getOwnerForNickname($nickname, true);
|
||||
$owner = static::getOwnerForNickname($nickname);
|
||||
$owner_uid = $owner['uid'];
|
||||
|
||||
// get the permissions
|
||||
|
@ -608,15 +608,6 @@ class Event
|
|||
$y = intval(DateTimeFormat::localNow('Y'));
|
||||
$m = intval(DateTimeFormat::localNow('m'));
|
||||
|
||||
// Put some limit on dates. The PHP date functions don't seem to do so well before 1900.
|
||||
if ($y < 1901) {
|
||||
$y = 1900;
|
||||
}
|
||||
|
||||
if ($y > 2099) {
|
||||
$y = 2100;
|
||||
}
|
||||
|
||||
if (empty($start)) {
|
||||
$start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
|
||||
} else {
|
||||
|
@ -671,7 +662,7 @@ class Event
|
|||
$fmt = DI::l10n()->t('l, F j');
|
||||
|
||||
$item = Post::selectFirst(['plink', 'author-name', 'author-network', 'author-id', 'author-avatar', 'author-link', 'private', 'uri-id'], ['id' => $event['itemid']]);
|
||||
if (!DBA::isResult($item)) {
|
||||
if (empty($item)) {
|
||||
// Using default values when no item had been found
|
||||
$item = ['plink' => '', 'author-name' => '', 'author-avatar' => '', 'author-link' => '', 'private' => Item::PUBLIC, 'uri-id' => ($event['uri-id'] ?? 0)];
|
||||
}
|
||||
|
@ -695,9 +686,9 @@ class Event
|
|||
$copy = null;
|
||||
$drop = null;
|
||||
if (DI::userSession()->getLocalUserId() && DI::userSession()->getLocalUserId() == $event['uid'] && $event['type'] == 'event') {
|
||||
$edit = !$event['cid'] ? [DI::baseUrl() . '/calendar/event/edit/' . $event['id'], DI::l10n()->t('Edit event') , '', ''] : null;
|
||||
$copy = !$event['cid'] ? [DI::baseUrl() . '/calendar/event/copy/' . $event['id'] , DI::l10n()->t('Duplicate event'), '', ''] : null;
|
||||
$drop = [DI::baseUrl() . '/calendar/api/delete/' . $event['id'] , DI::l10n()->t('Delete event') , '', ''];
|
||||
$edit = !$event['cid'] ? ['calendar/event/edit/' . $event['id'], DI::l10n()->t('Edit event') , '', ''] : null;
|
||||
$copy = !$event['cid'] ? ['calendar/event/copy/' . $event['id'] , DI::l10n()->t('Duplicate event'), '', ''] : null;
|
||||
$drop = ['calendar/api/delete/' . $event['id'] , DI::l10n()->t('Delete event') , '', ''];
|
||||
}
|
||||
|
||||
$title = BBCode::convertForUriId($event['uri-id'], Strings::escapeHtml($event['summary']));
|
||||
|
|
|
@ -184,7 +184,6 @@ class API extends BaseModule
|
|||
if (strcmp($finish, $start) < 0 && !$noFinish) {
|
||||
if ($isPreview) {
|
||||
System::httpExit($this->t('Event can not end before it has started.'));
|
||||
return;
|
||||
} else {
|
||||
$this->sysMessages->addNotice($this->t('Event can not end before it has started.'));
|
||||
$this->baseUrl->redirect($redirectOnError);
|
||||
|
@ -194,7 +193,6 @@ class API extends BaseModule
|
|||
if (empty($summary) || ($start === DBA::NULL_DATETIME)) {
|
||||
if ($isPreview) {
|
||||
System::httpExit($this->t('Event title and start time are required.'));
|
||||
return;
|
||||
} else {
|
||||
$this->sysMessages->addNotice($this->t('Event title and start time are required.'));
|
||||
$this->baseUrl->redirect($redirectOnError);
|
||||
|
@ -252,7 +250,6 @@ class API extends BaseModule
|
|||
|
||||
if (intval($request['preview'])) {
|
||||
System::httpExit(Event::getHTML($datarray));
|
||||
return;
|
||||
}
|
||||
|
||||
$eventId = Event::store($datarray);
|
||||
|
@ -269,7 +266,7 @@ class API extends BaseModule
|
|||
}
|
||||
|
||||
if (!$cid && $uriId) {
|
||||
Worker::add(Worker::PRIORITY_HIGH, "Notifier", Delivery::POST, $uriId, $uid);
|
||||
Worker::add(Worker::PRIORITY_HIGH, 'Notifier', Delivery::POST, $uriId, $uid);
|
||||
}
|
||||
|
||||
$this->baseUrl->redirect('calendar');
|
||||
|
|
|
@ -113,8 +113,8 @@ class Form extends BaseModule
|
|||
$this->page['htmlhead'] .= Renderer::replaceMacros($htpl, [
|
||||
'$calendar_api' => $this->baseUrl . '/calendar/api/get',
|
||||
'$event_api' => $this->baseUrl . '/calendar/event/show',
|
||||
'$modparams' => 2,
|
||||
'$i18n' => $i18n,
|
||||
'$modparams' => 2,
|
||||
'$i18n' => $i18n,
|
||||
]);
|
||||
|
||||
$share_checked = '';
|
||||
|
@ -152,18 +152,18 @@ class Form extends BaseModule
|
|||
|
||||
$n_checked = (!empty($orig_event['nofinish']) ? ' checked="checked" ' : '');
|
||||
|
||||
$t_orig = $orig_event['summary'] ?? '';
|
||||
$d_orig = $orig_event['desc'] ?? '';
|
||||
$t_orig = $orig_event['summary'] ?? '';
|
||||
$d_orig = $orig_event['desc'] ?? '';
|
||||
$l_orig = $orig_event['location'] ?? '';
|
||||
$eid = $orig_event['id'] ?? 0;
|
||||
$cid = $orig_event['cid'] ?? 0;
|
||||
$uri = $orig_event['uri'] ?? '';
|
||||
$eid = $orig_event['id'] ?? 0;
|
||||
$cid = $orig_event['cid'] ?? 0;
|
||||
$uri = $orig_event['uri'] ?? '';
|
||||
|
||||
if ($cid || $mode === 'edit') {
|
||||
$share_disabled = 'disabled="disabled"';
|
||||
}
|
||||
|
||||
$sdt = $orig_event['start'] ?? 'now';
|
||||
$sdt = $orig_event['start'] ?? 'now';
|
||||
$fdt = $orig_event['finish'] ?? 'now';
|
||||
|
||||
$syear = DateTimeFormat::local($sdt, 'Y');
|
||||
|
@ -198,15 +198,15 @@ class Form extends BaseModule
|
|||
$tpl = Renderer::getMarkupTemplate('calendar/event_form.tpl');
|
||||
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$post' => $this->baseUrl . '/calendar/api/create',
|
||||
'$post' => 'calendar/api/create',
|
||||
'$eid' => $eid,
|
||||
'$cid' => $cid,
|
||||
'$uri' => $uri,
|
||||
|
||||
'$title' => $this->t('Event details'),
|
||||
'$desc' => $this->t('Starting date and Title are required.'),
|
||||
'$s_text' => $this->t('Event Starts:') . ' <span class="required" title="' . $this->t('Required') . '">*</span>',
|
||||
'$s_dsel' => Temporal::getDateTimeField(
|
||||
'$title' => $this->t('Event details'),
|
||||
'$desc' => $this->t('Starting date and Title are required.'),
|
||||
'$s_text' => $this->t('Event Starts:') . ' <span class="required" title="' . $this->t('Required') . '">*</span>',
|
||||
'$s_dsel' => Temporal::getDateTimeField(
|
||||
new \DateTime(),
|
||||
\DateTime::createFromFormat('Y', intval($syear) + 5),
|
||||
\DateTime::createFromFormat('Y-m-d H:i', "$syear-$smonth-$sday $shour:$sminute"),
|
||||
|
@ -218,10 +218,10 @@ class Form extends BaseModule
|
|||
'',
|
||||
true
|
||||
),
|
||||
'$n_text' => $this->t('Finish date/time is not known or not relevant'),
|
||||
'$n_checked' => $n_checked,
|
||||
'$f_text' => $this->t('Event Finishes:'),
|
||||
'$f_dsel' => Temporal::getDateTimeField(
|
||||
'$n_text' => $this->t('Finish date/time is not known or not relevant'),
|
||||
'$n_checked' => $n_checked,
|
||||
'$f_text' => $this->t('Event Finishes:'),
|
||||
'$f_dsel' => Temporal::getDateTimeField(
|
||||
new \DateTime(),
|
||||
\DateTime::createFromFormat('Y', intval($fyear) + 5),
|
||||
\DateTime::createFromFormat('Y-m-d H:i', "$fyear-$fmonth-$fday $fhour:$fminute"),
|
||||
|
@ -231,6 +231,7 @@ class Form extends BaseModule
|
|||
true,
|
||||
'start_text'
|
||||
),
|
||||
|
||||
'$d_text' => $this->t('Description:'),
|
||||
'$d_orig' => $d_orig,
|
||||
'$l_text' => $this->t('Location:'),
|
||||
|
@ -251,3 +252,4 @@ class Form extends BaseModule
|
|||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,7 @@ class Show extends BaseModule
|
|||
|
||||
$event_item = [];
|
||||
foreach ($tplEvent['item'] as $k => $v) {
|
||||
$k = str_replace('-', '_', $k);
|
||||
$event_item[$k] = $v;
|
||||
$event_item[str_replace('-', '_', $k)] = $v;
|
||||
}
|
||||
$tplEvent['item'] = $event_item;
|
||||
|
||||
|
|
|
@ -75,10 +75,10 @@ class Show extends BaseModule
|
|||
|
||||
$htpl = Renderer::getMarkupTemplate('calendar/calendar_head.tpl');
|
||||
$this->page['htmlhead'] .= Renderer::replaceMacros($htpl, [
|
||||
'$calendar_api' => $this->baseUrl . '/calendar/api/get' . (!empty($this->parameters['nickname']) ? '/' . $this->parameters['nickname'] : ''),
|
||||
'$event_api' => $this->baseUrl . '/calendar/event/show' . (!empty($this->parameters['nickname']) ? '/' . $this->parameters['nickname'] : ''),
|
||||
'$modparams' => 2,
|
||||
'$i18n' => $i18n,
|
||||
'$calendar_api' => 'calendar/api/get' . (!empty($this->parameters['nickname']) ? '/' . $this->parameters['nickname'] : ''),
|
||||
'$event_api' => 'calendar/event/show' . (!empty($this->parameters['nickname']) ? '/' . $this->parameters['nickname'] : ''),
|
||||
'$modparams' => 2,
|
||||
'$i18n' => $i18n,
|
||||
]);
|
||||
|
||||
$tabs = '';
|
||||
|
@ -119,7 +119,7 @@ class Show extends BaseModule
|
|||
'$tabs' => $tabs,
|
||||
'$title' => $this->t('Events'),
|
||||
'$view' => $this->t('View'),
|
||||
'$new_event' => [$this->baseUrl . '/calendar/event/new', $this->t('Create New Event'), '', ''],
|
||||
'$new_event' => ['calendar/event/new', $this->t('Create New Event'), '', ''],
|
||||
|
||||
'$today' => $this->t('today'),
|
||||
'$month' => $this->t('month'),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script>
|
||||
function showEvent(eventid) {
|
||||
$.get(
|
||||
'{{$event_api}}/'+eventid,
|
||||
'{{$event_api}}/' + eventid,
|
||||
function(data){
|
||||
$.colorbox({html:data});
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
|||
|
||||
function doEventPreview() {
|
||||
$('#event-edit-preview').val(1);
|
||||
$.post('calendar',$('#event-edit-form').serialize(), function(data) {
|
||||
$.post('calendar', $('#event-edit-form').serialize(), function(data) {
|
||||
$.colorbox({ html: data });
|
||||
});
|
||||
$('#event-edit-preview').val(0);
|
||||
|
@ -93,7 +93,7 @@
|
|||
},
|
||||
loading: function(isLoading, view) {
|
||||
if(!isLoading) {
|
||||
$('td.fc-day').dblclick(function() { window.location.href='/calendar/event/new?start='+$(this).data('date'); });
|
||||
$('td.fc-day').dblclick(function() { window.location.href='calendar/event/new?start=' + $(this).data('date'); });
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<h3>{{$etitle}}</h3>
|
||||
|
||||
<ul class="sidebar-calendar-export-ul">
|
||||
<li role="menuitem" class="sidebar-calendar-export-li"><a href="{{$baseurl}}/calendar/export/{{$user}}/ical">{{$export_ical}}</a></li>
|
||||
<li role="menuitem" class="sidebar-calendar-export-li"><a href="{{$baseurl}}/calendar/export/{{$user}}/csv">{{$export_csv}}</a></li>
|
||||
<li role="menuitem" class="sidebar-calendar-export-li"><a href="calendar/export/{{$user}}/ical">{{$export_ical}}</a></li>
|
||||
<li role="menuitem" class="sidebar-calendar-export-li"><a href="calendar/export/{{$user}}/csv">{{$export_csv}}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -35,7 +35,7 @@ $(document).ready(function () {
|
|||
loading: function (isLoading, view) {
|
||||
if (!isLoading) {
|
||||
$("td.fc-day").dblclick(function () {
|
||||
addToModal("/calendar/event/new?start=" + $(this).data("date"));
|
||||
addToModal("calendar/event/new?start=" + $(this).data("date"));
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
year: yesterday.getFullYear(),
|
||||
month: yesterday.getMonth(),
|
||||
date: yesterday.getDate(),
|
||||
events: '{{$baseurl}}/calendar/api/get',
|
||||
events: 'calendar/api/get',
|
||||
header: false,
|
||||
timeFormat: 'H(:mm)',
|
||||
defaultView: 'basicWeek',
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<script>
|
||||
function showEvent(eventid) {
|
||||
$.get(
|
||||
'{{$event_api}}/'+eventid,
|
||||
'{{$event_api}}/'+ eventid,
|
||||
function(data){
|
||||
$.colorbox({html:data});
|
||||
}
|
||||
|
@ -99,7 +99,7 @@
|
|||
},
|
||||
loading: function(isLoading, view) {
|
||||
if(!isLoading) {
|
||||
$('td.fc-day').dblclick(function() { window.location.href='/calendar/event/new?start='+$(this).data('date'); });
|
||||
$('td.fc-day').dblclick(function() { window.location.href='/calendar/event/new?start=' + $(this).data('date'); });
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue