Custom Table Permission

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

Custom Table Permission

Post by Bishu »

I am trying to give a LIST permission to all the user who are login to my site
Trying code and error I got are -

1) In the User_Level_Loaded
if(Security()->IsLoggedIn()){
$this->AddUserPermission($this->GetUserLevelName(CurrentUserLevel()), "info", ALLOW_LIST);
}
I got the error as "Fatal error: Call to a member function IsLoggedIn()".

2) Under the TablePermission_Loaded

if(Security()->IsLoggedIn()){
if(CurrentTable()->TableName == "info")$this->setCanList(TRUE);
}
I got the error as "Notice: Trying to get property of non-object"
//In this second case I am unable to get the object CurrentTable()


mobhar
User
Posts: 11746

Post by mobhar »

Please change "CurrentTable" to "CurrentPage" and try again.


mobhar
User
Posts: 11746

Post by mobhar »

Bishu wrote:
if(Security()->IsLoggedIn()){

If you're using v2019 and you use the Security object, then you need to change "IsLoggedIn" to "isLoggedIn" (case-sensitive).

However, that code above can be simply changed also to:
if (IsLoggedIn()) {


Bishu
User
Posts: 429

Post by Bishu »

The 2nd option is working but for the first option it is not working
I am unable to get the security object at Global->UserLevel_Loaded
I try as
if(Security()->IsLoggedIn()){
and also
if (IsLoggedIn()) {

Unable to check the User is login or not at UserLevel_Loaded


arbei
User
Posts: 9410

Post by arbei »

You may try change Security() to $this. TablePermission_Loaded and UserLevel_Loaded are members of the security class.


Post Reply