mirror of
https://github.com/Mibew/mibew.git
synced 2025-01-31 21:34:42 +03:00
Get operator from AuthenticationManager in UsersProcessor
This commit is contained in:
parent
a99a839998
commit
6cdfb4a7bc
@ -86,6 +86,8 @@ class UsersController extends AbstractController
|
|||||||
public function updateAction(Request $request)
|
public function updateAction(Request $request)
|
||||||
{
|
{
|
||||||
$processor = UsersProcessor::getInstance();
|
$processor = UsersProcessor::getInstance();
|
||||||
|
$processor->setAuthenticationManager($this->getAuthenticationManager());
|
||||||
|
|
||||||
// TODO: Remove bufferization after *Processor classes will be rewritten
|
// TODO: Remove bufferization after *Processor classes will be rewritten
|
||||||
// to play nice with symfony request/response objects
|
// to play nice with symfony request/response objects
|
||||||
ob_start();
|
ob_start();
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
namespace Mibew\RequestProcessor;
|
namespace Mibew\RequestProcessor;
|
||||||
|
|
||||||
// Import namespaces and classes of the core
|
// Import namespaces and classes of the core
|
||||||
|
use Mibew\Authentication\AuthenticationManagerAwareInterface;
|
||||||
|
use Mibew\Authentication\AuthenticationManagerInterface;
|
||||||
use Mibew\Database;
|
use Mibew\Database;
|
||||||
use Mibew\EventDispatcher;
|
use Mibew\EventDispatcher;
|
||||||
use Mibew\Settings;
|
use Mibew\Settings;
|
||||||
@ -39,8 +41,29 @@ use Mibew\RequestProcessor\Exception\UsersProcessorException;
|
|||||||
* - usersUpdateVisitorsLoad
|
* - usersUpdateVisitorsLoad
|
||||||
* - usersUpdateVisitorsAlter
|
* - usersUpdateVisitorsAlter
|
||||||
*/
|
*/
|
||||||
class UsersProcessor extends ClientSideProcessor
|
class UsersProcessor extends ClientSideProcessor implements AuthenticationManagerAwareInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var AuthenticationManagerInterface|null
|
||||||
|
*/
|
||||||
|
protected $authenticationManager = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function setAuthenticationManager(AuthenticationManagerInterface $manager)
|
||||||
|
{
|
||||||
|
$this->authenticationManager = $manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getAuthenticationManager()
|
||||||
|
{
|
||||||
|
return $this->authenticationManager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*/
|
*/
|
||||||
@ -102,9 +125,9 @@ class UsersProcessor extends ClientSideProcessor
|
|||||||
* @throws UsersProcessorException If operators not logged in or if
|
* @throws UsersProcessorException If operators not logged in or if
|
||||||
* $operator_id varies from current logged in operator.
|
* $operator_id varies from current logged in operator.
|
||||||
*/
|
*/
|
||||||
protected static function checkOperator($operator_id)
|
protected function checkOperator($operator_id)
|
||||||
{
|
{
|
||||||
$operator = get_logged_in();
|
$operator = $this->getAuthenticationManager()->getOperator();
|
||||||
if (!$operator) {
|
if (!$operator) {
|
||||||
throw new UsersProcessorException(
|
throw new UsersProcessorException(
|
||||||
"Operator not logged in!",
|
"Operator not logged in!",
|
||||||
@ -130,7 +153,7 @@ class UsersProcessor extends ClientSideProcessor
|
|||||||
*/
|
*/
|
||||||
protected function apiAway($args)
|
protected function apiAway($args)
|
||||||
{
|
{
|
||||||
$operator = self::checkOperator($args['agentId']);
|
$operator = $this->checkOperator($args['agentId']);
|
||||||
notify_operator_alive($operator['operatorid'], 1);
|
notify_operator_alive($operator['operatorid'], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +166,7 @@ class UsersProcessor extends ClientSideProcessor
|
|||||||
*/
|
*/
|
||||||
protected function apiAvailable($args)
|
protected function apiAvailable($args)
|
||||||
{
|
{
|
||||||
$operator = self::checkOperator($args['agentId']);
|
$operator = $this->checkOperator($args['agentId']);
|
||||||
notify_operator_alive($operator['operatorid'], 0);
|
notify_operator_alive($operator['operatorid'], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +188,7 @@ class UsersProcessor extends ClientSideProcessor
|
|||||||
*/
|
*/
|
||||||
protected function apiUpdateThreads($args)
|
protected function apiUpdateThreads($args)
|
||||||
{
|
{
|
||||||
$operator = self::checkOperator($args['agentId']);
|
$operator = $this->checkOperator($args['agentId']);
|
||||||
|
|
||||||
$since = $args['revision'];
|
$since = $args['revision'];
|
||||||
// Get operator groups
|
// Get operator groups
|
||||||
@ -364,7 +387,7 @@ class UsersProcessor extends ClientSideProcessor
|
|||||||
protected function apiUpdateVisitors($args)
|
protected function apiUpdateVisitors($args)
|
||||||
{
|
{
|
||||||
// Check access
|
// Check access
|
||||||
self::checkOperator($args['agentId']);
|
$this->checkOperator($args['agentId']);
|
||||||
|
|
||||||
// Close old invitations
|
// Close old invitations
|
||||||
invitation_close_old();
|
invitation_close_old();
|
||||||
@ -495,7 +518,7 @@ class UsersProcessor extends ClientSideProcessor
|
|||||||
protected function apiUpdateOperators($args)
|
protected function apiUpdateOperators($args)
|
||||||
{
|
{
|
||||||
// Check access and get operators info
|
// Check access and get operators info
|
||||||
$operator = self::checkOperator($args['agentId']);
|
$operator = $this->checkOperator($args['agentId']);
|
||||||
|
|
||||||
// Return empty array if show operators option disabled
|
// Return empty array if show operators option disabled
|
||||||
if (Settings::get('showonlineoperators') != '1') {
|
if (Settings::get('showonlineoperators') != '1') {
|
||||||
@ -543,7 +566,7 @@ class UsersProcessor extends ClientSideProcessor
|
|||||||
protected function apiUpdate($args)
|
protected function apiUpdate($args)
|
||||||
{
|
{
|
||||||
// Check access and get operator array
|
// Check access and get operator array
|
||||||
$operator = self::checkOperator($args['agentId']);
|
$operator = $this->checkOperator($args['agentId']);
|
||||||
|
|
||||||
// Update operator status
|
// Update operator status
|
||||||
notify_operator_alive($operator['operatorid'], $operator['istatus']);
|
notify_operator_alive($operator['operatorid'], $operator['istatus']);
|
||||||
@ -571,7 +594,7 @@ class UsersProcessor extends ClientSideProcessor
|
|||||||
protected function apiCurrentTime($args)
|
protected function apiCurrentTime($args)
|
||||||
{
|
{
|
||||||
// Check access
|
// Check access
|
||||||
self::checkOperator($args['agentId']);
|
$this->checkOperator($args['agentId']);
|
||||||
|
|
||||||
// Return time
|
// Return time
|
||||||
return array(
|
return array(
|
||||||
|
Loading…
Reference in New Issue
Block a user