I have made a patch to add requester and requestee current user field.

Many people request it and is very simple to implement...

I have tested here and sounds good to me!

Thanks for this very useful module!

Comments

YK85’s picture

Status: Active » Needs review

Awesome! I will definitely be testing this out soon

Would you able to add one more field for 'Current user is either requestee or requester'?

For a Pending Request, a user can either be the requestee or the requester. It would be great to be able to make a view where it shows ALL Pending Requests of a user (requests sent by current user as well as requests received by current user).

Thanks for the great work!

pedrofaria’s picture

You're welcome :)

Install Views Or module to add OR clauses on your filters.

Cya

ajayg’s picture

who is the current user in this case? Is the current user passed through the argument or the current logged in user?
Also what is the value logged in (True /false) signify? If you select True for logged in user then it seems to be working. But How do you then filter out based current user passed as argument?

Do you mind giving the use case where this is useful or show a view where it is useful? This sounds like a needed patch but I am baffled by the options when I try to add this filter.

YK85’s picture

Status: Needs review » Reviewed & tested by the community

Hello,

The patch applied smoothly and the below two fields were added to views. It works great!
User relationships: Requester user is current user
User relationships: Requestee user is current user

I'm excited to play with this further and see what UR-Views integration issues this will be able to resolve. Also, it looks like Views3 supports OR clauses in filters so 'Current user is either requestee or requester' will most likely work without the Views Or module.

@ajayg - to try to help answer your question from my use-case:
1) Requester user is current user (Is the logged in user: YES)
- will show all pending and approved relationships of the current logged in user
- additional filter 'Relationship status' will allow showing only pending or only approved relationships of the current logged in user
2) Requester user is current user (Is the logged in user: NO) aka Requester user is not current user
- will show all pending and approved relationships of all users except current logged in user
- helpful with managing the relationship info as admin by filtering out the admin as the requester (using other relationships you can show requestee of pending requests including where admin is the requestee)
3) Requestee user is current user (Is the logged in user: YES)
- will show all pending relationships of the current logged in user
4) Requestee user is current user (Is the logged in user: NO) aka Requestee user is not current user
- will show all pending and approved relationships of all other users
note: my use-case doesn't include how this new feature helps with one-way relationships, but i'm sure it helps!

If you are able to spend anymore time to help improve UR-Views integration, please check out this combined feature request post here:
#822508: Improve UR-Views Integration

guntherdevisch’s picture

Nice patch pedrofaria!

@yaz085: Which type of view did you select to create your pending requests view? I have a User relationship type view, but i'm not seeing the 'Views Or' filter ...

Thanks,
Gunther

pedrofaria’s picture

Thanks guys... :)

I will take a look on #822508

@gunther, Views Or is a module...

cya

YK85’s picture

StatusFileSize
new3.31 KB

Hi Gunther,

Views Or is a module that allows adding OR functionality to views 2 filters. But Views 3 comes shipped with OR functionality for filters so you don't need to install the Views Or module. To get to the AND/OR clauses for filters in Views 3 click on the Reorder button for the filters. You can change the operator to OR, or click the 'Add new group' button and make a separate OR filter group.

I attached an export of a simple view 3 export that achieves the All Pending Requests (requests sent and requests received) view.

The filter looks like:

(
  User relationships: Relationship status = 0
) AND (
  User relationships: Requestee user is current user True
  OR User relationships: Requester user is current user True
)

Please email me directly through the contact page for further views customization questions.
I hope this patch gets reviewed more and committed =)

YK85’s picture

Hi pedrofaria,

You're patch also helps greatly with one-way relationships it seems =)
Solves the 'my fans' view #864590: How to create "fans (them to you") view of one way relationship?

pedrofaria’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new4.09 KB

@yaz085, i added in patch your request about "requester or requestee"...

pls, check if it is what you need...

cya.

pedrofaria’s picture

StatusFileSize
new5.26 KB

Add counter field for views... according #684156: Views relationship count

pedrofaria

YK85’s picture

Hello,

Minor field name change recommendation:
User relationships: Counter user relationships >> User relationships: Counter

Also, the counter doesn't seem to work at the moment. The counter is showing as '2' for every User.

Thanks

YK85’s picture

Hi,

One more thing to consider, if possible, is a counter for pending requests or counter for approved requests.

Many thanks!

YK85’s picture

Hi again =)

I opened #873874: Requester/Requestee user fields should show username like "User: Name" field instead of text 'view'

Both the "User relationships: Requestee user" and "User relationships: Requester user" fields currently only show the text 'view' and linked to the user profile page. I think this should be showing the themed username in the same way "User: Name" works. The Rewrite the output of this field could be used to change this to view or any other text.

I hope you can help with this as well =)

Thanks and I look forward to testing the next version of your patch!

ajayg’s picture

-1 for patch #11

Although I really appreciate the great work pedrofaria is doing, I am really concered a feature creep is happening here. My Suggestion is let us review and test the patch in #10. mark it RTBC and get it checked in.

Meanwhile open a seperate issue for counters and start discussing it there. IMHO delaying this patch (in #10) for other additional work is not a good idea. If both patches gets in same time that is a different issue. But atleast having one patch ready for Alex to check in, is far more userful for all of us and the progress of UR module.

YK85’s picture

Hi pedrofaria,

I have to agree with ajayg on this one as separate patches may help get things tested and committed faster.
Would you be able to kindly upload the patches separately for the issues?

Of course, as you are the one wielding the sword - I will accept whatever decision you make =)

You're work has been a tremendous help to UR-Views integration!

pedrofaria’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new4.09 KB

OK, i agree, i will repost the #10 patch and set as rtbc status and ignore #11 for now...

I guess that counter field is more difficult than i thought...

guntherdevisch’s picture

Hi pedrofaria,

Great patch!

It works with one-way relationships, but does it also work for two-way relationships?

I have one view for my pending requests. But in that view you can only choose one of the two relationships (User relationships: Requestee user / User relationships: Requester user) on a field.

Example: Now i have a pending relationship with a friend. In my pending relationships the name of the other person is there. But in my friend's account, his own name is there (instead of my name) -> this because you can only choose one relationship on a field. In my case i choose the 'requestee' relationship on my Username field.

Is there a way to fix this or do i have to make 2 different pages in my view?

Thanks,
Gunther

Bilmar’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new9.38 KB

Hello,

I have confirmed Gunther's findings as well.

A Two-way relationship view for ALL pending requests (requests sent and requests received) seems difficult.

Fields
User: Name

Filters
User relationships: Requester or Requestee is current user / True 
User relationships: Relationship status = 0

test users:
user1 (me)
user2
user3

requests sent:
user1 sends request to user2
user3 sends request to user1

The All pending view (as user1) will show:
user2
user1

We want to show:
user2
user3

Adding Relationship field "User relationships: Requester user" and adding to the field shows:
user1
user3

Adding Relationship field "User relationships: Requestee user" and adding to the field shows:
user2
user1

Attached is the view export which includes views pages: My Approved, My Pending (All), My Pending (sent), My Pending (received); where My Pending (All) does not work properly yet.

ajayg’s picture

Status: Needs review » Needs work

Was anybody able to apply patch in #17 (originally #10)? When I tried the patch, it applied clean but I am getting white screen of death.

I am still investigating why , but one thing I noticed , the patch didn't create a new file "user_relationship_views/views_handler_filter_user_relationships_requester_or_requestee_current_user.inc" as expected. Not sure if this is the issue or something else.

I had applied the original patch at the top of the page previously. It installed clean and was working. So before installing patch in #17, I reverted this original patch just to make sure. So something got introduced in patch #17 (patch #10) that is not correct.

pedrofaria’s picture

The #17 is the same of #10...

ajayg’s picture

yes I know. But most of us (atleast me ) had tried and tested your very original patch at the top of page. And it worked. Then I tried patch #17 (which is patch 10) and got a white screen of death and now my site is completely unusable. I am still trying to recover but thought I would inquire here if someone has actually tried patch #17(#10). As I mentioned the patch also failed to create the new file "user_relationship_views/views_handler_filter_user_relationships_requester_or_requestee_current_user.inc". So atleast some minor change is required there. I suspect this missing file is the cause of whitescreen but I don't know for sure yet.

YK85’s picture

Status: Needs work » Reviewed & tested by the community

Hi pedrofaria,

I'm not a programmer so not sure but I wanted to share #649394: Add views handlers necessary for friends tracker from the issue queue here hoping that it may add other ideas.

@ajayg - Did you figure out what you were doing wrong? The patch at #17 works perfectly. How are you applying the patch? Try uploading a fresh copy of UR to your server to fix your WSOD, then download a fresh copy of UR and patch with #17 then upload to your server. I've tested this many times =)

Thanks

guntherdevisch’s picture

Hi all,

Because there isn't a two-way relationship possible yet, i'm making 2 pending pages (tabs) in my view. That's working fine, but now i want to restrict the 2 pages for the requestee or requester. Is there a way to do this? I only want to show the page (tab) if the current user is either requestee or requester. By example: if ($user) = 'requestee' give access to/show the page (tab).

Can someone help?

Thanks!
Gunther

chuckbar77’s picture

This filter works perfectly! Thanks

(I don't think we should wait for someone to develop filters for every scenario before committing. This resolves the views filter needed for most cases, and hopefully someone can look into other filters to be able to have one view for both sent and received requests. Also, the question asked in #24 is unrelated to the development and testing of the patch in #17.)

Alex - could you please take a quick look at commit the work?

alex.k’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

freelylw’s picture

I have installed the latest RC5 version which should including this patch already, but I still can not show my fan's view. please see the code I exported from my views.( which came from http://drupal.org/node/864590 ) anybody can give a little bit help, I have been struck here for a while. Thank you.

$view = new view;
$view->name = 'sample_myfans';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'users';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'requester_id' => array(
'label' => 'requester',
'required' => 0,
'id' => 'requester_id',
'table' => 'user_relationships',
'field' => 'requester_id',
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'uid' => array(
'label' => 'Uid',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'absolute' => 0,
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'html' => 0,
'strip_tags' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_user' => 1,
'exclude' => 0,
'id' => 'uid',
'table' => 'users',
'field' => 'uid',
'relationship' => 'requester_id',
),
));
$handler->override_option('filters', array(
'requestee_id_current' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'requestee_id_current',
'table' => 'user_relationships',
'field' => 'requestee_id_current',
'relationship' => 'none',
),
'rtype' => array(
'operator' => 'in',
'value' => array(
'0' => '2',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'rtype',
'table' => 'user_relationships',
'field' => 'rtype',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));

dabeast’s picture

Is there a way that this filtering on the current user could be extended to an Argument (i.e. Requestee or requester is the (uid) in the Argument)? Thanks for providing this functionality.