Skip to content

Commit

Permalink
Merge branch 'master' of github.com:freescout-helpdesk/freescout into…
Browse files Browse the repository at this point in the history
… dist
  • Loading branch information
freescout-help-desk committed Nov 4, 2023
2 parents 45a7f9a + cc2ece5 commit c28b663
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 90 deletions.
9 changes: 6 additions & 3 deletions .github/ISSUE_TEMPLATE/general_help_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: General Help Request
about: Create a general help request

---

<!--
* If you have some error the first thing you should do is to check "Manage » Logs » App Logs"! If there are any errors there - make sure to provide them in the issue.
* Have you read FAQ? https://github.com/freescout-helpdesk/freescout/wiki/FAQ
* If you have "Whoops something went wrong" error see: https://github.com/freescout-helpdesk/freescout/wiki/Installation-Guide#11-troubleshooting
Expand All @@ -12,9 +12,12 @@ about: Create a general help request
* Create separate issues for different topics - no need to mix all your problems into one issue.
* Questions on issues with payments for modules should be sent by email: https://freescout.net/contact-us/
* Don't forget that you are not the project manager. Try to be humble, polite, friendly and positive. Otherwise your account may be banned and it can't be undone.
* Mentioning how much you've spent on modules or donated is the way to be banned.
* Mentioning how much you've spent on modules is the way to be banned.
Still here? Well clean this out and go ahead :)
-->

PHP version:
FreeScout version:
FreeScout version:
Database: MySQL / PostgreSQL
Are you using CloudFlare: Yes / No
30 changes: 21 additions & 9 deletions app/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ public function setUser($user_id)
*
* @return Conversation
*/
public function getNearby($mode = 'closest', $folder_id = null)
public function getNearby($mode = 'closest', $folder_id = null, $status = null, $prev_if_no_next = false)
{
$conversation = null;

Expand All @@ -684,29 +684,37 @@ public function getNearby($mode = 'closest', $folder_id = null)

$query = \Eventy::filter('conversation.get_nearby_query', $query, $this, $mode, $folder);

if ($status) {
$query->where('status', $status);
}

$order_bys = $folder->getOrderByArray();

// Next.
if ($mode != 'prev') {
// Try to get next conversation
$query_next = $query;
$query_next = clone $query;
foreach ($order_bys as $order_by) {
foreach ($order_by as $field => $sort_order) {
if (!$this->$field) {
continue;
}
$field_value = $this->$field;
if ($field == 'status' && $status !== null) {
$field_value = $status;
}
if ($sort_order == 'asc') {
$query_next->where($field, '>=', $this->$field);
$query_next->where($field, '>=', $field_value);
} else {
$query_next->where($field, '<=', $this->$field);
$query_next->where($field, '<=', $field_value);
}
$query_next->orderBy($field, $sort_order);
}
}
$conversation = $query_next->first();
}

if ($conversation || $mode == 'next') {
if ($conversation || ($mode == 'next' && !$prev_if_no_next)) {
return $conversation;
}

Expand All @@ -717,10 +725,14 @@ public function getNearby($mode = 'closest', $folder_id = null)
if (!$this->$field) {
continue;
}
$field_value = $this->$field;
if ($field == 'status' && $status !== null) {
$field_value = $status;
}
if ($sort_order == 'asc') {
$query_prev->where($field, '<=', $this->$field);
$query_prev->where($field, '<=', $field_value);
} else {
$query_prev->where($field, '>=', $this->$field);
$query_prev->where($field, '>=', $field_value);
}
$query_prev->orderBy($field, $sort_order == 'asc' ? 'desc' : 'asc');
}
Expand All @@ -732,9 +744,9 @@ public function getNearby($mode = 'closest', $folder_id = null)
/**
* Get URL of the next conversation.
*/
public function urlNext($folder_id = null)
public function urlNext($folder_id = null, $status = null, $prev_if_no_next = false)
{
$next_conversation = $this->getNearby('next', $folder_id);
$next_conversation = $this->getNearby('next', $folder_id, $status, $prev_if_no_next = true);
if ($next_conversation) {
$url = $next_conversation->url();
} else {
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/ConversationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,8 @@ public function getRedirectUrl($request, $conversation, $user)
$redirect_url = route('mailboxes.view.folder', ['id' => $conversation->mailbox_id, 'folder_id' => $folder_id]);
break;
case MailboxUser::AFTER_SEND_NEXT:
$redirect_url = $conversation->urlNext(Conversation::getFolderParam());
// We need to get not any next conversation, but ACTIVE next conversation.
$redirect_url = $conversation->urlNext(Conversation::getFolderParam(), Conversation::STATUS_ACTIVE, true);
break;
}
} else {
Expand Down
9 changes: 2 additions & 7 deletions app/Http/Middleware/HttpsRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@ public function handle($request, Closure $next)
{
if (\Helper::isHttps()) {
//$request->setTrustedProxies( [ $request->getClientIp() ], array_keys($this->headers));

if (//!$request->secure()
!in_array(strtolower($_SERVER['X_FORWARDED_PROTO'] ?? ''), array('https', 'on', 'ssl', '1'), true)
&& strtolower($_SERVER['HTTPS'] ?? '') != 'on'
&& ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') != 'https'
&& ($_SERVER['HTTP_CF_VISITOR'] ?? '') != '{"scheme":"https"}'
) {
//!$request->secure()
if (!\Helper::isCurrentUrlHttps()) {
return redirect()->secure($request->getRequestUri());
}
}
Expand Down
36 changes: 35 additions & 1 deletion app/Misc/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,14 @@ public static function sqlLikeOperator()
return self::isPgSql() ? 'ilike' : 'like';
}

// PostgreSQL truncates string if it contains \u0000 symbol starting from this symbol.
// https://stackoverflow.com/questions/31671634/handling-unicode-sequences-in-postgresql
// https://github.com/freescout-helpdesk/freescout/issues/3485
public static function sqlSanitizeString($string)
{
return str_replace(json_decode('"\u0000"'), "", $string);
}

public static function humanFileSize($size, $unit="")
{
if ((!$unit && $size >= 1<<30) || $unit == "GB") {
Expand Down Expand Up @@ -1765,7 +1773,33 @@ public static function getProtocol($url = '')

public static function isHttps($url = '')
{
return self::getProtocol($url) == 'https';
if (\Helper::isInstaller()) {
// In the Installer we determine HTTPS from URL.
return self::isCurrentUrlHttps();
} else {
return self::getProtocol($url) == 'https';
}
}

public static function isInstaller()
{
$request_uri = $_SERVER['REQUEST_URI'] ?? '';
$request_uri = preg_replace("#\?.*#", '', $request_uri);

return strstr($request_uri, '/install/') || preg_match("#/install$#", $request_uri);
}

public static function isCurrentUrlHttps()
{
if (in_array(strtolower($_SERVER['X_FORWARDED_PROTO'] ?? ''), array('https', 'on', 'ssl', '1'), true)
|| strtolower($_SERVER['HTTPS'] ?? '') == 'on'
|| ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') == 'https'
|| ($_SERVER['HTTP_CF_VISITOR'] ?? '') == '{"scheme":"https"}'
) {
return true;
} else {
return false;
}
}

public static function fixProtocol($url)
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function register()
{
// Forse HTTPS if using CloudFlare "Flexible SSL"
// https://support.cloudflare.com/hc/en-us/articles/200170416-What-do-the-SSL-options-mean-
if (\Helper::getProtocol() == 'https') {
if (\Helper::isHttps()) {
// $_SERVER['HTTPS'] = 'on';
// $_SERVER['SERVER_PORT'] = '443';
$this->app['url']->forceScheme('https');
Expand Down
2 changes: 1 addition & 1 deletion app/Thread.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public function getCleanBody($body = '')
// Change "background:" to "background-color:".
// https://github.com/freescout-helpdesk/freescout/issues/2560
// Keep in mind that with large texts preg_replace() may return null.
$body = preg_replace("/(<[^<>]+style=[\"'][^\"']*)background: *([^;() ]+;)/", '$1background-color:$2', $body) ?: $body;
$body = preg_replace("/(<[^<>]+style=[\"'][^\"']*)background: *([^;() ]+[;\"'])/", '$1background-color:$2', $body) ?: $body;

// Cut out "collapse" class as it hides elements.
$body = preg_replace("/(<[^<>\r\n]+class=([\"'][^\"']* |[\"']))(collapse|hidden)([\"' ])/", '$1$4', $body) ?: $body;
Expand Down
28 changes: 28 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ class User extends Authenticatable
'permissions' => 'array',
];

public function __construct(array $attributes = array())
{
$this->setRawAttributes(array_merge($this->attributes, array(
'timezone' => config('app.timezone') ?: User::DEFAULT_TIMEZONE
)), true);
parent::__construct($attributes);
}

/**
* For array_unique function.
*
Expand Down Expand Up @@ -1198,4 +1206,24 @@ public static function getRobotsCondition()
{
return User::where('type', User::TYPE_ROBOT);
}

// Truncate fields to their max lengths to avoid PostgreSQL error:
// SQLSTATE[22001]: String data, right truncated: 7 ERROR: value too long for type character varying(100).
// https://github.com/freescout-helpdesk/freescout/issues/3489
public function setFirstNameAttribute($first_name)
{
$this->attributes['first_name'] = mb_substr($first_name, 0, 20);
}
public function setLastNameAttribute($last_name)
{
$this->attributes['last_name'] = mb_substr($last_name, 0, 30);
}
public function setEmailAttribute($email)
{
$this->attributes['email'] = mb_substr($email, 0, 100);
}
public function setJobTitleAttribute($job_title)
{
$this->attributes['job_title'] = mb_substr($job_title, 0, 100);
}
}
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
| or any other location as required by the application or its packages.
*/

'version' => '1.8.106',
'version' => '1.8.107',

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion config/purifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
'settings' => [
'default' => [
'HTML.Doctype' => 'HTML 4.01 Transitional',
'HTML.Allowed' => 'div[style],b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src],table[width|class],tr[bgcolor],td[style|colspan|rowspan|width],th[style|colspan|rowspan],thead,tfoot,tbody,blockquote,pre,s,strike,h1,h2,h3,h4,h5,h6',
'HTML.Allowed' => 'div[style],b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src],table[width|class],tr[bgcolor],td[style|colspan|rowspan|width],th[style|colspan|rowspan],thead,tfoot,tbody,blockquote,pre,s,strike,font[style|color],h1,h2,h3,h4,h5,h6',
//'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
'CSS.AllowedProperties' => 'font-weight,font-style,text-decoration,color,background-color,text-align,border,border-top,border-left,border-bottom,border-right',
'AutoFormat.AutoParagraph' => true,
Expand Down
9 changes: 9 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3888,6 +3888,15 @@ a.help-icon:hover {
color: #4f5d6b!important;
text-decoration: none!important;
}
.link-grey-blue,
.link-grey-blue:focus {
color: #93a1af!important;
text-decoration: none!important;
}
.link-grey-blue:hover {
color: #0078D7!important;
text-decoration: none!important;
}
.link-underlined {
text-decoration: underline;
}
Expand Down
2 changes: 2 additions & 0 deletions public/installer/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion public/installer/css/style.min.css

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions resources/lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"A conversation is assigned to me": "Rozmowa została mi przypisana",
"A conversation is assigned to someone else": "Rozmowa została przypisana do kogoś innego",
"A new version is available": "Dostępna jest nowa wersja",
"Accept Chat": "Zaakceptuj Czat",
"Accepted for delivery": "Zaakceptowano do dostarczenia",
"Access Settings": "Ustawienia Dostępu",
"Access denied": "Dostęp zabroniony",
Expand Down Expand Up @@ -128,6 +129,8 @@
"Change the customer to :customer_email?": "Zmienić klienta na :customer_email?",
"Change your password": "Zmień swoje hasło",
"Chat": "Czat",
"Chat Mode": "Tryb Czatu",
"Chats": "Czaty",
"Check Connection": "Sprawdź Połączenie",
"Check Frequency": "Sprawdź Częstotliwość",
"Check Interval (minutes)": "Interwał Sprawdzania (minuty)",
Expand Down Expand Up @@ -262,6 +265,7 @@
"Empty license key": "Pusty klucz licencyjny",
"Enable Auto Reply": "Włącz Auto Odpowiedź",
"Encryption": "Szyfrowanie",
"End Chat": "Zakończ Czat",
"Enter IMAP folder name to save outgoing replies if your mail service provider does not do it automatically (Gmail does it), otherwise leave it blank.": "Wprowadź nazwę folderu IMAP dla zapisu wychodzących odpowiedzi, o ile twój dostawca usługi e-mail nie określa tego automatycznie (jak Gmail), w innym razie pozostaw to pole pustym.",
"Equal to conversation ID": "Równy ID rozmowy",
"Error fetching email": "Błąd podczas pobierania wiadomości e-mail",
Expand All @@ -285,6 +289,7 @@
"Error sending password changed notification to user": "Błąd podczas wysyłania powiadomienia o zmianie hasła do użytkownika ",
"Every :number minutes": "Co :number minut(y)",
"Every minute": "Co minutę",
"Exit": "Wyjdź",
"Extra Recipients": "Dodatkowi Odbiorcy",
"Failed At": "Niepowodzenie:",
"Failed Jobs": "Nieudane Zadania",
Expand Down Expand Up @@ -351,6 +356,7 @@
"Installed Modules": "Zainstalowane Moduły",
"Installing": "Instalowanie",
"Invalid license key": "Nieważny klucz licencji",
"Invalid or missing modules symlinks": "Nieprawidłowe lub brakujące symlinki modułów",
"Invite email has been resent": "E-mail z zaproszeniem został wysłany ponownie",
"Invite email has been sent": "E-mail z zaproszeniem został wysłany",
"Invited": "Zaproszony",
Expand All @@ -373,6 +379,7 @@
"License key has been revoked": "Klucz licencyjny został odwołany",
"License key has expired": "Klucz licencyjny wygasł",
"License key has not been activated yet": "Klucz licencyjny nie został jeszcze aktywowany",
"License key is activated on another domain.": "Klucz licencyjny został aktywowany dla innej domeny",
"License successfully Deactivated!": "Licencja pomyślnie dezaktywowana!",
"License successfully activated!": "Licencja aktywowana pomyślnie!",
"List": "Lista",
Expand All @@ -391,6 +398,7 @@
"Logs Monitoring": "Monitorowanie dzienników",
"Logs to monitor": "Dzienniki do monitorowania",
"Lost internet connection": "Utracono połączenie z Internetem",
"Mail Date & Time": "Data i Czas",
"Mail From": "Nadawca",
"Mail Settings": "Ustawienia Poczty",
"Mailbox": "Skrzynka Pocztowa",
Expand All @@ -412,6 +420,7 @@
"Manage Mailboxes": "Zarządzaj Skrzynkami Pocztowymi",
"Manage Users": "Zarządzaj Użytkownikami",
"Mark all as read": "Oznacz wszystkie jako przeczytane",
"Max. Message Size": "Maks. Rozmiar Wiadomości",
"Me": "Ja",
"Merge": "Scal",
"Merge Conversations": "Scal Rozmowy",
Expand All @@ -420,6 +429,7 @@
"Message bounced (:link)": "Wiadomość odesłana (:link)",
"Message cannot be empty": "Wiadomość nie może być pusta",
"Message has been already sent. Please discard this draft.": "Wiadomość została już wysłana. Proszę odrzucić ten szkic.",
"Message is too large — :info. Please shorten your message or remove some attachments.": "Wiadomość zbyt duża — :info. Proszę skróć wiadomość albo usuń trochę załączników.",
"Message not sent to customer": "Wiadomość nie została wysłana do klienta",
"Method": "Metoda",
"Migrate DB": "Przeprowadź migrację bazy danych",
Expand Down Expand Up @@ -570,7 +580,6 @@
"Role": "Rola",
"Role of the only one administrator can not be changed.": "Roli jedynego ostatniego administratora nie można zmienić.",
"Roles": "Role",
"Run Workflow": "Uruchom Workflow",
"Run the following command": "Wykonaj następującą komendę",
"Running": "Działa",
"SMTP": "SMTP",
Expand Down Expand Up @@ -623,6 +632,7 @@
"Settings saved": "Ustawienia zapisane",
"Settings updated": "Ustawienia zaktualizowane",
"Show": "Pokaż",
"Show Details": "Pokaż Szczegóły",
"Show Original": "Pokaż Oryginalną Wiadomość",
"Show original": "Pokaż oryginał",
"Show original message": "Pokaż oryginalną wiadomość autora",
Expand Down Expand Up @@ -714,6 +724,9 @@
"Updating": "Aktualizacja",
"Upload Attachments": "Prześlij Załączniki",
"Use 'Deactivate License' link above to transfer license key from another domain": "Użyj przycisku Dezaktywuj Licencję, w celu przeniesienia klucza licencyjnego z innej domeny",
"Use ENTER to send the message and SHIFT+ENTER for a new line": "Użyj ENTER żeby wysłać wiadomość, a SHIFT+ENTER dla nowej linii",
"Use actual fetching date and time": "Użyj rzeczywistej daty i czasu pobrania",
"Use date and time from mail headers": "Użyj daty i czasu z nagłówków email",
"User": "Użytkownik",
"User Permissions": "Uprawnienia Użytkownika",
"User Setup Problem": "Problem Kreatora Użytkownika",
Expand Down Expand Up @@ -783,7 +796,6 @@
"auto reply": "automatyczna odpowiedź",
"close": "zamknij",
"me": "ja",
"more": "więcej",
"none": "żadna",
"on :date": "dnia :date",
"or Enter Mailbox Email": "lub Wpisz adres e-mail skrzynki pocztowej",
Expand Down
2 changes: 1 addition & 1 deletion resources/views/secure/dashboard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@section('content')
<div class="container">
<div class="heading">{{ App\Option::getCompanyName() }} {{ __('Dashboard') }}</div>
<div class="heading">{{ App\Option::getCompanyName() }} {{ __('Dashboard') }}@action('dashboard.heading_append')</div>
@filter('dashboard.before', '')
@if (count($mailboxes))
<div class="dash-cards margin-top">
Expand Down
Loading

0 comments on commit c28b663

Please sign in to comment.