/** * Generates list of all operators in the system. * * @param Request $request Incoming request. * @return string Rendered page content. */ public function indexAction(Request $request) { $operator = $this->getOperator(); $page = array('errors' => $request->attributes->get('errors', array())); $sort['by'] = $request->query->get('sortby'); if (!in_array($sort['by'], array('login', 'commonname', 'localename', 'lastseen'))) { $sort['by'] = 'login'; } $sort['desc'] = $request->query->get('sortdirection', 'desc') == 'desc'; $page['formsortby'] = $sort['by']; $page['formsortdirection'] = $sort['desc'] ? 'desc' : 'asc'; $list_options['sort'] = $sort; if (in_isolation($operator)) { $list_options['isolated_operator_id'] = $operator['operatorid']; } $operators_list = get_operators_list($list_options); // Prepare operator to render in template foreach ($operators_list as &$item) { $item['vclogin'] = $item['vclogin']; $item['vclocalename'] = $item['vclocalename']; $item['vccommonname'] = $item['vccommonname']; $item['isAvailable'] = operator_is_available($item); $item['isAway'] = operator_is_away($item); $item['lastTimeOnline'] = time() - $item['time']; $item['isDisabled'] = operator_is_disabled($item); } unset($item); $page['allowedAgents'] = $operators_list; $page['canmodify'] = is_capable(CAN_ADMINISTRATE, $operator); $page['availableOrders'] = array(array('id' => 'login', 'name' => getlocal('Login')), array('id' => 'localename', 'name' => getlocal('Name')), array('id' => 'commonname', 'name' => getlocal('International name')), array('id' => 'lastseen', 'name' => getlocal('Last active'))); $page['availableDirections'] = array(array('id' => 'desc', 'name' => getlocal('descending')), array('id' => 'asc', 'name' => getlocal('ascending'))); $page['title'] = getlocal('Operators'); $page['menuid'] = 'operators'; $page = array_merge($page, prepare_menu($operator)); $this->getAssetManager()->attachJs('js/compiled/operators.js'); return $this->render('operators', $page); }
function tpl_content() { global $page, $webimroot, $errors; ?> <?php echo getlocal("page_agents.intro"); ?> <br /> <br /> <?php require_once 'inc_errors.php'; ?> <?php if ($page['canmodify']) { ?> <div class="tabletool"> <img src='<?php echo $webimroot; ?> /images/buttons/createagent.gif' border="0" alt="" /> <a href='<?php echo $webimroot; ?> /operator/operator.php' title="<?php echo getlocal("page_agents.new_agent"); ?> "> <?php echo getlocal("page_agents.new_agent"); ?> </a> </div> <br clear="all"/> <?php } ?> <table class="list"> <thead> <tr class="header"> <th> <?php echo getlocal("page_agents.login"); ?> </th><th> <?php echo getlocal("page_agents.agent_name"); ?> </th><th> <?php echo getlocal("page_agents.status"); if ($page['canmodify']) { ?> </th><th> <?php } ?> </th> </tr> </thead> <tbody> <?php foreach ($page['allowedAgents'] as $a) { ?> <tr> <td class="notlast"> <a id="ti<?php echo $a['operatorid']; ?> " href="<?php echo $webimroot; ?> /operator/operator.php?op=<?php echo $a['operatorid']; ?> " class="man"> <?php echo htmlspecialchars(topage($a['vclogin'])); ?> </a> </td> <td class="notlast"> <?php echo htmlspecialchars(topage($a['vclocalename'])); ?> / <?php echo htmlspecialchars(topage($a['vccommonname'])); ?> </td> <td class="notlast"> <?php if (operator_is_available($a)) { ?> <?php echo getlocal("page_agents.isonline"); } else { if (operator_is_away($a)) { ?> <?php echo getlocal("page_agents.isaway"); } else { ?> <?php echo date_to_text(time() - $a['time']); } } ?> </td> <?php if ($page['canmodify']) { ?> <td> <a class="removelink" id="i<?php echo $a['operatorid']; ?> " href="<?php echo $webimroot; ?> /operator/operators.php?act=del&id=<?php echo $a['operatorid']; print_csrf_token_in_url(); ?> "> remove </a> </td> <?php } ?> </tr> <?php } ?> </tbody> </table> <script type="text/javascript" language="javascript"><!-- $('a.removelink').click(function(){ var login = $("#t"+this.id).text(); return confirm("<?php echo getlocalforJS("page_agents.confirm", array('"+$.trim(login)+"')); ?> "); }); //--></script> <?php }
/** * Return updated operators list. API function * * @param array $args Associative array of arguments. It must contains the * following keys: * - 'agentId': Id of the agent related to users window * * @return array Array of results. It contains the following keys: * - 'operators': array of online operators */ protected function apiUpdateOperators($args) { // Check access and get operators info $operator = $this->checkOperator($args['agentId']); // Return empty array if show operators option disabled if (Settings::get('showonlineoperators') != '1') { return array('operators' => array()); } // Check if curent operator is in isolation $list_options = in_isolation($operator) ? array('isolated_operator_id' => $operator['operatorid']) : array(); // Get operators list $operators = get_operators_list($list_options); // Create resulting list of operators $result_list = array(); foreach ($operators as $item) { if (!operator_is_online($item)) { continue; } $result_list[] = array('id' => (int) $item['operatorid'], 'name' => htmlspecialchars($item['vclocalename']), 'away' => (bool) operator_is_away($item)); } // Send operators list to the client side return array('operators' => $result_list); }
function print_operators() { global $mibew_encoding; echo "<operators>"; $operators = operator_get_all(); foreach ($operators as $operator) { if (!operator_is_online($operator)) { continue; } $name = myiconv($mibew_encoding, "utf-8", safe_htmlspecialchars(safe_htmlspecialchars($operator['vclocalename']))); $away = operator_is_away($operator) ? " away=\"1\"" : ""; echo "<operator name=\"{$name}\"{$away}/>"; } echo "</operators>"; }
function print_operators() { echo "<operators>"; $operators = operator_get_all(); foreach ($operators as $operator) { if (!operator_is_online($operator)) { continue; } $name = htmlspecialchars(htmlspecialchars($operator['vclocalename'])); $away = operator_is_away($operator) ? " away=\"1\"" : ""; echo "<operator name=\"{$name}\"{$away}/>"; } echo "</operators>"; }