You are here

function user_relationship_default_load in User Relationships 7

Same name and namespace in other branches
  1. 5.2 plugins/user_relationship_defaults/user_relationship_defaults.module \user_relationship_default_load()
  2. 6 user_relationship_defaults/user_relationship_defaults.module \user_relationship_default_load()

Public API for retrieving a default relationship.

Parameters

$param: The rdid or an associative array of attributes to search for in selecting the default, such as user_name or name. Attributes must match column names in the user_relationship_defaults or user_relationship_types table.

Return value

object of the default relationship with the user object and relationship_type object

1 call to user_relationship_default_load()
user_relationship_defaults_delete_form_submit in user_relationship_defaults/user_relationship_defaults.module
Process default relationship delete form submission.

File

user_relationship_defaults/user_relationship_defaults.module, line 25
Drupal Module: User Relationship Defaults

Code

function user_relationship_default_load($param = array()) {
  $defaults = user_relationship_defaults_load();
  if (is_numeric($param)) {
    return $defaults[$param];
  }
  foreach ($defaults as $default) {
    $found = TRUE;
    foreach ($param as $column => $value) {
      $column = drupal_strtolower($column);
      if ($column == 'name' || $column == 'plural_name') {
        $value = drupal_strtolower($value);
        $col_val = drupal_strtolower($default->{$column});
      }
      else {
        $col_val = $default->{$column};
      }

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