Skip to content

Commit

Permalink
Merge pull request #8659 from kaltura/master-merge-Orion-15.3.0
Browse files Browse the repository at this point in the history
Master merge orion 15.3.0
  • Loading branch information
MosheMaorKaltura authored Jul 22, 2019
2 parents 32ce52b + edf326b commit 8e46a5a
Show file tree
Hide file tree
Showing 110 changed files with 2,945 additions and 252 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Orion-15.2.0
Orion-15.3.0
3 changes: 3 additions & 0 deletions admin_console/configs/lang/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@
'Kaltura_Client_ContentDistribution_Enum_DistributionProfileStatus::ENABLED' => 'Enabled',
'Kaltura_Client_ContentDistribution_Enum_DistributionProfileStatus::DISABLED' => 'Disabled',

'Kaltura_Client_ContentDistribution_Enum_DistributeTrigger::ENTRY_READY' => 'On entry ready',
'Kaltura_Client_ContentDistribution_Enum_DistributeTrigger::MODERATION_APPROVED' => 'On moderation approved',

'init client failed' => 'Could not initiate the Kaltura client',
'entry not found' => 'Entry not found',
'partner not found' => 'Publisher not found',
Expand Down
30 changes: 18 additions & 12 deletions admin_console/controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,28 @@ public function loginAction()

$adapter->setTimezoneOffset($request->getPost('timezone_offset'));
$auth = Infra_AuthHelper::getAuthInstance();
$result = $auth->authenticate($adapter);

if ($result->isValid())
try
{
if ($request->getPost('remember_me'))
Zend_Session::rememberMe(60*60*24*7); // 1 week

$nextUri = $this->_getParam('next_uri');
if ($nextUri)
$this->_helper->redirector->gotoUrl($nextUri);
$result = $auth->authenticate($adapter);
if ($result->isValid())
{
if ($request->getPost('remember_me'))
Zend_Session::rememberMe(60 * 60 * 24 * 7); // 1 week

$nextUri = $this->_getParam('next_uri');
if ($nextUri)
$this->_helper->redirector->gotoUrl($nextUri);
else
$this->_helper->redirector('list', 'partner');
}
else
$this->_helper->redirector('list', 'partner');
{
$loginForm->setDescription('login error');
}
}
else
catch (Exception $ex)
{
$loginForm->setDescription('login error');
$loginForm->setDescription('login error ' . $ex->getMessage());
}
}

Expand Down
7 changes: 6 additions & 1 deletion admin_console/forms/PartnerConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ public function init()
'label' => 'Notification Configuration:',
'filters' => array('StringTrim'),
));

$this->addElement('text', 'allowed_from_email_white_list', array(
'label' => 'Allowed From Email WhiteList Notifications:',
'filters' => array('StringTrim'),
));

$this->addElement('checkbox', 'allow_multi_notification', array(
'label' => 'Allow multi-notifications',
Expand Down Expand Up @@ -926,7 +931,7 @@ public function addAllDisplayGroups($permissionNames)
$this->addDisplayGroup(array_merge(array('delivery_profile_ids', 'live_delivery_profile_ids', 'deliveryFormat', 'delivery_profile_type', 'editDeliveryProfiles', 'enforce_delivery', 'checkbox_host', 'host', 'checkbox_cdn_host', 'cdn_host', 'checkbox_thumbnail_host', 'thumbnail_host', 'checkbox_cache_flavor_version', 'cache_flavor_version', 'support_animated_thumbnails'), $permissionNames[self::GROUP_PUBLISHER_DELIVERY_SETTINGS], array ('crossLine')), 'publisherSpecificDeliverySettings', array('legend' => 'Publisher Specific Delivery Settings'));
$this->addDisplayGroup(array_merge(array('storage_serve_priority', 'storage_delete_from_kaltura','import_remote_source_for_convert'), $permissionNames[self::GROUP_REMOTE_STORAGE] ,array('crossLine')), 'remoteStorageAccountPolicy', array('legend' => 'Remote Storage Policy'));

$this->addDisplayGroup(array_merge(array('notifications_config', 'allow_multi_notification'), $permissionNames[self::GROUP_NOTIFICATION_CONFIG] ,array('crossLine')), 'advancedNotificationSettings', array('legend' => 'Advanced Notification Settings'));
$this->addDisplayGroup(array_merge(array('notifications_config', 'allowed_from_email_white_list', 'allow_multi_notification'), $permissionNames[self::GROUP_NOTIFICATION_CONFIG] ,array('crossLine')), 'advancedNotificationSettings', array('legend' => 'Advanced Notification Settings'));
$this->addDisplayGroup(array_merge(array('def_thumb_offset','def_thumb_density') , $permissionNames[self::GROUP_CONTENT_INGESTION_OPTIONS], array('enable_bulk_upload_notifications_emails', 'bulk_upload_notifications_email', 'crossLine')), 'publisherSpecificIngestionSettings', array('legend' => 'Content Ingestion Options'));
$this->addDisplayGroup(array('logout_url', 'crossLine'), 'signSignOn', array('legend' => 'Sign Sign On'));
$this->addDisplayGroup(array_merge(array('api_access_control_id', 'restrict_entry_by_metadata'), $permissionNames[self::GROUP_ACCESS_CONTROL], array('crossLine')), 'apiAccessControlIdGroup', array('legend' => 'Access Control'));
Expand Down
5 changes: 3 additions & 2 deletions alpha/apps/kaltura/lib/kManifestRenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,9 @@ final public function output()
$this->applyDomainPrefix();

$headers = $this->getHeaders();
$headers[] = "Access-Control-Allow-Origin:*";
$headers[] = "Access-Control-Expose-Headers: Server,range,Content-Length,Content-Range";
$headers[] = 'Access-Control-Allow-Origin:*';
$headers[] = 'Access-Control-Expose-Headers: Server,range,Content-Length,Content-Range';
$headers[] = 'Timing-Allow-Origin:*';
foreach ($headers as $header)
{
if ($this->deliveryCode)
Expand Down
18 changes: 14 additions & 4 deletions alpha/apps/kaltura/lib/kResourceReservation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,33 @@
class kResourceReservation
{
/**
* @var ResourceReservation $resourceReservator
* @var BinaryResourceReservation $resourceReservator
*/
private $resourceReservator;

function __construct($ttl = null)
function __construct($ttl = null, $binaryReservator = false)
{
$cache = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_RESOURCE_RESERVATION);
$ks = kCurrentContext::$ks;
if (!$ttl)
{
$ttl = kConf::get('ResourceReservationDuration');
$this->resourceReservator = new ResourceReservation($cache, $ttl, $ks);
}

if($binaryReservator)
{
$this->resourceReservator = new BinaryResourceReservation($cache, $ttl, $ks);
}
else
{
$this->resourceReservator = new ResourceReservation($cache, $ttl, $ks);
}
}


/**
* will reserve the resource for some time
* @param string $resourceId
*
* @return bool - true if reserve and false if could not
*/
public function reserve($resourceId)
Expand All @@ -30,6 +39,7 @@ public function reserve($resourceId)
KalturaLog::info("Resource reservation was done successfully for resource id [$resourceId]");
return true;
}

KalturaLog::info("Could not reserve resource id [$resourceId]");
return false;
}
Expand Down
153 changes: 149 additions & 4 deletions alpha/apps/kaltura/lib/myPlaylistUtils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,30 @@ class myPlaylistUtils
const CAPTION_FILES_LABEL = "label";
const CAPTION_FILES_PATH = "path";
const CAPTION_FILES_ID = "captionId";
const KALTURA_CLASS = 'kalturaClass';

private static $user_cache = null;

private static $isAdminKs = false;

private static $playlistContext;


private static $moderationStatusesNotIn = array(
entry::ENTRY_MODERATION_STATUS_PENDING_MODERATION,
entry::ENTRY_MODERATION_STATUS_REJECTED
);

private static $dates = array(
'_lteornull_start_date',
'_gteornull_start_date',
'_lte_start_date',
'_gte_start_date',
'_lteornull_end_date',
'_gteornull_end_date',
'_lte_end_date',
'_gte_end_date'
);

public static function setIsAdminKs($v)
{
self::$isAdminKs = $v;
Expand Down Expand Up @@ -483,11 +500,139 @@ public static function getDynamicPlaylistFilters($xml)
}
return $entry_filters;
}

public static function executeDynamicPlaylist ( $partner_id , $xml , $filter = null ,$detailed = true, $pager = null )

public static function getEntryFiltersFromXml($listOfFilters, $partnerId)
{
if (!$listOfFilters)
{
return null;
}
return self::fillEntryFilterFromXml($listOfFilters, $partnerId);
}

//splitting entry filters into filters that will run in Esearch and in Sphinx:
// Elastic - advancesSearch is not set OR advancesSearch is set and includes KalturaMetadataSearchItem
// Sphinx - advancesSearch is set and NOT including KalturaMetadataSearchItem
public static function splitEntryFilters($xml)
{
$entryFiltersViaEsearch = array();
$entryFiltersViaSphinx = array();
list ($totalResults, $entryFilters) = self::getPlaylistFilterListStruct($xml);
foreach ($entryFilters as $entryFilter)
{
if (!isset($entryFilter->advancedSearch) ||
( isset($entryFilter->advancedSearch) && (string)$entryFilter->advancedSearch[self::KALTURA_CLASS] === PlaylistService::KALTURA_METADATA_SEARCH_ITEM))
{
$entryFiltersViaEsearch[] = $entryFilter;
}
else
{
$entryFiltersViaSphinx[] = $entryFilter;
}
}
return array($entryFiltersViaEsearch, $entryFiltersViaSphinx, $totalResults);
}

public static function executeDynamicPlaylistViaEsearch ($entryFilters ,$totalResults, $pager = null)
{
$entryKPager = new kPager();
if ($pager)
{
$pager->toObject($entryKPager);
}
$entryQueryToFilterESearch = new ESearchEntryQueryFromFilter();
$entryIds= array();
foreach ($entryFilters as $entryFilter)
{
list ($currEntryIds, $count) = $entryQueryToFilterESearch->retrieveElasticQueryEntryIds($entryFilter, $entryKPager);
$entryIds = self::mergeEntriesByLimit($entryIds, $currEntryIds, $entryFilter->getLimit(),$totalResults);
$totalResults = max (0, $totalResults - count($entryIds));
if ( $totalResults === 0 )
{
break;
}
}
return array(self::getEntriesSorted($entryIds), $totalResults);
}

protected static function getEntriesSorted($entryIds)
{
$entryIds = array_unique($entryIds);
$entryIdsOrder = array_flip($entryIds);
$entries = entryPeer::retrieveByPKs($entryIds);
usort($entries, self::buildSorter($entryIdsOrder));
return $entries;
}

protected static function mergeEntriesByLimit($entryIds, $currEntryIds, $limit, $totalResults)
{
if ($totalResults < $limit)
{
$limit = $totalResults;
}
if (count($currEntryIds) > $limit)
{
$currEntryIds = array_slice($currEntryIds,0, $limit);
}
return array_merge ($entryIds, $currEntryIds);
}

protected static function buildSorter($objectsOrder)
{
return function ($a, $b) use ($objectsOrder)
{
return ($objectsOrder[$a->getId()] - $objectsOrder[$b->getId()]);
};
}

protected static function fillEntryFilterFromXml($listOfFilters, $partnerId)
{
$entryFilters = array();
foreach ($listOfFilters as $filter)
{
self::replaceContextTokens($filter);
$entryFilter = new entryFilter();
$entryFilter->fillObjectFromXml($filter, '_');
self::updateEntryFilterFields($entryFilter, $partnerId);
$entryFilters[] = $entryFilter;
}
return $entryFilters;
}

protected static function updateEntryFilterFields($entryFilter, $partnerId)
{
self::updateEntryFilter($entryFilter, $partnerId);
$typeArray = array (entryType::MEDIA_CLIP, entryType::MIX, entryType::LIVE_STREAM );
$typeArray = array_merge($typeArray, KalturaPluginManager::getExtendedTypes(entryPeer::OM_CLASS, entryType::MEDIA_CLIP));
$typeArray = array_unique(array_merge($typeArray, KalturaPluginManager::getExtendedTypes(entryPeer::OM_CLASS, entryType::LIVE_STREAM)));
$entryFilter->setTypeIn($typeArray);
$entryFilter->setStatusEquel(entryStatus::READY);
$entryFilter->setModerationStatusNotIn(self::$moderationStatusesNotIn);
if (self::$isAdminKs)
{
self::unsetDates($entryFilter);
}
}

protected static function unsetDates($filter)
{
foreach (self::$dates as $date)
{
if ($filter->is_set($date))
{
$filter->unsetByName($date);
}
}
}

public static function executeDynamicPlaylist ( $partner_id, $xml, $filter = null, $detailed = true, $pager = null )
{
list ( $total_results , $list_of_filters ) = self::getPlaylistFilterListStruct ( $xml );

return self::executeDynamicPlaylistFromFilters($total_results, $list_of_filters, $partner_id, $filter , $detailed, $pager);
}

public static function executeDynamicPlaylistFromFilters($total_results, $list_of_filters, $partner_id, $filter = null, $detailed = true, $pager = null)
{
$entry_filters = array();

if ( ! $list_of_filters ) return null;
Expand Down
2 changes: 2 additions & 0 deletions alpha/lib/enums/PermissionName.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,6 @@ interface PermissionName extends BaseEnum

const FEATURE_ANALYTICS_PERSISTENT_SESSION_ID = 'FEATURE_ANALYTICS_PERSISTENT_SESSION_ID';
const FEATURE_LIVE_ANALYTICS_DASHBOARD = 'FEATURE_LIVE_ANALYTICS_DASHBOARD';

const FEATURE_LIVE_ENTRIES_IN_FEED = 'FEATURE_LIVE_ENTRIES_IN_FEED';
}
13 changes: 13 additions & 0 deletions alpha/lib/model/Partner.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class Partner extends BasePartner

const ANALYTICS_HOST = "analytics_host";

const CUSTOM_DATA_ALLOWED_FROM_EMAIL_WHITELIST = 'allowedFromEmailWhiteList';

private $cdnWhiteListCache = array();

public function save(PropelPDO $con = null)
Expand Down Expand Up @@ -201,6 +203,17 @@ public function setPartnerStats( $v)

private static $s_config_params = array ( );

public function getAllowedFromEmailWhiteList()
{
return $this->getFromCustomData( self::CUSTOM_DATA_ALLOWED_FROM_EMAIL_WHITELIST);
}

public function setAllowedFromEmailWhiteList( $emails )
{
$emails = implode(',',array_map('trim',explode(',',$emails)));
$this->putInCustomData( self::CUSTOM_DATA_ALLOWED_FROM_EMAIL_WHITELIST, $emails);
}

public function getUseDefaultKshow() { return $this->getFromCustomData( "useDefaultKshow" , null , true ); }
public function setUseDefaultKshow( $v ) { return $this->putInCustomData( "useDefaultKshow", $v ); }

Expand Down
26 changes: 23 additions & 3 deletions alpha/lib/model/UserLoginDataPeer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class UserLoginDataPeer extends BaseUserLoginDataPeer implements IRelatedObjectP
{
const KALTURAS_CMS_PASSWORD_RESET = 51;
const LAST_LOGIN_TIME_UPDATE_INTERVAL = 600; // 10 Minutes
const OTP_MISSING = 'otp is missing';
const OTP_INVALID = 'otp is invalid';

public static function generateNewPassword()
{
Expand Down Expand Up @@ -82,7 +84,7 @@ private static function emailResetPassword($partner_id, $cms_email, $user_name,
);
}

public static function updateLoginData($oldLoginEmail, $oldPassword, $newLoginEmail = null, $newPassword = null, $newFirstName = null, $newLastName = null)
public static function updateLoginData($oldLoginEmail, $oldPassword, $newLoginEmail = null, $newPassword = null, $newFirstName = null, $newLastName = null, $otp = null)
{
// if email is null, no need to do any DB queries
if (!$oldLoginEmail) {
Expand Down Expand Up @@ -120,7 +122,7 @@ public static function updateLoginData($oldLoginEmail, $oldPassword, $newLoginEm
}

self::checkPasswordValidation ( $newPassword, $loginData );
self::validate2FA($loginData, $otp);
// update password if requested
if ($newPassword && $newPassword != $oldPassword) {
$password = $loginData->resetPassword($newPassword, $oldPassword);
Expand Down Expand Up @@ -153,7 +155,25 @@ public static function updateLoginData($oldLoginEmail, $oldPassword, $newLoginEm

return $loginData;
}


protected static function validate2FA($loginData, $otp)
{

$dbUser = kuserPeer::getAdminUser($loginData->getConfigPartnerId(), $loginData);
if ($dbUser && $loginData->isTwoFactorAuthenticationRequired($dbUser))
{
if(!$otp)
{
throw new kUserException (self::OTP_MISSING, kUserException::MISSING_OTP);
}
$result = authenticationUtils::verify2FACode($loginData, $otp);
if (!$result)
{
throw new kUserException (self::OTP_INVALID, kUserException::INVALID_OTP);
}
}
}

public static function checkPasswordValidation($newPassword, $loginData) {
// check that new password structure is valid
if ($newPassword &&
Expand Down
Loading

0 comments on commit 8e46a5a

Please sign in to comment.