summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnkur Rishi2004-09-16 20:58:13 (GMT)
committer Ankur Rishi2004-09-16 20:58:13 (GMT)
commit3858a919494bfa6574fd8e384ca34ec691c198ea (patch)
tree804d4f3a40bc5aab011b6e1679a9094b8902b1d7
parent1d88e6a1d0fc8798a2449dc26b13419321055082 (diff)
-Changed buddylist settings page to make number of buddies and buddy-ofs
configurable by a single setting. -Changed buddylist settings page to enable admin to configure number of buddies displayed in buddylist block. -Clarified instructions on buddylist settings page.
-rw-r--r--buddylist.module27
1 files changed, 19 insertions, 8 deletions
diff --git a/buddylist.module b/buddylist.module
index c295167..cd38646 100644
--- a/buddylist.module
+++ b/buddylist.module
@@ -16,20 +16,20 @@ function buddylist_help($field) {
*/
function buddylist_init() {
variable_set('buddylist_prof_buddies', variable_get('buddylist_prof_buddies', 4));
- variable_set('buddylist_prof_buddyofs', variable_get('buddylist_prof_buddyofs', 4));
+ variable_set('buddylist_blocklisting_size', variable_get('buddylist_blocklisting_size', 5));
}
/**
* Implementation of hook_settings
*/
function buddylist_settings() {
- $group .= form_select(t('Number of posts in block'), 'buddylist_posts_block', variable_get('buddylist_posts_block', 10), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), t('The default maximum number of posts to display on my buddy recent posts block.'));
+ $group .= form_select(t('Number of buddies to list in the user\'s buddy block'), 'buddylist_blocklisting_size', variable_get('buddylist_blocklisting_size', 5), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), t('This setting controls the maximum number of buddies displayed in a user\'s "buddylist block" given that the "buddylist block" is enabled in the %link.', array('%link' => l(t('block settings'), 'admin/block')) ));
+ $group .= form_select(t('Number of posts to list in the buddies\' recent posts block'), 'buddylist_posts_block', variable_get('buddylist_posts_block', 10), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), t('This setting controls the maximum number of posts to display in a user\'s "buddy recent posts" block given that the "buddies\' recent posts" block is enabled in the %link.', array('%link' => l(t('block settings'), 'admin/block')) ));
$group .= form_textfield(t('Block title'), 'buddylist_block_title', variable_get('buddylist_block_title', t('My buddies\' recent posts')), 70, 128, t('This will be the title for the recent buddies post block. If none is specified, the default will be used.'));
$output .= form_group(t('Buddylist block options'), $group);
// User profile page settings
- $group = form_select(t('Number of buddies for the user profile page'), 'buddylist_prof_buddies', variable_get('buddylist_prof_buddies', 4), drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), t('The default maximum number of buddies to display on the user profile page.'));
- $group .= form_select(t('Number of buddy-ofs for the user profile page'), 'buddylist_prof_buddyofs', variable_get('buddylist_prof_buddyofs', 4), drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), t('The default maximum number of buddyofs to display on the user profile page.'));
+ $group = form_select(t('Number of buddies and buddy-ofs for the user profile page'), 'buddylist_prof_buddies', variable_get('buddylist_prof_buddies', 4), drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)), t('The default maximum number of buddies and buddy-ofs to display on a user\'s profile page.'));
$output .= form_group(t('Profile page options'), $group);
return $output;
@@ -134,14 +134,25 @@ function buddylist_block($op = 'list', $delta = 0) {
else if ($op == 'view' && user_access('access content') && $user->uid > 0) {
switch ($delta) {
case 0 : // Shows buddylist block
- $result = db_query('SELECT b.buddy as uid, u.name FROM {buddylist} b, {users} u WHERE b.uid = %d AND u.uid = b.buddy ORDER BY b.timestamp DESC', $user->uid);
+ $result = db_query_range('SELECT b.buddy as uid, u.name FROM {buddylist} b, {users} u WHERE b.uid = %d AND u.uid = b.buddy ORDER BY b.timestamp DESC', $user->uid, 0, variable_get('buddylist_blocklisting_size', 5));
while ($account = db_fetch_object($result)) {
$account->link = l((strlen($account->name) > 15 ? substr($account->name, 0, 15) .'...' : $account->name), 'user/'. $account->uid);
$users[] = $account->link;
}
+
$block['content'] = theme('user_list', $users);
$block['subject'] = t('My buddy list');
+
+ // check if a "more" link should generated by seeing if there are more buddies than the specified $upperlimit
+ $queryresult = db_query('SELECT count(buddy) as buddycount FROM {buddylist} WHERE uid = %d', $user->uid);
+ $countresult = db_fetch_object($queryresult);
+ $morelink = '';
+
+ if ($countresult->buddycount > variable_get('buddylist_blocklisting_size', 5)) {
+ $block['content'] .= '<div class="more-link">' . l(t('more'), 'buddylist', array('title' => t('View more.'))) . '</div>';
+ }
+
return $block;
break;
@@ -409,14 +420,14 @@ function _buddylist_firstfew_buddies($id) {
$queryresult = db_query('SELECT count(buddy) as buddycount FROM {buddylist} WHERE uid = %d', $id);
$countresult = db_fetch_object($queryresult);
if ($countresult->buddycount > $upperlimit) {
- $output .= '<div class="more-link">'. l(t('see all buddies'), 'buddylist/'. $id, array('title' => t('View more.'))) .'</div>';
+ $output .= l(t('see all buddies'), 'buddylist/'. $id, array('title' => t('View more.')));
}
return $output;
}
function _buddylist_firstfew_buddyof($id) {
- $upperlimit = variable_get('buddylist_prof_buddyofs', 4);
+ $upperlimit = variable_get('buddylist_prof_buddies', 4);
$result = db_query_range('SELECT u.uid as uid FROM {buddylist} b INNER JOIN {users} u ON b.uid = u.uid WHERE b.buddy = %d ORDER BY u.changed DESC', $id, 0, $upperlimit);
$output = '<div id="profile">';
@@ -429,7 +440,7 @@ function _buddylist_firstfew_buddyof($id) {
$queryresult = db_query('SELECT count(uid) as buddyofcount FROM {buddylist} WHERE buddy = %d', $id);
$countresult = db_fetch_object($queryresult);
if ($countresult->buddyofcount > $upperlimit) {
- $output .= '<div class="more-link">'. l(t('see all buddy-ofs'), 'buddylist/buddyof/'. $id, array('title' => t('View more.'))) .'</div>';
+ $output .= l(t('see all buddy-ofs'), 'buddylist/buddyof/'. $id, array('title' => t('View more.')));
}
return $output;