tripal.module 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. <?php
  2. /**
  3. * @file
  4. * The Tripal Core module
  5. */
  6. // Import the full Tripal API into scope.
  7. tripal_import_api();
  8. require_once "includes/tripal.field_storage.inc";
  9. require_once "includes/tripal.fields.inc";
  10. require_once "includes/tripal.entity.inc";
  11. require_once "includes/TripalVocab.inc";
  12. require_once "includes/TripalVocabController.inc";
  13. require_once "includes/TripalVocabViewsController.inc";
  14. require_once "includes/TripalTerm.inc";
  15. require_once "includes/TripalTermController.inc";
  16. require_once "includes/TripalTermViewsController.inc";
  17. require_once "includes/TripalEntity.inc";
  18. require_once "includes/TripalEntityController.inc";
  19. require_once "includes/TripalEntityUIController.inc";
  20. require_once "includes/TripalEntityViewsController.inc";
  21. require_once "includes/TripalBundle.inc";
  22. require_once "includes/TripalBundleController.inc";
  23. require_once "includes/TripalBundleUIController.inc";
  24. require_once "includes/TripalBundleViewsController.inc";
  25. require_once "includes/TripalFields/TripalField.inc";
  26. require_once "includes/TripalFields/TripalFieldWidget.inc";
  27. require_once "includes/TripalFields/TripalFieldFormatter.inc";
  28. require_once "includes/TripalFieldQuery.inc";
  29. /**
  30. * @defgroup tripal Tripal Core Module
  31. * @ingroup tripal_modules
  32. * @{
  33. * Functionality useful for all other Tripal modules including the Tripal jobs, files,
  34. * materialized views and custom table functions.
  35. * @}
  36. */
  37. /**
  38. * Implements hook_views_api().
  39. */
  40. function tripal_views_api() {
  41. return array(
  42. 'api' => 3,
  43. );
  44. }
  45. /**
  46. * Implements hook_init().
  47. *
  48. * @ingroup tripal
  49. */
  50. function tripal_init() {
  51. global $base_url;
  52. // add some variables for all javasript to use for building URLs
  53. $clean_urls = variable_get('clean_url', 0);
  54. $tripal_path = url(drupal_get_path('module', 'tripal'));
  55. drupal_add_js("
  56. var baseurl = '$base_url';
  57. var isClean = $clean_urls;
  58. var tripal_path = '$tripal_path';",
  59. 'inline', 'header');
  60. // make sure the date time settings are the way Tripal will insert them
  61. // otherwise PostgreSQL version that may have a different datestyle setting
  62. // will fail when inserting or updating a date column in a table.
  63. db_query("SET DATESTYLE TO :style", array(':style' => 'MDY'));
  64. }
  65. function tripal_menu_alter(&$items) {
  66. //drupal_debug($items);
  67. }
  68. /**
  69. * Implements hook_menu().
  70. * Defines all menu items needed by Tripal Core
  71. *
  72. * @ingroup tripal
  73. */
  74. function tripal_menu() {
  75. $items = array();
  76. // Tripal setting groups
  77. $items['admin/tripal'] = array(
  78. 'title' => 'Tripal',
  79. 'description' => t("Manage the behavior or Tripal and its various modules."),
  80. 'weight' => -8,
  81. 'page callback' => 'system_admin_menu_block_page',
  82. 'access arguments' => array('administer tripal'),
  83. 'file' => 'system.admin.inc',
  84. 'file path' => drupal_get_path('module', 'system'),
  85. );
  86. $items['admin/tripal/storage'] = array(
  87. 'title' => 'Data Storage',
  88. 'description' => t("Tripal is designed to access biological
  89. data in any data storage back-end. A storage back-end must have a
  90. module that can be installed that interfaces with Tripal. By default
  91. the base Tripal package provides The Tripal Chado module for storing
  92. data in the GMOD Chado database schema. All available storage backends
  93. and their administrative tools are found here."),
  94. 'weight' => 8,
  95. 'access arguments' => array('administer tripal'),
  96. );
  97. $items['admin/tripal/terms'] = array(
  98. 'title' => 'Vocabularies',
  99. 'description' => t("Vocabulary terms are essential to creating content
  100. in Tripal. This allows data to be shared more easily with others
  101. using technologies such as the semantic web and web services.
  102. Before creating content you must have loaded vocabularies and their
  103. terms."),
  104. 'weight' => 8,
  105. 'access arguments' => array('administer tripal'),
  106. );
  107. $items['admin/tripal/dashboard'] = array(
  108. 'title' => 'Dashboard',
  109. 'description' => t("A dashboard view of Tripal including new fields for entities."),
  110. 'weight' => 0,
  111. 'page callback' => 'tripal_admin_usage_page',
  112. 'access arguments' => array('administer tripal'),
  113. 'type' => MENU_NORMAL_ITEM,
  114. 'file' => 'includes/tripal_admin_usage_page.inc',
  115. 'file path' => drupal_get_path('module', 'tripal'),
  116. );
  117. $items['admin/tripal/terms/import'] = array(
  118. 'title' => 'Import Vocabulary',
  119. 'description' => t("Import vocabularies and terms in OBO format."),
  120. 'access arguments' => array('administer tripal'),
  121. 'page callback' => 'drupal_get_form',
  122. 'page arguments' => array('tripal_vocabulary_import_form'),
  123. 'file' => 'includes/tripal.admin.inc',
  124. 'file path' => drupal_get_path('module', 'tripal'),
  125. 'type' => MENU_NORMAL_ITEM,
  126. );
  127. $items['admin/tripal/extension'] = array(
  128. 'title' => 'Extensions',
  129. 'description' => t("Configuration and management pages for Tripal extension modules."),
  130. 'weight' => 8,
  131. 'access arguments' => array('administer tripal'),
  132. );
  133. // Menu items for facilitating import of extension modules.
  134. $items['admin/tripal/extension/available'] = array(
  135. 'title' => 'Available Extensions',
  136. 'description' => t('Look for extensions to add new functionality to this
  137. site. Tripal can be extended with new functionality developed
  138. by other Tripal site developers. These include modules with new or
  139. different functionality, bulk loading templates, or materialized
  140. views. Anyone can create new extensions and share those for
  141. others to use. Once shared they will appear in this list.'),
  142. 'access arguments' => array('administer tripal'),
  143. 'page callback' => 'drupal_get_form',
  144. 'page arguments' => array('tripal_extensions_form'),
  145. 'type' => MENU_NORMAL_ITEM,
  146. 'file' => 'includes/tripal.extensions.inc',
  147. 'file path' => drupal_get_path('module', 'tripal'),
  148. 'weight' => -100
  149. );
  150. // $items['admin/tripal/extension/import'] = array(
  151. // 'title' => 'Import Extensions',
  152. // 'description' => 'Provides a list of the available extensions that are registered at the tripal.info site. From this page you can easily import or install extensions to your site.',
  153. // 'page callback' => 'drupal_get_form',
  154. // 'page arguments' => array('tripal_extensions_form'),
  155. // 'access arguments' => array('administer tripal'),
  156. // 'type' => MENU_NORMAL_ITEM,
  157. // 'file' => 'includes/tripal.extensions.inc',
  158. // 'file path' => drupal_get_path('module', 'tripal'),
  159. // 'weight' => -100,
  160. // );
  161. // Jobs Management
  162. $items['admin/tripal/tripal_jobs'] = array(
  163. 'title' => 'Jobs',
  164. 'description' => t('Provides tools for managing jobs submitted to Tripal. In some
  165. cases, long-running tasks are too slow to complete within a single
  166. browser session. The Tripal jobs system allows long-running tasks
  167. to be submitted to a queue that can be executed manually by the
  168. site admin or automatically using a module such as the ') .
  169. l('Tripal Daemon', 'https://www.drupal.org/project/tripal_daemon', array('attributes' => array('target' => '_blank'))) .
  170. ' extension module.',
  171. 'page callback' => 'tripal_jobs_admin_view',
  172. 'access arguments' => array('administer tripal'),
  173. 'type' => MENU_NORMAL_ITEM,
  174. 'weight' => 0,
  175. 'file' => 'includes/tripal.jobs.inc',
  176. );
  177. $items['admin/tripal/tripal_jobs/help'] = array(
  178. 'title' => 'Help',
  179. 'description' => t('Help for the tripal job management system'),
  180. 'page callback' => 'theme',
  181. 'page arguments' => array('tripal_job_help'),
  182. 'access arguments' => array('administer tripal'),
  183. 'type' => MENU_LOCAL_TASK,
  184. 'weight' => 10
  185. );
  186. $items['admin/tripal/tripal_jobs/cancel/%'] = array(
  187. 'title' => 'Jobs',
  188. 'description' => t('Cancel a pending job'),
  189. 'page callback' => 'tripal_cancel_job',
  190. 'page arguments' => array(4),
  191. 'access arguments' => array('administer tripal'),
  192. 'type' => MENU_CALLBACK,
  193. 'file' => 'api/tripal.jobs.api.inc',
  194. );
  195. $items['admin/tripal/tripal_jobs/status/%'] = array(
  196. 'page callback' => 'tripal_jobs_status_view',
  197. 'page arguments' => array(4),
  198. 'access arguments' => array('administer tripal'),
  199. 'type' => MENU_CALLBACK,
  200. 'file' => 'includes/tripal.jobs.inc',
  201. );
  202. $items['admin/tripal/tripal_jobs/rerun/%'] = array(
  203. 'title' => 'Jobs',
  204. 'description' => t('Re-run an existing job.'),
  205. 'page callback' => 'tripal_rerun_job',
  206. 'page arguments' => array(4),
  207. 'access arguments' => array('administer tripal'),
  208. 'type' => MENU_CALLBACK,
  209. 'file' => 'includes/tripal.jobs.inc',
  210. );
  211. $items['admin/tripal/tripal_jobs/view/%'] = array(
  212. 'title' => 'Jobs Details',
  213. 'description' => t('View job details.'),
  214. 'page callback' => 'tripal_jobs_view',
  215. 'page arguments' => array(4),
  216. 'access arguments' => array('administer tripal'),
  217. 'type' => MENU_CALLBACK,
  218. 'file' => 'includes/tripal.jobs.inc',
  219. );
  220. $items['admin/tripal/tripal_jobs/views/jobs/enable'] = array(
  221. 'title' => 'Enable Jobs Administrative View',
  222. 'page callback' => 'tripal_enable_view',
  223. 'page arguments' => array('tripal_admin_jobs', 'admin/tripal/tripal_jobs'),
  224. 'access arguments' => array('administer tripal'),
  225. 'type' => MENU_CALLBACK,
  226. 'file' => 'includes/tripal.jobs.inc',
  227. );
  228. /*
  229. * AJAX Callbacks.
  230. */
  231. $items['bio_data/ajax/field_attach/%'] = array(
  232. 'page callback' => 'tripal_ajax_attach_field',
  233. 'page arguments' => array(3),
  234. 'access arguments' => array('access content'),
  235. 'type' => MENU_CALLBACK,
  236. 'file' => 'includes/tripal.entity.inc',
  237. 'file path' => drupal_get_path('module', 'tripal'),
  238. );
  239. /*
  240. * Dashboard Action Item callbacks.
  241. */
  242. $items['admin/disable/notification/%'] = array(
  243. 'page callback' => 'tripal_disable_admin_notification',
  244. 'page arguments' => array(3),
  245. 'access arguments' => array('access content'),
  246. 'type' => MENU_CALLBACK,
  247. 'file' => 'includes/tripal_admin_usage_page.inc',
  248. 'file path' => drupal_get_path('module', 'tripal'),
  249. );
  250. $items['admin/import/field/%/%'] = array(
  251. 'page callback' => 'tripal_admin_notification_import_field',
  252. 'page arguments' => array(3, 4),
  253. 'access arguments' => array('access content'),
  254. 'type' => MENU_CALLBACK,
  255. 'file' => 'includes/tripal_admin_usage_page.inc',
  256. 'file path' => drupal_get_path('module', 'tripal'),
  257. );
  258. /*
  259. * Term Lookup
  260. */
  261. // TODO: finish this menu callback.
  262. // $items['cv/lookup'] = array(
  263. // 'title' => 'Vocabulary Lookup',
  264. // 'description' => t("Provides a tool to discover controlled vocabularies and their terms used by this site."),
  265. // 'access arguments' => array('access content'),
  266. // 'page callback' => 'drupal_get_form',
  267. // 'page arguments' => array('tripal_vocabulary_lookup_form'),
  268. // 'file' => 'includes/tripal.term_lookup.inc',
  269. // 'file path' => drupal_get_path('module', 'tripal'),
  270. // 'type' => MENU_NORMAL_ITEM,
  271. // );
  272. $items['cv/lookup/%/%'] = array(
  273. 'title' => 'Vocabulary Lookup',
  274. 'description' => t("Provides a tool to discover controlled vocabularies and their terms used by this site."),
  275. 'access arguments' => array('access content'),
  276. 'page callback' => 'tripal_vocabulary_lookup_term_page',
  277. 'page arguments' => array(2, 3),
  278. 'file' => 'includes/tripal.term_lookup.inc',
  279. 'file path' => drupal_get_path('module', 'tripal'),
  280. 'type' => MENU_CALLBACK,
  281. );
  282. // Adds a +Check for new fields link on the 'Tripal Content Types' page.
  283. $items['admin/structure/bio_data/manage/%/fields/check'] = array(
  284. 'title' => 'Check for new fields',
  285. 'description' => t('Check if new fields should be added to this content type.'),
  286. 'page callback' => 'tripal_check_new_fields',
  287. 'page arguments' => array(4),
  288. 'access arguments' => array('administer tripal'),
  289. 'file' => 'api/tripal.entities.api.inc',
  290. 'file path' => drupal_get_path('module', 'tripal'),
  291. 'type' => MENU_LOCAL_ACTION,
  292. );
  293. $items['tripal/upload'] = array(
  294. 'page callback' => 'tripal_file_upload',
  295. 'access arguments' => array('upload files'),
  296. 'file' => '/includes/tripal.upload.inc',
  297. 'type' => MENU_CALLBACK,
  298. );
  299. return $items;
  300. }
  301. /**
  302. * Implements hook_permission().
  303. */
  304. function tripal_permission() {
  305. $permissions = array(
  306. 'administer tripal' => array(
  307. 'title' => t('Administer Tripal'),
  308. 'description' => t('Allow the user to access administrative pages of Tripal. This includes management of jobs, the storage systems, extensions and the controlled vocabularies.'),
  309. 'restrict access' => TRUE,
  310. ),
  311. 'access tripal content overview' => array(
  312. 'title' => t('Access the Tripal content overview page'),
  313. 'description' => t('Get an overview of all Tripal content'),
  314. 'restrict access' => TRUE,
  315. ),
  316. 'manage tripal content types' => array(
  317. 'title' => t('Manage Tripal content types'),
  318. 'description' => t('Allows the user to create, update and delete Tripal content types.'),
  319. 'restrict access' => TRUE,
  320. ),
  321. 'view dev helps' => array(
  322. 'title' => t('View Developer Hints'),
  323. 'description' => t('Tripal will provide blue shaded boxes that provide
  324. instructions for how to customize or setup specific pages on a
  325. site. This permission should be enabled for developers. But can
  326. be disabled once developers are accustomed to these hints.'),
  327. 'restrict access' => TRUE,
  328. ),
  329. );
  330. // Add permissions for each content type.
  331. $bundles = tripal_get_content_types();
  332. foreach ($bundles as $bundle) {
  333. $permissions['view ' . $bundle->name] = array(
  334. 'title' => t('%label: View Content', array('%label' => $bundle->label)),
  335. 'description' => t('Allow the user to view %label content', array('%label' => $bundle->label)),
  336. );
  337. $permissions['create ' . $bundle->name] = array(
  338. 'title' => t('%label: Create Content', array('%label' => $bundle->label)),
  339. 'description' => t('Allow the user to create %label content', array('%label' => $bundle->label)),
  340. 'restrict access' => TRUE,
  341. );
  342. $permissions['edit ' . $bundle->name] = array(
  343. 'title' => t('%label: Edit Content', array('%label' => $bundle->label)),
  344. 'description' => t('Allow the user to edit %label content', array('%label' => $bundle->label)),
  345. 'restrict access' => TRUE,
  346. );
  347. $permissions['delete ' . $bundle->name] = array(
  348. 'title' => t('%label: Delete Content', array('%label' => $bundle->label)),
  349. 'description' => t('Allow the user to delete %label content', array('%label' => $bundle->label)),
  350. 'restrict access' => TRUE,
  351. );
  352. }
  353. return $permissions;
  354. }
  355. /**
  356. * Implements hook_theme().
  357. * Registers template files/functions used by this module.
  358. *
  359. * @ingroup tripal
  360. */
  361. function tripal_theme($existing, $type, $theme, $path) {
  362. $themes = array(
  363. // Admin messages theme
  364. 'tripal_admin_message' => array(
  365. 'function' => 'theme_tripal_admin_message',
  366. 'variables' => array('message' => NULL),
  367. ),
  368. 'tripal_entity' => array(
  369. 'render element' => 'elements',
  370. 'template' => 'tripal_entity',
  371. 'path' => "$path/theme/templates"
  372. ),
  373. 'tripal_add_list' => array(
  374. 'variables' => array('content' => NULL),
  375. ),
  376. // Themeing for all fields.
  377. 'tripal_field_default' => array(
  378. 'render element' => 'element',
  379. 'file' => 'includes/tripal.fields.inc',
  380. ),
  381. );
  382. return $themes;
  383. }
  384. /**
  385. * Implements hook_coder_ignore().
  386. * Defines the path to the file (tripal.coder_ignores.txt) where ignore rules for coder are stored
  387. */
  388. function tripal_coder_ignore() {
  389. return array(
  390. 'path' => drupal_get_path('module', 'tripal'),
  391. 'line prefix' => drupal_get_path('module', 'tripal'),
  392. );
  393. }
  394. /**
  395. * Implements hook_libraries_info().
  396. */
  397. function tripal_libraries_info() {
  398. $libraries = array();
  399. $libraries['d3'] = array(
  400. 'name' => 'D3.js',
  401. 'vendor url' => 'http://d3js.org/',
  402. 'download url' => 'https://github.com/mbostock/d3',
  403. 'version arguments' => array(
  404. 'file' => 'd3.js',
  405. 'pattern' => '/\s*version: "(\d+\.\d+\.\d+)"/',
  406. ),
  407. 'files' => array(
  408. 'js' => array(
  409. 'd3.min.js',
  410. ),
  411. ),
  412. );
  413. return $libraries;
  414. }
  415. /**
  416. * Implements hook_admin_paths().
  417. * Define administrative paths.
  418. */
  419. function tripal_admin_paths() {
  420. if (variable_get('node_admin_theme')) {
  421. $paths = array(
  422. 'bio_data/*/edit' => TRUE,
  423. 'bio_data/*/delete' => TRUE,
  424. 'bio_data/add' => TRUE,
  425. 'bio_data/add/*' => TRUE,
  426. );
  427. return $paths;
  428. }
  429. }
  430. /**
  431. * Implements hook_menu_local_tasks_alter().
  432. *
  433. * Used to add action links to pages.
  434. */
  435. function tripal_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  436. // Add an "Add Tripal Content" action link to the Admin >> Content >>
  437. // Biological Content page.
  438. if ($root_path == 'admin/content/bio_data') {
  439. $item = menu_get_item('bio_data/add');
  440. if ($item['access']) {
  441. $data['actions']['output'][] = array(
  442. '#theme' => 'menu_local_action',
  443. '#link' => $item,
  444. );
  445. }
  446. }
  447. }
  448. /**
  449. * Implements hook_shortcut_default_set().
  450. * Modify the shortcut menu to include Biological content links.
  451. *
  452. * @param object $account
  453. * The user account whose default shortcut set will be returned. If not provided, the
  454. * function will return the currently logged-in user's default shortcut set.
  455. *
  456. * @return
  457. * An object representing the default shortcut set.
  458. */
  459. function tripal_shortcut_default_set($account) {
  460. $sets = shortcut_sets();
  461. $found = FALSE;
  462. foreach ($sets as $set) {
  463. if ($set->title == 'TripalDefault') {
  464. $found = TRUE;
  465. }
  466. }
  467. if (!$found) {
  468. $t = get_t();
  469. // Create an initial default shortcut set.
  470. $shortcut_set = new stdClass();
  471. $shortcut_set->title = $t('TripalDefault');
  472. $shortcut_set->links = array(
  473. array(
  474. 'link_path' => 'node/add',
  475. 'link_title' => $t('Add content'),
  476. 'weight' => -35,
  477. ),
  478. array(
  479. 'link_path' => 'bio_data/add',
  480. 'link_title' => 'Add Tripal Content',
  481. 'weight' => -30,
  482. ),
  483. array(
  484. 'link_path' => 'admin/content',
  485. 'link_title' => $t('Find content'),
  486. 'weight' => -25,
  487. ),
  488. array(
  489. 'link_path' => 'admin/content/bio_data',
  490. 'link_title' => 'Find Tripal Content',
  491. 'weight' => -20,
  492. ),
  493. );
  494. shortcut_set_save($shortcut_set);
  495. }
  496. $sets = shortcut_sets();
  497. foreach ($sets as $set) {
  498. if ($set->title == 'TripalDefault') {
  499. return $set->set_name;
  500. }
  501. }
  502. }
  503. /**
  504. * Menu argument loader; Load a tripal data type by string.
  505. *
  506. * This function is not meant to be used as an API function. It is only meant
  507. * for use in the menu to resolve the %tripal_bundle wildcard.
  508. *
  509. * @param $type
  510. * The machine-readable name of a tripal data type to load.
  511. * @return
  512. * A tripal data type array or FALSE if $type does not exist.
  513. */
  514. function TripalBundle_load($bundle_type, $reset = FALSE) {
  515. // Get the type of entity by the ID.
  516. $bundle = db_select('tripal_bundle', 'tdt')
  517. ->fields('tdt')
  518. ->condition('name', $bundle_type)
  519. ->execute()
  520. ->fetchObject();
  521. if ($bundle) {
  522. $entity = entity_load('TripalBundle', array($bundle->id), array(), $reset);
  523. return reset($entity);
  524. }
  525. return FALSE;
  526. }
  527. /**
  528. * Allows the menu system to use a wildcard to fetch the entity.
  529. *
  530. * Make sure that the wildcard you choose in the tripal_entity entity
  531. * definition fits the function name here.
  532. *
  533. * This function is not meant to be used as an API function. It is only meant
  534. * for use in the menu to resolve the %tripal_entity wildcard.
  535. *
  536. * @param $id
  537. * Integer specifying the tripal_entity id.
  538. * @param $reset
  539. * A boolean indicating that the internal cache should be reset.
  540. * @return
  541. * A fully-loaded $tripal_entity object or FALSE if it cannot be loaded.
  542. *
  543. * @see tripal_entity_load_multiple()
  544. */
  545. function TripalEntity_load($id, $reset = FALSE) {
  546. // $entity = entity_load('TripalEntity', array($id), array(), $reset);
  547. $entity = tripal_load_entity('TripalEntity', array($id), $reset);
  548. return reset($entity);
  549. }
  550. /**
  551. * Imports all of the Tripal API into scope.
  552. *
  553. * Typically this function call is not necessary as all of the API is
  554. * automaticaly included by the tripal module. However this function can
  555. * be useful in the .install files during a site upgrade when the tripal
  556. * module is not enabld.
  557. *
  558. * Example usage:
  559. * @code
  560. * module_load_include('module', 'tripal', 'tripal');
  561. * tripal_import_api();
  562. * @endcode
  563. *
  564. */
  565. function tripal_import_api() {
  566. module_load_include('inc', 'tripal', 'api/tripal.d3js.api');
  567. module_load_include('inc', 'tripal', 'api/tripal.fields.api');
  568. module_load_include('inc', 'tripal', 'api/tripal.terms.api');
  569. module_load_include('inc', 'tripal', 'api/tripal.entities.api');
  570. module_load_include('inc', 'tripal', 'api/tripal.files.api');
  571. module_load_include('inc', 'tripal', 'api/tripal.jobs.api');
  572. module_load_include('inc', 'tripal', 'api/tripal.notice.api');
  573. module_load_include('inc', 'tripal', 'api/tripal.variables.api');
  574. module_load_include('inc', 'tripal', 'api/tripal.DEPRECATED.api');
  575. }
  576. /**
  577. * Implements hook_form_alter().
  578. */
  579. function tripal_form_alter(&$form, $form_state, $form_id) {
  580. // If this is the field_ui_field_edit_form (i.e. the form that appears
  581. // when editing a field that is attached to an entity). Then we want
  582. // to add term settings for any field attached to a TripalEntity
  583. // content type.
  584. if ($form_id == 'field_ui_field_edit_form' and $form['#instance']['entity_type'] == 'TripalEntity') {
  585. tripal_field_instance_settings_form_alter($form, $form_state);
  586. }
  587. }
  588. function tripal_check_new_fields($bundle_name) {
  589. tripal_refresh_bundle_fields($bundle_name);
  590. drupal_goto("admin/structure/bio_data/manage/$bundle_name/fields");
  591. }