Comments

alex.k’s picture

Status: Active » Closed (works as designed)

I'm not planning to integrate with Rules, as it's not a priority. FL needs Rules to send out emails, while UR has the Mailer submodule to take care of that. So for UR, Rules would be more of an add-on than a necessity.

henrijs.seso’s picture

Assigned: Unassigned » henrijs.seso
Status: Closed (works as designed) » Active

thanks for info alex. for me rules seems to be necessity so ill try to come up with nice and clean ur.rules.inc file and I hope you could at least take a look at code and comment on it when its ready...

my idea is that rules (via flags and tokens) may provide a way for commenter and node author to establish relationships with one click on node page (well, the other way around in my case). first draft is working well.

also user_relationships_api.actions.inc has large part of code for actions commented out and it seems it contains reusable material. what happened to that code? any history? is this code animated, does it do something?

alex.k’s picture

Issue tags: +actions, +rules

This would be a great addition, let's see what you come up with.

also user_relationships_api.actions.inc has large part of code for actions commented out and it seems it contains reusable material. what happened to that code? any history? is this code animated, does it do something?

Somebody asked me this a while ago as well... The code was commented out when I inherited it from the original author - so I don't know what state it is in. It does look pretty good at a glance. Please uncomment it, and see how it works. It would certainly be advantageous to use actions, rather than one-off code.

henrijs.seso’s picture

I have a question about

user_relationships_delete_relationship(&$relationship, &$deleted_by, $op = 'remove');

and in particular about $relationship. It has to be "object of the relationship". How do I load such object if I have 2 UIDs. Handbook (http://drupal.org/node/203396) says i could use

user_relationships_load($param = array(), $count = FALSE, $sort = 'rid', $order = NULL, $limit = NULL, $include_user_info = FALSE)

and that special key array("between" => array($uid1, $uid2)) will return all relationships between the two user ids. Im trying to get it to work but not with much luck so far. Ideally id like to receive only relationships of particular type.

Is handbook up to date? Maybe you could write some EXAMPLE parameters of that you THINK should work?

alex.k’s picture

If you already know the relationship type id, then you could simply add it to the $param array, like so:

$relationships = user_relationships_load(array('between' => array($uid1, $uid2), 'rtid' => $rtid));
$relationship = $relationships[$rtid][0];

The book pages you reference are for 5.x-2.x, actually... I added a note in them. The most up to date documentation on the API are comments in front of each function in user_relationships_api.api.inc

henrijs.seso’s picture

Thanks for the tip. Im getting error with this code:

warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\test02\sites\all\modules\user_relationships\user_relationships_api\user_relationships_api.api.inc on line 36.

It looks like first line does the magic and I get $relationships =

Array ( [26] => stdClass Object ( [rid] => 26 [requester_id] => 1 [requestee_id] => 3 [rtid] => 1 [approved] => 1 [created_at] => 1243971262 [updated_at] => 1243971262 [flags] => 0 [name] => friend [plural_name] => friends [is_oneway] => 0 [requires_approval] => 0 [expires_val] => 0 ) )

maybe second line $relationship = $relationships[$rtid][0]; does not work?

Any ideas?

najibx’s picture

without Rules modules, could UR send email only to his manager (already established one way relationship) when he submitted a node, for his manager's approval? i.e change cck field from draft to live state?

Or else, without using Rules, could this be achieve with workflow module as well? Or friendlist is better option?

msmccask’s picture

Hey - I have run into a situation where rules integration into user relationships would help me as well. Just curious if you were able to make any headway on this type of thing. If so, I'd be happy to help test/move forward.

Thanks.

henrijs.seso’s picture

yes, i need it too, but there is something not right, as explained in #6

Bilmar’s picture

I would truly appreciate Rules integration with User Relationships as well. Currently working on a website and I have hit a roadblock that requires this integration. Thank you.

henrijs.seso’s picture

Now iv got some time on my hands and will try to look into this.

with just first line of #5 code i get error warning: Attempt to assign property of non-object in C:\xampp\htdocs\test02\sites\all\modules\user_relationships\user_relationships_api\user_relationships_api.api.inc on line 257.

henrijs.seso’s picture

StatusFileSize
new1.92 KB

first steps in rules integration - adding and deleting relationships

It's alive!

attached you will find .zip file, expand it in user_relationships_api folder in user_relationships module folder (there are 2 files in archive). You will need token and rules modules of course. This will give you new actions in rules - "Request relationships between users" and "Delete relationships between users".

I created flag "Add author as friend" and if node is flagged with it action "Request relationships between users" happens and if node is unflagged action "Delete relationships between users" happens.

As for configuration of ADD actions I set [flagging_user:user-id] as Requester, [node:author-uid] as Requestee, 1 as Relationship type (maybe this can be made into drop down list with proper relationship type names), something as Message (for elaboration, you can use tokens for all kinds of custom messages, does not work yet, i think) and Require confirmation checkbox if it is needed (does not work yet, i think). For DELETE action I set remove as Op.

Voila! When you flag node, you become friend with its author, unflag and your friendship is gone with wind.

here is code, please suggest how to make it better, you know i am not coder :)

<?php
function user_relationships_api_action_delete_relationship($settings) {

  // setting $deleted_by
  $deleted_by = user_load(array('uid' => $settings['requester']));
  // getting relationship object
  $relationships = user_relationships_load(array('between' => array($settings['requester'], $settings['requestee']), 'rtid' => $settings['relationship_type']));
  // finding rid - this method can probably be made better
  $relationship_rid = array_keys($relationships);
  // preparing $relationship with rid
  $relationship = $relationships[$relationship_rid[0]];
  
  // voila...
  user_relationships_delete_relationship(&$relationship, &$deleted_by, $op = 'remove');
  
}
?>
henrijs.seso’s picture

Category: support » feature
Status: Active » Needs review
electricmonk’s picture

StatusFileSize
new1.84 KB

Hi all,

We've had a need for hooking into the different UR events, so we've taken the patch above, made it a full module (user_relationship_rules) and added event integration for request/approve/deny/remove actions.

This module is far from complete, for instance lacking a condition to narrow the relationship type, but it's a start. I strongly suggest that it be committed into the UR codebase.

- Shai

drupov’s picture

Subscribe

henrijs.seso’s picture

thanks monk,i definetly have no skills yet to take it that far. great job.

Michsk’s picture

I to would love this , UR and rules. When a members registers you can imidalty make a friendship with the admin. What i also would love to see is that when a member registers they imidiatly get a PM message

alex.k’s picture

@lasac

Have you tried the module in #14? Please test and comment with your feedback. Thanks!

Michsk’s picture

Yes i have seen it and am going to test. Will get back to you asap.

Michsk’s picture

First off.

This is exactly what i need! Keep on developing!

First thing:
1) I created a relationship, gave it the requester and requestee id and the id for the relationship. When the user has registered it shows the ids in the message
96
115
1
You have reggisterd for more info look at email etc etc etc...

- Debug rule evaluation
- Show fixed rules and rule sets
Above are turned off.

2) The relationship is not active even though i have NOT checked Require confirmation.
(Maybe because the relationship settings need confirmation? I would like relationships to set without needing to confirm when activating a relationship trough rules)

3) A e-mail is being send with the aproval link for the relationship. This is confusing. Because members gets two email first is activation for account and second for relationship. Make it a option to send the email? Or automaticly not send a email when the above (2) is done. So when the relationship doesnt need confirmation then just dont send the email.

4) The PM is not recieved. Look like it even isn't send out. PM settings for new users are accept PM from everybody, so that can;t be the problem.

Al with all. the module doesnt quite work YET. When more testing is needed contact me. I will be following this topic.

geraldito’s picture

Thanks electricmonk for this patch. Works for my approach to detect new UR approve event and create a new node using the $requester->uid as node author.

mortenson’s picture

Is there a way I can send email to my related users when content is created?
I tried with rules and actions but it seems not possible.

thanks for you work!

Michsk’s picture

alex.k any news on this???

d4rkngel’s picture

hi mortenson

i have did it, but i don't know if is the best way to do it (i'm not a coder), if somebody can find a better way please post it. I have 2 types of relationships, two way (friends) and one way (followers), so when a user create new content an e-mail is sent to all his followers.

Modules: rules, tokens.

You need to create a new rule with the following:

Condition: (Execute custom PHP code):

if($relationships = user_relationships_load(array('user' => $author->uid, 'rtid' => 2,'approved' => 1), array('count' => TRUE))){
return TRUE;
}

Action: (Execute custom PHP code):

$relationships = user_relationships_load(array('user' => $author->uid, 'rtid' => 2,'requestee_id' => $author->uid, 'approved' => 1));

foreach($relationships as $rtid => $relationship){
    $followers = user_load($relationship->requester_id);//there is a way to do it without calling user_load(), but i don't know how to use it, try include_user_info, of user_relationships_api

$body = 'Q onda '.$followers->realname.'[node:realname-link] ha publicado nuevo contenido en su blog.';

$headers = array(
'From' => 'site_mail@example.com',
'MIME-Version' => '1.0',
'Content-Type' => 'text/html; charset=UTF-8; format=flowed',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal'
);

$message = array(
  'id' => 'mail_id',
  'to' => $followers->mail,
  'subject' => '[node:realname] ha publicado nuevo contenido en su blog.',
  'body' => $body,
  'headers' => $headers,
);

echo drupal_mail_send($message);

}

DrakeRemory’s picture

StatusFileSize
new3.49 KB

I implemented a condition to check for a specific relationship type. I also added a drop down for selecting from the available types. I put the same form element in the already existing forms that were using this as well. There's still some work to do but this is getting close.

Michsk’s picture

going to test it out, thanks drakeremory!

Bilmar’s picture

DrakeRemory - thank you for the great work!

I tested your User Relationships Rules module and all the events worked perfectly!
Only request I have is for the 'request expired' event to be added.
For each relationship type there is 'Request expires in:' setting that is available. Would this event be possible?

Again, awesome work!

DrakeRemory’s picture

I'm sorry but this couldn't be done easily at least not by using hook_user_relationships because there is no such operation as "expire". I'm not quite sure how expiration is implemented in user relationships (and I don't have the time right now to dig into this) but I'm guessing it is just done by limiting sql queries. Therefore the event doesn't exist.

gallamine’s picture

Any status on getting this committed to the project, or perhaps turned into a completely separate project?

Bilmar’s picture

StatusFileSize
new1.63 KB

Hello everyone,

Attached is a User Relationship Rules module that was being developed but not completed.
I would really appreciate it if someone could take a look and clean it up to be used by the community.
The structure is different from the one in #25 and I'm not sure which is better. If #25 is the correct way then maybe the 'A user relationship has expired' from the attached module can be implemented into #25? Thanks very much in advance.

Events
1) A user relationship has been approved [works]
2) A user relationship has been disapproved [does not currently work]
3) A user relationship has been canceled [works]
4) A user relationship has expired [works]

rburgundy’s picture

confirmed #30 all works except for Disapproved relationship and #25 all works except for expired relationship.

can anyone take a look into combining into one awesome User Relationships Rules module for everyone to use?

rburgundy’s picture

It looks like 'Relationship request has expired' comes from event:

foreach (array_keys($relationship) as $rid) {
  /* Load relationship info */
  $relation = user_relationships_load($rid);
  /* Invoking the Rules event */
  rules_invoke_event(
    'user_relationship_expired',
    user_load($relation->requester_id),
    user_load($relation->requestee_id),
    $relationship->rtid
  );
  /* Removing the relationship */
  db_query("DELETE FROM {user_relationships} WHERE rid = %d", $rid);
}

Would anyone be able to add this to the module in #25?

d4rkngel’s picture

I have a problem.. I have two relationship types 'friend' and 'follower', I'm trying to send an email when a relationship is requested... with 'friend' works fine but when I try with 'follower' this message is shown:

warning: array_shift() [function.array-shift]: The argument should be an array in /home/hamster5/public_html/sites/all/modules/user_relationships/user_relationships_rules/user_relationships_rules.rules.inc on line 176.

This is with #25

DrakeRemory’s picture

StatusFileSize
new5.3 KB

I added the missing events for request expired and relationship deleted. I haven't tested the expired one but if it worked in the one from #30 it should work in this one as well.

I wasn't able to reproduce the issue in #33. Can you give me further information about your settings for the follower relationship type and the event on which this happens.

d4rkngel’s picture

Relationship Configuration:

Requires Approval: no
This is a one way relationship: yes
This one-way relationship can be reciprocated: yes

Rules:

Event:
A user relationship has been requested (I've tried 'A user relationship has been approved' but not email is sent)

Condition:
Relationship has type

Arguments configuration
User who initiated the request:
same
User whos relationship is requested:
same

Relationship:
The relationship object

Relationship type:
follower

Action:
Send a email to a user:
User whos relationship is requested

I get this error over and over again I'm trying different ways but is always the same, maybe I'm doing something wrong?

Bilmar’s picture

Thanks DrakeRemory! I will be testing this weekend.

fyi - I came across an issue with requests not expiring with User Relationships module (not related to this custom module; this module can be turned off and still same issue) and looks to be discussed here http://drupal.org/node/681094 If anyone can look into it or subscribe to show interest please visit the link. Thought this info might be helpful so people don't think the fault is with this user relationships rules module.

DrakeRemory’s picture

@Hamster5: I still can't reproduce this. It's working fine for me. What version of user relationships are you using?

d4rkngel’s picture

mm, that's weird I'm using 6.x-1.0-rc3 or should I use the dev version?

I've tried to make a condition where I execute php code using


if($relationship->rtid == 2){
return TRUE;
}

And the error is gone, and works fine but when I approve a 'friend' relationship, it send two e-mails, the one for 'friend request' and 'follower approved', I'm still proving

Sorry but I'm not a coder... so i don't know what i have to do...

Babalu’s picture

subscribe

Bilmar’s picture

#34 (combining #25 and #30) looks to be working great.
One small thing is to set "Rules module" and "User Relationships" as a dependencies for enabling the custom module.

For people who are testing, if you are experiencing problems with expiring requests (all requests after the first request not expiring) please subscribe and share info at #681094: Relationship Request not Expiring as per settings

YK85’s picture

+1 subscribing

robby.smith’s picture

Hello everyone following UR-Rules Integration,

I wanted to bring to you attention this feature request I opened #678806: Admin exception for 'Restrict Private Messaging to only related users', which expands on the UR-Privatemsg integration to give admin a level of privilege to still be able to send messages to any user. This is refering to the setting at www.example.com/admin/user/relationships/settings for "Allow sending messages only to confirmed relationships".

I believe this will be needed if we want a system message sent to the user notifying them of notifications using Rules, but still only wanting users to be able to message each other if they have a relationship. I am currently trying to set this up and hit this roadblock. I have no programming skills and would appreciate the help of the community =) Thanks!

Bilmar’s picture

Suggestion for additional Actions:
1) Create relationship between users
2) Approve relationship between users
3) Cancel relationship between users

Already existing Actions:
1) Delete relationships between users
2) Message user via messaging
3) Request relationships between users

DrakeRemory’s picture

I'll look into this this afternoon.

Concerning #42 I suggest a condition checking the setting.

robby.smith’s picture

hey DrakeRemory,

Please let me clarify #42. The setting at http://www.example.com/admin/user/relationships/settings for UR-Privatemsg integration works as the setting implies.."Allow sending messages only to confirmed relationships", and a Rule to send a privatemsg to a user from Admin is Denied because of it (Admin is treated as any other user). But I think that Admin should be able to have an exception (especially beneficial for UR-Rules integration!). I posted #42 hoping that someone may help with a patch that allows Admin to be given an exception.

I started the post [#678809] at privatemsg queue but the maintainer said that the setting lives in the User Relationship module so it should be asked here.

Hope you or someone in the community will be able to help. Your work with UR-Rules integration has been really great. Many thanks!

DrakeRemory’s picture

StatusFileSize
new7.93 KB

Ok, I just finished implementing the new features.

Concerning #45: There are two new conditions now. The first one checks for one or more specific relationships between users. The other one checks the setting of a specified user, in this case the user who is supposed to receive the message. Using them both should give you what you want. If admins should be able to always send messages you can add another or block checking for the permisssion.

Concerning #43: Most of it was already implemented. I changed some labels to make it easier to see what each action can do.

I also removed this modules send message action. Rules integration was commited to the new dev of privatemsg.

Please test this!

Cheers

Bilmar’s picture

Awesome! I will be testing tonight and return with feedback.
Thanks for the great work!

robby.smith’s picture

Hello DrakeRemory,

I have tested the newest version of your UR-Rules integration module and tried the new conditions to achieve a “Welcome Message”. (Note: I have the "Allow sending messages only to confirmed relationships" setting turned ON at http://www.example.com/admin/user/relationships/settings because I want to restrict users to be able to only send messages to their ‘friends”. I am able to achieve the send welcome message via rules with the above setting turned OFF)

Below are the conditions I created and I hoped this will block checking for the permission and allow the Admin to send a message to the new user but it was unsuccessful.

Is the "Allow sending messages only to confirmed relationships" setting unable to be blocked for the admin? It would be awesome if someone could take a look at the code. Your help is much appreciated!

(1) Condition: Allow private messages only to relationships
User whose setting you want to check: acting user
Negate (checked)
Weight: 0
(2) Condition: Check if two users are related
User A: Acting user
User B: Registered user
Negate (checked)
Relationship Types: Friend (checked)
Weight: 0
(3) Condition: Allow private messages only to relationships
User whose setting you want to check: registered user
Negate (checked)
Weight: 0

I first tried with only (1), then only (2), then (1) and (2), then finally (1) and (2) and (3).
I was unable to have a “Welcome Message” be sent to a newly registered user.

Again, thanks for your great work and I look forward to helping get UR-Rules fully integrated!

Bilmar’s picture

Hi DrakeRemory,

Great work with developing the UR-Rules Integration!
I tested the actions:
Request, create or approve relationships between users [worked great!]
Delete, cancel or disapprove relationships between users [worked great!]

I was a little confused by the below in Action - "Delete, cancel or disapprove relationships between users",
Replacement patterns for updated user
Replacement patterns for unchanged user
Replacement patterns for acting user [this is clear]

The conditions I am not clear on how to use, but would really like to learn how to use.

It seems like from your explanation in #45, we should be able to checking Event: "A message is sent" (Privatemsg) and set a condition for if the users does not have a relationship to one another to not allow the message to be sent. Is my understanding correct (this would be awesome)? and could you please explain how this can be done?

Thanks!

Bilmar’s picture

Another thing I just noticed:

In a Rules set: Rule: Action there are no "Token replacement patterns" available for Requester and Requestee.
I made sure to add Relationship as an argument in the Rule set. I see the "Token replacement patterns" in Triggered rule but not Rules set=>Rule=>Action.

Thanks!

d4rkngel’s picture

Still the same problem here :( I think that I'll have to return using UR Mailer...

rburgundy’s picture

I look forward to the next version of the User Relationships-Rules module.
Any updates?

DrakeRemory’s picture

Hi folks,

I'm pretty busy right now so I won't be able to spend time on this in the next 2 weeks.

Bilmar’s picture

We all understand. Your work has been awesome and we hope to hear from you again in the next several weeks.

If anyone else can continue DrakeRemory's work and add the last missing features it would be much appreciated.

Thanks!

Bilmar’s picture

The issue with requests not expiring has been fixed by alex.k #681094: Relationship Request not Expiring as per settings

However, with this fix and further testing I have found a problem with an event in this custom module:
The event A user relationship request has expired does not work as it should. It gets triggered without any problems but the Event cannot differentiate between one request expiring and multiple requests expiring for the logged in user.

For example: User A sends 3 relationship requests within 5 minutes. One day later they all expire (during the same cron cycle as the requests were close to one another). The Event is triggered only once(!) and not per expired request. This is an issue as I am aiming to set off an Action per request that is expired.

Please let me know if more details are needed in the above explanation.

Thanks!

2ndChanceTech’s picture

so I've installed the package and not sure if it's working correctly.

I have dev version of User Relationships.

Here's what I'm trying to do (if possible).

I'm using the invite module to auto create a relationship between inviter and invitee (works fine).
I called this relationship "Affiliate"

Now what I'd like is.
When User is granted points (event, works fine)
Load User Account -> Affiliate Requester (can't find proper token, or make work).

So I guess the question is, can the ID of a user be loaded based on their relationship to the current user?

-----------------------
I tried to find a work around using event "when user relationship is requested".
Load content profile of requestee
populate field w/ Requesters ID

I figured by making an affiliate field in the content profile, I could populate it with the ID of the requester and hide it.

The work around would of done what I needed, however the event doesn't trigger!

YK85’s picture

Hello, I was wondering if there has been any further development in this UR-Rules integration?
Can anyone else in the community help to finalize this module that integrates these two awesome modules? Many thanks!

robby.smith’s picture

it would be really nice if someone with programming knowledge would be able to spend a little time to finish cleaning up the language and look into fixing/removing the "request has expired" event as it doesn't seem to work properly.

@maitainers of User Relationships - is it still not possible to include this rules integration with the core module?

okday’s picture

subscribing

Johnny vd Laar’s picture

subscribing

sashainparis’s picture

Category: feature » bug

line 183: variable should not have & when you use it - only when you declare it.

//  user_relationships_delete_relationship(&$relationship, &$deleted_by, $op = 'remove');
  user_relationships_delete_relationship($relationship, $deleted_by, $op = 'remove');
robby.smith’s picture

@bloggybusiness - i dont think there is anyone maintaining this
would you be able to kindly go through the current version at #46 and update it?
as per #55 the event: request has expired does not work. i confirmed this with testing

thank you!

gorgo’s picture

Hi,
This seems really awesome!
I'm new to rules in drupal and I'm having a hard time using this...

I am using the Ucreate module to allow certain roles to create users. I'm trying to get this rule to automatically create a 1way relationship between the logged in user (who created the new user) and the new user (which I'm not sure how to get his newly created ID...) once the account is created.

Is this at all possible? could anybody please explain to me how I can go about it?

Thank you!
Guy

gorgo’s picture

ok I ALMOST got it!
I managed to get rules working to set the relationship the only problem I'm having is getting the variable for the new created used id... tried [user_added:uid] but that didn't work. anybody?!

Bilmar’s picture

Category: bug » feature

Summary of UR-Rules Integration module

Below is a breakdown of what this module offers for UR-Rules integration and changes needed for someone that could take the time to run through and finalize the work. The most recent version of the module is available at #46 (http://drupal.org/node/468764#comment-2486950)

Events
1. A user relationship has been approved
2. A user relationship has been cancelled
3. A user relationship has been denied
4. A user relationship has been removed
5. A user relationship has been requested
6. A user relationship request has expired [This needs to be removed from the module or the label renamed to say something like 'User Relationships expire request task has run' and add warning on the use] - The User Relationships module request expiration is triggered on cron run, but maximum once per 24hrs, and the task will expire all requests queued for expiration in one batch. Therefore, the rule event will be triggered only once even if 2+ requests are being expired. If you need a rule to be trigger for each request expiration, this functionality can be achieved using rules scheduling.

Conditions
1. Allow private messages only to relationships [I am not sure how to use this. Maybe not needed?]
- The settings to allow this functionality is at www.example.com/admin/user/relationships/settings
2. Check if two users are related
3. Relationship has type

Actions
1. Delete, cancel or disapprove relationships between users
2. Request, create or approve relationships between users

Regards

Bilmar’s picture

StatusFileSize
new8.35 KB

Bringing the current state of the UR-Rules module up to the front.

I made minor changes:
1) the word 'denied' changed to 'disapproved' in order to be in line with the UR module
2) added dependencies to user_relationships and rules in .info file

I don't know programming so this is as much as I can do =)

mstef’s picture

Status: Needs review » Needs work

Not sure how this red flag went unnoticed...

When confirming a friendship with a rule from this being triggered:

warning: Invalid argument supplied for foreach() in /var/www/trunk/docroot/sites/all/modules/contrib/user_relationships/user_relationships_api/user_relationships_api.api.inc on line 36.

Anyone else?

mstef’s picture

@66: I don't want to sound rude, but if you don't know how to program, don't try to. Your .info file was wrong. The module required is supposed to be user_relationships_api.

mstef’s picture

Status: Needs work » Needs review

Problem stemmed from a bug in UR itself, regarding Token evaluation. I posted a patch.

See: #811222: Incorrect Parameter inside user_relationships_api_token_values()

Bilmar’s picture

If no one is going to work on it (for half a year), I'd rather try and fail than sit around and do nothing.

All changes were documented in #66 (nothing left out). If the changes were incorrect, someone can fix it and upload a correct version. I do appreciate you working on it and will support by helping test the module.

Thanks

DrakeRemory’s picture

StatusFileSize
new8.45 KB

Summary of UR-Rules Integration module and new Version

Below is a breakdown of what this module offers for UR-Rules integration. I think this is pretty close to what this module should be.

Events

  • A user relationship has been approved
  • A user relationship has been cancelled
  • A user relationship has been denied
  • A user relationship has been removed
  • A user relationship has been requested

Conditions

  • Check if two users are related
  • Relationship has type

Actions

  • Delete, cancel or disapprove relationships between users
  • Request, create or approve relationships between users

Changes

  • Expire Event was removed since this can be easily done with the rules schedule module.
  • #43 was fixed in user relationships module and the condition to check for the private message setting was removed
  • The changes from #66 were included.
Bilmar’s picture

Thank you very much DrakeRemory!

jthomasbailey’s picture

It works!

blueblade’s picture

subscribe

joostvdl’s picture

subscribe

mstef’s picture

Pretty sure Line 16 in .module should be

rules_invoke_event('user_relationships_' . $op, user_load($relationship->requester_id), user_load($relationship->requestee_id), $relationship);

NOT

rules_invoke_event('user_relationships_' . $op, user_load($relationship->requester_id), user_load($relationship->requestee_id), user_relationships_load(array('rid' => $relationship->rid)));
joostvdl’s picture

The Elaboration text is not available in the $relationship. I want to use it to send an e-mail.

It looks like if the rules are invoked even before the elaboration module can save the elaboration text to the database.

Is there a way in getting the text?

joostvdl’s picture

@ #76
It's NOT working for me!

mstef’s picture

Well it works fine for me and fixes some bugs. One being that no data is returned on the action of a relationship being removed.

joostvdl’s picture

This is the Rules evaluation:
#

* 0 ms "A user relationship has been requested" has been invoked.
* 0.088 ms Executing the rule "Send e-mailnotification to editors after Liefdespartner is requested" on rule set "A user relationship has been requested"
* 1.168 ms Condition "Relationship has type" evaluated to FALSE.
* 1.226 ms Evaluation of "A user relationship has been requested" has been finished.

It looks like that the Relationship Type is not evaluated correctly with your solution.

mstef’s picture

It works perfectly for me. There's a bug in UR too which I had to patch. Probably why it's not working for you..

I'll post that issue here in a minute.

mstef’s picture

This is what was needed: http://drupal.org/node/811222#comment-3146010

A few comments below that is a patch.

joostvdl’s picture

After applying Patch it still didn't worked. When I removed the Condition to check on Relationship Type. It worked.

Patch made also the complete $relationship object available, so the elaboration text is now also available. Only problem remains that checking on Relationship type failes.

joostvdl’s picture

I found why the check is not working:

In the function: user_relationships_rules_condition_relationship_has_type($relationship, $settings) (file: user_relationships_rules.rules.inc) it uses an array_shift call.
But the $relationship is an object. Therefore it doesn't work.

There are two ways to solve this:
1. convert $relationship in the user_relationships_rules_condition_relationship_has_type to an array before the array shift
2. Convert the object to an array in calling the invoke.

What is preferable?

mstef’s picture

Whatever works..

I came across these issues because 1) the relationship type token wasn't making it to rules, 2) i was getting the php errors listed on that issue 3) removing a relationship wasn't invoking the rules

joostvdl’s picture

Are there no other functions that thinks they are getting an array instead of an object (fired by the invoke function)?

Or do you need an object for the stuff you need? Otherwise I think that converting to an array with the invoke is the safest solution.

joostvdl’s picture

StatusFileSize
new1.51 KB

A patch....

I removed the array_shift because it isn't necessary at all. I added the line from #76

mstef’s picture

This should be made into a separate project, no?

joostvdl’s picture

If more people can test this functionality, I think it can be part of the UR as a submodule like all other parts. But that's up to the maintainers ....

YK85’s picture

It would be awesome if someone could take this into a separate project or if it could be added into UR module (preferably the later). Thank you

BenK’s picture

+1 for adding this directly to User Relationships (as a sub-module).

berdir’s picture

Looks like this is even part of Drupal commons.. :)

See http://cyrve.com/commons

Can someone verify that it is the same module and if there are any changes compared to the version here?

Also, a re-roll with the patch in #87 applied would be nice, I can try to review this then.

jazzdrive3’s picture

Yes, a re-roll with all of the patches applied would be very much appreciated!

Michsk’s picture

How is this module going to life on? Will it be committed as a sub module or as a own module? Mikestefff: have you got any plans with this?

mstef’s picture

@Berdir: Yes it is in Drupal Commons - not with the patch from comment 87. Along with my patch of UR_API ( http://drupal.org/node/811222#comment-3157674 ).

mstef’s picture

This seriously needs to be a contrib module separate. There are about 3 separate threads I have to bounce around on for this module. Who's going to step up to the plate? I only patched it up - I don't want to take credit for writing it.

BenK’s picture

@mikestefff: Do you mean that patch of UR_API (http://drupal.org/node/811222#comment-3157674) is included in Drupal Commons?

Also, I'm not convinced this should be a separate module so long as we can get alex.k to commit it. The reason is that Berdir and I have been working on the D7 port of User Relationships and I'd like to get in Rules support to the D7 port. I think this might create an unnecessary obstacle if we move this to a separate module.

--Ben

Bilmar’s picture

@mikestefff - could you please re-roll for Berdir to give a final review. It will be awesome to get this into the D7 port and into D6 version.

@Berdir - would you be able to commit this as a submodule to UR in the future as I'm sure D7 version will want it? =)
I have started to write up documentation on use-cases with UR-Rules + Privatemsg + Userpoints similar to Userpoints-Rules at http://drupal.org/node/873386

mstef’s picture

@BenK: Yes. Download Commons and view PATCHES.txt in profiles/drupal_commons/modules/

@trupal218: Re-roll what exactly?

Bilmar’s picture

Hi mikesteff,

Is the patch at #87 needed after your patch at http://drupal.org/node/811222#comment-3157674 ?

Thanks

mstef’s picture

It may help - I haven't yet looked at it - so no, it's not needed.

manuj_78’s picture

Does the Drupal_commons implement the UR_Rules integration?

And can someone please clarify what all patches need to be implemented to get the UR_rules working with User relationship

Michsk’s picture

#102: yes commons implements this. And use the patch of #87

manuj_78’s picture

And would it be a drop in replacement for User relationship module? I mean if I were to replace the User Relationship module from drupal.org with the user relationship module from drupal commons...will that work for any drupal site?

Michsk’s picture

and you would do that because? But to awnser your question, i guess it would work tough i dont know for sure.

manuj_78’s picture

I had no idea why I asked that ..maybe because it was too late...

So as a summary I am assuming I need to apply the patches at

http://drupal.org/node/811222#comment-3157674 and
http://drupal.org/node/468764#comment-3169784
as well as
http://drupal.org/node/468764#comment-3029508 to get UR + Rules functionality

Is that correct or did I miss something?

chuckbar77’s picture

This is very exciting development! Can someone please re-roll the module with the patches required?

(subscribing)

manuj_78’s picture

I applied the above patches..however I am not able to create a trigger for sending mails to all related users when someone adds a node..can someone point me in the right direction please

henrijs.seso’s picture

Assigned: henrijs.seso » Unassigned

removing myself since development has gone viral...

manuj, you need to create php function to gather and return email addresses of all friends in comma separated string. You have to write php for this, since there is no action "load all friends" and probably never will. But it would be cool, I had to write my own php to send email to all people that has tagged node with term that is applied for user too... but anyways, thats another issue.

rschwab’s picture

Subscription Activation Go!

secoif’s picture

Subscribing

jazzdrive3’s picture

So is anyone close to rerolling all the patches into a coherent module? I can't understand where most of the paths lead. Plus any patch tool I try to use on Windows never, ever works.

secoif’s picture

@jazzdrive3 OT RE: windows patch tools: use cygwin.

tinohuda’s picture

subcribing

henrijs.seso’s picture

StatusFileSize
new3.2 KB

This is awesome. Tested high and low. Thank you DrakeRemory and mikestefff and everybody for great input. Code looks beautiful :) Here is patched files again, final working version in one peace. All you have to do to make it work is patch from here http://drupal.org/node/811222#comment-3157674 and that is already contributed.

Alex? IMO its contrib time!

henrijs.seso’s picture

one more thing...

Warning: Call-time pass-by-reference has been deprecated in sites/all/modules/user_relationships_rules/user_relationships_rules.rules.inc on line 165

YK85’s picture

Hi LavaMeTender - does you comment in #116 mean there might be a problem with the patch?
#811222: Incorrect Parameter inside user_relationships_api_token_values() looks to have already been committed so no need to apply that other patch as indicated in #115 right?
Very exciting to see this Rules integration wrap up and looking forward to seeing ship with UR.

Thanks!

YK85’s picture

In the Rules: Replacement patterns for logged in user I only see the following available:

[account:requestee]	The user who approved the connnection request.
[account:relationship-name]	The relationship name (singular form)

Is this strange?

Have been using this module on my live site and it works great!

henrijs.seso’s picture

#116 means minor fix is needed for php5 compability. As for 'is it strange?' it depends :) What action do you use? If you need some more replacement patterns, maybe you need to add load something action, like 'load user/node by ID' or something like that.

mstef’s picture

#116: Sounds like a php 5.3 issue

#119: What is strange?

YK85’s picture

With the "Request has been sent" rule event, I schedule a request reminder Rule Set with identifier "request reminder uid [requester:uid] to [requestee:uid]"

If the requestee logs into his/her account, I want to delete this scheduled rule but I am not able to get the [requester:uid] to [requestee:uid] as replacements in the action to delete the scheduled rule when user logs into account. I can get [requestee:uid] as the replacement with [account:uid] but unable to pull [requester:uid]. Is there a way to load the variables needed?

Thank you!

henrijs.seso’s picture

You need to load user by ID and ID is [requester:uid]. This question does not belong here. Please read rules documentation.

YK85’s picture

I thought it to be relevant here as those tokens are not available in Rules as instructed in #122, and this issue queue looks to be development towards Rules integration. If it's just my lack of understanding than I apologize in advance.

User_relationships_api tokens
[account:requestee]	The user who approved the connnection request.
[account:relationship-name]	The relationship name (singular form)
Tafa’s picture

Hello all,

As with #116, I am getting an error message at the top of the Rules page. Basically, it reads :

Warning: Call-time pass-by-reference has been deprecated in ...modules/user_relationships_rules_0_0/user_relationships_rules/user_relationships_rules.rules.inc on line 183 Warning: Call-time pass-by-reference has been deprecated in .../user_relationships_rules_0_0/user_relationships_rules/user_relationships_rules.rules.inc on line 183

After a bit of research, it appears that I have an old version of something lying somewhere. Can anyone help me with this?

Essentially, what I am using UR rules with is to send a tokenised email to users to request a relationship. In doing so, I hope to insert a link which users can use to accomplish more actions.
Let me know what you think.
Thanks,
T

msti’s picture

subscribe...

henrijs.seso’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new3.2 KB

Fixed #116. Works flawlessly now.

imDhaval’s picture

love to sub.

alex.k’s picture

Status: Reviewed & tested by the community » Fixed

Thank you tremendously to coders and testers for rounding this up. Committed in http://drupal.org/cvs?commit=449492.

henrijs.seso’s picture

wicked

Status: Fixed » Closed (fixed)
Issue tags: -actions, -rules

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