From 93955414dbf6242df125ec67fac0424a7b0fc688 Mon Sep 17 00:00:00 2001
From: kpaxman <kpaxman@uwaterloo.ca>
Date: Mon, 26 Jul 2021 14:37:44 -0400
Subject: [PATCH] ISTWCMS-4967: add update hook for permission changes to get
 around cd-update not updating reliably.

---
 uw_cfg_common.install | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/uw_cfg_common.install b/uw_cfg_common.install
index 9ed2ed61..9c20ffa8 100644
--- a/uw_cfg_common.install
+++ b/uw_cfg_common.install
@@ -8,6 +8,7 @@
 use Drupal\taxonomy\Entity\Term;
 use Drupal\node\Entity\Node;
 use Drupal\uw_cfg_common\UwPermissions\UwPermissions;
+use Drupal\user\Entity\Role;
 
 /**
  * Implements hook_install().
@@ -354,3 +355,22 @@ function uw_cfg_common_update_8101() {
     }
   }
 }
+
+/**
+ * Set draggable views permissions, since cd-update doesn't do it reliably.
+ */
+function uw_cfg_common_update_8102() {
+  $roles = [
+    'uw_role_content_author',
+    'uw_role_content_editor',
+    'uw_role_form_editor',
+    'uw_role_form_results_access',
+    'uw_role_site_manager',
+    'uw_role_site_owner',
+  ];
+  foreach($roles as $role_name) {
+    $role_object = Role::load($role_name);
+    $role_object->grantPermission('access draggableviews');
+    $role_object->save();
+  }
+}
-- 
GitLab