/**
  * @param CaptionAsset $captionAsset
  * @param BatchJob $parentJob
  * @throws kCoreException FILE_NOT_FOUND
  * @return BatchJob
  */
 public function addParseCaptionAssetJob(CaptionAsset $captionAsset, BatchJob $parentJob = null)
 {
     $syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
     $fileSync = kFileSyncUtils::getReadyInternalFileSyncForKey($syncKey);
     if (!$fileSync) {
         if (!PermissionPeer::isValidForPartner(CaptionPermissionName::IMPORT_REMOTE_CAPTION_FOR_INDEXING, $captionAsset->getPartnerId())) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         $fileSync = kFileSyncUtils::getReadyExternalFileSyncForKey($syncKey);
         if (!$fileSync) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         $fullPath = myContentStorage::getFSUploadsPath() . '/' . $captionAsset->getId() . '.tmp';
         if (!kFile::downloadUrlToFile($fileSync->getExternalUrl($captionAsset->getEntryId()), $fullPath)) {
             throw new kCoreException("File sync not found: {$syncKey}", kCoreException::FILE_NOT_FOUND);
         }
         kFileSyncUtils::moveFromFile($fullPath, $syncKey, true, false, true);
     }
     $jobData = new kParseCaptionAssetJobData();
     $jobData->setCaptionAssetId($captionAsset->getId());
     $batchJob = null;
     if ($parentJob) {
         $batchJob = $parentJob->createChild();
     } else {
         $batchJob = new BatchJob();
         $batchJob->setEntryId($captionAsset->getEntryId());
         $batchJob->setPartnerId($captionAsset->getPartnerId());
     }
     return kJobsManager::addJob($batchJob, $jobData, CaptionSearchPlugin::getBatchJobTypeCoreValue(CaptionSearchBatchJobType::PARSE_CAPTION_ASSET));
 }
Exemplo n.º 2
0
 /**
  * Add entry
  *
  * @action add
  * @param KalturaMediaEntry $entry
  * @return KalturaMediaEntry
  */
 function addAction(KalturaMediaEntry $entry)
 {
     if ($entry->conversionQuality && !$entry->conversionProfileId) {
         $entry->conversionProfileId = $entry->conversionQuality;
     }
     $dbEntry = parent::add($entry, $entry->conversionProfileId);
     $entryStatus = entryStatus::NO_CONTENT;
     if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_DRAFT_ENTRY_CONV_PROF_SELECTION, $dbEntry->getPartnerId())) {
         $entryConversionProfileHasFlavors = myPartnerUtils::entryConversionProfileHasFlavors($dbEntry->getId());
         if (!$entryConversionProfileHasFlavors) {
             // If the entry's conversion profile dones't contain any flavors, mark the entry as READY
             $entryStatus = entryStatus::READY;
         }
     }
     $dbEntry->setStatus($entryStatus);
     $dbEntry->save();
     $trackEntry = new TrackEntry();
     $trackEntry->setEntryId($dbEntry->getId());
     $trackEntry->setTrackEventTypeId(TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY);
     $trackEntry->setDescription(__METHOD__ . ":" . __LINE__ . "::ENTRY_MEDIA");
     TrackEntry::addTrackEntry($trackEntry);
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $dbEntry, $dbEntry->getPartnerId(), null, null, null, $dbEntry->getId());
     $entry->fromObject($dbEntry, $this->getResponseProfile());
     return $entry;
 }
Exemplo n.º 3
0
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     if ($this->getPartnerId() > 0 && !PermissionPeer::isValidForPartner(PermissionName::FEATURE_LIVE_CHANNEL, $this->getPartnerId())) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_FORBIDDEN, $this->serviceName . '->' . $this->actionName);
     }
 }
Exemplo n.º 4
0
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     $this->applyPartnerFilterForClass('LiveChannelSegment');
     if (!PermissionPeer::isValidForPartner(PermissionName::FEATURE_LIVE_CHANNEL, $this->getPartnerId())) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_FORBIDDEN, $this->serviceName . '->' . $this->actionName);
     }
 }
Exemplo n.º 5
0
 public function validateForResponseProfile()
 {
     if (kEntitlementUtils::getEntitlementEnforcement()) {
         if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENABLE_RESPONSE_PROFILE_USER_CACHE, kCurrentContext::getCurrentPartnerId())) {
             KalturaResponseProfileCacher::useUserCache();
             return;
         }
         throw new KalturaAPIException(KalturaErrors::CANNOT_LIST_RELATED_ENTITLED_WHEN_ENTITLEMENT_IS_ENABLE, get_class($this));
     }
 }
Exemplo n.º 6
0
 /**
  * @param entry $entry
  * @return bool true if cuepoints should be copied to given entry
  */
 public function hasPermissionToCopyToEntry(entry $entry)
 {
     if (!$entry->getIsTemporary() && PermissionPeer::isValidForPartner(AnnotationCuePointPermissionName::COPY_ANNOTATIONS_TO_CLIP, $entry->getPartnerId())) {
         return true;
     }
     if ($entry->getIsTemporary() && !PermissionPeer::isValidForPartner(AnnotationCuePointPermissionName::DO_NOT_COPY_ANNOTATIONS_TO_TRIMMED_ENTRY, $entry->getPartnerId())) {
         return true;
     }
     return false;
 }
 public function renderEntry($entry)
 {
     if (!$entry instanceof entry) {
         return "";
     }
     $entry_id = $entry->getId();
     $kaltura_elements = "<kaltura:entryId>" . $entry->getId() . "</kaltura:entryId>";
     if (isset(kCurrentContext::$partner_id) && !PermissionPeer::isValidForPartner(PermissionName::FEATURE_HIDE_SENSITIVE_DATA_IN_RSS_FEED, kCurrentContext::$partner_id)) {
         $kaltura_elements .= "<kaltura:views>" . ($entry->getViews() ? $entry->getViews() : "0") . "</kaltura:views>" . "<kaltura:plays>" . ($entry->getPlays() ? $entry->getPlays() : "0") . "</kaltura:plays>" . "<kaltura:userScreenName>" . $entry->getUserScreenName() . "</kaltura:userScreenName>" . "<kaltura:puserId>" . $entry->getPuserId() . "</kaltura:puserId>" . "<kaltura:userLandingPage>" . $entry->getUserLandingPage() . "</kaltura:userLandingPage>";
     } else {
         $kaltura_elements .= "<kaltura:views>0</kaltura:views>" . "<kaltura:plays>0</kaltura:plays>" . "<kaltura:userScreenName></kaltura:userScreenName>" . "<kaltura:puserId></kaltura:puserId>" . "<kaltura:userLandingPage></kaltura:userLandingPage>";
     }
     $kaltura_elements .= "<kaltura:partnerLandingPage>" . $entry->getPartnerLandingPage() . "</kaltura:partnerLandingPage>" . "<kaltura:tags>" . $entry->getTags() . "</kaltura:tags>" . "<kaltura:adminTags>" . $entry->getAdminTags() . "</kaltura:adminTags>" . "<kaltura:votes>" . ($entry->getVotes() ? $entry->getVotes() : "0") . "</kaltura:votes>" . "<kaltura:rank>" . ($entry->getRank() ? $entry->getRank() : "0") . "</kaltura:rank>" . "<kaltura:createdAt>" . $entry->getCreatedAt() . "</kaltura:createdAt>" . "<kaltura:createdAtInt>" . $entry->getCreatedAt(null) . "</kaltura:createdAtInt>" . "<kaltura:sourceLink>" . $entry->getSourceLink() . "</kaltura:sourceLink>" . "<kaltura:credit>" . $entry->getCredit() . "</kaltura:credit>";
     if ($this->type == self::TYPE_TABOOLA) {
         // TODO - use entry->getDisplayScope();
         $taboola_elements = $entry->getDisplayInSearch() >= 2 ? "<tv:label>_KN_</tv:label>" . "<tv:uploader>" . $entry->getPartnerId() . "</tv:uploader>" : '';
     } else {
         $taboola_elements = "";
     }
     // for now the partner_id & entry_id are set in the guid elementy of the item..
     // TODO - move the partner_id to be part of the primary key of the entry so entry will not appear in wrong partners
     $mrss = '<item>' . '<description>Kaltura Item</description>' . '<guid isPermaLink="false">' . $entry->getPartnerId() . "|" . $entry_id . '</guid>' . '<link>' . $entry->getPartnerLandingPage() . '</link>' . '<pubDate>' . $entry->getCreatedAt() . '</pubDate>' . '<media:content ' . 'url="' . $entry->getDataUrl() . '/ext/flv" ' . ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO ? 'type="video/x-flv" ' : '  ') . 'medium="' . $entry->getTypeAsString() . '" ' . 'duration="' . (int) ($entry->getLengthInMsecs() / 1000) . '" ' . 'lang="en"' . '/> ' . '<media:title type="plain">' . kString::xmlEncode($entry->getName()) . "</media:title>" . '<media:description>' . kString::xmlEncode($entry->getDescription()) . '</media:description>' . '<media:keywords>' . kString::xmlEncode($entry->getSearchText()) . '</media:keywords>' . '<media:thumbnail url="' . $entry->getThumbnailUrl() . '/width/640/height/480"/>' . '<media:credit role="kaltura partner">' . $entry->getPartnerId() . '</media:credit>' . $kaltura_elements . $taboola_elements . '</item>';
     return $mrss;
 }
Exemplo n.º 8
0
 public function validateForResponseProfile()
 {
     if (!kCurrentContext::$is_admin_session && !$this->idEqual && !$this->idIn && !$this->systemNameEqual && !$this->systemNameIn && !PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENABLE_RESPONSE_PROFILE_USER_CACHE, kCurrentContext::getCurrentPartnerId())) {
         throw new KalturaAPIException(KalturaCuePointErrors::USER_KS_CANNOT_LIST_RELATED_CUE_POINTS, get_class($this));
     }
 }
Exemplo n.º 9
0
 protected function invalidateCachedRelatedObjects(IRelatedObject $object)
 {
     self::invalidateRelated($object);
     if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_RECALCULATE_RESPONSE_PROFILE_CACHE, $object->getPartnerId())) {
         $this->addRecalculateRelatedObjectsCacheJob($object);
     }
     return true;
 }
Exemplo n.º 10
0
 /**
  * Get the external FileSync object by its key and statuses
  *
  * @param FileSyncKey $key
  * @param int $externalStorageId
  * @param array $statuses an array of required status values
  * @return FileSync
  */
 protected static function getExternalFileSyncForKeyByStatus(FileSyncKey $key, $externalStorageId = null, $statuses = array())
 {
     if (is_null($key->partner_id)) {
         throw new kFileSyncException("partner id not defined for key [{$key}]", kFileSyncException::FILE_SYNC_PARTNER_ID_NOT_DEFINED);
     }
     self::prepareStorageProfilesForSort($key->partner_id);
     $c = new Criteria();
     $c = FileSyncPeer::getCriteriaForFileSyncKey($key);
     if (is_null($externalStorageId)) {
         $c->addAnd(FileSyncPeer::FILE_TYPE, FileSync::FILE_SYNC_FILE_TYPE_URL);
         // any external
         $c->addAnd(FileSyncPeer::DC, self::$storageProfilesOrder, Criteria::IN);
     } else {
         $c->addAnd(FileSyncPeer::DC, $externalStorageId);
     }
     if (!empty($statuses)) {
         $c->addAnd(FileSyncPeer::STATUS, $statuses, Criteria::IN);
     }
     if (!PermissionPeer::isValidForPartner(PermissionName::FEATURE_REMOTE_STORAGE_DELIVERY_PRIORITY, $key->partner_id)) {
         return FileSyncPeer::doSelectOne($c);
     }
     $fileSyncs = FileSyncPeer::doSelect($c);
     if (count($fileSyncs) > 1) {
         uasort($fileSyncs, array('self', 'compareStorageProfiles'));
     }
     return reset($fileSyncs);
 }
Exemplo n.º 11
0
 /**
  * 
  * @param Partner $toPartner
  * @param array $permissionArray
  * 
  * @return bool
  */
 public static function isPartnerPermittedForCopy(Partner $toPartner, array $permissionArray)
 {
     foreach ($permissionArray as $permission) {
         if (!PermissionPeer::isValidForPartner($permission, $toPartner->getId())) {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 12
0
 public static function getPassResetLink($hashKey)
 {
     if (!$hashKey) {
         return null;
     }
     $loginData = self::isHashKeyValid($hashKey);
     if (!$loginData) {
         throw new Exception('Hash key not valid');
     }
     $resetLinksArray = kConf::get('password_reset_links');
     $resetLinkPrefix = $resetLinksArray['default'];
     $partnerId = $loginData->getConfigPartnerId();
     $partner = PartnerPeer::retrieveByPK($partnerId);
     if ($partner) {
         // partner may define a custom reset password url (admin console for example)
         $urlPrefixName = $partner->getPassResetUrlPrefixName();
         if ($urlPrefixName && isset($resetLinksArray[$urlPrefixName])) {
             $resetLinkPrefix = $resetLinksArray[$urlPrefixName];
         }
     }
     $httpsEnforcePermission = PermissionPeer::isValidForPartner(PermissionName::FEATURE_KMC_ENFORCE_HTTPS, $partnerId);
     if (strpos($resetLinkPrefix, infraRequestUtils::PROTOCOL_HTTPS) === false && $httpsEnforcePermission) {
         $resetLinkPrefix = str_replace(infraRequestUtils::PROTOCOL_HTTP, infraRequestUtils::PROTOCOL_HTTPS, $resetLinkPrefix);
     }
     return $resetLinkPrefix . $hashKey;
 }
Exemplo n.º 13
0
 /**
  * Override in order to filter objects returned from doSelect.
  *
  * @param      array $selectResults The array of objects to filter.
  * @param	   Criteria $criteria
  */
 public static function filterSelectResults(&$selectResults, Criteria $criteria)
 {
     if (empty($selectResults)) {
         return;
     }
     $partnerId = kCurrentContext::getCurrentPartnerId();
     $partner = PartnerPeer::retrieveByPK($partnerId);
     if ($partner && $partner->getShouldApplyAccessControlOnEntryMetadata() && !kCurrentContext::$is_admin_session) {
         if (is_null(self::$accessControlScope)) {
             self::$accessControlScope = new accessControlScope();
             self::$accessControlScope->setContexts(array(ContextType::METADATA));
         }
         $selectResults = array_filter($selectResults, array('entryPeer', 'filterByAccessControl'));
         if ($criteria instanceof KalturaCriteria) {
             $criteria->setRecordsCount(count($selectResults));
         }
     }
     $removedRecordsCount = 0;
     if (!kEntitlementUtils::getEntitlementEnforcement() && !is_null(kCurrentContext::$ks) || !self::$filerResults || !kEntitlementUtils::getInitialized()) {
         // if initEntitlement hasn't run - skip filters.
         return parent::filterSelectResults($selectResults, $criteria);
     }
     if (is_null(kCurrentContext::$ks) && count($selectResults)) {
         $entry = $selectResults[0];
         $partner = $entry->getPartner();
         if (!$partner) {
             throw new kCoreException('entry partner not found');
         }
         if (!$partner->getDefaultEntitlementEnforcement() || !PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENTITLEMENT, $partner->getId())) {
             return parent::filterSelectResults($selectResults, $criteria);
         }
     }
     foreach ($selectResults as $key => $entry) {
         if (!kEntitlementUtils::isEntryEntitled($entry)) {
             unset($selectResults[$key]);
             $removedRecordsCount++;
         }
     }
     if ($criteria instanceof KalturaCriteria) {
         $recordsCount = $criteria->getRecordsCount();
         $criteria->setRecordsCount($recordsCount - $removedRecordsCount);
     }
     self::$filerResults = false;
     parent::filterSelectResults($selectResults, $criteria);
 }
Exemplo n.º 14
0
 /**
  * @param FileSync $fileSync
  */
 protected function fileSyncDelete(FileSync $fileSync, BatchJob $raisedJob = null)
 {
     $partnerId = $fileSync->getPartnerId();
     $purgePermission = PermissionPeer::isValidForPartner('PURGE_FILES_ON_DELETE', $partnerId);
     if ($purgePermission) {
         $syncKey = kFileSyncUtils::getKeyForFileSync($fileSync);
         kJobsManager::addDeleteFileJob($raisedJob, null, $partnerId, $syncKey, $fileSync->getFullPath(), $fileSync->getDc());
     }
 }
Exemplo n.º 15
0
 /**
  * Returns the log file for bulk upload job
  * @param BatchJob $batchJob bulk upload batchjob
  */
 public static function writeBulkUploadLogFile($batchJob)
 {
     if ($batchJob->getJobSubType() && $batchJob->getJobSubType() != self::getBulkUploadTypeCoreValue(BulkUploadCsvType::CSV)) {
         return;
     }
     header("Content-Type: text/plain; charset=UTF-8");
     $criteria = new Criteria();
     $criteria->add(BulkUploadResultPeer::BULK_UPLOAD_JOB_ID, $batchJob->getId());
     $criteria->addAscendingOrderByColumn(BulkUploadResultPeer::LINE_INDEX);
     $criteria->setLimit(100);
     $bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
     if (!count($bulkUploadResults)) {
         die("Log file is not ready");
     }
     $STDOUT = fopen('php://output', 'w');
     $data = $batchJob->getData();
     /* @var $data kBulkUploadJobData */
     //Add header row to the output CSV only if partner level permission for it exists
     $partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id;
     if (PermissionPeer::isValidForPartner(self::FEATURE_CSV_HEADER_ROW, $partnerId)) {
         $headerRow = $data->getColumns();
         $headerRow[] = "resultStatus";
         $headerRow[] = "objectId";
         $headerRow[] = "objectStatus";
         $headerRow[] = "errorDescription";
         fputcsv($STDOUT, $headerRow);
     }
     $handledResults = 0;
     while (count($bulkUploadResults)) {
         $handledResults += count($bulkUploadResults);
         foreach ($bulkUploadResults as $bulkUploadResult) {
             /* @var $bulkUploadResult BulkUploadResult */
             $values = str_getcsv($bulkUploadResult->getRowData());
             //		    switch ($bulkUploadResult->getObjectType())
             //		    {
             //		        case BulkUploadObjectType::ENTRY:
             //		            $values = self::writeEntryBulkUploadResults($bulkUploadResult, $data);
             //		            break;
             //		        case BulkUploadObjectType::CATEGORY:
             //		            $values = self::writeCategoryBulkUploadResults($bulkUploadResult, $data);
             //		            break;
             //		        case BulkUploadObjectType::CATEGORY_USER:
             //		            $values = self::writeCategoryUserBulkUploadResults($bulkUploadResult, $data);
             //		            break;
             //		        case BulkUploadObjectType::USER:
             //		            $values = self::writeUserBulkUploadResults($bulkUploadResult, $data);
             //		            break;
             //		        default:
             //
             //		            break;
             //		    }
             $values[] = $bulkUploadResult->getStatus();
             $values[] = $bulkUploadResult->getObjectId();
             $values[] = $bulkUploadResult->getObjectStatus();
             $values[] = preg_replace('/[\\n\\r\\t]/', ' ', $bulkUploadResult->getErrorDescription());
             fputcsv($STDOUT, $values);
         }
         if (count($bulkUploadResults) < $criteria->getLimit()) {
             break;
         }
         kMemoryManager::clearMemory();
         $criteria->setOffset($handledResults);
         $bulkUploadResults = BulkUploadResultPeer::doSelect($criteria);
     }
     fclose($STDOUT);
     kFile::closeDbConnections();
     exit;
 }
 public function execute()
 {
     sfView::SUCCESS;
     /** check parameters and verify user is logged-in **/
     $this->partner_id = $this->getP("pid");
     $this->subp_id = $this->getP("subpid", (int) $this->partner_id * 100);
     $this->uid = $this->getP("uid");
     $this->ks = $this->getP("kmcks");
     if (!$this->ks) {
         // if kmcks from cookie doesn't exist, try ks from REQUEST
         $this->ks = $this->getP('ks');
     }
     $this->screen_name = $this->getP("screen_name");
     $this->email = $this->getP("email");
     /** if no KS found, redirect to login page **/
     if (!$this->ks) {
         $this->redirect("kmc/kmc");
         die;
     }
     $ksObj = kSessionUtils::crackKs($this->ks);
     /** END - check parameters and verify user is logged-in **/
     /** Get array of allowed partners for the current user **/
     $this->allowedPartners = array();
     $currentUser = kuserPeer::getKuserByPartnerAndUid($this->partner_id, $ksObj->user, true);
     if ($currentUser) {
         $partners = myPartnerUtils::getPartnersArray($currentUser->getAllowedPartnerIds());
         foreach ($partners as $partner) {
             $this->allowedPartners[] = array('id' => $partner->getId(), 'name' => $partner->getName());
         }
         $this->full_name = $currentUser->getFullName();
     }
     /** load partner from DB, and set templatePartnerId **/
     $this->partner = $partner = null;
     $this->templatePartnerId = self::SYSTEM_DEFAULT_PARTNER;
     $this->ignoreSeoLinks = false;
     $this->ignoreEntrySeoLinks = false;
     $this->useEmbedCodeProtocolHttps = false;
     $this->v2Flavors = false;
     if ($this->partner_id !== NULL) {
         $this->partner = $partner = PartnerPeer::retrieveByPK($this->partner_id);
         kmcUtils::redirectPartnerToCorrectKmc($partner, $this->ks, $this->uid, $this->screen_name, $this->email, self::CURRENT_KMC_VERSION);
         $this->templatePartnerId = $this->partner ? $this->partner->getTemplatePartnerId() : self::SYSTEM_DEFAULT_PARTNER;
         $this->ignoreSeoLinks = $this->partner->getIgnoreSeoLinks();
         $this->ignoreEntrySeoLinks = PermissionPeer::isValidForPartner(PermissionName::FEATURE_IGNORE_ENTRY_SEO_LINKS, $this->partner_id);
         $this->useEmbedCodeProtocolHttps = PermissionPeer::isValidForPartner(PermissionName::FEATURE_EMBED_CODE_DEFAULT_PROTOCOL_HTTPS, $this->partner_id);
         $this->v2Flavors = PermissionPeer::isValidForPartner(PermissionName::FEATURE_V2_FLAVORS, $this->partner_id);
     }
     /** END - load partner from DB, and set templatePartnerId **/
     /** set default flags **/
     $this->payingPartner = 'false';
     $this->kdp508_players = array();
     $this->first_login = false;
     /** END - set default flags **/
     /** set values for template **/
     $this->service_url = myPartnerUtils::getHost($this->partner_id);
     $this->host = $this->stripProtocol($this->service_url);
     $this->embed_host = $this->host;
     if (kConf::hasParam('cdn_api_host') && kConf::hasParam('www_host') && $this->host == kConf::get('cdn_api_host')) {
         $this->host = kConf::get('www_host');
     }
     $this->cdn_url = myPartnerUtils::getCdnHost($this->partner_id);
     $this->cdn_host = $this->stripProtocol($this->cdn_url);
     $this->rtmp_host = myPartnerUtils::getRtmpUrl($this->partner_id);
     $this->flash_dir = $this->cdn_url . myContentStorage::getFSFlashRootPath();
     // Decide if to hide akamai delivery type
     $this->hideAkamaiHDNetwork = $partner->getDisableAkamaiHDNetwork();
     /** set payingPartner flag **/
     if ($partner && $partner->getPartnerPackage() != PartnerPackages::PARTNER_PACKAGE_FREE) {
         $this->payingPartner = 'true';
     }
     /** END - set payingPartner flag **/
     /** get partner languae **/
     $this->language = null;
     if ($partner->getKMCLanguage()) {
         $this->language = $partner->getKMCLanguage();
     }
     /** END - get partner languae **/
     /** set first_login flag **/
     $this->first_login = $partner->getIsFirstLogin();
     if ($this->first_login === true) {
         $partner->setIsFirstLogin(false);
         $partner->save();
     }
     /** END - set first_login flag **/
     /** get logout url **/
     $this->logoutUrl = null;
     if ($partner->getLogoutUrl()) {
         $this->logoutUrl = $partner->getLogoutUrl();
     }
     /** END - get logout url**/
     /** partner-specific: change KDP version for partners working with auto-moderaion **/
     // set content kdp version according to partner id
     $moderated_partners = array(31079, 28575, 32774);
     $this->content_kdp_version = 'v2.7.0';
     if (in_array($this->partner_id, $moderated_partners)) {
         $this->content_kdp_version = 'v2.1.2.29057';
     }
     /** END - partner-specific: change KDP version for partners working with auto-moderaion **/
     $this->kmc_swf_version = kConf::get('kmc_version');
     /** uiconf listing work **/
     /** fill $this->confs with all uiconf objects for all modules **/
     $kmcGeneralUiConf = kmcUtils::getAllKMCUiconfs('kmc', $this->kmc_swf_version, self::SYSTEM_DEFAULT_PARTNER);
     $kmcGeneralTemplateUiConf = kmcUtils::getAllKMCUiconfs('kmc', $this->kmc_swf_version, $this->templatePartnerId);
     /** for each module, create separated lists of its uiconf, for each need **/
     /** kmc general uiconfs **/
     $this->kmc_general = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_kmcgeneral", false, $kmcGeneralUiConf);
     $this->kmc_permissions = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_kmcpermissions", false, $kmcGeneralUiConf);
     /** P&E players: **/
     //$this->content_uiconfs_previewembed = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_previewembed", true, $kmcGeneralUiConf);
     //$this->content_uiconfs_previewembed_list = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_previewembed_list", true, $kmcGeneralUiConf);
     $this->content_uiconfs_flavorpreview = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_flavorpreview", false, $kmcGeneralUiConf);
     /* KCW uiconfs */
     $this->content_uiconfs_upload_webcam = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_uploadWebCam", false, $kmcGeneralUiConf);
     $this->content_uiconfs_upload_import = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_uploadImport", false, $kmcGeneralUiConf);
     $this->content_uiconds_clipapp_kdp = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_kdpClipApp", false, $kmcGeneralUiConf);
     $this->content_uiconds_clipapp_kclip = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_kClipClipApp", false, $kmcGeneralUiConf);
     /** content KCW,KSE,KAE **/
     //$this->content_uiconfs_upload = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_upload", false, $kmcGeneralUiConf);
     //$this->simple_editor = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_simpleedit", false, $kmcGeneralUiConf);
     //$this->advanced_editor = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_advanceedit", false, $kmcGeneralUiConf);
     /** END - uiconf listing work **/
     /** get templateXmlUrl for whitelabeled partners **/
     //$this->appstudio_templatesXmlUrl = $this->getAppStudioTemplatePath();
 }
Exemplo n.º 17
0
 public function execute()
 {
     //entitlement should be disabled to serveFlavor action as we do not get ks on this action.
     KalturaCriterion::disableTag(KalturaCriterion::TAG_ENTITLEMENT_CATEGORY);
     requestUtils::handleConditionalGet();
     $flavorId = $this->getRequestParameter("flavorId");
     $shouldProxy = $this->getRequestParameter("forceproxy", false);
     $fileName = $this->getRequestParameter("fileName");
     $fileParam = $this->getRequestParameter("file");
     $fileParam = basename($fileParam);
     $pathOnly = $this->getRequestParameter("pathOnly", false);
     $referrer = base64_decode($this->getRequestParameter("referrer"));
     if (!is_string($referrer)) {
         // base64_decode can return binary data
         $referrer = '';
     }
     $flavorAsset = assetPeer::retrieveById($flavorId);
     if (is_null($flavorAsset)) {
         KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
     }
     $entryId = $this->getRequestParameter("entryId");
     if (!is_null($entryId) && $flavorAsset->getEntryId() != $entryId) {
         KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
     }
     if ($fileName) {
         header("Content-Disposition: attachment; filename=\"{$fileName}\"");
         header("Content-Type: application/force-download");
         header("Content-Description: File Transfer");
     }
     $clipTo = null;
     $entry = $flavorAsset->getentry();
     if (!$entry) {
         KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
     }
     KalturaMonitorClient::initApiMonitor(false, 'extwidget.serveFlavor', $flavorAsset->getPartnerId());
     myPartnerUtils::enforceDelivery($entry, $flavorAsset);
     $version = $this->getRequestParameter("v");
     if (!$version) {
         $version = $flavorAsset->getVersion();
     }
     $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET, $version);
     if ($pathOnly && kIpAddressUtils::isInternalIp($_SERVER['REMOTE_ADDR'])) {
         $path = null;
         list($file_sync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, false, false);
         if ($file_sync) {
             $parent_file_sync = kFileSyncUtils::resolve($file_sync);
             $path = $parent_file_sync->getFullPath();
             if ($fileParam && is_dir($path)) {
                 $path .= "/{$fileParam}";
             }
         }
         $renderer = new kRendererString('{"sequences":[{"clips":[{"type":"source","path":"' . $path . '"}]}]}', 'application/json');
         if ($path) {
             $this->storeCache($renderer, $flavorAsset->getPartnerId());
         }
         $renderer->output();
         KExternalErrors::dieGracefully();
     }
     if (kConf::hasParam('serve_flavor_allowed_partners') && !in_array($flavorAsset->getPartnerId(), kConf::get('serve_flavor_allowed_partners'))) {
         KExternalErrors::dieError(KExternalErrors::ACTION_BLOCKED);
     }
     if (!kFileSyncUtils::file_exists($syncKey, false)) {
         list($fileSync, $local) = kFileSyncUtils::getReadyFileSyncForKey($syncKey, true, false);
         if (is_null($fileSync)) {
             KalturaLog::log("Error - no FileSync for flavor [" . $flavorAsset->getId() . "]");
             KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
         }
         // always dump remote urls so they will be cached by the cdn transparently
         $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($fileSync);
         kFileUtils::dumpUrl($remoteUrl);
     }
     $path = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
     $isFlv = false;
     if (!$shouldProxy) {
         $flvWrapper = new myFlvHandler($path);
         $isFlv = $flvWrapper->isFlv();
     }
     $clipFrom = $this->getRequestParameter("clipFrom", 0);
     // milliseconds
     if (is_null($clipTo)) {
         $clipTo = $this->getRequestParameter("clipTo", self::NO_CLIP_TO);
     }
     // milliseconds
     if ($clipTo == 0) {
         $clipTo = self::NO_CLIP_TO;
     }
     if (!is_numeric($clipTo) || $clipTo < 0) {
         KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'clipTo must be a positive number');
     }
     $seekFrom = $this->getRequestParameter("seekFrom", -1);
     if ($seekFrom <= 0) {
         $seekFrom = -1;
     }
     $seekFromBytes = $this->getRequestParameter("seekFromBytes", -1);
     if ($seekFromBytes <= 0) {
         $seekFromBytes = -1;
     }
     if ($fileParam && is_dir($path)) {
         $path .= "/{$fileParam}";
         kFileUtils::dumpFile($path, null, null);
         KExternalErrors::dieGracefully();
     } else {
         if (!$isFlv || $clipTo == self::NO_CLIP_TO && $seekFrom < 0 && $seekFromBytes < 0) {
             $limit_file_size = 0;
             if ($clipTo != self::NO_CLIP_TO) {
                 if (strtolower($flavorAsset->getFileExt()) == 'mp4' && PermissionPeer::isValidForPartner(PermissionName::FEATURE_ACCURATE_SERVE_CLIPPING, $flavorAsset->getPartnerId())) {
                     $contentPath = myContentStorage::getFSContentRootPath();
                     $tempClipName = $version . '_' . $clipTo . '.mp4';
                     $tempClipPath = $contentPath . myContentStorage::getGeneralEntityPath("entry/tempclip", $flavorAsset->getIntId(), $flavorAsset->getId(), $tempClipName);
                     if (!file_exists($tempClipPath)) {
                         kFile::fullMkdir($tempClipPath);
                         $clipToSec = round($clipTo / 1000, 3);
                         $cmdLine = kConf::get("bin_path_ffmpeg") . " -i {$path} -vcodec copy -acodec copy -f mp4 -t {$clipToSec} -y {$tempClipPath} 2>&1";
                         KalturaLog::log("Executing {$cmdLine}");
                         $output = array();
                         $return_value = "";
                         exec($cmdLine, $output, $return_value);
                         KalturaLog::log("ffmpeg returned {$return_value}, output:" . implode("\n", $output));
                     }
                     if (file_exists($tempClipPath)) {
                         KalturaLog::log("Dumping {$tempClipPath}");
                         kFileUtils::dumpFile($tempClipPath);
                     } else {
                         KalturaLog::err('Failed to clip the file using ffmpeg, falling back to rough clipping');
                     }
                 }
                 $mediaInfo = mediaInfoPeer::retrieveByFlavorAssetId($flavorAsset->getId());
                 if ($mediaInfo && ($mediaInfo->getVideoDuration() || $mediaInfo->getAudioDuration() || $mediaInfo->getContainerDuration())) {
                     $duration = $mediaInfo->getVideoDuration() ? $mediaInfo->getVideoDuration() : ($mediaInfo->getAudioDuration() ? $mediaInfo->getAudioDuration() : $mediaInfo->getContainerDuration());
                     $limit_file_size = floor(@kFile::fileSize($path) * ($clipTo / $duration) * 1.2);
                 }
             }
             $renderer = kFileUtils::getDumpFileRenderer($path, null, null, $limit_file_size);
             if (!$fileName) {
                 $this->storeCache($renderer, $flavorAsset->getPartnerId());
             }
             $renderer->output();
             KExternalErrors::dieGracefully();
         }
     }
     $audioOnly = $this->getRequestParameter("audioOnly");
     // milliseconds
     if ($audioOnly === '0') {
         // audioOnly was explicitly set to 0 - don't attempt to make further automatic investigations
     } elseif ($flvWrapper->getFirstVideoTimestamp() < 0) {
         $audioOnly = true;
     }
     $bytes = 0;
     if ($seekFrom !== -1 && $seekFrom !== 0) {
         list($bytes, $duration, $firstTagByte, $toByte) = $flvWrapper->clip(0, -1, $audioOnly);
         list($bytes, $duration, $fromByte, $toByte, $seekFromTimestamp) = $flvWrapper->clip($seekFrom, -1, $audioOnly);
         $seekFromBytes = myFlvHandler::FLV_HEADER_SIZE + $flvWrapper->getMetadataSize($audioOnly) + $fromByte - $firstTagByte;
     } else {
         list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
     }
     $metadataSize = $flvWrapper->getMetadataSize($audioOnly);
     $dataOffset = $metadataSize + myFlvHandler::getHeaderSize();
     $totalLength = $dataOffset + $bytes;
     list($bytes, $duration, $fromByte, $toByte, $fromTs, $cuepointPos) = myFlvStaticHandler::clip($path, $clipFrom, $clipTo, $audioOnly);
     list($rangeFrom, $rangeTo, $rangeLength) = requestUtils::handleRangeRequest($totalLength);
     if ($totalLength < 1000) {
         // (actually $total_length is probably 13 or 143 - header + empty metadata tag) probably a bad flv maybe only the header - dont cache
         requestUtils::sendCdnHeaders("flv", $rangeLength, 0);
     } else {
         requestUtils::sendCdnHeaders("flv", $rangeLength);
     }
     // dont inject cuepoint into the stream
     $cuepointTime = 0;
     $cuepointPos = 0;
     try {
         Propel::close();
     } catch (Exception $e) {
         $this->logMessage("serveFlavor: error closing db {$e}");
     }
     header("Content-Type: video/x-flv");
     $flvWrapper->dump(self::CHUNK_SIZE, $fromByte, $toByte, $audioOnly, $seekFromBytes, $rangeFrom, $rangeTo, $cuepointTime, $cuepointPos);
     KExternalErrors::dieGracefully();
 }
Exemplo n.º 18
0
 public function execute()
 {
     KExternalErrors::setResponseErrorCode(KExternalErrors::HTTP_STATUS_NOT_FOUND);
     $this->deliveryAttributes = new DeliveryProfileDynamicAttributes();
     // Parse input parameters
     $this->deliveryAttributes->setSeekFromTime($this->getRequestParameter("seekFrom", -1));
     if ($this->deliveryAttributes->getSeekFromTime() <= 0) {
         $this->deliveryAttributes->setSeekFromTime(-1);
     }
     $this->deliveryAttributes->setClipTo($this->getRequestParameter("clipTo", 0));
     $this->deliveryAttributes->setPlaybackRate($this->getRequestParameter("playbackRate", 0));
     $deliveryCode = $this->getRequestParameter("deliveryCode", null);
     $playbackContext = $this->getRequestParameter("playbackContext", null);
     $this->deliveryAttributes->setMediaProtocol($this->getRequestParameter("protocol", null));
     if (!$this->deliveryAttributes->getMediaProtocol() || $this->deliveryAttributes->getMediaProtocol() === "null") {
         $this->deliveryAttributes->setMediaProtocol(PlaybackProtocol::HTTP);
     }
     $this->deliveryAttributes->setFormat($this->getRequestParameter("format"));
     if (!$this->deliveryAttributes->getFormat()) {
         $this->deliveryAttributes->setFormat(PlaybackProtocol::HTTP);
     }
     if ($this->deliveryAttributes->getFormat() == self::HDNETWORKSMIL) {
         $this->deliveryAttributes->setMediaProtocol(PlaybackProtocol::HTTP);
     }
     // Akamai HD doesn't support any other protocol
     if ($this->deliveryAttributes->getFormat() == PlaybackProtocol::AKAMAI_HDS) {
         if (strpos($this->deliveryAttributes->getMediaProtocol(), "http") !== 0) {
             $this->deliveryAttributes->setMediaProtocol(PlaybackProtocol::HTTP);
         }
     }
     $tags = $this->getRequestParameter("tags", null);
     if (!$tags) {
         $this->deliveryAttributes->setTags(self::getDefaultTagsByFormat($this->deliveryAttributes->getFormat()));
     } else {
         $tagsArray = explode(',', $tags);
         $tags = array();
         foreach ($tagsArray as $tag) {
             $tags[] = array(trim($tag));
         }
         $this->deliveryAttributes->setTags($tags);
     }
     $this->deliveryAttributes->setpreferredBitrate($this->getRequestParameter("preferredBitrate", null));
     $this->maxBitrate = $this->getRequestParameter("maxBitrate", null);
     if ($this->maxBitrate && (!is_numeric($this->maxBitrate) || $this->maxBitrate <= 0)) {
         KExternalErrors::dieError(KExternalErrors::INVALID_MAX_BITRATE);
     }
     $this->deliveryAttributes->setStorageId($this->getRequestParameter("storageId", null));
     $this->cdnHost = $this->getRequestParameter("cdnHost", null);
     $this->deliveryAttributes->setResponseFormat($this->getRequestParameter("responseFormat", null));
     // Initialize
     $this->initEntry();
     $this->deliveryAttributes->setEntryId($this->entryId);
     $this->deliveryAttributes->setUsePlayServer((bool) $this->getRequestParameter("usePlayServer") && PermissionPeer::isValidForPartner(PermissionName::FEATURE_PLAY_SERVER, $this->entry->getPartnerId()));
     if ($this->deliveryAttributes->getUsePlayServer()) {
         $this->deliveryAttributes->setPlayerConfig($this->getRequestParameter("playerConfig"));
         //In case request needs to be redirected to play-server we need to add the ui conf id to the manifest url as well
         $this->deliveryAttributes->setUiConfId($this->getRequestParameter("uiConfId"));
     }
     $this->secureEntryHelper->updateDeliveryAttributes($this->deliveryAttributes);
     $this->enforceEncryption();
     $renderer = null;
     switch ($this->entry->getType()) {
         case entryType::MEDIA_CLIP:
             // VOD
             $renderer = $this->serveVodEntry();
             break;
         case entryType::LIVE_STREAM:
         case entryType::LIVE_CHANNEL:
             // Live stream
             $renderer = $this->serveLiveEntry();
             break;
         default:
             KExternalErrors::dieError(KExternalErrors::INVALID_ENTRY_TYPE);
     }
     if (!$renderer) {
         KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'This format is unsupported');
     }
     $renderer->contributors = array();
     $config = new kManifestContributorConfig();
     $config->format = $this->deliveryAttributes->getFormat();
     $config->deliveryCode = $deliveryCode;
     $config->storageId = $this->deliveryAttributes->getStorageId();
     $config->entryId = $this->entryId;
     $contributors = KalturaPluginManager::getPluginInstances('IKalturaPlayManifestContributor');
     foreach ($contributors as $contributor) {
         /* @var $contributor IKalturaPlayManifestContributor */
         $renderer->contributors = array_merge($renderer->contributors, $contributor->getManifestEditors($config));
     }
     $renderer->entryId = $this->entryId;
     $renderer->duration = $this->duration;
     if ($this->deliveryProfile) {
         $renderer->tokenizer = $this->deliveryProfile->getTokenizer();
     }
     $renderer->defaultDeliveryCode = $this->entry->getPartner()->getDefaultDeliveryCode();
     $renderer->lastModified = time();
     // Handle caching
     $canCacheAccessControl = false;
     if (kConf::hasParam("force_caching_headers") && in_array($this->entry->getPartnerId(), kConf::get("force_caching_headers"))) {
         $renderer->cachingHeadersAge = 60;
         $renderer->forceCachingHeaders = true;
     }
     if (!$this->secureEntryHelper) {
         $canCacheAccessControl = true;
         // TODO: reconsider this if/when expired ktokens will be used
     } else {
         if (!$this->secureEntryHelper->shouldDisableCache() && !$this->secureEntryHelper->isKsAdmin() && ($this->secureEntryHelper->isKsWidget() || !$this->secureEntryHelper->hasRules())) {
             $canCacheAccessControl = true;
         }
     }
     if (!$renderer->tokenizer && $canCacheAccessControl) {
         // Note: kApiCache::hasExtraFields is checked in kManifestRenderers
         $renderer->cachingHeadersAge = 60;
     }
     if (!$this->secureEntryHelper || !$this->secureEntryHelper->shouldDisableCache()) {
         $cache = kPlayManifestCacher::getInstance();
         $cache->storeRendererToCache($renderer);
     }
     // Output the response
     KExternalErrors::terminateDispatch();
     $renderer->output($deliveryCode, $playbackContext);
 }
Exemplo n.º 19
0
 /**
  * Validate if the entry should be exported to the remote storage according to the defined export rules
  * 
  * @param kStorageProfileScope $scope
  */
 public function fulfillsRules(kStorageProfileScope $scope)
 {
     if (!PermissionPeer::isValidForPartner(PermissionName::FEATURE_REMOTE_STORAGE_RULE, $this->getPartnerId())) {
         return true;
     }
     if (!is_array($this->getRules()) || !count($this->getRules())) {
         return true;
     }
     $context = null;
     if (!array_key_exists($this->getId(), kStorageExporter::$entryContextDataResult)) {
         kStorageExporter::$entryContextDataResult[$this->getId()] = array();
     }
     if (array_key_exists($scope->getEntryId(), kStorageExporter::$entryContextDataResult[$this->getId()])) {
         KalturaLog::debug("Found rule->applyContext result in cache");
         $context = kStorageExporter::$entryContextDataResult[$this->getId()][$scope->getEntryId()];
     } else {
         KalturaLog::debug("Validating rules");
         $context = new kContextDataResult();
         foreach ($this->getRules() as $rule) {
             /* @var $rule kRule */
             $rule->setScope($scope);
             $fulfilled = $rule->applyContext($context);
             if ($fulfilled && $rule->getStopProcessing()) {
                 break;
             }
         }
         kStorageExporter::$entryContextDataResult[$this->getId()][$scope->getEntryId()] = $context;
     }
     foreach ($context->getActions() as $action) {
         /* @var $action kRuleAction */
         if ($action->getType() == RuleActionType::ADD_TO_STORAGE) {
             return true;
         }
     }
     return false;
 }
 /**
  * This action delivers entry-related data, based on the user's context: access control, restriction, playback format and storage information.
  * @action getContextData
  * @param string $entryId
  * @param KalturaEntryContextDataParams $contextDataParams
  * @return KalturaEntryContextDataResult
  */
 public function getContextData($entryId, KalturaEntryContextDataParams $contextDataParams)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     $ks = $this->getKs();
     $isAdmin = false;
     if ($ks) {
         $isAdmin = $ks->isAdmin();
     }
     $accessControl = $dbEntry->getAccessControl();
     /* @var $accessControl accessControl */
     $result = new KalturaEntryContextDataResult();
     $result->isAdmin = $isAdmin;
     $result->isScheduledNow = $dbEntry->isScheduledNow($contextDataParams->time);
     if ($dbEntry->getStartDate() && abs($dbEntry->getStartDate(null) - time()) <= 86400 || $dbEntry->getEndDate() && abs($dbEntry->getEndDate(null) - time()) <= 86400) {
         KalturaResponseCacher::setConditionalCacheExpiry(600);
     }
     if ($accessControl && $accessControl->hasRules()) {
         $disableCache = true;
         if (kConf::hasMap("optimized_playback")) {
             $partnerId = $accessControl->getPartnerId();
             $optimizedPlayback = kConf::getMap("optimized_playback");
             if (array_key_exists($partnerId, $optimizedPlayback)) {
                 $params = $optimizedPlayback[$partnerId];
                 if (array_key_exists('cache_kdp_acccess_control', $params) && $params['cache_kdp_acccess_control']) {
                     $disableCache = false;
                 }
             }
         }
         $accessControlScope = $accessControl->getScope();
         $contextDataParams->toObject($accessControlScope);
         $accessControlScope->setEntryId($entryId);
         $result->isAdmin = $accessControlScope->getKs() && $accessControlScope->getKs()->isAdmin();
         $dbResult = new kEntryContextDataResult();
         if ($accessControl->applyContext($dbResult) && $disableCache) {
             KalturaResponseCacher::disableCache();
         }
         $result->fromObject($dbResult);
     }
     $partner = PartnerPeer::retrieveByPK($dbEntry->getPartnerId());
     if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_REMOTE_STORAGE_DELIVERY_PRIORITY, $dbEntry->getPartnerId()) && $partner->getStorageServePriority() != StorageProfile::STORAGE_SERVE_PRIORITY_KALTURA_ONLY) {
         if (is_null($contextDataParams->flavorAssetId)) {
             if ($contextDataParams->flavorTags) {
                 $assets = assetPeer::retrieveReadyByEntryIdAndTag($entryId, $contextDataParams->flavorTags);
                 $asset = reset($assets);
             } else {
                 $asset = assetPeer::retrieveBestPlayByEntryId($entryId);
             }
             if (!$asset) {
                 throw new KalturaAPIException(KalturaErrors::NO_FLAVORS_FOUND, $entryId);
             }
         } else {
             $asset = assetPeer::retrieveByPK($contextDataParams->flavorAssetId);
             if (!$asset) {
                 throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $contextDataParams->flavorAssetId);
             }
         }
         if (!$asset) {
             throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $entryId);
         }
         $assetSyncKey = $asset->getSyncKey(asset::FILE_SYNC_ASSET_SUB_TYPE_ASSET);
         $fileSyncs = kFileSyncUtils::getAllReadyExternalFileSyncsForKey($assetSyncKey);
         $storageProfilesXML = new SimpleXMLElement("<StorageProfiles/>");
         foreach ($fileSyncs as $fileSync) {
             $storageProfileId = $fileSync->getDc();
             $storageProfile = StorageProfilePeer::retrieveByPK($storageProfileId);
             if (!$storageProfile->getDeliveryRmpBaseUrl() && (!$contextDataParams->streamerType || $contextDataParams->streamerType == StorageProfile::PLAY_FORMAT_AUTO)) {
                 $contextDataParams->streamerType = StorageProfile::PLAY_FORMAT_HTTP;
                 $contextDataParams->mediaProtocol = StorageProfile::PLAY_FORMAT_HTTP;
             }
             $storageProfileXML = $storageProfilesXML->addChild("StorageProfile");
             $storageProfileXML->addAttribute("storageProfileId", $storageProfileId);
             $storageProfileXML->addChild("Name", $storageProfile->getName());
             $storageProfileXML->addChild("SystemName", $storageProfile->getSystemName());
         }
         $result->storageProfilesXML = $storageProfilesXML->saveXML();
     }
     if ($contextDataParams->streamerType && $contextDataParams->streamerType != StorageProfile::PLAY_FORMAT_AUTO) {
         $result->streamerType = $contextDataParams->streamerType;
         $result->mediaProtocol = $contextDataParams->mediaProtocol ? $contextDataParams->mediaProtocol : $contextDataParams->streamerType;
     } else {
         $result->streamerType = $this->getPartner()->getStreamerType();
         if (!$result->streamerType) {
             $result->streamerType = StorageProfile::PLAY_FORMAT_HTTP;
         }
         $result->mediaProtocol = $this->getPartner()->getMediaProtocol();
         if (!$result->mediaProtocol) {
             $result->mediaProtocol = StorageProfile::PLAY_FORMAT_HTTP;
         }
     }
     return $result;
 }
Exemplo n.º 21
0
 public function execute()
 {
     // Disable layout
     $this->setLayout(false);
     $this->success = false;
     $this->type = $this->getRequestParameter('type');
     if (!$this->type) {
         KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'type');
     }
     $validTypes = array('name', 'email', 'password');
     if (!in_array($this->type, $validTypes)) {
         KExternalErrors::dieError(KExternalErrors::INVALID_SETTING_TYPE);
     }
     $ks = $this->getP("kmcks");
     if (!$ks) {
         KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, 'ks');
     }
     // Get partner & user info from KS
     $ksObj = kSessionUtils::crackKs($ks);
     $partnerId = $ksObj->partner_id;
     $userId = $ksObj->user;
     $partner = PartnerPeer::retrieveByPK($partnerId);
     if (!$partner) {
         KExternalErrors::dieError(KExternalErrors::PARTNER_NOT_FOUND);
     }
     if (!$partner->validateApiAccessControl()) {
         KExternalErrors::dieError(KExternalErrors::SERVICE_ACCESS_CONTROL_RESTRICTED);
     }
     $this->forceKMCHttps = PermissionPeer::isValidForPartner(PermissionName::FEATURE_KMC_ENFORCE_HTTPS, $partnerId);
     if ($this->forceKMCHttps) {
         // Prevent the page fron being embeded in an iframe
         header('X-Frame-Options: SAMEORIGIN');
     }
     if ($this->forceKMCHttps && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
         die;
     }
     // Load the current user
     $dbUser = kuserPeer::getKuserByPartnerAndUid($partnerId, $userId);
     if (!$dbUser) {
         KExternalErrors::dieError('INVALID_USER_ID', $userId);
     }
     $this->email = $dbUser->getEmail();
     $this->fname = $dbUser->getFirstName();
     $this->lname = $dbUser->getLastName();
     $this->parent_url = $this->clean($_GET['parent']);
     // Set page title
     switch ($this->type) {
         case 'password':
             $this->pageTitle = 'Change Password';
             break;
         case 'email':
             $this->pageTitle = 'Change Email Address';
             break;
         case 'name':
             $this->pageTitle = 'Change Username';
             break;
     }
     // select which action to do
     if (isset($_POST['do'])) {
         switch ($_POST['do']) {
             case "password":
                 $this->changePassword();
                 break;
             case "email":
                 $this->changeEmail();
                 break;
             case "name":
                 $this->changeName();
                 break;
         }
     }
     sfView::SUCCESS;
 }
Exemplo n.º 22
0
 /**
  * Authenticate live-stream entry against stream token and partner limitations
  * 
  * @action authenticate
  * @param string $entryId Live stream entry id
  * @param string $token Live stream broadcasting token
  * @return KalturaLiveStreamEntry The authenticated live stream entry
  * 
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  * @throws KalturaErrors::LIVE_STREAM_INVALID_TOKEN
  */
 function authenticateAction($entryId, $token)
 {
     $dbEntry = entryPeer::retrieveByPK($entryId);
     if (!$dbEntry || $dbEntry->getType() != entryType::LIVE_STREAM) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     /* @var $dbEntry LiveStreamEntry */
     if ($dbEntry->getStreamPassword() != $token) {
         throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_INVALID_TOKEN, $entryId);
     }
     $mediaServer = $dbEntry->getMediaServer(true);
     if ($mediaServer) {
         $url = null;
         $protocol = null;
         foreach (array(KalturaPlaybackProtocol::HLS, KalturaPlaybackProtocol::APPLE_HTTP) as $hlsProtocol) {
             $config = $dbEntry->getLiveStreamConfigurationByProtocol($hlsProtocol, requestUtils::PROTOCOL_HTTP, null, true);
             if ($config) {
                 $url = $config->getUrl();
                 $protocol = $hlsProtocol;
                 break;
             }
         }
         if ($url) {
             KalturaLog::info('Determining status of live stream URL [' . $url . ']');
             $dpda = new DeliveryProfileDynamicAttributes();
             $dpda->setEntryId($entryId);
             $dpda->setFormat($protocol);
             $deliveryProfile = DeliveryProfilePeer::getLiveDeliveryProfileByHostName(parse_url($url, PHP_URL_HOST), $dpda);
             if ($deliveryProfile && $deliveryProfile->isLive($url)) {
                 throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_ALREADY_BROADCASTING, $entryId, $mediaServer->getHostname());
             }
         }
     }
     // fetch current stream live params
     $liveParamsIds = flavorParamsConversionProfilePeer::getFlavorIdsByProfileId($dbEntry->getConversionProfileId());
     $usedLiveParamsIds = array();
     foreach ($liveParamsIds as $liveParamsId) {
         $usedLiveParamsIds[$liveParamsId] = array($entryId);
     }
     // fetch all live entries that currently are live
     $baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS);
     $filter = new entryFilter();
     $filter->setIsLive(true);
     $filter->setIdNotIn(array($entryId));
     $filter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE);
     $filter->attachToCriteria($baseCriteria);
     $entries = entryPeer::doSelect($baseCriteria);
     $maxInputStreams = $this->getPartner()->getMaxLiveStreamInputs();
     if (!$maxInputStreams) {
         $maxInputStreams = kConf::get('partner_max_live_stream_inputs', 'local', 10);
     }
     KalturaLog::debug("Max live stream inputs [{$maxInputStreams}]");
     $maxTranscodedStreams = 0;
     if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_KALTURA_LIVE_STREAM_TRANSCODE, $this->getPartnerId())) {
         $maxTranscodedStreams = $this->getPartner()->getMaxLiveStreamOutputs();
         if (!$maxTranscodedStreams) {
             $maxTranscodedStreams = kConf::get('partner_max_live_stream_outputs', 'local', 10);
         }
     }
     KalturaLog::debug("Max live stream outputs [{$maxTranscodedStreams}]");
     $totalInputStreams = count($entries) + 1;
     if ($totalInputStreams > $maxInputStreams + $maxTranscodedStreams) {
         KalturaLog::debug("Live input stream [{$totalInputStreams}]");
         throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_EXCEEDED_MAX_PASSTHRU, $entryId);
     }
     $entryIds = array($entryId);
     foreach ($entries as $liveEntry) {
         /* @var $liveEntry LiveEntry */
         $entryIds[] = $liveEntry->getId();
         $liveParamsIds = array_map('intval', explode(',', $liveEntry->getFlavorParamsIds()));
         foreach ($liveParamsIds as $liveParamsId) {
             if (isset($usedLiveParamsIds[$liveParamsId])) {
                 $usedLiveParamsIds[$liveParamsId][] = $liveEntry->getId();
             } else {
                 $usedLiveParamsIds[$liveParamsId] = array($liveEntry->getId());
             }
         }
     }
     $liveParams = assetParamsPeer::retrieveByPKs(array_keys($usedLiveParamsIds));
     $passthruEntries = null;
     $transcodedEntries = null;
     foreach ($liveParams as $liveParamsItem) {
         /* @var $liveParamsItem LiveParams */
         if ($liveParamsItem->hasTag(liveParams::TAG_INGEST)) {
             $passthruEntries = array_intersect(is_array($passthruEntries) ? $passthruEntries : $entryIds, $usedLiveParamsIds[$liveParamsItem->getId()]);
         } else {
             $transcodedEntries = array_intersect(is_array($transcodedEntries) ? $transcodedEntries : $entryIds, $usedLiveParamsIds[$liveParamsItem->getId()]);
         }
     }
     $passthruEntries = array_diff($passthruEntries, $transcodedEntries);
     $passthruEntriesCount = count($passthruEntries);
     $transcodedEntriesCount = count($transcodedEntries);
     KalturaLog::debug("Live transcoded entries [{$transcodedEntriesCount}], max live transcoded streams [{$maxTranscodedStreams}]");
     if ($transcodedEntriesCount > $maxTranscodedStreams) {
         throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_EXCEEDED_MAX_TRANSCODED, $entryId);
     }
     $maxInputStreams += $maxTranscodedStreams - $transcodedEntriesCount;
     KalturaLog::debug("Live params inputs [{$passthruEntriesCount}], max live stream inputs [{$maxInputStreams}]");
     if ($passthruEntriesCount > $maxInputStreams) {
         throw new KalturaAPIException(KalturaErrors::LIVE_STREAM_EXCEEDED_MAX_PASSTHRU, $entryId);
     }
     $entry = KalturaEntryFactory::getInstanceByType($dbEntry->getType());
     $entry->fromObject($dbEntry, $this->getResponseProfile());
     return $entry;
 }
Exemplo n.º 23
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;
 }
Exemplo n.º 24
0
 private function shouldSyncWidevineRepositoryForPartner($partnerId)
 {
     return PermissionPeer::isValidForPartner(WidevinePlugin::WIDEVINE_ENABLE_DISTRIBUTION_DATES_SYNC_PERMISSION, $partnerId);
 }
Exemplo n.º 25
0
 public function validateForResponseProfile()
 {
     if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENABLE_RESPONSE_PROFILE_USER_CACHE, kCurrentContext::getCurrentPartnerId())) {
         return;
     }
     if (kEntitlementUtils::getEntitlementEnforcement()) {
         throw new KalturaAPIException(KalturaErrors::CANNOT_LIST_RELATED_ENTITLED_WHEN_ENTITLEMENT_IS_ENABLE, get_class($this));
     }
     if (!kCurrentContext::$is_admin_session && !$this->idEqual && !$this->idIn && !$this->referenceIdEqual && !$this->redirectFromEntryId && !$this->referenceIdIn && !$this->parentEntryIdEqual) {
         if (kCurrentContext::$ks_object->privileges === ks::PATTERN_WILDCARD) {
             return;
         }
         if (kCurrentContext::$ks_object->getPrivilegeValue(ks::PRIVILEGE_LIST) === ks::PATTERN_WILDCARD) {
             return;
         }
         throw new KalturaAPIException(KalturaErrors::USER_KS_CANNOT_LIST_RELATED_ENTRIES, get_class($this));
     }
 }
Exemplo n.º 26
0
 public function isKsNeededForDownload()
 {
     $entry = $this->getentry();
     if (!$entry) {
         return true;
     }
     if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_ENTITLEMENT, $this->getPartnerId())) {
         return true;
     }
     return $entry->isSecuredEntry();
 }
Exemplo n.º 27
0
 /**
  * Enable user login 
  * @param string $loginId
  * @param string $password
  * @param bool $checkPasswordStructure
  * @throws kUserException::USER_LOGIN_ALREADY_ENABLED
  * @throws kUserException::INVALID_EMAIL
  * @throws kUserException::INVALID_PARTNER
  * @throws kUserException::ADMIN_LOGIN_USERS_QUOTA_EXCEEDED
  * @throws kUserException::PASSWORD_STRUCTURE_INVALID
  * @throws kUserException::LOGIN_ID_ALREADY_USED
  */
 public function enableLogin($loginId, $password = null, $checkPasswordStructure = true, $sendEmail = null)
 {
     if (!$password) {
         $password = UserLoginDataPeer::generateNewPassword();
         if (is_null($sendEmail)) {
             $sendEmail = true;
         }
     }
     if ($this->getLoginDataId()) {
         throw new kUserException('', kUserException::USER_LOGIN_ALREADY_ENABLED);
     }
     $loginDataExisted = null;
     $loginData = UserLoginDataPeer::addLoginData($loginId, $password, $this->getPartnerId(), $this->getFirstName(), $this->getLastName(), $this->getIsAdmin(), $checkPasswordStructure, $loginDataExisted);
     if (!$loginData) {
         throw new kUserException('', kUserException::LOGIN_DATA_NOT_FOUND);
     }
     $this->setLoginDataId($loginData->getId());
     //Email notification on user creation is sent while using kuser email so make sure this field is set before enabling login
     //if not than set the email to be the $loginId provided to this action (we now know this is a valid email since "addLoginData" verifies this)
     if (!$this->getEmail()) {
         $this->setEmail($loginId);
     }
     if ($sendEmail) {
         if ($loginDataExisted) {
             kuserPeer::sendNewUserMail($this, true);
         } else {
             kuserPeer::sendNewUserMail($this, false);
         }
         if (!PermissionPeer::isValidForPartner(PermissionName::FEATURE_DISABLE_NEW_USER_EMAIL, $this->getPartnerId())) {
             kuserPeer::sendNewUserMailToAdmins($this);
         }
     }
     return $this;
 }
Exemplo n.º 28
0
 public function getEnabledService($permissionName)
 {
     if (isset($this->setEnabledServices[$permissionName])) {
         return $this->setEnabledServices[$permissionName];
     } else {
         $permission = PermissionPeer::isValidForPartner($permissionName, $this->getId());
         return $permission ? true : false;
     }
 }
Exemplo n.º 29
0
 public function getCategoriesIds()
 {
     if (PermissionPeer::isValidForPartner(PermissionName::FEATURE_DISABLE_CATEGORY_LIMIT, $this->getPartnerId())) {
         return null;
     }
     return parent::getCategoriesIds();
 }
Exemplo n.º 30
0
 public function execute()
 {
     sfView::SUCCESS;
     /** check parameters and verify user is logged-in **/
     $this->ks = $this->getP("kmcks");
     if (!$this->ks) {
         // if kmcks from cookie doesn't exist, try ks from REQUEST
         $this->ks = $this->getP('ks');
     }
     /** if no KS found, redirect to login page **/
     if (!$this->ks) {
         $this->redirect("kmc/kmc");
         die;
     }
     $ksObj = kSessionUtils::crackKs($this->ks);
     // Set partnerId from KS
     $this->partner_id = $ksObj->partner_id;
     // Check if the KMC can be framed
     $allowFrame = PermissionPeer::isValidForPartner(PermissionName::FEATURE_KMC_ALLOW_FRAME, $this->partner_id);
     if (!$allowFrame) {
         header('X-Frame-Options: DENY');
     }
     // Check for forced HTTPS
     $force_ssl = PermissionPeer::isValidForPartner(PermissionName::FEATURE_KMC_ENFORCE_HTTPS, $this->partner_id);
     if ($force_ssl && (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) {
         header("Location: " . infraRequestUtils::PROTOCOL_HTTPS . "://" . $_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"]);
         die;
     }
     /** END - check parameters and verify user is logged-in **/
     /** Get array of allowed partners for the current user **/
     $allowedPartners = array();
     $this->full_name = "";
     $currentUser = kuserPeer::getKuserByPartnerAndUid($this->partner_id, $ksObj->user, true);
     if ($currentUser) {
         $partners = myPartnerUtils::getPartnersArray($currentUser->getAllowedPartnerIds());
         foreach ($partners as $partner) {
             $allowedPartners[] = array('id' => $partner->getId(), 'name' => $partner->getName());
         }
         $this->full_name = $currentUser->getFullName();
     }
     $this->showChangeAccount = count($allowedPartners) > 1 ? true : false;
     // Load partner
     $this->partner = $partner = PartnerPeer::retrieveByPK($this->partner_id);
     if (!$partner) {
         KExternalErrors::dieError(KExternalErrors::PARTNER_NOT_FOUND);
     }
     if (!$partner->validateApiAccessControl()) {
         KExternalErrors::dieError(KExternalErrors::SERVICE_ACCESS_CONTROL_RESTRICTED);
     }
     kmcUtils::redirectPartnerToCorrectKmc($partner, $this->ks, null, null, null, self::CURRENT_KMC_VERSION);
     $this->templatePartnerId = $this->partner ? $this->partner->getTemplatePartnerId() : self::SYSTEM_DEFAULT_PARTNER;
     $ignoreEntrySeoLinks = PermissionPeer::isValidForPartner(PermissionName::FEATURE_IGNORE_ENTRY_SEO_LINKS, $this->partner_id);
     $useEmbedCodeProtocolHttps = PermissionPeer::isValidForPartner(PermissionName::FEATURE_EMBED_CODE_DEFAULT_PROTOCOL_HTTPS, $this->partner_id);
     $showFlashStudio = PermissionPeer::isValidForPartner(PermissionName::FEATURE_SHOW_FLASH_STUDIO, $this->partner_id);
     $showHTMLStudio = PermissionPeer::isValidForPartner(PermissionName::FEATURE_SHOW_HTML_STUDIO, $this->partner_id);
     $deliveryTypes = $partner->getDeliveryTypes();
     $embedCodeTypes = $partner->getEmbedCodeTypes();
     $defaultDeliveryType = $partner->getDefaultDeliveryType() ? $partner->getDefaultDeliveryType() : 'http';
     $defaultEmbedCodeType = $partner->getDefaultEmbedCodeType() ? $partner->getDefaultEmbedCodeType() : 'auto';
     $this->previewEmbedV2 = PermissionPeer::isValidForPartner(PermissionName::FEATURE_PREVIEW_AND_EMBED_V2, $this->partner_id);
     /** set values for template **/
     $this->service_url = requestUtils::getRequestHost();
     $this->host = $this->stripProtocol($this->service_url);
     $this->embed_host = $this->stripProtocol(myPartnerUtils::getHost($this->partner_id));
     if (kConf::hasParam('cdn_api_host') && kConf::hasParam('www_host') && $this->host == kConf::get('cdn_api_host')) {
         $this->host = kConf::get('www_host');
     }
     if ($this->embed_host == kConf::get("www_host") && kConf::hasParam('cdn_api_host')) {
         $this->embed_host = kConf::get('cdn_api_host');
     }
     $this->embed_host_https = kConf::hasParam('cdn_api_host_https') ? kConf::get('cdn_api_host_https') : kConf::get('www_host');
     $this->cdn_url = myPartnerUtils::getCdnHost($this->partner_id);
     $this->cdn_host = $this->stripProtocol($this->cdn_url);
     $this->rtmp_host = kConf::get("rtmp_url");
     $this->flash_dir = $this->cdn_url . myContentStorage::getFSFlashRootPath();
     /** set payingPartner flag **/
     $this->payingPartner = 'false';
     if ($partner && $partner->getPartnerPackage() != PartnerPackages::PARTNER_PACKAGE_FREE) {
         $this->payingPartner = 'true';
         $ignoreSeoLinks = true;
     } else {
         $ignoreSeoLinks = $this->partner->getIgnoreSeoLinks();
     }
     /** get partner languae **/
     $language = null;
     if ($partner->getKMCLanguage()) {
         $language = $partner->getKMCLanguage();
     }
     $first_login = $partner->getIsFirstLogin();
     if ($first_login === true) {
         $partner->setIsFirstLogin(false);
         $partner->save();
     }
     /** get logout url **/
     $logoutUrl = null;
     if ($partner->getLogoutUrl()) {
         $logoutUrl = $partner->getLogoutUrl();
     }
     $this->kmc_swf_version = kConf::get('kmc_version');
     $akamaiEdgeServerIpURL = null;
     if (kConf::hasParam('akamai_edge_server_ip_url')) {
         $akamaiEdgeServerIpURL = kConf::get('akamai_edge_server_ip_url');
     }
     /** uiconf listing work **/
     /** fill $confs with all uiconf objects for all modules **/
     $kmcGeneralUiConf = kmcUtils::getAllKMCUiconfs('kmc', $this->kmc_swf_version, self::SYSTEM_DEFAULT_PARTNER);
     $kmcGeneralTemplateUiConf = kmcUtils::getAllKMCUiconfs('kmc', $this->kmc_swf_version, $this->templatePartnerId);
     /** for each module, create separated lists of its uiconf, for each need **/
     /** kmc general uiconfs **/
     $this->kmc_general = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_kmcgeneral", false, $kmcGeneralUiConf);
     $this->kmc_permissions = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_kmcpermissions", false, $kmcGeneralUiConf);
     /** P&E players: **/
     //$this->content_uiconfs_previewembed = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_previewembed", true, $kmcGeneralUiConf);
     //$this->content_uiconfs_previewembed_list = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_previewembed_list", true, $kmcGeneralUiConf);
     $this->content_uiconfs_flavorpreview = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_flavorpreview", false, $kmcGeneralUiConf);
     /* KCW uiconfs */
     $this->content_uiconfs_upload_webcam = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_uploadWebCam", false, $kmcGeneralUiConf);
     $this->content_uiconfs_upload_import = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_uploadImport", false, $kmcGeneralUiConf);
     $this->content_uiconds_clipapp_kdp = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_kdpClipApp", false, $kmcGeneralUiConf);
     $this->content_uiconds_clipapp_kclip = kmcUtils::find_confs_by_usage_tag($kmcGeneralTemplateUiConf, "kmc_kClipClipApp", false, $kmcGeneralUiConf);
     $this->studioUiConf = kmcUtils::getStudioUiconf(kConf::get("studio_version"));
     $this->content_uiconfs_studio_v2 = isset($this->studioUiConf) ? array_values($this->studioUiConf) : null;
     $this->content_uiconf_studio_v2 = is_array($this->content_uiconfs_studio_v2) && reset($this->content_uiconfs_studio_v2) ? reset($this->content_uiconfs_studio_v2) : null;
     $this->liveAUiConf = kmcUtils::getLiveAUiconf();
     $this->content_uiconfs_livea = isset($this->liveAUiConf) ? array_values($this->liveAUiConf) : null;
     $this->content_uiconf_livea = is_array($this->content_uiconfs_livea) && reset($this->content_uiconfs_livea) ? reset($this->content_uiconfs_livea) : null;
     $kmcVars = array('kmc_version' => $this->kmc_swf_version, 'kmc_general_uiconf' => $this->kmc_general->getId(), 'kmc_permissions_uiconf' => $this->kmc_permissions->getId(), 'allowed_partners' => $allowedPartners, 'kmc_secured' => (bool) kConf::get("kmc_secured_login"), 'enableLanguageMenu' => true, 'service_url' => $this->service_url, 'host' => $this->host, 'cdn_host' => $this->cdn_host, 'rtmp_host' => $this->rtmp_host, 'embed_host' => $this->embed_host, 'embed_host_https' => $this->embed_host_https, 'flash_dir' => $this->flash_dir, 'getuiconfs_url' => '/index.php/kmc/getuiconfs', 'terms_of_use' => kConf::get('terms_of_use_uri'), 'ks' => $this->ks, 'partner_id' => $this->partner_id, 'first_login' => (bool) $first_login, 'whitelabel' => $this->templatePartnerId, 'ignore_seo_links' => (bool) $ignoreSeoLinks, 'ignore_entry_seo' => (bool) $ignoreEntrySeoLinks, 'embed_code_protocol_https' => (bool) $useEmbedCodeProtocolHttps, 'delivery_types' => $deliveryTypes, 'embed_code_types' => $embedCodeTypes, 'default_delivery_type' => $defaultDeliveryType, 'default_embed_code_type' => $defaultEmbedCodeType, 'kcw_webcam_uiconf' => $this->content_uiconfs_upload_webcam->getId(), 'kcw_import_uiconf' => $this->content_uiconfs_upload_import->getId(), 'default_kdp' => array('id' => $this->content_uiconfs_flavorpreview->getId(), 'height' => $this->content_uiconfs_flavorpreview->getHeight(), 'width' => $this->content_uiconfs_flavorpreview->getWidth(), 'swf_version' => $this->content_uiconfs_flavorpreview->getswfUrlVersion()), 'clipapp' => array('version' => kConf::get("clipapp_version"), 'kdp' => $this->content_uiconds_clipapp_kdp->getId(), 'kclip' => $this->content_uiconds_clipapp_kclip->getId()), 'studio' => array('version' => kConf::get("studio_version"), 'uiConfID' => isset($this->content_uiconf_studio_v2) ? $this->content_uiconf_studio_v2->getId() : '', 'config' => isset($this->content_uiconf_studio_v2) ? $this->content_uiconf_studio_v2->getConfig() : '', 'showFlashStudio' => $showFlashStudio, 'showHTMLStudio' => $showHTMLStudio), 'liveanalytics' => array('version' => kConf::get("liveanalytics_version"), 'player_id' => isset($this->content_uiconf_livea) ? $this->content_uiconf_livea->getId() : '', 'map_zoom_levels' => kConf::hasParam("map_zoom_levels") ? kConf::get("map_zoom_levels") : '', 'map_urls' => kConf::hasParam("cdn_static_hosts") ? array_map(function ($s) {
         return "{$s}/content/static/maps/v1";
     }, kConf::get("cdn_static_hosts")) : ''), 'usagedashboard' => array('version' => kConf::get("usagedashboard_version")), 'disable_analytics' => (bool) kConf::get("kmc_disable_analytics"), 'google_analytics_account' => kConf::get("ga_account"), 'language' => $language, 'logoutUrl' => $logoutUrl, 'allowFrame' => (bool) $allowFrame, 'akamaiEdgeServerIpURL' => $akamaiEdgeServerIpURL, 'logoUrl' => kmcUtils::getWhitelabelData($partner, 'logo_url'), 'supportUrl' => kmcUtils::getWhitelabelData($partner, 'support_url'));
     $this->kmcVars = $kmcVars;
 }