Esempio n. 1
0
 /**
  * [getPreferences description]
  * @param  User   $user [description]
  * @return [type]       [description]
  */
 public function getPreferences(User $user)
 {
     $preferences = $this->repository->getUserPreferences($user->getId());
     if ($preferences == null) {
         return $this->createPreferences($user);
     } else {
         return $preferences;
     }
 }
Esempio n. 2
0
 /**
  *
  */
 public function companyVerificationEmail(User $photographer, $status)
 {
     if ($status == 2) {
         $template = 'MainCommonBundle:Emails\\Company:verificationOk.html.twig';
         $subject = $this->translator->trans('community.verification.ok.subject %name%', array('%name%' => $photographer->getUsername()), 'email');
     } elseif ($status == 4) {
         $template = 'MainCommonBundle:Emails\\Company:suspended.html.twig';
         $subject = $this->translator->trans('community.verification.suspended.subject', array(), 'email');
     } else {
         $template = 'MainCommonBundle:Emails\\Company:verificationKO.html.twig';
         $subject = $this->translator->trans('community.verification.ko.subject', array(), 'email');
     }
     $from = self::EMAIL;
     $to = $photographer->getEmail();
     $body = $this->templating->render($template, array('photographer' => $photographer, 'base_url' => $this->community));
     $this->sendMessage($from, $to, $subject, $body);
 }
Esempio n. 3
0
 /**
  * [editPP description]
  * @param  User   $user [description]
  * @param  [type] $data [description]
  * @return [type]       [description]
  */
 public function editPP(User $user, $data)
 {
     $photo = $data['photo'];
     if ($photo instanceof UploadedFile) {
         // traitement spéciale pour la pièce jointe
         $pjPath = $photo->getPathName();
         $mime = $photo->getMimeType();
         $size = $photo->getSize();
         $content = base64_encode(fread(fopen($pjPath, "r"), filesize($pjPath)));
         $url = hash('sha256', $content . $user->getId());
         if ($user->getPhoto() != $url) {
             try {
                 $file = fopen($this->path . $url, 'a');
                 fputs($file, $content);
                 fclose($file);
                 if ($user->getPhoto() != null) {
                     unlink($this->path . $user->getPhoto());
                 }
                 $user->setPhoto($url);
                 $user->setPhotoType($mime);
                 $user->setUpdatedAt(new \DateTime('now'));
                 $this->em->flush();
                 $this->session->successFlashMessage('flash.message.user.pp');
                 return true;
             } catch (\Exception $e) {
                 $this->session->errorFlashMessage();
                 $this->logger->error($e->getMessage());
                 return false;
                 //$this->logger->err('Impossible de créer un nouveau fichier : '.$e->getMessage());
                 //$codeErr = 1;
                 //throw $e;
             }
         }
         return false;
     }
     return false;
 }