ticket add spam filter from list

This commit is contained in:
OpenXE 2023-11-25 12:58:16 +01:00
parent 088ad4555c
commit d7db78489c
2 changed files with 80 additions and 10 deletions

View File

@ -49,7 +49,19 @@
<tr><td>{|Status|}:</td><td><select name="status">[STATUS]</select></td></tr>
<tr><td>{|Verantwortlich|}:</td><td><input type="text" name="warteschlange" id="warteschlange" value="[WARTESCHLANGE]" size="20"></td></tr>
<tr>
<td><input type="checkbox" value="1" id="autoalle" />&nbsp;alle markieren&nbsp;</td><td><input type="submit" class="btnBlue" name="ausfuehren" value="{|Zuordnen|}" /></td>
<td>
<input type="checkbox" value="1" id="autoalle" />&nbsp;alle markieren&nbsp;
</td>
<td>
<button name="submit" value="zuordnen" class="ui-button-icon" style="width:100%;">{|Zuordnen|}</button>
</td>
</tr>
<tr [SPAM_HIDDEN]>
<td>
</td>
<td>
<button name="submit" value="spam_filter" class="ui-button-icon" title="Ticket auf Status 'Papierkorb' setzen und Absender-Adresse in Ticketregel eintragen" style="width:100%;">{|Spamregel erstellen|}</button>
</td>
</tr>
</table>

View File

@ -187,6 +187,7 @@ class Ticket {
// Process multi action
$auswahl = $this->app->Secure->GetPOST('auswahl');
$submit = $this->app->Secure->GetPOST('submit');
$selectedIds = [];
if(!empty($auswahl)) {
foreach($auswahl as $selectedId) {
@ -196,19 +197,72 @@ class Ticket {
}
}
$status = $this->app->Secure->GetPOST('status');
$warteschlange = $this->app->Secure->GetPOST('warteschlange');
switch ($submit) {
case 'zuordnen':
$status = $this->app->Secure->GetPOST('status');
$warteschlange = $this->app->Secure->GetPOST('warteschlange');
$sql = "UPDATE ticket SET status = '".$status."', zeit = NOW()";
if ($warteschlange != '') {
$sql .= ", warteschlange = '".explode(" ",$warteschlange)[0]."'";
}
$sql = "UPDATE ticket SET status = '".$status."', zeit = NOW()";
if ($warteschlange != '') {
$sql .= ", warteschlange = '".explode(" ",$warteschlange)[0]."'";
}
$sql .= " WHERE id IN (".implode(",",$selectedIds).")";
$this->app->DB->Update($sql);
$sql .= " WHERE id IN (".implode(",",$selectedIds).")";
$this->app->DB->Update($sql);
$this->ticket_set_self_assigned_status($selectedIds);
$this->ticket_set_self_assigned_status($selectedIds);
break;
case 'spam_filter':
if($this->app->erp->RechteVorhanden('ticketregeln','create')) {
$sql = "UPDATE ticket SET status = 'spam', zeit = NOW()";
$sql .= " WHERE id IN (".implode(",",$selectedIds).")";
$this->app->DB->Update($sql);
foreach ($selectedIds as $selectedId) {
// Check existing
$sql = "SELECT id FROM ticket_regeln WHERE
empfaenger_email = '' AND
sender_email = (SELECT mailadresse FROM ticket WHERE id = ".$selectedId." LIMIT 1) AND
name = '' AND
betreff = '' AND
spam = 1 AND
aktiv = 1
";
if (!$this->app->DB->Select($sql)) {
$sql = "INSERT IGNORE INTO ticket_regeln (
empfaenger_email,
sender_email,
name,
betreff,
spam,
persoenlich,
prio,
dsgvo,
adresse,
warteschlange,
aktiv
) VALUES (
'',
(SELECT mailadresse FROM ticket WHERE id = ".$selectedId." LIMIT 1),
'',
'',
1,
0,
0,
0,
0,
0,
1
)";
$this->app->DB->Insert($sql);
}
}
}
break;
}
}
// List
@ -223,6 +277,10 @@ class Ticket {
$this->app->Tpl->Set('STATUS', $this->app->erp->GetStatusTicketSelect('neu'));
$this->app->YUI->AutoComplete("warteschlange","warteschlangename");
if(!$this->app->erp->RechteVorhanden('ticketregeln','create')) {
$this->app->Tpl->Set('SPAM_HIDDEN', 'hidden');
}
$this->app->YUI->TableSearch('TAB1', 'ticket_list', "show", "", "", basename(__FILE__), __CLASS__);
$this->app->Tpl->Parse('PAGE', "ticket_list.tpl");
}