You are here

farm_help.module in farmOS 7

Farm help module.

File

modules/farm/farm_help/farm_help.module
View source
<?php

/**
 * @file
 * Farm help module.
 */

/**
 * Implements hook_help().
 */
function farm_help_help($path, $args) {
  switch ($path) {

    // Help for the /farm/help path.
    case 'farm/help':
      return '<p>' . t('This page contains links to helpful farmOS resources. For more information, visit <a href="https://farmOS.org">farmOS.org</a>.') . '</p>';
  }
}

/**
 * Implements hook_permission().
 */
function farm_help_permission() {
  return array(
    'access farm help' => array(
      'title' => t('Access farm help pages'),
      'description' => t('Access the farm help pages.'),
    ),
  );
}

/**
 * Implements hook_farm_access_perms().
 */
function farm_help_farm_access_perms($role) {

  // Access farm help.
  return array(
    'access farm help',
  );
}

/**
 * Implements hook_menu().
 */
function farm_help_menu() {
  $items['farm/help'] = array(
    'title' => 'Help',
    'page callback' => 'farm_help_page_callback',
    'access arguments' => array(
      'access farm help',
    ),
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'user-menu',
    'weight' => 100,
  );
  return $items;
}

/**
 * Farm help page callback.
 */
function farm_help_page_callback() {

  // Set the title so it is different than the menu item.
  drupal_set_title(t('farmOS Resources'));

  // Create output array.
  $output = array();

  // Allow other modules to add output.
  $contrib_output = module_invoke_all('farm_help_page');
  $output = array_merge($output, $contrib_output);

  // Return the output, imploded into a string.
  return implode('', $output);
}

/**
 * Implements hook_farm_help_page().
 */
function farm_help_farm_help_page() {
  $output = array();

  // Add general text.
  $output[] = '<p>' . l('farmOS', 'https://farmos.org') . ' is built and maintained
  by a community of volunteers. Some farmOS community resources are listed
  below.</p>';

  // Add a link to the farmOS documentation.
  $output[] = '<h3>Documentation</h3><p>' . l('https://farmOS.org', 'https://farmOS.org') . '</h3>';

  // Add a link to the farmOS forum.
  $output[] = '<h3>Community Forum</h3><p>' . l('https://farmOS.discourse.group', 'https://farmOS.discourse.group') . '</p>';

  // Add a link to the farmOS chat rooms.
  $chat_rooms = array(
    l('#farmOS Riot.im channel on Matrix.org', 'https://riot.im/app/#/room/#farmOS:matrix.org'),
    l('#farmOS IRC channel on Freenode', 'http://webchat.freenode.net/?channels=#farmOS'),
  );
  $output[] = '<h3>Community Chat</h3><p>' . theme('item_list', array(
    'items' => $chat_rooms,
  )) . '</p>';

  // Add a link to the farmOS distribution issue queue.
  $output[] = '<h3>Issue Queues</h3><p>' . l('https://drupal.org/project/issues/farm', 'https://drupal.org/project/issues/farm') . '</p>';
  return $output;
}