You are here

activityhistory.module in Activity 5.3

File

contrib/activityhistory/activityhistory.module
View source
<?php

function activityhistory_activityapi(&$activity, $op) {
  global $user;
  static $history = array();
  switch ($op) {
    case 'load':
      if (!isset($history[$activity['aid']][$user->uid])) {
        $new = db_result(db_query('SELECT ah.timestamp FROM {activity_history} ah WHERE aid = %d AND uid = %d', $activity['aid'], $user->uid));
        if (empty($new)) {
          $history[$activity['aid']][$user->uid] = theme('mark', MARK_NEW, 'activityhistory');

          // update to show that it has been seen
          @db_query('INSERT INTO {activity_history} (uid, aid, timestamp) VALUES (%d, %d, %d)', $user->uid, $activity['aid'], time());
        }
        else {
          $history[$activity['aid']][$user->uid] = '';
        }
      }
      $activity['activity_history_new'] = $history[$activity['aid']][$user->uid];
      break;
  }
}
if (!function_exists('phptemplate_activity')) {
  function phptemplate_activity($message, $item) {
    return $item['activity_history_new'] . ' <span class="activity">' . $message . '</span>';
  }
}

Functions