Add author of node to buddylist
nodiac - August 3, 2008 - 18:31
| Project: | Buddylist |
| Version: | 5.x-1.1-beta |
| Component: | User interface |
| Category: | task |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | active |
Description
Am putting this here in case anyone else wants to do this. If anyone sees any errors or a more elegant way to do this, you can add to this thread.
Have found that this works when put on the node.tpl.php or the contemplate template for a node.
<?php global $user;
$object = user_load(array('uid'=>$node->uid));
if ($user->uid !== 0 && $node->uid !== $user->uid && $node->uid !== 0) {
if (@in_array($object->uid, array_keys(buddylist_get_buddies($user->uid))) && user_access('maintain buddy list')) { ?>
<div class = "buddylink">
<?php print l(t('Remove @username from your buddylist',array('@username'=>$node->name)), 'buddy/delete/'. $node->uid); ?>
</div>
<?php } elseif ($user->uid != $viewing_user->uid && user_access('maintain buddy list')) { ?>
<div class = "buddylink">
<?php print l(t('Add @username to your buddylist',array('@username'=>$node->name)), 'buddy/add/'. $node->uid);?>
</div>
<?php }
}
?>