function flag_trim_flag in Flag 6.2
Same name and namespace in other branches
- 7.3 flag.module \flag_trim_flag()
- 7.2 flag.module \flag_trim_flag()
Trim a flag to a certain size.
Parameters
$fid: The flag object.
$account: The user object on behalf the trimming will occur.
$cutoff_size: The number of flaggings allowed. Any flaggings beyond that will be trimmed.
1 call to flag_trim_flag()
- flag_rules_action_trim in includes/
flag.rules.inc - Base action implementation: Trim flag.
File
- ./
flag.module, line 904 - The Flag module.
Code
function flag_trim_flag($flag, $account, $cutoff_size) {
$result = db_query("SELECT * FROM {flag_content} WHERE fid = %d AND (uid = %d OR uid = 0) ORDER BY timestamp DESC", $flag->fid, $account->uid);
$i = 1;
while ($row = db_fetch_object($result)) {
if ($i++ > $cutoff_size) {
flag('unflag', $flag->name, $row->content_id, $account);
}
}
}