Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deny access

Status
Not open for further replies.

jimstarr

Programmer
Feb 6, 2001
975
US
A certain group of users need to be denied access to Page 4 of a certain pageframe. Right now the app accomplishes this by having the page disabled for these users.

The new plan is to leave the page enabled, but (somehow) block access while displaying an explanatory message. Since a Page object doesn't have a When event, I don't see a straightforward way to do this. Any ideas?

Thanks!


Jim
 
One approach:

Assuming that you somehow cause another Tab page to be the 'opening' tab (possibly by using ThisForm.Pageframe1.ActivePage = 1), you can use this specific Tab Page's Click method to set all of its objects ENABLED = .F. and then display a MessageBox() or some other window informing the users of your message.

NOTE - if you used this approach, you would also have to set all the Tab page's objects ENABLED = .T. for those users who were allowed.

Good Luck,
JRB-Bldr
 
Jim,

How about this ....

In the pageframe's Init, set the visibility of all the controls on the page, according to the user's permissions. Then toggle the visibility of the "access denied" message.

Something like this:

Code:
llAccess = <.T. if user is allowed access>
THISFORM.MyPageFrame.Page4.SetAll( ;
  "visible", llAccess)
THISFORM.MyPageFrame.Page4.lblNoAccess.visible = ;
  NOT llAccess

Just off the top of my head.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
The idea is that Page 4 should not show up at all, and especially not with all its controls disabled.

For the time being I've settled on a solution which covers the tab of Page 4 with a transparent rectangular shape. In the click event of the shape I have code like:

IF not allowed
=MESSAGEBOX(......)
ELSE
THISFORM.Pageframe1,ACTIVEPAGE = 4
ENDIF

This does the job pretty well, but I'm still open to cleaner suggestions.


Jim
 
Code:
if usernotallowed
   pageframe.pagecount = 3
endif

But page.enable=.f. would also help to disable the page for some users.

Bye, Olaf.
 
Jim,

Sorry, but your requirements seem a little confusing. You originally said:

The new plan is to leave the page enabled, but (somehow) block access while displaying an explanatory message.

But you also say:

The idea is that Page 4 should not show up at all, and especially not with all its controls disabled.

If it doesn't show up at all, how can it be enabled, and how can it display an explanatory message?

If you want it not to show up at all, why not simply reduce the PageCount to 3 at init time? Note that this will be a one-way trip: if you subsequently put it back to 4 in the same session, you will have lost all the controls. But presumably that won't matter, unless the user can change his permissions while the form is open.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Right, confusing.

I want the page tab to show up, not grayed-out, but not the page itself. For these users it should behave as if there were a When clause on the page tab containing:

=MESSAGEBOX('You're not allowed.....')
RETURN .F.

Currently the disabled page tab confuses some users - "Why is that grayed-out?" The idea is that when they try to get to page 4 they get a clear explanation as to why access is denied.


Jim
 
Hmmm. I thought it was a universally accepted indicator in Windows that if something was grayed out, it was not accessible by the user.

Another option may be to set the caption for that page to an emtpy string. Maybe set the tooltip to display a message that it was unavailable.



-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Dave, of course a grayed-out control is inaccessible to the user, but some users are wondering why.

BTW, the solution I mentioned above is working pretty well.


Jim
 
Hmmm. I thought it was a universally accepted indicator in Windows that if something was grayed out, it was not accessible by the user.
It is universally accepted that if it is grayed out, it's not accessible by the user. The thing is that user would think that it is some kind of a problem or a bug that can be cleared with a call to a support person. And they do. They never think they are not allowed there. So, I guess, a clear message would help.

I actually like the idea of covering the tab with a transparent rectangular shape - but I would like even more the idea of covering the whole contents of the page with an opaque rectangular shape the color of the page with a label on top of it, something like "You are not allowed to view/access this page".
 
Jim,

OK, I can see why you'd not want to disable the tab, and I understand that you want to give the user some feedback when they try to go there. But, personally, I wouldn't use a messagebox. It's like saying: Here's a tab you can click on, but, when you do, I'm going to tell you that you can't click on it after all.

My own choice would be to do what I said earlier: Keep the tab enabled and visible, but hide all the controls except a single label that contains a message that indicates "there's nothing here for you".

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Hello again, a you asked for a similar event for When() I pointed to activate(). Why didn't you asked if you didn't understood that hint?

Page4.Activate()
Code:
if ...user not allowed...
   nodefault
   Messagebox("not allowed")
endif

Bye, Olaf.
 
Olaf,

I very much appreciate your suggestion. However, by the time the Activate is triggered, the user is already on Page4, which is what I want to avoid. Try it.


Jim
 
Sorry, I tried it and it won't show the page.

You may try again:
Code:
o = CreateObject("form1")
o.show(1)

DEFINE CLASS form1 AS form
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"

	ADD OBJECT pageframe1 AS pageframe WITH ;
		PageCount = 4, ;
		Top = 12, ;
		Left = 12, ;
		Width = 348, ;
		Height = 228, ;
		Name = "Pageframe1", ;
		Page1.Caption = "Page1", ;
		Page1.Name = "Page1", ;
		Page2.Caption = "Page2", ;
		Page2.Name = "Page2", ;
		Page3.Caption = "Page3", ;
		Page3.Name = "Page3", ;
		Page4.Caption = "Page4", ;
		Page4.Name = "Page4"


	PROCEDURE pageframe1.Page4.Activate
		If .T. && put your condition here
		   NoDefault
		   MessageBox("access denied")
		EndIf
	ENDPROC

ENDDEFINE

Bye, Olaf.
 
Olaf,

Place a label on Page4 = "This is page 4". When I click the tab for Page4 I get the "access denied" message, and the focus is on the tab for the current page, but I see the "This is page 4" label. Your example seems to work, but only because Page4 is blank.


Jim
 
okay I see, but this is not even all, if you activate other pages, the label stays. It's as if now no other page can be activated again, only the tabs change, but page4 stays the active page. This seems like a real bug.

The only other event that could help then is UIEnable of each control.

Bye, Olaf.
 
Jim, we do this all the time. What we do is a combination of what are already doing and what Mike L suggested.

1. Put all the information on page 4 in a container.

2. Put a label on page 4 whose caption says "You have not been granted permissions to view this information. Contact your supervisor for this right" etc etc

3. In page 4's Activate event put:
This.refresh

4. In the containers refresh method put
this.visible = lRight
(people who are allowed to view this page should have a .T.)

5. In the labels refresh method put
this.visible = !lRight

6. Now if you want to get fancy:
In the pageframe's Init() put
this.pageframe1.page4.caption = iif(lright,"Financials","Restricted ")
you could even change the forecolor of Restricted to red etc.

Thats it...

Keep it simple and friendly for the user

 
Best option from a UI and usability standpoint is to remove the page from the page frame when they don't have access. That way, they don't know what they're not getting.

Craig Berntson
MCSD, Visual FoxPro MVP,
 
Thanks, Craig. But in this particular case we want them to know what they're not getting, and we want them to know why. -Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top