예제 #1
0
 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());
 }
 /**
  * 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 KalturaFreewheelGenericDistributionProfile) {
         return;
     }
     $this->videoAssetFilePaths = new KalturaStringArray();
     // loads all the flavor assets that should be submitted to the remote destination site
     $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds));
     foreach ($flavorAssets as $flavorAsset) {
         $videoAssetFilePath = new KalturaString();
         $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $videoAssetFilePath->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
         $this->videoAssetFilePaths[] = $videoAssetFilePath;
     }
     $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds));
     if (count($thumbAssets)) {
         $thumbAsset = reset($thumbAssets);
         $syncKey = $thumbAssets->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
     }
     // entry cue points
     $c = KalturaCriteria::create(CuePointPeer::OM_CLASS);
     $c->add(CuePointPeer::PARTNER_ID, $distributionJobData->entryDistribution->partnerId);
     $c->add(CuePointPeer::ENTRY_ID, $distributionJobData->entryDistribution->entryId);
     $c->add(CuePointPeer::TYPE, AdCuePointPlugin::getCuePointTypeCoreValue(AdCuePointType::AD));
     $c->addAscendingOrderByColumn(CuePointPeer::START_TIME);
     $cuePointsDb = CuePointPeer::doSelect($c);
     $this->cuePoints = KalturaCuePointArray::fromDbArray($cuePointsDb);
 }
예제 #3
0
 public function getChildren()
 {
     if ($this->isNew()) {
         return array();
     }
     $c = KalturaCriteria::create(CuePointPeer::OM_CLASS);
     $c->add(CuePointPeer::PARENT_ID, $this->getId());
     return CuePointPeer::doSelect($c);
 }
 public function getChildren()
 {
     if ($this->isNew()) {
         return array();
     }
     $c = new Criteria();
     $c->add(CuePointPeer::PARENT_ID, $this->getId());
     return CuePointPeer::doSelect($c);
 }
예제 #5
0
 /**
  * @param $partnerId
  * @param $entryId
  */
 protected function getCuePoints($partnerId, $entryId)
 {
     $c = KalturaCriteria::create(CuePointPeer::OM_CLASS);
     $c->add(CuePointPeer::PARTNER_ID, $partnerId);
     $c->add(CuePointPeer::ENTRY_ID, $entryId);
     $c->add(CuePointPeer::TYPE, AdCuePointPlugin::getCuePointTypeCoreValue(AdCuePointType::AD));
     $c->addAscendingOrderByColumn(CuePointPeer::START_TIME);
     return CuePointPeer::doSelect($c);
 }
 /**
  * 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 KalturaHuluDistributionProfile) {
         return;
     }
     // loads all the flavor assets that should be submitted to the remote destination site
     $flavorAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->flavorAssetIds));
     if (count($flavorAssets)) {
         $flavorAsset = reset($flavorAssets);
         $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $this->videoAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
     }
     $thumbAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->thumbAssetIds));
     if (count($thumbAssets)) {
         $thumbAsset = reset($thumbAssets);
         $syncKey = $thumbAsset->getSyncKey(thumbAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $this->thumbAssetFilePath = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
     }
     $additionalAssets = assetPeer::retrieveByIds(explode(',', $distributionJobData->entryDistribution->assetIds));
     $this->captionLocalPaths = new KalturaStringArray();
     if (count($additionalAssets)) {
         $captionAssetFilePathArray = array();
         foreach ($additionalAssets as $additionalAsset) {
             $assetType = $additionalAsset->getType();
             $syncKey = $additionalAsset->getSyncKey(CaptionAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
             if (kFileSyncUtils::fileSync_exists($syncKey)) {
                 if ($assetType == CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION) || $assetType == AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT)) {
                     $string = new KalturaString();
                     $string->value = kFileSyncUtils::getLocalFilePathForKey($syncKey, false);
                     $this->captionLocalPaths[] = $string;
                 }
             }
         }
     }
     $tempFieldValues = unserialize($this->fieldValues);
     $pattern = '/[^A-Za-z0-9_\\-]/';
     $seriesTitle = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::SERIES_TITLE]);
     $seasonNumber = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::SEASON_NUMBER]);
     $videoEpisodeNumber = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::VIDEO_EPISODE_NUMBER]);
     $videoTitle = preg_replace($pattern, '', $tempFieldValues[HuluDistributionField::VIDEO_TITLE]);
     $this->fileBaseName = $seriesTitle . '-' . $seasonNumber . '-' . $videoEpisodeNumber . '-' . $videoTitle;
     // entry cue points
     $c = KalturaCriteria::create(CuePointPeer::OM_CLASS);
     $c->add(CuePointPeer::PARTNER_ID, $distributionJobData->entryDistribution->partnerId);
     $c->add(CuePointPeer::ENTRY_ID, $distributionJobData->entryDistribution->entryId);
     $c->add(CuePointPeer::TYPE, AdCuePointPlugin::getCuePointTypeCoreValue(AdCuePointType::AD));
     $c->addAscendingOrderByColumn(CuePointPeer::START_TIME);
     $cuePointsDb = CuePointPeer::doSelect($c);
     $this->cuePoints = KalturaCuePointArray::fromDbArray($cuePointsDb);
 }
 /**
  * @param int $entryId
  */
 protected function entryDeleted($entryId)
 {
     $c = new Criteria();
     $c->add(CuePointPeer::ENTRY_ID, $entryId);
     CuePointPeer::setUseCriteriaFilter(false);
     $cuePoints = CuePointPeer::doSelect($c);
     $update = new Criteria();
     $update->add(CuePointPeer::STATUS, CuePointStatus::DELETED);
     $con = Propel::getConnection(myDbHelper::DB_HELPER_CONN_MASTER);
     BasePeer::doUpdate($c, $update, $con);
     foreach ($cuePoints as $cuePoint) {
         kEventsManager::raiseEvent(new kObjectDeletedEvent($cuePoint));
     }
 }
예제 #8
0
 /**
  * Download multiple cue points objects as XML definitions
  * 
  * @action serveBulk
  * @param KalturaCuePointFilter $filter
  * @param KalturaFilterPager $pager
  * @return file
  */
 function serveBulkAction(KalturaCuePointFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaCuePointFilter();
     }
     $c = KalturaCriteria::create(CuePointPeer::OM_CLASS);
     if ($this->getCuePointType()) {
         $c->add(CuePointPeer::TYPE, $this->getCuePointType());
     }
     $cuePointFilter = $filter->toObject();
     $cuePointFilter->attachToCriteria($c);
     if ($pager) {
         $pager->attachToCriteria($c);
     }
     $list = CuePointPeer::doSelect($c);
     $xml = kCuePointManager::generateXml($list);
     header("Content-Type: text/xml; charset=UTF-8");
     echo $xml;
     kFile::closeDbConnections();
     exit(0);
 }
예제 #9
0
 /**
  *
  * @param entry $clipEntry new entry to copy and adjust cue points from root entry to
  */
 public static function copyCuePointsToClipEntry(entry $clipEntry)
 {
     $clipAtts = self::getClipAttributesFromEntry($clipEntry);
     if (!is_null($clipAtts)) {
         $sourceEntry = entryPeer::retrieveByPK($clipEntry->getSourceEntryId());
         if (is_null($sourceEntry)) {
             KalturaLog::info("Didn't copy cuePoints for entry [{$clipEntry->getId()}] because source entry [" . $clipEntry->getSourceEntryId() . "] wasn't found");
             return;
         }
         $sourceEntryDuration = $sourceEntry->getLengthInMsecs();
         $clipStartTime = $clipAtts->getOffset();
         if (is_null($clipStartTime)) {
             $clipStartTime = 0;
         }
         $clipDuration = $clipAtts->getDuration();
         if (is_null($clipDuration)) {
             $clipDuration = $sourceEntryDuration;
         }
         $c = new KalturaCriteria();
         $c->add(CuePointPeer::ENTRY_ID, $clipEntry->getSourceEntryId());
         if ($clipDuration < $sourceEntryDuration) {
             $c->addAnd(CuePointPeer::START_TIME, $clipStartTime + $clipDuration, KalturaCriteria::LESS_EQUAL);
         }
         if ($clipStartTime > 0) {
             $c->addAnd(CuePointPeer::START_TIME, $clipStartTime, KalturaCriteria::GREATER_EQUAL);
             $c->addOr(CuePointPeer::START_TIME, 0, KalturaCriteria::EQUAL);
         }
         $c->addAscendingOrderByColumn(CuePointPeer::CREATED_AT);
         $rootEntryCuePointsToCopy = CuePointPeer::doSelect($c);
         if (count($rootEntryCuePointsToCopy) <= self::MAX_CUE_POINTS_TO_COPY_TO_CLIP) {
             foreach ($rootEntryCuePointsToCopy as $cuePoint) {
                 $cuePoint->copyToClipEntry($clipEntry, $clipStartTime, $clipDuration);
             }
         } else {
             KalturaLog::alert("Can't copy cuePoints for entry [{$clipEntry->getId()}] because cuePoints count exceeded max limit of [" . self::MAX_CUE_POINTS_TO_COPY_TO_CLIP . "]");
         }
     }
 }
예제 #10
0
 /**
  * Retrieve multiple objects by entry id.
  *
  * @param      string $entryId the entry id.
  * @param      array $types the cue point types from CuePointType enum
  * @param      PropelPDO $con the connection to use
  * @return     CuePoint
  */
 public static function retrieveByEntryId($entryId, $types = null, PropelPDO $con = null)
 {
     $criteria = KalturaCriteria::create(CuePointPeer::OM_CLASS);
     $criteria->add(CuePointPeer::ENTRY_ID, $entryId);
     $criteria->add(CuePointPeer::STATUS, CuePointStatus::DELETED, Criteria::NOT_EQUAL);
     if (!is_null($types)) {
         $criteria->add(CuePointPeer::TYPE, $types, Criteria::IN);
     }
     return CuePointPeer::doSelect($criteria, $con);
 }
예제 #11
0
파일: QuizPlugin.php 프로젝트: wzur/server
 /**
  * @param $objectIds
  * @param $orderBy
  * @param $questions
  * @param $ans
  * @return array
  */
 protected function getAggregateDataForQuestions($questions, $orderBy)
 {
     $ans = array();
     foreach ($questions as $question) {
         $numOfCorrectAnswers = 0;
         /**
          * @var QuestionCuePoint $question
          */
         $c = new Criteria();
         $c->add(CuePointPeer::ENTRY_ID, $question->getEntryId());
         $c->add(CuePointPeer::TYPE, QuizPlugin::getCoreValue('CuePointType', QuizCuePointType::QUIZ_ANSWER));
         $c->add(CuePointPeer::PARENT_ID, $question->getId());
         $anonKuserIds = $this->getAnonymousKuserIds($question->getPartnerId());
         if (!empty($anonKuserIds)) {
             $c->add(CuePointPeer::KUSER_ID, $anonKuserIds, Criteria::NOT_IN);
         }
         $answers = CuePointPeer::doSelect($c);
         $numOfAnswers = 0;
         foreach ($answers as $answer) {
             /**
              * @var AnswerCuePoint $answer
              */
             $quizUserEntryId = $answer->getQuizUserEntryId();
             if ($this->isQuizUserEntrySubmitted($quizUserEntryId)) {
                 $numOfAnswers++;
                 $optionalAnswers = $question->getOptionalAnswers();
                 $correct = false;
                 foreach ($optionalAnswers as $optionalAnswer) {
                     /**
                      * @var kOptionalAnswer $optionalAnswer
                      */
                     if ($optionalAnswer->getKey() === $answer->getAnswerKey()) {
                         if ($optionalAnswer->getIsCorrect()) {
                             $numOfCorrectAnswers++;
                             break;
                         }
                     }
                 }
             }
         }
         if ($numOfAnswers) {
             $pctg = $numOfCorrectAnswers / $numOfAnswers;
         } else {
             $pctg = 0.0;
         }
         $ans[] = array('question_id' => $question->getId(), 'percentage' => $pctg * 100, 'num_of_correct_answers' => $numOfCorrectAnswers, 'num_of_wrong_answers' => $numOfAnswers - $numOfCorrectAnswers);
     }
     uasort($ans, $this->getSortFunction($orderBy));
     return $ans;
 }
    $c->add(CuePointPeer::UPDATED_AT, $argv[1], Criteria::GREATER_EQUAL);
}
if ($argc > 2 && is_numeric($argv[2])) {
    $c->add(CuePointPeer::PARTNER_ID, $argv[2], Criteria::EQUAL);
}
if ($argc > 3 && is_numeric($argv[3])) {
    $c->add(CuePointPeer::ID, $argv[3], Criteria::GREATER_EQUAL);
}
$c->addAscendingOrderByColumn(CuePointPeer::UPDATED_AT);
$c->addAscendingOrderByColumn(CuePointPeer::ID);
$c->setLimit(10000);
$con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2);
//$sphinxCon = DbManager::getSphinxConnection();
$entries = CuePointPeer::doSelect($c, $con);
$sphinx = new kSphinxSearchManager();
while (count($entries)) {
    foreach ($entries as $entry) {
        /* @var $entry CuePoint */
        KalturaLog::log('cue point id ' . $entry->getId() . ' updated at ' . $entry->getUpdatedAt(null));
        try {
            $ret = $sphinx->saveToSphinx($entry, true);
        } catch (Exception $e) {
            KalturaLog::err($e->getMessage());
            exit - 1;
        }
    }
    $c->setOffset($c->getOffset() + count($entries));
    kMemoryManager::clearMemory();
    $entries = CuePointPeer::doSelect($c, $con);
}
KalturaLog::log('Done. Cureent time: ' . time());
 /**
  * List cue point objects by filter and pager
  * 
  * @action list
  * @param KalturaCuePointFilter $filter
  * @param KalturaFilterPager $pager
  * @return KalturaCuePointListResponse
  */
 function listAction(KalturaCuePointFilter $filter = null, KalturaFilterPager $pager = null)
 {
     if (!$filter) {
         $filter = new KalturaCuePointFilter();
     }
     $c = KalturaCriteria::create(CuePointPeer::OM_CLASS);
     if ($this->getCuePointType()) {
         $c->add(CuePointPeer::TYPE, $this->getCuePointType());
     }
     $cuePointFilter = $filter->toObject();
     $cuePointFilter->attachToCriteria($c);
     if ($pager) {
         $pager->attachToCriteria($c);
     }
     $list = CuePointPeer::doSelect($c);
     $response = new KalturaCuePointListResponse();
     $response->objects = KalturaCuePointArray::fromDbArray($list);
     $response->totalCount = $c->getRecordsCount();
     return $response;
 }
 /**
  * Retrieve a single object by entry id.
  *
  * @param      string $systemName the entry id.
  * @param      int $type the cue point type from CuePointType enum
  * @param      PropelPDO $con the connection to use
  * @return     CuePoint
  */
 public static function retrieveByEntryId($entryId, $type = null, PropelPDO $con = null)
 {
     $criteria = new Criteria();
     $criteria->add(CuePointPeer::ENTRY_ID, $entryId);
     if (!is_null($type)) {
         $criteria->add(CuePointPeer::TYPE, $type);
     }
     return CuePointPeer::doSelect($criteria, $con);
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(CuePointPeer::DATABASE_NAME);
         $criteria->add(CuePointPeer::ID, $pks, Criteria::IN);
         $objs = CuePointPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
예제 #16
0
    }
    $criteria = new Criteria();
    $criteria->add(CuePointPeer::PARTNER_ID, $partnerId);
    $criteria->add(CuePointPeer::STATUS, CuePointStatus::DELETED, Criteria::NOT_EQUAL);
    if ($type) {
        $criteria->add(CuePointPeer::TYPE, $type);
    }
    $criteria->addAscendingOrderByColumn(CuePointPeer::INT_ID);
    $criteria->setLimit(50);
    $partnerCuePoints = 0;
    $cuePoints = CuePointPeer::doSelect($criteria);
    while (count($cuePoints)) {
        foreach ($cuePoints as $cuePoint) {
            /* @var $cuePoint CuePoint */
            $tags = $cuePoint->getTags() ? explode(',', $cuePoint->getTags()) : array();
            array_walk($tags, 'trim');
            if (!in_array($tag, $tags)) {
                $tags[] = $tag;
                $cuePoint->setTags(implode(',', $tags));
                $cuePoint->save();
                kEventsManager::flushEvents();
            }
        }
        kMemoryManager::clearMemory();
        $partnerCuePoints += count($cuePoints);
        $criteria->setOffset($partnerCuePoints);
        $cuePoints = CuePointPeer::doSelect($criteria);
    }
    KalturaLog::debug("Added tag [{$tag}] to {$partnerCuePoints} cue-points for partner {$partnerId}");
}
KalturaLog::debug("Done!!!");