public function execute()
 {
     $kshow_id = $this->getRequestParameter('kshow_id', '');
     $this->kshowdataarray = myKshowUtils::getRelatedShowsData($kshow_id, null, 12);
     $this->getResponse()->setHttpHeader("Content-Type", "text/xml; charset=utf-8");
     $this->getController()->setRenderMode(sfView::RENDER_CLIENT);
 }
 /**
  * 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);
 }
Exemplo n.º 3
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $entry_id = $this->getPM("entry_id");
     $detailed = $this->getP("detailed", false);
     $entry = null;
     if ($entry_id) {
         $entry = entryPeer::retrieveByPK($entry_id);
     }
     if (!$entry) {
         $this->addError(APIErrors::INVALID_ENTRY_ID, $entry_id);
     } else {
         $kshow_id = $entry->getKshowId();
         $kshow = $entry->getKshow();
         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 {
                 $newEntry = $newKshow->getShowEntry();
                 $level = $detailed ? objectWrapperBase::DETAIL_LEVEL_DETAILED : objectWrapperBase::DETAIL_LEVEL_REGULAR;
                 $wrapper = objectWrapperBase::getWrapperClass($newEntry, $level);
                 // TODO - remove this code when cache works properly when saving objects (in their save method)
                 $wrapper->removeFromCache("entry", $newEntry->getId());
                 $this->addMsg("entry", $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)
 {
     $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);
 }
Exemplo n.º 6
0
 protected function executeImpl(kshow $kshow, entry &$entry)
 {
     if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_SHOW) {
         $this->show_versions = array_reverse($entry->getAllversions());
     } else {
         $this->show_versions = array();
     }
     $this->producer = kuser::getKuserById($kshow->getProducerId());
     $this->editor = $entry->getKuser();
     $this->thumbnail = $entry ? $entry->getThumbnailPath() : "";
     // is the logged-in-user is an admin or the producer or the show can always be published...
     $likuser_id = $this->getLoggedInUserId();
     $viewer_type = myKshowUtils::getViewerType($kshow, $likuser_id);
     $this->entry = $entry ? $entry : new entry();
     // create a dummy entry for the GUI
     $this->can_publish = $viewer_type == KshowKuser::KSHOWKUSER_VIEWER_PRODUCER || $kshow->getCanPublish();
 }
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $entry_id = $this->getP("entry_id");
     $kshow_id = $this->getP("kshow_id");
     $show_entry_id = $this->getP("show_entry_id");
     // Make sure the request is for a ready roughcut
     $c = entryPeer::getCriteriaFilter()->getFilter();
     $c->addAnd(entryPeer::STATUS, entryStatus::READY, Criteria::EQUAL);
     list($kshow, $show_entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $show_entry_id);
     if ($error_obj) {
         $this->addError($error_obj);
         return;
     }
     $entry = entryPeer::retrieveByPK($entry_id);
     if (!$entry) {
         $this->addError(APIErrors::INVALID_ENTRY_ID, "entry", $entry_id);
         return;
     }
     $metadata = $kshow->getMetadata();
     $relevant_kshow_version = 1 + $kshow->getVersion();
     // the next metadata will be the first relevant version for this new entry
     $version_info = array();
     $version_info["KuserId"] = $puser_kuser->getKuserId();
     $version_info["PuserId"] = $puser_id;
     $version_info["ScreenName"] = $puser_kuser->getPuserName();
     $new_metadata = myMetadataUtils::addEntryToMetadata($metadata, $entry, $relevant_kshow_version, $version_info);
     $entry_modified = true;
     if ($new_metadata) {
         // TODO - add thumbnail only for entries that are worthy - check they are not moderated !
         $thumb_modified = myKshowUtils::updateThumbnail($kshow, $entry, false);
         if ($thumb_modified) {
             $new_metadata = myMetadataUtils::updateThumbUrlFromMetadata($new_metadata, $entry->getThumbnailUrl());
         }
         // it is very important to increment the version count because even if the entry is deferred
         // it will be added on the next version
         if (!$kshow->getHasRoughcut()) {
             // make sure the kshow now does have a roughcut
             $kshow->setHasRoughcut(true);
             $kshow->save();
         }
         $kshow->setMetadata($new_metadata, true);
     }
     $this->addMsg("entry", objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR));
     $this->addMsg("kshow", objectWrapperBase::getWrapperClass($kshow, objectWrapperBase::DETAIL_LEVEL_REGULAR));
     $this->addMsg("metadata", $new_metadata);
 }
Exemplo n.º 8
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $entry_id = $this->getP("entry_id");
     $kshow_id = $this->getP("kshow_id");
     // Make sure the request is for a ready roughcut
     $c = entryPeer::getCriteriaFilter()->getFilter();
     $c->addAnd(entryPeer::STATUS, entryStatus::READY, Criteria::EQUAL);
     list($kshow, $entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $entry_id);
     if ($error_obj) {
         $this->addError($error_obj);
         return;
     }
     $version = $this->getP("version");
     // it's a path on the disk
     if (kString::beginsWith($version, ".")) {
         // someone is trying to hack in the system
         return sfView::ERROR;
     } elseif ($version == "-1") {
         $version = null;
     }
     // in case we're making a roughcut out of a regular invite, we start from scratch
     $entry_data_path = kFileSyncUtils::getLocalFilePathForKey($entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version));
     //replaced__getDataPath
     if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW || $entry_data_path === null) {
         $this->xml_content = "<xml></xml>";
         return;
     }
     $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version);
     $file_name = kFileSyncUtils::getReadyLocalFilePathForKey($sync_key, false);
     // fetch content of file from disk - it should hold the XML
     if (kString::endsWith($file_name, "xml")) {
         $xml_content = kFileSyncUtils::file_get_contents($sync_key, false, false);
         if (!$xml_content) {
             $xml_content = "<xml></xml>";
         }
         myMetadataUtils::updateEntryForPending($entry, $version, $xml_content);
         $this->addMsg("metadata", $xml_content);
     } else {
         $this->addError(APIErrors::INVALID_FILE_NAME, $file_name);
     }
 }
Exemplo n.º 9
0
 public function executeImpl(kshow $kshow, entry &$entry)
 {
     $genericWidget = "";
     $myspaceWidget = "";
     $kshow_id = $kshow->getId();
     $entry_id = $entry->getId();
     if (!$kshow->getPartnerId() && !$this->forceViewPermissions($kshow, $kshow_id, false, false)) {
         die;
     }
     $this->kshow_category = $kshow->getTypeText();
     $this->kshow_description = $kshow->getDescription();
     $this->kshow_name = $kshow->getName();
     $this->kshow_tags = $kshow->getTags();
     $kdata = @$_REQUEST["kdata"];
     if ($kdata == "null") {
         $kdata = "";
     }
     $this->widget_type = @$_REQUEST["widget_type"];
     list($genericWidget, $myspaceWidget) = myKshowUtils::getEmbedPlayerUrl($kshow_id, $entry_id, false, $kdata);
     if ($entry_id == 1002) {
         $this->share_url = requestUtils::getHost() . "/index.php/corp/kalturaPromo";
     } else {
         if ($kdata) {
             $this->share_url = myKshowUtils::getWidgetCmdUrl($kdata, "share");
         } else {
             $this->share_url = myKshowUtils::getUrl($kshow_id) . "&entry_id={$entry_id}";
         }
     }
     //list($status, $kmediaType, $kmediaData) = myContentRender::createPlayerMedia($entry); // myContentRender class removed, old code
     $status = $entry->getStatus();
     $kmediaType = $entry->getMediaType();
     $kmediaData = "";
     $this->message = $kmediaType == entry::ENTRY_MEDIA_TYPE_TEXT ? $kmediaData : "";
     $this->generic_embed_code = $genericWidget;
     $this->myspace_embed_code = $myspaceWidget;
     $this->thumbnail = $entry ? $entry->getBigThumbnailPath(true) : "";
     $this->kuser = $entry->getKuser();
     $this->entry = $entry;
 }
 public static function getViewerType($kshow, $kuserId)
 {
     $viewerType = KshowKuser::KSHOWKUSER_VIEWER_USER;
     // viewer
     if ($kuserId) {
         if ($kshow->getProducerId() == $kuserId) {
             $viewerType = KshowKuser::KSHOWKUSER_VIEWER_PRODUCER;
             // producer
         } else {
             if (myKshowUtils::isSubscribed($kshow->getId(), $kuserId)) {
                 $viewerType = KshowKuser::KSHOWKUSER_VIEWER_SUBSCRIBER;
             }
             // subscriber;
         }
     }
     return $viewerType;
 }
Exemplo n.º 11
0
 public static function getDefaultKshow($partner_id, $subp_id, $puser_kuser, $group_id = null, $create_anyway = false, $default_name = null)
 {
     $partner = PartnerPeer::retrieveByPK($partner_id);
     if (!$partner) {
         return null;
     }
     // see if partner allows a fallback kshow
     $allow = $partner->getUseDefaultKshow();
     if (!$allow) {
         return null;
     }
     $kshow = myKshowUtils::getDefaultKshow($partner_id, $subp_id, $puser_kuser, $group_id, $partner->getAllowQuickEdit(), $create_anyway, $default_name);
     return $kshow;
 }
Exemplo n.º 12
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     $entry_id = $this->getP("entry_id");
     $kshow_id = $this->getP("kshow_id");
     list($kshow, $entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $entry_id);
     if ($error_obj) {
         $this->addError($error_obj);
         return;
     }
     $kshow_id = $kshow->getId();
     if ($kshow_id === kshow::SANDBOX_ID) {
         $this->addError(APIErrors::SANDBOX_ALERT);
         return;
     }
     // TODO -  think what is the best way to verify the privileges - names and parameters that are initially set by the partner at
     // startsession time
     if (!$this->isOwnedBy($kshow, $puser_kuser->getKuserId())) {
         $this->verifyPrivileges("edit", $kshow_id);
     }
     // user was granted explicit permissions when initiatd the ks
     // this part overhere should be in a more generic place - part of the services
     $multiple_roghcuts = Partner::allowMultipleRoughcuts($partner_id);
     $likuser_id = $puser_kuser->getKuserId();
     $isIntro = $kshow->getIntroId() == $entry->getId();
     if ($multiple_roghcuts) {
         // create a new entry in two cases:
         // 1. the user saving the roughcut isnt the owner of the entry
         // 2. the entry is an intro and the current entry is not show (probably an image or video)
         if ($entry->getKuserId() != $likuser_id || $isIntro && $entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW) {
             // TODO: add security check to whether multiple roughcuts are allowed
             // create a new roughcut entry by cloning the original entry
             $entry = myEntryUtils::deepClone($entry, $kshow_id, false);
             $entry->setKuserId($likuser_id);
             $entry->setCreatorKuserId($puser_kuser->getKuserId());
             $entry->setCreatedAt(time());
             $entry->setMediaType(entry::ENTRY_MEDIA_TYPE_SHOW);
             $entry->save();
         }
     }
     $xml_content = "<xml><EntryID>" . $entry->getId() . "</EntryID></xml>";
     if ($isIntro) {
         $kshow->setIntroId($entry->getId());
     } else {
         $kshow->setShowEntryId($entry->getId());
         $has_roughcut = $this->getP("HasRoughCut", "1", true);
         if ($has_roughcut === "0") {
             $kshow->setHasRoughcut(false);
             $kshow->save();
             $this->addMsg("saved_entry", $entry->getId());
             return;
         }
     }
     $content = $this->getP("xml");
     $update_kshow = false;
     if ($content != NULL) {
         $version_info = array();
         $version_info["KuserId"] = $puser_kuser->getKuserId();
         $version_info["PuserId"] = $puser_id;
         $version_info["ScreenName"] = $puser_kuser->getPuserName();
         list($xml_content, $comments, $update_kshow) = myMetadataUtils::setMetadata($content, $kshow, $entry, false, $version_info);
     } else {
         $comments = "";
         // if there is no xml - receive it from the user
         $this->debug = true;
         return "text/html; charset=utf-8";
     }
     $this->addMsg("xml", $xml_content);
     $this->addMsg("saved_entry", $entry->getId());
     $this->addDebug("comment", $comments);
 }
Exemplo n.º 13
0
 /**
 Will allow creation of multiple entries
 ASSUME - the prefix of the entries is entryX_ where X is the index starting at 1
 */
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     //        $logger = sfLogger::getInstance();
     self::$escape_text = true;
     /*		if ( !$puser_kuser )
             {
                 $this->addError( "No such user ..." );
                 return;
     
             }
         */
     // TODO - validate if the user can add entries to this kshow
     $kshow_id = $this->getP("kshow_id");
     $show_entry_id = $this->getP("show_entry_id");
     $conversion_quality = $this->getP("conversionquality");
     // must be all lower case
     // for now - by default use quick_edit
     $partner = PartnerPeer::retrieveByPK($partner_id);
     for ($i = 0; $i <= $partner->getAddEntryMaxFiles(); ++$i) {
         if ($i == 0) {
             $prefix = $this->getObjectPrefix() . "_";
         } else {
             $prefix = $this->getObjectPrefix() . "{$i}" . "_";
         }
         $source = $this->getP($prefix . "source");
         $filename = $this->getP($prefix . "filename");
         if ($source != entry::ENTRY_MEDIA_SOURCE_WEBCAM || !$filename) {
             continue;
         }
         $content = myContentStorage::getFSContentRootPath();
         $entryFullPath = "{$content}/content/webcam/{$filename}.flv";
         if (!file_exists($entryFullPath)) {
             $remoteDCHost = kDataCenterMgr::getRemoteDcExternalUrlByDcId(1 - kDataCenterMgr::getCurrentDcId());
             if ($remoteDCHost) {
                 kFileUtils::dumpApiRequest($remoteDCHost);
             }
             $this->addError(APIErrors::INVALID_FILE_NAME, $filename);
             return;
         }
     }
     if (strpos($kshow_id, 'entry-') !== false && !$show_entry_id) {
         $show_entry_id = substr($kshow_id, 6);
     }
     $screen_name = $this->getP("screen_name");
     $site_url = $this->getP("site_url");
     $null_kshow = true;
     if ($show_entry_id) {
         // in this case we have the show_entry_id (of the relevant roughcut) - it suppresses the kshow_id
         $show_entry = entryPeer::retrieveByPK($show_entry_id);
         if ($show_entry) {
             $kshow_id = $show_entry->getKshowId();
         } else {
             $kshow_id = null;
         }
     }
     if ($kshow_id === kshow::SANDBOX_ID) {
         $this->addError(APIErrors::SANDBOX_ALERT);
         return;
     }
     $default_kshow_name = $this->getP("entry_name", null);
     if (!$default_kshow_name) {
         $default_kshow_name = $this->getP("entry1_name", 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, null, false, $default_kshow_name);
         $null_kshow = false;
         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, $default_kshow_name);
         $null_kshow = false;
         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;
     }
     // find permissions from kshow
     $permissions = $kshow->getPermissions();
     $kuser_id = $puser_kuser->getKuserId();
     // TODO - once the CW
     $quick_edit = myPolicyMgr::getPolicyFor("allowQuickEdit", $kshow, $partner);
     // let the user override the quick_edit propery
     if ($this->getP("quick_edit") == '0' || $this->getP("quick_edit") == "false") {
         $quick_edit = false;
     }
     if ($quick_edit == '0' || $quick_edit === "false" || !$quick_edit || $quick_edit == false) {
         KalturaLog::err('$quick_edit: [' . $quick_edit . ']');
         $quick_edit = false;
         //$quick_edit = true;
     }
     // works in one of 2 ways:
     // 1. get no requested name - will create a new kshow and return its details
     // 2. get some name - tries to fetch by name. if already exists - return it
     $new_entry_count = 0;
     $entries = array();
     $notification_ids = array();
     $notifications = array();
     $field_level = $this->isAdmin() ? 2 : 1;
     $updateable_fields = null;
     $imported_entries_count = 0;
     for ($i = 0; $i <= $partner->getAddEntryMaxFiles(); ++$i) {
         if ($i == 0) {
             $prefix = $this->getObjectPrefix() . "_";
         } else {
             $prefix = $this->getObjectPrefix() . "{$i}" . "_";
         }
         $file_name = $this->getP($prefix . "realFilename");
         if (!($this->getP($prefix . "name") || $file_name)) {
             continue;
         }
         // get the new properties for the kuser from the request
         $entry = new entry();
         $obj_wrapper = objectWrapperBase::getWrapperClass($entry, 0);
         if (!$updateable_fields) {
             $updateable_fields = $obj_wrapper->getUpdateableFields($field_level);
         }
         // fill the entry from request
         $fields_modified = baseObjectUtils::fillObjectFromMap($this->getInputParams(), $entry, $prefix, $updateable_fields);
         // check that mandatory fields were set
         // TODO
         KalturaLog::err("addentry: fields_modified: " . print_r($fields_modified, true));
         $entry_source = $entry->getSource();
         if (!$entry->getType()) {
             // this is the default for backward compatiblity
             $entry->setType(entryType::MEDIA_CLIP);
         }
         $token = $this->getKsUniqueString();
         $entry_full_path = "";
         if ($entry_source == entry::ENTRY_MEDIA_SOURCE_FILE) {
             $entry->setSourceLink($file_name);
             $file_alias = $this->getP($prefix . "filename");
             $file_extension = strtolower(pathinfo($this->getP($prefix . "realFilename"), PATHINFO_EXTENSION));
             $entry_full_path = myUploadUtils::getUploadPath($token, $file_alias, null, $file_extension);
             if (!file_exists($entry_full_path)) {
                 KalturaLog::err("Invalid UPLOAD PATH [" . $entry_full_path . "] while trying to add entry for partner id [" . $partner_id . "] with token [" . $token . "] & original name [" . $this->getP($prefix . "name") . "]");
                 $this->addError(APIErrors::INVALID_FILE_NAME);
                 continue;
             }
             myEntryUtils::setEntryTypeAndMediaTypeFromFile($entry, $entry_full_path);
         }
         //            No reason to rais the error
         //            Remarked by Tan-Tan
         //
         //            // when we reached this point the type and media type must be set
         //            if ($entry->getType() == entryType::AUTOMATIC || $entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_AUTOMATIC)
         //            {
         //				$this->addError ( APIErrors::CANNOT_USE_ENTRY_TYPE_AUTO_IN_IMPORT );
         //            	continue;
         //            }
         // limit two kinds of media
         // 1. not images - video/audio which are big files
         // 2. media which wasnt directly uploaded by the owner (the owner real content)
         if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_IMAGE && $entry_source != entry::ENTRY_MEDIA_SOURCE_FILE) {
             if ($imported_entries_count >= 4) {
                 continue;
             }
             ++$imported_entries_count;
         }
         // the conversion_quality is set once for the whole list of entries
         if ($conversion_quality) {
             $entry->setConversionQuality($conversion_quality);
         } else {
             // HACK - if the conversion_quality was not set in the proper way -
             // see if the partner_data holds a hack - string that starts with conversionQuality= - this is set when the CW is opened in the KMC
             // the conversionQuality is of format conversionQuality=XXX;<the rest of the text>
             //
             if (kString::beginsWith($entry->getPartnerData(), "conversionQuality:")) {
                 $partner_data_arr = explode(";", $entry->getPartnerData(), 2);
                 $conversion_quality_arr = explode(":", $partner_data_arr[0]);
                 $conversion_quality = @$conversion_quality_arr[1];
                 // the value of the conversion_quality
                 $entry->setPartnerData(@$partner_data_arr[1]);
                 // the rest of the string
                 $entry->setConversionQuality($conversion_quality);
             }
         }
         $insert = true;
         $entry_modified = false;
         $create_entry = true;
         // I don't remember why we set the kshow to null every time ...
         // but when we fetched it automatically - hang on to it !
         if ($null_kshow) {
             $kshow = null;
         }
         if ($entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_USER_CLIPS || $entry_source == "100") {
             if ($entry_source == "100") {
                 $entry_id = $this->getP("media{$i}_id");
             } else {
                 $entry_id = $this->getP($prefix . "id");
             }
             // $this->getP ( $prefix . "url" );
             if ($entry_id === null) {
                 $entry_id = $entry->getMediaId();
             }
             if ($entry_id) {
                 $entry = entryPeer::retrieveByPK($entry_id);
                 if ($entry) {
                     $create_entry = false;
                     $insert = false;
                 } else {
                     $this->addError(APIErrors::INVALID_ENTRY_ID, $this->getObjectPrefix(), $entry_id);
                     return;
                 }
             }
         }
         $new_entry_count++;
         if ($create_entry) {
             $entry->setPartnerId($partner_id);
             $entry->setSubpId($subp_id);
             $entry->setKuserId($kuser_id);
             $entry->setCreatorKuserId($kuser_id);
             $entry->setKshowId($kshow_id);
             $entry->setSiteUrl($site_url);
             $entry->setScreenName($screen_name);
             if ($this->getGroup()) {
                 $entry->setGroupId($this->getGroup());
             }
             if ($entry->getPermissions() === null) {
                 $entry->setPermissions($permissions);
             }
             // inherited from the enclosing kshow
             $entry->setDefaultModerationStatus();
             $entry->save();
             $entry_modified = true;
             if (!$entry->getName()) {
                 if ($file_name) {
                     // TODO - fix the file_name to fit
                     $entry->setName($file_name);
                 } else {
                     $entry->setName($partner_prefix . $entry->getId());
                 }
                 $entry_modified = true;
             }
             // TODO - decide on file naming mechanism !!
             // there are 3 types of insert:
             // 1. upload - the file is assumed to be in the upload directory and it's name is explicitly set in the fname$i param
             // 2. webcam - the file is assumed to be in the webcam directory and it's name is explicitly set in the fname$i param
             // 3. URL - the url is given in the entry_url$i param
             /*
                         $media_source = $this->getParam('entry_media_source');
                         $media_type = $this->getParam('entry_media_type');
                         $entry_url = $this->getParam('entry_url');
                         $entry_source_link = $this->getParam('entry_source_link');
                         $entry_fileName = $this->getParam('entry_data');
                         $entry_thumbNum = $this->getParam('entry_thumb_num', 0);
                         $entry_thumbUrl  = $this->getParam('entry_thumb_url', '');
                         $entry_from_time  = $this->getParam('entry_from_time', 0);
                         $entry_to_time  = $this->getParam('entry_to_time', 0);
             
                         $should_copy = $this->getParam('should_copy' , false );
                         $skip_conversion = $this->getParam('skip_conversion' , false );
             */
             $paramsArray = array('entry_media_source' => $entry->getSource(), 'entry_media_type' => $entry->getMediaType());
             //			$entry_source = $entry->getSource() ;
             if ($entry_source == entry::ENTRY_MEDIA_SOURCE_FILE) {
                 $paramsArray["entry_full_path"] = $entry_full_path;
             } elseif ($entry_source == entry::ENTRY_MEDIA_SOURCE_WEBCAM) {
                 $file_alias = $this->getP($prefix . "filename");
                 $paramsArray["webcam_suffix"] = $file_alias;
                 $paramsArray['entry_from_time'] = $this->getP($prefix . "fromTime", 0);
                 $paramsArray['entry_to_time'] = $this->getP($prefix . "toTime", 0);
             } elseif ($entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_PARTNER || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_PARTNER_KSHOW || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_KSHOW || $entry_source == entry::ENTRY_MEDIA_SOURCE_KALTURA_USER_CLIPS) {
                 // optimize - no need to actually go through the import and conversion phase
                 // find the source entry_id from the url
                 /*
                                     $entry_url = $this->getP ( $prefix . "url" );
                                     $entry_thumb_url = $this->getP ( $prefix .  "thumbUrl" );
                 
                                     if ( myEntryUtils::copyData( $entry_url , $entry_thumb_url , $entry ) )
                 */
                 $source_entry_id = $this->getP("media{$i}_id");
                 // $this->getP ( $prefix . "url" );
                 if ($source_entry_id === null) {
                     $source_entry_id = $entry->getMediaId();
                 }
                 if (myEntryUtils::copyData($source_entry_id, $entry)) {
                     // copy worked ok - no need to use insertEntryHelper
                     //$entry->setStatus ( entryStatus::READY );
                     // force the data to be ready even if the policy is to moderate - this is kaltura's content and was already approved
                     // (roman) true argument removed, so kaltura's content will be moderated according to partner's moderation settings
                     $entry->setStatusReady();
                     $insert = false;
                     $entry_modified = true;
                     $entry->save();
                 }
             } elseif ($entry_source == entry::ENTRY_MEDIA_SOURCE_URL || in_array($entry_source, myMediaSourceFactory::getAllMediaSourceProvidersIds())) {
                 // the URL is relevant
                 $paramsArray["entry_url"] = $this->getP($prefix . "url");
                 $paramsArray["entry_thumb_url"] = $this->getP($prefix . "thumbUrl");
                 // TODO - these fields are already set in the entry -
                 // the code in myInsertEntryHelper is redundant
                 $paramsArray["entry_license"] = $entry->getLicenseType();
                 $paramsArray["entry_credit"] = $entry->getCredit();
                 $paramsArray["entry_source_link"] = $entry->getSourceLink();
                 $paramsArray["entry_tags"] = $entry->getTags();
             } else {
                 $this->addError(APIErrors::UNKNOWN_MEDIA_SOURCE, $entry->getSource());
                 $insert = false;
             }
             if ($insert) {
                 KalturaLog::err("paramsArray" . print_r($paramsArray, true));
                 $insert_entry_helper = new myInsertEntryHelper($this, $kuser_id, $kshow_id, $paramsArray);
                 $insert_entry_helper->setPartnerId($partner_id, $subp_id);
                 $insert_entry_helper->insertEntry($token, $entry->getType(), $entry->getId(), $entry->getName(), $entry->getTags(), $entry);
                 $insert_entry_helper->getEntry();
                 $this->addDebug("added_entry{$i}", $entry->getName());
             }
         }
         // create_entry = true
         KalturaLog::err('id: ' . $entry->getId() . ' $quick_edit:' . $quick_edit);
         if ($quick_edit) {
             KalturaLog::info("quick edit with kshow_id [{$kshow_id}]");
             if (!$kshow) {
                 $kshow = kshowPeer::retrieveByPK($kshow_id);
             }
             // this i
             if (!$kshow) {
                 // BAD - this shount not be !
                 $this->addError(APIErrors::INVALID_KSHOW_ID, $kshow_id);
                 return;
             }
             $metadata = $kshow->getMetadata();
             if ($metadata !== null) {
                 KalturaLog::info("Having metadata");
                 $relevant_kshow_version = 1 + $kshow->getVersion();
                 // the next metadata will be the first relevant version for this new entry
                 $version_info = array();
                 $version_info["KuserId"] = $puser_kuser->getKuserId();
                 $version_info["PuserId"] = $puser_id;
                 $version_info["ScreenName"] = $puser_kuser->getPuserName();
                 $new_metadata = myMetadataUtils::addEntryToMetadata($metadata, $entry, $relevant_kshow_version, $version_info);
                 $entry_modified = true;
                 if ($new_metadata) {
                     // TODO - add thumbnail only for entries that are worthy - check they are not moderated !
                     $thumb_modified = myKshowUtils::updateThumbnail($kshow, $entry, false);
                     if ($thumb_modified) {
                         $new_metadata = myMetadataUtils::updateThumbUrlFromMetadata($new_metadata, $entry->getThumbnailUrl());
                     }
                     // it is very important to increment the version count because even if the entry is deferred
                     // it will be added on the next version
                     if (!$kshow->getHasRoughcut()) {
                         // make sure the kshow now does have a roughcut
                         $kshow->setHasRoughcut(true);
                         $kshow->save();
                     }
                     $kshow->setMetadata($new_metadata, true);
                 }
                 // no need to save kshow - the modification of the metadata was done to the show_entry which will propagate any chages to the kshow in it's own save method
             }
         }
         if ($entry_modified) {
             $entry->save();
         }
         $not_id = null;
         // send a synch notification
         @(list($not_id, $not, $url, $params, $serialized_params) = myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_ADD, $entry, null, null));
         if ($not_id) {
             $notification_ids[] = $not_id;
             $notifications[] = array("url" => $url, "params" => $serialized_params);
         }
         $wrapper = objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR);
         $entries[$prefix] = $wrapper;
         //$this->addMsg ( $prefix , $wrapper);
         // because the kshow's entrys field was changes do to this update, we have to remove object from cahce
         // TODO - think of some reverse way to automatically remove from the cache from within the wrapper
         // call some - update cache where the kshow_id plays a part in the update
         $wrapper->removeFromCache("kshow", $kshow_id, "entrys");
         $this->addDebug("added_fields", $fields_modified, $prefix);
     }
     $this->addMsg("entries", $entries);
     if (count($notification_ids) > 0) {
         $this->addMsg("notifications", $notifications);
     }
     if ($new_entry_count < 1) {
         $this->addError(APIErrors::NO_ENTRIES_ADDED);
         $this->addDebug("no_new_entries", "You have to have at least one new entry with a field called 'entry1_name'");
     }
     $this->addMsg("new_entry_count", $new_entry_count);
 }
Exemplo n.º 14
0
 public function executeImpl($partner_id, $subp_id, $puser_id, $partner_prefix, $puser_kuser)
 {
     if (!$partner_id) {
         die;
     }
     $entry_id = $this->getP("entry_id");
     // if the entry_type was sent by the client - make sure it's of type  ENTRY_TYPE_SHOW.
     // this is to prevent this service as part of a bad multirequest
     $entry_type = $this->getP("entry_type", null);
     if (!empty($entry_type) && $entry_type != entryType::MIX) {
         $this->addDebug("entry", "not of type " . entryType::MIX);
         return;
     }
     $kshow_id = $this->getP("kshow_id");
     list($kshow, $entry, $error, $error_obj) = myKshowUtils::getKshowAndEntry($kshow_id, $entry_id);
     if ($error_obj) {
         $this->addError($error_obj);
         return;
     }
     KalturaLog::log(__METHOD__ . " kshow_id [{$kshow_id}] entry_id [{$entry_id}]");
     $list_type = $this->getP("list_type", self::LIST_TYPE_ROUGHCUT);
     $version = $this->getP("version", null);
     if ((int) $version == -1) {
         $version = null;
     }
     // will retrieve the latest
     $disable_roughcut_entry_data = $this->getP("disable_roughcut_entry_data", false);
     $disable_user_data = $this->getP("disable_user_data", false);
     // will allow to optimize the cals and NOT join with the kuser table
     $merge_entry_lists = false;
     if ($this->getPartner()) {
         $merge_entry_lists = $this->getPartner()->getMergeEntryLists();
     }
     $kshow_entry_list = array();
     $kuser_entry_list = array();
     $aggrigate_id_list = array();
     $this->benchmarkStart("list_type_kshow");
     if ($list_type & self::LIST_TYPE_KSHOW && $kshow_id) {
         $c = new Criteria();
         $c->addAnd(entryPeer::TYPE, entryType::MEDIA_CLIP);
         //			$c->addAnd ( entryPeer::MEDIA_TYPE , entry::ENTRY_MEDIA_TYPE_SHOW , Criteria::NOT_EQUAL );
         $c->addAnd(entryPeer::KSHOW_ID, $kshow_id);
         $this->addIgnoreIdList($c, $aggrigate_id_list);
         //			$this->addOffsetAndLimit ( $c ); // fetch as many as the kshow has
         if ($disable_user_data) {
             $kshow_entry_list = entryPeer::doSelect($c);
         } else {
             $kshow_entry_list = entryPeer::doSelectJoinkuser($c);
         }
         $this->updateAggrigatedIdList($aggrigate_id_list, $kshow_entry_list);
     }
     $this->benchmarkEnd("list_type_kshow");
     $this->benchmarkStart("list_type_kuser");
     if ($list_type & self::LIST_TYPE_KUSER) {
         // try to get puserKuser - PS2
         $puser_kuser = PuserKuserPeer::retrieveByPartnerAndUid($partner_id, null, $puser_id, false);
         // try to get kuser by partnerId & puserId - PS3 - backward compatibility
         $apiv3Kuser = kuserPeer::getKuserByPartnerAndUid($partner_id, $puser_id, true);
         if ($puser_kuser && $puser_kuser->getKuserId() || $apiv3Kuser) {
             $c = new Criteria();
             $c->addAnd(entryPeer::TYPE, entryType::MEDIA_CLIP);
             //				$c->addAnd ( entryPeer::MEDIA_TYPE , entry::ENTRY_MEDIA_TYPE_SHOW , Criteria::NOT_EQUAL );
             $kuserIds = array();
             if ($puser_kuser && $puser_kuser->getKuserId()) {
                 $kuserIds[] = $puser_kuser->getKuserId();
             }
             if ($apiv3Kuser) {
                 if (!$puser_kuser || $puser_kuser->getKuserId() != $apiv3Kuser->getId()) {
                     $kuserIds[] = $apiv3Kuser->getId();
                 }
             }
             /*
             				if(count($kuserIds) > 1)
             				{
             					$c->addAnd ( entryPeer::KUSER_ID , $kuserIds, Criteria::IN );
             				}
             				else
             				{
             					$c->addAnd ( entryPeer::KUSER_ID , $kuserIds[0] );
             				}
             				if ( $merge_entry_lists )
             				{
             					// if will join lists - no need to fetch entries twice
             					$this->addIgnoreIdList ($c , $aggrigate_id_list);
             				}
             				$this->addOffsetAndLimit ( $c ); // limit the number of the user's clips
             				if ( $disable_user_data )
             					$kuser_entry_list = entryPeer::doSelect( $c );
             				else
             					$kuser_entry_list = entryPeer::doSelectJoinkuser( $c );
             */
             $this->addOffsetAndLimit($c);
             // limit the number of the user's clips
             if ($merge_entry_lists) {
                 // if will join lists - no need to fetch entries twice
                 $this->addIgnoreIdList($c, $aggrigate_id_list);
             }
             $kuser_entry_list = array();
             $kuserIds = array_unique($kuserIds);
             foreach ($kuserIds as $kuserId) {
                 $newC = clone $c;
                 $newC->addAnd(entryPeer::KUSER_ID, $kuserId);
                 if ($disable_user_data) {
                     $one_kuser_list = entryPeer::doSelect($newC);
                 } else {
                     $one_kuser_list = entryPeer::doSelectJoinkuser($newC);
                 }
                 $kuser_entry_list = array_merge($kuser_entry_list, $one_kuser_list);
             }
             // Since we are using 2 potential kusers, we might not have the obvious kuser from $puser_kuser
             $strEntries = "";
             if ($puser_kuser) {
                 $kuser = kuserPeer::retrieveByPk($puser_kuser->getKuserId());
                 if ($kuser) {
                     $strEntriesTemp = @unserialize($kuser->getPartnerData());
                     if ($strEntriesTemp) {
                         $strEntries .= $strEntriesTemp;
                     }
                 }
             }
             if ($apiv3Kuser) {
                 $strEntriesTemp = @unserialize($apiv3Kuser->getPartnerData());
                 if ($strEntriesTemp) {
                     $strEntries .= $strEntriesTemp;
                 }
             }
             if ($strEntries) {
                 $entries = explode(',', $strEntries);
                 $fixed_entry_list = array();
                 foreach ($entries as $entryId) {
                     $fixed_entry_list[] = trim($entryId);
                 }
                 $c = new Criteria();
                 $c->addAnd(entryPeer::TYPE, entryType::MEDIA_CLIP);
                 $c->addAnd(entryPeer::ID, $fixed_entry_list, Criteria::IN);
                 if ($merge_entry_lists) {
                     // if will join lists - no need to fetch entries twice
                     $this->addIgnoreIdList($c, $aggrigate_id_list);
                 }
                 if ($disable_user_data) {
                     $extra_user_entries = entryPeer::doSelect($c);
                 } else {
                     $extra_user_entries = entryPeer::doSelectJoinkuser($c);
                 }
                 if (count($extra_user_entries)) {
                     $kuser_entry_list = array_merge($extra_user_entries, $kuser_entry_list);
                 }
             }
         } else {
             $kuser_entry_list = array();
         }
         if ($merge_entry_lists) {
             $kshow_entry_list = kArray::append($kshow_entry_list, $kuser_entry_list);
             $kuser_entry_list = null;
         }
     }
     $this->benchmarkEnd("list_type_kuser");
     $this->benchmarkStart("list_type_episode");
     if ($list_type & self::LIST_TYPE_EPISODE) {
         if ($kshow && $kshow->getEpisodeId()) {
             // episode_id will point to the "parent" kshow
             // fetch the entries of the parent kshow
             $c = new Criteria();
             $c->addAnd(entryPeer::TYPE, entryType::MEDIA_CLIP);
             //				$c->addAnd ( entryPeer::MEDIA_TYPE , entry::ENTRY_MEDIA_TYPE_SHOW , Criteria::NOT_EQUAL );
             $c->addAnd(entryPeer::KSHOW_ID, $kshow->getEpisodeId());
             $this->addIgnoreIdList($c, $aggrigate_id_list);
             //				$this->addOffsetAndLimit ( $c ); // limit the number of the inherited entries from the episode
             if ($disable_user_data) {
                 $parent_kshow_entries = entryPeer::doSelect($c);
             } else {
                 $parent_kshow_entries = entryPeer::doSelectJoinkuser($c);
             }
             if (count($parent_kshow_entries)) {
                 $kshow_entry_list = kArray::append($kshow_entry_list, $parent_kshow_entries);
             }
         }
     }
     $this->benchmarkEnd("list_type_episode");
     // fetch all entries that were used in the roughcut - those of other kusers
     // - appeared under kuser_entry_list when someone else logged in
     $this->benchmarkStart("list_type_roughcut");
     $entry_data_from_roughcut_map = array();
     // will hold an associative array where the id is the key
     if ($list_type & self::LIST_TYPE_ROUGHCUT) {
         if ($entry->getType() == entryType::MIX) {
             $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA, $version);
             $roughcut_file_name = kFileSyncUtils::getReadyLocalFilePathForKey($sync_key);
             $entry_data_from_roughcut = myFlvStreamer::getAllAssetsData($roughcut_file_name);
             $final_id_list = array();
             foreach ($entry_data_from_roughcut as $data) {
                 $id = $data["id"];
                 // first element is the id
                 $entry_data_from_roughcut_map[] = $data;
                 $found = false;
                 foreach ($kshow_entry_list as $entry) {
                     // see we are not fetching duplicate entries
                     if ($entry->getId() == $id) {
                         $found = true;
                         break;
                     }
                 }
                 if (!$found) {
                     $final_id_list[] = $id;
                 }
             }
             if (count($final_id_list) > 0) {
                 // allow deleted entries when searching for entries on the roughcut
                 // don't forget to return the status at the end of the process
                 entryPeer::allowDeletedInCriteriaFilter();
                 $c = new Criteria();
                 $c->addAnd(entryPeer::ID, $final_id_list, Criteria::IN);
                 $c->addAnd(entryPeer::TYPE, entryType::MEDIA_CLIP);
                 $this->addIgnoreIdList($c, $aggrigate_id_list);
                 //				$this->addOffsetAndLimit ( $c );
                 if ($disable_user_data) {
                     $extra_entries = entryPeer::doSelect($c);
                 } else {
                     $extra_entries = entryPeer::doSelectJoinkuser($c);
                 }
                 // return the status to the criteriaFilter
                 entryPeer::blockDeletedInCriteriaFilter();
                 // merge the 2 lists into 1:
                 $kshow_entry_list = kArray::append($kshow_entry_list, $extra_entries);
             }
         }
     }
     $this->benchmarkEnd("list_type_roughcut");
     $this->benchmarkStart("create_wrapper");
     $entry_wrapper = objectWrapperBase::getWrapperClass($kshow_entry_list, objectWrapperBase::DETAIL_LEVEL_REGULAR, -3, 0, array("contributorScreenName"));
     //$entry_wrapper->addFields ( array ( "kuser.screenName" ) );
     $this->addMsg("show", $entry_wrapper);
     // if ! $disable_roughcut_entry_data - add the roughcut_entry_data
     if (!$disable_roughcut_entry_data) {
         $this->addMsg("roughcut_entry_data", $entry_data_from_roughcut_map);
     }
     if (count($kuser_entry_list) > 0) {
         $this->addMsg("user", objectWrapperBase::getWrapperClass($kuser_entry_list, objectWrapperBase::DETAIL_LEVEL_REGULAR));
     } else {
         $this->addMsg("user", null);
     }
     $this->benchmarkEnd("create_wrapper");
 }
 /**
  * Appends a media entry to a the end of the mix timeline, this will save the mix timeline as a new version.
  * 
  * @action appendMediaEntry
  * @param string $mixEntryId Mix entry to append to its timeline
  * @param string $mediaEntryId Media entry to append to the timeline
  * @return KalturaMixEntry The mix entry
  */
 function appendMediaEntryAction($mixEntryId, $mediaEntryId)
 {
     $dbMixEntry = entryPeer::retrieveByPK($mixEntryId);
     if (!$dbMixEntry || $dbMixEntry->getType() != KalturaEntryType::MIX) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $mixEntryId);
     }
     $dbMediaEntry = entryPeer::retrieveByPK($mediaEntryId);
     if (!$dbMediaEntry || $dbMediaEntry->getType() != KalturaEntryType::MEDIA_CLIP) {
         throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $mediaEntryId);
     }
     $kshow = $dbMixEntry->getkshow();
     if (!$kshow) {
         KalturaLog::CRIT("Kshow was not found for mix id [" . $mixEntryId . "]");
         throw new KalturaAPIException(KalturaErrors::INTERNAL_SERVERL_ERROR);
     }
     // FIXME: temp hack  - when kshow doesn't have a roughcut, and the media entry is not ready, it cannob be queued for append upon import/conversion completion
     if ($dbMediaEntry->getStatus() != entryStatus::READY) {
         $kshow->setShowEntryId($mixEntryId);
         $kshow->save();
         $dbMediaEntry->setKshowId($kshow->getId());
         $dbMediaEntry->save();
     }
     $metadata = $kshow->getMetadata();
     $relevantKshowVersion = 1 + $kshow->getVersion();
     // the next metadata will be the first relevant version for this new entry
     $newMetadata = myMetadataUtils::addEntryToMetadata($metadata, $dbMediaEntry, $relevantKshowVersion, array());
     $dbMediaEntry->save();
     // FIXME: should be removed, needed for the prev hack
     if ($newMetadata) {
         // TODO - add thumbnail only for entries that are worthy - check they are not moderated !
         $thumbModified = myKshowUtils::updateThumbnail($kshow, $dbMediaEntry, false);
         if ($thumbModified) {
             $newMetadata = myMetadataUtils::updateThumbUrlFromMetadata($newMetadata, $dbMixEntry->getThumbnailUrl());
         }
         // it is very important to increment the version count because even if the entry is deferred
         // it will be added on the next version
         if (!$kshow->getHasRoughcut()) {
             // make sure the kshow now does have a roughcut
             $kshow->setHasRoughcut(true);
             $kshow->save();
         }
         $kshow->setMetadata($newMetadata, true);
     }
     $mixEntry = new KalturaMixEntry();
     $mixEntry->fromObject($dbMixEntry);
     return $mixEntry;
 }
Exemplo n.º 16
0
 private function forcePermissionsImpl($kshow, $kshow_id, $verification_mode, $allow_redirect = true, $full_window = false)
 {
     if ($kshow == NULL) {
         $kshow = kshowPeer::retrieveByPK($kshow_id);
     }
     if (!$kshow) {
         $this->playDead("This Kaltura is no longer available. (Message No." . $kshow_id . ")");
         //throw new Exception ( "Cannot force permission for show $kshow_id");
     }
     $likuser_id = $this->getLoggedInUserId();
     // if the user is eother the producer or an admin - return true
     $viewer_type = myKshowUtils::getViewerType($kshow, $likuser_id);
     if ($viewer_type == KshowKuser::KSHOWKUSER_VIEWER_PRODUCER) {
         return true;
     }
     $this->setCredentialByName("requestKshow", $kshow_id);
     $this->setCredentialByName("verificationMode", $verification_mode);
     //		echo ("verificationMode: " .  $this->getCredentialByName ( "verificationMode" ) );
     if ($full_window) {
         // check if all's well - if not - forward
         $result = $this->forcePermissionsDoCheckOrRedirect($kshow, $kshow_id, $verification_mode, false);
         if ($result) {
             return true;
         }
         // ALL IS OK !
         $this->setFlash('vm', $verification_mode);
         $this->setFlash('kshow_id', $kshow_id);
         return $this->forward('login', 'openAuthenticate');
     } else {
         return $this->forcePermissionsDoCheckOrRedirect($kshow, $kshow_id, $verification_mode, $allow_redirect);
     }
 }