public static function factory(Storage $storage, $row) { $mailtemplate = new MailTemplate($storage); $mailtemplate->setTemplateID($row["templateid"]); $mailtemplate->setGliederungID($row["gliederungid"]); $mailtemplate->setLabel($row["label"]); $mailtemplate->setBody($row["body"]); return $mailtemplate; }
function parseMailTemplateFormular($ui, $session, &$template = null) { $label = stripslashes($_POST["label"]); $body = stripslashes($_POST["body"]); if ($template == null) { $gliederung = $session->getStorage()->getGliederung($session->getVariable("gliederungid")); if (!$session->isAllowed("mailtemplates_create", $gliederung->getGliederungID())) { $ui->viewLogin(); exit; } $template = new MailTemplate($session->getStorage()); $template->setGliederung($gliederung); } else { $gliederung = $template->getGliederung(); if (!$session->isAllowed("mailtemplates_modify", $gliederung->getGliederungID())) { $ui->viewLogin(); exit; } } $template->setLabel($label); $template->setBody($body); // Headerfelder $headerfields = $session->getListVariable("headerfields"); $headervalues = $session->getListVariable("headervalues"); $headerfieldsindex = array_map('strtolower', $headerfields); foreach ($template->getHeaders() as $field => $header) { if (empty($field) || !in_array(strtolower($field), $headerfieldsindex)) { $template->delHeader($field); } } $headers = array_combine($headerfields, $headervalues); foreach ($headers as $field => $value) { if (!empty($field)) { $template->setHeader($field, $value); } } $template->save(); }