diff options
author | Friendika <info@friendika.com> | 2011-03-15 17:31:49 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-03-15 17:31:49 -0700 |
commit | f01538a54f68c172e09aabed90e2651ca2305675 (patch) | |
tree | 69ca84f95663c93d098be91047f55daa31a12106 /include/items.php | |
parent | 73d3758e45f2049ad669225910afeb0d24e25e86 (diff) | |
download | volse-hubzilla-f01538a54f68c172e09aabed90e2651ca2305675.tar.gz volse-hubzilla-f01538a54f68c172e09aabed90e2651ca2305675.tar.bz2 volse-hubzilla-f01538a54f68c172e09aabed90e2651ca2305675.zip |
content expiration
Diffstat (limited to 'include/items.php')
-rw-r--r-- | include/items.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/include/items.php b/include/items.php index 2294fe294..051659321 100644 --- a/include/items.php +++ b/include/items.php @@ -1507,3 +1507,49 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { return $o; } +function item_expire($uid,$days) { + + if((! $uid) || (! $days)) + return; + + $r = q("SELECT * FROM `item` + WHERE `uid` = %d + AND `created` < UTC_TIMESTAMP() - INTERVAL %d DAY + AND `id` = `parent` + AND `deleted` = 0", + intval($uid), + intval($days) + ); + + if(! count($r)) + return; + + logger('expire: # items=' . count($r) ); + + foreach($r as $item) { + + // Only expire posts, not photos and photo comments + + if(strlen($item['resource-id'])) + continue; + + $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + + // kill the kids + + $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc($item['parent-uri']), + intval($item['uid']) + ); + + } + + proc_run('php',"include/notifier.php","expire","$uid"); + +}
\ No newline at end of file |