AntonLV 10 yıl önce
ebeveyn
işleme
cf59ac56dd

+ 52 - 0
inc/classes/BxDolAcl.php

@@ -128,6 +128,58 @@ class BxDolAcl extends BxDol implements iBxDolSingleton
         return $GLOBALS['bxDolClasses'][__CLASS__];
     }
 
+	/**
+     * Get necessary condition array to use membership level in search classes
+     * @param $sContentField content table field name
+     * @param $mixedLevelId level ID or array of level IDs
+     * @return array of conditions is returned
+     */
+    public function getContentByLevelAsCondition($sContentField, $mixedLevelId)
+    {
+        return array(
+        	'restriction_sql' => ' AND (`tlm`.DateStarts IS NULL OR `tlm`.DateStarts <= NOW()) AND (`tlm`.DateExpires IS NULL OR `tlm`.DateExpires > NOW())',
+            'restriction' => array (
+                'acl_members' => array(
+                    'value' => $mixedLevelId,
+                    'field' => 'IDLevel',
+                    'operator' => is_array($mixedLevelId) ? 'in' : '=',
+                    'table' => 'tlm',
+                ),
+            ),
+            'join' => array (
+                'acl_members' => array(
+                    'type' => 'INNER',
+                    'table' => 'sys_acl_levels_members',
+                    'table_alias' => 'tlm',
+                    'mainField' => $sContentField,
+                    'onField' => 'IDMember',
+                    'joinFields' => array(),
+                ),
+                'acl_levels' => array(
+                    'type' => 'INNER',
+                    'table' => 'sys_acl_levels',
+                    'table_alias' => 'tl',
+                    'mainTable' => 'tlm',
+                    'mainField' => 'IDLevel',
+                    'onField' => 'ID',
+                    'joinFields' => array(),
+                ),
+            ),
+        );
+    }
+
+	/**
+     * Get necessary parts of SQL query to use membership levels in other queries
+     * @param $sContentTable content table name
+     * @param $sContentField content table field name
+     * @param $mixedLevelId level ID or array of level IDs
+     * @return array of SQL string parts, for now 'where' part only is returned
+     */
+    public function getContentByLevelAsSQLPart($sContentTable, $sContentField, $mixedLevelId)
+    {
+        return $this->oDb->getContentByLevelAsSQLPart($sContentTable, $sContentField, $mixedLevelId);
+    }
+
     /**
      * Check if member has one of the provided membership levels
      * @param $iPermissions - integer value to check permissions for, every bit is matched with some membership id

+ 19 - 0
inc/classes/BxDolAclQuery.php

@@ -356,6 +356,25 @@ class BxDolAclQuery extends BxDolDb implements iBxDolSingleton
         $sQuery = $this->prepare("DELETE FROM `sys_acl_actions_track` WHERE `IDMember` = ?", (int)$iMemberId);
 	    return $this->query($sQuery);
     }
+
+	function getContentByLevelAsSQLPart($sContentTable, $sContentField, $mixedLevelId)
+    {
+    	$sJoin = $sWhere = ""; 
+
+        if(is_array($mixedLevelId))
+            $sWhere .= " AND `tlm`.`IDLevel` IN (" . $this->implode_escape($mixedLevelId) . ")";
+        else
+            $sWhere .= $this->prepareAsString(" AND `tlm`.`IDLevel` = ?", (int)$mixedLevelId);
+		$sWhere .= " AND (`tlm`.DateStarts IS NULL OR `tlm`.DateStarts <= NOW()) AND (`tlm`.DateExpires IS NULL OR `tlm`.DateExpires > NOW())";
+
+		$sJoin .= " INNER JOIN `sys_acl_levels_members` AS `tlm` ON `" . $sContentTable . "`.`" . $sContentField . "`=`tlm`.`IDMember`";
+		$sJoin .= " INNER JOIN `sys_acl_levels` AS `tl` ON `tlm`.`IDLevel`=`tl`.`ID`"; 
+
+        return array(
+            'where' => $sWhere,
+        	'join' => $sJoin
+        );
+    }
 }
 
 /** @} */

+ 12 - 0
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -280,6 +280,18 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolPro
         return $s . (!$iStart && $oPaginate->getNum() <= $iLimit ?  '' : $oPaginate->getSimplePaginate());
     }
 
+	public function serviceBrowseByAcl ($mixedLevelId, $iDesignBox = BX_DB_PADDING_DEF)
+    {
+        return $this->_serviceBrowse (
+            'acl',
+            array(
+                'level' => $mixedLevelId,
+			),
+            $iDesignBox,
+            true
+        );
+    }
+
     public function serviceEntityEditCover ($iContentId = 0)
     {
         return $this->_serviceEntityForm ('editDataForm', $iContentId, $this->_oConfig->CNF['OBJECT_FORM_ENTRY_DISPLAY_EDIT_COVER']);

+ 26 - 0
modules/base/profile/classes/BxBaseModProfileSearchResult.php

@@ -30,6 +30,32 @@ class BxBaseModProfileSearchResult extends BxBaseModGeneralSearchResult
         $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $a['restriction']);
         $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
 
+        return true;
+    }
+
+	protected function _setAclConditions ($aParams)
+    {
+        $oAcl =  BxDolAcl::getInstance();
+        if(!$oAcl || empty($aParams['level']))
+            return false;
+
+		if(!is_array($aParams['level']))
+			$aParams['level'] = array($aParams['level']);
+
+		$this->aCurrent['title'] = array();
+		foreach($aParams['level'] as $iLevelId) {
+			$aInfo = $oAcl->getMembershipInfo($iLevelId);
+			if(empty($aInfo) || !is_array($aInfo))
+				continue;
+
+			$this->aCurrent['title'][] = _t($aInfo['name']);
+		}
+
+        $aCondition = $oAcl->getContentByLevelAsCondition('id', $aParams['level']);        
+        $this->aCurrent['restriction_sql'] = (!empty($this->aCurrent['restriction_sql']) ? $this->aCurrent['restriction_sql'] : '') . $aCondition['restriction_sql'];
+        $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aCondition['restriction']);
+        $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $aCondition['join']);
+
         return true;
     }
 }

+ 7 - 0
modules/boonex/organizations/classes/BxOrgsSearchResult.php

@@ -85,6 +85,13 @@ class BxOrgsSearchResult extends BxBaseModProfileSearchResult
 
                     $this->aCurrent['rss']['link'] = 'modules/?r=orgs/rss/' . $sMode . '/' . $aParams['object'] . '/' . $aParams['type'] . '/' . (int)$aParams['profile'] . '/' . (int)$aParams['profile2'] . '/' . (int)$aParams['mutual'];
                 }
+                break;
+
+			case 'acl':
+                if ($this->_setAclConditions($aParams)) {
+					$this->aCurrent['title'] = _t('_bx_orgs_page_title_browse_by_acl', implode(', ', $this->aCurrent['title']));
+                    unset($this->aCurrent['rss']);
+                }
                 break;
 
             case 'recent':

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

@@ -57,6 +57,7 @@
 	<string name="_bx_orgs_page_title_browse_recent"><![CDATA[New Organizations]]></string>
 	<string name="_bx_orgs_page_title_browse_connections"><![CDATA[{0} connections]]></string>
 	<string name="_bx_orgs_page_title_browse_connections_mutual"><![CDATA[{0} and {1} mutual connections]]></string>
+	<string name="_bx_orgs_page_title_browse_by_acl"><![CDATA[{0} Organizations]]></string>
 	<string name="_bx_orgs_page_title_sys_profile_friends"><![CDATA[Friends]]></string>
 	<string name="_bx_orgs_page_title_profile_friends"><![CDATA[Friends]]></string>
 	<string name="_bx_orgs_page_title_sys_profile_info"><![CDATA[Profile Info]]></string>

+ 7 - 0
modules/boonex/persons/classes/BxPersonsSearchResult.php

@@ -85,6 +85,13 @@ class BxPersonsSearchResult extends BxBaseModProfileSearchResult
 
                     $this->aCurrent['rss']['link'] = 'modules/?r=persons/rss/' . $sMode . '/' . $aParams['object'] . '/' . $aParams['type'] . '/' . (int)$aParams['profile'] . '/' . (int)$aParams['profile2'] . '/' . (int)$aParams['mutual'];
                 }
+                break;
+
+			case 'acl':
+                if ($this->_setAclConditions($aParams)) {
+					$this->aCurrent['title'] = _t('_bx_persons_page_title_browse_by_acl', implode(', ', $this->aCurrent['title']));
+                    unset($this->aCurrent['rss']);
+                }
                 break;
 
             case 'recent':

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

@@ -55,6 +55,7 @@
 	<string name="_bx_persons_page_title_browse_recent"><![CDATA[New People]]></string>
 	<string name="_bx_persons_page_title_browse_connections"><![CDATA[{0} connections]]></string>
 	<string name="_bx_persons_page_title_browse_connections_mutual"><![CDATA[{0} and {1} mutual connections]]></string>
+	<string name="_bx_persons_page_title_browse_by_acl"><![CDATA[{0} People]]></string>
 	<string name="_bx_persons_page_title_sys_profile_friends"><![CDATA[Friends]]></string>
 	<string name="_bx_persons_page_title_profile_friends"><![CDATA[Friends]]></string>
 	<string name="_bx_persons_page_title_sys_profile_info"><![CDATA[Profile Info]]></string>

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

@@ -57,6 +57,7 @@
 	<string name="_bx_orgs_page_title_browse_recent"><![CDATA[Последние Добавленные Организации]]></string>
 	<string name="_bx_orgs_page_title_browse_connections"><![CDATA[{0} связей]]></string>
 	<string name="_bx_orgs_page_title_browse_connections_mutual"><![CDATA[{0} и {1} обоюдных связей]]></string>
+	<string name="_bx_orgs_page_title_browse_by_acl"><![CDATA[Организации уровня {0}]]></string>
 	<string name="_bx_orgs_page_title_sys_profile_friends"><![CDATA[Друзья]]></string>
 	<string name="_bx_orgs_page_title_profile_friends"><![CDATA[Друзья]]></string>
 	<string name="_bx_orgs_page_title_sys_profile_info"><![CDATA[Инфо профиля]]></string>

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

@@ -55,6 +55,7 @@
 	<string name="_bx_persons_page_title_browse_recent"><![CDATA[Последние Присоединившиеся Пользователи]]></string>
 	<string name="_bx_persons_page_title_browse_connections"><![CDATA[{0} связей]]></string>
 	<string name="_bx_persons_page_title_browse_connections_mutual"><![CDATA[{0} и {1} обоюдных связей]]></string>
+	<string name="_bx_persons_page_title_browse_by_acl"><![CDATA[Пользователи уровня {0}]]></string>
 	<string name="_bx_persons_page_title_sys_profile_friends"><![CDATA[Друзья]]></string>
 	<string name="_bx_persons_page_title_profile_friends"><![CDATA[Друзья]]></string>
 	<string name="_bx_persons_page_title_sys_profile_info"><![CDATA[Инфо профиля]]></string>