Skip to content

Commit

Permalink
Bugifxes 4.0.4 issues part2 (#2129)
Browse files Browse the repository at this point in the history
* Schedule : Throw specific error when not all Displays in Sync Group were given a Layout. xibosignage/xibo#3150
* Maintenance : Remove weather-humidity-percent asset, as it is no longer needed. xibosignage/xibo#3155
* Custom Install : Make sure we create fonts sub-folder under selected Library directory during install process. xibosignage/xibo#3156
* Layout : Make sure we only show enabled Resolutions in the dropdown in Layout Editor - while also always including currently selected resolution. xibosignage/xibo#3173
* Library Upload : Protect against empty default resize limit CMS setting. xibosignage/xibo#3159
  • Loading branch information
PeterMis committed Oct 3, 2023
1 parent 6e1ddc2 commit 192b1c1
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 21 deletions.
13 changes: 10 additions & 3 deletions lib/Controller/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -1943,9 +1943,10 @@ function editBackgroundForm(Request $request, Response $response, $id)
$sanitizedParams = $this->getSanitizer($request->getParams());

// Check Permissions
if (!$this->getUser()->checkEditable($layout))
if (!$this->getUser()->checkEditable($layout)) {
throw new AccessDeniedException();

}

// Edits always happen on Drafts, get the draft Layout using the Parent Layout ID
if ($layout->schemaVersion < 2) {
$resolution = $this->resolutionFactory->getByDesignerDimensions($layout->width, $layout->height);
Expand All @@ -1961,7 +1962,13 @@ function editBackgroundForm(Request $request, Response $response, $id)
$this->getState()->setData([
'layout' => $layout,
'resolution' => $resolution,
'resolutions' => $this->resolutionFactory->query(['resolution'], ['withCurrent' => $resolution->resolutionId]),
'resolutions' => $this->resolutionFactory->query(
['resolution'],
[
'withCurrent' => $resolution->resolutionId,
'enabled' => 1
]
),
'backgroundId' => $backgroundId,
'backgrounds' => $backgrounds,
]);
Expand Down
13 changes: 6 additions & 7 deletions lib/Controller/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,9 @@ public function add(Request $request, Response $response)
$this->getLog()->debug('Add Schedule');
$sanitizedParams = $this->getSanitizer($request->getParams());

$embed = ($sanitizedParams->getString('embed') != null) ? explode(',', $sanitizedParams->getString('embed')) : [];
$embed = ($sanitizedParams->getString('embed') != null)
? explode(',', $sanitizedParams->getString('embed'))
: [];

// Get the custom day part to use as a default day part
$customDayPart = $this->dayPartFactory->getCustomDayPart();
Expand Down Expand Up @@ -1266,17 +1268,14 @@ public function add(Request $request, Response $response)
// API Request
$rows = [];
if ($this->isApi($request)) {

$reminders = $sanitizedParams->getArray('scheduleReminders', ['default' => []]);
foreach ($reminders as $i => $reminder) {

$rows[$i]['reminder_value'] = (int) $reminder['reminder_value'];
$rows[$i]['reminder_type'] = (int) $reminder['reminder_type'];
$rows[$i]['reminder_option'] = (int) $reminder['reminder_option'];
$rows[$i]['reminder_isEmailHidden'] = (int) $reminder['reminder_isEmailHidden'];
}
} else {

for ($i=0; $i < count($sanitizedParams->getIntArray('reminder_value', ['default' => []])); $i++) {
$rows[$i]['reminder_value'] = $sanitizedParams->getIntArray('reminder_value')[$i];
$rows[$i]['reminder_type'] = $sanitizedParams->getIntArray('reminder_type')[$i];
Expand All @@ -1287,7 +1286,6 @@ public function add(Request $request, Response $response)

// Save new reminders
foreach ($rows as $reminder) {

// Do not add reminder if empty value provided for number of minute/hour
if ($reminder['reminder_value'] == 0) {
continue;
Expand All @@ -1314,6 +1312,7 @@ public function add(Request $request, Response $response)

if ($this->isSyncEvent($schedule->eventTypeId)) {
$syncGroup = $this->syncGroupFactory->getById($schedule->syncGroupId);
$syncGroup->validateForSchedule($sanitizedParams);
$schedule->updateSyncLinks($syncGroup, $sanitizedParams);
}

Expand Down Expand Up @@ -1866,16 +1865,16 @@ public function edit(Request $request, Response $response, $id)

if ($this->isSyncEvent($schedule->eventTypeId)) {
$syncGroup = $this->syncGroupFactory->getById($schedule->syncGroupId);
$syncGroup->validateForSchedule($sanitizedParams);
$schedule->updateSyncLinks($syncGroup, $sanitizedParams);
}

// Get form reminders
$rows = [];
for ($i=0; $i < count($sanitizedParams->getIntArray('reminder_value',['default' => []])); $i++) {

$entry = [];

if ($sanitizedParams->getIntArray('reminder_scheduleReminderId')[$i] == null ) {
if ($sanitizedParams->getIntArray('reminder_scheduleReminderId')[$i] == null) {
continue;
}

Expand Down
15 changes: 14 additions & 1 deletion lib/Entity/SyncGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Xibo\Helper\DateFormatHelper;
use Xibo\Support\Exception\InvalidArgumentException;
use Xibo\Support\Exception\NotFoundException;
use Xibo\Support\Sanitizer\SanitizerInterface;

/**
* @SWG\Definition()
Expand Down Expand Up @@ -137,7 +138,7 @@ public function __construct(
}

/**
* @return array[Display]
* @return Display[]
* @throws NotFoundException
*/
public function getSyncGroupMembers(): array
Expand Down Expand Up @@ -287,6 +288,18 @@ public function validate(): void
}
}

public function validateForSchedule(SanitizerInterface $sanitizer)
{
foreach ($this->getSyncGroupMembers() as $display) {
if (empty($sanitizer->getInt('layoutId_' . $display->displayId))) {
$this->getLog()->error('Sync Event : Missing Layout for DisplayID ' . $display->displayId);
throw new InvalidArgumentException(
__('Please make sure to select a Layout for all Displays in this Sync Group.')
);
}
}
}

private function add(): void
{
$time = Carbon::now()->format(DateFormatHelper::getSystemFormat());
Expand Down
16 changes: 13 additions & 3 deletions lib/Factory/ResolutionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ public function query($sortOrder = null, $filterBy = [])
$sortOrder = ['resolution'];
}

$entities = array();
$entities = [];

$params = array();
$params = [];
$select = '
SELECT `resolution`.resolutionId,
`resolution`.resolution,
Expand All @@ -168,7 +168,17 @@ public function query($sortOrder = null, $filterBy = [])
WHERE 1 = 1
';

if ($parsedFilter->getInt('enabled', ['default' => -1]) != -1) {
if ($parsedFilter->getInt('enabled', ['default' => -1]) != -1
&& $parsedFilter->getInt('withCurrent') !== null
) {
$body .= ' AND ( enabled = :enabled OR `resolution`.resolutionId = :withCurrent) ';
$params['enabled'] = $parsedFilter->getInt('enabled');
$params['withCurrent'] = $parsedFilter->getInt('withCurrent');
}

if ($parsedFilter->getInt('enabled', ['default' => -1]) != -1
&& $parsedFilter->getInt('withCurrent') === null
) {
$body .= ' AND enabled = :enabled ';
$params['enabled'] = $parsedFilter->getInt('enabled');
}
Expand Down
11 changes: 8 additions & 3 deletions lib/Helper/Install.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/**
* Copyright (C) 2022 Xibo Signage Ltd
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
Expand Down Expand Up @@ -414,6 +414,11 @@ public function step7(Request $request, Response $response) : Response
$library_location = $library_location . '/';
}

// Attempt to create fonts sub-folder in Library location
if (!mkdir($library_location . 'fonts', 0777, true)) {
throw new InstallationError(__('Could not create the fonts sub-folder under Library Location directory for you. Please ensure the webserver has permission to create a folder in this location, or create the folder manually and grant permission for the webserver to write to the folder.'));//phpcs:ignore
}

try {
$dbh = $store->getConnection();

Expand Down
3 changes: 0 additions & 3 deletions modules/templates/forecast-elements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ if (String(value).includes('°C')) {
return value + '%';
]]></onElementParseData>
<assets>
<asset id="weather-humidity-percent" type="path" cmsOnly="true" mimeType="image/png" path="/modules/assets/template-thumbnails/forecast/elements/weather-humidity-percent.png" />
</assets>
</template>
<template>
<id>weather_icon</id>
Expand Down
4 changes: 4 additions & 0 deletions ui/src/core/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function openUploadForm(options) {
uploadTemplate = Handlebars.compile($('#' + options.templateId).html());
}

if (typeof maxImagePixelSize === undefined || maxImagePixelSize === '') {
maxImagePixelSize = 0;
}

// Handle bars and open a dialog
const dialog = bootbox.dialog({
message: uploadTemplate(options.templateOptions),
Expand Down
2 changes: 1 addition & 1 deletion views/include-file-upload.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

{# Max image resize size from settings #}
<script type="text/javascript">
const maxImagePixelSize = {{ settings.DEFAULT_RESIZE_LIMIT }};
let maxImagePixelSize = "{{ settings.DEFAULT_RESIZE_LIMIT }}";
</script>

{# Handlebars Templates #}
Expand Down

0 comments on commit 192b1c1

Please sign in to comment.