You are here

function privatemsg_folder_access in Privatemsg 5

Same name and namespace in other branches
  1. 5.3 privatemsg.module \privatemsg_folder_access()

Returns TRUE if the user can access the folder.

1 call to privatemsg_folder_access()
privatemsg_menu in ./privatemsg.module
Implementation of hook_menu().

File

./privatemsg.module, line 2413

Code

function privatemsg_folder_access($uid, $fid) {

  // Administrators can access any folder.
  if ($uid == 1 || user_access('access all folders')) {
    return TRUE;
  }

  // Anonymous users have no access.
  if (intval($uid) == 0) {
    return FALSE;
  }
  if (intval($fid) == 0) {
    return FALSE;
  }

  // Check the database for the user ID of the folder.
  $owner = db_result(db_query("SELECT uid FROM {privatemsg_folder} WHERE fid = %d", $fid));
  if ($owner == $uid) {
    return TRUE;
  }
  return FALSE;
}