function faq_ask_node_access in FAQ_Ask 8
Same name and namespace in other branches
- 7 faq_ask.module \faq_ask_node_access()
Implements hook_node_access().
1 call to faq_ask_node_access()
- Utility::faqAskUnansweredBuild in src/
Utility.php - Create a categorized list of nodes that are not answered.
File
- ./
faq_ask.module, line 433 - This module is an add-on to FAQ module, allows users to 'ask question'.
Code
function faq_ask_node_access(NodeInterface $node, $op, $account) {
// Ignore non-FAQ node.
if ($node
->getType() != 'faq') {
return NULL;
}
if ($node->status->value == 1) {
return NULL;
}
if ($op == 'view') {
if ($node->status->value == 0 && \Drupal::currentUser()
->hasPermission('ask question')) {
return NULL;
}
else {
return NULL;
}
}
if ($op == 'delete') {
if ($node->status->value == 0 && \Drupal::currentUser()
->hasPermission('ask question')) {
return NULL;
}
else {
return NULL;
}
}
if ($op == 'create') {
return \Drupal::currentUser()
->hasPermission('ask question') || \Drupal::currentUser()
->hasPermission('answer question');
}
if ($op == 'update') {
if ($node->status->value == 0 && \Drupal::currentUser()
->hasPermission('ask question')) {
return NULL;
}
else {
return \Drupal::currentUser()
->hasPermission('ask question') || \Drupal::currentUser()
->hasPermission('answer question');
}
}
}