95 $modul = trim((
string)$modul);
96 $ddRef = trim((
string)$ddRef);
97 if ($modul ===
'' || $ddRef ===
'') {
104 $bindKey = trim((
string)$bindKey);
105 if ($bindKey ===
'') {
106 $bindKey = $recordNeed;
109 $contextFields = array(
'rid' =>
'id');
110 $summaryCandidates = array(
'subject',
'name',
'email',
'phone',
'message',
'title',
'label');
111 foreach ($summaryCandidates as $name) {
113 $contextFields[$name] = $name;
118 $recordNeed => array(
119 'type' =>
'dd_select',
120 'where' => array(
'trash' => 0),
122 'order_field' =>
'create_date',
123 'order_dir' =>
'DESC',
127 if (isset(
$fields[
'status']) && trim((
string)(
$fields[
'status'][
'options'] ??
'')) !==
'') {
128 $needs[
'status'] = array(
'type' =>
'dd_field_options',
'field' =>
'status');
131 $finishMap = array();
132 if (isset(
$fields[
'status'])) {
133 $finishMap[
'status'] =
'status';
135 if (isset(
$fields[
'reply_text'])) {
136 $needs[
'reply_text'] = array(
'type' =>
'dd_field_value',
'field' =>
'reply_text');
137 $finishMap[
'reply_text'] =
'reply_text';
139 if (isset(
$fields[
'reply_date'])) {
140 $finishMap[
'reply_date'] =
'@now';
142 if (isset(
$fields[
'reply_uid'])) {
143 $finishMap[
'reply_uid'] =
'@uid';
150 'id_need' => $recordNeed,
151 'prefill_rid' =>
true,
155 'type' =>
'dd_update',
160 if ($contextTpl !==
'') {
161 $bind[
'context'] = array(
162 'tpl' => $contextTpl,
163 'hide_on_need' => $recordNeed,
164 'fields' => $contextFields,
169 $mailTpl = $modul .
'|mail-contact-reply';
170 $mailFile =
dbx()->os_path(
dbx()->
get_base_dir() .
"dbx/modules/$modul/tpl/htm/mail-contact-reply.htm");
171 if (file_exists($mailFile)) {
172 $bind[
'needs'][
'send_mail'] = array(
173 'type' =>
'static_select',
174 'show_if_config' => array(
'modul' => $modul,
'key' =>
'mail_on_reply',
'has' =>
'mail'),
176 array(
'value' =>
'1',
'label' =>
'Ja, E-Mail senden'),
177 array(
'value' =>
'0',
'label' =>
'Nein, nur speichern'),
180 $bind[
'finish'][
'mail'] = array(
181 'when_need' =>
'send_mail',
183 'config_modul' => $modul,
184 'mode_key' =>
'mail_on_reply',
185 'to_field' =>
'email',
186 'subject_tpl' =>
'Antwort: {subject}',
187 'body_tpl' => $mailTpl,
188 'body_vars' => array(
189 'subject' =>
'subject',
190 'reply_text' =>
'@need:reply_text',
192 'track_fields' => array(
193 'reply_mail_sent' => 1,
194 'reply_mail_sent_date' =>
'@now',
202 'bind_key' => $bindKey,
203 'title' =>
'Workflow fuer ' . $modul .
' / ' . $ddRef,
204 'description' =>
'Automatisch aus DD/TPL erzeugtes Binding. Bitte Needs und Finish pruefen.',
205 'bind_json' => $this->write_json($bind),
254 $modul = (string)($record[
'modul'] ??
'');
255 $bindKey = (string)($record[
'bind_key'] ??
'');
256 if ($modul ===
'' || $bindKey ===
'') {
260 $rows =
$db->select($this->ddBind, array(
'modul' => $modul,
'bind_key' => $bindKey), array(
'id'),
'id',
'DESC',
'', 1, 0, 0);
261 if (isset(
$rows[0][
'id'])) {
264 return (
int)
$rows[0][
'id'];
267 return (
int)
$db->insert($this->ddBind, $record, 0, 1, 1, 1);