function useractivity_user in Activity 6
Same name and namespace in other branches
- 5.4 contrib/useractivity/useractivity.module \useractivity_user()
Implementation of hook_user().
File
- contrib/
useractivity/ useractivity.module, line 97
Code
function useractivity_user($op, &$edit, &$account, $category = NULL) {
global $user;
switch ($op) {
case 'insert':
case 'update':
case 'login':
case 'logout':
case 'view':
// don't record if new user requires admin approval
if ($op == 'insert' && variable_get('user_register', 1) != 1) {
return FALSE;
}
// check if action is not by done by the account user such
// as if user is edited by admin
if ($op == 'update' && $user->uid != $account->uid) {
return FALSE;
}
// Check if both type and operation are
// enabled for activity. If not then stop here
if (!in_array('user', variable_get('useractivity_token_types', array(
'user',
)), TRUE) || !in_array($op, variable_get('useractivity_op_types', array(
$op,
)), TRUE)) {
return FALSE;
}
// Privacy setting check
if (activity_user_privacy_optout($op == 'view' ? $user : $account)) {
return FALSE;
}
// User hide activity permission check
if (user_access('hide activity', $op == 'view' ? $user : $account)) {
return FALSE;
}
// If $op is view, don't record
if ($op == 'view' && $user->uid == $account->uid) {
return FALSE;
}
$data = array(
'operation' => $op,
'target-uid' => $account->uid,
);
$target_users_roles = array(
ACTIVITY_ALL => 'all',
$op == 'view' ? $user->uid : $account->uid => 'author',
);
activity_insert($op == 'view' ? $user->uid : $account->uid, 'useractivity', 'user', $op, $data, $target_users_roles);
break;
}
}