AntonLV 10 年之前
父节点
当前提交
14d6d61591

+ 5 - 3
modules/boonex/accounts/classes/BxAccntDb.php

@@ -11,13 +11,15 @@
 
 
 class BxAccntDb extends BxBaseModGeneralDb
 class BxAccntDb extends BxBaseModGeneralDb
 {
 {
-    /*
-     * Constructor.
-     */
     function __construct(&$oConfig)
     function __construct(&$oConfig)
     {
     {
         parent::__construct($oConfig);
         parent::__construct($oConfig);
     }
     }
+
+    public function updateAccount($aSet, $aWhere)
+    {
+    	return (int)$this->query("UPDATE `sys_accounts` SET " . $this->arrayToSQL($aSet) . " WHERE " . $this->arrayToSQL($aWhere, ' AND ')) > 0;
+    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 31 - 5
modules/boonex/accounts/classes/BxAccntGridAdministration.php

@@ -51,6 +51,16 @@ class BxAccntGridAdministration extends BxBaseModProfileGridAdministration
 		echoJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t($CNF['T']['grid_action_err_perform'])));
 		echoJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t($CNF['T']['grid_action_err_perform'])));
     }
     }
 
 
+	public function performActionMakeOperator()
+    {
+    	$this->_performActionChangeRole(3);
+    }
+
+	public function performActionUnmakeOperator()
+    {
+    	$this->_performActionChangeRole(1);
+    }
+
     public function resetQueryParams()
     public function resetQueryParams()
     {
     {
         $aKeys = array('order_field', 'order_dir', $this->_aOptions['paginate_get_start'], $this->_aOptions['paginate_get_per_page']);
         $aKeys = array('order_field', 'order_dir', $this->_aOptions['paginate_get_start'], $this->_aOptions['paginate_get_per_page']);
@@ -60,6 +70,27 @@ class BxAccntGridAdministration extends BxBaseModProfileGridAdministration
         }
         }
     }
     }
 
 
+	protected function _performActionChangeRole($iRole)
+    {
+    	$CNF = &$this->_oModule->_oConfig->CNF;
+
+    	$aIds = bx_get('ids');
+        if(!$aIds || !is_array($aIds)) {
+            echoJson(array());
+            return;
+        }
+
+        $iAffected = 0;
+        $aIdsAffected = array();
+        foreach($aIds as $iId)
+			if($this->_oModule->_oDb->updateAccount(array('role' => $iRole), array('id' => $iId))) {
+				$aIdsAffected[] = $iId;
+        		$iAffected++;
+			}
+
+		echoJson($iAffected ? array('grid' => $this->getCode(false), 'blink' => $aIdsAffected) : array('msg' => _t($CNF['T']['grid_action_err_perform'])));
+    }
+
 	protected function _performActionEnable($isChecked)
 	protected function _performActionEnable($isChecked)
     {
     {
     	$CNF = &$this->_oModule->_oConfig->CNF;
     	$CNF = &$this->_oModule->_oConfig->CNF;
@@ -121,11 +152,6 @@ class BxAccntGridAdministration extends BxBaseModProfileGridAdministration
     {
     {
     	return BxDolAccount::getInstance($iId)->delete(isset($aParams['with_content']) && $aParams['with_content'] === true);
     	return BxDolAccount::getInstance($iId)->delete(isset($aParams['with_content']) && $aParams['with_content'] === true);
     }
     }
-
-    protected function _isVisibleGrid ($a)
-    {
-        return isAdmin();
-    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 6 - 0
modules/boonex/accounts/classes/BxAccntMenuManageTools.php

@@ -41,6 +41,12 @@ class BxAccntMenuManageTools extends BxBaseModGeneralMenuManageTools
             case 'delete-with-content':
             case 'delete-with-content':
                 $sCheckFuncName = 'checkAllowedDelete';
                 $sCheckFuncName = 'checkAllowedDelete';
                 break;
                 break;
+            case 'make-operator':
+            	$sCheckFuncName = 'checkAllowedMakeOperator';
+            	break;
+            case 'unmake-operator':
+            	$sCheckFuncName = 'checkAllowedUnmakeOperator';
+            	break;
         }
         }
 
 
         if(!$sCheckFuncName || !method_exists($this->_oModule, $sCheckFuncName))
         if(!$sCheckFuncName || !method_exists($this->_oModule, $sCheckFuncName))

+ 18 - 0
modules/boonex/accounts/classes/BxAccntModule.php

@@ -46,6 +46,24 @@ class BxAccntModule extends BxBaseModGeneralModule
 
 
         return CHECK_ACTION_RESULT_ALLOWED;
         return CHECK_ACTION_RESULT_ALLOWED;
     }
     }
+
+    public function checkAllowedMakeOperator(&$aDataEntry, $isPerformAction = false)
+    {
+    	$bAdmin = isAdmin();
+    	if(!$bAdmin || (int)$aDataEntry['id'] == getLoggedId() || (int)$aDataEntry['role'] == 3)
+    		return _t('_sys_txt_access_denied');
+
+    	return CHECK_ACTION_RESULT_ALLOWED;
+    }
+
+	public function checkAllowedUnmakeOperator(&$aDataEntry, $isPerformAction = false)
+    {
+    	$bAdmin = isAdmin();
+    	if(!$bAdmin || (int)$aDataEntry['id'] == getLoggedId() || (int)$aDataEntry['role'] != 3)
+    		return _t('_sys_txt_access_denied');
+
+    	return CHECK_ACTION_RESULT_ALLOWED;
+    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 4 - 0
modules/boonex/accounts/install/langs/en.xml

@@ -17,6 +17,10 @@
     <string name="_bx_accnt_menu_item_title_delete"><![CDATA[Delete]]></string>
     <string name="_bx_accnt_menu_item_title_delete"><![CDATA[Delete]]></string>
     <string name="_bx_accnt_menu_item_title_system_delete_with_content"><![CDATA[Delete With Content]]></string>
     <string name="_bx_accnt_menu_item_title_system_delete_with_content"><![CDATA[Delete With Content]]></string>
     <string name="_bx_accnt_menu_item_title_delete_with_content"><![CDATA[Delete With Content]]></string>
     <string name="_bx_accnt_menu_item_title_delete_with_content"><![CDATA[Delete With Content]]></string>
+    <string name="_bx_accnt_menu_item_title_system_make_operator"><![CDATA[Make Operator]]></string>
+    <string name="_bx_accnt_menu_item_title_make_operator"><![CDATA[Make Operator]]></string>
+    <string name="_bx_accnt_menu_item_title_system_unmake_operator"><![CDATA[Unmake Operator]]></string>
+    <string name="_bx_accnt_menu_item_title_unmake_operator"><![CDATA[Unmake Operator]]></string>
 	<string name="_bx_accnt_menu_item_title_system_admt_accounts"><![CDATA[Accounts]]></string>
 	<string name="_bx_accnt_menu_item_title_system_admt_accounts"><![CDATA[Accounts]]></string>
 	<string name="_bx_accnt_menu_item_title_admt_accounts"><![CDATA[Accounts - {addon} unconfirmed]]></string>
 	<string name="_bx_accnt_menu_item_title_admt_accounts"><![CDATA[Accounts - {addon} unconfirmed]]></string>
 	<string name="_bx_accnt_menu_item_title_manage"><![CDATA[Manage]]></string>
 	<string name="_bx_accnt_menu_item_title_manage"><![CDATA[Manage]]></string>

+ 4 - 2
modules/boonex/accounts/install/sql/enable.sql

@@ -19,7 +19,9 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
 ('bx_accounts_menu_manage_tools', @sName, 'resend-cemail', '_bx_accnt_menu_item_title_system_resend_cemail', '_bx_accnt_menu_item_title_resend_cemail', 'javascript:void(0)', 'javascript:{js_object}.onClickResendCemail({content_id});', '_self', 'envelope-o', '', 192, 1, 0, 1),
 ('bx_accounts_menu_manage_tools', @sName, 'resend-cemail', '_bx_accnt_menu_item_title_system_resend_cemail', '_bx_accnt_menu_item_title_resend_cemail', 'javascript:void(0)', 'javascript:{js_object}.onClickResendCemail({content_id});', '_self', 'envelope-o', '', 192, 1, 0, 1),
 ('bx_accounts_menu_manage_tools', @sName, 'delete', '_bx_accnt_menu_item_title_system_delete', '_bx_accnt_menu_item_title_delete', 'javascript:void(0)', 'javascript:{js_object}.onClickDelete({content_id});', '_self', 'trash-o', '', 192, 1, 0, 2),
 ('bx_accounts_menu_manage_tools', @sName, 'delete', '_bx_accnt_menu_item_title_system_delete', '_bx_accnt_menu_item_title_delete', 'javascript:void(0)', 'javascript:{js_object}.onClickDelete({content_id});', '_self', 'trash-o', '', 192, 1, 0, 2),
-('bx_accounts_menu_manage_tools', @sName, 'delete-with-content', '_bx_accnt_menu_item_title_system_delete_with_content', '_bx_accnt_menu_item_title_delete_with_content', 'javascript:void(0)', 'javascript:{js_object}.onClickDeleteWithContent({content_id});', '_self', 'trash-o', '', 192, 1, 0, 3);
+('bx_accounts_menu_manage_tools', @sName, 'delete-with-content', '_bx_accnt_menu_item_title_system_delete_with_content', '_bx_accnt_menu_item_title_delete_with_content', 'javascript:void(0)', 'javascript:{js_object}.onClickDeleteWithContent({content_id});', '_self', 'trash-o', '', 192, 1, 0, 3),
+('bx_accounts_menu_manage_tools', @sName, 'make-operator', '_bx_accnt_menu_item_title_system_make_operator', '_bx_accnt_menu_item_title_make_operator', 'javascript:void(0)', 'javascript:{js_object}.onClickMakeOperator({content_id});', '_self', 'wrench', '', 192, 1, 0, 4),
+('bx_accounts_menu_manage_tools', @sName, 'unmake-operator', '_bx_accnt_menu_item_title_system_unmake_operator', '_bx_accnt_menu_item_title_unmake_operator', 'javascript:void(0)', 'javascript:{js_object}.onClickUnmakeOperator({content_id});', '_self', 'wrench', '', 192, 1, 0, 5);
 
 
 -- MENU: dashboard manage tools
 -- MENU: dashboard manage tools
 SET @iManageMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name`='sys_account_dashboard_manage_tools' LIMIT 1);
 SET @iManageMenuOrder = (SELECT IFNULL(MAX(`order`), 0) FROM `sys_menu_items` WHERE `set_name`='sys_account_dashboard_manage_tools' LIMIT 1);
@@ -51,7 +53,7 @@ INSERT INTO `sys_acl_matrix` (`IDLevel`, `IDAction`) VALUES
 
 
 -- GRIDS: administration
 -- GRIDS: administration
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `field_active`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_fields_translatable`, `filter_mode`, `sorting_fields`, `sorting_fields_translatable`, `visible_for_levels`, `override_class_name`, `override_class_file`) VALUES
-('bx_accounts_administration', 'Sql', 'SELECT `ta`.*, `tp`.`status` AS `status` FROM `sys_accounts` AS `ta` LEFT JOIN `sys_profiles` AS `tp` ON `ta`.`id`=`tp`.`account_id` AND `tp`.`type`=''system'' WHERE 1 ', 'sys_accounts', 'id', 'logged', 'status', '', 20, NULL, 'start', '', 'name,email', '', 'like', '', '', 2147483647, 'BxAccntGridAdministration', 'modules/boonex/accounts/classes/BxAccntGridAdministration.php');
+('bx_accounts_administration', 'Sql', 'SELECT `ta`.*, `tp`.`status` AS `status` FROM `sys_accounts` AS `ta` LEFT JOIN `sys_profiles` AS `tp` ON `ta`.`id`=`tp`.`account_id` AND `tp`.`type`=''system'' WHERE 1 ', 'sys_accounts', 'id', 'logged', 'status', '', 20, NULL, 'start', '', 'name,email', '', 'like', '', '', 192, 'BxAccntGridAdministration', 'modules/boonex/accounts/classes/BxAccntGridAdministration.php');
 
 
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `translatable`, `chars_limit`, `params`, `order`) VALUES
 ('bx_accounts_administration', 'checkbox', '_sys_select', '2%', 0, '', '', 1),
 ('bx_accounts_administration', 'checkbox', '_sys_select', '2%', 0, '', '', 1),

+ 20 - 0
modules/boonex/accounts/js/manage_tools.js

@@ -60,4 +60,24 @@ BxAccntManageTools.prototype.onClickDeleteWithContent = function(iContentId) {
 	glGrids[this._sObjNameGrid].actionWithId(iContentId, 'delete_with_content', {}, '', false, 1);
 	glGrids[this._sObjNameGrid].actionWithId(iContentId, 'delete_with_content', {}, '', false, 1);
 };
 };
 
 
+BxAccntManageTools.prototype.onClickMakeOperator = function(iContentId) {
+	$('.bx-popup-applied:visible').dolPopupHide({
+		onHide: function(oPopup) {
+			$(oPopup).remove();
+		} 
+	});
+
+	glGrids[this._sObjNameGrid].actionWithId(iContentId, 'make_operator', {}, '', false, 0);
+};
+
+BxAccntManageTools.prototype.onClickUnmakeOperator = function(iContentId) {
+	$('.bx-popup-applied:visible').dolPopupHide({
+		onHide: function(oPopup) {
+			$(oPopup).remove();
+		} 
+	});
+
+	glGrids[this._sObjNameGrid].actionWithId(iContentId, 'unmake_operator', {}, '', false, 0);
+};
+
 /** @} */
 /** @} */