You are here

function user_relationships_relationship_type_load in User Relationships 5

Public API for retrieving a specific relationship

Parameters

$array: An associative array of attributes to search for in selecting the relationship, such as rtid or name. Attributes must match column names in the user_relationships table.

Return value

object of the requested relationship type

16 calls to user_relationships_relationship_type_load()
theme_user_relationships_relationships_block_empty in ./user_relationships_theme.inc
Generate the content of an empty My/User Relationships block
theme_user_relationships_relationships_block_subject in ./user_relationships_theme.inc
Generate the title of a My/User Relationships block
user_relationships_relationship_load in ./user_relationships_api.inc
Public API for loading a relationship.
user_relationships_request_submit in ./user_relationships_actions.inc
Process relationship request.
user_relationships_type_delete in ./user_relationships_forms.inc
Relationship type delete page.

... See full list

File

./user_relationships_api.inc, line 19

Code

function user_relationships_relationship_type_load($criteria = array()) {
  if (!sizeof($criteria)) {
    return NULL;
  }
  $types = user_relationships_relationship_types_load();
  foreach ($types as $type) {
    $found = TRUE;

    // assume this is the type we're looking for
    foreach ($criteria as $column => $value) {
      $column = strtolower($column);
      if ($column == 'name' || $column == 'plural_name') {
        $value = strtolower($value);
      }
      if ($type->{$column} != $value) {
        $found = FALSE;

        // value doesn't match, so this isn't the type after all
      }
    }
    if ($found) {
      return $type;
    }
  }
  return NULL;
}