Skip to content

Commit

Permalink
add group support and fix #8
Browse files Browse the repository at this point in the history
  • Loading branch information
everyx committed Mar 25, 2017
1 parent 5284d7e commit 0375ef4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Controller/OperatorStatusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function isOperatorOnlineAction(Request $request)
}

/**
* 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
Expand All @@ -72,6 +72,25 @@ public function hasOnlineOperatorsAction(Request $request)
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.
*
Expand Down
5 changes: 5 additions & 0 deletions routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0375ef4

Please # to comment.