Ejemplo n.º 1
0
 /**
  * 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);
 }
Ejemplo n.º 2
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']);
 }
Ejemplo n.º 3
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;
     }
 }
Ejemplo n.º 4
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;
     }
 }
Ejemplo n.º 5
0
 /**
  * toString returns the name.
  *
  * @return string
  */
 public function __toString()
 {
     return (string) $this->contact->getDisplayName();
 }