Click here to Skip to main content
15,913,773 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have a list of reports in my reports section in which some reports are only meant for the top level management. I don't want the middle level users to view these reports. How can I achieve that in PHP? Like for example I have a reports section MANPOWER which has multiple sub reports but some of them should be only visible to top management and I am retrieving the list of these reports from an XML file.

Thanks in advance..
Posted
Updated 29-Mar-10 0:30am
v2

Pulling data from a database? As in, users of this type (or a particular user) is allowed to view a report but not another?

e.g.

Table:
Users:

UserID: int
UserName: nvarchar(50)
UserReports: int


Reports:

ReportID: int
ReportName: nvarchar(150)


UserReports:
UserID: int (fk rel Users.UserID)
ReportID: int (fk rel Reports.ReportID)
CanView: bit



Of course, on windows you'd be so much better of using domain groups and policies. This is a hack
 
Share this answer
 
Dear Ismail,
I got your point but then how will i maintain the permission level..
Whenever i create a new user i am planning something like putting a conbobox their and then putting the values like "Top Mngt","Middle Mgnt","Lower Mgnt" etc.
So if i select the user to be top Mgnt then he should be able to see all the reports or whatevert and if user is middle level then limited and like that..
Can u suggest me a way to do that..
Jazakallah Khair
 
Share this answer
 
Dear khanishfaq82,

I think Ismail has already shown you clear cut way to do you job. Use database tables to store all the users with their priority level. And when page is loaded for particular user check his priority in that table and decide according which reports you want to show for that priority.
And one more thing, you are saying user will select priority from drop down menu and you will show reports. Then what will you do if lower lever person select priority of higher management. You have to store somewhere that which user belongs to which priority group. (you can use some other method to store user-priority information like xml or plain text file. But you need that information to fetch appropriate report for a user.)

Hope you got Ismail and my point.
 
Share this answer
 
khanishfaq82 wrote:
Dear Ismail,
I got your point but then how will i maintain the permission level..
Whenever i create a new user i am planning something like putting a conbobox their and then putting the values like "Top Mngt","Middle Mgnt","Lower Mgnt" etc.
So if i select the user to be top Mgnt then he should be able to see all the reports or whatevert and if user is middle level then limited and like that..
Can u suggest me a way to do that..
Jazakallah Khairadvance



Easy :)

You need a user management or maintenance page. This way, even if you have promotions from one level to another (or demotions even), you can still maintain that information in the database.

Now, you can also use a numeric comparator to facilitate this implementation.

So, it would be like setting "Monthly cash flow report" to level 2. This would mean that anyone with a privilege of level 2 or greater has access to this page. This then simplifies the comparison after retrieving the data, you would do something as follows

if(user.Privilege >= privilege)
   GiveAccess();
else
  AccessDenied();


Where privilege is the variable that contains the returned privilege value from the database.

I hope that answers your question and if it does then please, mark this thread as answered.

If you have more questions, we'll be more than happy to help :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900