diff --git a/lib/Controller/Command.php b/lib/Controller/Command.php index 6d80b6b188..1e5b8342f6 100644 --- a/lib/Controller/Command.php +++ b/lib/Controller/Command.php @@ -1,8 +1,8 @@ getSanitizer($request->getParams()); + $sanitizedParams = $this->getSanitizer($request->getParams()); $filter = [ - 'commandId' => $sanitzedParams->getInt('commandId'), - 'command' => $sanitzedParams->getString('command'), - 'code' => $sanitzedParams->getString('code') + 'commandId' => $sanitizedParams->getInt('commandId'), + 'command' => $sanitizedParams->getString('command'), + 'code' => $sanitizedParams->getString('code'), + 'commandLike' => $sanitizedParams->getString('commandLike'), ]; - $commands = $this->commandFactory->query($this->gridRenderSort($sanitzedParams), $this->gridRenderFilter($filter, $sanitzedParams)); + $commands = $this->commandFactory->query( + $this->gridRenderSort($sanitizedParams), + $this->gridRenderFilter($filter, $sanitizedParams) + ); foreach ($commands as $command) { /* @var \Xibo\Entity\Command $command */ - if ($this->isApi($request)) + if ($this->isApi($request)) { continue; + } $command->includeProperty('buttons'); @@ -146,11 +157,14 @@ function grid(Request $request, Response $response) if ($this->getUser()->checkDeleteable($command)) { $command->buttons[] = [ 'id' => 'command_button_delete', - 'url' => $this->urlFor($request,'command.delete.form', ['id' => $command->commandId]), + 'url' => $this->urlFor($request, 'command.delete.form', ['id' => $command->commandId]), 'text' => __('Delete'), 'multi-select' => true, 'dataAttributes' => [ - ['name' => 'commit-url', 'value' => $this->urlFor($request,'command.delete', ['id' => $command->commandId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor($request, 'command.delete', ['id' => $command->commandId]) + ], ['name' => 'commit-method', 'value' => 'delete'], ['name' => 'id', 'value' => 'command_button_delete'], ['name' => 'text', 'value' => __('Delete')], @@ -165,18 +179,36 @@ function grid(Request $request, Response $response) // Permissions button $command->buttons[] = [ 'id' => 'command_button_permissions', - 'url' => $this->urlFor($request,'user.permissions.form', ['entity' => 'Command', 'id' => $command->commandId]), + 'url' => $this->urlFor( + $request, + 'user.permissions.form', + ['entity' => 'Command', 'id' => $command->commandId] + ), 'text' => __('Share'), 'multi-select' => true, 'dataAttributes' => [ - ['name' => 'commit-url', 'value' => $this->urlFor($request,'user.permissions.multi', ['entity' => 'Command', 'id' => $command->commandId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'user.permissions.multi', + ['entity' => 'Command', 'id' => $command->commandId] + ) + ], ['name' => 'commit-method', 'value' => 'post'], ['name' => 'id', 'value' => 'command_button_permissions'], ['name' => 'text', 'value' => __('Share')], ['name' => 'rowtitle', 'value' => $command->command], ['name' => 'sort-group', 'value' => 2], ['name' => 'custom-handler', 'value' => 'XiboMultiSelectPermissionsFormOpen'], - ['name' => 'custom-handler-url', 'value' => $this->urlFor($request,'user.permissions.multi.form', ['entity' => 'Command'])], + [ + 'name' => 'custom-handler-url', + 'value' => $this->urlFor( + $request, + 'user.permissions.multi.form', + ['entity' => 'Command'] + ) + ], ['name' => 'content-id-name', 'value' => 'commandId'] ] ]; diff --git a/lib/Controller/Display.php b/lib/Controller/Display.php index a9ca21892d..3d7f02d12e 100644 --- a/lib/Controller/Display.php +++ b/lib/Controller/Display.php @@ -490,7 +490,7 @@ public function getFilters(SanitizerInterface $parsedQueryParams): array 'clientAddress' => $parsedQueryParams->getString('clientAddress'), 'mediaInventoryStatus' => $parsedQueryParams->getInt('mediaInventoryStatus'), 'loggedIn' => $parsedQueryParams->getInt('loggedIn'), - 'lastAccessed' => ($parsedQueryParams->getDate('lastAccessed') != null) ? $parsedQueryParams->getDate('lastAccessed')->format('U') : null, + 'lastAccessed' => $parsedQueryParams->getDate('lastAccessed')?->format('U'), 'displayGroupIdMembers' => $parsedQueryParams->getInt('displayGroupIdMembers'), 'orientation' => $parsedQueryParams->getString('orientation'), 'commercialLicence' => $parsedQueryParams->getInt('commercialLicence'), @@ -499,7 +499,8 @@ public function getFilters(SanitizerInterface $parsedQueryParams): array 'logicalOperatorName' => $parsedQueryParams->getString('logicalOperatorName'), 'bounds' => $parsedQueryParams->getString('bounds'), 'syncGroupId' => $parsedQueryParams->getInt('syncGroupId'), - 'syncGroupIdMembers' => $parsedQueryParams->getInt('syncGroupIdMembers') + 'syncGroupIdMembers' => $parsedQueryParams->getInt('syncGroupIdMembers'), + 'xmrRegistered' => $parsedQueryParams->getInt('xmrRegistered'), ]; } @@ -638,6 +639,13 @@ public function getFilters(SanitizerInterface $parsedQueryParams): array * type="integer", * required=false * ), + * @SWG\Parameter( + * name="xmrRegistered", + * in="query", + * description="Filter by whether XMR is registed (1 or 0)", + * type="integer", + * required=false + * ), * @SWG\Response( * response=200, * description="successful operation", @@ -656,7 +664,7 @@ public function getFilters(SanitizerInterface $parsedQueryParams): array * @throws NotFoundException * @throws \Xibo\Support\Exception\ControllerNotImplemented */ - function grid(Request $request, Response $response) + public function grid(Request $request, Response $response) { $parsedQueryParams = $this->getSanitizer($request->getQueryParams()); // Embed? @@ -712,7 +720,8 @@ function grid(Request $request, Response $response) continue; } - // use try and catch here to cover scenario when there is no default display profile set for any of the existing display types. + // use try and catch here to cover scenario + // when there is no default display profile set for any of the existing display types. $displayProfileName = ''; try { $defaultDisplayProfile = $this->displayProfileFactory->getDefaultByType($display->clientType); @@ -803,21 +812,21 @@ function grid(Request $request, Response $response) && $this->getUser()->checkEditable($display) ) { // Manage - $display->buttons[] = array( + $display->buttons[] = [ 'id' => 'display_button_manage', 'url' => $this->urlFor($request, 'display.manage', ['id' => $display->displayId]), 'text' => __('Manage'), 'external' => true - ); + ]; $display->buttons[] = ['divider' => true]; // Edit - $display->buttons[] = array( + $display->buttons[] = [ 'id' => 'display_button_edit', 'url' => $this->urlFor($request, 'display.edit.form', ['id' => $display->displayId]), 'text' => __('Edit') - ); + ]; } // Delete @@ -835,7 +844,14 @@ function grid(Request $request, Response $response) if (Environment::isDevMode()) { $deleteButton['multi-select'] = true; $deleteButton['dataAttributes'] = [ - ['name' => 'commit-url', 'value' => $this->urlFor($request, 'display.delete', ['id' => $display->displayId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'display.delete', + ['id' => $display->displayId] + ) + ], ['name' => 'commit-method', 'value' => 'delete'], ['name' => 'id', 'value' => 'display_button_delete'], ['name' => 'sort-group', 'value' => 1], @@ -857,48 +873,73 @@ function grid(Request $request, Response $response) && $this->getUser()->checkEditable($display) ) { // Authorise - $display->buttons[] = array( + $display->buttons[] = [ 'id' => 'display_button_authorise', 'url' => $this->urlFor($request, 'display.authorise.form', ['id' => $display->displayId]), 'text' => __('Authorise'), 'multi-select' => true, - 'dataAttributes' => array( + 'dataAttributes' => [ ['name' => 'auto-submit', 'value' => true], - array('name' => 'commit-url', 'value' => $this->urlFor($request, 'display.authorise', ['id' => $display->displayId])), - array('name' => 'commit-method', 'value' => 'put'), - array('name' => 'id', 'value' => 'display_button_authorise'), - array('name' => 'sort-group', 'value' => 2), - array('name' => 'text', 'value' => __('Toggle Authorise')), - array('name' => 'rowtitle', 'value' => $display->display) - ) - ); + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'display.authorise', + ['id' => $display->displayId] + ) + ], + ['name' => 'commit-method', 'value' => 'put'], + ['name' => 'id', 'value' => 'display_button_authorise'], + ['name' => 'sort-group', 'value' => 2], + ['name' => 'text', 'value' => __('Toggle Authorise')], + ['name' => 'rowtitle', 'value' => $display->display] + ] + ]; // Default Layout - $display->buttons[] = array( + $display->buttons[] = [ 'id' => 'display_button_defaultlayout', 'url' => $this->urlFor($request, 'display.defaultlayout.form', ['id' => $display->displayId]), 'text' => __('Default Layout'), 'multi-select' => true, - 'dataAttributes' => array( - array('name' => 'commit-url', 'value' => $this->urlFor($request, 'display.defaultlayout', ['id' => $display->displayId])), - array('name' => 'commit-method', 'value' => 'put'), - array('name' => 'id', 'value' => 'display_button_defaultlayout'), - array('name' => 'sort-group', 'value' => 2), - array('name' => 'text', 'value' => __('Set Default Layout')), - array('name' => 'rowtitle', 'value' => $display->display), + 'dataAttributes' => [ + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'display.defaultlayout', + ['id' => $display->displayId] + ) + ], + ['name' => 'commit-method', 'value' => 'put'], + ['name' => 'id', 'value' => 'display_button_defaultlayout'], + ['name' => 'sort-group', 'value' => 2], + ['name' => 'text', 'value' => __('Set Default Layout')], + ['name' => 'rowtitle', 'value' => $display->display], ['name' => 'form-callback', 'value' => 'setDefaultMultiSelectFormOpen'] - ) - ); + ] + ]; if ($this->getUser()->featureEnabled('folder.view')) { // Select Folder $display->buttons[] = [ 'id' => 'displaygroup_button_selectfolder', - 'url' => $this->urlFor($request, 'displayGroup.selectfolder.form', ['id' => $display->displayGroupId]), + 'url' => $this->urlFor( + $request, + 'displayGroup.selectfolder.form', + ['id' => $display->displayGroupId] + ), 'text' => __('Select Folder'), 'multi-select' => true, 'dataAttributes' => [ - ['name' => 'commit-url', 'value' => $this->urlFor($request, 'displayGroup.selectfolder', ['id' => $display->displayGroupId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'displayGroup.selectfolder', + ['id' => $display->displayGroupId] + ) + ], ['name' => 'commit-method', 'value' => 'put'], ['name' => 'id', 'value' => 'displaygroup_button_selectfolder'], ['name' => 'sort-group', 'value' => 2], @@ -915,15 +956,22 @@ function grid(Request $request, Response $response) 'url' => $this->urlFor($request, 'display.licencecheck.form', ['id' => $display->displayId]), 'text' => __('Check Licence'), 'multi-select' => true, - 'dataAttributes' => array( + 'dataAttributes' => [ ['name' => 'auto-submit', 'value' => true], - array('name' => 'commit-url', 'value' => $this->urlFor($request, 'display.licencecheck', ['id' => $display->displayId])), - array('name' => 'commit-method', 'value' => 'put'), - array('name' => 'id', 'value' => 'display_button_checkLicence'), - array('name' => 'sort-group', 'value' => 2), - array('name' => 'text', 'value' => __('Check Licence')), - array('name' => 'rowtitle', 'value' => $display->display) - ) + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'display.licencecheck', + ['id' => $display->displayId] + ) + ], + ['name' => 'commit-method', 'value' => 'put'], + ['name' => 'id', 'value' => 'display_button_checkLicence'], + ['name' => 'sort-group', 'value' => 2], + ['name' => 'text', 'value' => __('Check Licence')], + ['name' => 'rowtitle', 'value' => $display->display] + ] ); } @@ -937,7 +985,11 @@ function grid(Request $request, Response $response) ) { $display->buttons[] = array( 'id' => 'display_button_schedule', - 'url' => $this->urlFor($request, 'schedule.add.form', ['id' => $display->displayGroupId, 'from' => 'DisplayGroup']), + 'url' => $this->urlFor( + $request, + 'schedule.add.form', + ['id' => $display->displayGroupId, 'from' => 'DisplayGroup'] + ), 'text' => __('Schedule') ); } @@ -950,7 +1002,8 @@ function grid(Request $request, Response $response) 'id' => 'display_button_layouts_jump', 'linkType' => '_self', 'external' => true, - 'url' => $this->urlFor($request, 'layout.view') . '?activeDisplayGroupId=' . $display->displayGroupId, + 'url' => $this->urlFor($request, 'layout.view') + . '?activeDisplayGroupId=' . $display->displayGroupId, 'text' => __('Jump to Scheduled Layouts') ]; } @@ -970,47 +1023,76 @@ function grid(Request $request, Response $response) ); // Screen Shot - $display->buttons[] = array( + $display->buttons[] = [ 'id' => 'display_button_requestScreenShot', 'url' => $this->urlFor($request, 'display.screenshot.form', ['id' => $display->displayId]), 'text' => __('Request Screen Shot'), 'multi-select' => true, - 'dataAttributes' => array( + 'dataAttributes' => [ ['name' => 'auto-submit', 'value' => true], - array('name' => 'commit-url', 'value' => $this->urlFor($request, 'display.requestscreenshot', ['id' => $display->displayId])), - array('name' => 'commit-method', 'value' => 'put'), - array('name' => 'sort-group', 'value' => 3), - array('name' => 'id', 'value' => 'display_button_requestScreenShot'), - array('name' => 'text', 'value' => __('Request Screen Shot')), - array('name' => 'rowtitle', 'value' => $display->display) - ) - ); + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'display.requestscreenshot', + ['id' => $display->displayId] + ) + ], + ['name' => 'commit-method', 'value' => 'put'], + ['name' => 'sort-group', 'value' => 3], + ['name' => 'id', 'value' => 'display_button_requestScreenShot'], + ['name' => 'text', 'value' => __('Request Screen Shot')], + ['name' => 'rowtitle', 'value' => $display->display] + ] + ]; // Collect Now - $display->buttons[] = array( + $display->buttons[] = [ 'id' => 'display_button_collectNow', - 'url' => $this->urlFor($request, 'displayGroup.collectNow.form', ['id' => $display->displayGroupId]), + 'url' => $this->urlFor( + $request, + 'displayGroup.collectNow.form', + ['id' => $display->displayGroupId] + ), 'text' => __('Collect Now'), 'multi-select' => true, - 'dataAttributes' => array( + 'dataAttributes' => [ ['name' => 'auto-submit', 'value' => true], - array('name' => 'commit-url', 'value' => $this->urlFor($request, 'displayGroup.action.collectNow', ['id' => $display->displayGroupId])), - array('name' => 'commit-method', 'value' => 'post'), - array('name' => 'sort-group', 'value' => 3), - array('name' => 'id', 'value' => 'display_button_collectNow'), - array('name' => 'text', 'value' => __('Collect Now')), - array('name' => 'rowtitle', 'value' => $display->display) - ) - ); + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'displayGroup.action.collectNow', + ['id' => $display->displayGroupId] + ) + ], + ['name' => 'commit-method', 'value' => 'post'], + ['name' => 'sort-group', 'value' => 3], + ['name' => 'id', 'value' => 'display_button_collectNow'], + ['name' => 'text', 'value' => __('Collect Now')], + ['name' => 'rowtitle', 'value' => $display->display] + ] + ]; // Trigger webhook $display->buttons[] = [ 'id' => 'display_button_trigger_webhook', - 'url' => $this->urlFor($request, 'displayGroup.trigger.webhook.form', ['id' => $display->displayGroupId]), + 'url' => $this->urlFor( + $request, + 'displayGroup.trigger.webhook.form', + ['id' => $display->displayGroupId] + ), 'text' => __('Trigger a web hook'), 'multi-select' => true, 'dataAttributes' => [ - ['name' => 'commit-url', 'value' => $this->urlFor($request, 'displayGroup.action.trigger.webhook', ['id' => $display->displayGroupId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'displayGroup.action.trigger.webhook', + ['id' => $display->displayGroupId] + ) + ], ['name' => 'commit-method', 'value' => 'post'], ['name' => 'id', 'value' => 'display_button_trigger_webhook'], ['name' => 'sort-group', 'value' => 3], @@ -1044,18 +1126,36 @@ function grid(Request $request, Response $response) // Permissions $display->buttons[] = [ 'id' => 'display_button_group_permissions', - 'url' => $this->urlFor($request, 'user.permissions.form', ['entity' => 'DisplayGroup', 'id' => $display->displayGroupId]), + 'url' => $this->urlFor( + $request, + 'user.permissions.form', + ['entity' => 'DisplayGroup', 'id' => $display->displayGroupId] + ), 'text' => __('Share'), 'multi-select' => true, 'dataAttributes' => [ - ['name' => 'commit-url', 'value' => $this->urlFor($request, 'user.permissions.multi', ['entity' => 'DisplayGroup', 'id' => $display->displayGroupId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'user.permissions.multi', + ['entity' => 'DisplayGroup', 'id' => $display->displayGroupId] + ) + ], ['name' => 'commit-method', 'value' => 'post'], ['name' => 'id', 'value' => 'display_button_group_permissions'], ['name' => 'text', 'value' => __('Share')], ['name' => 'rowtitle', 'value' => $display->display], ['name' => 'sort-group', 'value' => 4], ['name' => 'custom-handler', 'value' => 'XiboMultiSelectPermissionsFormOpen'], - ['name' => 'custom-handler-url', 'value' => $this->urlFor($request, 'user.permissions.multi.form', ['entity' => 'DisplayGroup'])], + [ + 'name' => 'custom-handler-url', + 'value' => $this->urlFor( + $request, + 'user.permissions.multi.form', + ['entity' => 'DisplayGroup'] + ) + ], ['name' => 'content-id-name', 'value' => 'displayGroupId'] ] ]; @@ -1075,11 +1175,28 @@ function grid(Request $request, Response $response) 'text' => __('Wake on LAN') ); - $display->buttons[] = array( + $display->buttons[] = [ 'id' => 'displaygroup_button_command', 'url' => $this->urlFor($request, 'displayGroup.command.form', ['id' => $display->displayGroupId]), - 'text' => __('Send Command') - ); + 'text' => __('Send Command'), + 'multi-select' => true, + 'dataAttributes' => [ + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'displayGroup.action.command', + ['id' => $display->displayGroupId] + ) + ], + ['name' => 'commit-method', 'value' => 'post'], + ['name' => 'id', 'value' => 'displaygroup_button_command'], + ['name' => 'text', 'value' => __('Send Command')], + ['name' => 'sort-group', 'value' => 3], + ['name' => 'rowtitle', 'value' => $display->display], + ['name' => 'form-callback', 'value' => 'sendCommandMultiSelectFormOpen'] + ] + ]; $display->buttons[] = ['divider' => true]; @@ -1089,7 +1206,14 @@ function grid(Request $request, Response $response) 'text' => __('Transfer to another CMS'), 'multi-select' => true, 'dataAttributes' => [ - ['name' => 'commit-url', 'value' => $this->urlFor($request, 'display.moveCms', ['id' => $display->displayId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'display.moveCms', + ['id' => $display->displayId] + ) + ], ['name' => 'commit-method', 'value' => 'put'], ['name' => 'id', 'value' => 'display_button_move_cms'], ['name' => 'text', 'value' => __('Transfer to another CMS')], @@ -1104,13 +1228,22 @@ function grid(Request $request, Response $response) 'multiSelectOnly' => true, // Show button only on multi-select menu 'id' => 'display_button_set_bandwidth', 'dataAttributes' => [ - ['name' => 'commit-url', 'value' => $this->urlFor($request, 'display.setBandwidthLimitMultiple')], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'display.setBandwidthLimitMultiple' + ) + ], ['name' => 'commit-method', 'value' => 'post'], ['name' => 'id', 'value' => 'display_button_set_bandwidth'], ['name' => 'text', 'value' => __('Set Bandwidth')], ['name' => 'rowtitle', 'value' => $display->display], ['name' => 'custom-handler', 'value' => 'XiboMultiSelectPermissionsFormOpen'], - ['name' => 'custom-handler-url', 'value' => $this->urlFor($request, 'display.setBandwidthLimitMultiple.form')], + [ + 'name' => 'custom-handler-url', + 'value' => $this->urlFor($request, 'display.setBandwidthLimitMultiple.form') + ], ['name' => 'content-id-name', 'value' => 'displayId'] ] ]; @@ -1715,7 +1848,12 @@ function edit(Request $request, Response $response, $id) // Get the display profile and use that to pull in any overrides // start with an empty config - $display->overrideConfig = $this->editConfigFields($display->getDisplayProfile(), $sanitizedParams, [], $display); + $display->overrideConfig = $this->editConfigFields( + $display->getDisplayProfile(), + $sanitizedParams, + [], + $display + ); // Tags are stored on the displaygroup, we're just passing through here if ($this->getUser()->featureEnabled('tag.tagging')) { @@ -1754,8 +1892,11 @@ function edit(Request $request, Response $response, $id) $display->save(); if ($this->isApi($request)) { - $display->lastAccessed = Carbon::createFromTimestamp($display->lastAccessed)->format(DateFormatHelper::getSystemFormat()); - $display->auditingUntil = ($display->auditingUntil == 0) ? 0 : Carbon::createFromTimestamp($display->auditingUntil)->format(DateFormatHelper::getSystemFormat()); + $display->lastAccessed = Carbon::createFromTimestamp($display->lastAccessed) + ->format(DateFormatHelper::getSystemFormat()); + $display->auditingUntil = ($display->auditingUntil == 0) + ? 0 + : Carbon::createFromTimestamp($display->auditingUntil)->format(DateFormatHelper::getSystemFormat()); } // Return @@ -2094,7 +2235,9 @@ public function requestScreenShotForm(Request $request, Response $response, $id) $nextCollect = __('once it has connected for the first time'); } else { $collectionInterval = $display->getSetting('collectInterval', 300); - $nextCollect = Carbon::createFromTimestamp($display->lastAccessed)->addSeconds($collectionInterval)->diffForHumans(); + $nextCollect = Carbon::createFromTimestamp($display->lastAccessed) + ->addSeconds($collectionInterval) + ->diffForHumans(); } $this->getState()->template = 'display-form-request-screenshot'; @@ -2183,7 +2326,10 @@ public function wakeOnLanForm(Request $request, Response $response, $id) } if ($display->macAddress == '') { - throw new InvalidArgumentException(__('This display has no mac address recorded against it yet. Make sure the display is running.'), 'macAddress'); + throw new InvalidArgumentException( + __('This display has no mac address recorded against it yet. Make sure the display is running.'), + 'macAddress' + ); } $this->getState()->template = 'display-form-wakeonlan'; @@ -2232,12 +2378,24 @@ public function wakeOnLan(Request $request, Response $response, $id) } if ($display->macAddress == '' || $display->broadCastAddress == '') { - throw new InvalidArgumentException(__('This display has no mac address recorded against it yet. Make sure the display is running.')); + throw new InvalidArgumentException( + __('This display has no mac address recorded against it yet. Make sure the display is running.') + ); } - $this->getLog()->notice('About to send WOL packet to ' . $display->broadCastAddress . ' with Mac Address ' . $display->macAddress); + $this->getLog()->notice( + 'About to send WOL packet to ' + . $display->broadCastAddress . ' with Mac Address ' . $display->macAddress + ); - WakeOnLan::TransmitWakeOnLan($display->macAddress, $display->secureOn, $display->broadCastAddress, $display->cidr, '9', $this->getLog()); + WakeOnLan::TransmitWakeOnLan( + $display->macAddress, + $display->secureOn, + $display->broadCastAddress, + $display->cidr, + '9', + $this->getLog() + ); $display->lastWakeOnLanCommandSent = Carbon::now()->format('U'); $display->save(['validate' => false]); @@ -2317,21 +2475,30 @@ public function validateDisplays($displays) // check if we are on exception day and if so override the start and endtime accordingly if ($exception['day'] == Carbon::now()->format('D')) { $exceptionsStartTime = explode(':', $exception['start']); - $startTime = Carbon::now()->setTime(intval($exceptionsStartTime[0]), intval($exceptionsStartTime[1])); + $startTime = Carbon::now()->setTime( + intval($exceptionsStartTime[0]), + intval($exceptionsStartTime[1]) + ); $exceptionsEndTime = explode(':', $exception['end']); - $endTime = Carbon::now()->setTime(intval($exceptionsEndTime[0]), intval($exceptionsEndTime[1])); + $endTime = Carbon::now()->setTime( + intval($exceptionsEndTime[0]), + intval($exceptionsEndTime[1]) + ); } } - // check if we are inside the operating hours for this display - we use that flag to decide if we need to create a notification and send an email. + // check if we are inside the operating hours for this display - + // we use that flag to decide if we need to create a notification and send an email. if (($now >= $startTime && $now <= $endTime)) { $operatingHours = true; } else { $operatingHours = false; } } catch (NotFoundException $e) { - $this->getLog()->debug('Unknown dayPartId set on Display Profile for displayId ' . $display->displayId); + $this->getLog()->debug( + 'Unknown dayPartId set on Display Profile for displayId ' . $display->displayId + ); } } @@ -2341,17 +2508,23 @@ public function validateDisplays($displays) // Display just gone offline, or always alert // Fields for email - // for displays without dayPartId set, this is always true, otherwise we check if we are inside the operating hours set for this display + // for displays without dayPartId set, this is always true, + // otherwise we check if we are inside the operating hours set for this display if ($operatingHours) { $subject = sprintf(__('Alert for Display %s'), $display->display); $body = sprintf( __('Display ID %d is offline since %s.'), $display->displayId, - Carbon::createFromTimestamp($display->lastAccessed)->format(DateFormatHelper::getSystemFormat()) + Carbon::createFromTimestamp($display->lastAccessed) + ->format(DateFormatHelper::getSystemFormat()) ); // Add to system - $notification = $this->notificationFactory->createSystemNotification($subject, $body, Carbon::now()); + $notification = $this->notificationFactory->createSystemNotification( + $subject, + $body, + Carbon::now() + ); // Add in any displayNotificationGroups, with permissions foreach ($this->userGroupFactory->getDisplayNotificationGroups($display->displayGroupId) as $group) { diff --git a/lib/Controller/DisplayGroup.php b/lib/Controller/DisplayGroup.php index 24a4407b48..370de447e0 100644 --- a/lib/Controller/DisplayGroup.php +++ b/lib/Controller/DisplayGroup.php @@ -113,8 +113,18 @@ class DisplayGroup extends Base * @param CampaignFactory $campaignFactory * @param FolderFactory $folderFactory */ - public function __construct($playerAction, $displayFactory, $displayGroupFactory, $layoutFactory, $moduleFactory, $mediaFactory, $commandFactory, $tagFactory, $campaignFactory, $folderFactory) - { + public function __construct( + $playerAction, + $displayFactory, + $displayGroupFactory, + $layoutFactory, + $moduleFactory, + $mediaFactory, + $commandFactory, + $tagFactory, + $campaignFactory, + $folderFactory + ) { $this->playerAction = $playerAction; $this->displayFactory = $displayFactory; $this->displayGroupFactory = $displayGroupFactory; @@ -271,7 +281,10 @@ public function grid(Request $request, Response $response) $scheduleWithView = ($this->getConfig()->getSetting('SCHEDULE_WITH_VIEW_PERMISSION') == 1); - $displayGroups = $this->displayGroupFactory->query($this->gridRenderSort($parsedQueryParams), $this->gridRenderFilter($filter, $parsedQueryParams)); + $displayGroups = $this->displayGroupFactory->query( + $this->gridRenderSort($parsedQueryParams), + $this->gridRenderFilter($filter, $parsedQueryParams) + ); foreach ($displayGroups as $group) { /* @var \Xibo\Entity\DisplayGroup $group */ @@ -296,37 +309,52 @@ public function grid(Request $request, Response $response) // Show the edit button, members button if ($group->isDynamic == 0) { // Group Members - $group->buttons[] = array( + $group->buttons[] = [ 'id' => 'displaygroup_button_group_members', - 'url' => $this->urlFor($request,'displayGroup.members.form', ['id' => $group->displayGroupId]), + 'url' => $this->urlFor( + $request, + 'displayGroup.members.form', + ['id' => $group->displayGroupId] + ), 'text' => __('Members') - ); + ]; $group->buttons[] = ['divider' => true]; } // Edit - $group->buttons[] = array( + $group->buttons[] = [ 'id' => 'displaygroup_button_edit', 'url' => $this->urlFor($request, 'displayGroup.edit.form', ['id' => $group->displayGroupId]), 'text' => __('Edit') - ); + ]; - $group->buttons[] = array( + $group->buttons[] = [ 'id' => 'displaygroup_button_copy', 'url' => $this->urlFor($request, 'displayGroup.copy.form', ['id' => $group->displayGroupId]), 'text' => __('Copy') - ); + ]; if ($this->getUser()->featureEnabled('folder.view')) { // Select Folder $group->buttons[] = [ 'id' => 'displaygroup_button_selectfolder', - 'url' => $this->urlFor($request, 'displayGroup.selectfolder.form', ['id' => $group->displayGroupId]), + 'url' => $this->urlFor( + $request, + 'displayGroup.selectfolder.form', + ['id' => $group->displayGroupId] + ), 'text' => __('Select Folder'), 'multi-select' => true, 'dataAttributes' => [ - ['name' => 'commit-url', 'value' => $this->urlFor($request, 'displayGroup.selectfolder', ['id' => $group->displayGroupId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'displayGroup.selectfolder', + ['id' => $group->displayGroupId] + ) + ], ['name' => 'commit-method', 'value' => 'put'], ['name' => 'id', 'value' => 'displaygroup_button_selectfolder'], ['name' => 'text', 'value' => __('Move to Folder')], @@ -347,7 +375,14 @@ public function grid(Request $request, Response $response) 'text' => __('Delete'), 'multi-select' => true, 'dataAttributes' => [ - ['name' => 'commit-url', 'value' => $this->urlFor($request, 'displayGroup.delete', ['id' => $group->displayGroupId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'displayGroup.delete', + ['id' => $group->displayGroupId] + ) + ], ['name' => 'commit-method', 'value' => 'delete'], ['name' => 'id', 'value' => 'displaygroup_button_delete'], ['name' => 'text', 'value' => __('Delete')], @@ -365,18 +400,18 @@ public function grid(Request $request, Response $response) && $this->getUser()->checkEditable($group) ) { // File Associations - $group->buttons[] = array( + $group->buttons[] = [ 'id' => 'displaygroup_button_fileassociations', 'url' => $this->urlFor($request, 'displayGroup.media.form', ['id' => $group->displayGroupId]), 'text' => __('Assign Files') - ); + ]; // Layout Assignments - $group->buttons[] = array( + $group->buttons[] = [ 'id' => 'displaygroup_button_layout_associations', 'url' => $this->urlFor($request, 'displayGroup.layout.form', ['id' => $group->displayGroupId]), 'text' => __('Assign Layouts') - ); + ]; } if ($this->getUser()->featureEnabled('displaygroup.modify') @@ -385,18 +420,36 @@ public function grid(Request $request, Response $response) // Show the modify permissions button $group->buttons[] = [ 'id' => 'displaygroup_button_permissions', - 'url' => $this->urlFor($request, 'user.permissions.form', ['entity' => 'DisplayGroup', 'id' => $group->displayGroupId]), + 'url' => $this->urlFor( + $request, + 'user.permissions.form', + ['entity' => 'DisplayGroup', 'id' => $group->displayGroupId] + ), 'text' => __('Share'), 'multi-select' => true, 'dataAttributes' => [ - ['name' => 'commit-url', 'value' => $this->urlFor($request, 'user.permissions.multi', ['entity' => 'DisplayGroup', 'id' => $group->displayGroupId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'user.permissions.multi', + ['entity' => 'DisplayGroup', 'id' => $group->displayGroupId] + ) + ], ['name' => 'commit-method', 'value' => 'post'], ['name' => 'id', 'value' => 'displaygroup_button_permissions'], ['name' => 'text', 'value' => __('Share')], ['name' => 'rowtitle', 'value' => $group->displayGroup], ['name' => 'sort-group', 'value' => 2], ['name' => 'custom-handler', 'value' => 'XiboMultiSelectPermissionsFormOpen'], - ['name' => 'custom-handler-url', 'value' => $this->urlFor($request, 'user.permissions.multi.form', ['entity' => 'DisplayGroup'])], + [ + 'name' => 'custom-handler-url', + 'value' => $this->urlFor( + $request, + 'user.permissions.multi.form', + ['entity' => 'DisplayGroup'] + ) + ], ['name' => 'content-id-name', 'value' => 'displayGroupId'] ] ]; @@ -407,30 +460,65 @@ public function grid(Request $request, Response $response) ) { $group->buttons[] = ['divider' => true]; - $group->buttons[] = array( + $group->buttons[] = [ 'id' => 'displaygroup_button_command', 'url' => $this->urlFor($request, 'displayGroup.command.form', ['id' => $group->displayGroupId]), - 'text' => __('Send Command') - ); + 'text' => __('Send Command'), + 'multi-select' => true, + 'dataAttributes' => [ + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'displayGroup.action.command', + ['id' => $group->displayGroupId] + ) + ], + ['name' => 'commit-method', 'value' => 'post'], + ['name' => 'id', 'value' => 'displaygroup_button_command'], + ['name' => 'text', 'value' => __('Send Command')], + ['name' => 'sort-group', 'value' => 3], + ['name' => 'rowtitle', 'value' => $group->displayGroup], + ['name' => 'form-callback', 'value' => 'sendCommandMultiSelectFormOpen'] + ] + ]; - $group->buttons[] = array( + $group->buttons[] = [ 'id' => 'displaygroup_button_collectNow', 'url' => $this->urlFor($request, 'displayGroup.collectNow.form', ['id' => $group->displayGroupId]), 'text' => __('Collect Now'), 'dataAttributes' => [ ['name' => 'auto-submit', 'value' => true], - ['name' => 'commit-url', 'value' => $this->urlFor($request, 'displayGroup.action.collectNow', ['id' => $group->displayGroupId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'displayGroup.action.collectNow', + ['id' => $group->displayGroupId] + ) + ], ] - ); + ]; // Trigger webhook $group->buttons[] = [ 'id' => 'displaygroup_button_trigger_webhook', - 'url' => $this->urlFor($request, 'displayGroup.trigger.webhook.form', ['id' => $group->displayGroupId]), + 'url' => $this->urlFor( + $request, + 'displayGroup.trigger.webhook.form', + ['id' => $group->displayGroupId] + ), 'text' => __('Trigger a web hook'), 'multi-select' => true, 'dataAttributes' => [ - ['name' => 'commit-url', 'value' => $this->urlFor($request, 'displayGroup.action.trigger.webhook', ['id' => $group->displayGroupId])], + [ + 'name' => 'commit-url', + 'value' => $this->urlFor( + $request, + 'displayGroup.action.trigger.webhook', + ['id' => $group->displayGroupId] + ) + ], ['name' => 'commit-method', 'value' => 'post'], ['name' => 'id', 'value' => 'displaygroup_button_trigger_webhook'], ['name' => 'text', 'value' => __('Trigger a web hook')], @@ -592,7 +680,8 @@ public function membersForm(Request $request, Response $response, $id) * @SWG\Parameter( * name="dynamicCriteria", * in="formData", - * description="The filter criteria for this dynamic group. A comma separated set of regular expressions to apply", + * description="The filter criteria for this dynamic group. + * A comma separated set of regular expressions to apply", * type="string", * required=false * ), @@ -606,7 +695,8 @@ public function membersForm(Request $request, Response $response, $id) * @SWG\Parameter( * name="dynamicCriteriaTags", * in="formData", - * description="The filter criteria for this dynamic group. A comma separated set of regular expressions to apply", + * description="The filter criteria for this dynamic group. + * A comma separated set of regular expressions to apply", * type="string", * required=false * ), @@ -765,7 +855,8 @@ public function add(Request $request, Response $response) * @SWG\Parameter( * name="dynamicCriteria", * in="formData", - * description="The filter criteria for this dynamic group. A command separated set of regular expressions to apply", + * description="The filter criteria for this dynamic group. + * A command separated set of regular expressions to apply", * type="string", * required=false * ), @@ -779,7 +870,8 @@ public function add(Request $request, Response $response) * @SWG\Parameter( * name="dynamicCriteriaTags", * in="formData", - * description="The filter criteria for this dynamic group. A comma separated set of regular expressions to apply", + * description="The filter criteria for this dynamic group. + * A comma separated set of regular expressions to apply", * type="string", * required=false * ), @@ -861,8 +953,12 @@ public function edit(Request $request,Response $response, $id) $displayGroup->displayGroup = $parsedRequestParams->getString('displayGroup'); $displayGroup->description = $parsedRequestParams->getString('description'); $displayGroup->isDynamic = $parsedRequestParams->getCheckbox('isDynamic'); - $displayGroup->dynamicCriteria = ($displayGroup->isDynamic == 1) ? $parsedRequestParams->getString('dynamicCriteria') : null; - $displayGroup->dynamicCriteriaLogicalOperator = ($displayGroup->isDynamic == 1) ? $parsedRequestParams->getString('logicalOperatorName') : 'OR'; + $displayGroup->dynamicCriteria = ($displayGroup->isDynamic == 1) + ? $parsedRequestParams->getString('dynamicCriteria') + : null; + $displayGroup->dynamicCriteriaLogicalOperator = ($displayGroup->isDynamic == 1) + ? $parsedRequestParams->getString('logicalOperatorName') + : 'OR'; $displayGroup->folderId = $parsedRequestParams->getInt('folderId', ['default' => $displayGroup->folderId]); $displayGroup->ref1 = $parsedRequestParams->getString('ref1'); @@ -887,14 +983,24 @@ public function edit(Request $request,Response $response, $id) } $displayGroup->updateTagLinks($tags); - $displayGroup->dynamicCriteriaTags = ($displayGroup->isDynamic == 1) ? $parsedRequestParams->getString('dynamicCriteriaTags') : null; - $displayGroup->dynamicCriteriaExactTags = ($displayGroup->isDynamic == 1) ? $parsedRequestParams->getCheckbox('exactTags') : 0; - $displayGroup->dynamicCriteriaTagsLogicalOperator = ($displayGroup->isDynamic == 1) ? $parsedRequestParams->getString('logicalOperator') : 'OR'; + $displayGroup->dynamicCriteriaTags = ($displayGroup->isDynamic == 1) + ? $parsedRequestParams->getString('dynamicCriteriaTags') + : null; + $displayGroup->dynamicCriteriaExactTags = ($displayGroup->isDynamic == 1) + ? $parsedRequestParams->getCheckbox('exactTags') + : 0; + $displayGroup->dynamicCriteriaTagsLogicalOperator = ($displayGroup->isDynamic == 1) + ? $parsedRequestParams->getString('logicalOperator') + : 'OR'; } // if we have changed the type from dynamic to non-dynamic or other way around, clear display/dg members if ($preEditIsDynamic != $displayGroup->isDynamic) { - $this->getLog()->debug('Display Group Id ' . $displayGroup->displayGroupId . ' switched is dynamic from ' . $preEditIsDynamic . ' To ' . $displayGroup->isDynamic . ' Clearing members for this Display Group.'); + $this->getLog()->debug( + 'Display Group Id ' . $displayGroup->displayGroupId + . ' switched is dynamic from ' . $preEditIsDynamic + . ' To ' . $displayGroup->isDynamic . ' Clearing members for this Display Group.' + ); // get an array of assigned displays $membersDisplays = $this->displayFactory->getByDisplayGroupId($id); @@ -1032,8 +1138,10 @@ public function assignDisplay(Request $request, Response $response, $id) $sanitizedParams = $this->getSanitizer($request->getParams()); if ($displayGroup->isDisplaySpecific == 1) { - throw new InvalidArgumentException(__('This is a Display specific Display Group and its assignments cannot be modified.'), - 'displayGroupId'); + throw new InvalidArgumentException( + __('This is a Display specific Display Group and its assignments cannot be modified.'), + 'displayGroupId' + ); } if (!$this->getUser()->checkEditable($displayGroup)) { @@ -1041,7 +1149,10 @@ public function assignDisplay(Request $request, Response $response, $id) } if ($displayGroup->isDynamic == 1) { - throw new InvalidArgumentException(__('Displays cannot be manually assigned to a Dynamic Group'), 'isDynamic'); + throw new InvalidArgumentException( + __('Displays cannot be manually assigned to a Dynamic Group'), + 'isDynamic' + ); } $displayGroup->load(); @@ -1070,8 +1181,9 @@ public function assignDisplay(Request $request, Response $response, $id) $displayGroup->assignDisplay($display); // Store so that we can flag as incomplete - if (!in_array($display, $modifiedDisplays)) + if (!in_array($display, $modifiedDisplays)) { $modifiedDisplays[] = $display; + } } // Have we been provided with unassign id's as well? @@ -1092,8 +1204,9 @@ public function assignDisplay(Request $request, Response $response, $id) $displayGroup->unassignDisplay($display); // Store so that we can flag as incomplete - if (!in_array($display, $modifiedDisplays)) + if (!in_array($display, $modifiedDisplays)) { $modifiedDisplays[] = $display; + } } // Save the result @@ -1161,8 +1274,10 @@ public function unassignDisplay(Request $request, Response $response, $id) $sanitizedParams = $this->getSanitizer($request->getParams()); if ($displayGroup->isDisplaySpecific == 1) { - throw new InvalidArgumentException(__('This is a Display specific Display Group and its assignments cannot be modified.'), - 'displayGroupId'); + throw new InvalidArgumentException( + __('This is a Display specific Display Group and its assignments cannot be modified.'), + 'displayGroupId' + ); } $displayGroup->load(); @@ -1173,7 +1288,10 @@ public function unassignDisplay(Request $request, Response $response, $id) } if ($displayGroup->isDynamic == 1) { - throw new InvalidArgumentException(__('Displays cannot be manually unassigned to a Dynamic Group'), 'isDynamic'); + throw new InvalidArgumentException( + __('Displays cannot be manually unassigned to a Dynamic Group'), + 'isDynamic' + ); } $displays = $sanitizedParams->getIntArray('displayId', ['default' => []]); @@ -1256,8 +1374,10 @@ public function assignDisplayGroup(Request $request, Response $response, $id) $sanitizedParams = $this->getSanitizer($request->getParams()); if ($displayGroup->isDisplaySpecific == 1) { - throw new InvalidArgumentException(__('This is a Display specific Display Group and its assignments cannot be modified.'), - 'displayGroupId'); + throw new InvalidArgumentException( + __('This is a Display specific Display Group and its assignments cannot be modified.'), + 'displayGroupId' + ); } $displayGroup->load(); @@ -1268,7 +1388,10 @@ public function assignDisplayGroup(Request $request, Response $response, $id) } if ($displayGroup->isDynamic == 1) { - throw new InvalidArgumentException(__('DisplayGroups cannot be manually assigned to a Dynamic Group'), 'isDynamic'); + throw new InvalidArgumentException( + __('DisplayGroups cannot be manually assigned to a Dynamic Group'), + 'isDynamic' + ); } $displayGroups = $sanitizedParams->getIntArray('displayGroupId', ['default' => []]); @@ -1355,7 +1478,10 @@ public function unassignDisplayGroup(Request $request, Response $response, $id) $sanitizedParams = $this->getSanitizer($request->getParams()); if ($displayGroup->isDisplaySpecific == 1) { - throw new InvalidArgumentException(__('This is a Display specific Display Group and its assignments cannot be modified.'), 'displayGroupId'); + throw new InvalidArgumentException( + __('This is a Display specific Display Group and its assignments cannot be modified.'), + 'displayGroupId' + ); } if (!$this->getUser()->checkEditable($displayGroup)) { @@ -1366,7 +1492,10 @@ public function unassignDisplayGroup(Request $request, Response $response, $id) $this->getDispatcher()->dispatch(new DisplayGroupLoadEvent($displayGroup), DisplayGroupLoadEvent::$NAME); if ($displayGroup->isDynamic == 1) { - throw new InvalidArgumentException(__('DisplayGroups cannot be manually unassigned to a Dynamic Group'), 'isDynamic'); + throw new InvalidArgumentException( + __('DisplayGroups cannot be manually unassigned to a Dynamic Group'), + 'isDynamic' + ); } $displayGroups = $sanitizedParams->getIntArray('displayGroupId', ['default' => []]); @@ -2727,7 +2856,10 @@ public function triggerWebhook(Request $request, Response $response, $id) throw new InvalidArgumentException(__('Please provide a Trigger Code'), 'triggerCode'); } - $this->playerAction->sendAction($this->displayFactory->getByDisplayGroupId($id), new TriggerWebhookAction($triggerCode)); + $this->playerAction->sendAction( + $this->displayFactory->getByDisplayGroupId($id), + new TriggerWebhookAction($triggerCode) + ); // Return $this->getState()->hydrate([ diff --git a/lib/Entity/Schedule.php b/lib/Entity/Schedule.php index 27cdde3166..a846626ba7 100644 --- a/lib/Entity/Schedule.php +++ b/lib/Entity/Schedule.php @@ -464,8 +464,9 @@ public function setOwner($ownerId) */ private function inScheduleLookAhead() { - if ($this->isAlwaysDayPart()) + if ($this->isAlwaysDayPart()) { return true; + } // From Date and To Date are in UNIX format $currentDate = Carbon::now(); @@ -480,7 +481,8 @@ private function inScheduleLookAhead() // A recurring event $this->getLog()->debug('Checking look ahead based on recurrence'); // we should check whether the event from date is before the lookahead (i.e. the event has recurred once) - // we should also check whether the recurrence range is still valid (i.e. we've not stopped recurring and we don't recur forever) + // we should also check whether the recurrence range is still valid + // (i.e. we've not stopped recurring and we don't recur forever) return ( $this->fromDt <= $rfLookAhead->format('U') && ($this->recurrenceRange == 0 || $this->recurrenceRange > $currentDate->format('U')) @@ -492,7 +494,10 @@ private function inScheduleLookAhead() return ($this->fromDt >= $currentDate->format('U') && $this->fromDt <= $rfLookAhead->format('U')); } else { // Compare the event dates - $this->getLog()->debug('Checking look ahead based event dates ' . $currentDate->toRssString() . ' / ' . $rfLookAhead->toRssString()); + $this->getLog()->debug( + 'Checking look ahead based event dates ' + . $currentDate->toRssString() . ' / ' . $rfLookAhead->toRssString() + ); return ($this->fromDt <= $rfLookAhead->format('U') && $this->toDt >= $currentDate->format('U')); } } @@ -509,8 +514,9 @@ public function load($options = []) ], $options); // If we are already loaded, then don't do it again - if ($this->loaded || $this->eventId == null || $this->eventId == 0) + if ($this->loaded || $this->eventId == null || $this->eventId == 0) { return; + } $this->displayGroups = $this->displayGroupFactory->getByEventId($this->eventId); @@ -535,8 +541,9 @@ public function assignDisplayGroup($displayGroup) { $this->load(); - if (!in_array($displayGroup, $this->displayGroups)) + if (!in_array($displayGroup, $this->displayGroups)) { $this->displayGroups[] = $displayGroup; + } } /** @@ -577,6 +584,13 @@ public function validate() throw new InvalidArgumentException(__('The from date is too far in the past.'), 'fromDt'); } + if (!empty($this->name) && strlen($this->name) > 50) { + throw new InvalidArgumentException( + __('Name cannot be longer than 50 characters.'), + 'name' + ); + } + if ($this->eventTypeId == Schedule::$LAYOUT_EVENT || $this->eventTypeId == Schedule::$CAMPAIGN_EVENT || $this->eventTypeId == Schedule::$OVERLAY_EVENT || @@ -591,8 +605,12 @@ public function validate() if ($this->isCustomDayPart()) { // validate the dates - if ($this->toDt <= $this->fromDt) - throw new InvalidArgumentException(__('Can not have an end time earlier than your start time'), 'start/end'); + if ($this->toDt <= $this->fromDt) { + throw new InvalidArgumentException( + __('Can not have an end time earlier than your start time'), + 'start/end' + ); + } } $this->commandId = null; @@ -600,7 +618,10 @@ public function validate() // additional validation for Interrupt Layout event type if ($this->eventTypeId == Schedule::$INTERRUPT_EVENT) { if (!v::intType()->notEmpty()->min(0)->max(3600)->validate($this->shareOfVoice)) { - throw new InvalidArgumentException(__('Share of Voice must be a whole number between 0 and 3600'), 'shareOfVoice'); + throw new InvalidArgumentException( + __('Share of Voice must be a whole number between 0 and 3600'), + 'shareOfVoice' + ); } } @@ -617,7 +638,10 @@ public function validate() } if (!v::stringType()->notEmpty()->validate($this->actionTriggerCode)) { - throw new InvalidArgumentException(__('Please select a Action trigger code for this event.'), 'actionTriggerCode'); + throw new InvalidArgumentException( + __('Please select a Action trigger code for this event.'), + 'actionTriggerCode' + ); } if ($this->actionType === 'command') { @@ -626,7 +650,10 @@ public function validate() } } elseif ($this->actionType === 'navLayout') { if (!v::stringType()->notEmpty()->validate($this->actionLayoutCode)) { - throw new InvalidArgumentException(__('Please select a Layout code for this event.'), 'actionLayoutCode'); + throw new InvalidArgumentException( + __('Please select a Layout code for this event.'), + 'actionLayoutCode' + ); } $this->commandId = null; } @@ -639,7 +666,10 @@ public function validate() if ($this->isCustomDayPart()) { // validate the dates if ($this->toDt <= $this->fromDt) { - throw new InvalidArgumentException(__('Can not have an end time earlier than your start time'), 'start/end'); + throw new InvalidArgumentException( + __('Can not have an end time earlier than your start time'), + 'start/end' + ); } } } else { @@ -649,7 +679,10 @@ public function validate() // Make sure we have a sensible recurrence setting if (!$this->isCustomDayPart() && ($this->recurrenceType == 'Minute' || $this->recurrenceType == 'Hour')) { - throw new InvalidArgumentException(__('Repeats selection is invalid for Always or Daypart events'), 'recurrencyType'); + throw new InvalidArgumentException( + __('Repeats selection is invalid for Always or Daypart events'), + 'recurrencyType' + ); } // Check display order is positive if ($this->displayOrder < 0) { @@ -765,10 +798,16 @@ public function save($options = []) if ($options['notify']) { // Only if the schedule effects the immediate future - i.e. within the RF Look Ahead if ($this->inScheduleLookAhead()) { - $this->getLog()->debug('Schedule changing is within the schedule look ahead, will notify ' . count($this->displayGroups) . ' display groups'); + $this->getLog()->debug( + 'Schedule changing is within the schedule look ahead, will notify ' + . count($this->displayGroups) . ' display groups' + ); foreach ($this->displayGroups as $displayGroup) { /* @var DisplayGroup $displayGroup */ - $this->getDisplayNotifyService()->collectNow()->notifyByDisplayGroupId($displayGroup->displayGroupId); + $this + ->getDisplayNotifyService() + ->collectNow() + ->notifyByDisplayGroupId($displayGroup->displayGroupId); } } else { $this->getLog()->debug('Schedule changing is not within the schedule look ahead'); @@ -820,7 +859,7 @@ public function delete($options = []) } if ($this->eventTypeId === self::$SYNC_EVENT) { - $this->getStore()->update('DELETE FROM `schedule_sync` WHERE eventId = :eventId',[ + $this->getStore()->update('DELETE FROM `schedule_sync` WHERE eventId = :eventId', [ 'eventId' => $this->eventId ]); } @@ -832,10 +871,16 @@ public function delete($options = []) if ($options['notify']) { // Only if the schedule effects the immediate future - i.e. within the RF Look Ahead if ($this->inScheduleLookAhead() && $this->displayNotifyService !== null) { - $this->getLog()->debug('Schedule changing is within the schedule look ahead, will notify ' . count($notify) . ' display groups'); + $this->getLog()->debug( + 'Schedule changing is within the schedule look ahead, will notify ' + . count($notify) . ' display groups' + ); foreach ($notify as $displayGroup) { /* @var DisplayGroup $displayGroup */ - $this->getDisplayNotifyService()->collectNow()->notifyByDisplayGroupId($displayGroup->displayGroupId); + $this + ->getDisplayNotifyService() + ->collectNow() + ->notifyByDisplayGroupId($displayGroup->displayGroupId); } } else if ($this->displayNotifyService === null) { $this->getLog()->info('Notify disabled, dependencies not set'); @@ -1043,15 +1088,18 @@ public function getEvents($fromDt, $toDt) $fromDt = $fromDt->copy(); $toDt = $toDt->copy(); - if ($this->pool == null) + if ($this->pool == null) { throw new ConfigurationException(__('Cache pool not available')); - - if ($this->eventId == null) + } + if ($this->eventId == null) { throw new InvalidArgumentException(__('Unable to generate schedule, unknown event'), 'eventId'); - + } // What if we are requesting a single point in time? if ($fromDt == $toDt) { - $this->log->debug('Requesting event for a single point in time: ' . $fromDt->format(DateFormatHelper::getSystemFormat())); + $this->log->debug( + 'Requesting event for a single point in time: ' + . $fromDt->format(DateFormatHelper::getSystemFormat()) + ); } $events = []; @@ -1062,7 +1110,10 @@ public function getEvents($fromDt, $toDt) $fromDt->startOfMonth(); if ($fromDt == $toDt) { - $this->log->debug('From and To Dates are the same after rewinding 1 month, the date is the 1st of the month, adding a month to toDate.'); + $this->log->debug( + 'From and To Dates are the same after rewinding 1 month, + the date is the 1st of the month, adding a month to toDate.' + ); $toDt->addMonth(); } @@ -1076,7 +1127,10 @@ public function getEvents($fromDt, $toDt) // wind back the generate from date $fromDt->subMonth(); - $this->getLog()->debug('Expecting events from the prior month to spill over into this one, pulled back the generate from dt to ' . $fromDt->toRssString()); + $this->getLog()->debug( + 'Expecting events from the prior month to spill over into this one, + pulled back the generate from dt to ' . $fromDt->toRssString() + ); } else { $this->getLog()->debug('The main event has a start and end date within the month, no need to pull it in from the prior month. [eventId:' . $this->eventId . ']'); } @@ -1086,7 +1140,6 @@ public function getEvents($fromDt, $toDt) // Request month cache while ($fromDt < $toDt) { - // Empty scheduleEvents as we are looping through each month // we dont want to save previous month events $this->scheduleEvents = []; @@ -1094,10 +1147,12 @@ public function getEvents($fromDt, $toDt) // Events for the month. $this->generateMonth($fromDt, $eventStart, $eventEnd); - $this->getLog()->debug('Filtering Events: ' . json_encode($this->scheduleEvents, JSON_PRETTY_PRINT) . '. fromTimeStamp: ' . $fromTimeStamp . ', toTimeStamp: ' . $toTimeStamp); + $this->getLog()->debug( + 'Filtering Events: ' . json_encode($this->scheduleEvents, JSON_PRETTY_PRINT) + . '. fromTimeStamp: ' . $fromTimeStamp . ', toTimeStamp: ' . $toTimeStamp + ); foreach ($this->scheduleEvents as $scheduleEvent) { - // Find the excluded recurring events $exclude = false; foreach ($scheduleExclusions as $exclusion) { @@ -1134,7 +1189,10 @@ public function getEvents($fromDt, $toDt) // Clear our cache of schedule exclusions $scheduleExclusions = null; - $this->getLog()->debug('Filtered ' . count($this->scheduleEvents) . ' to ' . count($events) . ', events: ' . json_encode($events, JSON_PRETTY_PRINT)); + $this->getLog()->debug( + 'Filtered ' . count($this->scheduleEvents) . ' to ' . count($events) + . ', events: ' . json_encode($events, JSON_PRETTY_PRINT) + ); return $events; } @@ -1154,7 +1212,8 @@ private function generateMonth($generateFromDt, $start, $end) $generateFromDt->copy()->startOfMonth(); $generateToDt = $generateFromDt->copy()->addMonth(); - $this->getLog()->debug('Request for schedule events on eventId ' . $this->eventId + $this->getLog()->debug( + 'Request for schedule events on eventId ' . $this->eventId . ' from: ' . Carbon::createFromTimestamp($generateFromDt->format(DateFormatHelper::getSystemFormat())) . ' to: ' . Carbon::createFromTimestamp($generateToDt->format(DateFormatHelper::getSystemFormat())) . ' [eventId:' . $this->eventId . ']' @@ -1171,12 +1230,14 @@ private function generateMonth($generateFromDt, $start, $end) } // If we don't have any recurrence, we are done - if (empty($this->recurrenceType) || empty($this->recurrenceDetail)) + if (empty($this->recurrenceType) || empty($this->recurrenceDetail)) { return; + } // Detect invalid recurrences and quit early - if (!$this->isCustomDayPart() && ($this->recurrenceType == 'Minute' || $this->recurrenceType == 'Hour')) + if (!$this->isCustomDayPart() && ($this->recurrenceType == 'Minute' || $this->recurrenceType == 'Hour')) { return; + } // Check the cache $item = $this->pool->getItem('schedule/' . $this->eventId . '/' . $generateFromDt->format('Y-m')); @@ -1200,14 +1261,19 @@ private function generateMonth($generateFromDt, $start, $end) ? Carbon::createFromTimestamp($this->lastRecurrenceWatermark) : Carbon::createFromTimestamp(self::$DATE_MIN); - $this->getLog()->debug('Recurrence calculation required - last water mark is set to: ' . $lastWatermark->toRssString() - . '. Event dates: ' . $start->toRssString() . ' - ' . $end->toRssString() . ' [eventId:' . $this->eventId . ']'); + $this->getLog()->debug( + 'Recurrence calculation required - last water mark is set to: ' . $lastWatermark->toRssString() + . '. Event dates: ' . $start->toRssString() . ' - ' + . $end->toRssString() . ' [eventId:' . $this->eventId . ']' + ); // Set the temp starts // the start date should be the latest of the event start date and the last recurrence date if ($lastWatermark > $start && $lastWatermark < $generateFromDt) { - $this->getLog()->debug('The last watermark is later than the event start date and the generate from dt, using the watermark for forward population' - . ' [eventId:' . $this->eventId . ']'); + $this->getLog()->debug( + 'The last watermark is later than the event start date and the generate from dt, + using the watermark for forward population [eventId:' . $this->eventId . ']' + ); // Need to set the toDt based on the original event duration and the watermark start date $eventDuration = $start->diffInSeconds($end, true); @@ -1217,7 +1283,7 @@ private function generateMonth($generateFromDt, $start, $end) $end = $start->copy()->addSeconds($eventDuration); if ($start <= $generateToDt && $end >= $generateFromDt) { - $this->getLog()->debug('The event start/end is inside the month' ); + $this->getLog()->debug('The event start/end is inside the month'); // If we're a weekly repeat, check that the start date is on a selected day if ($this->recurrenceType !== 'Week' || (!empty($this->recurrenceRepeatsOn) @@ -1239,17 +1305,21 @@ private function generateMonth($generateFromDt, $start, $end) $range = $generateToDt->copy(); } - $this->getLog()->debug('[' . $generateFromDt->toRssString() . ' - ' . $generateToDt->toRssString() - . '] Looping from ' . $start->toRssString() . ' to ' . $range->toRssString() . ' [eventId:' . $this->eventId . ']'); + $this->getLog()->debug( + '[' . $generateFromDt->toRssString() . ' - ' . $generateToDt->toRssString() + . '] Looping from ' . $start->toRssString() + . ' to ' . $range->toRssString() . ' [eventId:' . $this->eventId . ']' + ); // loop until we have added the recurring events for the schedule - while ($start < $range) - { - $this->getLog()->debug('Loop: ' . $start->toRssString() . ' to ' . $range->toRssString() . ' [eventId:' . $this->eventId . ', end: ' . $end->toRssString() . ']'); + while ($start < $range) { + $this->getLog()->debug( + 'Loop: ' . $start->toRssString() . ' to ' . $range->toRssString() + . ' [eventId:' . $this->eventId . ', end: ' . $end->toRssString() . ']' + ); // add the appropriate time to the start and end - switch ($this->recurrenceType) - { + switch ($this->recurrenceType) { case 'Minute': $start->minute($start->minute + $this->recurrenceDetail); $end->minute($end->minute + $this->recurrenceDetail); @@ -1279,7 +1349,10 @@ private function generateMonth($generateFromDt, $start, $end) // What is the end of this week $endOfWeek = $start->copy()->locale(Translate::GetLocale())->endOfWeek(); - $this->getLog()->debug('Days selected: ' . $this->recurrenceRepeatsOn . '. End of week = ' . $endOfWeek . ' start date ' . $start . ' [eventId:' . $this->eventId . ']'); + $this->getLog()->debug( + 'Days selected: ' . $this->recurrenceRepeatsOn . '. End of week = ' . $endOfWeek + . ' start date ' . $start . ' [eventId:' . $this->eventId . ']' + ); for ($i = 1; $i <= 7; $i++) { // Add a day to the start dates @@ -1304,12 +1377,13 @@ private function generateMonth($generateFromDt, $start, $end) } if ($end > $generateFromDt && $start < $generateToDt) { - $this->getLog()->debug('Adding detail for ' . $start->toAtomString() . ' to ' . $end->toAtomString()); + $this->getLog()->debug( + 'Adding detail for ' . $start->toAtomString() . ' to ' . $end->toAtomString() + ); if ($this->eventTypeId == self::$COMMAND_EVENT) { $this->addDetail($start->format('U'), null); - } - else { + } else { // If we are a daypart event, look up the start/end times for the event $this->calculateDayPartTimes($start, $end); @@ -1320,7 +1394,9 @@ private function generateMonth($generateFromDt, $start, $end) } } - $this->getLog()->debug('Finished 7 day roll forward, start date is ' . $start . ' [eventId:' . $this->eventId . ']'); + $this->getLog()->debug( + 'Finished 7 day roll forward, start date is ' . $start . ' [eventId:' . $this->eventId . ']' + ); // If we haven't passed the end of the week, roll forward if ($start < $endOfWeek) { @@ -1332,7 +1408,9 @@ private function generateMonth($generateFromDt, $start, $end) $start->day($start->day - 7); $end->day($end->day - 7); - $this->getLog()->debug('Resetting start date to ' . $start . ' [eventId:' . $this->eventId . ']'); + $this->getLog()->debug( + 'Resetting start date to ' . $start . ' [eventId:' . $this->eventId . ']' + ); } // Jump forward a week from the original start date (when we entered this loop) @@ -1393,7 +1471,10 @@ private function generateMonth($generateFromDt, $start, $end) // after we have added the appropriate amount, are we still valid if ($start > $range) { - $this->getLog()->debug('Breaking mid loop because we\'ve exceeded the range. Start: ' . $start->toRssString() . ', range: ' . $range->toRssString() . ' [eventId:' . $this->eventId . ']'); + $this->getLog()->debug( + 'Breaking mid loop because we\'ve exceeded the range. Start: ' . $start->toRssString() + . ', range: ' . $range->toRssString() . ' [eventId:' . $this->eventId . ']' + ); break; } @@ -1401,13 +1482,14 @@ private function generateMonth($generateFromDt, $start, $end) $lastWatermark = $start->copy(); // Don't add if we are weekly recurrency (handles it's own adding) - if ($this->recurrenceType == 'Week' && !empty($this->recurrenceRepeatsOn)) + if ($this->recurrenceType == 'Week' && !empty($this->recurrenceRepeatsOn)) { continue; + } if ($start <= $generateToDt && $end >= $generateFromDt) { - if ($this->eventTypeId == self::$COMMAND_EVENT) + if ($this->eventTypeId == self::$COMMAND_EVENT) { $this->addDetail($start->format('U'), null); - else { + } else { // If we are a daypart event, look up the start/end times for the event $this->calculateDayPartTimes($start, $end); @@ -1416,7 +1498,10 @@ private function generateMonth($generateFromDt, $start, $end) } } - $this->getLog()->debug('Our last recurrence watermark is: ' . $lastWatermark->toRssString() . '[eventId:' . $this->eventId . ']'); + $this->getLog()->debug( + 'Our last recurrence watermark is: ' . $lastWatermark->toRssString() + . '[eventId:' . $this->eventId . ']' + ); // Update our schedule with the new last watermark $lastWatermarkTimeStamp = $lastWatermark->format('U'); @@ -1446,8 +1531,9 @@ private function dropEventCache($key = null) { $compKey = 'schedule/' . $this->eventId; - if ($key !== null) + if ($key !== null) { $compKey .= '/' . $key; + } $this->pool->deleteItem($compKey); } @@ -1470,7 +1556,9 @@ private function calculateDayPartTimes($start, $end) // Get the day part $dayPart = $this->getDayPart(); - $this->getLog()->debug('Start and end time for dayPart is ' . $dayPart->startTime . ' - ' . $dayPart->endTime); + $this->getLog()->debug( + 'Start and end time for dayPart is ' . $dayPart->startTime . ' - ' . $dayPart->endTime + ); // What day of the week does this start date represent? // dayOfWeek is 0 for Sunday to 6 for Saturday @@ -1481,10 +1569,14 @@ private function calculateDayPartTimes($start, $end) $start->setTimeFromTimeString($exception['start']); $end->setTimeFromTimeString($exception['end']); - if ($start >= $end) + if ($start >= $end) { $end->addDay(); + } - $this->getLog()->debug('Found exception Start and end time for dayPart exception is ' . $exception['start'] . ' - ' . $exception['end']); + $this->getLog()->debug( + 'Found exception Start and end time for dayPart exception is ' + . $exception['start'] . ' - ' . $exception['end'] + ); $found = true; break; } @@ -1535,7 +1627,9 @@ private function manageAssignments($notify) } if (count($diff) > 0) { - $this->getLog()->debug('manageAssignments: There are ' . count($diff) . ' existing DisplayGroups on this Event'); + $this->getLog()->debug( + 'manageAssignments: There are ' . count($diff) . ' existing DisplayGroups on this Event' + ); $ids = array_map(function ($element) { return $element->getId(); }, $this->displayGroups); @@ -1544,7 +1638,10 @@ private function manageAssignments($notify) if (count($except) > 0) { foreach ($except as $item) { - $this->getLog()->debug('manageAssignments: calling notify on displayGroupId ' . $diff[$item]->getId()); + $this->getLog()->debug( + 'manageAssignments: calling notify on displayGroupId ' + . $diff[$item]->getId() + ); $this->getDisplayNotifyService()->collectNow()->notifyByDisplayGroupId($diff[$item]->getId()); } } else { @@ -1643,21 +1740,19 @@ public function isCustomDayPart() * @throws InvalidArgumentException * @throws NotFoundException */ - public function getNextReminderDate($now, $reminder, $remindSeconds) { - + public function getNextReminderDate($now, $reminder, $remindSeconds) + { // Determine toDt so that we don't getEvents which never ends // adding the recurrencedetail at the end (minute/hour/week) to make sure we get at least 2 next events $toDt = $now->copy(); // For a future event we need to forward now to event fromDt $fromDt = Carbon::createFromTimestamp($this->fromDt); - if ( $fromDt > $toDt ) { + if ($fromDt > $toDt) { $toDt = $fromDt; } - switch ($this->recurrenceType) - { - + switch ($this->recurrenceType) { case 'Minute': $toDt->minute(($toDt->minute + $this->recurrenceDetail) + $this->recurrenceDetail); break; @@ -1689,7 +1784,7 @@ public function getNextReminderDate($now, $reminder, $remindSeconds) { // toDt is set so that we get two next events from now $scheduleEvents = $this->getEvents($now, $toDt); - foreach($scheduleEvents as $event) { + foreach ($scheduleEvents as $event) { if ($reminder->option == ScheduleReminder::$OPTION_BEFORE_START) { $reminderDt = $event->fromDt - $remindSeconds; if ($reminderDt >= $now->format('U')) { @@ -1722,8 +1817,8 @@ public function getNextReminderDate($now, $reminder, $remindSeconds) { * @return string * @throws GeneralException */ - public function getEventTitle() { - + public function getEventTitle() + { // Setting for whether we show Layouts with out permissions $showLayoutName = ($this->config->getSetting('SCHEDULE_SHOW_LAYOUT_NAME') == 1); @@ -1752,8 +1847,9 @@ public function getEventTitle() { // Campaign $campaign = $this->campaignFactory->getById($this->campaignId); - if (!$user->checkViewable($campaign)) + if (!$user->checkViewable($campaign)) { $this->campaign = __('Private Item'); + } } $title = __('%s scheduled on %s', $this->campaign, $displayGroupList); } @@ -1765,30 +1861,30 @@ private function toArray($jsonEncodeArrays = false) { $objectAsJson = $this->jsonSerialize(); - foreach ($objectAsJson as $key => $value) { - $displayGroups = []; - if (is_array($value) && $jsonEncodeArrays) { - if ($key === 'displayGroups') { - foreach($value as $index => $displayGroup) { - /** @var DisplayGroup $displayGroup */ - $displayGroups[$index] = $displayGroup->jsonForAudit(); - } - - $objectAsJson[$key] = json_encode($displayGroups); - } else { - $objectAsJson[$key] = json_encode($value); + foreach ($objectAsJson as $key => $value) { + $displayGroups = []; + if (is_array($value) && $jsonEncodeArrays) { + if ($key === 'displayGroups') { + foreach ($value as $index => $displayGroup) { + /** @var DisplayGroup $displayGroup */ + $displayGroups[$index] = $displayGroup->jsonForAudit(); } - } - if (in_array($key, $this->datesToFormat)) { - $objectAsJson[$key] = Carbon::createFromTimestamp($value)->format(DateFormatHelper::getSystemFormat()); + $objectAsJson[$key] = json_encode($displayGroups); + } else { + $objectAsJson[$key] = json_encode($value); } + } - if ($key === 'campaignId' && isset($this->campaignFactory)) { - $campaign = $this->campaignFactory->getById($value); - $objectAsJson['campaign'] = $campaign->campaign; - } + if (in_array($key, $this->datesToFormat)) { + $objectAsJson[$key] = Carbon::createFromTimestamp($value)->format(DateFormatHelper::getSystemFormat()); + } + + if ($key === 'campaignId' && isset($this->campaignFactory)) { + $campaign = $this->campaignFactory->getById($value); + $objectAsJson['campaign'] = $campaign->campaign; } + } return $objectAsJson; } @@ -1804,40 +1900,50 @@ public function getChangedProperties($jsonEncodeArrays = false) $changedProperties = []; foreach ($this->jsonSerialize() as $key => $value) { - - if (!is_array($value) && !is_object($value) && $this->propertyOriginallyExisted($key) && $this->hasPropertyChanged($key)) { + if (!is_array($value) + && !is_object($value) + && $this->propertyOriginallyExisted($key) + && $this->hasPropertyChanged($key) + ) { if (in_array($key, $this->datesToFormat)) { - $changedProperties[$key] = Carbon::createFromTimestamp($this->getOriginalValue($key))->format(DateFormatHelper::getSystemFormat()) . ' > ' . Carbon::createFromTimestamp($value)->format(DateFormatHelper::getSystemFormat()); + $changedProperties[$key] = Carbon::createFromTimestamp($this->getOriginalValue($key)) + ->format(DateFormatHelper::getSystemFormat()) + . ' > ' . Carbon::createFromTimestamp($value)->format(DateFormatHelper::getSystemFormat()); } else { $changedProperties[$key] = $this->getOriginalValue($key) . ' > ' . $value; if ($key === 'campaignId' && isset($this->campaignFactory)) { $campaign = $this->campaignFactory->getById($value); - $changedProperties['campaign'] = $this->getOriginalValue('campaign') . ' > ' . $campaign->campaign; + $changedProperties['campaign'] = + $this->getOriginalValue('campaign') . ' > ' . $campaign->campaign; } } } - if (is_array($value) && $jsonEncodeArrays && $this->propertyOriginallyExisted($key) && $this->hasPropertyChanged($key)) { + if (is_array($value) + && $jsonEncodeArrays + && $this->propertyOriginallyExisted($key) + && $this->hasPropertyChanged($key) + ) { if ($key === 'displayGroups') { $displayGroups = []; $originalDisplayGroups = []; - foreach($this->getOriginalValue($key) as $index => $displayGroup) { + foreach ($this->getOriginalValue($key) as $index => $displayGroup) { /** @var DisplayGroup $displayGroup */ $originalDisplayGroups[$index] = $displayGroup->jsonForAudit(); } - foreach($value as $index => $displayGroup) { + foreach ($value as $index => $displayGroup) { $displayGroups[$index] = $displayGroup->jsonForAudit(); } - $changedProperties[$key] = json_encode($originalDisplayGroups) . ' > ' . json_encode($displayGroups); - + $changedProperties[$key] = + json_encode($originalDisplayGroups) . ' > ' . json_encode($displayGroups); } else { - $changedProperties[$key] = json_encode($this->getOriginalValue($key)) . ' > ' . json_encode($value); + $changedProperties[$key] = + json_encode($this->getOriginalValue($key)) . ' > ' . json_encode($value); } - } } diff --git a/lib/Factory/CommandFactory.php b/lib/Factory/CommandFactory.php index 6ab668117d..c0be241d11 100644 --- a/lib/Factory/CommandFactory.php +++ b/lib/Factory/CommandFactory.php @@ -1,8 +1,8 @@ getString('command'); } + if ($sanitizedFilter->getString('commandLike') != null) { + $body .= ' AND `command`.command LIKE :commandLike '; + $params['commandLike'] = '%' . $sanitizedFilter->getString('commandLike') . '%'; + } + if ($sanitizedFilter->getString('code') != null) { $body .= ' AND `command`.code = :code '; $params['code'] = $sanitizedFilter->getString('code'); diff --git a/lib/Factory/DisplayFactory.php b/lib/Factory/DisplayFactory.php index 21fa115996..fb389284c7 100644 --- a/lib/Factory/DisplayFactory.php +++ b/lib/Factory/DisplayFactory.php @@ -68,8 +68,15 @@ class DisplayFactory extends BaseFactory * @param DisplayProfileFactory $displayProfileFactory * @param FolderFactory $folderFactory */ - public function __construct($user, $userFactory, $displayNotifyService, $config, $displayGroupFactory, $displayProfileFactory, $folderFactory) - { + public function __construct( + $user, + $userFactory, + $displayNotifyService, + $config, + $displayGroupFactory, + $displayProfileFactory, + $folderFactory + ) { $this->setAclDependencies($user, $userFactory); $this->displayNotifyService = $displayNotifyService; @@ -556,7 +563,16 @@ public function query($sortOrder = null, $filterBy = []) '; $tags = explode(',', $tagFilter); - $this->tagFilter($tags, 'lktagdisplaygroup', 'lkTagDisplayGroupId', 'displayGroupId', $logicalOperator, $operator, $body, $params); + $this->tagFilter( + $tags, + 'lktagdisplaygroup', + 'lkTagDisplayGroupId', + 'displayGroupId', + $logicalOperator, + $operator, + $body, + $params + ); } } @@ -628,7 +644,21 @@ public function query($sortOrder = null, $filterBy = []) $params['syncGroupId'] = $parsedBody->getInt('syncGroupId'); } - $this->viewPermissionSql('Xibo\Entity\DisplayGroup', $body, $params, 'displaygroup.displayGroupId', null, $filterBy, '`displaygroup`.permissionsFolderId'); + if ($parsedBody->getInt('xmrRegistered') === 1) { + $body .= ' AND `display`.xmrChannel IS NOT NULL '; + } else if ($parsedBody->getInt('xmrRegistered') === 0) { + $body .= ' AND `display`.xmrChannel IS NULL '; + } + + $this->viewPermissionSql( + 'Xibo\Entity\DisplayGroup', + $body, + $params, + 'displaygroup.displayGroupId', + null, + $filterBy, + '`displaygroup`.permissionsFolderId' + ); // Sorting? $order = ''; diff --git a/lib/Service/PlayerActionService.php b/lib/Service/PlayerActionService.php index 3bf1765f37..29d88947a1 100644 --- a/lib/Service/PlayerActionService.php +++ b/lib/Service/PlayerActionService.php @@ -1,8 +1,8 @@ triggerPlayerActions) + if (!$this->triggerPlayerActions) { return; + } // XMR network address - if ($this->xmrAddress == null) + if ($this->xmrAddress == null) { $this->xmrAddress = $this->getConfig()->getSetting('XMR_ADDRESS'); + } - if (!is_array($displays)) + if (!is_array($displays)) { $displays = [$displays]; + } // Check ZMQ - if (!Environment::checkZmq()) - throw new ConfigurationException(__('ZeroMQ is required to send Player Actions. Please check your configuration.')); + if (!Environment::checkZmq()) { + throw new ConfigurationException( + __('ZeroMQ is required to send Player Actions. Please check your configuration.') + ); + } - if ($this->xmrAddress == '') + if ($this->xmrAddress == '') { throw new InvalidArgumentException(__('XMR address is not set'), 'xmrAddress'); + } // Send a message to all displays foreach ($displays as $display) { /* @var Display $display */ - if ($display->xmrChannel == '' || $display->xmrPubKey == '') - throw new InvalidArgumentException(__('This Player is not configured or ready to receive push commands over XMR. Please contact your administrator.'), 'xmrRegistered'); + if ($display->xmrChannel == '' || $display->xmrPubKey == '') { + throw new InvalidArgumentException( + sprintf( + __('%s is not configured or ready to receive push commands over XMR. + Please contact your administrator.'), + $display->display + ), + 'xmrRegistered' + ); + } $displayAction = clone $action; try { $displayAction->setIdentity($display->xmrChannel, $display->xmrPubKey); } catch (\Exception $exception) { - throw new InvalidArgumentException(__('Invalid XMR registration'), 'xmrPubKey'); + throw new InvalidArgumentException( + sprintf( + __('%s Invalid XMR registration'), + $display->display + ), + 'xmrPubKey' + ); } // Add to collection @@ -125,15 +145,16 @@ public function getQueue(): array */ public function processQueue() { - if (count($this->actions) > 0) + if (count($this->actions) > 0) { $this->log->debug('Player Action Service is looking to send %d actions', count($this->actions)); - else + } else { return; + } // XMR network address - if ($this->xmrAddress == null) + if ($this->xmrAddress == null) { $this->xmrAddress = $this->getConfig()->getSetting('XMR_ADDRESS'); - + } $failures = 0; foreach ($this->actions as $action) { @@ -144,14 +165,20 @@ public function processQueue() $this->log->error('Player action refused by XMR (connected but XMR returned false).'); $failures++; } - } catch (PlayerActionException $sockEx) { $this->log->error('Player action connection failed. E = ' . $sockEx->getMessage()); $failures++; } } - if ($failures > 0) - throw new ConfigurationException(sprintf(__('%d of %d player actions failed'), $failures, count($this->actions))); + if ($failures > 0) { + throw new ConfigurationException( + sprintf( + __('%d of %d player actions failed'), + $failures, + count($this->actions) + ) + ); + } } } \ No newline at end of file diff --git a/views/authed.twig b/views/authed.twig index 25d455f706..77dfd254ef 100644 --- a/views/authed.twig +++ b/views/authed.twig @@ -822,6 +822,28 @@ }; }); } + + function sendCommandMultiSelectFormOpen(dialog) { + // Inject a list of layouts into the form, in a drop down. + const $commandSelect = $( + '