You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
4.2 KiB

  1. <?php
  2. namespace modl;
  3. class ConferenceDAO extends SQL {
  4. function set(Conference $c) {
  5. $this->_sql = '
  6. update conference
  7. set name = :name,
  8. nick = :nick,
  9. autojoin = :autojoin,
  10. status = :status
  11. where jid = :jid
  12. and conference= :conference';
  13. $this->prepare(
  14. 'Conference',
  15. array(
  16. 'jid' => $c->jid,
  17. 'conference' => $c->conference,
  18. 'name' => $c->name,
  19. 'nick' => $c->nick,
  20. 'autojoin' => $c->autojoin,
  21. 'status' => $c->status
  22. )
  23. );
  24. $this->run('Conference');
  25. if(!$this->_effective) {
  26. $this->_sql = '
  27. insert into conference
  28. (jid, conference, name, nick, autojoin, status)
  29. values (:jid, :conference, :name, :nick, :autojoin, :status)';
  30. $this->prepare(
  31. 'Conference',
  32. array(
  33. 'jid' => $c->jid,
  34. 'conference' => $c->conference,
  35. 'name' => $c->name,
  36. 'nick' => $c->nick,
  37. 'autojoin' => $c->autojoin,
  38. 'status' => $c->status
  39. )
  40. );
  41. $this->run('Conference');
  42. }
  43. }
  44. function get($conference) {
  45. $this->_sql = '
  46. select * from conference
  47. where jid = :jid
  48. and conference= :conference';
  49. $this->prepare(
  50. 'Conference',
  51. array(
  52. 'jid' => $this->_user,
  53. 'conference' => $conference,
  54. )
  55. );
  56. return $this->run('Conference', 'item');
  57. }
  58. function getAll() {
  59. $this->_sql = '
  60. select * from conference
  61. where jid = :jid';
  62. $this->prepare(
  63. 'Conference',
  64. array(
  65. 'jid' => $this->_user
  66. )
  67. );
  68. return $this->run('Conference');
  69. }
  70. function getConnected() {
  71. $this->_sql = '
  72. select * from conference
  73. where jid = :jid
  74. and status= 1';
  75. $this->prepare(
  76. 'Conference',
  77. array(
  78. 'jid' => $this->_user
  79. )
  80. );
  81. return $this->run('Conference');
  82. }
  83. /*
  84. function getSubscribed() {
  85. $this->_sql = '
  86. select
  87. subscription.jid,
  88. subscription.server,
  89. subscription.node,
  90. subscription,
  91. name
  92. from subscription
  93. left outer join item
  94. on item.server = subscription.server
  95. and item.node = subscription.node
  96. where subscription.jid = :jid
  97. group by
  98. subscription.server,
  99. subscription.node,
  100. subscription.jid,
  101. subscription, item.name
  102. order by
  103. subscription.server';
  104. $this->prepare(
  105. 'Subscription',
  106. array(
  107. 'jid' => $this->_user
  108. )
  109. );
  110. return $this->run('Subscription');
  111. }
  112. */
  113. function delete() {
  114. $this->_sql = '
  115. delete from conference
  116. where jid = :jid';
  117. $this->prepare(
  118. 'Subscription',
  119. array(
  120. 'jid' => $this->_user
  121. )
  122. );
  123. return $this->run('conference');
  124. }
  125. function deleteNode($conference) {
  126. $this->_sql = '
  127. delete from conference
  128. where jid = :jid
  129. and conference= :conference';
  130. $this->prepare(
  131. 'Conference',
  132. array(
  133. 'jid' => $this->_user,
  134. 'conference' => $conference
  135. )
  136. );
  137. return $this->run('Conference');
  138. }
  139. }