public function getScope() { $scope = parent::getScope(); if (method_exists($this->object, 'getPartnerId')) { $scope->setPartnerId($this->object->getPartnerId()); } return $scope; }
public function getScope() { $scope = parent::getScope(); if ($this->raisedJob) { $scope->setPartnerId($this->raisedJob->getPartnerId()); $scope->setParentRaisedJob($this->raisedJob); } elseif (method_exists($this->object, 'getPartnerId')) { $scope->setPartnerId($this->object->getPartnerId()); } return $scope; }
public function shouldConsumeDataChangedEvent(BaseObject $object, $previousVersion = null) { if (class_exists('CaptionAsset') && $object instanceof CaptionAsset) { return CaptionSearchPlugin::isAllowedPartner($object->getPartnerId()); } return false; }
public function shouldConsumeCreatedEvent(BaseObject $object) { if ($object instanceof flavorParamsOutputWrap && $object->getType() == WidevinePlugin::getAssetTypeCoreValue(WidevineAssetType::WIDEVINE_FLAVOR) && $this->shouldSyncWidevineRepositoryForPartner($object->getPartnerId())) { return true; } else { return false; } }
public function objectDeleted(BaseObject $object, BatchJob $raisedJob = null) { $shortLinks = ShortLinkPeer::retrieveByKuserId($object->getId(), $object->getPartnerId()); foreach ($shortLinks as $shortLink) { $shortLink->setStatus(ShortLinkStatus::DELETED); $shortLink->save(); } return true; }
/** * @param BaseObject $object * @param BatchJob $raisedJob * @return bool true if should continue to the next consumer */ public function objectDeleted(BaseObject $object, BatchJob $raisedJob = null) { if ($object instanceof asset && EdgeCastPlugin::isAllowedPartner($object->getPartnerId())) { self::purgeAssetFromEdgeCast($object); } if ($object instanceof entry && EdgeCastPlugin::isAllowedPartner($object->getPartnerId())) { self::purgeEntryFromEdgeCast($object); } return true; }
/** * @param BaseObject $object * @param SimpleXMLElement $mrss * @param kMrssParameters $mrssParams * @return SimpleXMLElement */ public function contribute(BaseObject $object, SimpleXMLElement $mrss, kMrssParameters $mrssParams = null) { if (!$object instanceof entry) { return; } $children = entryPeer::retrieveChildEntriesByEntryIdAndPartnerId($object->getId(), $object->getPartnerId()); if (!count($children)) { return; } $childrenNode = $mrss->addChild('children'); $childrenDom = dom_import_simplexml($childrenNode); foreach ($children as $child) { $childXML = kMrssManager::getEntryMrssXml($child); $childDom = dom_import_simplexml($childXML); $childDom = $childrenDom->ownerDocument->importNode($childDom, true); $childrenDom->appendChild($childDom); } }
/** * @param KalturaMetadataObjectType $objectType * @param BaseObject $fromObject * @param BaseObject $toObject */ protected function copyMetadata($objectType, BaseObject $fromObject, BaseObject $toObject) { KalturaLog::debug("Copy metadata type [{$objectType}] from " . get_class($fromObject) . '[' . $fromObject->getId() . "] to[" . $toObject->getId() . "]"); $c = new Criteria(); $c->add(MetadataPeer::OBJECT_TYPE, $objectType); $c->add(MetadataPeer::OBJECT_ID, $fromObject->getId()); $metadatas = MetadataPeer::doSelect($c); foreach ($metadatas as $metadata) { $newMetadata = $metadata->copy(); $newMetadata->setObjectId($toObject->getId()); $newMetadata->setPartnerId($toObject->getPartnerId()); $metadataProfileId = kObjectCopyHandler::getMappedId('MetadataProfile', $metadata->getMetadataProfileId()); if ($metadataProfileId) { $metadataProfile = MetadataProfilePeer::retrieveById($metadataProfileId); if ($metadataProfile) { $newMetadata->setMetadataProfileId($metadataProfileId); $newMetadata->setMetadataProfileVersion($metadataProfile->getVersion()); } } $newMetadata->save(); kFileSyncUtils::createSyncFileLinkForKey($newMetadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA), $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA), false); } }
public function objectChanged(BaseObject $object, array $modifiedColumns) { // if changed object is entry if ($object instanceof entry && in_array(entryPeer::MODERATION_STATUS, $modifiedColumns) && $object->getModerationStatus() == entry::ENTRY_MODERATION_STATUS_APPROVED) { $externalStorages = StorageProfilePeer::retrieveAutomaticByPartnerId($object->getPartnerId()); foreach ($externalStorages as $externalStorage) { if ($externalStorage->getTrigger() == StorageProfile::STORAGE_TEMP_TRIGGER_MODERATION_APPROVED) { self::exportEntry($object, $externalStorage); } } } // if changed object is flavor asset if ($object instanceof flavorAsset && !$object->getIsOriginal() && in_array(assetPeer::STATUS, $modifiedColumns) && $object->isLocalReadyStatus()) { $entry = $object->getentry(); $externalStorages = StorageProfilePeer::retrieveAutomaticByPartnerId($object->getPartnerId()); foreach ($externalStorages as $externalStorage) { if ($externalStorage->triggerFitsReadyAsset($entry->getId())) { self::exportFlavorAsset($object, $externalStorage); } } } return true; }
public function shouldConsumeChangedEvent(BaseObject $object, array $modifiedColumns) { if ($object instanceof Permission && $object->getPartnerId() && in_array($object->getType(), self::$partnerLevelPermissionTypes) && in_array(PermissionPeer::STATUS, $modifiedColumns) && $object->getStatus() == PermissionStatus::ACTIVE) { return true; } return false; }
public static function setPartnerIdForObj(BaseObject $obj) { if (self::$s_set_partner_id_policy == self::PARTNER_SET_POLICY_NONE) { return; } if ($obj == null) { return; } $current_obj_partner = $obj->getPartnerId(); if (self::$s_set_partner_id_policy == self::PARTNER_SET_POLICY_IF_NULL && $current_obj_partner == null) { $obj->setPartnerId(self::$s_current_partner_id); return; } // force $obj->setPartnerId(self::$s_current_partner_id); }
/** Will set the 'display_in_search' field according to business-logic per object type // kuser | kshow | entry // for objects that are search worthy - search_text will hold text from relevant columns depending on the object type */ public static function setDisplayInSearch(BaseObject $obj, $parent_obj = null) { if ($obj == null) { return; } // update the displayInSearch with the logic above only when the object is new or null if ($obj->isNew() || $obj->getDisplayInSearch() === null) { $res = myPartnerUtils::shouldDisplayInSearch($obj->getPartnerId()); $obj_id = $obj->getId(); if ($obj_id && is_numeric($obj_id)) { self::setRes($res, $obj_id > entry::MINIMUM_ID_TO_DISPLAY); } if ($res) { if ($obj instanceof kuser) { // if the status is not self::setRes($res, $obj->getStatus() == KuserStatus::ACTIVE); } elseif ($obj instanceof kshow) { self::setRes($res, $obj->getViewPermissions() == kshow::KSHOW_PERMISSION_EVERYONE || $obj->getViewPermissions() == null); // if the viewPermission changed from kshow::KSHOW_PERMISSION_EVERYONE to something else // update all entries if ($res && $obj->isColumnModified(kshowPeer::VIEW_PERMISSIONS)) { $entries = $obj->getentrys(); foreach ($entries as $entry) { // run this code for each entry self::setDisplayInSearch($entry, $obj); } } } elseif ($obj instanceof entry) { // status=READY , type=MEDIACLIP, view permissions of kshow self::setRes($res, true); } else { throw new Exception("mySearchUtils::setDisplayInSearch - cannot handle objects of type " . get_class($obj)); } } $obj->setDisplayInSearch($res); } else { // if not new - use the value from the object $res = $obj->getDisplayInSearch(); } // echo __METHOD__ . " (" . get_class ( $obj ) . ") res [$res]\n"; $words = ""; $fields_to_use = $obj->getColumnNames(); foreach ($fields_to_use as $field) { $field_str = $obj->getByName($field, BasePeer::TYPE_FIELDNAME); // call_user_func ( array ( $obj , $func_name ) ); $words .= " " . $field_str; } $extra_invisible_data = null; if ($obj instanceof kshow) { $type = $obj->getType(); if (empty($type)) { $type = kshow::KSHOW_TYPE_OTHER; } // add the category to the search $words .= " _CAT_" . $type; } elseif ($obj instanceof entry) { $extra_invisible_data = "_MEDIA_TYPE_" . $obj->getMediaType(); $type = $obj->getType(); // add the SEARCH_ENTRY_TYPE_RC to the words if ($type == entryType::MIX) { $extra_invisible_data .= " " . self::SEARCH_ENTRY_TYPE_RC; } } $prepared_text = self::prepareSearchText($words); $partner_id = $obj->getPartnerId(); // if res == 1 - only for partner , if == 2 - also for kaltura network $obj->setSearchText(self::addPartner($partner_id, $prepared_text, $res, $extra_invisible_data)); }
/** * @param BaseObject $object * @return bool true if the consumer should handle the event */ public function shouldConsumeDeletedEvent(BaseObject $object) { if ($object instanceof FileSync) { if (!PermissionPeer::isValidForPartner(PermissionName::FEATURE_REMOTE_STORAGE, $object->getPartnerId())) { return false; } if ($object->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL) { $storage = StorageProfilePeer::retrieveByPK($object->getDc()); if ($storage->getStatus() == StorageProfile::STORAGE_STATUS_AUTOMATIC && $storage->getAllowAutoDelete()) { return true; } } } return false; }
/** * Return textual search data to be associated with the object * * @param BaseObject $object * @return string */ public static function getSearchData(BaseObject $object) { if ($object instanceof entry) { if (self::isAllowedPartner($object->getPartnerId())) { return kMetadataManager::getSearchValuesByObject(Metadata::TYPE_ENTRY, $object->getId()); } } return null; }
public function objectCreated(BaseObject $object) { if ($object instanceof Permission) { // changes in permissions for partner, may require new cache generation if ($object->getPartnerId() != PartnerPeer::GLOBAL_PARTNER) { self::markPartnerRoleCacheDirty($object->getPartnerId()); return true; } } if ($object instanceof PermissionToPermissionItem) { $permission = $object->getPermission(); if ($permission && $permission->getPartnerId() != PartnerPeer::GLOBAL_PARTNER) { self::markPartnerRoleCacheDirty($permission->getPartnerId()); return true; } } return true; }
public static function getSearchData(BaseObject $object) { if ($object instanceof entry && self::isAllowedPartner($object->getPartnerId())) { return self::getCaptionSearchData($object); } return null; }
/** * @param BaseObject $object * @return bool true if the consumer should handle the event */ public function shouldConsumeDeletedEvent(BaseObject $object) { if ($object instanceof FileSync) { if (!PermissionPeer::isValidForPartner(PermissionName::FEATURE_REMOTE_STORAGE, $object->getPartnerId())) { return false; } if ($object->getFileType() == FileSync::FILE_SYNC_FILE_TYPE_URL) { $storage = StorageProfilePeer::retrieveByPK($object->getDc()); KalturaLog::debug("storage auto delete policy: " . $storage->getAllowAutoDelete()); if ($storage->getStatus() == StorageProfile::STORAGE_STATUS_AUTOMATIC && $storage->getAllowAutoDelete()) { return true; } KalturaLog::debug('Unable to consume deleted event; storageProfile status is not equal to ' . StorageProfile::STORAGE_STATUS_AUTOMATIC); } } return false; }
public static function getSearchData(BaseObject $object) { if ($object instanceof entry) { if (self::isAllowedPartner($object->getPartnerId())) { return kMetadataManager::getSearchValuesByObject(MetadataObjectType::ENTRY, $object->getId()); } } if ($object instanceof category) { if (self::isAllowedPartner($object->getPartnerId())) { return kMetadataManager::getSearchValuesByObject(MetadataObjectType::CATEGORY, $object->getId()); } } if ($object instanceof Partner) { if (self::isAllowedPartner($object->getPartnerId())) { return kMetadataManager::getSearchValuesByObject(MetadataObjectType::PARTNER, $object->getId()); } } if ($object instanceof kuser) { if (self::isAllowedPartner($object->getPartnerId())) { return kMetadataManager::getSearchValuesByObject(MetadataObjectType::USER, $object->getId()); } } if ($object instanceof Metadata) { if (self::isAllowedPartner($object->getPartnerId())) { return kMetadataManager::getMetadataValuesByMetadataObjects(array($object)); } } return null; }
public function objectChanged(BaseObject $object, array $modifiedColumns) { $privacyContexts = null; if ($object instanceof entry) { $criteria = new Criteria(); $criteria->add(categoryEntryPeer::ENTRY_ID, $object->getId()); $categoryEntries = categoryEntryPeer::doSelect($criteria); $privacyContexts = array(self::NULL_PC); if (count($categoryEntries)) { foreach ($categoryEntries as $categoryEntry) { /* @var $categoryEntry categoryEntry */ if ($categoryEntry->getPrivacyContext() != "") { $privacyContexts = array_merge($privacyContexts, self::trimObjectTags($categoryEntry->getPrivacyContext())); } else { $privacyContexts[] = kEntitlementUtils::DEFAULT_CONTEXT; } } $privacyContexts = array_unique($privacyContexts); } } $oldTags = $object->getColumnsOldValue(self::getClassConstValue(get_class($object->getPeer()), self::TAGS_FIELD_NAME)); $newTags = $object->getTags(); $tagsForDelete = implode(',', array_diff(explode(',', $oldTags), explode(',', $newTags))); $tagsForUpdate = implode(',', array_diff(explode(',', $newTags), explode(',', $oldTags))); if ($oldTags && $oldTags != "") { self::decrementExistingTagsInstanceCount($tagsForDelete, $object->getPartnerId(), get_class($object), $privacyContexts); } self::addOrIncrementTags($tagsForUpdate, $object->getPartnerId(), get_class($object), $privacyContexts); }
/** Will set the 'display_in_search' field according to business-logic per object type // kuser | kshow | entry // for objects that are search worthy - search_text will hold text from relevant columns depending on the object type */ public static function setDisplayInSearch(BaseObject $obj, $parent_obj = null) { if ($obj == null) { return; } // update the displayInSearch with the logic above only when the object is new or null if ($obj->isNew() || $obj->getDisplayInSearch() === null) { $res = myPartnerUtils::shouldDisplayInSearch($obj->getPartnerId()); $obj_id = $obj->getId(); if ($obj_id && is_numeric($obj_id)) { self::setRes($res, $obj_id > entry::MINIMUM_ID_TO_DISPLAY); } if ($res) { if ($obj instanceof kuser) { // if the status is not self::setRes($res, $obj->getStatus() == KuserStatus::ACTIVE); } elseif ($obj instanceof kshow) { self::setRes($res, $obj->getViewPermissions() == kshow::KSHOW_PERMISSION_EVERYONE || $obj->getViewPermissions() == null); // if the viewPermission changed from kshow::KSHOW_PERMISSION_EVERYONE to something else // update all entries if ($res && $obj->isColumnModified(kshowPeer::VIEW_PERMISSIONS)) { $entries = $obj->getentrys(); foreach ($entries as $entry) { // run this code for each entry self::setDisplayInSearch($entry, $obj); } } } elseif ($obj instanceof entry) { // status=READY , type=MEDIACLIP, view permissions of kshow self::setRes($res, true); } else { throw new Exception("mySearchUtils::setDisplayInSearch - cannot handle objects of type " . get_class($obj)); } } $obj->setDisplayInSearch($res); } }