]> git.mxchange.org Git - friendica.git/blobdiff - mod/events.php
Merge pull request #9408 from annando/announce
[friendica.git] / mod / events.php
index f92a01cf606d552cc367ae24469463d9351e776c..695432e2a4b89db8f955bcd5477dc97b82369da5 100644 (file)
@@ -1,6 +1,22 @@
 <?php
 /**
- * @file mod/events.php
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
  * The events module
  */
 
@@ -8,7 +24,6 @@ use Friendica\App;
 use Friendica\Content\Nav;
 use Friendica\Content\Widget\CalendarExport;
 use Friendica\Core\ACL;
-use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
 use Friendica\Core\Theme;
@@ -17,8 +32,8 @@ use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Event;
 use Friendica\Model\Item;
-use Friendica\Model\Profile;
 use Friendica\Model\User;
+use Friendica\Module\BaseProfile;
 use Friendica\Module\Security\Login;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Strings;
@@ -51,7 +66,7 @@ function events_init(App $a)
 function events_post(App $a)
 {
 
-       Logger::log('post: ' . print_r($_REQUEST, true), Logger::DATA);
+       Logger::debug('post', ['request' => $_REQUEST]);
 
        if (!local_user()) {
                return;
@@ -117,7 +132,7 @@ function events_post(App $a)
        $onerror_path = 'events/' . $action . '?' . http_build_query($params, null, null, PHP_QUERY_RFC3986);
 
        if (strcmp($finish, $start) < 0 && !$nofinish) {
-               notice(DI::l10n()->t('Event can not end before it has started.') . EOL);
+               notice(DI::l10n()->t('Event can not end before it has started.'));
                if (intval($_REQUEST['preview'])) {
                        echo DI::l10n()->t('Event can not end before it has started.');
                        exit();
@@ -126,7 +141,7 @@ function events_post(App $a)
        }
 
        if (!$summary || ($start === DBA::NULL_DATETIME)) {
-               notice(DI::l10n()->t('Event title and start time are required.') . EOL);
+               notice(DI::l10n()->t('Event title and start time are required.'));
                if (intval($_REQUEST['preview'])) {
                        echo DI::l10n()->t('Event title and start time are required.');
                        exit();
@@ -210,7 +225,7 @@ function events_post(App $a)
 function events_content(App $a)
 {
        if (!local_user()) {
-               notice(DI::l10n()->t('Permission denied.') . EOL);
+               notice(DI::l10n()->t('Permission denied.'));
                return Login::form();
        }
 
@@ -241,6 +256,11 @@ function events_content(App $a)
        // get the translation strings for the callendar
        $i18n = Event::getStrings();
 
+       DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.min.css');
+       DI::page()->registerStylesheet('view/asset/fullcalendar/dist/fullcalendar.print.min.css', 'print');
+       DI::page()->registerFooterScript('view/asset/moment/min/moment-with-locales.min.js');
+       DI::page()->registerFooterScript('view/asset/fullcalendar/dist/fullcalendar.min.js');
+
        $htpl = Renderer::getMarkupTemplate('event_head.tpl');
        DI::page()['htmlhead'] .= Renderer::replaceMacros($htpl, [
                '$module_url' => '/events',
@@ -252,7 +272,7 @@ function events_content(App $a)
        $tabs = '';
        // tabs
        if ($a->theme_events_in_profile) {
-               $tabs = Profile::getTabs($a, 'events', true);
+               $tabs = BaseProfile::getTabsHTML($a, 'events', true);
        }
 
        $mode = 'view';
@@ -454,16 +474,16 @@ function events_content(App $a)
                $t_orig = $orig_event['summary']  ?? '';
                $d_orig = $orig_event['desc']     ?? '';
                $l_orig = $orig_event['location'] ?? '';
-               $eid = !empty($orig_event) ? $orig_event['id']  : 0;
-               $cid = !empty($orig_event) ? $orig_event['cid'] : 0;
-               $uri = !empty($orig_event) ? $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 = !empty($orig_event) ? $orig_event['start']  : 'now';
-               $fdt = !empty($orig_event) ? $orig_event['finish'] : 'now';
+               $sdt = $orig_event['start'] ?? 'now';
+               $fdt = $orig_event['finish'] ?? 'now';
 
                $tz = date_default_timezone_get();
                if (!empty($orig_event)) {
@@ -568,9 +588,7 @@ function events_content(App $a)
                }
 
                if (Item::exists(['id' => $ev[0]['itemid']])) {
-                       notice(DI::l10n()->t('Failed to remove event') . EOL);
-               } else {
-                       info(DI::l10n()->t('Event removed') . EOL);
+                       notice(DI::l10n()->t('Failed to remove event'));
                }
 
                DI::baseUrl()->redirect('events');