From 9582ad31f6fcaa715abffa770377f210f631139c Mon Sep 17 00:00:00 2001 From: Dan Garner Date: Mon, 14 Aug 2023 11:32:52 +0100 Subject: [PATCH] SSP: add SSP widget. --- lib/Connector/XiboSspConnector.php | 35 +++++++++++++++++++++++++ modules/ssp.xml | 41 ++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 modules/ssp.xml diff --git a/lib/Connector/XiboSspConnector.php b/lib/Connector/XiboSspConnector.php index 99589fb07b..45b109e03c 100644 --- a/lib/Connector/XiboSspConnector.php +++ b/lib/Connector/XiboSspConnector.php @@ -29,8 +29,10 @@ use Xibo\Event\ConnectorDeletingEvent; use Xibo\Event\ConnectorEnabledChangeEvent; use Xibo\Event\MaintenanceRegularEvent; +use Xibo\Event\WidgetEditOptionRequestEvent; use Xibo\Support\Exception\GeneralException; use Xibo\Support\Exception\InvalidArgumentException; +use Xibo\Support\Exception\NotFoundException; use Xibo\Support\Sanitizer\SanitizerInterface; class XiboSspConnector implements ConnectorInterface @@ -61,6 +63,7 @@ public function registerWithDispatcher(EventDispatcherInterface $dispatcher): Co $dispatcher->addListener(MaintenanceRegularEvent::$NAME, [$this, 'onRegularMaintenance']); $dispatcher->addListener(ConnectorDeletingEvent::$NAME, [$this, 'onDeleting']); $dispatcher->addListener(ConnectorEnabledChangeEvent::$NAME, [$this, 'onEnabledChange']); + $dispatcher->addListener(WidgetEditOptionRequestEvent::$NAME, [$this, 'onWidgetEditOption']); return $this; } @@ -500,5 +503,37 @@ public function onEnabledChange(ConnectorEnabledChangeEvent $event) $event->getConfigService()->changeSetting('isAdspaceEnabled', $event->getConnector()->isEnabled); } + public function onWidgetEditOption(WidgetEditOptionRequestEvent $event) + { + $this->getLogger()->debug('onWidgetEditOption'); + + // Pull the widget we're working with. + $widget = $event->getWidget(); + if ($widget === null) { + throw new NotFoundException(); + } + + // We handle the dashboard widget and the property with id="type" + if ($widget->type === 'ssp' && $event->getPropertyId() === 'partnerId') { + // Pull in existing information + $partnerFilter = $event->getPropertyValue(); + $options = $event->getOptions(); + + foreach ($this->getAvailablePartners() as $partnerId => $partner) { + if ((empty($partnerFilter) || $partnerId === $partnerFilter) + && $this->getPartnerSetting($partnerId, 'enabled') == 1 + ) { + $options[] = [ + 'id' => $partnerId, + 'type' => $partnerId, + 'name' => $partner['name'], + ]; + } + } + + $event->setOptions($options); + } + } + // } diff --git a/modules/ssp.xml b/modules/ssp.xml new file mode 100644 index 0000000000..472101f780 --- /dev/null +++ b/modules/ssp.xml @@ -0,0 +1,41 @@ + + + core-ssp + SSP + Core + Manually schedule SSP content from the SSP connector via select partners. + ssp + + 1 + 1 + 1 + native + 10 + + + + Partner + Choose from the partners that support this type of scheduling. + + + + \ No newline at end of file