You are here

function linkit_get_dashboard_profile in Linkit 7.2

Get the "best" Linkit profile based on the users roles to use on the dashboard.

6 calls to linkit_get_dashboard_profile()
linkit_dashboard_form in ./linkit.module
Implements hook_form().
linkit_get_attributes in ./linkit.module
Get all attributes defined by hook_linkit_attributes().
linkit_get_profile_attributes in ./linkit.module
Get all enabled attributes for the profiles used on the dashboard.
linkit_get_profile_plugins in ./linkit.module
Get all enabled plugins for the profiles used on the dashboard.
_linkit_add_settings in ./linkit.module
Add necessary settings to the Drupal.settings array and include the libraries we need.

... See full list

File

./linkit.module, line 806
Main file for linkit module.

Code

function linkit_get_dashboard_profile() {
  global $user;
  $best_profile =& drupal_static(__FUNCTION__);
  if (!isset($best_profile)) {
    $best_profile = NULL;

    // Get the profiles.
    $profiles = linkit_profile_load_all();
    usort($profiles, '_linkit_sort_profiles_by_weight');
    foreach ($profiles as $profile) {

      // Dont work with disabled profiles.
      if (isset($profile->disabled) && $profile->disabled) {
        continue;
      }

      // Loop thru the associated roles, if we get a match, use that and break
      // out of this loop.
      foreach ($profile->role_rids as $rid => $value) {
        if (array_key_exists($rid, $user->roles)) {
          $best_profile = $profile;
          break 2;
        }
      }
    }
  }
  return $best_profile;
}