When one user follows another, we get a status update like, " UserA followered UserB"

as a result of the default Activity log Rule config, ""[requester:user] [relationship:relationship-name]ed [requestee:user]""

For Commons, we probably want something like "UserA is now following UserB".

CommentFileSizeAuthor
#2 screenshot_011 (2).png10.44 KBezra-g

Comments

ezra-g’s picture

Assigned: Unassigned » ezra-g

I'll look into solutions here.

ezra-g’s picture

Title: "followered" should be "is now following" » Awkward language around "following"
StatusFileSize
new10.44 KB

mikesteff pointed out the attached screenshot which shows a page view of people the current user is following.

Since we already display a list of people the user is following on the user's profile page, do we need this second, awkward list? Also, do we provide a link to it anywhere? I didn't see a link to this page, but if we have one, it seems like one solution would be to remove it.

For the awkward follower confirmation text: "Are you sure you want to become ezra's follower?"

Why not just disable confirmation entirely? It's not like following is an unrecoverable, destructive action. As an example, Twitter doesn't make you confirm followers.

For the text in the stream and digest I think we can just alter the exports that contain the "followered" text and change it to the desired "is following." As long as we don't have grouped status updates (Ezra, Mike and Jay *are* following Isaac) that should be sufficient. Commons doesn't ship with any other user relationship types.

batsonjay’s picture

I agree with both things: eliminate the extra tab, and eliminate the confirmation.

Frankly, I don't like the "you to them" stuff, either - it just confuses me. But it might be too hard to eliminate.

ezra-g’s picture

Title: Awkward language around "following" » Awkward language around "following", unclosed div tag in status messages
Status: Active » Needs review

As it turns out, removing the confirmation form is not a configurable option - the forms are baked into user_relationships. This patch instead changes the form so that it looks like https://skitch.com/ezra-g/f16gc/userb-commons1.

Note, this needs to be tested on a fresh install.

As far as I can tell, Rules doen't provide a suitable hook to override Rules default exports. We could add a drupal_alter() to each of the modules we're overriding, but given the timeline and likelihood we'll eliminate the need to override these at all in the future, I've overridden here.This also integrates #1257450: Activity items about following people breaks the theme.

Pull request: https://github.com/acquia/commons/pull/19

ezra-g’s picture

Also, it looks like someone changed the "My stuff" menu link text from "My friends" to "My relationships" which I think addresses the intention here of removing all "Friends" text.

mstef’s picture

Assigned: ezra-g » mstef
Status: Needs review » Needs work

Not going to use the pull request. There's a better approach, in my opinion (plus the pull request still has faulty HTML in it), and that's using the patch for rules @ #978620: add hook_rules_defaults_alter() which provides a hook_rules_defaults_alter(). We can then use that to fix the broken rules templates in activity_log and digest.

So, just to recap, so we can fix both modules later:
1) They use a strange "ed" to suffix relationship types (hoping for "user friended userB" type of sentence)
2) The UR templates contain an open DIV tag, which breaks the themeing
3) The UR templates in activity_log DO NOT contain the [requester:picture] token which seems to be needed to output a user thumbnail.

mstef’s picture

Here's my alter:

/**
 * Implementation of hook_rules_defaults_alter()
 */
function commons_status_streams_rules_defaults_alter(&$rules) {
  // Fix faulty HTML in activity_log and digest templates
  // Also default the language to something that matches
  // our user relationship type
  // @see http://drupal.org/node/1255980
  // @see http://drupal.org/node/1256722
 
  // Activity log digests: rules_activity_log_digests_ur_request
  $actions = &$rules['rules']['rules_activity_log_digests_ur_request']['#actions'];
  $template_standard = '<div class="activity-log-picture">[requester:picture]</div><div class="activity-log-indent"></div><div class="activity-log-content">[requester:user] is now following [requestee:user]</div>'; 
  $template_grouping = '<div class="activity-log-picture">[requester:picture]</div><div class="activity-log-indent"></div><div class="activity-log-content">[requester:user] is now following [requestee:user] [collection]</div>';
  $actions[0]['#settings']['templates']['en']['template'] = $template_standard;
  $actions[1]['#settings']['templates']['en']['template'] = $template_standard;
  $actions[0]['#settings']['grouping']['templates']['en']['template'] = $template_grouping;
  $actions[1]['#settings']['grouping']['templates']['en']['template'] = $template_grouping;
  
  // Activity log: rules_activity_log_ur_request
  $actions = &$rules['rules']['rules_activity_log_ur_request']['#actions'];
  $template_standard = '<div class="activity-log-picture">[requester:picture]</div><div class="activity-log-indent"></div><div class="activity-log-content">[requester:user] is now following [requestee:user]</div>'; 
  $template_grouping = '<div class="activity-log-picture">[requester:picture]</div><div class="activity-log-indent"></div><div class="activity-log-content">[requester:user] is now following [requestee:user] [collection]</div>';
  $actions[0]['#settings']['templates']['en']['template'] = $template_standard;
  $actions[1]['#settings']['templates']['en']['template'] = $template_standard;
  $actions[0]['#settings']['grouping']['templates']['en']['template'] = $template_grouping;
  $actions[1]['#settings']['grouping']['templates']['en']['template'] = $template_grouping;
}

And here's the error I'm getting now when invoking the actions..

warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/commons-git/commons/docroot/profiles/drupal_commons/modules/contrib/rules/rules/rules.variables.inc on line 19.
warning: Invalid argument supplied for foreach() in /var/www/commons-git/commons/docroot/profiles/drupal_commons/modules/contrib/rules/rules/rules.variables.inc on line 27.
warning: Invalid argument supplied for foreach() in /var/www/commons-git/commons/docroot/profiles/drupal_commons/modules/contrib/rules/rules/rules.variables.inc on line 32.

Rule debug

0 ms "" has been invoked.
0.113 ms Executing the rule "Log activity when a user creates a relationship" on rule set ""
7.367 ms Warning: Unable to get variable "requestee".
7.429 ms Element "Log activity for the acting user" has not been executed. There are not all execution arguments needed by an input evaluator available.
7.705 ms Warning: Unable to get variable "requestee".
7.756 ms Element "Log activity for the acting user's relationships" has not been executed. There are not all execution arguments needed by an input evaluator available.
7.842 ms Executing the rule "Email: Log activity when a user creates a relationship" on rule set ""
8.153 ms Warning: Unable to get variable "requestee".
8.205 ms Element "Log activity for the acting user" has not been executed. There are not all execution arguments needed by an input evaluator available.
8.465 ms Warning: Unable to get variable "requestee".
8.517 ms Element "Log activity for the acting user's relationships" has not been executed. There are not all execution arguments needed by an input evaluator available.
8.572 ms Evaluation of "" has been finished.
mstef’s picture

ezra-g’s picture

Status: Fixed » Needs work
mstef’s picture

Seemed too hacky to me. Forgot to consult. Can't really assume our UR rtid is always going to be 1.

ezra-g’s picture

In the short term: couldn't we use the approach we use in other places where we set a variable for the vid?
In the long term: Machine names/exportables are another reason why we should use Flag for this functionality.

gibry21’s picture

I copied the new code and implemented.

Not sure if it was supposed to solve the issue but I am still getting unexpected behavior.

I choose to 'Follow' my colleague....

Great...

Now in 'My Relationships' I can see:

Jayde follower(you to them)

Great, that's what I would expect. However, in her profile, she see's:

Ryan follower(them to you)

Again, this is correct behavior....

The problem.....she then decides to 'Follow' me back....she goes to my profile and the link says 'Unfollow'

But she isn't following me.... I am following her!

Whats going on with this relationship or are we missing something??

Thanks guys

ezra-g’s picture

@gibry21 Do you get this error without making any code modifications? If so, can you file a new issue? Otherwise, the snippet here isn't intended to be manually added, but needs to be re-rolled as a patch.

gibry21’s picture

The issue was apparent out of the box on my Commons 2.0 install.

I believe the same issue was logged here http://drupal.org/node/1244998 which linked me to this post and fix.

I am a relative newb so wasn't sure if it was a patch or just needed to added the code, I just copied the code from Git and pasted it into my module. Problem was still there. (Although I think it may have fixed the secondary 'confusing language' issue you guys were discussing here.)

I have just downloaded the whole project from Git as it is now and will see how it looks.

Where and how to I file an issue?

Thanks for your quick response and continued awesome contribution

Cheers

gibry21

japerry’s picture

Version: » 6.x-2.x-dev