Example #1
0
 /**
  * Add or remove an email address from the mailing list
  *
  * @param boolean $status True if insert, false if remove
  * @param string $email Email address
  * @param boolean $customer If email address belongs to a customer
  * @return boolean If operation was successful
  */
 public function sUpdateNewsletter($status, $email, $customer = false)
 {
     if (!$status) {
         // Delete email address from database
         $this->db->delete('s_campaigns_mailaddresses', array('email = ?' => $email));
     } else {
         // Check if mail address is already subscribed, return
         if ($this->db->fetchOne('SELECT id FROM s_campaigns_mailaddresses WHERE email = ?', array($email))) {
             return false;
         }
         $optInNewsletter = $this->config->get('optinnewsletter');
         if ($optInNewsletter) {
             $hash = md5(uniqid(rand()));
             $data = serialize(array("newsletter" => $email, "subscribeToNewsletter" => true));
             $link = $this->front->Router()->assemble(array('sViewport' => 'newsletter', 'action' => 'index', 'sConfirmation' => $hash));
             $this->sendMail($email, 'sOPTINNEWSLETTER', $link);
             $this->db->insert('s_core_optin', array('datum' => new Zend_Date(), 'hash' => $hash, 'data' => $data));
             return true;
         }
         $groupID = $this->config->get('sNEWSLETTERDEFAULTGROUP');
         if (!$groupID) {
             $groupID = "0";
         }
         // Insert email into database
         if (!empty($customer)) {
             $this->db->insert('s_campaigns_mailaddresses', array('customer' => 1, 'email' => $email, 'added' => $this->getCurrentDateFormatted()));
         } else {
             $this->db->insert('s_campaigns_mailaddresses', array('groupID' => $groupID, 'email' => $email, 'added' => $this->getCurrentDateFormatted()));
         }
     }
     return true;
 }
Example #2
0
 /**
  * Tries to rewrite the provided link using SEO friendly urls
  *
  * @param string $link The link to rewrite.
  * @param string $title Title of the link or related element.
  * @return mixed|string Complete url, rewritten if possible
  */
 public function sRewriteLink($link = null, $title = null)
 {
     $url = str_replace(',', '=', $link);
     $url = html_entity_decode($url);
     $query = parse_url($url, PHP_URL_QUERY);
     parse_str($query, $query);
     if (!empty($title)) {
         $query['title'] = $title;
     }
     $query['module'] = 'frontend';
     return $this->front->Router()->assemble($query);
 }