public function fetchPage($action, $filter, $my_pager, $base_criteria = null) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; $keywords = @$_REQUEST["keywords"]; // $sort_alias is what is sent from the browser $sort_alias = $this->sort_alias != null ? $this->sort_alias : @$_REQUEST["sort"]; // $keywords_array = mySearchUtils::getKeywordsFromStr ( $keywords ); if ($base_criteria != null) { $c = $base_criteria; } else { $c = KalturaCriteria::create(entryPeer::OM_CLASS); } $filter->addSearchMatchToCriteria($c, $keywords, $this->getSearchableColumnName()); // each entity can do specific modifications to the criteria $this->modifyCriteria($c); if ($this->skip_count) { $my_pager->attachCriteria($c, $this->getPeerMethod(), $this->getPeerCountMethod()); //$res = $my_pager->fetchPage(null , true , 0); $res = $my_pager->fetchPage(null); // , true , 0); } else { $my_pager->attachCriteria($c, $this->getPeerMethod(), $this->getPeerCountMethod()); $res = $my_pager->fetchPage(); } return $res; }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; $partnerId = $this->getRequestParameter("partnerId", null); $uiConfId = $this->getRequestParameter("uiConfId", null); $page = $this->getRequestParameter("page", 1); if ($partnerId !== null && $partnerId !== "") { $pageSize = 50; $c = new Criteria(); $c->add(widgetPeer::PARTNER_ID, $partnerId); if ($uiConfId) { $c->add(widgetPeer::UI_CONF_ID, $uiConfId); } $c->addDescendingOrderByColumn(widgetPeer::CREATED_AT); $total = widgetPeer::doCount($c); $lastPage = ceil($total / $pageSize); $c->setOffset(($page - 1) * $pageSize); $c->setLimit($pageSize); $widgets = widgetPeer::doSelect($c); } else { $total = 0; $lastPage = 0; $widgets = array(); } $this->uiConfId = $uiConfId; $this->page = $page; $this->lastPage = $lastPage; $this->widgets = $widgets; $this->partner = PartnerPeer::retrieveByPK($partnerId); $this->partnerId = $partnerId; }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; //myDbHelper::DB_HELPER_CONN_PROPEL2 $uiConfId = $this->getRequestParameter("id"); $uiConf = uiConfPeer::retrieveByPK($uiConfId); $subTypes = array(uiconf::FILE_SYNC_UICONF_SUB_TYPE_DATA, uiconf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES); foreach ($subTypes as $subType) { if ($subType == uiconf::FILE_SYNC_UICONF_SUB_TYPE_DATA) { echo "Data:" . PHP_EOL; } else { if ($subType == uiconf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES) { echo "Features:" . PHP_EOL; } } $syncKey = $uiConf->getSyncKey($subType); if (kFileSyncUtils::file_exists($syncKey)) { echo "File sync already exists." . PHP_EOL; } else { list($rootPath, $filePath) = $uiConf->generateFilePathArr($subType); $fullPath = $rootPath . $filePath; if (file_exists($fullPath)) { kFileSyncUtils::createSyncFileForKey($syncKey); echo "Created successfully." . PHP_EOL; } else { echo "File not found:" . PHP_EOL; echo $fullPath . PHP_EOL; echo "Not creating file sync." . PHP_EOL; } } echo PHP_EOL; } die; }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; $go = $this->getP("go"); $filter = new ConversionProfileFilter(); $this->list = array(); $fields_set = $filter->fillObjectFromRequest($_REQUEST, "filter_", null); if ($go) { $c = new Criteria(); // filter $filter->attachToCriteria($c); //if ($order_by != -1) kshowPeer::setOrder( $c , $order_by ); $this->list = ConversionProfilePeer::doSelect($c); } $the_conv = myConversionProfileUtils::getConversionProfile($filter->get("_eq_partner_id"), $filter->get("_eq_profile_type")); $selected = false; if ($the_conv) { foreach ($this->list as &$conv) { if ($conv->getId() == $the_conv->getId()) { $selected = true; $conv->selected = true; } } } // is none was selected - need to add the_conv to the list if (!$selected && $the_conv) { $the_conv->selected = true; $this->list[] = $the_conv; } $this->filter = $filter; }
/** * List media info objects by filter and pager * * @action list * @param KalturaMediaInfoFilter $filter * @param KalturaFilterPager $pager * @return KalturaMediaInfoListResponse */ function listAction(KalturaMediaInfoFilter $filter = null, KalturaFilterPager $pager = null) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; if (!$filter) { $filter = new KalturaMediaInfoFilter(); } if (!$pager) { $pager = new KalturaFilterPager(); } $mediaInfoFilter = new MediaInfoFilter(); $filter->toObject($mediaInfoFilter); if ($filter->flavorAssetIdEqual) { // Since media_info table does not have partner_id column, enforce partner by getting the asset if (!assetPeer::retrieveById($filter->flavorAssetIdEqual)) { throw new KalturaAPIException(KalturaErrors::FLAVOR_ASSET_ID_NOT_FOUND, $filter->flavorAssetIdEqual); } } $c = new Criteria(); $mediaInfoFilter->attachToCriteria($c); $totalCount = mediaInfoPeer::doCount($c); $pager->attachToCriteria($c); $dbList = mediaInfoPeer::doSelect($c); $list = KalturaMediaInfoArray::fromDbArray($dbList, $this->getResponseProfile()); $response = new KalturaMediaInfoListResponse(); $response->objects = $list; $response->totalCount = $totalCount; return $response; }
/** * Will anipulate a single entry */ public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; $command = $this->getP("command"); if ($command == "updateEntry") { $id = $this->getP("id"); $entry = entryPeer::retrieveByPK($id); if ($entry) { $name = $this->getP("name"); $value = $this->getP("value"); $obj_wrapper = objectWrapperBase::getWrapperClass($entry, 0); $updateable_fields = $obj_wrapper->getUpdateableFields("2"); if (!in_array($name, $updateable_fields)) { die; } if ($name) { $setter = "set" . $name; call_user_func(array($entry, $setter), $value); $entry->save(); } } } die; }
/** * Will investigate a single entry */ public function execute() { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; $this->forceSystemAuthentication(); entryPeer::setUseCriteriaFilter(false); $this->result = NULL; $kshow_ids = @$_REQUEST["kshow_ids"]; $this->kshow_ids = $kshow_ids; $this->kshow = NULL; $entry_ids = @$_REQUEST["entry_ids"]; $this->entry_ids = $entry_ids; $this->entry = NULL; $this->show_entry = null; $show_entry_list = array(); if (!empty($kshow_ids)) { $ids_arr = explode(",", $kshow_ids); $kshows = kshowPeer::retrieveByPKs($ids_arr); if (!$kshows) { $this->result = "No kshows [{$kshow_ids}] in DB"; return; } foreach ($kshows as $kshow) { $show_entry = $kshow->getShowEntry(); $show_entry_list[] = $show_entry; } } else { if (empty($entry_ids)) { $this->result = "Submit an entry_id of a kshow_id to fix"; return; } $ids_arr = explode(",", $entry_ids); $entries = entryPeer::retrieveByPKs($ids_arr); if (!$entries) { $this->result = "No entries [{$entry_ids}] in DB"; return; } foreach ($entries as $entry) { if ($entry->getType() != entryType::MIX) { continue; } $show_entry_list[] = $entry; } } $fixed_data_list = array(); foreach ($show_entry_list as $show_entry) { $fix_data = new fixData(); $fix_data->show_entry = $show_entry; if ($show_entry->getType() != entryType::MIX) { $fix_data->error = "Entry is not a roughcut"; } else { $fix_data->old_content = $show_entry->getMetadata(); $fix_data->old_duration = $show_entry->getLengthInMsecs(); $fix_data->fixed_content = $show_entry->fixMetadata(false); $fix_data->fixed_duration = $show_entry->getLengthInMsecs(); } $fixed_data_list[] = $fix_data; } $this->fixed_data_list = $fixed_data_list; }
/** * Will investigate a single entry */ public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; //myDbHelper::DB_HELPER_CONN_PROPEL2; $status_list = $this->getP("status"); $mode = $this->getP("mode"); if ($mode == "old") { $preconvert = glob(myContentStorage::getFSContentRootPath() . "/content/preconvert/data/*"); $preconvert_indicators = glob(myContentStorage::getFSContentRootPath() . "/content/preconvert/files/*"); // indicators or inproc } else { $preconvert = glob(myContentStorage::getFSContentRootPath() . "/content/new_preconvert/*"); $preconvert_indicators = glob(myContentStorage::getFSContentRootPath() . "/new_content/preconvert/*.in*"); // indicators or inproc } $indicators = array(); foreach ($preconvert_indicators as $file) { $file = pathinfo($file, PATHINFO_BASENAME); $name = substr($file, 0, strpos($file, ".")); $indicators[$name] = $name; } $entry_ids = array(); foreach ($preconvert as $file) { $file = pathinfo($file, PATHINFO_BASENAME); $name = substr($file, 0, strpos($file, ".")); if (!isset($indicators[$name])) { $entry_ids[] = $name; // only those that don't have indicators } } $ids_str = "'" . implode("','", $entry_ids) . "'"; echo "<html><body style='font-family:arial; font-size:12px;'>"; echo "preconvert files: [" . count($preconvert) . "]<br>"; echo "preconvert indicators : [" . count($preconvert_indicators) . "] [" . count($indicators) . "]<br>"; echo "entry_ids: [" . count($entry_ids) . "]<br>"; if (count($entry_ids)) { if (!$status_list) { $status_list = "1"; } $connection = Propel::getConnection(); $query = "SELECT id,partner_id,status,created_at FROM entry WHERE status IN ({$status_list}) AND id IN ({$ids_str}) ORDER BY created_at ASC "; echo "query: {$query}<br>"; $statement = $connection->prepareStatement($query); $resultset = $statement->executeQuery(); echo "<table cellpadding=2 cellspacing=0 border=1 style='font-family:arial; font-size:12px;'>"; echo "<tr><td>partner_id</td><td>id</td><td>status</td><td>created_at</td></tr>"; $real_count = 0; while ($resultset->next()) { echo "<tr>" . "<td>" . $resultset->getInt('partner_id') . "</td>" . "<td>" . $resultset->getString('id') . "</td>" . "<td>" . $resultset->getInt('status') . "</td>" . "<td>" . $resultset->get('created_at') . "</td>" . "</tr>"; $real_count++; } echo "</table>"; echo "count [{$real_count}]"; $resultset->close(); } echo "</body></html>"; die; }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; $this->ok_to_save = $this->getP("oktosave"); $conv_profile_id = $this->getP("convprofile_id"); if ($conv_profile_id < 0) { $conv_profile_id = ""; } $this->message = ""; $this->display_disabled = $this->getP("display_disabled"); $command = $this->getP("command"); if ($command == "removeCache") { } elseif ($command == "save") { $conv_profile = new ConversionProfile(); $wrapper = objectWrapperBase::getWrapperClass($conv_profile, 0); $extra_fields = array("partnerId", "enabled"); // add fields that cannot be updated using the API $allowed_params = array_merge($wrapper->getUpdateableFields(), $extra_fields); $fields_modified = baseObjectUtils::fillObjectFromMap($_REQUEST, $conv_profile, "convprofile_", $allowed_params, BasePeer::TYPE_PHPNAME, true); if ($conv_profile_id) { $conv_profile_from_db = ConversionProfilePeer::retrieveByPK($conv_profile_id); if ($conv_profile_from_db) { baseObjectUtils::fillObjectFromObject($allowed_params, $conv_profile, $conv_profile_from_db, baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME, true); } $conv_profile_from_db->save(); } else { $conv_profile->save(); $conv_profile_id = $conv_profile->getId(); } } $this->conv_profile = ConversionProfilePeer::retrieveByPK($conv_profile_id); $this->conv_profile_id = $conv_profile_id; if ($this->conv_profile) { $this->conv_profile_type = $this->conv_profile->getProfileType(); $this->fallback_mode = array(); $this->conv_params_list = ConversionParamsPeer::retrieveByConversionProfile($this->conv_profile, $this->fallback_mode, false); // to see if there are any disabled params - call again with true $tmp_fallback = array(); $tmp_conv_params_list = ConversionParamsPeer::retrieveByConversionProfile($this->conv_profile, $tmp_fallback, true); if ($tmp_fallback["mode"] == $this->fallback_mode["mode"]) { $this->fallback_mode = $tmp_fallback; $this->conv_params_list = $tmp_conv_params_list; } else { if ($this->display_disabled) { $this->fallback_mode = $tmp_fallback; $this->conv_params_list = $tmp_conv_params_list; $this->message = "This display is missleading due to [dispaly disabled=true]<br>It shows params that are disabled for this profile and WOULD NOT be used at run-time"; } } } else { $this->conv_profile_type = null; $this->conv_params_list = null; } }
public function __construct($feedId) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $microTimeStart = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialize "); // initialize the database for all services DbManager::setConfig(kConf::getDB()); DbManager::initialize(); $this->syndicationFeedDB = $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId); if (!$syndicationFeedDB) { throw new Exception("Feed Id not found"); } kEntitlementUtils::initEntitlementEnforcement($syndicationFeedDB->getPartnerId(), $syndicationFeedDB->getEnforceEntitlement()); if (!is_null($syndicationFeedDB->getPrivacyContext()) && $syndicationFeedDB->getPrivacyContext() != '') { kEntitlementUtils::setPrivacyContextSearch($syndicationFeedDB->getPrivacyContext()); } $tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType()); $tmpSyndicationFeed->fromObject($syndicationFeedDB); $this->syndicationFeed = $tmpSyndicationFeed; // add partner to default criteria categoryPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true); assetPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true); entryPeer::setDefaultCriteriaFilter(); $this->baseCriteria = entryPeer::getDefaultCriteriaFilter(); $startDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::START_DATE, time(), Criteria::LESS_EQUAL); $startDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::START_DATE, null)); $this->baseCriteria->addAnd($startDateCriterion); $endDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::END_DATE, time(), Criteria::GREATER_EQUAL); $endDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::END_DATE, null)); $this->baseCriteria->addAnd($endDateCriterion); $entryFilter = new entryFilter(); $entryFilter->setPartnerSearchScope($this->syndicationFeed->partnerId); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setTypeIn(array(entryType::MEDIA_CLIP, entryType::MIX)); $entryFilter->setModerationStatusNotIn(array(entry::ENTRY_MODERATION_STATUS_REJECTED, entry::ENTRY_MODERATION_STATUS_PENDING_MODERATION)); $entryFilter->attachToCriteria($this->baseCriteria); if ($this->syndicationFeed->playlistId) { $this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId); foreach ($this->entryFilters as $entryFilter) { $entryFilter->setPartnerSearchScope(baseObjectFilter::MATCH_KALTURA_NETWORK_AND_PRIVATE); // partner scope already attached } $playlist = entryPeer::retrieveByPK($this->syndicationFeed->playlistId); if ($playlist) { if ($playlist->getMediaType() != entry::ENTRY_MEDIA_TYPE_XML) { $this->staticPlaylist = true; $this->staticPlaylistEntriesIdsOrder = explode(',', $playlist->getDataContent()); } } } else { $this->entryFilters = array(); } $microTimeEnd = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]"); }
protected function forceSystemAuthentication() { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $kal_sys_auth = @$_COOKIE[self::COOKIE_NAME]; if ($kal_sys_auth == $this->authKey()) { return true; } $this->setFlash('sign_in_referer', $_SERVER["REQUEST_URI"]); //echo "forceSystemAuthentication - false"; return $this->forward('system', 'login'); }
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; }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser, $create_cachekey = false) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; // TODO - verify permissions for viewing lists $detailed = $this->getP("detailed", false); $limit = $this->getP("page_size", 10); $limit = $this->maxPageSize($limit); $page = $this->getP("page", 1); $user_filter_prefix = $this->getP("fp", "filter"); $offset = ($page - 1) * $limit; // TODO - should limit search to partner ?? // kuserPeer::setUseCriteriaFilter( false ); // entryPeer::setUseCriteriaFilter( false ); $playlist_id = $this->getPM("playlist_id"); $input_params = $this->getInputParams(); $extra_filters = array(); for ($i = 1; $i < self::MAX_FILTER_COUNT; $i++) { // filter $extra_filter = new entryFilter(); $fields_set = $extra_filter->fillObjectFromRequest($input_params, "{$user_filter_prefix}{$i}_", null); if ($fields_set) { $extra_filters[$i] = $extra_filter; } } // this service is executed twice! (first time for the cache key, second time for the execution) if (is_null($this->playlist)) { $playlist = entryPeer::retrieveByPK($playlist_id); if (!$playlist) { throw new APIException(APIErrors::INVALID_ENTRY_ID, "Playlist", $playlist_id); } myPartnerUtils::addPartnerToCriteria(new accessControlPeer(), $playlist->getPartnerId(), $this->getPrivatePartnerData(), $this->partnerGroup2(), null); $this->playlist = $playlist; } if ($create_cachekey) { if ($this->isAdmin()) { return null; } $cache_key_arr = array("playlist_id" => $playlist_id, "filters" => $extra_filters); $cahce_key = new executionCacheKey(); $cahce_key->expiry = 600; $cahce_key->key = md5(print_r($cache_key_arr, true)); return $cahce_key; } if ($this->isAdmin()) { myPlaylistUtils::setIsAdminKs(true); } $entry_list = myPlaylistUtils::executePlaylistById($partner_id, $playlist_id, $extra_filters, $detailed); myEntryUtils::updatePuserIdsForEntries($entry_list); $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $wrapper = objectWrapperBase::getWrapperClass($entry_list, $level); $this->addMsg("count", count($entry_list)); $this->addMsg($this->getObjectPrefix(), $wrapper); }
protected function doGetListResponse(KalturaFilterPager $pager, array $types = null) { $this->validateEntryIdFiltered(); myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; // verify access to the relevant entries - either same partner as the KS or kaltura network if ($this->entryIdEqual) { $entryIds = array($this->entryIdEqual); } else { if ($this->entryIdIn) { $entryIds = explode(',', $this->entryIdIn); } else { throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn'); } } $entryIds = array_slice($entryIds, 0, baseObjectFilter::getMaxInValues()); $c = KalturaCriteria::create(entryPeer::OM_CLASS); $c->addAnd(entryPeer::ID, $entryIds, Criteria::IN); $criterionPartnerOrKn = $c->getNewCriterion(entryPeer::PARTNER_ID, kCurrentContext::getCurrentPartnerId()); $criterionPartnerOrKn->addOr($c->getNewCriterion(entryPeer::DISPLAY_IN_SEARCH, mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK)); $c->addAnd($criterionPartnerOrKn); $dbEntries = entryPeer::doSelect($c); if (!$dbEntries) { return array(array(), 0); } $entryIds = array(); foreach ($dbEntries as $dbEntry) { $entryIds[] = $dbEntry->getId(); } $this->entryIdEqual = null; $this->entryIdIn = implode(',', $entryIds); // get the flavors $flavorAssetFilter = new AssetFilter(); $this->toObject($flavorAssetFilter); $c = new Criteria(); $flavorAssetFilter->attachToCriteria($c); if ($types) { $c->add(assetPeer::TYPE, $types, Criteria::IN); } $pager->attachToCriteria($c); $list = assetPeer::doSelect($c); $resultCount = count($list); if ($resultCount && $resultCount < $pager->pageSize) { $totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount; } else { KalturaFilterPager::detachFromCriteria($c); $totalCount = assetPeer::doCount($c); } myDbHelper::$use_alternative_con = null; return array($list, $totalCount); }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; $partnerId = $this->getRequestParameter("partnerId", null); if ($partnerId !== null) { $partnerId = (int) $partnerId; } $c = new Criteria(); $c->add(uiConfPeer::PARTNER_ID, $partnerId); $c->addDescendingOrderByColumn(uiConfPeer::CREATED_AT); $this->uiconfs = uiConfPeer::doSelect($c); $partner = PartnerPeer::retrieveByPK($partnerId); $this->partner = $partner; $this->partnerId = $partnerId; }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser, $create_cachekey = false) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; // TODO - verify permissions for viewing lists $detailed = $this->getP("detailed", false); if (!$detailed) { $detailed = false; } $playlist_id = $this->getPM("playlist_id"); if ($create_cachekey) { if ($this->isAdmin()) { return null; } $ks_partner_id = null; $privileges = null; $ks = ks::fromSecureString(kCurrentContext::$ks); if ($ks) { $ks_partner_id = $ks->getPartnerId(); $privileges = $ks->getPrivileges(); } $cache_key_arr = array("playlist_id" => $playlist_id, "partner_id" => $partner_id, "ks_partner_id" => $ks_partner_id, "detailed" => $detailed, "user" => kCurrentContext::$ks_uid, "privileges" => $privileges, "is_admin" => $this->isAdmin(), "protocol" => infraRequestUtils::getProtocol()); $cahce_key = new executionCacheKey(); $cahce_key->expiry = 600; $cahce_key->key = md5(print_r($cache_key_arr, true)); return $cahce_key; } // this service is executed twice! (first time for the cache key, second time for the execution) if (is_null($this->playlist)) { $playlist = entryPeer::retrieveByPK($playlist_id); if (!$playlist) { throw new APIException(APIErrors::INVALID_ENTRY_ID, "Playlist", $playlist_id); } myPartnerUtils::addPartnerToCriteria('accessControl', $playlist->getPartnerId(), $this->getPrivatePartnerData(), $this->partnerGroup2(), null); $this->playlist = $playlist; } if ($this->isAdmin()) { myPlaylistUtils::setIsAdminKs(true); } $entry_list = myPlaylistUtils::executePlaylistById($partner_id, $playlist_id, null, $detailed); myEntryUtils::updatePuserIdsForEntries($entry_list); $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $wrapper = objectWrapperBase::getWrapperClass($entry_list, $level); $this->addMsg("count", count($entry_list)); $this->addMsg($this->getObjectPrefix(), $wrapper); }
public function getListResponse(KalturaFilterPager $pager, KalturaDetachedResponseProfile $responseProfile = null) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; $c = new Criteria(); $c->add(kvotePeer::PARTNER_ID, kCurrentContext::$ks_partner_id); if ($this->entryIdEqual) { $c->add(kvotePeer::ENTRY_ID, $this->entryIdEqual); } if ($this->userIdEqual) { $c->add(kvotePeer::PUSER_ID, $this->userIdEqual); } $pager->attachToCriteria($c); $list = kvotePeer::doSelect($c); $response = new KalturaLikeListResponse(); $response->objects = KalturaLikeArray::fromDbArray($list, $responseProfile); $response->totalCount = count($list); return $response; }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; //myDbHelper::DB_HELPER_CONN_PROPEL2 $this->partner_error = null; if (isset($_POST['partnerId']) && $_POST['partnerId'] !== null && $_POST['partnerId'] !== '') { $partner = PartnerPeer::retrieveByPK($_POST['partnerId']); if ($partner) { $uiConf = new uiConf(); $uiConf->setPartnerId($_POST['partnerId']); $uiConf->setCreationMode(uiConf::UI_CONF_CREATION_MODE_ADVANCED); $uiConf->save(); $this->redirect("system/editUiconf?id=" . $uiConf->getId()); } else { $this->partner_error = 'Partner ID ' . $_POST['partnerId'] . ' not found !'; } } }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; //myDbHelper::DB_HELPER_CONN_PROPEL2 $this->saved = false; $uiConfId = $this->getRequestParameter("id"); $this->uiConf = uiConfPeer::retrieveByPK($uiConfId); if ($this->uiConf->getObjType() != uiConf::UI_CONF_TYPE_CW) { die("Not a CW UIConf!"); } if ($this->uiConf->getCreationMode() != uiConf::UI_CONF_CREATION_MODE_ADVANCED) { die("Creation mode must be advanced!"); } if ($this->getRequest()->getMethodName() == "POST") { $this->uiConf->setConfFile($this->getRequestParameter("confFile")); $this->uiConf->save(); $this->redirect("system/editUiconf?id=" . $this->uiConf->getId()); } }
public function __construct($feedId) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $microTimeStart = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialize "); // initialize the database for all services DbManager::setConfig(kConf::getDB()); DbManager::initialize(); $syndicationFeedDB = syndicationFeedPeer::retrieveByPK($feedId); if (!$syndicationFeedDB) { throw new Exception("Feed Id not found"); } $tmpSyndicationFeed = KalturaSyndicationFeedFactory::getInstanceByType($syndicationFeedDB->getType()); $tmpSyndicationFeed->fromObject($syndicationFeedDB); $this->syndicationFeed = $tmpSyndicationFeed; // add partner to default criteria categoryPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true); flavorAssetPeer::addPartnerToCriteria($this->syndicationFeed->partnerId, true); $this->baseCriteria = KalturaCriteria::create(entryPeer::OM_CLASS); $startDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::START_DATE, time(), Criteria::LESS_EQUAL); $startDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::START_DATE, null)); $this->baseCriteria->addAnd($startDateCriterion); $endDateCriterion = $this->baseCriteria->getNewCriterion(entryPeer::END_DATE, time(), Criteria::GREATER_EQUAL); $endDateCriterion->addOr($this->baseCriteria->getNewCriterion(entryPeer::END_DATE, null)); $this->baseCriteria->addAnd($endDateCriterion); $entryFilter = new entryFilter(); $entryFilter->setPartnerSearchScope($this->syndicationFeed->partnerId); $entryFilter->setStatusEquel(entryStatus::READY); $entryFilter->setTypeIn(array(entryType::MEDIA_CLIP, entryType::MIX)); $entryFilter->setModerationStatusNot(entry::ENTRY_MODERATION_STATUS_REJECTED); $entryFilter->setDurationGreaterThan(0); $entryFilter->attachToCriteria($this->baseCriteria); if ($this->syndicationFeed->playlistId) { $this->entryFilters = myPlaylistUtils::getPlaylistFiltersById($this->syndicationFeed->playlistId); } else { $this->entryFilters = array(); } $microTimeEnd = microtime(true); KalturaLog::info("syndicationFeedRenderer- initialization done [" . ($microTimeEnd - $microTimeStart) . "]"); }
protected function doGetListResponse(KalturaFilterPager $pager, array $types = null) { $this->validateEntryIdFiltered(); myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; // verify access to the relevant entries - either same partner as the KS or kaltura network if ($this->entryIdEqual) { $entryIds = array($this->entryIdEqual); } else { if ($this->entryIdIn) { $entryIds = explode(',', $this->entryIdIn); } else { throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_CANNOT_BE_NULL, 'KalturaAssetFilter::entryIdEqual/KalturaAssetFilter::entryIdIn'); } } $entryIds = entryPeer::filterEntriesByPartnerOrKalturaNetwork($entryIds, kCurrentContext::getCurrentPartnerId()); if (!$entryIds) { return array(array(), 0); } $this->entryIdEqual = null; $this->entryIdIn = implode(',', $entryIds); // get the flavors $flavorAssetFilter = new AssetFilter(); $this->toObject($flavorAssetFilter); $c = new Criteria(); $flavorAssetFilter->attachToCriteria($c); if ($types) { $c->add(assetPeer::TYPE, $types, Criteria::IN); } $pager->attachToCriteria($c); $list = assetPeer::doSelect($c); $resultCount = count($list); if ($resultCount && $resultCount < $pager->pageSize) { $totalCount = ($pager->pageIndex - 1) * $pager->pageSize + $resultCount; } else { KalturaFilterPager::detachFromCriteria($c); $totalCount = assetPeer::doCount($c); } myDbHelper::$use_alternative_con = null; return array($list, $totalCount); }
public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $entry_ids = str_replace(" ", "", $this->getPM("entry_ids")); $detailed = $this->getP("detailed", false); $separator = $this->getP("separator", ","); $id_arr = explode($separator, $entry_ids); $limit = 50; $id_arr = array_splice($id_arr, 0, $limit); $entries = entryPeer::retrieveByPKs($id_arr); if (!$entries) { $this->addError(APIErrors::INVALID_ENTRY_IDS, $entry_ids); } else { $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR; $extra_fields = $this->getExtraFields(); if ($extra_fields) { $this->addMsg("entries", objectWrapperBase::getWrapperClass($entries, $level, objectWrapperBase::DETAIL_VELOCITY_DEFAULT, 0, $extra_fields)); } else { $this->addMsg("entries", objectWrapperBase::getWrapperClass($entries, $level)); } } }
/** * Will reconvert an entry - should infact move to some utility function */ public function execute() { ini_set("max_execution_time", 480); $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; //myDbHelper::DB_HELPER_CONN_PROPEL2; $this->conversion_profile_id = null; $entry_ids = trim($this->getP("entry_ids")); $this->priority = trim($this->getP("priority", 3)); $this->entry_ids = $entry_ids; $this->dbBatchJob = null; $result = array(); $entry_id_arr = preg_split("/[, \n]/", $entry_ids); foreach ($entry_id_arr as $entry_id) { if (!trim($entry_id)) { continue; } $result[] = $this->reconvertEntry(trim($entry_id), $this->conversion_profile_id, $this->priority); // $result[] = array ( $entry_id , null , null , "err" . $entry_id ); } $this->entry_ids = $entry_ids; $this->result = $result; }
/** * Retrieve a list of available UIConfs with no partner limitation * * @action list * @param KalturaUiConfFilter $filter * @param KalturaFilterPager $pager * @return KalturaUiConfAdminListResponse */ function listAction(KalturaUiConfFilter $filter = null, KalturaFilterPager $pager = null) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; if (!$filter) { $filter = new KalturaUiConfFilter(); } $uiConfFilter = new uiConfFilter(); $filter->toObject($uiConfFilter); $c = new Criteria(); $uiConfFilter->attachToCriteria($c); $count = uiConfPeer::doCount($c); if ($pager) { $pager->attachToCriteria($c); } $list = uiConfPeer::doSelect($c); $newList = KalturaUiConfAdminArray::fromUiConfAdminArray($list); $response = new KalturaUiConfAdminListResponse(); $response->objects = $newList; $response->totalCount = $count; return $response; }
/** * Will forward to the regular swf player according to the widget_id */ public function execute() { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; requestUtils::handleConditionalGet(); ignore_user_abort(); $entry_id = $this->getRequestParameter("entry_id"); $widget_id = $this->getRequestParameter("widget_id", 0); $upload_token_id = $this->getRequestParameter("upload_token_id"); $version = $this->getIntRequestParameter("version", null, 0, 10000000); $type = $this->getIntRequestParameter("type", 1, 1, 5); //Hack: if KMS sends thumbnail request containing "!" char, the type should be treated as 5. $width = $this->getRequestParameter("width", -1); $height = $this->getRequestParameter("height", -1); if (strpos($width, "!") || strpos($height, "!")) { $type = 5; } $width = $this->getFloatRequestParameter("width", -1, -1, 10000); $height = $this->getFloatRequestParameter("height", -1, -1, 10000); $crop_provider = $this->getRequestParameter("crop_provider", null); $quality = $this->getIntRequestParameter("quality", 0, 0, 100); $src_x = $this->getFloatRequestParameter("src_x", 0, 0, 10000); $src_y = $this->getFloatRequestParameter("src_y", 0, 0, 10000); $src_w = $this->getFloatRequestParameter("src_w", 0, 0, 10000); $src_h = $this->getFloatRequestParameter("src_h", 0, 0, 10000); $vid_sec = $this->getFloatRequestParameter("vid_sec", -1, -1); $vid_slice = $this->getRequestParameter("vid_slice", -1); $vid_slices = $this->getRequestParameter("vid_slices", -1); $density = $this->getFloatRequestParameter("density", 0, 0); $stripProfiles = $this->getRequestParameter("strip", null); $flavor_id = $this->getRequestParameter("flavor_id", null); $file_name = $this->getRequestParameter("file_name", null); $file_name = basename($file_name); // actual width and height of image from which the src_* values were taken. // these will be used to multiply the src_* parameters to make them relate to the original image size. $rel_width = $this->getFloatRequestParameter("rel_width", -1, -1, 10000); $rel_height = $this->getFloatRequestParameter("rel_height", -1, -1, 10000); if ($width == -1 && $height == -1) { $width = 120; $height = 90; } else { if ($width == -1) { // if only either width or height is missing reset them to zero, and convertImage will handle them $width = 0; } else { if ($height == -1) { $height = 0; } } } $bgcolor = $this->getRequestParameter("bgcolor", "ffffff"); $partner = null; // validating the inputs if (!is_numeric($quality) || $quality < 0 || $quality > 100) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'quality must be between 20 and 100'); } if (!is_numeric($src_x) || $src_x < 0 || $src_x > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_x must be between 0 and 10000'); } if (!is_numeric($src_y) || $src_y < 0 || $src_y > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_y must be between 0 and 10000'); } if (!is_numeric($src_w) || $src_w < 0 || $src_w > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_w must be between 0 and 10000'); } if (!is_numeric($src_h) || $src_h < 0 || $src_h > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'src_h must be between 0 and 10000'); } if (!is_numeric($width) || $width < 0 || $width > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'width must be between 0 and 10000'); } if (!is_numeric($height) || $height < 0 || $height > 10000) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'height must be between 0 and 10000'); } if (!is_numeric($density) || $density < 0) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'density must be positive'); } if (!is_numeric($vid_sec) || $vid_sec < -1) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'vid_sec must be positive'); } if (!preg_match('/^[0-9a-fA-F]{1,6}$/', $bgcolor)) { KExternalErrors::dieError(KExternalErrors::BAD_QUERY, 'bgcolor must be six hexadecimal characters'); } if ($upload_token_id) { $upload_token = UploadTokenPeer::retrieveByPK($upload_token_id); if ($upload_token) { $partnerId = $upload_token->getPartnerId(); $partner = PartnerPeer::retrieveByPK($partnerId); if ($density == 0) { $density = $partner->getDefThumbDensity(); } if (is_null($stripProfiles)) { $stripProfiles = $partner->getStripThumbProfile(); } $thumb_full_path = myContentStorage::getFSCacheRootPath() . myContentStorage::getGeneralEntityPath("uploadtokenthumb", $upload_token->getIntId(), $upload_token->getId(), $upload_token->getId() . ".jpg"); kFile::fullMkdir($thumb_full_path); if (file_exists($upload_token->getUploadTempPath())) { $src_full_path = $upload_token->getUploadTempPath(); $valid_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP); $image_type = exif_imagetype($src_full_path); if (!in_array($image_type, $valid_image_types)) { // capture full frame myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 3); if (!file_exists($thumb_full_path)) { myFileConverter::captureFrame($src_full_path, $thumb_full_path, 1, "image2", -1, -1, 0); } $src_full_path = $thumb_full_path; } // and resize it myFileConverter::convertImage($src_full_path, $thumb_full_path, $width, $height, $type, $bgcolor, true, $quality, $src_x, $src_y, $src_w, $src_h, $density, $stripProfiles); kFile::dumpFile($thumb_full_path); } else { KalturaLog::debug("token_id [{$upload_token_id}] not found in DC [" . kDataCenterMgr::getCurrentDcId() . "]. dump url to romote DC"); $remoteUrl = kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId()) . $_SERVER['REQUEST_URI']; kFile::dumpUrl($remoteUrl); } } } if ($entry_id) { $entry = entryPeer::retrieveByPKNoFilter($entry_id); if (!$entry) { // problem could be due to replication lag kFile::dumpApiRequest(kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId())); } } else { // get the widget $widget = widgetPeer::retrieveByPK($widget_id); if (!$widget) { KExternalErrors::dieError(KExternalErrors::ENTRY_AND_WIDGET_NOT_FOUND); } // get the kshow $kshow_id = $widget->getKshowId(); $kshow = kshowPeer::retrieveByPK($kshow_id); if ($kshow) { $entry_id = $kshow->getShowEntryId(); } else { $entry_id = $widget->getEntryId(); } $entry = entryPeer::retrieveByPKNoFilter($entry_id); if (!$entry) { KExternalErrors::dieError(KExternalErrors::ENTRY_NOT_FOUND); } } $partner = $entry->getPartner(); if ($density == 0) { $density = $partner->getDefThumbDensity(); } $thumbParams = new kThumbnailParameters(); $thumbParams->setSupportAnimatedThumbnail($partner->getSupportAnimatedThumbnails()); if (is_null($stripProfiles)) { $stripProfiles = $partner->getStripThumbProfile(); } //checks whether the thumbnail display should be restricted by KS $base64Referrer = $this->getRequestParameter("referrer"); $referrer = base64_decode($base64Referrer); if (!is_string($referrer)) { $referrer = ""; } // base64_decode can return binary data if (!$referrer) { $referrer = kApiCache::getHttpReferrer(); } $ksStr = $this->getRequestParameter("ks"); $securyEntryHelper = new KSecureEntryHelper($entry, $ksStr, $referrer, accessControlContextType::THUMBNAIL); $securyEntryHelper->validateForPlay(); // multiply the passed $src_* values so that they will relate to the original image size, according to $src_display_* if ($rel_width != -1) { $widthRatio = $entry->getWidth() / $rel_width; $src_x = $src_x * $widthRatio; $src_w = $src_w * $widthRatio; } if ($rel_height != -1) { $heightRatio = $entry->getHeight() / $rel_height; $src_y = $src_y * $heightRatio; $src_h = $src_h * $heightRatio; } $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB; if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) { $subType = entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA; } KalturaLog::debug("get thumbnail filesyncs"); $dataKey = $entry->getSyncKey($subType); list($file_sync, $local) = kFileSyncUtils::getReadyFileSyncForKey($dataKey, true, false); $tempThumbPath = null; $entry_status = $entry->getStatus(); // both 640x480 and 0x0 requests are probably coming from the kdp // 640x480 - old kdp version requesting thumbnail // 0x0 - new kdp version requesting the thumbnail of an unready entry // we need to distinguish between calls from the kdp and calls from a browser: <img src=...> // that can't handle swf input if (($width == 640 && $height == 480 || $width == 0 && $height == 0) && ($entry_status == entryStatus::PRECONVERT || $entry_status == entryStatus::IMPORT || $entry_status == entryStatus::ERROR_CONVERTING || $entry_status == entryStatus::DELETED)) { $contentPath = myContentStorage::getFSContentRootPath(); $msgPath = $contentPath . "content/templates/entry/bigthumbnail/"; if ($entry_status == entryStatus::DELETED) { $msgPath .= $entry->getModerationStatus() == moderation::MODERATION_STATUS_BLOCK ? "entry_blocked.swf" : "entry_deleted.swf"; } else { $msgPath .= $entry_status == entryStatus::ERROR_CONVERTING ? "entry_error.swf" : "entry_converting.swf"; } kFile::dumpFile($msgPath, null, 0); } if (!$file_sync) { $tempThumbPath = $entry->getLocalThumbFilePath($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, $density, $stripProfiles, $flavor_id, $file_name); if (!$tempThumbPath) { KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } } if (!$local && !$tempThumbPath && $file_sync) { if (!in_array($file_sync->getDc(), kDataCenterMgr::getDcIds())) { $remoteUrl = $file_sync->getExternalUrl($entry->getId()); header("Location: {$remoteUrl}"); die; } $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($file_sync, $_SERVER['REQUEST_URI']); kFile::dumpUrl($remoteUrl); } // if we didnt return a template for the player die and dont return the original deleted thumb if ($entry_status == entryStatus::DELETED) { KExternalErrors::dieError(KExternalErrors::ENTRY_DELETED_MODERATED); } if (!$tempThumbPath) { try { $tempThumbPath = myEntryUtils::resizeEntryImage($entry, $version, $width, $height, $type, $bgcolor, $crop_provider, $quality, $src_x, $src_y, $src_w, $src_h, $vid_sec, $vid_slice, $vid_slices, null, $density, $stripProfiles, $thumbParams); } catch (Exception $ex) { if ($ex->getCode() != kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC) { KalturaLog::log("Error - resize image failed"); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } // get original flavor asset $origFlavorAsset = assetPeer::retrieveOriginalByEntryId($entry_id); if (!$origFlavorAsset) { KalturaLog::log("Error - no original flavor for entry [{$entry_id}]"); KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } $syncKey = $origFlavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $remoteFileSync = kFileSyncUtils::getOriginFileSyncForKey($syncKey, false); if (!$remoteFileSync) { // file does not exist on any DC - die KalturaLog::log("Error - no FileSync for entry [{$entry_id}]"); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } if ($remoteFileSync->getDc() == kDataCenterMgr::getCurrentDcId()) { KalturaLog::log("ERROR - Trying to redirect to myself - stop here."); KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } if (!in_array($remoteFileSync->getDc(), kDataCenterMgr::getDcIds())) { KExternalErrors::dieError(KExternalErrors::MISSING_THUMBNAIL_FILESYNC); } $remoteUrl = kDataCenterMgr::getRedirectExternalUrl($remoteFileSync); kFile::dumpUrl($remoteUrl); } } $nocache = strpos($tempThumbPath, "_NOCACHE_") !== false; if ($securyEntryHelper->shouldDisableCache() || kApiCache::hasExtraFields() || !$securyEntryHelper->isKsWidget() && $securyEntryHelper->hasRules()) { $nocache = true; } // notify external proxy, so it'll cache this url if (!$nocache && requestUtils::getHost() == kConf::get("apphome_url") && file_exists($tempThumbPath)) { self::notifyProxy($_SERVER["REQUEST_URI"]); } // cache result if (!$nocache) { $requestKey = $_SERVER["REQUEST_URI"]; $cache = new myCache("thumb", 86400 * 30); // 30 days $cache->put($requestKey, $tempThumbPath); } kFile::dumpFile($tempThumbPath, null, $nocache ? 0 : null); // TODO - can delete from disk assuming we caneasily recreate it and it will anyway be cached in the CDN // however dumpfile dies at the end so we cant just write it here (maybe register a shutdown callback) }
protected function doGetListResponse(KalturaFilterPager $pager) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL3; $disableWidgetSessionFilters = false; if ($this && ($this->idEqual != null || $this->idIn != null || $this->referenceIdEqual != null || $this->redirectFromEntryId != null || $this->referenceIdIn != null || $this->parentEntryIdEqual != null)) { $disableWidgetSessionFilters = true; } $c = $this->prepareEntriesCriteriaFilter($pager); if ($disableWidgetSessionFilters) { KalturaCriterion::disableTag(KalturaCriterion::TAG_WIDGET_SESSION); } $list = entryPeer::doSelect($c); $totalCount = $c->getRecordsCount(); if ($disableWidgetSessionFilters) { KalturaCriterion::restoreTag(KalturaCriterion::TAG_WIDGET_SESSION); } myDbHelper::$use_alternative_con = null; return array($list, $totalCount); }
public function execute() { $this->forceSystemAuthentication(); $this->pid = $this->getRequestParameter("pid", 0); if (!is_null($this->getRequestParameter("advanced"))) { $this->getResponse()->setCookie('flavor-params-advanced', $this->getRequestParameter("advanced")); $this->advanced = (int) $this->getRequestParameter("advanced"); } else { $this->advanced = (int) $this->getRequest()->getCookie('flavor-params-advanced'); } myDbHelper::$use_alternative_con = null; $this->editFlavorParam = null; $this->editFlavorParam = assetParamsPeer::retrieveByPK($this->getRequestParameter("id")); if ($this->getRequestParameter("clone")) { $newFalvorParams = $this->editFlavorParam->copy(); $newFalvorParams->setSourceAssetParamsIds($this->editFlavorParam->getSourceAssetParamsIds()); $newFalvorParams->setAspectRatioProcessingMode($this->editFlavorParam->getAspectRatioProcessingMode()); $newFalvorParams->setForceFrameToMultiplication16($this->editFlavorParam->getForceFrameToMultiplication16()); $newFalvorParams->setIsGopInSec($this->editFlavorParam->getIsGopInSec()); $newFalvorParams->setIsAvoidVideoShrinkFramesizeToSource($this->editFlavorParam->getIsAvoidVideoShrinkFramesizeToSource()); $newFalvorParams->setIsAvoidVideoShrinkBitrateToSource($this->editFlavorParam->getIsAvoidVideoShrinkBitrateToSource()); $newFalvorParams->setIsVideoFrameRateForLowBrAppleHls($this->editFlavorParam->getIsVideoFrameRateForLowBrAppleHls()); $newFalvorParams->setIsAvoidForcedKeyFrames($this->editFlavorParam->getIsAvoidForcedKeyFrames()); $newFalvorParams->setMultiStream($this->editFlavorParam->getMultiStream()); $newFalvorParams->setAnamorphicPixels($this->editFlavorParam->getAnamorphicPixels()); $newFalvorParams->setMaxFrameRate($this->editFlavorParam->getMaxFrameRate()); $newFalvorParams->setWatermarkData($this->editFlavorParam->getWatermarkData()); $newFalvorParams->setIsDefault(false); $newFalvorParams->setPartnerId(-1); $newFalvorParams->save(); $this->redirect("system/flavorParams?pid=" . $this->pid . "&id=" . $newFalvorParams->getId()); } if ($this->getRequestParameter("delete")) { if ($this->advanced || $this->editFlavorParam->getPartnerId() != 0) { $this->editFlavorParam->setDeletedAt(time()); $this->editFlavorParam->save(); } $this->redirect("system/flavorParams?pid=" . $this->pid); } if ($this->getRequest()->getMethod() == sfRequest::POST) { if ($this->advanced || $this->editFlavorParam->getPartnerId() != 0) { $partnerId = $this->getRequestParameter("partner-id"); if ($this->advanced) { $this->editFlavorParam->setPartnerId($partnerId); } else { if ($partnerId != 0) { $this->editFlavorParam->setPartnerId($partnerId); } } if ($this->advanced >= 1) { $this->editFlavorParam->setName($this->getRequestParameter("name")); $this->editFlavorParam->setSystemName($this->getRequestParameter("systemName")); $this->editFlavorParam->setDescription($this->getRequestParameter("description")); $this->editFlavorParam->setIsDefault($this->getRequestParameter("is-default", false)); $this->editFlavorParam->setReadyBehavior($this->getRequestParameter("ready-behavior")); $this->editFlavorParam->setTags($this->getRequestParameter("tags")); $this->editFlavorParam->setSourceAssetParamsIds($this->getRequestParameter("sourceAssetParamsIds")); $this->editFlavorParam->setFormat($this->getRequestParameter("format")); $this->editFlavorParam->setTwoPass($this->getRequestParameter("two-pass", false)); $this->editFlavorParam->setRotate($this->getRequestParameter("rotate", false)); $this->editFlavorParam->setAspectRatioProcessingMode($this->getRequestParameter("aspectRatioProcessingMode", 0)); $this->editFlavorParam->setIsGopInSec($this->getRequestParameter("isGopInSec", 0)); $this->editFlavorParam->setForceFrameToMultiplication16($this->getRequestParameter("forceFrameToMultiplication16") ? "1" : "0"); $this->editFlavorParam->setIsAvoidVideoShrinkFramesizeToSource($this->getRequestParameter("isAvoidVideoShrinkFramesizeToSource", 0)); $this->editFlavorParam->setIsAvoidVideoShrinkBitrateToSource($this->getRequestParameter("isAvoidVideoShrinkBitrateToSource", 0)); $this->editFlavorParam->setIsVideoFrameRateForLowBrAppleHls($this->getRequestParameter("isVideoFrameRateForLowBrAppleHls", 0)); $this->editFlavorParam->setIsAvoidForcedKeyFrames($this->getRequestParameter("isAvoidForcedKeyFrames", 0)); $this->editFlavorParam->setMultiStream($this->getRequestParameter("multiStream", 0)); $this->editFlavorParam->setAnamorphicPixels($this->getRequestParameter("anamorphicPixels", 0)); $this->editFlavorParam->setWidth($this->getRequestParameter("width")); $this->editFlavorParam->setHeight($this->getRequestParameter("height")); $this->editFlavorParam->setVideoCodec($this->getRequestParameter("video-codec")); $this->editFlavorParam->setVideoBitrate($this->getRequestParameter("video-bitrate")); $this->editFlavorParam->setWatermarkData($this->getRequestParameter("watermarkData", 0)); $this->editFlavorParam->setFrameRate($this->getRequestParameter("frame-rate")); $this->editFlavorParam->setMaxFrameRate($this->getRequestParameter("max-frame-rate")); $this->editFlavorParam->setGopSize($this->getRequestParameter("gop-size")); $this->editFlavorParam->setAudioCodec($this->getRequestParameter("audio-codec")); $this->editFlavorParam->setAudioBitrate($this->getRequestParameter("audio-bitrate")); $this->editFlavorParam->setAudioChannels($this->getRequestParameter("audio-channels")); $this->editFlavorParam->setAudioSampleRate($this->getRequestParameter("audio-sample-rate")); $this->editFlavorParam->setAudioResolution($this->getRequestParameter("audio-resolution")); $this->editFlavorParam->setConversionEngines($this->getRequestParameter("conversion-engines")); $this->editFlavorParam->setConversionEnginesExtraParams($this->getRequestParameter("conversion-engines-extra-params")); $this->editFlavorParam->setOperators($this->getRequestParameter("operators")); $this->editFlavorParam->setEngineVersion($this->getRequestParameter("engine-version")); $this->editFlavorParam->setType($this->getRequestParameter("type")); } $this->editFlavorParam->save(); } $this->redirect("system/flavorParams?pid=" . $this->editFlavorParam->getPartnerId()); } $c = new Criteria(); $c->add(assetParamsPeer::PARTNER_ID, array(0, $this->pid), Criteria::IN); $this->flavorParams = assetParamsPeer::doSelect($c); $this->formats = self::getEnumValues("flavorParams", "CONTAINER_FORMAT"); $this->videoCodecs = self::getEnumValues("flavorParams", "VIDEO_CODEC"); $this->audioCodecs = self::getEnumValues("flavorParams", "AUDIO_CODEC"); $this->readyBehaviors = self::getEnumValues("flavorParamsConversionProfile", "READY_BEHAVIOR"); $this->creationModes = self::getEnumValues("flavorParams", "CREATION_MODE"); }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; //myDbHelper::DB_HELPER_CONN_PROPEL2 $this->saved = false; $uiConfId = $this->getRequestParameter("id"); if ($uiConfId) { $uiConf = uiConfPeer::retrieveByPK($uiConfId); } else { $uiConf = new uiConf(); } if ($this->getRequest()->getMethodName() == "POST") { $uiConf->setPartnerId($this->getRequestParameter("partnerId")); $uiConf->setSubpId($uiConf->getPartnerId() * 100); $uiConf->setObjType($this->getRequestParameter("type")); $uiConf->setName($this->getRequestParameter("name")); $uiConf->setWidth($this->getRequestParameter("width")); $uiConf->setHeight($this->getRequestParameter("height")); $uiConf->setCreationMode($this->getRequestParameter("creationMode")); $uiConf->setSwfUrl($this->getRequestParameter("swfUrl")); $uiConf->setConfVars($this->getRequestParameter("confVars")); $useCdn = $this->getRequestParameter("useCdn"); $uiConf->setUseCdn($useCdn === "1" ? true : false); $uiConf->setDisplayInSearch($this->getRequestParameter("displayInSearch")); $uiConf->setConfVars($this->getRequestParameter("confVars")); $uiConf->setTags($this->getRequestParameter("tags")); /* files: */ if ($uiConf->getCreationMode() != uiConf::UI_CONF_CREATION_MODE_MANUAL) { $confFile = $this->getRequestParameter("uiconf_confFile"); $confFileFeatures = $this->getRequestParameter("uiconf_confFileFeatures"); if ($uiConf->getConfFile() != $confFile || $uiConf->getConfFileFeatures() != $confFileFeatures) { $uiConf->setConfFile($confFile); $uiConf->setConfFileFeatures($confFileFeatures); } } $uiConf->save(); $this->saved = true; } // so script won't die when uiconf is missing if (!$uiConf) { $uiConf = new uiConf(); } $partner = PartnerPeer::retrieveByPK($uiConf->getPartnerId()); $types = $uiConf->getUiConfTypeMap(); $c = new Criteria(); $c->add(widgetPeer::UI_CONF_ID, $uiConf->getId()); $c->setLimit(1000); $widgets = widgetPeer::doSelect($c); $widgetsPerPartner = array(); $this->tooMuchWidgets = false; if (count($widgets) == 1000) { $this->tooMuchWidgets = true; } else { if ($widgets) { foreach ($widgets as $widget) { if (!array_key_exists($widget->getPartnerId(), $widgetsPerPartner)) { $widgetsPerPartner[$widget->getPartnerId()] = 0; } $widgetsPerPartner[$widget->getPartnerId()]++; } } } // find the FileSync $fileSyncs = array(); $fileSyncs[] = array("key" => $uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_DATA)); $fileSyncs[] = array("key" => $uiConf->getSyncKey(uiConf::FILE_SYNC_UICONF_SUB_TYPE_FEATURES)); foreach ($fileSyncs as &$fileSync) { $fileSync["fileSyncs"] = FileSyncPeer::retrieveAllByFileSyncKey($fileSync["key"]); } $this->fileSyncs = $fileSyncs; $this->widgetsPerPartner = $widgetsPerPartner; $this->directoryMap = $uiConf->getDirectoryMap(); $this->swfNames = $uiConf->getSwfNames(); $this->types = $types; $this->uiConf = $uiConf; $this->partner = $partner; }
public function execute() { $this->forceSystemAuthentication(); myDbHelper::$use_alternative_con = null; // ajax stuff are here because there are too many actions in system module $ajax = $this->getRequestParameter("ajax", null); if ($ajax !== null) { switch ($ajax) { case "getPartnerName": $name = "Unknown Partner"; $partnerId = $this->getRequestParameter("id"); $partner = PartnerPeer::retrieveByPK($partnerId); if ($partner) { $name = $partner->getName(); } return $this->renderText(json_encode($name)); case "validateWidgetIds": $widgetIds = explode(",", $this->getRequestParameter("widgetIds")); $existingIds = array(); if (is_array($widgetIds)) { $widgets = widgetPeer::retrieveByPKs($widgetIds); if ($widgets) { foreach ($widgets as $widget) { $id = $widget->getId(); if (in_array($id, $widgetIds)) { $existingIds[] = $id; } } } } return $this->renderText(json_encode($existingIds)); } } // end of ajax stuff $uiConfId = $this->getRequestParameter("uiConfId"); $uiConf = uiConfPeer::retrieveByPK($uiConfId); if ($this->getRequest()->getMethodName() == "POST") { $numOfWidgets = (int) $this->getRequestParameter("numOfWidgets"); $startIndex = (int) $this->getRequestParameter("startIndex"); $partnerId = $this->getRequestParameter("partnerId"); $uiConfId = $this->getRequestParameter("uiConfId"); $entryId = $this->getRequestParameter("entryId"); $securityType = $this->getRequestParameter("securityType"); $securityPolicy = $this->getRequestParameter("securityPolicy"); $prefix = $this->getRequestParameter("prefix"); if ($prefix) { $prefix = "_"; } else { $prefix = ""; } for ($i = $startIndex; $i < $startIndex + $numOfWidgets; $i++) { $widget = new widget(); if (!$i) { $widget->setId($prefix . $partnerId . "_" . $uiConfId); } else { $widget->setId($prefix . $partnerId . "_" . $uiConfId . "_" . $i); } $widget->setUiConfId($uiConfId); $widget->setPartnerId($partnerId); $widget->setSubpId($partnerId * 100); $widget->setEntryId($entryId); $widget->setSecurityType($securityType); $widget->setSecurityPolicy($securityPolicy); $widget->save(); } $this->redirect("system/editUiconf?id=" . $uiConfId); } if ($uiConf) { $partner = PartnerPeer::retrieveByPK($uiConf->getPartnerId()); } else { $uiConf = new uiConf(); $partner = new Partner(); } $this->widget = new widget(); $this->uiConf = $uiConf; $this->partner = $partner; }
/** * This is not a regular service. * Because the caller is not a partner but rather a 3rd party provider that wishs to query our system, * The security is slightly different and the respons is in the format of mRss which is related to entries only. */ public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser) { myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2; header("Content-Type: text/xml; charset=utf-8"); // TODO - verify permissions for viewing lists // validate the ks of the caller $code = $this->getP("code"); if ($code != 'fsalh5423a43g') { return "<xml></xml>"; die; } $detailed = $this->getP("detailed", false); $limit = $this->getP("page_size", 100); $limit = $this->maxPageSize($limit); $operated_partner_id = $this->getP("operated_partner_id"); $page = $this->getP("page", 1); $offset = ($page - 1) * $limit; // kuserPeer::setUseCriteriaFilter( false ); if ($operated_partner_id) { entryPeer::setUseCriteriaFilter(true); } else { entryPeer::setUseCriteriaFilter(false); } // FOR now - display only 2 partners // 2460 - dorimedia $partner_list = array(593, 2460); $c = KalturaCriteria::create(entryPeer::OM_CLASS); $c->addAnd(entryPeer::STATUS, entryStatus::READY); // for now display only entries that are part of the kaltura network // $c->addAnd ( entryPeer::DISPLAY_IN_SEARCH , mySearchUtils::DISPLAY_IN_SEARCH_KALTURA_NETWORK ); // filter $filter = new entryFilter(); $fields_set = $filter->fillObjectFromRequest($this->getInputParams(), "filter_", null); $this->setExtraFilters($filter); $offset = ($page - 1) * $limit; $c->setLimit($limit); if ($offset > 0) { $c->setOffset($offset); } $filter->attachToCriteria($c); //if ($order_by != -1) entryPeer::setOrder( $c , $order_by ); $c->addAnd(entryPeer::PARTNER_ID, $partner_list, Criteria::IN); $start_1 = microtime(true); if ($detailed) { // for some entry types - there are no kshow or kusers - don't join even when detailed if ($this->joinOnDetailed()) { $list = entryPeer::doSelectJoinAll($c); } else { $list = entryPeer::doSelect($c); } $level = objectWrapperBase::DETAIL_LEVEL_DETAILED; } else { $list = entryPeer::doSelect($c); $level = objectWrapperBase::DETAIL_LEVEL_REGULAR; } $count = $c->getRecordsCount(); $end_1 = microtime(true); KalturaLog::log("benchmark db: [" . ($end_1 - $start_1) . "]"); $result_count = count($list); $start_2 = microtime(true); $mrss_renderer = new kalturaRssRenderer(kalturaRssRenderer::TYPE_TABOOLA); $str = $mrss_renderer->renderMrssFeed($list, $page, $result_count); $end_2 = microtime(true); KalturaLog::log("benchmark render: [" . ($end_2 - $start_2) . "]"); echo $str; // don't return to the rest of the implementation - the base class manipulates the content. die; }