/**
  * Prepare datas before save
  *
  * @see \ContentinumComponents\Mapper\Process::save()
  */
 public function save($datas, $entity = null, $stage = '', $id = null)
 {
     $entity = $this->handleEntity($entity);
     if (null === $entity->getPrimaryValue()) {
         $ident = $this->fetchRow("SELECT * FROM mcevent_dates WHERE id = {$datas['mceventIdent']}");
         $configure = $this->fetchRow($this->queryString($ident['configure_id']));
         $datas['organizerIdent'] = $configure['organizer_id'];
         $datas['registerIdent'] = Id::get();
         if (strlen($datas['poststreet']) < 2) {
             $datas['poststreet'] = $datas['street'];
             $datas['postnumber'] = $datas['number'];
             $datas['postcity'] = $datas['city'];
             $datas['postzipcode'] = $datas['zipcode'];
         }
         parent::save($datas, $entity, $stage, $id);
         if ('1' === $datas['sendConfirm']) {
             return $this->sendmail($datas, $configure, $ident);
         }
     } else {
         parent::save($datas, $entity, $stage, $id);
         $ident = $this->fetchRow("SELECT * FROM mcevent_dates WHERE id = {$datas['mceventIdent']}");
         $configure = $this->fetchRow($this->queryString($ident['configure_id']));
         $datas['organizerIdent'] = $configure['organizer_id'];
         $datas['registerIdent'] = $entity->registerIdent;
         parent::save($datas, $entity, $stage, $id);
         if ('1' === $datas['sendConfirm']) {
             return $this->sendmail($datas, $configure, $ident);
         }
     }
 }
 /**
  * Prepare datas before save
  *
  * @see \ContentinumComponents\Mapper\Process::save()
  */
 public function save($datas, $entity = null, $stage = '', $id = null)
 {
     $entity = $this->handleEntity($entity);
     if (null === $entity->getPrimaryValue()) {
         $newHost = false;
         if ('createnewhost' == $datas['hostId']) {
             $datas['hostId'] = Id::get();
             $datas['standardDomain'] = 'yes';
             $newHost = true;
         } else {
             $datas['standardDomain'] = 'no';
             $newHost = false;
         }
         $msg = parent::save($datas, $entity, $stage, $id);
         if (true === $newHost) {
             $this->addDefaultPage($datas, $this->lastInsertId);
         }
         $this->emptyCache('contentinum_domain_preference');
         return $msg;
     } else {
         unset($datas['standardDomain']);
         if (1 === $entity->getPrimaryValue()) {
             unset($datas['host']);
         }
         $this->emptyCache('contentinum_domain_preference');
         parent::save($datas, $entity, $stage, $id);
     }
 }
 /**
  * Prepare datas before save
  *
  * @see \ContentinumComponents\Mapper\Process::save()
  */
 public function save($datas, $entity = null, $stage = '', $id = null)
 {
     $entity = $this->handleEntity($entity);
     if (null === $entity->getPrimaryValue()) {
         $ident = $this->fetchRow("SELECT * FROM mcevent_dates WHERE id = {$datas['mceventIdent']}");
         $configure = $this->fetchRow($this->queryString($ident['configure_id']));
         $datas['organizerIdent'] = $configure['organizer_id'];
         $datas['registerIdent'] = Id::get();
         parent::save($datas, $entity, $stage, $id);
         return $this->sendmail($datas, $configure, $ident);
     }
 }
 /**
  * Prepare datas before save
  *
  * @see \ContentinumComponents\Mapper\Process::save()
  */
 public function save($datas, $entity = null, $stage = '', $id = null)
 {
     $entity = $this->handleEntity($entity);
     if (null === $entity->getPrimaryValue()) {
         $datas['verifyString'] = Id::get();
         $datas['close'] = 'open';
         $datas['publish'] = 'yes';
         $datas['date'] = date('Y-m-d H:i:s');
         parent::save($datas, $entity, $stage, $id);
     } else {
         parent::save($datas, $entity, $stage, $id);
     }
 }
 /**
  * Prepare datas before save
  *
  * @see \ContentinumComponents\Mapper\Process::save()
  */
 public function save($datas, $entity = null, $stage = '', $id = null)
 {
     $entity = $this->handleEntity($entity);
     if (null === $entity->getPrimaryValue()) {
         $datas['accountName'] = '';
         $filter = new Prepare();
         $datas['organisationScope'] = $filter->filter($datas['organisation']);
         unset($filter);
         $datas['accountId'] = Id::get();
         parent::save($datas, $entity, $stage, $id);
     } else {
         $filter = new Prepare();
         $datas['organisationScope'] = $filter->filter($datas['organisation']);
         unset($filter);
         parent::save($datas, $entity, $stage, $id);
     }
 }
 /**
  * Content query
  *
  * @param array $params
  *            query conditions
  * @return multitype:
  */
 public function fetchContent(array $params = null)
 {
     $datas = $this->fetchRow("SELECT * FROM newsletter_user WHERE verify_string = '{$params['category']}';");
     if (is_array($datas) && !empty($datas)) {
         $newVerify = Id::get();
         $this->executeQuery("UPDATE newsletter_user SET verify_string = '{$newVerify}', close = 'open', publish = 'yes' WHERE verify_string = '{$params['category']}';");
         $this->setTransport($this->getSl()->get('contentinum_smtp_transport'));
         $configuration = $this->getSl()->get('contentinum_customer');
         $support = $configuration->default->support_mail;
         $newsletter = $configuration->default->newsletter;
         $template = file_get_contents(CON_ROOT_PATH . '/data/files/emailtemplates/' . $this->template);
         //var_dump($pageOptions);exit;
         $body = str_replace('{DATETIME}', date('d.m.Y H:i'), $template);
         $body = str_replace('{TITLE}', $newsletter->website, $body);
         require CON_ROOT_PATH . '/vendor/phpmailer/phpmailer/PHPMailerAutoload.php';
         $mail = new \PHPMailer();
         $mail->isSMTP();
         $transport = $this->getTransport()->getOptions();
         $mail->Host = $transport->getHost();
         $mail->SMTPAuth = true;
         $mail->CharSet = 'utf-8';
         $creditals = $transport->getConnectionConfig();
         $mail->Username = $creditals["username"];
         $mail->Password = $creditals["password"];
         $mail->SMTPSecure = 'ssl';
         $mail->Port = $transport->getPort();
         $mail->From = $support->mailfrom;
         $mail->FromName = $support->mailfromname;
         $mail->addReplyTo($support->mailfrom, $support->mailfromname);
         $mail->addAddress($datas['email']);
         $mail->isHTML(false);
         $mail->Subject = 'Newsletteranmeldung bestätigt';
         $mail->Body = $body;
         if (!$mail->send()) {
             return array('error' => $mail->ErrorInfo);
         } else {
             return array('success' => 'OK');
         }
     } else {
         return array('error' => 'Der Link ist ung&uuml;ltig, bitte nehmen Sie mit uns Kontakt auf!');
     }
 }