Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugifxes 4.0.4 issues part2 #2129

Merged
merged 7 commits into from
Oct 3, 2023
13 changes: 10 additions & 3 deletions lib/Controller/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@
$resolution = $this->resolutionFactory->getByDimensions($layout->width, $layout->height);
}
} catch (NotFoundException $notFoundException) {
$this->getLog()->info('Layout Designer with an unknown resolution, we will create it with name: ' . $layout->width . ' x ' . $layout->height);

Check warning on line 247 in lib/Controller/Layout.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 154 characters

$resolution = $this->resolutionFactory->create($layout->width . ' x ' . $layout->height, (int)$layout->width, (int)$layout->height);

Check warning on line 249 in lib/Controller/Layout.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 144 characters
$resolution->userId = $this->userFactory->getSystemUser()->userId;
$resolution->save();
}
Expand Down Expand Up @@ -605,7 +605,7 @@

// if it was not a template, and user added template tag, throw an error.
if (!$isTemplate && $layout->hasTag('template')) {
throw new InvalidArgumentException(__('Cannot assign a Template tag to a Layout, to create a template use the Save Template button instead.'), 'tags');

Check warning on line 608 in lib/Controller/Layout.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 163 characters
}

$layout->retired = $sanitizedParams->getCheckbox('retired');
Expand Down Expand Up @@ -653,7 +653,7 @@
]);
}

// if the folder changed on original Layout, make sure we keep its regionPlaylists and draft regionPlaylists updated

Check warning on line 656 in lib/Controller/Layout.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 132 characters
if ($folderChanged) {
$savedLayout->load();
$allRegions = array_merge($savedLayout->regions, $savedLayout->drawers);
Expand Down Expand Up @@ -1667,7 +1667,7 @@
'text' => __('Checkout'),
'dataAttributes' => [
['name' => 'auto-submit', 'value' => true],
['name' => 'commit-url', 'value' => $this->urlFor($request, 'layout.checkout', ['id' => $layout->layoutId])],

Check warning on line 1670 in lib/Controller/Layout.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 137 characters
['name' => 'commit-method', 'value' => 'PUT']
]
);
Expand Down Expand Up @@ -1704,7 +1704,7 @@
if ($this->getUser()->featureEnabled('schedule.add')) {
$layout->buttons[] = array(
'id' => 'layout_button_schedule',
'url' => $this->urlFor($request, 'schedule.add.form', ['id' => $layout->campaignId, 'from' => 'Layout']),

Check warning on line 1707 in lib/Controller/Layout.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 125 characters
'text' => __('Schedule')
);
}
Expand Down Expand Up @@ -1768,7 +1768,7 @@
'text' => __('Select Folder'),
'multi-select' => true,
'dataAttributes' => [
['name' => 'commit-url', 'value' => $this->urlFor($request, 'campaign.selectfolder', ['id' => $layout->campaignId])],

Check warning on line 1771 in lib/Controller/Layout.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 145 characters
['name' => 'commit-method', 'value' => 'put'],
['name' => 'id', 'value' => 'campaign_button_selectfolder'],
['name' => 'text', 'value' => __('Move to Folder')],
Expand All @@ -1793,7 +1793,7 @@
'text' => __('Retire'),
'multi-select' => true,
'dataAttributes' => [
['name' => 'commit-url', 'value' => $this->urlFor($request, 'layout.retire', ['id' => $layout->layoutId])],

Check warning on line 1796 in lib/Controller/Layout.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 135 characters
['name' => 'commit-method', 'value' => 'put'],
['name' => 'id', 'value' => 'layout_button_retire'],
['name' => 'text', 'value' => __('Retire')],
Expand All @@ -1818,7 +1818,7 @@
'text' => __('Delete'),
'multi-select' => true,
'dataAttributes' => [
['name' => 'commit-url', 'value' => $this->urlFor($request, 'layout.delete', ['id' => $layout->layoutId])],

Check warning on line 1821 in lib/Controller/Layout.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 135 characters
['name' => 'commit-method', 'value' => 'delete'],
['name' => 'id', 'value' => 'layout_button_delete'],
['name' => 'text', 'value' => __('Delete')],
Expand All @@ -1835,7 +1835,7 @@
'text' => __('Enable stats collection?'),
'multi-select' => true,
'dataAttributes' => [
['name' => 'commit-url', 'value' => $this->urlFor($request, 'layout.setenablestat', ['id' => $layout->layoutId])],

Check warning on line 1838 in lib/Controller/Layout.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 138 characters
['name' => 'commit-method', 'value' => 'put'],
['name' => 'id', 'value' => 'layout_button_setenablestat'],
['name' => 'text', 'value' => __('Enable stats collection?')],
Expand Down Expand Up @@ -1943,9 +1943,10 @@
$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 @@
$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');
}

PeterMis marked this conversation as resolved.
Show resolved Hide resolved
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)) {
dasgarner marked this conversation as resolved.
Show resolved Hide resolved
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
Loading