Hi,

I think it has to to with:

friendlist_ui.module:
function friendlist_ui_user($op, &$edit, &$account, $category = NULL)

friendlist_api.module:
function friendlist_api_user($type, &$edit, &$account, $category = NULL)

Which one is the correct one?

Thanks.

Comments

zanhsieh’s picture

If anybody is interested in how this work, here is the trick. Do not think it's a complete configurable; just a small patch.

Change friendlist_ui.module:

/**
 * Implementation of hook_user().
 *
 * It displays the possible operations (add/delete) the viewer can do
 * to the viewed user.
 */
function friendlist_ui_user($op, &$edit, &$account, $category = NULL) {

  global $user;

  if ($op == 'view' && user_access('have relationships with friendlist')) {


    if ($account->uid != $user->uid) {

      $contents = friendlist_ui_user_links($account);

      if ($contents != '') {

        $account->content['friendlist_ui'] = array(
          '#type' => 'user_profile_item',
          '#title' => t('Connections'),
          '#value' => $contents,
          '#attributes' => array('class' => 'friendlist_ui_profile'),
        );
        return $account;
      }
    }
  }
  if ($op == 'login' && user_access('have relationships with friendlist')) {
      $count = friendlist_unresponded_request_count();
      if ($count) {
        drupal_set_message(t('You have <a href="@rinbox">%request</a>.', array('@rinbox' => url('user/'.$user->uid.'/community/received'), '%request' => format_plural($count, '1 friend request', '@count friend requests'))));
      }
  }
}

/**
 * API function
 *
 * Return number of unresponded requests for an account.
 */
function friendlist_unresponded_request_count($account = NULL) {
  static $counts = array();
  if (!$account || $account->uid == 0) {
    global $user;
    $account = $user;
  }
  if (!isset($counts[$account->uid])) {    
    $counts[$account->uid] = db_result(db_query('SELECT count(*) FROM {friendlist_statuses} WHERE requestee_id = %d AND status = "TW_1_TO_2_P"', $account->uid));
  }
  return $counts[$account->uid];
}

Please note that my site only allows 1-to-1 relationship; no fan. If you have configured your site just like me, then this small patch will work for you; otherwise we have to add more code for handling 'fan' (1-to-many) situations.

Thanks.

mercmobily’s picture

Status: Active » Fixed

Hi,

I don't think patching the module is a good way to go.

I do think it would be nice to have a feature here where users are greeted with a message like "You have X pending requests" when they log in -- please add a feature request! It should be pretty straightforward to implement, and it's actually useful.

Thanks,

Merc.

jjohn’s picture

hi

how do this work?
i mean where can i enable/view the
expected results?

thanks

mercmobily’s picture

Status: Fixed » Closed (fixed)