tripal_db.DEPRECATED.inc 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?php
  2. /**
  3. * @file
  4. * Wrapper functions to provide backwards compatibility for the tripal db api
  5. */
  6. /**
  7. * @deprecated Restructured API to make naming more readable and consistent.
  8. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  9. * now. This function has been replaced by tripal_get_db().
  10. *
  11. * @see tripal_get_db().
  12. */
  13. function tripal_db_get_db($select_values) {
  14. tripal_report_error(
  15. 'tripal_deprecated',
  16. TRIPAL_NOTICE,
  17. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  18. [
  19. '%old_function' => 'tripal_db_get_db',
  20. '%new_function' => 'tripal_get_db',
  21. ]
  22. );
  23. return tripal_get_db($select_values);
  24. }
  25. /**
  26. * @deprecated Restructured API to make naming more readable and consistent.
  27. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  28. * now. This function has been replaced by tripal_get_db().
  29. *
  30. * @see tripal_get_db().
  31. */
  32. function tripal_db_get_db_by_db_id($db_id) {
  33. tripal_report_error(
  34. 'tripal_deprecated',
  35. TRIPAL_NOTICE,
  36. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  37. [
  38. '%old_function' => 'tripal_db_get_db_by_db_id',
  39. '%new_function' => 'tripal_get_db',
  40. ]
  41. );
  42. return tripal_get_db(['db_id' => $db_id]);
  43. }
  44. /**
  45. * @deprecated Restructured API to make naming more readable and consistent.
  46. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  47. * now. This function has been replaced by tripal_get_db().
  48. *
  49. * @see tripal_get_db().
  50. */
  51. function tripal_db_get_db_by_name($name) {
  52. tripal_report_error(
  53. 'tripal_deprecated',
  54. TRIPAL_NOTICE,
  55. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  56. [
  57. '%old_function' => 'tripal_db_get_db_by_name',
  58. '%new_function' => 'tripal_get_db',
  59. ]
  60. );
  61. return tripal_get_db(['name' => $name]);
  62. }
  63. /**
  64. * @deprecated Restructured API to make naming more readable and consistent.
  65. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  66. * now. This function has been replaced by tripal_get_db_select_options().
  67. *
  68. * @see tripal_get_db_select_options().
  69. */
  70. function tripal_db_get_db_options() {
  71. tripal_report_error(
  72. 'tripal_deprecated',
  73. TRIPAL_NOTICE,
  74. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  75. [
  76. '%old_function' => 'tripal_db_get_db_options',
  77. '%new_function' => 'tripal_get_db_select_options',
  78. ]
  79. );
  80. return tripal_get_db_select_options();
  81. }
  82. /**
  83. * @deprecated Restructured API to make naming more readable and consistent.
  84. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  85. * now. This function has been replaced by tripal_get_db().
  86. *
  87. * @see tripal_get_dbxref().
  88. */
  89. function tripal_db_get_dbxref($select_values) {
  90. tripal_report_error(
  91. 'tripal_deprecated',
  92. TRIPAL_NOTICE,
  93. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  94. [
  95. '%old_function' => 'tripal_db_get_dbxref',
  96. '%new_function' => 'tripal_get_dbxref',
  97. ]
  98. );
  99. return tripal_get_dbxref($select_values);
  100. }
  101. /**
  102. * @deprecated Restructured API to make naming more readable and consistent.
  103. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  104. * now. This function has been replaced by tripal_get_db().
  105. *
  106. * @see tripal_get_dbxref().
  107. */
  108. function tripal_db_get_dbxref_by_accession($accession, $db_id = 0) {
  109. tripal_report_error(
  110. 'tripal_deprecated',
  111. TRIPAL_NOTICE,
  112. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  113. [
  114. '%old_function' => 'tripal_db_get_dbxref_by_accession',
  115. '%new_function' => 'tripal_get_dbxref',
  116. ]
  117. );
  118. $identifiers = [
  119. 'accession' => $accession,
  120. ];
  121. if ($db_id > 0) {
  122. $identifiers['db'] = [
  123. 'db_id' => $db_id,
  124. ];
  125. }
  126. return tripal_get_dbxref($identifiers);
  127. }
  128. /**
  129. * @deprecated Restructured API to make naming more readable and consistent.
  130. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  131. * now. This function has been replaced by tripal_insert_db().
  132. *
  133. * @see tripal_insert_db().
  134. */
  135. function tripal_db_add_db($dbname, $description = '', $url = '', $urlprefix = '', $update = 0) {
  136. tripal_report_error(
  137. 'tripal_deprecated',
  138. TRIPAL_NOTICE,
  139. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  140. [
  141. '%old_function' => 'tripal_db_add_db',
  142. '%new_function' => 'tripal_insert_db',
  143. ]
  144. );
  145. return tripal_insert_db(
  146. [
  147. 'name' => $dbname,
  148. 'description' => $description,
  149. 'url' => $url,
  150. 'urlprefix' => $urlprefix,
  151. ],
  152. [
  153. 'update_existing' => $update,
  154. ]
  155. );
  156. }
  157. /**
  158. * @deprecated Restructured API to make naming more readable and consistent.
  159. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  160. * now. This function has been replaced by tripal_insert_dbxref().
  161. *
  162. * @see tripal_insert_dbxref().
  163. */
  164. function tripal_db_add_dbxref($db_id, $accession, $version = '', $description = '') {
  165. tripal_report_error(
  166. 'tripal_deprecated',
  167. TRIPAL_NOTICE,
  168. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  169. [
  170. '%old_function' => 'tripal_db_add_dbxref',
  171. '%new_function' => 'tripal_insert_dbxref',
  172. ]
  173. );
  174. return tripal_insert_dbxref([
  175. 'db_id' => $db_id,
  176. 'accession' => $accession,
  177. 'version' => $version,
  178. 'description' => $description,
  179. ]);
  180. }
  181. /**
  182. * @deprecated Restructured API to make naming more readable and consistent.
  183. * Function was deprecated in Tripal 2.0 and will be removed 2 releases from
  184. * now. This function has been replaced by tripal_associate_dbxref().
  185. *
  186. * @see tripal_associate_dbxref().
  187. */
  188. function tripal_db_add_dbxref_link($linking_table, $dbxref_id, $foreignkey_name, $foreignkey_id) {
  189. tripal_report_error(
  190. 'tripal_deprecated',
  191. TRIPAL_NOTICE,
  192. "DEPRECATED: %old_function has been replaced with %new_function. Please update your code.",
  193. [
  194. '%old_function' => 'tripal_db_add_dbxref_link',
  195. '%new_function' => 'tripal_associate_dbxref',
  196. ]
  197. );
  198. if (preg_match('/(\w+)_dbxref/', $linking_table, $matches)) {
  199. $basetable = $matches[1];
  200. return tripal_associate_dbxref($basetable, $foreignkey_id, ['dbxref_id' => $dbxref_id]);
  201. }
  202. else {
  203. return FALSE;
  204. }
  205. }