diff --git a/RELEASENOTES.md b/RELEASENOTES.md index b78559e28..a8c2253ae 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -3,6 +3,7 @@ ### 4.3.3 (UNRELEASED) * Fix for reports where they are always recursing service bodies regardless of the setting [#980] * Fix for metrics counts summaries. +* Fix for language word overrides. [#997] * Removing `file_get_contents()` usage to support some cases where servers may be misconfigured. * Using native Laravel database migrations. diff --git a/src/Makefile b/src/Makefile index e66b25672..0f526f237 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,14 +1,14 @@ .PHONY: run run: - cd src; composer install - cd src; npm install - cd src; env ENVIRONMENT=test php artisan serve + composer install + npm install + env ENVIRONMENT=test php artisan serve .PHONY: lint lint: - cd src; find . -name "*.php" ! -path '*/vendor/*' -print0 | xargs -0 -n1 -P8 php -l - cd src; composer install - cd src; vendor/squizlabs/php_codesniffer/bin/phpcs + find . -name "*.php" ! -path '*/vendor/*' -print0 | xargs -0 -n1 -P8 php -l + composer install + vendor/squizlabs/php_codesniffer/bin/phpcs .PHONY: lint-fix lint-fix: diff --git a/src/app/Http/Middleware/DatabaseMigrations.php b/src/app/Http/Middleware/DatabaseMigrations.php index 068d68336..419bb6618 100644 --- a/src/app/Http/Middleware/DatabaseMigrations.php +++ b/src/app/Http/Middleware/DatabaseMigrations.php @@ -26,7 +26,7 @@ public function __construct(SettingsService $settings) public function handle(Request $request, Closure $next) { if ($this->settings->has('mysql_hostname')) { - Artisan::call("migrate"); + Artisan::call("migrate", array('--force' => true)); } return $next($request); diff --git a/src/app/Services/SettingsService.php b/src/app/Services/SettingsService.php index 5dc1a1dd5..ec6559561 100644 --- a/src/app/Services/SettingsService.php +++ b/src/app/Services/SettingsService.php @@ -144,6 +144,14 @@ public function __construct() } $this->shortLanguage = $this->getWordLanguage() === "da-DK" ? "dk" : explode("-", $this->getWordLanguage())[0]; + + foreach ($_SESSION ?? [] as $session_key => $session_value) { + $language = $this->getWordLanguage(); + $stripped_key_test = str_replace("override_", "", $session_key); + if (isset($this->localizations->getLocalization($language)[$stripped_key_test])) { + $this->localizations->getLocalization($language)[$session_key] = $session_value; + } + } } public function getShortLanguage(): string diff --git a/src/database/migrations/2024_03_24_035821_create_alerts_table.php b/src/database/migrations/2024_03_24_035821_create_alerts_table.php index 42c0b018b..b8e04dd70 100644 --- a/src/database/migrations/2024_03_24_035821_create_alerts_table.php +++ b/src/database/migrations/2024_03_24_035821_create_alerts_table.php @@ -13,13 +13,15 @@ */ public function up() { - Schema::create('alerts', function (Blueprint $table) { - $table->integer('id', true); - $table->timestamp('timestamp')->nullable(); - $table->integer('alert_id'); - $table->longText('payload')->nullable(); - $table->integer('status')->nullable(); - }); + if (!Schema::hasTable('alerts')) { + Schema::create('alerts', function (Blueprint $table) { + $table->integer('id', true); + $table->timestamp('timestamp')->nullable(); + $table->integer('alert_id'); + $table->longText('payload')->nullable(); + $table->integer('status')->nullable(); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_cache_records_conference_participants_table.php b/src/database/migrations/2024_03_24_035821_create_cache_records_conference_participants_table.php index 7809dbaca..2f6f77e39 100644 --- a/src/database/migrations/2024_03_24_035821_create_cache_records_conference_participants_table.php +++ b/src/database/migrations/2024_03_24_035821_create_cache_records_conference_participants_table.php @@ -13,12 +13,14 @@ */ public function up() { - Schema::create('cache_records_conference_participants', function (Blueprint $table) { - $table->string('parent_callsid', 100)->nullable()->index('idx_rcp_parent_parent_callsid'); - $table->string('callsid', 100)->nullable()->index('idx_rcp_parent_callsid'); - $table->string('guid', 36)->nullable(); - $table->integer('service_body_id')->nullable(); - }); + if (!Schema::hasTable('cache_records_conference_participants')) { + Schema::create('cache_records_conference_participants', function (Blueprint $table) { + $table->string('parent_callsid', 100)->nullable()->index('idx_rcp_parent_parent_callsid'); + $table->string('callsid', 100)->nullable()->index('idx_rcp_parent_callsid'); + $table->string('guid', 36)->nullable(); + $table->integer('service_body_id')->nullable(); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_cache_table.php b/src/database/migrations/2024_03_24_035821_create_cache_table.php index 2b28fe795..db7408fb3 100644 --- a/src/database/migrations/2024_03_24_035821_create_cache_table.php +++ b/src/database/migrations/2024_03_24_035821_create_cache_table.php @@ -13,12 +13,14 @@ */ public function up() { - Schema::create('cache', function (Blueprint $table) { - $table->bigInteger('id', true); - $table->longText('key')->nullable(); - $table->longText('value')->nullable(); - $table->integer('expiry')->nullable(); - }); + if (!Schema::hasTable('cache')) { + Schema::create('cache', function (Blueprint $table) { + $table->bigInteger('id', true); + $table->longText('key')->nullable(); + $table->longText('value')->nullable(); + $table->integer('expiry')->nullable(); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_conference_participants_table.php b/src/database/migrations/2024_03_24_035821_create_conference_participants_table.php index cf8b7b772..8068bd9e1 100644 --- a/src/database/migrations/2024_03_24_035821_create_conference_participants_table.php +++ b/src/database/migrations/2024_03_24_035821_create_conference_participants_table.php @@ -13,16 +13,18 @@ */ public function up() { - Schema::create('conference_participants', function (Blueprint $table) { - $table->integer('id', true); - $table->timestamp('timestamp')->useCurrent(); - $table->string('conferencesid', 100)->index('idx_conference_participants_conferencesid'); - $table->string('callsid', 100)->index('idx_conference_participants_callsid'); - $table->string('friendlyname', 100); - $table->integer('role'); + if (!Schema::hasTable('conference_participants')) { + Schema::create('conference_participants', function (Blueprint $table) { + $table->integer('id', true); + $table->timestamp('timestamp')->useCurrent(); + $table->string('conferencesid', 100)->index('idx_conference_participants_conferencesid'); + $table->string('callsid', 100)->index('idx_conference_participants_callsid'); + $table->string('friendlyname', 100); + $table->integer('role'); - ///$table->primary(['id']); - }); + ///$table->primary(['id']); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_config_table.php b/src/database/migrations/2024_03_24_035821_create_config_table.php index 97e80beb1..8e7a7622d 100644 --- a/src/database/migrations/2024_03_24_035821_create_config_table.php +++ b/src/database/migrations/2024_03_24_035821_create_config_table.php @@ -13,16 +13,17 @@ */ public function up() { - Schema::create('config', function (Blueprint $table) { - $table->integer('id', true); - $table->unsignedInteger('service_body_id'); - $table->mediumText('data'); - $table->string('data_type', 45); - $table->unsignedInteger('parent_id')->nullable(); - $table->integer('status')->nullable(); + if (!Schema::hasTable('config')) { + Schema::create('config', function (Blueprint $table) { + $table->integer('id', true); + $table->unsignedInteger('service_body_id'); + $table->mediumText('data'); + $table->string('data_type', 45); + $table->unsignedInteger('parent_id')->nullable(); - $table->unique(['service_body_id', 'data_type', 'parent_id'], 'service_body_id_data_type_parent_id_unique'); - }); + $table->unique(['service_body_id', 'data_type', 'parent_id'], 'service_body_id_data_type_parent_id_unique'); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_event_status_table.php b/src/database/migrations/2024_03_24_035821_create_event_status_table.php index 36380ab70..3febc0a3d 100644 --- a/src/database/migrations/2024_03_24_035821_create_event_status_table.php +++ b/src/database/migrations/2024_03_24_035821_create_event_status_table.php @@ -13,15 +13,17 @@ */ public function up() { - Schema::create('event_status', function (Blueprint $table) { - $table->bigInteger('id', true)->unique('id_unique'); - $table->string('callsid')->nullable(); - $table->integer('status')->nullable(); - $table->integer('event_id')->nullable(); - $table->timestamps(); + if (!Schema::hasTable('event_status')) { + Schema::create('event_status', function (Blueprint $table) { + $table->bigInteger('id', true)->unique('id_unique'); + $table->string('callsid')->nullable(); + $table->integer('status')->nullable(); + $table->integer('event_id')->nullable(); + $table->timestamps(); - //$table->primary(['id']); - }); + //$table->primary(['id']); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_flags_table.php b/src/database/migrations/2024_03_24_035821_create_flags_table.php index d57a67c8a..94cea9d12 100644 --- a/src/database/migrations/2024_03_24_035821_create_flags_table.php +++ b/src/database/migrations/2024_03_24_035821_create_flags_table.php @@ -13,12 +13,14 @@ */ public function up() { - Schema::create('flags', function (Blueprint $table) { - $table->integer('id', true); - $table->string('flag_name', 50)->unique('flag_name_unique'); - $table->integer('flag_setting'); - $table->timestamp('timestamp')->useCurrent(); - }); + if (!Schema::hasTable('flags')) { + Schema::create('flags', function (Blueprint $table) { + $table->integer('id', true); + $table->string('flag_name', 50)->unique('flag_name_unique'); + $table->integer('flag_setting'); + $table->timestamp('timestamp')->useCurrent(); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_metrics_table.php b/src/database/migrations/2024_03_24_035821_create_metrics_table.php index f4414e5ea..f18d56c29 100644 --- a/src/database/migrations/2024_03_24_035821_create_metrics_table.php +++ b/src/database/migrations/2024_03_24_035821_create_metrics_table.php @@ -13,14 +13,16 @@ */ public function up() { - Schema::create('metrics', function (Blueprint $table) { - $table->integer('id', true)->unique('id_metrics_unique'); - $table->timestamp('timestamp')->useCurrent(); - $table->text('data'); - $table->unsignedInteger('service_body_id')->nullable(); + if (!Schema::hasTable('metrics')) { + Schema::create('metrics', function (Blueprint $table) { + $table->integer('id', true)->unique('id_metrics_unique'); + $table->timestamp('timestamp')->useCurrent(); + $table->text('data'); + $table->unsignedInteger('service_body_id')->nullable(); - //$table->primary(['id']); - }); + //$table->primary(['id']); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_migrations_table.php b/src/database/migrations/2024_03_24_035821_create_migrations_table.php index 02025c6de..8ff28b772 100644 --- a/src/database/migrations/2024_03_24_035821_create_migrations_table.php +++ b/src/database/migrations/2024_03_24_035821_create_migrations_table.php @@ -13,11 +13,13 @@ */ public function up() { - Schema::create('migrations', function (Blueprint $table) { - $table->integer('id', true); - $table->string('version', 45)->nullable(); - $table->timestamp('timestamp')->useCurrent(); - }); + if (!Schema::hasTable('migrations')) { + Schema::create('migrations', function (Blueprint $table) { + $table->integer('id', true); + $table->string('version', 45)->nullable(); + $table->timestamp('timestamp')->useCurrent(); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_records_events_table.php b/src/database/migrations/2024_03_24_035821_create_records_events_table.php index fec0807cf..8c98a782f 100644 --- a/src/database/migrations/2024_03_24_035821_create_records_events_table.php +++ b/src/database/migrations/2024_03_24_035821_create_records_events_table.php @@ -13,15 +13,17 @@ */ public function up() { - Schema::create('records_events', function (Blueprint $table) { - $table->integer('id', true); - $table->string('callsid')->index('idx_records_events_callsid'); - $table->timestamp('event_time')->nullable(); - $table->integer('event_id'); - $table->integer('service_body_id')->nullable()->index('idx_records_events_service_body_id'); - $table->text('meta')->nullable(); - $table->integer('type')->nullable(); - }); + if (!Schema::hasTable('records_events')) { + Schema::create('records_events', function (Blueprint $table) { + $table->integer('id', true); + $table->string('callsid')->index('idx_records_events_callsid'); + $table->timestamp('event_time')->nullable(); + $table->integer('event_id'); + $table->integer('service_body_id')->nullable()->index('idx_records_events_service_body_id'); + $table->text('meta')->nullable(); + $table->integer('type')->nullable(); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_records_table.php b/src/database/migrations/2024_03_24_035821_create_records_table.php index 8a8bab997..bda4c6ad4 100644 --- a/src/database/migrations/2024_03_24_035821_create_records_table.php +++ b/src/database/migrations/2024_03_24_035821_create_records_table.php @@ -13,17 +13,19 @@ */ public function up() { - Schema::create('records', function (Blueprint $table) { - $table->integer('id', true); - $table->string('callsid')->index('idx_records_callsid'); - $table->timestamp('start_time')->nullable(); - $table->timestamp('end_time')->nullable(); - $table->string('from_number'); - $table->string('to_number'); - $table->longText('payload')->nullable(); - $table->integer('duration'); - $table->integer('type')->nullable(); - }); + if (!Schema::hasTable('records')) { + Schema::create('records', function (Blueprint $table) { + $table->integer('id', true); + $table->string('callsid')->index('idx_records_callsid'); + $table->timestamp('start_time')->nullable(); + $table->timestamp('end_time')->nullable(); + $table->string('from_number'); + $table->string('to_number'); + $table->longText('payload')->nullable(); + $table->integer('duration'); + $table->integer('type')->nullable(); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_sessions_table.php b/src/database/migrations/2024_03_24_035821_create_sessions_table.php index afc38de29..5c453ead0 100644 --- a/src/database/migrations/2024_03_24_035821_create_sessions_table.php +++ b/src/database/migrations/2024_03_24_035821_create_sessions_table.php @@ -13,11 +13,13 @@ */ public function up() { - Schema::create('sessions', function (Blueprint $table) { - $table->string('callsid'); - $table->timestamp('timestamp')->useCurrent(); - $table->integer('pin'); - }); + if (!Schema::hasTable('sessions')) { + Schema::create('sessions', function (Blueprint $table) { + $table->string('callsid'); + $table->timestamp('timestamp')->useCurrent(); + $table->integer('pin'); + }); + } } /** diff --git a/src/database/migrations/2024_03_24_035821_create_users_table.php b/src/database/migrations/2024_03_24_035821_create_users_table.php index a18a8c54d..ecfe12a64 100644 --- a/src/database/migrations/2024_03_24_035821_create_users_table.php +++ b/src/database/migrations/2024_03_24_035821_create_users_table.php @@ -13,16 +13,18 @@ */ public function up() { - Schema::create('users', function (Blueprint $table) { - $table->integer('id', true); - $table->string('name'); - $table->string('username', 45)->unique('username_unique'); - $table->string('password'); - $table->integer('permissions')->default(0); - $table->integer('is_admin')->nullable(); - $table->timestamp('created_on')->useCurrent(); - $table->text('service_bodies')->nullable(); - }); + if (!Schema::hasTable('users')) { + Schema::create('users', function (Blueprint $table) { + $table->integer('id', true); + $table->string('name'); + $table->string('username', 45)->unique('username_unique'); + $table->string('password'); + $table->integer('permissions')->default(0); + $table->integer('is_admin')->nullable(); + $table->timestamp('created_on')->useCurrent(); + $table->text('service_bodies')->nullable(); + }); + } } /** diff --git a/src/database/migrations/2024_04_04_031341_create_config_table_status_column.php b/src/database/migrations/2024_04_04_031341_create_config_table_status_column.php new file mode 100644 index 000000000..0ff6b5d2b --- /dev/null +++ b/src/database/migrations/2024_04_04_031341_create_config_table_status_column.php @@ -0,0 +1,28 @@ +addColumn('integer', 'status')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::whenTableHasColumn('config', 'status', function (Blueprint $table) { + $table->removeColumn('status'); + }); + } +}; diff --git a/src/tests/Feature/InputMethodTest.php b/src/tests/Feature/InputMethodTest.php index 359805f6a..29b162bac 100644 --- a/src/tests/Feature/InputMethodTest.php +++ b/src/tests/Feature/InputMethodTest.php @@ -3,6 +3,7 @@ use App\Constants\SearchType; use App\Models\RecordType; use App\Repositories\ReportsRepository; +use App\Services\SettingsService; beforeAll(function () { putenv("ENVIRONMENT=test"); @@ -36,6 +37,25 @@ ], false); })->with(['GET', 'POST']); +test('search for volunteers with word overrides', function ($method) { + $_SESSION['override_city_or_county'] = "city or suburb"; + $response = $this->call($method, '/input-method.php', [ + "Digits"=>"1" + ]); + $response + ->assertStatus(200) + ->assertHeader("Content-Type", "text/xml; charset=UTF-8") + ->assertSeeInOrderExact([ + '', + '', + '', + 'press one to search for someone to talk to by city or suburb', + 'press two to search for someone to talk to by zip code', + '', + '' + ], false); +})->with(['GET', 'POST']); + test('search for meetings', function ($method) { $reportsRepository = Mockery::mock(ReportsRepository::class); $reportsRepository->shouldReceive("insertCallEventRecord")