In the screenshots there a "pending message" message/popup showing something like "you have 1 pending message".

How is that done? ATM i don't see any notifying - you have explicit to click on the friends->pending tabs in the account page.

Comments

sirkitree’s picture

I ended up getting rid of this as it wasn't customizable enough using a drupal_set_message() within hook_init(). I could possibly throw it back in with a setting to disable or something.

michtoen’s picture

Well, thought i had some missed - for me a custom call would be better then (have an customized user status block).

sirkitree’s picture

Your English doesn't quite make sense there... are you saying that you would find a function that you can call within a custom block more useful?

michtoen’s picture

Sorry, it was late...

I have a custom "user status" block for logged in users. Beside links to the users profile and others i want
a notification for PM's and for the friendlist.

I *think* its ok to fetch for a logged in user both infos - for PMs its not the big query, it think its ok for the flag friends too, or?

sirkitree’s picture

Sure, very simple. You can get the count like so:

// load the flag
$flag = flag_get_flag('friend');

// get the count of who has flagged a user
$count = $flag->get_count($uid);

$count now holds the amount of people who have flagged whatever $uid you pass in.

Note that this doesn't necessarily mean that a user filled out the message, but will give you an accurate count of 'pending' relationship requests.

Let me know if this takes care of your problem.

Ujval Shah’s picture

I have enabled flag and flag module, i have also configured flag friend.

When i send a request to another user as - 'Add as Friend', There is no status/notification message to another user to whom i have placed a request.

Does this feature yet to developed or am i missing some configuration.

Help would be much appreciated.

sirkitree’s picture

@thedrupal: If you read the rest of this thread you will have your answer.

mstef’s picture

<?php
// load the flag
$flag = flag_get_flag('friend');

// get the count of who has flagged a user
$count = $flag->get_count($uid);
?>

That seems to be a good solution. How exactly would you recommend setting this up? My first thought would be to make a block containing that code, and issue a drupal message if the count is above zero. But then you'd have to load the flag and check the count for every single page view the logged in user makes? Seems inefficient. Any other ideas?

Also, on a slightly related note, how about email notifications upon friend requests?

Thanks

avpaderno’s picture

Title: pending message? » Pending message
sirkitree’s picture

First of all, you should be putting this in your site's custom module, probably in hook_init() though you may have some trouble with message duplication. I would suggest you look at a couple of the previous version of the module within CVS and see if you can find it.

Second, email notification is implemented, though i had a report of it not working: @see #351714: Friend message not going out. and reopen that one if you are still having issues.

mstef’s picture

Well what I did worked fine - I just thought it may be a bit inefficient. I created a block that only shows to authenticated users. The display mode is based on PHP - shown only if $count is bigger than zero. The block is simply a message giving a link to pending requests. I thought that was better than using drupal_set_message to avoid any more database calls - also, it's less intrusive if the user doesn't care about it.

I'll check the other thread for email notification because it's not working for me..

sirkitree’s picture

drupal_set_message() doesn't do any database calls, but you're right about it being somewhat intrusive. That was actually the main reason I got rid of it from the module. I would still encourage you to have this in a custom module for your site rather than in a custom php block which is stored in the database. That _is_ causing another database call and if you make a mistake you can very easily WSOD your site. It's just considered bad practice for this reason and more.

liliplanet’s picture

Would be tremendous if we could have a block of 'you have x pending friend requests'.

The custom module mentioned above, is it perhaps possible to release it to us please?

sirkitree’s picture

Status: Active » Closed (fixed)

I'm going to be working on a custom function for the count, but it won't be a block. Please see #434020: Get total count of friends by $flag->get_user_count