Przeglądaj źródła

#281 Groups:
- subscribe admins automatically
- timeline post event re-translator

Alex Trofimov 10 lat temu
rodzic
commit
b5a2ee4efb

+ 8 - 0
modules/boonex/groups/classes/BxGroupsAlertsResponse.php

@@ -19,6 +19,14 @@ class BxGroupsAlertsResponse extends BxDolAlertsResponse
     public function response($oAlert)
     public function response($oAlert)
     {
     {
         $this->_oModule = BxDolModule::getInstance('bx_groups');
         $this->_oModule = BxDolModule::getInstance('bx_groups');
+        $CNF = $this->_oModule->_oConfig->CNF;
+
+        // re-translate timeline alert
+        if ('bx_timeline' == $oAlert->sUnit && 'post_common' == $oAlert->sAction && ($oGroupProfile = BxDolProfile::getInstance($oAlert->aExtras['object_author_id']))) {
+            $aContentInfo = $this->_oModule->serviceGetContentInfoById($oGroupProfile->getContentId());
+            echoDbgLog($aContentInfo);
+            bx_alert($this->_oModule->getName(), 'timeline_post_common', $aContentInfo[$CNF['FIELD_ID']], $oGroupProfile->id(), array('content' => $aContentInfo, 'group_profile' => $oGroupProfile->id(), 'profile' => $oAlert->iSender, 'notification_subobject_id' => $oAlert->iSender, 'object_author_id' => $aContentInfo[$CNF['FIELD_AUTHOR']]));
+        }
 
 
         // connection events
         // connection events
         if ('bx_groups_fans' == $oAlert->sUnit && 'connection_added' == $oAlert->sAction) {
         if ('bx_groups_fans' == $oAlert->sUnit && 'connection_added' == $oAlert->sAction) {

+ 5 - 0
modules/boonex/groups/classes/BxGroupsGridConnections.php

@@ -131,12 +131,17 @@ class BxGroupsGridConnections extends BxDolGridConnections
             $sEmailTemplate = 'toAdmins' == $sFunc ? 'bx_groups_fan_become_admin' : 'bx_groups_admin_become_fan';
             $sEmailTemplate = 'toAdmins' == $sFunc ? 'bx_groups_fan_become_admin' : 'bx_groups_admin_become_fan';
             list($iGroupProfileId, $iProfileId) = $this->_prepareGroupProfileAndMemberProfile($iGroupProfileId, $iId);
             list($iGroupProfileId, $iProfileId) = $this->_prepareGroupProfileAndMemberProfile($iGroupProfileId, $iId);
             if (bx_get_logged_profile_id() != $iProfileId) {
             if (bx_get_logged_profile_id() != $iProfileId) {
+                // notify about admin status
                 sendMailTemplate($sEmailTemplate, 0, $iProfileId, array(
                 sendMailTemplate($sEmailTemplate, 0, $iProfileId, array(
                     'EntryUrl' => BxDolProfile::getInstance($iGroupProfileId)->getUrl(),
                     'EntryUrl' => BxDolProfile::getInstance($iGroupProfileId)->getUrl(),
                     'EntryTitle' => BxDolProfile::getInstance($iGroupProfileId)->getDisplayName(),
                     'EntryTitle' => BxDolProfile::getInstance($iGroupProfileId)->getDisplayName(),
                 ), BX_EMAIL_NOTIFY);
                 ), BX_EMAIL_NOTIFY);
             }
             }
 
 
+            // subscribe admins automatically
+            if ('toAdmins' == $sFunc && ($oConn = BxDolConnection::getObjectInstance('sys_profiles_subscriptions')))
+                $oConn->addConnection($iProfileId, $iGroupProfileId);
+
             echoJson(array('grid' => $this->getCode(false), 'blink' => $iId));
             echoJson(array('grid' => $this->getCode(false), 'blink' => $iId));
         }
         }
     }
     }

+ 12 - 0
modules/boonex/groups/classes/BxGroupsModule.php

@@ -243,17 +243,29 @@ class BxGroupsModule extends BxBaseModProfileModule
                 array('group' => $sModule . '_vote', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'undoVote'),
                 array('group' => $sModule . '_vote', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'undoVote'),
 
 
                 array('group' => $sModule . '_fan_added', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'fan_added', 'module_name' => $sModule, 'module_method' => 'get_notifications_fan_added', 'module_class' => 'Module'),
                 array('group' => $sModule . '_fan_added', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'fan_added', 'module_name' => $sModule, 'module_method' => 'get_notifications_fan_added', 'module_class' => 'Module'),
+
                 array('group' => $sModule . '_join_request', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'join_request', 'module_name' => $sModule, 'module_method' => 'get_notifications_join_request', 'module_class' => 'Module', 'module_event_privacy' => 'bx_groups_allow_view_notification_to'),
                 array('group' => $sModule . '_join_request', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'join_request', 'module_name' => $sModule, 'module_method' => 'get_notifications_join_request', 'module_class' => 'Module', 'module_event_privacy' => 'bx_groups_allow_view_notification_to'),
+                
+                array('group' => $sModule . '_timeline_post_common', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'timeline_post_common', 'module_name' => $sModule, 'module_method' => 'get_notifications_timeline_post_common', 'module_class' => 'Module'),
             ),
             ),
             'alerts' => array(
             'alerts' => array(
                 array('unit' => $sModule, 'action' => 'doVote'),
                 array('unit' => $sModule, 'action' => 'doVote'),
                 array('unit' => $sModule, 'action' => 'undoVote'),
                 array('unit' => $sModule, 'action' => 'undoVote'),
                 array('unit' => $sModule, 'action' => 'fan_added'),
                 array('unit' => $sModule, 'action' => 'fan_added'),
                 array('unit' => $sModule, 'action' => 'join_request'),
                 array('unit' => $sModule, 'action' => 'join_request'),
+                array('unit' => $sModule, 'action' => 'timeline_post_common'),
             )
             )
         );
         );
     }
     }
 
 
+    /**
+     * Notification about new member requst in the group
+     */
+    public function serviceGetNotificationsTimelinePostCommon($aEvent)
+    {
+        return $this->_serviceGetNotification($aEvent, '_bx_groups_txt_ntfs_timeline_post_common');
+    }
+
     /**
     /**
      * Notification about new member requst in the group
      * Notification about new member requst in the group
      */
      */

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

@@ -210,6 +210,7 @@
 
 
     <string name="_bx_groups_txt_ntfs_fan_added"><![CDATA[<a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a> group has got new member - <a href="{subentry_url}">{subentry_sample}</a>]]></string>
     <string name="_bx_groups_txt_ntfs_fan_added"><![CDATA[<a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a> group has got new member - <a href="{subentry_url}">{subentry_sample}</a>]]></string>
     <string name="_bx_groups_txt_ntfs_join_request"><![CDATA[<a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a> group has new request from <a href="{subentry_url}">{subentry_sample}</a>]]></string>
     <string name="_bx_groups_txt_ntfs_join_request"><![CDATA[<a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a> group has new request from <a href="{subentry_url}">{subentry_sample}</a>]]></string>
+    <string name="_bx_groups_txt_ntfs_timeline_post_common"><![CDATA[New post in <a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a> group timeline  from <a href="{subentry_url}">{subentry_sample}</a>]]></string>
 
 
     <string name="_bx_groups_privacy_group_closed"><![CDATA[Closed]]></string>
     <string name="_bx_groups_privacy_group_closed"><![CDATA[Closed]]></string>
     <string name="_bx_groups_privacy_group_secret"><![CDATA[Secret]]></string>
     <string name="_bx_groups_privacy_group_secret"><![CDATA[Secret]]></string>

+ 1 - 0
modules/boonex/groups/install/langs/ru.xml

@@ -209,6 +209,7 @@
 
 
     <string name="_bx_groups_txt_ntfs_fan_added"><![CDATA[В группу "<a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a>" добавился новый член - <a href="{subentry_url}">{subentry_sample}</a>]]></string>
     <string name="_bx_groups_txt_ntfs_fan_added"><![CDATA[В группу "<a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a>" добавился новый член - <a href="{subentry_url}">{subentry_sample}</a>]]></string>
     <string name="_bx_groups_txt_ntfs_join_request"><![CDATA[В группу "<a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a>" хочет присоединиться новый член - <a href="{subentry_url}">{subentry_sample}</a>]]></string>
     <string name="_bx_groups_txt_ntfs_join_request"><![CDATA[В группу "<a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a>" хочет присоединиться новый член - <a href="{subentry_url}">{subentry_sample}</a>]]></string>
+    <string name="_bx_groups_txt_ntfs_timeline_post_common"><![CDATA[В группе <a class="bx-ntfs-content-profile" href="{owner_link}">{owner_name}</a> новая публикация от <a href="{subentry_url}">{subentry_sample}</a>]]></string>
 
 
     <string name="_bx_groups_privacy_group_closed"><![CDATA[Закрытая группа]]></string>
     <string name="_bx_groups_privacy_group_closed"><![CDATA[Закрытая группа]]></string>
     <string name="_bx_groups_privacy_group_secret"><![CDATA[Секретная группа]]></string>
     <string name="_bx_groups_privacy_group_secret"><![CDATA[Секретная группа]]></string>

+ 1 - 0
modules/boonex/groups/install/sql/enable.sql

@@ -372,6 +372,7 @@ INSERT INTO `sys_alerts_handlers` (`name`, `class`, `file`, `service_call`) VALU
 SET @iHandler := LAST_INSERT_ID();
 SET @iHandler := LAST_INSERT_ID();
 
 
 INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
+('bx_timeline', 'post_common', @iHandler),
 ('bx_groups_fans', 'connection_added', @iHandler),
 ('bx_groups_fans', 'connection_added', @iHandler),
 ('bx_groups_fans', 'connection_removed', @iHandler),
 ('bx_groups_fans', 'connection_removed', @iHandler),
 ('profile', 'delete', @iHandler),
 ('profile', 'delete', @iHandler),