Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Being able to extend the buddy listing page table and changing the translations externally would be nice.
I added this to buddylist_translation()
return array_merge($translations,module_invoke_all('buddylist_translation'));
and to function buddylist_buddylisting_page($uid = NULL, $mode = 'buddies')
$header = array_merge(array(t('@buddy', buddylist_translation()), t('online')),module_invoke_all('buddylist_buddypage_headers'));
$online_interval = time() - variable_get('user_block_seconds_online', 180);
if (db_num_rows($result)) {
while ($account = db_fetch_object($result)) {
$online = $account->access > $online_interval;
$rows[] = array_merge(array(theme('username', user_load(array('uid' => $account->buddy))), theme('buddylist_online', $online)),module_invoke_all('buddylist_buddypage_rowvalues',$account->buddy));
}
$output .= theme('table', $header, $rows);
}
else {
$output .= t('No @buddies found.', buddylist_translation());
}
in my custom module I can then add to $headers and $rows[] and change the translations without changing buddylist.module
function mymodule_buddylist_translation() {
$translations = array(
'@buddy' => t('member'),
'@Buddy' => t('Member'),
'@buddylist' => t('network'),
'@Buddylist' => t('Network'),
'@buddies' => t('members'),
'@Buddies' => t('Members'),
'@buddyof' => t('member of'),
'@Buddyof' => t('Member of'),
);
return $translations;
}
function mymodule_buddylist_buddypage_headers() {
$headers = array(t('city'),t('professional info'),t('area of interest'));
return $headers;
}
function mymodule_buddylist_buddypage_rowvalues($bid) {
$profile = (object)array('uid' => $bid);
profile_load_profile($profile);
return array($profile->profile_city,'',$profile->profile_spec);
}
You might consider this for a future release.
Comments
Comment #1
fagohm, or another idea:
what about using drupal's variable_get() mechanism for this?
we could replace buddylists's functions with a call to variable_get, which defaults to the buddylist default values. then everyone could come and overwrite the settings by populating the $conf array in the site's settings.php
Comment #2
fagoI just went ahead and did it so. Committed to both 4.7 and 5.0 branches.
Comment #3
dldege CreditAttribution: dldege commentedI haven't been able to keep up with the holidays... thanks for making the change - your approach sounds fine - that's why I only posted this as an idea and not a patch since I wasn't convinced it was the best way to go about it.
Comment #4
dldege CreditAttribution: dldege commentedI just got the latest code and see your change for buddylist_translation but you didn't add my module hooks (see the array_merge lines) for extending the table header and row data in
function buddylist_buddylisting_page
I still think these are useful additions to allow the table to be customized.
thx.
Comment #5
(not verified) CreditAttribution: commented