Просмотр исходного кода

Ticket #5018 - Jobs: Author shouldn't be listed as assignee.

AntonLV 1 год назад
Родитель
Сommit
335a63c300

+ 56 - 25
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -236,6 +236,7 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
             'GetQuestionnaire' => '',
             'GetInitialMembers' => '',
             'EntityInvite' => '',
+            'FansWithoutAdmins' => '',
         ]);
     }
 
@@ -540,7 +541,7 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
             ]);
         }
         // send notification to group's admins that new connection is pending confirmation 
-        elseif (!$bSendInviteOnly && $oConnection->isConnected((int)$iInitiatorId, $oGroupProfile->id()) && !$oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId) && $aContentInfo['join_confirmation']) {
+        elseif (!$bSendInviteOnly && $oConnection->isConnected((int)$iInitiatorId, $oGroupProfile->id()) && !$oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId) && $aContentInfo['join_confirmation'] && $aContentInfo[$CNF['FIELD_AUTHOR']] != $iProfileId) {
             /**
              * @hooks
              * @hookdef hook-bx_base_groups-join_request '{module_name}', 'join_request' - hook before adding new join to context request
@@ -601,23 +602,25 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
                  $this->addFollower((int)$iInitiatorId, $oGroupProfile->id()); 
             }
 
-            /**
-             * @hooks
-             * @hookdef hook-bx_base_groups-fan_added '{module_name}', 'fan_added' - hook before adding (registering) new context member
-             * It's equivalent to @ref hook-bx_base_groups-join_request
-             * @hook @ref hook-bx_base_groups-fan_added
-             */
-            bx_alert($this->getName(), 'fan_added', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, [
-            	'object_author_id' => $iGroupProfileId,
-            	'performer_id' => $iProfileId,
-
-            	'content' => $aContentInfo,
-            	'entry_title' => $sEntryTitle, 
-            	'entry_url' => $sEntryUrl,
-
-            	'group_profile' => $iGroupProfileId, 
-            	'profile' => $iProfileId,
-            ]);
+            if ($aContentInfo[$CNF['FIELD_AUTHOR']] != $iProfileId) {
+                /**
+                 * @hooks
+                 * @hookdef hook-bx_base_groups-fan_added '{module_name}', 'fan_added' - hook before adding (registering) new context member
+                 * It's equivalent to @ref hook-bx_base_groups-join_request
+                 * @hook @ref hook-bx_base_groups-fan_added
+                 */
+                bx_alert($this->getName(), 'fan_added', $aContentInfo[$CNF['FIELD_ID']], $iGroupProfileId, [
+                    'object_author_id' => $iGroupProfileId,
+                    'performer_id' => $iProfileId,
+
+                    'content' => $aContentInfo,
+                    'entry_title' => $sEntryTitle, 
+                    'entry_url' => $sEntryUrl,
+
+                    'group_profile' => $iGroupProfileId, 
+                    'profile' => $iProfileId,
+                ]);
+            }
 
             $this->doAudit($iGroupProfileId, $iInitiatorId, '_sys_audit_action_group_join_request_accepted');
             
@@ -768,15 +771,43 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
             return false;
 
         $aAdmins = $this->_oDb->getAdmins($oGroupProfile->id());
-        if(!empty($aAdmins) && is_array($aAdmins))
-            $aFans = array_diff($aFans, $aAdmins);
+        if(!empty($aAdmins) && is_array($aAdmins) && !($aFans = array_diff($aFans, $aAdmins)))
+            return false;
 
-        $iStart = (int)bx_get('start');
-        $iLimit = !empty($CNF['PARAM_NUM_CONNECTIONS_QUICK']) ? getParam($CNF['PARAM_NUM_CONNECTIONS_QUICK']) : 4;
-        if(!$iLimit)
-            $iLimit = 4;
+        if(!$this->_bIsApi && $bAsArray)
+            return $aFans;
+
+        $iStart = $iLimit = 0;
+        if($this->_bIsApi) {
+            $aParams = bx_api_get_browse_params($bAsArray);
+
+            $iStart = isset($aParams['start']) ? (int)$aParams['start'] : 0;
+            $iLimit = isset($aParams['per_page']) ? (int)$aParams['per_page'] : 0;
+        }
+        else {
+            $iStart = (int)bx_get('start');
+            $iLimit = (int)bx_get('per_page');
+        }
+
+        $iLimit = !$iLimit && ($sKey = 'PARAM_NUM_CONNECTIONS_QUICK') && !empty($CNF[$sKey]) && ($iValue = (int)getParam($CNF[$sKey])) ? $iValue : 4;
 
-        return $this->_serviceBrowseQuick($aFans, $iStart, $iLimit);
+        if($this->_bIsApi) {
+            $aData = [
+                'data' => [],
+                'request_url' => '/api.php?r=' . $this->_oConfig->getName() . '/fans_without_admins/&params[]=' . $iContentId . '&params[]=',
+                'params' => [
+                    'start' => $iStart,
+                    'per_page' => $iLimit
+                ]
+            ];
+
+            foreach($aProfiles as $iProfileId)
+                $aData['data'][] = BxDolProfile::getData($iProfileId);
+
+            return [bx_api_get_block('profiles_list', $aData)];
+        }
+        else
+            return $this->_serviceBrowseQuick($aFans, $iStart, $iLimit);
     }
 
     public function serviceAdmins ($iContentId = 0, $sParams = '')

+ 35 - 0
modules/boonex/jobs/classes/BxJobsConnectionFans.php

@@ -20,6 +20,41 @@ class BxJobsConnectionFans extends BxBaseModGroupsConnectionFans
         $this->_bBan = true;
         $this->_bQuestionnaire = true;
     }
+    
+    public function getConnectedInitiatorsCount($iContent, $isMutual = false)
+    {
+        $iResult = parent::getConnectedInitiatorsCount($iContent, $isMutual);
+
+        if(($aAdmins = $this->_oModule->_oDb->getAdmins($iContent)) && is_array($aAdmins) && ($iAdmins = count($aAdmins)) > 0)
+            $iResult -= $iAdmins;
+
+        return $iResult;
+    }
+
+    public function getConnectedInitiators($iContent, $isMutual = false, $iStart = 0, $iLimit = BX_CONNECTIONS_LIST_LIMIT, $iOrder = BX_CONNECTIONS_ORDER_NONE)
+    {
+        $aResults = parent::getConnectedInitiators($iContent, $isMutual, $iStart, $iLimit, $iOrder);
+
+        if(($aAdmins = $this->_oModule->_oDb->getAdmins($iContent)) && is_array($aAdmins))
+            $aResults = array_diff($aResults, $aAdmins);
+
+        return $aResults;
+    }
+
+    public function getConnectedContentAsCondition($sContentField, $iInitiator, $iMutual = false)
+    {
+        $aResults = parent::getConnectedContentAsCondition($sContentField, $iInitiator, $iMutual);
+
+        if(($aAdmins = $this->_oModule->_oDb->getAdmins($iInitiator)) && is_array($aAdmins))
+            $aResults['restriction']['connections_exclude_' . $this->_sObject] = [
+                'value' => $aAdmins,
+                'field' => 'content',
+                'operator' => 'not in',
+                'table' => $this->_aObject['table'],
+            ];
+
+        return $aResults;
+    }
 }
 
 /** @} */

+ 2 - 2
modules/boonex/jobs/install/sql/enable.sql

@@ -46,8 +46,8 @@ INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `t
 ('bx_jobs_view_profile', 1, 'bx_jobs', '', '_bx_jobs_page_block_title_profile_description', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:7:"bx_jobs";s:6:"method";s:17:"entity_text_block";}', 0, 0, 1, 1, 3),
 ('bx_jobs_view_profile', 3, 'bx_jobs', '', '_bx_jobs_page_block_title_profile_location', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:7:"bx_jobs";s:6:"method";s:15:"entity_location";}', 0, 0, 0, 0, 0),
 ('bx_jobs_view_profile', 3, 'bx_jobs', '', '_bx_jobs_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:"module";s:7:"bx_jobs";s:6:"method";s:14:"entity_context";}', 0, 0, 1, 0, 1),
-('bx_jobs_view_profile', 3, 'bx_jobs', '', '_bx_jobs_page_block_title_fans', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:7:"bx_jobs";s:6:"method";s:4:"fans";}', 0, 0, 1, 0, 3),
-('bx_jobs_view_profile', 3, 'bx_jobs', '', '_bx_jobs_page_block_title_admins', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:7:"bx_jobs";s:6:"method";s:6:"admins";}', 0, 0, 1, 0, 4),
+('bx_jobs_view_profile', 3, 'bx_jobs', '', '_bx_jobs_page_block_title_admins', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:7:"bx_jobs";s:6:"method";s:6:"admins";}', 0, 0, 1, 0, 3),
+('bx_jobs_view_profile', 3, 'bx_jobs', '', '_bx_jobs_page_block_title_fans', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:7:"bx_jobs";s:6:"method";s:19:"fans_without_admins";}', 0, 0, 1, 0, 4),
 ('bx_jobs_view_profile', 3, 'bx_jobs', '', '_bx_jobs_page_block_title_profile_location', 3, 2147483647, 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:13:"locations_map";s:6:"params";a:2:{i:0;s:7:"bx_jobs";i:1;s:12:"{content_id}";}s:5:"class";s:20:"TemplServiceMetatags";}', 0, 0, 1, 0, 5),
 ('bx_jobs_view_profile', 4, 'bx_jobs', '', '_bx_jobs_page_block_title_profile_comments', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:7:"bx_jobs";s:6:"method";s:15:"entity_comments";}', 0, 0, 0, 0, 0),
 ('bx_jobs_view_profile', 4, 'bx_jobs', '', '_bx_jobs_page_block_title_entry_reports', 11, 2147483647, 'service', 'a:2:{s:6:"module";s:7:"bx_jobs";s:6:"method";s:14:"entity_reports";}', 0, 0, 1, 0, 1);