瀏覽代碼

Merge branch 'master' of https://github.com/unaio/una

AntonLV 4 年之前
父節點
當前提交
c6c34c7de3

+ 2 - 1
composer.json

@@ -96,7 +96,8 @@
         "stripe/stripe-php": "^7.95",
         "twilio/sdk": "^5.19",
         "avto-dev/composer-cleanup-plugin": "dev-master",
-        "mpratt/embera": "~2.0"
+        "mpratt/embera": "~2.0",
+        "spatie/calendar-links": "^1.5"
     },
     "scripts": {
         "post-update-cmd": [

+ 59 - 1
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "0d6367e8155d2c7d5698ab532ec0ce79",
+    "content-hash": "eacc01865686bee312b7dd2d1d42ac01",
     "packages": [
         {
             "name": "achingbrain/php5-akismet",
@@ -1593,6 +1593,64 @@
             },
             "time": "2018-08-30T22:45:56+00:00"
         },
+        {
+            "name": "spatie/calendar-links",
+            "version": "1.5.0",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/spatie/calendar-links.git",
+                "reference": "fe4b566b6f47c1fac54e393ae72b44808ae48fa7"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/spatie/calendar-links/zipball/fe4b566b6f47c1fac54e393ae72b44808ae48fa7",
+                "reference": "fe4b566b6f47c1fac54e393ae72b44808ae48fa7",
+                "shasum": ""
+            },
+            "require": {
+                "php": "^7.2 || ^8.0"
+            },
+            "require-dev": {
+                "phpunit/phpunit": "^8.5 || ^9.0",
+                "spatie/phpunit-snapshot-assertions": "^3.0|^4.0",
+                "vimeo/psalm": "^4.1"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-4": {
+                    "Spatie\\CalendarLinks\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Sebastian De Deyne",
+                    "email": "sebastian@spatie.be",
+                    "homepage": "https://spatie.be",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Generate add to calendar links for Google, iCal and other calendar systems",
+            "homepage": "https://github.com/spatie/calendar-links",
+            "keywords": [
+                "calendar-links",
+                "spatie"
+            ],
+            "support": {
+                "issues": "https://github.com/spatie/calendar-links/issues",
+                "source": "https://github.com/spatie/calendar-links/tree/1.5.0"
+            },
+            "funding": [
+                {
+                    "url": "https://spatie.be/open-source/support-us",
+                    "type": "custom"
+                }
+            ],
+            "time": "2021-04-22T15:06:47+00:00"
+        },
         {
             "name": "stripe/stripe-php",
             "version": "v7.128.0",

+ 47 - 0
modules/boonex/events/classes/BxEventsMenuViewActionsAll.php

@@ -9,6 +9,8 @@
  * @{
  */
 
+use Spatie\CalendarLinks\Link;
+
 /**
  * View entry all actions menu
  */
@@ -21,6 +23,51 @@ class BxEventsMenuViewActionsAll extends BxBaseModGroupsMenuViewActionsAll
         parent::__construct($aObject, $oTemplate);
     }
 
+    public function setContentId($iContentId)
+    {
+        parent::setContentId($iContentId);
+
+        $oDateStart = new DateTime('@' . $this->_aContentInfo['date_start']);
+        $oDateEnd = new DateTime('@' . ($this->_aContentInfo['date_end'] > $this->_aContentInfo['repeat_stop'] ? $this->_aContentInfo['date_end'] : $this->_aContentInfo['repeat_stop']));
+
+        $CNF = $this->_oModule->_oConfig->CNF;
+
+        if ($this->_aContentInfo[$CNF['FIELD_TIMEZONE']]) {
+            $oTz = new DateTimeZone($this->_aContentInfo[$CNF['FIELD_TIMEZONE']]);
+            $oDateStart->setTimezone($oTz);
+            $oDateEnd->setTimezone($oTz);
+        }
+
+        $oICalLink = $oDateStart && $oDateEnd ? Link::create(
+            $this->_aContentInfo[$CNF['FIELD_TITLE']],
+            $oDateStart,
+            $oDateEnd
+        ) : null;
+
+        if (!empty($CNF['OBJECT_METATAGS'])) {
+            $oMetatags = BxDolMetatags::getObjectInstance($CNF['OBJECT_METATAGS']);
+            if ($oMetatags->locationsIsEnabled()) {
+                $sLocation = $oMetatags->locationsString($this->_aContentInfo[$CNF['FIELD_ID']], false);
+                if ($sLocation)
+                    $oICalLink->address($sLocation);
+            }
+        }
+
+        $this->addMarkers([
+            'ical_url' => $oICalLink ? $oICalLink->ics() : '',
+        ]);
+    }
+
+    protected function _getMenuAttrs ($aMenuItem)
+    {
+        $s = parent::_getMenuAttrs ($aMenuItem);
+        if ('ical-export' == $aMenuItem['name']) {
+            $CNF = $this->_oModule->_oConfig->CNF;
+            $s .= ' download="' . title2uri($this->_aContentInfo[$CNF['FIELD_TITLE']]) . '.ics"';
+        }
+        return $s;
+    }
+
     protected function _getMenuItemJoinEventProfile($aItem)
     {
         return $this->_getMenuItemByNameActions($aItem);

+ 11 - 1
modules/boonex/events/classes/BxEventsModule.php

@@ -72,6 +72,16 @@ class BxEventsModule extends BxBaseModGroupsModule implements iBxDolCalendarServ
         echo json_encode($aEntries);
     }
     
+    public function serviceIsIcalExportAvaliable($iContentId)
+    {
+        return true;
+        $aContentInfo = $iContentId ? $this->_oDb->getContentInfoById($iContentId) : false;
+        if ($aContentInfo)
+            return false;
+        
+        return $aContentInfo['date_start'] && $aContentInfo['date_end'];
+    }
+
     public function serviceGetCalendarEntries($iProfileId)
     {
         $CNF = &$this->_oConfig->CNF;
@@ -340,7 +350,7 @@ class BxEventsModule extends BxBaseModGroupsModule implements iBxDolCalendarServ
         $oDateStart = date_create('@' . $aContentInfo['date_start']);
         if ($oDateStart)
             $oDateStart->setTimezone(new DateTimeZone($aContentInfo['timezone'] ? $aContentInfo['timezone'] : 'UTC'));
-        $oDateEnd = date_create('@' . ($aContentInfo['date_start'] > $aContentInfo['repeat_stop'] ? $aContentInfo['date_start'] : $aContentInfo['repeat_stop']));
+        $oDateEnd = date_create('@' . ($aContentInfo['date_end'] > $aContentInfo['repeat_stop'] ? $aContentInfo['date_end'] : $aContentInfo['repeat_stop']));
         if ($oDateEnd)
             $oDateEnd->setTimezone(new DateTimeZone($aContentInfo['timezone'] ? $aContentInfo['timezone'] : 'UTC'));
 

+ 1 - 0
modules/boonex/events/install/langs/en.xml

@@ -365,6 +365,7 @@
     <string name="_bx_events_menu_item_title_sm_date_start"><![CDATA[Date start]]></string>
     <string name="_bx_events_menu_item_title_system_sm_date_end"><![CDATA[Date end]]></string>
     <string name="_bx_events_menu_item_title_sm_date_end"><![CDATA[Date end]]></string>
+    <string name="_bx_events_menu_item_title_ical_export"><![CDATA[Sync to Calendar]]></string>
 
     <string name="_bx_events_grid_filter_item_title_adm_select_one_filter1"><![CDATA[All Statuses]]></string>
     <string name="_bx_events_grid_filter_item_title_adm_select_one_filter2"><![CDATA[Any Audience]]></string>

+ 2 - 0
modules/boonex/events/install/sql/enable.sql

@@ -295,6 +295,7 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_events_view_actions', 'bx_events', 'profile-fan-add', '_bx_events_menu_item_title_system_become_fan', '{title_add_fan}', 'javascript:void(0)', 'bx_conn_action(this, \'bx_events_fans\', \'add\', \'{profile_id}\')', '', 'sign-in-alt', '', 0, 2147483647, 'a:3:{s:6:"module";s:9:"bx_events";s:6:"method";s:22:"is_free_join_avaliable";s:6:"params";a:1:{i:0;s:12:"{profile_id}";}}', 1, 0, 0, 5),
 ('bx_events_view_actions', 'bx_events', 'profile-subscribe-add', '_bx_events_menu_item_title_system_subscribe', '_bx_events_menu_item_title_subscribe', 'javascript:void(0)', 'bx_conn_action(this, \'sys_profiles_subscriptions\', \'add\', \'{profile_id}\')', '', 'check', '', 0, 2147483647, '', 1, 0, 1, 20),
 ('bx_events_view_actions', 'bx_events', 'profile-set-badges', '_sys_menu_item_title_system_set_badges', '_sys_menu_item_title_set_badges', 'javascript:void(0)', 'bx_menu_popup(''sys_set_badges'', window, {}, {module: ''bx_events'', content_id: {content_id}});', '', 'check-circle', '', 0, 192, 'a:2:{s:6:"module";s:9:"bx_events";s:6:"method";s:19:"is_badges_avaliable";}', 1, 0, 1, 30),
+('bx_events_view_actions', 'bx_events', 'ical-export', '', '_bx_events_menu_item_title_ical_export', '{ical_url}', '', '', 'calendar-plus', '', 0, 2147483647, 'a:3:{s:6:"module";s:9:"bx_events";s:6:"method";s:24:"is_ical_export_avaliable";s:6:"params";a:1:{i:0;s:12:"{content_id}";}}', 1, 0, 1, 40),
 ('bx_events_view_actions', 'bx_events', 'profile-actions-more', '_bx_events_menu_item_title_system_more_actions', '_bx_events_menu_item_title_more_actions', 'javascript:void(0)', 'bx_menu_popup(''bx_events_view_actions_more'', this, {}, {profile_id:{profile_id}});', '', 'cog', 'bx_events_view_actions_more', 1, 2147483647, '', 1, 0, 1, 9999);
 
 -- MENU: view actions more
@@ -330,6 +331,7 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_events_view_actions_all', 'bx_events', 'profile-subscribe-add', '_bx_events_menu_item_title_system_subscribe', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 30),
 ('bx_events_view_actions_all', 'bx_events', 'profile-subscribe-remove', '_bx_events_menu_item_title_system_unsubscribe', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 40),
 ('bx_events_view_actions_all', 'bx_events', 'profile-set-badges', '_sys_menu_item_title_system_set_badges', '', '', '', '', '', '', '', 0, 192, 'a:2:{s:6:"module";s:9:"bx_events";s:6:"method";s:19:"is_badges_avaliable";}', 1, 0, 50),
+('bx_events_view_actions_all', 'bx_events', 'ical-export', '', '_bx_events_menu_item_title_ical_export', '{ical_url}', '', '', 'calendar-plus', '', '', 0, 2147483647, 'a:3:{s:6:"module";s:9:"bx_events";s:6:"method";s:24:"is_ical_export_avaliable";s:6:"params";a:1:{i:0;s:12:"{content_id}";}}', 1, 0, 60),
 ('bx_events_view_actions_all', 'bx_events', 'comment', '_sys_menu_item_title_system_va_comment', '', '', '', '', '', '', '', 0, 2147483647, '', 0, 0, 200),
 ('bx_events_view_actions_all', 'bx_events', 'view', '_sys_menu_item_title_system_va_view', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 210),
 ('bx_events_view_actions_all', 'bx_events', 'vote', '_sys_menu_item_title_system_va_vote', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 220),

+ 1 - 0
modules/boonex/russian/data/langs/bx_events/ru.xml

@@ -327,6 +327,7 @@
     <string name="_bx_events_menu_item_title_sm_date_start"><![CDATA[Начало]]></string>
     <string name="_bx_events_menu_item_title_system_sm_date_end"><![CDATA[Конец]]></string>
     <string name="_bx_events_menu_item_title_sm_date_end"><![CDATA[Конец]]></string>
+    <string name="_bx_events_menu_item_title_ical_export"><![CDATA[Добавить в календарь]]></string>
 
     <string name="_bx_events_grid_filter_item_title_adm_select_one_filter1"><![CDATA[Все статусы]]></string>
     <string name="_bx_events_grid_filter_item_title_adm_select_one_filter2"><![CDATA[Любая аудитория]]></string>