From 9932ecabac1873c707e74b5649e002a57938fad5 Mon Sep 17 00:00:00 2001 From: protitude Date: Mon, 17 Aug 2026 14:18:04 -0400 Subject: [PATCH 1/2] adding goodkind chatbot to oit header --- oit.module | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/oit.module b/oit.module index ff4f197..506f7ae 100644 --- a/oit.module +++ b/oit.module @@ -6,6 +6,7 @@ */ use Drupal\block\Entity\Block; +use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Xss; use Drupal\Core\Access\AccessResult; @@ -396,6 +397,28 @@ function oit_page_attachments_alter(array &$attachments) { ], ]; $attachments['#attached']['html_head'][] = [$google_site_verify, 'google-site-verification']; + + // Goodkind chatbot widget. + $chatbot_config = [ + 'aiBotId' => '6765a3c67b1f300012149d6e', + 'apiKey' => '659425d1a56d1027865e1d658b27679e288bdd07adb4814d0d812a69bba6b429c77939ec0214f41e731ec17a26ce1ddcff47d138efbfc5199ff87a2569ed8115f4fbfca462109099a2cdf031b6c7b55fb3734024368179943a227b5cc6ec566bb01a45695e42a074f00d15ad0029775f46b7ad', + ]; + $chatbot_settings = [ + '#tag' => 'script', + '#attributes' => ['type' => 'text/javascript'], + '#value' => 'window.gkCBWConfig = ' . Json::encode($chatbot_config) . ';', + ]; + $attachments['#attached']['html_head'][] = [$chatbot_settings, 'gk-chatbot-widget-config']; + $chatbot_widget = [ + '#tag' => 'script', + '#attributes' => [ + 'type' => 'module', + 'src' => 'https://widget.goodkind.com/gk-chatbot-widget.js', + 'defer' => TRUE, + ], + '#value' => '', + ]; + $attachments['#attached']['html_head'][] = [$chatbot_widget, 'gk-chatbot-widget']; } } From cb7e1e1384873dc66632e7d9579ac166278b58fc Mon Sep 17 00:00:00 2001 From: protitude Date: Tue, 18 Aug 2026 13:28:53 -0400 Subject: [PATCH 2/2] goodkind: UCBoulder/oit_dingo#1378 Hide widget from admin and local --- oit.module | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/oit.module b/oit.module index 506f7ae..af5b992 100644 --- a/oit.module +++ b/oit.module @@ -398,27 +398,32 @@ function oit_page_attachments_alter(array &$attachments) { ]; $attachments['#attached']['html_head'][] = [$google_site_verify, 'google-site-verification']; - // Goodkind chatbot widget. - $chatbot_config = [ - 'aiBotId' => '6765a3c67b1f300012149d6e', - 'apiKey' => '659425d1a56d1027865e1d658b27679e288bdd07adb4814d0d812a69bba6b429c77939ec0214f41e731ec17a26ce1ddcff47d138efbfc5199ff87a2569ed8115f4fbfca462109099a2cdf031b6c7b55fb3734024368179943a227b5cc6ec566bb01a45695e42a074f00d15ad0029775f46b7ad', - ]; - $chatbot_settings = [ - '#tag' => 'script', - '#attributes' => ['type' => 'text/javascript'], - '#value' => 'window.gkCBWConfig = ' . Json::encode($chatbot_config) . ';', - ]; - $attachments['#attached']['html_head'][] = [$chatbot_settings, 'gk-chatbot-widget-config']; - $chatbot_widget = [ - '#tag' => 'script', - '#attributes' => [ - 'type' => 'module', - 'src' => 'https://widget.goodkind.com/gk-chatbot-widget.js', - 'defer' => TRUE, - ], - '#value' => '', - ]; - $attachments['#attached']['html_head'][] = [$chatbot_widget, 'gk-chatbot-widget']; + $user = \Drupal::currentUser(); + $roles = $user->getRoles(); + $environment = getenv('PANTHEON_ENVIRONMENT'); + if (!in_array('administrator', $roles) && $environment != 'local') { + // Goodkind chatbot widget. + $chatbot_config = [ + 'aiBotId' => '6765a3c67b1f300012149d6e', + 'apiKey' => '659425d1a56d1027865e1d658b27679e288bdd07adb4814d0d812a69bba6b429c77939ec0214f41e731ec17a26ce1ddcff47d138efbfc5199ff87a2569ed8115f4fbfca462109099a2cdf031b6c7b55fb3734024368179943a227b5cc6ec566bb01a45695e42a074f00d15ad0029775f46b7ad', + ]; + $chatbot_settings = [ + '#tag' => 'script', + '#attributes' => ['type' => 'text/javascript'], + '#value' => 'window.gkCBWConfig = ' . Json::encode($chatbot_config) . ';', + ]; + $attachments['#attached']['html_head'][] = [$chatbot_settings, 'gk-chatbot-widget-config']; + $chatbot_widget = [ + '#tag' => 'script', + '#attributes' => [ + 'type' => 'module', + 'src' => 'https://widget.goodkind.com/gk-chatbot-widget.js', + 'defer' => TRUE, + ], + '#value' => '', + ]; + $attachments['#attached']['html_head'][] = [$chatbot_widget, 'gk-chatbot-widget']; + } } }