mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-03 19:54:14 +00:00 
			
		
		
		
	Created access forbidden modal
This commit is contained in:
		@@ -5,10 +5,19 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Callout special stylesheet
 | 
			
		||||
 * User signed out
 | 
			
		||||
 */
 | 
			
		||||
.user_page_access_forbidden {
 | 
			
		||||
.user_access_denied_signed_out {
 | 
			
		||||
	margin: auto;
 | 
			
		||||
	margin-top: 30px;
 | 
			
		||||
	max-width: 500px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * User signed in
 | 
			
		||||
 */
 | 
			
		||||
.box-user-access-denied {
 | 
			
		||||
	margin: auto;
 | 
			
		||||
	margin-top: 30px;
 | 
			
		||||
	max-width: 350px;
 | 
			
		||||
}
 | 
			
		||||
@@ -687,9 +687,14 @@ var ComunicWeb = {
 | 
			
		||||
				/**
 | 
			
		||||
				 * Display the page for user with forbidden access
 | 
			
		||||
				 */
 | 
			
		||||
				display: function(id, params, target){}
 | 
			
		||||
				display: function(id, params, target){},
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
				/**
 | 
			
		||||
				 * Show basic user informations
 | 
			
		||||
				 */
 | 
			
		||||
				showBasicInfos: function(userInfos, target){},
 | 
			
		||||
 | 
			
		||||
			},
 | 
			
		||||
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,12 +27,90 @@ ComunicWeb.pages.userPage.accessForbidden = {
 | 
			
		||||
				"danger"
 | 
			
		||||
			);
 | 
			
		||||
 | 
			
		||||
			elem.className += " user_page_access_forbidden";
 | 
			
		||||
			elem.className += " user_access_denied_signed_out";
 | 
			
		||||
 | 
			
		||||
			target.appendChild(elem);
 | 
			
		||||
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		//Fetch informations about the user
 | 
			
		||||
		ComunicWeb.user.userInfos.getUserInfos(id, function(userinfos){
 | 
			
		||||
			
 | 
			
		||||
			//Check for errors
 | 
			
		||||
			if(userinfos.error){
 | 
			
		||||
 | 
			
		||||
				//Inform user it is impossible for him to access this page
 | 
			
		||||
				elem = ComunicWeb.common.messages.createCalloutElem(
 | 
			
		||||
					"Access denied",
 | 
			
		||||
					"You don't have the right to access this page.",
 | 
			
		||||
					"danger"
 | 
			
		||||
				);
 | 
			
		||||
 | 
			
		||||
				elem.className += " user_access_denied_signed_out";
 | 
			
		||||
 | 
			
		||||
				target.appendChild(elem);
 | 
			
		||||
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			//Show a dialog with basic user informations
 | 
			
		||||
			ComunicWeb.pages.userPage.accessForbidden.showBasicInfos(userinfos, target);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Show basic user informations
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param {Object} userInfos Informations about the user to display
 | 
			
		||||
	 * @param {HTMLElement} target Target element for user informations
 | 
			
		||||
	 */
 | 
			
		||||
	showBasicInfos: function(userInfos, target){
 | 
			
		||||
		
 | 
			
		||||
		//Create box root
 | 
			
		||||
		var boxRoot = createElem2({
 | 
			
		||||
			appendTo: target,
 | 
			
		||||
			type: "div",
 | 
			
		||||
			class: "box box-primary box-user-access-denied" 
 | 
			
		||||
		});
 | 
			
		||||
		
 | 
			
		||||
		//Create box body
 | 
			
		||||
		var boxBody = createElem2({
 | 
			
		||||
			appendTo: boxRoot,
 | 
			
		||||
			class: "box-body box-profile",
 | 
			
		||||
			type: "div"
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		//Add user profile image
 | 
			
		||||
		var profileImage = createElem2({
 | 
			
		||||
			appendTo: boxBody,
 | 
			
		||||
			type: "img",
 | 
			
		||||
			class: "profile-user-img img-responsive img-circle",
 | 
			
		||||
			src: userInfos.accountImage,
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		//Add user name
 | 
			
		||||
		var userName = createElem2({
 | 
			
		||||
			appendTo: boxBody,
 | 
			
		||||
			type:"h3",
 | 
			
		||||
			class: "profile-username text-center",
 | 
			
		||||
			innerHTML: userInfos.firstName + " " + userInfos.lastName,
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		//Add a message to inform access to the page was denied
 | 
			
		||||
		var infosMsg = createElem2({
 | 
			
		||||
			appendTo: boxBody,
 | 
			
		||||
			type: "p",
 | 
			
		||||
			class: "text-center",
 | 
			
		||||
			innerHTML: "This account is private."
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		//Add friendship request message
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user