AntonLV 8 лет назад
Родитель
Сommit
2393b2ddd8

+ 2 - 2
inc/classes/BxDolMetatags.php

@@ -877,8 +877,8 @@ class BxDolMetatags extends BxDolFactory implements iBxDolFactoryObject
         if ($iRet = $this->_oQuery->$sFuncAdd($iId, $aMetas)) {
             foreach ($aMetas as $sMeta) {
                 $iObjectId = 'mention' == $sAlertName ? $sMeta : $iId;
-                bx_alert($this->_sObject, $sAlertName . '_add', $iObjectId, bx_get_logged_profile_id(), array('meta' => $sMeta, 'content_id' => $iId));
-                bx_alert('meta_' . $sAlertName, 'add', $iObjectId, bx_get_logged_profile_id(), array('meta' => $sMeta, 'content_id' => $iId, 'object' => $this->_sObject));
+                bx_alert($this->_sObject, $sAlertName . '_added', $iObjectId, bx_get_logged_profile_id(), array('meta' => $sMeta, 'content_id' => $iId));
+                bx_alert('meta_' . $sAlertName, 'added', $iObjectId, bx_get_logged_profile_id(), array('meta' => $sMeta, 'content_id' => $iId, 'object' => $this->_sObject));
             }
         }
 

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

@@ -2239,6 +2239,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_menu_title_switch_language_inline"><![CDATA[Language Switch (inline)]]></string>
 	<string name="_sys_menu_title_switch_template"><![CDATA[Switch Template]]></string>
 	<string name="_sys_menu_title_snippet_meta"><![CDATA[Snippet Meta Info]]></string>
+	<string name="_sys_metatags_mention_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> mentioned <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
 	<string name="_sys_mobile_friends"><![CDATA[Friends]]></string>
 	<string name="_sys_mobile_info"><![CDATA[Info]]></string>
 	<string name="_sys_mobile_mail"><![CDATA[Messages]]></string>

+ 1 - 3
modules/boonex/notifications/classes/BxNtfsDb.php

@@ -94,10 +94,8 @@ class BxNtfsDb extends BxBaseModNotificationsDb
 					$aQueryParts = $oConnection->getConnectedContentAsSQLParts($this->_sPrefix . "events", 'owner_id', $aParams['owner_id']);
 					if(!empty($aQueryParts['join']))
 					    $sJoinClause .= ' ' . str_replace('INNER', 'LEFT', $aQueryParts['join']);
-                    if(!empty($aQueryParts['fields']['added']))
-					    $sWhereClause .= "AND `{$this->_sTable}`.`date` > " . $aQueryParts['fields']['added'];
 
-					$sWhereClause .= $this->prepareAsString("AND ((NOT ISNULL(`c`.`content`) AND `{$this->_sTable}`.`action` <> 'replyPost') || (`{$this->_sTable}`.`owner_id` <> `{$this->_sTable}`.`object_owner_id` AND `{$this->_sTable}`.`object_owner_id`=?)) ", $aParams['owner_id']);
+					$sWhereClause .= $this->prepareAsString("AND ((NOT ISNULL(`c`.`content`)" . (!empty($aQueryParts['fields']['added']) ? " AND `{$this->_sTable}`.`date` > " . $aQueryParts['fields']['added'] : "") . " AND `{$this->_sTable}`.`action` <> 'replyPost') || (`{$this->_sTable}`.`owner_id` <> `{$this->_sTable}`.`object_owner_id` AND `{$this->_sTable}`.`object_owner_id`=?)) ", $aParams['owner_id']);
                     break;
 			}
 

+ 12 - 0
modules/boonex/notifications/classes/BxNtfsResponse.php

@@ -323,6 +323,18 @@ class BxNtfsResponse extends BxBaseModNotificationsResponse
 		$sResult = curl_exec($oChannel);
 		curl_close($oChannel);
     }
+
+    protected function _getObjectOwnerId($aExtras)
+    {
+        $iResult = parent::_getObjectOwnerId($aExtras);
+        if(!empty($iResult))
+            return $iResult;
+
+        if(isset($aExtras['meta']))
+            return (int)$aExtras['meta'];
+
+        return 0;
+    }
 }
 
 /** @} */

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

@@ -27,6 +27,7 @@
 	<string name="_bx_ntfs_alert_action_doVote"><![CDATA[add vote]]></string>
 	<string name="_bx_ntfs_alert_action_timeline_post_common"><![CDATA[post to timeline]]></string> 
 
+    <string name="_bx_ntfs_alert_module_meta_mention"><![CDATA[Profiles Mentions]]></string>
 	<string name="_bx_ntfs_alert_module_sys_profiles_subscriptions"><![CDATA[Profiles Subscriptions]]></string>
 	<string name="_bx_ntfs_alert_module_sys_profiles_friends"><![CDATA[Profiles Friends]]></string>
 	<string name="_bx_ntfs_alert_action_connection_added"><![CDATA[add connection]]></string>

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

@@ -66,6 +66,8 @@ SET @iHandler := LAST_INSERT_ID();
 INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 ('profile', 'delete', @iHandler),
 
+('meta_mention', 'added', @iHandler),
+
 ('sys_profiles_friends', 'connection_added', @iHandler),
 ('sys_profiles_friends', 'connection_removed', @iHandler),
 

+ 2 - 0
modules/boonex/notifications/install/sql/install.sql

@@ -42,6 +42,8 @@ CREATE TABLE IF NOT EXISTS `bx_notifications_handlers` (
 INSERT INTO `bx_notifications_handlers`(`group`, `type`, `alert_unit`, `alert_action`, `content`) VALUES
 ('profile', 'delete', 'profile', 'delete', ''),
 
+('mention', 'insert', 'meta_mention', 'added', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:30:"get_notifications_post_mention";s:12:"module_class";s:20:"TemplServiceMetatags";}'),
+
 ('friendship', 'insert', 'sys_profiles_friends', 'connection_added', 'a:3:{s:11:"module_name";s:6:"system";s:13:"module_method";s:33:"get_notifications_post_friendship";s:12:"module_class";s:23:"TemplServiceConnections";}'),
 ('friendship', 'delete', 'sys_profiles_friends', 'connection_removed', ''),
 

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

@@ -27,6 +27,7 @@
 	<string name="_bx_ntfs_alert_action_doVote"><![CDATA[добавить голос]]></string>
 	<string name="_bx_ntfs_alert_action_timeline_post_common"><![CDATA[сообщение на линейке]]></string>
 
+    <string name="_bx_ntfs_alert_module_meta_mention"><![CDATA[Упоминания о профайлах]]></string>
 	<string name="_bx_ntfs_alert_module_sys_profiles_subscriptions"><![CDATA[Подписки профайлов]]></string>
 	<string name="_bx_ntfs_alert_module_sys_profiles_friends"><![CDATA[Друзья профайлов]]></string>
 	<string name="_bx_ntfs_alert_action_connection_added"><![CDATA[добавить связь]]></string>	

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

@@ -2238,6 +2238,7 @@
 	<string name="_sys_menu_title_switch_language_inline"><![CDATA[Переключатель языка (встроенный)]]></string>
 	<string name="_sys_menu_title_switch_template"><![CDATA[Переключить тему]]></string>
 	<string name="_sys_menu_title_snippet_meta"><![CDATA[Мета информация в карточке]]></string>
+	<string name="_sys_metatags_mention_added"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> упомянул <b class="bx-ntfs-content-entry">{entry_caption}</b>]]></string>
 	<string name="_sys_mobile_friends"><![CDATA[Друзья]]></string>
 	<string name="_sys_mobile_info"><![CDATA[Инфо]]></string>
 	<string name="_sys_mobile_mail"><![CDATA[Сообщения]]></string>

+ 19 - 0
template/scripts/BxBaseServiceMetatags.php

@@ -48,6 +48,25 @@ class BxBaseServiceMetatags extends BxDol
     {
         return BxDolMetatags::getObjectInstance($sObject)->getLocationsMap($iId, $sMapSize);
     }
+    
+	/**
+     * Get notification data for Notifications module - action Mention. 
+     */
+	public function serviceGetNotificationsPostMention($aEvent)
+    {
+    	$iProfile = (int)$aEvent['object_owner_id'];
+    	$oProfile = BxDolProfile::getInstance($iProfile);
+        if(!$oProfile)
+			return array();
+
+		return array(
+			'entry_sample' => '_sys_profile_sample_single',
+			'entry_url' => BX_DOL_URL_ROOT . bx_append_url_params('searchKeyword.php', array('type' => 'mention', 'keyword' => $iProfile)),
+			'entry_caption' => $oProfile->getDisplayName(),
+			'entry_author' => $iProfile,
+			'lang_key' => '_sys_metatags_mention_added',
+		);
+    }
 }
 
 /** @} */