function student_files_user_may_delete_student_file

7.x student_files.module student_files_user_may_delete_student_file($student_id, $fid)
6.x student_files.module student_files_user_may_delete_student_file($student_id, $fid)

Returns TRUE or FALSE if the current user is allowed to delete the file.

1 call to student_files_user_may_delete_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 350
This is the student_files module, which will facilitate uploading (securely) files to be associated with student accounts.

Code

function student_files_user_may_delete_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.
  }

  // Does this user have access to delete ANY file?
  if (user_has_permission("delete_any_student_files")) {
    return TRUE;
  }

  // Does this user have permission to delete OWN files, and they uploaded this file?
  if (user_has_permission("delete_own_student_files")) {
    if ($file ["uploaded_by_cwid"] == $user->cwid) {
      // Yes, this user is the one who uploaded this file, so yes, they can delete it.
      return TRUE;
    }
  }



  // All else failed, so deny
  return FALSE;

}