ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 require_once 'Services/Mail/classes/class.ilMailTemplate.php';
5 
11 {
15  protected $mail_templates = array();
16 
20  protected $db;
21 
25  public function __construct()
26  {
27  global $DIC;
28 
29  $this->db = $DIC->database();
30 
31  $this->read();
32  }
33 
37  private function read()
38  {
39  $res = $this->db->query('SELECT * FROM mail_man_tpl');
40  while ($row = $this->db->fetchAssoc($res)) {
41  $this->mail_templates[$row['tpl_id']] = new ilMailTemplate($row);
42  }
43  }
44 
48  public function getTableData()
49  {
50  $list = array();
51  foreach ($this->mail_templates as $objMailTpl) {
52  $list[] = array(
53  'tpl_id' => $objMailTpl->getTplId(),
54  'title' => $objMailTpl->getTitle(),
55  'context' => $objMailTpl->getContext(),
56  'lang' => $objMailTpl->getLang()
57  );
58  }
59 
60  return $list;
61  }
62 
67  public function getTemplateById($tpl_id)
68  {
69  return $this->mail_templates[$tpl_id];
70  }
71 
76  public function getTemplateByContextId($context_id)
77  {
78  return array_filter($this->mail_templates, function (ilMailTemplate $template) use ($context_id) {
79  return $context_id === $template->getContext();
80  });
81  }
82 
86  public function deleteTemplates($tpl_ids = array())
87  {
88  if (count($tpl_ids) > 0) {
89  $this->db->manipulate(
90  '
91  DELETE FROM mail_man_tpl WHERE ' .
92  $this->db->in('tpl_id', $tpl_ids, false, 'integer')
93  );
94  }
95  }
96 }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
$template
global $DIC
Definition: saml.php:7
__construct()
ilMailTemplateDataProvider constructor.
Class ilMailTemplate.
Class ilMailTemplateDataProvider.
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.