Răsfoiți Sursa

Ticket #367 - Related changes in core files.

AntonLV 10 ani în urmă
părinte
comite
0b87bf7ef5

+ 8 - 7
inc/classes/BxDolGrid.php

@@ -468,7 +468,7 @@ class BxDolGrid extends BxDol implements iBxDolFactoryObject, iBxDolReplaceable
         return $oDb->getAll($sQuery);
     }
 
-    protected function _getDataSqlOrderClause ($sOrderByFilter, $sOrderField, $sOrderDir)
+    protected function _getDataSqlOrderClause ($sOrderByFilter, $sOrderField, $sOrderDir, $bFieldsOnly = false)
     {
         $sOrderClause = '';
 
@@ -481,34 +481,35 @@ class BxDolGrid extends BxDol implements iBxDolFactoryObject, iBxDolReplaceable
                 // translatable fields
                 $iLang = BxDolLanguages::getInstance()->getCurrentLangId();
                 $oDb = BxDolDb::getInstance();
-                $sOrderClause = $oDb->prepareAsString("ORDER BY (SELECT `s`.`string` FROM `sys_localization_strings` AS `s` INNER JOIN `sys_localization_keys` AS `k` ON (`k`.`ID` = `s`.`IDKey`) WHERE `k`.`KEY` = `$sOrderField` AND `s`.`IDLanguage` = ? LIMIT 1) ", $iLang) . $sDir;
+                $sOrderClause = $oDb->prepareAsString("(SELECT `s`.`string` FROM `sys_localization_strings` AS `s` INNER JOIN `sys_localization_keys` AS `k` ON (`k`.`ID` = `s`.`IDKey`) WHERE `k`.`KEY` = `$sOrderField` AND `s`.`IDLanguage` = ? LIMIT 1) ", $iLang) . $sDir;
 
             } else {
 
                 // regular fields
-                $sOrderClause = " ORDER BY `$sOrderField` $sDir";
+                $sOrderClause = "`" . $sOrderField . "` $sDir";
 
             }
 
         } elseif ($sOrderByFilter) { // order by filter
 
-            $sOrderClause = " ORDER BY $sOrderByFilter DESC";
+            $sOrderClause = $sOrderByFilter . " DESC";
 
         } elseif (!empty($this->_aOptions['field_order'])) { // order by "order" field
 
             if (false == strpos($this->_aOptions['field_order'], ',')) {
-                $sOrderClause = " ORDER BY `" . $this->_aOptions['field_order'] . "` " . $this->_sDefaultSortingOrder;
+                $sOrderClause = "`" . $this->_aOptions['field_order'] . "` " . $this->_sDefaultSortingOrder;
             } else {
                 $a = explode(',', $this->_aOptions['field_order']);
                 foreach ($a as $sField)
                     $sOrderClause .= "`" . trim($sField) . "` " . $this->_sDefaultSortingOrder . ", ";
+
                 if ($sOrderClause)
-                    $sOrderClause = " ORDER BY " . trim($sOrderClause, ', ');
+                    $sOrderClause = trim($sOrderClause, ', ');
             }
 
         }
 
-        return $sOrderClause;
+        return $bFieldsOnly ? $sOrderClause : " ORDER BY " . $sOrderClause;
     }
 
     protected function _getCellData($sKey, $aField, $aRow)

+ 30 - 11
inc/classes/BxDolPrivacy.php

@@ -209,18 +209,8 @@ class BxDolPrivacy extends BxDol implements iBxDolFactoryObject
      */
     public function getContentPublicAsCondition($iProfileIdOwner = 0, $aCustomGroups = array())
     {
-        $mixedPrivacyGroups = array(BX_DOL_PG_ALL);
-        if(isLogged()) {
-            $iProfileIdLogged = bx_get_logged_profile_id();
-            if($iProfileIdLogged == $iProfileIdOwner)
-                return array();
+        $mixedPrivacyGroups = $this->getPrivacyGroupsForContentPublic($iProfileIdOwner, $aCustomGroups);
 
-            if ($iProfileIdOwner && $this->checkFriends($iProfileIdOwner, bx_get_logged_profile_id()))
-                $mixedPrivacyGroups = array(BX_DOL_PG_ALL, BX_DOL_PG_MEMBERS, BX_DOL_PG_FRIENDS);
-            else
-                $mixedPrivacyGroups = array(BX_DOL_PG_ALL, BX_DOL_PG_MEMBERS);
-        }
-        $mixedPrivacyGroups = array_merge($mixedPrivacyGroups, $aCustomGroups);
         return $this->getContentByGroupAsCondition($mixedPrivacyGroups);
     }
 
@@ -235,6 +225,18 @@ class BxDolPrivacy extends BxDol implements iBxDolFactoryObject
         return $this->_oDb->getContentByGroupAsSQLPart($sField, $mixedGroupId);
     }
 
+	/**
+     * Get necessary parts of SQL query to use privacy in other queries
+     * @param $iProfileIdOwner owner profile ID
+     * @return array of SQL string parts, for now 'where' part only is returned
+     */
+    public function getContentPublicAsSQLPart($iProfileIdOwner = 0, $aCustomGroups = array())
+    {
+        $mixedPrivacyGroups = $this->getPrivacyGroupsForContentPublic($iProfileIdOwner, $aCustomGroups);
+
+        return $this->getContentByGroupAsSQLPart($mixedPrivacyGroups);
+    }
+
     /**
      * Check whether the viewer can make requested action.
      *
@@ -287,6 +289,23 @@ class BxDolPrivacy extends BxDol implements iBxDolFactoryObject
         return BxDolConnection::getObjectInstance('sys_profiles_friends')->isConnected($iOwnerId, $iViewerId, true);
     }
 
+	protected function getPrivacyGroupsForContentPublic($iProfileIdOwner = 0, $aCustomGroups = array())
+    {
+    	$mixedPrivacyGroups = array(BX_DOL_PG_ALL);
+        if(isLogged()) {
+            $iProfileIdLogged = bx_get_logged_profile_id();
+            if($iProfileIdLogged == $iProfileIdOwner)
+                return array();
+
+            if ($iProfileIdOwner && $this->checkFriends($iProfileIdOwner, bx_get_logged_profile_id()))
+                $mixedPrivacyGroups = array(BX_DOL_PG_ALL, BX_DOL_PG_MEMBERS, BX_DOL_PG_FRIENDS);
+            else
+                $mixedPrivacyGroups = array(BX_DOL_PG_ALL, BX_DOL_PG_MEMBERS);
+        }
+
+        return array_merge($mixedPrivacyGroups, $aCustomGroups);
+    }
+
     protected function getCheckMethod($s)
     {
         if(substr($s, 0, 1) != '@')

+ 34 - 0
inc/js/functions.js

@@ -6,6 +6,40 @@
  * @{
  */
 
+function processJsonData(oData) {
+	var $this = this;
+
+	if(oData && oData.message != undefined && oData.message.length != 0)
+    	alert(oData.message);
+
+    if(oData && oData.reload != undefined && parseInt(oData.reload) == 1)
+    	document.location = document.location;
+
+    if(oData && oData.popup != undefined) {
+    	var oPopup = null;
+    	var oOptions = {
+            fog: {
+				color: '#fff',
+				opacity: .7
+            },
+            closeOnOuterClick: false
+        };
+
+    	if(typeof(oData.popup) == 'object') {
+    		oOptions = $.extend({}, oOptions, oData.popup.options);
+    		oPopup = $(oData.popup.html);
+    	}
+    	else 
+    		oPopup = $(oData.popup);
+
+    	$('#' + oPopup.attr('id')).remove();
+        oPopup.hide().prependTo('body').dolPopup(oOptions);
+    }
+
+    if (oData && oData.eval != undefined)
+        eval(oData.eval);
+};
+
 function getHtmlData( elem, url, callback, method , confirmation)
 {
     if ('undefined' != typeof(confirmation) && confirmation && !confirm(_t('_are you sure?'))) 

+ 4 - 0
modules/base/text/classes/BxBaseModTextGridCommon.php

@@ -20,7 +20,11 @@ class BxBaseModTextGridCommon extends BxBaseModTextGridAdministration
 
     protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
     {
+    	$CNF = $this->_oModule->_oConfig->CNF;
+
 		$this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `author`=?", bx_get_logged_profile_id());
+		if(!empty($CNF['FIELD_STATUS_ADMIN']))
+			$this->_aOptions['source'] .= " AND `" . $CNF['FIELD_STATUS_ADMIN'] . "`='active'";
 
         return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
     }

+ 8 - 6
modules/base/text/classes/BxBaseModTextTemplate.php

@@ -205,12 +205,14 @@ class BxBaseModTextTemplate extends BxBaseModGeneralTemplate
         if (!$aGhostFiles)
             return false;
 
-        foreach ($aGhostFiles as $k => $a) {
-            // don't show thumbnail in attachments
-            if ($a['id'] == $aData[$CNF['FIELD_THUMB']])
-                unset($aGhostFiles[$k]);
-        }
-        if (!$aGhostFiles)
+		if(isset($aData[$CNF['FIELD_THUMB']]))
+	        foreach ($aGhostFiles as $k => $a) {
+	            // don't show thumbnail in attachments
+	            if ($a['id'] == $aData[$CNF['FIELD_THUMB']])
+	                unset($aGhostFiles[$k]);
+	        }
+
+        if(!$aGhostFiles)
             return false;
 
         foreach ($aGhostFiles as $k => $a) {