/**
  * 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);
 }
Example #2
0
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&amp;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 
}