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;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
 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 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;
 }
Ejemplo n.º 6
0
 /**
  * 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;
 }
Ejemplo n.º 7
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Ejemplo n.º 9
0
 public function writeSolrLog($entry)
 {
     KalturaLog::debug("writeSolrLog " . $entry->getId());
     $solrLog = new SphinxLog();
     $solrLog->setEntryId($entry->getId());
     $solrLog->setPartnerId($entry->getPartnerId());
     $solrLog->save(myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_SOLR_LOG));
 }
 public static function alternativeCon($con, $queryDB = kQueryCache::QUERY_DB_UNDEFINED)
 {
     if ($con === null) {
         $con = myDbHelper::alternativeCon($con);
     }
     if ($con === null) {
         $con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL3);
     }
     return $con;
 }
Ejemplo n.º 11
0
 public static function alternativeCon($con)
 {
     if ($con === null) {
         $con = myDbHelper::alternativeCon($con);
     }
     if ($con === null) {
         $con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL3);
     }
     return $con;
 }
 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) . "]");
 }
 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;
     }
 }
Ejemplo n.º 14
0
 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);
 }
Ejemplo n.º 17
0
 public function getConfigs()
 {
     $c = new Criteria();
     $c->clearSelectColumns();
     $c->addSelectColumn('MAX(' . SchedulerConfigPeer::ID . ')');
     $c->addGroupByColumn(SchedulerConfigPeer::VARIABLE);
     $c->addGroupByColumn(SchedulerConfigPeer::VARIABLE_PART);
     $c->addAscendingOrderByColumn(SchedulerConfigPeer::VARIABLE);
     $c->add(SchedulerConfigPeer::SCHEDULER_ID, $this->id);
     $c->add(SchedulerConfigPeer::WORKER_ID, null);
     $rs = SchedulerConfigPeer::doSelectStmt($c, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
     $configIds = $rs->fetchAll(PDO::FETCH_COLUMN, 0);
     return SchedulerConfigPeer::retrieveByPKs($configIds, myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2));
 }
Ejemplo n.º 18
0
 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;
 }
Ejemplo n.º 20
0
 public static function doQueueStatus(PDO $con = null)
 {
     if (is_null($con)) {
         $con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2);
     }
     //			$con = Propel::getConnection(BatchJobPeer::DATABASE_NAME);
     $stmt = null;
     try {
         $now = time();
         $sql = "SELECT\t\tAVG(TIMEDIFF(NOW(), CREATED_AT)) AS CREATED_AT_AVG,\n\t\t\t\t\t\t\t\tCOUNT(JOB_TYPE) AS JOB_TYPE_COUNT, \n\t\t\t\t\t\t\t\tJOB_TYPE \n\t\t\t\t\tFROM\t\tbatch_job \n\t\t\t\t\tFORCE INDEX (created_at_job_type_status_index)\n\t\t\t\t\tWHERE\t\tSTATUS IN (" . BatchJob::BATCHJOB_STATUS_PENDING . ',' . BatchJob::BATCHJOB_STATUS_RETRY . ")\n\t\t\t\t\tAND\t\t\t(\n\t\t\t\t\t\t\t\t\tCHECK_AGAIN_TIMEOUT < {$now}\n\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\tCHECK_AGAIN_TIMEOUT IS NULL\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\tAND\t\t\tJOB_TYPE IS NOT NULL\n\t\t\t\t\tAND\t\t\tCREATED_AT > DATE_ADD(NOW(), INTERVAL -1 HOUR)\n\t\t\t\t\tGROUP BY\tJOB_TYPE";
         $stmt = $con->query($sql);
     } catch (Exception $e) {
         Propel::log($e->getMessage(), Propel::LOG_ERR);
         throw new PropelException($e);
     }
     return $stmt->fetchAll();
 }
Ejemplo n.º 21
0
 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);
 }
Ejemplo n.º 22
0
 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;
 }
Ejemplo n.º 23
0
 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());
     }
 }
Ejemplo n.º 25
0
 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 __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) . "]");
 }
Ejemplo n.º 27
0
 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;
 }
Ejemplo n.º 29
0
 public static function alternativeCon($con, $queryDB = kQueryCache::QUERY_DB_UNDEFINED)
 {
     if ($con === null) {
         switch ($queryDB) {
             case kQueryCache::QUERY_DB_MASTER:
                 $con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_MASTER);
                 break;
             case kQueryCache::QUERY_DB_SLAVE:
                 $con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2);
                 break;
         }
     }
     if ($con === null) {
         $con = myDbHelper::alternativeCon($con);
     }
     if ($con === null) {
         $con = Propel::getConnection(MetadataProfilePeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     return $con;
 }
Ejemplo n.º 30
0
 /**
  * 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;
 }