Field Permissions (hide / lock fields by usergroup)

Got something cool to share with AppGini users? Feel free to post it here!
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2019-11-12 09:21

Hi

as AppGini (AG) in the current version 5.81 does not support field specific permissions, I decided to make a start.

I present documentation and code to implement field specific permissions in your own AG application: You can easily LOCK and HIDE fields for specific usergroups. Single users are not supported at this time.

Please see the attached ZIP which contains a PDF with instructions and the code needed.

Installation time: approx. 30 minutes (my guess - please let me know how long it actually took you)

This solution implements a frontend hiding and locking as well as a backend checking. If a users tries to cheat and fiddles around in the code of the page to change values he actually does not have access to (hidden/locked fields) the attempt to save the changes will fail.

Important
This Field Permissions extension requires AppGini Helper! You need to buy AppGini Helper which can be obtained for small money from https://www.bizzworxx.de/en/appgini-helper/
I decided to use Appgini Helper as it is a great script which supports all field types of AppGini and provides many new features to AppGini (AG Forum: viewtopic.php?f=2&t=3206). Please take a look and support Jan Setzer ( jsetzer, memberlist.php?mode=viewprofile&u=9279 ) who is the programmer and great supporter of all users in the AppGini forum.

Look of locked fields:
field_permissions_v5.png
field_permissions_v5.png (7.94 KiB) Viewed 10634 times
Additional contents in your AG application:
field_permissions_v2.png
field_permissions_v2.png (10.63 KiB) Viewed 10634 times
Permission definition A:
field_permissions_v3.png
field_permissions_v3.png (50.13 KiB) Viewed 10634 times
Permission definition B:
field_permissions_v4.png
field_permissions_v4.png (10.31 KiB) Viewed 10634 times
Download
field_permissions_v1.0.zip
(254.74 KiB) Downloaded 200 times
Please post your suggestions and comments, as well as any errors I made in the documentation so that i can correct them.

Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2019-11-20 16:44

Hi,

a small update. I noticed, if you include the code, but do not have any fields in that table that are hidden / locked, you get a JS error. This has been fixed in this version 1.1.

Download
field_permissions_v1.1.zip
(254.18 KiB) Downloaded 228 times
Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

User avatar
a.gneady
Site Admin
Posts: 1089
Joined: 2012-09-27 14:46
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by a.gneady » 2019-11-23 17:59

Thanks for sharing :)
:idea: Calendar plugin: Organize your data into beautiful calendars. NEW
:arrow: Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
:arrow: Summary Reports plugin: Build powerful reports and charts for your AppGini apps.
:arrow: Search Page Maker: Compose user-friendly yet powerful search pages for your AppGini apps.

ckebbell
Posts: 6
Joined: 2020-01-28 18:09

Re: Field Permissions (hide / lock fields by usergroup)

Post by ckebbell » 2020-01-29 11:39

Hi Olaf

Thank you for this wonderful mod (which is really useful to me!)

I have tried to implement it in my application but I don't get anything appear in the field list? The user groups list appears correctly but there are no matches in the tables / fields dropdown.
HideField.JPG
HideField.JPG (40 KiB) Viewed 9940 times
I have attached 2x screenshots, 1 of the table as shown in my local testing environment and 1 of the appgini app (to make sure I got the fields right!) I have followed the PDF instructions step by step (twice, just to make sure I didn't get anything wrong the first time!) so I am not sure what I am doing wrong?
HideFieldtables.JPG
HideFieldtables.JPG (27.76 KiB) Viewed 9940 times
Has this happened to anyone else and can anyone help me with a possible solution?

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-01-29 13:54

Hi ckebbell,

thanks for asking for help. You are the first one to ask anything, so there might be a mistake in my PDF. We both will try to figure it out.
Did you do step 5 of the PDF?
Step 5
Adjust /hooks/db_field_permission.php (created by generating your code)
Step 5.1
Open the file and add directly after the opening with <?php this code:
//Field Permissions Code
if (!function_exists('fill_tmp_tables_fields')) {
    include("hooks/field_permission_tmp.php");
}

This way we make sure the list of tables and fields you can choose from in this table is always regenerated when this file is accessed.

Step 5.2
Look for the function ..._init and
before the line return TRUE; add this line of code:
fill_tmp_tables_fields();
In 5.1 the file field_permission_tmp.php gets included where function fill_tmp_tables_fields is placed. This function is prepared in step 5.2: By calling the function the table tmp_tables_fields should be filled.
The problem seems to be
a) you did not add this to the _init part of the file or
b) some other reason.
I suppose b) - as you said you followed instructions.
Please try to open the tmp_tables_fields table with phpmyadmin (or a similar tool) and see, if the field table_field has some contents.
If not, please try to run some SQL (from phpmyadmin) to see what happens - and if there is a mistake (please report here).
First run this SQL - it should list all tables in your database:

Code: Select all

SHOW FULL TABLES WHERE table_type = 'BASE TABLE';
Then, please run this SQL (I added your tablename BStandards to make this example work). If should show all fields in your table:

Code: Select all

SHOW COLUMNS FROM BStandards
Maybe it helps, when you post screenshots of the SQL output (header + 1 or 2 rows maybe).

So, what happens?
Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

ckebbell
Posts: 6
Joined: 2020-01-28 18:09

Re: Field Permissions (hide / lock fields by usergroup)

Post by ckebbell » 2020-01-30 09:27

Hi Olaf

Thank you so much for replying! I have taken screenshots of each part so you can check whether I have done it correctly? I am not sure whether I have carried out Step 2 correctly and will post screenshots in a separate post.

Steps 5.1 and 5.2:
fieldperms.JPG
fieldperms.JPG (75.84 KiB) Viewed 9903 times
SQL to show Base Tables:
BaseTables2.JPG
BaseTables2.JPG (14.44 KiB) Viewed 9903 times
View of tmp_tables_field
tmptables.JPG
tmptables.JPG (27.45 KiB) Viewed 9903 times
SQL to show columns in an example table:
Columns.JPG
Columns.JPG (40.73 KiB) Viewed 9903 times

ckebbell
Posts: 6
Joined: 2020-01-28 18:09

Re: Field Permissions (hide / lock fields by usergroup)

Post by ckebbell » 2020-01-30 09:30

So this is Step 2, carried out on the Sites table. I am hoping this part is correct? I wasn't sure whether I had to replace tablename with the name of the table, so this is why I am not confident that this part is correct!
Sites.JPG
Sites.JPG (39.51 KiB) Viewed 9903 times
Footer edits:
Sitesfooter.JPG
Sitesfooter.JPG (36.84 KiB) Viewed 9903 times
beforeupdate eit:
beforeupdate.JPG
beforeupdate.JPG (33.06 KiB) Viewed 9903 times

geppoleppo
Posts: 7
Joined: 2015-03-25 13:10

Re: Field Permissions (hide / lock fields by usergroup)

Post by geppoleppo » 2020-01-30 18:25

Hi Olaf

Thank you for your wonderful work.
Everything works fine for me in detail view mode, while in table mode I still view fields checked as "hidden" in the db_field_permissions table: have you got any suggestions to solve the problem? (I have inserted step 2.2b code in tableview, detailview and tableview+detailview).
I think that there is a little mistake in the pdf guide, step 3.4: groupID is simply defined as (Integer, VarChar), while I defined it as integer, setting it to Lookup Field and choosing as Parent table view_membership_groups and as Parent caption field part 1 name.

Thank you again, Paolo

ckebbell
Posts: 6
Joined: 2020-01-28 18:09

Re: Field Permissions (hide / lock fields by usergroup)

Post by ckebbell » 2020-01-31 00:36

Hello, I was reading the other php files to see if I could find anything that might give me a clue. I found that there is a section grayed out in field_permission_base.php
permsbase.JPG
permsbase.JPG (139.41 KiB) Viewed 9859 times
Should it look like this?
The attachment permsbase2.JPG is no longer available
Although I am still unable to see any tables.fields, I was wondering whether this might be part of it?

I am now going to look at field_permission_tmp to see if I can see anything...

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-01-31 09:58

Hi Paolo,

thank you for reporting the error in the PDF. You are correct, I checked with my AG file. The description in 3.4 for groupID should be
groupID (Integer). Set this to Lookup Field and choose as Parent table view_membership_groups and as Parent caption field part 1 name.
Which looks like this
ec2001-04.png
ec2001-04.png (22.75 KiB) Viewed 9841 times
I am attaching an updated version.
Download v 1.14
Sorry, PDF was to large for uploading, please download from here: https://dl.olaf-noehring.de/?t=640be0ec ... 399f112b99


@Paolo: I missed that in my (old) PDF: LOCK and HIDE are applied in Detailview (where users normally are able to edit the data), but not in Tableview (only listing the data as a table) at this time. Sorry for that. But it's an idea I will keep in mind and get on when I find some time.

@ckebbell: Please redo step 3.4 ad described above. Maybe this solves your problem already.
The screenshot of Steps 5.1 and 5.2 looks correct.
The screenshot of SQL to show Base Tables seems to show the correct information - so the permission-script is able to read all tables from your database.
The screenshot of SQL to show columns in an example table also looks correct.
The screenshot of View of tmp_tables_field does not look correct. The table should be empty only before the db_field_permission.php has been run the first time. At this time (as in your screenshot of steps 5.1 and 5.2 correctly set) in the _init function of the file the command fill_tmp_tables_fields() should fill that tmp_tables_field table.
For your screenshot Sites.JPG, I appologize for not being clear enough in the PDF description. I tried to update this in the current version:
Step 2
Open the each file that belongs to a table where you want to use field permissions from the hooks folder in an editor and make the following adjustments in each table. Example: If you have a table named customers, you have to edit the file /hooks/customers.php. For the table articles, you will need to edit the file /hooks/articles.php

You did nothing wrong here: You correctly copied the code from the documentation. I suppose you mean $options->TableName; - here TableName is a variable which does not need to be changed as it is handled by code
The other screenshots of your 2nd posting seem ok at first glance.

Yes, the greyed out part is correct. There the php variable $extraJS_Disable_Field_Timer is defined. The grey stuff is the contents of that variable, the pad_field_permissions ... is again php code which inserts the list of locked fields as comma seperated valued into that variable where each value is included in " . Example: "firstfield","secondfield"

I believe redoing step 3.4 will not solve the problem, but please try. What version of PHP and MySQL are you using?
I have attached a special file you (ckebbell) you for testing: field_permission_tmp_TEST.zip. If step 3.4 does not solve your issue, please try the following:
1. Download field_permission_tmp_TEST.zip and extract.
2. Rename extracted file to field_permission_tmp.php (name is now same as in the "real" field-permissions).
3. Upload this new file to the /hooks directory and overwriting the existing file.
4. Please open the db_field_permissions in your browser as you have done before.
5. The new file fill be called and create a file app.log either in your hooks or your root directory.
6. Please send me that log file in a PN, I will take a look how far the script handles the data and where it fails. (The app.log is a simple text file, you can check it out using notepad++).

Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

ckebbell
Posts: 6
Joined: 2020-01-28 18:09

Re: Field Permissions (hide / lock fields by usergroup)

Post by ckebbell » 2020-01-31 21:44

Hi Olaf

Thank you so much for your detailed answer :D

I am carrying out testing in a local environment, so I can wipe everything and generate a brand new version tonight. It may be that because I had already generated the app and carried out some work (uploading data via csv, changing some hooks) that maybe the addition of the HideFields mod didn't work correctly?

I had already guessed the steps mentioned by Paolo above (the field type and caption) so mine looks the same in Appgini.

There is no attachment called field_permission_tmp_TEST.zip that I can see to download in your post? I have downloaded the v1.14 but it looks like just a PDF? I will try re-generating anyway and if that doesn't work I will try the log file and send to you (if you can please upload it?)

I am using PHP 7.1.1 and MySQL 5.6.34 (latest version of xampp, I think?)

Thank you!

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-02-01 06:39

Hi,

sorry, forgot to upload the test file See attachment to this post.
field_permission_tmp_TEST.zip
(1.34 KiB) Downloaded 185 times
Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

geppoleppo
Posts: 7
Joined: 2015-03-25 13:10

Re: Field Permissions (hide / lock fields by usergroup)

Post by geppoleppo » 2020-02-01 20:02

Hi Olaf,

to hide fields in table view I have followed the procedure I found here: https://bigprof.com/blog/appgini/how-to ... ser-group/
Probably it's not the best way to solve the problem, but it's enough for my needs at the moment.

Thanks, Paolo
onoehring wrote:
2020-01-31 09:58
@Paolo: I missed that in my (old) PDF: LOCK and HIDE are applied in Detailview (where users normally are able to edit the data), but not in Tableview (only listing the data as a table) at this time. Sorry for that. But it's an idea I will keep in mind and get on when I find some time.

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-02-02 16:45

Hi Paolo,

thanks for pointing this out. I will try to implement it, but I am working on a small update for some other software I am offering for free: PowerPoint Progress Indicator (maybe this can be of use for someone here ;-) ). Once that update is done, I will get on the field permissions again.

Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-02-02 17:09

Hi Paolo,

I have read the blog post, and I am not sure if I will (try to) use that or simply do a JS solution. The problem I see with this post is, that it seems the field-permissions-script would need to regenerate/copy a lot of files for an application.
I must admit, that I developed the script for a closed user group where certain users should have more permissions than other and hiding fields might make editing for some groups easier. Thus I did not care to much about hiding fields directly on the serverside, but just hiding them with JS. Every user could open the console /html and still see original data. A change of locked data is not possible as this is checked on the backend when the users tries to save.
As I tried to make field-permissions universal, I will probably not use the approach described in the blog. Maybe, just maybe - if I decided to walk this way, I might combine the blog approach with JS: I could hide data using JS and replace this data before publishing it on the page. Instead of the customer ID the data in that column might be "0", and JS hides that column. This way, noone could see actual data even when looking at the code. No other files would need to be changed installing the field-permissions script. .... Well, did I explain this in an understandable way? I hope so.

Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

User avatar
aarlauskas
Veteran Member
Posts: 58
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: Field Permissions (hide / lock fields by usergroup)

Post by aarlauskas » 2020-02-28 18:14

I'm pulling my last hair out... Why is this not working for me :D All the new created tables displays groups, tables and fields, DB Field Permission feels like doing its job, lets you select field, select option lock/hide, but nothing really locks or hides for the selected field. It looks like really insane job done by Olaf and I wish I could get this to work.. Such a great tool. I have followed the PDF several times, tried in local mode and uploaded on hosting server where my site is, still no luck. Please help, I want this so bad :D

Thanks Olaf.

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-02-29 08:32

Hi aarlauskas,

before you are getting balled, tell me some details, what does when not work?
Please note, that the hide/lock at this time do only work in detail view of the table (or in table+detail) - but not in the "table"-part. This has been described and is on my todo list.
If I understand you correct, you do see the table*field list where you can choose hide/lock for the fields.
Did you touch all files where the field permissions should be set / put to work and insert the code as described in the latest docs (1.14)?
Have you purchased the AppGini Helper from jsetzer?
So, fields do not hide in detail view?
And fields do not lock in detail view?

Did you try to remove all files from the server and upload all of them again? Did you clear your browser cache and did you try another browser?

What php version are you using? I have tested it on php7.something.

Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

User avatar
aarlauskas
Veteran Member
Posts: 58
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: Field Permissions (hide / lock fields by usergroup)

Post by aarlauskas » 2020-02-29 22:04

Hi Olaf. Yes you do understand correct, the interface seems like its fine, you can see the tables*fields, select lock/hide, then log on with the user in that ‘locked/hidden’ group, but they can still do anything they like with this field. I did try all suggestions from here, but the result is the same. I did this now for the fifth time, generated new test app, uploaded into empty directory, nothing.
I did follow your latest 1.14 doc.
All configured as per your script (I think the instructions are very clear).
I have Appgini Helper from Jan.
I don’t care about Table View.
PHP Version 7.3
Tried different browsers, clearing cache, refreshing etc.
I know the Appgini Helper is working as I do use some of the Jans code in same tables.
I was just thinking, could it be the older Appgini Helper that you configured your script on? Based on Jans log he did change the name of the helper and that also happened 11.2019, the same sort of time you published you script here?
helper_name.png
helper_name.png (17.44 KiB) Viewed 9372 times
Interface
db_interface.png
db_interface.png (27.91 KiB) Viewed 9372 times
db_fields.png
db_fields.png (35.58 KiB) Viewed 9372 times
I can use the below, (not sure if its yours or P. Botchers) to hide some fields manually, but it only does text field.. So your solution would be Game Changer if it worked.

Code: Select all

function table_name_footer($contentType, $memberInfo, &$args){
		$footer='';

		switch($contentType){
			case 'tableview':
				//$footer='';
if ($memberInfo['group'] != 'Admins') {
	$footer="<%%FOOTER%%><script>\$j('#field_name,#site_name').attr('readonly','true')</script>";
}
else $footer='';
				break;

			case 'detailview':
				//$footer='';
if ($memberInfo['group'] != 'Admins') {
	$footer="<%%FOOTER%%><script>\$j('#field_name,#site_name').attr('readonly','true')</script>";
}
else $footer='';
				break;

			case 'tableview+detailview':
				//$footer='';
if ($memberInfo['group'] != 'Admins') {
	$footer="<%%FOOTER%%><script>\$j('#field_name,#site_name').attr('readonly','true')</script>";
}
else $footer='';
				break;

			case 'print-tableview':
				$footer='';
				break;

			case 'print-detailview':
				$footer='';
				break;

			case 'filters':
				$footer='';
				break;
		}

		return $footer;
	}
Thanks Olaf.

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-03-01 11:58

Hi aarlauskas,

please try the following
open field_permission_base.php with your editor
Search for

Code: Select all

$extraJS_Start  . "\n\n\n" . $extraJS_End){
(somewhere in the end of the file, last couple of lines)
replace the complete line with this

Code: Select all

if ($extraJS_field_permission == $extraJS_Start  . "\n\n\n" . $extraJS_End){
Does it work now?

If yes, I will post a new version for all others.


Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

User avatar
aarlauskas
Veteran Member
Posts: 58
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: Field Permissions (hide / lock fields by usergroup)

Post by aarlauskas » 2020-03-01 13:41

Hi Olaf, YES IT DOES!!!!! Happy Days. That gives totaly new face for our Appgini! :D Thanks a lot for this! The below is your fantastic script in action. Locking or hiding lookup fields , Finally.

https://youtu.be/rZAZIOERcRc

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-03-01 14:12

Hi aarlauskas,

thanks for the feedback and for screencasting.
For all here is the new version. I missed a small - but important - bug so far. Instead of doing == I only did = in a php comparison. Sorry for that.
For everyone who is using the add-on already: You can simply upgrade by replacing the old files from the plugin with the files in the new downloadable zip.
For all people new to this plugin, simply download and follow installation instructions

Download 1.15
Sorry, file to large for uploading, so please download here: https://dl.olaf-noehring.de/?t=f86b6659 ... 06ab9ee98e

Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

ibirdsey
Posts: 1
Joined: 2020-03-01 14:36

Re: Field Permissions (hide / lock fields by usergroup)

Post by ibirdsey » 2020-03-01 17:08

Olaf,

I have created all the relevant files and uploaded accordingly, but when i get to the "ReadySetGo" part all i get is a blank screen in different web browsers

any thoughts or ideas would be most welcome

Thank you

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-03-02 07:40

Hi,

please give some more details, so that we can tap forward to finding the solution and we are not searching the needle in a haystack.
  • Did you follow all instructions?
  • Some more detailed things to check:Did you clear your browser cache?
  • Do you have the AppGini Helper plugin from Jan (it is not needed to define lock/hidden, but to actually not show the hidden/locked fields)?
  • Are the needed files (step 1) in your /hooks folder?Please check (using phpmyadmin or similar), that the tables from your AG application have been generated and that the view (step 3) is there.
  • Did you create your AG application (Step 4) and then made the changes as described in step 5?
  • You you have permissions (AG) to access the db_field_permission table?
Might also come in handy: What versions are you using?
AppGini
MySQL
PHP

Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

User avatar
aarlauskas
Veteran Member
Posts: 58
Joined: 2019-04-28 18:03
Location: Medway, UK

Re: Field Permissions (hide / lock fields by usergroup)

Post by aarlauskas » 2020-03-02 08:35

Hi Olaf, just a very quick one (not an issue), I have a 'Traffic Lights'' in table view, it changes the color of the row based on field value. I have noticed when applying Lock status on the field (not the one that is assigned to Traffic Lights), it kills the script, no more colors in that row. I have deleted the code in table_name_footer from Tableview line and that seems to be ok now. This is not really required as there is no change to table view anyway. Thanks again for your hard work here :)
footer_New.png
footer_New.png (18.58 KiB) Viewed 9301 times
Now all ok.
traffic_lights.png
traffic_lights.png (8.03 KiB) Viewed 9301 times

onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 541
Joined: 2019-05-21 22:42
Contact:

Re: Field Permissions (hide / lock fields by usergroup)

Post by onoehring » 2020-03-02 12:07

Hi aarlauskas,

good point. I did not think about this, but you are correct. At this time it does not matter for the table-view at all - I am planning to implement some comment from above, so that hidden fields are actually hidden in table view as well. Then it might matter.
But still strange. I have something similar in a table and the field-permissions does not kill the JS formating

I am using this

Code: Select all

//Farbige Hintergründe abhängig vom Feldinhalt (ID_posZ)
$j(function () {
	$j('.ecomo_container-ID_posZ').each(function(){ 
		var ebene = $j(this).text();
		
		var new_CSS_basename = "ebene_";
		var new_CSS_class = new_CSS_basename.concat(ebene);
		
		$j(this).parents('tr').addClass(new_CSS_class);
	})
});
in hooks/tablename-tv.js to add a css class to each row. The class is different (ebene_1, ebene_2 etc.), depending on the value in the field ID_posZ
Looks like this:
ec202003_01.png
ec202003_01.png (6.16 KiB) Viewed 9289 times
Strange.

Olaf
Some postings I was involved, you might find useful:
Backup your database (viewtopic.php?f=4&t=3341); Improve security (viewtopic.php?f=4&t=3168); Field Permissions (viewtopic.php?f=4&t=3308); Custom (error) message (viewtopic.php?f=7&t=1740&p=10871#p10906); Audit Log (viewtopic.php?f=4&t=1369&p=10407); Two Factor Authentication (viewtopic.php?f=7&t=3306&p=11478); Add 2nd SAVE CHANGES button (viewtopic.php?f=2&t=3242&p=11104); Place a search on details view (viewtopic.php?f=2&t=3479&p=12484#p12484); Column-Value-Based-Permissions (viewtopic.php?f=4&t=3498)

Post Reply