function student_files_user_may_download_student_file
Search API
7.x student_files.module | student_files_user_may_download_student_file($student_id, $fid) |
6.x student_files.module | student_files_user_may_download_student_file($student_id, $fid) |
Returns TRUE or FALSE if the user has access to download this particular student's file.
1 call to student_files_user_may_download_student_file()
- student_files_content_alter in modules/
student_files/ student_files.module - Implememnt hook_content_alter
File
- modules/
student_files/ student_files.module, line 277 - This is the student_files module, which will facilitate uploading (securely) files to be associated with student accounts.
Code
function student_files_user_may_download_student_file($student_id, $fid) {
global $user;
$files_array = student_files_get_files_for_student($student_id);
$file = @$files_array [$fid];
if ($user->id == 1) {
return TRUE; // this is the admin user.
}
// Is this a faculty only file, and the user is a student?
if ($file ["access_type"] == "faculty" && $user->is_student == TRUE) {
return FALSE; // nope, can't view it.
}
// Is this a student, and this is a file for THEM?
if ($file ["student_id"] == $user->cwid && $file ["access_type"] != "faculty") {
return TRUE;
}
// Does this user have access to download advisee's files and is this student someone they are allowed to advise?
if (user_has_permission("download_advising_student_files")) {
// Now, is this user allowed to view THIS student's advising history?
if (advise_can_access_view($student_id)) {
return TRUE;
}
}
// All else failed, return FALSE
return FALSE;
}