/**
  * Executes addComment action, which returns a form enabling the insertion of a comment
  * The request may include 1 fields: entry id.
  */
 protected function executeImpl(kshow $kshow, entry &$entry)
 {
     $version = @$_REQUEST["version"];
     // it's a path on the disk
     if (kString::beginsWith($version, ".")) {
         // someone is trying to hack in the system
         return sfView::ERROR;
     }
     // in case we're making a roughcut out of a regular invite, we start from scratch
     if ($entry->getMediaType() != entry::ENTRY_MEDIA_TYPE_SHOW || $entry->getDataPath($version) === null) {
         $this->xml_content = "<xml></xml>";
         return;
     }
     // fetch content of file from disk - it should hold the XML
     $file_name = myContentStorage::getFSContentRootPath() . "/" . $entry->getDataPath($version);
     //echo "[$file_name]";
     if (kString::endsWith($file_name, "xml")) {
         if (file_exists($file_name)) {
             $this->xml_content = kFile::getFileContent($file_name);
             //	echo "[" . $this->xml_content . "]" ;
         } else {
             $this->xml_content = "<xml></xml>";
         }
         myMetadataUtils::updateEntryForPending($entry, $version, $this->xml_content);
     } else {
         return sfView::ERROR;
     }
     // this is NOT an xml file we are looking for !
 }
 protected function executeImpl(kshow $kshow, entry &$entry)
 {
     $list_type = $this->getP("list_type", self::LIST_TYPE_ALL);
     $kshow_entry_list = array();
     $kuser_entry_list = array();
     if ($list_type & self::LIST_TYPE_KSHOW) {
         $c = new Criteria();
         $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP);
         $c->add(entryPeer::MEDIA_TYPE, entry::ENTRY_MEDIA_TYPE_SHOW, Criteria::NOT_EQUAL);
         $c->add(entryPeer::KSHOW_ID, $this->kshow_id);
         $kshow_entry_list = entryPeer::doSelectJoinkuser($c);
     }
     if ($list_type & self::LIST_TYPE_KUSER) {
         $c = new Criteria();
         $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP);
         $c->add(entryPeer::MEDIA_TYPE, entry::ENTRY_MEDIA_TYPE_SHOW, Criteria::NOT_EQUAL);
         $c->add(entryPeer::KUSER_ID, $this->getLoggedInUserIds(), Criteria::IN);
         $kuser_entry_list = entryPeer::doSelectJoinkuser($c);
     }
     if ($list_type & self::LIST_TYPE_EPISODE) {
         if ($kshow->getEpisodeId()) {
             // episode_id will point to the "parent" kshow
             // fetch the entries of the parent kshow
             $c = new Criteria();
             $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP);
             $c->add(entryPeer::MEDIA_TYPE, entry::ENTRY_MEDIA_TYPE_SHOW, Criteria::NOT_EQUAL);
             $c->add(entryPeer::KSHOW_ID, $kshow->getEpisodeId());
             $parent_kshow_entries = entryPeer::doSelectJoinkuser($c);
             if (count($parent_kshow_entries)) {
                 $kshow_entry_list = kArray::append($kshow_entry_list, $parent_kshow_entries);
             }
         }
     }
     // fetch all entries that were used in the roughcut - those of other kusers
     // - appeared under kuser_entry_list when someone else logged in
     if ($list_type & self::LIST_TYPE_ROUGHCUT) {
         if ($kshow->getHasRoughcut()) {
             $roughcut_file_name = $entry->getDataPath();
             $entry_ids_from_roughcut = myFlvStreamer::getAllAssetsIds($roughcut_file_name);
             $final_id_list = array();
             foreach ($entry_ids_from_roughcut as $id) {
                 $found = false;
                 foreach ($kshow_entry_list as $entry) {
                     if ($entry->getId() == $id) {
                         $found = true;
                         break;
                     }
                 }
                 if (!$found) {
                     $final_id_list[] = $id;
                 }
             }
             $c = new Criteria();
             $c->add(entryPeer::ID, $final_id_list, Criteria::IN);
             $extra_entries = entryPeer::doSelectJoinkuser($c);
             // merge the 2 lists into 1:
             $kshow_entry_list = kArray::append($kshow_entry_list, $extra_entries);
         }
     }
     $this->kshow_entry_list = $kshow_entry_list;
     $this->kuser_entry_list = $kuser_entry_list;
 }
 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();
 }