Buddylist2 integration

Nexotap - July 4, 2008 - 23:54
Project:Advanced Profile Kit
Version:5.x-1.0-alpha5
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active (needs more info)
Description

I have no clue where exactly to put this as it was a feature i wanted to have and worked myself on it. Maybe its interesting for Michelle or any other out there. Anyway to have buddylist2 working with this module you have to put the following code snippet into the advanced_profile.module file at aprox. line 277. Right after the buddylist if-statement.

  // Add / remove from buddylist2
  if (module_exists('buddy_api')) { 
    if (user_access('maintain buddy list') && @in_array($account_id, array_keys(buddy_api_get_buddies($user->uid)))) {
      // Remove buddy
      $variables['buddylist_class'] = "buddy-remove";
      $variables['buddylist_icon'] = theme_image($icon_directory . "/group_delete.png", 'Remove Buddy', 'Remove Buddy', NULL, TRUE);
      $variables['buddylist_text'] = t('Remove buddy');
      $variables['buddylist_link'] = 'buddy/delete/'. $account_id;
    } else {
      // Add buddy
      if ($account_id != $user->uid && user_access('maintain buddy list')) {
        $variables['buddylist_class'] = "buddy-add";
        $variables['buddylist_icon'] = theme_image($icon_directory . "/group_add.png", 'Add to buddy list', 'Add to buddy list', NULL, TRUE);
        $variables['buddylist_text'] = t('Add buddy');
        $variables['buddylist_link'] = 'buddy/add/'. $account_id;
      }
    }
   
    $variables['buddylist'] = '<div class="' . $variables['buddylist_class'] . '">' .
      l($variables['buddylist_icon'] . ' '  . $variables['buddylist_text'], $variables['buddylist_link'], NULL, NULL, NULL, NULL, TRUE) . '</div>';
  }

Maybe it even gets implemented in furter development. Anyway if i could have helped out some people while posting this, then im happy.

Cheers

Nexo

#1

Michelle - July 5, 2008 - 00:34
Version:5.x-1.0-alpha5» 5.x-1.x-dev
Status:active» patch (code needs review)

Looks like the module has a different name, so it won't conflict with buddylist 1. In that case, I'll add it to the module.

Thanks,

Michelle

#2

Nexotap - July 5, 2008 - 09:38

Thanks goes back to you Michelle, for your nice module.

#3

typehost - July 8, 2008 - 07:40

I added this code to the module as instructed - under "contributed modules" in the "add content" section of panels there is a "buddy list" listed - when I add that there is no display of the block in the profile.

In the add content there is also a "my buddies" under "advanced profile" listed - when I add this, it displays but seems to show every user no matter whether they are buddies or the same user as the profile. Also, this block has a major display issue when listed above another block in the profile.

Is there any other information on integrating buddylist2 and advanced profile? Does buddylist2 give any additional functionality from the original buddylist?

Thanks both for your time & assistance.

#4

Nexotap - July 11, 2008 - 21:01

Actually this few lines do not provide any more or different functionality than what already exists for buddylist. Those lines actually only call the functions of the buddylist2 which are equivalent of buddylist.

About the the difference of the two buddylists ... i only can refer to the buddylist2 where the author gives a comparison:
http://drupal.org/project/buddylist2

#5

WiseTeck - July 29, 2008 - 16:09
Version:5.x-1.x-dev» 5.x-1.0-alpha5
Status:patch (code needs review)» active (needs more info)

I think advanced profile kit use "buddylist_of_uid" to display that block. This view (you can find its export at advanced_profile/includes/view-buddylist_of_uid.inc) seems to work only with buddlist.

I've manage to make it work with buddylist2 by editing the buddylist_of_uid view (in my Views admin pane). Here is my export for it:

(the basic change is on the argument section. "type" should be buddylist2_buddies instead of buddylist_buddies

<?php
  $view
= new stdClass();
 
$view->name = 'buddylist_of_uid';
 
$view->description = 'Buddies of the given user';
 
$view->access = array (
);
 
$view->view_args_php = '';
 
$view->page = TRUE;
 
$view->page_title = 'Buddylist';
 
$view->page_header = '';
 
$view->page_header_format = '1';
 
$view->page_footer = '';
 
$view->page_footer_format = '1';
 
$view->page_empty = 'User has no buddies';
 
$view->page_empty_format = '1';
 
$view->page_type = 'list';
 
$view->url = 'buddies-of-uid';
 
$view->use_pager = TRUE;
 
$view->nodes_per_page = '10';
 
$view->sort = array (
    array (
     
'tablename' => 'node',
     
'field' => 'created',
     
'sortorder' => 'DESC',
     
'options' => 'normal',
    ),
  );
 
$view->argument = array (
    array (
     
'type' => 'buddylist2_buddies',
     
'argdefault' => '7',
     
'title' => '',
     
'options' => '',
     
'wildcard' => '',
     
'wildcard_substitution' => '',
    ),
  );
 
$view->field = array (
    array (
     
'tablename' => 'users',
     
'field' => 'uid',
     
'label' => '',
    ),
    array (
     
'tablename' => 'usernode_users',
     
'field' => 'name',
     
'label' => '',
     
'handler' => 'usernode_views_handler_field_username_text',
    ),
    array (
     
'tablename' => 'usernode_users',
     
'field' => 'uid',
     
'label' => '',
    ),
  );
 
$view->filter = array (
    array (
     
'tablename' => 'node',
     
'field' => 'status',
     
'operator' => '=',
     
'options' => '',
     
'value' => '1',
    ),
    array (
     
'tablename' => 'node',
     
'field' => 'type',
     
'operator' => 'OR',
     
'options' => '',
     
'value' => array (
 
0 => 'usernode',
),
    ),
  );
 
$view->exposed_filter = array (
  );
 
$view->requires = array(node, users, usernode_users);
 
$views[$view->name] = $view;
?>

Hope this help.

 
 

Drupal is a registered trademark of Dries Buytaert.