This topic is locked

User management

12/1/2010 11:35:12 AM
PHPRunner General questions
D
dara author

Hello i have an important question here.
I need to add a user that can only see some fields of a table so i added some fieldblock and added this code on Before Display :

$userid = $_SESSION["UserID"];

if (($userid=="olivier"))

{

$xt->assign("identite1_fieldblock",true);

$xt->assign("identite2_fieldblock",true);

$xt->assign("adresse_telephone_fieldblock",true);

}

else {

$xt->assign("identite1_fieldblock",false);

$xt->assign("identite2_fieldblock",false);

$xt->assign("adresse_telephone_fieldblock",false);

}


so every user else than "olivier" cannot see these fieldblock and this works perfectly fine for view Page.
But Now the new user need to add some entry in the table and to be able to edit all the fields of the entry he added

i cannot find the variable which gives me the user who created this entry in the table.
i suppose there is a way to create users whithout doing this every time but i didn't manage to find how to do it so i had to do it with the "Before Display" code.
Thanks for all your help.
Dara

J
Jane 12/1/2010

Dara,
to check user who created this entry add new field (for example CreatedBy) to this table in the database.

Then set up default value for this field as $_SESSION["UserID"] on the "Edit as" settings dialog on the Visual Editor tab. You can set up this field as readonlyso user can't edit this value.
Then check value from this field on the edit page in your event and hide or show fields if needed.

D
dara author 12/1/2010

Jane, thanks for your advice , i already thought about that. thanks to confirm this idea.
I wanted to know if there is any other way to manage the user more easily( by the client in the best case)or by me but whitout having to change the code everytime like this.
Thanks again.

D
dara author 12/2/2010

hello i tried many ways but i don't manage to make it work :
i created the field createdby but it cannot make the test to see if
$_SESSION["UserID"]==$values["createdby"]

it tells me undefined variable values.
i tried to set a global $created;

$_SESSION["UserID"]==$created["createdby"]

it doesnt work.
i also tried :

global $created;

$userid = $_SESSION["UserID"];

if (($userid=="olivier"))

{

$xt->assign("identite1_fieldblock",true);

}

else {

$xt->assign("identite1_fieldblock",$_SESSION["UserID"]==$created["createdby"]);

}


how can i get the value of a variable on : BeforeShowEdit Edit Page : Before Display ?
Thanks
Dara

Sergey Kornilov admin 12/2/2010

BeforeDisplay event doesn't provide access to $values array so it needs to be handled some other way.
I would ask you to post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL so we can find the best way to implement this.