Skip to content

Commit

Permalink
3.3.8 fixes (xibosignage#2053)
Browse files Browse the repository at this point in the history
* Interactive: make sure notifyByLayoutCode checks for scheduled actions. xibosignage/xibo#3086
* Library Upload : check if the provided playlist is editable - for region playlists.
* Folders : Throw specific error when attempting to delete a Folder set as homeFolderId xibosignage/xibo#3083
* Schedule : Fix updating a Layout scheduled using a user created day part not notifying Displays correctly. xibosignage/xibo#3089
  • Loading branch information
PeterMis committed Sep 8, 2023
1 parent 19bea76 commit f3f7d76
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 14 deletions.
14 changes: 13 additions & 1 deletion lib/Controller/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,23 @@ public function delete(Request $request, Response $response, $folderId)
throw new AccessDeniedException();
}

if ($folder->isHome()) {
throw new InvalidArgumentException(
__('Cannot remove Folder set as home Folder for a user'),
'folderId',
__('Change home Folder for Users using this Folder before deleting')
);
}

try {
$folder->delete();
} catch (\Exception $exception) {
$this->getLog()->debug('Folder delete failed with message: ' . $exception->getMessage());
throw new InvalidArgumentException(__('Cannot remove Folder with content'), 'folderId', __('Reassign objects from this Folder before deleting.'));
throw new InvalidArgumentException(
__('Cannot remove Folder with content'),
'folderId',
__('Reassign objects from this Folder before deleting.')
);
}

// Return
Expand Down
17 changes: 15 additions & 2 deletions lib/Entity/Folder.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 @@ -451,4 +451,17 @@ public function isTheSameBranch(int $newParentFolderId): bool

return $found;
}

/**
* Check if this folder is used as Home Folder for any existing Users
* @return bool
*/
public function isHome(): bool
{
$userIds = $this->getStore()->select('SELECT userId FROM `user` WHERE `user`.homeFolderId = :folderId', [
'folderId' => $this->id
]);

return count($userIds) > 0;
}
}
8 changes: 6 additions & 2 deletions lib/Helper/XiboUploadHandler.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/*
* Copyright (c) 2022 Xibo Signage Ltd
* Copyright (C) 2022-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 @@ -419,6 +419,10 @@ protected function handle_form_data($file, $index)
// Get the Playlist
$playlist = $controller->getPlaylistFactory()->getById($this->options['playlistId']);

if (!$playlist->isEditable()) {
throw new InvalidArgumentException(__('This Layout is not a Draft, please checkout.'), 'layoutId');
}

// Create a Widget and add it to our region
$widget = $controller->getWidgetFactory()->create(
$this->options['userId'],
Expand Down
40 changes: 34 additions & 6 deletions lib/Service/DisplayNotifyService.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 @@ -278,7 +278,7 @@ public function notifyByCampaignId($campaignId)
) campaigns
ON campaigns.campaignId = `schedule`.campaignId
WHERE (
(`schedule`.FromDT < :toDt AND IFNULL(`schedule`.toDt, `schedule`.fromDt) > :fromDt)
(`schedule`.FromDT < :toDt AND IFNULL(`schedule`.toDt, UNIX_TIMESTAMP()) > :fromDt)
OR `schedule`.recurrence_range >= :fromDt
OR (
IFNULL(`schedule`.recurrence_range, 0) = 0 AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\'
Expand Down Expand Up @@ -411,7 +411,7 @@ public function notifyByDataSetId($dataSetId)
AND `widgetoption`.option = \'dataSetId\'
AND `widgetoption`.value = :activeDataSetId
WHERE (
(schedule.FromDT < :toDt AND IFNULL(`schedule`.toDt, `schedule`.fromDt) > :fromDt)
(schedule.FromDT < :toDt AND IFNULL(`schedule`.toDt, UNIX_TIMESTAMP()) > :fromDt)
OR `schedule`.recurrence_range >= :fromDt
OR (
IFNULL(`schedule`.recurrence_range, 0) = 0 AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\'
Expand Down Expand Up @@ -563,7 +563,7 @@ public function notifyByPlaylistId($playlistId)
ON `playlist`.regionId = `region`.regionId
WHERE `playlist`.playlistId = :playlistId
AND (
(schedule.FromDT < :toDt AND IFNULL(`schedule`.toDt, `schedule`.fromDt) > :fromDt)
(schedule.FromDT < :toDt AND IFNULL(`schedule`.toDt, UNIX_TIMESTAMP()) > :fromDt)
OR `schedule`.recurrence_range >= :fromDt
OR (
IFNULL(`schedule`.recurrence_range, 0) = 0 AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\'
Expand Down Expand Up @@ -716,13 +716,41 @@ public function notifyByLayoutCode($code)
) campaigns
ON campaigns.campaignId = `schedule`.campaignId
WHERE (
(`schedule`.FromDT < :toDt AND IFNULL(`schedule`.toDt, `schedule`.fromDt) > :fromDt)
(`schedule`.FromDT < :toDt AND IFNULL(`schedule`.toDt, UNIX_TIMESTAMP()) > :fromDt)
OR `schedule`.recurrence_range >= :fromDt
OR (
IFNULL(`schedule`.recurrence_range, 0) = 0 AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\'
)
)
UNION
SELECT DISTINCT display.displayId,
schedule.eventId,
schedule.fromDt,
schedule.toDt,
schedule.recurrence_type AS recurrenceType,
schedule.recurrence_detail AS recurrenceDetail,
schedule.recurrence_range AS recurrenceRange,
schedule.recurrenceRepeatsOn,
schedule.lastRecurrenceWatermark,
schedule.dayPartId
FROM `schedule`
INNER JOIN `lkscheduledisplaygroup`
ON `lkscheduledisplaygroup`.eventId = `schedule`.eventId
INNER JOIN `lkdgdg`
ON `lkdgdg`.parentId = `lkscheduledisplaygroup`.displayGroupId
INNER JOIN `lkdisplaydg`
ON lkdisplaydg.DisplayGroupID = `lkdgdg`.childId
INNER JOIN `display`
ON lkdisplaydg.DisplayID = display.displayID
WHERE schedule.actionLayoutCode = :code
AND (
(`schedule`.FromDT < :toDt AND IFNULL(`schedule`.toDt, UNIX_TIMESTAMP()) > :fromDt)
OR `schedule`.recurrence_range >= :fromDt
OR (
IFNULL(`schedule`.recurrence_range, 0) = 0 AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\'
)
)
UNION
SELECT DISTINCT display.DisplayID,
0 AS eventId,
0 AS fromDt,
Expand Down
9 changes: 6 additions & 3 deletions ui/src/core/xibo-cms.js
Original file line number Diff line number Diff line change
Expand Up @@ -3748,11 +3748,14 @@ function initJsTreeAjax(container, id, isForm, ttl, onReady = null, onSelected =
$('#container-folder-tree').jstree(true).refresh();
}
} else {
toastr.error(translations.folderWithContent);
console.log(data.message);
if (data.message !== undefined) {
toastr.error(data.message)
} else {
toastr.error(translations.folderWithContent);
}

$(container).jstree(true).refresh();
}

}
});
}).bind("changed.jstree", function (e, data) {
Expand Down

0 comments on commit f3f7d76

Please sign in to comment.