Sfoglia il codice sorgente

Ticket #1347 - Improvements.

AntonLV 7 anni fa
parent
commit
7230da5f4f

+ 7 - 5
inc/js/classes/BxDolCreatePost.js

@@ -11,6 +11,7 @@ function BxDolCreatePost(oOptions) {
     this._sRootUrl = oOptions.sRootUrl == undefined ? sUrlRoot : oOptions.sRootUrl;
     this._sDefault = oOptions.sDefault == undefined ? '' : oOptions.sDefault;
     this._iContextId = oOptions.iContextId == undefined ? 0 : oOptions.iContextId;
+    this._oCustom = oOptions.oCustom == undefined ? {} : oOptions.oCustom;
 
     this._sAnimationEffect = oOptions.sAnimationEffect == undefined ? 'fade' : oOptions.sAnimationEffect;
     this._iAnimationSpeed = oOptions.iAnimationSpeed == undefined ? 'slow' : oOptions.iAnimationSpeed;
@@ -34,11 +35,12 @@ BxDolCreatePost.prototype.getForm = function (sModuleName, sModuleUri,  oElement
 
 	$.get(
 		this._sRootUrl + 'modules/?r=' + sModuleUri + '/get_create_post_form/', {
-			ajax_mode: true,
-			dynamic_mode: true,
-			absolute_action_url: true,
-			context_id: this._iContextId,
-	    	_t:oDate.getTime()
+                    ajax_mode: true,
+                    dynamic_mode: true,
+                    absolute_action_url: true,
+                    context_id: this._iContextId,
+                    custom: this._oCustom,
+                    _t:oDate.getTime()
 		},
 		function(oData) {
 			$this._loadingInBlock(oElement, false);

+ 26 - 18
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -36,6 +36,7 @@ class BxBaseModGeneralModule extends BxDolModule
             'absolute_action_url' => false,
             'visibility_autoselect' => false,
             'context_id' => 0,
+            'custom' => array()
         );
     }
 
@@ -54,11 +55,11 @@ class BxBaseModGeneralModule extends BxDolModule
 
     	$sForm = $this->serviceGetCreatePostForm($aParams);
     	if(empty($sForm))
-    		return echoJson(array());
+            return echoJson(array());
 
-	   	return echoJson(array(
-    		'module' => $this->_oConfig->getName(),
-    		'content' => $sForm
+        return echoJson(array(
+            'module' => $this->_oConfig->getName(),
+            'content' => $sForm
     	));
     }
 
@@ -69,7 +70,7 @@ class BxBaseModGeneralModule extends BxDolModule
 
     	$oForm = $this->serviceGetObjectForm('add', $aParams);
     	if(!$oForm)
-    		return ''; 	
+            return ''; 	
 
     	return $this->serviceEntityCreate($aParams);
     }
@@ -422,7 +423,7 @@ class BxBaseModGeneralModule extends BxDolModule
         if (!in_array($sType, array('add', 'edit', 'view', 'delete')))
             return false;
 
-		$CNF = &$this->_oConfig->CNF;
+        $CNF = &$this->_oConfig->CNF;
 
         bx_import('FormsEntryHelper', $this->_aModule);
         $sClass = $this->_aModule['class_prefix'] . 'FormsEntryHelper';
@@ -435,24 +436,31 @@ class BxBaseModGeneralModule extends BxDolModule
 
         $sParamsKey = 'absolute_action_url';
         if(isset($aParams[$sParamsKey]) && (bool)$aParams[$sParamsKey] === true) {
-        	$sKeyUri = 'URI_' . strtoupper($sType) . '_ENTRY';
-        	if(!empty($this->_oConfig->CNF[$sKeyUri]))
-        		$oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $this->_oConfig->CNF[$sKeyUri]);
+            $sKeyUri = 'URI_' . strtoupper($sType) . '_ENTRY';
+            if(!empty($this->_oConfig->CNF[$sKeyUri]))
+                $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $this->_oConfig->CNF[$sKeyUri]);
         }
 
         $sParamsKey = 'ajax_mode';
         if(isset($aParams[$sParamsKey]) && is_bool($aParams[$sParamsKey]))
         	$oForm->setAjaxMode((bool)$aParams[$sParamsKey]);
 
-		$sKey = 'FIELD_ALLOW_VIEW_TO';
-		if(!empty($aParams['context_id']) && !empty($CNF[$sKey]) && !empty($oForm->aInputs[$CNF[$sKey]])) {
-			foreach($oForm->aInputs[$CNF[$sKey]]['values'] as $aValue)
-				if(isset($aValue['key']) && (int)$aValue['key'] == -(int)$aParams['context_id']) {
-					$oForm->aInputs[$CNF[$sKey]]['value'] = -(int)$aParams['context_id'];
-					$oForm->aInputs[$CNF[$sKey]]['type'] = 'hidden';
-					break;
-				}
-		}
+        $sKey = 'FIELD_ALLOW_VIEW_TO';
+        if(!empty($aParams['context_id']) && !empty($CNF[$sKey]) && !empty($oForm->aInputs[$CNF[$sKey]])) {
+            foreach($oForm->aInputs[$CNF[$sKey]]['values'] as $aValue)
+                if(isset($aValue['key']) && (int)$aValue['key'] == -(int)$aParams['context_id']) {
+                    $oForm->aInputs[$CNF[$sKey]]['value'] = -(int)$aParams['context_id'];
+                    $oForm->aInputs[$CNF[$sKey]]['type'] = 'hidden';
+                    break;
+                }
+        }
+
+        bx_alert('system', 'get_object_form', 0, 0, array(
+            'module' => $this->_oConfig->getName(),
+            'type' => $sType,
+            'params' => $aParams,
+            'form' => &$oForm
+        ));
 
         return $oForm;
     }

+ 19 - 1
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -77,7 +77,7 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
     }
 
     /**
-     * check if provided profile is member if the group 
+     * check if provided profile is member of the group 
      */ 
     public function serviceIsFan ($iGroupProfileId, $iProfileId = false) 
     {
@@ -85,6 +85,24 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
         return $this->isFan($oGroupProfile->getContentId(), $iProfileId);
     }
 
+    /**
+     * check if provided profile is admin of the group 
+     */ 
+    public function serviceIsAdmin ($iGroupProfileId, $iProfileId = false) 
+    {
+        if(!$iProfileId)
+            $iProfileId = bx_get_logged_profile_id();
+
+        $oGroupProfile = BxDolProfile::getInstance($iGroupProfileId);
+
+        $iGroupContentId = $oGroupProfile->getContentId();
+        if(!$this->isFan($iGroupContentId, $iProfileId))
+            return false;
+
+        $aGroupContentInfo = $this->_oDb->getContentInfoById($iGroupContentId);
+        return $this->_oDb->isAdmin($iGroupProfileId, $iProfileId, $aGroupContentInfo);
+    }
+    
     /**
      * Delete profile from fans and admins tables
      * @param $iProfileId profile id 

+ 15 - 0
modules/boonex/timeline/classes/BxTimelineDb.php

@@ -498,6 +498,21 @@ class BxTimelineDb extends BxBaseModNotificationsDb
             $sLimitClause = "";
         }
 
+        $aAlertParams = $aParams;
+        unset($aAlertParams['browse']);
+
+        bx_alert($this->_oConfig->getName(), 'get_events', 0, 0, array(
+            'browse' => $aParams['browse'],
+            'params' => $aAlertParams,
+            'table' => $this->_sTable,
+            'method' => &$sMethod,
+            'select_clause' => &$sSelectClause,
+            'join_clause' => &$sJoinClause,
+            'where_clause' => &$sWhereClause,
+            'order_clause' => &$sOrderClause,
+            'limit_clause' => &$sLimitClause
+        ));
+
         return array($sMethod, $sSelectClause, $sJoinClause, $sWhereClause, $sOrderClause, $sLimitClause);
     }
 

+ 10 - 1
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -539,7 +539,16 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
                 $aParams['form_display'] = 'form_display_post_add_profile';
         }
 
-    	return $this->getFormPostObject($aParams);
+        $oForm = $this->getFormPostObject($aParams);
+
+        bx_alert('system', 'get_object_form', 0, 0, array(
+            'module' => $this->_oConfig->getName(),
+            'type' => $sType,
+            'params' => $aParams,
+            'form' => &$oForm
+        ));
+
+    	return $oForm;
     }
     
     /**

+ 17 - 16
template/scripts/BxBaseServices.php

@@ -99,25 +99,25 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
         return array();
     }
     
-    public function serviceGetCreatePostForm($iContextId = 0, $sDefault = '')
+    public function serviceGetCreatePostForm($iContextId = 0, $sDefault = '', $aCustom = array())
     {
     	if(!isLogged())
-    		return '';
+            return '';
 
     	$oProfile = BxDolProfile::getInstance();
 
-		$sTitle = _t('_sys_page_block_title_create_post_' . (empty($iContextId) ? 'public' : 'context'));
-		$sPlaceholder = _t('_sys_txt_create_post_placeholder', $oProfile->getDisplayName());
+        $sTitle = _t('_sys_page_block_title_create_post_' . (empty($iContextId) ? 'public' : 'context'));
+        $sPlaceholder = _t('_sys_txt_create_post_placeholder', $oProfile->getDisplayName());
 
     	$oMenu = BxDolMenu::getObjectInstance('sys_create_post');
 
     	$aMenuItems = $oMenu->getMenuItems();
     	if(empty($aMenuItems) || !is_array($aMenuItems))
-    		return '';
+            return '';
 
     	if(empty($sDefault)) {
-    		$aDefault = array_shift($aMenuItems);
-    		$sDefault = $aDefault['module'];
+            $aDefault = array_shift($aMenuItems);
+            $sDefault = $aDefault['module'];
     	}
     	$oMenu->setSelected($sDefault, $sDefault);
 
@@ -128,19 +128,20 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
         $sJsContent = $oTemplate->_wrapInTagJsCode("var " . $sJsObject . " = new BxDolCreatePost(" . json_encode(array(
             'sObjName' => $sJsObject,
             'sRootUrl' => BX_DOL_URL_ROOT,
-        	'sDefault' => $sDefault,
-        	'iContextId' => $iContextId
+            'sDefault' => $sDefault,
+            'iContextId' => $iContextId,
+            'oCustom' => $aCustom
         )) . ");");
 
     	return array('content' => BxDolTemplate::getInstance()->parseHtmlByName('create_post_form.html', array(
-    		'default' => $sDefault,
-    		'title' => $sTitle,
-			'placeholder' => $sPlaceholder,
+            'default' => $sDefault,
+            'title' => $sTitle,
+            'placeholder' => $sPlaceholder,
             'user_thumb' => BxDolProfile::getInstance()->getUnit(0, array('template' => 'unit_wo_info')),
-    		'menu' => $oMenu->getCode(),
-            'form' => BxDolService::call($sDefault, 'get_create_post_form', array(array('context_id' => $iContextId, 'ajax_mode' => true, 'absolute_action_url' => true))),
-    		'js_object' => $sJsObject,
-    		'js_content' => $sJsContent
+            'menu' => $oMenu->getCode(),
+            'form' => BxDolService::call($sDefault, 'get_create_post_form', array(array('context_id' => $iContextId, 'ajax_mode' => true, 'absolute_action_url' => true, 'custom' => $aCustom))),
+            'js_object' => $sJsObject,
+            'js_content' => $sJsContent
     	)));
     }