You are here

function flag_rules_action_trim in Flag 6

Same name and namespace in other branches
  1. 6.2 includes/flag.rules.inc \flag_rules_action_trim()
  2. 7.3 flag.rules.inc \flag_rules_action_trim()
  3. 7.2 flag.rules.inc \flag_rules_action_trim()

Base action implementation.

File

includes/flag.rules.inc, line 233
flag.rules.inc Rules integration for the Flag module.

Code

function flag_rules_action_trim($flag, $flagging_user, $cutoff_size, $settings) {

  // We can't use db_query_range(), because we can't specify 'infinity'.
  $result = db_query("SELECT * FROM {flag_content} WHERE fid = %d AND (uid = %d OR uid = 0) ORDER BY timestamp DESC", $flag->fid, $flagging_user->uid);
  $i = 1;
  while ($row = db_fetch_object($result)) {
    if ($i++ > $cutoff_size) {
      flag('unflag', $flag->name, $row->content_id, $flagging_user);
    }
  }
}