privacy.php 711 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /*
  3. * Perform permission check by node_id only if 'node_privacy_byrole' module is enabled
  4. */
  5. function tripal_check_permission_by_node_id ($nid) {
  6. if (module_exists('node_privacy_byrole')) {
  7. global $user;
  8. $roles = $user->roles;
  9. $node_access = 0;
  10. foreach ($roles AS $rid => $role) {
  11. $p_sql = "SELECT grant_view FROM {node_access} WHERE nid=%d AND gid = %d";
  12. $access = db_result(db_query($p_sql,$nid, $rid));
  13. if ($access == 1) {
  14. $node_access = 1;
  15. break;
  16. }
  17. }
  18. if ($node_access == 1 || $user->uid == 1) {
  19. return TRUE;
  20. } else {
  21. return FALSE;
  22. }
  23. // If 'node_privacy_byrole' module is not enabled, return TRUE;
  24. } else {
  25. return TRUE;
  26. }
  27. }