Beispiel #1
0
 /**
  * @param Contact $contact
  * @param null    $height
  * @param bool    $responsive
  * @param null    $classes
  *
  * @return string
  */
 public function __invoke(Contact $contact, $height = null, $responsive = true, $classes = null)
 {
     if (is_null($contact->getPhoto())) {
         return sprintf('<img src="assets/' . DEBRANOVA_HOST . '/style/image/anonymous.jpg" class="%s" %s>', !($responsive && is_null($height)) ?: implode(' ', ['img-responsive']), is_null($height) ?: 'height="' . $height . '"');
     }
     /**
      * @var Photo $photo
      */
     $photo = $contact->getPhoto()->first();
     if (null !== $classes && !is_array($classes)) {
         $classes = [$classes];
     } elseif (null === $classes) {
         $classes = [];
     }
     if ($responsive) {
         $classes[] = 'img-responsive';
     }
     $this->setClasses($classes);
     /*
      * Return an empty photo when there is no, or only a empty object
      */
     if (!$photo || is_null($photo->getId())) {
         return sprintf('<img src="assets/' . DEBRANOVA_HOST . '/style/image/anonymous.jpg" class="%s" %s>', !($responsive && is_null($height)) ?: implode(' ', ['img-responsive']), is_null($height) ?: 'height="' . $height . '"');
     }
     $this->setRouter('assets/contact-photo');
     $this->addRouterParam('hash', $photo->getHash());
     $this->addRouterParam('ext', $photo->getContentType()->getExtension());
     $this->addRouterParam('id', $photo->getId());
     $this->setHeight($height);
     return $this->createImageUrl();
 }
 /**
  * findAmbassadorByContact returns a generator with only elements of ambassadors
  * based on the country.
  */
 public function testfindAmbassadorByContact()
 {
     $contact = new Contact();
     $contact->setId(1);
     $ambassadorCollection = $this->ambassadorService->findAmbassadorByContact($contact);
     foreach ($ambassadorCollection as $ambassador) {
         $this->assertInstanceOf('Ambassador', $ambassador);
         // contact and all Ambassadors selected have the Contact
         $this->assertEquals($ambassador->getContact(), $contact);
     }
 }
 /**
  * Tests the Contact.
  */
 public function testContact()
 {
     $ambassador = new Ambassador();
     $this->assertInstanceOf("Contact\\Entity\\Contact", $ambassador->getContact());
     // check if ambassador is initialized with an empty country
     $this->assertNull($ambassador->getContact()->getId());
     // if a new country is set check if it is set correctly
     $contact = new Contact();
     $contact->setId(rand(1, 10000));
     $ambassador->setContact($contact);
     $this->assertEquals($contact, $ambassador->getContact());
 }
Beispiel #4
0
 /**
  * @param ProjectEntity $project
  * @param Contact       $contact
  *
  * @return ResultEntity[]
  */
 public function findResultsByProjectAndContact(ProjectEntity $project, Contact $contact)
 {
     $qb = $this->_em->createQueryBuilder();
     $qb->select('r');
     $qb->from("Project\\Entity\\Result\\Result", 'r');
     $qb->join('r.type', 't');
     $qb->join('t.access', 'a');
     $qb->where('r.project = ?1');
     $qb->andWhere($qb->expr()->in('a.access', array_merge_recursive(['public'], $contact->getRoles())));
     $qb->setParameter(1, $project);
     return $qb->getQuery()->getResult();
 }
Beispiel #5
0
 /**
  * @param  Entity\Contact  $contact
  * @param  Entity\Facebook $facebook
  * @return bool
  */
 public function isContactInFacebook(Entity\Contact $contact, Entity\Facebook $facebook)
 {
     $resultSetMap = new ResultSetMapping();
     $resultSetMap->addEntityResult('Contact\\Entity\\Contact', 'c');
     /**
      * Don't map the contact_id because that will overwrite the existing contact object leaving an emtpy one
      */
     $resultSetMap->addFieldResult('c', 'email', 'email');
     $queryInString = sprintf("SELECT %s FROM %s WHERE %s", $facebook->getContactKey(), $facebook->getFromClause(), $facebook->getWhereClause());
     $query = $this->getEntityManager()->createNativeQuery(sprintf("SELECT email FROM contact WHERE contact_id = %s AND contact_id IN (%s) AND date_end IS NULL", $contact->getId(), $queryInString), $resultSetMap);
     return sizeof($query->getResult()) > 0;
 }
Beispiel #6
0
 public function testCanRenderCallNda()
 {
     $renderNda = new RenderNda();
     $renderNda->setServiceLocator($this->serviceManager);
     $contact = new Contact();
     $contact->setFirstName('Johan');
     $contact->setLastName('van der Heide');
     $nda = new Nda();
     $nda->setContact($contact);
     $pdf = $renderNda->renderForCall($nda);
     $this->assertInstanceOf("Program\\Controller\\Plugin\\ProgramPdf", $pdf);
     $this->assertTrue(strlen($pdf->getPDFData()) > 0);
 }
Beispiel #7
0
 /**
  * @param QueryBuilder $qb
  * @param bool         $includeView Trigger to include the documents with type == view
  * @param Contact      $contact
  *
  * @return QueryBuilder $qb
  */
 public function filterForAccess(QueryBuilder $qb, Contact $contact, $includeView = false)
 {
     //Filter based on the type access type
     $subSelect = $this->_em->createQueryBuilder();
     $subSelect->select('type');
     $subSelect->from('Project\\Entity\\Document\\Type', 'type');
     $subSelect->join('type.access', 'access');
     if (!$includeView) {
         $subSelect->andWhere($qb->expr()->in('access.access', array_merge_recursive([strtolower(Access::ACCESS_PUBLIC)], $contact->getRoles())));
     } else {
         $subSelect->andWhere($qb->expr()->orX($qb->expr()->in('access.access', array_merge_recursive([strtolower(Access::ACCESS_PUBLIC)], $contact->getRoles())), $qb->expr()->in('type.view', DocumentType::VIEW)));
     }
     $qb->andWhere($qb->expr()->in('d.type', $subSelect->getDQL()));
     return $qb;
 }
Beispiel #8
0
 public function testCanRenderDoa()
 {
     /**
      * Bootstrap the application to have the other information available
      */
     $renderDoa = new RenderDoa();
     $renderDoa->setServiceLocator($this->serviceManager);
     $contact = new Contact();
     $contact->setFirstName('Johan');
     $contact->setLastName('van der Heide');
     $program = new Program();
     $program->setProgram('testProgram');
     $doa = new Doa();
     $doa->setContact($contact);
     $doa->setProgram($program);
     $pdf = $renderDoa->renderForDoa($doa);
     $this->assertInstanceOf("Program\\Controller\\Plugin\\ProgramPdf", $pdf);
     $this->assertTrue(strlen($pdf->getPDFData()) > 0);
 }
Beispiel #9
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->nda = new Nda();
     $this->nda->setId(1);
     $contact = new Contact();
     $contact->setId(1234);
     $this->nda->setContact($contact);
     $program = new Program();
     $program->setId(1);
     $program->setProgram('Program');
     $call = new Call();
     $call->setId(1);
     $call->setCall("Call");
     $call->setProgram($program);
     $this->nda->setCall(new ArrayCollection([$call]));
     $this->ndaLink = $this->serviceManager->get('viewhelpermanager')->get('ndaLink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
 /**
  * Update or insert a contact document
  *
  * @param Contact $contact
  *
  * <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
  * <field name="contact_id" type="int" indexed="true" stored="true" omitNorms="true"/>
  * <field name="fullname" type="text_general" indexed="true" stored="true" omitNorms="true"/>
  * <field name="lastname" type="string" indexed="true" stored="true" omitNorms="true"/>
  * <field name="position" type="text_en_splitting" indexed="true" stored="true" omitNorms="true"/>
  * <field name="type" type="string" indexed="true" stored="true" omitNorms="true"/>
  * <field name="photo_url" type="string" indexed="true" stored="true" omitNorms="true"/>
  * <field name="organisation" type="string" indexed="true" stored="true" omitNorms="true"/>
  * <field name="organisation_type" type="string" indexed="true" stored="true" omitNorms="true"/>
  * <field name="country" type="string" indexed="true" stored="true" omitNorms="true"/>
  * <field name="profile" type="text_en_splitting" indexed="true" stored="true" omitNorms="true"/>
  * <field name="cv" type="text_en_splitting" indexed="true" stored="true" omitNorms="true"/>
  *
  * @return \Solarium\Core\Query\Result\ResultInterface
  * @throws \Solarium\Exception\HttpException
  */
 public function updateDocument($contact)
 {
     // Get an update query instance
     $update = $this->getSolrClient()->createUpdate();
     $contactDocument = $update->createDocument();
     $contactDocument->id = $contact->getResourceId();
     $contactDocument->contact_id = $contact->getId();
     $contactDocument->type = 'contact';
     $contactDocument->fullname = $contact->getDisplayName();
     $contactDocument->lastname = $contact->getLastName();
     $contactDocument->position = $contact->getPosition();
     if (!is_null($contact->getProfile())) {
         $contactDocument->profile = str_replace(PHP_EOL, '', strip_tags($contact->getProfile()->getDescription()));
         if ($contact->getProfile()->getHidePhoto() === Profile::NOT_HIDE_PHOTO && $contact->getPhoto()->count() > 0) {
             $photo = $contact->getPhoto()->first();
             $contactDocument->photo_url = $this->getServiceLocator()->get('ViewHelperManager')->get('url')->__invoke('assets/contact-photo', ['hash' => $photo->getHash(), 'ext' => $photo->getContentType()->getExtension(), 'id' => $photo->getId()]);
         }
     }
     if (!is_null($contact->getContactOrganisation())) {
         $contactDocument->organisation = $contact->getContactOrganisation()->getOrganisation()->getOrganisation();
         $contactDocument->organisation_type = $contact->getContactOrganisation()->getOrganisation()->getType();
         $contactDocument->country = $contact->getContactOrganisation()->getOrganisation()->getCountry()->getCountry();
     }
     if (!is_null($contact->getCv())) {
         $contactDocument->cv = str_replace(PHP_EOL, '', strip_tags(stream_get_contents($contact->getCv()->getCv())));
     }
     $update->addDocument($contactDocument);
     $update->addCommit();
     return $this->executeUpdateDocument($update);
 }
Beispiel #11
0
 /**
  * @param QueryBuilder $qb
  * @param Contact      $contact
  *
  * @return QueryBuilder $qb
  */
 public function filterForAccess(QueryBuilder $qb, Contact $contact)
 {
     //Filter based on the type access type
     $subSelect = $this->_em->createQueryBuilder();
     $subSelect->select('type');
     $subSelect->from('Calendar\\Entity\\Type', 'type');
     $subSelect->join('type.access', 'access');
     $subSelect->andWhere($qb->expr()->in('access.access', array_merge([strtolower(Access::ACCESS_PUBLIC)], $contact->getRoles())));
     $subSelectCalendarContact = $this->_em->createQueryBuilder();
     $subSelectCalendarContact->select('calendar2');
     $subSelectCalendarContact->from('Calendar\\Entity\\Calendar', 'calendar2');
     $subSelectCalendarContact->join('calendar2.calendarContact', 'calenderContact2');
     $subSelectCalendarContact->join('calenderContact2.contact', 'contact2');
     $subSelectCalendarContact->andWhere('contact2.id = ' . $contact);
     $qb->andWhere($qb->expr()->orX($qb->expr()->in('c.type', $subSelect->getDQL()), $qb->expr()->in('c', $subSelectCalendarContact->getDQL())));
     return $qb;
 }
Beispiel #12
0
 /**
  * @param int     $optInId
  * @param Contact $contact
  *
  * @return OptIn
  */
 public function hasOptInEnabledByContact($optInId, Contact $contact)
 {
     /**
      * The OptIn is a n:m entity, so we just check if the contact has the optIn
      */
     foreach ($contact->getOptIn() as $optIn) {
         if ($optIn->getId() === $optInId) {
             return true;
         }
     }
     return false;
 }
Beispiel #13
0
 /**
  * @param Contact $contact
  */
 public function setFromContact(Contact $contact)
 {
     /*
      * The From contact cannot have the FROM email since we don't want to sent emails directly from other users
      */
     $config = $this->getServiceManager()->get('config');
     $this->from = $config['email']['defaults']['from_email'];
     $this->replyTo = $contact->getEmail();
     $this->replyToName = $contact->getDisplayName();
     $this->fromName = sprintf("%s (via %s)", $contact->getDisplayName(), $config['email']['defaults']['from_name']);
 }
Beispiel #14
0
 /**
  * Create an array with the incomplete items in the profile and the relative weight.
  *
  * @param Contact $contact
  *
  * @return array;
  */
 public function getProfileInCompleteness(Contact $contact)
 {
     $inCompleteness = [];
     $totalWeight = 0;
     $totalWeight += 10;
     if (is_null($contact->getFirstName())) {
         $inCompleteness['firstName']['message'] = _("txt-first-name-is-missing");
         $inCompleteness['firstName']['weight'] = 10;
     }
     $totalWeight += 10;
     if (is_null($contact->getLastName())) {
         $inCompleteness['lastName']['message'] = _("txt-last-name-is-missing");
         $inCompleteness['lastName']['weight'] = 10;
     }
     $totalWeight += 10;
     if (sizeof($contact->getPhone()) === 0) {
         $inCompleteness['phone']['message'] = _("txt-no-telephone-number-known");
         $inCompleteness['phone']['weight'] = 10;
     }
     $totalWeight += 10;
     if (sizeof($contact->getAddress()) === 0) {
         $inCompleteness['address']['message'] = _("txt-no-address-known");
         $inCompleteness['address']['weight'] = 10;
     }
     $totalWeight += 10;
     if (sizeof($contact->getPhoto()) === 0) {
         $inCompleteness['photo']['message'] = _("txt-no-profile-photo-given");
         $inCompleteness['photo']['weight'] = 10;
     }
     $totalWeight += 10;
     if (is_null($contact->getSaltedPassword())) {
         $inCompleteness['password']['message'] = _("txt-no-password-given");
         $inCompleteness['password']['weight'] = 10;
     }
     $totalWeight += 20;
     if (is_null($contact->getContactOrganisation()) === 0) {
         $inCompleteness['organisation']['message'] = _("txt-no-organisation-known");
         $inCompleteness['organisation']['weight'] = 20;
     }
     /*
      * Determine the total weight
      */
     $incompletenessWeight = 0;
     /*
      * Update the values in the table to create a total weight of 100%
      */
     foreach ($inCompleteness as &$itemPerType) {
         $itemPerType['weight'] = $itemPerType['weight'] / $totalWeight * 100;
         $incompletenessWeight += $itemPerType['weight'];
     }
     return ['items' => $inCompleteness, 'incompletenessWeight' => $incompletenessWeight];
 }
Beispiel #15
0
 /**
  * Return Contact entities based on a selection SQL using a native SQL query
  *
  * @param Entity\Contact $contact
  * @param SelectionSql   $sql
  *
  * @return bool
  */
 public function isContactInSelectionSQL(Entity\Contact $contact, SelectionSQL $sql)
 {
     $resultSetMap = new ResultSetMapping();
     $resultSetMap->addEntityResult('Contact\\Entity\\Contact', 'c');
     $resultSetMap->addFieldResult('c', 'contact_id', 'id');
     $query = $this->getEntityManager()->createNativeQuery("SELECT\n             contact_id\n             FROM contact\n             WHERE contact_id\n             IN (" . $sql->getQuery() . ") AND contact_id = " . $contact->getId(), $resultSetMap);
     return sizeof($query->getResult()) > 0;
 }
Beispiel #16
0
 /**
  * Body function, creating the contactObjects.
  */
 private function prepareContent()
 {
     foreach ($this->content as $key => $content) {
         //See first if the contact can be found
         $contact = $this->getContactService()->findContactByEmail($content[$this->headerKeys['email']]);
         if (!is_null($contact)) {
             $contact->key = $key;
             $this->contacts[] = $contact;
             continue;
         }
         /**
          * 'organisation_id' => int 0
          * 'organisation' => int 1
          * 'firstname' => int 2
          * 'middlename' => int 3
          * 'lastname' => int 4
          * 'position' => int 5
          * 'email' => int 6
          * 'phone' => int 7
          * 'country' => int 8
          * 'gender' => int 8
          * 'title' => int 8
          */
         //Contact is not found
         $contact = new Contact();
         $contact->key = $key;
         $contact->setFirstName($content[$this->headerKeys['firstname']]);
         $contact->setMiddleName($content[$this->headerKeys['middlename']]);
         $contact->setLastName($content[$this->headerKeys['lastname']]);
         $contact->setEmail($content[$this->headerKeys['email']]);
         $gender = null;
         $title = null;
         if (isset($this->headerKeys['gender']) && !empty($content[$this->headerKeys['gender']])) {
             $gender = $contact->setGender($this->getGeneralService()->findGenderByGender($content[$this->headerKeys['gender']]));
         }
         if (!is_null($gender)) {
             $contact->setGender($gender);
         } else {
             $contact->setGender($this->getGeneralService()->findEntityById('gender', Gender::GENDER_UNKNOWN));
         }
         if (isset($this->headerKeys['title']) && !empty($content[$this->headerKeys['title']])) {
             $title = $contact->setTitle($this->getGeneralService()->findTitleByTitle($content[$this->headerKeys['title']]));
         }
         if (!is_null($title)) {
             $contact->setTitle($title);
         } else {
             $contact->setTitle($this->getGeneralService()->findEntityById('title', Title::TITLE_UNKNOWN));
         }
         $contact->setPosition($content[$this->headerKeys['position']]);
         //If found, set the phone number
         if (isset($this->headerKeys['phone']) && !empty($content[$this->headerKeys['phone']])) {
             $phone = new Phone();
             $phoneType = $this->getContactService()->findEntityById('phoneType', PhoneType::PHONE_TYPE_DIRECT);
             $phone->setType($phoneType);
             $phone->setPhone($content[$this->headerKeys['phone']]);
             $phone->setContact($contact);
             $phones = new ArrayCollection();
             $phones->add($phone);
             $contact->setPhone($phones);
         }
         //Try to find the country
         $country = $this->getGeneralService()->findCountryByName($content[$this->headerKeys['country']]);
         //Try to find the organisation
         $organisationName = $content[$this->headerKeys['organisation']];
         $organisation = null;
         if (isset($this->headerKeys['organisation_id']) && !empty($content[$this->headerKeys['organisation_id']])) {
             $organisation = $this->getOrganisationService()->setOrganisationId($content[$this->headerKeys['organisation_id']])->getOrganisation();
         }
         if (is_null($organisation) && !is_null($country)) {
             $organisation = $this->getOrganisationService()->findOrganisationByNameCountry($organisationName, $country);
         }
         //If the organisation does not exist, create it
         if (is_null($organisation) && !is_null($country)) {
             $organisation = new Organisation();
             $organisation->setOrganisation($organisationName);
             $organisation->setCountry($country);
             //Add the type
             $organisationType = $this->getOrganisationService()->findEntityById('type', Type::TYPE_UNKNOWN);
             $organisation->setType($organisationType);
             //Add the domain
             $validate = new EmailAddress();
             $validate->isValid($content[$this->headerKeys['email']]);
             $organisationWebElements = new ArrayCollection();
             $organisationWeb = new Web();
             $organisationWeb->setWeb($validate->hostname);
             $organisationWeb->setMain(Web::MAIN);
             $organisationWeb->setOrganisation($organisation);
             $organisationWebElements->add($organisationWeb);
             if (isset($this->headerKeys['website']) && !is_null($content[$this->headerKeys['website']])) {
                 //Strip the http:// and https://
                 $website = str_replace('http://', '', $content[$this->headerKeys['website']]);
                 $website = str_replace('https://', '', $website);
                 $organisationWebsite = new Web();
                 $organisationWebsite->setMain(Web::MAIN);
                 $organisationWebsite->setWeb($website);
                 $organisationWebsite->setOrganisation($organisation);
                 $organisationWebElements->add($organisationWebsite);
             }
             $organisation->setWeb($organisationWebElements);
         }
         /**
          * If an organisation is found, add it to the contact
          */
         if (!is_null($organisation)) {
             $contactOrganisation = new ContactOrganisation();
             $contactOrganisation->setOrganisation($organisation);
             $contactOrganisation->setContact($contact);
             $contact->setContactOrganisation($contactOrganisation);
         }
         /** Add the contact to the contacts array */
         $this->contacts[] = $contact;
     }
 }
 /**
  * @param Contact $contact
  *
  * @return array
  */
 public function findOrganisationForProfileEditByContact(Contact $contact)
 {
     $organisations = [];
     //Start with your own organisation
     if (!is_null($contact->getContactOrganisation())) {
         $organisations[$contact->getContactOrganisation()->getOrganisation()->getId()] = $contact->getContactOrganisation()->getOrganisation();
     }
     foreach ($this->findOrganisationByEmailAddress($contact->getEmail()) as $organisation) {
         $organisations[$organisation->getId()] = $organisation;
     }
     asort($organisations);
     //Add an empty value
     $emptyOrganisation = new Entity\Organisation();
     $emptyOrganisation->setId(0);
     $emptyOrganisation->setOrganisation('&mdash; None of the above');
     $organisations[$emptyOrganisation->getId()] = $emptyOrganisation;
     return $organisations;
 }
 /**
  * @param Project $project
  * @param Contact $contact
  * @param int     $which
  *
  * @return null|Affiliation
  */
 public function findAffiliationByProjectAndContactAndWhich(Project $project, Contact $contact, $which = self::WHICH_ONLY_ACTIVE)
 {
     /**
      * If the contact has no contact organisation, return null because we will not have a affiliation
      */
     if (is_null($contact->getContactOrganisation())) {
         return;
     }
     foreach ($project->getAffiliation() as $affiliation) {
         if ($which === self::WHICH_ONLY_ACTIVE && !is_null($affiliation->getDateEnd())) {
             continue;
         }
         if ($which === self::WHICH_ONLY_INACTIVE && is_null($affiliation->getDateEnd())) {
             continue;
         }
         if ($affiliation->getOrganisation()->getId() === $contact->getContactOrganisation()->getOrganisation()->getId()) {
             return $affiliation;
         }
     }
     return;
 }
Beispiel #19
0
 /**
  * Needed for the hydration of form elements.
  *
  * @return array
  */
 public function getArrayCopy()
 {
     return ['id' => $this->id, 'rationale' => $this->rationale, 'contact' => $this->contact->getId()];
 }
Beispiel #20
0
 /**
  * Send the email.
  */
 public function send()
 {
     switch ($this->email->isPersonal()) {
         case true:
             foreach ($this->email->getTo() as $recipient => $contact) {
                 /*
                  * Create a new message for everyone
                  */
                 $this->message = new Message();
                 $this->message->setEncoding('UTF-8');
                 $this->generateMessage();
                 //add the CC and BCC to the email
                 $this->setShadowRecipients();
                 /*
                  * We have a recipient which can be an instance of the contact. Produce a contactService object
                  * and fill the templateVars with extra options
                  */
                 if ($contact instanceof Contact) {
                     $this->updateTemplateVarsWithContact($contact);
                 } else {
                     $contactName = $contact;
                     $contact = new Contact();
                     $contact->setEmail($recipient);
                     if (!is_null($contactName)) {
                         $contact->setFirstName($contactName);
                     }
                 }
                 /*
                  * Overrule the to when we are in development
                  */
                 if (!defined("DEBRANOVA_ENVIRONMENT") || 'development' === DEBRANOVA_ENVIRONMENT) {
                     $this->message->addTo($this->config["emails"]["admin"], $contact->getDisplayName());
                 } else {
                     $this->message->addTo($contact->getEmail(), $contact->getDisplayName());
                 }
                 //$this->message->addTo($contact->getEmail(), $contact->getDisplayName());
                 /*
                  * We have the contact and can now produce the content of the message
                  */
                 $this->parseSubject();
                 /*
                  * We have the contact and can now produce the content of the message
                  */
                 $this->parseBody();
                 /*
                  * Send the email
                  */
                 $this->transport->send($this->message);
             }
             break;
         case false:
             /*
              * Create a new message for everyone
              */
             $this->message = new Message();
             $this->message->setEncoding('UTF-8');
             $this->generateMessage();
             //add the CC and BCC to the email
             $this->setShadowRecipients();
             foreach ($this->email->getTo() as $recipient => $contact) {
                 /*
                  * We have a recipient which can be an instance of the contact. Produce a contactService object
                  * and fill the templateVars with extra options
                  */
                 if (!$contact instanceof Contact) {
                     $contactName = $contact;
                     $contact = new Contact();
                     $contact->setEmail($recipient);
                     $contact->setFirstName($contactName);
                 }
                 /*
                  * Overrule the to when we are in development
                  */
                 if (!defined("DEBRANOVA_ENVIRONMENT") || 'development' === DEBRANOVA_ENVIRONMENT) {
                     $this->message->addTo($this->config["emails"]["admin"], $contact->getDisplayName());
                 } else {
                     $this->message->addTo($contact->getEmail(), $contact->getDisplayName());
                 }
             }
             /*
              * We have the contact and can now produce the content of the message
              */
             $this->parseSubject();
             /*
              * We have the contact and can now produce the content of the message
              */
             $this->parseBody();
             /*
              * Send the email
              */
             $this->transport->send($this->message);
             break;
     }
 }
Beispiel #21
0
 public function testHasInputFilter()
 {
     $contact = new Contact();
     $this->assertInstanceOf('Zend\\InputFilter\\InputFilter', $contact->getInputFilter());
 }
Beispiel #22
0
 /**
  * Send the email.
  */
 public function send()
 {
     switch ($this->email->isPersonal()) {
         case true:
             foreach ($this->email->getTo() as $recipient => $contact) {
                 /*
                  * Create a new message for everyone
                  */
                 $this->message = new Message();
                 $this->message->setEncoding('UTF-8');
                 $this->generateMessage();
                 //add the CC and BCC to the email
                 $this->setShadowRecipients();
                 /*
                  * We have a recipient which can be an instance of the contact. Produce a contactService object
                  * and fill the templateVars with extra options
                  */
                 if ($contact instanceof Contact) {
                     $this->updateTemplateVarsWithContact($contact);
                 } else {
                     $contact = new Contact();
                     $contact->setEmail($recipient);
                 }
                 /*
                  * Overrule the to when we are in development
                  */
                 if (!defined("DEBRANOVA_ENVIRONMENT") || 'development' === DEBRANOVA_ENVIRONMENT) {
                     $this->message->addTo('*****@*****.**', $contact->getDisplayName());
                 } else {
                     $this->message->addTo($contact->getEmail(), !is_null($contact->getId()) ? $contact->getDisplayName() : null);
                 }
                 /**
                  * We have the contact and can now produce the content of the message
                  */
                 $this->parseSubject();
                 /**
                  * If we have a deeplink, parse it
                  */
                 $this->parseDeeplink();
                 /**
                  * If we have an unsubscribe, parse it
                  */
                 $this->parseUnsubscribe();
                 /**
                  * We have the contact and can now produce the content of the message
                  */
                 $this->parseBody();
                 /**
                  * Send the email
                  */
                 $this->transport->send($this->message);
             }
             break;
         case false:
             /*
              * Create a new message for everyone
              */
             $this->message = new Message();
             $this->message->setEncoding('UTF-8');
             $this->generateMessage();
             //add the CC and BCC to the email
             $this->setShadowRecipients();
             foreach ($this->email->getTo() as $recipient => $contact) {
                 /*
                  * We have a recipient which can be an instance of the contact. Produce a contactService object
                  * and fill the templateVars with extra options
                  */
                 if (!$contact instanceof Contact) {
                     $contact = new Contact();
                     $contact->setEmail($recipient);
                 }
                 /*
                  * Overrule the to when we are in development
                  */
                 if (!defined("DEBRANOVA_ENVIRONMENT") || 'development' === DEBRANOVA_ENVIRONMENT) {
                     $this->message->addTo('*****@*****.**', $contact->getDisplayName());
                 } else {
                     $this->message->addTo($contact->getEmail(), !is_null($contact->getId()) ? $contact->getDisplayName() : null);
                 }
             }
             /*
              * We have the contact and can now produce the content of the message
              */
             $this->parseSubject();
             /**
              * If we have a deeplink, parse it
              */
             $this->parseDeeplink();
             /**
              * If we have an unsubscribe, parse it
              */
             $this->parseUnsubscribe();
             /*
              * We have the contact and can now produce the content of the message
              */
             $this->parseBody();
             /*
              * Send the email
              */
             $this->transport->send($this->message);
             break;
     }
 }
Beispiel #23
0
 /**
  * toString returns the name.
  *
  * @return string
  */
 public function __toString()
 {
     return (string) $this->contact->getDisplayName();
 }