function tripal_analysis_check_permission
2.x tripal_analysis_privacy.inc | tripal_analysis_check_permission($analysis_id) |
3.x tripal_analysis_privacy.inc | tripal_analysis_check_permission($analysis_id) |
1.x tripal_analysis_privacy.inc | tripal_analysis_check_permission($analysis_id) |
Perform permission check by analysis_id only if 'node_privacy_byrole' module is enabled
Parameters
$analysis_id: Which analysis to check if the user has permission to view
Related topics
File
- tripal_analysis/
includes/ tripal_analysis_privacy.inc, line 17 - Perform permission check (required node_privacy_byrole module).
Code
function tripal_analysis_check_permission($analysis_id) {
if (module_exists('node_privacy_byrole')) {
global $user;
$roles = $user->roles;
$node_access = 0;
foreach ($roles as $rid => $role) {
$p_sql = "
SELECT grant_view
FROM {node_access} NA
INNER JOIN {chado_analysis} CA ON NA.nid = CA.nid
WHERE analysis_id = :analysis_id AND gid = :gid";
$access = db_query($p_sql, array(':analysis_id' => $analysis_id, ':gid' => $rid))->fetchField();
if ($access == 1) {
$node_access = 1;
break;
}
}
if ($node_access == 1 || $user->uid == 1) {
return TRUE;
}
else {
return FALSE;
}
// If 'node_privacy_byrole' module is not enabled, return TRUE;
}
else {
return TRUE;
}
}