add group support and fix #8

This commit is contained in:
everyx 2017-03-25 20:36:47 +08:00
parent 5284d7e5ad
commit 0375ef42d7
2 changed files with 25 additions and 1 deletions

View File

@ -59,7 +59,7 @@ class OperatorStatusController extends AbstractController
}
/**
* Returns true or false of whether an operator is online or not.
* Returns true or false of whether any operators is online or not.
*
* @param Request $request
* @return Response Rendered page content
@ -72,6 +72,25 @@ class OperatorStatusController extends AbstractController
return $this->prepareResponse($is_online, $callback);
}
/**
* Returns true or false of whether any operators in specificed group is online or not.
*
* @param Request $request
* @return Response Rendered page content
*/
public function isOperatorGroupOnlineAction(Request $request)
{
$is_online = false;
$group_id = $request->attributes->get('group_id');
if (Settings::get('enablegroups') == '1') {
$is_online = has_online_operators($group_id);
}
$callback = $request->query->get('callback');
return $this->prepareResponse($is_online, $callback);
}
/**
* Returns prepared response: JSONP or plain text.
*

View File

@ -3,6 +3,11 @@ mibew_operator_status_has_online_operators:
defaults:
_controller: Mibew\Mibew\Plugin\OperatorStatus\Controller\OperatorStatusController::hasOnlineOperatorsAction
mibew_operator_status_has_online_group_operators:
path: /opstatus/group/{group_id}
defaults:
_controller: Mibew\Mibew\Plugin\OperatorStatus\Controller\OperatorStatusController::isOperatorGroupOnlineAction
mibew_operator_status_is_operator_online:
path: /opstatus/{opcode}
defaults: