tripal_library.module

  1. 2.x tripal_library/tripal_library.module
  2. 3.x legacy/tripal_library/tripal_library.module
  3. 1.x tripal_library/tripal_library.module

File

tripal_library/tripal_library.module
View source
  1. <?php
  2. /**
  3. * @defgroup tripal_library Library Module
  4. * @ingroup tripal_modules
  5. * @{
  6. * Provides functions for managing chado libraries including creating details pages for each library
  7. * @}
  8. */
  9. require('api/tripal_library.api.inc');
  10. require('includes/tripal_library.admin.inc');
  11. /**
  12. * Display help and module information
  13. * @param path which path of the site we're displaying help
  14. * @param arg array that holds the current path as would be returned from arg()
  15. * function
  16. * @return help text for the path
  17. *
  18. * @ingroup tripal_library
  19. */
  20. function tripal_library_help($path, $arg) {
  21. $output = '';
  22. switch ($path) {
  23. case "admin/help#tripal_library":
  24. $output = '<p>'.
  25. t("Displays links to nodes created on this date") .
  26. '</p>';
  27. break;
  28. }
  29. return $output;
  30. }
  31. /**
  32. * Provide information to drupal about the node types that we're creating
  33. * in this module
  34. *
  35. * @ingroup tripal_library
  36. */
  37. function tripal_library_node_info() {
  38. $nodes = array();
  39. $nodes['chado_library'] = array(
  40. 'name' => t('Library'),
  41. 'module' => 'chado_library',
  42. 'description' => t('A library from the chado database'),
  43. 'has_title' => FALSE,
  44. 'title_label' => t('Library'),
  45. 'has_body' => FALSE,
  46. 'body_label' => t('Library Description'),
  47. 'locked' => TRUE
  48. );
  49. return $nodes;
  50. }
  51. /**
  52. * Set the permission types that the chado module uses. Essentially we
  53. * want permissionis that protect creation, editing and deleting of chado
  54. * data objects
  55. *
  56. * @ingroup tripal_library
  57. */
  58. function tripal_library_perm() {
  59. return array(
  60. 'access chado_library content',
  61. 'create chado_library content',
  62. 'delete chado_library content',
  63. 'edit chado_library content',
  64. 'administer tripal libraries',
  65. );
  66. }
  67. /**
  68. * Implement hook_access().
  69. *
  70. * This hook allows node modules to limit access to the node types they define.
  71. *
  72. * @param $op
  73. * The operation to be performed
  74. *
  75. * @param $node
  76. * The node on which the operation is to be performed, or, if it does not yet exist, the
  77. * type of node to be created
  78. *
  79. * @param $account
  80. * A user object representing the user for whom the operation is to be performed
  81. *
  82. * @return
  83. * If the permission for the specified operation is not set then return FALSE. If the
  84. * permission is set then return NULL as this allows other modules to disable
  85. * access. The only exception is when the $op == 'create'. We will always
  86. * return TRUE if the permission is set.
  87. *
  88. * @ingroup tripal_library
  89. */
  90. function chado_library_access($op, $node, $account) {
  91. if ($op == 'create') {
  92. if (!user_access('create chado_library content', $account)) {
  93. return FALSE;
  94. }
  95. return TRUE;
  96. }
  97. if ($op == 'update') {
  98. if (!user_access('edit chado_library content', $account)) {
  99. return FALSE;
  100. }
  101. }
  102. if ($op == 'delete') {
  103. if (!user_access('delete chado_library content', $account)) {
  104. return FALSE;
  105. }
  106. }
  107. if ($op == 'view') {
  108. if (!user_access('access chado_library content', $account)) {
  109. return FALSE;
  110. }
  111. }
  112. return NULL;
  113. }
  114. /**
  115. * Menu items are automatically added for the new node types created
  116. * by this module to the 'Create Content' Navigation menu item. This function
  117. * adds more menu items needed for this module.
  118. *
  119. * @ingroup tripal_library
  120. */
  121. function tripal_library_menu() {
  122. $items = array();
  123. // The administative settings menu
  124. $items['admin/tripal/tripal_library'] = array(
  125. 'title' => 'Libraries',
  126. 'description' => 'Basic Description of Tripal Library Module Functionality',
  127. 'page callback' => 'theme',
  128. 'page arguments' => array('tripal_library_admin'),
  129. 'access arguments' => array('administer tripal libraries'),
  130. 'type' => MENU_NORMAL_ITEM,
  131. );
  132. $items['admin/tripal/tripal_library/configuration'] = array(
  133. 'title' => 'Configuration',
  134. 'description' => 'Configure the Tripal Library module',
  135. 'page callback' => 'drupal_get_form',
  136. 'page arguments' => array('tripal_library_admin'),
  137. 'access arguments' => array('administer tripal libraries'),
  138. 'type' => MENU_NORMAL_ITEM,
  139. );
  140. // Synchronizing libraries from Chado to Drupal
  141. $items['chado_sync_libraries'] = array(
  142. 'title' => 'Sync Library Data',
  143. 'page callback' => 'tripal_library_sync_libraries',
  144. 'access arguments' => array('administer tripal libraries'),
  145. 'type' => MENU_CALLBACK
  146. );
  147. return $items;
  148. }
  149. /**
  150. * Implements hook_views_api()
  151. * Purpose: Essentially this hook tells drupal that there is views support for
  152. * for this module which then includes tripal_db.views.inc where all the
  153. * views integration code is
  154. *
  155. * @ingroup tripal_library
  156. */
  157. function tripal_library_views_api() {
  158. return array(
  159. 'api' => 2.0,
  160. );
  161. }
  162. /**
  163. * Implementation of hook_nodeapi().
  164. * Display library information for associated features or organisms
  165. * This function also provides contents for indexing
  166. *
  167. * @ingroup tripal_library
  168. */
  169. function tripal_library_nodeapi(&$node, $op, $teaser, $page) {
  170. switch ($op) {
  171. // Note that this function only adds library view to an organism/feature
  172. // node.
  173. case 'view':
  174. // add the library to the organism/feature search indexing
  175. if ($node->build_mode == NODE_BUILD_SEARCH_INDEX) {
  176. $node->content['tripal_library_index_version'] = array(
  177. '#value' => theme('tripal_library_search_index', $node),
  178. );
  179. }
  180. elseif ($node->build_mode == NODE_BUILD_SEARCH_RESULT) {
  181. $node->content['tripal_library_index_version'] = array(
  182. '#value' => theme('tripal_library_search_result', $node),
  183. );
  184. }
  185. else {
  186. switch ($node->type) {
  187. case 'chado_organism':
  188. // Show library if the organism/feature is not at teaser view
  189. $node->content['tripal_organism_libraries'] = array(
  190. '#value' => theme('tripal_organism_libraries', $node),
  191. );
  192. break;
  193. case 'chado_feature':
  194. // Show library if the organism/feature is not at teaser view
  195. $node->content['tripal_feature_libraries'] = array(
  196. '#value' => theme('tripal_feature_libraries', $node),
  197. );
  198. break;
  199. }
  200. }
  201. break;
  202. }
  203. }
  204. /**
  205. * We need to let drupal know about our theme functions and their arguments.
  206. * We create theme functions to allow users of the module to customize the
  207. * look and feel of the output generated in this module
  208. *
  209. * @ingroup tripal_library
  210. */
  211. function tripal_library_theme() {
  212. return array(
  213. 'tripal_library_library_table' => array(
  214. 'arguments' => array('libraries'),
  215. ),
  216. 'tripal_library_search_index' => array(
  217. 'arguments' => array('node'),
  218. ),
  219. 'tripal_library_search_result' => array(
  220. 'arguments' => array('node'),
  221. ),
  222. 'tripal_organism_libraries' => array(
  223. 'arguments' => array('node' => NULL),
  224. 'template' => 'tripal_organism_libraries',
  225. ),
  226. 'tripal_feature_libraries' => array(
  227. 'arguments' => array('node' => NULL),
  228. 'template' => 'tripal_feature_libraries',
  229. ),
  230. 'tripal_library_base' => array(
  231. 'arguments' => array('node' => NULL),
  232. 'template' => 'tripal_library_base',
  233. ),
  234. 'tripal_library_synonyms' => array(
  235. 'arguments' => array('node' => NULL),
  236. 'template' => 'tripal_library_synonyms',
  237. ),
  238. 'tripal_library_references' => array(
  239. 'arguments' => array('node' => NULL),
  240. 'template' => 'tripal_library_references',
  241. ),
  242. 'tripal_library_properties' => array(
  243. 'arguments' => array('node' => NULL),
  244. 'template' => 'tripal_library_properties',
  245. ),
  246. 'tripal_library_terms' => array(
  247. 'arguments' => array('node' => NULL),
  248. 'template' => 'tripal_library_terms',
  249. ),
  250. 'tripal_library_admin' => array(
  251. 'template' => 'tripal_library_admin',
  252. 'arguments' => array(NULL),
  253. 'path' => drupal_get_path('module', 'tripal_library') . '/theme',
  254. ),
  255. );
  256. }
  257. /**
  258. * This function is an extension of the chado_feature_view and
  259. * chado_organism_view by providing the markup for the library object
  260. * THAT WILL BE INDEXED.
  261. *
  262. * @ingroup tripal_library
  263. */
  264. function theme_tripal_library_search_index($node) {
  265. if ($node->type == 'chado_organism') {
  266. $content = "";
  267. // get the libraries for the organism
  268. $sql = "SELECT * FROM {library} L ".
  269. "WHERE L.organism_id = %d";
  270. $libraries = array();
  271. $results = chado_query($sql, $node->organism->organism_id);
  272. while ($library = db_fetch_object($results)) {
  273. // get the description
  274. $sql = "SELECT * FROM {libraryprop} LP ".
  275. " INNER JOIN {CVTerm} CVT ON CVT.cvterm_id = LP.type_id ".
  276. "WHERE LP.library_id = $library->library_id ".
  277. " AND CVT.name = 'library_description'";
  278. $desc = db_fetch_object(chado_query($sql));
  279. $library->description = $desc->value;
  280. $libraries[] = $library;
  281. }
  282. if (count($libraries) > 0) {
  283. foreach ($libraries as $library) {
  284. $content .= "$library->name ";
  285. $content .= "$library->description";
  286. };
  287. }
  288. // Provide library names to show in a feature page
  289. }
  290. elseif ($node->type == 'chado_feature') {
  291. $content = "";
  292. $organism_id = $node->feature->organism_id;
  293. $sql = "SELECT * FROM {library} L ".
  294. " INNER JOIN {Library_feature} LF ON L.library_id = LF.library_id ".
  295. "WHERE LF.feature_id = " . $node->feature->feature_id;
  296. $libraries = array();
  297. $results = chado_query($sql);
  298. while ($library = db_fetch_object($results)) {
  299. $libraries[] = $library;
  300. }
  301. if (count($libraries) > 0) {
  302. $lib_additions = array();
  303. foreach ($libraries as $library) {
  304. $content .= $library->name;
  305. };
  306. }
  307. }
  308. return $content;
  309. }
  310. /**
  311. * This function shows library information on an organism/feature node
  312. *
  313. * @ingroup tripal_library
  314. */
  315. function theme_tripal_library_node_libraries($node) {
  316. $content = "";
  317. // Show library information in a expandable box for a organism page.
  318. // Make sure we have $node->organism_id. In the case of creating a new
  319. // organism, the organism_id is not created until we save. This will cause
  320. // an error when users preview the creation without a $node->organism_id
  321. if ($node->type == 'chado_organism' && $node->organism_id) {
  322. $box_status = variable_get("tripal_library-box-libraries", "menu_off");
  323. if (strcmp($box_status, "menu_off")==0) {
  324. return get_tripal_library_organism_libraries($node->nid);
  325. }
  326. }
  327. // Provide library names to show in a feature page.
  328. // Make sure we have $node->feature->feature_id or there will be an error
  329. // when a feature is previewed at its creation
  330. elseif ($node->type == 'chado_feature' && $node->feature->feature_id) {
  331. $organism_id = $node->feature->organism_id;
  332. $sql = "SELECT * FROM {library} L ".
  333. " INNER JOIN Library_feature LF ON L.library_id = LF.library_id ".
  334. "WHERE LF.feature_id = " . $node->feature->feature_id;
  335. $libraries = array();
  336. $results = chado_query($sql);
  337. while ($library = db_fetch_object($results)) {
  338. $libraries[] = $library;
  339. }
  340. if (count($libraries) > 0) {
  341. $lib_additions = array();
  342. foreach ($libraries as $library) {
  343. $sql = "SELECT nid FROM {chado_library} WHERE library_id = %d";
  344. $lib_nid = db_result(db_query($sql, $library->library_id));
  345. if ($lib_nid) {
  346. $lib_url = url("node/$lib_nid");
  347. }
  348. $lib_additions[$lib_url] = $library->name;
  349. };
  350. $node->lib_additions = $lib_additions;
  351. }
  352. }
  353. return $content;
  354. }
  355. /**
  356. *
  357. * @ingroup tripal_library
  358. */
  359. function tripal_library_cron() {
  360. }
  361. /**
  362. * The following function proves access control for users trying to
  363. * perform actions on data managed by this module
  364. *
  365. * @ingroup tripal_library
  366. */
  367. function tripal_library_library_access($op, $node, $account) {
  368. if ($op == 'create') {
  369. if (!user_access('create chado_library content', $account)) {
  370. return FALSE;
  371. }
  372. }
  373. if ($op == 'update') {
  374. if (!user_access('edit any chado_library content', $account) &&
  375. !user_access('edit own chado_library content', $account)) {
  376. return FALSE;
  377. }
  378. if (user_access('edit own chado_library content', $account) &&
  379. $account->uid != $node->uid) {
  380. return FALSE;
  381. }
  382. }
  383. if ($op == 'delete') {
  384. if (!user_access('delete any chado_library content', $account) &&
  385. !user_access('delete own chado_library content', $account)) {
  386. return FALSE;
  387. }
  388. if (user_access('delete own chado_library content', $account) &&
  389. $account->uid != $node->uid) {
  390. return FALSE;
  391. }
  392. }
  393. return NULL;
  394. }
  395. /**
  396. * When editing or creating a new node of type 'chado_library' we need
  397. * a form. This function creates the form that will be used for this.
  398. *
  399. * @ingroup tripal_library
  400. */
  401. function chado_library_form($node) {
  402. $form = array();
  403. $library = $node->library;
  404. // get the default values
  405. $uniquename = $node->uniquename;
  406. if (!$uniquename) {
  407. $uniquename = $library->uniquename;
  408. }
  409. $library_type = $node->library_type;
  410. if (!$library_type) {
  411. $library_type = $library->type_id->cvterm_id;
  412. }
  413. $organism_id = $node->organism_id;
  414. if (!$organism_id) {
  415. $organism_id = $library->organism_id->organism_id;
  416. }
  417. $library_description = $node->library_description;
  418. if (!$library_description) {
  419. $libprop = tripal_library_get_property($library->library_id, 'library_description');
  420. $library_description = $libprop->value;
  421. }
  422. // keep track of the library id if we have. If we do have one then
  423. // this is an update as opposed to an insert.
  424. $form['library_id'] = array(
  425. '#type' => 'value',
  426. '#value' => $library->library_id,
  427. );
  428. $form['title']= array(
  429. '#type' => 'textfield',
  430. '#title' => t('Library Title'),
  431. '#description' => t('Please enter the title for this library. '.
  432. 'This appears at the top of the library page.'),
  433. '#required' => TRUE,
  434. '#default_value' => $node->title,
  435. '#weight' => 1
  436. );
  437. $form['uniquename']= array(
  438. '#type' => 'textfield',
  439. '#title' => t('Unique Library Name'),
  440. '#description' => t('Please enter a unique name for this library'),
  441. '#required' => TRUE,
  442. '#default_value' => $uniquename,
  443. '#weight' => 2
  444. );
  445. // get the list of library types
  446. $values = array(
  447. 'cv_id' => array(
  448. 'name' => 'tripal_library_types',
  449. )
  450. );
  451. $columns = array('cvterm_id','name');
  452. $options = array('order_by' => array('name' => 'ASC'));
  453. $lib_types = tripal_core_chado_select('cvterm', $columns, $values, $options);
  454. $types = array();
  455. $types[''] = '';
  456. foreach($lib_types as $type) {
  457. $types[$type->cvterm_id] = $type->name;
  458. }
  459. $form['library_type'] = array(
  460. '#title' => t('Library Type'),
  461. '#type' => t('select'),
  462. '#description' => t("Choose the library type."),
  463. '#required' => TRUE,
  464. '#default_value' => $library_type,
  465. '#options' => $types,
  466. '#weight' => 3
  467. );
  468. // get the list of organisms
  469. $sql = "SELECT * FROM {Organism}";
  470. $org_rset = chado_query($sql);
  471. $organisms = array();
  472. $organisms[''] = '';
  473. while ($organism = db_fetch_object($org_rset)) {
  474. $organisms[$organism->organism_id] =
  475. "$organism->genus $organism->species ($organism->common_name)";
  476. }
  477. $form['organism_id'] = array(
  478. '#title' => t('Organism'),
  479. '#type' => t('select'),
  480. '#description' => t("Choose the organism with which this library is ".
  481. "associated."),
  482. '#required' => TRUE,
  483. '#default_value' => $organism_id,
  484. '#options' => $organisms,
  485. '#weight' => 4,
  486. );
  487. $form['library_description']= array(
  488. '#type' => 'textarea',
  489. '#title' => t('Library Description'),
  490. '#description' => t('A brief description of the library'),
  491. '#required' => TRUE,
  492. '#default_value' => $library_description,
  493. '#weight' => 5
  494. );
  495. return $form;
  496. }
  497. /**
  498. * validates submission of form when adding or updating a library node
  499. *
  500. * @ingroup tripal_library
  501. */
  502. function chado_library_validate($node) {
  503. $lib = 0;
  504. // check to make sure the unique name on the library is unique
  505. // before we try to insert into chado.
  506. if ($node->library_id) {
  507. $sql = "SELECT * FROM ".
  508. "{Library} WHERE ".
  509. "uniquename = '%s' ".
  510. "AND NOT library_id = %d";
  511. $lib = db_fetch_object(chado_query($sql, $node->uniquename, $node->library_id));
  512. }
  513. else {
  514. $sql = "SELECT * FROM ".
  515. "{Library} ".
  516. "WHERE uniquename = '%s'";
  517. $lib = db_fetch_object(chado_query($sql, $node->uniquename));
  518. }
  519. if ($lib) {
  520. form_set_error('uniquename', t('The unique library name already exists. '.
  521. 'Please choose another'));
  522. }
  523. }
  524. /**
  525. * When a new chado_library node is created we also need to add information
  526. * to our chado_library table. This function is called on insert of a new node
  527. * of type 'chado_library' and inserts the necessary information.
  528. *
  529. * @ingroup tripal_library
  530. */
  531. function chado_library_insert($node) {
  532. if ($node->library_id) {
  533. $library['library_id'] = $node->library_id;
  534. }
  535. else {
  536. $values = array(
  537. 'name' => $node->title,
  538. 'uniquename' => $node->uniquename,
  539. 'organism_id' => $node->organism_id,
  540. 'type_id' => $node->library_type,
  541. );
  542. $library = tripal_core_chado_insert('library', $values);
  543. }
  544. if ($library) {
  545. // add the description property
  546. tripal_library_insert_property($library['library_id'], 'library_description',
  547. $node->library_description);
  548. // make sure the entry for this feature doesn't already exist in the chado_library table
  549. // if it doesn't exist then we want to add it.
  550. $library_id = chado_get_id_for_node('library', $node) ;
  551. if (!$library_id) {
  552. // next add the item to the drupal table
  553. $sql = "INSERT INTO {chado_library} (nid, vid, library_id) ".
  554. "VALUES (%d, %d, %d)";
  555. db_query($sql, $node->nid, $node->vid, $library['library_id']);
  556. }
  557. }
  558. else {
  559. drupal_set_message(t('Unable to add library.', 'warning'));
  560. watchdog('tripal_library',
  561. 'Insert feature: Unable to create library where values: %values',
  562. array('%values' => print_r($values, TRUE)),
  563. WATCHDOG_WARNING
  564. );
  565. }
  566. }
  567. /**
  568. * Update nodes
  569. *
  570. * @ingroup tripal_library
  571. */
  572. function chado_library_update($node) {
  573. if ($node->revision) {
  574. // there is no way to handle revisions in Chado but leave
  575. // this here just to make not we've addressed it.
  576. }
  577. $library_id = chado_get_id_for_node('library', $node) ;
  578. // update the library record
  579. $match = array(
  580. 'library_id' => $library_id,
  581. );
  582. $values = array(
  583. 'name' => $node->title,
  584. 'uniquename' => $node->uniquename,
  585. 'organism_id' => $node->organism_id,
  586. 'type_id' => $node->library_type,
  587. );
  588. $status = tripal_core_chado_update('library', $match, $values);
  589. tripal_library_update_property($library_id, 'library_description', $node->library_description, 1);
  590. }
  591. /**
  592. * When a node is requested by the user this function is called to allow us
  593. * to add auxiliary data to the node object.
  594. *
  595. * @ingroup tripal_library
  596. */
  597. function chado_library_load($node) {
  598. // get the feature details from chado
  599. $library_id = chado_get_id_for_node('library', $node);
  600. $values = array('library_id' => $library_id);
  601. $library = tripal_core_generate_chado_var('library', $values);
  602. $additions = new stdClass();
  603. $additions->library = $library;
  604. return $additions;
  605. }
  606. /**
  607. * This function customizes the view of the chado_library node. It allows
  608. * us to generate the markup. This function is required for node [Preview]
  609. *
  610. * @ingroup tripal_library
  611. */
  612. function chado_library_view($node, $teaser = FALSE, $page = FALSE) {
  613. // use drupal's default node view:
  614. if (!$teaser) {
  615. $node = node_prepare($node, $teaser);
  616. // If Hook_view() is called by Hook_form(), we'll only have orgnism_id
  617. // but not genus/species/common_name. We need to get those from chado
  618. // database so they will show up in preview
  619. if (!$node->genus) {
  620. $sql = "SELECT * FROM {organism} WHERE organism_id = %d";
  621. $data = db_fetch_object(chado_query($sql, $node->organism_id));
  622. $node->genus = $data->genus;
  623. $node->species = $data->species;
  624. $node->common_name = $data->common_name;
  625. }
  626. }
  627. return $node;
  628. }
  629. /**
  630. * Delete data from drupal and chado databases when a node is deleted
  631. * @ingroup tripal_library
  632. */
  633. function chado_library_delete(&$node) {
  634. $library_id = chado_get_id_for_node('library', $node);
  635. // if we don't have a library id for this node then this isn't a node of
  636. // type chado_library or the entry in the chado_library table was lost.
  637. if (!$library_id) {
  638. return;
  639. }
  640. // Remove data from {chado_library}, {node} and {node_revisions} tables of
  641. // drupal database
  642. $sql_del = "DELETE FROM {chado_library} ".
  643. "WHERE nid = %d ".
  644. "AND vid = %d";
  645. db_query($sql_del, $node->nid, $node->vid);
  646. $sql_del = "DELETE FROM {node_revisions} ".
  647. "WHERE nid = %d ".
  648. "AND vid = %d";
  649. db_query($sql_del, $node->nid, $node->vid);
  650. $sql_del = "DELETE FROM {node} ".
  651. "WHERE nid = %d ".
  652. "AND vid = %d";
  653. db_query($sql_del, $node->nid, $node->vid);
  654. // Remove data from library and libraryprop tables of chado database as well
  655. chado_query("DELETE FROM {libraryprop} WHERE library_id = %d", $library_id);
  656. chado_query("DELETE FROM {library} WHERE library_id = %d", $library_id);
  657. }
  658. /**
  659. * Display block with libraries
  660. * @param op - parameter to define the phase being called for the block
  661. * @param delta - id of the block to return (ignored when op is list)
  662. * @param edit - when op is save, contains the submitted form data
  663. *
  664. * @ingroup tripal_library
  665. */
  666. function tripal_library_block($op = 'list', $delta = '0', $edit = array()) {
  667. switch ($op) {
  668. case 'list':
  669. $blocks['libreferences']['info'] = t('Tripal Library Cross References');
  670. $blocks['libreferences']['cache'] = BLOCK_NO_CACHE;
  671. $blocks['libbase']['info'] = t('Tripal Library Details');
  672. $blocks['libbase']['cache'] = BLOCK_NO_CACHE;
  673. $blocks['libterms']['info'] = t('Tripal Library Terms');
  674. $blocks['libterms']['cache'] = BLOCK_NO_CACHE;
  675. $blocks['libsynonyms']['info'] = t('Tripal Library Synonyms');
  676. $blocks['libsynonyms']['cache'] = BLOCK_NO_CACHE;
  677. $blocks['libproperties']['info'] = t('Tripal Library Properties');
  678. $blocks['libproperties']['cache'] = BLOCK_NO_CACHE;
  679. $blocks['featurelibs']['info'] = t('Tripal Feature Libraries');
  680. $blocks['featurelibs']['cache'] = BLOCK_NO_CACHE;
  681. $blocks['orglibs']['info'] = t('Tripal Organism Libraries');
  682. $blocks['orglibs']['cache'] = BLOCK_NO_CACHE;
  683. return $blocks;
  684. case 'view':
  685. if (user_access('access chado_library content') and arg(0) == 'node' and is_numeric(arg(1))) {
  686. $nid = arg(1);
  687. $node = node_load($nid);
  688. $block = array();
  689. switch ($delta) {
  690. case 'libreferences':
  691. $block['subject'] = t('Cross References');
  692. $block['content'] = theme('tripal_library_references', $node);
  693. break;
  694. case 'libbase':
  695. $block['subject'] = t('Library Details');
  696. $block['content'] = theme('tripal_library_base', $node);
  697. break;
  698. case 'libsynonyms':
  699. $block['subject'] = t('Synonyms');
  700. $block['content'] = theme('tripal_library_synonyms', $node);
  701. break;
  702. case 'libproperties':
  703. $block['subject'] = t('Properties');
  704. $block['content'] = theme('tripal_library_properties', $node);
  705. break;
  706. case 'libterms':
  707. $block['subject'] = t('Library Terms');
  708. $block['content'] = theme('tripal_library_terms', $node);
  709. break;
  710. case 'featurelibs':
  711. $block['subject'] = t('Libraries');
  712. $block['content'] = theme('tripal_feature_libraries', $node);
  713. break;
  714. case 'orglibs':
  715. $block['subject'] = t('Libraries');
  716. $block['content'] = theme('tripal_organism_libraries', $node);
  717. break;
  718. default :
  719. }
  720. return $block;
  721. }
  722. }
  723. }