first_steps_controller.rb 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class FirstStepsController < ApplicationController
  3. before_action :authentication_check
  4. def index
  5. result = []
  6. if !current_user.role?(%w(Agent Admin))
  7. render json: result
  8. return
  9. end
  10. invite_agents = false
  11. #if User.of_role('Agent').count > 2
  12. # invite_agents = true
  13. #end
  14. invite_customers = false
  15. #if User.of_role('Customer').count > 2
  16. # invite_customers = true
  17. #end
  18. chat_active = false
  19. if Setting.get('chat')
  20. chat_active = true
  21. end
  22. from_active = false
  23. if Setting.get('form_ticket_create')
  24. from_active = true
  25. end
  26. twitter_active = false
  27. if Channel.where(area: 'Twitter::Account').count > 0
  28. twitter_active = true
  29. end
  30. facebook_active = false
  31. if Channel.where(area: 'Facebook::Account').count > 0
  32. facebook_active = true
  33. end
  34. email_active = false
  35. if Channel.where(area: 'Email::Account').count > 0
  36. email_active = true
  37. end
  38. text_module_active = false
  39. if TextModule.count > 0
  40. text_module_active = true
  41. end
  42. macro_active = false
  43. if Macro.count > 1
  44. macro_active = true
  45. end
  46. if current_user.role?('Admin')
  47. result = [
  48. {
  49. name: 'Configuration',
  50. items: [
  51. {
  52. name: 'Branding',
  53. checked: true,
  54. location: '#settings/branding',
  55. },
  56. {
  57. name: 'Your Email Configuration',
  58. checked: email_active,
  59. location: '#channels/email',
  60. },
  61. {
  62. name: 'Invite Agents/Colleges to help working on Tickets',
  63. checked: invite_agents,
  64. location: '#',
  65. class: 'js-inviteAgent',
  66. },
  67. {
  68. name: 'Invite Customers to create issues in Zammad',
  69. checked: invite_customers,
  70. location: '#',
  71. class: 'js-inviteCustomer',
  72. },
  73. ],
  74. },
  75. {
  76. name: 'How to use it',
  77. items: [
  78. {
  79. name: 'Intro',
  80. checked: true,
  81. location: '#clues',
  82. },
  83. {
  84. name: 'Create a Test Ticket',
  85. checked: false,
  86. location: '#create_test_ticket',
  87. },
  88. {
  89. name: 'Create Overviews',
  90. checked: false,
  91. location: '#manage/overviews',
  92. },
  93. {
  94. name: 'Create Text Modues',
  95. checked: text_module_active,
  96. location: '#manage/text_modules',
  97. },
  98. {
  99. name: 'Create Macros',
  100. checked: macro_active,
  101. location: '#manage/macros',
  102. },
  103. ],
  104. },
  105. {
  106. name: 'Additionals Channels',
  107. items: [
  108. {
  109. name: 'Twitter',
  110. checked: twitter_active,
  111. location: '#channels/twitter',
  112. },
  113. {
  114. name: 'Facebook',
  115. checked: facebook_active,
  116. location: '#channels/facebook',
  117. },
  118. {
  119. name: 'Chat',
  120. checked: chat_active,
  121. location: '#channels/chat',
  122. },
  123. {
  124. name: 'Online Forms',
  125. checked: from_active,
  126. location: '#channels/form',
  127. },
  128. ],
  129. },
  130. ]
  131. render json: result
  132. return
  133. end
  134. result = [
  135. {
  136. name: 'How to use it',
  137. items: [
  138. {
  139. name: 'Intro',
  140. checked: true,
  141. location: '#clues',
  142. },
  143. {
  144. name: 'Create a Test Ticket',
  145. checked: false,
  146. location: '#create_test_ticket',
  147. },
  148. {
  149. name: 'Invite Customers to create issues in Zammad',
  150. checked: invite_customers,
  151. location: '#',
  152. class: 'js-inviteCustomer',
  153. },
  154. ],
  155. },
  156. ]
  157. render json: result
  158. end
  159. end