晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 .
Prv8 Shell
Server : Apache
System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64
User : rainic ( 1014)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/akaindir/www/crm/layouts/vlayout/modules/Settings/SharingAccess/resources/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/akaindir/www/crm/layouts/vlayout/modules/Settings/SharingAccess/resources/SharingAccess.js
/*+***********************************************************************************
 * The contents of this file are subject to the vtiger CRM Public License Version 1.0
 * ("License"); You may not use this file except in compliance with the License
 * The Original Code is:  vtiger CRM Open Source
 * The Initial Developer of the Original Code is vtiger.
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
 *************************************************************************************/
jQuery.Class('Settings_Sharing_Access_Js', {}, {

	contentTable : false,
	contentsContainer : false,
	
	init : function() {
		this.setContentTable('.sharingAccessDetails').setContentContainer('#sharingAccessContainer');

	},

	setContentTable : function(element) {
		if(element instanceof jQuery){
			this.contentTable = element;
			return this;
		}
		this.contentTable = jQuery(element);
		return this;
	},

	setContentContainer : function(element) {
		if(element instanceof jQuery){
			this.contentsContainer = element;
			return this;
		}
		this.contentsContainer = jQuery(element);
		return this;
	},

	getContentTable : function() {
		return this.contentTable;
	},

	getContentContainer : function() {
		return this.contentsContainer;
	},

	getCustomRuleContainerClassName : function(parentModuleName) {
		return parentModuleName+'CustomRuleList';
	},

	showCustomRulesNextToElement : function(parentElement, rulesListElement) {
		var moduleName = parentElement.data('moduleName')
		var trElementForRuleList = jQuery('<tr class="'+this.getCustomRuleContainerClassName(moduleName)+'"><td class="customRuleContainer row-fluid" colspan="6"></td></tr>');
		jQuery('td',trElementForRuleList).append(rulesListElement);
		jQuery('.ruleListContainer', trElementForRuleList).css('display', 'none');
		parentElement.after(trElementForRuleList).addClass('collapseRow');
		jQuery('.ruleListContainer', trElementForRuleList).slideDown('slow');
	},
	
	/*
	 * function to get custom rules data based on the module
	 * @params: forModule.
	 */
	getCustomRules : function(forModule) {
		var aDeferred = jQuery.Deferred();
		var params = {}
		params['for_module'] = forModule;
		params['module'] = app.getModuleName();
		params['parent'] = app.getParentModuleName();
		params['view'] = 'IndexAjax';
		params['mode'] = 'showRules';
		AppConnector.request(params).then(
			function(data) {
				aDeferred.resolve(data);
			},
			function(error) {
				//TODO : Handle error
				aDeferred.reject(error);
			}
		);
		return aDeferred.promise();
	},

	save : function(data) {
		var aDeferred = jQuery.Deferred();

		var progressIndicatorElement = jQuery.progressIndicator({
				'position' : 'html',
				'blockInfo' : {
					'enabled' : true
				}
			});
		if(typeof data == 'undefined') {
			data = {};
		}

		AppConnector.request(data).then(
			function(data){
				progressIndicatorElement.progressIndicator({'mode' : 'hide'});
				aDeferred.resolve(data);
			},
			function(error, errorThrown){
				progressIndicatorElement.progressIndicator({'mode' : 'hide'});
				aDeferred.reject(error);
			}
		)

		return aDeferred.promise();
	},
	

	
	/*
	 * function to Save the Custom Rule
	 */
	saveCustomRule : function(form, e) {
		var thisInstance = this;
		var data = form.serializeFormData();

		if(typeof data == 'undefined' ) {
			data = {};
		}
		
		var progressIndicatorElement = jQuery.progressIndicator({
			'position' : 'html',
			'blockInfo' : {
				'enabled' : true
			}
		});
		data.module = app.getModuleName();
		data.parent = app.getParentModuleName();
		data.action = 'IndexAjax';
		data.mode = 'saveRule';

		AppConnector.request(data).then(
			function(data) {
				progressIndicatorElement.progressIndicator({'mode':'hide'});
				app.hideModalWindow();
				thisInstance.displaySaveCustomRuleResponse(data);
				var moduleName = jQuery('[name="for_module"]', form).val();
				thisInstance.loadCustomRulesList(moduleName);
			}
		);
	},
	
	/*
	 * function to load the CustomRules List for the module after save the custom rule
	 */
	loadCustomRulesList : function(moduleName) {
		var thisInstance = this;
		var contentTable = this.getContentTable();
		
		thisInstance.getCustomRules(moduleName).then(
			function(data){
				var customRuleListContainer = jQuery('.'+thisInstance.getCustomRuleContainerClassName(moduleName),contentTable);
				customRuleListContainer.find('td.customRuleContainer').html(data);
			},
			function(error){
				//TODO: Handle Error
			}
		);
	},
	
	/*
	 * Function to display the SaveCustomRule response message
	 */
	displaySaveCustomRuleResponse : function(data) {
		var thisInstance = this;
		var success = data['success'];
		var params = {};
		if(success) {
			params = {
				text: app.vtranslate('JS_CUSTOM_RULE_SAVED_SUCCESSFULLY'),
				type: 'success'
			}
		} else {
			params = {
				text: app.vtranslate('JS_CUSTOM_RULE_SAVING_FAILED'),
				type: 'error'
			}
		}
		thisInstance.showNotify(params);
	},
	
	//This will show the notification message of SaveCustomRule using pnotify
	showNotify : function(customParams) {
		var params = {
			text: customParams.text,
			type: customParams.type,
			width: '30%',
			delay: '3000'
		};
		Vtiger_Helper_Js.showPnotify(params);
	},
	
	editCustomRule : function(url) {
		var thisInstance = this;
		var progressIndicatorElement = jQuery.progressIndicator({
			'position' : 'html',
			'blockInfo' : {
				'enabled' : true
			}
		});
		
		app.showModalWindow(null, url, function(modalContainer){
			var form = jQuery('#editCustomRule');
			
			form.on('submit', function(e) {
				//To stop the submit of form
				e.preventDefault();
				var formElement = jQuery(e.currentTarget);
				thisInstance.saveCustomRule(formElement, e);
			})
		});
	},
	
	/*
	 * function to delete Custom Rule from the list
	 * @params: deleteElement.
	 */
	deleteCustomRule : function(deleteElement) {
		var deleteUrl = deleteElement.data('url');
		var currentRow = deleteElement.closest('tr.customRuleEntries');
		var message = app.vtranslate('LBL_DELETE_CONFIRMATION');
		Vtiger_Helper_Js.showConfirmationBox({'message' : message}).then(function(data) {
			AppConnector.request(deleteUrl).then(
				function(data){
					if(data.success == true){
						currentRow.fadeOut('slow');
						var customRuleTable = currentRow.closest('table .customRuleTable');
						//after delete the custom rule, update the sequence number of existing rules
						var nextRows = currentRow.nextAll('tr.customRuleEntries');
						if(nextRows.length > 0){
							jQuery.each(nextRows,function(i,element) {
								var currentSequenceElement = jQuery(element).find('.sequenceNumber');
								var updatedNumber = parseInt(currentSequenceElement.text())-1;
								currentSequenceElement.text(updatedNumber);
							});	
						}
						currentRow.remove();
						var customRuleEntries = customRuleTable.find('.customRuleEntries');
						//if there are no custom rule entries, we have to hide headers also and show the empty message div
						if(customRuleEntries.length < 1) {
							customRuleTable.find('.customRuleHeaders').fadeOut('slow').remove();
							customRuleTable.parent().find('.recordDetails').removeClass('hide');
							customRuleTable.addClass('hide');
						}
					}else{
						Vtiger_Helper_Js.showPnotify(data.error.message);
					}
				});
			},
			function(error, err){
			}
		);
	},
	
	/*
	 * function to register click event for radio buttons
	 */
	registerSharingAccessEdit : function() {
		var contentContainer = this.getContentContainer();
		contentContainer.one('click','input:radio', function(e){
			contentContainer.find('button:submit').removeClass('hide');
		});
	},
	
	/*
	 * Function to register change event for dependent modules privileges
	 */
	registerDependentModulesPrivilegesChange : function() {
		var thisInstance = this;
		var container = thisInstance.getContentContainer();
		var contentTable = this.getContentTable();
		var modulesList = JSON.parse(container.find('.dependentModules').val());
		
		jQuery.each(modulesList, function(moduleName, dependentList) {
			var dependentPrivilege = contentTable.find('[data-module-name="'+moduleName+'"]').find('[data-action-state="Private"]');
			dependentPrivilege.change(function(e) {
				var currentTarget = jQuery(e.currentTarget);
				if(currentTarget.is(':checked')) {
					var message = app.vtranslate('JS_DEPENDENT_PRIVILEGES_SHOULD_CHANGE');
					 bootbox.alert(message);
					jQuery.each(dependentList, function(index, module) {
						contentTable.find('[data-module-name="'+module+'"]').find('[data-action-state="Private"]').attr('checked', 'checked');
					})
				}
			})
		})
	},
	
	registerEvents : function() {
		var thisInstance = this;
		var contentTable = this.getContentTable();
		var contentContainer = this.getContentContainer();
		thisInstance.registerSharingAccessEdit();
		thisInstance.registerDependentModulesPrivilegesChange();
		
		contentTable.on('click', 'td.triggerCustomSharingAccess', function(e){
			var element = jQuery(e.currentTarget);
			var trElement = element.closest('tr');
			var moduleName = trElement.data('moduleName');
			var customRuleListContainer = jQuery('.'+thisInstance.getCustomRuleContainerClassName(moduleName),contentTable);
			
			if(customRuleListContainer.length > 0) {
				if(app.isHidden(customRuleListContainer)) {
					customRuleListContainer.show();
					jQuery('.ruleListContainer', customRuleListContainer).slideDown('slow');
					trElement.addClass('collapseRow');
					element.find('button.arrowDown').addClass('hide');
					element.find('button.arrowUp').removeClass('hide').addClass('show');
				}else{
					jQuery('.ruleListContainer', customRuleListContainer).slideUp('slow', function(e) {
						customRuleListContainer.css('display', 'none');
					});
					element.find('button.arrowUp').addClass('hide');
					element.find('button.arrowDown').removeClass('hide').addClass('show');
					trElement.removeClass('collapseRow');
				}
				return;
			}
			
			var progressIndicatorElement = jQuery.progressIndicator({
				'position' : 'html',
				'blockInfo' : {
					'enabled' : true
				}
			});
			
			thisInstance.getCustomRules(moduleName).then(
					function(data){
						progressIndicatorElement.progressIndicator({'mode':'hide'});
						thisInstance.showCustomRulesNextToElement(trElement, data);
						element.find('button.arrowDown').addClass('hide');
						element.find('button.arrowUp').removeClass('hide').addClass('show');
					},
					function(error){
						//TODO: Handle Error
					}
			);
		});

		contentTable.on('click', 'button.addCustomRule' , function(e) {
			var button = jQuery(e.currentTarget);
			thisInstance.editCustomRule(button.data('url'));
		})

		contentTable.on('click', '.edit', function(e){
			var editElement = jQuery(e.currentTarget);
			var editUrl = editElement.data('url');
			thisInstance.editCustomRule(editUrl);
		});
		
		contentTable.on('click', '.delete', function(e){
			var deleteElement = jQuery(e.currentTarget);
			thisInstance.deleteCustomRule(deleteElement);
		});
		
		contentContainer.on('submit', '#EditSharingAccess', function(e){
			e.preventDefault();
			var form = jQuery(e.currentTarget);
			var data = form.serializeFormData();
			thisInstance.save(data).then(
				function(data) {
					contentContainer.find('button:submit').addClass('hide');
					thisInstance.registerSharingAccessEdit();
					var params = {
						text: app.vtranslate('JS_NEW_SHARING_RULES_APPLIED_SUCCESSFULLY'),
						type: 'success'
					};
					thisInstance.showNotify(params);
				},
				function(error,err){
				}
			);
		});
	}
});


jQuery(document).ready(function(){
	var settingSharingAcessInstance = new Settings_Sharing_Access_Js();
	settingSharingAcessInstance.registerEvents();
})

haha - 2025