예제 #1
0
 public function getPhoto($size = "full")
 {
     $photo = sfPhotoGalleryPeer::retrieveByUuid($this->getPicture());
     if (is_null($photo)) {
         $photo = "noproject.png";
     } else {
         $photo = $photo->getRealName();
     }
     if ($size == "small") {
         return '/' . sfConfig::get('sf_upload_dir_name') . '/thumbnails/small/' . $photo;
     }
     if ($size == "medium") {
         return '/' . sfConfig::get('sf_upload_dir_name') . '/thumbnails/medium/' . $photo;
     }
     if ($size == "large") {
         return '/' . sfConfig::get('sf_upload_dir_name') . '/thumbnails/large/' . $photo;
     }
     if ($size == "full") {
         return '/' . sfConfig::get('sf_upload_dir_name') . '/photos/' . $photo;
     }
 }
예제 #2
0
 public function executeRemovePhoto()
 {
     $photo = sfPhotoGalleryPeer::retrieveByUuid($this->getRequestParameter('photo'));
     $this->forward404Unless($photo, 'Photo not found, unable to set profile photo');
     // Make sure photo belongs to user
     if (sfPhotoGalleryPeer::isAttachedToEntity('User', $this->getUser()->getProfile()->getId(), $photo->getUuid())) {
         // Make sure we update the picture if profile photo
         if ($photo->getUuid() != $this->getUser()->getProfile()->getPicture()) {
             $photo->delete();
         } else {
             $photo->delete();
             $this->getUser()->getProfile()->setPicture(NULL);
             $this->getUser()->getProfile()->save();
         }
     }
     $this->redirect($this->getRequest()->getReferer());
 }