ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
class.ilMailTemplateRepository.php
Go to the documentation of this file.
1
<?
php
2
/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
7
class
ilMailTemplateRepository
8
{
10
protected
$db
;
11
16
public
function
__construct
(\
ilDBInterface
$db
= null)
17
{
18
global
$DIC
;
19
20
if
(null ===
$db
) {
21
$db
= $DIC->database();
22
}
23
$this->db =
$db
;
24
}
25
29
public
function
getAll
() : array
30
{
31
$templates = [];
32
33
$res
= $this->db->query(
'SELECT * FROM mail_man_tpl'
);
34
while
(
$row
= $this->db->fetchAssoc(
$res
)) {
35
$template
= new \ilMailTemplate(
$row
);
36
$templates[] =
$template
;
37
}
38
39
return
$templates;
40
}
41
47
public
function
findById
(
int
$templateId) : \
ilMailTemplate
48
{
49
$res
= $this->db->queryF(
50
'SELECT * FROM mail_man_tpl WHERE tpl_id = %s'
,
51
[
'integer'
],
52
[$templateId]
53
);
54
55
if
(1 === (
int
) $this->db->numRows(
$res
)) {
56
$row
= $this->db->fetchAssoc(
$res
);
57
return
new \ilMailTemplate(
$row
);
58
}
59
60
throw
new \OutOfBoundsException(sprintf(
"Could not find template by id: %s"
, $templateId));
61
}
62
67
public
function
findByContextId
(
string
$contextId) : array
68
{
69
return
array_filter($this->
getAll
(),
function
(\
ilMailTemplate
$template
) use ($contextId) {
70
return
$contextId === $template->
getContext
();
71
});
72
}
73
77
public
function
deleteByIds
(array $templateIds)
78
{
79
if
(count($templateIds) > 0) {
80
$this->db->manipulate(
81
'
82
DELETE FROM mail_man_tpl WHERE '
.
83
$this->db->in(
'tpl_id'
, $templateIds,
false
,
'integer'
)
84
);
85
}
86
}
87
91
public
function
store
(\
ilMailTemplate
$template
)
92
{
93
if
($template->
getTplId
() > 0) {
94
$this->db->update(
95
'mail_man_tpl'
,
96
[
97
'title'
=> [
'text'
, $template->
getTitle
()],
98
'context'
=> [
'text'
, $template->
getContext
()],
99
'lang'
=> [
'text'
, $template->
getLang
()],
100
'm_subject'
=> [
'text'
, $template->
getSubject
()],
101
'm_message'
=> [
'text'
, $template->
getMessage
()],
102
'is_default'
=> [
'text'
, $template->
isDefault
()],
103
],
104
[
105
'tpl_id'
=> [
'integer'
, $template->
getTplId
()],
106
]
107
);
108
}
else
{
109
$nextId = $this->db->nextId(
'mail_man_tpl'
);
110
$this->db->insert(
'mail_man_tpl'
, [
111
'tpl_id'
=> [
'integer'
, $nextId],
112
'title'
=> [
'text'
, $template->
getTitle
()],
113
'context'
=> [
'text'
, $template->
getContext
()],
114
'lang'
=> [
'text'
, $template->
getLang
()],
115
'm_subject'
=> [
'text'
, $template->
getSubject
()],
116
'm_message'
=> [
'text'
, $template->
getMessage
()],
117
'is_default'
=> [
'integer'
, $template->
isDefault
()],
118
]);
119
$template->
setTplId
($nextId);
120
}
121
}
122
}
ilMailTemplateRepository\__construct
__construct(\ilDBInterface $db=null)
ilMailTemplateRepository constructor.
Definition:
class.ilMailTemplateRepository.php:16
$template
$template
Definition:
consentAdmin.php:218
ilMailTemplate\getLang
getLang()
Definition:
class.ilMailTemplate.php:114
ilMailTemplate\getTitle
getTitle()
Definition:
class.ilMailTemplate.php:82
$DIC
global $DIC
Definition:
saml.php:7
ilMailTemplateRepository\findByContextId
findByContextId(string $contextId)
Definition:
class.ilMailTemplateRepository.php:67
ilMailTemplate
Class ilMailTemplate.
Definition:
class.ilMailTemplate.php:8
ilMailTemplateRepository\$db
$db
Definition:
class.ilMailTemplateRepository.php:10
ilMailTemplateRepository\deleteByIds
deleteByIds(array $templateIds)
Definition:
class.ilMailTemplateRepository.php:77
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
ilMailTemplateRepository\getAll
getAll()
Definition:
class.ilMailTemplateRepository.php:29
ilMailTemplate\getContext
getContext()
Definition:
class.ilMailTemplate.php:98
ilDBInterface
ilMailTemplate\getMessage
getMessage()
Definition:
class.ilMailTemplate.php:146
ilMailTemplateRepository\store
store(\ilMailTemplate $template)
Definition:
class.ilMailTemplateRepository.php:91
$row
$row
Definition:
migrateto20.php:360
ilMailTemplate\isDefault
isDefault()
Definition:
class.ilMailTemplate.php:162
ilMailTemplate\getTplId
getTplId()
Definition:
class.ilMailTemplate.php:66
ilMailTemplate\setTplId
setTplId(int $templateId)
Definition:
class.ilMailTemplate.php:74
ilMailTemplate\getSubject
getSubject()
Definition:
class.ilMailTemplate.php:130
ilMailTemplateRepository\findById
findById(int $templateId)
Definition:
class.ilMailTemplateRepository.php:47
ilMailTemplateRepository
Class ilMailTemplateRepository.
Definition:
class.ilMailTemplateRepository.php:7
php
Services
Mail
classes
class.ilMailTemplateRepository.php
Generated on Thu Jan 16 2025 19:02:24 for ILIAS by
1.8.13 (using
Doxyfile
)