#189009 by AjK: edit own poll permission was missing from poll module (although available for other content types)

6.x
Gábor Hojtsy 2007-11-05 16:28:25 +00:00
parent 2d8529a032
commit 73d88aa929
1 changed files with 11 additions and 4 deletions

View File

@ -54,15 +54,20 @@ function poll_theme() {
* Implementation of hook_perm(). * Implementation of hook_perm().
*/ */
function poll_perm() { function poll_perm() {
return array('create polls', 'vote on polls', 'cancel own vote', 'inspect all votes'); return array('create polls', 'edit polls', 'edit own poll', 'vote on polls', 'cancel own vote', 'inspect all votes');
} }
/** /**
* Implementation of hook_access(). * Implementation of hook_access().
*/ */
function poll_access($op, $node, $account) { function poll_access($op, $node, $account) {
if ($op == 'create') { global $user;
return user_access('create polls', $account);
switch ($op) {
case 'create':
return user_access('create polls', $account);
case 'update':
return user_access('edit polls') || (user_access('edit own poll') && ($node->uid == $user->uid));
} }
} }
@ -177,7 +182,9 @@ function poll_node_info() {
* Implementation of hook_form(). * Implementation of hook_form().
*/ */
function poll_form(&$node, $form_state) { function poll_form(&$node, $form_state) {
$admin = user_access('administer nodes'); global $user;
$admin = user_access('administer nodes') || user_access('edit polls') || (user_access('edit own polls') && $user->uid == $node->nid);
$type = node_get_types('type', $node); $type = node_get_types('type', $node);
$form = array( $form = array(