Ejemplo n.º 1
0
 protected function getLoggedInUser()
 {
     if ($this->likuser != NULL) {
         return $this->likuser;
     }
     try {
         $id = $this->getLoggedInUserId();
         if ($id == NULL) {
             return NULL;
         }
         $this->likuser = kuser::getKuserById($id);
         return $this->likuser;
     } catch (Exception $ex) {
         return NULL;
     }
 }
Ejemplo n.º 2
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)
 {
     $fileField = "csv_file";
     $profileId = $this->getP("profile_id");
     if (count($_FILES) == 0) {
         $this->addError(APIErrors::NO_FILES_RECEIVED);
         return;
     }
     if (!@$_FILES[$fileField]) {
         $this->addError(APIErrors::INVALID_FILE_FIELD, $fileField);
         return;
     }
     // first we copy the file to "content/batchfiles/[partner_id]/"
     $fileName = $_FILES[$fileField]['name'];
     $filePath = $_FILES[$fileField]['tmp_name'];
     $kuser = kuser::getKuserById($puser_kuser->getKuserId());
     $partner = PartnerPeer::retrieveByPK($partner_id);
     kJobsManager::addBulkUploadJob($filePath, $fileName, $partner, $kuser->getPuserId(), $kuser->getPuserId(), $profileId);
 }
 public static function createTeam1Image($kshow_id)
 {
     try {
         $contentPath = myContentStorage::getFSContentRootPath();
         $kshow = kshowPeer::retrieveByPK($kshow_id);
         if (!$kshow) {
             return NULL;
         }
         // the canvas for the output -
         $im = imagecreatetruecolor(120, 90);
         $logo_path = kFile::fixPath(SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'main' . DIRECTORY_SEPARATOR . 'kLogoBig.gif');
         $logoIm = imagecreatefromgif($logo_path);
         $logoIm_x = imagesx($logoIm);
         $logoIm_y = imagesy($logoIm);
         imagecopyresampled($im, $logoIm, 0, 0, 0, 0, $logoIm_x * 0.25, $logoIm_y * 0.25, $logoIm_x, $logoIm_y);
         imagedestroy($logoIm);
         // get producer's image
         $producer = kuser::getKuserById($kshow->getProducerId());
         $producer_image_path = kFile::fixPath($contentPath . $producer->getPicturePath());
         if (file_exists($producer_image_path)) {
             list($sourcewidth, $sourceheight, $type, $attr, $srcIm) = myFileConverter::createImageByFile($producer_image_path);
             $srcIm_x = imagesx($srcIm);
             $srcIm_y = imagesy($srcIm);
             // producer -
             imagecopyresampled($im, $srcIm, 0, 0, $srcIm_x * 0.1, $srcIm_y * 0.1, self::DIM_X * 2, self::DIM_Y * 2, $srcIm_x * 0.9, $srcIm_y * 0.9);
             imagedestroy($srcIm);
         }
         // fetch as many different kusers as possible who contributed to the kshow
         // first entries willcome up first
         $c = new Criteria();
         $c->add(entryPeer::KSHOW_ID, $kshow_id);
         $c->add(entryPeer::TYPE, entryType::MEDIA_CLIP, Criteria::EQUAL);
         //$c->add ( entryPeer::PICTURE, null, Criteria::NOT_EQUAL );
         $c->setLimit(16);
         // we'll need 16 images of contributers
         $c->addGroupByColumn(entryPeer::KUSER_ID);
         $c->addDescendingOrderByColumn(entryPeer::CREATED_AT);
         $entries = entryPeer::doSelectJoinkuser($c);
         if ($entries == NULL || count($entries) == 0) {
             imagedestroy($im);
             return;
         }
         //		$entry_index = 0;
         $entry_list_len = count($entries);
         reset($entries);
         if ($entry_list_len > 0) {
             /*
             				 $pos = array(2,3,4, 7,8,9, 10,11,12,13,14, 15,16,17,18,19);
             				 $i = 20;
             				 while(--$i)
             				 {
             $p1 = rand(0, 15);
             $p2 = rand(0, 15);
             $p = $pos[$p1];
             $pos[$p1] = $pos[$p2];
             $pos[$p2] = $p;
             }
             
             $i = count($entries);
             while($i--)
             {
             $x = current($pos) % 5;
             $y = floor(current($pos) / 5);
             next($pos);
             self::addKuserPictureFromEntry ( $contentPath , $im ,$entries , $x , $y );
             }
             */
             for ($y = 0; $y <= 1; ++$y) {
                 for ($x = 2; $x <= 4; ++$x) {
                     self::addKuserPictureFromEntry($contentPath, $im, $entries, $x, $y);
                 }
             }
             for ($y = 2; $y <= 3; ++$y) {
                 for ($x = 0; $x <= 4; ++$x) {
                     self::addKuserPictureFromEntry($contentPath, $im, $entries, $x, $y);
                 }
             }
         } else {
             // no contributers - need to create some other image
         }
         // add the clapper image on top
         $clapper_path = kFile::fixPath(SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'mykaltura' . DIRECTORY_SEPARATOR . 'productionicon.png');
         $clapperIm = imagecreatefrompng($clapper_path);
         imagecopyresampled($im, $clapperIm, 1.2 * self::DIM_X, 1.2 * self::DIM_Y, 0, 0, self::DIM_X, self::DIM_Y, imagesx($clapperIm), imagesy($clapperIm));
         imagedestroy($clapperIm);
         $path = kFile::fixPath($contentPath . $kshow->getTeamPicturePath());
         myContentStorage::fullMkdir($path);
         imagepng($im, $path);
         imagedestroy($im);
         $kshow->setHasTeamImage(true);
         $kshow->save();
     } catch (Exception $ex) {
         // nothing much we can do here !
     }
 }