Add User Level

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
rman3112
User
Posts: 12

Add User Level

Post by rman3112 »

Hallo,
I have table user like this :
CREATE TABLE users (
EmployeeID INT(11) NOT NULL AUTO_INCREMENT,
LastName VARCHAR(20) NULL DEFAULT NULL,
FirstName VARCHAR(10) NULL DEFAULT NULL,
Email VARCHAR(30) NULL DEFAULT NULL,
Photo VARCHAR(255) NULL DEFAULT NULL,
Password VARCHAR(50) NOT NULL DEFAULT '',
SexVARCHAR(1) NULL DEFAULT NULL,
UserLevel INT(11) NULL DEFAULT NULL,
Username VARCHAR(20) NOT NULL DEFAULT '',
Activated ENUM('Y','N') NOT NULL DEFAULT 'N',
PRIMARY KEY (EmployeeID),
UNIQUE INDEX Username (Username)
)
COLLATE='utf8_general_ci'
ENGINE=MyISAM
ROW_FORMAT=DEFAULT
AUTO_INCREMENT=10

Example if i used this function :
function TablePermission_Loading() {
if (CurrentUserName() == "nancy")
$this->AddUserLevel("Manager");
}
this is can work well.

but i want to add user level is based "Sex" , so that i add userlevel is "Male" and this function become :
function TablePermission_Loading() {
if (CurrentUserInfo("Sex") == "1") //assumed value "1" is male
$this->AddUserLevel("Male");
}
but can't work.
is there someone who can help me?
Thank You very much.


mobhar
User
Posts: 11741

Post by mobhar »

It might be clash with the current user level that belongs to the user.

So, try this:

  1. Make sure you have already created a user level named "Male" from your "userlevels" table.
  2. Make sure you have already given the permission to the "Male" user level, from the generated "userpriv.php" page.
  3. From your "users" table, just assign "Male" user level to the users who have value of "1" in their "Sex" field.

This should fix your issue.


rman3112
User
Posts: 12

Post by rman3112 »

Thanks Mobhar for your response

I am sure it has been added a user level named "male" in my "userlevel" table.
because i'm not programming, I don't know how to given the permission to the "Male" user level in "userpriv.php".

Is there a sample script that you recommend and where do I put the script?

Thank's


mobhar
User
Posts: 11741

Post by mobhar »

No need to customize any script. As I mentioned before, you need to access your generated web app, simply open/go to "userpriv.php" page.

You may try using the demo website that provided by PHPMaker, login using username "admin" and password "master".
http://download.hkvstore.com/phpdemo10/login.php

Then, go to "Admin Only" -> "userlevels", afterwards, click on "Permission" link that belongs to your desired user level. For example, when you click on "Permission" link that belong to "Sales" user level which has value of userlevelid = 1, then the URL of userpriv.php page will become: "userpriv.php?userlevelid=1".

In the next page, you can simply define the permissions that belong to its user level. Do the same way in your web app.


rman3112
User
Posts: 12

Post by rman3112 »

Thank's mobhar
i'm sorry if i'm give not enough information
if i before writed :
"Example if i used this function :
function TablePermission_Loading() {
if (CurrentUserName() == "nancy")
$this->AddUserLevel("Manager");
}
this is can work well."

for example : username is "nancy". she has two userlevel (i assumed = "sales" + "Manager")
I want to each 1 username have 2 userlevel or more (multiple userlevel)
but not be accepted from field username but accepted from field Sex

Thanks


mobhar
User
Posts: 11741

Post by mobhar »

For such case, then you should create a new User Level which contains the combination of permission from "sales" and "Manager" user levels. Just assign the new user level to your desired users.


Post Reply