You are here

function sms_og_sms_receive in SMS Framework 5

Implements hook_sms_receive()

File

modules/sms_og/sms_og.module, line 74

Code

function sms_og_sms_receive($node, $message) {

  //$groups = og_get_subscriptions($node->uid); // Could be a feature, check if user is subscribed
  $words = explode(' ', $message['text']);
  foreach ($words as $word) {

    // is it appropriate for '#' to be hardcoded or can other keys be chosen?
    if (substr($word, 0, 1) == '#') {
      $tag = rtrim(ltrim($word, '#'), '`~!@#$%^&*()_+-={}|[]\\:;"<>?,./');
      $content_type = variable_get('sms_og_type');
      $content_field = variable_get('sms_og_field');
      $result = db_query("SELECT * FROM {content_type_" . $content_type . "} WHERE `" . $content_field . "_value` = '%s'", $tag);
      if ($group = db_fetch_object($result)) {
        $node->og_groups[$group->nid] = $group->nid;
      }
    }
  }
  return $node;
}