tripal_analysis.module 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. <?php
  2. /**
  3. * @file
  4. * Contains all the main hook implementations for the tripal_analysis module
  5. *
  6. * @defgroup tripal_analysis Analysis Module
  7. * @ingroup tripal_modules
  8. * @{
  9. * Provides functions for managing chado analysis' including creating details pages for each one
  10. *
  11. * @}
  12. *
  13. *
  14. */
  15. require('api/tripal_analysis.api.inc');
  16. require('includes/tripal_analysis_privacy.inc');
  17. require('includes/tripal_analysis.admin.inc');
  18. require('includes/tripal_analysis.form.inc');
  19. require('includes/tripal_analysis.sync.inc');
  20. /**
  21. * Add tripal javascript to page headers
  22. *
  23. * @ingroup tripal_analysis
  24. */
  25. function tripal_analysis_init() {
  26. drupal_add_js(drupal_get_path('module', 'tripal_analysis') . '/theme/js/tripal_analysis.js');
  27. drupal_add_css(drupal_get_path('module', 'tripal_analysis') . '/theme/css/tripal_analysis.css');
  28. }
  29. /**
  30. * Provide information to drupal about the node types that we're creating
  31. * in this module
  32. *
  33. * @ingroup tripal_analysis
  34. */
  35. function tripal_analysis_node_info() {
  36. $nodes = array();
  37. $nodes['chado_analysis'] = array(
  38. 'name' => t('Analysis'),
  39. 'base' => 'chado_analysis',
  40. 'description' => t('An analysis'),
  41. 'has_title' => FALSE,
  42. 'title_label' => t('Analysis'),
  43. 'locked' => TRUE
  44. );
  45. return $nodes;
  46. }
  47. /**
  48. * Implementation of hook_menu().
  49. * Entry points and paths of the module
  50. *
  51. * @ingroup tripal_analysis
  52. */
  53. function tripal_analysis_menu() {
  54. // Tripal Analysis administrative settings
  55. $items['admin/tripal/chado/tripal_analysis'] = array(
  56. 'title' => 'Analyses',
  57. 'description' => 'A bioinformatics analysis producing features.',
  58. 'access arguments' => array('administer tripal analyses'),
  59. 'type' => MENU_NORMAL_ITEM,
  60. );
  61. $items['admin/tripal/chado/tripal_analysis/help'] = array(
  62. 'title' => 'Help',
  63. 'description' => "A description of the Tripal Analysis module including a short description of it's usage.",
  64. 'page callback' => 'theme',
  65. 'page arguments' => array('tripal_analysis_help'),
  66. 'access arguments' => array('administer tripal analyses'),
  67. 'type' => MENU_NORMAL_ITEM,
  68. );
  69. $items['admin/tripal/chado/tripal_analysis/configuration'] = array(
  70. 'title' => 'Configuration',
  71. 'description' => 'Settings for the displays of analysis results.',
  72. 'page callback' => 'drupal_get_form',
  73. 'page arguments' => array('tripal_analysis_admin'),
  74. 'access arguments' => array('administer tripal analyses'),
  75. 'type' => MENU_NORMAL_ITEM,
  76. );
  77. $items['admin/tripal/chado/tripal_analysis/sync'] = array(
  78. 'title' => 'Sync Analyses',
  79. 'description' => 'Sync Chado analyses with Drupal.',
  80. 'page callback' => 'drupal_get_form',
  81. 'page arguments' => array('tripal_analysis_sync_form'),
  82. 'access arguments' => array('administer tripal analyses'),
  83. 'type' => MENU_NORMAL_ITEM,
  84. );
  85. return $items;
  86. }
  87. /**
  88. * Implements hook_help()
  89. * Purpose: Adds a help page to the module list
  90. */
  91. function tripal_analysis_help ($path, $arg) {
  92. if ($path == 'admin/help#tripal_analysis') {
  93. return theme('tripal_analysis_help', array());
  94. }
  95. }
  96. /**
  97. * Set the permission types that the chado module uses. Essentially we
  98. * want permissionis that protect creation, editing and deleting of chado
  99. * data objects
  100. *
  101. * @ingroup tripal_analysis
  102. */
  103. function tripal_analysis_permission() {
  104. return array(
  105. 'access chado_analysis content' => array(
  106. 'title' => t('View Analyses'),
  107. 'description' => t('Allow users to view analysis pages.'),
  108. ),
  109. 'create chado_analysis content' => array(
  110. 'title' => t('Create Analyses'),
  111. 'description' => t('Allow users to create new analysis pages.'),
  112. ),
  113. 'delete chado_analysis content' => array(
  114. 'title' => t('Delete Analyses'),
  115. 'description' => t('Allow users to delete analysis pages.'),
  116. ),
  117. 'edit chado_analysis content' => array(
  118. 'title' => t('Edit Analyses'),
  119. 'description' => t('Allow users to edit analysis pages.'),
  120. ),
  121. 'adminster tripal analysis' => array(
  122. 'title' => t('Administer Analyses'),
  123. 'description' => t('Allow users to administer all analyses.'),
  124. ),
  125. );
  126. }
  127. /**
  128. * We need to let drupal know about our theme functions and their arguments.
  129. * We create theme functions to allow users of the module to customize the
  130. * look and feel of the output generated in this module
  131. *
  132. * @ingroup tripal_analysis
  133. */
  134. function tripal_analysis_theme($existing, $type, $theme, $path) {
  135. $core_path = drupal_get_path('module', 'tripal_core');
  136. $theme_path = drupal_get_path('module', 'tripal_analysis') . '/theme';
  137. $items = array(
  138. 'node__chado_analysis' => array(
  139. 'template' => 'node--chado-generic',
  140. 'render element' => 'node',
  141. 'base hook' => 'node',
  142. 'path' => "$core_path/theme",
  143. ),
  144. 'tripal_analysis_base' => array(
  145. 'variables' => array('node' => NULL),
  146. 'template' => 'tripal_analysis_base',
  147. 'path' => "$path/theme/tripal_analysis",
  148. ),
  149. 'tripal_feature_analyses' => array(
  150. 'template' => 'tripal_feature_analyses',
  151. 'variables' => array('node' => NULL),
  152. 'path' => "$path/theme/tripal_analysis",
  153. ),
  154. 'tripal_analysis_properties' => array(
  155. 'variables' => array('node' => NULL),
  156. 'path' => "$path/theme/tripal_analysis",
  157. ),
  158. 'tripal_analysis_help' => array(
  159. 'template' => 'tripal_analysis_help',
  160. 'variables' => array(NULL),
  161. 'path' => "$path/theme",
  162. ),
  163. 'chado_analysis_form' => array(
  164. 'render element' => 'form',
  165. )
  166. );
  167. return $items;
  168. }
  169. /**
  170. *
  171. *
  172. * @ingroup tripal_analysis
  173. */
  174. function tripal_analysis_block_info() {
  175. $blocks['base']['info'] = t('Tripal Analysis Details');
  176. $blocks['base']['cache'] = DRUPAL_NO_CACHE;
  177. $blocks['featureblast']['info'] = t('Tripal Feature Analyses');
  178. $blocks['featureblast']['cache'] = DRUPAL_NO_CACHE;
  179. return $blocks;
  180. }
  181. /**
  182. *
  183. *
  184. * @ingroup tripal_analysis
  185. */
  186. function tripal_analysis_block_view($delta = '') {
  187. if (user_access('access chado_analysis content') and arg(0) == 'node' and is_numeric(arg(1))) {
  188. $nid = arg(1);
  189. $node = node_load($nid);
  190. $block = array();
  191. switch ($delta) {
  192. case 'base':
  193. $block['subject'] = t('Analysis Details');
  194. $block['content'] = theme('tripal_analysis_base', $node);
  195. break;
  196. case 'tripal_feature_analyses':
  197. $block['subject'] = t('Feature Analyses');
  198. $block['content'] = theme('tripal_feature_analyses', $node);
  199. break;
  200. default :
  201. }
  202. return $block;
  203. }
  204. }
  205. /**
  206. *
  207. * @ingroup tripal_feature
  208. */
  209. function tripal_analysis_node_view($node, $view_mode, $langcode) {
  210. switch ($node->type) {
  211. case 'chado_analysis':
  212. // Show feature browser and counts
  213. if ($view_mode == 'full') {
  214. $node->content['tripal_analysis_base'] = array(
  215. '#value' => theme('tripal_analysis_base', array('node' => $node)),
  216. );
  217. $node->content['tripal_analysis_properties'] = array(
  218. '#value' => theme('tripal_analysis_properties', array('node' => $node)),
  219. );
  220. }
  221. break;
  222. }
  223. }
  224. /**
  225. * Implements hook_views_api()
  226. * Purpose: Essentially this hook tells drupal that there is views support for
  227. * for this module which then includes tripal_analysis.views.inc where all the
  228. * views integration code is
  229. *
  230. * @ingroup tripal_analysis
  231. */
  232. function tripal_analysis_views_api() {
  233. return array(
  234. 'api' => 2.0,
  235. );
  236. }
  237. /*
  238. *
  239. */
  240. function tripal_analysis_form_alter(&$form, &$form_state, $form_id) {
  241. if ($form_id == "chado_analysis_node_form") {
  242. }
  243. }
  244. /**
  245. * When a new chado_analysis node is created we also need to add information
  246. * to our chado_analysis table. This function is called on insert of a new
  247. * node of type 'chado_analysis' and inserts the necessary information.
  248. *
  249. * @ingroup tripal_analysis
  250. */
  251. function chado_analysis_insert($node) {
  252. $node->analysisname = trim($node->analysisname);
  253. $node->description = trim($node->description);
  254. $node->program = trim($node->program);
  255. $node->programversion = trim($node->programversion);
  256. $node->algorithm = trim($node->algorithm);
  257. $node->sourcename = trim($node->sourcename);
  258. $node->sourceversion = trim($node->sourceversion);
  259. $node->sourceuri = trim($node->sourceuri);
  260. // if there is an analysis_id in the $node object then this must be a sync so
  261. // we can skip adding the analysis as it is already there, although
  262. // we do need to proceed with the rest of the insert
  263. if (!property_exists($node,'analysis_id')) {
  264. // Create a timestamp so we can insert it into the chado database
  265. $time = $node->timeexecuted;
  266. $month = $time['month'];
  267. $day = $time['day'];
  268. $year = $time['year'];
  269. $timestamp = $month . '/' . $day . '/' . $year;
  270. // insert and then get the newly inserted analysis record
  271. $values = array(
  272. 'name' => $node->analysisname,
  273. 'description' => $node->description,
  274. 'program' => $node->program,
  275. 'programversion' => $node->programversion,
  276. 'algorithm' => $node->algorithm,
  277. 'sourcename' => $node->sourcename,
  278. 'sourceversion' => $node->sourceversion,
  279. 'sourceuri' => $node->sourceuri,
  280. 'timeexecuted' => $timestamp
  281. );
  282. $analysis = tripal_core_chado_insert('analysis', $values);
  283. if (!$analysis) {
  284. drupal_set_message(t('Unable to add analysis.', 'warning'));
  285. watchdog('tripal_analysis', 'Insert analysis: Unable to create analysis where values:%values',
  286. array('%values' => print_r($values, TRUE)), WATCHDOG_ERROR);
  287. return;
  288. }
  289. $analysis_id = $analysis['analysis_id'];
  290. }
  291. else {
  292. $analysis_id = $node->analysis_id;
  293. }
  294. // Make sure the entry for this analysis doesn't already exist in the
  295. // chado_analysis table if it doesn't exist then we want to add it.
  296. $check_org_id = chado_get_id_for_node('analysis', $node->nid);
  297. if (!$check_org_id) {
  298. $record = new stdClass();
  299. $record->nid = $node->nid;
  300. $record->vid = $node->vid;
  301. $record->analysis_id = $analysis_id;
  302. drupal_write_record('chado_analysis', $record);
  303. }
  304. // add the analysis to the node object for
  305. // use by other analysis modules that may be using this function
  306. $node->analysis = $analysis;
  307. $node->analysis_id = $analysis_id; // we need to set this for children
  308. // now add the properties
  309. $properties = array(); // stores all of the properties we need to add
  310. // get the list of properties for easy lookup (without doing lots of database queries
  311. $properties_list = array();
  312. $sql = "
  313. SELECT DISTINCT CVT.cvterm_id, CVT.name, CVT.definition
  314. FROM {cvterm} CVT
  315. INNER JOIN {cv} ON CVT.cv_id = CV.cv_id
  316. WHERE
  317. CV.name = 'analysis_property' AND
  318. NOT CVT.is_obsolete = 1
  319. ORDER BY CVT.name ASC
  320. ";
  321. $prop_types = chado_query($sql);
  322. while ($prop = $prop_types->fetchObject()) {
  323. $properties_list[$prop->cvterm_id] = $prop->name;
  324. }
  325. // get the properties that should be added. Properties are in one of two forms:
  326. // 1) prop_value-[type id]-[index]
  327. // 2) new_value-[type id]-[index]
  328. // 3) new_id, new_value
  329. foreach ($node as $name => $value) {
  330. if (preg_match('/^new_value-(\d+)-(\d+)/', $name, $matches)) {
  331. $type_id = $matches[1];
  332. $index = $matches[2];
  333. $name = $properties_list[$type_id];
  334. $properties[$name][$index] = trim($value);
  335. }
  336. }
  337. if ($node->new_id and $node->new_value) {
  338. $type_id = $node->new_id;
  339. $name = $properties_list[$type_id];
  340. $index = count($properties[$name]);
  341. $properties[$name][$index] = trim($node->new_value);
  342. }
  343. // now add in the properties
  344. foreach ($properties as $property => $elements) {
  345. foreach ($elements as $rank => $value) {
  346. $status = tripal_analysis_insert_property($analysis_id, $property, $value, FALSE, 'analysis_property');
  347. if (!$status) {
  348. drupal_set_message("Error cannot add property: $property", "error");
  349. watchdog('t_analysis', "Error cannot add property: %prop",
  350. array('%property' => $property), WATCHDOG_ERROR);
  351. }
  352. }
  353. }
  354. }
  355. /**
  356. * Removes analysis from the chado database
  357. *
  358. * @param $node
  359. * The node object specifying which chado record to delete
  360. *
  361. * @ingroup tripal_analysis
  362. */
  363. function chado_analysis_delete($node) {
  364. $analysis_id = chado_get_id_for_node('analysis', $node->nid);
  365. // if we don't have an analysis id for this node then this isn't a node of
  366. // type chado_analysis or the entry in the chado_analysis table was lost.
  367. if (!$analysis_id) {
  368. return;
  369. }
  370. // Remove data from the {chado_analysis}, {node}, and {node_revisions} tables
  371. $sql_del = "DELETE FROM {chado_analysis} WHERE nid = :nid AND vid = :vid";
  372. db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  373. $sql_del = "DELETE FROM {node} WHERE nid = :nid AND vid = :vid";
  374. db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  375. $sql_del = "DELETE FROM {node_revision} WHERE nid = :nid AND vid = :vid";
  376. db_query($sql_del, array(':nid' => $node->nid, ':vid' => $node->vid));
  377. //Remove from analysis and analysisprop tables of chado database as well
  378. chado_query("DELETE FROM {analysis} WHERE analysis_id = :analysis_id", array(':analysis_id' => $analysis_id));
  379. }
  380. /**
  381. * Update analyses
  382. *
  383. * @param $node
  384. * The updated node object
  385. *
  386. * @ingroup tripal_analysis
  387. */
  388. function chado_analysis_update($node) {
  389. $node->analysisname = trim($node->analysisname);
  390. $node->description = trim($node->description);
  391. $node->program = trim($node->program);
  392. $node->programversion = trim($node->programversion);
  393. $node->algorithm = trim($node->algorithm);
  394. $node->sourcename = trim($node->sourcename);
  395. $node->sourceversion = trim($node->sourceversion);
  396. $node->sourceuri = trim($node->sourceuri);
  397. if ($node->revision) {
  398. // TODO -- decide what to do about revisions
  399. }
  400. // Create a timestamp so we can insert it into the chado database
  401. $time = $node->timeexecuted;
  402. $month = $time['month'];
  403. $day = $time['day'];
  404. $year = $time['year'];
  405. $timestamp = $month . '/' . $day . '/' . $year;
  406. // get the analysis_id for this node:
  407. $sql = "
  408. SELECT analysis_id
  409. FROM {chado_analysis}
  410. WHERE nid = :nid
  411. ";
  412. $analysis = db_query($sql, array(':nid' => $node->nid))->fetchObject();
  413. $analysis_id = $analysis->analysis_id;
  414. $sql = "
  415. UPDATE {analysis}
  416. SET name = :name,
  417. description = :description,
  418. program = :program,
  419. programversion = :programversion,
  420. algorithm = :algorithm,
  421. sourcename = :sourcename,
  422. sourceversion = :sourceversion,
  423. sourceuri = :sourceuri,
  424. timeexecuted = :timeexecuted
  425. WHERE analysis_id = :analysis_id
  426. ";
  427. $args = array(
  428. ':name' => $node->analysisname,
  429. ':description' => $node->description,
  430. ':program' => $node->program,
  431. ':programversion' => $node->programversion,
  432. ':algorithm' => $node->algorithm,
  433. ':sourcename' => $node->sourcename,
  434. ':sourceversion' => $node->sourceversion,
  435. ':sourceuri' => $node->sourceuri,
  436. ':timeexecuted' => $timestamp,
  437. ':analysis_id' => $anslysis_id
  438. );
  439. chado_query($sql, $args);
  440. // Create a title for the analysis node using the unique keys so when the
  441. // node is saved, it will have a title
  442. $record = new stdClass();
  443. // If the analysis has a name, use it as the node title. If not, construct
  444. // the title using program, programversion, and sourcename
  445. if ($node->analysisname) {
  446. $record->title = $node->analysisname;
  447. }
  448. else {
  449. //Construct node title as "program (version)
  450. $record->title = "$node->program ($node->programversion)";
  451. }
  452. $record->nid = $node->nid;
  453. drupal_write_record('node', $record, 'nid');
  454. drupal_write_record('node_revisions', $record, 'nid');
  455. // now update the properties
  456. $properties = array(); // stores all of the properties we need to add
  457. // get the list of properties for easy lookup (without doing lots of database queries
  458. $properties_list = array();
  459. $sql = "
  460. SELECT DISTINCT CVT.cvterm_id, CVT.name, CVT.definition
  461. FROM {cvterm} CVT
  462. INNER JOIN {cv} ON CVT.cv_id = CV.cv_id
  463. WHERE
  464. CV.name = 'analysis_property' AND
  465. NOT CVT.is_obsolete = 1
  466. ORDER BY CVT.name ASC
  467. ";
  468. $prop_types = chado_query($sql);
  469. while ($prop = $prop_types->fetchObject()) {
  470. $properties_list[$prop->cvterm_id] = $prop->name;
  471. }
  472. // get the properties that should be added. Properties are in one of three forms:
  473. // 1) prop_value-[type id]-[index]
  474. // 2) new_value-[type id]-[index]
  475. // 3) new_id, new_value
  476. // dpm($node);
  477. foreach ($node as $key => $value) {
  478. if (preg_match('/^prop_value-(\d+)-(\d+)/', $key, $matches)) {
  479. $type_id = $matches[1];
  480. $index = $matches[2];
  481. $name = $properties_list[$type_id];
  482. $properties[$name][$index] = trim($value);
  483. }
  484. if (preg_match('/^new_value-(\d+)-(\d+)/', $key, $matches)) {
  485. $type_id = $matches[1];
  486. $index = $matches[2];
  487. $name = $properties_list[$type_id];
  488. $properties[$name][$index] = trim($value);
  489. }
  490. }
  491. if ($node->new_id and $node->new_value) {
  492. $type_id = $node->new_id;
  493. $name = $properties_list[$type_id];
  494. $index = count($properties[$name]);
  495. $properties[$name][$index] = trim($node->new_value);
  496. }
  497. // now add in the properties by first removing any the analysis
  498. // already has and adding the ones we have
  499. $sql = "
  500. DELETE FROM {analysisprop} WHERE analysis_id = :analysis_id AND type_id IN (
  501. SELECT CVT.cvterm_id
  502. FROM {cvterm} CVT
  503. INNER JOIN {cv} ON CVT.cv_id = CV.cv_id
  504. WHERE CV.name = 'analysis_property')
  505. ";
  506. $success = chado_query($sql, array(':analysis_id' => $analysis_id));
  507. if (!$success) {
  508. drupal_set_message("Cannot update analysis properties", "error");
  509. watchdog('t_analysis', "Cannot update analysis properties.", array(), WATCHDOG_ERROR);
  510. return;
  511. }
  512. foreach ($properties as $property => $elements) {
  513. foreach ($elements as $rank => $value) {
  514. $status = tripal_analysis_insert_property($analysis_id, $property, $value, FALSE, 'analysis_property');
  515. if (!$status) {
  516. drupal_set_message("Error cannot add property: '$property'", "error");
  517. watchdog('t_analysis', "Error cannot add property: '%prop'",
  518. array('%prop' => $property), WATCHDOG_ERROR);
  519. }
  520. }
  521. }
  522. }
  523. /**
  524. * When a node is requested by the user this function is called to allow us
  525. * to add auxiliary data to the node object.
  526. *
  527. * @ingroup tripal_analysis
  528. */
  529. function chado_analysis_load($nodes) {
  530. foreach ($nodes as $nid => $node) {
  531. // find the analysis and add in the details
  532. $analysis_id = chado_get_id_for_node('analysis', $nid);
  533. // build the analysis variable
  534. $values = array('analysis_id' => $analysis_id);
  535. $analysis = tripal_core_generate_chado_var('analysis', $values);
  536. // add in the description field
  537. $analysis = tripal_core_expand_chado_vars($analysis, 'field', 'analysis.description');
  538. $nodes[$nid]->analysis = $analysis;
  539. }
  540. }
  541. /**
  542. * This function customizes the view of the chado_analysis node. It allows
  543. * us to generate the markup.
  544. *
  545. * @ingroup tripal_analysis
  546. */
  547. function chado_analysis_view($node, $teaser = FALSE, $page = FALSE) {
  548. // use drupal's default node view:
  549. if (!$teaser) {
  550. $node = node_prepare($node, $teaser);
  551. // When previewing a node submitting form, it shows 'Array' instead of
  552. // correct date format. We need to format the date here
  553. $time = $node->timeexecuted;
  554. if (is_array($time)) {
  555. $month = $time['month'];
  556. $day = $time['day'];
  557. $year = $time['year'];
  558. $timestamp = $year . '-' . $month . '-' . $day;
  559. $node->timeexecuted = $timestamp;
  560. }
  561. }
  562. return $node;
  563. }
  564. /**
  565. * Implement hook_access().
  566. *
  567. * This hook allows node modules to limit access to the node types they define.
  568. *
  569. * @param $node
  570. * The node on which the operation is to be performed, or, if it does not yet exist, the
  571. * type of node to be created
  572. *
  573. * @param $op
  574. * The operation to be performed
  575. *
  576. * @param $account
  577. * A user object representing the user for whom the operation is to be performed
  578. *
  579. * @return
  580. * If the permission for the specified operation is not set then return FALSE. If the
  581. * permission is set then return NULL as this allows other modules to disable
  582. * access. The only exception is when the $op == 'create'. We will always
  583. * return TRUE if the permission is set.
  584. *
  585. * @ingroup tripal_analysis
  586. */
  587. function chado_analysis_node_access($node, $op, $account) {
  588. if ($op == 'create') {
  589. if (!user_access('create chado_analysis content', $account)) {
  590. return FALSE;
  591. }
  592. return TRUE;
  593. }
  594. if ($op == 'update') {
  595. if (!user_access('edit chado_analysis content', $account)) {
  596. return FALSE;
  597. }
  598. }
  599. if ($op == 'delete') {
  600. if (!user_access('delete chado_analysis content', $account)) {
  601. return FALSE;
  602. }
  603. }
  604. if ($op == 'view') {
  605. if (!user_access('access chado_analysis content', $account)) {
  606. return FALSE;
  607. }
  608. }
  609. return NULL;
  610. }