From c0c79781bf87cb1bba51cbfda7c26403077239f6 Mon Sep 17 00:00:00 2001 From: osaajani <> Date: Tue, 26 Jan 2021 19:27:30 +0100 Subject: [PATCH 1/3] Add meta_hidden to adapters --- adapters/AdapterInterface.php | 6 ++++++ adapters/BenchmarkAdapter.php | 9 +++++++++ adapters/GammuAdapter.php | 10 ++++++++++ adapters/OctopushShortcodeAdapter.php | 11 ++++++++++- adapters/OctopushVirtualNumberAdapter.php | 9 +++++++++ adapters/OvhSmsShortcodeAdapter.php | 9 +++++++++ adapters/OvhSmsVirtualNumberAdapter.php | 9 +++++++++ adapters/TestAdapter.php | 9 +++++++++ adapters/TwilioVirtualNumberAdapter.php | 9 +++++++++ 9 files changed, 80 insertions(+), 1 deletion(-) diff --git a/adapters/AdapterInterface.php b/adapters/AdapterInterface.php index f778fcc..eb3ec75 100644 --- a/adapters/AdapterInterface.php +++ b/adapters/AdapterInterface.php @@ -38,6 +38,12 @@ namespace adapters; */ public static function meta_uid(): string; + /** + * Should this adapter be hidden in user interface for phone creation and + * available to creation through API only + */ + public static function meta_hidden(): bool; + /** * Name of the adapter. * It should probably be the name of the service it adapt (e.g : Gammu SMSD, OVH SMS, SIM800L, etc.). diff --git a/adapters/BenchmarkAdapter.php b/adapters/BenchmarkAdapter.php index 43ea3dc..866d9bd 100644 --- a/adapters/BenchmarkAdapter.php +++ b/adapters/BenchmarkAdapter.php @@ -56,6 +56,15 @@ namespace adapters; { return 'benchmark_adapter'; } + + /** + * Should this adapter be hidden in user interface for phone creation and + * available to creation through API only + */ + public static function meta_hidden(): bool + { + return false; + } /** * Name of the adapter. diff --git a/adapters/GammuAdapter.php b/adapters/GammuAdapter.php index d6fec3d..f4512a1 100644 --- a/adapters/GammuAdapter.php +++ b/adapters/GammuAdapter.php @@ -51,6 +51,16 @@ namespace adapters; { return 'gammu_adapter'; } + + /** + * Should this adapter be hidden in user interface for phone creation and + * available to creation through API only + */ + public static function meta_hidden(): bool + { + return false; + } + /** * Name of the adapter. diff --git a/adapters/OctopushShortcodeAdapter.php b/adapters/OctopushShortcodeAdapter.php index 4123bc2..a93f34e 100644 --- a/adapters/OctopushShortcodeAdapter.php +++ b/adapters/OctopushShortcodeAdapter.php @@ -77,6 +77,15 @@ class OctopushShortcodeAdapter implements AdapterInterface { return 'octopush_shortcode_adapter'; } + + /** + * Should this adapter be hidden in user interface for phone creation and + * available to creation through API only + */ + public static function meta_hidden(): bool + { + return false; + } /** * Name of the adapter. @@ -393,7 +402,7 @@ class OctopushShortcodeAdapter implements AdapterInterface $response = [ 'error' => false, 'error_message' => null, - 'uid' => null, + 'sms' => null, ]; header('Connection: close'); diff --git a/adapters/OctopushVirtualNumberAdapter.php b/adapters/OctopushVirtualNumberAdapter.php index 830e26b..1525179 100644 --- a/adapters/OctopushVirtualNumberAdapter.php +++ b/adapters/OctopushVirtualNumberAdapter.php @@ -83,6 +83,15 @@ class OctopushVirtualNumberAdapter implements AdapterInterface { return 'octopush_virtual_number_adapter'; } + + /** + * Should this adapter be hidden in user interface for phone creation and + * available to creation through API only + */ + public static function meta_hidden(): bool + { + return false; + } /** * Name of the adapter. diff --git a/adapters/OvhSmsShortcodeAdapter.php b/adapters/OvhSmsShortcodeAdapter.php index 5deeda8..f68c9d4 100644 --- a/adapters/OvhSmsShortcodeAdapter.php +++ b/adapters/OvhSmsShortcodeAdapter.php @@ -62,6 +62,15 @@ namespace adapters; { return 'ovh_sms_shortcode_adapter'; } + + /** + * Should this adapter be hidden in user interface for phone creation and + * available to creation through API only + */ + public static function meta_hidden(): bool + { + return false; + } /** * Name of the adapter. diff --git a/adapters/OvhSmsVirtualNumberAdapter.php b/adapters/OvhSmsVirtualNumberAdapter.php index 3e7d3c9..00d3f86 100644 --- a/adapters/OvhSmsVirtualNumberAdapter.php +++ b/adapters/OvhSmsVirtualNumberAdapter.php @@ -74,6 +74,15 @@ namespace adapters; { return 'ovh_sms_virtual_number_adapter'; } + + /** + * Should this adapter be hidden in user interface for phone creation and + * available to creation through API only + */ + public static function meta_hidden(): bool + { + return false; + } /** * Name of the adapter. diff --git a/adapters/TestAdapter.php b/adapters/TestAdapter.php index 6586bd6..99759fb 100644 --- a/adapters/TestAdapter.php +++ b/adapters/TestAdapter.php @@ -61,6 +61,15 @@ namespace adapters; { return 'test_adapter'; } + + /** + * Should this adapter be hidden in user interface for phone creation and + * available to creation through API only + */ + public static function meta_hidden(): bool + { + return false; + } /** * Name of the adapter. diff --git a/adapters/TwilioVirtualNumberAdapter.php b/adapters/TwilioVirtualNumberAdapter.php index 58e12e8..3a78dd8 100644 --- a/adapters/TwilioVirtualNumberAdapter.php +++ b/adapters/TwilioVirtualNumberAdapter.php @@ -73,6 +73,15 @@ class TwilioVirtualNumberAdapter implements AdapterInterface { return 'twilio_virtual_number_adapter'; } + + /** + * Should this adapter be hidden in user interface for phone creation and + * available to creation through API only + */ + public static function meta_hidden(): bool + { + return false; + } /** * Name of the adapter. From 05cb62a503fd8effb78397b0e31f6d56f47c2a43 Mon Sep 17 00:00:00 2001 From: osaajani <> Date: Tue, 26 Jan 2021 19:33:08 +0100 Subject: [PATCH 2/3] implement logic for hiddens phone adapters --- controllers/publics/Phone.php | 7 +++++++ templates/phone/add.php | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/controllers/publics/Phone.php b/controllers/publics/Phone.php index 60e71ab..a1349fe 100644 --- a/controllers/publics/Phone.php +++ b/controllers/publics/Phone.php @@ -209,6 +209,13 @@ class Phone extends \descartes\Controller return $this->redirect(\descartes\Router::url('Phone', 'add')); } + if ($find_adapter['meta_hidden']) + { + \FlashMessage\FlashMessage::push('danger', 'Ce type de téléphone ne peux pas être créé via l\'interface graphique.'); + + return $this->redirect(\descartes\Router::url('Phone', 'add')); + } + //If missing required data fields, error foreach ($find_adapter['meta_data_fields'] as $field) { diff --git a/templates/phone/add.php b/templates/phone/add.php index 74f52b2..aad0103 100644 --- a/templates/phone/add.php +++ b/templates/phone/add.php @@ -54,14 +54,16 @@

From 61ba62ac86317ecd56658b35a23c454c731aa804 Mon Sep 17 00:00:00 2001 From: osaajani <> Date: Tue, 26 Jan 2021 20:43:39 +0100 Subject: [PATCH 3/3] Improve htaccess to allow direct access only to assets dir --- .htaccess | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.htaccess b/.htaccess index 994e4e0..e0be5de 100644 --- a/.htaccess +++ b/.htaccess @@ -1,2 +1,4 @@ RewriteEngine on -RewriteRule "!\.(js|ico|ICO|gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG|css|woff|woff2|ttf|wav|ogg|mp3|svg|json)$" index.php +RewriteRule ^assets - [L] +RewriteRule ^.well-known - [L] +RewriteRule . index.php