tripal_analysis.module 21 KB

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