You are here

function user_relationships_type_load in User Relationships 7

Same name and namespace in other branches
  1. 5.3 user_relationships_api/user_relationships_api.api.inc \user_relationships_type_load()
  2. 5.2 user_relationships_api.inc \user_relationships_type_load()
  3. 6 user_relationships_api/user_relationships_api.api.inc \user_relationships_type_load()

Public API for retrieving a specific relationship

Parameters

$param: The rtid or 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_relationship_types table.

Return value

object of the requested relationship type

35 calls to user_relationships_type_load()
theme_user_relationship_block_subject in user_relationship_blocks/user_relationship_blocks.module
Theme function to generate the title of a block
UserRelationshipsPrivatemsgRecipientTestCase::testSendToRelationship in user_relationship_privatemsg/user_relationship_privatemsg.test
Tests sending a message to related users.
UserRelationshipsTestCase::testTypeAPI in ./user_relationships.test
Test API functions for relationship types.
user_relationships_admin_type_delete_submit in ./user_relationships.admin.inc
Process relationship delete form submission.
user_relationships_get_message in ./user_relationships.module
Public API for getting the set or default message

... See full list

1 string reference to 'user_relationships_type_load'
user_relationships_i18n_object_info in ./user_relationships.i18n.inc
Implements hook_i18n_object_info().

File

./user_relationships.module, line 417
User Relationships API. Module shell.

Code

function user_relationships_type_load($param = array()) {
  $types = user_relationships_types_load();
  if (!is_array($param)) {
    if (isset($types[$param])) {
      return $types[$param];
    }
    return FALSE;
  }
  foreach ($types as $type) {
    $found = TRUE;
    foreach ($param as $column => $value) {
      $column = strtolower($column);
      if ($column == 'name' || $column == 'plural_name') {
        $value = strtolower($value);
        $col_val = strtolower($type->{$column});
      }
      else {
        $col_val = $type->{$column};
      }

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