summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordsnopek2016-08-16 22:09:05 (GMT)
committerJakob Perry2016-08-16 22:09:05 (GMT)
commitd2fc20baf79de8ffa44e707172e70ca3c55555b4 (patch)
treea2eb999e2be9b00ce8b2f679d7f0975b4aeed708
parent49ee4c16510a3a7b13f0615864b3380d5cf176f0 (diff)
Issue #2784981 by dsnopek: Remove confusing legacy permissions from Panels Node
-rw-r--r--panels_node/panels_node.install38
-rw-r--r--panels_node/panels_node.module33
2 files changed, 38 insertions, 33 deletions
diff --git a/panels_node/panels_node.install b/panels_node/panels_node.install
index c68e40d..f1b24f9 100644
--- a/panels_node/panels_node.install
+++ b/panels_node/panels_node.install
@@ -69,3 +69,41 @@ function panels_node_update_6001() {
db_add_field('panels_node', 'pipeline', $field);
return $ret;
}
+
+/**
+ * Migrate legacy Drupal 6 permissions to Drupal 7.
+ */
+function panels_node_update_6002() {
+ $permissions = array(
+ 'create panel-nodes' => 'create panel content',
+ 'edit any panel-nodes' => 'edit any panel content',
+ 'edit own panel-nodes' => 'edit own panel content',
+ 'delete any panel-nodes' => 'delete any panel content',
+ 'delete own panel-nodes' => 'delete own panel content',
+ );
+ foreach ($permissions as $legacy_permission => $new_permission) {
+ $query = db_select('role_permission', 'p')
+ ->fields('p', array('rid'))
+ ->condition('permission', $legacy_permission);
+ $rids = $query->execute()->fetchCol();
+ foreach ($rids as $rid) {
+ // Insert the new permission if it doesn't already exist.
+ db_merge('role_permission')
+ ->key(array(
+ 'rid' => $rid,
+ 'permission' => $new_permission,
+ ))
+ ->insertFields(array(
+ 'rid' => $rid,
+ 'permission' => $new_permission,
+ 'module' => 'node',
+ ))
+ ->execute();
+ }
+
+ // Delete the legacy permission.
+ db_delete('role_permission')
+ ->condition('permission', $legacy_permission)
+ ->execute();
+ }
+}
diff --git a/panels_node/panels_node.module b/panels_node/panels_node.module
index 03d8bbe..0d01587 100644
--- a/panels_node/panels_node.module
+++ b/panels_node/panels_node.module
@@ -17,30 +17,10 @@
*/
function panels_node_permission() {
return array(
- 'create panel-nodes' => array(
- 'title' => t('Create panel nodes'),
- 'description' => t('Create new panel nodes.'),
- ),
- 'edit any panel-nodes' => array(
- 'title' => t('Edit any panel-nodes'),
- 'description' => t('Edit all pre-existing panel nodes regardless of ownership.'),
- ),
- 'edit own panel-nodes' => array(
- 'title' => t('Edit own panel nodes'),
- 'description' => t('Edit panel nodes owned by this user.'),
- ),
'administer panel-nodes' => array(
'title' => t('Administer panel nodes'),
'description' => t('Full administrative access to panel nodes including create, update and delete all'),
),
- 'delete any panel-nodes' => array(
- 'title' => t('Delete any panel nodes'),
- 'description' => t('Delete any panel node regardless of ownership'),
- ),
- 'delete own panel-nodes' => array(
- 'title' => t('Delete own panel nodes'),
- 'description' => t('Delete any panel node owned by this user.'),
- ),
);
}
@@ -156,19 +136,6 @@ function panels_node_node_access($node, $op, $account) {
if (user_access('administer panel-nodes', $account)) {
return NODE_ACCESS_ALLOW;
}
-
- if ($op == 'create' && user_access('create panel-nodes', $account)) {
- return NODE_ACCESS_ALLOW;
- }
-
- if ($op == 'update' && (user_access('edit any panel-nodes', $account) || $node->uid == $account->uid && user_access('edit own panel-nodes', $account))) {
- return NODE_ACCESS_ALLOW;
- }
-
-
- if ($op == 'delete' && (user_access('delete any panel-nodes') || $node->uid == $account->uid && user_access('delete own panel-nodes'))) {
- return NODE_ACCESS_ALLOW;
- }
}
/**