AntonLV há 8 anos atrás
pai
commit
c5d01191ca

+ 30 - 0
inc/classes/BxDolProfileQuery.php

@@ -86,6 +86,36 @@ class BxDolProfileQuery extends BxDolDb implements iBxDolSingleton
         return $mixedResult;
     }
 
+    public function getConnectedProfilesByType ($aSqlParts, $sType, $iStart, $iLimit)
+    {
+        if(empty($aSqlParts['join']))
+            return array();
+
+        $aBindings = array();
+
+        $sSelectClause = '';
+        if(!empty($aSqlParts['fields']))
+            foreach($aSqlParts['fields'] as $sName => $sField)
+                $sSelectClause .= ', ' . $sField;
+
+        $sWhereClause = '';
+        if(!empty($sType)) {
+            $sWhereClause = ' AND `sys_profiles`.`type`=:type';
+
+            $aBindings['type'] = $sType;
+        }
+
+        $sOrderClause = '';
+        if(!empty($aSqlParts['fields']['added']))
+            $sOrderClause = ' ORDER BY ' . $aSqlParts['fields']['added'] . ' DESC';
+
+        $sLimitClause = '';
+        if(!empty($iLimit))
+            $sLimitClause = $this->prepareAsString(' LIMIT ?, ?', $iStart, $iLimit);
+
+        return $this->getAllWithKey("SELECT `sys_profiles`.*" . $sSelectClause . " FROM `sys_profiles` " . $aSqlParts['join'] . " WHERE 1" . $sWhereClause . $sOrderClause . $sLimitClause, 'id', $aBindings);
+    }
+
     /**
      * Insert account and content id association. Also if currect profile id is not defined - it updates current profile id in account.
      * @param $iAccountId account id

+ 77 - 7
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -474,6 +474,69 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         return $this->_serviceBrowseQuick($a, $iStart, $iLimit);
     }
 
+    public function serviceBrowseConnectionsByType ($aParamsCnn, $aParamsBrs = array())
+    {
+        $sAll = 'all';
+
+        $aParamsCnn['object'] = !empty($aParamsCnn['object']) ? $aParamsCnn['object'] : 'sys_profiles_friends';
+        $aParamsCnn['type'] = !empty($aParamsCnn['type']) ? $aParamsCnn['type'] : 'content';
+        $aParamsCnn['profile_id2'] = !empty($aParamsCnn['profile_id2']) ? (int)$aParamsCnn['profile_id2'] : 0;
+        $aParamsCnn['mutual'] = isset($aParamsCnn['mutual']) ? $aParamsCnn['mutual'] : false;
+
+        $oConnection = BxDolConnection::getObjectInstance($aParamsCnn['object']);
+        if(!$oConnection)
+            return '';
+
+        $aSQLParts = $oConnection->getConnectionsAsSQLParts ($aParamsCnn['type'], 'sys_profiles', 'id', $aParamsCnn['profile_id'], $aParamsCnn['profile_id2'], $aParamsCnn['mutual']);
+
+        $sType = !empty($aParamsBrs['type']) ? $aParamsBrs['type'] : $sAll;
+        if(bx_get('type') !== false)
+            $sType = bx_process_input(bx_get('type'));
+
+        $iStart = (int)bx_get('start');
+
+        $iLimitDefault = 4;
+        $iLimit = !empty($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']) ? getParam($this->_oConfig->CNF['PARAM_NUM_CONNECTIONS_QUICK']) : $iLimitDefault;
+        if(!empty($aParamsBrs['per_page']))
+            $iLimit = (int)$aParamsBrs['per_page'];
+        if(!$iLimit)
+            $iLimit = $iLimitDefault;
+
+        $aProfiles = BxDolProfileQuery::getInstance()->getConnectedProfilesByType($aSQLParts, ($sType != $sAll ? $sType : ''), $iStart, $iLimit + 1);
+
+        $mixedMenu = '';
+        if(!isset($aParamsBrs['filter_menu']) || $aParamsBrs['filter_menu'] === true) {
+            $aModules = array(
+                array('name' => $sAll)
+            );
+            $aModules = array_merge($aModules, BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1)));
+
+            $aMenuItems = array();
+            foreach($aModules as $aModule)
+                if($aModule['name'] == $sAll || BxDolRequest::serviceExists($aModule['name'], 'act_as_profile'))
+                    $aMenuItems[] = array(
+                    	'id' => $aModule['name'], 
+                    	'name' => $aModule['name'], 
+                    	'class' => '', 
+                    	'link' => 'javascript:void(0)', 
+                    	'onclick' => "return !loadDynamicBlockAutoPaginate(this, " . $iStart . ", " . $iLimit . ", " . bx_js_string(json_encode(array('type' => $aModule['name']))) . ");", 
+                    	'target' => '_self', 
+                    	'title' => _t('_' . $aModule['name']), 
+                    	'active' => 1
+                    );
+    
+            if(!empty($aMenuItems)) {
+                $mixedMenu = new BxTemplMenu(array('template' => 'menu_vertical.html', 'menu_id'=> $this->_oConfig->getName() . '-connections-by-type', 'menu_items' => $aMenuItems));
+                $mixedMenu->setSelected('', $sType);
+            }
+        }
+
+        return array(
+            'menu' => $mixedMenu,
+            'content' => $this->_serviceBrowseQuick(array_keys($aProfiles), $iStart, $iLimit, array('type' => $sType))
+        );
+    }
+
 	public function serviceBrowseByAcl ($mixedLevelId, $iDesignBox = BX_DB_PADDING_DEF)
     {
         return $this->_serviceBrowse (
@@ -560,7 +623,7 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         return $s;
     }
 
-    public function serviceProfileSubscriptions ($iContentId = 0)
+    public function serviceProfileSubscriptions ($iContentId = 0, $aParams = array())
     {
         $mixedContent = $this->_getContent($iContentId);
         if($mixedContent === false)
@@ -569,11 +632,18 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         list($iContentId, $aContentInfo) = $mixedContent;
 
         bx_import('BxDolConnection');
-        $s = $this->serviceBrowseConnectionsQuick ($aContentInfo['profile_id'], 'sys_profiles_subscriptions', BX_CONNECTIONS_CONTENT_TYPE_CONTENT);
-        if (!$s)
-            return MsgBox(_t('_sys_txt_empty'));
+        $aResult = $this->serviceBrowseConnectionsByType(array(
+        	'profile_id' => $aContentInfo['profile_id'],  
+        	'object' => 'sys_profiles_subscriptions', 
+            'type' => BX_CONNECTIONS_CONTENT_TYPE_CONTENT
+        ), array(
+            'type' => isset($aParams['type']) ? $aParams['type'] : '',
+            'filter_menu' => isset($aParams['filter_menu']) ? $aParams['filter_menu'] : true,
+        ));
+        if(empty($aResult['content']))
+            $aResult['content'] = MsgBox(_t('_sys_txt_empty'));
 
-        return $s;
+        return $aResult;
     }
 
     public function serviceProfileSubscribedMe ($iContentId = 0)
@@ -1003,11 +1073,11 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         return $aParams;
     }
 
-    protected function _serviceBrowseQuick($aProfiles, $iStart = 0, $iLimit = 4)
+    protected function _serviceBrowseQuick($aProfiles, $iStart = 0, $iLimit = 4, $aAdditionalParams = array())
     {
         // get paginate object
         $oPaginate = new BxTemplPaginate(array(
-            'on_change_page' => "return !loadDynamicBlockAutoPaginate(this, '{start}', '{per_page}');",
+            'on_change_page' => "return !loadDynamicBlockAutoPaginate(this, '{start}', '{per_page}', " . bx_js_string(json_encode($aAdditionalParams)) . ");",
             'num' => count($aProfiles),
             'per_page' => $iLimit,
             'start' => $iStart,

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

@@ -8,6 +8,7 @@
 	<string name="_ATT_UNCONFIRMED_E"><![CDATA[You will need to follow the link supplied in the e-mail to get your account submitted for approval. <br />Send me <a target=_blank href="activation_email.php">confirmation e-mail</a>.]]></string>
 	<string name="_Access denied"><![CDATA[Access denied]]></string>
 	<string name="_Action"><![CDATA[Action]]></string>
+	<string name="_all"><![CDATA[All]]></string>
 	<string name="_Allowed Since"><![CDATA[Allowed Since]]></string>
 	<string name="_Allowed Until"><![CDATA[Allowed Until]]></string>
 	<string name="_Allowed actions"><![CDATA[Allowed actions]]></string>

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

@@ -8,6 +8,7 @@
 	<string name="_ATT_UNCONFIRMED_E"><![CDATA[Вам нужно нажать на ссылку, присланную в эл. сообщении, чтобы запросить активацию своего аккаунта. <br />Прислать мне <a target=_blank href="activation_email.php">письмо с подтверждением</a>.]]></string>
 	<string name="_Access denied"><![CDATA[Доступ запрещён]]></string>
 	<string name="_Action"><![CDATA[Действие]]></string>
+	<string name="_all"><![CDATA[Все]]></string>
 	<string name="_Allowed Since"><![CDATA[Разрешено с]]></string>
 	<string name="_Allowed Until"><![CDATA[Разрешено до]]></string>
 	<string name="_Allowed actions"><![CDATA[Разрешённые действия]]></string>