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; } $entry_id = $this->getPM("entry_id"); $entry = entryPeer::retrieveByPK($entry_id); // TODO - verify the user is allowed to modify the entry $source_entry_id = $this->getP("source_entry_id"); if ($source_entry_id) { $source_entry = entryPeer::retrieveByPK($source_entry_id); if (!$source_entry) { return; } } else { $source_entry = $entry; } $time_offset = $this->getP("time_offset", -1); if (!myEntryUtils::createThumbnailFromEntry($entry, $source_entry, $time_offset)) { $this->addError(APIErrors::INVALID_ENTRY_TYPE, "ENTRY_TYPE_MEDIACLIP"); return; } if ($entry->getType() == entryType::MIX) { /* $roughcutPath = myContentStorage::getFSContentRootPath() . $entry->getDataPath(); // replaced__getDataPath $xml_doc = new DOMDocument(); $xml_doc->load( $roughcutPath ); if (myMetadataUtils::updateThumbUrl($xml_doc, $entry->getThumbnailUrl())) $xml_doc->save($roughcutPath); */ $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); $xml_doc = new DOMDocument(); $xml_doc->loadXML(kFileSyncUtils::file_get_contents($sync_key)); if (myMetadataUtils::updateThumbUrl($xml_doc, $entry->getThumbnailUrl())) { $entry->setMetadata(null, $xml_doc->saveXML(), true, null, null); //$entry->getVersion() ); } myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $entry); } $wrapper = objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_DETAILED); $wrapper->removeFromCache("entry", $entry->getId()); $this->addMsg("entry", $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; } $entry_id = $this->getPM("entry_id"); $entry = entryPeer::retrieveByPK($entry_id); // TODO - verify the user is allowed to modify the entry if ($entry->getKshowId() === kshow::SANDBOX_ID) { $this->addError(APIErrors::SANDBOX_ALERT); return; } $entry->setThumbnail(".jpg"); $entry->setCreateThumb(false); $entry->save(); if (isset($HTTP_RAW_POST_DATA)) { $thumb_data = $HTTP_RAW_POST_DATA; } else { $thumb_data = file_get_contents("php://input"); } $thumb_data_size = strlen($thumb_data); $fileSyncKey = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_THUMB); $fileSync = FileSync::createForFileSyncKey($fileSyncKey); kFileSyncUtils::file_put_contents($fileSyncKey, $thumb_data); // update the metadata in case of a roughcut if ($entry->getType() == entryType::MIX) { $sync_key = $entry->getSyncKey(entry::FILE_SYNC_ENTRY_SUB_TYPE_DATA); $xml_doc = new DOMDocument(); $xml_doc->loadXML(kFileSyncUtils::file_get_contents($sync_key)); if (myMetadataUtils::updateThumbUrl($xml_doc, $entry->getThumbnailUrl())) { $entry->setMetadata(null, $xml_doc->saveXML(), true, null, null); //$entry->getVersion() ); } myNotificationMgr::createNotification(kNotificationJobData::NOTIFICATION_TYPE_ENTRY_UPDATE_THUMBNAIL, $entry); } $this->res = $entry->getBigThumbnailUrl(); $wrapper = objectWrapperBase::getWrapperClass($entry, objectWrapperBase::DETAIL_LEVEL_REGULAR); $wrapper->removeFromCache("entry", $entry->getId()); $this->addMsg("entry", $wrapper); }
protected function executeImpl(kshow $kshow, entry &$entry) { $this->res = ""; $likuser_id = $this->getLoggedInUserId(); // if we allow multiple rouchcuts - there is no reason for one suer to override someone else's thumbnail if ($this->allowMultipleRoughcuts()) { if ($likuser_id != $entry->getKuserId()) { // ERROR - attempting to update an entry which doesnt belong to the user return "<xml>!!</xml>"; //$this->securityViolation( $kshow->getId() ); } } $debug = @$_GET["debug"]; /* $kshow_id = @$_GET["kshow_id"]; $debug = @$_GET["debug"]; $this->kshow_id = $kshow_id; if ( $kshow_id == NULL || $kshow_id == 0 ) return; $kshow = kshowPeer::retrieveByPK( $kshow_id ); if ( ! $kshow ) { $this->res = "No kshow " . $kshow_id ; return; } // is the logged-in-user is not an admin or the producer - check if show can be published $likuser_id = $this->getLoggedInUserId(); $viewer_type = myKshowUtils::getViewerType($kshow, $likuser_id); if ( $viewer_type != KshowKuser::KSHOWKUSER_VIEWER_PRODUCER && ( ! $kshow->getCanPublish() ) ) { // ERROR - attempting to publish a non-publishable show return "<xml>!</xml>";//$this->securityViolation( $kshow->getId() ); } // ASSUME - the kshow & roughcut already exist $show_entry_id = $kshow->getShowEntryId(); $roughcut = entryPeer::retrieveByPK( $show_entry_id ); $roughcut = entryPeer::retrieveByPK( $entry_id ); if ( ! $roughcut) { $this->res = "No roughcut for kshow " . $kshow->getId() ; return; } */ // echo "for entry: $show_entry_id current thumb path: " . $entry->getThumbnail() ; $entry->setThumbnail(".jpg"); $entry->setCreateThumb(false); $entry->save(); //$thumb_data = $_REQUEST["ThumbData"]; if (isset($HTTP_RAW_POST_DATA)) { $thumb_data = $HTTP_RAW_POST_DATA; } else { $thumb_data = file_get_contents("php://input"); } // $thumb_data = $GLOBALS["HTTP_RAW_POST_DATA"]; $thumb_data_size = strlen($thumb_data); $bigThumbPath = myContentStorage::getFSContentRootPath() . $entry->getBigThumbnailPath(); kFile::fullMkdir($bigThumbPath); kFile::setFileContent($bigThumbPath, $thumb_data); $path = myContentStorage::getFSContentRootPath() . $entry->getThumbnailPath(); kFile::fullMkdir($path); myFileConverter::createImageThumbnail($bigThumbPath, $path); $roughcutPath = myContentStorage::getFSContentRootPath() . $entry->getDataPath(); $xml_doc = new KDOMDocument(); $xml_doc->load($roughcutPath); if (myMetadataUtils::updateThumbUrl($xml_doc, $entry->getBigThumbnailUrl())) { $xml_doc->save($roughcutPath); } $this->res = $entry->getBigThumbnailUrl(); }