You are here

vud.module in Vote Up/Down 8

Same filename and directory in other branches
  1. 6.3 vud.module
  2. 6.2 vud.module
  3. 7.2 vud.module
  4. 7 vud.module

Implements the core voting module on top of Voting API.

File

vud.module
View source
<?php

/**
 * @file
 * Implements the core voting module on top of Voting API.
 */

// Include the theme.inc file.
module_load_include('inc', 'vud', 'vud.theme');

/**
 * Check if the passed user can vote.
 *
 * @param $account
 *  Entity object of an User
 *
 * @return bool
 */
function vud_can_vote($account) {
  return $account
    ->hasPermission('use vote up/down');
}

/**
 * Check if the passed user can reset vote.
 *
 * @param $account
 *  Entity object of an User
 *
 * @return bool
 */
function vud_can_reset_vote($account) {
  return $account
    ->hasPermission("reset vote up/down votes");
}

/**
 * Implements hook_preprocess().
 */
function vud_preprocess(&$variables, $hook) {
  $module_handler = \Drupal::service('module_handler');
  $module_path = $module_handler
    ->getModule('vud')
    ->getPath();
  $variables['#attached']['drupalSettings']['basePath'] = $module_path;
}

/**
 * Implementation of hook_help().
 */
function vud_help($path, $arg) {
  switch ($path) {
    case 'admin.page.vud':
      $output = '<p>' . t('Provides a configurable up/down voting widget for other modules to use.') . '</p>';
      return $output;
    default:
      return FALSE;
      break;
  }
}

Functions

Namesort descending Description
vud_can_reset_vote Check if the passed user can reset vote.
vud_can_vote Check if the passed user can vote.
vud_help Implementation of hook_help().
vud_preprocess Implements hook_preprocess().