Advertisement
Remote

Untitled

Oct 1st, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.36 KB | None | 0 0
  1. <?php if (! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Sendmail extends CI_Model
  4. {
  5.     function __construct()
  6.     {
  7.         parent::__construct();
  8.         $this->load->library('email');
  9.     }
  10.  
  11.     /**
  12.      * [objectToArray]
  13.      * @param  [stdClass] Opowiedź SOAP
  14.      * @return [ARRAY]
  15.      */
  16.     private function objectToArray($object)
  17.     {
  18.         if((!is_object($object)) && (!is_array($object)))
  19.         {
  20.             return $object;
  21.         }
  22.         if(is_object($object))
  23.         {
  24.             $object = get_object_vars($object);
  25.         }
  26.         return array_map(array($this, 'objectToArray'), $object);
  27.     }
  28.  
  29.     /**
  30.      * Generowanie naglowkow maila
  31.      */
  32.     public function genHeader($mailto, $header)
  33.     {
  34.         $this->email->from($this->email->smtp_user, $this->config->item('name_site'));
  35.         $this->email->to($mailto);
  36.         $this->email->subject('['.$this->config->item('name_site').'] '. $header);
  37.     }
  38.  
  39.     /**
  40.      * Generowanie stopki maila
  41.      */
  42.     public function sendNow($message)
  43.     {
  44.         $this->email->message($message);
  45.         $this->email->send();
  46.         return false;
  47.     }
  48.  
  49.     /**
  50.      * [send_error]
  51.      */
  52.     public function send_soap_error($content)
  53.     {
  54.         $this->Sendmail->genHeader('[email protected]', 'Błąd wysyłania paczki!');
  55.         $message = $this->parser->parse($this->config->item('url_panel').'sendmail/soaperror.tpl', $content, true);
  56.         $this->Sendmail->sendNow($message);
  57.     }
  58.  
  59.     /**
  60.      * Recovery Password
  61.      */
  62.     public function recovery_pass($mailto, $content)
  63.     {
  64.         $this->Sendmail->genHeader($mailto, 'Przypomnienie hasła');
  65.         $new_array = array_merge(
  66.             array(
  67.                 'siteName'      => $this->config->item('name_site'),
  68.                 'baseUrl'       => $this->config->item('base_url'),
  69.                 'emailFooter'   => $this->Settings->get('email_footer'),
  70.                 $content));
  71.         $message = $this->parser->parse($this->config->item('url_panel').'sendmail/recovery_pass.tpl', $new_array, true);
  72.         $this->Sendmail->sendNow($message);
  73.     }
  74.  
  75.     /**
  76.      * New user
  77.      */
  78.     public function new_user($mailto, $content)
  79.     {
  80.         $this->Sendmail->genHeader($mailto, 'Aktywacja konta');
  81.         $new_array = array_merge(
  82.             array(
  83.                 'siteName'      => $this->config->item('name_site'),
  84.                 'baseUrl'       => $this->config->item('base_url'),
  85.                 'emailFooter'   => $this->Settings->get('email_footer'),
  86.                 $content));
  87.         $message = $this->parser->parse($this->config->item('url_panel').'sendmail/new_user.tpl', $new_array, true);
  88.         $this->Sendmail->sendNow($message);
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement