From 9f546757021305b6cfe924f38ca1af5fd5d3e69b Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 29 Jan 2014 01:52:23 -0800 Subject: chatroom list widget backend --- include/chat.php | 9 +++++++++ include/widgets.php | 9 +++++++++ 2 files changed, 18 insertions(+) (limited to 'include') diff --git a/include/chat.php b/include/chat.php index 4df419294..cb910bd62 100644 --- a/include/chat.php +++ b/include/chat.php @@ -114,4 +114,13 @@ function chatroom_leave($observer_xchan,$room_id,$status) { ); } return true; +} + + +function chatroom_list($uid) { + + $r = q("select cr_name, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d order by cr_name group by cp_id", + intval($uid) + ); + return $r; } \ No newline at end of file diff --git a/include/widgets.php b/include/widgets.php index efa350785..8b22515b1 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -576,3 +576,12 @@ function widget_menu_preview($arr) { require_once('include/menu.php'); return menu_render(get_app()->data['menu_item']); } + +function widget_chatroom_list($arr) { + require_once("include/chat.php"); + $r = chatroom_list(local_user()); + return replace_macros(get_markup_template('chatroomlist.tpl'),array( + '$header' => t('Chat Rooms'), + '$items' => $r, + )); +} \ No newline at end of file -- cgit v1.2.3