nodequeue_service.inc 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * @file
  4. * Miscellaneous functions for Nodequeue Service.
  5. *
  6. * @author Greg Harvey - http://www.drupaler.co.uk
  7. */
  8. /**
  9. * Returns an array of available nodequeue "channels" available.
  10. *
  11. * @return
  12. * array with key of nodequeue ids and all settings within
  13. */
  14. function nodequeue_service_get_nodequeues() {
  15. if (module_exists('nodequeue')) {
  16. // Fetch all of the queues.
  17. $queues = nodequeue_load_queues(nodequeue_get_all_qids(0));
  18. if (empty($queues)) {
  19. return services_error(t('Nodequeue available, but no nodequeues exist.'));
  20. }
  21. else {
  22. $availablequeues = array();
  23. foreach ($queues as $queue) {
  24. $availablequeues[$queue->qid]['qid'] = $queue->qid;
  25. $availablequeues[$queue->qid]['title'] = $queue->title;
  26. $availablequeues[$queue->qid]['subqueue_title'] = $queue->subqueue_title;
  27. $availablequeues[$queue->qid]['size'] = $queue->size;
  28. $availablequeues[$queue->qid]['link'] = $queue->link;
  29. $availablequeues[$queue->qid]['link_remove'] = $queue->link_remove;
  30. $availablequeues[$queue->qid]['owner'] = $queue->owner;
  31. $availablequeues[$queue->qid]['show_in_ui'] = $queue->show_in_ui;
  32. $availablequeues[$queue->qid]['show_in_tab'] = $queue->show_in_tab;
  33. $availablequeues[$queue->qid]['show_in_links'] = $queue->show_in_links;
  34. $availablequeues[$queue->qid]['reference'] = $queue->reference;
  35. $availablequeues[$queue->qid]['reverse'] = $queue->reverse;
  36. $availablequeues[$queue->qid]['subqueues'] = $queue->subqueues;
  37. $availablequeues[$queue->qid]['types'] = $queue->types;
  38. $availablequeues[$queue->qid]['roles'] = $queue->roles;
  39. $availablequeues[$queue->qid]['count'] = $queue->count;
  40. }
  41. }
  42. return $availablequeues;
  43. }
  44. else {
  45. return services_error(t('Nodequeue module unavailable.'));
  46. }
  47. }
  48. /**
  49. * Returns an array of available subqueues by parent queue id.
  50. *
  51. * @param $qid
  52. * integer representing the queue id of the parent nodequeue
  53. *
  54. * @return
  55. * array with key of subqueue ids and all settings within
  56. */
  57. function nodequeue_service_get_subqueues($qid) {
  58. if (module_exists('nodequeue')) {
  59. $subqueues = nodequeue_load_subqueues_by_queue($qid);
  60. if (!empty($subqueues)) {
  61. foreach ($subqueues as $subqueue) {
  62. $availablequeues[$subqueue->sqid]['sqid'] = $subqueue->sqid;
  63. $availablequeues[$subqueue->sqid]['qid'] = $qid;
  64. $availablequeues[$subqueue->sqid]['reference'] = $subqueue->reference;
  65. $availablequeues[$subqueue->sqid]['title'] = check_plain($subqueue->title);
  66. $availablequeues[$subqueue->sqid]['count'] = $subqueue->count;
  67. }
  68. return $availablequeues;
  69. }
  70. else {
  71. return services_error(t('Specified nodequeue has no subqueues.'));
  72. }
  73. }
  74. else {
  75. return services_error(t('Nodequeue module unavailable.'));
  76. }
  77. }
  78. /**
  79. * Access callback function for the nodequeue service.
  80. */
  81. function nodequeue_service_get_nodequeues_access() {
  82. if (user_access('get nodequeues')) {
  83. return TRUE;
  84. }
  85. }