Skip to content

Commit

Permalink
TR-1693 - sanity fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hilak committed Nov 22, 2017
1 parent 729b8b4 commit 5aa1646
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function doFromObject($dbObject, KalturaDetachedResponseProfile $response
parent::doFromObject($dbObject, $responseProfile);
/* @var $dbObject kEmailNotificationCategoryRecipientProvider */
$categoryIdFieldType = get_class($dbObject->getCategoryId());
KalturaLog::info("Retrieving API object for categoryId fild of type [$categoryIdFieldType]");
KalturaLog::info("Retrieving API object for categoryId field of type [$categoryIdFieldType]");
switch ($categoryIdFieldType)
{
case 'kObjectIdField':
Expand All @@ -95,7 +95,27 @@ public function doFromObject($dbObject, KalturaDetachedResponseProfile $response
{
$this->categoryId->fromObject($dbObject->getCategoryId());
}


$categoryIdsFieldType = get_class($dbObject->getCategoryIds());
KalturaLog::info("Retrieving API object for categoryIds field of type [$categoryIdsFieldType]");
switch ($categoryIdsFieldType)
{
case 'kEvalStringField':
$this->categoryIds = new KalturaEvalStringField();
break;
case 'kStringValue':
$this->categoryIds = new KalturaStringValue();
break;
default:
$this->categoryIds = KalturaPluginManager::loadObject('KalturaStringValue', $categoryIdFieldType);
break;
}

if ($this->categoryIds)
{
$this->categoryIds->fromObject($dbObject->getCategoryIds());
}

if ($dbObject->getCategoryUserFilter())
{
$this->categoryUserFilter = new KalturaCategoryUserProviderFilter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,31 @@ public function setCategoryIds($category_ids) {
/* (non-PHPdoc)
* @see kEmailNotificationRecipientProvider::getScopedProviderJobData()
*/
public function getScopedProviderJobData(kScope $scope = null)
{
$ret = new kEmailNotificationCategoryRecipientJobData();

if(!$this->categoryId)
return $ret;

if ($this->categoryId instanceof kStringField)
$this->categoryId->setScope($scope);
public function getScopedProviderJobData(kScope $scope = null)
{
$ret = new kEmailNotificationCategoryRecipientJobData();

if (!$this->categoryId && !$this->categoryIds)
{
return $ret;
}

$implicitCategoryId = null;
if ($this->categoryId && $this->categoryId instanceof kStringField)
{
$this->categoryId->setScope($scope);
$implicitCategoryId = $this->categoryId->getValue();
}

$implicitCategoryIds = null;
if ($this->categoryIds && $this->categoryIds instanceof kStringField)
{

if ($this->categoryIds instanceof kStringField)
$this->categoryIds->setScope($scope);

$implicitCategoryId = $this->categoryId->getValue();
$implicitCategoryIds = $this->categoryIds->getValue();
$implicitCategoryIds = $this->categoryIds->getValue();
}

if ($implicitCategoryIds)
if ($implicitCategoryIds && $implicitCategoryId)
{
$implicitCategoryIds .= ",$implicitCategoryId";
}
Expand Down
81 changes: 81 additions & 0 deletions tests/standAloneClient/entryReadyInChannel.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<xml>
<config>
<serviceUrl>http://{prompt:Host name:}/</serviceUrl>
<partnerId>-2</partnerId>
<clientTag>Stand alone php 1.0.0</clientTag>
<curlTimeout>30</curlTimeout>
<userAgent>Stand alone php 1.0.0</userAgent>
</config>
<session>
<!-- script will ask for username / password interactively -->
</session>
<multirequest>
<!-- Entry Ready -->
<request service="eventNotificationTemplate" action="add" plugin="eventNotification" partnerId="0">
<template objectType="KalturaEmailNotificationTemplate">
<name>Entry Ready In Category</name>
<systemName>Entry_Ready_In_Category</systemName>
<description>Email notification template to be sent to all category subscribers of categories the entry belongs <to></to> when a new entry is ready.</description>
<automaticDispatchEnabled>1</automaticDispatchEnabled>
<eventType>3</eventType> <!-- EventNotificationEventType::OBJECT_CHANGED -->
<eventObjectType>1</eventObjectType> <!-- EventNotificationEventObjectType::ENTRY -->
<eventConditions objectType="array">
<item objectType="KalturaEventFieldCondition">
<description>Status changed to ready, See:KalturaEntryStatus:/api_v3/testmeDoc/?object=KalturaEntryStatus</description>
<field objectType="KalturaEvalBooleanField">
<code>$scope->getObject() instanceof entry &amp;&amp; in_array(entryPeer::STATUS, $scope->getEvent()->getModifiedColumns()) &amp;&amp; $scope->getObject()->getStatus() == entryStatus::READY</code>
</field>
</item>
</eventConditions>
<format>1</format>
<subject>[AppTitle] - Your video is ready to be played</subject>
<body>Your recently uploaded media: {entry_name} is ready to play: [AppEntryUrl]{entry_id}</body>
<fromEmail>{from_email}</fromEmail>
<fromName>{from_name}</fromName>
<bcc objectType="KalturaEmailNotificationCategoryRecipientProvider">
<categoryIds objectType="KalturaEvalStringField">
<code>implode(',', $scope->getObject()->getAllCategoriesIds())</code>
</categoryIds>
<categoryUserFilter objectType="KalturaCategoryUserProviderFilter">
<permissionNamesMatchOr>CATEGORY_MODERATE</permissionNamesMatchOr>
</categoryUserFilter>
</bcc>
<contentParameters objectType="array">
<item objectType="KalturaEventNotificationParameter">
<key>from_email</key>
<description>Server configuration: partner_notification_email</description>
<value objectType="KalturaEvalStringField">
<code>kConf::get("partner_notification_email")</code>
</value>
</item>
<item objectType="KalturaEventNotificationParameter">
<key>from_name</key>
<description>Server configuration: partner_notification_name</description>
<value objectType="KalturaEvalStringField">
<code>kConf::get("partner_notification_name")</code>
</value>
</item>
<item objectType="KalturaEventNotificationParameter">
<key>entry_name</key>
<description>Entry name</description>
<value objectType="KalturaEvalStringField">
<code>$scope->getObject()->getName()</code>
</value>
</item>
<item objectType="KalturaEventNotificationParameter">
<key>entry_id</key>
<description>Entry ID</description>
<value objectType="KalturaEvalStringField">
<code>$scope->getObject()->getId()</code>
</value>
</item>
</contentParameters>
</template>
</request>
<request service="eventNotificationTemplate" action="updateStatus" plugin="eventNotification" partnerId="0">
<id>{1:result:id}</id>
<status>1</status><!-- EventNotificationTemplateStatus::DISABLED -->
</request>
</multirequest>
</xml>

0 comments on commit 5aa1646

Please sign in to comment.