ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMailTemplateDataProvider.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Mail/classes/class.ilMailTemplate.php';
5
11{
15 protected $mail_templates = array();
16
17 public function __construct()
18 {
19 $this->read();
20 }
21
25 private function read()
26 {
27 global $ilDB;
28
29 $res = $ilDB->query('SELECT * FROM mail_man_tpl');
30 while($row = $ilDB->fetchAssoc($res))
31 {
32 $this->mail_templates[$row['tpl_id']] = new ilMailTemplate($row);
33 }
34 }
35
39 public function getTableData()
40 {
41 $list = array();
42 foreach($this->mail_templates as $objMailTpl)
43 {
44 $list[] = array(
45 'tpl_id' => $objMailTpl->getTplId(),
46 'title' => $objMailTpl->getTitle(),
47 'context' => $objMailTpl->getContext(),
48 'lang' => $objMailTpl->getLang()
49 );
50 }
51
52 return $list;
53 }
54
59 public function getTemplateById($tpl_id)
60 {
61 return $this->mail_templates[$tpl_id];
62 }
63
68 public function getTemplateByContexId($context_id)
69 {
70 return array_filter($this->mail_templates, function(ilMailTemplate $template) use ($context_id) {
71 return $context_id === $template->getContext();
72 });
73 }
74
78 public function deleteTemplates($tpl_ids = array())
79 {
80 global $ilDB;
81
82 if(count($tpl_ids) > 0)
83 {
84 $ilDB->manipulate('
85 DELETE FROM mail_man_tpl WHERE ' .
86 $ilDB->in('tpl_id', $tpl_ids, false, 'integer')
87 );
88 }
89 }
90}
Class ilMailTemplateDataProvider.
Class ilMailTemplate.
global $ilDB