'spaces', 'attribute' => 'feature', 'value' => 'contacts', 'block' => array( array( 'module' => 'spaces_contacts', 'delta' => 'contact_list', 'region' => 'right', 'weight' => -11, ), ), 'spaces' => array( 'label' => t('Contacts'), 'description' => t('A contacts section with member listings.'), 'types' => array('og'), 'menu' => array( 'contacts' => array('title' => t('Contacts')), ), ), ); return $items; } /** * Implementation of hook_block() */ function spaces_contacts_block($op = 'list', $delta = 0) { if ($op == 'list') { $blocks['contact_list']['info'] = t('Spaces Contacts: Contact List'); return $blocks; } else if ($op == 'view') { switch ($delta) { case 'contact_list': $users = _spaces_contacts_users(); $items = array(); if ($users) { foreach ($users as $account) { $item = new stdClass(); $item->title = theme('username', $account); $items[] = theme('datetime_view_style_item', $item); } $block['content'] = theme('item_list', $items); } else { $block['content'] = "

". t('No contacts found.') ."

"; } $block['subject'] = t('Contacts'); return $block; } } } /** * Implementation of hook_menu() */ function spaces_contacts_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array( 'path' => 'contacts', 'title' => t('Contacts'), 'description' => t('Provides a group-aware contact listing.'), 'callback' => 'spaces_contacts_pageview', 'access' => user_access('access content'), 'type' => MENU_NORMAL_ITEM, ); } return $items; } /** * Implementation of hook_help() */ function spaces_contacts_help($page) { if (context_get('spaces', 'feature') == 'contacts') { return "

". t('Contacts shows the team members that are part of this group and any additional contact information if they have provided it.') ."

"; } } /** * Implementation of hook_user() */ function spaces_contacts_user($op, &$edit, &$account, $category = NULL) { if (in_array($op, array('view', 'form')) && spaces_get_space()) { context_set('spaces', 'feature', 'contacts'); } } /** * Page callback that displays a user contact listing */ function spaces_contacts_pageview() { drupal_set_title(t('Contacts')); context_set('spaces', 'feature', 'contacts'); context_set('theme', 'layout', 'wide'); $rows = array(); $users = _spaces_contacts_users(); foreach ($users as $account) { $row = array( theme('user_picture', $account), theme('username', $account), l($account->mail, 'mailto:'. $account->mail) ); if (module_exists('profile')) { $row[] = $account->profile_organization ? $account->profile_organization : null; } $rows[] = $row; } $labels = array(null, t('Name'), t('Email')); if (module_exists('profile')) { $labels[] = t('Organization'); } // wrap the table as if it were produced by a view return "
". theme('table', $labels, $rows, array('class' => 'userlist')) ."
"; } /** * Wrapper around spaces_og_get_users() that provides additional support for vcard name fields */ function _spaces_contacts_users() { $users = spaces_og_get_users(); if (module_exists('profile')) { foreach ($users as $key => $account) { $account = user_load($account); profile_load_profile($account); // Replace username listing with real name if possible if ($account->profile_givenname && $account->profile_familyname) { $account->name = $account->profile_givenname .' '. $account->profile_familyname; } else if ($account->profile_givenname) { $account->name = $account->profile_givenname; } $users[$key] = $account; } } return $users; }