4 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
5 require_once
'Services/Mail/classes/class.ilMailTemplateDataProvider.php';
6 require_once
'Services/Mail/classes/class.ilMailTemplate.php';
7 require_once
'Services/Mail/classes/class.ilMailTemplateService.php';
8 require_once
'Services/Mail/classes/class.ilMailTemplateGenericContext.php';
67 $this->tpl = $DIC->ui()->mainTemplate();
68 $this->ctrl = $DIC->ctrl();
69 $this->lng = $DIC->language();
70 $this->toolbar = $DIC->toolbar();
71 $this->rbacsystem = $DIC->rbac()->system();
72 $this->error = $DIC[
'ilErr'];
74 $this->lng->loadLanguageModule(
'meta');
84 return $this->rbacsystem->checkAccess(
'write', $this->parentObject->getRefId());
92 $next_class = $this->ctrl->getNextClass($this);
93 $cmd = $this->ctrl->getCmd();
95 switch ($next_class) {
97 if (!$cmd || !method_exists($this, $cmd)) {
98 $cmd =
'showTemplates';
111 require_once
'Services/UIComponent/Button/classes/class.ilLinkButton.php';
112 require_once
'Services/Mail/classes/class.ilMailTemplateTableGUI.php';
115 if (count($contexts) <= 1) {
119 $create_tpl_button->setCaption(
'mail_new_template');
120 $create_tpl_button->setUrl($this->ctrl->getLinkTarget($this,
'showInsertTemplateForm'));
121 $this->toolbar->addButtonInstance($create_tpl_button);
125 $tbl->setData($this->provider->getTableData());
127 $this->tpl->setContent(
$tbl->getHTML());
136 $this->error->raiseError($this->lng->txt(
'msg_no_perm_write'), $this->error->WARNING);
141 if (!
$form->checkInput()) {
142 $form->setValuesByPost();
148 if (
$form->getInput(
'context') == $generic_context->getId()) {
149 $form->getItemByPostVar(
'context')->setAlert($this->lng->txt(
'mail_template_no_valid_context'));
150 $form->setValuesByPost();
158 $template->setTitle(
$form->getInput(
'title'));
159 $template->setContext($context->getId());
160 $template->setLang(
$form->getInput(
'lang'));
161 $template->setSubject(
$form->getInput(
'm_subject'));
162 $template->setMessage(
$form->getInput(
'm_message'));
166 $this->ctrl->redirect($this,
'showTemplates');
168 $form->getItemByPostVar(
'context')->setAlert($this->lng->txt(
'mail_template_no_valid_context'));
172 $form->setValuesByPost();
185 $this->tpl->setContent(
$form->getHTML());
194 $this->error->raiseError($this->lng->txt(
'msg_no_perm_write'), $this->error->WARNING);
197 if (!isset(
$_POST[
'tpl_id']) || !strlen(
$_POST[
'tpl_id'])) {
211 if (!
$form->checkInput()) {
212 $form->setValuesByPost();
218 if (
$form->getInput(
'context') == $generic_context->getId()) {
219 $form->getItemByPostVar(
'context')->setAlert($this->lng->txt(
'mail_template_no_valid_context'));
220 $form->setValuesByPost();
228 $template->setContext($context->getId());
235 $this->ctrl->redirect($this,
'showTemplates');
237 $form->getItemByPostVar(
'context')->setAlert($this->lng->txt(
'mail_template_no_valid_context'));
241 $form->setValuesByPost();
251 if (!isset(
$_GET[
'tpl_id']) || !strlen(
$_GET[
'tpl_id'])) {
257 $template = $this->provider->getTemplateById((
int)
$_GET[
'tpl_id']);
268 $this->tpl->setContent(
$form->getHTML());
281 'lang' => $template->
getLang(),
293 $this->error->raiseError($this->lng->txt(
'msg_no_perm_write'), $this->error->WARNING);
296 if (isset(
$_POST[
'tpl_id']) && is_array(
$_POST[
'tpl_id']) && count(
$_POST[
'tpl_id']) > 0) {
297 $tpl_ids = array_filter(array_map(
'intval',
$_POST[
'tpl_id']));
299 if (isset(
$_GET[
'tpl_id']) && strlen(
$_GET[
'tpl_id'])) {
300 $tpl_ids = array_filter(
array((
int)
$_GET[
'tpl_id']));
306 if (count($tpl_ids) == 0) {
312 require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
314 $confirm->setFormAction($this->ctrl->getFormAction($this,
'deleteTemplate'));
315 $confirm->setHeaderText($this->lng->txt(
'mail_sure_delete_entry'));
316 $confirm->setConfirm($this->lng->txt(
'confirm'),
'deleteTemplate');
317 $confirm->setCancel($this->lng->txt(
'cancel'),
'showTemplates');
319 foreach ($tpl_ids as $tpl_id) {
320 $template = $this->provider->getTemplateById((
int) $tpl_id);
321 $confirm->addItem(
'tpl_id[]', $tpl_id,
$template->getTitle());
323 $this->tpl->setContent($confirm->getHTML());
332 $this->error->raiseError($this->lng->txt(
'msg_no_perm_write'), $this->error->WARNING);
335 if (isset(
$_POST[
'tpl_id']) && is_array(
$_POST[
'tpl_id']) && count(
$_POST[
'tpl_id']) > 0) {
336 $tpl_ids = array_filter(array_map(
'intval',
$_POST[
'tpl_id']));
337 if (0 == count($tpl_ids)) {
348 $this->provider->deleteTemplates($tpl_ids);
350 if (1 == count($tpl_ids)) {
355 $this->ctrl->redirect($this,
'showTemplates');
361 require_once
'Services/Mail/classes/Form/class.ilManualPlaceholderInputGUI.php';
363 $placeholders->setInstructionText($this->lng->txt(
'mail_nacc_use_placeholder'));
364 $placeholders->setAdviseText(sprintf($this->lng->txt(
'placeholders_advise'),
'<br />'));
366 foreach ($context->getPlaceholders() as
$key => $value) {
367 $placeholders->addPlaceholder($value[
'placeholder'], $value[
'label']);
369 $placeholders->render(
true);
382 $title->setRequired(
true);
390 if (count($contexts) <= 1) {
392 $this->ctrl->redirect($this,
'showTemplates');
395 $context_sort =
array();
396 $context_options =
array();
398 foreach ($contexts as $ctx) {
399 if ($ctx->getId() != $generic_context->getId()) {
400 $context_options[$ctx->getId()] = $ctx;
401 $context_sort[$ctx->getId()] = $ctx->getTitle();
404 asort($context_sort);
406 foreach ($context_sort as
$id =>
$title) {
407 $ctx = $context_options[
$id];
408 $option =
new ilRadioOption($ctx->getTitle(), $ctx->getId());
409 $option->
setInfo($ctx->getDescription());
410 $context->addOption($option);
416 $context->setValue($first);
417 $context->setRequired(
true);
418 $form->addItem($context);
421 $hidde_language->setValue($this->lng->getLangKey());
422 $form->addItem($hidde_language);
424 $subject =
new ilTextInputGUI($this->lng->txt(
'subject'),
'm_subject');
426 $subject->setRequired(
true);
427 $subject->setSize(50);
428 $form->addItem($subject);
437 require_once
'Services/Mail/classes/Form/class.ilManualPlaceholderInputGUI.php';
440 $placeholders->setInstructionText($this->lng->txt(
'mail_nacc_use_placeholder'));
441 $placeholders->setAdviseText(sprintf($this->lng->txt(
'placeholders_advise'),
'<br />'));
442 $placeholders->supportsRerenderSignal(
444 $this->ctrl->getLinkTarget($this,
'getAjaxPlaceholdersById',
'',
true,
false)
447 $context_id = $generic_context->getId();
452 foreach ($context->getPlaceholders() as
$key => $value) {
453 $placeholders->addPlaceholder($value[
'placeholder'], $value[
'label']);
455 $form->addItem($placeholders);
460 $form->setTitle($this->lng->txt(
'mail_edit_tpl'));
461 $form->setFormAction($this->ctrl->getFormaction($this,
'updateTemplate'));
464 $form->addCommandButton(
'updateTemplate', $this->lng->txt(
'save'));
467 $form->setTitle($this->lng->txt(
'mail_create_tpl'));
468 $form->setFormAction($this->ctrl->getFormaction($this,
'insertTemplate'));
471 $form->addCommandButton(
'insertTemplate', $this->lng->txt(
'save'));
476 $form->addCommandButton(
'showTemplates', $this->lng->txt(
'cancel'));
478 $form->addCommandButton(
'showTemplates', $this->lng->txt(
'back'));
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class represents an option in a radio group.
__construct(\ilObject $parentObject)
showEditTemplateForm(ilPropertyFormGUI $form=null)
getTemplateForm(ilMailTemplate $template=null)
if(!array_key_exists('StateId', $_REQUEST)) $id
getAjaxPlaceholdersById()
setInfo($a_info)
Set Info.
Class ilMailTemplateDataProvider.
static getTemplateContexts($a_id=null)
Returns an array of mail template contexts, the key of each entry matches its id. ...
Class ilMailTemplateTableGUI.
catch(Exception $e) $message
populateFormWithTemplate(ilPropertyFormGUI $form, ilMailTemplate $template)
This class represents a text property in a property form.
showInsertTemplateForm(ilPropertyFormGUI $form=null)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
This class represents a text area property in a property form.
Confirmation screen class.
static getTemplateContextById($a_id)