/**
  * @param KalturaMetadataObjectType $objectType
  * @param BaseObject $fromObject
  * @param BaseObject $toObject
  */
 protected function copyMetadata($objectType, BaseObject $fromObject, BaseObject $toObject)
 {
     KalturaLog::debug("Copy metadata type [{$objectType}] from " . get_class($fromObject) . '[' . $fromObject->getId() . "] to[" . $toObject->getId() . "]");
     $c = new Criteria();
     $c->add(MetadataPeer::OBJECT_TYPE, $objectType);
     $c->add(MetadataPeer::OBJECT_ID, $fromObject->getId());
     $metadatas = MetadataPeer::doSelect($c);
     foreach ($metadatas as $metadata) {
         $newMetadata = $metadata->copy();
         $newMetadata->setObjectId($toObject->getId());
         if ($toObject instanceof Partner) {
             $newMetadata->setPartnerId($toObject->getId());
         } else {
             $newMetadata->setPartnerId($toObject->getPartnerId());
         }
         $metadataProfileId = kObjectCopyHandler::getMappedId('MetadataProfile', $metadata->getMetadataProfileId());
         if ($metadataProfileId) {
             $metadataProfile = MetadataProfilePeer::retrieveByPK($metadataProfileId);
             if ($metadataProfile) {
                 $newMetadata->setMetadataProfileId($metadataProfileId);
                 $newMetadata->setMetadataProfileVersion($metadataProfile->getVersion());
             }
         }
         $newMetadata->save();
         kFileSyncUtils::createSyncFileLinkForKey($newMetadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA), $metadata->getSyncKey(Metadata::FILE_SYNC_METADATA_DATA));
     }
 }
Esempio n. 2
0
 public function getKey()
 {
     if (method_exists($this->toObject, 'getId')) {
         return get_class($this->object) . $this->toObject->getId();
     }
     return null;
 }
Esempio n. 3
0
 protected function calculateCrumb(BaseObject $object)
 {
     $parentId = $object->getParentId();
     if (!$parentId) {
         $this->crumbsByObjectId[$object->getId()] = array($object->getName());
         return $this->crumbsByObjectId[$object->getId()];
     }
     if (isset($this->crumbsByObjectId[$parentId])) {
         $this->crumbsByObjectId[$object->getId()] = $this->crumbsByObjectId[$parentId];
         $this->crumbsByObjectId[$object->getId()][] = $object->getName();
         return $this->crumbsByObjectId[$object->getId()];
     }
     $storage = $object->getStorage();
     $fake = Driver::getInstance()->getFakeSecurityContext();
     $this->crumbsByObjectId[$object->getId()] = array();
     foreach ($object->getParents($fake, array('select' => array('ID', 'NAME', 'TYPE')), SORT_DESC) as $parent) {
         if ($parent->getId() == $storage->getRootObjectId()) {
             continue;
         }
         $this->crumbsByObjectId[$object->getId()][] = $parent->getName();
     }
     unset($parent);
     $this->crumbsByObjectId[$parentId] = $this->crumbsByObjectId[$object->getId()];
     $this->crumbsByObjectId[$object->getId()][] = $object->getName();
     return $this->crumbsByObjectId[$object->getId()];
 }
 /**
  * @param kObjectSavedEventConsumer $consumer
  * @return bool true if should continue to the next consumer
  */
 protected function doConsume(KalturaEventConsumer $consumer)
 {
     if (!$consumer->shouldConsumeSavedEvent($this->object)) {
         return true;
     }
     $additionalLog = '';
     if (method_exists($this->object, 'getId')) {
         $additionalLog .= 'id [' . $this->object->getId() . ']';
     }
     KalturaLog::debug(get_class($this) . ' event consumed by ' . get_class($consumer) . ' object type [' . get_class($this->object) . '] ' . $additionalLog);
     return $consumer->objectSaved($this->object);
 }
Esempio n. 5
0
 /**
  * @param kObjectSavedEventConsumer $consumer
  * @return bool true if should continue to the next consumer
  */
 protected function doConsume(KalturaEventConsumer $consumer)
 {
     if (!$consumer->shouldConsumeSavedEvent($this->object)) {
         return true;
     }
     $additionalLog = '';
     if (method_exists($this->object, 'getId')) {
         $additionalLog .= 'id [' . $this->object->getId() . ']';
     }
     KalturaLog::debug('consumer [' . get_class($consumer) . '] started handling [' . get_class($this) . '] object type [' . get_class($this->object) . '] ' . $additionalLog);
     $result = $consumer->objectSaved($this->object);
     KalturaLog::debug('consumer [' . get_class($consumer) . '] finished handling [' . get_class($this) . '] object type [' . get_class($this->object) . '] ' . $additionalLog);
     return $result;
 }
    /**
     * Returns recommended objects which the user has not rated based on his/her 
     * rating of other objects.
     * 
     * This implementation is based on the 
     * OpenSlopeOne project by Chaoqun Fu, http://code.google.com/p/openslopeone/.
     * 
     * @param BaseObject $object The user for which to return the recommendations
     * @param string $model The name of the class for which to return recommendations
     * @param int $limit The number of recommendation objects which should be returned. 
     * Use NULL for returning all recommended objects
     * @return array of sfRecommendationObject objects which wrap the recommended objects
     */
    public function getRecommendations(BaseObject $object, $model, $limit = NULL)
    {
        $parser = new sfPropelSlopeOneSqlParser();
        $slopeQuery = 'SELECT 	sf_slope_one.item2_id AS id, 
    												SUM((%ratings%.%rating% * sf_slope_one.times) - sf_slope_one.rating)/
                            SUM(sf_slope_one.times) AS rating
                    FROM sf_slope_one, %ratings% 
                    WHERE %ratings%.%rater_id% = :rater_id AND
                          %ratings%.%rateable_model% = :item_model AND
                          %ratings%.%rateable_id% = sf_slope_one.item1_id AND
                          %ratings%.%rateable_model% = sf_slope_one.item1_model AND
                          sf_slope_one.item2_id NOT IN (SELECT %ratings%.%rateable_id% 
														                          	FROM %ratings% 
														                          	WHERE %ratings%.%rater_id% = :rater_id)
                    GROUP BY item2_id
                    ORDER BY rating DESC';
        $slopeQuery .= isset($limit) ? ' LIMIT ' . $limit : '';
        $connection = Propel::getConnection();
        $statement = $connection->prepare($parser->parse($slopeQuery));
        $statement->execute(array('rater_id' => $object->getId(), 'item_model' => $model));
        $ratings = array();
        while ($result = $statement->fetch()) {
            $ratings[$result['id']] = $result['rating'];
        }
        $modelObject = new $model();
        $objects = call_user_func(array(get_class($modelObject->getPeer()), 'retrieveByPKs'), array_keys($ratings));
        foreach ($objects as &$object) {
            $object = new sfSlopeOneRecommendation($object, $ratings[$object->getId()]);
        }
        return $objects;
    }
 /**
  * @param BaseObject $object
  */
 public function attachCreatedObject(BaseObject $object)
 {
     $dropFolderFile = DropFolderFilePeer::retrieveByPK($this->getDropFolderFileId());
     $dropFolder = DropFolderPeer::retrieveByPK($dropFolderFile->getDropFolderId());
     $entryId = $asset = null;
     // create import job for remote drop folder files
     if ($dropFolder instanceof RemoteDropFolder) {
         // get params
         if ($object instanceof asset) {
             $entryId = $object->getEntryId();
             $asset = $object;
         } else {
             if ($object instanceof entry) {
                 $entryId = $object->getId();
                 $asset = null;
             } else {
                 return;
             }
         }
         $importUrl = $dropFolder->getFolderUrl();
         $importUrl .= '/' . $dropFolderFile->getFileName();
         $jobData = $dropFolder->getImportJobData();
         $jobData->setDropFolderFileId($this->getDropFolderFileId());
         // add job
         kJobsManager::addImportJob(null, $entryId, $dropFolderFile->getPartnerId(), $importUrl, $asset, $dropFolder->getFileTransferMgrType(), $jobData);
         // set file status to DOWNLOADING
         $dropFolderFile->setStatus(DropFolderFileStatus::DOWNLOADING);
         $dropFolderFile->save();
     }
 }
    /**
     * Returns objects of the same class and with similar ratings as the current rateable object.
     * 
     * This implementation is based on the 
     * OpenSlopeOne project by Chaoqun Fu, http://code.google.com/p/openslopeone/.
     *
     * @param BaseObject $object The rateable object for which to return other recommended object
     * @param int $limit The number of recommendation objects which should be returned. Use NULL for returning all recommended objects
     * @return array of sfRecommendationObject objects which wrap the recommended objects
     */
    public function getRecommendations(BaseObject $object, $limit = NULL)
    {
        $parser = new sfPropelSlopeOneSqlParser();
        $slopeQuery = 'SELECT 	item2_id AS id,
    												SUM(rating/times) AS rating
                    FROM sf_slope_one 
                    WHERE item1_id = :item_id AND 
													item1_model = :item_model AND
                          item1_model = item2_model
                    GROUP BY item2_id
                    ORDER BY rating DESC';
        $slopeQuery .= isset($limit) ? ' LIMIT ' . $limit : '';
        $connection = Propel::getConnection();
        $statement = $connection->prepare($parser->parse($slopeQuery));
        $statement->execute(array('item_id' => $object->getId(), 'item_model' => get_class($object)));
        $ratings = array();
        while ($result = $statement->fetch()) {
            $ratings[$result['id']] = $result['rating'];
        }
        $objects = call_user_func(array(get_class($object->getPeer()), 'retrieveByPKs'), array_keys($ratings));
        foreach ($objects as &$object) {
            $object = new sfSlopeOneRecommendation($object, $ratings[$object->getId()]);
        }
        return $objects;
    }
 /**
  * @param BaseObject $object
  * @return bool true if should continue to the next consumer
  */
 public function objectAdded(BaseObject $object)
 {
     if (!$object instanceof FileSync || $object->getStatus() != FileSync::FILE_SYNC_STATUS_PENDING || $object->getFileType() != FileSync::FILE_SYNC_FILE_TYPE_FILE || $object->getDc() == kDataCenterMgr::getCurrentDcId()) {
         return true;
     }
     $c = new Criteria();
     $c->addAnd(FileSyncPeer::OBJECT_ID, $object->getObjectId());
     $c->addAnd(FileSyncPeer::VERSION, $object->getVersion());
     $c->addAnd(FileSyncPeer::OBJECT_TYPE, $object->getObjectType());
     $c->addAnd(FileSyncPeer::OBJECT_SUB_TYPE, $object->getObjectSubType());
     $c->addAnd(FileSyncPeer::ORIGINAL, '1');
     $original_filesync = FileSyncPeer::doSelectOne($c);
     if (!$original_filesync) {
         KalturaLog::err('Original filesync not found for object_id[' . $object->getObjectId() . '] version[' . $object->getVersion() . '] type[' . $object->getObjectType() . '] subtype[' . $object->getObjectSubType() . ']');
         return true;
     }
     $sourceFileUrl = $original_filesync->getExternalUrl();
     if (!$sourceFileUrl) {
         KalturaLog::err('External URL not found for filesync id [' . $object->getId() . ']');
         return true;
     }
     $job = kMultiCentersManager::addFileSyncImportJob($this->getEntryId($object), $object->getPartnerId(), $object->getId(), $sourceFileUrl);
     $job->setDc($object->getDc());
     $job->save();
     return true;
 }
 /**
  * @param BaseObject $fromObject
  * @param BaseObject $toObject
  * @return bool true if should continue to the next consumer
  */
 public function objectCopied(BaseObject $fromObject, BaseObject $toObject)
 {
     if ($fromObject instanceof Partner) {
         $this->copyDistributionProfiles($fromObject->getId(), $toObject->getId());
     }
     return true;
 }
 /**
  * Execute method reload
  *
  * @param string $request 
  * @return array
  * @author Łukasz Wojciechowski
  */
 public function execute($request)
 {
     if ($request->isMethod('post')) {
         if ($this->processPostData()) {
             $result = array('success' => true, 'message' => "Saved with success!", 'redirect' => $this->widgetUri . '?id=' . $this->object->getId());
             return $result;
         }
     }
 }
 public function objectDeleted(BaseObject $object, BatchJob $raisedJob = null)
 {
     $shortLinks = ShortLinkPeer::retrieveByKuserId($object->getId());
     foreach ($shortLinks as $shortLink) {
         $shortLink->setStatus(ShortLinkStatus::DELETED);
         $shortLink->save();
     }
     return true;
 }
Esempio n. 13
0
 public function objectCreated(BaseObject $object)
 {
     /* @var $object entry */
     $partner = $object->getPartner();
     $velocixLiveParamsJSON = json_decode($partner->getLiveStreamProvisionParams());
     if (!isset($velocixLiveParamsJSON->velocix) || !isset($velocixLiveParamsJSON->velocix->userName) || !isset($velocixLiveParamsJSON->velocix->password)) {
         $object->setStatus(entryStatus::ERROR_IMPORTING);
         $object->save();
         return true;
     }
     if (isset($velocixLiveParamsJSON->velocix->streamNamePrefix)) {
         $object->setStreamName($velocixLiveParamsJSON->velocix->streamNamePrefix . '_' . $object->getId());
     } else {
         $object->setStreamName($object->getId());
     }
     $object->save();
     return true;
 }
 public function objectDeleted(BaseObject $object, BatchJob $raisedJob = null)
 {
     if ($object instanceof entry) {
         $this->entryDeleted($object->getId());
     }
     if ($object instanceof CuePoint) {
         $this->cuePointDeleted($object);
     }
     return true;
 }
 public function contribute(BaseObject $object, SimpleXMLElement $mrss, kMrssParameters $mrssParams = null)
 {
     if (!$object instanceof entry) {
         return;
     }
     $entryDistributions = EntryDistributionPeer::retrieveByEntryId($object->getId());
     foreach ($entryDistributions as $entryDistribution) {
         $this->contributeDistribution($entryDistribution, $mrss);
     }
 }
Esempio n. 16
0
 public function objectDeleted(BaseObject $object)
 {
     if ($object instanceof kuser) {
         $shortLinks = ShortLinkPeer::retrieveByKuserId($object->getId());
         foreach ($shortLinks as $shortLink) {
             $shortLink->setStatus(ShortLinkStatus::DELETED);
             $shortLink->save();
         }
     }
 }
 public function objectCopied(BaseObject $fromObject, BaseObject $toObject)
 {
     if ($fromObject instanceof asset) {
         self::mapIds('asset', $fromObject->getId(), $toObject->getId());
         $flavorParamsId = self::getMappedId('assetParams', $fromObject->getFlavorParamsId());
         if ($flavorParamsId) {
             $toObject->setFlavorParamsId($flavorParamsId);
             $toObject->save();
         }
     } elseif ($fromObject instanceof assetParams) {
         self::mapIds('assetParams', $fromObject->getId(), $toObject->getId());
     } elseif ($fromObject instanceof assetParamsOutput) {
         self::mapIds('assetParamsOutput', $fromObject->getId(), $toObject->getId());
         $flavorParamsId = self::getMappedId('assetParams', $fromObject->getFlavorParamsId());
         if ($flavorParamsId) {
             $toObject->setFlavorParamsId($flavorParamsId);
             $toObject->save();
         }
     } else {
         self::mapIds(get_class($fromObject), $fromObject->getId(), $toObject->getId());
     }
     if ($fromObject instanceof category && $fromObject->getParentId()) {
         $parentId = self::getMappedId('category', $fromObject->getParentId());
         if ($parentId) {
             $toObject->setParentId($parentId);
             $toObject->save();
         }
     }
     if ($fromObject instanceof entry) {
         $conversionProfileId = self::getMappedId('conversionProfile2', $fromObject->getConversionProfileId());
         if ($conversionProfileId) {
             $toObject->setConversionProfileId($conversionProfileId);
             $toObject->save();
         }
         $accessControlId = self::getMappedId('accessControl', $fromObject->getAccessControlId());
         if ($accessControlId) {
             $toObject->setAccessControlId($accessControlId);
             $toObject->save();
         }
     }
     return true;
 }
Esempio n. 18
0
 /**
  * @param BaseObject $object
  */
 public function objectDeleted(BaseObject $object)
 {
     KalturaLog::debug("annotation objectDeleted");
     if ($object instanceof entry) {
         $this->entryDeleted($object->getId());
     }
     if ($object instanceof Annotation) {
         $this->annotationDeleted($object);
     }
     return true;
 }
 public function objectChanged(BaseObject $object, array $modifiedColumns)
 {
     $c = new Criteria();
     $c->addAnd(BatchJobLogPeer::JOB_ID, $object->getId());
     $batchJobLog = BatchJobLogPeer::doSelectOne($c);
     if (!$batchJobLog) {
         return;
     }
     KalturaLog::info("Handling batch job log object with Id [" . $batchJobLog->getId() . "]");
     $batchJobLog = $this->copyModifiedColumns($batchJobLog, $object, $modifiedColumns);
     $batchJobLog->save();
 }
 /**
  * @param BaseObject $object
  */
 public function objectDeleted(BaseObject $object)
 {
     if ($object instanceof entry) {
         $this->deleteMetadataObjects(Metadata::TYPE_ENTRY, $object->getId());
     }
     if ($object instanceof Metadata) {
         $this->metadataDeleted($object);
     }
     if ($object instanceof MetadataProfile) {
         $this->metadataProfileDeleted($object);
     }
     return true;
 }
Esempio n. 21
0
 /**
  * @param BaseObject $fromObject
  * @param BaseObject $toObject
  * @return bool true if should continue to the next consumer
  */
 public function objectCopied(BaseObject $fromObject, BaseObject $toObject)
 {
     if ($fromObject instanceof assetParams) {
         self::mapIds('assetParams', $fromObject->getId(), $toObject->getId());
     }
     if ($fromObject instanceof assetParamsOutput) {
         $flavorParamsId = self::getMappedId('assetParams', $fromObject->getFlavorParamsId());
         if ($flavorParamsId) {
             $toObject->setFlavorParamsId($flavorParamsId);
         }
     }
     return true;
 }
 public function objectDeleted(BaseObject $object, BatchJob $raisedJob = null)
 {
     if ($object instanceof entry) {
         $this->deleteMetadataObjects(MetadataObjectType::ENTRY, $object->getId());
     }
     if ($object instanceof kuser) {
         $this->deleteMetadataObjects(MetadataObjectType::USER, $object->getId());
     }
     if ($object instanceof category) {
         $this->deleteMetadataObjects(MetadataObjectType::CATEGORY, $object->getId());
     }
     if ($object instanceof Partner) {
         $this->deleteMetadataObjects(MetadataObjectType::PARTNER, $object->getId());
     }
     if ($object instanceof Metadata) {
         $this->metadataDeleted($object);
     }
     if ($object instanceof MetadataProfile) {
         $this->metadataProfileDeleted($object);
     }
     return parent::objectDeleted($object);
 }
 public function objectDeleted(BaseObject $object, BatchJob $raisedJob = null)
 {
     /* @var $object CaptionAsset */
     // delete them one by one to raise the erased event
     $captionAssetItems = CaptionAssetItemPeer::retrieveByAssetId($object->getId());
     foreach ($captionAssetItems as $captionAssetItem) {
         /* @var $captionAssetItem CaptionAssetItem */
         $captionAssetItem->delete();
     }
     // updates entry on order to trigger reindexing
     $entry = $object->getentry();
     $entry->setUpdatedAt(time());
     $entry->save();
 }
Esempio n. 24
0
 public function objectCreated(BaseObject $object)
 {
     $entry = entryPeer::retrieveByPK($object->getEntryId());
     if ($entry && $entry->getReplacedEntryId()) {
         $entry = entryPeer::retrieveByPK($entry->getReplacedEntryId());
     }
     $wvFlavorParamsOutput = assetParamsOutputPeer::retrieveByPK($object->getId());
     if ($entry && $wvFlavorParamsOutput) {
         $wvFlavorParamsOutput->setWidevineDistributionStartDate($this->getLicenseStartDateFromEntry($entry));
         $wvFlavorParamsOutput->setWidevineDistributionEndDate($this->getLicenseEndDateFromEntry($entry));
         $wvFlavorParamsOutput->save();
     }
     return true;
 }
 /**
  * @param BaseObject $object
  * @param SimpleXMLElement $mrss
  * @param kMrssParameters $mrssParams
  * @return SimpleXMLElement
  */
 public function contribute(BaseObject $object, SimpleXMLElement $mrss, kMrssParameters $mrssParams = null)
 {
     if (!$object instanceof entry) {
         return;
     }
     $children = entryPeer::retrieveChildEntriesByEntryIdAndPartnerId($object->getId(), $object->getPartnerId());
     if (!count($children)) {
         return;
     }
     $childrenNode = $mrss->addChild('children');
     $childrenDom = dom_import_simplexml($childrenNode);
     foreach ($children as $child) {
         $childXML = kMrssManager::getEntryMrssXml($child);
         $childDom = dom_import_simplexml($childXML);
         $childDom = $childrenDom->ownerDocument->importNode($childDom, true);
         $childrenDom->appendChild($childDom);
     }
 }
 public function objectCreated(BaseObject $object)
 {
     /* @var $object entry */
     $partner = $object->getPartner();
     $limeLightLiveParamsJSON = $partner->getLiveStreamProvisionParams();
     $limeLightLiveParams = json_decode($limeLightLiveParamsJSON);
     if (!isset($limeLightLiveParams->Limelight) || !isset($limeLightLiveParams->Limelight->limelightPrimaryPublishUrl) || !isset($limeLightLiveParams->Limelight->limelightSecondaryPublishUrl) || !isset($limeLightLiveParams->Limelight->limelightStreamUrl)) {
         $object->setStatus(entryStatus::ERROR_IMPORTING);
         $object->save();
         return true;
     }
     $object->setPrimaryBroadcastingUrl($limeLightLiveParams->Limelight->limelightPrimaryPublishUrl);
     $object->setSecondaryBroadcastingUrl($limeLightLiveParams->Limelight->limelightSecondaryPublishUrl);
     $object->setStreamUrl($limeLightLiveParams->Limelight->limelightStreamUrl);
     $object->setStreamName($object->getId() . '_%i');
     $object->setStatus(entryStatus::READY);
     $object->save();
     return true;
 }
Esempio n. 27
0
 /**
  * @param BaseObject $object
  * @return bool true if should continue to the next consumer
  */
 public function objectAdded(BaseObject $object)
 {
     if ($object instanceof flavorAsset && $object->getIsOriginal()) {
         $entry = $object->getentry();
         if ($entry->getType() == entryType::DOCUMENT) {
             if ($entry->getConversionQuality() > 0) {
                 $syncKey = $object->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
                 $path = kFileSyncUtils::getLocalFilePathForKey($syncKey);
                 kJobsManager::addConvertProfileJob(null, $entry, $object->getId(), $path);
             } else {
                 // only for documents entry, make the source ready since no conversion profile will be executed by default
                 $object->setFlavorParamsId(flavorParams::SOURCE_FLAVOR_ID);
                 $object->setStatus(flavorAsset::FLAVOR_ASSET_STATUS_READY);
                 $object->save();
                 $entry->setStatusReady();
                 $entry->save();
             }
         }
     }
     return true;
 }
 /**
  * 
  * Compares two propel objects and notifies the PHPUnit / Kaltura's listeners
  * @param BaseObject $outputReference
  * @param BaseObject $newResult
  * @return array<> $newErrors, if the objects are equal
  */
 public function comparePropelObjectsByFields($outputReference, $newResult, $validErrorFields)
 {
     //Gets the data peer of the object (used to geting all the obejct feilds)
     $dataPeer = $outputReference->getPeer();
     $outputReferenceId = $outputReference->getId();
     $newResultId = $newResult->getId();
     //Gets all object feilds
     $fields = call_user_func(array($dataPeer, "getFieldNames"), BasePeer::TYPE_PHPNAME);
     $newErrors = array();
     //Create the xml elements by all fields and their values
     foreach ($fields as $field) {
         PHP_Timer::start();
         //If the field is in the valid failure list then we skip him
         if (in_array($field, $validErrorFields)) {
             continue;
         } else {
             $expectedValue = $outputReference->getByName($field);
             $actualValue = $newResult->getByName($field);
             //if this is an array we need to change it to a string
             $this->compareOnField($field, $actualValue, $expectedValue, "assertEquals");
         }
     }
     return $newErrors;
 }
Esempio n. 29
0
 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;
 }
Esempio n. 30
0
 public function objectChanged(BaseObject $object, array $modifiedColumns)
 {
     /* @var $object FileSync */
     $c = new Criteria();
     $c->add(FileSyncPeer::DC, $object->getDc());
     $c->add(FileSyncPeer::FILE_TYPE, array(FileSync::FILE_SYNC_FILE_TYPE_LINK, FileSync::FILE_SYNC_FILE_TYPE_URL), Criteria::IN);
     $c->add(FileSyncPeer::LINKED_ID, $object->getId());
     $c->addAscendingOrderByColumn(FileSyncPeer::ID);
     $c->setLimit(100);
     $offset = 0;
     $links = FileSyncPeer::doSelect($c);
     while ($links) {
         $offset += count($links);
         foreach ($links as $link) {
             $link->setStatus($object->getStatus());
             $link->save();
         }
         $c->setOffset($offset);
         $links = FileSyncPeer::doSelect($c);
     }
 }