13    public static function clearFromXml($a_component, array $a_new_templates)
 
   17        if (!
$DIC->database()->tableExists(
'mail_tpl_ctx')) {
 
   21        $persisted_templates = array();
 
   22        $query = 
'SELECT id FROM mail_tpl_ctx WHERE component = ' . 
$DIC->database()->quote($a_component, 
'text');
 
   24        while (
$row = 
$DIC->database()->fetchAssoc($set)) {
 
   25            $persisted_templates[] = 
$row[
'id'];
 
   28        if (count($persisted_templates)) {
 
   29            if (count($a_new_templates)) {
 
   30                foreach ($persisted_templates as 
$id) {
 
   31                    if (!in_array(
$id, $a_new_templates)) {
 
   32                        $DIC->database()->manipulate(
 
   33                            'DELETE FROM mail_tpl_ctx WHERE component = ' . 
$DIC->database()->quote(
 
   36                            ) . 
' AND id = ' . 
$DIC->database()->quote(
$id, 
'text')
 
   38                        $DIC[
'ilLog']->debug(
"Mail Template XML - Context " . 
$id . 
" in class " . $a_component . 
" deleted.");
 
   42                $DIC->database()->manipulate(
'DELETE FROM mail_tpl_ctx WHERE component = ' . 
$DIC->database()->quote(
 
   46                $DIC[
'ilLog']->debug(
"Mail Template XML - All contexts deleted for " . $a_component . 
" as component is inactive.");
 
   57    public static function insertFromXML($a_component, $a_id, $a_class, $a_path)
 
   61        if (!
$DIC->database()->tableExists(
'mail_tpl_ctx')) {
 
   79        $first_context = current($contexts);
 
   81            require_once 
'Services/Mail/exceptions/class.ilMailException.php';
 
   82            throw new ilMailException(sprintf(
"Could not find a mail template context with id: %s", $a_id));
 
   84        return $first_context;
 
   98        if ($a_id && !is_array($a_id)) {
 
  102        $query = 
'SELECT * FROM mail_tpl_ctx';
 
  105            $where[] = 
$DIC->database()->in(
'id', $a_id, 
false, 
'text');
 
  108            $query .= 
' WHERE ' . implode(
' AND ', $where);
 
  112        while (
$row = 
$DIC->database()->fetchAssoc($set)) {
 
  137            $a_path = $a_component . 
'/classes/';
 
  139        $class_file = $a_path . 
'class.' . $a_class . 
'.php';
 
  141        if (file_exists($class_file)) {
 
  142            require_once $class_file;
 
  143            if (class_exists($a_class)) {
 
  149                        $mess .= 
" - context id mismatch";
 
  152                    $mess .= 
" - does not extend ilMailTemplateContext";
 
  155                $mess = 
"- class not found in file";
 
  158            $mess = 
" - class file not found";
 
  161        $DIC[
'ilLog']->debug(
"Mail Template XML - Context " . $a_id . 
" in class " . $a_class . 
" (" . $class_file . 
") is invalid." . $mess);
 
  174        $query = 
"SELECT id FROM mail_tpl_ctx WHERE id = %s";
 
  177        $context_exists = (
$row[
'id'] == $a_context->
getId());
 
  179        if (!$context_exists) {
 
  180            $DIC->database()->insert(
'mail_tpl_ctx', array(
 
  181                'id' => array(
'text', $a_context->
getId()),
 
  182                'component' => array(
'text', $a_component),
 
  183                'class' => array(
'text', $a_class),
 
  184                'path' => array(
'text', $a_path)
 
  187            $DIC[
'ilLog']->debug(
"Mail Template  XML - Context " . $a_context->
getId() . 
" in class " . $a_class . 
" added.");
 
  189            $DIC->database()->update(
'mail_tpl_ctx', array(
 
  190                'component' => array(
'text', $a_component),
 
  191                'class' => array(
'text', $a_class),
 
  192                'path' => array(
'text', $a_path)
 
  194                'id' => array(
'text', $a_context->
getId())
 
  197            $DIC[
'ilLog']->debug(
"Mail Template  XML - Context " . $a_context->
getId() . 
" in class " . $a_class . 
" updated.");
 
An exception for terminatinating execution or to throw for unit testing.
Class ilMailTemplateContextService.
static createEntry(ilMailTemplateContext $a_context, $a_component, $a_class, $a_path)
static getTemplateContextById($a_id)
static clearFromXml($a_component, array $a_new_templates)
static getTemplateContexts($a_id=null)
Returns an array of mail template contexts, the key of each entry matches its id.
static insertFromXML($a_component, $a_id, $a_class, $a_path)
static getContextInstance($a_component, $a_id, $a_class, $a_path)
Class ilMailTemplateContext.
getId()
Returns a unique (in the context of mail template contexts) id.
if(!array_key_exists('StateId', $_REQUEST)) $id
foreach($_POST as $key=> $value) $res