Field Permissions (hide / lock fields by usergroup)

Got something cool to share with AppGini users? Feel free to post it here!
User avatar
lramirez
Veteran Member
Posts: 72
Joined: 2019-11-01 23:23

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

Post by lramirez » 2024-01-24 20:06

Hello Olaf,
excuse my English..
I have observed that in the latest versions of AppGini 23, something happens in the FIELD PERMISSIONS configurations (V1.15) and it does not block the fields, it just hides them, sometimes yes or sometimes no. Could it be something that was reconfigured? :cry:

thank you for your time
Luis Ramirez R.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1210
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2024-02-06 10:26

Hi,
I want to apologize for not seeing your replies sooner.

@urichard: If i remember correct: yes, you do need Jan's add on.

@lramirez: Thanks for letting me know. I might check this out in the next couple of days, but I will test only on the latest AG (24.10 rev 1579). It does not make sense to test older software.
It may depend on the field type. Can you please post more details where what problems occur. Thanks.

Olaf

hannah.kkp
Posts: 2
Joined: 2024-09-18 10:34

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

Post by hannah.kkp » 2024-10-21 03:40

Hello Olaf and friends!
I've new to the forums but have been using appgini for a few years.
I'm not the best coder but I've made do with appgini throughout the years but I seriously need some help this time. :(
I've been trying to implement field permissions and have tried every version with a similar problem.
I have reset my database and redone it step-by-step multiple times!

View_membership_groups = Good
but my tmp_tables_fields table is empty and so my db_field_permissions won't load.

If I don't do step 5 and erase/remove these:
Image

Code: Select all

<?php
//Field Permissions Code
if (!function_exists('fill_tmp_tables_fields')) {
	include("hooks/field_permission_tmp.php");
	}
	// For help on using hooks, please refer to https://bigprof.com/appgini/help/advanced-topics/hooks/

	function db_field_permission_init(&$options, $memberInfo, &$args) {
		fill_tmp_tables_fields();
		return TRUE;
	}

Then the db_field_permissions table will load but the tmp_tables_fields is still blank.
Image
Image


I ran these sql and everything seems to be fine in the backend. (photos attached)

Code: Select all

SHOW FULL TABLES WHERE table_type = 'BASE TABLE';

Code: Select all

SHOW COLUMNS FROM BStandards
Image
Image

Is there something wrong with the calling of my function fill_tmp_tables_fields(){
or
am I doing something wrong?

Please help I'm stressing! I believe the field settings are a bit off as well but i don't think it's causing this issue.
Image

I've read through the others comments but couldn't find a solution. (I believe "ckebbell" back in 2020 may have had a similar issue but the solution was not posted.)

V.1.21 field permissions script with Appgini 24.17

Thank You.
(Also, I'm a big fan of all of the appgini team and am excited to finally be able to post and advance. Thank you for your time and all your continued hard work!)

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 354
Joined: 2018-03-04 09:30
Location: David

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

Post by D Oliveira » 2024-10-23 17:07

Try chaging updateDB.php directly, edit the column definitions in the php file and appgini will be happy

hannah.kkp
Posts: 2
Joined: 2024-09-18 10:34

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

Post by hannah.kkp » 2024-10-23 18:47

Hi D Oliveira,

I'm assuming you mean for me to edit this code for the tmp_tables_fields.

Code: Select all

		setupTable('view_membership_groups', [
				" ALTER TABLE `view_membership_groups` CHANGE `allowSignup` `allowSignup` TINYINT NULL ",
				" ALTER TABLE `view_membership_groups` CHANGE `allowSignup` `allowSignup` TINYINT(4) NULL ",
				" ALTER TABLE `view_membership_groups` CHANGE `needsApproval` `needsApproval` TINYINT NULL ",
				" ALTER TABLE `view_membership_groups` CHANGE `needsApproval` `needsApproval` TINYINT(4) NULL ",
				" ALTER TABLE `view_membership_groups` CHANGE `name` `name` VARCHAR(100) NULL ",
				"ALTER TABLE `view_membership_groups` DROP INDEX `name_unique`",
				" ALTER TABLE `view_membership_groups` CHANGE `groupID` `groupID` INT(10) NOT NULL ",
				" ALTER TABLE `view_membership_groups` CHANGE `groupID` `groupID` INT(10) UNSIGNED NOT NULL ",
				" ALTER TABLE `view_membership_groups` CHANGE `groupID` `groupID` INT(10) UNSIGNED NOT NULL DEFAULT '0' ",
			]);

		setupTable('tmp_tables_fields', []);

		setupTable('db_field_permission', []);
		setupIndexes('db_field_permission', ['groupID','table_field',]);

Unfortunately, I am unsure how I am supposed to edit the tmp_tables_fields to call my table fields.. as the script is supposed to do.
Could you maybe elaborate on how I can solve this?


I even tried to alter view_membership_groups in the updateDB.php to match the database definitions, to not avail. I don't know why it says I have 2 errors to fix. but the pdf says to have groupID as the primary key so I'm just going to leave it for now.
Image

I've reentered Step 5 into my db_field_permissions.php and it is still not loading as shown.
Image
TMP FIELDS not called.
Image

Any advice would be much appreciated!
Thanks!!
Hannah

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1210
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2024-10-23 22:43

Hi Hannah and all,

currently I can not take part in solving the problem, sorry. I am following this thread however and will post once I have the chance to try myself.
Olaf

User avatar
lramirez
Veteran Member
Posts: 72
Joined: 2019-11-01 23:23

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

Post by lramirez » 2024-12-09 18:52

Hello... I use xampp with version php7, but I updated to php8 and now I get this error:

Fatal error: Uncaught Error: Call to undefined function fill_tmp_tables_fields() in C:\xampp\htdocs\myApp\hooks\db_field_permission.php:11 Stack trace: #0 C:\xampp\htdocs\myApp\db_field_permission_view.php(113): db_field_permission_init(Object(DataList), Array, Array) #1 {main} thrown in C:\xampp\htdocs\myApp\hooks\db_field_permission.php on line 11

I returned to php 7 and the error no longer appears and everything works fine... what could be happening?

I use the latest version of appgini and the most recent version of the appgini helper library.

THANKS..
Luis Ramirez R.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1210
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2024-12-10 06:29

Hi Iramirez,

just looking at your post. Seeing

Code: Select all

 Call to undefined function fill_tmp_tables_fields()
makes me ask if you have copied all files correctly:

field_permission_base.php
field_permission_functions.php
field_permission_table_init.php
field_permission_tmp.php

The last file contains a function with this name.

I suppose you followed the docs

Code: Select all

3.4 Now we need to create the table to define field permissions
Create a table db_field_permission
and

Code: Select all

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.
Thus, you have added the include?

Olaf

User avatar
lramirez
Veteran Member
Posts: 72
Joined: 2019-11-01 23:23

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

Post by lramirez » 2024-12-10 20:34

Hi OLAF, I have everything correctly configured with XAMPP 7.4.30 and everything has worked fine... but when I update to version 8, the aforementioned error occurs. And if I go back to version 7, everything works fine again.
Attachments
table_fields.png
table_fields.png (62.26 KiB) Viewed 948 times
Luis Ramirez R.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1210
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2024-12-11 07:46

Hi,

just a quick shot in the morning.
Maybe it's php8 which wants a more specific include path.
Try this for once please

Code: Select all

$hooks_dir = dirname(__FILE__);
if (!function_exists('fill_tmp_tables_fields')) {
    include("$hooks_dir/field_permission_tmp.php");	
}
(code not tested).
IF this works, this code needs to go into other places as well as I seem to check for the existing function in all files that use it.
Please report back if this solves the problem. Thanks

Olaf

Post Reply