Added Mailtemplate
This commit is contained in:
@@ -1,13 +1,41 @@
|
||||
<?php
|
||||
|
||||
class Mailtemplate extends mfBaseModel {
|
||||
private $files;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
|
||||
public function getVariableReplacedSubject($replaceVars) {
|
||||
return $this->replaceVariables($this->subject, $replaceVars);
|
||||
}
|
||||
|
||||
public function getVariableReplacedBody($replaceVars) {
|
||||
return $this->replaceVariables($this->body, $replaceVars);
|
||||
}
|
||||
|
||||
private function replaceVariables($text, $replaceVars) {
|
||||
if(!is_array($replaceVars)) return false;
|
||||
|
||||
foreach($replaceVars as $key => $replacement) {
|
||||
$body = str_replace("{{".$key."}}", $replacement, $body);
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "files") {
|
||||
$files = MailtemplateFileModel::search(["mailtemplate_id" => $this->id]);
|
||||
if(!count($files)) {
|
||||
return [];
|
||||
}
|
||||
$this->files = $files;
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$user = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($user) {
|
||||
|
||||
Reference in New Issue
Block a user