mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-12 10:31:09 +03:00
Remove "get_logged_in" function
This commit is contained in:
parent
43f7df6c76
commit
18e9cf7039
@ -38,6 +38,7 @@ class ThreadController extends AbstractController
|
|||||||
{
|
{
|
||||||
$processor = ThreadProcessor::getInstance();
|
$processor = ThreadProcessor::getInstance();
|
||||||
$processor->setRouter($this->getRouter());
|
$processor->setRouter($this->getRouter());
|
||||||
|
$processor->setAuthenticationManager($this->getAuthenticationManager());
|
||||||
|
|
||||||
return $processor->handleRequest($request);
|
return $processor->handleRequest($request);
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,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\Settings;
|
use Mibew\Settings;
|
||||||
use Mibew\Thread;
|
use Mibew\Thread;
|
||||||
use Mibew\API\API as MibewAPI;
|
use Mibew\API\API as MibewAPI;
|
||||||
@ -44,8 +46,15 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
*
|
*
|
||||||
* @todo Move all API functions to another place.
|
* @todo Move all API functions to another place.
|
||||||
*/
|
*/
|
||||||
class ThreadProcessor extends ClientSideProcessor implements RouterAwareInterface
|
class ThreadProcessor extends ClientSideProcessor implements
|
||||||
|
RouterAwareInterface,
|
||||||
|
AuthenticationManagerAwareInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var AuthenticationManagerInterface|null
|
||||||
|
*/
|
||||||
|
protected $authenticationManager = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The request which is hadled now.
|
* The request which is hadled now.
|
||||||
*
|
*
|
||||||
@ -107,26 +116,6 @@ class ThreadProcessor extends ClientSideProcessor implements RouterAwareInterfac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if operator logged in
|
|
||||||
*
|
|
||||||
* @return array Operators info array
|
|
||||||
* @throws \Mibew\RequestProcessor\ThreadProcessorException If operator is
|
|
||||||
* not logged in.
|
|
||||||
*/
|
|
||||||
public static function checkOperator()
|
|
||||||
{
|
|
||||||
$operator = get_logged_in();
|
|
||||||
if (!$operator) {
|
|
||||||
throw new ThreadProcessorException(
|
|
||||||
"Operator is not logged in!",
|
|
||||||
ThreadProcessorException::ERROR_AGENT_NOT_LOGGED_IN
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $operator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -155,6 +144,22 @@ class ThreadProcessor extends ClientSideProcessor implements RouterAwareInterfac
|
|||||||
$this->router = $router;
|
$this->router = $router;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function setAuthenticationManager(AuthenticationManagerInterface $manager)
|
||||||
|
{
|
||||||
|
$this->authenticationManager = $manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getAuthenticationManager()
|
||||||
|
{
|
||||||
|
return $this->authenticationManager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*/
|
*/
|
||||||
@ -177,6 +182,26 @@ class ThreadProcessor extends ClientSideProcessor implements RouterAwareInterfac
|
|||||||
return MibewAPI::getAPI('\\Mibew\\API\\Interaction\\ChatInteraction');
|
return MibewAPI::getAPI('\\Mibew\\API\\Interaction\\ChatInteraction');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if operator logged in
|
||||||
|
*
|
||||||
|
* @return array Operators info array
|
||||||
|
* @throws \Mibew\RequestProcessor\ThreadProcessorException If operator is
|
||||||
|
* not logged in.
|
||||||
|
*/
|
||||||
|
protected function checkOperator()
|
||||||
|
{
|
||||||
|
$operator = $this->getAuthenticationManager()->getOperator();
|
||||||
|
if (!$operator) {
|
||||||
|
throw new ThreadProcessorException(
|
||||||
|
"Operator is not logged in!",
|
||||||
|
ThreadProcessorException::ERROR_AGENT_NOT_LOGGED_IN
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $operator;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends asynchronous request
|
* Sends asynchronous request
|
||||||
*
|
*
|
||||||
@ -279,7 +304,7 @@ class ThreadProcessor extends ClientSideProcessor implements RouterAwareInterfac
|
|||||||
self::checkParams($args, array('user', 'typed'));
|
self::checkParams($args, array('user', 'typed'));
|
||||||
|
|
||||||
if (!$args['user']) {
|
if (!$args['user']) {
|
||||||
$operator = self::checkOperator();
|
$operator = $this->checkOperator();
|
||||||
$thread->checkForReassign($operator);
|
$thread->checkForReassign($operator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +366,7 @@ class ThreadProcessor extends ClientSideProcessor implements RouterAwareInterfac
|
|||||||
|
|
||||||
// Check access
|
// Check access
|
||||||
if (!$args['user']) {
|
if (!$args['user']) {
|
||||||
self::checkOperator();
|
$this->checkOperator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send new messages
|
// Send new messages
|
||||||
@ -378,7 +403,7 @@ class ThreadProcessor extends ClientSideProcessor implements RouterAwareInterfac
|
|||||||
|
|
||||||
// Get operator's array
|
// Get operator's array
|
||||||
if (!$args['user']) {
|
if (!$args['user']) {
|
||||||
$operator = self::checkOperator();
|
$operator = $this->checkOperator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check message can be sent
|
// Check message can be sent
|
||||||
@ -464,7 +489,7 @@ class ThreadProcessor extends ClientSideProcessor implements RouterAwareInterfac
|
|||||||
|
|
||||||
// Load operator
|
// Load operator
|
||||||
if (!$args['user']) {
|
if (!$args['user']) {
|
||||||
$operator = self::checkOperator();
|
$operator = $this->checkOperator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close thread
|
// Close thread
|
||||||
|
@ -526,13 +526,6 @@ function get_operator_name($operator)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_logged_in()
|
|
||||||
{
|
|
||||||
return isset($_SESSION[SESSION_PREFIX . "operator"])
|
|
||||||
? $_SESSION[SESSION_PREFIX . "operator"]
|
|
||||||
: false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setup_redirect_links(UrlGeneratorInterface $url_generator, $threadid, $operator, $token)
|
function setup_redirect_links(UrlGeneratorInterface $url_generator, $threadid, $operator, $token)
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
|
Loading…
Reference in New Issue
Block a user