Exemplo n.º 1
0
 public function output()
 {
     if ($this->output) {
         if (class_exists('Kuler')) {
             $this->output = Kuler::getInstance()->processOutput($this->output);
         }
         if ($this->level) {
             $output = $this->compress($this->output, $this->level);
         } else {
             $output = $this->output;
         }
         if (!headers_sent()) {
             foreach ($this->headers as $header) {
                 header($header, true);
             }
         }
         echo $output;
     }
 }
Exemplo n.º 2
0
 public function subscribeNewsletter(array $info)
 {
     $kuler = Kuler::getInstance();
     $mail_service = $kuler->getSkinOption('mail_service');
     $result = false;
     $contact_list = $kuler->getSkinOption('contact_list');
     if (empty($contact_list)) {
         throw new Exception(_t('error_the_newsletter_system_is_not_configured_please_contact_to_site_admin'));
     }
     switch ($mail_service) {
         case 'mailchimp':
             require_once 'mail_service/mailchimp.php';
             $api_key = $kuler->getSkinOption('mailchimp_api_key');
             if (empty($api_key)) {
                 throw new Exception(_t('error_the_newsletter_system_is_not_configured_please_contact_to_site_admin'));
             }
             $api = new MCAPI($api_key);
             $mail = $info['mail'];
             $merge = array('FNAME' => 'Email', 'LNAME' => ' :' . $mail);
             $api->listSubscribe($contact_list, $mail, $merge);
             if ($api->errorCode) {
                 $message = $api->errorMessage;
                 if ($api->errorCode == 214) {
                     $message = _t('error_your_email_is_already_subscribed_to_list');
                 }
                 throw new Exception($message);
             }
             $result = true;
             break;
         case 'icontact':
             require_once 'mail_service/icontact.php';
             $key = $kuler->getSkinOption('icontact_app_key');
             $username = $kuler->getSkinOption('icontact_username');
             $password = $kuler->getSkinOption('icontact_password');
             if (empty($key) || empty($username) || empty($password)) {
                 throw new Exception(_t('error_the_newsletter_system_is_not_configured_please_contact_to_site_admin'));
             }
             iContactApi::getInstance()->setConfig(array('appId' => $key, 'apiUsername' => $username, 'apiPassword' => $password));
             $oiContact = iContactApi::getInstance();
             try {
                 $result = $oiContact->addContact($info['mail']);
                 $result = $oiContact->subscribeContactToList($result->contactId, $contact_list, 'normal');
             } catch (Exception $e) {
                 throw new Exception($e->getMessage());
             }
             $result = true;
             break;
     }
     return $result;
 }