123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- <?php
- require_once('api/tripal_natural_diversity.api.inc');
- require_once('includes/tripal_natural_diversity.schema.inc');
- require_once('includes/tripal_natural_diversity.nd_geolocation.inc');
- require_once('includes/tripal_natural_diversity.admin.inc');
- /**
- * @file
- * This file contains the basic functions needed for this drupal module.
- * The drupal tripal_natural_diversity module maps directly to the chado X module.
- *
- * For documentation regarding the Chado X module:
- * @see http://gmod.org/wiki/Chado_General_Module
- *
- * @defgroup tripal_natural_diversity Natural Diversity Module
- * @ingroup tripal_modules
- */
- /*************************************************************************
- * Implements hook_views_api()
- * Purpose: Essentially this hook tells drupal that there is views support for
- * for this module which then includes tripal_natural_diversity.views.inc where all the
- * views integration code is
- *
- * @ingroup tripal_natural_diversity
- */
- function tripal_natural_diversity_views_api() {
- return array(
- 'api' => 2.0,
- );
- }
- /**
- * Implements hook_theme
- *
- * @ingroup tripal_natural_diversity
- */
- function tripal_natural_diversity_theme() {
- return array(
- 'tripal_feature_nd_genotypes' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_feature_nd_genotypes',
- ),
- 'tripal_stock_nd_genotypes' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_stock_nd_genotypes',
- ),
- 'tripal_stock_nd_phenotypes' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_stock_nd_phenotypes',
- ),
- 'tripal_nd_geolocation_base' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_nd_geolocation_base',
- ),
- 'tripal_nd_geolocation_properties' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_nd_geolocation_properties',
- ),
- 'tripal_natural_diversity_admin' => array(
- 'template' => 'tripal_natural_diversity_admin',
- 'arguments' => array(NULL),
- 'path' => drupal_get_path('module', 'tripal_natural_diversity') . '/theme'
- ),
- );
- }
- /**
- * Implements hook_nodeapi().
- *
- * @ingroup tripal_natural_diversity
- */
- function tripal_natural_diversity_nodeapi(&$node, $op, $teaser, $page){
- switch ($op) {
- case 'view':
- if ($node->type == 'chado_feature') {
- // the tripal_genetic module provides a tripal_feature_genotype
- // template. The only difference between them is the addition of
- // natural_diversity information by this module's template. Therefore,
- // if the tripal_genetic content is present get rid of as this
- // module superceeds it.
- if (array_key_exists('tripal_feature_genotypes', $node->content)) {
- unset($node->content['tripal_feature_genotypes']);
- }
- $node->content['tripal_feature_nd_genotypes'] = array(
- '#value' => theme('tripal_feature_nd_genotypes', $node),
- );
- }
- if ($node->type == 'chado_stock') {
- $node->content['tripal_stock_nd_genotypes'] = array(
- '#value' => theme('tripal_stock_nd_genotypes', $node),
- );
- $node->content['tripal_stock_nd_phenotypes'] = array(
- '#value' => theme('tripal_stock_nd_phenotypes', $node),
- );
- }
- break;
- }
- }
- /**
- *
- *
- * @ingroup tripal_natural_diversity
- */
- function tripal_natural_diversity_preprocess_tripal_stock_nd_genotypes(&$variables){
- }
- /**
- * Implements hook_menu
- *
- * @ingroup tripal_natural_diversity
- */
- function tripal_natural_diversity_menu() {
- $items[ 'admin/tripal/tripal_natural_diversity' ]= array(
- 'title' => 'Natural Diversity',
- 'description' => ('A module for interfacing the GMOD chado database with Drupal, providing viewing of natural_diversity data'),
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_natural_diversity_admin'),
- 'access arguments' => array('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM
- );
- $items[ 'admin/tripal/tripal_natural_diversity/configuration' ]= array(
- 'title' => 'Configuration',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_natural_diversity_admin'),
- 'access arguments' => array('administer site configuration'),
- 'type' => MENU_NORMAL_ITEM
- );
- return $items;
- }
- /**
- * Implements hook_perm()
- *
- * This function sets the permission for the user to access the information in the database.
- * This includes creating, inserting, deleting and updating of information in the database
- *
- *
- * @ingroup tripal_natural_diversity
- */
- function tripal_natural_diversity_perm() {
- return array(
- 'access chado_nd_geolocation content',
- 'create chado_nd_geolocation content',
- 'delete chado_nd_geolocation content',
- 'edit chado_nd_geolocation content',
- 'adminster tripal natural_diversity',
- );
- }
- /**
- * Implement hook_access().
- *
- * This hook allows node modules to limit access to the node types they define.
- *
- * @param $op
- * The operation to be performed
- *
- * @param $node
- * The node on which the operation is to be performed, or, if it does not yet exist, the
- * type of node to be created
- *
- * @param $account
- * A user object representing the user for whom the operation is to be performed
- *
- * @return
- * If the permission for the specified operation is not set then return FALSE. If the
- * permission is set then return NULL as this allows other modules to disable
- * access. The only exception is when the $op == 'create'. We will always
- * return TRUE if the permission is set.
- *
- * @ingroup tripal_natural_diversity
- */
- function chado_natural_diversity_access($op, $node, $account) {
- if ($op == 'create') {
- if (!user_access('create chado_nd_geolocation content', $account)) {
- return FALSE;
- }
- return TRUE;
- }
- if ($op == 'update') {
- if (!user_access('edit chado_nd_geolocation content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'delete') {
- if (!user_access('delete chado_nd_geolocation content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'view') {
- if (!user_access('access chado_nd_geolocation content', $account)) {
- return FALSE;
- }
- }
- return NULL;
- }
- /**
- * Implementation of hook_node_info().
- *
- * This node_info, is a simple node that describes the functionallity of the module. It specifies
- * that the title(Project Name) and body(Description) set to true so that they information can be
- * entered
- *
- *
- * @ingroup tripal_natural_diversity
- */
- function tripal_natural_diversity_node_info() {
- return array(
- 'chado_nd_geolocation' => array(
- 'name' => t('ND Geolocation'),
- 'module' => 'chado_nd_geolocation',
- 'description' => t('A module for interfacing the GMOD chado database with Drupal, providing viewing of nd_geolocation'),
- 'has_title' => TRUE,
- 'title_label' => t('ND Geolocation'),
- 'had_body' => FALSE,
- 'body_label' => t('Full Description'),
- )
- );
- }
|