diff --git a/application/models/EmailText.php b/application/models/EmailText.php index da3bcf18..cca59a22 100644 --- a/application/models/EmailText.php +++ b/application/models/EmailText.php @@ -1,20 +1,19 @@ tmpid)) - { - $this->tmpid = 0; - } + function __construct($db,$id,$replace) + { + $this->db=$db; + $this->tmpid=$id; + $this->data=$replace; + $this->load(); } - public function getinfo(){ + protected function getinfo(){ if(is_numeric($this->tmpid)) $sql = "select * from emailtext where id='".$this->tmpid."'"; @@ -27,18 +26,19 @@ class EmailText{ } - public function loadtmp(){ + public function load($body){ if(empty($this->tmpid)) { return false; }else{ + if (empty($body)) + { + $this->getinfo(); + $body=$this->tmpinfo['body']; + } - $this->getinfo(); - - $c = $this->tmpinfo; - - if(!empty($c['id'])) + if(!empty($body)) { if(count($this->data)==0) { @@ -55,8 +55,8 @@ class EmailText{ } ksort($patterns); ksort($replacements); - $newString=preg_replace($patterns, $replacements, $c['body']); - return $newString; + $this->tmpinfo['body']=preg_replace($patterns, $replacements, $body); + return true; }//count($this->data) } else @@ -64,5 +64,11 @@ class EmailText{ return false; } }//empty($this->tmpid) - }//function loadtmp + }//function loadtmp + public function getBody() { + return $this->tmpinfo['body']; + } + public function getSubject() { + return $this->tmpinfo['subject']; + } } \ No newline at end of file