Skip to content

Commit

Permalink
Client: Adds missing Request URI Plugin
Browse files Browse the repository at this point in the history
Use requestURIPlugin() and SessionTimeoutPlugin() in client controller actions
as it is done in every other controller for consistancy.
  • Loading branch information
fbergkemper committed Jun 7, 2016
1 parent 6c1429d commit 7576363
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 48 deletions.
96 changes: 49 additions & 47 deletions module/Client/src/Client/Controller/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,69 +36,71 @@ class ClientController extends AbstractActionController

public function indexAction()
{
if($_SESSION['bareos']['authenticated'] == true && $this->SessionTimeoutPlugin()->timeout()) {

$clients = $this->getClientModel()->getClients();
$this->RequestURIPlugin()->setRequestURI();

return new ViewModel(
array(
'clients' => $clients,
)
);
}
else {
return $this->redirect()->toRoute('auth', array('action' => 'login'));
if(!$this->SessionTimeoutPlugin()->isValid()) {
return $this->redirect()->toRoute('auth', array('action' => 'login'), array('query' => array('req' => $this->RequestURIPlugin()->getRequestURI())));
}

$clients = $this->getClientModel()->getClients();

return new ViewModel(
array(
'clients' => $clients,
)
);
}

public function detailsAction()
{
if($_SESSION['bareos']['authenticated'] == true && $this->SessionTimeoutPlugin()->timeout()) {

return new ViewModel(
array(
'client' => $this->params()->fromRoute('id')
)
);
$this->RequestURIPlugin()->setRequestURI();

if(!$this->SessionTimeoutPlugin()->isValid()) {
return $this->redirect()->toRoute('auth', array('action' => 'login'), array('query' => array('req' => $this->RequestURIPlugin()->getRequestURI())));
}
else {
return $this->redirect()->toRoute('auth', array('action' => 'login'));
}

return new ViewModel(
array(
'client' => $this->params()->fromRoute('id')
)
);

}

public function getDataAction()
{
if($_SESSION['bareos']['authenticated'] == true && $this->SessionTimeoutPlugin()->timeout()) {

$data = $this->params()->fromQuery('data');
$client = $this->params()->fromQuery('client');

if($data == "all") {
$result = $this->getClientModel()->getClients();
}
elseif($data == "details" && isset($client)) {
$result = $this->getClientModel()->getClient($client);
}
elseif($data == "backups" && isset($client)) {
$result = $this->getClientModel()->getClientBackups($client, null, 'desc');
}
else {
$result = null;
}

$response = $this->getResponse();
$response->getHeaders()->addHeaderLine('Content-Type', 'application/json');

if(isset($result)) {
$response->setContent(JSON::encode($result));
}

return $response;

$this->RequestURIPlugin()->setRequestURI();

if(!$this->SessionTimeoutPlugin()->isValid()) {
return $this->redirect()->toRoute('auth', array('action' => 'login'), array('query' => array('req' => $this->RequestURIPlugin()->getRequestURI())));
}

$data = $this->params()->fromQuery('data');
$client = $this->params()->fromQuery('client');

if($data == "all") {
$result = $this->getClientModel()->getClients();
}
elseif($data == "details" && isset($client)) {
$result = $this->getClientModel()->getClient($client);
}
elseif($data == "backups" && isset($client)) {
$result = $this->getClientModel()->getClientBackups($client, null, 'desc');
}
else {
return $this->redirect()->toRoute('auth', array('action' => 'login'));
$result = null;
}

$response = $this->getResponse();
$response->getHeaders()->addHeaderLine('Content-Type', 'application/json');

if(isset($result)) {
$response->setContent(JSON::encode($result));
}

return $response;
}

public function getClientModel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,3 @@ public function getStorageModel()
}

}

0 comments on commit 7576363

Please sign in to comment.