Commit 593358fd authored by Fran Garcia-Linares's avatar Fran Garcia-Linares Committed by Neil Drumm
Browse files

Issue #3301358 by fjgarlin, B_man: Remove release unpublish/edit access from site moderators

parent cd0739f4
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -46,6 +46,10 @@ function drupalorg_permission() {
      'title' => t('Administer Drupal Association sponsorships'),
      'description' => t('Can update ad copy'),
    ],
    'administer all releases' => [
      'title' => t('Administer all releases'),
      'description' => t('Edit and change published status of all releases'),
    ],
  ];

  // Generate unpublished node permissions for all applicable node types.
@@ -4293,6 +4297,19 @@ function drupalorg_node_access($node, $op, $account) {
    }
  }

  if (in_array($op, ['update', 'delete']) && project_release_node_is_release($node)) {
    $project_nid = $node->field_release_project[LANGUAGE_NONE][0]['target_id'];
    // Project maintainer or users with explicit permission can update/delete.
    if (
      project_user_access($project_nid, 'administer releases') ||
      user_access('administer all releases')
    ) {
      return NODE_ACCESS_ALLOW;
    }
    // Rest of users won't be able to edit or delete releases.
    return NODE_ACCESS_DENY;
  }

  if ($op === 'view' && $node->status == NODE_NOT_PUBLISHED && user_access('view any unpublished ' . $type . ' content', $account)) {
    return NODE_ACCESS_ALLOW;
  }
+8 −0
Original line number Diff line number Diff line
@@ -991,6 +991,14 @@ function drupalorg_project_form_node_form_alter(&$form, &$form_state) {
        }
      }
    }

    // Removing the access to the published checkbox will remove the input from
    // the form, and the fieldset summary will wrongly state "Not published",
    // even if the node is published. See "modules/node/node.js" logic. So we
    // will just show the field as disabled instead.
    if (!user_access('administer all releases')) {
      $form['options']['status']['#disabled'] = TRUE;
    }
  }
}