Skip to content

Commit

Permalink
Merge pull request #1227 from xibosignage/release30
Browse files Browse the repository at this point in the history
Release 3.0.2
  • Loading branch information
dasgarner authored Aug 2, 2021
2 parents 3ea18ef + e91d5b4 commit 380a595
Show file tree
Hide file tree
Showing 65 changed files with 806 additions and 464 deletions.
51 changes: 32 additions & 19 deletions lib/Controller/Applications.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,32 @@ public function grid(Request $request, Response $response)
public function authorizeRequest(Request $request, Response $response)
{
// Pull authorize params from our session
if (!$authParams = $this->session->get('authParams')) {
/** @var AuthorizationRequest $authParams */
$authParams = $this->session->get('authParams');
if (!$authParams) {
throw new InvalidArgumentException(__('Authorisation Parameters missing from session.'), 'authParams');
}

// Process any scopes.
$scopes = [];
$authScopes = $authParams->getScopes();
if ($authScopes !== null) {
foreach ($authScopes as $scope) {
$this->getLog()->debug('Loading scope: ' . $scope->getIdentifier());
$scopes[] = $this->applicationScopeFactory->getById($scope->getIdentifier());
}
}

// `all` is the default scope
if (count($scopes) <= 0) {
$scopes[] = $this->applicationScopeFactory->getById('all');
}

// Get, show page
$this->getState()->template = 'applications-authorize-page';
$this->getState()->setData([
'authParams' => $authParams
'authParams' => $authParams,
'scopes' => $scopes
]);

return $this->render($request, $response);
Expand All @@ -196,20 +214,17 @@ public function authorizeRequest(Request $request, Response $response)
public function authorize(Request $request, Response $response)
{
// Pull authorize params from our session
if (!$authParams = $this->session->get('authParams')) {
/** @var AuthorizationRequest $authRequest */
$authRequest = $this->session->get('authParams');
if (!$authRequest) {
throw new InvalidArgumentException(__('Authorisation Parameters missing from session.'), 'authParams');
}

$sanitizedQueryParams = $this->getSanitizer($request->getParams());

// get auth server
/** @var AuthorizationRequest $authRequest */
$authRequest = $this->session->get('authParams');

$apiKeyPaths = $this->getConfig()->getApiKeyDetails();

$privateKey = $apiKeyPaths['privateKeyPath'];
$encryptionKey = $apiKeyPaths['publicKeyPath'];
$encryptionKey = $apiKeyPaths['encryptionKey'];

$server = new AuthorizationServer(
$this->applicationFactory,
Expand All @@ -231,21 +246,18 @@ public function authorize(Request $request, Response $response)
// Default scope
$server->setDefaultScope('all');

// get oauth User Entity and set the UserId to the current web userId
$authRequest->setUser($this->getUser());

// We are authorized
if ($sanitizedQueryParams->getString('authorization') === 'Approve') {

$authRequest->setAuthorizationApproved(true);

// get oauth User Entity and set the UserId to the current web userId
$authRequest->setUser($this->getUser());

// Redirect back to the home page
return $server->completeAuthorizationRequest($authRequest, $response);
}
else {
} else {
$authRequest->setAuthorizationApproved(false);
return $server->completeAuthorizationRequest($authRequest, $response);
}

// Redirect back to the specified redirect url
return $server->completeAuthorizationRequest($authRequest, $response);
}

/**
Expand Down Expand Up @@ -470,6 +482,7 @@ public function edit(Request $request, Response $response, $id)
$client->name = $sanitizedParams->getString('name');
$client->authCode = $sanitizedParams->getCheckbox('authCode');
$client->clientCredentials = $sanitizedParams->getCheckbox('clientCredentials');
$client->isConfidential = $sanitizedParams->getCheckbox('isConfidential');

if ($sanitizedParams->getCheckbox('resetKeys') == 1) {
$client->resetSecret();
Expand Down
7 changes: 6 additions & 1 deletion lib/Controller/DayPart.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Copyright (C) 2020 Xibo Signage Ltd
* Copyright (C) 2021 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
*
Expand Down Expand Up @@ -34,6 +34,7 @@
use Xibo\Service\ConfigServiceInterface;
use Xibo\Service\LogServiceInterface;
use Xibo\Support\Exception\AccessDeniedException;
use Xibo\Support\Exception\InvalidArgumentException;

/**
* Class DayPart
Expand Down Expand Up @@ -628,6 +629,10 @@ public function delete(Request $request, Response $response, $id)
{
$dayPart = $this->dayPartFactory->getById($id);

if ($dayPart->isSystemDayPart()) {
throw new InvalidArgumentException('Cannot delete system dayPart', 'dayPartId');
}

if (!$this->getUser()->checkDeleteable($dayPart)) {
throw new AccessDeniedException();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ function displayManage(Request $request, Response $response, $id)
'sizeRemaining' => round((double)($totalSize - $completeSize) / (pow(1024, $base)), 2),
],
'defaults' => [
'fromDate' => Carbon::now()->subSeconds(86400 * 35)->format(DateFormatHelper::getSystemFormat()),
'fromDateOneDay' => Carbon::now()->subSeconds(86400)->format(DateFormatHelper::getSystemFormat()),
'toDate' => Carbon::now()->format(DateFormatHelper::getSystemFormat())
'fromDate' => Carbon::now()->startOfMonth()->format(DateFormatHelper::getSystemFormat()),
'fromDateOneDay' => Carbon::now()->subDay()->format(DateFormatHelper::getSystemFormat()),
'toDate' => Carbon::now()->endOfMonth()->format(DateFormatHelper::getSystemFormat())
]
]);

Expand Down
14 changes: 10 additions & 4 deletions lib/Controller/DisplayGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -1900,8 +1900,11 @@ public function changeLayout(Request $request, Response $response, $id)
// in this case we should build it and notify before we send the action
// notify should NOT collect now, as we will do that during our own action.
$layout = $this->layoutFactory->concurrentRequestLock($layout);
$layout->xlfToDisk(['notify' => true, 'collectNow' => false]);
$this->layoutFactory->concurrentRequestRelease($layout);
try {
$layout->xlfToDisk(['notify' => true, 'collectNow' => false]);
} finally {
$this->layoutFactory->concurrentRequestRelease($layout);
}
}
}

Expand Down Expand Up @@ -2092,8 +2095,11 @@ public function overlayLayout(Request $request, Response $response, $id)
// in this case we should build it and notify before we send the action
// notify should NOT collect now, as we will do that during our own action.
$layout = $this->layoutFactory->concurrentRequestLock($layout);
$layout->xlfToDisk(['notify' => true, 'collectNow' => false]);
$this->layoutFactory->concurrentRequestRelease($layout);
try {
$layout->xlfToDisk(['notify' => true, 'collectNow' => false]);
} finally {
$this->layoutFactory->concurrentRequestRelease($layout);
}
}
}

Expand Down
19 changes: 17 additions & 2 deletions lib/Controller/DisplayProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,26 @@ public function copy(Request $request, Response $response, $id)
// Create a form out of the config object.
$displayProfile = $this->displayProfileFactory->getById($id);

if ($this->getUser()->userTypeId != 1 && $this->getUser()->userId != $displayProfile->userId)
if ($this->getUser()->userTypeId != 1 && $this->getUser()->userId != $displayProfile->userId) {
throw new AccessDeniedException(__('You do not have permission to delete this profile'));
}

// clear DisplayProfileId, commands and set isDefault to 0
$new = clone $displayProfile;
$new->name = $this->getSanitizer($request->getParams())->getString('name');

foreach ($displayProfile->commands as $command) {
/* @var \Xibo\Entity\Command $command */
if (!empty($command->commandStringDisplayProfile)) {
// if the original Display Profile has a commandString
// assign this command with the same commandString to new Display Profile
// commands with only default commandString are not directly assigned to Display profile
$command->commandString = $command->commandStringDisplayProfile;
$command->validationString = $command->validationStringDisplayProfile;
$new->assignCommand($command);
}
}

$new->save();

// Return
Expand All @@ -639,4 +654,4 @@ public function copy(Request $request, Response $response, $id)

return $this->render($request, $response);
}
}
}
Loading

0 comments on commit 380a595

Please sign in to comment.