function flagactivity_flag in Activity 6
Same name and namespace in other branches
- 5.4 contrib/flagactivity/flagactivity.module \flagactivity_flag()
Implementation of hook_flag()
Parameters
$op: flag operation
$flag: flag object
$nid: object id of flagged object
$user: user object of user who flagged
File
- contrib/flagactivity/ flagactivity.module, line 110 
Code
function flagactivity_flag($op, $flag, $content_id, $account) {
  // Check if both type and operation are
  // enabled for activity. If not then stop here
  if (!in_array($flag->name, variable_get('flagactivity_token_types', array(
    $flag->name,
  )), TRUE) || !in_array($op, variable_get('flagactivity_op_types', array(
    $op,
  )), TRUE)) {
    return FALSE;
  }
  // Privacy setting check
  if (activity_user_privacy_optout($account)) {
    return FALSE;
  }
  // User hide activity permission check
  if (user_access('hide activity', $user)) {
    return FALSE;
  }
  $data = array(
    'operation' => $op,
    'content-id' => $content_id,
    'content-type' => $flag->content_type,
  );
  $target_users_roles = array(
    ACTIVITY_ALL => 'all',
    $account->uid => 'author',
  );
  activity_insert($account->uid, 'flagactivity', $flag->name, $op, $data, $target_users_roles);
}