/** * Will anipulate a single entry */ public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; $command = $this->getP("command"); if ($command == "updateEntry") { $id = $this->getP("id"); $entry = entryPeer::retrieveByPK($id); if ($entry) { $name = $this->getP("name"); $value = $this->getP("value"); $obj_wrapper = objectWrapperBase::getWrapperClass($entry, 0); $updateable_fields = $obj_wrapper->getUpdateableFields("2"); if (!in_array($name, $updateable_fields)) { die; } if ($name) { $setter = "set" . $name; call_user_func(array($entry, $setter), $value); $entry->save(); } } } die; }
/** * @return kUrlTokenizer */ public function getTokenizer() { switch ($this->protocol) { case StorageProfile::PLAY_FORMAT_HTTP: $name = isset($this->params['http_auth_param_name']) ? $this->params['http_auth_param_name'] : "h"; $key = isset($this->params['http_auth_key']) ? $this->params['http_auth_key'] : false; $gen = isset($this->params['http_auth_gen']) ? $this->params['http_auth_gen'] : false; $window = 0; $entry = entryPeer::retrieveByPK($this->entryId); if ($entry && $entry->getSecurityPolicy()) { $window = 30; } if ($name && $key !== false && $gen !== false) { return new kLevel3UrlTokenizer($name, $key, $gen, false, $window); } break; case StorageProfile::PLAY_FORMAT_RTMP: $name = isset($this->params['rtmp_auth_param_name']) ? $this->params['rtmp_auth_param_name'] : "h"; $key = isset($this->params['rtmp_auth_key']) ? $this->params['rtmp_auth_key'] : false; $gen = isset($this->params['rtmp_auth_gen']) ? $this->params['rtmp_auth_gen'] : false; if ($name && $key !== false && $gen !== false) { return new kLevel3UrlTokenizer($name, $key, $gen, true); } break; } return null; }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $entry_id = $this->getPM("entry_id"); $detailed = $this->getP("detailed", false); $entry = null; if ($entry_id) { $entry = entryPeer::retrieveByPK($entry_id); } if (!$entry) { $this->addError(APIErrors::INVALID_ENTRY_ID, $entry_id); } else { $kshow_id = $entry->getKshowId(); $kshow = $entry->getKshow(); if (!$kshow) { $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id); } else { $newKshow = myKshowUtils::shalowCloneById($kshow_id, $puser_kuser->getKuserId()); if (!$newKshow) { $this->addError(APIErrors::KSHOW_CLONE_FAILED, $kshow_id); } else { $newEntry = $newKshow->getShowEntry(); $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $wrapper = objectWrapperBase::getWrapperClass($newEntry, $level); // TODO - remove this code when cache works properly when saving objects (in their save method) $wrapper->removeFromCache("entry", $newEntry->getId()); $this->addMsg("entry", $wrapper); } } } }
public function save(PropelPDO $con = null) { if ($this->isColumnModified(accessControlPeer::DELETED_AT)) { if ($this->isDefault === true) { throw new Exception("Default access control profile can't be deleted"); } $c = new Criteria(); $c->add(entryPeer::ACCESS_CONTROL_ID, $this->getId()); $entryCount = entryPeer::doCount($c); if ($entryCount > 0) { throw new Exception("Access control profile is linked with entries and can't be deleted"); } } if ($this->isNew()) { $c = new Criteria(); $c->add(accessControlPeer::PARTNER_ID, $this->partner_id); $count = accessControlPeer::doCount($c); if ($count >= Partner::MAX_ACCESS_CONTROLS) { throw new kCoreException("Max number of access control profiles was reached", kCoreException::MAX_NUMBER_OF_ACCESS_CONTROLS_REACHED); } } parent::save($con); // set this conversion profile as partners default $partner = PartnerPeer::retrieveByPK($this->partner_id); if ($partner && $this->isDefault === true) { $partner->setDefaultAccessControlId($this->getId()); $partner->save(); } }
/** const SUBJECT_TYPE_KSHOW = '1'; const SUBJECT_TYPE_ENTRY = '2'; const SUBJECT_TYPE_USER = '******'; */ public static function addFavorite(favorite $favorite) { self::add($favorite); $type = $favorite->getSubjectType(); $id = $favorite->getSubjectId(); if ($type == favorite::SUBJECT_TYPE_ENTRY) { $obj = entryPeer::retrieveByPK($id); if ($obj) { $v = $obj->getFavorites(); self::inc($v); $obj->setFavorites($v); } } elseif ($type == favorite::SUBJECT_TYPE_KSHOW) { $obj = kshowPeer::retrieveByPK($id); if ($obj) { $v = $obj->getFavorites(); self::inc($v); $obj->setFavorites($v); } } elseif ($type == favorite::SUBJECT_TYPE_USER) { $obj = kuserPeer::retrieveByPK($id); if ($obj) { $v = $obj->getFans(); self::inc($v); $obj->setFans($v); } } // don't forget to save the modified object self::add($obj); }
public function getEntry() { if ($this->aEntry == null && $this->getEntryId()) { $this->aEntry = entryPeer::retrieveByPKNoFilter($this->getEntryId()); } return $this->aEntry; }
protected function applyFilterFields(baseObjectFilter $filter) { /* @var $filter cuePointFilter */ // Reduce the cache expiry when fetching live stream cuepoints $entryId = $filter->get('_in_entry_id'); if ($entryId && strpos($entryId, ',') === false) { $entry = entryPeer::retrieveByPK($entryId); if ($entry && $entry->getType() == entryType::LIVE_STREAM) { kApiCache::setExpiry(self::LIVE_ENTRY_CUE_POINT_CACHE_EXPIRY_SECONDS); } } if ($filter->get('_free_text')) { $this->sphinxSkipped = false; $freeTexts = $filter->get('_free_text'); KalturaLog::debug("Attach free text [{$freeTexts}]"); $this->addFreeTextToMatchClauseByMatchFields($freeTexts, CuePointFilter::FREE_TEXT_FIELDS); } $filter->unsetByName('_free_text'); if ($filter->get('_eq_is_public')) { $this->sphinxSkipped = false; $isPublic = $filter->get('_eq_is_public'); $this->addCondition('is_public' . " = " . $isPublic); } $filter->unsetByName('_eq_is_public'); return parent::applyFilterFields($filter); }
public function createQuestionPdf() { $dbEntry = entryPeer::retrieveByPK($this->entryId); $title = "Here are the questions from [" . $dbEntry->getName() . "]"; KalturaLog::debug("Questions from [" . $dbEntry->getName() . "]"); $this->pdf->addTitle($title, $this->titleStyle); $questionType = QuizPlugin::getCuePointTypeCoreValue(QuizCuePointType::QUIZ_QUESTION); $questions = CuePointPeer::retrieveByEntryId($this->entryId, array($questionType)); //arange the array so that the questions will be the key for the array $questArray = array(); foreach ($questions as $question) { $questArray[$question->getName()] = $question; } //sort the array alphabetically according to its key; i.e. the question ksort($questArray, SORT_LOCALE_STRING); $questNum = 0; foreach ($questArray as $question) { $questNum += 1; $this->pdf->addList($questNum, $question->getName(), $this->listWithAddLineBeforeStyle); $this->pdf->addHeadline(6, "Optional Answers:", $this->heading6Style); $ansNum = 0; foreach ($question->getOptionalAnswers() as $optionalAnswer) { $ansNum += 1; $this->pdf->addList($ansNum, $optionalAnswer->getText(), $this->indentListStyle); } } }
public function execute() { // keywords & page // keywords // $keywords = $this->request->getRequestParameter ( "keywords" , "" ); // page // $page = $this->request->getRequestParameter ( "page" , "1" ); $partner_id = $this->getP("partner_id", null); if (false && $partner_id) { $criteria_filter = enrtyPeer::getCriteriaFilter(); $criteria = $criteria_filter->getFilter(); $criteria->addAnd(entryPeer::PARTNER_ID, "(" . entryPeer::PARTNER_ID . "<100 OR " . entryPeer::PARTNER_ID . "={$partner_id} )", Criteria::CUSTOM); entryPeer::enable(); } $page_size = 20; $entry_filter = new entryFilter(); $entry_pager = new mySmartPager($this, "entry", $page_size); $act = new AJAX_getEntriesAction(); $act->setIdList(NULL); $act->setSortAlias("ids"); $act->setPublicOnly(true); $act->skip_count = false; $this->entry_results = $act->fetchPage($this, $entry_filter, $entry_pager); $this->getResponse()->setHttpHeader("Content-Type", "text/xml; charset=utf-8"); $this->number_of_results = $entry_pager->getNumberOfResults(); $this->number_of_pages = $entry_pager->getNumberOfPages(); }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { $obj_type = $this->getPM("obj_type"); $obj_id = $this->getPM("obj_id"); $command = $this->getPM("command"); $value = $this->getP("value"); $extra_info = $this->getP("extra_info"); if ($obj_type == "entry") { $entry = entryPeer::retrieveByPK($obj_id); if ($command == "view") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_VIEWS); myStatisticsMgr::incEntryViews($entry); } elseif ($command == "play") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_PLAYS); myStatisticsMgr::incEntryPlays($entry); } } elseif ($obj_type == "kshow") { $kshow = kshowPeer::retrieveByPK($obj_id); if ($command == "view") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_VIEWS); myStatisticsMgr::incKshowViews($kshow); } elseif ($command == "play") { PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_PLAYS); myStatisticsMgr::incKshowPlays($kshow); } } $this->addMsg("collectedStats", "{$obj_type}, {$obj_id}, {$command}, {$value}, {$extra_info}"); }
public function getObject() { if ($this->m_object) { return $this->m_object; } $object_id = $this->object_id; if ($object_id == null) { return null; } switch ($this->getObjectType()) { case self::MODERATION_OBJECT_TYPE_KSHOW: $this->m_object = kshowPeer::retrieveByPK($object_id); break; case self::MODERATION_OBJECT_TYPE_ENTRY: // be able to fetch entries that are deleted entryPeer::allowDeletedInCriteriaFilter(); $this->m_object = entryPeer::retrieveByPK($object_id); entryPeer::blockDeletedInCriteriaFilter(); break; case self::MODERATION_OBJECT_TYPE_USER: // $object_id is the puser_id $puser_kuser = PuserKuserPeer::retrieveByPartnerAndUid($this->getPartnerId(), NULL, $object_id, true); if ($puser_kuser && $puser_kuser->getKuser()) { $this->m_object = $puser_kuser->getKuser(); } // $this->m_object = kuserPeer::retrieveByPK( $object_id ); break; } return $this->m_object; }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { if (!$puser_kuser) { $this->addError(APIErrors::INVALID_USER_ID, $puser_id); return; } $time_offset = $this->getPM("time_offset"); $entry_ids = $this->getPM("entry_ids"); $detailed = $this->getP("detailed", false); $separator = $this->getP("separator", ","); $id_arr = explode($separator, $entry_ids); $limit = 50; $id_arr = array_splice($id_arr, 0, $limit); $entries = entryPeer::retrieveByPKs($id_arr); $updated_entries = array(); if (!$entries) { $this->addError(APIErrors::INVALID_ENTRY_IDS, $entry_ids); } else { foreach ($entries as $entry) { if (!myEntryUtils::createThumbnailFromEntry($entry, $entry, $time_offset)) { $this->addError(APIErrors::INVALID_ENTRY_TYPE, "ENTRY_TYPE_MEDIACLIP [" . $entry->getId() . "]"); continue; } $updated_entries[] = $entry; myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $entry); $wrapper = objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_DETAILED); $wrapper->removeFromCache("entry", $entry->getId()); } } $this->addMsg("entries", objectWrapperBase::getWrapperClass($updated_entries, objectWrapperBase::DETAIL_LEVEL_REGULAR)); }
public function postUpdate(PropelPDO $con = null) { parent::postUpdate($con); categoryPeer::setUseCriteriaFilter(false); $category = categoryPeer::retrieveByPK($this->getCategoryId()); categoryPeer::setUseCriteriaFilter(true); if (!$category) { throw new kCoreException('category id [' . $this->getCategoryId() . 'was not found', kCoreException::ID_NOT_FOUND); } $entry = entryPeer::retrieveByPK($this->getEntryId()); if (!$entry && $this->getStatus() != CategoryEntryStatus::DELETED) { throw new kCoreException('entry id [' . $this->getEntryId() . 'was not found', kCoreException::ID_NOT_FOUND); } if ($entry && $this->getStatus() == CategoryEntryStatus::ACTIVE && $this->getColumnsOldValue(categoryEntryPeer::STATUS) == CategoryEntryStatus::PENDING) { $entry = $this->setEntryOnCategory($category, $entry); } if ($this->getStatus() == CategoryEntryStatus::REJECTED && $this->getColumnsOldValue(categoryEntryPeer::STATUS) == CategoryEntryStatus::PENDING) { $category->decrementPendingEntriesCount(); } if ($this->getStatus() == CategoryEntryStatus::PENDING && $this->getColumnsOldValue(categoryEntryPeer::STATUS) == CategoryEntryStatus::REJECTED) { $category->incrementPendingEntriesCount(); } if ($this->getStatus() == CategoryEntryStatus::DELETED) { if ($this->getColumnsOldValue(categoryEntryPeer::STATUS) == CategoryEntryStatus::ACTIVE) { $category->decrementEntriesCount($this->getEntryId()); $category->decrementDirectEntriesCount($this->getEntryId()); if ($entry && !categoryEntryPeer::getSkipSave()) { $categories = array(); if (trim($entry->getCategories()) != '') { $categories = explode(entry::ENTRY_CATEGORY_SEPARATOR, $entry->getCategories()); foreach ($categories as $index => $entryCategoryFullName) { if ($entryCategoryFullName == $category->getFullName()) { unset($categories[$index]); } } } $categoriesIds = array(); if (trim($entry->getCategoriesIds()) != '') { $categoriesIds = explode(entry::ENTRY_CATEGORY_SEPARATOR, $entry->getCategoriesIds()); foreach ($categories as $index => $entryCategoryId) { if ($entryCategoryId == $category->getId()) { unset($categoriesIds[$index]); } } } $entry->setCategories(implode(entry::ENTRY_CATEGORY_SEPARATOR, $categories)); $entry->setCategoriesIds(implode(entry::ENTRY_CATEGORY_SEPARATOR, $categoriesIds)); $entry->save(); } kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); } if ($this->getColumnsOldValue(categoryEntryPeer::STATUS) == CategoryEntryStatus::PENDING) { $category->decrementPendingEntriesCount(); } } $category->save(); if ($entry && !categoryEntryPeer::getSkipSave()) { $entry->indexToSearchIndex(); } }
/** * @param string $cdnHost * @param string $entryId * @return kUrlManager */ public static function getUrlManagerByCdn($cdnHost, $entryId) { $class = 'kUrlManager'; $cdnHost = preg_replace('/https?:\\/\\//', '', $cdnHost); $cdnHost = preg_replace('/:\\d+$/', '', $cdnHost); $params = null; $urlManagers = kConf::getMap('url_managers'); if (isset($urlManagers[$cdnHost])) { $class = $urlManagers[$cdnHost]["class"]; $params = @$urlManagers[$cdnHost]["params"]; $entry = entryPeer::retrieveByPK($entryId); $urlManagersMap = kConf::getMap('url_managers'); if ($entry && isset($urlManagersMap["override"])) { $overrides = $urlManagersMap["override"]; $partnerId = $entry->getPartnerId(); if (array_key_exists($partnerId, $overrides)) { $overrides = $overrides[$partnerId]; foreach ($overrides as $override) { if ($override['domain'] == $cdnHost) { $params = array_merge($params, $override["params"]); } } } } } KalturaLog::log("Uses url manager [{$class}]"); return new $class(null, $params, $entryId); }
/** * Will return the first virus scan profile of the entry's partner, that defines an entry filter suitable for the given entry. * @param int $entryId * @return VirusScanProfile the suitable profile object, or null if none found */ public static function getSuitableProfile($entryId) { $entry = entryPeer::retrieveByPK($entryId); if (!$entry) { KalturaLog::err('Cannot find entry with id [' . $entryId . ']'); return null; } if ($entry->getSource() == entry::ENTRY_MEDIA_SOURCE_WEBCAM) { return null; } $cProfile = new Criteria(); $cProfile->addAnd(VirusScanProfilePeer::PARTNER_ID, $entry->getPartnerId()); $cProfile->addAnd(VirusScanProfilePeer::STATUS, VirusScanProfileStatus::ENABLED, Criteria::EQUAL); $profiles = VirusScanProfilePeer::doSelect($cProfile); if (!$profiles) { KalturaLog::debug('No virus scan profiles found for partner [' . $entry->getPartnerId() . ']'); return null; } foreach ($profiles as $profile) { $virusEntryFilter = $profile->getEntryFilterObject(); if ($virusEntryFilter->matches($entry)) { KalturaLog::debug('Returning profile with id [' . $profile->getId() . ']'); return $profile; } } return null; }
/** * @return entry */ public function getEntry() { if (!$this->aEntry && $this->getEntryId()) { $this->aEntry = entryPeer::retrieveByPK($this->getEntryId()); } return $this->aEntry; }
public function clearMemory() { accessControlPeer::clearInstancePool(); BatchJobPeer::clearInstancePool(); BulkUploadResultPeer::clearInstancePool(); categoryPeer::clearInstancePool(); EmailIngestionProfilePeer::clearInstancePool(); entryPeer::clearInstancePool(); FileSyncPeer::clearInstancePool(); flavorAssetPeer::clearInstancePool(); flavorParamsConversionProfilePeer::clearInstancePool(); flavorParamsOutputPeer::clearInstancePool(); flavorParamsPeer::clearInstancePool(); kshowPeer::clearInstancePool(); mediaInfoPeer::clearInstancePool(); moderationFlagPeer::clearInstancePool(); moderationPeer::clearInstancePool(); notificationPeer::clearInstancePool(); roughcutEntryPeer::clearInstancePool(); SchedulerConfigPeer::clearInstancePool(); SchedulerPeer::clearInstancePool(); SchedulerStatusPeer::clearInstancePool(); SchedulerWorkerPeer::clearInstancePool(); StorageProfilePeer::clearInstancePool(); syndicationFeedPeer::clearInstancePool(); TrackEntryPeer::clearInstancePool(); uiConfPeer::clearInstancePool(); UploadTokenPeer::clearInstancePool(); // TODO clear default filters // TODO call all memory cleaner plugins if (function_exists('gc_collect_cycles')) { // php 5.3 and above gc_collect_cycles(); } }
/** * Creates perioding metadata sync-point events on a live stream * * @action createPeriodicSyncPoints * @actionAlias liveStream.createPeriodicSyncPoints * @param string $entryId Kaltura live-stream entry id * @param int $interval Events interval in seconds * @param int $duration Duration in seconds * * @throws KalturaErrors::ENTRY_ID_NOT_FOUND * @throws KalturaErrors::NO_MEDIA_SERVER_FOUND * @throws KalturaErrors::MEDIA_SERVER_SERVICE_NOT_FOUND */ function createPeriodicSyncPoints($entryId, $interval, $duration) { $entryDc = substr($entryId, 0, 1); if ($entryDc != kDataCenterMgr::getCurrentDcId()) { $remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId($entryDc); kFileUtils::dumpApiRequest($remoteDCHost, true); } $dbEntry = entryPeer::retrieveByPK($entryId); if (!$dbEntry || $dbEntry->getType() != KalturaEntryType::LIVE_STREAM || !in_array($dbEntry->getSource(), array(KalturaSourceType::LIVE_STREAM, KalturaSourceType::LIVE_STREAM_ONTEXTDATA_CAPTIONS))) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId); } /* @var $dbEntry LiveStreamEntry */ $mediaServers = $dbEntry->getMediaServers(); if (!count($mediaServers)) { throw new KalturaAPIException(KalturaErrors::NO_MEDIA_SERVER_FOUND, $entryId); } foreach ($mediaServers as $key => $kMediaServer) { if ($kMediaServer && $kMediaServer instanceof kLiveMediaServer) { $mediaServer = $kMediaServer->getMediaServer(); $mediaServerCuePointsService = $mediaServer->getWebService(MediaServer::WEB_SERVICE_CUE_POINTS); KalturaLog::debug("Sending sync points for DC [" . $mediaServer->getDc() . "] "); if ($mediaServerCuePointsService && $mediaServerCuePointsService instanceof KalturaMediaServerCuePointsService) { KalturaLog::debug("Call createTimeCuePoints on DC [" . $mediaServer->getDc() . "] "); $mediaServerCuePointsService->createTimeCuePoints($entryId, $interval, $duration); } else { KalturaLog::debug("Media server service not found on DC: [" . $mediaServer->getDc() . "] "); } } } }
/** * @param SimpleXMLElement $mrss * @param SimpleXMLElement $metadata * @param kMrssParameters $mrssParams * @return SimpleXMLElement */ public function contributeMetadataObject(SimpleXMLElement $mrss, SimpleXMLElement $metadata, kMrssParameters $mrssParams = null, $currentXPath) { $currentXPath .= "/*[local-name()='" . $metadata->getName() . "']"; $metadataObject = $mrss->addChild($metadata->getName()); foreach ($metadata->attributes() as $attributeField => $attributeValue) { $metadataObject->addAttribute($attributeField, $attributeValue); } foreach ($metadata as $metadataField => $metadataValue) { if ($metadataValue instanceof SimpleXMLElement && count($metadataValue)) { $this->contributeMetadataObject($metadataObject, $metadataValue, $mrssParams, $currentXPath); } else { $metadataObject->addChild($metadataField, kString::stringToSafeXml($metadataValue)); $itemXPath = $currentXPath . "/*[local-name()='{$metadataField}']"; if ($mrssParams && is_array($mrssParams->getItemXpathsToExtend()) && in_array($itemXPath, $mrssParams->getItemXpathsToExtend())) { $relatedEntry = entryPeer::retrieveByPK((string) $metadataValue); if ($relatedEntry) { $relatedItemField = $metadataObject->addChild($metadataField . '_item'); $recursionMrssParams = null; if ($mrssParams) { $recursionMrssParams = clone $mrssParams; $recursionMrssParams->setItemXpathsToExtend(array()); // stop the recursion } $relatedEntryMrss = kMrssManager::getEntryMrssXml($relatedEntry, $relatedItemField, $recursionMrssParams); } } } } }
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()); }
/** * getAccessAction * input: flavor ids, drmProvider * Get Access Action * @action getAccess * @param string $entryId * @param string $flavorIds * @param string $referrer * @return KalturaDrmLicenseAccessDetails **/ public function getAccessAction($entryId, $flavorIds, $referrer) { $response = new KalturaDrmLicenseAccessDetails(); $response->policy = ""; $response->duration = 0; $response->absolute_duration = 0; $flavorIdsArr = explode(",", $flavorIds); $entry = entryPeer::retrieveByPK($entryId); if (isset($entry)) { try { $drmLU = new DrmLicenseUtils($entry, $referrer); if ($this->validateFlavorAssetssAllowed($drmLU, $flavorIdsArr) == true) { $policyId = $drmLU->getPolicyId(); KalturaLog::info("policy_id is '{$policyId}'"); $dbPolicy = DrmPolicyPeer::retrieveByPK($policyId); if (isset($dbPolicy)) { $expirationDate = DrmLicenseUtils::calculateExpirationDate($dbPolicy, $entry); $response->policy = $dbPolicy->getName(); $response->duration = $expirationDate; $response->absolute_duration = $expirationDate; KalturaLog::info("response is '" . print_r($response, true) . "' "); } else { KalturaLog::err("Could not get DRM policy from DB"); } } } catch (Exception $e) { KalturaLog::err("Could not validate license access, returned with message '" . $e->getMessage() . "'"); } } else { KalturaLog::err("Entry '{$entryId}' not found"); } return $response; }
public static function getKshowRoughcutCount(array $kuser_id_list) { $c = new Criteria(); $c->add(entryPeer::TYPE, entryType::MIX); $c->add(entryPeer::KSHOW_ID, $kuser_id_list, Criteria::IN); $c->addSelectColumn(entryPeer::KSHOW_ID); $c->addAsColumn('cnt', 'COUNT(' . entryPeer::KSHOW_ID . ')'); $c->addGroupByColumn(entryPeer::KSHOW_ID); $rs = entryPeer::doSelectStmt($c); $kusers_roughcuts = array(); $res = $rs->fetchAll(); foreach ($res as $record) { $id = $record[0]; $cnt = $record[1]; $kusers_roughcuts[$id] = $cnt; } // // old code from doSelectRs // while($rs->next()) // { // $id= $rs->getInt(1); // $cnt = $rs->getInt(2); // $kusers_roughcuts[$id]=$cnt; // } $rs->close(); return $kusers_roughcuts; }
public function getLocalThumbFilePath($version, $width, $height, $type, $bgcolor = "ffffff", $crop_provider = null, $quality = 0, $src_x = 0, $src_y = 0, $src_w = 0, $src_h = 0, $vid_sec = -1, $vid_slice = 0, $vid_slices = -1, $density = 0, $stripProfiles = false, $flavorId = null, $fileName = null) { if ($this->getStatus() == entryStatus::DELETED || $this->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK) { KalturaLog::log("rejected live stream entry - not serving thumbnail"); KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED); } $contentPath = myContentStorage::getFSContentRootPath(); $liveEntryExist = false; $liveThumbEntry = null; $liveThumbEntryId = null; $partner = $this->getPartner(); if ($partner) { $liveThumbEntryId = $partner->getLiveThumbEntryId(); } if ($liveThumbEntryId) { $liveThumbEntry = entryPeer::retrieveByPK($liveThumbEntryId); } if ($liveThumbEntry && $liveThumbEntry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) { $fileSyncVersion = $partner->getLiveThumbEntryVersion(); $liveEntryKey = $liveThumbEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $fileSyncVersion); $contentPath = kFileSyncUtils::getLocalFilePathForKey($liveEntryKey); if ($contentPath) { $msgPath = $contentPath; $liveEntryExist = true; } else { KalturaLog::err('no local file sync for audio entry id'); } } if (!$liveEntryExist) { $msgPath = $contentPath . "content/templates/entry/thumbnail/live_thumb.jpg"; } return myEntryUtils::resizeEntryImage($this, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $msgPath, $density, $stripProfiles); }
public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaDailymotionDistributionProfile) { return; } $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); if (count($flavorAssets)) { // if we have specific flavor assets for this distribution, grab the first one $flavorAsset = reset($flavorAssets); } else { // take the source asset $flavorAsset = assetPeer::retrieveOriginalReadyByEntryId($distributionJobData->entryDistribution->entryId); } if ($flavorAsset) { $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $this->videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); } // look for krule with action block and condition of country $entry = entryPeer::retrieveByPK($distributionJobData->entryDistribution->entryId); if ($entry && $entry->getAccessControl()) { $this->setGeoBlocking($entry->getAccessControl()); } $this->addCaptionsData($distributionJobData); }
/** * Called on the server side and enables you to populate the object with any data from the DB * * @param KalturaDistributionJobData $distributionJobData */ public function __construct(KalturaDistributionJobData $distributionJobData = null) { parent::__construct($distributionJobData); if (!$distributionJobData) { return; } if (!$distributionJobData->distributionProfile instanceof KalturaQuickPlayDistributionProfile) { return; } $this->videoFilePaths = new KalturaStringArray(); $this->thumbnailFilePaths = new KalturaStringArray(); // loads all the flavor assets that should be submitted to the remote destination site $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds)); $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds)); $entry = entryPeer::retrieveByPK($distributionJobData->entryDistribution->entryId); foreach ($flavorAssets as $asset) { $syncKey = $asset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $str = new KalturaString(); $str->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->videoFilePaths[] = $str; } } foreach ($thumbAssets as $asset) { $syncKey = $asset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); if (kFileSyncUtils::fileSync_exists($syncKey)) { $str = new KalturaString(); $str->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false); $this->thumbnailFilePaths[] = $str; } } $feed = new QuickPlayFeed($distributionJobData, $this, $flavorAssets, $thumbAssets, $entry); $this->xml = $feed->getXml(); }
/** * Will investigate a single entry */ public function execute() { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; $this->forceSystemAuthentication(); entryPeer::setUseCriteriaFilter(false); $this->result = NULL; $kshow_ids = @$_REQUEST["kshow_ids"]; $this->kshow_ids = $kshow_ids; $this->kshow = NULL; $entry_ids = @$_REQUEST["entry_ids"]; $this->entry_ids = $entry_ids; $this->entry = NULL; $this->show_entry = null; $show_entry_list = array(); if (!empty($kshow_ids)) { $ids_arr = explode(",", $kshow_ids); $kshows = kshowPeer::retrieveByPKs($ids_arr); if (!$kshows) { $this->result = "No kshows [{$kshow_ids}] in DB"; return; } foreach ($kshows as $kshow) { $show_entry = $kshow->getShowEntry(); $show_entry_list[] = $show_entry; } } else { if (empty($entry_ids)) { $this->result = "Submit an entry_id of a kshow_id to fix"; return; } $ids_arr = explode(",", $entry_ids); $entries = entryPeer::retrieveByPKs($ids_arr); if (!$entries) { $this->result = "No entries [{$entry_ids}] in DB"; return; } foreach ($entries as $entry) { if ($entry->getType() != entryType::MIX) { continue; } $show_entry_list[] = $entry; } } $fixed_data_list = array(); foreach ($show_entry_list as $show_entry) { $fix_data = new fixData(); $fix_data->show_entry = $show_entry; if ($show_entry->getType() != entryType::MIX) { $fix_data->error = "Entry is not a roughcut"; } else { $fix_data->old_content = $show_entry->getMetadata(); $fix_data->old_duration = $show_entry->getLengthInMsecs(); $fix_data->fixed_content = $show_entry->fixMetadata(false); $fix_data->fixed_duration = $show_entry->getLengthInMsecs(); } $fixed_data_list[] = $fix_data; } $this->fixed_data_list = $fixed_data_list; }
/** * Will forward to the regular swf player according to the widget_id */ public function execute() { $entryId = $this->getRequestParameter("entry_id"); $flavorId = $this->getRequestParameter("flavor"); $fileName = $this->getRequestParameter("file_name"); $ksStr = $this->getRequestParameter("ks"); $referrer = $this->getRequestParameter("referrer"); $referrer = base64_decode($referrer); if (!is_string($referrer)) { // base64_decode can return binary data $referrer = ""; } // get entry $entry = entryPeer::retrieveByPK($entryId); if (is_null($entry)) { KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND); } myPartnerUtils::blockInactivePartner($entry->getPartnerId()); $securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer); $securyEntryHelper->validateForDownload($entry, $ksStr); $flavorAsset = null; if ($flavorId) { // get flavor asset $flavorAsset = flavorAssetPeer::retrieveById($flavorId); if (is_null($flavorAsset) || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) { KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } // the request flavor should belong to the requested entry if ($flavorAsset->getEntryId() != $entryId) { KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } } else { $flavorAsset = flavorAssetPeer::retrieveBestPlayByEntryId($entry->getId()); } // Gonen 26-04-2010: in case entry has no flavor with 'mbr' tag - we return the source if (!$flavorAsset && ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO)) { $flavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entryId); } if ($flavorAsset) { $syncKey = $this->getSyncKeyAndForFlavorAsset($entry, $flavorAsset); } else { $syncKey = $this->getBestSyncKeyForEntry($entry); } list($fileBaseName, $fileExt) = $this->getFileName($entry, $flavorAsset); if (!$fileName) { $fileName = $fileBaseName; } if ($fileExt) { $fileName = $fileName . '.' . $fileExt; } if (is_null($syncKey)) { KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND); } $this->handleFileSyncRedirection($syncKey); $filePath = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey); $this->dumpFile($filePath, $fileName); die; // no view }
public function getFieldNameFromPeer($field_name) { try { return entryPeer::translateFieldName($field_name, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME); } catch (PropelException $e) { return 'entry.' . strtoupper($field_name); } }
/** * @action getFeed * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY * @param int $distributionProfileId * @param string $hash * @return file */ public function getFeedAction($distributionProfileId, $hash) { if (!$this->getPartnerId() || !$this->getPartner()) { throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId()); } $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId); if (!$profile || !$profile instanceof SynacorHboDistributionProfile) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId); } if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId); } if ($profile->getUniqueHashForFeedUrl() != $hash) { throw new KalturaAPIException(SynacorHboDistributionErrors::INVALID_FEED_URL); } // "Creates advanced filter on distribution profile $distributionAdvancedSearch = new ContentDistributionSearchFilter(); $distributionAdvancedSearch->setDistributionProfileId($profile->getId()); $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE); $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY); $distributionAdvancedSearch->setEntryDistributionFlag(EntryDistributionDirtyStatus::NONE); $distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false); //Creates entry filter with advanced filter $entryFilter = new entryFilter(); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED); $entryFilter->setPartnerSearchScope($this->getPartnerId()); $entryFilter->setAdvancedSearch($distributionAdvancedSearch); $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL); $entryFilter->attachToCriteria($baseCriteria); $entries = entryPeer::doSelect($baseCriteria); $feed = new SynacorHboFeed('synacor_hbo_feed_template.xml'); $feed->setDistributionProfile($profile); $counter = 0; foreach ($entries as $entry) { /* @var $entry entry */ $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId()); if (!$entryDistribution) { KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']'); continue; } $fields = $profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); $additionalAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getAssetIds())); $feed->addItem($fields, $entry, $flavorAssets, $thumbAssets, $additionalAssets); $counter++; //to avoid the cache exceeding the memory size if ($counter >= 100) { kMemoryManager::clearMemory(); $counter = 0; } } header('Content-Type: text/xml'); echo $feed->getXml(); die; }
/** * @action getFeed * @disableTags TAG_WIDGET_SESSION,TAG_ENTITLEMENT_ENTRY,TAG_ENTITLEMENT_CATEGORY * @param int $distributionProfileId * @param string $hash * @return file */ public function getFeedAction($distributionProfileId, $hash) { if (!$this->getPartnerId() || !$this->getPartner()) { throw new KalturaAPIException(KalturaErrors::INVALID_PARTNER_ID, $this->getPartnerId()); } $profile = DistributionProfilePeer::retrieveByPK($distributionProfileId); if (!$profile || !$profile instanceof UverseDistributionProfile) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_NOT_FOUND, $distributionProfileId); } if ($profile->getStatus() != KalturaDistributionProfileStatus::ENABLED) { throw new KalturaAPIException(ContentDistributionErrors::DISTRIBUTION_PROFILE_DISABLED, $distributionProfileId); } if ($profile->getUniqueHashForFeedUrl() != $hash) { throw new KalturaAPIException(UverseDistributionErrors::INVALID_FEED_URL); } // "Creates advanced filter on distribution profile $distributionAdvancedSearch = new ContentDistributionSearchFilter(); $distributionAdvancedSearch->setDistributionProfileId($profile->getId()); $distributionAdvancedSearch->setDistributionSunStatus(EntryDistributionSunStatus::AFTER_SUNRISE); $distributionAdvancedSearch->setEntryDistributionStatus(EntryDistributionStatus::READY); $distributionAdvancedSearch->setHasEntryDistributionValidationErrors(false); //Creates entry filter with advanced filter $entryFilter = new entryFilter(); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED); $entryFilter->setPartnerSearchScope($this->getPartnerId()); $entryFilter->setAdvancedSearch($distributionAdvancedSearch); $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $baseCriteria->add(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM, Criteria::NOT_EQUAL); $entryFilter->attachToCriteria($baseCriteria); $entries = entryPeer::doSelect($baseCriteria); $feed = new UverseFeed('uverse_template.xml'); $feed->setDistributionProfile($profile); $feed->setChannelFields(); $lastBuildDate = $profile->getUpdatedAt(null); foreach ($entries as $entry) { /* @var $entry entry */ $entryDistribution = EntryDistributionPeer::retrieveByEntryAndProfileId($entry->getId(), $profile->getId()); if (!$entryDistribution) { KalturaLog::err('Entry distribution was not found for entry [' . $entry->getId() . '] and profile [' . $profile->getId() . ']'); continue; } $fields = $profile->getAllFieldValues($entryDistribution); $flavorAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getFlavorAssetIds())); $flavorAsset = reset($flavorAssets); $flavorAssetRemoteUrl = $entryDistribution->getFromCustomData(UverseEntryDistributionCustomDataField::REMOTE_ASSET_URL); $thumbAssets = assetPeer::retrieveByIds(explode(',', $entryDistribution->getThumbAssetIds())); $feed->addItem($fields, $flavorAsset, $flavorAssetRemoteUrl, $thumbAssets); // we want to find the newest update time between all entries if ($entry->getUpdatedAt(null) > $lastBuildDate) { $lastBuildDate = $entry->getUpdatedAt(null); } } $feed->setChannelLastBuildDate($lastBuildDate); header('Content-Type: text/xml'); echo $feed->getXml(); die; }