19 declare(strict_types=1);
32 return 'ilUpdateMailTemplatesForMustache';
37 return self::NUMBER_OF_STEPS;
43 new \ilDatabaseUpdatedObjective()
49 $this->db = $environment->
getResource(Environment::RESOURCE_DATABASE);
55 if ($tpl_values === null) {
59 [$tpl_id,
$lang] = $tpl_values;
66 $q =
'SELECT COUNT(tpl_id) AS open FROM mail_man_tpl ' . PHP_EOL . $this->
getWhere();
67 $res = $this->db->query(
$q);
68 $row = $this->db->fetchAssoc(
$res);
70 return (
int) $row[
'open'];
78 $this->db->setLimit(1);
79 $q =
'SELECT tpl_id, lang FROM mail_man_tpl ' . PHP_EOL . $this->
getWhere();
80 $res = $this->db->query(
$q);
82 if ($this->db->numRows(
$res) === 0) {
86 $row = $this->db->fetchAssoc(
$res);
96 return " WHERE (m_subject REGEXP '\[[A-Z_]+?\]' OR m_message REGEXP '\[[A-Z_]+?\]')" . PHP_EOL;
101 $res = $this->db->queryF(
102 'SELECT m_subject, m_message FROM mail_man_tpl WHERE tpl_id = %s AND lang = %s',
106 if ($this->db->numRows(
$res) === 1) {
107 $row = $this->db->fetchAssoc(
$res);
109 $subject = isset($row[
'm_subject']) ? preg_replace(
114 $message = isset($row[
'm_message']) ? preg_replace(
120 $this->db->manipulateF(
121 'UPDATE mail_man_tpl SET m_subject = %s, m_message = %s WHERE tpl_id = %s AND lang = %s',
123 [$subject,
$message, $tpl_id, $lang]
A migration is a potentially long lasting operation that can be broken into discrete steps...
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An environment holds resources to be used in the setup process.