diff --git a/modules/book/book.install b/modules/book/book.install index 445a20a4acd..e6f016bb889 100644 --- a/modules/book/book.install +++ b/modules/book/book.install @@ -83,7 +83,7 @@ function book_update_6000() { $replace = array( 'outline posts in books' => 'administer book outlines', 'create book pages' => 'create book content', - 'edit book pages' => 'edit book content', + 'edit book pages' => 'edit any book content', 'edit own book pages' => 'edit own book content', 'see printer-friendly version' => 'access printer-friendly version', ); diff --git a/modules/node/node.module b/modules/node/node.module index 909d26773d9..7896a5812cf 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1048,9 +1048,9 @@ function node_perm() { $name = check_plain($type->type); $perms[] = 'create '. $name .' content'; $perms[] = 'delete own '. $name .' content'; - $perms[] = 'delete '. $name .' content'; + $perms[] = 'delete any '. $name .' content'; $perms[] = 'edit own '. $name .' content'; - $perms[] = 'edit '. $name .' content'; + $perms[] = 'edit any '. $name .' content'; } } @@ -2223,13 +2223,13 @@ function node_content_access($op, $node, $account) { } if ($op == 'update') { - if (user_access('edit '. $type .' content', $account) || (user_access('edit own '. $type .' content', $account) && ($user->uid == $node->uid))) { + if (user_access('edit any '. $type .' content', $account) || (user_access('edit own '. $type .' content', $account) && ($user->uid == $node->uid))) { return TRUE; } } if ($op == 'delete') { - if (user_access('delete '. $type .' content') || (user_access('delete own '. $type .' content') && ($user->uid == $node->uid))) { + if (user_access('delete any '. $type .' content') || (user_access('delete own '. $type .' content') && ($user->uid == $node->uid))) { return TRUE; } } diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 63d95fbed17..311d732a1de 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -54,7 +54,7 @@ function poll_theme() { * Implementation of hook_perm(). */ function poll_perm() { - return array('create polls', 'edit polls', 'edit own poll', 'vote on polls', 'cancel own vote', 'inspect all votes'); + return array('create poll content', 'edit any poll content', 'edit own poll content', 'vote on polls', 'cancel own vote', 'inspect all votes'); } /** @@ -65,9 +65,9 @@ function poll_access($op, $node, $account) { switch ($op) { case 'create': - return user_access('create polls', $account); + return user_access('create poll content', $account); case 'update': - return user_access('edit polls') || (user_access('edit own poll') && ($node->uid == $user->uid)); + return user_access('edit any poll content') || (user_access('edit own poll content') && ($node->uid == $user->uid)); } } @@ -184,7 +184,7 @@ function poll_node_info() { function poll_form(&$node, $form_state) { global $user; - $admin = user_access('administer nodes') || user_access('edit polls') || (user_access('edit own polls') && $user->uid == $node->nid); + $admin = user_access('administer nodes') || user_access('edit any poll content') || (user_access('edit own poll content') && $user->uid == $node->nid); $type = node_get_types('type', $node); $form = array( diff --git a/modules/system/system.install b/modules/system/system.install index d3e35e78d3a..c489eb86280 100644 --- a/modules/system/system.install +++ b/modules/system/system.install @@ -2716,6 +2716,25 @@ function system_update_6038() { return $ret; } +/** + * Rename permissions "edit foo content" to "edit any foo content". + * Also update poll module permission "create polls" to "create + * poll content". + */ +function system_update_6039() { + $ret = array(); + $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid"); + while ($role = db_fetch_object($result)) { + $renamed_permission = preg_replace('/(?<=^|,\ )edit\ ([a-zA-Z0-9_\-]+)\ content(?=,|$)/', 'edit any $1 content', $role->perm); + $renamed_permission = preg_replace('/(?<=^|,\ )create\ polls(?=,|$)/', 'create poll content', $renamed_permission); + if ($renamed_permission != $role->perm) { + $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid"); + } + } + return $ret; +} + + /** * @} End of "defgroup updates-5.x-to-6.x" * The next series of updates should start at 7000.