public function getId()
 {
     if ($this->__isInitialized__ === false) {
         return (int) $this->_identifier["id"];
     }
     $this->__load();
     return parent::getId();
 }
 /**
  * @Route("/{id}/approve",requirements={"id"="\d+"}, name="civix_front_group_members_approve")
  * @Method({"POST"})
  */
 public function approveUser(User $user)
 {
     $entityManager = $this->getDoctrine()->getManager();
     $csrfProvider = $this->get('form.csrf_provider');
     if ($csrfProvider->isCsrfTokenValid('approve_members_' . $user->getId(), $this->getRequest()->get('_token'))) {
         $userGroup = $entityManager->getRepository('CivixCoreBundle:UserGroup')->isJoinedUser($this->getUser(), $user);
         if ($userGroup) {
             $userGroup->setStatus(UserGroup::STATUS_ACTIVE);
             $entityManager->persist($userGroup);
             $entityManager->flush();
             $this->get('civix_core.social_activity_manager')->noticeGroupJoiningApproved($userGroup);
             $this->get('session')->getFlashBag()->add('notice', 'User has been successfully approved');
             return $this->redirect($this->generateUrl('civix_front_group_manage_approvals'));
         }
     }
     $this->get('session')->getFlashBag()->add('error', 'Something went wrong');
 }
 public function updateProfileCommon(User $user, User $new)
 {
     $user->setFirstName($new->getFirstName())->setLastName($new->getLastName())->setBirth($new->getBirth())->setAddress1($new->getAddress1())->setAddress2($new->getAddress2())->setCity($new->getCity())->setState($new->getState())->setCountry($new->getCountry())->setZip($new->getZip())->setEmail($new->getEmail())->setPhone($new->getPhone())->setFacebookLink($new->getFacebookLink())->setTwitterLink($new->getTwitterLink())->setUpdateProfileAt(new \DateTime())->setBio($new->getBio())->setSlogan($new->getSlogan())->setInterests($new->getInterests());
     if ($new->getPassword()) {
         $user->setPassword($new->getPassword())->setSalt($new->getSalt());
     }
     if ($new->getAvatarFileName() && $new->getAvatarFileName() !== $user->getAvatarFileName()) {
         $img = imagecreatefromstring(base64_decode($new->getAvatarFileName()));
         if ($img != false) {
             $filename = $user->getId() . '_' . uniqid() . '.jpeg';
             $temp_file = tempnam(sys_get_temp_dir(), 'avatar');
             if (imagejpeg($img, $temp_file)) {
                 //square avatars
                 try {
                     $this->cropImageService->rebuildImage($temp_file, $temp_file);
                 } catch (\Exception $exc) {
                 }
                 $fileUpload = new UploadedFile($temp_file, $filename);
                 $user->setAvatar($fileUpload);
             }
         }
     }
     $user->setIsRegistrationComplete(true);
 }
Example #4
0
 public static function toUserOwnerData(User $user)
 {
     return ['id' => $user->getId(), 'type' => $user->getType(), 'official_title' => '', 'first_name' => $user->getFirstName(), 'last_name' => $user->getLastName(), 'avatar_file_path' => $user->getAvatarFileName()];
 }
 public function findActivitiesByFollowing(User $following)
 {
     return $this->createQueryBuilder('act')->leftJoin('act.activityConditions', 'act_c')->where('act_c.userId = :following')->setParameter('following', $following->getId())->orderBy('act.sentAt', 'DESC')->setMaxResults(100)->getQuery()->getResult();
 }
 private function createUserActivityConditions(Activity $activity, User $user)
 {
     $condition = new ActivityCondition($activity);
     $condition->setUserId($user->getId());
     $this->entityManager->persist($condition);
     $this->entityManager->flush($condition);
 }
 private function addUnfollowingFilter(QueryBuilder $qb, User $user)
 {
     $excludedIds = array_merge(array($user->getId()), $user->getFollowingIds());
     $qb->andWhere('u.id NOT IN (:excluded_ids)')->setParameter('excluded_ids', $excludedIds);
     return $qb;
 }
 /**
  * @Route("/{id}/approve",requirements={"id"="\d+"}, name="civix_front_group_members_approve")
  * @Method({"POST"})
  */
 public function approveUser(User $user)
 {
     $entityManager = $this->getDoctrine()->getManager();
     $csrfProvider = $this->get('form.csrf_provider');
     if ($csrfProvider->isCsrfTokenValid('approve_members_' . $user->getId(), $this->getRequest()->get('_token'))) {
         $userGroup = $entityManager->getRepository('CivixCoreBundle:UserGroup')->isJoinedUser($this->getUser(), $user);
         if ($userGroup) {
             $slugify = new Slugify();
             $groupName = $slugify->slugify($userGroup->getGroup()->getOfficialName(), '');
             $mailgun = $this->get('civix_core.mailgun')->listaddmemberAction($groupName, $userGroup->getUser()->getEmail(), $userGroup->getUser()->getFirstName() . ' ' . $userGroup->getUser()->getLastName());
             if ($mailgun['http_response_code'] != 200) {
                 $this->get('session')->getFlashBag()->add('error', 'cannot add user to mailgun list');
                 return $this->redirect($this->generateUrl('civix_front_group_manage_approvals'));
             }
             $userGroup->setStatus(UserGroup::STATUS_ACTIVE);
             $entityManager->persist($userGroup);
             $entityManager->flush();
             $this->get('civix_core.social_activity_manager')->noticeGroupJoiningApproved($userGroup);
             $this->get('session')->getFlashBag()->add('notice', 'User has been successfully approved');
             return $this->redirect($this->generateUrl('civix_front_group_manage_approvals'));
         }
     }
     $this->get('session')->getFlashBag()->add('error', 'Something went wrong');
 }