Class ilMailTemplateService.
More...
◆ clearFromXml()
static ilMailTemplateService::clearFromXml |
( |
|
$a_component, |
|
|
array |
$a_new_templates |
|
) |
| |
|
static |
- Parameters
-
string | $a_component | |
array | $a_new_templates | |
Definition at line 17 of file class.ilMailTemplateService.php.
References $DIC, $id, $query, $row, and array.
Referenced by ilObjDefReader\handlerEndTag().
21 if (!$DIC->database()->tableExists(
'mail_tpl_ctx')) {
25 $persisted_templates =
array();
26 $query =
'SELECT id FROM mail_tpl_ctx WHERE component = ' . $DIC->database()->quote($a_component,
'text');
27 $set = $DIC->database()->query(
$query);
28 while (
$row = $DIC->database()->fetchAssoc($set)) {
29 $persisted_templates[] =
$row[
'id'];
32 if (count($persisted_templates)) {
33 if (count($a_new_templates)) {
34 foreach ($persisted_templates as
$id) {
35 if (!in_array($id, $a_new_templates)) {
36 $DIC->database()->manipulate(
37 'DELETE FROM mail_tpl_ctx WHERE component = ' . $DIC->database()->quote($a_component,
'text') .
' AND id = ' . $DIC->database()->quote($id,
'text')
39 $DIC[
'ilLog']->debug(
"Mail Template XML - Context " . $id .
" in class " . $a_component .
" deleted.");
43 $DIC->database()->manipulate(
'DELETE FROM mail_tpl_ctx WHERE component = ' . $DIC->database()->quote($a_component,
'text'));
44 $DIC[
'ilLog']->debug(
"Mail Template XML - All contexts deleted for " . $a_component .
" as component is inactive.");
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.
◆ createEntry()
static ilMailTemplateService::createEntry |
( |
ilMailTemplateContext |
$a_context, |
|
|
|
$a_component, |
|
|
|
$a_class, |
|
|
|
$a_path |
|
) |
| |
|
staticprotected |
- Parameters
-
Definition at line 168 of file class.ilMailTemplateService.php.
References $DIC, $query, $res, $row, array, and ilMailTemplateContext\getId().
172 $query =
"SELECT id FROM mail_tpl_ctx WHERE id = %s";
174 $row = $DIC->database()->fetchAssoc(
$res);
175 $context_exists = (
$row[
'id'] == $a_context->
getId());
177 if (!$context_exists) {
178 $DIC->database()->insert(
'mail_tpl_ctx',
array(
180 'component' =>
array(
'text', $a_component),
181 'class' =>
array(
'text', $a_class),
182 'path' =>
array(
'text', $a_path)
185 $DIC[
'ilLog']->debug(
"Mail Template XML - Context " . $a_context->
getId() .
" in class " . $a_class .
" added.");
187 $DIC->database()->update(
'mail_tpl_ctx',
array(
188 'component' =>
array(
'text', $a_component),
189 'class' =>
array(
'text', $a_class),
190 'path' =>
array(
'text', $a_path)
195 $DIC[
'ilLog']->debug(
"Mail Template XML - Context " . $a_context->
getId() .
" in class " . $a_class .
" updated.");
getId()
Returns a unique (in the context of mail template contexts) id.
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
◆ getContextInstance()
static ilMailTemplateService::getContextInstance |
( |
|
$a_component, |
|
|
|
$a_id, |
|
|
|
$a_class, |
|
|
|
$a_path |
|
) |
| |
|
staticprotected |
- Parameters
-
string | $a_component | |
string | $a_id | |
string | $a_class | |
string | $a_path | |
- Returns
- null|ilMailTemplateContext
Definition at line 128 of file class.ilMailTemplateService.php.
References $DIC.
135 $a_path = $a_component .
'/classes/';
137 $class_file = $a_path .
'class.' . $a_class .
'.php';
139 if (file_exists($class_file)) {
140 require_once $class_file;
141 if (class_exists($a_class)) {
142 $context =
new $a_class();
144 if ($context->getId() == $a_id) {
147 $mess .=
" - context id mismatch";
150 $mess .=
" - does not extend ilMailTemplateContext";
153 $mess =
"- class not found in file";
156 $mess =
" - class file not found";
159 $DIC[
'ilLog']->debug(
"Mail Template XML - Context " . $a_id .
" in class " . $a_class .
" (" . $class_file .
") is invalid." . $mess);
Class ilMailTemplateContext.
◆ getTemplateContextById()
static ilMailTemplateService::getTemplateContextById |
( |
|
$a_id | ) |
|
|
static |
◆ getTemplateContexts()
static ilMailTemplateService::getTemplateContexts |
( |
|
$a_id = null | ) |
|
|
static |
Returns an array of mail template contexts, the key of each entry matches its id.
- Parameters
-
null | string | array | $a_id | |
- Returns
- ilMailTemplateContext[]
Definition at line 90 of file class.ilMailTemplateService.php.
References $DIC, $query, $row, and array.
Referenced by ilMailTemplateTableGUI\__construct(), ilMailTemplateGUI\getTemplateForm(), and ilMailTemplateGUI\showTemplates().
96 if ($a_id && !is_array($a_id)) {
100 $query =
'SELECT * FROM mail_tpl_ctx';
103 $where[] = $DIC->database()->in(
'id', $a_id,
false,
'text');
106 $query .=
' WHERE ' . implode(
' AND ', $where);
109 $set = $DIC->database()->query(
$query);
110 while (
$row = $DIC->database()->fetchAssoc($set)) {
111 $context = self::getContextInstance(
$row[
'component'],
$row[
'id'],
$row[
'class'],
$row[
'path']);
113 $templates[$context->getId()] = $context;
Class ilMailTemplateContext.
Create styles array
The data for the language used.
◆ insertFromXML()
static ilMailTemplateService::insertFromXML |
( |
|
$a_component, |
|
|
|
$a_id, |
|
|
|
$a_class, |
|
|
|
$a_path |
|
) |
| |
|
static |
- Parameters
-
string | $a_component | |
string | $a_id | |
string | $a_class | |
string | $a_path | |
Definition at line 55 of file class.ilMailTemplateService.php.
References $DIC.
Referenced by ilObjDefReader\handlerBeginTag().
59 if (!$DIC->database()->tableExists(
'mail_tpl_ctx')) {
63 $context = self::getContextInstance($a_component, $a_id, $a_class, $a_path);
65 self::createEntry($context, $a_component, $a_class, $a_path);
Class ilMailTemplateContext.
The documentation for this class was generated from the following file: