the face book status to the account profile screen also I use the friend module and notice feed any compatibility with that would be awesome...

Comments

icecreamyou’s picture

  • I'll consider adding the status to the profile.
  • I won't add integration with the Friends module because I don't use it and I have no way to test it. However, facebook_status is integrated with User Relationships, and I recommend using that instead of Friends because it's more flexible. On the other hand, if you'd like to write a patch to integrate Friends, I will add it to the module. FriendList is the other prominent SN module for 6.x (and Buddylist and Buddylist2 for 5.x) and the same applies there.
  • I will add compatibility with noticefeed.
  • Please do not list multiple feature requests in the same issue. Next time, open separate feature requests for each one.
icecreamyou’s picture

Component: User interface » Code - Functionality
Assigned: Unassigned » icecreamyou
josecancel’s picture

Thanks alot...IceCreamYou

icecreamyou’s picture

I decided against adding the status to the profile, for various reasons.

I need you to test NoticeFeed integration for me before I add it to the actual module. To do that, you should insert this code at the very end of facebook_status.module (without the PHP tags!):

function fbs_notice_insert($uid) {
  if (module_exists("notice")) {
    $new_id = db_last_insert_id('facebook_status','sid');
    $notice_array = array(
      'nb_type' => NOTICE_NORMAL,
      'module_type' => "facebook_status",
      'source_uid' => $uid,
      'prime_id' => $new_id,
      'op' => "facebook_status_add",
    );
    noticeapi_notice_add("facebook_status",$notice_array);
  }
}

function facebook_status_notice($op, $type, $record) {
  switch ($op) {
    case 'feed':
      $sql = "SELECT * FROM {facebook_status} WHERE sid = %d";
      $record2 = db_fetch_object(db_query($sql, $record->prime_id));
      $output = '<div class="notice-'. $record->module_type .'">';
      $user = user_load(array('uid' => $record2->uid));
      $output .= t('%user has a new status.', array('%user' => $user->name));
      $output .= '</div>';
      return $output;
      break;
  };
}

Then, in the function facebook_status_update_form_submit, search for the phrase "status has been updated" (without the quotes) and add this code (also without the PHP tags) immediately after the two lines on which the phrase occurs:

if (module_exists('noticefeed')) {
  fbs_notice_insert($user->uid)
}

...then try adding/changing a status and see whether everything works. Check your log as well to make sure it's not throwing up errors.

icecreamyou’s picture

Status: Active » Needs review
icecreamyou’s picture

Title: Can you add » Notice Feed Integration

Please note that I cannot add this code to the module if it has not been confirmed that it works.

Flying Drupalist’s picture

I'll do it, cheers :D

Flying Drupalist’s picture

Sorry, I don't know if I'm doing something wrong, but I got:

Parse error: syntax error, unexpected '}' in /public_html/sites/all/modules/facebook_status/facebook_status.module on line 340

The function looks like this, did I do something bad?

function facebook_status_update_form_submit($form, &$form_state) {
  global $user;
      //Note that this first part is only for people who can edit their own status, so we don't need to check whose database records to update.
      if ( user_access('edit own facebook_status') && !user_access('edit all facebook_status') ) {
  if ( db_query("INSERT INTO {facebook_status} (status_fb, status_time, uid) VALUES('%s', %d, %d)", $form_state['values']['name'], time(), $user->uid) ) {
    drupal_set_message(t('Your status has been updated.'));
    if (module_exists('noticefeed')) {
  fbs_notice_insert($user->uid)
}
  }
  else {
    drupal_set_message(t('An error has occurred while updating your status.  Please try again.  If the problem persists, please contact an administrator.'), 'error');
  }
      }
      else if (user_access('edit all facebook_status')) {
  //Determine the uid of the user whose status will be updated.
  if ( arg(0) == 'user' && is_numeric(arg(1)) ) {
    $uid = arg(1);
  }
  else if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
    $uid = db_result(db_query("SELECT uid FROM {node} WHERE nid = %d", arg(1)));
  }
  else {
    $uid = $user->uid;
  }
  if ( db_query("INSERT INTO {facebook_status} (status_fb, status_time, uid) VALUES('%s', %d, %d)", $form_state['values']['name'], time(), $uid) ) {
    drupal_set_message(t('The status has been updated.'));
    if (module_exists('noticefeed')) {
    fbs_notice_insert($user->uid)
    }
  }
  else {
    drupal_set_message(t('An error has occurred while updating the status.  Please try again.'), 'error');
  }
      }
      //This technically shouldn't happen, but we need a catch in case someone without permission manages to submit the form.
      else {
        drupal_set_message(t('An error has occurred while updating the status: you do not have permission to perform this action.  Please contact an administrator.'), 'error');
      }
}
icecreamyou’s picture

That's my fault actually, you need a semicolon (;) right after fbs_notice_insert($user->uid) (in both places).

Flying Drupalist’s picture

Thanks, just wanted to say that I'm having some unrelated issues. I'll get right back to you on the testing.

Flying Drupalist’s picture

Hi, I'm not sure if I'm doing anything wrong, but it is not working as far as I can discern. No notices about changed statuses show up. I think I'm going to drop the notice module in favor of activity log though.

icecreamyou’s picture

Status: Needs review » Closed (won't fix)

Notice Feed does seem like a pretty weak module to me. You're probably justified in going for Activity Log instead, which is written by a very good programmer who's likely to support it well.

Because I can't test this to see what's not working, and because it doesn't seem needed at this point, I'm going to mark this as "won't fix." Feel free to change it back if the situation changes.

icecreamyou’s picture

By the way, I think the problem is that the module is called 'notice,' not 'noticefeed,' so the function wasn't getting called because it wasn't passing module_exists.

Flying Drupalist’s picture

Status: Closed (won't fix) » Fixed

I changed it (to notice), and it works. It doesn't display exactly what the new status is though, but it does say status has been changed. And you're right, noticefeed is pretty weak, nothing that friends do show up on the feed, so I don't really understand how it's integrated with friend at all. Thanks for the code, looking at it I think it works as intended.

icecreamyou’s picture

Status: Fixed » Reviewed & tested by the community

In that case, marking as RTBC so I remember to actually add this to the module.

icecreamyou’s picture

Status: Reviewed & tested by the community » Fixed

Fixed locally, will update CVS soon.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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