diff options
author | friendica <info@friendica.com> | 2014-01-30 20:10:47 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-01-30 20:10:47 -0800 |
commit | a1d40431f22e82b8e018dce65ced0801c40b20ff (patch) | |
tree | 1b9fa64a689ff56a932f82428cc8cd3a1d932303 /include/chat.php | |
parent | 49f07bd90f7304e76c2b06d0a9616d680df6ab47 (diff) | |
download | volse-hubzilla-a1d40431f22e82b8e018dce65ced0801c40b20ff.tar.gz volse-hubzilla-a1d40431f22e82b8e018dce65ced0801c40b20ff.tar.bz2 volse-hubzilla-a1d40431f22e82b8e018dce65ced0801c40b20ff.zip |
chat expiration (default 2 hours) - but can be set on a per-chatroom basis
Diffstat (limited to 'include/chat.php')
-rw-r--r-- | include/chat.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/chat.php b/include/chat.php index b88c63fc3..08fd154b5 100644 --- a/include/chat.php +++ b/include/chat.php @@ -31,16 +31,19 @@ function chatroom_create($channel,$arr) { return $ret; } + if(! array_key_exists('expire',$arr)) + $arr['expire'] = 120; // minutes, e.g. 2 hours $created = datetime_convert(); - $x = q("insert into chatroom ( cr_aid, cr_uid, cr_name, cr_created, cr_edited, allow_cid, allow_gid, deny_cid, deny_gid ) - values ( %d, %d , '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", + $x = q("insert into chatroom ( cr_aid, cr_uid, cr_name, cr_created, cr_edited, cr_expire, allow_cid, allow_gid, deny_cid, deny_gid ) + values ( %d, %d , '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s' ) ", intval($channel['channel_account_id']), intval($channel['channel_id']), dbesc($name), dbesc($created), dbesc($created), + intval($arr['expire']), dbesc($arr['allow_cid']), dbesc($arr['allow_gid']), dbesc($arr['deny_cid']), @@ -111,6 +114,9 @@ function chatroom_enter($observer_xchan,$room_id,$status,$client) { return false; } + if(intval($x[0]['cr_expire'])) + $r = q("delete from chat where created < UTC_TIMESTAMP() - INTERVAL " . intval($x[0]['cr_expire']) . " MINUTE and chat_room = " . intval($x[0]['cr_id'])); + $r = q("select * from chatpresence where cp_xchan = '%s' and cp_room = %d limit 1", dbesc($observer_xchan), intval($room_id) |