Pārlūkot izejas kodu

Ticket #3679 - Notifications: for Organization itself.

AntonLV 4 gadi atpakaļ
vecāks
revīzija
077415f3e3

+ 6 - 1
modules/base/groups/classes/BxBaseModGroupsPrivacyNotifications.php

@@ -24,7 +24,12 @@ class BxBaseModGroupsPrivacyNotifications extends BxBaseModGroupsPrivacy
         if (!($aEvent = BxDolService::call('bx_notifications', 'get_event_by_id', array($iObjectId))))
             return false;
 
-        return $this->_oModule->_oDb->isAdmin($aEvent['object_owner_id'], $iViewerId ? $iViewerId : bx_get_logged_profile_id());
+        return $this->checkGroupMember($aEvent['object_owner_id'], $iViewerId ? $iViewerId : bx_get_logged_profile_id());
+    }
+
+    public function checkGroupMember($iGroupProfileId, $iViewerId)
+    {
+        return $this->_oModule->_oDb->isAdmin($iGroupProfileId, $iViewerId);
     }
 }
 

+ 1 - 0
modules/boonex/organizations/classes/BxOrgsConfig.php

@@ -237,6 +237,7 @@ class BxOrgsConfig extends BxBaseModGroupsConfig
                 'txt_N_fans' => '_bx_orgs_txt_N_friends',
                 'txt_ntfs_join_invitation' => '_bx_orgs_txt_ntfs_join_invitation',
             	'txt_ntfs_join_request' => '_bx_orgs_txt_ntfs_join_request',
+                'txt_ntfs_join_request_for_owner' => '_bx_orgs_txt_ntfs_join_request_for_owner',
                 'txt_ntfs_fan_added' => '_bx_orgs_txt_ntfs_fan_added',
             	'txt_ntfs_timeline_post_common' => '_bx_orgs_txt_ntfs_timeline_post_common',
                 'option_members_mode_multi_roles' => '_bx_orgs_option_members_mode_multi_roles',

+ 20 - 0
modules/boonex/organizations/classes/BxOrgsModule.php

@@ -91,6 +91,26 @@ class BxOrgsModule extends BxBaseModGroupsModule
     	return BxBaseModProfileModule::serviceGetTimelineData();
     }
 
+    public function serviceGetNotificationsInsertData($oAlert, $aHandler, $aDataItems)
+    {
+        if($oAlert->sAction != 'join_request' || empty($aDataItems) || !is_array($aDataItems))
+            return $aDataItems;
+
+        $aDataItem = reset($aDataItems);
+        $aDataItem['owner_id'] = $oAlert->aExtras['performer_id'];
+
+        $aDataItems[] = $aDataItem;
+        return $aDataItems;
+    }
+
+    public function serviceGetNotificationsJoinRequest($aEvent)
+    {
+        if($aEvent['owner_id'] == $aEvent['object_owner_id'])
+            return parent::serviceGetNotificationsJoinRequest($aEvent);
+
+        return $this->_serviceGetNotification($aEvent, $this->_oConfig->CNF['T']['txt_ntfs_join_request_for_owner']);
+    }
+
     public function onFanRemovedFromAdmins($iGroupProfileId, $iProfileId)
     {
         if (!($oProfile = BxDolProfile::getInstance($iProfileId)))

+ 8 - 0
modules/boonex/organizations/classes/BxOrgsPrivacyNotifications.php

@@ -16,6 +16,14 @@ class BxOrgsPrivacyNotifications extends BxBaseModGroupsPrivacyNotifications
     	$this->MODULE = 'bx_organizations';
         parent::__construct($aOptions, $oTemplate);
     }
+
+    public function checkGroupMember($iGroupProfileId, $iViewerId)
+    {
+        if($iGroupProfileId == $iViewerId)
+            return true;
+
+        return parent::checkGroupMember($iGroupProfileId, $iViewerId);
+    }
 }
 
 /** @} */

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

@@ -481,6 +481,7 @@
     <string name="_bx_orgs_txt_ntfs_fan_added"><![CDATA[Organization <b class="bx-ntfs-content-profile">{owner_name}</b> has got a member <b class="bx-ntfs-content-entry">{subentry_sample}</b>]]></string>
     <string name="_bx_orgs_txt_ntfs_join_invitation"><![CDATA[<b class="bx-ntfs-content-profile">{owner_name}</b> organization's representative invites <b class="bx-ntfs-content-entry">{subentry_sample}</b> to join organization]]></string>
     <string name="_bx_orgs_txt_ntfs_join_request"><![CDATA[Organization <b class="bx-ntfs-content-profile">{owner_name}</b> has a join request from <b class="bx-ntfs-content-entry">{subentry_sample}</b>]]></string>
+    <string name="_bx_orgs_txt_ntfs_join_request_for_owner"><![CDATA[<b class="bx-ntfs-content-entry">{subentry_sample}</b> sent a join request to your organization]]></string>
     <string name="_bx_orgs_txt_ntfs_timeline_post_common"><![CDATA[New post <b class="bx-ntfs-content-entry">{subentry_sample}</b> in <b class="bx-ntfs-content-profile">{owner_name}</b> organization timeline]]></string>
 
     <string name="_bx_orgs_txt_sample_single"><![CDATA[organization]]></string>

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

@@ -476,6 +476,7 @@
     <string name="_bx_orgs_txt_ntfs_fan_added"><![CDATA[В организацию <b class="bx-ntfs-content-profile">{owner_name}</b> вступил <b class="bx-ntfs-content-entry">{subentry_sample}</b>]]></string>
     <string name="_bx_orgs_txt_ntfs_join_invitation"><![CDATA[Представитель организации <b class="bx-ntfs-content-profile">{owner_name}</b> пригласил <b class="bx-ntfs-content-entry">{subentry_sample}</b> вступить в организацию]]></string>
     <string name="_bx_orgs_txt_ntfs_join_request"><![CDATA[В организацию <b class="bx-ntfs-content-profile">{owner_name}</b> хочет вступить <b class="bx-ntfs-content-entry">{subentry_sample}</b>]]></string>
+    <string name="_bx_orgs_txt_ntfs_join_request_for_owner"><![CDATA[<b class="bx-ntfs-content-entry">{subentry_sample}</b> хочет вступить в вашу организацию]]></string>
     <string name="_bx_orgs_txt_ntfs_timeline_post_common"><![CDATA[В организации <b class="bx-ntfs-content-profile">{owner_name}</b> новая публикация <b class="bx-ntfs-content-entry">{subentry_sample}</b>]]></string>
 
     <string name="_bx_orgs_txt_sample_single"><![CDATA[Организация]]></string>