public static function isRelativeTimeEnabled() { if (!kConf::hasParam('disable_relative_time_partners')) { return true; } return !in_array(kCurrentContext::getCurrentPartnerId(), kConf::get('disable_relative_time_partners')); }
public function translateSphinxCriterion(SphinxCriterion $crit) { $field = $crit->getTable() . '.' . $crit->getColumn(); $value = $crit->getValue(); $fieldName = null; if ($field == TagPeer::OBJECT_TYPE) { $fieldName = "TagPeer::OBJECT_TYPE"; } if ($field == TagPeer::PRIVACY_CONTEXT) { $fieldName = "TagPeer::PRIVACY_CONTEXT"; } if ($fieldName) { $partnerIdCrit = $this->getCriterion(TagPeer::PARTNER_ID); if ($partnerIdCrit && $partnerIdCrit->getComparison() == Criteria::EQUAL) { $partnerId = $partnerIdCrit->getValue(); } else { $partnerId = kCurrentContext::getCurrentPartnerId(); } $value = Tag::getIndexedFieldValue($fieldName, $value, $partnerId); } if ($field == TagPeer::TAG && in_array($crit->getComparison(), array(Criteria::EQUAL, Criteria::IN))) { $value = str_replace(kTagFlowManager::$specialCharacters, kTagFlowManager::$specialCharactersReplacement, $value); } return array($field, $crit->getComparison(), $value); }
/** * @action notify * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY * @param int $id integration job id */ public function notifyAction($id) { $coreType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION); $batchJob = BatchJobPeer::retrieveByPK($id); $invalidJobId = false; $invalidKs = false; if (!self::validateKs($batchJob)) { $invalidKs = true; KalturaLog::err("ks not valid for notifying job [{$id}]"); } elseif (!$batchJob) { $invalidJobId = true; KalturaLog::err("Job [{$id}] not found"); } elseif ($batchJob->getJobType() != $coreType) { $invalidJobId = true; KalturaLog::err("Job [{$id}] wrong type [" . $batchJob->getJobType() . "] expected [" . $coreType . "]"); } elseif ($batchJob->getStatus() != KalturaBatchJobStatus::ALMOST_DONE) { $invalidJobId = true; KalturaLog::err("Job [{$id}] wrong status [" . $batchJob->getStatus() . "] expected [" . KalturaBatchJobStatus::ALMOST_DONE . "]"); } elseif ($batchJob->getPartnerId() != kCurrentContext::getCurrentPartnerId()) { $invalidKs = true; KalturaLog::err("Job [{$id}] of wrong partner [" . $batchJob->getPartnerId() . "] expected [" . kCurrentContext::getCurrentPartnerId() . "]"); } if ($invalidJobId) { throw new KalturaAPIException(KalturaErrors::INVALID_BATCHJOB_ID, $id); } if ($invalidKs) { throw new KalturaAPIException(KalturaIntegrationErrors::INTEGRATION_NOTIFY_FAILED); } kJobsManager::updateBatchJob($batchJob, KalturaBatchJobStatus::FINISHED); }
public function validateForUpdate($sourceObject, $propertiesToSkip = array()) { if (!WidevinePlugin::isAllowedPartner(kCurrentContext::getCurrentPartnerId()) || !WidevinePlugin::isAllowedPartner($sourceObject->getPartnerId())) { throw new KalturaAPIException(KalturaErrors::PERMISSION_NOT_FOUND, 'Permission not found to use the Widevine feature.'); } return parent::validateForUpdate($sourceObject, $propertiesToSkip); }
public static function createCustomData($entryId, KalturaFlavorAssetArray $flavorAssets, $signingKey) { $flavorIds = ""; $first = true; foreach ($flavorAssets as $flavor) { /** * @var asset $flavor */ if ($first) { $first = false; } else { $flavorIds .= ","; } $flavorIds .= $flavor->id; } $innerData = array(); $innerData["ca_system"] = self::SYSTEM_NAME; $innerData["user_token"] = kCurrentContext::$ks; $innerData["account_id"] = kCurrentContext::getCurrentPartnerId(); $innerData["content_id"] = $entryId; $innerData["files"] = $flavorIds; $customData = array(); foreach ($flavorAssets as $flavor) { /* * we sign for each flavor asset in case that in the future someone will want to add data per flavor asset */ $innerDataJson = json_encode($innerData); $innerDataSignature = self::signDataWithKey($innerDataJson, $signingKey); $innerDataJsonEncoded = rawurlencode(base64_encode($innerDataJson)); $customData[$flavor->id] = array(); $customData[$flavor->id]["custom_data"] = $innerDataJsonEncoded; $customData[$flavor->id]["signature"] = $innerDataSignature; } return $customData; }
protected function doGetListResponse(KalturaFilterPager $pager, $type = null) { $this->validateEntryIdFiltered(); $this->translateUserIds(); $c = KalturaCriteria::create(CuePointPeer::OM_CLASS); if ($type) { $c->add(CuePointPeer::TYPE, $type); } $entryIds = null; if ($this->entryIdEqual) { $entryIds = array($this->entryIdEqual); } else { if ($this->entryIdIn) { $entryIds = explode(',', $this->entryIdIn); } } if (!is_null($entryIds)) { $entryIds = entryPeer::filterEntriesByPartnerOrKalturaNetwork($entryIds, kCurrentContext::getCurrentPartnerId()); if (!$entryIds) { return array(array(), 0); } $this->entryIdEqual = null; $this->entryIdIn = implode(',', $entryIds); } $cuePointFilter = $this->toObject(); $cuePointFilter->attachToCriteria($c); $pager->attachToCriteria($c); $list = CuePointPeer::doSelect($c); return array($list, $c->getRecordsCount()); }
public function validateForUsage($sourceObject, $propertiesToSkip = array()) { parent::validateForUsage($sourceObject, $propertiesToSkip); $this->validatePropertyNotNull('eventNotificationTemplateId'); myPartnerUtils::addPartnerToCriteria('EventNotificationTemplate', kCurrentContext::getCurrentPartnerId(), true); $eventNotificationTemplate = EventNotificationTemplatePeer::retrieveByPK($this->eventNotificationTemplateId); if (is_null($eventNotificationTemplate)) { throw new KalturaAPIException(KalturaEventNotificationErrors::EVENT_NOTIFICATION_TEMPLATE_NOT_FOUND, $this->eventNotificationTemplateId); } }
/** * Creates default criteria filter */ public static function setDefaultCriteriaFilter() { if (self::$s_criteria_filter == null) { self::$s_criteria_filter = new criteriaFilter(); } $c = KalturaCriteria::create(KuserKgroupPeer::OM_CLASS); $c->addAnd(KuserKgroupPeer::STATUS, array(KuserKgroupStatus::DELETED), Criteria::NOT_IN); $c->addAnd(KuserKgroupPeer::PARTNER_ID, kCurrentContext::getCurrentPartnerId(), Criteria::EQUAL); self::$s_criteria_filter->setFilter($c); }
public function validateForResponseProfile() { if (kEntitlementUtils::getEntitlementEnforcement()) { if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENABLE_RESPONSE_PROFILE_USER_CACHE, kCurrentContext::getCurrentPartnerId())) { KalturaResponseProfileCacher::useUserCache(); return; } throw new KalturaAPIException(KalturaErrors::CANNOT_LIST_RELATED_ENTITLED_WHEN_ENTITLEMENT_IS_ENABLE, get_class($this)); } }
/** * Add a new scheduled task profile * * @action add * @param KalturaScheduledTaskProfile $scheduledTaskProfile * @return KalturaScheduledTaskProfile * * @disableRelativeTime $scheduledTaskProfile */ public function addAction(KalturaScheduledTaskProfile $scheduledTaskProfile) { /* @var $dbScheduledTaskProfile ScheduledTaskProfile */ $dbScheduledTaskProfile = $scheduledTaskProfile->toInsertableObject(); $dbScheduledTaskProfile->setPartnerId(kCurrentContext::getCurrentPartnerId()); $dbScheduledTaskProfile->save(); // return the saved object $scheduledTaskProfile = new KalturaScheduledTaskProfile(); $scheduledTaskProfile->fromObject($dbScheduledTaskProfile, $this->getResponseProfile()); return $scheduledTaskProfile; }
public static function validateMetadataObjects($profileField, $objectIds, &$errorMessage) { /** @var MetadataProfileField $profileField */ $partnerId = kCurrentContext::getCurrentPartnerId(); $dbObjects = kuserPeer::getKuserByPartnerAndUids($partnerId, $objectIds); if (count($dbObjects) != count($objectIds)) { $errorMessage = 'One of the following objects: ' . implode(', ', $objectIds) . ' was not found'; return false; } return true; }
public function validateForUsage($sourceObject, $propertiesToSkip = array()) { parent::validateForUsage($sourceObject, $propertiesToSkip); $this->validatePropertyNotNull('metadataProfileId'); $this->validatePropertyNotNull('metadataObjectType'); $this->validatePropertyNotNull('xslt'); myPartnerUtils::addPartnerToCriteria('MetadataProfile', kCurrentContext::getCurrentPartnerId(), true); $metadataProfile = MetadataProfilePeer::retrieveByPK($this->metadataProfileId); if (is_null($metadataProfile)) { throw new KalturaAPIException(MetadataErrors::METADATA_PROFILE_NOT_FOUND, $this->metadataProfileId); } }
public function validateForInsert($propertiesToSkip = array()) { $partnerId = kCurrentContext::getCurrentPartnerId(); $partner = PartnerPeer::retrieveByPK($partnerId); if (!$partner) { throw new KalturaAPIException(KalturaErrors::PARTNER_NOT_FOUND, $partnerId); } if (!$partner->getPluginEnabled(FreewheelGenericDistributionPlugin::DEPENDENTS_ON_PLUGIN_NAME_CUE_POINT)) { throw new KalturaAPIException(KalturaErrors::PLUGIN_NOT_AVAILABLE_FOR_PARTNER, FreewheelGenericDistributionPlugin::DEPENDENTS_ON_PLUGIN_NAME_CUE_POINT, $partnerId); } return parent::validateForInsert($propertiesToSkip); }
public function setPgroupId($pgroupId) { if (self::getPgroupId() == $pgroupId) { // same value - don't set for nothing return; } parent::setPgroupId($pgroupId); $partnerId = kCurrentContext::getCurrentPartnerId(); $kgroup = kuserPeer::getKuserByPartnerAndUid($partnerId, $pgroupId, false, KuserType::GROUP); if (!$kgroup) { throw new kCoreException("Invalid group Id [{$pgroupId}]", kCoreException::INVALID_USER_ID); } parent::setKgroupId($kgroup->getId()); }
protected function doGetListResponse(KalturaFilterPager $pager, array $types = null) { $this->validateEntryIdFiltered(); myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; // verify access to the relevant entries - either same partner as the KS or kaltura network if ($this->entryIdEqual) { $entryIds = array($this->entryIdEqual); } else { if ($this->entryIdIn) { $entryIds = explode(',', $this->entryIdIn); } else { throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn'); } } $entryIds = array_slice($entryIds, 0, baseObjectFilter::getMaxInValues()); $c = KalturaCriteria::create(entryPeer::OM_CLASS); $c->addAnd(entryPeer::ID, $entryIds, Criteria::IN); $criterionPartnerOrKn = $c->getNewCriterion(entryPeer::PARTNER_ID, kCurrentContext::getCurrentPartnerId()); $criterionPartnerOrKn->addOr($c->getNewCriterion(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK)); $c->addAnd($criterionPartnerOrKn); $dbEntries = entryPeer::doSelect($c); if (!$dbEntries) { return array(array(), 0); } $entryIds = array(); foreach ($dbEntries as $dbEntry) { $entryIds[] = $dbEntry->getId(); } $this->entryIdEqual = null; $this->entryIdIn = implode(',', $entryIds); // get the flavors $flavorAssetFilter = new AssetFilter(); $this->toObject($flavorAssetFilter); $c = new Criteria(); $flavorAssetFilter->attachToCriteria($c); if ($types) { $c->add(assetPeer::TYPE, $types, Criteria::IN); } $pager->attachToCriteria($c); $list = assetPeer::doSelect($c); $resultCount = count($list); if ($resultCount && $resultCount < $pager->pageSize) { $totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount; } else { KalturaFilterPager::detachFromCriteria($c); $totalCount = assetPeer::doCount($c); } myDbHelper::$use_alternative_con = null; return array($list, $totalCount); }
/** * The user_id is infact a puser_id and the kuser_id should be retrieved */ protected function fixFilterUserId() { if ($this->userIdEqual !== null) { $kuser = kuserPeer::getKuserByPartnerAndUid(kCurrentContext::getCurrentPartnerId(), $this->userIdEqual); if ($kuser) { $this->userIdEqual = $kuser->getId(); } else { $this->userIdEqual = -1; } // no result will be returned when the user is missing } if (!empty($this->userIdIn)) { $this->userIdIn = $this->preparePusersToKusersFilter($this->userIdIn); } }
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null) { if (!is_null($this->isAnonymous)) { if (KalturaNullableBoolean::toBoolean($this->isAnonymous) === false) { if ($this->userIdNotIn == null) { $anonKuserIds = ""; $anonKusers = kuserPeer::getKuserByPartnerAndUids(kCurrentContext::getCurrentPartnerId(), array('', 0)); foreach ($anonKusers as $anonKuser) { $anonKuserIds .= $anonKuser->getKuserId() . ","; } $this->userIdNotIn = $anonKuserIds; } } } return parent::getListResponse($pager, $responseProfile); }
public function getFieldValue(kScope $scope) { $profileId = $this->profileId; if (!$profileId) { if (!$this->profileSystemName) { KalturaLog::err("No metadata profile id and system-name supplied"); return null; } $profile = MetadataProfilePeer::retrieveBySystemName($this->profileSystemName, kCurrentContext::getCurrentPartnerId()); if (!$profile) { KalturaLog::notice("Metadata profile with system-name [{$this->profileSystemName}] not found"); return null; } $profileId = $profile->getId(); } $metadata = null; if ($scope instanceof accessControlScope || $scope instanceof kStorageProfileScope) { $metadata = MetadataPeer::retrieveByObject($profileId, MetadataObjectType::ENTRY, $scope->getEntryId()); } elseif ($scope instanceof kEventScope) { $object = $scope->getEvent()->getObject(); if (kMetadataManager::isMetadataObject($object)) { $objectType = kMetadataManager::getTypeNameFromObject($object); $metadata = MetadataPeer::retrieveByObject($profileId, $objectType, $object->getId()); } else { if ($object instanceof Metadata) { $metadata = $object; } elseif ($scope->getEvent()->getObject() instanceof categoryEntry) { $profileObject = kMetadataManager::getObjectTypeName($profile->getObjectType()); $getter = "get{$profileObject}Id"; KalturaLog::info("Using {$getter} in order to retrieve the metadata object ID"); $categoryEntry = $scope->getEvent()->getObject(); $objectId = $categoryEntry->{$getter}(); $metadata = MetadataPeer::retrieveByObject($profileId, $profile->getObjectType(), $objectId); } elseif ($object instanceof asset) { $metadata = MetadataPeer::retrieveByObject($profileId, MetadataObjectType::ENTRY, $object->getEntryId()); } } } if ($metadata) { return kMetadataManager::parseMetadataValues($metadata, $this->xPath); } KalturaLog::notice("Metadata object not found for scope [" . get_class($scope) . "]"); return null; }
public function toObject($obj = null, $props_to_skip = array()) { if (!$obj) { $obj = new kCategoryKuserAdvancedFilter(); } if (!$this->memberIdEq && !$this->memberIdIn) { throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'memberIdEq,memberIdIn'); } if (!$this->memberPermissionsMatchOr && !$this->memberPermissionsMatchAnd) { throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'memberIdEq,memberIdIn'); } if ($this->memberIdEq) { $kuser = kuserPeer::getKuserByPartnerAndUid(kCurrentContext::getCurrentPartnerId(), $this->memberIdEq); if (!$kuser) { throw new KalturaAPIException(KalturaErrors::USER_NOT_FOUND); } $kuserIds = array($kuser->getId()); // retrieve categories that the user is a member by a group. $kgroupIds = KuserKgroupPeer::retrieveKgroupIdsByKuserId($kuser->getId()); if (!is_null($kgroupIds) && is_array($kgroupIds)) { $kuserIds = array_merge($kgroupIds, $kuserIds); } $obj->setMemberIdIn($kuserIds); } if ($this->memberIdIn) { $kusers = kuserPeer::getKuserByPartnerAndUids(kCurrentContext::getCurrentPartnerId(), explode(',', $this->memberIdIn)); $kuserIds = array(); if (!$kusers || !count($kusers)) { throw new KalturaAPIException(KalturaErrors::USER_NOT_FOUND); } foreach ($kusers as $kuser) { $kuserIds[] = $kuser->getId(); } // retrieve categories that the users are members by a group. $kgroupIds = KuserKgroupPeer::retrieveKgroupIdsByKuserIds($kuserIds); if (!is_null($kgroupIds) && is_array($kgroupIds)) { $kuserIds = array_merge($kgroupIds, $kuserIds); } $obj->setMemberIdIn($kuserIds); } return parent::toObject($obj, $props_to_skip); }
protected function applyFilterFields(baseObjectFilter $filter) { /* @var $filter AnswerCuePointFilter */ if ($filter->get('_eq_quiz_user_entry_id')) { $userEntryId = $filter->get('_eq_quiz_user_entry_id'); $searchValue = $userEntryId . kCurrentContext::getCurrentPartnerId() . QuizPlugin::SEARCH_TEXT_SUFFIX; $this->addMatch("(@plugins_data {$searchValue})"); } $filter->unsetByName('_eq_quiz_user_entry_id'); if ($filter->get('_in_quiz_user_entry_id')) { $userEntryIds = explode(',', $filter->get('_in_quiz_user_entry_id')); foreach ($userEntryIds as &$userEntryId) { $userEntryId .= kCurrentContext::getCurrentPartnerId() . QuizPlugin::SEARCH_TEXT_SUFFIX; } $searchValues = implode(' | ', $userEntryIds); $this->addMatch("(@plugins_data ({$searchValues}))"); } $filter->unsetByName('_in_quiz_user_entry_id'); return parent::applyFilterFields($filter); }
public function toObject($object_to_fill = null, $props_to_skip = array()) { if ($this->metadataObjectTypeEqual == KalturaMetadataObjectType::USER) { if ($this->objectIdEqual) { $kuser = kuserPeer::getKuserByPartnerAndUid(kCurrentContext::getCurrentPartnerId(), $this->objectIdEqual); if ($kuser) { $this->objectIdEqual = $kuser->getId(); } } if ($this->objectIdIn) { $kusers = kuserPeer::getKuserByPartnerAndUids(kCurrentContext::getCurrentPartnerId(), explode(',', $this->objectIdIn)); $kusersIds = array(); foreach ($kusers as $kuser) { $kusersIds[] = $kuser->getId(); } $this->objectIdIn = implode(',', $kusersIds); } } return parent::toObject($object_to_fill, $props_to_skip); }
public static function addintegrationJob($objectType, $objectId, kIntegrationJobData $data) { $partnerId = kCurrentContext::getCurrentPartnerId(); $batchJob = new BatchJob(); $batchJob->setPartnerId($partnerId); $batchJob->setObjectType($objectType); $batchJob->setObjectId($objectId); if ($objectType == BatchJobObjectType::ENTRY) { $batchJob->setEntryId($objectId); } elseif ($objectType == BatchJobObjectType::ASSET) { $asset = assetPeer::retrieveById($objectId); if ($asset) { $batchJob->setEntryId($asset->getEntryId()); } } $batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS); $jobType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION); $batchJob = kJobsManager::addJob($batchJob, $data, $jobType, $data->getProviderType()); return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING); }
protected function doGetListResponse(KalturaFilterPager $pager, array $types = null) { $this->validateEntryIdFiltered(); myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; // verify access to the relevant entries - either same partner as the KS or kaltura network if ($this->entryIdEqual) { $entryIds = array($this->entryIdEqual); } else { if ($this->entryIdIn) { $entryIds = explode(',', $this->entryIdIn); } else { throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn'); } } $entryIds = entryPeer::filterEntriesByPartnerOrKalturaNetwork($entryIds, kCurrentContext::getCurrentPartnerId()); if (!$entryIds) { return array(array(), 0); } $this->entryIdEqual = null; $this->entryIdIn = implode(',', $entryIds); // get the flavors $flavorAssetFilter = new AssetFilter(); $this->toObject($flavorAssetFilter); $c = new Criteria(); $flavorAssetFilter->attachToCriteria($c); if ($types) { $c->add(assetPeer::TYPE, $types, Criteria::IN); } $pager->attachToCriteria($c); $list = assetPeer::doSelect($c); $resultCount = count($list); if ($resultCount && $resultCount < $pager->pageSize) { $totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount; } else { KalturaFilterPager::detachFromCriteria($c); $totalCount = assetPeer::doCount($c); } myDbHelper::$use_alternative_con = null; return array($list, $totalCount); }
protected function internalFulfilled(kScope $scope) { $profileId = $this->profileId; if (!$profileId) { if (!$this->profileSystemName) { return null; } $profile = MetadataProfilePeer::retrieveBySystemName($this->profileSystemName, kCurrentContext::getCurrentPartnerId()); if (!$profile) { return null; } $profileId = $profile->getId(); } $metadata = null; if ($scope instanceof accessControlScope) { $metadata = MetadataPeer::retrieveByObject($profileId, MetadataObjectType::ENTRY, $scope->getEntryId()); } elseif ($scope instanceof kEventScope && $scope->getEvent() instanceof kApplicativeEvent) { $object = $scope->getEvent()->getObject(); if ($object instanceof Metadata) { $metadata = $object; } elseif (kMetadataManager::isMetadataObject($object)) { $objectType = kMetadataManager::getTypeNameFromObject($object); $metadata = MetadataPeer::retrieveByObject($profileId, $objectType, $object->getId()); } } if (!$metadata) { return false; } if ($this->versionA) { $valuesA = kMetadataManager::parseMetadataValues($metadata, $this->xPath, $this->versionA); } $valuesB = kMetadataManager::parseMetadataValues($metadata, $this->xPath, $this->versionB); if (!$valuesA || !count($valuesA)) { //previous MD version does not exist $changedValues = $valuesB; } else { $changedValues = array_diff($valuesA, $valuesB); } return count($changedValues) > 0; }
protected function applyFilterFields(baseObjectFilter $filter) { //Role ids and kuser permission names are indexed with the partner ID if ($filter->get('_eq_role_ids')) { $filter->set('_eq_role_ids', kuser::getIndexedFieldValue('kuserPeer::ROLE_IDS', $filter->get('_eq_role_ids'), kCurrentContext::getCurrentPartnerId())); } if ($filter->get('_in_role_ids')) { $filter->set('_eq_role_ids', kuser::getIndexedFieldValue('kuserPeer::ROLE_IDS', $filter->get('_eq_role_ids'), kCurrentContext::getCurrentPartnerId())); } if ($filter->get('_mlikeand_permission_names')) { $permissionNames = kuser::getIndexedFieldValue('kuserPeer::PERMISSION_NAMES', $filter->get('_mlikeand_permission_names'), kCurrentContext::getCurrentPartnerId()); $permissionNames = implode(' ', explode(',', $permissionNames)); $universalPermissionName = kuser::getIndexedFieldValue('kuserPeer::PERMISSION_NAMES', kuser::UNIVERSAL_PERMISSION, kCurrentContext::getCurrentPartnerId()); $value = "({$universalPermissionName} | ({$permissionNames}))"; $this->addMatch("@permission_names {$value}"); $filter->unsetByName('_mlikeand_permission_names'); } if ($filter->get('_mlikeor_permission_names')) { $filter->set('_mlikeor_permission_names', kuser::getIndexedFieldValue('kuserPeer::PERMISSION_NAMES', $filter->get('_mlikeor_permission_names') . ',' . kuser::UNIVERSAL_PERMISSION, kCurrentContext::getCurrentPartnerId())); } if ($filter->get('_likex_puser_id_or_screen_name')) { $freeTexts = $filter->get('_likex_puser_id_or_screen_name'); KalturaLog::debug("Attach free text [{$freeTexts}]"); $additionalConditions = array(); $advancedSearch = $filter->getAdvancedSearch(); if ($advancedSearch) { $additionalConditions = $advancedSearch->getFreeTextConditions($filter->getPartnerSearchScope(), $freeTexts); } $this->addFreeTextToMatchClauseByMatchFields($freeTexts, kuserFilter::PUSER_ID_OR_SCREEN_NAME, $additionalConditions, true); } $filter->unsetByName('_likex_puser_id_or_screen_name'); if ($filter->get('_likex_first_name_or_last_name')) { $names = $filter->get('_likex_first_name_or_last_name'); KalturaLog::debug("Attach free text [{$names}]"); $this->addFreeTextToMatchClauseByMatchFields($names, kuserFilter::FIRST_NAME_OR_LAST_NAME, null, true); } $filter->unsetByName('_likex_first_name_or_last_name'); return parent::applyFilterFields($filter); }
/** * @param int $eventNotificationType * @param kEventNotificationDispatchJobData $jobData * @param string $partnerId * @param string $entryId * @param BatchJob $parentJob * @return BatchJob */ protected function addEventNotificationDispatchJob($eventNotificationType, kEventNotificationDispatchJobData $jobData, $partnerId = null, $entryId = null, BatchJob $parentJob = null) { $jobType = EventNotificationPlugin::getBatchJobTypeCoreValue(EventNotificationBatchType::EVENT_NOTIFICATION_HANDLER); $batchJob = null; if ($parentJob) { $batchJob = $parentJob->createChild($jobType, $eventNotificationType, false); } else { $batchJob = new BatchJob(); $batchJob->setEntryId($entryId); if (!$partnerId) { $partnerId = kCurrentContext::getCurrentPartnerId(); } $batchJob->setPartnerId($partnerId); } KalturaLog::log("Creating event notification dispatch job on template id [" . $jobData->getTemplateId() . "] engine[{$eventNotificationType}]"); $batchJob->setObjectId($entryId); $batchJob->setObjectType(BatchJobObjectType::ENTRY); $batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS); $batchJob = kJobsManager::addJob($batchJob, $jobData, $jobType, $eventNotificationType); $jobData->setJobId($batchJob->getId()); $batchJob->setData($jobData); return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING); }
public static function addintegrationJob($objectType, $objectId, kIntegrationJobData $data) { $partnerId = kCurrentContext::getCurrentPartnerId(); $providerType = $data->getProviderType(); $integrationProvider = KalturaPluginManager::loadObject('IIntegrationProvider', $providerType); if (!$integrationProvider || !$integrationProvider->validatePermissions($partnerId)) { KalturaLog::err("partner {$partnerId} not permitted with provider type {$providerType}"); return false; } $batchJob = new BatchJob(); $batchJob->setPartnerId($partnerId); $batchJob->setObjectType($objectType); $batchJob->setObjectId($objectId); if ($objectType == BatchJobObjectType::ENTRY) { $batchJob->setEntryId($objectId); } elseif ($objectType == BatchJobObjectType::ASSET) { $asset = assetPeer::retrieveById($objectId); if ($asset) { $batchJob->setEntryId($asset->getEntryId()); } } $batchJob->setStatus(BatchJob::BATCHJOB_STATUS_DONT_PROCESS); $jobType = IntegrationPlugin::getBatchJobTypeCoreValue(IntegrationBatchJobType::INTEGRATION); $batchJob = kJobsManager::addJob($batchJob, $data, $jobType, $providerType); if ($integrationProvider->shouldSendCallBack()) { $jobId = $batchJob->getId(); $ks = self::generateKs($partnerId, $jobId); $callBackUrl = "http://" . kConf::get('cdn_api_host'); $callBackUrl .= "/api_v3/index.php/service/integration_integration/action/notify"; $callBackUrl .= "/id/{$jobId}/ks/{$ks}"; $data = $batchJob->getData(); $data->setCallbackNotificationUrl($callBackUrl); $batchJob->setData($data); } return kJobsManager::updateBatchJob($batchJob, BatchJob::BATCHJOB_STATUS_PENDING); }
public function getFieldValue(kScope $scope) { $profileId = $this->profileId; if (!$profileId) { if (!$this->profileSystemName) { return null; } $profile = MetadataProfilePeer::retrieveBySystemName($this->profileSystemName, kCurrentContext::getCurrentPartnerId()); if (!$profile) { return null; } $profileId = $profile->getId(); } $metadata = null; if ($scope instanceof accessControlScope || $scope instanceof kStorageProfileScope) { $metadata = MetadataPeer::retrieveByObject($profileId, MetadataObjectType::ENTRY, $scope->getEntryId()); } elseif ($scope instanceof kEventScope && $scope->getEvent() instanceof kApplicativeEvent) { $object = $scope->getEvent()->getObject(); if (kMetadataManager::isMetadataObject($object)) { $objectType = kMetadataManager::getTypeNameFromObject($object); $metadata = MetadataPeer::retrieveByObject($profileId, $objectType, $object->getId()); } else { if ($object instanceof Metadata) { $metadata = $object; } } } if (!$metadata) { return null; } $values = kMetadataManager::parseMetadataValues($metadata, $this->xPath); if (is_null($values)) { return null; } return array_map('intval', $values); }
/** * @action exportToCsv * @param KalturaLiveReportExportType $reportType * @param KalturaLiveReportExportParams $params * @return KalturaLiveReportExportResponse */ public function exportToCsvAction($reportType, KalturaLiveReportExportParams $params) { if (!$params->recpientEmail) { $kuser = kCurrentContext::getCurrentKsKuser(); if ($kuser) { $params->recpientEmail = $kuser->getEmail(); } else { $partnerId = kCurrentContext::getCurrentPartnerId(); $partner = PartnerPeer::retrieveByPK($partnerId); $params->recpientEmail = $partner->getAdminEmail(); } } // Validate input if ($params->entryIds) { $entryIds = explode(",", $params->entryIds); $entries = entryPeer::retrieveByPKs($entryIds); if (count($entryIds) != count($entries)) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $params->entryIds); } } $dbBatchJob = kJobsManager::addExportLiveReportJob($reportType, $params); $res = new KalturaLiveReportExportResponse(); $res->referenceJobId = $dbBatchJob->getId(); $res->reportEmail = $params->recpientEmail; return $res; }
public function validateForResponseProfile() { if (!kCurrentContext::$is_admin_session && !$this->idEqual && !$this->idIn && !$this->systemNameEqual && !$this->systemNameIn && !PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENABLE_RESPONSE_PROFILE_USER_CACHE, kCurrentContext::getCurrentPartnerId())) { throw new KalturaAPIException(KalturaCuePointErrors::USER_KS_CANNOT_LIST_RELATED_CUE_POINTS, get_class($this)); } }