diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 9a74a56..0751336 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -1,7 +1,13 @@
{
"permissions": {
"allow": [
- "Bash(git log:*)"
+ "Bash(git log:*)",
+ "Bash(git checkout:*)",
+ "Bash(mysql:*)",
+ "Bash(if [ -f logs.txt ])",
+ "Bash(then rm logs.txt)",
+ "Bash(else echo \"Plik logs.txt nie istnieje\")",
+ "Bash(fi)"
]
}
}
diff --git a/.vscode/ftp-kr.sync.cache.json b/.vscode/ftp-kr.sync.cache.json
index fc542cc..52ab8b9 100644
--- a/.vscode/ftp-kr.sync.cache.json
+++ b/.vscode/ftp-kr.sync.cache.json
@@ -151,9 +151,9 @@
},
"config.php": {
"type": "-",
- "size": 1249,
+ "size": 1230,
"lmtime": 1770587027872,
- "modified": false
+ "modified": true
},
"cron.php": {
"type": "-",
@@ -204,9 +204,9 @@
},
"main_view.php": {
"type": "-",
- "size": 42341,
+ "size": 42781,
"lmtime": 1770583657535,
- "modified": false
+ "modified": true
},
"task_edit.php": {
"type": "-",
@@ -216,8 +216,8 @@
},
"task_popup.php": {
"type": "-",
- "size": 11071,
- "lmtime": 0,
+ "size": 12356,
+ "lmtime": 1770711646996,
"modified": false
},
"task_single.php": {
diff --git a/autoload/Domain/Tasks/MailToTaskImporter.php b/autoload/Domain/Tasks/MailToTaskImporter.php
index 7e92549..da6be39 100644
--- a/autoload/Domain/Tasks/MailToTaskImporter.php
+++ b/autoload/Domain/Tasks/MailToTaskImporter.php
@@ -154,7 +154,7 @@ class MailToTaskImporter
null,
false,
'off',
- false,
+ true,
self::TASK_STATUS_ID,
'on',
0
@@ -172,6 +172,30 @@ class MailToTaskImporter
continue;
}
+ // Konwertuj inline images do Base64 i osadź w treści
+ $cid_to_data_uri = [];
+ if ( isset( $content['inline_images'] ) && is_array( $content['inline_images'] ) )
+ {
+ foreach ( $content['inline_images'] as $cid => $inline_image )
+ {
+ // Konwertuj obraz do Base64 data URI
+ $data_uri = $this -> convertToDataUri( $inline_image['content'], $inline_image['mime'] );
+ if ( $data_uri !== '' )
+ $cid_to_data_uri[$cid] = $data_uri;
+ }
+ }
+
+ // Jeśli są inline images i HTML, zastąp CIDy na Base64 data URI i użyj HTML jako treść
+ if ( !empty( $cid_to_data_uri ) && isset( $content['html'] ) && trim( $content['html'] ) !== '' )
+ {
+ $html_with_images = $this -> replaceCidReferences( $content['html'], $cid_to_data_uri );
+ $task_text = $this -> prepareImportedTaskTextFromHtml( $html_with_images );
+
+ // Zaktualizuj treść zadania
+ $this -> mdb -> update( 'tasks', [ 'text' => $task_text ], [ 'id' => $task_id ] );
+ }
+
+ // Zapisz normalne załączniki
foreach ( $content['attachments'] as $attachment )
{
$this -> attachments -> uploadFromContent( $task_id, self::TASK_USER_ID, $attachment['name'], $attachment['content'] );
@@ -412,9 +436,25 @@ class MailToTaskImporter
}
$cid_refs = $this -> extractReferencedCidValues( $html );
+
$attachments = [];
+ $inline_images = [];
+
foreach ( $attachment_candidates as $part )
{
+ $content_id = isset( $part['content_id'] ) ? (string)$part['content_id'] : '';
+
+ // Sprawdź czy to inline image używany w HTML
+ if ( $content_id !== '' && isset( $cid_refs[$content_id] ) )
+ {
+ $inline_images[$content_id] = [
+ 'name' => $part['name'],
+ 'content' => $part['body'],
+ 'mime' => isset( $part['mime'] ) ? $part['mime'] : 'application/octet-stream'
+ ];
+ continue;
+ }
+
if ( !$this -> shouldImportAttachment( $part, $cid_refs ) )
continue;
@@ -429,6 +469,8 @@ class MailToTaskImporter
return [
'text' => $text,
+ 'html' => $html,
+ 'inline_images' => $inline_images,
'attachments' => $attachments
];
}
@@ -616,6 +658,22 @@ class MailToTaskImporter
if ( preg_match( '/^\s*--\s*$/', $line_trim ) )
break;
+ // Polskie stopki
+ if ( preg_match( '/^\s*(Pozdrawiam|Pozdrowienia|Z\s+powa[zż]aniem|Dzi[eę]kuj[eę]|Serdecznie|Miłego\s+dnia)/iu', $line_trim ) )
+ break;
+
+ // Angielskie stopki
+ if ( preg_match( '/^\s*(Best\s+regards|Kind\s+regards|Regards|Sincerely|Thanks|Thank\s+you|Cheers)/i', $line_trim ) )
+ break;
+
+ // Mobilne sygnatury
+ if ( preg_match( '/^\s*Sent\s+from\s+(my\s+)?(iPhone|iPad|Android|Samsung|mobile)/i', $line_trim ) )
+ break;
+
+ // Separatory z podkreślników
+ if ( preg_match( '/^\s*_{3,}\s*$/', $line_trim ) )
+ break;
+
$clean[] = $line_trim;
}
@@ -982,4 +1040,90 @@ class MailToTaskImporter
return '';
}
+
+ private function convertToDataUri( $content, $mime_type )
+ {
+ $content = (string)$content;
+ if ( $content === '' )
+ return '';
+
+ $mime_type = trim( (string)$mime_type );
+ if ( $mime_type === '' || $mime_type === 'application/octet-stream' )
+ $mime_type = 'image/png'; // Domyślny typ dla obrazów
+
+ $base64 = base64_encode( $content );
+ return 'data:' . $mime_type . ';base64,' . $base64;
+ }
+
+ private function replaceCidReferences( $html, array $cid_to_url )
+ {
+ if ( trim( (string)$html ) === '' || empty( $cid_to_url ) )
+ return $html;
+
+ foreach ( $cid_to_url as $cid => $url )
+ {
+ // Zastąp wszystkie odniesienia do tego CID
+ $html = preg_replace(
+ '/(
]+src=["\'])cid:' . preg_quote( $cid, '/' ) . '(["\'][^>]*>)/i',
+ '$1' . $url . '$2',
+ $html
+ );
+ }
+
+ return $html;
+ }
+
+ private function prepareImportedTaskTextFromHtml( $html )
+ {
+ $html = trim( (string)$html );
+ if ( $html === '' )
+ return '(brak tresci)';
+
+ // Usuń niepotrzebne elementy (style, script, blockquote)
+ $html = preg_replace( '/