6

Is there a way to configure the Assets file browser in a SafeCracker form to only show assets for the currently logged-in member?

2

Assets 2.1 is easily hackable, here's what you can do to restrict the file browser to the currently logged-in member's (standard ExpressionEngine) assets only:

First, add a 'member_id' column to the assets_files table:

ALTER TABLE  `exp_assets_files` ADD  `member_id` INT( 10 ) UNSIGNED NULL

Modify assets/sources/base_source.php (line 605) to add the member_id to the db table:

'file_name' => $filename,
'member_id' => $this->EE->session->userdata('member_id'), // Add 'member_id' to database
'kind' => Assets_helper::get_kind($filename)

Finally, modify assets/libraries/assets_lib.php (line 712) to limit the display of files to the currently logged in member only:

Change this existing line:

$this->EE->db->where_in('exp_assets_files.folder_id', $full_folder_list);

To this:

$this->EE->db->where_in('exp_assets_files.folder_id', $full_folder_list)->where('member_id', $this->EE->session->userdata('member_id'));
| improve this answer | |
  • I wonder if there are hooks available that would allow this to be implemented via another addon... – Ian Pitts May 26 '13 at 18:25
1

No, not yet, sorry Roger. We do have something planned for that, but I can't make any promises regarding ETA.

| 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.