<commit_before><?php
/**
 * @package plugins.elasticSearch
 * @subpackage lib.entitlement
 */

class kElasticUserEntitlementCondition extends kElasticBaseEntitlementCondition
{
    protected static function getEntitlementCondition(array $params = array(), $fieldPrefix ='')
    {
        $conditions = array(
            array(
                'terms' => array(
                    "{$fieldPrefix}entitled_kusers_edit" => array(
                        'index' => ElasticIndexMap::ELASTIC_KUSER_INDEX,
                        'type' => ElasticIndexMap::ELASTIC_KUSER_TYPE,
                        'id' => $params['kuserId'],
                        'path' => 'group_ids'
                    )
                )
            ),
            array(
                'term' => array(
                    "{$fieldPrefix}entitled_kusers_edit" => $params['kuserId'],
                )
            ),
            array(
                'terms' => array(
                    "{$fieldPrefix}entitled_kusers_publish" => array(
                        'index' => ElasticIndexMap::ELASTIC_KUSER_INDEX,
                        'type' => ElasticIndexMap::ELASTIC_KUSER_TYPE,
                        'id' => $params['kuserId'],
                        'path' => 'group_ids'
                    )
                )
            ),
            array(
                'term' => array(
                    "{$fieldPrefix}entitled_kusers_publish" => $params['kuserId'],
                )
            ),
            array(
                'term' => array(
                    "{$fieldPrefix}creator_kuser_id" => $params['kuserId']
                )
            ),
            array(
                'term' => array(
                    "{$fieldPrefix}kuser_id" => $params['kuserId']
                )
            )
        );

        return $conditions;
    }

    public static function applyCondition(&$entryQuery, &$parentEntryQuery)
    {
        $kuserId = kEntryElasticEntitlement::$kuserId;
        if(!$kuserId)
        {
            KalturaLog::log('cannot add user entitlement to elastic without a kuserId - setting kuser id to -1');
            $kuserId = -1;
        }
        $params['kuserId'] = $kuserId;
        
        if($parentEntryQuery)
        {
            //add parent conditions
            $conditions = self::getEntitlementCondition($params, 'parent_entry.');<commit_msg>PLAT-8173: remove creator kuser id from entitlement condition to align code to isEntryEntitled<commit_after><?php
/**
 * @package plugins.elasticSearch
 * @subpackage lib.entitlement
 */

class kElasticUserEntitlementCondition extends kElasticBaseEntitlementCondition
{
    protected static function getEntitlementCondition(array $params = array(), $fieldPrefix ='')
    {
        $conditions = array(
            array(
                'terms' => array(
                    "{$fieldPrefix}entitled_kusers_edit" => array(
                        'index' => ElasticIndexMap::ELASTIC_KUSER_INDEX,
                        'type' => ElasticIndexMap::ELASTIC_KUSER_TYPE,
                        'id' => $params['kuserId'],
                        'path' => 'group_ids'
                    )
                )
            ),
            array(
                'term' => array(
                    "{$fieldPrefix}entitled_kusers_edit" => $params['kuserId'],
                )
            ),
            array(
                'terms' => array(
                    "{$fieldPrefix}entitled_kusers_publish" => array(
                        'index' => ElasticIndexMap::ELASTIC_KUSER_INDEX,
                        'type' => ElasticIndexMap::ELASTIC_KUSER_TYPE,
                        'id' => $params['kuserId'],
                        'path' => 'group_ids'
                    )
                )
            ),
            array(
                'term' => array(
                    "{$fieldPrefix}entitled_kusers_publish" => $params['kuserId'],
                )
            ),
            array(
                'term' => array(
                    "{$fieldPrefix}kuser_id" => $params['kuserId']
                )
            )
        );

        return $conditions;
    }

    public static function applyCondition(&$entryQuery, &$parentEntryQuery)
    {
        $kuserId = kEntryElasticEntitlement::$kuserId;
        if(!$kuserId)
        {
            KalturaLog::log('cannot add user entitlement to elastic without a kuserId - setting kuser id to -1');
            $kuserId = -1;
        }
        $params['kuserId'] = $kuserId;
        
        if($parentEntryQuery)
        {
            //add parent conditions
            $conditions = self::getEntitlementCondition($params, 'parent_entry.');
{'fraction_non_alphanumeric': 0.11453650181973882, 'fraction_numerical': 0.0017126953543138515, 'mean_word_length': 1.389769820971867, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6278026', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1214, 'n_words': 204}