本文整理汇总了PHP中kEventsManager::flushEvents方法的典型用法代码示例。如果您正苦于以下问题:PHP kEventsManager::flushEvents方法的具体用法?PHP kEventsManager::flushEvents怎么用?PHP kEventsManager::flushEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kEventsManager
的用法示例。
在下文中一共展示了kEventsManager::flushEvents方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateSunStatusAction
/**
* updates entry distribution sun status in the search engine
*
* @action updateSunStatus
*/
function updateSunStatusAction()
{
$updatedEntries = array();
// serach all records that their sun status changed to after sunset
$criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
$criteria->add(EntryDistributionPeer::STATUS, EntryDistributionStatus::READY);
$criteria->add(EntryDistributionPeer::SUN_STATUS, EntryDistributionSunStatus::AFTER_SUNSET, Criteria::NOT_EQUAL);
$crit1 = $criteria->getNewCriterion(EntryDistributionPeer::SUNSET, time(), Criteria::LESS_THAN);
$criteria->add($crit1);
$entryDistributions = EntryDistributionPeer::doSelect($criteria);
foreach ($entryDistributions as $entryDistribution) {
/* @var $entryDistribution EntryDistribution */
$entryId = $entryDistribution->getEntryId();
if (isset($updatedEntries[$entryId])) {
continue;
}
$updatedEntries[$entryId] = true;
kEventsManager::raiseEvent(new kObjectUpdatedEvent($entryDistribution));
// raise the updated events to trigger index in search engine (sphinx)
kEventsManager::flushEvents();
// save entry changes to sphinx
kMemoryManager::clearMemory();
}
$updatedEntries = array();
// serach all records that their sun status changed to after sunrise
$criteria = KalturaCriteria::create(EntryDistributionPeer::OM_CLASS);
$criteria->add(EntryDistributionPeer::STATUS, EntryDistributionStatus::QUEUED);
$criteria->add(EntryDistributionPeer::SUN_STATUS, EntryDistributionSunStatus::BEFORE_SUNRISE);
$criteria->add(EntryDistributionPeer::SUNRISE, time(), Criteria::LESS_THAN);
$entryDistributions = EntryDistributionPeer::doSelect($criteria);
foreach ($entryDistributions as $entryDistribution) {
/* @var $entryDistribution EntryDistribution */
$entryId = $entryDistribution->getEntryId();
if (isset($updatedEntries[$entryId])) {
continue;
}
$updatedEntries[$entryId] = true;
kEventsManager::raiseEvent(new kObjectUpdatedEvent($entryDistribution));
// raise the updated events to trigger index in search engine (sphinx)
kEventsManager::flushEvents();
// save entry changes to sphinx
kMemoryManager::clearMemory();
}
}
示例2: parseAction
/**
* Parse content of caption asset and index it
*
* @action parse
* @param string $captionAssetId
* @throws KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND
*/
function parseAction($captionAssetId)
{
$captionAsset = assetPeer::retrieveById($captionAssetId);
if (!$captionAsset) {
throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND, $captionAssetId);
}
$captionAssetItems = CaptionAssetItemPeer::retrieveByAssetId($captionAssetId);
foreach ($captionAssetItems as $captionAssetItem) {
/* @var $captionAssetItem CaptionAssetItem */
$captionAssetItem->delete();
}
// make sure that all old items are deleted from the sphinx before creating the new ones
kEventsManager::flushEvents();
$syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
$content = kFileSyncUtils::file_get_contents($syncKey, true, false);
if (!$content) {
return;
}
$captionsContentManager = kCaptionsContentManager::getCoreContentManager($captionAsset->getContainerFormat());
if (!$captionsContentManager) {
return;
}
$itemsData = $captionsContentManager->parse($content);
foreach ($itemsData as $itemData) {
$item = new CaptionAssetItem();
$item->setCaptionAssetId($captionAsset->getId());
$item->setEntryId($captionAsset->getEntryId());
$item->setPartnerId($captionAsset->getPartnerId());
$item->setStartTime($itemData['startTime']);
$item->setEndTime($itemData['endTime']);
$content = '';
foreach ($itemData['content'] as $curChunk) {
$content .= $curChunk['text'];
}
//Make sure there are no invalid chars in the caption asset items to avoid braking the search request by providing invalid XML
$content = kString::stripUtf8InvalidChars($content);
$content = kXml::stripXMLInvalidChars($content);
$item->setContent($content);
$item->save();
}
}
示例3: execute
public function execute()
{
// can't read using $_REQUEST because the 'myaction' paramter is created in a routing.yml rule
$service_name = $this->getRequestParameter("myaction");
// remove all '_' and set to lowercase
$myaction_name = trim(strtolower(str_replace("_", "", $service_name)));
$clazz_name = $myaction_name . "Action";
// echo "[$myaction_name] [$clazz_name]<br>";
// $clazz = get_class ( $clazz_name );
//$multi_request = $this->getRequestParameter( "multirequest" , null );
$multi_request = $myaction_name == "multirequest";
if ($multi_request) {
$multi_request = new myMultiRequest($_REQUEST, $this);
$response = $multi_request->execute();
} else {
$include_result = @(include_once "{$clazz_name}.class.php");
if ($include_result) {
$myaction = new $clazz_name($this);
$myaction->setInputParams($_REQUEST);
$response = $myaction->execute();
kEventsManager::flushEvents();
} else {
$format = $this->getP("format");
$response = "Error: Invalid service [{$service_name}]";
}
}
$format = $this->getP("format");
if ($format == kalturaWebserviceRenderer::RESPONSE_TYPE_PHP_ARRAY || $format == kalturaWebserviceRenderer::RESPONSE_TYPE_PHP_OBJECT) {
//$this->setHttpHeader ( "Content-Type" , "text/html; charset=utf-8" );
$response = "<pre>" . print_r($response, true) . "</pre>";
}
// uncomment in order to cache api responses
if (kConf::get('enable_cache')) {
$this->cacheResponse($response);
}
$ret = $this->renderText($response);
KExternalErrors::terminateDispatch();
return $ret;
}
示例4: objectReplaced
public function objectReplaced(BaseObject $object, BaseObject $replacingObject, BatchJob $raisedJob = null)
{
//replacement as a result of convertLiveSegmentFinished
if (!$replacingObject->getIsTemporary()) {
return true;
}
$c = new Criteria();
$c->add(CuePointPeer::ENTRY_ID, $object->getId());
if (CuePointPeer::doCount($c) > self::MAX_CUE_POINTS_TO_COPY_TO_CLIP) {
KalturaLog::alert("Can't handle cuePoints after replacement for entry [{$object->getId()}] because cuePoints count exceeded max limit of [" . self::MAX_CUE_POINTS_TO_COPY_TO_CLIP . "]");
return true;
}
$clipAttributes = self::getClipAttributesFromEntry($replacingObject);
//replacement as a result of trimming
if (!is_null($clipAttributes)) {
kEventsManager::setForceDeferredEvents(true);
$this->deleteCuePoints($c);
//copy cuepoints from replacement entry
$replacementCuePoints = CuePointPeer::retrieveByEntryId($replacingObject->getId());
foreach ($replacementCuePoints as $cuePoint) {
$newCuePoint = $cuePoint->copyToEntry($object);
$newCuePoint->save();
}
kEventsManager::flushEvents();
} else {
if (PermissionPeer::isValidForPartner(CuePointPermissionName::REMOVE_CUE_POINTS_WHEN_REPLACING_MEDIA, $object->getPartnerId())) {
$this->deleteCuePoints($c);
}
}
return true;
}
示例5: syncEntriesCategories
public static function syncEntriesCategories(entry $entry, $isCategoriesModified)
{
self::$skipEntrySave = true;
if ($entry->getNewCategories() != null && $entry->getNewCategories() !== "") {
$newCats = explode(entry::ENTRY_CATEGORY_SEPARATOR, $entry->getNewCategories());
} else {
$newCats = array();
}
if (!$isCategoriesModified) {
if ($entry->getNewCategoriesIds() != null && $entry->getNewCategoriesIds() !== "") {
$newCatsIds = explode(entry::ENTRY_CATEGORY_SEPARATOR, $entry->getNewCategoriesIds());
} else {
$newCatsIds = array();
}
KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$dbCategories = categoryPeer::retrieveByPKs($newCatsIds);
KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
foreach ($dbCategories as $dbCategory) {
//skip categoy with privacy contexts.
if ($dbCategory->getPrivacyContexts() != null && $dbCategory->getPrivacyContexts() != '') {
continue;
}
$newCats[] = $dbCategory->getFullName();
}
}
$newCats = array_unique($newCats);
$allIds = array();
$allCats = array();
$allIdsWithParents = array();
$addedCats = array();
$removedCats = array();
$remainingCats = array();
$oldCats = array();
$oldCatsIds = array();
$dbOldCategoriesEntry = categoryEntryPeer::selectByEntryId($entry->getId());
foreach ($dbOldCategoriesEntry as $dbOldCategoryEntry) {
$oldCatsIds[] = $dbOldCategoryEntry->getCategoryId();
}
$oldCategoris = categoryPeer::retrieveByPKsNoFilter($oldCatsIds);
foreach ($oldCategoris as $category) {
if ($category->getPrivacyContexts() != '' && $category->getPrivacyContexts() != null) {
continue;
}
$oldCats[] = $category->getFullName();
}
foreach ($oldCats as $cat) {
if (array_search($cat, $newCats) === false) {
$removedCats[] = $cat;
}
}
foreach ($newCats as $cat) {
if (array_search($cat, $oldCats) === false) {
$addedCats[] = $cat;
} else {
$remainingCats[] = $cat;
}
}
foreach ($remainingCats as $cat) {
KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$category = categoryPeer::getByFullNameExactMatch($cat);
KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
if ($category) {
if ($category->getPrivacyContext() == '' || $category->getPrivacyContext() == null) {
$allCats[] = $category->getFullName();
$allIds[] = $category->getId();
}
$allIdsWithParents[] = $category->getId();
$allIdsWithParents = array_merge($allIdsWithParents, $category->getAllParentsIds());
}
}
$alreadyAddedCatIds = $allIdsWithParents;
foreach ($addedCats as $cat) {
$category = categoryPeer::getByFullNameExactMatch($cat);
if (!$category) {
KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
$unentitedCategory = categoryPeer::getByFullNameExactMatch($cat);
KalturaCriterion::restoreTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
if (!$unentitedCategory) {
$category = category::createByPartnerAndFullName($entry->getPartnerId(), $cat);
//it is possible to add on an entry a few new categories on the same new parent -
//and we need to sync sphinx once we add so the category will not be duplicated
kEventsManager::flushEvents();
}
} else {
$categoryKuser = categoryKuserPeer::retrieveByCategoryIdAndActiveKuserId($category->getId(), kCurrentContext::$ks_kuser_id);
if (kEntitlementUtils::getEntitlementEnforcement() && $category->getContributionPolicy() != ContributionPolicyType::ALL && (!$categoryKuser || $categoryKuser->getPermissionLevel() == CategoryKuserPermissionLevel::MEMBER)) {
//user is not entitled to add entry to this category
$category = null;
}
}
if (!$category) {
continue;
}
//when use caetgoryEntry->add categoryEntry object was alreay created - and no need to create it.
//when using baseEntry->categories = 'my category' will need to add the new category.
$categoryEntry = categoryEntryPeer::retrieveByCategoryIdAndEntryId($category->getId(), $entry->getId());
if (!$categoryEntry) {
$categoryEntry = new categoryEntry();
$categoryEntry->setEntryId($entry->getId());
$categoryEntry->setCategoryId($category->getId());
//.........这里部分代码省略.........
示例6: dispatch
public function dispatch($service, $action, $params = array())
{
$start = microtime(true);
// prevent impersonate to partner zero
$p = isset($params["p"]) && $params["p"] ? $params["p"] : null;
if (!$p) {
$p = isset($params["partnerId"]) && $params["partnerId"] ? $params["partnerId"] : null;
}
$GLOBALS["partnerId"] = $p;
// set for logger
$userId = "";
$ksStr = isset($params["ks"]) ? $params["ks"] : null;
if (!$service) {
throw new KalturaAPIException(KalturaErrors::SERVICE_NOT_SPECIFIED);
}
//strtolower on service - map is indexed according to lower-case service IDs
$service = strtolower($service);
$serviceActionItem = KalturaServicesMap::retrieveServiceActionItem($service, $action);
$action = strtolower($action);
if (!isset($serviceActionItem->actionMap[$action])) {
KalturaLog::crit("Action does not exist!");
throw new KalturaAPIException(KalturaErrors::ACTION_DOES_NOT_EXISTS, $action, $service);
}
try {
$actionReflector = new KalturaActionReflector($service, $action, $serviceActionItem->actionMap[$action]);
} catch (Exception $e) {
throw new Exception("Could not create action reflector for service [{$service}], action [{$action}]. Received error: " . $e->getMessage());
}
$actionParams = $actionReflector->getActionParams();
$actionInfo = $actionReflector->getActionInfo();
// services.ct - check if partner is allowed to access service ...
kCurrentContext::$host = isset($_SERVER["HOSTNAME"]) ? $_SERVER["HOSTNAME"] : gethostname();
kCurrentContext::$user_ip = requestUtils::getRemoteAddress();
kCurrentContext::$ps_vesion = "ps3";
kCurrentContext::$service = $serviceActionItem->serviceInfo->serviceName;
kCurrentContext::$action = $action;
kCurrentContext::$client_lang = isset($params['clientTag']) ? $params['clientTag'] : null;
kCurrentContext::initKsPartnerUser($ksStr, $p, $userId);
// validate it's ok to access this service
$deserializer = new KalturaRequestDeserializer($params);
$this->arguments = $deserializer->buildActionArguments($actionParams);
KalturaLog::debug("Dispatching service [" . $service . "], action [" . $action . "], reqIndex [" . kCurrentContext::$multiRequest_index . "] with params " . print_r($this->arguments, true));
$responseProfile = $deserializer->getResponseProfile();
if ($responseProfile) {
KalturaLog::debug("Response profile: " . print_r($responseProfile, true));
}
kPermissionManager::init(kConf::get('enable_cache'));
kEntitlementUtils::initEntitlementEnforcement();
$disableTags = $actionInfo->disableTags;
if ($disableTags && is_array($disableTags) && count($disableTags)) {
foreach ($disableTags as $disableTag) {
KalturaCriterion::disableTag($disableTag);
}
}
if ($actionInfo->validateUserObjectClass && $actionInfo->validateUserIdParamName && isset($actionParams[$actionInfo->validateUserIdParamName])) {
// // TODO maybe if missing should throw something, maybe a bone?
// if(!isset($actionParams[$actionInfo->validateUserIdParamName]))
// throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, $actionInfo->validateUserIdParamName);
KalturaLog::debug("validateUserIdParamName: " . $actionInfo->validateUserIdParamName);
$objectId = $params[$actionInfo->validateUserIdParamName];
$this->validateUser($actionInfo->validateUserObjectClass, $objectId, $actionInfo->validateUserPrivilege, $actionInfo->validateOptions);
}
// initialize the service before invoking the action on it
// action reflector will init the service to maintain the pluginable action transparency
$actionReflector->initService($responseProfile);
$invokeStart = microtime(true);
KalturaLog::debug("Invoke start");
try {
$res = $actionReflector->invoke($this->arguments);
} catch (KalturaAPIException $e) {
if ($actionInfo->returnType != 'file') {
throw $e;
}
KalturaResponseCacher::adjustApiCacheForException($e);
$res = new kRendererDieError($e->getCode(), $e->getMessage());
}
kEventsManager::flushEvents();
KalturaLog::debug("Invoke took - " . (microtime(true) - $invokeStart) . " seconds");
KalturaLog::debug("Dispatch took - " . (microtime(true) - $start) . " seconds, memory: " . memory_get_peak_usage(true));
return $res;
}
示例7: execute
//.........这里部分代码省略.........
KalturaLog::log('PS2 action ' . get_class($this) . ' is being blocked for partner ' . $currentPartner->getId() . ' defined with FEATURE_PS2_PERMISSIONS_VALIDATION enabled');
$this->addException(APIErrors::SERVICE_FORBIDDEN, get_class($this));
}
}
$this->private_partner_data = $private_partner_data;
//print_r ( $arr );
// TODO - validate the matchIp is ok with the user's IP
$this->validateIp();
// most services should not attempt to cache the results - for them this will return null
$execution_cache_key = $this->getExecutionCacheKeyWrapper($partner_id, $subp_id, $puser_id);
// if the key is not null - it will be used in the renderer for using the cotent from the cache
if ($nocache) {
$renderer->deleteCacheKey($execution_cache_key, $this->response_type);
} else {
$renderer->setCacheKey($execution_cache_key);
}
if (!$renderer->hasContentForCacheKey($this->response_type)) {
$this->benchmarkStart("applyPartnerFilters");
//init entitlement before set the default criteire by myPartnerUtils::applyPartnerFilters
kEntitlementUtils::initEntitlementEnforcement();
// apply filters for Criteria so there will be no chance of exposure of date from other partners !
// TODO - add the parameter for allowing kaltura network
myPartnerUtils::applyPartnerFilters($partner_id, $private_partner_data, $this->partnerGroup2(), $this->kalturaNetwork2());
$this->benchmarkEnd("applyPartnerFilters");
$this->benchmarkStart("puserKuser");
list($partner_id, $subp_id, $puser_id, $partner_prefix) = $this->preparePartnerPuserDetails($partner_id, $subp_id, $puser_id);
$puser_kuser = $this->getPuserKuser($partner_id, $subp_id, $puser_id);
$this->benchmarkEnd("puserKuser");
$this->benchmarkEnd("beforeImpl");
// ----------------------------- impl --------------------------
$start_impl = microtime(true);
$result = $this->executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser);
$end_impl = microtime(true);
kEventsManager::flushEvents();
} else {
/// the renderer claims to have the desired result ! just flow down the code ... ;)
}
// ----------------------------- impl --------------------------
} catch (APIException $api_ex) {
$message = $api_ex->getMessage();
if ($this->should_debug && $message) {
$this->addError(APIErrors::SERVERL_ERROR, "[{$message}]");
} elseif ($api_ex->api_code) {
call_user_func_array(array(&$this, 'addError'), $api_ex->extra_data);
// $this->addError ( $api_ex->api_code ,$api_ex->extra_data );
}
} catch (PropelException $pex) {
KalturaLog::alert($pex->getMessage());
$this->addError(APIErrors::INTERNAL_DATABASE_ERROR);
} catch (Exception $ex) {
$this->addError(APIErrors::INTERNAL_SERVERL_ERROR, $ex->getMessage());
KalturaLog::err($ex->getMessage());
}
$execute_impl_end_time = microtime(true);
// render according to the format_type
$res = array();
$this->addMsg("serverTime", time());
$res['result'] = $this->msg;
$res['error'] = $this->error;
if ($this->should_debug) {
// this specific debug line should be used
$this->addDebug("execute_impl_time", $end_impl - $start_impl);
$this->addDebug("execute_time", $execute_impl_end_time - $start_time);
// will be used as a place holder and will be replaced after the rendering.
if ($add_extra_debug_data) {
$this->addDebug("total_time", self::__TOTAL_TIME__);
示例8: replaceEntry
//.........这里部分代码省略.........
}
if ($newAsset->getFlavorParamsId() || $newAsset instanceof flavorAsset) {
$newAssets[$newAsset->getType()][$newAsset->getFlavorParamsId()] = $newAsset;
KalturaLog::info("Added new asset [" . $newAsset->getId() . "] for asset params [" . $newAsset->getFlavorParamsId() . "]");
} else {
$newAssets[$newAsset->getType()]['asset_' . count($newAssets[$newAsset->getType()])] = $newAsset;
KalturaLog::info("Added new asset [" . $newAsset->getId() . "] with no asset params");
}
}
$defaultThumbAssetNew = null;
$defaultThumbAssetOld = null;
foreach ($oldAssets as $oldAsset) {
/* @var $oldAsset asset */
//If the newAssets map contains an asset of the same type and paramsId as the current old asset,
// re-link the old asset to the new asset.
if (isset($newAssets[$oldAsset->getType()]) && isset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()])) {
$newAsset = $newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()];
if ($oldAsset->hasTag(assetParams::TAG_RECORDING_ANCHOR)) {
$newAsset->addTags(array(assetParams::TAG_RECORDING_ANCHOR));
}
/* @var $newAsset asset */
KalturaLog::info("Create link from new asset [" . $newAsset->getId() . "] to old asset [" . $oldAsset->getId() . "] for flavor [" . $oldAsset->getFlavorParamsId() . "]");
$oldAsset->linkFromAsset($newAsset);
$oldAsset->save();
self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_ISM);
self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_ISMC);
self::createFileSyncLinkFromReplacingAsset($oldAsset, $newAsset, asset::FILE_SYNC_ASSET_SUB_TYPE_MPD);
$newFlavorMediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($newAsset->getId());
if ($newFlavorMediaInfo) {
$oldFlavorNewMediaInfo = $newFlavorMediaInfo->copy();
$oldFlavorNewMediaInfo->setFlavorAssetId($oldAsset->getId());
$oldFlavorNewMediaInfo->setFlavorAssetVersion($oldAsset->getVersion());
$oldFlavorNewMediaInfo->save();
}
unset($newAssets[$oldAsset->getType()][$oldAsset->getFlavorParamsId()]);
if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
$defaultThumbAssetNew = $oldAsset;
KalturaLog::info("Nominating ThumbAsset [" . $oldAsset->getId() . "] as the default ThumbAsset after replacent");
}
} elseif ($oldAsset instanceof flavorAsset || $oldAsset instanceof thumbAsset) {
if ($oldAsset instanceof thumbAsset && $oldAsset->keepOnEntryReplacement()) {
KalturaLog::info("KeepManualThumbnails ind is set, manual thumbnail is not deleted [" . $oldAsset->getId() . "]");
if ($oldAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
$defaultThumbAssetOld = $oldAsset;
}
} else {
KalturaLog::info("Delete old asset [" . $oldAsset->getId() . "] for paramsId [" . $oldAsset->getFlavorParamsId() . "]");
$oldAsset->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_DELETED);
$oldAsset->setDeletedAt(time());
$oldAsset->save();
}
}
}
foreach ($newAssets as $newAssetsByTypes) {
foreach ($newAssetsByTypes as $newAsset) {
$createdAsset = $newAsset->copyToEntry($entry->getId(), $entry->getPartnerId());
KalturaLog::info("Copied from new asset [" . $newAsset->getId() . "] to copied asset [" . $createdAsset->getId() . "] for flavor [" . $newAsset->getFlavorParamsId() . "]");
if ($createdAsset->hasTag(thumbParams::TAG_DEFAULT_THUMB)) {
$defaultThumbAssetNew = $newAsset;
KalturaLog::info("Nominating ThumbAsset [" . $newAsset->getId() . "] as the default ThumbAsset after replacent");
}
}
}
if ($defaultThumbAssetOld) {
KalturaLog::info("Kepping ThumbAsset [" . $defaultThumbAssetOld->getId() . "] as the default ThumbAsset");
} elseif ($defaultThumbAssetNew) {
kBusinessConvertDL::setAsDefaultThumbAsset($defaultThumbAssetNew);
KalturaLog::info("Setting ThumbAsset [" . $defaultThumbAssetNew->getId() . "] as the default ThumbAsset");
} else {
KalturaLog::info("No default ThumbAsset found for replacing entry [" . $tempEntry->getId() . "]");
$entry->setThumbnail(".jpg");
// thumbnailversion++
$entry->save();
$tempEntrySyncKey = $tempEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
$realEntrySyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
kFileSyncUtils::createSyncFileLinkForKey($realEntrySyncKey, $tempEntrySyncKey);
}
self::createIsmManifestFileSyncLinkFromReplacingEntry($tempEntry, $entry);
$entry->setDimensions($tempEntry->getWidth(), $tempEntry->getHeight());
$entry->setLengthInMsecs($tempEntry->getLengthInMsecs());
$entry->setConversionProfileId($tempEntry->getConversionProfileId());
$entry->setConversionQuality($tempEntry->getConversionQuality());
$entry->setReplacingEntryId(null);
$entry->setReplacementStatus(entryReplacementStatus::NONE);
$entry->setReplacementOptions(null);
$entry->setStatus($tempEntry->getStatus());
$entry->save();
//flush deffered events to re-index sphinx before temp entry deletion
kEventsManager::flushEvents();
kBusinessConvertDL::checkForPendingLiveClips($entry);
kEventsManager::raiseEvent(new kObjectReplacedEvent($entry, $tempEntry));
myEntryUtils::deleteEntry($tempEntry, null, true);
$te = new TrackEntry();
$te->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_REPLACED_ENTRY);
$te->setEntryId($entry->getId());
$te->setParam1Str($tempEntry->getId());
$te->setDescription(__METHOD__ . "[" . __LINE__ . "]");
TrackEntry::addTrackEntry($te);
}
示例9: restoreDeletedEntryAction
/**
* Restore deleted entry.
*
* @action restoreDeletedEntry
* @param string $entryId
* @return KalturaBaseEntry The restored entry
*/
public function restoreDeletedEntryAction($entryId)
{
$deletedEntry = entryPeer::retrieveByPKNoFilter($entryId);
if (!$deletedEntry) {
throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
}
$fileSyncKeys = array();
foreach (self::$fileSyncKeysToRestore as $key) {
$fileSyncKeys[] = $deletedEntry->getSyncKey($key);
}
$c = new Criteria();
$c->add(assetPeer::ENTRY_ID, $entryId, Criteria::EQUAL);
assetPeer::setUseCriteriaFilter(false);
$deletedAssets = assetPeer::doSelect($c);
assetPeer::setUseCriteriaFilter(true);
foreach ($deletedAssets as $deletedAsset) {
array_push($fileSyncKeys, $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET), $deletedAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_CONVERT_LOG));
}
$fileSyncs = array();
FileSyncPeer::setUseCriteriaFilter(false);
foreach ($fileSyncKeys as $fileSyncKey) {
$fileSyncs = array_merge($fileSyncs, FileSyncPeer::retrieveAllByFileSyncKey($fileSyncKey));
}
FileSyncPeer::setUseCriteriaFilter(true);
if (!$this->validateEntryForRestoreDelete($deletedEntry, $fileSyncs, $deletedAssets)) {
throw new KalturaAPIException(KalturaAdminConsoleErrors::ENTRY_ASSETS_WRONG_STATUS_FOR_RESTORE, $entryId);
}
$this->restoreFileSyncs($fileSyncs);
//restore assets
foreach ($deletedAssets as $deletedAsset) {
$deletedAsset->setStatus(asset::ASSET_STATUS_READY);
$deletedAsset->save();
}
//restore entry
$deletedEntry->setStatusReady();
$deletedEntry->setThumbnail($deletedEntry->getFromCustomData("deleted_original_thumb"), true);
$deletedEntry->setData($deletedEntry->getFromCustomData("deleted_original_data"), true);
//data should be resotred even if it's NULL
$deletedEntry->save();
kEventsManager::flushEvents();
kMemoryManager::clearMemory();
$entry = KalturaEntryFactory::getInstanceByType($deletedEntry->getType(), true);
$entry->fromObject($deletedEntry, $this->getResponseProfile());
return $entry;
}
示例10: postInsert
public function postInsert(PropelPDO $con = null)
{
parent::postInsert($con);
if ($this->getFullIds() == null) {
$this->reSetFullIds();
parent::save();
}
if (!$this->alreadyInSave) {
kEventsManager::raiseEvent(new kObjectAddedEvent($this));
}
kEventsManager::flushEvents();
if ($this->getParentCategory()) {
$parentCategory = $this->getParentCategory();
if ($parentCategory) {
$parentCategory->reSetDirectSubCategoriesCount();
$parentCategory->save();
}
}
}
示例11: time
$updatedAt = time() - $daysOld * 24 * 60 * 60;
chdir(dirname(__FILE__));
require_once dirname(__FILE__) . '/../bootstrap.php';
$typesToDelete = array();
$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
$c = new Criteria();
$c->add(entryPeer::PARTNER_ID, 100, Criteria::GREATER_THAN);
$c->add(entryPeer::UPDATED_AT, $updatedAt, Criteria::LESS_THAN);
if (count($typesToDelete)) {
$c->add(entryPeer::TYPE, $typesToDelete, Criteria::IN);
}
$count = 0;
$entries = entryPeer::doSelect($c);
while ($entries) {
$count += count($entries);
foreach ($entries as $entry) {
kCurrentContext::$ks_partner_id = $entry->getPartnerId();
kCurrentContext::$partner_id = $entry->getPartnerId();
kCurrentContext::$master_partner_id = $entry->getPartnerId();
KalturaLog::debug("Deletes entry [" . $entry->getId() . "]");
KalturaStatement::setDryRun($dryRun);
myEntryUtils::deleteEntry($entry, $entry->getPartnerId());
KalturaStatement::setDryRun(false);
}
kEventsManager::flushEvents();
kMemoryManager::clearMemory();
$entries = entryPeer::doSelect($c);
}
KalturaLog::debug("Deleted [{$count}] entries");
示例12: setAllTemplateEntriesToAdminKuser
private function setAllTemplateEntriesToAdminKuser($partnerId, $kuserId)
{
$c = new Criteria();
$c->addAnd(entryPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
entryPeer::setUseCriteriaFilter(false);
$allEntries = entryPeer::doSelect($c);
entryPeer::setUseCriteriaFilter(true);
// set the new partner id into the default category criteria filter
$defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter();
$oldPartnerIdCategory = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $partnerId);
// set the new partner id into the default category criteria filter
$defaultCategoryEntryFilter = categoryEntryPeer::getCriteriaFilter()->getFilter();
$oldPartnerIdCategoryEntry = $defaultCategoryFilter->get(categoryEntryPeer::PARTNER_ID);
$defaultCategoryEntryFilter->remove(categoryEntryPeer::PARTNER_ID);
$defaultCategoryEntryFilter->addAnd(categoryEntryPeer::PARTNER_ID, $partnerId);
foreach ($allEntries as $entry) {
$entry->setKuserId($kuserId);
$entry->setCreatorKuserId($kuserId);
$entry->save();
}
kEventsManager::flushEvents();
// restore the original partner id in the default category criteria filter
$defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
$defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerIdCategory);
$defaultCategoryEntryFilter->remove(categoryEntryPeer::PARTNER_ID);
$defaultCategoryEntryFilter->addAnd(categoryEntryPeer::PARTNER_ID, $oldPartnerIdCategoryEntry);
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:29,代码来源:myPartnerRegistration.class.php
示例13: copyEntry
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());
$flavorParamsStr = $entry->getFlavorParamsIds();
$flavorParams = explode(',', $flavorParamsStr);
$newFlavorParams = array();
foreach ($flavorParams as $flavorParamsId) {
$newFlavorParamsId = kObjectCopyHandler::getMappedId('flavorParams', $flavorParamsId);
if (is_null($newFlavorParamsId)) {
$newFlavorParamsId = $flavorParamsId;
}
$newFlavorParams[] = $newFlavorParamsId;
}
$newEntry->setFlavorParamsIds(implode(',', $newFlavorParams));
}
$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();
//we must flush events to sync categories to sphinx. if categories are not synced - then they might be duplicated, if 2 entries are assign to the same category.
kEventsManager::flushEvents();
// 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"])) {
//.........这里部分代码省略.........