Added Mailtemplate

This commit is contained in:
Frank Schubert
2024-08-29 23:22:49 +02:00
parent 42d2541f6a
commit ebd5d6182a
9 changed files with 527 additions and 41 deletions
+28
View File
@@ -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) {