AntonLV 12 лет назад
Родитель
Сommit
fd1a66b6b1

+ 2 - 2
modules/base/general/classes/BxBaseModGeneralGridAdministration.php

@@ -34,7 +34,7 @@ class BxBaseModGeneralGridAdministration extends BxTemplGrid
         if(empty($sFilterName) || empty($aFilterValues))
             return '';
 
-		$sJsObject = $this->_oModule->_oConfig->getJsObject($this->_sManageType);
+		$sJsObject = $this->_oModule->_oConfig->getJsObject('manage_tools');
 
 		$sFilterField = '_s' . str_replace(' ', '', ucwords(str_replace('_', ' ', $sFilterName)));
 		foreach($aFilterValues as $sKey => $sValue)
@@ -58,7 +58,7 @@ class BxBaseModGeneralGridAdministration extends BxTemplGrid
 
 	protected function _getSearchInput()
     {
-        $sJsObject = $this->_oModule->_oConfig->getJsObject($this->_sManageType);
+        $sJsObject = $this->_oModule->_oConfig->getJsObject('manage_tools');
 
         $aInputSearch = array(
             'type' => 'text',

+ 4 - 4
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -53,17 +53,17 @@ class BxBaseModGeneralModule extends BxDolModule
 
     // ====== SERVICE METHODS
 
-	public function serviceManageEntities($sType)
+	public function serviceManageTools($sType)
     {
     	bx_import('BxDolGrid');
         $oGrid = BxDolGrid::getObjectInstance($this->_oConfig->getGridObject($sType));
         if(!$oGrid)
             return '';
 
-        $this->_oTemplate->addCss(array($sType . '.css'));
-        $this->_oTemplate->addJs(array($sType . '.js'));
+        $this->_oTemplate->addCss(array('manage_tools.css'));
+        $this->_oTemplate->addJs(array('manage_tools.js'));
         $this->_oTemplate->addJsTranslation(array('_sys_grid_search'));
-        return $this->_oTemplate->getJsCode($sType) . $oGrid->getCode();
+        return $this->_oTemplate->getJsCode('manage_tools', array('sObjNameGrid' => $this->_oConfig->getGridObject($sType))) . $oGrid->getCode();
     }
 
     /**

+ 5 - 5
modules/base/general/classes/BxBaseModGeneralTemplate.php

@@ -24,19 +24,19 @@ class BxBaseModGeneralTemplate extends BxDolModuleTemplate
         $this->addCss ('main.css');
     }
 
-	public function getJsCode($sType, $aRequestParams = array(), $bWrap = true)
+	public function getJsCode($sType, $aParams = array(), $bWrap = true)
     {
         $sBaseUri = $this->_oConfig->getBaseUri();
         $sJsClass = $this->_oConfig->getJsClass($sType);
         $sJsObject = $this->_oConfig->getJsObject($sType);
 
-        $aParams = array(
+        $aParams = array_merge(array(
             'sActionUri' => $sBaseUri,
             'sActionUrl' => BX_DOL_URL_ROOT . $sBaseUri,
             'sObjName' => $sJsObject,
-        	'sObjNameGrid' => $this->_oConfig->getGridObject($sType),
-            'oRequestParams' => !empty($aRequestParams) ? $aRequestParams : array()
-        );
+        	'sObjNameGrid' => '',
+            'oRequestParams' => array()
+        ), $aParams);
         $sContent = "var " . $sJsObject . " = new " . $sJsClass . "(" . json_encode($aParams) . ");";
 
         return !$bWrap ? $sContent : $this->_wrapInTagJsCode($sContent);

+ 0 - 0
modules/base/general/template/css/administration.css → modules/base/general/template/css/manage_tools.css


+ 0 - 1
modules/base/general/template/css/moderation.css

@@ -1 +0,0 @@
-@import url(administration.css);

+ 84 - 5
modules/base/profile/classes/BxBaseModProfileGridAdministration.php

@@ -26,8 +26,36 @@ class BxBaseModProfileGridAdministration extends BxBaseModGeneralGridAdministrat
         }
     }
 
-	public function performActionDelete()
+    public function performActionSetAclLevel()
     {
+    	bx_import('BxDolMenu');
+    	$oMenu = BxDolMenu::getObjectInstance('sys_set_acl_level');
+
+    	$aIds = bx_get('ids');
+        if(!$aIds || !is_array($aIds) || !$oMenu) {
+            $this->_echoResultJson(array());
+            exit;
+        }
+
+        foreach($aIds as $iKey => $iId)
+        	$aIds[$iKey] = $this->_getProfileId($iId);
+
+		if(count($aIds) == 1)
+			$aIds = $aIds[0];
+
+    	bx_import('BxTemplFunctions');
+		$sContent = BxTemplFunctions::getInstance()->transBox($this->_oModule->_oConfig->getName() . 'set_acl_level_popup', $oMenu->getCode($aIds));
+
+    	$this->_echoResultJson(array('popup' => $sContent), true);
+    }
+
+	public function performActionDelete($bWithContent = false)
+    {
+    	if($bWithContent) {
+			$this->_echoResultJson(array('msg' => 'TODO: delete with content'));
+	    	return;
+    	}
+
         $iAffected = 0;
         $aIds = bx_get('ids');
         if(!$aIds || !is_array($aIds)) {
@@ -37,7 +65,7 @@ class BxBaseModProfileGridAdministration extends BxBaseModGeneralGridAdministrat
 
         $aIdsAffected = array ();
         foreach($aIds as $iId) {
-        	$oProfile = BxDolProfile::getInstanceByContentAndType((int)$iId, $this->_oModule->_oConfig->getName());
+        	$oProfile = $this->_getProfileObject(iId);
 
         	if((int)$this->_delete($iId) == 0)
                 continue;
@@ -45,6 +73,10 @@ class BxBaseModProfileGridAdministration extends BxBaseModGeneralGridAdministrat
         	if(!$oProfile->delete())
         		continue;
 
+        	if($bWithContent)	{
+        		//TODO: delete content after profile deletion
+        	}
+
             $aIdsAffected[] = $iId;
             $iAffected++;
         }
@@ -52,6 +84,11 @@ class BxBaseModProfileGridAdministration extends BxBaseModGeneralGridAdministrat
         $this->_echoResultJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t('_adm_nav_err_menus_delete')));
     }
 
+	public function performActionDeleteSpammer()
+    {
+    	$this->performActionDelete(true);
+    }
+
 	protected function _switcherChecked2State($isChecked)
     {
         return $isChecked ? 'active' : 'suspended';
@@ -64,9 +101,9 @@ class BxBaseModProfileGridAdministration extends BxBaseModGeneralGridAdministrat
 
     protected function _enable ($mixedId, $isChecked)
     {
-        $oDb = BxDolDb::getInstance();
-        $sQuery = $oDb->prepare("UPDATE `sys_profiles` SET `status` = ? WHERE `content_id` = ? AND `type` = ?", $this->_switcherChecked2State($isChecked), $mixedId, $this->_oModule->_oConfig->getName());
-        return $oDb->query($sQuery);
+    	$iAction = BX_PROFILE_ACTION_MANUAL;
+    	$oProfile = $this->_getProfileObject($mixedId);
+    	return $isChecked ? $oProfile->activate($iAction) : $oProfile->suspend($iAction);
     }
 
     protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
@@ -95,10 +132,52 @@ class BxBaseModProfileGridAdministration extends BxBaseModGeneralGridAdministrat
         return  $this->_getFilterSelectOne($sFilterName, $aFilterValues) . $this->_getSearchInput();
     }
 
+    protected function _getCellFullname($mixedValue, $sKey, $aField, $aRow)
+    {
+    	$oProfile = $this->_getProfileObject($aRow['id']);
+
+        $mixedValue = $this->_oTemplate->parseHtmlByName('bx_a.html', array(
+            'href' => $oProfile->getUrl(),
+            'title' => $mixedValue,
+            'bx_repeat:attrs' => array(),
+            'content' => $mixedValue
+        ));
+
+        return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
+    }
+
+    protected function _getActionSettings($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
+    {
+    	$sName = $this->_oModule->_oConfig->getName() . "_menu_manage_tools";
+    	$sJsObject = $this->_oModule->_oConfig->getJsObject('manage_tools');
+
+    	$sMenu = BxDolMenu::getObjectInstance($sName)->getCode();
+    	if(empty($sMenu))
+    		return '';
+
+    	$a['attr'] = array_merge($a['attr'], array(
+    		"bx-popup-id" => $sName . "-" . $aRow['id'],
+    		"onclick" => "$(this).off('click'); " . $sJsObject . ".onClickSettings('" . $sName . "', this);"
+    	));
+
+    	return $this->_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
+    }
+
     protected function _getCellLastOnline($mixedValue, $sKey, $aField, $aRow)
     {
         return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
     }
+
+    protected function _getProfileObject($iId)
+    {
+    	bx_import('BxDolProfile');
+    	return  BxDolProfile::getInstanceByContentAndType((int)$iId, $this->_oModule->_oConfig->getName());
+    }
+
+    protected function _getProfileId($iId)
+    {
+    	return $this->_getProfileObject($iId)->id();
+    }
 }
 
 /** @} */

+ 1 - 1
modules/base/profile/classes/BxBaseModProfileGridModeration.php

@@ -20,7 +20,7 @@ class BxBaseModProfileGridModeration extends BxBaseModProfileGridAdministration
         $this->_sManageType = 'moderation';
     }
 
-	public function performActionDelete()
+	public function performActionDelete($bWithContent = false)
     {
         $this->_echoResultJson(array());
     }

+ 38 - 0
modules/base/profile/classes/BxBaseModProfileMenuManageTools.php

@@ -0,0 +1,38 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    BaseProfile Base classes for profile modules
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxTemplMenu');
+
+/**
+ * Manage tools submenu
+ */
+class BxBaseModProfileMenuManageTools extends BxTemplMenu
+{
+	protected $_oModule;
+
+    public function __construct($aObject, $oTemplate = false)
+    {
+        parent::__construct($aObject, $oTemplate);
+
+        $this->_oModule = BxDolModule::getInstance($this->MODULE);
+
+        $iContentId = 0;
+        if(bx_get('content_id') !== false)
+        	$iContentId = (int)bx_get('content_id');
+
+		$this->addMarkers(array(
+			'js_object' => $this->_oModule->_oConfig->getJsObject('manage_tools'),
+			'content_id' => $iContentId
+		));
+    }
+}
+
+/** @} */

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

@@ -2056,7 +2056,7 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_top"><![CDATA[Top]]></string>
 	<string name="_uknown"><![CDATA[unknown]]></string>
 	<string name="_undefined"><![CDATA[undefined]]></string>
-	<string name="_vote_do_like"><![CDATA[Thank you]]></string>
+	<string name="_vote_do_like"><![CDATA[Thank you!]]></string>
 	<string name="_vote_do_unlike"><![CDATA[No thank you]]></string>
 	<string name="_vote_do_like_by"><![CDATA[Thanked by]]></string>
 	<string name="_vote_err_duplicate_vote"><![CDATA[Duplicate vote]]></string>

+ 27 - 0
modules/boonex/persons/classes/BxPersonsMenuManageTools.php

@@ -0,0 +1,27 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    Persons Persons
+ * @ingroup     DolphinModules
+ *
+ * @{
+ */
+
+bx_import('BxBaseModProfileMenuManageTools');
+
+/**
+ * 'View person' menu.
+ */
+class BxPersonsMenuManageTools extends BxBaseModProfileMenuManageTools
+{
+
+    public function __construct($aObject, $oTemplate = false)
+    {
+        $this->MODULE = 'bx_persons';
+        parent::__construct($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 44 - 23
template/scripts/BxBaseMenuSetAclLevel.php

@@ -14,33 +14,24 @@ bx_import('BxTemplMenu');
  */
 class BxBaseMenuSetAclLevel extends BxTemplMenu
 {
+	protected $mixedProfileId;
+
     public function __construct ($aObject, $oTemplate)
     {
         parent::__construct ($aObject, $oTemplate);
     }
 
-    public function getCode ()
+    public function getCode ($mixedProfileId = 0)
     {
-        if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && ($iProfileId = bx_get('profile_id', 'post')) && ($iAclLevelId = bx_get('acl_level_id', 'post'))) {
-
-            $sMsg = '';
-            bx_import('BxDolAcl');
-
-            $aCheck = checkActionModule($iProfileId, 'set acl level', 'system', false);
-            if (isAdmin() || $aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED) {
-
-                $oAcl = BxDolAcl::getInstance();
-                if ($oAcl->setMembership($iProfileId, $iAclLevelId, 0, true))
-                    checkActionModule($iProfileId, 'delete account', 'system', true); // perform action
-                else
-                    $sMsg = _t('_error occured');
+    	$this->mixedProfileId = $mixedProfileId;
 
-            } else {
-                $sMsg = $aCheck[CHECK_ACTION_MESSAGE];
-            }
+        if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && ($mixedProfileId = bx_get('profile_id', 'post')) && ($iAclLevelId = bx_get('acl_level_id', 'post'))) {
+			$mixedProfileId = urldecode($mixedProfileId);
+			if(!is_numeric($mixedProfileId))
+				$mixedProfileId = unserialize($mixedProfileId);
 
             header('Content-type: text/html; charset=utf-8');
-            echo $sMsg;
+            echo $this->setMembership($mixedProfileId, $iAclLevelId);
             exit;
         }
 
@@ -55,17 +46,22 @@ class BxBaseMenuSetAclLevel extends BxTemplMenu
 
     protected function loadData()
     {
-        $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
+    	$mixedProfileId = $this->mixedProfileId;
+    	if(bx_get('profile_id') !== false)
+        	$mixedProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
 
         bx_import('BxDolAcl');
         $oAcl = BxDolAcl::getInstance();
         if (!$oAcl)
             return;
 
-        $aProfileAclLevel = $oAcl->getMemberMembershipInfo($iProfileId);
-        $aAclLevels = $oAcl->getMemberships(false, true);
+		$bBulk = is_array($mixedProfileId);
+		if(!$bBulk) {
+			$aProfileAclLevel = $oAcl->getMemberMembershipInfo($mixedProfileId);
+			$this->setSelected('', $aProfileAclLevel['id']);
+		}
 
-        $this->setSelected('', $aProfileAclLevel['id']);
+		$aAclLevels = $oAcl->getMemberships(false, true);
 
         $aItems = array();
         foreach ($aAclLevels as $iId => $sTitle) {
@@ -76,12 +72,37 @@ class BxBaseMenuSetAclLevel extends BxTemplMenu
                 'title' => $sTitle,
                 'icon' => '',
                 'link' => 'javascript:void(0);',
-                'onclick' => "bx_set_acl_level({$iProfileId}, {$iId}, '#bx-popup-ajax-wrapper-sys_set_acl_level');"
+                'onclick' => "bx_set_acl_level(" . (!$bBulk ? $mixedProfileId : "'" . urlencode(serialize($mixedProfileId)) . "'") . ", {$iId}, '.bx-popup-applied');"
             );
         }
 
         $this->_aObject['menu_items'] = $aItems;
     }
+
+    protected function setMembership($mixedProfileId, $iAclLevelId)
+    {
+        bx_import('BxDolAcl');
+
+        if(!is_array($mixedProfileId))
+        	$mixedProfileId = array($mixedProfileId);
+
+		$iPerformerId = bx_get_logged_profile_id();
+        $aCheck = checkActionModule($iPerformerId, 'set acl level', 'system', false);
+        if(!isAdmin() && $aCheck[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
+			return $aCheck[CHECK_ACTION_MESSAGE];
+
+		$iSet = 0;
+		$oAcl = BxDolAcl::getInstance();
+		foreach($mixedProfileId as $iProfileId) {
+        	if(!$oAcl->setMembership($iProfileId, $iAclLevelId, 0, true))
+        		continue;
+
+			$iSet += 1;
+			checkActionModule($iPerformerId, 'set acl level', 'system', true); // perform action
+		}
+
+		return count($mixedProfileId) != $iSet ? _t('_error occured') : '';
+    }
 }
 
 /** @} */