You are here

function linkedin_user_access in LinkedIn Integration 6

Same name and namespace in other branches
  1. 7 linkedin.module \linkedin_user_access()
1 string reference to 'linkedin_user_access'
linkedin_menu in ./linkedin.module

File

./linkedin.module, line 90

Code

function linkedin_user_access($account) {
  global $user;
  if ($user->uid == $account->uid) {

    // Check if some perms have been defined by submodules.
    $perms = module_invoke_all('linkedin_user_edit_perms');
    foreach ($perms as $perm) {
      if (user_access($perm)) {
        return TRUE;
      }
    }
    if (module_exists('linkedin_auth')) {
      return TRUE;
    }
  }
  if (variable_get('linkedin_debug_mode', 0) == 1) {
    if ($user->uid != $account->uid) {
      drupal_set_message(t('LinkedIn debug : Access denied to /linkedin/token/@requested.<br />
      Requesting user (uid @requesting) is different from the requested account (uid @requested)', array(
        '@requested' => $account->uid,
        '@requesting' => $user->uid,
      )));
      return FALSE;
    }
    if (empty($perms)) {
      drupal_set_message(t('LinkedIn debug : Access denied to /linkedin/token/@requested.<br />
      No module is implementing hook_linkedin_user_edit_perms. Enable at least one submodule and check permissions'));
      return FALSE;
    }
    foreach ($perms as $perm) {
      $permissions .= $perm . ', ';
    }
    drupal_set_message(t('LinkedIn debug : Access denied to /linkedin/token/@requested.<br />
      User must have at least one of these permissions : @permissions', array(
      '@permissions' => $permissions,
    )));
  }
  return FALSE;
}