From f1803662a8e7ffd824329cd13d58a2071fd3c3cc Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Mon, 4 Mar 2013 09:22:11 +0000 Subject: [PATCH] Create some usefull groups functions Create group_is_online and get_group_description functions. --- src/messenger/webim/libs/groups.php | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/messenger/webim/libs/groups.php b/src/messenger/webim/libs/groups.php index 4e5d47fc..d9d0765a 100644 --- a/src/messenger/webim/libs/groups.php +++ b/src/messenger/webim/libs/groups.php @@ -128,4 +128,36 @@ function get_group_email($group_id) { return false; } +/** + * Check if group online + * + * @param array $group Associative group array. Should contain 'ilastseen' key. + * @return bool + */ +function group_is_online($group) { + return ($group['ilastseen'] !== NULL + && $group['ilastseen'] < Settings::get('online_timeout')); +} + +/** + * Return local or common group description depending on current locale. + * + * @global string $home_locale Code of the home locale + * @global string $current_locale Code of the current locale + * @param array $group Associative group array. Should contain following keys: + * - 'vccommondescription': string, contain common description of the group; + * - 'vclocaldescription': string, contain local description of the group. + * @return string Group description + */ +function get_group_description($group) { + global $home_locale, $current_locale; + if ($home_locale == $current_locale + || !isset($group['vccommondescription']) + || !$group['vccommondescription']) { + return $group['vclocaldescription']; + } else { + return $group['vccommondescription']; + } +} + ?> \ No newline at end of file