function activityhistory_activityapi in Activity 6
Same name and namespace in other branches
- 5.4 contrib/activityhistory/activityhistory.module \activityhistory_activityapi()
- 5.3 contrib/activityhistory/activityhistory.module \activityhistory_activityapi()
File
- contrib/
activityhistory/ activityhistory.module, line 3
Code
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];
if ($activity['activity_history_new']) {
if ($activity['mark']) {
$activity['mark'] .= ' ' . $activity['activity_history_new'] . ' ';
}
else {
$activity['mark'] = $activity['activity_history_new'] . ' ';
}
}
break;
}
}