/**
  * Will forward to the uploader swf according to the ui_conf_id 
  */
 public function execute()
 {
     $ui_conf_id = $this->getRequestParameter("ui_conf_id");
     $uiConf = uiConfPeer::retrieveByPK($ui_conf_id);
     if (!$uiConf) {
         KExternalErrors::dieError(KExternalErrors::UI_CONF_NOT_FOUND, "UI conf not found");
     }
     $partner_id = $uiConf->getPartnerId();
     $subp_id = $uiConf->getSubpId();
     $host = requestUtils::getRequestHost();
     $ui_conf_swf_url = $uiConf->getSwfUrl();
     if (!$ui_conf_swf_url) {
         KExternalErrors::dieError(KExternalErrors::ILLEGAL_UI_CONF, "SWF URL not found in UI conf");
     }
     if (kString::beginsWith($ui_conf_swf_url, "http")) {
         $swf_url = $ui_conf_swf_url;
         // absolute URL
     } else {
         $use_cdn = $uiConf->getUseCdn();
         $cdn_host = $use_cdn ? myPartnerUtils::getCdnHost($partner_id) : myPartnerUtils::getHost($partner_id);
         $swf_url = $cdn_host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url;
         // relative to the current host
     }
     $conf_vars = $uiConf->getConfVars();
     if ($conf_vars) {
         $conf_vars = "&" . $conf_vars;
     }
     $params = "host=" . $host . "&uiConfId=" . $ui_conf_id . $conf_vars;
     KExternalErrors::terminateDispatch();
     $this->redirect("{$swf_url}?{$params}");
 }
Exemple #2
0
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     myPartnerUtils::addPartnerToCriteria(new UserRolePeer(), $this->getPartnerId(), $this->private_partner_data, $this->partnerGroup());
     myPartnerUtils::addPartnerToCriteria(new PermissionPeer(), $this->getPartnerId(), $this->private_partner_data, $this->partnerGroup());
     myPartnerUtils::addPartnerToCriteria(new PermissionItemPeer(), $this->getPartnerId(), $this->private_partner_data, $this->partnerGroup());
 }
 /**
  * Will forward to the uploader swf according to the ui_conf_id 
  */
 public function execute()
 {
     $ui_conf_id = $this->getRequestParameter("ui_conf_id");
     $uiConf = uiConfPeer::retrieveByPK($ui_conf_id);
     if (!$uiConf) {
         die;
     }
     $partner_id = $uiConf->getPartnerId();
     $subp_id = $uiConf->getSubpId();
     $host = requestUtils::getRequestHost();
     $ui_conf_swf_url = $uiConf->getSwfUrl();
     if (!$ui_conf_swf_url) {
         die;
     }
     if (kString::beginsWith($ui_conf_swf_url, "http")) {
         $swf_url = $ui_conf_swf_url;
         // absolute URL
     } else {
         $use_cdn = $uiConf->getUseCdn();
         $cdn_host = $use_cdn ? myPartnerUtils::getCdnHost($partner_id) : myPartnerUtils::getHost($partner_id);
         $swf_url = $cdn_host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url;
         // relative to the current host
     }
     $conf_vars = $uiConf->getConfVars();
     if ($conf_vars) {
         $conf_vars = "&" . $conf_vars;
     }
     $params = "host=" . $host . "&uiConfId=" . $ui_conf_id . $conf_vars;
     $this->redirect("{$swf_url}?{$params}");
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     $partner_id = $this->getRequestParameter('partner_id', -1);
     if ($partner_id >= 0) {
         myPartnerUtils::applyPartnerFilters($partner_id);
     }
     $this->partner_id = $partner_id;
     $order = $this->getRequestParameter('sort', kuser::KUSER_SORT_MOST_VIEWED);
     $page = $this->getRequestParameter('page', 1);
     $pager = kuserPeer::getAllUsersOrderedPager($order, 10, $page);
     $kuser_list = $pager->getResults();
     dashboardUtils::updateKusersRoughcutCount($kuser_list);
     $kusersData = array();
     foreach ($kuser_list as $kuser) {
         $kusersData[] = $this->createkuserData($kuser, $order);
     }
     // following variables will be used by the view
     $this->firstTime = $this->getRequestParameter('first', 1) == 1;
     $this->order = $order;
     $this->page = $page;
     $this->lastPage = $pager->getLastPage();
     $this->numResults = $pager->getNbResults();
     $this->kusersData = $kusersData;
     // allow the action buttons to show only for entires the user on their own pages
     $this->allowactions = true;
 }
 /**
  * @param flavorAsset $flavorAsset
  * @return string
  */
 public function getFlavorAssetUrl(flavorAsset $flavorAsset)
 {
     $entry = $flavorAsset->getentry();
     $partnerId = $entry->getPartnerId();
     $subpId = $entry->getSubpId();
     $flavorAssetId = $flavorAsset->getId();
     $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId);
     $this->setFileExtension($flavorAsset->getFileExt());
     $url = "/s{$partnerPath}/serveFlavor/flavorId/{$flavorAssetId}";
     if ($this->clipTo) {
         $url .= "/clipTo/{$this->clipTo}";
     }
     if ($this->extention) {
         $url .= "/name/{$flavorAssetId}.{$this->extention}";
     }
     $url = str_replace('\\', '/', $url);
     if ($this->protocol != StorageProfile::PLAY_FORMAT_RTMP) {
         $url .= '?novar=0';
         $url .= '&e=' . (time() + 120);
         $secret = $this->getMediaVault();
         $fullUrl = $this->protocol . '://' . $this->domain . $url;
         $url .= '&h=' . md5($secret . $fullUrl);
         $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $seekFromBytes = $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey));
         if ($seekFromBytes) {
             $url .= '&fs=' . $seekFromBytes;
         }
     } else {
         $url .= '/forceproxy/true';
     }
     return $url;
 }
 /**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     $ui_conf_id = $this->getRequestParameter("ui_conf_id");
     $uiConf = uiConfPeer::retrieveByPK($ui_conf_id);
     if (!$uiConf) {
         die;
     }
     $partner_id = $uiConf->getPartnerId();
     $subp_id = $uiConf->getSubpId();
     if (!$subp_id) {
         $subp_id = 0;
     }
     $host = myPartnerUtils::getHost($partner_id);
     $ui_conf_swf_url = $uiConf->getSwfUrl();
     if (!$ui_conf_swf_url) {
         $ui_conf_swf_url = "/swf/ContributionWizard.swf";
     }
     if (kString::beginsWith($ui_conf_swf_url, "http")) {
         $swf_url = $ui_conf_swf_url;
         // absolute URL
     } else {
         $use_cdn = $uiConf->getUseCdn();
         $cdn_host = $use_cdn ? myPartnerUtils::getCdnHost($partner_id) : myPartnerUtils::getHost($partner_id);
         $swf_url = $cdn_host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url;
         // relative to the current host
     }
     $params = "contentUrl=" . urlencode($swf_url) . "&host=" . str_replace("http://", "", str_replace("https://", "", $host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", myPartnerUtils::getCdnHost($partner_id))) . "&uiConfId=" . $ui_conf_id;
     $wrapper_swf = myContentStorage::getFSFlashRootPath() . "/flexwrapper/" . kConf::get('kcw_flex_wrapper_version') . "/FlexWrapper.swf";
     $this->redirect($host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . "{$wrapper_swf}?{$params}");
 }
 private static function purgeAssetFromEdgeCast(asset $asset)
 {
     // get partner
     $partnerId = $asset->getPartnerId();
     $partner = PartnerPeer::retrieveByPK($partnerId);
     if (!$partner) {
         KalturaLog::err('Cannot find partner with id [' . $partnerId . ']');
         return false;
     }
     $mediaType = $asset instanceof thumbAsset ? self::EDGE_SERVICE_HTTP_SMALL_OBJECT_MEDIA_TYPE : self::EDGE_SERVICE_HTTP_LARGE_OBJECT_MEDIA_TYPE;
     $mediaTypePathList = array();
     try {
         $mediaTypePathList[] = array('MediaType' => $mediaType, 'MediaPath' => $asset->getDownloadUrl());
         // asset download url
     } catch (Exception $e) {
         KalturaLog::err('Cannot get asset URL for asset id [' . $asset->getId() . '] - ' . $e->getMessage());
     }
     if ($asset instanceof flavorAsset) {
         // get a list of all URLs leading to the asset for purging
         $subPartnerId = $asset->getentry()->getSubpId();
         $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subPartnerId);
         $assetId = $asset->getId();
         $serveFlavorUrl = "{$partnerPath}/serveFlavor/entryId/" . $asset->getEntryId() . "/flavorId/{$assetId}" . '*';
         // * wildcard should delete all serveFlavor urls
         $hosts = array($partner->getCdnHost(), $partner->getRtmpUrl(), $partner->getIisHost());
         foreach ($hosts as $host) {
             if (!empty($host)) {
                 $mediaTypePathList[] = array('MediaType' => $mediaType, 'MediaPath' => $host . $serveFlavorUrl);
             }
         }
     }
     return self::purgeFromEdgeCast($mediaTypePathList, $partner);
 }
 /**
  * @param Partner $fromPartner
  * @param Partner $toPartner
  */
 protected function copyEventNotificationTemplates(Partner $fromPartner, Partner $toPartner, $permissionRequiredOnly = false)
 {
     $fromPartnerId = $fromPartner->getId();
     $toPartnerId = $toPartner->getId();
     KalturaLog::debug("Copy event-notification templates from [{$fromPartnerId}] to [{$toPartnerId}]");
     $c = new Criteria();
     $c->add(EventNotificationTemplatePeer::PARTNER_ID, $fromPartnerId);
     $systemNameCriteria = new Criteria();
     $systemNameCriteria->add(EventNotificationTemplatePeer::PARTNER_ID, $toPartnerId);
     $systemNameCriteria->add(EventNotificationTemplatePeer::STATUS, EventNotificationTemplateStatus::ACTIVE);
     $eventNotificationTemplates = EventNotificationTemplatePeer::doSelect($c);
     foreach ($eventNotificationTemplates as $eventNotificationTemplate) {
         /* @var $eventNotificationTemplate EventNotificationTemplate */
         if ($permissionRequiredOnly && !count($eventNotificationTemplate->getRequiredCopyTemplatePermissions())) {
             continue;
         }
         if (!myPartnerUtils::isPartnerPermittedForCopy($toPartner, $eventNotificationTemplate->getRequiredCopyTemplatePermissions())) {
             continue;
         }
         if ($eventNotificationTemplate->getSystemName()) {
             $c = clone $systemNameCriteria;
             $c->add(EventNotificationTemplatePeer::SYSTEM_NAME, $eventNotificationTemplate->getSystemName());
             if (EventNotificationTemplatePeer::doCount($c)) {
                 continue;
             }
         }
         $newEventNotificationTemplate = $eventNotificationTemplate->copy();
         $newEventNotificationTemplate->setPartnerId($toPartnerId);
         $newEventNotificationTemplate->save();
     }
 }
 /**
  * Return the notifications for a specific entry id and type
  * 
  * @action getClientNotification
  * @param string $entryId
  * @param KalturaNotificationType $type
  * @return KalturaClientNotification
  */
 function getClientNotificationAction($entryId, $type)
 {
     // in case of a multirequest, a mediaService.addFromUploadedFile may fail and therefore the resulting entry id will be empty
     // in such a case return immidiately without looking for the notification
     if ($entryId == '') {
         throw new KalturaAPIException(KalturaErrors::NOTIFICATION_FOR_ENTRY_NOT_FOUND, $entryId);
     }
     $notifications = BatchJobPeer::retrieveByEntryIdAndType($entryId, BatchJobType::NOTIFICATION, $type);
     // FIXME: throw error if not found
     if (count($notifications) == 0) {
         throw new KalturaAPIException(KalturaErrors::NOTIFICATION_FOR_ENTRY_NOT_FOUND, $entryId);
     }
     $notification = $notifications[0];
     $partnerId = $this->getPartnerId();
     $nofication_config_str = null;
     list($nofity, $nofication_config_str) = myPartnerUtils::shouldNotify($partnerId);
     if (!$nofity) {
         return new KalturaClientNotification();
     }
     $nofication_config = myNotificationsConfig::getInstance($nofication_config_str);
     $nofity_send_type = $nofication_config->shouldNotify($type);
     if ($nofity_send_type != myNotificationMgr::NOTIFICATION_MGR_SEND_SYNCH && $nofity_send_type != myNotificationMgr::NOTIFICATION_MGR_SEND_BOTH) {
         return new KalturaClientNotification();
     }
     $partner = PartnerPeer::retrieveByPK($partnerId);
     list($url, $signatureKey) = myNotificationMgr::getPartnerNotificationInfo($partner);
     list($params, $rawSignature) = myNotificationMgr::prepareNotificationData($url, $signatureKey, $notification, null);
     $serializedParams = http_build_query($params, "", "&");
     $result = new KalturaClientNotification();
     $result->url = $url;
     $result->data = $serializedParams;
     return $result;
 }
Exemple #10
0
 /**
  * Start an impersonated session with Kaltura's server.
  * The result KS is the session key that you should pass to all services that requires a ticket.
  * 
  * @action impersonate
  * @param string $secret Remember to provide the correct secret according to the sessionType you want
  * @param int $impersonatedPartnerId
  * @param string $userId
  * @param KalturaSessionType $type Regular session or Admin session
  * @param int $partnerId
  * @param int $expiry KS expiry time in seconds
  * @param string $privileges 
  * @return string
  *
  * @throws APIErrors::START_SESSION_ERROR
  */
 function impersonateAction($secret, $impersonatedPartnerId, $userId = "", $type = 0, $partnerId = null, $expiry = 86400, $privileges = null)
 {
     KalturaResponseCacher::disableCache();
     // verify that partnerId exists and is in correspondence with given secret
     $result = myPartnerUtils::isValidSecret($partnerId, $secret, "", $expiry, $type);
     if ($result !== true) {
         throw new KalturaAPIException(APIErrors::START_SESSION_ERROR, $partnerId);
     }
     // verify partner is allowed to start session for another partner
     if (!myPartnerUtils::allowPartnerAccessPartner($partnerId, $this->partnerGroup(), $impersonatedPartnerId)) {
         throw new KalturaAPIException(APIErrors::START_SESSION_ERROR, $partnerId);
     }
     // get impersonated partner
     $impersonatedPartner = PartnerPeer::retrieveByPK($impersonatedPartnerId);
     if (!$impersonatedPartner) {
         // impersonated partner could not be fetched from the DB
         throw new KalturaAPIException(APIErrors::START_SESSION_ERROR, $partnerId);
     }
     // set the correct secret according to required session type
     if ($type == KalturaSessionType::ADMIN) {
         $impersonatedSecret = $impersonatedPartner->getAdminSecret();
     } else {
         $impersonatedSecret = $impersonatedPartner->getSecret();
     }
     // make sure the secret fits the one in the partner's table
     $ks = "";
     $result = kSessionUtils::startKSession($impersonatedPartner->getId(), $impersonatedSecret, $userId, $ks, $expiry, $type, "", $privileges, $partnerId);
     if ($result >= 0) {
         return $ks;
     } else {
         throw new KalturaAPIException(APIErrors::START_SESSION_ERROR, $partnerId);
     }
 }
 public function myBatchPartnerUsage($partnerId = null)
 {
     self::initDb();
     $partners_exists = true;
     $start_pos = 0;
     $bulk_size = 500;
     while ($partners_exists) {
         $c = new Criteria();
         if (!is_null($partnerId)) {
             $c->addAnd(PartnerPeer::ID, $partnerId);
         }
         $c->addAnd(PartnerPeer::PARTNER_PACKAGE, 1);
         // get only free partners
         $c->addAnd(PartnerPeer::MONITOR_USAGE, 1);
         $c->addAnd(PartnerPeer::STATUS, Partner::PARTNER_STATUS_DELETED, CRITERIA::NOT_EQUAL);
         $c->setOffset($start_pos);
         $c->setLimit($bulk_size);
         $partners = PartnerPeer::doSelect($c);
         if (!$partners) {
             KalturaLog::debug("No more partners. offset: {$start_pos} , limit: {$bulk_size} .");
             $partners_exists = false;
         } else {
             KalturaLog::debug("Looping " . ($start_pos + $bulk_size - 1) . " partners, offset: {$start_pos} .");
             foreach ($partners as $partner) {
                 myPartnerUtils::doPartnerUsage($partner, true);
             }
         }
         unset($partners);
         PartnerPeer::clearInstancePool();
         $start_pos += $bulk_size;
     }
 }
Exemple #12
0
 public static function createKSessionNoValidations($partner_id, $puser_id, &$ks_str, $desired_expiry_in_seconds = 86400, $admin = false, $partner_key = "", $privileges = "")
 {
     $ks_max_expiry_in_seconds = myPartnerUtils::getExpiry($partner_id);
     if ($ks_max_expiry_in_seconds && $ks_max_expiry_in_seconds < $desired_expiry_in_seconds) {
         $desired_expiry_in_seconds = $ks_max_expiry_in_seconds;
     }
     $ks = new ks();
     $ks->valid_until = kApiCache::getTime() + $desired_expiry_in_seconds;
     // store in milliseconds to make comparison easier at validation time
     //			$ks->type = $admin ? ks::TYPE_KAS : ks::TYPE_KS;
     if ($admin == false) {
         $ks->type = ks::TYPE_KS;
     } else {
         $ks->type = $admin;
     }
     // if the admin > 1 - use it rather than automatially setting it to be 2
     $ks->partner_id = $partner_id;
     $ks->partner_pattern = $partner_id;
     $ks->error = 0;
     $ks->rand = microtime(true);
     $ks->user = $puser_id;
     $ks->privileges = $privileges;
     $ks_str = $ks->toSecureString();
     return 0;
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     $partner_id = $this->getRequestParameter('partner_id', -1);
     if ($partner_id >= 0) {
         myPartnerUtils::applyPartnerFilters($partner_id);
     }
     $this->partner_id = $partner_id;
     $order = $this->getRequestParameter('sort', kshow::KSHOW_SORT_MOST_VIEWED);
     $page = $this->getRequestParameter('page', 1);
     //$this->producer_id = $this->getRequestParameter('producer_id', 0 );
     //$this->kaltura_part_of_flag = $this->getRequestParameter('partof', 0 );
     $pager = kshowPeer::getOrderedPager($order, 10, $page);
     $kshow_list = $pager->getResults();
     dashboardUtils::updateKshowsRoughcutCount($kshow_list);
     $kshowsData = array();
     foreach ($kshow_list as $kshow) {
         $kshowsData[] = $this->createKShowData($kshow, $order);
     }
     // following variables will be used by the view
     $this->firstTime = $this->getRequestParameter('first', 1) == 1;
     $this->order = $order;
     $this->page = $page;
     $this->lastPage = $pager->getLastPage();
     $this->numResults = $pager->getNbResults();
     $this->kshowsData = $kshowsData;
     // allow the action buttons to show only for shows the user produced, and only for authenticated users, on their own pages
     $this->allowactions = true;
     // !$this->kaltura_part_of_flag && $this->getUser()->isAuthenticated() && $this->getUser()->getAttribute('id') == $this->producer_id;
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshow_id = $this->getPM("kshow_id");
     $detailed = $this->getP("detailed", false);
     $kshow_indexedCustomData3 = $this->getP("indexedCustomData3");
     $kshow = null;
     if ($kshow_id == kshow::KSHOW_ID_USE_DEFAULT) {
         // see if the partner has some default kshow to add to
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser);
         if ($kshow) {
             $kshow_id = $kshow->getId();
         }
     } elseif ($kshow_id) {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
     } elseif ($kshow_indexedCustomData3) {
         $kshow = kshowPeer::retrieveByIndexedCustomData3($kshow_indexedCustomData3);
     }
     if (!$kshow) {
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
     } else {
         $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR;
         $wrapper = objectWrapperBase::getWrapperClass($kshow, $level);
         // TODO - remove this code when cache works properly when saving objects (in their save method)
         $wrapper->removeFromCache("kshow", $kshow_id);
         $this->addMsg("kshow", $wrapper);
     }
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $allow_empty = $this->getP("allow_empty_field", false);
     if ($allow_empty == "false" || $allow_empty === 0) {
         $allow_empty = false;
     }
     $partner = new Partner();
     $obj_wrapper = objectWrapperBase::getWrapperClass($partner, 0);
     $updateable_fields = $obj_wrapper->getUpdateableFields();
     // TODO - use fillObjectFromMapOrderedByFields instead
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $partner, "partner_", $updateable_fields, BasePeer::TYPE_PHPNAME, $allow_empty);
     // check that mandatory fields were set
     // TODO
     if (count($fields_modified) > 0) {
         $target_partner = PartnerPeer::retrieveByPK($partner_id);
         if ($partner && $target_partner) {
             if (@$fields_modified["adminEmail"] && $target_partner->getAdminEmail() != $fields_modified["adminEmail"]) {
                 myPartnerUtils::emailChangedEmail($partner_id, $target_partner->getAdminEmail(), $fields_modified["adminEmail"], $target_partner->getName(), PartnerPeer::KALTURAS_PARTNER_EMAIL_CHANGE);
             }
             $partner->setType($target_partner->getType());
             baseObjectUtils::fillObjectFromObject($updateable_fields, $partner, $target_partner, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME, $allow_empty);
             $target_partner->save();
             $this->addMsg("partner", objectWrapperBase::getWrapperClass($target_partner, objectWrapperBase::DETAIL_LEVEL_DETAILED));
             $this->addDebug("added_fields", $fields_modified);
         } else {
             $this->addError(APIErrors::UNKNOWN_PARTNER_ID);
         }
     } else {
         $this->addError(APIErrors::NO_FIELDS_SET_FOR_PARTNER);
     }
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshow_id = $this->getP("kshow_id", kshow::KSHOW_ID_USE_DEFAULT);
     $entry = null;
     if ($kshow_id == kshow::KSHOW_ID_USE_DEFAULT) {
         // see if the partner has some default kshow to add to
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser);
         if ($kshow) {
             $kshow_id = $kshow->getId();
         }
     } elseif ($kshow_id == kshow::KSHOW_ID_CREATE_NEW) {
         // if the partner allows - create a new kshow
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, true);
         if ($kshow) {
             $kshow_id = $kshow->getId();
             $entry = $kshow->getShowEntry();
             // use the newly created kshow's roughcut
         }
     } else {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
     }
     if (!$kshow) {
         // the partner is attempting to add an entry to some invalid or non-existing kwho
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
         return;
     }
     if (!$entry) {
         $entry = $kshow->createEntry(entry::ENTRY_MEDIA_TYPE_SHOW, $kshow->getProducerId(), "&auto_edit.jpg", "");
     }
     $obj_wrapper = objectWrapperBase::getWrapperClass($entry, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $entry, $this->getObjectPrefix() . "_", array("name", "tags", "groupId", "partnerData", "permissions", "screenName", "description", "indexedCustomData1"));
     $entry->save();
     $this->addMsg($this->getObjectPrefix(), objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR));
     $this->addDebug("added_fields", $fields_modified);
 }
 /**
  * @param flavorAsset $flavorAsset
  * @return string
  */
 protected function doGetFlavorAssetUrl(flavorAsset $flavorAsset)
 {
     $entry = $flavorAsset->getentry();
     $partnerId = $entry->getPartnerId();
     $subpId = $entry->getSubpId();
     $flavorAssetId = $flavorAsset->getId();
     $partnerPath = myPartnerUtils::getUrlForPartner($partnerId, $subpId);
     $this->setFileExtension($flavorAsset->getFileExt());
     $versionString = $this->getFlavorVersionString($flavorAsset);
     $url = "/s{$partnerPath}/serveFlavor/entryId/" . $flavorAsset->getEntryId() . "{$versionString}/flavorId/{$flavorAssetId}";
     if ($this->clipTo) {
         $url .= "/clipTo/{$this->clipTo}";
     }
     if ($this->extention) {
         $url .= "/name/a.{$this->extention}";
     }
     $url = str_replace('\\', '/', $url);
     if ($this->protocol != StorageProfile::PLAY_FORMAT_RTMP) {
         $url .= '?novar=0';
         $syncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
         $seekFromBytes = $this->getSeekFromBytes(kFileSyncUtils::getLocalFilePathForKey($syncKey));
         if ($seekFromBytes) {
             $url .= '&fs=' . $seekFromBytes;
         }
     } else {
         if ($this->extention && strtolower($this->extention) != 'flv' || $this->containerFormat && strtolower($this->containerFormat) != 'flash video') {
             $url = "mp4:{$url}";
         }
     }
     return $url;
 }
 public static function startKSession($partner_id, $partner_secret, $puser_id, &$ks_str, $desired_expiry_in_seconds = 86400, $admin = false, $partner_key = "", $privileges = "", $master_partner_id = null, $additional_data = null)
 {
     $ks_max_expiry_in_seconds = "";
     // see if we want to use the generic setting of the partner
     $result = myPartnerUtils::isValidSecret($partner_id, $partner_secret, $partner_key, $ks_max_expiry_in_seconds, $admin);
     if ($result >= 0) {
         if ($ks_max_expiry_in_seconds && $ks_max_expiry_in_seconds < $desired_expiry_in_seconds) {
             $desired_expiry_in_seconds = $ks_max_expiry_in_seconds;
         }
         //	echo "startKSession: from DB: $ks_max_expiry_in_seconds | desired: $desired_expiry_in_seconds " ;
         $ks = new ks();
         $ks->valid_until = time() + $desired_expiry_in_seconds;
         // store in milliseconds to make comparison easier at validation time
         //			$ks->type = $admin ? ks::TYPE_KAS : ks::TYPE_KS;
         if ($admin == false) {
             $ks->type = ks::TYPE_KS;
         } else {
             $ks->type = $admin;
         }
         // if the admin > 1 - use it rather than automatially setting it to be 2
         $ks->partner_id = $partner_id;
         $ks->master_partner_id = $master_partner_id;
         $ks->partner_pattern = $partner_id;
         $ks->error = 0;
         $ks->rand = microtime(true);
         $ks->user = $puser_id;
         $ks->privileges = $privileges;
         $ks->additional_data = $additional_data;
         $ks_str = $ks->toSecureString();
         return 0;
     } else {
         return $result;
     }
 }
 /**
  * return the flavor params the best fits the fileFormat for a given partner_id
  * 
  * @param int $partnerId
  * @param string $fileFormat
  * @return FlavorParams
  */
 public static function getFlavorParamsFromFileFormat($partnerId, $fileFormat, $ignoreSourceTag = true)
 {
     $defaultCriteria = assetParamsPeer::getCriteriaFilter()->getFilter();
     $defaultCriteria->remove(assetParamsPeer::PARTNER_ID);
     //		assetParamsPeer::allowAccessToPartner0AndPartnerX($partnerId); // the flavor params can be from partner 0 too
     $c = new Criteria();
     $c->addAnd(assetParamsPeer::PARTNER_ID, array($partnerId, 0), Criteria::IN);
     //		$c->add (  assetParamsPeer::FORMAT , $fileFormat );
     $possible_flavor_params = assetParamsPeer::doSelect($c);
     myPartnerUtils::resetPartnerFilter('assetParams');
     $best_fp = null;
     foreach ($possible_flavor_params as $fp) {
         if ($fileFormat != $fp->getFormat()) {
             continue;
         }
         if ($ignoreSourceTag && $fp->hasTag(flavorParams::TAG_SOURCE)) {
             continue;
         }
         if (!$best_fp) {
             $best_fp = $fp;
         }
         if ($fp->getPartnerId() != $partnerId) {
             continue;
         }
         // same format for the partner
         $best_fp = $fp;
         break;
     }
     // if not fount any - choose the first flavor params from the list
     if (!$best_fp) {
         $best_fp = $possible_flavor_params[0];
     }
     return $best_fp;
 }
Exemple #20
0
 /**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     $ui_conf_id = $this->getRequestParameter("ui_conf_id");
     $uiConf = uiConfPeer::retrieveByPK($ui_conf_id);
     if (!$uiConf) {
         die;
     }
     $partner_id = $uiConf->getPartnerId();
     $subp_id = $uiConf->getSubpId();
     $host = myPartnerUtils::getHost($partner_id);
     $ui_conf_swf_url = $uiConf->getSwfUrl();
     if (!$ui_conf_swf_url) {
         $ui_conf_swf_url = "/swf/simpleeditor.swf";
     }
     if (kString::beginsWith($ui_conf_swf_url, "http")) {
         $swf_url = $ui_conf_swf_url;
         // absolute URL
     } else {
         $use_cdn = $uiConf->getUseCdn();
         $cdn_host = $use_cdn ? myPartnerUtils::getCdnHost($partner_id) : myPartnerUtils::getHost($partner_id);
         $swf_url = $cdn_host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . $ui_conf_swf_url;
         // relative to the current host
     }
     // handle buggy case for backward compatiblity
     $partner_host = $host;
     if ($partner_host == "http://www.kaltura.com") {
         $partner_host = 1;
     }
     // otherwise the kse will build a flawed url with [[IMPORT]]
     $params = "contentUrl=" . urlencode($swf_url) . "&host=" . str_replace("http://", "", str_replace("https://", "", $partner_host)) . "&cdnHost=" . str_replace("http://", "", str_replace("https://", "", myPartnerUtils::getCdnHost($partner_id))) . "&uiConfId=" . $ui_conf_id . "&disableurlhashing=" . kConf::get('disable_url_hashing');
     $wrapper_swf = myContentStorage::getFSFlashRootPath() . "/flexwrapper/" . kConf::get('editors_flex_wrapper_version') . "/FlexWrapper.swf";
     $this->redirect($host . myPartnerUtils::getUrlForPartner($partner_id, $subp_id) . "{$wrapper_swf}?{$params}");
 }
 public function myBatchPartnerUsage()
 {
     self::initDb();
     $partners_exists = true;
     $start_pos = 0;
     $bulk_size = 500;
     while ($partners_exists) {
         $c = new Criteria();
         // get only free partners
         $c->addAnd(PartnerPeer::PARTNER_PACKAGE, 1);
         $c->addAnd(PartnerPeer::MONITOR_USAGE, 1);
         $c->setOffset($start_pos);
         $c->setLimit($bulk_size);
         $partners = PartnerPeer::doSelect($c);
         if (!$partners) {
             TRACE("No more partners. offset: {$start_pos} , limit: {$bulk_size} .");
             $partners_exists = false;
         } else {
             TRACE("Looping " . ($start_pos + $bulk_size - 1) . " partners, offset: {$start_pos} .");
             foreach ($partners as $partner) {
                 myPartnerUtils::doPartnerUsage($partner, true);
             }
         }
         unset($partners);
         $start_pos += $bulk_size;
     }
 }
 /**
  * Will forward to the regular swf player according to the widget_id 
  */
 public function execute()
 {
     $entryId = $this->getRequestParameter("entry_id");
     $flavorId = $this->getRequestParameter("flavor");
     $fileName = $this->getRequestParameter("file_name");
     $ksStr = $this->getRequestParameter("ks");
     $referrer = $this->getRequestParameter("referrer");
     $referrer = base64_decode($referrer);
     if (!is_string($referrer)) {
         // base64_decode can return binary data
         $referrer = "";
     }
     // get entry
     $entry = entryPeer::retrieveByPK($entryId);
     if (is_null($entry)) {
         KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND);
     }
     myPartnerUtils::blockInactivePartner($entry->getPartnerId());
     $securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer);
     $securyEntryHelper->validateForDownload($entry, $ksStr);
     $flavorAsset = null;
     if ($flavorId) {
         // get flavor asset
         $flavorAsset = flavorAssetPeer::retrieveById($flavorId);
         if (is_null($flavorAsset) || $flavorAsset->getStatus() != flavorAsset::FLAVOR_ASSET_STATUS_READY) {
             KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
         }
         // the request flavor should belong to the requested entry
         if ($flavorAsset->getEntryId() != $entryId) {
             KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND);
         }
     } else {
         $flavorAsset = flavorAssetPeer::retrieveBestPlayByEntryId($entry->getId());
     }
     // Gonen 26-04-2010: in case entry has no flavor with 'mbr' tag - we return the source
     if (!$flavorAsset && ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_VIDEO || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO)) {
         $flavorAsset = flavorAssetPeer::retrieveOriginalByEntryId($entryId);
     }
     if ($flavorAsset) {
         $syncKey = $this->getSyncKeyAndForFlavorAsset($entry, $flavorAsset);
     } else {
         $syncKey = $this->getBestSyncKeyForEntry($entry);
     }
     list($fileBaseName, $fileExt) = $this->getFileName($entry, $flavorAsset);
     if (!$fileName) {
         $fileName = $fileBaseName;
     }
     if ($fileExt) {
         $fileName = $fileName . '.' . $fileExt;
     }
     if (is_null($syncKey)) {
         KExternalErrors::dieError(KExternalErrors::FILE_NOT_FOUND);
     }
     $this->handleFileSyncRedirection($syncKey);
     $filePath = kFileSyncUtils::getReadyLocalFilePathForKey($syncKey);
     $this->dumpFile($filePath, $fileName);
     die;
     // no view
 }
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     if ($actionName != 'goto') {
         myPartnerUtils::addPartnerToCriteria(new ShortLinkPeer(), $this->getPartnerId(), $this->private_partner_data, $this->partnerGroup());
         myPartnerUtils::addPartnerToCriteria(new kuserPeer(), $this->getPartnerId(), $this->private_partner_data, $this->partnerGroup());
     }
 }
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     if ($this->getPartnerId() != Partner::BATCH_PARTNER_ID) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_FORBIDDEN, $this->serviceName . '->' . $this->actionName);
     }
     myPartnerUtils::resetAllFilters();
 }
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     myPartnerUtils::addPartnerToCriteria(new GenericDistributionProviderActionPeer(), $this->getPartnerId(), $this->private_partner_data, $this->partnerGroup());
     if (!ContentDistributionPlugin::isAllowedPartner(kCurrentContext::$master_partner_id)) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_FORBIDDEN, $this->serviceName . '->' . $this->actionName);
     }
 }
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     if (!DropFolderPlugin::isAllowedPartner($this->getPartnerId())) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_FORBIDDEN, $this->serviceName . '->' . $this->actionName);
     }
     myPartnerUtils::addPartnerToCriteria(new DropFolderPeer(), $this->getPartnerId(), $this->private_partner_data, $this->partnerGroup());
     myPartnerUtils::addPartnerToCriteria(new DropFolderFilePeer(), $this->getPartnerId(), $this->private_partner_data, $this->partnerGroup());
 }
Exemple #27
0
 /**
  * This function returns the file system path for a requested content entity.
  * this function is here to support PS2 getEntry and 2Tor which uses datapath
  * @return string the content path
  */
 public function getDataPath($version = NULL)
 {
     $url = $this->getDownloadUrl($version);
     // this is to make sure direct embeds (formerly done by going to /content/entry/data/../file.swf)
     // will still work
     $url .= '/direct_serve/1/forceproxy/true';
     $host = myPartnerUtils::getCdnHost($this->getPartnerId());
     $url = str_replace($host, '', $url);
     return $url;
 }
 public function validateForUsage($sourceObject, $propertiesToSkip = array())
 {
     parent::validateForUsage($sourceObject, $propertiesToSkip);
     $this->validatePropertyNotNull('eventNotificationTemplateId');
     myPartnerUtils::addPartnerToCriteria('EventNotificationTemplate', kCurrentContext::getCurrentPartnerId(), true);
     $eventNotificationTemplate = EventNotificationTemplatePeer::retrieveByPK($this->eventNotificationTemplateId);
     if (is_null($eventNotificationTemplate)) {
         throw new KalturaAPIException(KalturaEventNotificationErrors::EVENT_NOTIFICATION_TEMPLATE_NOT_FOUND, $this->eventNotificationTemplateId);
     }
 }
 public function initService($serviceId, $serviceName, $actionName)
 {
     parent::initService($serviceId, $serviceName, $actionName);
     if ($this->getPartnerId() != Partner::ADMIN_CONSOLE_PARTNER_ID) {
         myPartnerUtils::addPartnerToCriteria(new GenericDistributionProviderPeer(), $this->getPartnerId(), $this->private_partner_data, $this->partnerGroup());
     }
     if (!ContentDistributionPlugin::isAllowedPartner($this->getPartnerId())) {
         throw new KalturaAPIException(KalturaErrors::SERVICE_FORBIDDEN, $this->serviceName . '->' . $this->actionName);
     }
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = null;
     //myDbHelper::DB_HELPER_CONN_PROPEL3;
     $entry_id = $this->getP("entry_id");
     echo "Creating new conversion profile for entry [{$entry_id}]<br>";
     $new_conversion_profile = myPartnerUtils::getConversionProfile2ForEntry($entry_id);
     echo "result:\n" . print_r($new_conversion_profile, true . "<br>");
     die;
 }