File download restriction.

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
User avatar
Jay Webb
Veteran Member
Posts: 80
Joined: 2017-08-26 15:27
Contact:

File download restriction.

Post by Jay Webb » 2017-10-12 19:17

I'm using AppGini 5.62

I have table field for pdf file type only, upload. would like to restrict download links to Admins and Officers only.

Can this be done with hook code, where and how would help.

Thanks..
What we envision, we make happen.

User avatar
baudwalker
Veteran Member
Posts: 188
Joined: 2015-02-03 08:08
Location: Bellingen NSW Australia

Re: File download restriction.

Post by baudwalker » 2018-01-19 00:30

I too would like the upload of a PDF only. With the lack of response it does not look too hopeful

bescott53

Re: File download restriction.

Post by bescott53 » 2018-01-21 20:11

Jay, you go to the page hook file.

Look for the 'init' function in the hook file, The code below is an example to restrict download to certain users.

function XXXXXXXXXXX_init(&$options, $memberInfo, &$args){

$csvusers = array("123456789", "uk", "europe");

if(in_array($memberInfo['username'], $csvusers)){
$options->AllowCSV=1;
}else{
$options->AllowCSV=0;
}

return TRUE;


You can change the 'username' to one of the other variables like groups etc. to see what is available, take a look here - If you look at the member array here - http://bigprof.com/appgini/help/advance ... memberInfo

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 352
Joined: 2013-03-21 04:37

Re: File download restriction.

Post by peebee » 2018-01-31 07:10

baudwalker - to allow PDF ONLY upload, you can do one of two things:

1. To generate the code to restrict uploads of PDF only through AppGini itself; edit the \appgini\add-ons\fileTypes.cfg file. Add a new line in the cfg file under existing lines with just the file type pdf. You'll then see the PDF option in the dropdown of filetypes - see the screenshot below from the AppGini help screen that relates (click the "Configure" button then the red Danger link on the Media tab to get to this screen). You'll need a text editor to open the fileTypes.cfg file - Notepad++ is a good choice if you're looking for one
screenshot.jpg
screenshot.jpg (107.87 KiB) Viewed 3196 times

2. Edit the generated yourtablename_dml.php file. You'll have to search through and find all lines that relate to "PrepareUploadedFile" and edit the allowed file type to just PDF for the particular fields you want to limit. You'll probably see the default files types of: txt|doc|docx|docm|odt|pdf|rtf Just edit those files types to 'pdf' Now Users will receive an error if they try to upload anything other than a PDF.

User avatar
baudwalker
Veteran Member
Posts: 188
Joined: 2015-02-03 08:08
Location: Bellingen NSW Australia

Re: File download restriction.

Post by baudwalker » 2018-01-31 08:37

Thank you. nearly as simple as me :)

Post Reply