From b314d386c4081d8100668d605e74cb2a3f8698e7 Mon Sep 17 00:00:00 2001 From: yossipapi Date: Wed, 25 Dec 2024 13:07:52 +0200 Subject: [PATCH] REACH2-1285: Support excluding entries from reach based on entry admin tags --- .../admin/forms/CatalogItemConfigure.php | 6 +++++ .../KalturaVendorCatalogItem.php | 6 +++++ plugins/reach/lib/kReachManager.php | 8 +++++++ plugins/reach/lib/model/VendorCatalogItem.php | 22 +++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/plugins/reach/admin/forms/CatalogItemConfigure.php b/plugins/reach/admin/forms/CatalogItemConfigure.php index dc41d57180..afc7a75cb7 100644 --- a/plugins/reach/admin/forms/CatalogItemConfigure.php +++ b/plugins/reach/admin/forms/CatalogItemConfigure.php @@ -204,6 +204,12 @@ public function init() 'filters' => array('StringTrim'), 'placement' => 'prepend', )); + + $this->addElement('text', 'adminTagsToExclude', array( + 'label' => 'Admin tags to exclude:', + 'filters' => array('StringTrim'), + 'placement' => 'prepend', + )); $liveCatalogItemTypesArray = array(Kaltura_Client_Reach_Enum_VendorServiceFeature::LIVE_CAPTION, Kaltura_Client_Reach_Enum_VendorServiceFeature::LIVE_TRANSLATION); if (in_array($this->catalogItemType, $liveCatalogItemTypesArray)) diff --git a/plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorCatalogItem.php b/plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorCatalogItem.php index 4632fa3605..9ea0ddd63b 100644 --- a/plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorCatalogItem.php +++ b/plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorCatalogItem.php @@ -126,6 +126,11 @@ abstract class KalturaVendorCatalogItem extends KalturaObject implements IRelate * @var int */ public $partnerId; + + /** + * @var string + */ + public $adminTagsToExclude; private static $map_between_objects = array ( @@ -149,6 +154,7 @@ abstract class KalturaVendorCatalogItem extends KalturaObject implements IRelate 'contract', 'createdBy', 'notes', + 'adminTagsToExclude', ); abstract protected function getServiceFeature(); diff --git a/plugins/reach/lib/kReachManager.php b/plugins/reach/lib/kReachManager.php index 266538912b..8fdb940b10 100644 --- a/plugins/reach/lib/kReachManager.php +++ b/plugins/reach/lib/kReachManager.php @@ -738,12 +738,20 @@ public static function addEntryVendorTaskByObjectIds(entry $entry, VendorCatalog public static function addEntryVendorTask(entry $entry, ReachProfile $reachProfile, VendorCatalogItem $vendorCatalogItem, $validateModeration = true, $version = 0, $context = null, $creationMode = EntryVendorTaskCreationMode::MANUAL, $taskDuration = null) { + //Check if the entry is temporary, if so, dont create the task if($entry->getIsTemporary()) { KalturaLog::debug("Entry [{$entry->getId()}] is temporary, entry vendor task object wont be created for it"); return null; } + //Check if static content and the catalog item is excluding static content, if so, dont create the task + if(count($vendorCatalogItem->getAdminTagsToExcludeArray()) && array_intersect($vendorCatalogItem->getAdminTagsToExcludeArray(), $entry->getAdminTagsArr())) + { + KalturaLog::debug("Entry [{$entry->getId()}] has admin tags that are excluded by the catalog item, entry vendor task object wont be created for it"); + return null; + } + //Create new entry vendor task object $entryVendorTask = new EntryVendorTask(); diff --git a/plugins/reach/lib/model/VendorCatalogItem.php b/plugins/reach/lib/model/VendorCatalogItem.php index 1df1480b5b..4a25dacbae 100644 --- a/plugins/reach/lib/model/VendorCatalogItem.php +++ b/plugins/reach/lib/model/VendorCatalogItem.php @@ -47,6 +47,7 @@ public function applyDefaultValues() const CUSTOM_DATA_CONTRACT = 'contract'; const CUSTOM_DATA_CREATED_BY = 'createdBy'; const CUSTOM_DATA_NOTES = 'notes'; + const CUSTOM_ADMIN_TAGS_TO_EXCLUDE = 'admin_tags_to_exclude'; public function setAllowResubmission($allowResubmission) { @@ -354,6 +355,27 @@ public function getNotes() { return $this->getFromCustomData(self::CUSTOM_DATA_NOTES); } + + public function setAdminTagsToExclude($v) + { + $this->putInCustomData(self::CUSTOM_ADMIN_TAGS_TO_EXCLUDE, $v); + } + + public function getAdminTagsToExclude() + { + return $this->getFromCustomData(self::CUSTOM_ADMIN_TAGS_TO_EXCLUDE); + } + + public function getAdminTagsToExcludeArray() + { + $adminTagsToExclude = $this->getFromCustomData(self::CUSTOM_ADMIN_TAGS_TO_EXCLUDE); + if(!$adminTagsToExclude) + { + return array(); + } + + return array_map("trim", explode(',', $adminTagsToExclude)); + } public function isEntryDurationExceeding(entry $entry) {