function system_can_access_student
Search API
7.x system.module | system_can_access_student($student_id = "") |
6.x system.module | system_can_access_student($student_id = "") |
Used by the menu to determine if the user can access some basic information about the student (like Profile page, etc)
File
- modules/
system/ system.module, line 629
Code
function system_can_access_student($student_id = "") {
global $current_student_id, $user;
if ($student_id == "") {
$student_id = $current_student_id;
}
// must be logged in first...
if (!user_has_permission("access_logged_in_content")) {
return FALSE;
}
if ($student_id == "" || $student_id === 0) {
return FALSE;
}
if ($user->id == 1) {
return TRUE; // the admin user.
}
// Can the user view ANY advising session?
if (user_has_permission("view_any_advising_session")) {
return TRUE;
}
// can the user only see their own advisees, and is this student one of their advisees?
if (user_has_permission("view_advisee_advising_session")) {
// Is the student_id in their list of advisees?
$advisees = advise_get_advisees();
if (in_array($student_id, $advisees)) {
return TRUE;
}
}
// Is this user viewing THEIR OWN advising session?
if (user_has_permission("view_own_advising_session")) {
if ($student_id == $user->cwid && ($student_id != "" && $student_id !== 0)) {
return TRUE;
}
}
// All else fails, return FALSE
return FALSE;
}