function quiz_stats_validate_vid in Quiz 6.x
Same name and namespace in other branches
- 8.6 modules/quiz_stats/quiz_stats.module \quiz_stats_validate_vid()
- 8.4 modules/quiz_stats/quiz_stats.module \quiz_stats_validate_vid()
- 8.5 modules/quiz_stats/quiz_stats.module \quiz_stats_validate_vid()
- 6.4 includes/quiz_stats/quiz_stats.module \quiz_stats_validate_vid()
- 7.6 modules/quiz_stats/quiz_stats.module \quiz_stats_validate_vid()
- 7 includes/quiz_stats/quiz_stats.module \quiz_stats_validate_vid()
- 7.4 includes/quiz_stats/quiz_stats.module \quiz_stats_validate_vid()
- 7.5 modules/quiz_stats/quiz_stats.module \quiz_stats_validate_vid()
Validate the node.
Check if its of type quiz, and that the user has access to it, and that the vid is a vid of that quiz.
Parameters
$quiz: The quiz node.
$vid: The version id.
Return value
TRUE if user has access.
1 string reference to 'quiz_stats_validate_vid'
- quiz_stats_menu in modules/
quiz_stats/ quiz_stats.module - Implements hook_menu().
File
- modules/
quiz_stats/ quiz_stats.module, line 141 - Quiz stats.
Code
function quiz_stats_validate_vid($quiz, $vid) {
if ($quiz->type != 'quiz') {
return FALSE;
}
if (!user_access('access author stats')) {
return FALSE;
}
// TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
// You will need to use `\Drupal\core\Database\Database::getConnection()` if you do not yet have access to the container here.
return $quiz->nid == \Drupal::database()
->query('SELECT n.nid FROM {node} n INNER JOIN {node_revision} nr ON (n.nid = nr.nid) WHERE nr.vid = :vid', [
':vid' => $vid,
])
->fetchField();
}