protected function addData($playlist) { // TODO - how to retrieve the widget_id and ui_conf_id for this partner ? // ui_conf_id = 190 will hold the correct ui_conf for the playlist list($embed, $width, $height) = myPlaylistUtils::getEmbedCode($playlist, null, 199); $this->addMsg("embed", $embed); $this->addMsg("width", $width); $this->addMsg("height", $height); }
protected function validateEntry($entry) { myPlaylistUtils::validatePlaylist($entry); // this is a small hack - to use this hook to update the count, countDate & the lengthInMsecs for the playlist // only if set "update_stats" if ($this->getP("update_stats")) { myPlaylistUtils::updatePlaylistStatistics($entry->getPartnerId(), $entry); } }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser, $create_cachekey = false) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; // TODO - verify permissions for viewing lists $detailed = $this->getP("detailed", false); $limit = $this->getP("page_size", 10); $limit = $this->maxPageSize($limit); $page = $this->getP("page", 1); $user_filter_prefix = $this->getP("fp", "filter"); $offset = ($page - 1) * $limit; // TODO - should limit search to partner ?? // kuserPeer::setUseCriteriaFilter( false ); // entryPeer::setUseCriteriaFilter( false ); $playlist_id = $this->getPM("playlist_id"); $input_params = $this->getInputParams(); $extra_filters = array(); for ($i = 1; $i < self::MAX_FILTER_COUNT; $i++) { // filter $extra_filter = new entryFilter(); $fields_set = $extra_filter->fillObjectFromRequest($input_params, "{$user_filter_prefix}{$i}_", null); if ($fields_set) { $extra_filters[$i] = $extra_filter; } } // this service is executed twice! (first time for the cache key, second time for the execution) if (is_null($this->playlist)) { $playlist = entryPeer::retrieveByPK($playlist_id); if (!$playlist) { throw new APIException(APIErrors::INVALID_ENTRY_ID, "Playlist", $playlist_id); } myPartnerUtils::addPartnerToCriteria(new accessControlPeer(), $playlist->getPartnerId(), $this->getPrivatePartnerData(), $this->partnerGroup2(), null); $this->playlist = $playlist; } if ($create_cachekey) { if ($this->isAdmin()) { return null; } $cache_key_arr = array("playlist_id" => $playlist_id, "filters" => $extra_filters); $cahce_key = new executionCacheKey(); $cahce_key->expiry = 600; $cahce_key->key = md5(print_r($cache_key_arr, true)); return $cahce_key; } if ($this->isAdmin()) { myPlaylistUtils::setIsAdminKs(true); } $entry_list = myPlaylistUtils::executePlaylistById($partner_id, $playlist_id, $extra_filters, $detailed); myEntryUtils::updatePuserIdsForEntries($entry_list); $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $wrapper = objectWrapperBase::getWrapperClass($entry_list, $level); $this->addMsg("count", count($entry_list)); $this->addMsg($this->getObjectPrefix(), $wrapper); }
protected function validateEntry($entry) { myPlaylistUtils::validatePlaylist($entry); // this is a small hack - to use this hook to update the count, countDate & the lengthInMsecs for the playlist // only if set "update_stats" $update_stats = $this->getP("update_stats"); if ($update_stats == "false" || $update_stats === "0") { $update_stats = false; } if ($update_stats) { myPlaylistUtils::updatePlaylistStatistics($entry->getPartnerId(), $entry); } $entry->setDisplayInSearch(2); // make all the playlist entries PUBLIC ! }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { // TODO - verify permissions for viewing lists $detailed = $this->getP("detailed", false); // fill the playlist (infact only the mediaType and contentData are important $playlist = new entry(); $playlist->setType(entryType::PLAYLIST); // prepare the playlist type before filling from request $obj_wrapper = objectWrapperBase::getWrapperClass($playlist, 0); $playlist->setMediaType($this->getP("playlist_mediaType")); $data_content = $this->getP("playlist_dataContent"); $playlist->setDataContent($data_content); myPlaylistUtils::updatePlaylistStatistics($partner_id, $playlist); $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $wrapper = objectWrapperBase::getWrapperClass($playlist, $level); $this->addMsg("playlist", $wrapper); }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser, $create_cachekey = false) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; // TODO - verify permissions for viewing lists $detailed = $this->getP("detailed", false); if (!$detailed) { $detailed = false; } $playlist_id = $this->getPM("playlist_id"); if ($create_cachekey) { if ($this->isAdmin()) { return null; } $ks_partner_id = null; $privileges = null; $ks = ks::fromSecureString(kCurrentContext::$ks); if ($ks) { $ks_partner_id = $ks->getPartnerId(); $privileges = $ks->getPrivileges(); } $cache_key_arr = array("playlist_id" => $playlist_id, "partner_id" => $partner_id, "ks_partner_id" => $ks_partner_id, "detailed" => $detailed, "user" => kCurrentContext::$ks_uid, "privileges" => $privileges, "is_admin" => $this->isAdmin(), "protocol" => infraRequestUtils::getProtocol()); $cahce_key = new executionCacheKey(); $cahce_key->expiry = 600; $cahce_key->key = md5(print_r($cache_key_arr, true)); return $cahce_key; } // this service is executed twice! (first time for the cache key, second time for the execution) if (is_null($this->playlist)) { $playlist = entryPeer::retrieveByPK($playlist_id); if (!$playlist) { throw new APIException(APIErrors::INVALID_ENTRY_ID, "Playlist", $playlist_id); } myPartnerUtils::addPartnerToCriteria('accessControl', $playlist->getPartnerId(), $this->getPrivatePartnerData(), $this->partnerGroup2(), null); $this->playlist = $playlist; } if ($this->isAdmin()) { myPlaylistUtils::setIsAdminKs(true); } $entry_list = myPlaylistUtils::executePlaylistById($partner_id, $playlist_id, null, $detailed); myEntryUtils::updatePuserIdsForEntries($entry_list); $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $wrapper = objectWrapperBase::getWrapperClass($entry_list, $level); $this->addMsg("count", count($entry_list)); $this->addMsg($this->getObjectPrefix(), $wrapper); }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { // TODO - verify permissions for viewing lists $detailed = $this->getP("detailed", false); if (!$detailed) { $detailed = false; } $limit = $this->getP("page_size", 10); $limit = $this->maxPageSize($limit); $page = $this->getP("page", 1); $user_filter_prefix = $this->getP("fp", "filter"); $offset = ($page - 1) * $limit; // TODO - should limit search to partner ?? // kuserPeer::setUseCriteriaFilter( false ); // entryPeer::setUseCriteriaFilter( false ); $input_params = $this->getInputParams(); // fill the playlist (infact only the mediaType and contentData are important $playlist = new entry(); $playlist->setType(entryType::PLAYLIST); // prepare the playlist type before filling from request $obj_wrapper = objectWrapperBase::getWrapperClass($playlist, 0); $playlist->setMediaType($this->getP("playlist_mediaType")); $data_content = $this->getP("playlist_dataContent"); $playlist->setDataContent($data_content); /* $updateable_fields = $obj_wrapper->getUpdateableFields() ; $fields_modified = baseObjectUtils::fillObjectFromMapOrderedByFields( $input_params , $playlist , "playlist_" , $updateable_fields , BasePeer::TYPE_PHPNAME ,false ); */ // rest is similar to the executeplaylist service $extra_filters = array(); for ($i = 1; $i < self::MAX_FILTER_COUNT; $i++) { // filter $extra_filter = new entryFilter(); $fields_set = $extra_filter->fillObjectFromRequest($input_params, "{$user_filter_prefix}{$i}_", null); $extra_filters[$i] = $extra_filter; } $entry_list = myPlaylistUtils::executePlaylist($partner_id, $playlist, $extra_filters, $detailed); myEntryUtils::updatePuserIdsForEntries($entry_list); $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $wrapper = objectWrapperBase::getWrapperClass($entry_list, $level); $this->addMsg("count", count($entry_list)); $this->addMsg($this->getObjectPrefix(), $wrapper); }
public function playlistContentXmlToFilters() { list($totalResults, $listOfFilters) = myPlaylistUtils::getPlaylistFilterListStruct($this->playlistContent); // $totalResults is SimpleXMLElement $this->filters = new KalturaMediaEntryFilterForPlaylistArray(); foreach ($listOfFilters as $entryFilterXml) { $entryFilter = new entryFilter(); $entryFilter->fillObjectFromXml($entryFilterXml, "_"); $filter = new KalturaMediaEntryFilterForPlaylist(); $filter->fromObject($entryFilter); $this->filters[] = $filter; } $this->totalResults = (int) $totalResults; // will cast SimpleXMLElement correctly }
//= input ( 'playlist id' , 'text' , 'playlist_id' ) ?> </div> <div id='dynamic'> <?php require_once __DIR__ . '/galleryPartialSuccess.php'; ?> </div id='dynamic'> </form> <div id='widget' style='position: absolute; left: 1200px; top: 200px'> <!-- widget --> <?php if ($is_playlist) { echo myPlaylistUtils::getEmbedCode($playlist_id, $widget_id, $ui_conf_id); } else { if ($widget) { echo $widget->getWidgetHtml("kaltura_player"); } else { echo "No widget to display"; } } ?> </div> <script type="text/javascript"> <!-- jQuery.noConflict(); updateAllStatus(document.getElementById("filter__in_status_all")); updateAllType(document.getElementById("filter__in_type_all")); //-->
/** * Retrieve playlist statistics * * @action getStatsFromContent * @param KalturaPlaylistType $playlistType * @param string $playlistContent * @return KalturaPlaylist */ function getStatsFromContentAction($playlistType, $playlistContent) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $dbPlaylist = new entry(); $dbPlaylist->setId(-1); // set with some dummy number so the getDataContent will later work properly $dbPlaylist->setType(entryType::PLAYLIST); // prepare the playlist type before filling from request $dbPlaylist->setMediaType($playlistType); $dbPlaylist->setDataContent($playlistContent); myPlaylistUtils::updatePlaylistStatistics($this->getPartnerId(), $dbPlaylist); //, $extra_filters , $detailed ); $playlist = new KalturaPlaylist(); // start from blank $playlist->fromObject($dbPlaylist, $this->getResponseProfile()); return $playlist; }
protected function servePlaylist($entry) { // allow only manual playlist if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_TEXT) { KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE); } // get request parameters $flavorParamIds = $this->getRequestParameter("flavorParamIds"); if ($flavorParamIds) { $flavorParamIds = explode(',', $flavorParamIds); } $version = $this->getRequestParameter("v"); // execute the playlist if ($version) { $entry->setDesiredVersion($version); } list($entryIds, $durations, $referenceEntry) = myPlaylistUtils::executeStitchedPlaylist($entry); if (!$referenceEntry) { KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND); } // load the flavor assets // Note: not filtering by $flavorParamIds here, so that in case some flavor is missing // we can fill in the gap using some other flavor params $c = new Criteria(); $c->add(assetPeer::ENTRY_ID, $entryIds, Criteria::IN); $c->add(assetPeer::STATUS, flavorAsset::FLAVOR_ASSET_STATUS_READY); $flavorTypes = assetPeer::retrieveAllFlavorsTypes(); $c->add(assetPeer::TYPE, $flavorTypes, Criteria::IN); $flavorAssets = assetPeer::doSelect($c); // group the flavors by entry and flavor params $groupedFlavors = array(); foreach ($flavorAssets as $flavor) { if (!isset($groupedFlavors[$flavor->getEntryId()])) { $groupedFlavors[$flavor->getEntryId()] = array(); } $groupedFlavors[$flavor->getEntryId()][$flavor->getFlavorParamsId()] = $flavor; } // remove entries that don't have flavors for ($i = count($entryIds) - 1; $i >= 0; $i--) { $entryId = $entryIds[$i]; if (isset($groupedFlavors[$entryId])) { continue; } unset($entryIds[$i]); unset($durations[$i]); } // get the flavor params of the reference entry that should be returned $referenceEntryFlavorParamsIds = array_keys($groupedFlavors[$referenceEntry->getId()]); if ($flavorParamIds) { $flavorParamIds = array_intersect($referenceEntryFlavorParamsIds, $flavorParamIds); } else { $flavorParamIds = $referenceEntryFlavorParamsIds; } if (!$flavorParamIds) { KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } // build the sequences $storeCache = true; $sequences = array(); foreach ($flavorParamIds as $flavorParamsId) { $referenceFlavor = $groupedFlavors[$referenceEntry->getId()][$flavorParamsId]; // build the clips of the current sequence $clips = array(); foreach ($entryIds as $entryId) { if (isset($groupedFlavors[$entryId][$flavorParamsId])) { $flavor = $groupedFlavors[$entryId][$flavorParamsId]; } else { // don't have a flavor for this entry in the desired flavor params, // choose the one with the closest bitrate $flavor = null; foreach ($groupedFlavors[$entryId] as $curFlavor) { if (!$flavor || abs($curFlavor->getBitrate() - $referenceFlavor->getBitrate()) < abs($flavor->getBitrate() - $referenceFlavor->getBitrate())) { $flavor = $curFlavor; } } } // get the file path of the flavor $syncKey = $flavor->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, false, false); if ($fileSync) { $resolvedFileSync = kFileSyncUtils::resolve($fileSync); $path = $resolvedFileSync->getFullPath(); } else { error_log('missing file sync for flavor ' . $flavor->getId() . ' version ' . $flavor->getVersion()); $path = ''; $storeCache = false; } $clips[] = array('type' => 'source', 'path' => $path); } $sequences[] = array('clips' => $clips); } // build the json $mediaSet = array('durations' => $durations, 'sequences' => $sequences); $json = json_encode($mediaSet); $renderer = new kRendererString($json, self::JSON_CONTENT_TYPE); if ($storeCache) { $this->storeCache($renderer, $entry->getPartnerId()); } $renderer->output(); KExternalErrors::dieGracefully(); }
public function getDataUrl($version = NULL) { if ($this->getType() == entryType::PLAYLIST) { return myPlaylistUtils::getExecutionUrl($this); } //$path = $this->getThumbnailPath ( $version ); $path = myPartnerUtils::getUrlForPartner($this->getPartnerId(), $this->getSubpId()) . "/flvclipper/entry_id/" . $this->getId(); $current_version = $this->getVersion(); if ($version) { $path .= "/version/{$version}"; } else { $path .= "/version/{$current_version}"; } $url = myPartnerUtils::getCdnHost($this->getPartnerId()) . $path; return $url; }
public static function copyEntry(entry $entry, Partner $toPartner = null, $dontCopyUsers = false) { KalturaLog::log("copyEntry - Copying entry [" . $entry->getId() . "] to partner [" . $toPartner->getId() . "]"); $newEntry = $entry->copy(); $newEntry->setIntId(null); $newEntry->setCategories(null); $newEntry->setCategoriesIds(null); if ($toPartner instanceof Partner) { $newEntry->setPartnerId($toPartner->getId()); $newEntry->setSubpId($toPartner->getId() * 100); $newEntry->setAccessControlId($toPartner->getDefaultAccessControlId()); } $newKuser = null; if (!$dontCopyUsers) { // copy the kuser (if the same puser id exists its kuser will be used) kuserPeer::setUseCriteriaFilter(false); $kuser = $entry->getKuser(); $newKuser = kuserPeer::createKuserForPartner($newEntry->getPartnerId(), $kuser->getPuserId()); $newEntry->setKuserId($newKuser->getId()); $newEntry->setCreatorKuserId($newKuser->getId()); kuserPeer::setUseCriteriaFilter(true); } // copy the kshow kshowPeer::setUseCriteriaFilter(false); $kshow = $entry->getKshow(); if ($kshow) { $newKshow = $kshow->copy(); $newKshow->setIntId(null); $newKshow->setPartnerId($toPartner->getId()); $newKshow->setSubpId($toPartner->getId() * 100); if ($newKuser) { $newKshow->setProducerId($newKuser->getId()); } $newKshow->save(); $newEntry->setKshowId($newKshow->getId()); } kshowPeer::setUseCriteriaFilter(true); // reset the statistics myEntryUtils::resetEntryStatistics($newEntry); // set the new partner id into the default category criteria filter $defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter(); $oldPartnerId = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID); $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID); $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId()); // save the entry $newEntry->save(); // restore the original partner id in the default category criteria filter $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID); $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerId); KalturaLog::log("copyEntry - New entry [" . $newEntry->getId() . "] was created"); if ($entry->getStatus() != entryStatus::READY) { $clonePendingEntries = $entry->getClonePendingEntries(); $clonePendingEntries[] = $newEntry->getId(); $entry->setClonePendingEntries($clonePendingEntries); $entry->save(); } else { self::copyEntryData($entry, $newEntry); } //if entry is a static playlist, link between it and its new child entries if ($entry->getType() == entryType::PLAYLIST) { switch ($entry->getMediaType()) { case entry::ENTRY_MEDIA_TYPE_TEXT: $from = $entry->getDataContent(); KalturaLog::debug("Entries to copy from source static playlist: [{$from}]"); $fromEntryIds = explode(",", $from); $toEntryIds = array(); foreach ($fromEntryIds as $fromEntryId) { $toEntryIds[] = kObjectCopyHandler::getMappedId(entryPeer::OM_CLASS, $fromEntryId); } $newEntry->setDataContent(implode(",", $toEntryIds)); break; case entry::ENTRY_MEDIA_TYPE_XML: list($totalResults, $fromFiltersList) = myPlaylistUtils::getPlaylistFilterListStruct($entry->getDataContent()); $toPlaylistXml = new SimpleXMLElement("<playlist/>"); $toPlaylistXml->addChild("total_results", $totalResults); $toFiltersXml = $toPlaylistXml->addChild("filters"); foreach ($fromFiltersList as $filterXML) { $entryFilter = new entryFilter(); $entryFilter->fillObjectFromXml($filterXML, "_"); if (isset($entryFilter->fields["_matchand_categories_ids"])) { $categoriesIds = explode(",", $entryFilter->fields["_matchand_categories_ids"]); $newCategoriesIds = array(); foreach ($categoriesIds as $categoryId) { $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId); } $entryFilter->fields["_matchand_categories_ids"] = implode(",", $newCategoriesIds); } if (isset($entryFilter->fields["_matchor_categories_ids"])) { $categoriesIds = explode(",", $entryFilter->fields["_matchor_categories_ids"]); $newCategoriesIds = array(); foreach ($categoriesIds as $categoryId) { $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId); } $entryFilter->fields["_matchor_categories_ids"] = implode(",", $newCategoriesIds); } if (isset($entryFilter->fields["_in_category_ancestor_id"])) { $categoriesIds = explode(",", $entryFilter->fields["_in_category_ancestor_id"]); $newCategoriesIds = array(); foreach ($categoriesIds as $categoryId) { $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId); } $entryFilter->fields["_in_category_ancestor_id"] = implode(",", $newCategoriesIds); } $toEntryFilterXML = $toFiltersXml->addChild("filter"); $toEntryFilterXML = $entryFilter->toXml($toEntryFilterXML); } $newEntry->setDataContent($toPlaylistXml->asXML()); break; } } // copy relationships to categories KalturaLog::debug('Copy relationships to categories from entry [' . $entry->getId() . '] to entry [' . $newEntry->getId() . ']'); $c = KalturaCriteria::create(categoryEntryPeer::OM_CLASS); $c->addAnd(categoryEntryPeer::ENTRY_ID, $entry->getId()); $c->addAnd(categoryEntryPeer::STATUS, CategoryEntryStatus::ACTIVE, Criteria::EQUAL); $c->addAnd(categoryEntryPeer::PARTNER_ID, $entry->getPartnerId()); categoryEntryPeer::setUseCriteriaFilter(false); $categoryEntries = categoryEntryPeer::doSelect($c); categoryEntryPeer::setUseCriteriaFilter(true); // Create srcCategoryIdToDstCategoryIdMap - a map of source partner category ids -> dst. partner category ids // // Build src category IDs set $srcCategoryIdSet = array(); foreach ($categoryEntries as $categoryEntry) { $srcCategoryIdSet[] = $categoryEntry->getCategoryId(); } $illegalCategoryStatus = array(CategoryStatus::DELETED, CategoryStatus::PURGED); // Get src category objects $c = KalturaCriteria::create(categoryPeer::OM_CLASS); $c->add(categoryPeer::ID, $srcCategoryIdSet, Criteria::IN); $c->addAnd(categoryPeer::PARTNER_ID, $entry->getPartnerId()); $c->addAnd(categoryPeer::STATUS, $illegalCategoryStatus, Criteria::NOT_IN); categoryPeer::setUseCriteriaFilter(false); $srcCategories = categoryPeer::doSelect($c); categoryPeer::setUseCriteriaFilter(true); // Map the category names to their IDs $fullNamesToSrcCategoryIdMap = array(); foreach ($srcCategories as $category) { $fullNamesToSrcCategoryIdMap[$category->getFullName()] = $category->getId(); } // Get dst. partner categories based on src. category full-names $c = KalturaCriteria::create(categoryPeer::OM_CLASS); $c->add(categoryPeer::FULL_NAME, array_keys($fullNamesToSrcCategoryIdMap), KalturaCriteria::IN); $c->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId()); $c->addAnd(categoryPeer::STATUS, $illegalCategoryStatus, Criteria::NOT_IN); categoryPeer::setUseCriteriaFilter(false); $dstCategories = categoryPeer::doSelect($c); categoryPeer::setUseCriteriaFilter(true); $srcCategoryIdToDstCategoryIdMap = array(); foreach ($dstCategories as $dstCategory) { $fullName = $dstCategory->getFullName(); if (array_key_exists($fullName, $fullNamesToSrcCategoryIdMap)) { $srcCategoryId = $fullNamesToSrcCategoryIdMap[$fullName]; $srcCategoryIdToDstCategoryIdMap[$srcCategoryId] = $dstCategory->getId(); } } foreach ($categoryEntries as $categoryEntry) { /* @var $categoryEntry categoryEntry */ $newCategoryEntry = $categoryEntry->copy(); $newCategoryEntry->setPartnerId($newEntry->getPartnerId()); $newCategoryEntry->setEntryId($newEntry->getId()); $srcCategoryId = $categoryEntry->getCategoryId(); if (!array_key_exists($srcCategoryId, $srcCategoryIdToDstCategoryIdMap)) { continue; // Skip the category_entry's creation } $dstCategoryId = $srcCategoryIdToDstCategoryIdMap[$srcCategoryId]; $newCategoryEntry->setCategoryId($dstCategoryId); categoryPeer::setUseCriteriaFilter(false); entryPeer::setUseCriteriaFilter(false); $newCategoryEntry->save(); entryPeer::setUseCriteriaFilter(true); categoryPeer::setUseCriteriaFilter(true); } return $newEntry; }
public function verifyPlaylistPrivileges($required_priv_name, $entryId, $partnerId) { // break all privileges to their pairs - this is to support same "multi-priv" method expected for // edit privilege (edit:XXX,edit:YYY,...) $allPrivileges = explode(',', $this->privileges); // foreach pair - check privileges on playlist foreach ($allPrivileges as $priv) { // extract playlist ID from pair $exPrivileges = explode(':', $priv); if ($exPrivileges[0] == $required_priv_name) { // if found in playlist - return true if (myPlaylistUtils::isEntryInPlaylist($entryId, $exPrivileges[1], $partnerId)) { return true; } } } return false; }
public function __construct($feedId, $feedProcessingKey = null, $ks = null) { $this->feedProcessingKey = $feedProcessingKey; myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $microTimeStart = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialize "); $this->syndicationFeedDb = $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId); if (!$syndicationFeedDB) { throw new Exception("Feed Id not found"); } kCurrentContext::initKsPartnerUser($ks, $syndicationFeedDB->getPartnerId(), ''); kPermissionManager::init(); kEntitlementUtils::initEntitlementEnforcement($syndicationFeedDB->getPartnerId(), $syndicationFeedDB->getEnforceEntitlement()); if (!is_null($syndicationFeedDB->getPrivacyContext()) && $syndicationFeedDB->getPrivacyContext() != '') { kEntitlementUtils::setPrivacyContextSearch($syndicationFeedDB->getPrivacyContext()); } $tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType()); $tmpSyndicationFeed->fromObject($syndicationFeedDB); $this->syndicationFeed = $tmpSyndicationFeed; // add partner to default criteria myPartnerUtils::addPartnerToCriteria('category', $this->syndicationFeed->partnerId, true); myPartnerUtils::addPartnerToCriteria('asset', $this->syndicationFeed->partnerId, true); myPartnerUtils::resetPartnerFilter('entry'); $this->baseCriteria = clone entryPeer::getDefaultCriteriaFilter(); $startDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::START_DATE, time(), Criteria::LESS_EQUAL); $startDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::START_DATE, null)); $this->baseCriteria->addAnd($startDateCriterion); $endDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::END_DATE, time(), Criteria::GREATER_EQUAL); $endDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::END_DATE, null)); $this->baseCriteria->addAnd($endDateCriterion); $this->baseCriteria->addAnd(entryPeer::PARTNER_ID, $this->syndicationFeed->partnerId); $this->baseCriteria->addAnd(entryPeer::STATUS, entryStatus::READY); $this->baseCriteria->addAnd(entryPeer::TYPE, array(entryType::MEDIA_CLIP, entryType::MIX), Criteria::IN); $this->baseCriteria->addAnd(entryPeer::MODERATION_STATUS, array(entry::ENTRY_MODERATION_STATUS_REJECTED, entry::ENTRY_MODERATION_STATUS_PENDING_MODERATION), Criteria::NOT_IN); if ($this->syndicationFeed->playlistId) { $this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId); foreach ($this->entryFilters as $entryFilter) { $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); // partner scope already attached } $playlist = entryPeer::retrieveByPK($this->syndicationFeed->playlistId); if ($playlist) { if ($playlist->getMediaType() != entry::ENTRY_MEDIA_TYPE_XML) { $this->staticPlaylist = true; $this->staticPlaylistEntriesIdsOrder = explode(',', $playlist->getDataContent()); } } } else { $this->entryFilters = array(); } $microTimeEnd = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]"); }
protected function initPlaylistFlavorAssetArray() { list($entryIds, $durations, $mediaEntry) = myPlaylistUtils::executeStitchedPlaylist($this->entry); if (!$mediaEntry) { KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND); } $this->duration = array_sum($durations) / 1000; $flavorAssets = array(); if ($this->flavorIds) { $flavorAssets = assetPeer::retrieveReadyByEntryId($mediaEntry->getId(), $this->flavorIds); $flavorAssets = $this->removeNotAllowedFlavors($flavorAssets); $flavorAssets = $this->removeMaxBitrateFlavors($flavorAssets); } if (!$flavorAssets) { $flavorAssets = assetPeer::retrieveReadyFlavorsByEntryId($mediaEntry->getId()); $flavorAssets = $this->removeNotAllowedFlavors($flavorAssets); $flavorAssets = $this->removeMaxBitrateFlavors($flavorAssets); $flavorAssets = $this->deliveryAttributes->filterFlavorsByTags($flavorAssets); } $this->deliveryAttributes->setStorageId(null); $this->deliveryAttributes->setFlavorAssets($flavorAssets); }
public function __construct($feedId) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $microTimeStart = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialize "); // initialize the database for all services DbManager::setConfig(kConf::getDB()); DbManager::initialize(); $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId); if (!$syndicationFeedDB) { throw new Exception("Feed Id not found"); } $tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType()); $tmpSyndicationFeed->fromObject($syndicationFeedDB); $this->syndicationFeed = $tmpSyndicationFeed; // add partner to default criteria categoryPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true); flavorAssetPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true); $this->baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $startDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::START_DATE, time(), Criteria::LESS_EQUAL); $startDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::START_DATE, null)); $this->baseCriteria->addAnd($startDateCriterion); $endDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::END_DATE, time(), Criteria::GREATER_EQUAL); $endDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::END_DATE, null)); $this->baseCriteria->addAnd($endDateCriterion); $entryFilter = new entryFilter(); $entryFilter->setPartnerSearchScope($this->syndicationFeed->partnerId); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setTypeIn(array(entryType::MEDIA_CLIP, entryType::MIX)); $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED); $entryFilter->setDurationGreaterThan(0); $entryFilter->attachToCriteria($this->baseCriteria); if ($this->syndicationFeed->playlistId) { $this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId); } else { $this->entryFilters = array(); } $microTimeEnd = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]"); }
/** * Static method to set the static $playlistContext variable * @param kContext $v */ public static function setPlaylistContext(kContext $v) { self::$playlistContext = $v; }
public function __construct($feedId) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $microTimeStart = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialize "); // initialize the database for all services DbManager::setConfig(kConf::getDB()); DbManager::initialize(); $this->syndicationFeedDB = $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId); if (!$syndicationFeedDB) { throw new Exception("Feed Id not found"); } kEntitlementUtils::initEntitlementEnforcement($syndicationFeedDB->getPartnerId(), $syndicationFeedDB->getEnforceEntitlement()); if (!is_null($syndicationFeedDB->getPrivacyContext()) && $syndicationFeedDB->getPrivacyContext() != '') { kEntitlementUtils::setPrivacyContextSearch($syndicationFeedDB->getPrivacyContext()); } $tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType()); $tmpSyndicationFeed->fromObject($syndicationFeedDB); $this->syndicationFeed = $tmpSyndicationFeed; // add partner to default criteria categoryPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true); assetPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true); entryPeer::setDefaultCriteriaFilter(); $this->baseCriteria = entryPeer::getDefaultCriteriaFilter(); $startDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::START_DATE, time(), Criteria::LESS_EQUAL); $startDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::START_DATE, null)); $this->baseCriteria->addAnd($startDateCriterion); $endDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::END_DATE, time(), Criteria::GREATER_EQUAL); $endDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::END_DATE, null)); $this->baseCriteria->addAnd($endDateCriterion); $entryFilter = new entryFilter(); $entryFilter->setPartnerSearchScope($this->syndicationFeed->partnerId); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setTypeIn(array(entryType::MEDIA_CLIP, entryType::MIX)); $entryFilter->setModerationStatusNotIn(array(entry::ENTRY_MODERATION_STATUS_REJECTED, entry::ENTRY_MODERATION_STATUS_PENDING_MODERATION)); $entryFilter->attachToCriteria($this->baseCriteria); if ($this->syndicationFeed->playlistId) { $this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId); foreach ($this->entryFilters as $entryFilter) { $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); // partner scope already attached } $playlist = entryPeer::retrieveByPK($this->syndicationFeed->playlistId); if ($playlist) { if ($playlist->getMediaType() != entry::ENTRY_MEDIA_TYPE_XML) { $this->staticPlaylist = true; $this->staticPlaylistEntriesIdsOrder = explode(',', $playlist->getDataContent()); } } } else { $this->entryFilters = array(); } $microTimeEnd = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]"); }
private function setContextDataFlavorAssets($flavorTags) { if ($this->entry->getType() == entryType::PLAYLIST && $this->entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_TEXT) { list($entryIds, $durations, $mediaEntry) = myPlaylistUtils::executeStitchedPlaylist($this->entry); if (!$mediaEntry) { return; } $mediaEntryId = $mediaEntry->getId(); $this->msDuration = array_sum($durations); } else { $mediaEntryId = $this->entry->getId(); $this->msDuration = $this->entry->getLengthInMsecs(); } $flavorParamsIds = null; $flavorParamsNotIn = false; if (!$this->isAdmin) { foreach ($this->contextDataResult->getActions() as $action) { if ($action->getType() == RuleActionType::BLOCK) { //in case of block action do not set the list of flavors return; } if ($action->getType() == RuleActionType::LIMIT_FLAVORS) { /* @var $action kAccessControlLimitFlavorsAction */ $flavorParamsIds = explode(',', $action->getFlavorParamsIds()); $flavorParamsNotIn = $action->getIsBlockedList(); } } } $flavorAssets = array(); if (is_null($this->asset)) { if (count($flavorParamsIds)) { $flavorAssets = assetPeer::retrieveReadyByEntryIdAndFlavorParams($mediaEntryId, $flavorParamsIds, $flavorParamsNotIn); } else { $flavorAssets = assetPeer::retrieveFlavorsByEntryIdAndStatus($mediaEntryId, null, array(flavorAsset::ASSET_STATUS_READY)); } if ($mediaEntryId != $this->entry->getId()) { // hack: setting the entry id of the flavors to the original playlist id // since the player uses it in the playManifest url foreach ($flavorAssets as $flavorAsset) { $flavorAsset->setEntryId($this->entry->getId()); } } } else { $flavorAllowed = true; if (count($flavorParamsIds)) { $flavorAllowed = $this->isFlavorAllowed($this->asset->getFlavorParamsId(), $flavorParamsIds, $flavorParamsNotIn); } if ($flavorAllowed) { $flavorAssets[] = $this->asset; } } $this->filterFlavorAssetsByTags($flavorAssets, $flavorTags); }
public static function copyEntry(entry $entry, Partner $toPartner = null, $dontCopyUsers = false) { KalturaLog::log("copyEntry - Copying entry [" . $entry->getId() . "] to partner [" . $toPartner->getId() . "]"); $newEntry = $entry->copy(); $newEntry->setIntId(null); $newEntry->setCategories(null); $newEntry->setCategoriesIds(null); if ($toPartner instanceof Partner) { $newEntry->setPartnerId($toPartner->getId()); $newEntry->setSubpId($toPartner->getId() * 100); $newEntry->setAccessControlId($toPartner->getDefaultAccessControlId()); } $newKuser = null; if (!$dontCopyUsers) { // copy the kuser (if the same puser id exists its kuser will be used) kuserPeer::setUseCriteriaFilter(false); $kuser = $entry->getKuser(); $newKuser = kuserPeer::createKuserForPartner($newEntry->getPartnerId(), $kuser->getPuserId()); $newEntry->setKuserId($newKuser->getId()); $newEntry->setCreatorKuserId($newKuser->getId()); kuserPeer::setUseCriteriaFilter(true); } // copy the kshow kshowPeer::setUseCriteriaFilter(false); $kshow = $entry->getKshow(); if ($kshow) { $newKshow = $kshow->copy(); $newKshow->setIntId(null); $newKshow->setPartnerId($toPartner->getId()); $newKshow->setSubpId($toPartner->getId() * 100); if ($newKuser) { $newKshow->setProducerId($newKuser->getId()); } $newKshow->save(); $newEntry->setKshowId($newKshow->getId()); } kshowPeer::setUseCriteriaFilter(true); // reset the statistics myEntryUtils::resetEntryStatistics($newEntry); // set the new partner id into the default category criteria filter $defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter(); $oldPartnerId = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID); $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID); $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId()); // save the entry $newEntry->save(); // restore the original partner id in the default category criteria filter $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID); $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerId); KalturaLog::log("copyEntry - New entry [" . $newEntry->getId() . "] was created"); // for any type that does not require assets: $shouldCopyDataForNonClip = true; if ($entry->getType() == entryType::MEDIA_CLIP) { $shouldCopyDataForNonClip = false; } if ($entry->getType() == entryType::PLAYLIST) { $shouldCopyDataForNonClip = false; } $shouldCopyDataForClip = false; // only images get their data copied if ($entry->getType() == entryType::MEDIA_CLIP) { if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_AUDIO) { $shouldCopyDataForClip = true; } } //if entry is a static playlist, link between it and its new child entries if ($entry->getType() == entryType::PLAYLIST) { switch ($entry->getMediaType()) { case entry::ENTRY_MEDIA_TYPE_TEXT: $from = $entry->getDataContent(); KalturaLog::debug("Entries to copy from source static playlist: [{$from}]"); $fromEntryIds = explode(",", $from); $toEntryIds = array(); foreach ($fromEntryIds as $fromEntryId) { $toEntryIds[] = kObjectCopyHandler::getMappedId(entryPeer::OM_CLASS, $fromEntryId); } $newEntry->setDataContent(implode(",", $toEntryIds)); break; case entry::ENTRY_MEDIA_TYPE_XML: list($totalResults, $fromFiltersList) = myPlaylistUtils::getPlaylistFilterListStruct($entry->getDataContent()); $toPlaylistXml = new SimpleXMLElement("<playlist/>"); $toPlaylistXml->addChild("total_results", $totalResults); $toFiltersXml = $toPlaylistXml->addChild("filters"); foreach ($fromFiltersList as $filterXML) { $entryFilter = new entryFilter(); $entryFilter->fillObjectFromXml($filterXML, "_"); if (isset($entryFilter->fields["_matchand_categories_ids"])) { $categoriesIds = explode(",", $entryFilter->fields["_matchand_categories_ids"]); $newCategoriesIds = array(); foreach ($categoriesIds as $categoryId) { $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId); } $entryFilter->fields["_matchand_categories_ids"] = implode(",", $newCategoriesIds); } if (isset($entryFilter->fields["_matchor_categories_ids"])) { $categoriesIds = explode(",", $entryFilter->fields["_matchor_categories_ids"]); $newCategoriesIds = array(); foreach ($categoriesIds as $categoryId) { $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId); } $entryFilter->fields["_matchor_categories_ids"] = implode(",", $newCategoriesIds); } if (isset($entryFilter->fields["_in_category_ancestor_id"])) { $categoriesIds = explode(",", $entryFilter->fields["_in_category_ancestor_id"]); $newCategoriesIds = array(); foreach ($categoriesIds as $categoryId) { $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId); } $entryFilter->fields["_in_category_ancestor_id"] = implode(",", $newCategoriesIds); } $toEntryFilterXML = $toFiltersXml->addChild("filter"); $toEntryFilterXML = $entryFilter->toXml($toEntryFilterXML); } $newEntry->setDataContent($toPlaylistXml->asXML()); break; } } if ($shouldCopyDataForNonClip || $shouldCopyDataForClip) { // copy the data $from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); // replaced__getDataPath $to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); // replaced__getDataPath KalturaLog::log("copyEntriesByType - copying entry data [" . $from . "] to [" . $to . "]"); kFileSyncUtils::softCopy($from, $to); } $ismFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM); if (kFileSyncUtils::fileSync_exists($ismFrom)) { $ismTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM); KalturaLog::log("copying entry ism [" . $ismFrom . "] to [" . $ismTo . "]"); kFileSyncUtils::softCopy($ismFrom, $ismTo); } $ismcFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC); if (kFileSyncUtils::fileSync_exists($ismcFrom)) { $ismcTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC); KalturaLog::log("copying entry ism [" . $ismcFrom . "] to [" . $ismcTo . "]"); kFileSyncUtils::softCopy($ismcFrom, $ismcTo); } $from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); // replaced__getThumbnailPath $considerCopyThumb = true; // if entry is image - data is thumbnail, and it was copied if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) { $considerCopyThumb = false; } // if entry is not clip, and there is no file in both DCs - nothing to copy if ($entry->getType() != entryType::MEDIA_CLIP && !kFileSyncUtils::file_exists($from, true)) { $considerCopyThumb = false; } if ($considerCopyThumb) { $skipThumb = false; // don't attempt to copy a thumbnail for images - it's the same as the data which was just created if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) { // check if audio entry has real thumb, if not - don't copy thumb. $originalFileSync = kFileSyncUtils::getOriginFileSyncForKey($from, false); if (!$originalFileSync) { $skipThumb = true; } } if (!$skipThumb) { $to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); // replaced__getThumbnailPath KalturaLog::log("copyEntriesByType - copying entry thumbnail [" . $from . "] to [" . $to . "]"); kFileSyncUtils::softCopy($from, $to); } } // added by Tan-Tan 12/01/2010 to support falvors copy $sourceAssets = assetPeer::retrieveByEntryId($entry->getId()); foreach ($sourceAssets as $sourceAsset) { $sourceAsset->copyToEntry($newEntry->getId(), $newEntry->getPartnerId()); } // copy relationships to categories KalturaLog::debug('Copy relationships to categories from entry [' . $entry->getId() . '] to entry [' . $newEntry->getId() . ']'); $c = KalturaCriteria::create(categoryEntryPeer::OM_CLASS); $c->addAnd(categoryEntryPeer::ENTRY_ID, $entry->getId()); $c->addAnd(categoryEntryPeer::STATUS, CategoryEntryStatus::ACTIVE, Criteria::EQUAL); $c->addAnd(categoryEntryPeer::PARTNER_ID, $entry->getPartnerId()); categoryEntryPeer::setUseCriteriaFilter(false); $categoryEntries = categoryEntryPeer::doSelect($c); categoryEntryPeer::setUseCriteriaFilter(true); // Create srcCategoryIdToDstCategoryIdMap - a map of source partner category ids -> dst. partner category ids // // Build src category IDs set $srcCategoryIdSet = array(); foreach ($categoryEntries as $categoryEntry) { $srcCategoryIdSet[] = $categoryEntry->getCategoryId(); } $illegalCategoryStatus = array(CategoryStatus::DELETED, CategoryStatus::PURGED); // Get src category objects $c = KalturaCriteria::create(categoryPeer::OM_CLASS); $c->add(categoryPeer::ID, $srcCategoryIdSet, Criteria::IN); $c->addAnd(categoryPeer::PARTNER_ID, $entry->getPartnerId()); $c->addAnd(categoryPeer::STATUS, $illegalCategoryStatus, Criteria::NOT_IN); categoryPeer::setUseCriteriaFilter(false); $srcCategories = categoryPeer::doSelect($c); categoryPeer::setUseCriteriaFilter(true); // Map the category names to their IDs $fullNamesToSrcCategoryIdMap = array(); foreach ($srcCategories as $category) { $fullNamesToSrcCategoryIdMap[$category->getFullName()] = $category->getId(); } // Get dst. partner categories based on src. category full-names $c = KalturaCriteria::create(categoryPeer::OM_CLASS); $c->add(categoryPeer::FULL_NAME, array_keys($fullNamesToSrcCategoryIdMap), KalturaCriteria::IN); $c->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId()); $c->addAnd(categoryPeer::STATUS, $illegalCategoryStatus, Criteria::NOT_IN); categoryPeer::setUseCriteriaFilter(false); $dstCategories = categoryPeer::doSelect($c); categoryPeer::setUseCriteriaFilter(true); $srcCategoryIdToDstCategoryIdMap = array(); foreach ($dstCategories as $dstCategory) { $fullName = $dstCategory->getFullName(); if (array_key_exists($fullName, $fullNamesToSrcCategoryIdMap)) { $srcCategoryId = $fullNamesToSrcCategoryIdMap[$fullName]; $srcCategoryIdToDstCategoryIdMap[$srcCategoryId] = $dstCategory->getId(); } } foreach ($categoryEntries as $categoryEntry) { /* @var $categoryEntry categoryEntry */ $newCategoryEntry = $categoryEntry->copy(); $newCategoryEntry->setPartnerId($newEntry->getPartnerId()); $newCategoryEntry->setEntryId($newEntry->getId()); $srcCategoryId = $categoryEntry->getCategoryId(); if (!array_key_exists($srcCategoryId, $srcCategoryIdToDstCategoryIdMap)) { continue; // Skip the category_entry's creation } $dstCategoryId = $srcCategoryIdToDstCategoryIdMap[$srcCategoryId]; $newCategoryEntry->setCategoryId($dstCategoryId); categoryPeer::setUseCriteriaFilter(false); entryPeer::setUseCriteriaFilter(false); $newCategoryEntry->save(); entryPeer::setUseCriteriaFilter(true); categoryPeer::setUseCriteriaFilter(true); } return $newEntry; }
public function getDataUrl($version = NULL) { if ($this->getType() == entryType::PLAYLIST) { return myPlaylistUtils::getExecutionUrl($this); } $current_version = $this->getVersion(); $entryId = $this->getId(); $media_type = $this->getMediaType(); if ($media_type == self::ENTRY_MEDIA_TYPE_VIDEO || $media_type == self::ENTRY_MEDIA_TYPE_AUDIO) { $protocolStr = infraRequestUtils::getProtocol(); $url = requestUtils::getApiCdnHost(); $url .= myPartnerUtils::getUrlForPartner($this->getPartnerId(), $this->getSubpId()); $url .= "/playManifest/entryId/{$entryId}/format/url/protocol/{$protocolStr}"; } else { if ($media_type == self::ENTRY_MEDIA_TYPE_IMAGE) { $width = self::DEFAULT_IMAGE_WIDTH; $height = self::DEFAULT_IMAGE_HEIGHT; $url = myPartnerUtils::getCdnHost($this->getPartnerId()); $url .= myPartnerUtils::getUrlForPartner($this->getPartnerId(), $this->getSubpId()); if (!$version) { $version = $current_version; } $url .= "/thumbnail/entry_id/{$entryId}/def_height/{$height}/def_width/{$width}/version/{$version}/type/1"; } else { return null; } } return $url; }
private static function setPuserKuserFromCache($puser_id, $puser_kuser) { if (self::$user_cache == null) { self::$user_cache = array(); } self::$user_cache[$puser_id] = $puser_kuser; }