/**
  * 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;
 }
예제 #2
0
 /**
  * 
  * @param int $objectType
  * @param string $objectId
  * @return ISyncableFile
  */
 public static function retrieveObject($objectType, $objectId)
 {
     $object = null;
     switch ($objectType) {
         case FileSyncObjectType::ENTRY:
             entryPeer::setUseCriteriaFilter(false);
             $object = entryPeer::retrieveByPK($objectId);
             entryPeer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::UICONF:
             uiConfPeer::setUseCriteriaFilter(false);
             $object = uiConfPeer::retrieveByPK($objectId);
             uiConfPeer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::BATCHJOB:
             BatchJobPeer::setUseCriteriaFilter(false);
             $object = BatchJobPeer::retrieveByPK($objectId);
             BatchJobPeer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::FLAVOR_ASSET:
             assetPeer::setUseCriteriaFilter(false);
             $object = assetPeer::retrieveById($objectId);
             assetPeer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::SYNDICATION_FEED:
             syndicationFeedPeer::setUseCriteriaFilter(false);
             $object = syndicationFeedPeer::retrieveByPK($objectId);
             syndicationFeedPeer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::CONVERSION_PROFILE:
             conversionProfile2Peer::setUseCriteriaFilter(false);
             $object = conversionProfile2Peer::retrieveByPK($objectId);
             conversionProfile2Peer::setUseCriteriaFilter(true);
             break;
         case FileSyncObjectType::FILE_ASSET:
             conversionProfile2Peer::setUseCriteriaFilter(false);
             $object = FileAssetPeer::retrieveByPK($objectId);
             conversionProfile2Peer::setUseCriteriaFilter(true);
             break;
     }
     if ($object == null) {
         $object = KalturaPluginManager::loadObject('ISyncableFile', $objectType, array('objectId' => $objectId));
     }
     if ($object == null) {
         $error = __METHOD__ . " Cannot find object type [" . $objectType . "] with object_id [" . $objectId . "]";
         KalturaLog::err($error);
         throw new kFileSyncException($error);
     }
     return $object;
 }
예제 #3
0
 /**
  * Will display errornous entries
  */
 public function execute()
 {
     $this->forceSystemAuthentication();
     entryPeer::setUseCriteriaFilter(false);
     // find entries with status error
     $c = new Criteria();
     $c->add(entryPeer::STATUS, entryStatus::ERROR_CONVERTING);
     $this->error_converting = entryPeer::doSelect($c);
     $date_format = 'Y-m-d H:i:s';
     $this->several_minutes_ago = time() - 5 * 60;
     // 5 minutes ago //mktime(0, 0, 0, date("m"), date("d"),   date("Y"));
     $start_date = date($date_format, $this->several_minutes_ago);
     $c = new Criteria();
     $c->add(entryPeer::STATUS, array(entryStatus::IMPORT, entryStatus::PRECONVERT), Criteria::IN);
     $c->add(entryPeer::UPDATED_AT, $start_date, Criteria::LESS_THAN);
     $this->error_waiting_too_long = entryPeer::doSelect($c);
     $this->start_date = $start_date;
 }
예제 #4
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     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);
     $page = $this->getP("page", 1);
     //$order_by = int( $this->getP ( "order_by" , -1 ) );
     $puser_kuser = null;
     $use_filter_puser_id = $this->getP("use_filter_puser_id", 1);
     if ($use_filter_puser_id == "false") {
         $use_filter_puser_id = false;
     }
     $offset = ($page - 1) * $limit;
     kuserPeer::setUseCriteriaFilter(false);
     entryPeer::setUseCriteriaFilter(false);
     $c = new Criteria();
     // filter
     $filter = new kshowFilter();
     $fields_set = $filter->fillObjectFromRequest($this->getInputParams(), "filter_", null);
     $this->setExtraFilters($filter);
     if ($use_filter_puser_id) {
         // if so - assume the producer_id is infact a puser_id and the kuser_id should be retrieved
         $target_puser_id = $filter->get("_eq_producer_id");
         //$this->getP ( "filter__eq_producer_id" );
         if ($target_puser_id) {
             // TODO - shoud we use the subp_id to retrieve the puser_kuser ?
             $puser_kuser = PuserKuserPeer::retrieveByPartnerAndUid($partner_id, null, $target_puser_id, false);
             if ($puser_kuser) {
                 $filter->set("_eq_producer_id", $puser_kuser->getkuserId());
                 //$this->setP ( "filter__eq_producer_id" , $puser_kuser->getkuserId() );
             }
         }
     }
     $filter->attachToCriteria($c);
     //if ($order_by != -1) kshowPeer::setOrder( $c , $order_by );
     $count = kshowPeer::doCount($c);
     $offset = ($page - 1) * $limit;
     $c->setLimit($limit);
     if ($offset > 0) {
         $c->setOffset($offset);
     }
     if ($detailed) {
         $list = kshowPeer::doSelectJoinAll($c);
         $level = objectWrapperBase::DETAIL_LEVEL_DETAILED;
         // will have to populate the show_entry before according to the ids
         fdb::populateObjects($list, new entryPeer(), "showentryid", "showentry", false);
     } else {
         $list = kshowPeer::doSelect($c);
         $level = objectWrapperBase::DETAIL_LEVEL_REGULAR;
         // will have to populate the show_entry before according to the ids - we display the thumbnail from the showentry
         fdb::populateObjects($list, new entryPeer(), "showentryid", "showentry", false);
     }
     $this->addMsg("count", $count);
     $this->addMsg("page_size", $limit);
     $this->addMsg("page", $page);
     $wrapper = objectWrapperBase::getWrapperClass($list, $level);
     $this->addMsg("kshows", $wrapper);
     if ($use_filter_puser_id) {
         $this->addMsg("user", objectWrapperBase::getWrapperClass($puser_kuser, objectWrapperBase::DETAIL_LEVEL_REGULAR));
     }
     /*
     		$i=0;
     		foreach ( $list as $kshow )
     		{
     			$i++;
     			$wrapper =  objectWrapperBase::getWrapperClass( $kshow  , $level );
     			$this->addMsg ( "kshow$i" , $wrapper ) ;
     		}
     */
     //		echo "bbb count: " . count ($list );
     //		echo "ccc";
     //$this->addMsg ( "kshows" , $wrapper ) ;
 }
 /**
  * Will investigate a single entry
  */
 public function execute()
 {
     $this->forceSystemAuthentication();
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
     entryPeer::setUseCriteriaFilter(false);
     $this->result = NULL;
     $fast = $this->getRequestParameter("fast", "") != "";
     $this->fast = $fast;
     $kshow_id = $this->getRequestParameter("kshow_id");
     $this->kshow_id = $kshow_id;
     $this->kshow = NULL;
     $entry_id = $this->getRequestParameter("entry_id");
     $this->entry_id = $entry_id;
     $this->entry = NULL;
     $this->error = $this->getRequestParameter("error");
     $this->bg_entry = NULL;
     if (!empty($kshow_id)) {
         $c = new Criteria();
         $c->add(kshowPeer::ID, $kshow_id);
         $kshows = kshowPeer::doSelect($c);
         $kshow = new kshow();
         if (!$kshows) {
             $this->result = "No kshow [{$kshow_id}] in DB";
             return;
         }
         $kshow_original = $kshows[0];
         $kshow_original->getShowEntry();
         // pre fetch
         $kshow_original->getIntro();
         // pre fetch
         $this->kshow_original = $kshows[0];
         $this->kshow = new genericObjectWrapper($this->kshow_original, true);
         $alredy_exist_entries = array();
         $alredy_exist_entries[] = $kshow_original->getShowEntryId();
         if ($kshow_original->getIntroId()) {
             $alredy_exist_entries[] = $kshow_original->getIntroId();
         }
         $skin_obj = $this->kshow_original->getSkinObj();
         $bg_entry_id = $skin_obj->get("bg_entry_id");
         if ($bg_entry_id) {
             $alredy_exist_entries[] = $bg_entry_id;
             $this->bg_entry = new genericObjectWrapper(entryPeer::retrieveByPK($bg_entry_id), true);
         }
         $c = new Criteria();
         $c->add(entryPeer::ID, $alredy_exist_entries, Criteria::NOT_IN);
         $c->setLimit(100);
         $this->kshow_entries = $this->kshow_original->getEntrysJoinKuser($c);
         return;
         //return "KshowSuccess";
     }
     if (empty($entry_id)) {
         return;
     }
     entryPeer::setUseCriteriaFilter(false);
     // from entry table
     $c = new Criteria();
     $c->add(entryPeer::ID, $entry_id);
     //$entries = entryPeer::doSelectJoinAll ( $c );
     $entries = entryPeer::doSelect($c);
     if (!$entries) {
         $this->result = "No entry [{$entry_id}] in DB";
         return;
     }
     $this->entry = new genericObjectWrapper($entries[0], true);
     // from conversion table
     $c = new Criteria();
     $c->add(conversionPeer::ENTRY_ID, $entry_id);
     $original_conversions = conversionPeer::doSelect($c);
     //$this->conversions = array() ; //
     $this->conversions = $original_conversions;
     //new genericObjectWrapper( $original_conversions );
     // find all relevant batches in DB
     // from batch_job table
     $c = new Criteria();
     //$c->add ( BatchJobPeer::DATA , "%\"entryId\";i:" . $entry_id . ";%" , Criteria::LIKE );
     $c->add(BatchJobPeer::ENTRY_ID, $entry_id);
     $original_batch_jobs = BatchJobPeer::doSelect($c);
     $this->batch_jobs = $original_batch_jobs;
     // new genericObjectWrapper( $original_batch_jobs );
     // use this as a refernece of all the directories
     //		myBatchFileConverterServer::init( true );
     $entry_patttern = "/" . $entry_id . "\\..*/";
     $getFileData_method = array('kFile', 'getFileData');
     $getFileDataWithContent_method = array('kFile', 'getFileDataWithContent');
     // find all relevant files on disk
     $c = new Criteria();
     $c->add(FileSyncPeer::OBJECT_TYPE, FileSyncObjectType::ENTRY);
     $c->add(FileSyncPeer::OBJECT_ID, $entry_id);
     // order by OBJECT SUB TYPE
     $c->addAscendingOrderByColumn(FileSyncPeer::OBJECT_SUB_TYPE);
     $this->file_syncs = FileSyncPeer::doSelect($c);
     $file_sync_links = array();
     $flavors = assetPeer::retrieveFlavorsByEntryId($entry_id);
     $flavor_ids = array();
     $this->flavors = array();
     foreach ($flavors as $f) {
         $flavor_ids[] = $f->getId();
         $f->getflavorParamsOutputs();
         $f->getflavorParams();
         $f->getmediaInfos();
         $this->flavors[] = $f;
     }
     // find all relevant files on disk
     $c = new Criteria();
     $c->add(FileSyncPeer::OBJECT_TYPE, FileSyncObjectType::FLAVOR_ASSET);
     $c->add(FileSyncPeer::OBJECT_ID, $flavor_ids, Criteria::IN);
     // order by OBJECT SUB TYPE
     $c->addAscendingOrderByColumn(FileSyncPeer::OBJECT_SUB_TYPE);
     $flavors_file_syncs = FileSyncPeer::doSelect($c);
     $this->flavors_file_syncs = array();
     foreach ($flavors as $flav) {
         foreach ($flavors_file_syncs as $f) {
             if ($f->getLinkedId()) {
                 $file_sync_links[] = $f->getLinkedId();
             }
             if ($f->getObjectId() == $flav->getId()) {
                 $this->flavors_file_syncs[$flav->getId()][] = $f;
             }
         }
     }
     if ($this->file_syncs) {
         $this->file_syncs_by_sub_type = array();
         foreach ($this->file_syncs as $fs) {
             if ($fs->getLinkedId()) {
                 $file_sync_links[] = $fs->getLinkedId();
             }
             $sub_type = $fs->getObjectSubType();
             if (!isset($this->file_syncs_by_sub_type[$sub_type])) {
                 // create the array
                 $this->file_syncs_by_sub_type[$sub_type] = array();
             }
             $this->file_syncs_by_sub_type[$sub_type][] = $fs;
         }
     } else {
         $this->file_syncs_by_sub_type = array();
     }
     $file_sync_criteria = new Criteria();
     $file_sync_criteria->add(FileSyncPeer::ID, $file_sync_links, Criteria::IN);
     $this->file_sync_links = FileSyncPeer::doSelect($file_sync_criteria);
     $track_entry_c = new Criteria();
     $track_entry_c->add(TrackEntryPeer::ENTRY_ID, $entry_id);
     $track_entry_list = TrackEntryPeer::doSelect($track_entry_c);
     $more_interesting_track_entries = array();
     foreach ($track_entry_list as $track_entry) {
         if ($track_entry->getTrackEventTypeId() == TrackEntry::TRACK_ENTRY_EVENT_TYPE_ADD_ENTRY) {
             $more_interesting_track_entries[] = $track_entry->getParam3Str();
         }
     }
     $track_entry_list2 = array();
     //very heavy query, skip this
     /*
     // add all the track_entry objects that are related (joined on PARAM_3_STR)
     $track_entry_c2 = new Criteria();
     $track_entry_c2->add ( TrackEntryPeer::TRACK_EVENT_TYPE_ID , TrackEntry::TRACK_ENTRY_EVENT_TYPE_UPLOADED_FILE );
     $track_entry_c2->add ( TrackEntryPeer::PARAM_3_STR , $more_interesting_track_entries , Criteria::IN );
     $track_entry_list2 = TrackEntryPeer::doSelect ( $track_entry_c2 );
     */
     // first add the TRACK_ENTRY_EVENT_TYPE_UPLOADED_FILE - they most probably happend before the rest
     $this->track_entry_list = array_merge($track_entry_list2, $track_entry_list);
 }
예제 #6
0
 /**
  * Code to be run after inserting to database
  * @param PropelPDO $con 
  */
 public function postInsert(PropelPDO $con = null)
 {
     entryPeer::setUseCriteriaFilter(false);
     $this->reload();
     entryPeer::setUseCriteriaFilter(true);
     kEventsManager::raiseEvent(new kObjectCreatedEvent($this));
     if ($this->copiedFrom) {
         kEventsManager::raiseEvent(new kObjectCopiedEvent($this->copiedFrom, $this));
     }
 }
예제 #7
0
 private function getEntryByIdNoFilter($entryId)
 {
     entryPeer::setUseCriteriaFilter(false);
     $entry = entryPeer::retrieveByPK($entryId);
     entryPeer::setUseCriteriaFilter(true);
     return $entry;
 }
 private function pollConverted($write_to_log = true)
 {
     list($full_conv_res_path, $file_name, $in_proc) = $this->getFileFromConvertion($write_to_log);
     if (!$full_conv_res_path) {
         return;
     }
     $entry_id = self::getEntryIdFromFileName($file_name);
     KalturaLog::debug("Updating entry [" . $entry_id . "]");
     entryPeer::setUseCriteriaFilter(false);
     // update the entry even if it's deleted
     //		$c = new Criteria();
     //		$c->add(entryPeer::ID, $entry_id);
     //		$entry = entryPeer::doSelectOne( $c );
     $entry = entryPeer::retrieveByPK($entry_id);
     // fetch file from the conversion server and store it in the correct place - content/entry/data/...
     // using the ame logic as in contribute/insertEntryAction & myContentStorage...
     $this->removeInProc($in_proc);
     if ($entry == NULL) {
         // TODO - entry does not exist in DB - what to do ?
         // move file to some directory
         return;
     }
     // the target of the entry was already set at time of sentToCenversion
     $conv_res = kConversionResult::fromFile($full_conv_res_path);
     KalturaLog::debug(print_r($conv_res, true));
     // sleep a while for synching data on the disk
     sleep(3);
     $this->markFileSyncAsReady($entry);
     $this->updateConvertedEntry($conv_res->status_ok, $entry, $conv_res);
     // flag a success to break the row of faliures (is any)
     self::succeeded();
 }
예제 #9
0
 public static function copyEntry(entry $entry, Partner $toPartner = null, $dontCopyUsers = false)
 {
     KalturaLog::log("copyEntry - Copying entry [" . $entry->getId() . "] to partner [" . $toPartner->getId() . "]");
     $newEntry = $entry->copy();
     $newEntry->setIntId(null);
     $newEntry->setCategories(null);
     $newEntry->setCategoriesIds(null);
     if ($toPartner instanceof Partner) {
         $newEntry->setPartnerId($toPartner->getId());
         $newEntry->setSubpId($toPartner->getId() * 100);
         $newEntry->setAccessControlId($toPartner->getDefaultAccessControlId());
     }
     $newKuser = null;
     if (!$dontCopyUsers) {
         // copy the kuser (if the same puser id exists its kuser will be used)
         kuserPeer::setUseCriteriaFilter(false);
         $kuser = $entry->getKuser();
         $newKuser = kuserPeer::createKuserForPartner($newEntry->getPartnerId(), $kuser->getPuserId());
         $newEntry->setKuserId($newKuser->getId());
         $newEntry->setCreatorKuserId($newKuser->getId());
         kuserPeer::setUseCriteriaFilter(true);
     }
     // copy the kshow
     kshowPeer::setUseCriteriaFilter(false);
     $kshow = $entry->getKshow();
     if ($kshow) {
         $newKshow = $kshow->copy();
         $newKshow->setIntId(null);
         $newKshow->setPartnerId($toPartner->getId());
         $newKshow->setSubpId($toPartner->getId() * 100);
         if ($newKuser) {
             $newKshow->setProducerId($newKuser->getId());
         }
         $newKshow->save();
         $newEntry->setKshowId($newKshow->getId());
     }
     kshowPeer::setUseCriteriaFilter(true);
     // reset the statistics
     myEntryUtils::resetEntryStatistics($newEntry);
     // set the new partner id into the default category criteria filter
     $defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter();
     $oldPartnerId = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId());
     // save the entry
     $newEntry->save();
     // restore the original partner id in the default category criteria filter
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerId);
     KalturaLog::log("copyEntry - New entry [" . $newEntry->getId() . "] was created");
     // for any type that does not require assets:
     $shouldCopyDataForNonClip = true;
     if ($entry->getType() == entryType::MEDIA_CLIP) {
         $shouldCopyDataForNonClip = false;
     }
     if ($entry->getType() == entryType::PLAYLIST) {
         $shouldCopyDataForNonClip = false;
     }
     $shouldCopyDataForClip = false;
     // only images get their data copied
     if ($entry->getType() == entryType::MEDIA_CLIP) {
         if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_VIDEO && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_AUDIO) {
             $shouldCopyDataForClip = true;
         }
     }
     //if entry is a static playlist, link between it and its new child entries
     if ($entry->getType() == entryType::PLAYLIST) {
         switch ($entry->getMediaType()) {
             case entry::ENTRY_MEDIA_TYPE_TEXT:
                 $from = $entry->getDataContent();
                 KalturaLog::debug("Entries to copy from source static playlist: [{$from}]");
                 $fromEntryIds = explode(",", $from);
                 $toEntryIds = array();
                 foreach ($fromEntryIds as $fromEntryId) {
                     $toEntryIds[] = kObjectCopyHandler::getMappedId(entryPeer::OM_CLASS, $fromEntryId);
                 }
                 $newEntry->setDataContent(implode(",", $toEntryIds));
                 break;
             case entry::ENTRY_MEDIA_TYPE_XML:
                 list($totalResults, $fromFiltersList) = myPlaylistUtils::getPlaylistFilterListStruct($entry->getDataContent());
                 $toPlaylistXml = new SimpleXMLElement("<playlist/>");
                 $toPlaylistXml->addChild("total_results", $totalResults);
                 $toFiltersXml = $toPlaylistXml->addChild("filters");
                 foreach ($fromFiltersList as $filterXML) {
                     $entryFilter = new entryFilter();
                     $entryFilter->fillObjectFromXml($filterXML, "_");
                     if (isset($entryFilter->fields["_matchand_categories_ids"])) {
                         $categoriesIds = explode(",", $entryFilter->fields["_matchand_categories_ids"]);
                         $newCategoriesIds = array();
                         foreach ($categoriesIds as $categoryId) {
                             $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
                         }
                         $entryFilter->fields["_matchand_categories_ids"] = implode(",", $newCategoriesIds);
                     }
                     if (isset($entryFilter->fields["_matchor_categories_ids"])) {
                         $categoriesIds = explode(",", $entryFilter->fields["_matchor_categories_ids"]);
                         $newCategoriesIds = array();
                         foreach ($categoriesIds as $categoryId) {
                             $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
                         }
                         $entryFilter->fields["_matchor_categories_ids"] = implode(",", $newCategoriesIds);
                     }
                     if (isset($entryFilter->fields["_in_category_ancestor_id"])) {
                         $categoriesIds = explode(",", $entryFilter->fields["_in_category_ancestor_id"]);
                         $newCategoriesIds = array();
                         foreach ($categoriesIds as $categoryId) {
                             $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
                         }
                         $entryFilter->fields["_in_category_ancestor_id"] = implode(",", $newCategoriesIds);
                     }
                     $toEntryFilterXML = $toFiltersXml->addChild("filter");
                     $toEntryFilterXML = $entryFilter->toXml($toEntryFilterXML);
                 }
                 $newEntry->setDataContent($toPlaylistXml->asXML());
                 break;
         }
     }
     if ($shouldCopyDataForNonClip || $shouldCopyDataForClip) {
         // copy the data
         $from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         // replaced__getDataPath
         $to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
         // replaced__getDataPath
         KalturaLog::log("copyEntriesByType - copying entry data [" . $from . "] to [" . $to . "]");
         kFileSyncUtils::softCopy($from, $to);
     }
     $ismFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
     if (kFileSyncUtils::fileSync_exists($ismFrom)) {
         $ismTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISM);
         KalturaLog::log("copying entry ism [" . $ismFrom . "] to [" . $ismTo . "]");
         kFileSyncUtils::softCopy($ismFrom, $ismTo);
     }
     $ismcFrom = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
     if (kFileSyncUtils::fileSync_exists($ismcFrom)) {
         $ismcTo = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_ISMC);
         KalturaLog::log("copying entry ism [" . $ismcFrom . "] to [" . $ismcTo . "]");
         kFileSyncUtils::softCopy($ismcFrom, $ismcTo);
     }
     $from = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
     // replaced__getThumbnailPath
     $considerCopyThumb = true;
     // if entry is image - data is thumbnail, and it was copied
     if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE) {
         $considerCopyThumb = false;
     }
     // if entry is not clip, and there is no file in both DCs - nothing to copy
     if ($entry->getType() != entryType::MEDIA_CLIP && !kFileSyncUtils::file_exists($from, true)) {
         $considerCopyThumb = false;
     }
     if ($considerCopyThumb) {
         $skipThumb = false;
         // don't attempt to copy a thumbnail for images - it's the same as the data which was just created
         if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUDIO) {
             // check if audio entry has real thumb, if not - don't copy thumb.
             $originalFileSync = kFileSyncUtils::getOriginFileSyncForKey($from, false);
             if (!$originalFileSync) {
                 $skipThumb = true;
             }
         }
         if (!$skipThumb) {
             $to = $newEntry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB);
             // replaced__getThumbnailPath
             KalturaLog::log("copyEntriesByType - copying entry thumbnail [" . $from . "] to [" . $to . "]");
             kFileSyncUtils::softCopy($from, $to);
         }
     }
     // added by Tan-Tan 12/01/2010 to support falvors copy
     $sourceAssets = assetPeer::retrieveByEntryId($entry->getId());
     foreach ($sourceAssets as $sourceAsset) {
         $sourceAsset->copyToEntry($newEntry->getId(), $newEntry->getPartnerId());
     }
     // copy relationships to categories
     KalturaLog::debug('Copy relationships to categories from entry [' . $entry->getId() . '] to entry [' . $newEntry->getId() . ']');
     $c = KalturaCriteria::create(categoryEntryPeer::OM_CLASS);
     $c->addAnd(categoryEntryPeer::ENTRY_ID, $entry->getId());
     $c->addAnd(categoryEntryPeer::STATUS, CategoryEntryStatus::ACTIVE, Criteria::EQUAL);
     $c->addAnd(categoryEntryPeer::PARTNER_ID, $entry->getPartnerId());
     categoryEntryPeer::setUseCriteriaFilter(false);
     $categoryEntries = categoryEntryPeer::doSelect($c);
     categoryEntryPeer::setUseCriteriaFilter(true);
     // Create srcCategoryIdToDstCategoryIdMap - a map of source partner category ids -> dst. partner category ids
     //
     // Build src category IDs set
     $srcCategoryIdSet = array();
     foreach ($categoryEntries as $categoryEntry) {
         $srcCategoryIdSet[] = $categoryEntry->getCategoryId();
     }
     $illegalCategoryStatus = array(CategoryStatus::DELETED, CategoryStatus::PURGED);
     // Get src category objects
     $c = KalturaCriteria::create(categoryPeer::OM_CLASS);
     $c->add(categoryPeer::ID, $srcCategoryIdSet, Criteria::IN);
     $c->addAnd(categoryPeer::PARTNER_ID, $entry->getPartnerId());
     $c->addAnd(categoryPeer::STATUS, $illegalCategoryStatus, Criteria::NOT_IN);
     categoryPeer::setUseCriteriaFilter(false);
     $srcCategories = categoryPeer::doSelect($c);
     categoryPeer::setUseCriteriaFilter(true);
     // Map the category names to their IDs
     $fullNamesToSrcCategoryIdMap = array();
     foreach ($srcCategories as $category) {
         $fullNamesToSrcCategoryIdMap[$category->getFullName()] = $category->getId();
     }
     // Get dst. partner categories based on src. category full-names
     $c = KalturaCriteria::create(categoryPeer::OM_CLASS);
     $c->add(categoryPeer::FULL_NAME, array_keys($fullNamesToSrcCategoryIdMap), KalturaCriteria::IN);
     $c->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId());
     $c->addAnd(categoryPeer::STATUS, $illegalCategoryStatus, Criteria::NOT_IN);
     categoryPeer::setUseCriteriaFilter(false);
     $dstCategories = categoryPeer::doSelect($c);
     categoryPeer::setUseCriteriaFilter(true);
     $srcCategoryIdToDstCategoryIdMap = array();
     foreach ($dstCategories as $dstCategory) {
         $fullName = $dstCategory->getFullName();
         if (array_key_exists($fullName, $fullNamesToSrcCategoryIdMap)) {
             $srcCategoryId = $fullNamesToSrcCategoryIdMap[$fullName];
             $srcCategoryIdToDstCategoryIdMap[$srcCategoryId] = $dstCategory->getId();
         }
     }
     foreach ($categoryEntries as $categoryEntry) {
         /* @var $categoryEntry categoryEntry */
         $newCategoryEntry = $categoryEntry->copy();
         $newCategoryEntry->setPartnerId($newEntry->getPartnerId());
         $newCategoryEntry->setEntryId($newEntry->getId());
         $srcCategoryId = $categoryEntry->getCategoryId();
         if (!array_key_exists($srcCategoryId, $srcCategoryIdToDstCategoryIdMap)) {
             continue;
             // Skip the category_entry's creation
         }
         $dstCategoryId = $srcCategoryIdToDstCategoryIdMap[$srcCategoryId];
         $newCategoryEntry->setCategoryId($dstCategoryId);
         categoryPeer::setUseCriteriaFilter(false);
         entryPeer::setUseCriteriaFilter(false);
         $newCategoryEntry->save();
         entryPeer::setUseCriteriaFilter(true);
         categoryPeer::setUseCriteriaFilter(true);
     }
     return $newEntry;
 }
예제 #10
0
 /**
  * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
  *
  * This will only work if the object has been saved and has a valid primary key set.
  *
  * @param      boolean $deep (optional) Whether to also de-associated any related objects.
  * @param      PropelPDO $con (optional) The PropelPDO connection to use.
  * @return     void
  * @throws     PropelException - if this object is deleted, unsaved or doesn't have pk match in db
  */
 public function reload($deep = false, PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("Cannot reload a deleted object.");
     }
     if ($this->isNew()) {
         throw new PropelException("Cannot reload an unsaved object.");
     }
     if ($con === null) {
         $con = Propel::getConnection(entryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     // We don't need to alter the object instance pool; we're just modifying this instance
     // already in the pool.
     entryPeer::setUseCriteriaFilter(false);
     $criteria = $this->buildPkeyCriteria();
     entryPeer::addSelectColumns($criteria);
     $stmt = BasePeer::doSelect($criteria, $con);
     entryPeer::setUseCriteriaFilter(true);
     $row = $stmt->fetch(PDO::FETCH_NUM);
     $stmt->closeCursor();
     if (!$row) {
         throw new PropelException('Cannot find matching row in the database to reload object values.');
     }
     $this->hydrate($row, 0, true);
     // rehydrate
     if ($deep) {
         // also de-associate any related objects?
         $this->akuser = null;
         $this->collLiveChannelSegmentsRelatedByChannelId = null;
         $this->lastLiveChannelSegmentRelatedByChannelIdCriteria = null;
         $this->collLiveChannelSegmentsRelatedByEntryId = null;
         $this->lastLiveChannelSegmentRelatedByEntryIdCriteria = null;
         $this->collkvotes = null;
         $this->lastkvoteCriteria = null;
         $this->collconversions = null;
         $this->lastconversionCriteria = null;
         $this->collWidgetLogs = null;
         $this->lastWidgetLogCriteria = null;
         $this->collmoderationFlags = null;
         $this->lastmoderationFlagCriteria = null;
         $this->collroughcutEntrysRelatedByRoughcutId = null;
         $this->lastroughcutEntryRelatedByRoughcutIdCriteria = null;
         $this->collroughcutEntrysRelatedByEntryId = null;
         $this->lastroughcutEntryRelatedByEntryIdCriteria = null;
         $this->collwidgets = null;
         $this->lastwidgetCriteria = null;
         $this->collassetParamsOutputs = null;
         $this->lastassetParamsOutputCriteria = null;
         $this->collUserEntrys = null;
         $this->lastUserEntryCriteria = null;
     }
     // if (deep)
 }
예제 #11
0
 /**
  * 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;
 }
예제 #12
0
 /**
  * @return BaseObject
  */
 public function getObject()
 {
     switch ($this->getObjectType()) {
         case BatchJobObjectType::ENTRY:
             entryPeer::setUseCriteriaFilter(false);
             $object = entryPeer::retrieveByPK($this->getObjectId());
             entryPeer::setUseCriteriaFilter(true);
             return $object;
         case BatchJobObjectType::ASSET:
             assetPeer::setUseCriteriaFilter(false);
             $object = assetPeer::retrieveById($this->getObjectId());
             assetPeer::setUseCriteriaFilter(true);
             return $object;
         case BatchJobObjectType::CATEGORY:
             categoryPeer::setUseCriteriaFilter(false);
             $object = categoryPeer::retrieveByPK($this->getObjectId());
             categoryPeer::setUseCriteriaFilter(true);
             return $object;
         case BatchJobObjectType::FILE_SYNC:
             FileSyncPeer::setUseCriteriaFilter(false);
             $object = FileSyncPeer::retrieveByPK($this->getObjectId());
             FileSyncPeer::setUseCriteriaFilter(true);
             return $object;
         default:
             // TODO implement IBatchable in relevant plugins
             return KalturaPluginManager::loadObject('IBatchable', $this->getObjectId());
     }
     return $this->aRootJob;
 }
예제 #13
0
 /**
  * 
  * Gets all the pusers from the entry table
  * @param int $lastEntryDate - the last entry date
  * @param int $limit - the limit for the query
  */
 private function getAllPusersInEntry($lastEntryDate, $limit)
 {
     $pusers = array();
     entryPeer::clearInstancePool();
     $c = new Criteria();
     $c->add(entryPeer::CREATED_AT, $lastEntryDate, Criteria::GREATER_THAN);
     $c->addAnd(entryPeer::PUSER_ID, null, Criteria::NOT_EQUAL);
     $c->addAnd(entryPeer::PUSER_ID, "", Criteria::NOT_EQUAL);
     if ($this->partnerId) {
         $c->addAnd(entryPeer::PARTNER_ID, $this->partnerId, Criteria::EQUAL);
     }
     $c->addAnd(entryPeer::PARTNER_ID, $this->ignorePartners, Criteria::NOT_IN);
     $c->addAscendingOrderByColumn(entryPeer::CREATED_AT);
     $c->setLimit($limit);
     entryPeer::setUseCriteriaFilter(false);
     $entries = entryPeer::doSelect($c);
     entryPeer::setUseCriteriaFilter(true);
     foreach ($entries as $entry) {
         //		$this->printToLog("Found entry with puser [{$entry->getPuserId()}], partner [{$entry->getPartnerId()}]");
         $pusers[] = new puserDetails($entry->getPuserId(), $entry->getPartnerId());
         file_put_contents($this->lastEntryFile, $entry->getCreatedAt());
     }
     return $pusers;
 }
예제 #14
0
 /**
  * Serves caption by its id converting it to segmented WebVTT
  *
  * @action serveWebVTT
  * @param string $captionAssetId
  * @param int $segmentDuration
  * @param int $segmentIndex
  * @param int $localTimestamp
  * @return file
  *
  * @throws KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND
  */
 public function serveWebVTTAction($captionAssetId, $segmentDuration = 30, $segmentIndex = null, $localTimestamp = 10000)
 {
     $captionAsset = $this->validateForDownload($captionAssetId);
     if (!$segmentIndex) {
         entryPeer::setUseCriteriaFilter(false);
         $entry = entryPeer::retrieveByPK($captionAsset->getEntryId());
         if (!$entry) {
             throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ENTRY_ID_NOT_FOUND, $captionAsset->getEntryId());
         }
         entryPeer::setUseCriteriaFilter(true);
         return new kRendererString(kWebVTTGenerator::buildWebVTTM3U8File($segmentDuration, (int) $entry->getDuration()), 'application/x-mpegurl');
     }
     $syncKey = $captionAsset->getSyncKey(asset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET);
     $content = kFileSyncUtils::file_get_contents($syncKey, true, false, self::MAX_SERVE_WEBVTT_FILE_SIZE);
     if (!$content) {
         throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_FILE_NOT_FOUND, $captionAssetId);
     }
     $captionsContentManager = kCaptionsContentManager::getCoreContentManager($captionAsset->getContainerFormat());
     if (!$captionsContentManager) {
         throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_INVALID_FORMAT, $captionAssetId);
     }
     $parsedCaption = $captionsContentManager->parse($content);
     if (!$parsedCaption) {
         throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_PARSING_FAILED, $captionAssetId);
     }
     return new kRendererString(kWebVTTGenerator::buildWebVTTSegment($parsedCaption, $segmentIndex, $segmentDuration, $localTimestamp), 'text/vtt');
 }
예제 #15
0
 protected static function init()
 {
     kEventsManager::enableDeferredEvents(false);
     MetadataProfilePeer::setUseCriteriaFilter(false);
     MetadataPeer::setUseCriteriaFilter(false);
     entryPeer::setUseCriteriaFilter(false);
     uiConfPeer::setUseCriteriaFilter(false);
     assetPeer::setUseCriteriaFilter(false);
     PartnerPeer::setUseCriteriaFilter(false);
     FileSyncPeer::setUseCriteriaFilter(false);
     $options = getopt('hrl:p:o:b:e:', array('real-run', 'error-objects', 'old-versions', 'blocked-partners', 'files'));
     if (isset($options['h'])) {
         self::failWrongInputs();
     }
     if (isset($options['blocked-partners'])) {
         self::$deleteDeletedPartnersFileSyncs = true;
     }
     if (isset($options['error-objects'])) {
         self::$deleteErrorObjects = true;
     }
     if (isset($options['old-versions'])) {
         self::$deleteOldVersions = true;
     }
     if (isset($options['files'])) {
         self::$purgeDeletedFileSyncs = true;
     }
     if (isset($options['r']) || isset($options['real-run'])) {
         self::$dryRun = false;
     }
     KalturaStatement::setDryRun(self::$dryRun);
     $cacheFilePath = kConf::get('cache_root_path') . '/scripts/deleteOldContent.cache';
     if (file_exists($cacheFilePath)) {
         $cache = unserialize(file_get_contents($cacheFilePath));
         if (isset($cache['oldVersionsStartUpdatedAt'])) {
             self::$oldVersionsStartUpdatedAt = $cache['oldVersionsStartUpdatedAt'];
         }
         if (isset($cache['purgeStartUpdatedAt'])) {
             self::$purgeStartUpdatedAt = $cache['purgeStartUpdatedAt'];
         }
     }
     if (!self::$purgeStartUpdatedAt) {
         $criteria = new Criteria();
         $criteria->add(FileSyncPeer::UPDATED_AT, 0, Criteria::GREATER_THAN);
         $criteria->add(FileSyncPeer::DC, kDataCenterMgr::getCurrentDcId());
         $criteria->add(FileSyncPeer::STATUS, FileSync::FILE_SYNC_STATUS_DELETED);
         $criteria->addSelectColumn('UNIX_TIMESTAMP(MIN(' . FileSyncPeer::UPDATED_AT . '))');
         $stmt = FileSyncPeer::doSelectStmt($criteria);
         $mins = $stmt->fetchAll(PDO::FETCH_COLUMN);
         if (count($mins)) {
             self::$purgeStartUpdatedAt = reset($mins);
         }
     }
     if (is_null(self::$purgeStartUpdatedAt)) {
         self::$purgeStartUpdatedAt = 0;
     }
     self::$purgeNextStartUpdatedAt = self::$purgeStartUpdatedAt;
     $oldVersionsUpdatedAtPeriod = 30;
     // days
     if (isset($options['o'])) {
         if (!is_numeric($options['o']) || $options['o'] < 0) {
             self::failWrongInputs("Period of old versions to delete must be positive numeric of days");
         }
         $oldVersionsUpdatedAtPeriod = $options['o'];
     }
     foreach (self::$oldVersionsStartUpdatedAt as $objectType => $oldVersionsStartUpdatedAt) {
         self::$oldVersionsEndUpdatedAt[$objectType] = $oldVersionsStartUpdatedAt + $oldVersionsUpdatedAtPeriod * 60 * 60 * 24;
     }
     // days
     $purgeUpdatedAtPeriod = 30;
     // days
     if (isset($options['p'])) {
         if (!is_numeric($options['p']) || $options['p'] < 0) {
             self::failWrongInputs("Period of purge must be positive numeric of days");
         }
         $purgeUpdatedAtPeriod = $options['p'];
     }
     self::$purgeEndUpdatedAt = self::$purgeStartUpdatedAt + $purgeUpdatedAtPeriod * 60 * 60 * 24;
     // days
     $oldPartnersUpdatedAtPeriod = 24;
     // months
     if (isset($options['b'])) {
         if (!is_numeric($options['b']) || $options['b'] < 0) {
             self::failWrongInputs("Period of blocked partners to delete must be positive numeric of months");
         }
         $oldPartnersUpdatedAtPeriod = $options['b'];
     }
     self::$oldPartnersUpdatedAt = time() - $oldPartnersUpdatedAtPeriod * 60 * 60 * 24 * 30;
     // months
     $errObjectsUpdatedAtPeriod = 24;
     // months
     if (isset($options['e'])) {
         if (!is_numeric($options['e']) || $options['e'] < 0) {
             self::failWrongInputs("Period of error objects to delete must be positive numeric of months");
         }
         $errObjectsUpdatedAtPeriod = $options['e'];
     }
     self::$errObjectsUpdatedAt = time() - $errObjectsUpdatedAtPeriod * 60 * 60 * 24 * 30;
     // months
     if (isset($options['l'])) {
         if (!is_numeric($options['l']) || $options['l'] < 0) {
             self::failWrongInputs("Limit querymust be positive numeric value");
         }
         self::$queryLimit = $options['l'];
     }
 }
define('SF_DEBUG', true);
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
require_once SF_ROOT_DIR . '/../infra/bootstrap_base.php';
require_once KALTURA_INFRA_PATH . DIRECTORY_SEPARATOR . "KAutoloader.php";
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "batch", "mediaInfoParser", "*"));
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "vendor", "propel", "*"));
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "plugins", "*"));
KAutoloader::setClassMapFilePath('./logs/classMap.cache');
KAutoloader::register();
error_reporting(E_ALL);
$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
if ($argc !== 2) {
    die('pleas provide partner id as input' . PHP_EOL . 'to run script: ' . basename(__FILE__) . ' X' . PHP_EOL . 'whereas X is partner id' . PHP_EOL);
}
$partnerId = @$argv[1];
$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
$sphinx = new kSphinxSearchManager();
$c = new Criteria();
$c->add(entryPeer::PARTNER_ID, $partnerId);
entryPeer::setUseCriteriaFilter(false);
$entries = entryPeer::doSelect($c);
foreach ($entries as $entry) {
    usleep(100);
    $sphinx->saveToSphinx($entry, false, true);
    echo $entry->getId() . "Saved\n";
}
echo "Done\n";
예제 #17
0
<?php

chdir(dirname(__FILE__));
require_once __DIR__ . '/../../bootstrap.php';
$c = new Criteria();
if ($argc > 1 && is_numeric($argv[1])) {
    $c->add(entryPeer::UPDATED_AT, $argv[1], Criteria::GREATER_EQUAL);
}
if ($argc > 2 && is_numeric($argv[2])) {
    $c->add(entryPeer::PARTNER_ID, $argv[2], Criteria::EQUAL);
}
if ($argc > 3 && is_numeric($argv[3])) {
    $c->add(entryPeer::INT_ID, $argv[3], Criteria::GREATER_EQUAL);
}
if ($argc > 4) {
    entryPeer::setUseCriteriaFilter((bool) $argv[4]);
}
$c->addAscendingOrderByColumn(entryPeer::UPDATED_AT);
$c->addAscendingOrderByColumn(entryPeer::ID);
$c->setLimit(10000);
$con = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_PROPEL2);
//$sphinxCon = DbManager::getSphinxConnection();
$entries = entryPeer::doSelect($c, $con);
$sphinx = new kSphinxSearchManager();
while (count($entries)) {
    foreach ($entries as $entry) {
        KalturaLog::log('entry id ' . $entry->getId() . ' int id[' . $entry->getIntId() . '] crc id[' . $sphinx->getSphinxId($entry) . '] updated at [' . $entry->getUpdatedAt(null) . ']');
        try {
            $ret = $sphinx->saveToSphinx($entry, true);
        } catch (Exception $e) {
            KalturaLog::err($e->getMessage());
예제 #18
0
 public static function copyEntriesByType(Partner $fromPartner, Partner $toPartner, $entryType, $dontCopyUsers = false)
 {
     KalturaLog::log("Copying entries from partner [" . $fromPartner->getId() . "] to partner [" . $toPartner->getId() . "] with type [" . $entryType . "]");
     entryPeer::setUseCriteriaFilter(false);
     $c = new Criteria();
     $c->addAnd(entryPeer::PARTNER_ID, $fromPartner->getId());
     $c->addAnd(entryPeer::TYPE, $entryType);
     $c->addAnd(entryPeer::STATUS, entryStatus::READY);
     $c->addDescendingOrderByColumn(entryPeer::CREATED_AT);
     $entries = entryPeer::doSelect($c);
     entryPeer::setUseCriteriaFilter(true);
     foreach ($entries as $entry) {
         myEntryUtils::copyEntry($entry, $toPartner, $dontCopyUsers);
     }
 }
예제 #19
0
 /**
  * Clone an entry with optional attributes to apply to the clone
  * 
  * @action clone
  * @param string $entryId Id of entry to clone
  * @param KalturaBaseEntryCloneOptionsArray $cloneOptions
  * @param KalturaBaseEntry $updateEntry [optional] Attributes from these entry will be updated into the cloned entry
  * @return KalturaBaseEntry The cloned entry
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  */
 public function cloneAction($entryId, $cloneOptions = null)
 {
     // Reset criteria filters such that it will be
     entryPeer::setUseCriteriaFilter(false);
     categoryEntryPeer::setUseCriteriaFilter(false);
     // Get the entry
     $coreEntry = entryPeer::retrieveByPK($entryId);
     if (!$coreEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     //		$coreClonedOptionsArray = array();
     //		foreach ($cloneOptions as $item)
     //		{
     //			$coreClonedOptionsArray[] = $item->toObject();
     //		}
     $coreClonedOptionsArray = $cloneOptions->toObjectsArray();
     // Copy the entry into a new one based on the given partner data.
     $clonedEntry = myEntryUtils::copyEntry($coreEntry, $this->getPartner(), $coreClonedOptionsArray);
     return $this->getEntry($clonedEntry->getId());
 }
예제 #20
0
 /**
  * Clone an entry with optional attributes to apply to the clone
  * 
  * @action clone
  * @param string $entryId Id of entry to clone
  * @param KalturaBaseEntry $updateEntry [optional] Attributes from these entry will be updated into the cloned entry
  * @return KalturaBaseEntry The cloned entry
  * @throws KalturaErrors::ENTRY_ID_NOT_FOUND
  */
 function cloneAction($entryId)
 {
     // Reset criteria filters such that it will be
     entryPeer::setUseCriteriaFilter(false);
     categoryEntryPeer::setUseCriteriaFilter(false);
     // Get the entry
     $coreEntry = entryPeer::retrieveByPK($entryId);
     if (!$coreEntry) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryId);
     }
     // Copy the entry into a new one based on the given partner data.
     $clonedEntry = myEntryUtils::copyEntry($coreEntry, $this->getPartner());
     return $this->getEntry($clonedEntry->getId());
 }
 private function setAllTemplateEntriesToAdminKuser($partnerId, $kuserId)
 {
     $c = new Criteria();
     $c->addAnd(entryPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
     entryPeer::setUseCriteriaFilter(false);
     $allEntries = entryPeer::doSelect($c);
     entryPeer::setUseCriteriaFilter(true);
     foreach ($allEntries as $entry) {
         $entry->setKuserId($kuserId);
         $entry->save();
     }
 }
예제 #22
0
 public static function copyEntry(entry $entry, Partner $toPartner = null, $dontCopyUsers = false)
 {
     KalturaLog::log("copyEntry - Copying entry [" . $entry->getId() . "] to partner [" . $toPartner->getId() . "]");
     $newEntry = $entry->copy();
     $newEntry->setIntId(null);
     $newEntry->setCategories(null);
     $newEntry->setCategoriesIds(null);
     if ($toPartner instanceof Partner) {
         $newEntry->setPartnerId($toPartner->getId());
         $newEntry->setSubpId($toPartner->getId() * 100);
         $newEntry->setAccessControlId($toPartner->getDefaultAccessControlId());
     }
     $newKuser = null;
     if (!$dontCopyUsers) {
         // copy the kuser (if the same puser id exists its kuser will be used)
         kuserPeer::setUseCriteriaFilter(false);
         $kuser = $entry->getKuser();
         $newKuser = kuserPeer::createKuserForPartner($newEntry->getPartnerId(), $kuser->getPuserId());
         $newEntry->setKuserId($newKuser->getId());
         $newEntry->setCreatorKuserId($newKuser->getId());
         kuserPeer::setUseCriteriaFilter(true);
     }
     // copy the kshow
     kshowPeer::setUseCriteriaFilter(false);
     $kshow = $entry->getKshow();
     if ($kshow) {
         $newKshow = $kshow->copy();
         $newKshow->setIntId(null);
         $newKshow->setPartnerId($toPartner->getId());
         $newKshow->setSubpId($toPartner->getId() * 100);
         if ($newKuser) {
             $newKshow->setProducerId($newKuser->getId());
         }
         $newKshow->save();
         $newEntry->setKshowId($newKshow->getId());
     }
     kshowPeer::setUseCriteriaFilter(true);
     // reset the statistics
     myEntryUtils::resetEntryStatistics($newEntry);
     // set the new partner id into the default category criteria filter
     $defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter();
     $oldPartnerId = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId());
     // save the entry
     $newEntry->save();
     // restore the original partner id in the default category criteria filter
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerId);
     KalturaLog::log("copyEntry - New entry [" . $newEntry->getId() . "] was created");
     if ($entry->getStatus() != entryStatus::READY) {
         $clonePendingEntries = $entry->getClonePendingEntries();
         $clonePendingEntries[] = $newEntry->getId();
         $entry->setClonePendingEntries($clonePendingEntries);
         $entry->save();
     } else {
         self::copyEntryData($entry, $newEntry);
     }
     //if entry is a static playlist, link between it and its new child entries
     if ($entry->getType() == entryType::PLAYLIST) {
         switch ($entry->getMediaType()) {
             case entry::ENTRY_MEDIA_TYPE_TEXT:
                 $from = $entry->getDataContent();
                 KalturaLog::debug("Entries to copy from source static playlist: [{$from}]");
                 $fromEntryIds = explode(",", $from);
                 $toEntryIds = array();
                 foreach ($fromEntryIds as $fromEntryId) {
                     $toEntryIds[] = kObjectCopyHandler::getMappedId(entryPeer::OM_CLASS, $fromEntryId);
                 }
                 $newEntry->setDataContent(implode(",", $toEntryIds));
                 break;
             case entry::ENTRY_MEDIA_TYPE_XML:
                 list($totalResults, $fromFiltersList) = myPlaylistUtils::getPlaylistFilterListStruct($entry->getDataContent());
                 $toPlaylistXml = new SimpleXMLElement("<playlist/>");
                 $toPlaylistXml->addChild("total_results", $totalResults);
                 $toFiltersXml = $toPlaylistXml->addChild("filters");
                 foreach ($fromFiltersList as $filterXML) {
                     $entryFilter = new entryFilter();
                     $entryFilter->fillObjectFromXml($filterXML, "_");
                     if (isset($entryFilter->fields["_matchand_categories_ids"])) {
                         $categoriesIds = explode(",", $entryFilter->fields["_matchand_categories_ids"]);
                         $newCategoriesIds = array();
                         foreach ($categoriesIds as $categoryId) {
                             $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
                         }
                         $entryFilter->fields["_matchand_categories_ids"] = implode(",", $newCategoriesIds);
                     }
                     if (isset($entryFilter->fields["_matchor_categories_ids"])) {
                         $categoriesIds = explode(",", $entryFilter->fields["_matchor_categories_ids"]);
                         $newCategoriesIds = array();
                         foreach ($categoriesIds as $categoryId) {
                             $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
                         }
                         $entryFilter->fields["_matchor_categories_ids"] = implode(",", $newCategoriesIds);
                     }
                     if (isset($entryFilter->fields["_in_category_ancestor_id"])) {
                         $categoriesIds = explode(",", $entryFilter->fields["_in_category_ancestor_id"]);
                         $newCategoriesIds = array();
                         foreach ($categoriesIds as $categoryId) {
                             $newCategoriesIds[] = kObjectCopyHandler::getMappedId(categoryPeer::OM_CLASS, $categoryId);
                         }
                         $entryFilter->fields["_in_category_ancestor_id"] = implode(",", $newCategoriesIds);
                     }
                     $toEntryFilterXML = $toFiltersXml->addChild("filter");
                     $toEntryFilterXML = $entryFilter->toXml($toEntryFilterXML);
                 }
                 $newEntry->setDataContent($toPlaylistXml->asXML());
                 break;
         }
     }
     // copy relationships to categories
     KalturaLog::debug('Copy relationships to categories from entry [' . $entry->getId() . '] to entry [' . $newEntry->getId() . ']');
     $c = KalturaCriteria::create(categoryEntryPeer::OM_CLASS);
     $c->addAnd(categoryEntryPeer::ENTRY_ID, $entry->getId());
     $c->addAnd(categoryEntryPeer::STATUS, CategoryEntryStatus::ACTIVE, Criteria::EQUAL);
     $c->addAnd(categoryEntryPeer::PARTNER_ID, $entry->getPartnerId());
     categoryEntryPeer::setUseCriteriaFilter(false);
     $categoryEntries = categoryEntryPeer::doSelect($c);
     categoryEntryPeer::setUseCriteriaFilter(true);
     // Create srcCategoryIdToDstCategoryIdMap - a map of source partner category ids -> dst. partner category ids
     //
     // Build src category IDs set
     $srcCategoryIdSet = array();
     foreach ($categoryEntries as $categoryEntry) {
         $srcCategoryIdSet[] = $categoryEntry->getCategoryId();
     }
     $illegalCategoryStatus = array(CategoryStatus::DELETED, CategoryStatus::PURGED);
     // Get src category objects
     $c = KalturaCriteria::create(categoryPeer::OM_CLASS);
     $c->add(categoryPeer::ID, $srcCategoryIdSet, Criteria::IN);
     $c->addAnd(categoryPeer::PARTNER_ID, $entry->getPartnerId());
     $c->addAnd(categoryPeer::STATUS, $illegalCategoryStatus, Criteria::NOT_IN);
     categoryPeer::setUseCriteriaFilter(false);
     $srcCategories = categoryPeer::doSelect($c);
     categoryPeer::setUseCriteriaFilter(true);
     // Map the category names to their IDs
     $fullNamesToSrcCategoryIdMap = array();
     foreach ($srcCategories as $category) {
         $fullNamesToSrcCategoryIdMap[$category->getFullName()] = $category->getId();
     }
     // Get dst. partner categories based on src. category full-names
     $c = KalturaCriteria::create(categoryPeer::OM_CLASS);
     $c->add(categoryPeer::FULL_NAME, array_keys($fullNamesToSrcCategoryIdMap), KalturaCriteria::IN);
     $c->addAnd(categoryPeer::PARTNER_ID, $newEntry->getPartnerId());
     $c->addAnd(categoryPeer::STATUS, $illegalCategoryStatus, Criteria::NOT_IN);
     categoryPeer::setUseCriteriaFilter(false);
     $dstCategories = categoryPeer::doSelect($c);
     categoryPeer::setUseCriteriaFilter(true);
     $srcCategoryIdToDstCategoryIdMap = array();
     foreach ($dstCategories as $dstCategory) {
         $fullName = $dstCategory->getFullName();
         if (array_key_exists($fullName, $fullNamesToSrcCategoryIdMap)) {
             $srcCategoryId = $fullNamesToSrcCategoryIdMap[$fullName];
             $srcCategoryIdToDstCategoryIdMap[$srcCategoryId] = $dstCategory->getId();
         }
     }
     foreach ($categoryEntries as $categoryEntry) {
         /* @var $categoryEntry categoryEntry */
         $newCategoryEntry = $categoryEntry->copy();
         $newCategoryEntry->setPartnerId($newEntry->getPartnerId());
         $newCategoryEntry->setEntryId($newEntry->getId());
         $srcCategoryId = $categoryEntry->getCategoryId();
         if (!array_key_exists($srcCategoryId, $srcCategoryIdToDstCategoryIdMap)) {
             continue;
             // Skip the category_entry's creation
         }
         $dstCategoryId = $srcCategoryIdToDstCategoryIdMap[$srcCategoryId];
         $newCategoryEntry->setCategoryId($dstCategoryId);
         categoryPeer::setUseCriteriaFilter(false);
         entryPeer::setUseCriteriaFilter(false);
         $newCategoryEntry->save();
         entryPeer::setUseCriteriaFilter(true);
         categoryPeer::setUseCriteriaFilter(true);
     }
     return $newEntry;
 }
예제 #23
0
 /**
  * Will investigate a single entry
  */
 public function execute()
 {
     $partial = $this->getP("partial");
     $this->widget = null;
     $this->forceSystemAuthentication();
     //		myDbHelper::$use_alternative_con = null;
     myDbHelper::$use_alternative_con = myDbHelper::DB_HELPER_CONN_PROPEL2;
     // dont' filter out anything
     entryPeer::setUseCriteriaFilter(false);
     $partner_id = $this->getP("partner_id");
     $this->entries = $this->widget_id = null;
     $this->count = 0;
     $this->page = $this->getP("page", 0);
     $this->page_size = $this->getP("page_size", 25);
     $this->ready_only = $this->getP("ready_only", 0);
     $this->gte_int_id = $this->getP("gte_int_id", null);
     $this->widget_id = $this->getP("widget_id");
     $this->ui_conf_id = $this->getP("ui_conf_id");
     $this->is_playlist = $this->getP("is_playlist");
     $this->playlist_id = $this->getP("playlist_id");
     $offset = $this->page * $this->page_size;
     if ($partner_id !== null) {
         $c = new Criteria();
         if ($partner_id != "ALL") {
             // is is a special backdoor word for viewing all partners
             $c->add(entryPeer::PARTNER_ID, $partner_id);
         }
         if ($this->ready_only) {
             $c->add(entryPeer::STATUS, 2);
         }
         if ($entry_ids = $this->getP("entry_ids")) {
             $entry_id_arr = explode(",", $entry_ids);
             $c->Add(entryPeer::ID, $entry_id_arr, Criteria::IN);
         }
         $search_text = $this->getP("filter__like_search_text");
         if ($search_text) {
             $c->add(entryPeer::SEARCH_TEXT, "%{$search_text}%", Criteria::LIKE);
         }
         if ($this->gte_int_id) {
             $c->add(entryPeer::INT_ID, $this->gte_int_id, Criteria::GREATER_EQUAL);
         }
         if ($this->getP("filter__in_type_all")) {
         } else {
             $media_type_arr = array($this->getP("filter__in_type_1"), $this->getP("filter__in_type_2"), $this->getP("filter__in_type_5"), $this->getP("filter__in_type_6"));
             $c->add(entryPeer::MEDIA_TYPE, $media_type_arr, Criteria::IN);
         }
         if ($this->getP("filter__in_status_all")) {
         } else {
             $status_arr = array($this->getP("filter__in_type_0"), $this->getP("filter__in_type_1"), $this->getP("filter__in_type_2"), $this->getP("filter__in_type_3"), $this->getP("filter__in_type_6"));
             if ($this->getP("filter__in_status_err")) {
                 $status_arr[] = -1;
                 $status_arr[] = -2;
             }
             $c->add(entryPeer::STATUS, $status_arr, Criteria::IN);
         }
         if ($this->getP("filter__gte_created_at")) {
             $c->addAnd(entryPeer::CREATED_AT, $this->getP("filter__gte_created_at"), Criteria::GREATER_EQUAL);
         }
         if ($this->getP("filter__lte_created_at")) {
             $to_date = $this->getP("filter__lte_created_at");
             $timeStamp = strtotime($to_date);
             $timeStamp += 24 * 60 * 60;
             // inc one day
             $to_date_str = date("Y-m-d", $timeStamp);
             $c->addAnd(entryPeer::CREATED_AT, $to_date_str, Criteria::LESS_EQUAL);
         }
         $this->count = entryPeer::doCount($c);
         $c->addAscendingOrderByColumn(entryPeer::INT_ID);
         $c->setLimit($this->page_size);
         $c->setOffset($offset);
         $this->entries = entryPeer::doSelect($c);
         if (!$partial) {
             // no need for widget if displaying partial page
             $d = new Criteria();
             $d->add(widgetPeer::PARTNER_ID, $partner_id);
             if ($this->widget_id) {
                 $d->add(widgetPeer::ID, $this->widget_id);
             } else {
                 $d->add(widgetPeer::SOURCE_WIDGET_ID, "");
             }
             $this->widget = widgetPeer::doSelectOne($d);
             if (!$this->widget) {
                 $d = new Criteria();
                 $d->add(widgetPeer::PARTNER_ID, $partner_id);
                 $d->addAscendingOrderByColumn(widgetPeer::CREATED_AT);
                 $this->widget = widgetPeer::doSelectOne($d);
             }
         }
     }
     if ($this->entries == null) {
         $this->entries = array();
     }
     $this->partner_id = $partner_id;
     if ($partial) {
         return "PartialSuccess";
     }
 }
예제 #24
0
파일: entry.php 프로젝트: AdiTal/server
 public function save(PropelPDO $con = null)
 {
     $is_new = false;
     if ($this->isNew()) {
         $this->setId(self::calculateId());
         // start by setting the modified_at to the current time
         $this->setModifiedAt(time());
         $this->setModerationCount(0);
         if (is_null($this->getAccessControlId())) {
             $partner = $this->getPartner();
             if ($partner) {
                 $this->setAccessControlId($partner->getDefaultAccessControlId());
             }
         }
         // only media clips should increments - not roughcuts or backgrounds
         if ($this->type == entryType::MEDIA_CLIP) {
             myStatisticsMgr::addEntry($this);
         }
         $is_new = true;
     }
     if ($this->type == entryType::MIX) {
         // some of the properties should be copied to the kshow
         $kshow = $this->getkshow();
         if ($kshow) {
             $modified = false;
             if ($kshow->getRank() != $this->getRank()) {
                 $kshow->setRank($this->getRank());
                 $modified = true;
             }
             if ($kshow->getLengthInMsecs() != $this->getLengthInMsecs()) {
                 $kshow->setLengthInMsecs($this->getLengthInMsecs());
                 $modified = true;
             }
             if ($modified) {
                 $kshow->save();
             }
         } else {
             $this->log("entry [" . $this->getId() . "] does not have a real kshow with id [" . $this->getKshowId() . "]", Propel::LOG_WARNING);
         }
     }
     myPartnerUtils::setPartnerIdForObj($this);
     if ($this->getDisplayInSearch() != mySearchUtils::DISPLAY_IN_SEARCH_SYSTEM) {
         mySearchUtils::setDisplayInSearch($this);
     }
     ktagword::updateAdminTags($this);
     // same for puserId ...
     $this->getPuserId();
     // make sure this entry is saved before calling updateAllMetadataVersionsRelevantForEntry, since fixMetadata retrieves the entry from the DB
     // and checks its data path which was modified above.
     $res = parent::save($con);
     if ($is_new) {
         // when retrieving the entry - ignore thr filter - when in partner has moderate_content =1 - the entry will have status=3 and will fail the retrieveByPk
         entryPeer::setUseCriteriaFilter(false);
         $obj = entryPeer::retrieveByPk($this->getId());
         $this->setIntId($obj->getIntId());
         entryPeer::setUseCriteriaFilter(true);
     }
     if ($this->should_call_set_data_content) {
         // calling the funciton with null will cause it to use the $this->data_content
         $this->setDataContent(null);
         $res = parent::save($con);
     }
     // the fix should be done whether the status is READY or ERROR_CONVERTING
     if ($this->getStatus() == entryStatus::READY || $this->getStatus() == entryStatus::ERROR_CONVERTING) {
         // fire some stuff due to the new status
         $version_to_update = $this->getUpdateWhenReady();
         if ($version_to_update) {
             try {
                 myMetadataUtils::updateAllMetadataVersionsRelevantForEntry($this);
                 $this->resetUpdateWhenReady();
                 $res = parent::save($con);
             } catch (Exception $e) {
                 KalturaLog::err($e->getMessage());
             }
         }
     }
     $this->syncCategories();
     return $res;
 }
 private function setAllTemplateEntriesToAdminKuser($partnerId, $kuserId)
 {
     $c = new Criteria();
     $c->addAnd(entryPeer::PARTNER_ID, $partnerId, Criteria::EQUAL);
     entryPeer::setUseCriteriaFilter(false);
     $allEntries = entryPeer::doSelect($c);
     entryPeer::setUseCriteriaFilter(true);
     // set the new partner id into the default category criteria filter
     $defaultCategoryFilter = categoryPeer::getCriteriaFilter()->getFilter();
     $oldPartnerIdCategory = $defaultCategoryFilter->get(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $partnerId);
     // set the new partner id into the default category criteria filter
     $defaultCategoryEntryFilter = categoryEntryPeer::getCriteriaFilter()->getFilter();
     $oldPartnerIdCategoryEntry = $defaultCategoryFilter->get(categoryEntryPeer::PARTNER_ID);
     $defaultCategoryEntryFilter->remove(categoryEntryPeer::PARTNER_ID);
     $defaultCategoryEntryFilter->addAnd(categoryEntryPeer::PARTNER_ID, $partnerId);
     foreach ($allEntries as $entry) {
         $entry->setKuserId($kuserId);
         $entry->setCreatorKuserId($kuserId);
         $entry->save();
     }
     kEventsManager::flushEvents();
     // restore the original partner id in the default category criteria filter
     $defaultCategoryFilter->remove(categoryPeer::PARTNER_ID);
     $defaultCategoryFilter->addAnd(categoryPeer::PARTNER_ID, $oldPartnerIdCategory);
     $defaultCategoryEntryFilter->remove(categoryEntryPeer::PARTNER_ID);
     $defaultCategoryEntryFilter->addAnd(categoryEntryPeer::PARTNER_ID, $oldPartnerIdCategoryEntry);
 }