Commit d2fc20ba authored by dsnopek's avatar dsnopek Committed by japerry

Issue #2784981 by dsnopek: Remove confusing legacy permissions from Panels Node

parent 49ee4c16
......@@ -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();
}
}
......@@ -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;
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment