You are here

function activity_token_replace in Activity 5

Same name and namespace in other branches
  1. 5.4 activity.module \activity_token_replace()
  2. 5.2 activity.module \activity_token_replace()
  3. 5.3 activity.module \activity_token_replace()
  4. 6 activity.module \activity_token_replace()

determine what the message should say

2 calls to activity_token_replace()
theme_activity_feed in ./activity.module
theme_activity_page in ./activity.module
theme function for displaying the users activity page

File

./activity.module, line 369
Activity module: Allow users to see their friends' activity on the site.

Code

function activity_token_replace($activity) {

  // what tokens are available for this module
  if (variable_get('activity_' . $activity->module . '_module', 0) == 1) {

    #dsm($activity);

    // FORMAT: (array)token => value
    $tokens = unserialize($activity->tokens);

    #dsm($tokens);

    // FORMAT: [user] did [something] to [what]
    if (variable_get('activity_' . $activity->module . '_' . $activity->action . '_' . $activity->type . '_token', FALSE)) {
      $pattern = variable_get('activity_' . $activity->module . '_' . $activity->action . '_' . $activity->type . '_token', 0);
    }
    else {
      $pattern = variable_get('activity_' . $activity->module . '_' . $activity->action . '_token', 0);
    }

    #dsm($pattern);

    // user-link
    if (strstr($pattern, 'user-link') !== FALSE) {
      $tokens['user-link'] = l($tokens['user-name'], 'user/' . $tokens['user-id']);
    }

    // buddy-link
    if (strstr($pattern, 'buddy-link') !== FALSE) {
      $tokens['buddy-link'] = l($tokens['buddy-name'], 'user/' . $tokens['buddy-id']);
    }

    // node-title-link
    if (strstr($pattern, 'node-title-link') !== FALSE) {
      $tokens['node-title-link'] = l($tokens['node-title'], 'node/' . $tokens['node-id']);
    }
    foreach ($tokens as $key => $val) {
      $pattern = str_replace('[' . $key . ']', $val, $pattern);
    }
    return $pattern;
  }
  else {
    $tokens = unserialize($activity->tokens);
    return $tokens['contents'];
  }
}