1

I have historical data recorded in pdf files for our clients. Now I am developing a website (in Drupal) from where clients should be able to access this data. The problem is that i don't want this files to be available to anyone else than the user to whom the information belongs.

Since this data is periodically recorded I could store it in a specific folder for each user. My question is that if it's possible to give access to this folders or its content to specific users in Drupal. Because the alternative would be to create a Role for every user which is not good.

0
  1. Create a new content type and add fields according to your requirement or user reference field
  2. Disable its Front page publish option.
  3. Create new user Role like "client".
  4. Create view of files and add relationship or contentuxal filter against user loggin id.
  5. Create block view assign this block into specific region.
| improve this answer | |
  • would it make te files unavailable to access for other users? – Miquel Correa Casablanca Oct 13 '15 at 9:40
  • yes due to only login user can view their own file – Adi Oct 13 '15 at 9:44
0

At the end I found a solution that covers all my needs. I created a custom page template for the page from where i want to access the files (ex. node--4.tpl.php) that catches the username and generates a cookie with it:

global $user;
$username = $user->name;
$cookie_name = 'cookie_name';//
$cookie_value = $username;//
setcookie($cookie_name, $cookie_value, time() + (3600), "/");

Then I create a .htaccess file in each user's folder that contains this code:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_COOKIE} !cookiename=username [NC]
RewriteRule .* http://alternativepath/ [L]

So only the user who's username is like the username i ask for in the htaccess can access the folder. In my case I ask for another field, not the username, but this should be enough as a simple example.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.