diff --git a/install/phpnuxbill.sql b/install/phpnuxbill.sql index f66eb5c4..bcb966f8 100644 --- a/install/phpnuxbill.sql +++ b/install/phpnuxbill.sql @@ -229,7 +229,7 @@ CREATE TABLE `tbl_customers_inbox` ( `date_created` datetime NOT NULL, `date_read` datetime DEFAULT NULL, `subject` varchar(64) COLLATE utf8mb4_general_ci NOT NULL, - `body` varchar(512) COLLATE utf8mb4_general_ci NOT NULL, + `body` TEXT NULL DEFAULT NULL, `from` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'System' COMMENT 'System or Admin or Else', `admin_id` int NOT NULL DEFAULT '0' COMMENT 'other than admin is 0', PRIMARY KEY (`id`) diff --git a/system/autoload/Text.php b/system/autoload/Text.php index bc094e15..beb55164 100644 --- a/system/autoload/Text.php +++ b/system/autoload/Text.php @@ -44,16 +44,17 @@ class Text return $result; } - public static function maskText($text){ + public static function maskText($text) + { $len = strlen($text); - if($len < 3){ + if ($len < 3) { return "***"; - }else if($len<5){ - return substr($text,0,1)."***".substr($text,-1,1); - }else if($len<8){ - return substr($text,0,2)."***".substr($text,-2,2); - }else{ - return substr($text,0,4)."******".substr($text,-3,3); + } else if ($len < 5) { + return substr($text, 0, 1) . "***" . substr($text, -1, 1); + } else if ($len < 8) { + return substr($text, 0, 2) . "***" . substr($text, -2, 2); + } else { + return substr($text, 0, 4) . "******" . substr($text, -3, 3); } } @@ -61,4 +62,9 @@ class Text { return preg_replace("/[^A-Za-z0-9]/", '_', $str);; } + + public static function is_html($string) + { + return preg_match("/<[^<]+>/", $string, $m) != 0; + } } diff --git a/system/controllers/mail.php b/system/controllers/mail.php index c47f0b9d..c54318fd 100644 --- a/system/controllers/mail.php +++ b/system/controllers/mail.php @@ -20,11 +20,26 @@ switch ($action) { $mail->date_read = date('Y-m-d H:i:s'); $mail->save(); } + $next = ORM::for_table('tbl_customers_inbox')->select("id")->where('customer_id', $user['id'])->where_gt("id", $routes['2'])->order_by_asc("id")->find_one(); + $prev = ORM::for_table('tbl_customers_inbox')->select("id")->where('customer_id', $user['id'])->where_lt("id", $routes['2'])->order_by_desc("id")->find_one(); + + $ui->assign('next', $next['id']); + $ui->assign('prev', $prev['id']); $ui->assign('mail', $mail); $ui->assign('tipe', 'view'); $ui->assign('_system_menu', 'inbox'); $ui->assign('_title', Lang::T('Inbox')); $ui->display('user-inbox.tpl'); + break; + case 'delete': + if($routes['2']){ + if(ORM::for_table('tbl_customers_inbox')->where('customer_id', $user['id'])->where('id', $routes['2'])->find_one()->delete()){ + r2(U. 'mail', 's', Lang::T('Mail Deleted Successfully')); + }else{ + r2(U. 'home', 'e', Lang::T('Failed to Delete Message')); + } + break; + } default: $q = _req('q'); $limit = 40; diff --git a/system/lan/english.json b/system/lan/english.json index 4dc09ab4..280aaef4 100644 --- a/system/lan/english.json +++ b/system/lan/english.json @@ -685,6 +685,8 @@ "Channel": "Channel", "Payment_Link": "Payment Link", "Created": "Created", - "2": "2", - "_": "-" + "Previous": "Previous", + "Share": "Share", + "Mail_Deleted_Successfully": "Mail Deleted Successfully", + "Message_Not_Found": "Message Not Found" } \ No newline at end of file diff --git a/system/updates.json b/system/updates.json index eee72c33..ceb443a2 100644 --- a/system/updates.json +++ b/system/updates.json @@ -135,6 +135,6 @@ "ALTER TABLE `tbl_payment_gateway` CHANGE `pg_url_payment` `pg_url_payment` VARCHAR(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '';" ], "2024.8.2" : [ - "CREATE TABLE IF NOT EXISTS `tbl_customers_inbox` (`id` int UNSIGNED NOT NULL AUTO_INCREMENT, `customer_id` int NOT NULL, `date_created` datetime NOT NULL, `date_read` datetime DEFAULT NULL, `subject` varchar(64) COLLATE utf8mb4_general_ci NOT NULL, `body` varchar(512) COLLATE utf8mb4_general_ci NOT NULL, `from` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'System' COMMENT 'System or Admin or Else',`admin_id` int NOT NULL DEFAULT '0' COMMENT 'other than admin is 0', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;" + "CREATE TABLE IF NOT EXISTS `tbl_customers_inbox` (`id` int UNSIGNED NOT NULL AUTO_INCREMENT, `customer_id` int NOT NULL, `date_created` datetime NOT NULL, `date_read` datetime DEFAULT NULL, `subject` varchar(64) COLLATE utf8mb4_general_ci NOT NULL, `body` TEXT NULL DEFAULT NULL, `from` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'System' COMMENT 'System or Admin or Else',`admin_id` int NOT NULL DEFAULT '0' COMMENT 'other than admin is 0', PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;" ] } \ No newline at end of file diff --git a/ui/ui/user-inbox.tpl b/ui/ui/user-inbox.tpl index 6fd4fa89..a9fd9e95 100644 --- a/ui/ui/user-inbox.tpl +++ b/ui/ui/user-inbox.tpl @@ -1,74 +1,112 @@ {include file="sections/user-header.tpl"} {if $tipe == 'view'} - -{else}
-
-

Inbox

-
-
-
- -
- -
-
-
-
-
-
- -
-
- {if $p>0} - - {/if} - +
+

{$mail['subject']}

+
From: {$mail['from']} + {Lang::dateTimeFormat($mail['date_created'])} +
+
+
+ {if Text::is_html($mail['body'])} + {$mail['body']} + {else} + {nl2br($mail['body'])} + {/if} +
+
+ + +
+{else} +
+
+
+
+
+ +
+
-
- - - {foreach $mails as $mail} - - - - - - - {/foreach} - -
- {if $mail['date_read'] == null} - - {else} - - {/if}{$mail['subject']} - {$mail['from']}{Lang::dateTimeFormat($mail['date_created'])}
+ +
+
+
+ +
+
+ {if $p>0} + + {/if} + +
-