AntonLV 9 лет назад
Родитель
Сommit
56f9d9e343

+ 6 - 12
modules/boonex/notifications/js/push.js → inc/js/classes/BxDolPush.js

@@ -1,17 +1,11 @@
-function BxNtfsPush(oOptions) {
-	this._sActionsUri = oOptions.sActionUri;
-    this._sActionsUrl = oOptions.sActionUrl;
-    this._sObjName = oOptions.sObjName == undefined ? 'oBxNtfsPush' : oOptions.sObjName;
-    this._iOwnerId = oOptions.iOwnerId == undefined ? 0 : oOptions.iOwnerId;
+function BxDolPush(oOptions) {
+    this._sObjName = oOptions.sObjName == undefined ? 'oBxDolPush' : oOptions.sObjName;
     this._sSiteName = oOptions.sSiteName == undefined ? '' : oOptions.sSiteName;
     this._iProfileId = oOptions.iProfileId == undefined ? 0 : oOptions.iProfileId;
     this._sAppId = oOptions.sAppId == undefined ? '' : oOptions.sAppId;
     this._sShortName = oOptions.sShortName == undefined ? '' : oOptions.sShortName;
     this._sSafariWebId = oOptions.sSafariWebId == undefined ? '' : oOptions.sSafariWebId;
     this._sNotificationUrl = oOptions.sNotificationUrl == undefined ? '' : oOptions.sNotificationUrl;
-    this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'slide' : oOptions.sAnimationEffect;
-    this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
-    this._aHtmlIds = oOptions.aHtmlIds == undefined ? {} : oOptions.aHtmlIds;
 
     var $this = this;
     $(document).ready(function() {
@@ -19,7 +13,7 @@ function BxNtfsPush(oOptions) {
     });
 }
 
-BxNtfsPush.prototype.init = function() {
+BxDolPush.prototype.init = function() {
 	var $this = this;
 	var OneSignal = window.OneSignal || [];
 	OneSignal.push(["init", {
@@ -37,11 +31,11 @@ BxNtfsPush.prototype.init = function() {
 		promptOptions: {
 			/* These prompt options values configure both the HTTP prompt and the HTTP popup. */
 			/* actionMessage limited to 90 characters */
-			actionMessage: _t('_bx_ntfs_push_notification_request', $this._sSiteName), 
+			actionMessage: _t('_sys_push_notification_request', $this._sSiteName), 
 			/* acceptButtonText limited to 15 characters */
-			acceptButtonText: _t('_bx_ntfs_push_notification_request_yes'),
+			acceptButtonText: _t('_sys_push_notification_request_yes'),
 			/* cancelButtonText limited to 15 characters */
-			cancelButtonText: _t('_bx_ntfs_push_notification_request_no')
+			cancelButtonText: _t('_sys_push_notification_request_no')
 		}
 	}]);
 

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
install/sql/system.sql


+ 7 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -1289,6 +1289,10 @@
 	<string name="_adm_stg_cpt_option_sys_pb_cache_engine"><![CDATA[Page blocks cache engine (other than File option may require custom server setup)]]></string>
 	<string name="_adm_stg_cpt_option_sys_per_page_search_keyword_single"><![CDATA[Number of items in Keyword Search results]]></string>
 	<string name="_adm_stg_cpt_option_sys_per_page_search_keyword_plural"><![CDATA[Number of items in Site Search results]]></string>
+	<string name="_adm_stg_cpt_option_sys_push_app_id"><![CDATA[OneSignal App ID]]></string>
+    <string name="_adm_stg_cpt_option_sys_push_rest_api"><![CDATA[REST API Key]]></string>
+    <string name="_adm_stg_cpt_option_sys_push_short_name"><![CDATA[Short name (required only for http sites. It must match the Subdomain you entered on the Web Push settings on the OneSignal dashboard)]]></string>
+    <string name="_adm_stg_cpt_option_sys_push_safari_id"><![CDATA[Apple Safari Web ID on the Web Push settings]]></string>
 	<string name="_adm_stg_cpt_option_sys_recaptcha_key_private"><![CDATA[reCAPTCHA private key]]></string>
 	<string name="_adm_stg_cpt_option_sys_recaptcha_key_public"><![CDATA[reCAPTCHA public key]]></string>
 	<string name="_adm_stg_cpt_option_sys_redirect_after_account_added"><![CDATA[Redirect after account creation to]]></string>
@@ -2303,6 +2307,9 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_ps_group_title_public"><![CDATA[Public]]></string>
 	<string name="_sys_ps_group_title_closed"><![CDATA[Closed]]></string>
 	<string name="_sys_ps_group_title_secret"><![CDATA[Secret]]></string>
+	<string name="_sys_push_notification_request"><![CDATA[Would you like to get notifications from {0}?]]></string>  
+    <string name="_sys_push_notification_request_yes"><![CDATA[Yes]]></string>  
+    <string name="_sys_push_notification_request_no"><![CDATA[No, thanks]]></string>
     <string name="_sys_read_more"><![CDATA[Continue reading "{0}"]]></string>
 	<string name="_sys_request_module_not_found_cpt"><![CDATA[Module was not found]]></string>
 	<string name="_sys_request_module_not_found_cnt"><![CDATA[Module({0}) was not found]]></string>

+ 0 - 7
modules/boonex/notifications/classes/BxNtfsConfig.php

@@ -28,11 +28,6 @@ class BxNtfsConfig extends BxBaseModNotificationsConfig
         $this->CNF = array (
         	'URL_HOME' => 'page.php?i=notifications-view',
 
-        	'PARAM_PUSH_APP_ID' => 'bx_notifications_push_app_id',
-        	'PARAM_PUSH_REST_API' => 'bx_notifications_push_rest_api',
-        	'PARAM_PUSH_SHORT_NAME' => 'bx_notifications_push_short_name',
-			'PARAM_PUSH_SAFARI_WEB_ID' => 'bx_notifications_push_safari_id',
-
         	'OBJECT_MENU_SUBMENU' => 'bx_notifications_submenu', // main module submenu
         );
         
@@ -52,12 +47,10 @@ class BxNtfsConfig extends BxBaseModNotificationsConfig
         $this->_aJsClasses = array(
             'main' => 'BxNtfsMain',
         	'view' => 'BxNtfsView',
-        	'push' => 'BxNtfsPush',
         );
         $this->_aJsObjects = array(
         	'main' => 'oBxNtfsMain',
             'view' => 'oBxNtfsView',
-        	'push' => 'oBxNtfsPush',
         );
 
         $sHtmlPrefix = str_replace('_', '-', $this->_sName);

+ 0 - 26
modules/boonex/notifications/classes/BxNtfsModule.php

@@ -51,32 +51,6 @@ class BxNtfsModule extends BxBaseModNotificationsModule
     /**
      * SERVICE METHODS
      */
-    
-	/**
-     * @page service Service Calls
-     * @section bx_notifications Notifications
-     * @subsection bx_notifications-integration Integration
-     * @subsubsection bx_notifications-include include
-     * 
-     * @code bx_srv('bx_notifications', 'include', [...]); @endcode
-     * 
-     * Get integration code with all necessary includes. 
-     *
-     * @return HTML sting with integration code to display on the site, all necessary CSS and JS files are automatically added to the HEAD section of the site HTML. Empty string is returned if there is no enough input data.
-     * 
-     * @see BxSnipcartModule::serviceInclude
-     */
-    /** 
-     * @ref bx_notifications-include_css_js "include"
-     */
-    public function serviceGetInclude($iProfileId = 0)
-    {
-        $iProfileId = !empty($iProfileId) ? $iProfileId : bx_get_logged_profile_id();
-        if(empty($iProfileId))
-            return '';
-
-        return $this->_oTemplate->getInclude($iProfileId);
-    }
 
     /**
      * @page service Service Calls

+ 2 - 2
modules/boonex/notifications/classes/BxNtfsResponse.php

@@ -266,8 +266,8 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
 
-        $sAppId = getParam($CNF['PARAM_PUSH_APP_ID']);
-        $sRestApi = getParam($CNF['PARAM_PUSH_REST_API']);
+        $sAppId = getParam('sys_push_app_id');
+        $sRestApi = getParam('sys_push_rest_api');
         if(empty($sAppId) || empty($sRestApi))
             return;
 

+ 0 - 32
modules/boonex/notifications/classes/BxNtfsTemplate.php

@@ -16,38 +16,6 @@ class BxNtfsTemplate extends BxBaseModNotificationsTemplate
         parent::__construct($oConfig, $oDb);
     }
 
-    public function getInclude($iProfileId)
-    {
-        $CNF = &$this->_oConfig->CNF;
-
-        $sAppId = getParam($CNF['PARAM_PUSH_APP_ID']);
-        if(empty($sAppId))
-            return;
-
-        $sShortName = getParam($CNF['PARAM_PUSH_SHORT_NAME']);
-        $sSafariWebId = getParam($CNF['PARAM_PUSH_SAFARI_WEB_ID']);
-
-        $this->addJs(array(
-        	'https://cdn.onesignal.com/sdks/OneSignalSDK.js',
-        	'push.js',
-        ));
-
-        $this->addJsTranslation(array(
-            '_bx_ntfs_push_notification_request',
-            '_bx_ntfs_push_notification_request_yes',
-            '_bx_ntfs_push_notification_request_no'
-        ));
-
-        return $this->getJsCode('push', array(
-            'sSiteName' => getParam('site_title'),
-            'iProfileId' => $iProfileId,
-            'sAppId' => $sAppId,
-            'sShortName' => $sShortName,
-            'sSafariWebId' => $sSafariWebId,
-            'sNotificationUrl' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($CNF['URL_HOME']),
-        ));
-    }
-
     public function getViewBlock($aParams)
     {
         return $this->parseHtmlByName('block_view.html', array(

+ 0 - 7
modules/boonex/notifications/install/langs/en.xml

@@ -18,10 +18,6 @@
 	<string name="_bx_ntfs_option_events_hide_site"><![CDATA[Onsite notifications]]></string>
 	<string name="_bx_ntfs_option_events_hide_email"><![CDATA[Email notifications]]></string>
 	<string name="_bx_ntfs_option_events_hide_push"><![CDATA[Push notifications]]></string>
-	<string name="_bx_ntfs_option_push_app_id"><![CDATA[OneSignal App ID]]></string>
-    <string name="_bx_ntfs_option_push_rest_api"><![CDATA[REST API Key]]></string>
-    <string name="_bx_ntfs_option_push_short_name"><![CDATA[Short name (required only for http sites. It must match the Subdomain you entered on the Web Push settings on the OneSignal dashboard)]]></string>
-    <string name="_bx_ntfs_option_push_safari_id"><![CDATA[Apple Safari Web ID on the Web Push settings]]></string>
 
 	<string name="_bx_ntfs_privacy_view"><![CDATA[View event]]></string>
 
@@ -38,9 +34,6 @@
 	<string name="_bx_ntfs_txt_object_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> added a {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
 	<string name="_bx_ntfs_txt_subobject_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> added a {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
 
-    <string name="_bx_ntfs_push_notification_request"><![CDATA[Would you like to get notifications from {0}?]]></string>  
-    <string name="_bx_ntfs_push_notification_request_yes"><![CDATA[Yes]]></string>  
-    <string name="_bx_ntfs_push_notification_request_no"><![CDATA[No, thanks]]></string>
     <string name="_bx_ntfs_push_new_event_subject"><![CDATA[New on "{0}"]]></string>
 
 	<string name="_bx_ntfs_email_new_event"><![CDATA[New notification]]></string>

+ 0 - 4
modules/boonex/notifications/install/sql/disable.sql

@@ -36,7 +36,3 @@ DELETE FROM `sys_alerts_handlers` WHERE `id` = @iHandlerId LIMIT 1;
 
 -- EMAIL TEMPLATES
 DELETE FROM `sys_email_templates` WHERE `Module` = @sName;
-
-
--- INJECTION
-DELETE FROM `sys_injections` WHERE `name`=@sName;

+ 1 - 10
modules/boonex/notifications/install/sql/enable.sql

@@ -45,11 +45,7 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_notifications_events_per_page', '10', @iCategId, '_bx_ntfs_option_events_per_page', 'digit', '', '', '', '', 1),
 ('bx_notifications_events_hide_site', '', @iCategId, '_bx_ntfs_option_events_hide_site', 'rlist', '', '', '', 'a:2:{s:6:"module";s:16:"bx_notifications";s:6:"method";s:21:"get_actions_checklist";}', 10),
 ('bx_notifications_events_hide_email', '', @iCategId, '_bx_ntfs_option_events_hide_email', 'rlist', '', '', '', 'a:2:{s:6:"module";s:16:"bx_notifications";s:6:"method";s:21:"get_actions_checklist";}', 11),
-('bx_notifications_events_hide_push', '', @iCategId, '_bx_ntfs_option_events_hide_push', 'rlist', '', '', '', 'a:2:{s:6:"module";s:16:"bx_notifications";s:6:"method";s:21:"get_actions_checklist";}', 12),
-('bx_notifications_push_app_id', '', @iCategId, '_bx_ntfs_option_push_app_id', 'digit', '', '', '', '', 20),
-('bx_notifications_push_rest_api', '', @iCategId, '_bx_ntfs_option_push_rest_api', 'digit', '', '', '', '', 21),
-('bx_notifications_push_short_name', '', @iCategId, '_bx_ntfs_option_push_short_name', 'digit', '', '', '', '', 22),
-('bx_notifications_push_safari_id', '', @iCategId, '_bx_ntfs_option_push_safari_id', 'digit', '', '', '', '', 23);
+('bx_notifications_events_hide_push', '', @iCategId, '_bx_ntfs_option_events_hide_push', 'rlist', '', '', '', 'a:2:{s:6:"module";s:16:"bx_notifications";s:6:"method";s:21:"get_actions_checklist";}', 12);
 
 
 -- PRIVACY 
@@ -80,8 +76,3 @@ INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 -- EMAIL TEMPLATES
 INSERT INTO `sys_email_templates` (`Module`, `NameSystem`, `Name`, `Subject`, `Body`) VALUES
 (@sName, '_bx_ntfs_email_new_event', 'bx_notifications_new_event', '_bx_ntfs_email_new_event_subject', '_bx_ntfs_email_new_event_body');
-
-
--- INJECTION
-INSERT INTO `sys_injections`(`name`, `page_index`, `key`, `type`, `data`, `replace`, `active`) VALUES
-(@sName, 0, 'injection_header', 'service', 'a:2:{s:6:"module";s:16:"bx_notifications";s:6:"method";s:11:"get_include";}', '0', '1');

+ 0 - 7
modules/boonex/russian/data/langs/bx_notifications/ru.xml

@@ -18,10 +18,6 @@
 	<string name="_bx_ntfs_option_events_hide_site"><![CDATA[Уведомления на сайте]]></string>
 	<string name="_bx_ntfs_option_events_hide_email"><![CDATA[Уведомления через имейл]]></string>
 	<string name="_bx_ntfs_option_events_hide_push"><![CDATA[Push-уведомления]]></string>
-	<string name="_bx_ntfs_option_push_app_id"><![CDATA[OneSignal App ID]]></string>
-    <string name="_bx_ntfs_option_push_rest_api"><![CDATA[REST API Key]]></string>
-    <string name="_bx_ntfs_option_push_short_name"><![CDATA[Короткое имя (требуется только если у вас https сайт. Оно должно совпадать с поддоменом, введёным, в настройках пуш оповещений на OneSignal)]]></string>
-    <string name="_bx_ntfs_option_push_safari_id"><![CDATA[Apple Safari Web ID в натройках Web Push]]></string>
 
 	<string name="_bx_ntfs_privacy_view"><![CDATA[Просматривать события]]></string>
 
@@ -38,9 +34,6 @@
 	<string name="_bx_ntfs_txt_object_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - {entry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
 	<string name="_bx_ntfs_txt_subobject_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> - {subentry_sample} <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
 
-    <string name="_bx_ntfs_push_notification_request"><![CDATA[Вы не хотели бы получать уведомления с сайта {0}?]]></string>   
-    <string name="_bx_ntfs_push_notification_request_yes"><![CDATA[Да]]></string>   
-    <string name="_bx_ntfs_push_notification_request_no"><![CDATA[Нет, спасибо]]></string>
     <string name="_bx_ntfs_push_new_event_subject"><![CDATA[Новое на сайте "{0}"]]></string>
 
 	<string name="_bx_ntfs_email_new_event"><![CDATA[Новое уведомление]]></string>

+ 9 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -1287,6 +1287,10 @@
 	<string name="_adm_stg_cpt_option_sys_pb_cache_engine"><![CDATA[Кэш-движок для блоков страниц (значение, отличное от File, может потребовать дополнительной настройки сервера)]]></string>
 	<string name="_adm_stg_cpt_option_sys_per_page_search_keyword_single"><![CDATA[Число элементов на странице в результатах поиска по ключевому слову]]></string>
     <string name="_adm_stg_cpt_option_sys_per_page_search_keyword_plural"><![CDATA[Число элементов на странице в результатах поиска по сайту]]></string>
+    <string name="_adm_stg_cpt_option_sys_push_app_id"><![CDATA[OneSignal App ID]]></string>
+    <string name="_adm_stg_cpt_option_sys_push_rest_api"><![CDATA[REST API Key]]></string>
+    <string name="_adm_stg_cpt_option_sys_push_short_name"><![CDATA[Короткое имя (требуется только если у вас https сайт. Оно должно совпадать с поддоменом, введёным, в настройках пуш оповещений на OneSignal)]]></string>
+    <string name="_adm_stg_cpt_option_sys_push_safari_id"><![CDATA[Apple Safari Web ID в натройках Web Push]]></string>    
 	<string name="_adm_stg_cpt_option_sys_recaptcha_key_private"><![CDATA[reCAPTCHA - приватный ключ]]></string>
 	<string name="_adm_stg_cpt_option_sys_recaptcha_key_public"><![CDATA[reCAPTCHA - публичный ключ]]></string>
 	<string name="_adm_stg_cpt_option_sys_redirect_after_account_added"><![CDATA[Перенаправлять после создания аккаунта на]]></string>
@@ -2300,6 +2304,11 @@
 	<string name="_sys_ps_group_title_me_only"><![CDATA[Только я]]></string>
 	<string name="_sys_ps_group_title_members"><![CDATA[Пользователей]]></string>
 	<string name="_sys_ps_group_title_public"><![CDATA[Публичные]]></string>
+	<string name="_sys_ps_group_title_closed"><![CDATA[Закрытая]]></string>
+    <string name="_sys_ps_group_title_secret"><![CDATA[Секретная]]></string>
+	<string name="_sys_push_notification_request"><![CDATA[Вы не хотели бы получать уведомления с сайта {0}?]]></string>   
+    <string name="_sys_push_notification_request_yes"><![CDATA[Да]]></string>   
+    <string name="_sys_push_notification_request_no"><![CDATA[Нет, спасибо]]></string>
     <string name="_sys_read_more"><![CDATA[Продолжить чтение "{0}"]]></string>
 	<string name="_sys_request_module_not_found_cpt"><![CDATA[Модуль не найден]]></string>
 	<string name="_sys_request_module_not_found_cnt"><![CDATA[Модуль({0}) не найден]]></string>

+ 42 - 0
template/scripts/BxBaseServices.php

@@ -171,6 +171,48 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
             'input' => $oForm->genRow($aInputText)
         )), true);
     }
+
+    public function serviceAddPushInit($iProfileId = 0)
+    {
+        $iProfileId = !empty($iProfileId) ? $iProfileId : bx_get_logged_profile_id();
+        if(empty($iProfileId))
+            return '';
+
+        $sAppId = getParam('sys_push_app_id');
+        if(empty($sAppId))
+            return '';
+
+        $oTemplate = BxDolTemplate::getInstance();
+
+        $sShortName = getParam('sys_push_short_name');
+        $sSafariWebId = getParam('sys_push_safari_id');
+
+        $oTemplate->addJs(array(
+        	'https://cdn.onesignal.com/sdks/OneSignalSDK.js',
+        	'BxDolPush.js',
+        ));
+
+        $oTemplate->addJsTranslation(array(
+            '_sys_push_notification_request',
+            '_sys_push_notification_request_yes',
+            '_sys_push_notification_request_no'
+        ));
+
+        $sJsClass = 'BxDolPush';
+        $sJsObject = 'oBxDolPush';
+
+        $sContent = "var " . $sJsObject . " = new " . $sJsClass . "(" . json_encode(array(
+        	'sObjName' => $sJsObject,
+            'sSiteName' => getParam('site_title'),
+            'iProfileId' => $iProfileId,
+            'sAppId' => $sAppId,
+            'sShortName' => $sShortName,
+            'sSafariWebId' => $sSafariWebId,
+            'sNotificationUrl' => BX_DOL_URL_ROOT,
+        )) . ");";
+
+        return $oTemplate->_wrapInTagJsCode($sContent);
+    }
 }
 
 /** @} */

Некоторые файлы не были показаны из-за большого количества измененных файлов