]> git.mxchange.org Git - friendica.git/blobdiff - mod/events.php
Issue 2657: Mentions will now be recognized by clients
[friendica.git] / mod / events.php
index eead66c01022dba9a20ec70b2de6d2e8c732a2b3..b87120672faa17cb59eb891460c5e189c1dcede0 100644 (file)
@@ -46,7 +46,7 @@ use Friendica\Worker\Delivery;
 
 function events_init(App $a)
 {
-       if (!local_user()) {
+       if (!DI::userSession()->getLocalUserId()) {
                return;
        }
 
@@ -54,7 +54,7 @@ function events_init(App $a)
                DI::page()['aside'] = '';
        }
 
-       $cal_widget = CalendarExport::getHTML(local_user());
+       $cal_widget = CalendarExport::getHTML(DI::userSession()->getLocalUserId());
 
        DI::page()['aside'] .= $cal_widget;
 
@@ -64,13 +64,13 @@ function events_init(App $a)
 function events_post(App $a)
 {
        Logger::debug('post', ['request' => $_REQUEST]);
-       if (!local_user()) {
+       if (!DI::userSession()->getLocalUserId()) {
                return;
        }
 
        $event_id = !empty($_POST['event_id']) ? intval($_POST['event_id']) : 0;
        $cid = !empty($_POST['cid']) ? intval($_POST['cid']) : 0;
-       $uid = local_user();
+       $uid = DI::userSession()->getLocalUserId();
 
        $start_text  = Strings::escapeHtml($_REQUEST['start_text'] ?? '');
        $finish_text = Strings::escapeHtml($_REQUEST['finish_text'] ?? '');
@@ -121,7 +121,7 @@ function events_post(App $a)
        $onerror_path = 'events/' . $action . '?' . http_build_query($params, '', '&', PHP_QUERY_RFC3986);
 
        if (strcmp($finish, $start) < 0 && !$nofinish) {
-               notice(DI::l10n()->t('Event can not end before it has started.'));
+               DI::sysmsg()->addNotice(DI::l10n()->t('Event can not end before it has started.'));
                if (intval($_REQUEST['preview'])) {
                        System::httpExit(DI::l10n()->t('Event can not end before it has started.'));
                }
@@ -129,7 +129,7 @@ function events_post(App $a)
        }
 
        if (!$summary || ($start === DBA::NULL_DATETIME)) {
-               notice(DI::l10n()->t('Event title and start time are required.'));
+               DI::sysmsg()->addNotice(DI::l10n()->t('Event title and start time are required.'));
                if (intval($_REQUEST['preview'])) {
                        System::httpExit(DI::l10n()->t('Event title and start time are required.'));
                }
@@ -173,22 +173,23 @@ function events_post(App $a)
                $private_event = true;
        }
 
-       $datarray = [];
-       $datarray['start']     = $start;
-       $datarray['finish']    = $finish;
-       $datarray['summary']   = $summary;
-       $datarray['desc']      = $desc;
-       $datarray['location']  = $location;
-       $datarray['type']      = $type;
-       $datarray['nofinish']  = $nofinish;
-       $datarray['uid']       = $uid;
-       $datarray['cid']       = $cid;
-       $datarray['allow_cid'] = $str_contact_allow;
-       $datarray['allow_gid'] = $str_group_allow;
-       $datarray['deny_cid']  = $str_contact_deny;
-       $datarray['deny_gid']  = $str_group_deny;
-       $datarray['private']   = $private_event;
-       $datarray['id']        = $event_id;
+       $datarray = [
+               'start'     => $start,
+               'finish'    => $finish,
+               'summary'   => $summary,
+               'desc'      => $desc,
+               'location'  => $location,
+               'type'      => $type,
+               'nofinish'  => $nofinish,
+               'uid'       => $uid,
+               'cid'       => $cid,
+               'allow_cid' => $str_contact_allow,
+               'allow_gid' => $str_group_allow,
+               'deny_cid'  => $str_contact_deny,
+               'deny_gid'  => $str_group_deny,
+               'private'   => $private_event,
+               'id'        => $event_id,
+       ];
 
        if (intval($_REQUEST['preview'])) {
                System::httpExit(Event::getHTML($datarray));
@@ -213,8 +214,8 @@ function events_post(App $a)
 
 function events_content(App $a)
 {
-       if (!local_user()) {
-               notice(DI::l10n()->t('Permission denied.'));
+       if (!DI::userSession()->getLocalUserId()) {
+               DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
                return Login::form();
        }
 
@@ -223,11 +224,11 @@ function events_content(App $a)
        }
 
        if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'ignore') && intval(DI::args()->getArgv()[2])) {
-               DBA::update('event', ['ignore' => true], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
+               DBA::update('event', ['ignore' => true], ['id' => DI::args()->getArgv()[2], 'uid' => DI::userSession()->getLocalUserId()]);
        }
 
        if ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[1] === 'unignore') && intval(DI::args()->getArgv()[2])) {
-               DBA::update('event', ['ignore' => false], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
+               DBA::update('event', ['ignore' => false], ['id' => DI::args()->getArgv()[2], 'uid' => DI::userSession()->getLocalUserId()]);
        }
 
        if ($a->getThemeInfoValue('events_in_profile')) {
@@ -322,9 +323,9 @@ function events_content(App $a)
 
                // get events by id or by date
                if ($event_params['event_id']) {
-                       $r = Event::getListById(local_user(), $event_params['event_id']);
+                       $r = Event::getListById(DI::userSession()->getLocalUserId(), $event_params['event_id']);
                } else {
-                       $r = Event::getListByDate(local_user(), $event_params);
+                       $r = Event::getListByDate(DI::userSession()->getLocalUserId(), $event_params);
                }
 
                $links = [];
@@ -395,7 +396,7 @@ function events_content(App $a)
        }
 
        if (($mode === 'edit' || $mode === 'copy') && $event_id) {
-               $orig_event = DBA::selectFirst('event', [], ['id' => $event_id, 'uid' => local_user()]);
+               $orig_event = DBA::selectFirst('event', [], ['id' => $event_id, 'uid' => DI::userSession()->getLocalUserId()]);
        }
 
        // Passed parameters overrides anything found in the DB
@@ -404,8 +405,8 @@ function events_content(App $a)
                $share_disabled = '';
 
                if (empty($orig_event)) {
-                       $orig_event = User::getById(local_user(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']);;
-               } elseif ($orig_event['allow_cid'] !== '<' . local_user() . '>'
+                       $orig_event = User::getById(DI::userSession()->getLocalUserId(), ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']);;
+               } elseif ($orig_event['allow_cid'] !== '<' . DI::userSession()->getLocalUserId() . '>'
                        || $orig_event['allow_gid']
                        || $orig_event['deny_cid']
                        || $orig_event['deny_gid']) {
@@ -523,15 +524,15 @@ function events_content(App $a)
 
        // Remove an event from the calendar and its related items
        if ($mode === 'drop' && $event_id) {
-               $ev = Event::getListById(local_user(), $event_id);
+               $ev = Event::getListById(DI::userSession()->getLocalUserId(), $event_id);
 
                // Delete only real events (no birthdays)
                if (DBA::isResult($ev) && $ev[0]['type'] == 'event') {
-                       Item::deleteForUser(['id' => $ev[0]['itemid']], local_user());
+                       Item::deleteForUser(['id' => $ev[0]['itemid']], DI::userSession()->getLocalUserId());
                }
 
                if (Post::exists(['id' => $ev[0]['itemid']])) {
-                       notice(DI::l10n()->t('Failed to remove event'));
+                       DI::sysmsg()->addNotice(DI::l10n()->t('Failed to remove event'));
                }
 
                DI::baseUrl()->redirect('events');