For FBSS there is a Rules Integration which is very powerful. Would be great nif there was one for FBSSC too.

CommentFileSizeAuthor
#6 fbssc_rules.tar_.gz921 bytes7sudos

Comments

icecreamyou’s picture

Status: Active » Postponed

From the project page:

A beta will be released when integrations with other modules have been completed and the API has been documented.

In other words, it's planned. I usually don't really like it when issues are opened for something already mentioned on the project page, but I guess I wasn't specific, and there's no harm in leaving this open for now.

jrivelli’s picture

Is there any plan when this will be completed?

icecreamyou’s picture

No plan. It will get completed when I have a sudden urge to do so in one of those rare moments when I actually have free development time... in other words I would like to get FBSSC in a solid stable state with all planned features by the end of August, but whether that will actually happen is kind of doubtful.

jrivelli’s picture

Alright sounds like a plan. I'm going to contact you to get some development going. I'm gonna fund all this I've finally decided.

momper’s picture

subscribe

7sudos’s picture

StatusFileSize
new921 bytes

Here's a module we wrote to add some limited rules integration for FBSSC. We used the fbss_after_save hook to provide a way to pass info about the comment into rules, as the site we were working on required user notification when other users commented on their statuses. This was very quick-and-dirty, but works (although we couldn't get the date type working, it wasn't necessary for our implementation).

capellic’s picture

Wow.. this is great! Thanks for this module -- exactly what I was looking for!

logickal’s picture

Capellic - Glad it helped you out!

I've put this module up in a sandbox repo in case anyone else needs it. Not sure how much more maintiaining I would actually do for this module, if I had time I would probably integrate the functionality into FBSSC itself.

Anyway, here's the link!

http://drupal.org/sandbox/logickal/1075186

logickal’s picture

IceCreamYou: I haven't yet had a chance to check out the new version of FBSC, which I assume will completely depricate my little rules integration module. Do you have any quick tips on what I could do to get this functionality ready for your next version or do you have that covered at this point?

icecreamyou’s picture

I think your module should be basically the same except that IIRC hook_fbssc_after_save() is now hook_fbss_comments_after_save (since the module was renamed from fbssc to fbss_comments).

logickal’s picture

I will pull your new versions down and update - if you aren't officially planning on rolling this functionality into the parent module, I'll clean this up and apply for full project status for it.

icecreamyou’s picture

Status: Postponed » Active

I am planning to roll it into the parent. (Thanks for contributing.) Just need to find some time!

logickal’s picture

Sounds great! Glad I could help!

icecreamyou’s picture

Project: Facebook-style Statuses Comments » Facebook-style Statuses (Microblog)
Version: 6.x-1.x-dev » 6.x-3.x-dev
Component: Code » Submodules
Status: Active » Needs review

...needs to be rolled into FBSS 3.x

icecreamyou’s picture

Title: Triggers or Rules Integration » Triggers or Rules Integration in Comments submodule
liliplanet’s picture

subscribe, thx!

mrwhizkid’s picture

Hi --

I've been playing around with the submodule in #6. Seems to work quite well for alerting status authors when comments are posted to their status.

However, I have just spent the entire day trying to figure out how to alert all those who have commented to a status that the status they commented on has been updated.

I was looking at the Appbar helper function (which of course won't work with current versions of Appbar) to see if I could figure this out.

I found this:

 array_shift($uids);
  array_shift($uids);
  foreach ($uids as $nuid) {
    if ($status->uid == $status->pid) {
      appbar_set_message(t('!user commented on a <a href="!message">status</a> on which you also commented.',
        array('!user' => $user_link, '!message' => $status_link)), 'fbssc-commenter', $nuid);
    }

I'm wondering if it's possible for me to do some sort of textual comparison in Rules based on this and then send a message out to all users who commented on the status?

Thanks for your help.

@IceCreamyou -- I realize you're very busy...I posted this here hoping that someone else might have a quick solution to this. Thanks.

icecreamyou’s picture

If you have the status ID as $sid, you can get a list of everyone who commented on the same status like this:

  $status = facebook_status_load($sid); // where $sid is the status ID
  $result = db_query("SELECT uid FROM {fbss_comments} WHERE sid = %d", $sid);
  $uids = array();
  while ($account = db_fetch_object($result)) {
    if ($account->uid != $status->sender && ($account->uid != $status->recipient || $status->type != 'user')) { // Exclude the sender and recipient of the status
      if ($account->uid != $GLOBALS['user']->uid) { // Exclude the person who posted the comment
        if (!in_array($account->uid, $uids)) { // No repeats
          $uids[] = $account->uid;
        }
      }
    }
  }

I have not tested this. Also creating an interface for it is complicated because you can't create a token that represents an array. There would probably need to be a select box for the recipient with options like "commenter", "other commenters", "sender", "recipient (if applicable)", and "arbitrary user", and then there would need to be some JS to show and hide a textfield to enter tokens for the arbitrary user depending on whether that option is selected.

@IceCreamyou -- I realize you're very busy...I posted this here hoping that someone else might have a quick solution to this. Thanks.

I appreciate you being considerate of my time. :) I expect to have much more time to work on FBSS over the next 3-4 months, starting in the next few days. (Unless I get distracted by Portal 2 or Crysis 2. :P)

mrwhizkid’s picture

Thanks! I think this gets me going in the right direction.

I was trying to figure out how to make this work with rules. I think I can set up a rule (user comments on facebook status) and then add an action to execute some custom PHP code using the code you gave me to list the uid's that have commented on the status.

The only jump I can't seem to make here is how I could add a few more lines of code to send an appbar alert out to all of those UID's in the same code.

Based on what I saw above (I'm still trying to learn PHP), it would be something like:

appbar_set_message(t('$comment_user commented on a <a href="/statuses/$sid">status</a> on which you also commented.',

But how do I tell appbar to send the alerts to the uids generated from the php code that you gave me?

icecreamyou’s picture

Appbar API: http://drupal.org/node/546536#api (this thread is not the best place to have that discussion)

If you are using an "execute custom PHP" action, just do appbar_set_message(t('My message'), $account->uid) inside of all the if() statements instead of building an array of the UIDs.

[The more generic solution would be to create a rules action in code that uses the code in #19 to select the recipients. However there's nothing FBSS itself can do to make it easier to do this in general because it's the action that has to know what to act on and actions are generally designed to deal with only one item (user) at a time.]

mrwhizkid’s picture

I am so close! I got the action to work correctly. It works beautifully except...

 appbar_set_message(t('!user commented on a <a href="!message">status</a> on which you also commented.',
        array('!user' => $user_link, '!message' => $status_link)), $account->uid);

I can't get the variables to show up correctly. Username and sid are not working correctly.

***Update -- I added

global $user; //@todo: really should use $uid instead of $user->uid here
  if (!module_exists('appbar')) {
    return;
  }
  $user_link = theme('username', user_load(array('uid' => $uid)));
  $status_link = url('statuses/'. $sid);

and now the status id is working correctly. However, the username is showing up as anonymous.

Here is the code that I am using:

<?php
global $user; //@todo: really should use $uid instead of $user->uid here
  if (!module_exists('appbar')) {
    return;
  }
  $user_link = theme('username', user_load(array('uid' => $uid)));
  $status_link = url('statuses/'. $sid);
  $status = facebook_status_load($sid); // where $sid is the status ID
  $result = db_query("SELECT uid FROM {fbssc} WHERE sid = %d", $sid);

  $uids = array();
  while ($account = db_fetch_object($result)) {
    if ($account->uid != $status->sender && ($account->uid != $status->recipient || $status->type != 'user')) { // Exclude the sender and recipient of the status
      if ($account->uid != $GLOBALS['user']->uid) { // Exclude the person who posted the comment
        if (!in_array($account->uid, $uids)) { // No repeats
          $uids[] = $account->uid;
        appbar_set_message(t('A comment has been made on a mini blog or wall post that you also commented on. <a href="!message">Click here </a> to view.',
        array('!user' => $user_link, '!message' => $status_link)), $account->uid);
        }
      }
    }
  }
?>
icecreamyou’s picture

Status: Needs review » Fixed

Committed Rules integration for the Comments submodule to dev

Status: Fixed » Closed (fixed)

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