/**
  * If 
  */
 public static function createWidgetFromWidget($parent_widget_obj_or_id, $kshow_id, $entry_id = null, $ui_conf_id = null, $custom_data = null, $partner_data = null, $security_type = null)
 {
     if ($parent_widget_obj_or_id == null) {
         throw new Exception("Cannot createWidget from empty object");
     }
     if ($parent_widget_obj_or_id instanceof widget) {
         $source_widget = $parent_widget_obj_or_id;
     } else {
         // assume its an id
         $source_widget = widgetPeer::retrieveByPK($parent_widget_obj_or_id);
         if (!$source_widget) {
             throw new Exception("Cannot createWidget from a none-existing widget [{$parent_widget_obj_or_id}]");
         }
     }
     $kshow = null;
     $widget_kshow_id = $source_widget->getKshowId();
     if (!$widget_kshow_id) {
         // fetch the kshow/entry according to the kshow_id/entry_id rules
         list($kshow, $entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $entry_id);
         $widget_kshow_id = $kshow_id;
         if ($source_widget->getEntryId()) {
             $entry_id = $source_widget->getEntryId();
         }
     }
     if (!$kshow) {
         $kshow = kshowPeer::retrieveByPK($widget_kshow_id);
         if (!$kshow) {
             return null;
         }
     }
     return self::createWidget($kshow, $entry_id, $source_widget, $ui_conf_id, $custom_data, $partner_data, $security_type);
 }
 public static function getTopBands($number_of_results = self::NUMBER_OF_TOP_TO_DISPLAY, $rand = true)
 {
     if (self::$s_top_list_cache == NULL) {
         self::$s_top_list_cache = new myCache("topList", self::TOP_LIST_EXPIRY_IN_SECONDS);
     }
     $top_list_name = "kshowBands";
     //get_class( $cls );
     $top_list_full = self::$s_top_list_cache->get($top_list_name);
     if ($top_list_full == NULL) {
         $featuredIds = array(26404, 42551, 31401, 31554, 12913, 18309, 13411, 11931, 15789, 13948, 13380, 13929, 21944, 23057);
         //$top_list_full = kshowPeer::retrieveByPks($featuredIds);
         $c = new Criteria();
         $c->add(kshowPeer::ID, $featuredIds, Criteria::IN);
         $top_list_full = kshowPeer::doSelectJoinkuser($c);
         self::$s_top_list_cache->put($top_list_name, $top_list_full);
     }
     //if ( $number_of_results < 1 ) $number_of_results = self::NUMBER_OF_TOP_TO_DISPLAY;
     if ($rand) {
         // shuffle the array and return the first  $number_of_results
         if (is_array($top_list_full)) {
             shuffle($top_list_full);
         }
     }
     if (count($top_list_full) > $number_of_results) {
         $top_list_full = array_slice($top_list_full, 0, $number_of_results);
     }
     return $top_list_full;
 }
 public function execute()
 {
     $this->getResponse()->setHttpHeader("Content-Type", "application/x-javascript");
     $kshow_id = $this->getRequestParameter('kshow_id', 0);
     $uid = kuser::ANONYMOUS_PUSER_ID;
     $kshow = kshowPeer::retrieveByPK($kshow_id);
     if (!$kshow) {
         return sfView::ERROR;
     }
     // kshow_id might be a string (something like "15483str") but it will be returned using retriveByPK anyways
     // lets make sure we pass just the id to the contribution wizard
     $kshow_id = $kshow->getId();
     $partner_id = $kshow->getPartnerId();
     $partner = PartnerPeer::retrieveByPK($partner_id);
     $subp_id = $kshow->getSubpId();
     $partner_secret = $partner->getSecret();
     $partner_name = $partner->getPartnerName();
     $kaltura_services = new startsessionAction();
     $kaltura_services->setInputParams(array("format" => kalturaWebserviceRenderer::RESPONSE_TYPE_PHP_ARRAY, "partner_id" => $partner_id, "subp_id" => $subp_id, "uid" => $uid, "secret" => $partner_secret));
     $result = $kaltura_services->internalExecute();
     $this->ks = @$result["result"]["ks"];
     $this->widget_host = requestUtils::getHost();
     $this->kshow_id = $kshow_id;
     $this->uid = $uid;
     $this->partner_id = $partner_id;
     $this->subp_id = $subp_id;
     $this->partner_name = $partner_name;
     return sfView::SUCCESS;
 }
示例#4
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshow_id = $this->getPM("kshow_id");
     $detailed = $this->getP("detailed", false);
     $kshow_indexedCustomData3 = $this->getP("indexedCustomData3");
     $kshow = null;
     if ($kshow_id == kshow::KSHOW_ID_USE_DEFAULT) {
         // see if the partner has some default kshow to add to
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser);
         if ($kshow) {
             $kshow_id = $kshow->getId();
         }
     } elseif ($kshow_id) {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
     } elseif ($kshow_indexedCustomData3) {
         $kshow = kshowPeer::retrieveByIndexedCustomData3($kshow_indexedCustomData3);
     }
     if (!$kshow) {
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
     } else {
         $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR;
         $wrapper = objectWrapperBase::getWrapperClass($kshow, $level);
         // TODO - remove this code when cache works properly when saving objects (in their save method)
         $wrapper->removeFromCache("kshow", $kshow_id);
         $this->addMsg("kshow", $wrapper);
     }
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $this->response_type = kalturaWebserviceRenderer::RESPONSE_TYPE_HTML;
     //
     $widget_id = $this->getP("widget_id");
     $kshow_id = $this->getP("kshow_id");
     $entry_id = $this->getP("entry_id");
     $widget_type = $this->getP("widget_type", 1);
     // TODO -decide on a good default;
     if ($widget_id) {
         $this->addMsg("<b>", $this->createGenericWidgetHtml2($partner_id, $subp_id, $puser_id));
         return;
     }
     if (in_array($partner_id, array(321, 449))) {
         $widget_type = 60;
     }
     list($kshow, $entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $entry_id);
     if ($error_obj) {
         $this->addError($error_obj);
         return;
     }
     $kshow = kshowPeer::retrieveByPK($kshow_id);
     if (!$kshow) {
         $this->addMsg("<b>", "Error: no such {$kshow_id}");
         return;
     }
     $this->addMsg("<b>", $this->createGenericWidgetHtml($partner_id, $subp_id, $kshow_id, $puser_id, $widget_type));
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $obj_type = $this->getPM("obj_type");
     $obj_id = $this->getPM("obj_id");
     $command = $this->getPM("command");
     $value = $this->getP("value");
     $extra_info = $this->getP("extra_info");
     if ($obj_type == "entry") {
         $entry = entryPeer::retrieveByPK($obj_id);
         if ($command == "view") {
             PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_VIEWS);
             myStatisticsMgr::incEntryViews($entry);
         } elseif ($command == "play") {
             PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_PLAYS);
             myStatisticsMgr::incEntryPlays($entry);
         }
     } elseif ($obj_type == "kshow") {
         $kshow = kshowPeer::retrieveByPK($obj_id);
         if ($command == "view") {
             PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_VIEWS);
             myStatisticsMgr::incKshowViews($kshow);
         } elseif ($command == "play") {
             PartnerActivity::incrementActivity($partner_id, PartnerActivity::PARTNER_ACTIVITY_KDP, PartnerActivity::PARTNER_SUB_ACTIVITY_KDP_PLAYS);
             myStatisticsMgr::incKshowPlays($kshow);
         }
     }
     $this->addMsg("collectedStats", "{$obj_type}, {$obj_id}, {$command}, {$value}, {$extra_info}");
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshow_id = $this->getP("kshow_id");
     $detailed = $this->getP("detailed", false);
     $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR;
     $widget_size = $this->getP("size");
     $kshow_from_db = null;
     if ($kshow_id) {
         $kshow_from_db = kshowPeer::retrieveByPK($kshow_id);
     }
     if ($kshow_from_db) {
         $this->addMsg("kshow", objectWrapperBase::getWrapperClass($kshow_from_db, $level));
         $this->addMsg("already_exists_objects", 1);
         $this->addDebug("already_exists_objects", 1);
     } else {
         // no kshow to be found - creae a new one
         parent::executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser);
     }
     // create widget code for the new kshow
     $kshow = $this->getMsg("kshow");
     $kshow_id = $kshow->id;
     list($genericWidget, $myspaceWidget) = myKshowUtils::getEmbedPlayerUrl($kshow_id, null, false, "");
     $code = array("generic_code" => $genericWidget, "myspace_code" => $myspaceWidget);
     $this->addMsg("widget_code", $code);
 }
示例#8
0
 public function clearMemory()
 {
     accessControlPeer::clearInstancePool();
     BatchJobPeer::clearInstancePool();
     BulkUploadResultPeer::clearInstancePool();
     categoryPeer::clearInstancePool();
     EmailIngestionProfilePeer::clearInstancePool();
     entryPeer::clearInstancePool();
     FileSyncPeer::clearInstancePool();
     flavorAssetPeer::clearInstancePool();
     flavorParamsConversionProfilePeer::clearInstancePool();
     flavorParamsOutputPeer::clearInstancePool();
     flavorParamsPeer::clearInstancePool();
     kshowPeer::clearInstancePool();
     mediaInfoPeer::clearInstancePool();
     moderationFlagPeer::clearInstancePool();
     moderationPeer::clearInstancePool();
     notificationPeer::clearInstancePool();
     roughcutEntryPeer::clearInstancePool();
     SchedulerConfigPeer::clearInstancePool();
     SchedulerPeer::clearInstancePool();
     SchedulerStatusPeer::clearInstancePool();
     SchedulerWorkerPeer::clearInstancePool();
     StorageProfilePeer::clearInstancePool();
     syndicationFeedPeer::clearInstancePool();
     TrackEntryPeer::clearInstancePool();
     uiConfPeer::clearInstancePool();
     UploadTokenPeer::clearInstancePool();
     // TODO clear default filters
     // TODO call all memory cleaner plugins
     if (function_exists('gc_collect_cycles')) {
         // php 5.3 and above
         gc_collect_cycles();
     }
 }
示例#9
0
 public function getObject()
 {
     if ($this->m_object) {
         return $this->m_object;
     }
     $object_id = $this->object_id;
     if ($object_id == null) {
         return null;
     }
     switch ($this->getObjectType()) {
         case self::MODERATION_OBJECT_TYPE_KSHOW:
             $this->m_object = kshowPeer::retrieveByPK($object_id);
             break;
         case self::MODERATION_OBJECT_TYPE_ENTRY:
             // be able to fetch entries that are deleted
             entryPeer::allowDeletedInCriteriaFilter();
             $this->m_object = entryPeer::retrieveByPK($object_id);
             entryPeer::blockDeletedInCriteriaFilter();
             break;
         case self::MODERATION_OBJECT_TYPE_USER:
             // $object_id is the puser_id
             $puser_kuser = PuserKuserPeer::retrieveByPartnerAndUid($this->getPartnerId(), NULL, $object_id, true);
             if ($puser_kuser && $puser_kuser->getKuser()) {
                 $this->m_object = $puser_kuser->getKuser();
             }
             //				$this->m_object = kuserPeer::retrieveByPK( $object_id );
             break;
     }
     return $this->m_object;
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshow_id = $this->getP("kshow_id", kshow::KSHOW_ID_USE_DEFAULT);
     $entry = null;
     if ($kshow_id == kshow::KSHOW_ID_USE_DEFAULT) {
         // see if the partner has some default kshow to add to
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser);
         if ($kshow) {
             $kshow_id = $kshow->getId();
         }
     } elseif ($kshow_id == kshow::KSHOW_ID_CREATE_NEW) {
         // if the partner allows - create a new kshow
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, true);
         if ($kshow) {
             $kshow_id = $kshow->getId();
             $entry = $kshow->getShowEntry();
             // use the newly created kshow's roughcut
         }
     } else {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
     }
     if (!$kshow) {
         // the partner is attempting to add an entry to some invalid or non-existing kwho
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
         return;
     }
     if (!$entry) {
         $entry = $kshow->createEntry(entry::ENTRY_MEDIA_TYPE_SHOW, $kshow->getProducerId(), "&auto_edit.jpg", "");
     }
     $obj_wrapper = objectWrapperBase::getWrapperClass($entry, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $entry, $this->getObjectPrefix() . "_", array("name", "tags", "groupId", "partnerData", "permissions", "screenName", "description", "indexedCustomData1"));
     $entry->save();
     $this->addMsg($this->getObjectPrefix(), objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR));
     $this->addDebug("added_fields", $fields_modified);
 }
示例#11
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshow_id = $this->getPM("kshow_id");
     $detailed = $this->getP("detailed", false);
     $kshow_indexedCustomData3 = $this->getP("indexedCustomData3");
     $kshow = null;
     if ($kshow_id) {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
     } elseif ($kshow_indexedCustomData3) {
         $kshow = kshowPeer::retrieveByIndexedCustomData3($kshow_indexedCustomData3);
     }
     if (!$kshow) {
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
     } else {
         $newKshow = myKshowUtils::shalowCloneById($kshow_id, $puser_kuser->getKuserId());
         if (!$newKshow) {
             $this->addError(APIErrors::KSHOW_CLONE_FAILED, $kshow_id);
         } else {
             $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR;
             $wrapper = objectWrapperBase::getWrapperClass($newKshow, $level);
             // TODO - remove this code when cache works properly when saving objects (in their save method)
             $wrapper->removeFromCache("kshow", $newKshow->getId());
             $this->addMsg("kshow", $wrapper);
         }
     }
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     if (!$puser_kuser) {
         $this->addError(APIErrors::INVALID_USER_ID, $puser_id);
         return;
     }
     $kshow_id = $this->getPM("kshow_id");
     $kshow = kshowPeer::retrieveByPK($kshow_id);
     // even in case of an error - return the kshow object
     if (!$kshow) {
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
         return;
     } else {
         $desired_version = $this->getPM("kshow_version");
         $result = $kshow->rollbackVersion($desired_version);
         if (!$result) {
             $this->addError(APIErrors::ERROR_KSHOW_ROLLBACK, $kshow_id, $desired_version);
             return;
         }
     }
     // after calling this method - most probably the state of the kshow has changed in the cache
     $wrapper = objectWrapperBase::getWrapperClass($kshow, objectWrapperBase::DETAIL_LEVEL_REGULAR);
     $wrapper->removeFromCache("kshow", $kshow_id);
     $this->addMsg("kshow", $wrapper);
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     $partner_id = $this->getRequestParameter('partner_id', -1);
     if ($partner_id >= 0) {
         myPartnerUtils::applyPartnerFilters($partner_id);
     }
     $this->partner_id = $partner_id;
     $order = $this->getRequestParameter('sort', kshow::KSHOW_SORT_MOST_VIEWED);
     $page = $this->getRequestParameter('page', 1);
     //$this->producer_id = $this->getRequestParameter('producer_id', 0 );
     //$this->kaltura_part_of_flag = $this->getRequestParameter('partof', 0 );
     $pager = kshowPeer::getOrderedPager($order, 10, $page);
     $kshow_list = $pager->getResults();
     dashboardUtils::updateKshowsRoughcutCount($kshow_list);
     $kshowsData = array();
     foreach ($kshow_list as $kshow) {
         $kshowsData[] = $this->createKShowData($kshow, $order);
     }
     // following variables will be used by the view
     $this->firstTime = $this->getRequestParameter('first', 1) == 1;
     $this->order = $order;
     $this->page = $page;
     $this->lastPage = $pager->getLastPage();
     $this->numResults = $pager->getNbResults();
     $this->kshowsData = $kshowsData;
     // allow the action buttons to show only for shows the user produced, and only for authenticated users, on their own pages
     $this->allowactions = true;
     // !$this->kaltura_part_of_flag && $this->getUser()->isAuthenticated() && $this->getUser()->getAttribute('id') == $this->producer_id;
 }
 /**
  * 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;
 }
 public function execute()
 {
     $this->forceSystemAuthentication();
     $kshow_id = @$_REQUEST["kshow_id"];
     $this->kshow_id = $kshow_id;
     $this->kshow = NULL;
     $entry_id = @$_REQUEST["entry_id"];
     $this->entry_id = $entry_id;
     $this->entry = NULL;
     $this->message = "";
     if (!empty($kshow_id)) {
         $this->kshow = kshowPeer::retrieveByPK($kshow_id);
         if (!$this->kshow) {
             $this->message = "Cannot find kshow [{$kshow_id}]";
         } else {
             $this->entry = $this->kshow->getShowEntry();
         }
     } elseif (!empty($kshow_id)) {
         $this->entry = entryPeer::retrieveByPK($entry_id);
         if (!$this->entry) {
             $this->message = "Cannot find entry [{$entry_id}]";
         } else {
             $this->kshow = $this->{$this}->entry->getKshow();
         }
     }
     if ($this->kshow) {
         $this->metadata = $this->kshow->getMetadata();
     } else {
         $this->metadata = "";
     }
     $pending_str = $this->getP("pending");
     $remove_pending = $this->getP("remove_pending");
     if ($this->metadata && ($remove_pending || $pending_str)) {
         if ($remove_pending) {
             $pending_str = "";
         }
         $xml_doc = new DOMDocument();
         $xml_doc->loadXML($this->metadata);
         $metadata = kXml::getFirstElement($xml_doc, "MetaData");
         $should_save = kXml::setChildElement($xml_doc, $metadata, "Pending", $pending_str, true);
         if ($remove_pending) {
             $should_save = kXml::setChildElement($xml_doc, $metadata, "LastPendingTimeStamp", "", true);
         }
         if ($should_save) {
             $fixed_content = $xml_doc->saveXML();
             $content_dir = myContentStorage::getFSContentRootPath();
             $file_name = realpath($content_dir . $this->entry->getDataPath());
             $res = file_put_contents($file_name, $fixed_content);
             // sync - NOTOK
             $this->metadata = $fixed_content;
         }
     }
     $this->pending = $pending_str;
     $this->kshow_id = $kshow_id;
     $this->entry_id = $entry_id;
 }
示例#16
0
 public static function getKshowEntryId($kshow_id, $entry_id)
 {
     if ($entry_id == -1) {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
         if ($kshow) {
             $entry_id = $kshow->getShowEntryId();
         }
     }
     return $entry_id;
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshow_id_to_delete = $this->getPM("kshow_id");
     $kshow_to_delete = kshowPeer::retrieveByPK($kshow_id_to_delete);
     if (!$kshow_to_delete) {
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id_to_delete);
         return;
     }
     $kshow_to_delete->delete();
     myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_KSHOW_DELETE, $kshow_to_delete);
     $this->addMsg("deleted_kshow", objectWrapperBase::getWrapperClass($kshow_to_delete, objectWrapperBase::DETAIL_LEVEL_REGULAR));
 }
示例#18
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     // get the new properties for the kuser from the request
     $dvd_entry = new entry();
     $this->getTypeAndMediaType($dvd_entry);
     // important to set type before the auto-fill so the setDataContent will work properly
     $dvd_entry->setLengthInMsecs(0);
     $obj_wrapper = objectWrapperBase::getWrapperClass($dvd_entry, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $dvd_entry, $this->getObjectPrefix() . "_", $obj_wrapper->getUpdateableFields());
     // check that mandatory fields were set
     // TODO
     $new_widget = null;
     if (count($fields_modified) > 0) {
         $kshow_id = $this->getP("kshow_id", kshow::KSHOW_ID_USE_DEFAULT);
         if ($kshow_id == kshow::KSHOW_ID_USE_DEFAULT) {
             // see if the partner has some default kshow to add to
             $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser);
             if ($kshow) {
                 $kshow_id = $kshow->getId();
             }
         } elseif ($kshow_id == kshow::KSHOW_ID_CREATE_NEW) {
             // if the partner allows - create a new kshow
             $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, true);
             if ($kshow) {
                 $kshow_id = $kshow->getId();
             }
         } else {
             $kshow = kshowPeer::retrieveByPK($kshow_id);
         }
         if (!$kshow) {
             // the partner is attempting to add an entry to some invalid or non-existing kwho
             $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
             return;
         }
         // force the type and media type
         // TODO - set the kshow to some default kshow of the partner - maybe extract it from the custom_data of this specific partner
         $dvd_entry->setKshowId($kshow_id);
         $dvd_entry->setStatus(entryStatus::READY);
         $dvd_entry->setPartnerId($partner_id);
         $dvd_entry->setSubpId($subp_id);
         $dvd_entry->setKuserId($puser_kuser->getKuserId());
         $dvd_entry->setCreatorKuserId($puser_kuser->getKuserId());
         $dvd_entry->save();
         $this->addMsg($this->getObjectPrefix(), objectWrapperBase::getWrapperClass($dvd_entry, objectWrapperBase::DETAIL_LEVEL_DETAILED));
         $this->addDebug("added_fields", $fields_modified);
     } else {
         $this->addError(APIErrors::NO_FIELDS_SET_FOR_GENERIC_ENTRY, $this->getObjectPrefix());
     }
 }
 /**
  * Will forward to the the thumbnail of the kshows using the widget id
  */
 public function execute()
 {
     $widget_id = $this->getRequestParameter("wid");
     $widget = widgetPeer::retrieveByPK($widget_id);
     if (!$widget) {
         die;
     }
     // because of the routing rule - the entry_id & kmedia_type WILL exist. be sure to ignore them if smaller than 0
     $kshow_id = $widget->getKshowId();
     if ($kshow_id) {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
         if ($kshow->getShowEntry()) {
             $this->redirect($kshow->getShowEntry()->getBigThumbnailUrl());
         }
     }
 }
示例#20
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $kshow_id = $this->getPM("kshow_id");
     $rank = $this->getPM("rank");
     $kshow = kshowPeer::retrieveByPK($kshow_id);
     if (!$kshow) {
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
         return;
     }
     if ($rank > entry::MAX_NORMALIZED_RANK || $rank < 0 || !is_numeric($rank)) {
         $this->addError(APIErrors::INVALID_RANK, $rank);
         return;
     }
     $kuser_id = $puser_kuser->getKuserId();
     $entry_id = $kshow->getShowEntryId();
     $partner = PartnerPeer::retrieveByPK($partner_id);
     if (!$partner->getAllowAnonymousRanking()) {
         // prevent duplicate votes
         $c = new Criteria();
         $c->add(kvotePeer::KUSER_ID, $kuser_id);
         $c->add(kvotePeer::ENTRY_ID, $entry_id);
         $c->add(kvotePeer::KSHOW_ID, $kshow_id);
         $kvote = kvotePeer::doSelectOne($c);
         if ($kvote != NULL) {
             $this->addError(APIErrors::USER_ALREADY_RANKED_KSHOW, $puser_id, $kshow_id);
             return;
         }
     }
     $kvote = new kvote();
     $kvote->setKshowId($kshow_id);
     $kvote->setEntryId($entry_id);
     $kvote->setKuserId($kuser_id);
     $kvote->setRank($rank);
     $kvote->save();
     $statistics_results = $kvote->getStatisticsResults();
     $updated_kshow = @$statistics_results["kshow"];
     if ($updated_kshow) {
         myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_KSHOW_RANK, $updated_kshow);
         $data = array("kshow_id" => $kshow_id, "uid" => $puser_id, "rank" => $updated_kshow->getRank(), "votes" => $updated_kshow->getVotes());
         //$this->addMsg ( "kshow" , objectWrapperBase::getWrapperClass( $updated_kshow , objectWrapperBase::DETAIL_LEVEL_DETAILED) );
         $this->addMsg("rank", $data);
     }
 }
示例#21
0
 /**
 	 * 
 select kshow.id,concat('http://www.kaltura.com/index.php/browse/bands?band_id=',indexed_custom_data_1),concat('http://profile.myspace.com/index.cfm?fuseaction=user.viewpr
 ofile&friendID=',indexed_custom_data_1) ,  kuser.screen_name , indexed_custom_data_1  from kshow ,kuser where kshow.partner_id=5 AND kuser.id=kshow.producer_id AND kshow.
 id>=10815  order by kshow.id ;
 ~
 */
 public function execute()
 {
     //	$this->forceSystemAuthentication();
     $from = $this->getRequestParameter("from", null);
     $to = $this->getRequestParameter("to", null);
     $limit = $this->getRequestParameter("limit", 100);
     $c = new Criteria();
     $c->setLimit($limit);
     $c->add(kshowPeer::PARTNER_ID, 5);
     // myspace
     $c->addAscendingOrderByColumn(kshowPeer::ID);
     if (!empty($from)) {
         $c->addAnd(kshowPeer::ID, $from, Criteria::GREATER_EQUAL);
     }
     if (!empty($to)) {
         $c->addAnd(kshowPeer::ID, $to, Criteria::LESS_EQUAL);
     }
     $this->band_list = kshowPeer::doSelectJoinkuser($c);
 }
 public function createMetadata($kshow_id)
 {
     //		echo ( "createMetadata for [$kshow_id]\n" );
     $kshow = kshowPeer::retrieveByPK($kshow_id);
     $show_entry_id = $kshow->getShowEntryId();
     $intro_id = $kshow->getIntroId();
     // fetch all entries for a kshow without the kshow entry or the intro
     // the order is ascending by creation date of the entry
     // if ordering by ascending ID - the intro will always be first
     $c = new Criteria();
     $c->add(entryPeer::KSHOW_ID, $kshow_id);
     $c->add(entryPeer::ID, array($show_entry_id, $intro_id), Criteria::NOT_IN);
     //		$c->addDescendingOrderByColumn('(' . entryPeer::ID . '=' . $intro_id . ')');
     $c->addAscendingOrderByColumn(entryPeer::ID);
     //		$c->add ( entryPeer::STATUS , entryStatus::READY );
     //		$c->addAscendingOrderByColumn( entryPeer::CREATED_AT );
     $entry_list = entryPeer::doSelect($c);
     //		echo ( "kshow [$kshow_id] has " . count ( $entry_list ) . " entries\n" );
     return $this->createMetadataForList($entry_list);
 }
示例#23
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     // get the new properties for the kuser from the request
     $widget = new widget();
     $obj_wrapper = objectWrapperBase::getWrapperClass($widget, 0);
     $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $widget, "widget_", $obj_wrapper->getUpdateableFields());
     // check that mandatory fields were set
     // TODO
     $new_widget = null;
     if (count($fields_modified) > 0) {
         // see if to create a widget from a widget or from a kshow
         if ($widget->getSourceWidgetId()) {
             $widget_from_db = widgetPeer::retrieveByPK($widget->getSourceWidgetId());
             $new_widget = widget::createWidgetFromWidget($widget_from_db, $widget->getKshowId(), $widget->getEntryId(), $widget->getUiConfId(), $widget->getCustomData(), $widget->getPartnerData(), $widget->getSecurityType());
             if (!$new_widget) {
                 $this->addError(APIErrors::INVALID_KSHOW_AND_ENTRY_PAIR, $widget->getKshowId(), $widget->getEntryId());
                 return;
             }
         } else {
             $kshow_id = $widget->getKshowId();
             if ($kshow_id) {
                 $kshow = kshowPeer::retrieveByPK($kshow_id);
                 if (!$kshow) {
                     $this->addError(APIErrors::KSHOW_DOES_NOT_EXISTS);
                     // This field in unique. Please change ");
                     return;
                 }
             } else {
                 $kshow = new kshow();
                 $kshow->setId(0);
                 $kshow->setPartnerId($partner_id);
                 $kshow->setSubpId($subp_id);
             }
             $new_widget = widget::createWidget($kshow, $widget->getEntryId(), null, $widget->getUiConfId(), $widget->getCustomData(), $widget->getPartnerData(), $widget->getSecurityType());
         }
         $this->addMsg("widget", objectWrapperBase::getWrapperClass($new_widget, objectWrapperBase::DETAIL_LEVEL_DETAILED));
         $this->addDebug("added_fields", $fields_modified);
     } else {
         $this->addError(APIErrors::NO_FIELDS_SET_FOR_WIDGET);
     }
 }
示例#24
0
 public function execute()
 {
     $hdr = "text/xml; charset=utf-8";
     $this->response->setHttpHeader("Content-Type", $hdr);
     $movie = $this->getP("movie");
     if ($movie) {
         //@list ( $obj_type , $id ) = explode ( "_" , $movie );
         // Gonen 28/03/2010: changed code to support both Andromeda style entry ID (0_XXX....) and old style entry ID (chars only)
         $obj_type = @substr($movie, 0, strpos($movie, '_'));
         $id = @str_replace($obj_type . '_', '', $movie);
         if ($obj_type == "entry") {
             return $this->renderText(self::renderEntry($id));
         } else {
             $kshow = kshowPeer::retrieveByPK($id);
             if ($kshow) {
                 return $this->renderText(self::renderEntry($kshow->getShowEntryId()));
             }
         }
     }
     return $this->renderText("OK");
 }
 /**
  * test several mandatory elements in the system.
  * if one of them doesn't work - DIE !
  * this will prevent users to see half baked pages
  */
 private function healthCheck()
 {
     try {
         $request = $this->getContext()->getRequest();
         $r = new sfWebRequest();
         if ($request->isXmlHttpRequest()) {
             // don't tdo the heavy tests for ajax
             return;
         }
         // 	memcache
         $dummy_cache = new myCache("healthCheck");
         // TODO - performance
         // DB
         $c = new Criteria();
         $c->add(kshowPeer::ID, 1);
         $id_list = kshowPeer::selectIdsForCriteria($c);
     } catch (Exception $ex) {
         // on error - redirect to maintenance page
         $context = $this->getContext();
         return $context->getController()->redirect(self::ERROR_URL);
     }
 }
示例#26
0
 private static function getCachedKshowList($config_param_name, $fallback = NULL)
 {
     return array();
     self::init();
     // becuase the $config_param_name is unique in the config - use it in the cache too
     $cached_show_list = self::$s_cache->get($config_param_name);
     if ($cached_show_list == NULL) {
         // read the ids from config
         $id_list = self::$s_config->getList($config_param_name);
         if ($id_list == NULL && !$fallback) {
             $id_list = self::$s_config->getList($fallback);
         }
         if ($id_list == NULL) {
             throw new Exception("Cannot find featured list in app.yml (key=" . $config_param_name . ")");
         }
         $c = new Criteria();
         $c->add(kshowPeer::ID, $id_list, Criteria::IN);
         // fetch the real kshows from the DB
         $kshow_list = kshowPeer::doSelectJoinkuser($c);
         // create stub objects with only the minimum data from the real kshow
         $cached_show_list = array();
         $temp_array = array();
         // the order is not the one we had in the $id_list - it's sorted by the DB
         foreach ($kshow_list as $kshow) {
             $temp_array[$kshow->getId()] = new kshowStub($kshow);
         }
         $i = 0;
         foreach ($id_list as $id) {
             if (key_exists($id, $temp_array)) {
                 $cached_show_list[$i] = $temp_array[$id];
                 ++$i;
             }
         }
         // store the stub list in the cache for next time
         self::$s_cache->put($config_param_name, $cached_show_list);
     }
     return $cached_show_list;
 }
示例#27
0
 public static function getExtData($kshow_id, $partner_id)
 {
     $kshow = kshowPeer::retrieveByPK($kshow_id);
     $show_entry_id = $kshow->getShowEntryId();
     $show_entry = entryPeer::retrieveByPK($show_entry_id);
     $show_entry_data_key = $show_entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA);
     if ($show_entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW) {
         return array(null, null);
     }
     $content = kFileSyncUtils::file_get_contents($show_entry_data_key);
     if ($content == "") {
         return array(null, null);
     }
     $xml_doc = new DOMDocument();
     $xml_doc->loadXML($content);
     $xpath = new DOMXPath($xml_doc);
     $extDataNodelist = $xpath->query("//ExtData[@partner_id='{$partner_id}']");
     $node = null;
     if ($extDataNodelist && $extDataNodelist->length) {
         $node = $extDataNodelist->item(0);
     }
     return array($xml_doc, $node);
 }
 protected function getKshow($partner_id, $subp_id, $puser_kuser, $kshow_id, $entry)
 {
     if ($kshow_id == kshow::KSHOW_ID_USE_DEFAULT) {
         // see if the partner has some default kshow to add to
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser);
         if ($kshow) {
             $kshow_id = $kshow->getId();
         }
     } elseif ($kshow_id == kshow::KSHOW_ID_CREATE_NEW) {
         // if the partner allows - create a new kshow
         $kshow = myPartnerUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, null, true);
         if ($kshow) {
             $kshow_id = $kshow->getId();
         }
     } else {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
     }
     if (!$kshow) {
         // the partner is attempting to add an entry to some invalid or non-existing kwho
         $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
         return;
     }
     return $kshow;
 }
示例#29
0
文件: Basekshow.php 项目: wzur/server
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @return     Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = new Criteria(kshowPeer::DATABASE_NAME);
     $criteria->add(kshowPeer::ID, $this->id);
     if ($this->alreadyInSave) {
         if ($this->isColumnModified(kshowPeer::CUSTOM_DATA)) {
             if (!is_null($this->custom_data_md5)) {
                 $criteria->add(kshowPeer::CUSTOM_DATA, "MD5(cast(" . kshowPeer::CUSTOM_DATA . " as char character set latin1)) = '{$this->custom_data_md5}'", Criteria::CUSTOM);
             } else {
                 $criteria->add(kshowPeer::CUSTOM_DATA, NULL, Criteria::ISNULL);
             }
         }
         if (count($this->modifiedColumns) == 2 && $this->isColumnModified(kshowPeer::UPDATED_AT)) {
             $theModifiedColumn = null;
             foreach ($this->modifiedColumns as $modifiedColumn) {
                 if ($modifiedColumn != kshowPeer::UPDATED_AT) {
                     $theModifiedColumn = $modifiedColumn;
                 }
             }
             $atomicColumns = kshowPeer::getAtomicColumns();
             if (in_array($theModifiedColumn, $atomicColumns)) {
                 $criteria->add($theModifiedColumn, $this->getByName($theModifiedColumn, BasePeer::TYPE_COLNAME), Criteria::NOT_EQUAL);
             }
         }
     }
     return $criteria;
 }
 public function getLastKshowUrl()
 {
     // return the last kshow_id created by this kuser
     $c = new Criteria();
     $c->add(kshowPeer::PRODUCER_ID, $this->getId());
     $c->addDescendingOrderByColumn(kshowPeer::ID);
     $kshow = kshowPeer::doSelectOne($c);
     $host = requestUtils::getHost() . "/";
     if ($kshow) {
         return "<a href='" . $host . "/id/" . $kshow->getId() . "'>" . $kshow->getName() . "</a>";
     } else {
         // This should never happen
         return "<a href='" . $host . "'>Kaltura</a>";
     }
 }