You are here

function _user_relationship_blocks_hook_list in User Relationships 5.2

helper function user_relationship_blocks_block delegates to when $op == 'list'

1 call to _user_relationship_blocks_hook_list()
user_relationship_blocks_block in plugins/user_relationship_blocks/user_relationship_blocks.module
Implementation for hook_block

File

plugins/user_relationship_blocks/user_relationship_blocks.module, line 38

Code

function _user_relationship_blocks_hook_list() {
  $my = UR_BLOCK_MY . UR_BLOCK_SEPARATOR;
  $usr = UR_BLOCK_USER . UR_BLOCK_SEPARATOR;

  // return list of all blocks defined by the module
  $blocks = array(
    $my . UR_BLOCK_ALL_TYPES => array(
      'info' => t('My Relationships: All relationships'),
    ),
    $usr . UR_BLOCK_ALL_TYPES => array(
      'info' => t('User Relationships: All relationships'),
    ),
    'pending' => array(
      'info' => t('My Pending Relationships'),
    ),
    'actions' => array(
      'info' => t('User Relationships: Actions'),
    ),
  );
  $types = user_relationships_types_load();
  foreach ($types as $type) {
    $my_delta = "{$my}{$type->rtid}";
    $usr_delta = "{$usr}{$type->rtid}";
    $extras = array(
      '' => '',
    );
    if ($type->is_oneway) {
      $extras = array(
        UR_BLOCK_SEPARATOR . 'you_to_them' => t('(You to Them)'),
        UR_BLOCK_SEPARATOR . 'them_to_you' => t('(Them to You)'),
      );
    }
    foreach ($extras as $token => $extra) {
      $block_types = array(
        "{$my_delta}{$token}" => 'My Relationships: @type @extra',
        "{$usr_delta}{$token}" => 'User Relationships: @type @extra',
      );
      foreach ($block_types as $delta => $title) {
        $blocks[$delta] = array(
          'info' => t($title, array(
            '@type' => $type->plural_name,
            '@extra' => $extra,
          )),
          'cache' => BLOCK_NO_CACHE,
        );
      }
    }
  }
  return $blocks;
}