public function onEmailTemplates() { if (!isset($_POST['templateID'])) { CommonErrors::fatal(COMMONERROR_MISSINGFIELDS, $this, 'Required fields are missing.'); } if(empty($_POST['templateID'])) { if ($this->_realAccessLevel < ACCESS_LEVEL_SA && !$_SESSION['CATS']->hasUserCategory('careerportal')) { CommonErrors::fatal(COMMONERROR_PERMISSION, $this); return; } $useThisTemplate = isset($_POST['useThisTemplate']); $text = $this->getTrimmedInput('emailBody', $_POST); if ($useThisTemplate) { $disabled = 0; } else { $disabled = 1; } $emailTemplates = new EmailTemplates($this->_siteID); $emailTemplates->insert($_REQUEST["emailSubject"], $text, $_REQUEST["templatemodule"] ,$disabled); } else { if ($this->_realAccessLevel < ACCESS_LEVEL_SA && !$_SESSION['CATS']->hasUserCategory('careerportal')) { CommonErrors::fatal(COMMONERROR_PERMISSION, $this); return; //$this->fatal(ERROR_NO_PERMISSION); } if (!$this->isRequiredIDValid('templateID', $_POST)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid template ID.'); } $templateID = $_POST['templateID']; $useThisTemplate = isset($_POST['useThisTemplate']); $text = $this->getTrimmedInput('emailBody', $_POST); if ($useThisTemplate) { $disabled = 0; } else { $disabled = 1; } $emailTemplates = new EmailTemplates($this->_siteID); $emailTemplates->update($templateID, $text, $disabled); } CATSUtility::transferRelativeURI('m=settings&a=emailTemplates'); }