You are here

function user_relationship_implication_load in User Relationships 5.2

Public API to load an implied relationship

Parameters

$riid: integer of the implied relationship ID

Return value

object with the relationship_type object and implied relationship_type object

1 call to user_relationship_implication_load()
user_relationship_implications_user_relationships_page_alter in plugins/user_relationship_implications/user_relationship_implications.module
hook_user_relationships_page_alter()

File

plugins/user_relationship_implications/user_relationship_implications.module, line 21
Drupal Module: User Relationship Implications

Code

function user_relationship_implication_load($param = array()) {
  $implied_relationships = user_relationship_implications_load();
  if (is_numeric($param)) {
    return $implied_relationships[$param];
  }
  foreach ($implied_relationships as $implied) {
    $found = TRUE;
    foreach ($param as $column => $value) {
      $column = strtolower($column);
      if ($column == 'name' || $column == 'plural_name') {
        $value = strtolower($value);
        $col_val = strtolower($implied->{$column});
      }
      else {
        $col_val = $implied->{$column};
      }

      // mismatch, move to the next type
      if ($col_val != $value) {
        $found = FALSE;
        break;
      }
    }
    if ($found) {
      return $type;
    }
  }
}