You are here

certificate_test.module in Certificate 8.3

File

modules/certificate_test/certificate_test.module
View source
<?php

/**
 * Implements certificate_map_options().
 */
function certificate_test_certificate_map_options() {
  $chars = drupal_map_assoc(array_merge(range('a', 'z')));
  return array(
    'firstletter' => array(
      'title' => 'Username first letter',
      'description' => "Map by the first letter of the user's name",
      'options' => $chars,
    ),
  );
}

/**
 * Implements certificate_map().
 */
function certificate_test_certificate_map($node, $user, $map_type, $options) {
  if ($map_type == 'firstletter') {
    foreach ($options as $option) {

      // User selected $option
      if (strtolower($user->name[0]) == $option) {

        // User's first letter matched selected options.
        return $option;
      }
    }
  }
}

/**
 * Implements hook_access_certificate().
 *
 * Has user finished this activity?
 */
function certificate_test_access_certificate($node, $user) {
  if ($node->type == 'certificate_activity') {
    if (isset($GLOBALS['certificate_ok']) || isset($_GET['certificate_ok'])) {
      return TRUE;
    }
    else {
      return 'Custom access denied message.';
    }
  }
}

Functions

Namesort descending Description
certificate_test_access_certificate Implements hook_access_certificate().
certificate_test_certificate_map Implements certificate_map().
certificate_test_certificate_map_options Implements certificate_map_options().