예제 #1
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());
 }