GitHub PullRequestReviewCommentEvent at 2014-05-21 12:31:03
Repository: openscholar
Actor: amitaibu
Payload: {"comment":{"url":"https://api.github.com/repos/openscholar/openscholar/pulls/comments/12893121","id":12893121,"diff_hunk":"@@ -562,29 +562,48 @@ function vsite_group_default_homepage_value($entity_type, $entity, $field, $inst\n /**\n  * Implements hook_node_access().\n  *\n- * Deny access to create node outside of a VSite for non-privileged user. Also\n- * deny access to creating groups from within a VSite (e.g.\n+ * Deny access to create node outside of a VSite for non-privileged user.\n+ * Deny access to creating groups from within a VSite (e.g.\n  * john/node/add/personal) as they are handled via site/register.\n+ * Deny access to deleting vsite for non-privileged user.\n  */\n function vsite_node_access($node, $op, $account) {\n-  if ($op != 'create' || user_access('administer group')) {\n-    return NODE_ACCESS_IGNORE;\n-  }\n-\n-  // @todo: Just remove from the permissions list?\n   $group_types = array_keys(array_intersect(module_invoke_all('vsite_og_node_type_info'), array('group')));\n-  if (in_array($node,  $group_types)) {\n-    // Deny direct access to creating groups.\n-    return NODE_ACCESS_DENY;\n-  }\n \n-  if (!$vsite = vsite_get_vsite()) {\n-    // Deny access when outside of VSite.\n-    return NODE_ACCESS_DENY;\n+  switch ($op) {\n+    // Handle 'create' cases:\n+    case 'create':\n+      if (user_access('administer group')) {\n+        return NODE_ACCESS_IGNORE;\n+      }\n+\n+      if (in_array($node, $group_types)) {\n+        // Deny direct access to creating groups.\n+        return NODE_ACCESS_DENY;\n+      }\n+      if (!$vsite = vsite_get_vsite()) {\n+        // Deny access when outside of VSite.\n+        return NODE_ACCESS_DENY;\n+      }\n+      // Check the user's permission to create new content in the current VSite.\n+      return !og_user_access('node', $vsite->group->nid, 'create ' . $node . ' content', $account) ? NODE_ACCESS_DENY : NODE_ACCESS_IGNORE;\n+      break;\n+\n+    // Handle 'delete' cases:\n+    case 'delete':\n+      if (!in_array($node->type, $group_types)) {\n+        // Ignore deletion of non-groups.\n+        return NODE_ACCESS_IGNORE;\n+      }\n+      return !user_access('delete vsite') ? NODE_ACCESS_DENY : NODE_ACCESS_IGNORE;","path":"openscholar/modules/vsite/vsite.module","position":51,"original_position":51,"commit_id":"ff9033df6f03700f1f81c5e96722f3eab17f23b9","original_commit_id":"ff9033df6f03700f1f81c5e96722f3eab17f23b9","user":{"login":"amitaibu","id":125707,"avatar_url":"https://avatars.githubusercontent.com/u/125707?","gravatar_id":"dd083a563230226543fcab3e1395b1fd","url":"https://api.github.com/users/amitaibu","html_url":"https://github.com/amitaibu","followers_url":"https://api.github.com/users/amitaibu/followers","following_url":"https://api.github.com/users/amitaibu/following{/other_user}","gists_url":"https://api.github.com/users/amitaibu/gists{/gist_id}","starred_url":"https://api.github.com/users/amitaibu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitaibu/subscriptions","organizations_url":"https://api.github.com/users/amitaibu/orgs","repos_url":"https://api.github.com/users/amitaibu/repos","events_url":"https://api.github.com/users/amitaibu/events{/privacy}","received_events_url":"https://api.github.com/users/amitaibu/received_events","type":"User","site_admin":false},"body":"don't forget to pass the ``$account`` in the ``user_access()``","created_at":"2014-05-21T12:31:03Z","updated_at":"2014-05-21T12:31:03Z","html_url":"https://github.com/openscholar/openscholar/pull/6150#discussion_r12893121","pull_request_url":"https://api.github.com/repos/openscholar/openscholar/pulls/6150","_links":{"self":{"href":"https://api.github.com/repos/openscholar/openscholar/pulls/comments/12893121"},"html":{"href":"https://github.com/openscholar/openscholar/pull/6150#discussion_r12893121"},"pull_request":{"href":"https://api.github.com/repos/openscholar/openscholar/pulls/6150"}}}}