Mercurial > hg > isophonics-drupal-site
comparison core/modules/node/src/NodeGrantDatabaseStorage.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
11:bfffd8d7479a | 12:7a779792577d |
---|---|
209 // Only perform work when node_access modules are active. | 209 // Only perform work when node_access modules are active. |
210 if (!empty($grants) && count($this->moduleHandler->getImplementations('node_grants'))) { | 210 if (!empty($grants) && count($this->moduleHandler->getImplementations('node_grants'))) { |
211 $query = $this->database->insert('node_access')->fields(['nid', 'langcode', 'fallback', 'realm', 'gid', 'grant_view', 'grant_update', 'grant_delete']); | 211 $query = $this->database->insert('node_access')->fields(['nid', 'langcode', 'fallback', 'realm', 'gid', 'grant_view', 'grant_update', 'grant_delete']); |
212 // If we have defined a granted langcode, use it. But if not, add a grant | 212 // If we have defined a granted langcode, use it. But if not, add a grant |
213 // for every language this node is translated to. | 213 // for every language this node is translated to. |
214 $fallback_langcode = $node->getUntranslated()->language()->getId(); | |
214 foreach ($grants as $grant) { | 215 foreach ($grants as $grant) { |
215 if ($realm && $realm != $grant['realm']) { | 216 if ($realm && $realm != $grant['realm']) { |
216 continue; | 217 continue; |
217 } | 218 } |
218 if (isset($grant['langcode'])) { | 219 if (isset($grant['langcode'])) { |
225 // Only write grants; denies are implicit. | 226 // Only write grants; denies are implicit. |
226 if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) { | 227 if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) { |
227 $grant['nid'] = $node->id(); | 228 $grant['nid'] = $node->id(); |
228 $grant['langcode'] = $grant_langcode; | 229 $grant['langcode'] = $grant_langcode; |
229 // The record with the original langcode is used as the fallback. | 230 // The record with the original langcode is used as the fallback. |
230 if ($grant['langcode'] == $node->language()->getId()) { | 231 if ($grant['langcode'] == $fallback_langcode) { |
231 $grant['fallback'] = 1; | 232 $grant['fallback'] = 1; |
232 } | 233 } |
233 else { | 234 else { |
234 $grant['fallback'] = 0; | 235 $grant['fallback'] = 0; |
235 } | 236 } |