Hey all,

The Rules module (http://drupal.org/project/rules) is a popular module in the Drupal community that allows site administrators to define conditionally executed actions based on occurring events from a point-and-click UI. (According to the latest usage stats, more than 37,000 sites use this module.)

It would be fantastic if we created a rules integration sub-module that specified a "Linked account was added" event (an event that occurs when a third-party account is added via the Janrain Engage module) and an inverse "Linked account was removed" event. Because numerous modules integrate with Rules, this would allow site administrators to configure automated actions such as:

1. Change a user's role when they add a linked account. (Drupal core)
2. Send a user an e-mail when they add a linked account. (Drupal core)
3. Display a custom screen message when the user adds a linked account. (Drupal core)
4. Award a user "points" when the user adds a linked account. (Userpoints module)
5. Deduct points when a user removes a linked account. (Userpoints module)
6. Send a user a private message when the user adds a linked account. (Private Message module)

And that's only the beginning of the potential use cases. Additionally, because Rules can react conditionally, it would be great if the Rules integration allowed for actions to be taken conditionally based on the type of linked account being added. By doing this, each of the actions described above would only be taken if a user adds a specific type of linked account (such as a Facebook account, but not a Twitter account). This would allow, for instance, for an e-mail to be sent or a message displayed that offers suggestions for Facebook wall postings only if a user adds a linked Facebook account.

To configure this type of Rules condition, a site administrator would just use Rules' default "Data comparison" condition. The Janrain Engage account type would appear as a data selector that could be selected by the administrator. The site administrator would then compare the account type data selector to a manually entered value (such as "Facebook"). The manually entered value would just need to match how the account type is stored by the Janrain Engage module.

For good examples of how to create a Rules integration sub-module, see the Userpoints (http://drupal.org/project/userpoints) and Private Message (http://drupal.org/project/privatemsg) modules. Both modules have Rules integration sub-modules (userpoints_rules and privatemsg_rules) with very solid code that can be adapted.

Cheers,
Ben

Comments

BenK’s picture

For additional information about rules, documentation can be found here:
http://drupal.org/node/298476

--Ben

geokat’s picture

Assigned: Unassigned » geokat
BenK’s picture

Hey George,

One more thought I had recently: In addition to the Rules events and conditions described above, we really should have our own Rules action that implements the module's social sharing features. For instance, we may want a "Post to linked account" action that allows any Rules event to trigger a posting to any third-party account (Facebook, Twitter, etc.) that has been authenticated by the user via Janrain Engage. Using this action, for instance, the site could automatically post messages to Facebook, Twitter, and other sites (via Janrain Engage) when users:

* Earn points (Userpoints module)
* Change roles (Drupal core)
* Create a site account (Drupal core)
* Earn a badge (User Badges module)
* Make a friend (User Relationships module)
* Bookmark site content (Flag module)

Ideally, the action should have options to post to only one linked account (post just to Facebook), post to multiple specified accounts (post only to Facebook and Twitter), or else post to all linked accounts. The action would also need a text area to specify the default message text for the posting (with regular Rules tokens available for data inserted by other modules). As you can see from the examples above, this type of Rules action would really expand the possible use cases of social sharing for Drupal site builders/developers.

One alternate approach would be to actually create separate actions for each type of linked account, such as a "Post to Facebook" action and a separate "Post to Twitter" action. The advantage of this approach is that you could have different options per action that are specific to the particular account type. (Facebook, for example, could have more available posting options than Twitter.) The drawback of this approach, however, is that we would duplicate code between actions and would need to create a new rules action every time Janrain adds support for a new third-party social network. That's why I think the first approach would probably be a more elegant solution.

Cheers,
Ben

geokat’s picture

Hi Ben,

I've just added the basic Rules integration as suggested in the
original post above.

As for the "Post to linked account" action, I think this is a good
idea and I'll try to see if I can implement it as part of the next
feature commit.

Thanks,
George

BenK’s picture

George, sounds good. I'll be testing your initial Rules integration shortly.

--Ben

BenK’s picture

Status: Active » Needs work

Hey George,

I've just completed testing the initial Rules integration and things are looking really good.

I tested both the 'Linked account was added' and 'Linked account was deleted' actions and they both functioned well.

I also tested conditions for each of these actions and I got that working, too. Specifically, I used the generic Data Comparison condition to only take an action if a specific 'provider' had been added. That worked, too, although it took me a little while to figure out that I needed to use the human-readable version of the provider name (such as "MySpace") instead of the machine name ("myspace"). Because the data comparison needs to be an exact match, upper and lower case needs to be exact.

So one suggestion: Can you post below a list of all the possible human-readable provider names? That will be useful for anyone who wants to create a Data Comparison using the provider name. I can also add this list to the eventual module documentation. Otherwise, it's easy to mistakenly use 'google' instead of 'Google' and be confused why the data comparison isn't working.

So that we have it handy, here's a list of the provider machine names (as I found in the Janrain Engage documentation) that we need human-readable names for:

"aol"
"facebook"
"google"
"live_id"
"myspace"
"openid"
"yahoo"
"flickr"
"livejournal"
"myopenid"
"verisign"
"wordpress"
"blogger"
"hyves"
"netlog"
"twitter"
"linkedin"
"paypal"

Let me know if I left out any recently added providers.

And have you made any progress on the "Post to linked account" rules action?

Nice job on all of this! :-)

Best,
Ben

geokat’s picture

Hi Ben,

Yes, all these machine names are correct. And these are all of them.

I just committed a fix that makes the rules submodule use the machine
names instead of the provider title. I agree that they are easier to
use.

I haven't had the time to work on the actions yet.

Thanks,
George

BenK’s picture

George,

Can you make both machine names and human-readible names available to Rules? Basically, there would be two different versions of 'provider' available with slightly different names to differentiate between the two.

The reason is that the human-readable versions were handy if you ever needed to use the provider name as a user-facing token within a Rules action.

For example, if your action was to 'Send a mail' or 'Show a message on the site', you could use the human-readable version of the provider name and actually have the proper capitalization when it is displayed to the user in the e-mail or screen message.

If you wanted to include the provider name in the subject line of an e-mail, for instance, you could use code like this:

Subject:  You added a linked <?php echo $rpx->provider; ?> account.

So machine names are easier to use for data comparisons (and similar user cases), but human readable versions are helpful for tokens.

--Ben

BenK’s picture

One more thing: I think we should change the Rules group for both the 'Linked account was added' and 'Linked account was deleted' events. Both are now part of the 'User' group (which does make perfect sense logically).

However, when most contributed modules add their Rules events, they usually create their own group (so that the events are easy to find in the big list of possible events). Currently, it looks like 'Linked account was added' is a Drupal core event because it is listed with all of the other core user events. So I'd recommend making these two events part of a separate "Janrain Engage" group. This would make these events very easy to spot when you first enable the Janrain Engage Rules integration sub-module (because they would be in their own separate group section).

--Ben

geokat’s picture

Hi Ben,

I fixed #8 and #9.

However, if we want to be able to use the data selectors in emails (and
such), I think I need to implement them as tokens as well. This way
they could be used like this:

Subject: You added a linked [rpx:provider-title] account.

Thanks,
George

BenK’s picture

George,

I've done a bit more testing of the existing Rules integration and the new "provider-title" and "provider-machinename" are working well.

--Ben

P.S. Just one note for anyone who want to use "$rpx->provider-title" or "$rpx->provider-machinename" to do a replacement with PHP evaluation (or later with tokens). Because rules substitutes dashes for hyphens, you have to use "$rpx->provider_title" or $rpx->provider_machinename" to make the replacement work properly. It's an easy thing to forget and can easily cause you to wonder why it isn't working.

geokat’s picture

Status: Needs work » Needs review

Hi,

[rpx:provider-machinename] and [rpx:provider-title] are now available
as tokens (committed to HEAD). I would appreciate if somebody could
test this.

Thanks,
George

geokat’s picture

Hey Ben,

I'm working on adding the "Post to linked account" action. There are
several things to consider:

Firstly, the API's that allow server-to-server social sharing are only
available to Pro and Enterprise Janrain customers.

Also, if a user has several 3rd party ID's linked to his account, it
might take some time to push the social update to all of the networks,
which may result in a noticeable delay in the page reload time (or
even PHP timeout errors, I suppose). I wonder if we can use something
like the Drupal Batch API here to make this process asynchronous, thus
avoiding the delay.

If the user is not signed in on all of the networks we are trying to
push the update to, the update for those networks will probably
silently fail... At least I don't see a clean way of informing the
user why the update failed and what he can do to avoid it in the
future.

Or, we could make this action pop up the social sharing widget. This
way we would solve all of the problems above, but it would not be as
slick as pushing the updates from server side.

Cheers,
George

BenK’s picture

Status: Needs review » Needs work

Hey George,

All great points and questions. A few things:

1. In thinking about it, I actually think we actually want two different Rules actions here (and possibly a third):

a) "Launch social sharing widget" -- This action would simply pop up the social sharing widget and allow the site administrator to specify the default post message (with tokens) from within the rules configuration. This would be the simplest to implement and would work for all subscribers.

b) "Automatically post to linked account" -- This would be the "slick" method you describe above for server-to-server social sharing. Yes, I think it would be important to implement some type of batching or asynchronous solution. It's fine if this only works for Pro and Enterprise users because we also provide the method in a).

c) "Load a user's linked accounts" -- This is an optional third action which would allow Rules to take subsequent actions based on which type of accounts are linked to the user. You could specify, for instance, that the subsequent "Launch social sharing widget" action would only occur if the user has a linked Twitter account. I'm not sure how difficult this would be to implement from the module code perspective.

What do you think? One suggestion for how to proceed would be to get a) working first (since it's the simplest), then work on the other stuff.

--Ben

BenK’s picture

P.S. I'll test the [rpx:provider-machinename] and [rpx:provider-title] tokens very soon and report back.

geokat’s picture

Hi Ben,

I'm not sure about the third action. You mean that the admin would be
able to define an action that would load all linked accounts for a
user, which then will be used in a condition of another rule (checking
that Twitter is among them) that invokes the "Launch social sharing
widget" action? Does Rules allow "piping" rules like this?

Also, thinking about the automatic server-to-server social sharing:
wouldn't users want to control what gets shared on their social
networks? When we pop up the widget, they at least have a choice in
the matter.

Thanks,
George

BenK’s picture

George,

Yes, the Rules module allows rules to be nested within other rules. The key is to create a "rule set" and define arguments that you need within that rule set.

Here's an example using the Private Message module (http://drupal.org/project/privatemsg): I recently configured a rule that sends a reminder email to a user when the user receives a new message and has more than 10 unread messages in his private message mailbox. To do this, I did the following:

1. Created a "rule set" by selecting "Add new component" from the "Components" tab.
2. Within this rule set, I created a "data comparison" condition (setting the data value to greater than 10) and defined a new argument to be compared named "unread-messages".
3. Also in this rule set, I created a "Send e-mail" action that sends an e-mail to the [recipient:mail] token. This e-mail will be sent if the data comparison in 2. is true.
4. Now that this rule set is created (and can be called upon later), I create a brand new rule. This rule fires on the "A message is sent" event.
5. Within this new rule, I first create a "Load number of unread messages" action (an action supplied by the Private Message module). I choose the private message "recipient" as the user account and provide a variable for the "Number of unread messages". I name this variable "unread_count".
6. I add another action to this rule. This time I choose the rule set that I previously created (which is listed as an available action in the "Components" group). As my data selector for the "unread_messages" argument (which matches the name I gave in step 2.), I choose "unread-count" (which matches the variable name I gave in step 5). For the recipient, I choose the private message "recipient" as my data selector.

Now when I send a user a private message, the rule first loads the unread messages of the recipient and then fires the rule set. The number of unread messages is available to this rule set as an input. If the number of unread messages is greater than 10, then the e-mail action is fired.

So this example illustrates how a "Load a user's linked accounts" action could potentially be used in a similar fashion. In our use case, we'd first fire the "Load a user's linked accounts" action and then use this as an input to a subsequent rule set (which would only launch the social sharing widget if the loaded linked accounts contained "twitter" as a provider-machinename).

In this way, Rules configurations can actually be quite powerful.

--Ben

BenK’s picture

One more thing: For an example of how to code the "Load a user's linked accounts" action, see the "Load number of unread messages" action supplied by the Private Message module (http://drupal.org/project/privatemsg). The Private Message module has a sub-module named privatemsg_rules.

--Ben

BenK’s picture

Also, thinking about the automatic server-to-server social sharing:
wouldn't users want to control what gets shared on their social
networks? When we pop up the widget, they at least have a choice in
the matter.

Well, there could be some use cases where you would want this done automatically (such as if you're congratulating a user on earning a badge, it's a little weird to let the user re-write their own congratulations message in the widget). But I think you're right that the "Launch social sharing widget" action would be suitable for many use cases because it allows for user approval in each instance. It's also the simplest to implement.

So perhaps we should start with the "Launch social sharing widget" action and get that working first....

--Ben

geokat’s picture

Hey Ben,

it's a little weird to let the user re-write their own congratulations message in the widget

The point is that with the widget the user may choose to just close it, without going through with sharing anything on the social networks. With server-to-server, they would not have this option.

And thanks for the Rules usage example, it is very helpful.

Thanks,
George

BenK’s picture

Hey George,

I just tested your tokens for [rpx:provider-machinename] and [rpx:provider-title]. It's working perfectly. I tested those tokens both with rules integration and in the verification e-mail. In both cases, everything is working as expected. Nice work! :-)

--Ben

flahertypj’s picture

Did token support make it into 6.x version?

Thanks
Patrick

geokat’s picture

Hi Patrick,

No, it hasn't been ported yet.
We are hoping to start backporting pretty soon. Please stay tuned.

Cheers,
George

flahertypj’s picture

Thanks for the answer and thanks in advance for the backport.

All the best,
Patrick

cmcintosh’s picture

i was looking at backporting this myself please let me know if your already working on it, if not ill post my patch when i get it up here

geokat’s picture

Status: Needs work » Needs review

"Launch Social Sharing Widget" action is now supported in 7.x-1.x-dev.

BenK’s picture

Status: Needs review » Needs work

Hey George,

I've just completed some testing of the new "Launch social sharing widget" action and it is working very well. A few things I noticed:

1) When sharing with Facebook (and possible some other networks), the page title is hard-coded into the share text. Sometimes this is undesirable because the widget may be launching from a private page that outside users don't have access to. So could we offer a field in the rules config that allows for customizing what is used as the page title? See this screenshot for an example of what I mean:

https://skitch.com/benk_tech/rs4cr/facebooktest

2) When sharing with Facebook, it is posting the first name of the Facebook user before the link text. Is there any way to get rid of this and just have the link text be the entire text (with no first name prefix)? See this screenshot for an example:

https://skitch.com/benk_tech/rs4ct/facebooktest

3) In the social sharing widget, it isn't respecting capital letters in the widget. For instance, my user name is BenK Last, but it is displaying in the widget link text as "Benk last". It will display with proper capitalization once share with Facebook, but it would be better if the widget also displayed it the proper way. See this screenshot:

https://skitch.com/benk_tech/rs4ca/widgettest

4) If an apostrophe is included in the description, it is displaying in the widget as:

&#039;

It will look fine when eventually posted to Facebook, but it appears the text needs to be escaped before being displayed in the widget. See an example here:

https://skitch.com/benk_tech/rs4py/apostrophe

5) I've been trying to chain rules so that when a the social sharing widget is launched other actions (send a thank you message, award points, change roles, etc.) can be taken in response. But what I realize now is that in our current implementation we don't really know if the user actually shared something... we just know that they launched the sharing widget (but could have closed it without sharing). To solve this, I think there are two possible options:

a. Create a new "User shared via social widget" Rules event. By having this new event, we'd actually know that information was shared with linked accounts and could take subsequent actions. This shouldn't be any harder to implement than the original "Linked account was added" event.

b. Create two or three new Rules events:

* "User shared content" (for nodes)
* "User shared a comment" (for comments)
* "User shared other information" (for other site stuff triggered by the "Launch social sharing widget" action... specially not nodes and comments)

The advantage of this latter approach would be that for the "User shared content" event, for instance, you could easily allow conditionals for the content type so that the action would only fire if an "article" content type was shared.

So George, what do you think? I'm excited about these new possible events. It would give site builders the ability to reward users for sharing content (and would also, in turn, increase the repeat use of Janrain Engage).

Cheers,
Ben

geokat’s picture

Hi Ben,

For 1), 2), and 3) I will have to check if this is something that can
be controlled from outside the widget.

4) I will try and fix this.

5) I think it shouldn't be too hard to implement. The client-side
javascript will have to trigger a page reload once the sharing widget
is done pushing the update, so that those events can be fired.

I'm going to return to this once we finish the D6 backport.

Cheers,
George

cmcintosh’s picture

Has there been any looks into adding any sort of rules for handling things like when a user Shares content on a site, ie they click to share(and actually share) it would cause a trigger to fire and possibly have some rule evaluated? I know right now i am running into a Cross-Domain js issue because of the jrain/rpx widget being a iFrame from another domain.

Thanks.

urlM-2.0’s picture

subscribing.

BenK’s picture

One additional note on item 4) above (apostrophe issue): In addition to the "description" area of the widget, if the comment text includes a token (such as node title) and that token includes an apostrophe (such as a node titled "Ben's Article"), then the apostrophe in the comment area is also not being escaped properly. I'm not entirely sure if this is an issue with our module or possibly a Token issue.

--Ben

geokat’s picture

Hey Ben,

I see a problem with the "User shared..." events. Since sharing is
done completely from the client-side, the browser will have to notify
Drupal that sharing has taken place by setting a cookie and triggering
a page reload. This will have to be done by a callback function called
by the sharing widget upon successful share.

The problem is that users will be able to exploit your rules setup by
calling that function directly (e.g. from the javascript console)
without actually sharing anything.

I see no way to prevent this.

Account linking has no such problem, as the sign-in transaction is
verified by the server with a server-to-server call to Engage using an
Engage-provided token. With sharing, though, the server has no role in
the transaction, it's all done from the client-side.

Cheers,
George

EDIT: on second thought, there might be a way... Let me check something.

EDIT2: no, I can't seem to come up with a clean solution. Do we want
to go ahead and implement the "broken" one?

geokat’s picture

Status: Needs review » Needs work

As Ben suggested, I'm going to implement the following three rules:

"Social sharing cookie was set for shared content" (for nodes)
"Social sharing cookie was set for shared comment" (for comments)
"Social sharing cookie was set for other information" (other site
staff triggered by the "Launch social sharing widget" action)

Social sharing cookie will be set by the sharing widget to let Drupal
know that content has been shared by the user.

Cheers,
George

EDIT: oops, of course I meant 'events' above (not 'rules').

geokat’s picture

Status: Needs work » Needs review

Committed.

geokat’s picture

Status: Needs work » Needs review

From #27 above:

1) When sharing with Facebook (and possible some other networks), the page title is hard-coded into the share text. Sometimes this is undesirable because the widget may be launching from a private page that outside users don't have access to. So could we offer a field in the rules config that allows for customizing what is used as the page title? See this screenshot for an example of what I mean:

https://skitch.com/benk_tech/rs4cr/facebooktest

Committed a fix.

geokat’s picture

Committed a fix for:

4) If an apostrophe is included in the description, it is displaying in the widget as:
&#039;

It will look fine when eventually posted to Facebook, but it appears the text needs to be escaped before being displayed in the widget. See an example here:

https://skitch.com/benk_tech/rs4py/apostrophe

and

One additional note on item 4) above (apostrophe issue): In addition to the "description" area of the widget, if the comment text includes a token (such as node title) and that token includes an apostrophe (such as a node titled "Ben's Article"), then the apostrophe in the comment area is also not being escaped properly. I'm not entirely sure if this is an issue with our module or possibly a Token issue.

geokat’s picture

2) When sharing with Facebook, it is posting the first name of the Facebook user before the link text. Is there any way to get rid of this and just have the link text be the entire text (with no first name prefix)? See this screenshot for an example:

https://skitch.com/benk_tech/rs4ct/facebooktest

This is most probably an Engage/Facebook issue, i.e. something that we can't control in the module.

geokat’s picture

3) In the social sharing widget, it isn't respecting capital letters in the widget. For instance, my user name is BenK Last, but it is displaying in the widget link text as "Benk last". It will display with proper capitalization once share with Facebook, but it would be better if the widget also displayed it the proper way. See this screenshot:

https://skitch.com/benk_tech/rs4ca/widgettest

This is an Engage issue. Can't fix in the module.

BenK’s picture

Bumping this so that I remember to test...

BenK’s picture

Status: Needs review » Needs work

George,

I've been testing the three new Rules events (related to the social sharing cookie being set) and I've gotten mixed results. The "Social sharing cookie was set for shared content" is working great. But I can't get the ones for comments and other information to work properly.

A. When I try to use the "Cookie was set for comments" event, I get a "Page Not Found" error when the the event is supposed to be triggered. The error is occurring when trying to visit the following URL:

http://localhost/node/rpx/cookie_handler?destination=http://localhost/no...

Also, the above URL occurs when sharing a comment immediately after posting it. If you try to share a comment you posted previously, you get the same Page Not Found error, but the link doesn't specify the comment ID:

http://localhost/node/rpx/cookie_handler?destination=http://localhost/no...

B. I tried the "Cookie was set for other information..." event in the following setup. First, on the "Linked account was added" event, I created a "Launch social sharing widget" event. Then, on the "Cookie was set for other information..." event, I created an action to award the user points (via the Userpoints module). But even though the event evaluates true (according to my Rules debug), it does not seem to be triggering the Cookie was set event.

C. The "Cookie was set for content..." event is working nicely, but a couple of quick suggestions. First, if possible, it would be nice to have "rpx:user" available as a data selector (like we have for other Janrain Engage events). Currently, on the default current site user is available. Second, is it possible to allow a conditional for the provider that was shared with (so that the event would only fire if the cookie was set for sharing with Facebook)? We have this, for example, for the "Linked account was added" event. I'm not sure how difficult this would be to implement because the cookie would somehow need to record that information. Anyway, just an idea.

--Ben

BenK’s picture

I just tried to test the fixes to 1) and 4) from comment #27, but now I can't get the "Launch social sharing widget" action to fire. Is it working in your -dev environment? Or did we introduce a bug in a recent commit that causes this to no longer work?

--Ben

geokat’s picture

I just tried to test the fixes to 1) and 4) from comment #27, but now I can't get the "Launch social sharing widget" action to fire. Is it working in your -dev environment? Or did we introduce a bug in a recent commit that causes this to no longer work?

Oops, that was a bug. I changed the order of the action parameters
without changing them in the callback.

Fixed. Can you try again?

Thanks a lot,
George

geokat’s picture

A. When I try to use the "Cookie was set for comments" event, I get a "Page Not Found" error when the the event is supposed to be triggered. The error is occurring when trying to visit the following URL:

I can't reproduce the bug, it works fine here. And the javascript code
that does the redirection is the same for "Cookie was set for
comments" and "Cookie was set for nodes"; so it is weird that it works
for one, but fails for the other.

The error is occurring when trying to visit the following URL:

http://localhost/node/rpx/cookie_handler?destination=http://localhost/no...

It should redirect to 'location.href + rpx/cookie_handler'. Why it
redirects to location.href + 'node/' + 'rpx/cookie_handler' is beyond
me.

It's kind of hard to debug without being able to reproduce the bug.

What I actually do, is instruct the sharing widget to set a cookie and
trigger a page reload with the following JS code:

location.href = 'rpx/cookie_handler?destination=' + location.href;

The 'rpx/cookie_handler' menu callback reads the cookies, fires the
events and redirects to the destination URL passed above.

Again, this works fine for me, but seems to only partially work for
you.

EDIT1: Finally I reproduced the bug; now let's see what gives :)

geokat’s picture

I tried the "Cookie was set for other information..." event in the following setup. First, on the "Linked account was added" event, I created a "Launch social sharing widget" event. Then, on the "Cookie was set for other information..." event, I created an action to award the user points (via the Userpoints module). But even though the event evaluates true (according to my Rules debug), it does not seem to be triggering the Cookie was set event.

Again, can't reproduce. I tried the exact same setup: the account is
linked, the sharing widget is launched, the "cookie" event is fired,
points are awarded. I'm using Userpoints 7.x-1.0-alpha2 and Rules
7.x-2.0-alpha4.

geokat’s picture

The "Cookie was set for content..." event is working nicely, but a couple of quick suggestions. First, if possible, it would be nice to have "rpx:user" available as a data selector (like we have for other Janrain Engage events). Currently, on the default current site user is available. Second, is it possible to allow a conditional for the provider that was shared with (so that the event would only fire if the cookie was set for sharing with Facebook)? We have this, for example, for the "Linked account was added" event. I'm not sure how difficult this would be to implement because the cookie would somehow need to record that information. Anyway, just an idea.

Sorry, I won't be able to complete this in time for the Thursday
release, but these are nice points and we can include them in a future
one (e.g. 2.1).

Thanks,
George

geokat’s picture

Ben,

I seem to have reproduced the bug you described in #40. Let's see...

geokat’s picture

Just pushed a fix for the bug described in #40.

geokat’s picture

I tried the "Cookie was set for other information..." event in the following setup. First, on the "Linked account was added" event, I created a "Launch social sharing widget" event. Then, on the "Cookie was set for other information..." event, I created an action to award the user points (via the Userpoints module). But even though the event evaluates true (according to my Rules debug), it does not seem to be triggering the Cookie was set event.

OK, I upgraded my Userpoints (to 7.x-1.0-beta1), Rules (to 7.x-2.0-beta1) and Entity (to 7.x-1.0-beta8) modules, and now the bug is manifested on my setup as well.

geokat’s picture

Hey Ben,

Does awarding points work for you with users that have the
administrator role? It does for me. However, it fails with non-admin
users. And it seems this has nothing to do with our "cookie" events.
To test this, I created a rule that simply awarded points for viewing
a user account; the behavior was the same: works for admins, doesn't
work for others.

And considering that it worked fine before I upgraded the Userpoints
module, I think it is an issue with that module.

So I guess this is a "won't fix".

Thanks,
George

geokat’s picture

Status: Needs work » Needs review
BenK’s picture

George,

Did you try the "Launch social sharing widget" with a core event? Did that work? I also tried to launch the social sharing widget on the "Linked account was added" event and that didn't work either.

--Ben

P.S. I've only tested using administrator users so I wouldn't have found the error if it only happened with non-admin users.

BenK’s picture

George,

I don't think this is a Userpoints problem (or if it is, that's an additional problem to something in the Janrain Engage module). I just tried the following:

* Rules event: After saving new content
* Rules action: Launch social sharing widget

This rule did not work for me. Can you see if it works for you?

--Ben

geokat’s picture

I don't think this is a Userpoints problem (or if it is, that's an additional problem to something in the Janrain Engage module). I just tried the following:

* Rules event: After saving new content
* Rules action: Launch social sharing widget

This rule did not work for me. Can you see if it works for you?

It does work when I'm not using the overlay, but fails otherwise.
I guess we can't use hook_page_alter() when the overlay is used.
Let me see if I can come up with a solution.

However, I stand by my assertion that the current version of
Userpoints fails to grant points to non-admin users :) Can you check
that on your setup?

Thanks,
George

geokat’s picture

OK, I think I found a solution. Just pushed a commit that should fix this:

I just tried the following:

* Rules event: After saving new content
* Rules action: Launch social sharing widget

This rule did not work for me.

geokat’s picture

This one should now work, too:

I also tried to launch the social sharing widget on the "Linked account was added" event and that didn't work either.

BenK’s picture

I've confirmed that the "Launch social sharing widget" is now working for me even when using the overlay. The only issue is that it only seems to work once the overlay is closed. For instance, if I enable the "Launch social sharing widget" action on the "After saving new content" event, then the widget launches immediately because the overlay is automatically closed by Drupal when adding new content. But if I instead use Userpoints' "User was awarded points" action--and add points using the admin-only user points add form--then the widget won't fire until the overlay is manually clicked closed.

Not sure if there is a solution for this... but it's a fairly minor issue since only those with some admin access would presumably be using the overlay.

--Ben

BenK’s picture

George, in my setup non-admin users are able to earn userpoints (from the "Grant points to user" action). So I'm not sure about the problem you were experiencing. But I'm also using the latest -dev version of Userpoints (rather than the beta) so that could be an old issue that is now fixed.

--Ben

BenK’s picture

Confirmed that 1) (hardcoded page title) and 4) (apostrophe not escaped) are both fixed. :-)

BenK’s picture

Status: Needs review » Needs work

George,

I've confirmed that the following Rules events are now working:

"Social sharing cookie was set for shared content"
"Social sharing cookie was set for shared comment"
"Social sharing cookie was set for other information"

Only one strange thing I noticed that I couldn't reproduce: On two occasions when I shared content (a node), both the shared content and shared comment events fired simultaneously. I tried to recreate this but I couldn't. Most of the time everything works fine. Any reason why sharing content would also set the comment cookie in some rare circumstances?

Anyway, everything is working pretty well... just thought I'd mention this in case you had an idea as to the possible cause.

--Ben

geokat’s picture

Status: Needs work » Postponed

Ben, It might have been a stale cookie left over from the previous testing when the redirection did not work correctly and cookie was not cleared by the cookie handler.

Cheers,
George

BenK’s picture

That makes sense. Any thoughts as to my comment #56?

geokat’s picture

#56 is confirmed, but I don't see a way to solve it right now.
Anyway, that behavior is slightly better than no social widget at all (as it was before).

Will have to come back to this.

Thanks,
George

brunorios1’s picture

subscribing for the D6 backport!

BenK’s picture

Status: Postponed » Fixed

Marking this as fixed since most of the items on this thread have been accomplished. We can open up new thread for further Rules integration.

--Ben

Status: Fixed » Closed (fixed)

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