Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mercury 13.2.0 plat 7951 #6120

Merged
merged 4 commits into from
Sep 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions alpha/apps/kaltura/lib/kEntitlementUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ public static function isEntryEntitled(entry $entry, $kuserId = null)
return true;
}

// kuser is set on the entry entitled users edit or publish
if($entry->isEntitledKuserEdit($kuserId) || $entry->isEntitledKuserPublish($kuserId))
// kuser is set on the entry entitled users edit or publish or view
if($entry->isEntitledKuserEdit($kuserId) || $entry->isEntitledKuserPublish($kuserId) || $entry->isEntitledKuserView($kuserId))
{
KalturaLog::info('Entry [' . print_r($entry->getId(), true) . '] entitled: ks user is the same as entry->entitledKusersEdit or entry->entitledKusersPublish');
KalturaLog::info('Entry [' . print_r($entry->getId(), true) . '] entitled: ks user is the same as entry->entitledKusersEdit or entry->entitledKusersPublish or entry->entitledKusersView');
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ public function init ()
"_eq_parent_entry_id",
"_matchand_entitled_kusers_edit",
"_matchand_entitled_kusers_publish",
"_matchand_entitled_kusers_view",
"_matchor_entitled_kusers_edit",
"_matchor_entitled_kusers_publish",
"_matchor_entitled_kusers_view",
"_is_root",
"_matchand_roots",
"_notin_roots",
Expand Down
77 changes: 74 additions & 3 deletions alpha/lib/model/entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -1951,11 +1951,53 @@ public function getEntitledKusersEditArray()
return array_keys($this->getEntitledUserPuserEditArray());
}

public function getEntitledKusersView()
{
return implode(',', array_keys($this->getEntitledPusersViewArray()));
}

public function getEntitledKusersViewArray()
{
return array_keys($this->getEntitledPusersViewArray());
}

public function getEntitledPusersEdit()
{
return implode(',', $this->getEntitledUserPuserEditArray());
}

public function setEntitledPusersView($v)
{
$entitledUserPuserView = array();

$v = trim($v);
if($v == '')
{
$this->putInCustomData ( "entitledUserPuserView" , serialize($entitledUserPuserView) );
return;
}

$entitledPusersView = explode(',',$v);

$partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
foreach ($entitledPusersView as $puserId)
{
$puserId = trim($puserId);
if ( $puserId === '' )
{
continue;
}

$kuser = kuserPeer::getActiveKuserByPartnerAndUid($partnerId, $puserId);
if (!$kuser)
throw new kCoreException('Invalid user id', kCoreException::INVALID_USER_ID);

$entitledUserPuserView[$kuser->getId()] = $kuser->getPuserId();
}

$this->putInCustomData ( "entitledUserPuserView" , serialize($entitledUserPuserView) );
}

public function isOwnerActionsAllowed($kuserId)
{
$ownerKuserId = $this->getKuserId();
Expand All @@ -1966,9 +2008,9 @@ public function isOwnerActionsAllowed($kuserId)
return in_array($ownerKuserId, $kuserKGroupIds);
}

public function isEntitledKuserEdit($kuserId)

private function isEntitledKuser ($kuserId, $entitledKuserArray)
{
$entitledKuserArray = array_keys($this->getEntitledUserPuserEditArray());
if(in_array(trim($kuserId), $entitledKuserArray))
return true;

Expand All @@ -1979,6 +2021,20 @@ public function isEntitledKuserEdit($kuserId)

return $this->isOwnerActionsAllowed($kuserId);
}

public function isEntitledKuserEdit($kuserId)
{
$entitledKuserArray = array_keys($this->getEntitledUserPuserEditArray());

return $this->isEntitledKuser($kuserId, $entitledKuserArray);
}

public function isEntitledKuserView($kuserId)
{
$entitledKuserArray = array_keys($this->getEntitledPusersViewArray());

return $this->isEntitledKuser($kuserId, $entitledKuserArray);
}

private function getEntitledUserPuserEditArray()
{
Expand Down Expand Up @@ -2031,6 +2087,15 @@ private function getEntitledPusersPublishArray()
return unserialize($entitledUserPuserPublish);
}

private function getEntitledPusersViewArray()
{
$entitledUserPuserView = $this->getFromCustomData( "entitledUserPuserView", null, 0 );
if (!$entitledUserPuserView)
return array();

return unserialize($entitledUserPuserView);
}

public function getEntitledKusersPublish()
{
return implode(',', array_keys($this->getEntitledPusersPublishArray()));
Expand All @@ -2050,6 +2115,11 @@ public function getEntitledPusersPublish()
return implode(',', $this->getEntitledPusersPublishArray());
}

public function getEntitledPusersView()
{
return implode(',', $this->getEntitledPusersViewArray());
}

public function isEntitledKuserPublish($kuserId, $useUserGroups = true)
{
$entitledKusersArray = explode(',', $this->getEntitledKusersPublish());
Expand Down Expand Up @@ -3203,8 +3273,9 @@ public function getEntitledKusers()
{
$entitledKusersPublish = explode(',', $this->getEntitledKusersPublish());
$entitledKusersEdit = explode(',', $this->getEntitledKusersEdit());
$entitledKusersView = explode(',', $this->getEntitledKusersView());

$entitledKusersNoPrivacyContext = array_merge($entitledKusersPublish, $entitledKusersEdit);
$entitledKusersNoPrivacyContext = array_merge($entitledKusersPublish, $entitledKusersEdit, $entitledKusersView);
$entitledKusersNoPrivacyContext[] = $this->getKuserId();

foreach ($entitledKusersNoPrivacyContext as $key => $value)
Expand Down
5 changes: 5 additions & 0 deletions alpha/lib/model/index/entryIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public static function getIndexFieldsMap()
'last_played_at' => 'lastPlayedAt',
'entitled_kusers_publish' => 'entitledKusersPublish',
'entitled_kusers_edit' => 'entitledKusersEdit',
'entitled_kusers_view' => 'entitledKusersView',
'entitled_kusers' => 'entitledKusers',
'privacy_by_contexts' => 'privacyByContexts',
'creator_kuser_id' => 'creatorKuserId',
Expand Down Expand Up @@ -157,6 +158,7 @@ public static function getIndexFieldTypesMap()
'last_played_at' => IIndexable::FIELD_TYPE_DATETIME,
'entitled_kusers_publish' => IIndexable::FIELD_TYPE_STRING,
'entitled_kusers_edit' => IIndexable::FIELD_TYPE_STRING,
'entitled_kusers_view' => IIndexable::FIELD_TYPE_STRING,
'entitled_kusers' => IIndexable::FIELD_TYPE_STRING,
'privacy_by_contexts' => IIndexable::FIELD_TYPE_STRING,
'creator_kuser_id' => IIndexable::FIELD_TYPE_STRING,
Expand Down Expand Up @@ -190,6 +192,7 @@ public static function getIndexNullableList()
'roots',
'entitled_kusers_publish',
'entitled_kusers_edit',
'entitled_kusers_view',
'entitled_kusers',
'privacy_by_contexts',
);
Expand Down Expand Up @@ -248,6 +251,7 @@ public static function getIndexSearchableFieldsMap()
'entry.LAST_PLAYED_AT' => 'last_played_at',
'entry.ENTITLED_KUSERS_PUBLISH' => 'entitled_kusers_publish',
'entry.ENTITLED_KUSERS_EDIT' => 'entitled_kusers_edit',
'entry.ENTITLED_KUSERS_VIEW' => 'entitled_kusers_view',
'entry.ENTITLED_KUSERS' => 'entitled_kusers',
'entry.PRIVACY_BY_CONTEXTS' => 'privacy_by_contexts',
'entry.CREATOR_KUSER_ID' => 'creator_kuser_id',
Expand Down Expand Up @@ -307,6 +311,7 @@ public static function getIndexMatchableList()
"roots",
"entitled_kusers_publish",
"entitled_kusers_edit",
"entitled_kusers_view",
"dynamic_attributes",
"plugins_data",
"search_text",
Expand Down
24 changes: 22 additions & 2 deletions api_v3/lib/types/entry/KalturaBaseEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,20 +334,28 @@ class KalturaBaseEntry extends KalturaObject implements IRelatedFilterable, IApi
public $operationAttributes;

/**
* list of user ids that are entitled to edit the entry (no server enforcement) The difference between entitledUsersEdit and entitledUsersPublish is applicative only
* list of user ids that are entitled to edit the entry (no server enforcement) The difference between entitledUsersEdit, entitledUsersPublish and entitledUsersView is applicative only
*
* @var string
* @filter matchand,matchor
*/
public $entitledUsersEdit;

/**
* list of user ids that are entitled to publish the entry (no server enforcement) The difference between entitledUsersEdit and entitledUsersPublish is applicative only
* list of user ids that are entitled to publish the entry (no server enforcement) The difference between entitledUsersEdit, entitledUsersPublish and entitledUsersView is applicative only
*
* @var string
* @filter matchand,matchor
*/
public $entitledUsersPublish;

/**
* list of user ids that are entitled to view the entry (no server enforcement) The difference between entitledUsersEdit, entitledUsersPublish and entitledUsersView is applicative only
*
* @var string
* @filter matchand,matchor
*/
public $entitledUsersView;

/**
* Comma seperated string of the capabilities of the entry. Any capability needed can be added to this list.
Expand Down Expand Up @@ -416,6 +424,7 @@ class KalturaBaseEntry extends KalturaObject implements IRelatedFilterable, IApi
"parentEntryId",
"entitledUsersEdit" => "entitledPusersEdit",
"entitledUsersPublish" => "entitledPusersPublish",
"entitledUsersView" => "entitledPusersView",
"operationAttributes",
"capabilities",
"templateEntryId",
Expand Down Expand Up @@ -639,6 +648,17 @@ public function validateUsers()
}
}

if(!$this->isNull('entitledUsersView'))
{
$entitledPusersView = explode(',', $this->entitledUsersView);

foreach ($entitledPusersView as $puserId)
{
$puserId = trim($puserId);
kuserPeer::createKuserForPartner($partnerId, $puserId);
}
}

}

/* (non-PHPdoc)
Expand Down
12 changes: 12 additions & 0 deletions api_v3/lib/types/entry/filters/KalturaBaseEntryFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class KalturaBaseEntryFilter extends KalturaBaseEntryBaseFilter
"entitledUsersPublishMatchAnd" => "_matchand_entitled_kusers_publish",
"entitledUsersEditMatchOr" => "_matchor_entitled_kusers_edit",
"entitledUsersPublishMatchOr" => "_matchor_entitled_kusers_publish",
"entitledUsersViewMatchAnd" => "_matchand_entitled_kusers_view",
"entitledUsersViewMatchOr" => "_matchor_entitled_kusers_view",
);

static private $order_by_map = array
Expand Down Expand Up @@ -142,6 +144,16 @@ private function fixFilterUserId()
{
$this->entitledUsersPublishMatchOr = $this->preparePusersToKusersFilter( $this->entitledUsersPublishMatchOr );
}

if(!empty($this->entitledUsersViewMatchOr))
{
$this->entitledUsersViewMatchOr = $this->preparePusersToKusersFilter( $this->entitledUsersViewMatchOr );
}

if(!empty($this->entitledUsersViewMatchAnd))
{
$this->entitledUsersViewMatchAnd = $this->preparePusersToKusersFilter( $this->entitledUsersViewMatchAnd );
}
}

/**
Expand Down
12 changes: 12 additions & 0 deletions api_v3/lib/types/entry/filters/base/KalturaBaseEntryBaseFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ abstract class KalturaBaseEntryBaseFilter extends KalturaRelatedFilter
"entitledUsersEditMatchOr" => "_matchor_entitled_users_edit",
"entitledUsersPublishMatchAnd" => "_matchand_entitled_users_publish",
"entitledUsersPublishMatchOr" => "_matchor_entitled_users_publish",
"entitledUsersViewMatchAnd" => "_matchand_entitled_users_view",
"entitledUsersViewMatchOr" => "_matchor_entitled_users_view",
"tagsNameMultiLikeOr" => "_mlikeor_tags-name",
"tagsAdminTagsMultiLikeOr" => "_mlikeor_tags-admin_tags",
"tagsAdminTagsNameMultiLikeOr" => "_mlikeor_tags-admin_tags-name",
Expand Down Expand Up @@ -541,6 +543,16 @@ public function getOrderByMap()
*/
public $entitledUsersPublishMatchOr;

/**
* @var string
*/
public $entitledUsersViewMatchAnd;

/**
* @var string
*/
public $entitledUsersViewMatchOr;

/**
* @var string
*/
Expand Down
1 change: 1 addition & 0 deletions configurations/sphinx/kaltura.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ index kaltura_entry:kaltura_base
rt_field = creator_puser_id
rt_field = entitled_kusers_publish
rt_field = entitled_kusers_edit
rt_field = entitled_kusers_view
rt_field = entitled_kusers
rt_field = privacy_by_contexts
rt_field = sphinx_match_optimizations
Expand Down