function activity_insert in Activity 5.3
Same name and namespace in other branches
- 5.4 activity.module \activity_insert()
- 5 activity.module \activity_insert()
- 5.2 activity.module \activity_insert()
- 6 activity.module \activity_insert()
API function Insert an activity record. This gets called by modules wishing to record their activities.
Parameters
$module The name of the module that is doing the recording, eg. 'node':
$type Module's can track more than one type of activity. For example,: the nodeactivity module tracks activities for each content type separately. $type should be an identifier for the calling module to use.
9 calls to activity_insert()
- ActivityAPITest::testGetActivity1 in tests/
ActivityAPITests.test - Test activity_get_activity activity_get_activity($uids = ACTIVITY_ALL, $filters = NULL, $limit = NULL, $tablesort_headers = NULL)
- ActivityAPITest::testGetActivity2 in tests/
ActivityAPITests.test - ActivityAPITest::testInsertActivity in tests/
ActivityAPITests.test - function activity_insert($module, $type, $operation, $data, $target_users_roles)
- buddylistactivity_buddylist in contrib/
buddylistactivity/ buddylistactivity.module - Implementation of hook_buddylist_api() $arg[0] = operation $arg[1] = user being added/removed $arg[2] = user doing the add/remove
- commentactivity_comment in contrib/
commentactivity/ commentactivity.module - Implementation of hook_comment().
File
- ./
activity.module, line 197 - Activity module: Allow users to see their friends' activity on the site.
Code
function activity_insert($module, $type, $operation, $data, $target_users_roles) {
// check time limit, ignore activity if within the limit
$result = db_query("SELECT COUNT(*) FROM {activity} WHERE module = '%s' AND type = '%s' AND operation = '%s' AND data = '%s' AND created >= %d", $module, $type, $operation, serialize($data), time() - variable_get('activity_time_limit', 30));
if (db_fetch_object($result)->count != 0) {
return FALSE;
}
$aid = db_next_id('activity');
db_query("INSERT INTO {activity} (aid, module, type, operation, created, data)\n VALUES (%d, '%s', '%s', '%s', %d, '%s')", $aid, $module, $type, $operation, time(), serialize($data));
foreach ($target_users_roles as $uid => $role) {
db_query("INSERT INTO {activity_targets} (aid, target_uid, target_role) VALUES (%d, %d, '%s')", $aid, $uid, $role);
}
$activity = array(
'module' => $module,
'type' => $type,
'operation' => $operation,
'data' => $data,
'target_user_roles' => $target_users_roles,
'aid' => $aid,
);
// Invoke activityapi
activity_invoke_activityapi($activity, 'insert');
return $aid;
}