123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- <?php
- require('api/tripal_featuremap.api.inc');
- require('includes/tripal_featuremap.admin.inc');
- function tripal_featuremap_help($path, $arg) {
- $output = '';
- switch ($path) {
- case "admin/help#tripal_featuremap":
- $output = '<p>'.
- t("Displays links to nodes created on this date") .
- '</p>';
- break;
- }
- return $output;
- }
- function tripal_featuremap_node_info() {
- $nodes = array();
- $nodes['chado_featuremap'] = array(
- 'name' => t('Map'),
- 'module' => 'chado_featuremap',
- 'description' => t('A feature map from the chado database (e.g. genetic map)'),
- 'has_title' => FALSE,
- 'title_label' => t('Feature Map'),
- 'has_body' => FALSE,
- 'body_label' => t('Feature Map Description'),
- 'locked' => TRUE
- );
- return $nodes;
- }
- function tripal_featuremap_perm() {
- return array(
- 'access chado_featuremap content',
- 'create chado_featuremap content',
- 'delete chado_featuremap content',
- 'edit chado_featuremap content',
- 'administer tripal featuremap',
- );
- }
- function chado_featuremap_access($op, $node, $account) {
- if ($op == 'create') {
- if (!user_access('create chado_featuremap content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'update') {
- if (!user_access('edit chado_featuremap content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'delete') {
- if (!user_access('delete chado_featuremap content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'view') {
- if (!user_access('access chado_featuremap content', $account)) {
- return FALSE;
- }
- }
- return NULL;
- }
- function tripal_featuremap_menu() {
- $items = array();
-
-
- $items['admin/tripal/tripal_featuremap'] = array(
- 'title' => 'Maps',
- 'description' => 'Basic Description of Tripal Map Module Functionality',
- 'page callback' => 'theme',
- 'page arguments' => array('tripal_featuremap_admin'),
- 'access arguments' => array('administer tripal featuremap'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/tripal_featuremap/configuration'] = array(
- 'title' => 'Configuration',
- 'description' => 'Manage integration of Chado maps including associated features.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('tripal_featuremap_admin'),
- 'access arguments' => array('administer tripal featuremap'),
- 'type' => MENU_NORMAL_ITEM,
- );
-
- $items['chado_sync_featuremaps'] = array(
- 'title' => 'Sync Data',
- 'page callback' => 'tripal_featuremap_sync_featuremaps',
- 'access arguments' => array('administer tripal featuremap'),
- 'type' => MENU_CALLBACK
- );
-
- return $items;
- }
- function tripal_featuremap_views_api() {
- return array(
- 'api' => 2.0,
- );
- }
- function tripal_featuremap_nodeapi(&$node, $op, $teaser, $page) {
- switch ($op) {
-
-
- case 'view':
-
- if ($node->build_mode == NODE_BUILD_SEARCH_INDEX) {
- $node->content['tripal_featuremap_index_version'] = array(
- '#value' => theme('tripal_featuremap_search_index', $node),
- );
- }
- elseif ($node->build_mode == NODE_BUILD_SEARCH_RESULT) {
- $node->content['tripal_featuremap_index_version'] = array(
- '#value' => theme('tripal_featuremap_search_result', $node),
- );
- }
- }
- }
- function tripal_featuremap_theme() {
- return array(
- 'tripal_featuremap_search_index' => array(
- 'arguments' => array('node'),
- ),
- 'tripal_featuremap_search_result' => array(
- 'arguments' => array('node'),
- ),
- 'tripal_featuremap_base' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_featuremap_base',
- ),
- 'tripal_featuremap_properties' => array(
- 'arguments' => array('node' => NULL),
- 'template' => 'tripal_featuremap_properties',
- ),
- 'tripal_featuremap_admin' => array(
- 'template' => 'tripal_featuremap_admin',
- 'arguments' => array(NULL),
- 'path' => drupal_get_path('module', 'tripal_featuremap') . '/theme'
- ),
- );
- }
- function theme_tripal_featuremap_search_index($node) {
- }
- function tripal_featuremap_cron() {
- }
- function tripal_featuremap_map_access($op, $node, $account) {
- if ($op == 'create') {
- if (!user_access('create chado_featuremap content', $account)) {
- return FALSE;
- }
- }
- if ($op == 'update') {
- if (!user_access('edit any chado_featuremap content', $account) &&
- !user_access('edit own chado_featuremap content', $account)) {
- return FALSE;
- }
- if (user_access('edit own chado_featuremap content', $account) &&
- $account->uid != $node->uid) {
- return FALSE;
- }
- }
- if ($op == 'delete') {
- if (!user_access('delete any chado_featuremap content', $account) &&
- !user_access('delete own chado_featuremap content', $account)) {
- return FALSE;
- }
- if (user_access('delete own chado_featuremap content', $account) &&
- $account->uid != $node->uid) {
- return FALSE;
- }
- }
- return NULL;
- }
- function chado_featuremap_form($node) {
- $type = node_get_types('type', $node);
- $form = array();
- $featuremap = $node->featuremap;
-
-
- $form['featuremap_id'] = array(
- '#type' => 'value',
- '#value' => $featuremap->featuremap_id,
- );
- $form['title']= array(
- '#type' => 'textfield',
- '#title' => t('Map Name'),
- '#description' => t('Please enter a name for this map'),
- '#required' => TRUE,
- '#default_value' => $featuremap->name,
- );
- $form['description']= array(
- '#type' => 'textarea',
- '#title' => t('Map Description'),
- '#description' => t('A description of the map.'),
- '#required' => TRUE,
- '#default_value' => $featuremap->description,
- );
-
-
- $values = array(
- 'cv_id' => array(
- 'name' => 'tripal_featuremap',
- )
- );
- $columns = array('cvterm_id','name');
- $options = array('order_by' => array('name' => 'ASC'));
- $featuremap_units = tripal_core_chado_select('cvterm', $columns, $values, $options);
- $units = array();
- $units[''] = '';
- foreach($featuremap_units as $unit) {
- $units[$unit->cvterm_id] = $unit->name;
- }
- $form['unittype_id'] = array(
- '#title' => t('Map Units'),
- '#type' => t('select'),
- '#description' => t("Chose the units for this map"),
- '#required' => TRUE,
- '#default_value' => $featuremap->unittype_id->cvterm_id,
- '#options' => $units,
- );
- return $form;
- }
- function chado_featuremap_validate($node) {
- $map = 0;
-
-
-
-
-
- if ($node->featuremap_id) {
- $sql = "SELECT * FROM ".
- "{featuremap} WHERE ".
- "name = '%s' ".
- "AND NOT featuremap_id = %d";
- $map = db_fetch_object(chado_query($sql, $node->title, $node->featuremap_id));
- }
- else {
- $sql = "SELECT * FROM ".
- "{featuremap} ".
- "WHERE name = '%s'";
- $map = db_fetch_object(chado_query($sql, $node->title));
- }
- if ($map) {
- form_set_error('name', t('The unique map name already exists. Please choose another'));
- }
- }
- function chado_featuremap_insert($node) {
- if ($node->featuremap_id) {
- $featuremap['featuremap_id'] = $node->featuremap_id;
- }
- else {
- $values = array(
- 'name' => $node->title,
- 'description' => $node->description,
- 'unittype_id' => $node->unittype_id
- );
- $featuremap = tripal_core_chado_insert('featuremap', $values);
- }
- if ($featuremap) {
-
-
- $featuremap_id = chado_get_id_for_node('featuremap', $node) ;
- if (!$featuremap_id) {
-
- $sql = "INSERT INTO {chado_featuremap} (nid, vid, featuremap_id) ".
- "VALUES (%d, %d, %d)";
- db_query($sql, $node->nid, $node->vid, $featuremap['featuremap_id']);
- }
- }
- else {
- drupal_set_message(t('Unable to add featuremap.', 'warning'));
- watchdog('tripal_featuremap',
- 'Insert feature: Unable to create featuremap where values: %values',
- array('%values' => print_r($values, TRUE)),
- WATCHDOG_WARNING
- );
- }
- }
- function chado_featuremap_update($node) {
- if ($node->revision) {
-
-
- }
- $featuremap_id = chado_get_id_for_node('featuremap', $node) ;
-
- $match = array(
- 'featuremap_id' => $featuremap_id,
- );
- $values = array(
- 'name' => $node->title,
- 'unittype_id' => $node->unittype_id
- );
- $status = tripal_core_chado_update('featuremap', $match, $values);
- }
- function chado_featuremap_load($node) {
-
- $featuremap_id = chado_get_id_for_node('featuremap', $node);
- $values = array('featuremap_id' => $featuremap_id);
- $featuremap = tripal_core_generate_chado_var('featuremap', $values);
- $additions = new stdClass();
- $additions->featuremap = $featuremap;
- return $additions;
- }
- function chado_featuremap_view($node, $teaser = FALSE, $page = FALSE) {
-
- if (!$teaser) {
- $node = node_prepare($node, $teaser);
- }
- return $node;
- }
- function chado_featuremap_delete(&$node) {
- $featuremap_id = chado_get_id_for_node('featuremap', $node);
-
-
-
- if (!$featuremap_id) {
- return;
- }
-
-
-
- $sql_del = "DELETE FROM {chado_featuremap} ".
- "WHERE nid = %d ".
- "AND vid = %d";
- db_query($sql_del, $node->nid, $node->vid);
- $sql_del = "DELETE FROM {node} ".
- "WHERE nid = %d ".
- "AND vid = %d";
- db_query($sql_del, $node->nid, $node->vid);
- $sql_del = "DELETE FROM {node_revisions} ".
- "WHERE nid = %d ".
- "AND vid = %d";
- db_query($sql_del, $node->nid, $node->vid);
-
- chado_query("DELETE FROM {featuremap} WHERE featuremap_id = %d", $featuremap_id);
- chado_query("DELETE FROM {featuremapprop} WHERE featuremap_id = %d", $featuremap_id);
- }
- function theme_tripal_featuremap_search_result($node) {
- }
|