1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8//this script may only be included - so its better to die if called directly. 9if (strpos($_SERVER['SCRIPT_NAME'], basename(__FILE__)) !== false) { 10 header('location: index.php'); 11 exit; 12} 13 14/** 15 * @return array 16 */ 17function module_who_is_there_info() 18{ 19 return [ 20 'name' => tra('Online Users'), 21 'description' => tra('Display information about users currently logged in.'), 22 'prefs' => [], 23 'documentation' => 'Module who_is_there', 24 'params' => [ 25 'content' => [ 26 'name' => tra('List Type'), 27 'description' => tra('Display the number of users logged in, the list of users logged in, or both.') . " " . tr('Possible values: "count", "list" or "both". Default value: "both"') 28 ], 29 'cluster' => [ 30 'name' => tra('Cluster Mode'), 31 'description' => tra('If set to "1", separate users based on which host/server they logged on.') 32 ], 33 'silent' => [ 34 'name' => tra('Silent Mode'), 35 'description' => tra('If set to "1" hides the module, which allows another "who is there" module to include users that should not see it.') 36 ], 37 ] 38 ]; 39} 40 41/** 42 * @param $mod_reference 43 * @param $module_params 44 */ 45function module_who_is_there($mod_reference, $module_params) 46{ 47 $tikilib = TikiLib::lib('tiki'); 48 $smarty = TikiLib::lib('smarty'); 49 $count = ! isset($module_params['content']) || $module_params['content'] != 'list'; 50 $list = ! isset($module_params['content']) || $module_params['content'] != 'count'; 51 $smarty->assign('count', $count); 52 $smarty->assign('list', $list); 53 54 if ($count) { 55 $logged_users = $tikilib->count_sessions(); 56 $smarty->assign('logged_users', $logged_users); 57 } 58 59 if ($list) { 60 $online_users = $tikilib->get_online_users(); 61 $smarty->assign_by_ref('online_users', $online_users); 62 } 63 64 if (isset($module_params['cluster']) && $module_params['cluster'] == 1) { 65 $smarty->assign('cluster', true); 66 if ($count) { 67 $logged_cluster_users = $tikilib->count_cluster_sessions(); 68 $smarty->assign('logged_cluster_users', $logged_cluster_users); 69 } 70 } else { 71 $smarty->assign('cluster', false); 72 } 73} 74