Disable CSV export?

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Disable CSV export?

Post by sblasic » 2022-04-01 10:57

Hello AppGini users!

I would like to disable CSV data export for certain users/groups.


Preferably, this could be done manually by the Admin.

Is there a simple way that a non-coder like me could do this?

Thank you in advance for any help and/or suggestion!

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Disable CSV export?

Post by pbottcher » 2022-04-01 14:18

Hi,

well, I dont think this will work without code.
Also the requirement seems not completely clear. Do you want to disable CSV export for all tables for certain users / groups, or definied per table individually?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Disable CSV export?

Post by sblasic » 2022-04-04 11:15

pböttcher, thank you again for your feedback!

I would like to be able to prevent some employees to export CSV data of EVERY table in the database.

So, some employees will be able to export CSV, some will not have this right.

For better understanding:
Employee Tom will be able to export CSV (of any table he wants).
Employee Mark will not have the right to export CSV at all - regardless of the table.

So basically: CSV EXPORT ON and OFF switch.

This right will be granted by the admin MANUALLY for each employee.

pböttcher, if the code is not too complicated to write - I'm sure I could implement into the project (with some instruction).
If you think that this will be complicated - I could give you my email for PM - so you could give me the estimate for the project.

Thank you in advance!

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1638
Joined: 2018-04-01 10:12

Re: Disable CSV export?

Post by pbottcher » 2022-04-04 18:36

Hi,

well as a quick solution, I would create a new table "allow_csv" with two fields:

id <-- PK
name <-- unique varchar(100)

Then you allow only the admin to see this table and handle all entries.

In this table (allow_csv) you can store all names that are allowed the CSV export. Make sure that the name matches the username as stored in the membership_users table. (You may check if the name matches in the before_insert/update function)

Now in the _init function (of each table) you check if the $memberInfo['username'] is contained in the record of the allow_csv table.
If no, set

$options->AllowCSV=0.

That should work.

If you need help, you may contact me by PM
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Disable CSV export?

Post by sblasic » 2022-04-05 09:48

Thank you very much, pböttcher!

I'll contact you soon when I catch some time to do it!

Cheers!

sblasic
Veteran Member
Posts: 53
Joined: 2021-02-22 15:55

Re: Disable CSV export?

Post by sblasic » 2022-04-10 10:22

Ahmed pinpointed me to the solution:
https://bigprof.com/appgini/help/advanc ... ename_init

Again, thank you for your suggestion!

xbox2007
Veteran Member
Posts: 134
Joined: 2016-12-16 16:49

Re: Disable CSV export?

Post by xbox2007 » 2022-04-13 20:44

in my project i remove CSV button

i add this code on footer-extras.php

Code: Select all

<?php } 
	$mi = getMemberInfo();
	if(!in_array($mi['group'], array('Admins', 'Data entry'))){
?>
		<script>
			$j("#CSV").remove();
			$j('.btn-import-csv').hide();
		</script>
<?php 
	}		
?>

Post Reply