This topic is locked
[SOLVED]

 Restrict views to different users

8/17/2019 1:18:01 AM
PHPRunner General questions
A
AndrewMark author

In Designer , if I add additional view pages eg View1 and View2 or list1 and list 2 for the same table, is it possible to restrict different user groups to be able to only see this restricted list or view when they login. eg Admin can only see View1, Customer can only see View2 etc.. If so, is there some instruction on the code required to implement this?
I found the following article https://xlinesoft.com/blog/2019/03/05/page-designer-frequently-asked-questions-answered/ but it did not completely explain this.

J
jacques 8/17/2019



In Designer , if I add additional view pages eg View1 and View2 or list1 and list 2 for the same table, is it possible to restrict different user groups to be able to only see this restricted list or view when they login. eg Admin can only see View1, Customer can only see View2 etc.. If so, is there some instruction on the code required to implement this?
I found the following article https://xlinesoft.co...tions-answered/ but it did not completely explain this.


Look at the blog
https://xlinesoft.com/blog/2015/12/04/storing-field-labels-and-visibility-rules-in-the-database/
add a field for wich usergroup you want to hide the field/column.

combine this with usergroups then the possibilities are limitless

A
AndrewMark author 8/17/2019



Look at the blog
https://xlinesoft.com/blog/2015/12/04/storing-field-labels-and-visibility-rules-in-the-database/
add a field for wich usergroup you want to hide the field/column.

combine this with usergroups then the possibilities are limitless



Thanks, this blog seems to be about visibility rules for fields. What I am trying to achieve is visibility rules for a complete View page in a table ie the layout design as well as the fields. so View1 may have a very different design layout to View2. Can this blog apply to the "complete view" not just which fields are included or excluded?

D
david22585 8/17/2019

I would just add a new custom view with only the page that you need and restrict the access on that page.

A
AndrewMark author 8/17/2019



I would just add a new custom view with only the page that you need and restrict the access on that page.



Thanks. I have already created the different views with additional view pages in Designer, which I understand has mainly superseded custom views. The question is how do I set it up to restrict access to different users for the different view pages?

A
acpan 8/17/2019

I don't think there is option to assign additional views to different groups at the moment in phprunner.
"additional view pages in Designer superseded custom views" => Actually you can just create unlimited number of views and name them differntly and assign to different groups.
In general, these are the 3 methods i can think of:
Method 1:
Try checking group permission and redirect to the additional views as per user group.
https://phprunner.com/phprunner/docs/secapi_get_user_group.htm
Method 2 (same as what mentioned above):
Create another seperate veiw with a seperate view name and assign the view permission to the user groups.
https://phprunner.com/phprunner/docs/user_group_permissions.htm
Method 3:
Create seperate app (with different views) for different user groups.
ACP

A
AndrewMark author 8/17/2019



I don't think there is option to assign additional views to different groups at the moment in phprunner.
"additional view pages in Designer superseded custom views" => Actually you can just create unlimited number of views and name them differntly and assign to different groups.
In general, these are the 3 methods i can think of:
Method 1:
Try checking group permission and redirect to the additional views as per user group.
https://phprunner.com/phprunner/docs/secapi_get_user_group.htm
Method 2 (same as what mentioned above):
Create another seperate veiw with a seperate view name and assign the view permission to the user groups.
https://phprunner.com/phprunner/docs/user_group_permissions.htm
Method 3:
Create seperate app (with different views) for different user groups.
ACP


Thanks, you mentioned "you can just create unlimited number of views and name them differntly and assign to different groups" This is exactly what I am trying to achieve but I could not see how to do this in the links you sent. I know how to create the different view and how to name them differently. What I cant figure out is how to assign them to the different user groups. After creating multiple views in Designer and then going into Security Permissions , it only displays the option to select one View. Also what I read in the links you sent seemed to always restrict the assignment permission to only 1 View option, 1 Edit option, 1 Add option etc.. per table, rather than eg 4 View options, 1 Edit option etc.... So I do not know how to select a view for assignment other than the default one created in Designer.

A
acpan 8/18/2019

Create unlimited views:
"After creating multiple views in Designer" => You don't do it Desginer.
Open Phprunner Project, go to Table => right click a table you want, select Add custom view. (this is also same as what david22585 suggested).
ACP
P.S. Try breaking your sentences, so that people who help you have a better times reading what you mean.

J
jacques 8/18/2019



Create unlimited views:
"After creating multiple views in Designer" => You don't do it Desginer.
Open Phprunner Project, go to Table => right click a table you want, select Add custom view. (this is also same as what david22585 suggested).
ACP
P.S. Try breaking your sentences, so that people who help you have a better times reading what you mean.


I my case I added a column hide_group to the query to the example in the blog

  • utf8;


[font="Consolas, Courier New, Courier, mono"]
[font="Consolas, Courier New, Courier, mono"]
[font="Consolas, Courier New, Courier, mono"]
global $strTableName;

$niveau = Security::getUserGroup();
$sql="select * from display_table_field where tablename='".$strTableName."'";

$rs = CustomQuery($sql);

while ($data = db_fetch_array($rs)) {

if ($data["visible"]!=1) {

$pageObject->hideField($data["field"]);

}
// ================ add this to the given example

if(!empty($niveau ));

{

$pos = strpos($data["hide_group"], $niveau );

if($pos!== false)

{

$pageObject->hideField($data["field"]);

}

}

// ================ add this to the given example
}
[font="Consolas, Courier New, Courier, mono"]
[font="Consolas, Courier New, Courier, mono"]

A
AndrewMark author 8/18/2019



Create unlimited views:
"After creating multiple views in Designer" => You don't do it Desginer.
Open Phprunner Project, go to Table => right click a table you want, select Add custom view. (this is also same as what david22585 suggested).
ACP
P.S. Try breaking your sentences, so that people who help you have a better times reading what you mean.



thanks, got it now!

A
AndrewMark author 8/18/2019



I my case I added a column hide_group to the query to the example in the blog
thanks

  • utf8;
    [font="Consolas, Courier New, Courier, mono"]
    [font="Consolas, Courier New, Courier, mono"]
    [font="Consolas, Courier New, Courier, mono"]
    global $strTableName;

    $niveau = Security::getUserGroup();
    $sql="select * from display_table_field where tablename='".$strTableName."'";

    $rs = CustomQuery($sql);

    while ($data = db_fetch_array($rs)) {

    if ($data["visible"]!=1) {

    $pageObject->hideField($data["field"]);

    }
    // ================ add this to the given example

    if(!empty($niveau ));

    {

    $pos = strpos($data["hide_group"], $niveau );

    if($pos!== false)

    {

    $pageObject->hideField($data["field"]);

    }

    }

    // ================ add this to the given example
    }
    [font="Consolas, Courier New, Courier, mono"]
    [font="Consolas, Courier New, Courier, mono"]


Thanks