Skip to content

Commit

Permalink
Merge pull request #2611 from xibosignage/develop
Browse files Browse the repository at this point in the history
Release 4.0.13
  • Loading branch information
dasgarner authored Jul 9, 2024
2 parents 129f92b + e8e6008 commit 732a02f
Show file tree
Hide file tree
Showing 111 changed files with 1,267 additions and 1,418 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/test-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ jobs:
# Step 4: The Rest
- name: Check Comment
id: check_comment
env:
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
comment_body="${{ github.event.comment.body }}"
if [[ "$comment_body" =~ TEST:\ (all|\*) ]]; then
# Sanitize and validate comment body for TEST command
if [[ "$COMMENT_BODY" =~ ^TEST:\ (all|\*)$ ]]; then
test_all=true
elif [[ "$comment_body" =~ TEST:(.*?)END ]]; then
elif [[ "$COMMENT_BODY" =~ ^TEST:(.*?)END$ ]]; then
specs="${BASH_REMATCH[1]}"
# Split the content by commas and remove spaces
IFS=',' read -ra content_array <<< "$specs"
Expand All @@ -46,7 +48,7 @@ jobs:
content_array=("${content_array[@]%/}")
# Add "/app/cypress/e2e/" prefix to each element
for ((i=0; i<${#content_array[@]}; i++)); do
content_array[$i]="/app/cypress/e2e/${content_array[$i]}"
content_array[$i]="/app/cypress/e2e/${content_array[$i]}"
done
# Join the content array elements with commas
content_no_spaces="$(IFS=','; echo "${content_array[*]}")"
Expand Down
7 changes: 1 addition & 6 deletions lib/Connector/OpenWeatherMapConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,13 @@ class OpenWeatherMapConnector implements ConnectorInterface
private $forecast3Hourly = '2.5/forecast';
private $forecastDaily = '2.5/forecast/daily';
private $forecastCombinedV3 = '3.0/onecall';
private $forecastUv = 'uvi';

/** @var string */
protected $timezone;

/** @var \Xibo\Widget\DataType\Forecast */
protected $currentDay;

/** @var \Xibo\Widget\DataType\Forecast[] */
protected $forecast;

public function registerWithDispatcher(EventDispatcherInterface $dispatcher): ConnectorInterface
{
$dispatcher->addListener(WidgetDataRequestEvent::$NAME, [$this, 'onDataRequest']);
Expand Down Expand Up @@ -90,8 +86,7 @@ public function processSettingsForm(SanitizerInterface $params, array $settings)
{
if (!$this->isProviderSetting('owmApiKey')) {
$settings['owmApiKey'] = $params->getString('owmApiKey');
$settings['owmApiVersion'] = $params->getString('owmApiVersion');
$settings['owmIsPaidPlan'] = $params->getString('owmIsPaidPlan');
$settings['owmIsPaidPlan'] = $params->getCheckbox('owmIsPaidPlan');
$settings['cachePeriod'] = $params->getInt('cachePeriod');
}
return $settings;
Expand Down
9 changes: 1 addition & 8 deletions lib/Controller/DataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -1198,24 +1198,17 @@ public function import(Request $request, Response $response, $id)

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


$options = array(
'userId' => $this->getUser()->userId,
'dataSetId' => $id,
'controller' => $this,
'upload_dir' => $libraryFolder . 'temp/',
'download_via_php' => true,
'script_url' => $this->urlFor($request,'dataSet.import', ['id' => $id]),
'upload_url' => $this->urlFor($request,'dataSet.import', ['id' => $id]),
'image_versions' => array(),
'accept_file_types' => '/\.csv/i',
'sanitizer' => $sanitizer
);

try {
// Hand off to the Upload Handler provided by jquery-file-upload
new DataSetUploadHandler($options);

new DataSetUploadHandler($libraryFolder . 'temp/', $this->getLog()->getLoggerInterface(), $options);
} catch (\Exception $e) {
// We must not issue an error, the file upload return should have the error object already
$this->getState()->setCommitState(false);
Expand Down
1 change: 0 additions & 1 deletion lib/Controller/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,6 @@ function edit(Request $request, Response $response, $id)

// Tags are stored on the displaygroup, we're just passing through here
if ($this->getUser()->featureEnabled('tag.tagging')) {
$display->setOriginalValue('tags', $display->tags);
if (is_array($sanitizedParams->getParam('tags'))) {
$tags = $this->tagFactory->tagsFromJson($sanitizedParams->getArray('tags'));
} else {
Expand Down
16 changes: 6 additions & 10 deletions lib/Controller/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use Xibo\Factory\FontFactory;
use Xibo\Helper\ByteFormatter;
use Xibo\Helper\HttpCacheProvider;
use Xibo\Helper\UploadHandler;
use Xibo\Service\DownloadService;
use Xibo\Service\MediaService;
use Xibo\Service\MediaServiceInterface;
Expand Down Expand Up @@ -381,9 +380,6 @@ public function add(Request $request, Response $response)
$libraryLimit = $this->getConfig()->getSetting('LIBRARY_SIZE_LIMIT_KB') * 1024;

$options = [
'upload_dir' => $libraryFolder . 'temp/',
'script_url' => $this->urlFor($request, 'font.add'),
'upload_url' => $this->urlFor($request, 'font.add'),
'accept_file_types' => '/\.' . implode('|', $validExt) . '$/i',
'libraryLimit' => $libraryLimit,
'libraryQuotaFull' => ($libraryLimit > 0 && $this->getMediaService()->libraryUsage() > $libraryLimit),
Expand All @@ -395,20 +391,19 @@ public function add(Request $request, Response $response)
$this->getLog()->debug('Hand off to Upload Handler with options: ' . json_encode($options));

// Hand off to the Upload Handler provided by jquery-file-upload
$uploadService = new UploadService($options, $this->getLog(), $this->getState());
$uploadService = new UploadService($libraryFolder . 'temp/', $options, $this->getLog(), $this->getState());
$uploadHandler = $uploadService->createUploadHandler();

$uploadHandler->setPostProcessor(function ($file, $uploadHandler) {
$uploadHandler->setPostProcessor(function ($file, $uploadHandler) use ($libraryFolder) {
// Return right away if the file already has an error.
if (!empty($file->error)) {
return $file;
}

$this->getUser()->isQuotaFullByUser(true);

/** @var UploadHandler $uploadHandler */
$filePath = $uploadHandler->getUploadPath() . $file->fileName;
$libraryLocation = $this->getConfig()->getSetting('LIBRARY_LOCATION');
// Get the uploaded file and move it to the right place
$filePath = $libraryFolder . 'temp/' . $file->fileName;

// Add the Font
$font = $this->getFontFactory()
Expand All @@ -424,7 +419,7 @@ public function add(Request $request, Response $response)
}

// everything is fine, move the file from temp folder.
rename($filePath, $libraryLocation . 'fonts/' . $font->fileName);
rename($filePath, $libraryFolder . 'fonts/' . $font->fileName);

// return
$file->id = $font->id;
Expand All @@ -434,6 +429,7 @@ public function add(Request $request, Response $response)
return $file;
});

// Handle the post request
$uploadHandler->post();

// all done, refresh fonts.css
Expand Down
6 changes: 1 addition & 5 deletions lib/Controller/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -2560,10 +2560,6 @@ public function import(Request $request, Response $response)
'userId' => $this->getUser()->userId,
'controller' => $this,
'dataSetFactory' => $this->getDataSetFactory(),
'upload_dir' => $libraryFolder . 'temp/',
'download_via_php' => true,
'script_url' => $this->urlFor($request, 'layout.import'),
'upload_url' => $this->urlFor($request, 'layout.import'),
'image_versions' => [],
'accept_file_types' => '/\.zip$/i',
'libraryLimit' => $libraryLimit,
Expand All @@ -2576,7 +2572,7 @@ public function import(Request $request, Response $response)
$this->setNoOutput(true);

// Hand off to the Upload Handler provided by jquery-file-upload
new LayoutUploadHandler($options);
new LayoutUploadHandler($libraryFolder . 'temp/', $this->getLog()->getLoggerInterface(), $options);

// Explicitly set the Content-Type header to application/json
$response = $response->withHeader('Content-Type', 'application/json');
Expand Down
7 changes: 1 addition & 6 deletions lib/Controller/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -1199,11 +1199,6 @@ public function add(Request $request, Response $response)
'allowMediaTypeChange' => $options['allowMediaTypeChange'],
'displayOrder' => $parsedBody->getInt('displayOrder'),
'playlistId' => $parsedBody->getInt('playlistId'),
'upload_dir' => $libraryFolder . 'temp/',
'download_via_php' => true,
'script_url' => $this->urlFor($request,'library.add'),
'upload_url' => $this->urlFor($request,'library.add'),
'image_versions' => [],
'accept_file_types' => '/\.' . implode('|', $validExt) . '$/i',
'libraryLimit' => $libraryLimit,
'libraryQuotaFull' => ($libraryLimit > 0 && $this->getMediaService()->libraryUsage() > $libraryLimit),
Expand All @@ -1220,7 +1215,7 @@ public function add(Request $request, Response $response)
$this->getLog()->debug('Hand off to Upload Handler with options: ' . json_encode($options));

// Hand off to the Upload Handler provided by jquery-file-upload
new XiboUploadHandler($options);
new XiboUploadHandler($libraryFolder . 'temp/', $this->getLog()->getLoggerInterface(), $options);

// Explicitly set the Content-Type header to application/json
$response = $response->withHeader('Content-Type', 'application/json');
Expand Down
7 changes: 1 addition & 6 deletions lib/Controller/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,6 @@ public function addAttachment(Request $request, Response $response)
$options = array(
'userId' => $this->getUser()->userId,
'controller' => $this,
'upload_dir' => $libraryFolder . 'temp/',
'download_via_php' => true,
'script_url' => $this->urlFor($request,'notification.add'),
'upload_url' => $this->urlFor($request,'notification.add'),
'image_versions' => array(),
'accept_file_types' => '/\.jpg|.jpeg|.png|.bmp|.gif|.zip|.pdf/i'
);

Expand All @@ -418,7 +413,7 @@ public function addAttachment(Request $request, Response $response)
$this->getLog()->debug('Hand off to Upload Handler with options: ' . json_encode($options));

// Hand off to the Upload Handler provided by jquery-file-upload
new AttachmentUploadHandler($options);
new AttachmentUploadHandler($libraryFolder . 'temp/', $this->getLog()->getLoggerInterface(), $options);

// Explicitly set the Content-Type header to application/json
$response = $response->withHeader('Content-Type', 'application/json');
Expand Down
15 changes: 5 additions & 10 deletions lib/Controller/PlayerSoftware.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use Xibo\Factory\ModuleFactory;
use Xibo\Factory\PlayerVersionFactory;
use Xibo\Helper\ByteFormatter;
use Xibo\Helper\UploadHandler;
use Xibo\Service\DownloadService;
use Xibo\Service\MediaService;
use Xibo\Service\MediaServiceInterface;
Expand Down Expand Up @@ -576,9 +575,6 @@ public function add(Request $request, Response $response)
$libraryLimit = $this->getConfig()->getSetting('LIBRARY_SIZE_LIMIT_KB') * 1024;

$options = [
'upload_dir' => $libraryFolder . 'temp/',
'script_url' => $this->urlFor($request, 'playersoftware.add'),
'upload_url' => $this->urlFor($request, 'playersoftware.add'),
'accept_file_types' => '/\.' . implode('|', $validExt) . '$/i',
'libraryLimit' => $libraryLimit,
'libraryQuotaFull' => ($libraryLimit > 0 && $this->getMediaService()->libraryUsage() > $libraryLimit),
Expand All @@ -590,10 +586,10 @@ public function add(Request $request, Response $response)
$this->getLog()->debug('Hand off to Upload Handler with options: ' . json_encode($options));

// Hand off to the Upload Handler provided by jquery-file-upload
$uploadService = new UploadService($options, $this->getLog(), $this->getState());
$uploadService = new UploadService($libraryFolder . 'temp/', $options, $this->getLog(), $this->getState());
$uploadHandler = $uploadService->createUploadHandler();

$uploadHandler->setPostProcessor(function ($file, $uploadHandler) {
$uploadHandler->setPostProcessor(function ($file, $uploadHandler) use ($libraryFolder) {
// Return right away if the file already has an error.
if (!empty($file->error)) {
$this->getState()->setCommitState(false);
Expand All @@ -602,9 +598,8 @@ public function add(Request $request, Response $response)

$this->getUser()->isQuotaFullByUser(true);

/** @var UploadHandler $uploadHandler */
$filePath = $uploadHandler->getUploadPath() . $file->fileName;
$libraryLocation = $this->getConfig()->getSetting('LIBRARY_LOCATION');
// Get the uploaded file and move it to the right place
$filePath = $libraryFolder . 'temp/' . $file->fileName;

// Add the Player Software record
$playerSoftware = $this->getPlayerVersionFactory()->createEmpty();
Expand Down Expand Up @@ -633,7 +628,7 @@ public function add(Request $request, Response $response)
}

// everything is fine, move the file from temp folder.
rename($filePath, $libraryLocation . 'playersoftware/' . $playerSoftware->fileName);
rename($filePath, $libraryFolder . 'playersoftware/' . $playerSoftware->fileName);

// return
$file->id = $playerSoftware->versionId;
Expand Down
29 changes: 25 additions & 4 deletions lib/Controller/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -2284,8 +2284,9 @@ public function grid(Request $request, Response $response)
], $params)
);

// Setting for whether we show Layouts with out permissions
// Grab some settings which determine how events are displayed.
$showLayoutName = ($this->getConfig()->getSetting('SCHEDULE_SHOW_LAYOUT_NAME') == 1);
$defaultTimezone = $this->getConfig()->getSetting('defaultTimezone');

foreach ($events as $event) {
$event->load();
Expand Down Expand Up @@ -2348,15 +2349,25 @@ public function grid(Request $request, Response $response)
$i++;
}
} else if ($event->recurrenceType === 'Month') {
// Force the timezone for this date (schedule from/to dates are timezone agnostic, but this
// date still has timezone information, which could lead to use formatting as the wrong day)
$date = Carbon::parse($event->fromDt)->tz($defaultTimezone);
$this->getLog()->debug('grid: setting description for monthly event with date: '
. $date->toAtomString());

if ($event->recurrenceMonthlyRepeatsOn === 0) {
$repeatsOn = 'the ' . Carbon::parse($event->fromDt)->format('jS') . ' day of the month';
$repeatsOn = 'the ' . $date->format('jS') . ' day of the month';
} else {
$date = Carbon::parse($event->fromDt);
// Which day of the month is this?
$firstDay = Carbon::parse('first ' . $date->format('l') . ' of ' . $date->format('F'));

$this->getLog()->debug('grid: the first day of the month for this date is: '
. $firstDay->toAtomString());

$nth = $firstDay->diffInDays($date) / 7 + 1;
$repeatWeekDayDate = $date->copy()->setDay($nth)->format('jS');
$repeatsOn = 'the ' . $repeatWeekDayDate . ' '
. Carbon::parse($event->fromDt)->format('l')
. $date->format('l')
. ' of the month';
}
}
Expand Down Expand Up @@ -2391,6 +2402,16 @@ public function grid(Request $request, Response $response)
$event->toDt = $event->fromDt;
}

// Set the row from/to date to be an ISO date for display (no timezone)
$event->setUnmatchedProperty(
'displayFromDt',
Carbon::createFromTimestamp($event->fromDt)->format(DateFormatHelper::getSystemFormat())
);
$event->setUnmatchedProperty(
'displayToDt',
Carbon::createFromTimestamp($event->toDt)->format(DateFormatHelper::getSystemFormat())
);

if ($this->isApi($request)) {
continue;
}
Expand Down
14 changes: 1 addition & 13 deletions lib/Controller/StatusDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,16 +310,9 @@ public function displayPage(Request $request, Response $response)
$data['libraryWidgetData'] = json_encode($libraryUsage);

// Get a count of users
$data['countUsers'] = count($this->userFactory->query());
$data['countUsers'] = $this->userFactory->count();

// Get a count of active layouts, only for display groups we have permission for
$displayGroups = $this->displayGroupFactory->query(null, ['isDisplaySpecific' => -1]);
$displayGroupIds = array_map(function ($element) {
return $element->displayGroupId;
}, $displayGroups);
// Add an empty one
$displayGroupIds[] = -1;

$params = ['now' => Carbon::now()->format('U')];

$sql = '
Expand Down Expand Up @@ -422,18 +415,14 @@ public function displayPage(Request $request, Response $response)

// Display Status and Media Inventory data - Level one
$displays = $this->displayFactory->query();
$displayIds = [];
$displayLoggedIn = [];
$displayNames = [];
$displayMediaStatus = [];
$displaysOnline = 0;
$displaysOffline = 0;
$displaysMediaUpToDate = 0;
$displaysMediaNotUpToDate = 0;

foreach ($displays as $display) {
$displayIds[] = $display->displayId;
$displayNames[] = $display->display;
$displayLoggedIn[] = $display->loggedIn;
$displayMediaStatus[] = $display->mediaInventoryStatus;
}
Expand All @@ -456,7 +445,6 @@ public function displayPage(Request $request, Response $response)

$data['displayStatus'] = json_encode([$displaysOnline, $displaysOffline]);
$data['displayMediaStatus'] = json_encode([$displaysMediaUpToDate, $displaysMediaNotUpToDate]);
$data['displayLabels'] = json_encode($displayNames);
} catch (Exception $e) {
$this->getLog()->error($e->getMessage());
$this->getLog()->debug($e->getTraceAsString());
Expand Down
6 changes: 5 additions & 1 deletion lib/Controller/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Xibo\Event\DisplayGroupLoadEvent;
use Xibo\Event\TagDeleteEvent;
use Xibo\Event\TagEditEvent;
use Xibo\Event\TriggerTaskEvent;
use Xibo\Factory\CampaignFactory;
use Xibo\Factory\DisplayFactory;
use Xibo\Factory\DisplayGroupFactory;
Expand Down Expand Up @@ -743,7 +744,10 @@ public function editMultiple(Request $request, Response $response)
// Once we're done, and if we're a Display entity, we need to calculate the dynamic display groups
if ($targetType === 'display') {
// Background update.
$this->getConfig()->changeSetting('DYNAMIC_DISPLAY_GROUP_ASSESS', 1);
$this->getDispatcher()->dispatch(
new TriggerTaskEvent('\Xibo\XTR\MaintenanceRegularTask', 'DYNAMIC_DISPLAY_GROUP_ASSESSED'),
TriggerTaskEvent::$NAME
);
}
} else {
$this->getLog()->debug('Tags were not changed');
Expand Down
Loading

0 comments on commit 732a02f

Please sign in to comment.