permissions.rb 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. Permission.create_if_not_exists(
  3. name: 'admin',
  4. note: __('Admin Interface'),
  5. preferences: {},
  6. )
  7. Permission.create_if_not_exists(
  8. name: 'admin.user',
  9. note: __('Manage %s'),
  10. preferences: {
  11. translations: [__('Users')]
  12. },
  13. )
  14. Permission.create_if_not_exists(
  15. name: 'admin.group',
  16. note: __('Manage %s'),
  17. preferences: {
  18. translations: [__('Groups')]
  19. },
  20. )
  21. Permission.create_if_not_exists(
  22. name: 'admin.role',
  23. note: __('Manage %s'),
  24. preferences: {
  25. translations: [__('Roles')]
  26. },
  27. )
  28. Permission.create_if_not_exists(
  29. name: 'admin.organization',
  30. note: __('Manage %s'),
  31. preferences: {
  32. translations: [__('Organizations')]
  33. },
  34. )
  35. Permission.create_if_not_exists(
  36. name: 'admin.overview',
  37. note: __('Manage %s'),
  38. preferences: {
  39. translations: [__('Overviews')]
  40. },
  41. )
  42. Permission.create_if_not_exists(
  43. name: 'admin.text_module',
  44. note: __('Manage %s'),
  45. preferences: {
  46. translations: [__('Text Modules')]
  47. },
  48. )
  49. Permission.create_if_not_exists(
  50. name: 'admin.time_accounting',
  51. note: __('Manage %s'),
  52. preferences: {
  53. translations: [__('Time Accounting')]
  54. },
  55. )
  56. Permission.create_if_not_exists(
  57. name: 'admin.macro',
  58. note: __('Manage %s'),
  59. preferences: {
  60. translations: [__('Macros')]
  61. },
  62. )
  63. Permission.create_if_not_exists(
  64. name: 'admin.tag',
  65. note: __('Manage %s'),
  66. preferences: {
  67. translations: [__('Tags')]
  68. },
  69. )
  70. Permission.create_if_not_exists(
  71. name: 'admin.calendar',
  72. note: __('Manage %s'),
  73. preferences: {
  74. translations: [__('Calendar')]
  75. },
  76. )
  77. Permission.create_if_not_exists(
  78. name: 'admin.sla',
  79. note: __('Manage %s'),
  80. preferences: {
  81. translations: [__('SLA')]
  82. },
  83. )
  84. Permission.create_if_not_exists(
  85. name: 'admin.trigger',
  86. note: __('Manage %s'),
  87. preferences: {
  88. translations: [__('Triggers')]
  89. },
  90. )
  91. Permission.create_if_not_exists(
  92. name: 'admin.scheduler',
  93. note: __('Manage %s'),
  94. preferences: {
  95. translations: [__('Scheduler')]
  96. },
  97. )
  98. Permission.create_if_not_exists(
  99. name: 'admin.report_profile',
  100. note: __('Manage %s'),
  101. preferences: {
  102. translations: [__('Report Profiles')]
  103. },
  104. )
  105. Permission.create_if_not_exists(
  106. name: 'admin.channel_web',
  107. note: __('Manage %s'),
  108. preferences: {
  109. translations: [__('Channel - Web')]
  110. },
  111. )
  112. Permission.create_if_not_exists(
  113. name: 'admin.channel_formular',
  114. note: __('Manage %s'),
  115. preferences: {
  116. translations: [__('Channel - Form')]
  117. },
  118. )
  119. Permission.create_if_not_exists(
  120. name: 'admin.channel_email',
  121. note: __('Manage %s'),
  122. preferences: {
  123. translations: [__('Channel - Email')]
  124. },
  125. )
  126. Permission.create_if_not_exists(
  127. name: 'admin.channel_twitter',
  128. note: __('Manage %s'),
  129. preferences: {
  130. translations: [__('Channel - Twitter')]
  131. },
  132. )
  133. Permission.create_if_not_exists(
  134. name: 'admin.channel_facebook',
  135. note: __('Manage %s'),
  136. preferences: {
  137. translations: [__('Channel - Facebook')]
  138. },
  139. )
  140. Permission.create_if_not_exists(
  141. name: 'admin.channel_telegram',
  142. note: __('Manage %s'),
  143. preferences: {
  144. translations: [__('Channel - Telegram')]
  145. },
  146. )
  147. Permission.create_if_not_exists(
  148. name: 'admin.channel_google',
  149. note: __('Manage %s'),
  150. preferences: {
  151. translations: [__('Channel - Google')]
  152. },
  153. )
  154. Permission.create_if_not_exists(
  155. name: 'admin.channel_microsoft365',
  156. note: __('Manage %s'),
  157. preferences: {
  158. translations: [__('Channel - Microsoft 365')]
  159. },
  160. )
  161. Permission.create_if_not_exists(
  162. name: 'admin.channel_sms',
  163. note: __('Manage %s'),
  164. preferences: {
  165. translations: [__('Channel - SMS')]
  166. },
  167. )
  168. Permission.create_if_not_exists(
  169. name: 'admin.channel_chat',
  170. note: __('Manage %s'),
  171. preferences: {
  172. translations: [__('Channel - Chat')]
  173. },
  174. )
  175. Permission.create_if_not_exists(
  176. name: 'admin.branding',
  177. note: __('Manage %s'),
  178. preferences: {
  179. translations: [__('Branding')]
  180. },
  181. )
  182. Permission.create_if_not_exists(
  183. name: 'admin.setting_system',
  184. note: __('Manage %s Settings'),
  185. preferences: {
  186. translations: [__('System')]
  187. },
  188. )
  189. Permission.create_if_not_exists(
  190. name: 'admin.security',
  191. note: __('Manage %s Settings'),
  192. preferences: {
  193. translations: [__('Security')]
  194. },
  195. )
  196. Permission.create_if_not_exists(
  197. name: 'admin.ticket',
  198. note: __('Manage %s Settings'),
  199. preferences: {
  200. translations: [__('Ticket')]
  201. },
  202. )
  203. Permission.create_if_not_exists(
  204. name: 'admin.package',
  205. note: __('Manage %s'),
  206. preferences: {
  207. translations: [__('Packages')]
  208. },
  209. )
  210. Permission.create_if_not_exists(
  211. name: 'admin.integration',
  212. note: __('Manage %s'),
  213. preferences: {
  214. translations: [__('Integrations')]
  215. },
  216. )
  217. Permission.create_if_not_exists(
  218. name: 'admin.api',
  219. note: __('Manage %s'),
  220. preferences: {
  221. translations: [__('API')]
  222. },
  223. )
  224. Permission.create_if_not_exists(
  225. name: 'admin.object',
  226. note: __('Manage %s'),
  227. preferences: {
  228. translations: [__('Objects')]
  229. },
  230. )
  231. Permission.create_if_not_exists(
  232. name: 'admin.template',
  233. note: __('Manage %s'),
  234. preferences: {
  235. translations: [__('Templates')]
  236. },
  237. )
  238. Permission.create_if_not_exists(
  239. name: 'admin.translation',
  240. note: __('Manage %s'),
  241. preferences: {
  242. translations: [__('Translations')]
  243. },
  244. )
  245. Permission.create_if_not_exists(
  246. name: 'admin.monitoring',
  247. note: __('Manage %s'),
  248. preferences: {
  249. translations: [__('Monitoring')]
  250. },
  251. )
  252. Permission.create_if_not_exists(
  253. name: 'admin.data_privacy',
  254. note: __('Manage %s'),
  255. preferences: {
  256. translations: [__('Data Privacy')]
  257. },
  258. )
  259. Permission.create_if_not_exists(
  260. name: 'admin.maintenance',
  261. note: __('Manage %s'),
  262. preferences: {
  263. translations: [__('Maintenance')]
  264. },
  265. )
  266. Permission.create_if_not_exists(
  267. name: 'admin.session',
  268. note: __('Manage %s'),
  269. preferences: {
  270. translations: [__('Sessions')]
  271. },
  272. )
  273. Permission.create_if_not_exists(
  274. name: 'admin.webhook',
  275. note: __('Manage %s'),
  276. preferences: {
  277. translations: [__('Webhooks')]
  278. },
  279. )
  280. Permission.create_if_not_exists(
  281. name: 'admin.core_workflow',
  282. note: __('Manage %s'),
  283. preferences: {
  284. translations: [__('Core Workflow')]
  285. },
  286. )
  287. Permission.create_if_not_exists(
  288. name: 'admin.public_links',
  289. note: __('Manage %s'),
  290. preferences: {
  291. translations: [__('Public Links')]
  292. },
  293. )
  294. Permission.create_if_not_exists(
  295. name: 'user_preferences',
  296. note: __('User Preferences'),
  297. preferences: {},
  298. allow_signup: true,
  299. )
  300. Permission.create_if_not_exists(
  301. name: 'user_preferences.password',
  302. note: __('Change %s'),
  303. preferences: {
  304. translations: [__('Password')]
  305. },
  306. allow_signup: true,
  307. )
  308. Permission.create_if_not_exists(
  309. name: 'user_preferences.notifications',
  310. note: __('Manage %s'),
  311. preferences: {
  312. translations: [__('Notifications')],
  313. required: ['ticket.agent'],
  314. },
  315. allow_signup: true,
  316. )
  317. Permission.create_if_not_exists(
  318. name: 'user_preferences.access_token',
  319. note: __('Manage %s'),
  320. preferences: {
  321. translations: [__('Token Access')]
  322. },
  323. allow_signup: true,
  324. )
  325. Permission.create_if_not_exists(
  326. name: 'user_preferences.language',
  327. note: __('Change %s'),
  328. preferences: {
  329. translations: [__('Language')]
  330. },
  331. allow_signup: true,
  332. )
  333. Permission.create_if_not_exists(
  334. name: 'user_preferences.linked_accounts',
  335. note: __('Manage %s'),
  336. preferences: {
  337. translations: [__('Linked Accounts')]
  338. },
  339. allow_signup: true,
  340. )
  341. Permission.create_if_not_exists(
  342. name: 'user_preferences.device',
  343. note: __('Manage %s'),
  344. preferences: {
  345. translations: [__('Devices')]
  346. },
  347. allow_signup: true,
  348. )
  349. Permission.create_if_not_exists(
  350. name: 'user_preferences.avatar',
  351. note: __('Manage %s'),
  352. preferences: {
  353. translations: [__('Avatar')]
  354. },
  355. allow_signup: true,
  356. )
  357. Permission.create_if_not_exists(
  358. name: 'user_preferences.calendar',
  359. note: __('Access to %s'),
  360. preferences: {
  361. translations: [__('Calendars')],
  362. required: ['ticket.agent'],
  363. },
  364. allow_signup: true,
  365. )
  366. Permission.create_if_not_exists(
  367. name: 'user_preferences.out_of_office',
  368. note: __('Change %s'),
  369. preferences: {
  370. translations: [__('Out of Office')],
  371. required: ['ticket.agent'],
  372. },
  373. allow_signup: true,
  374. )
  375. Permission.create_if_not_exists(
  376. name: 'user_preferences.overview_sorting',
  377. note: __('Change %s'),
  378. preferences: {
  379. translations: [__('Order of Overviews')],
  380. required: ['ticket.agent'],
  381. },
  382. allow_signup: true,
  383. )
  384. Permission.create_if_not_exists(
  385. name: 'user_preferences.appearance',
  386. note: __('Manage %s'),
  387. preferences: {
  388. translations: [__('Appearance')]
  389. },
  390. allow_signup: true,
  391. )
  392. Permission.create_if_not_exists(
  393. name: 'report',
  394. note: __('Report Interface'),
  395. preferences: {},
  396. )
  397. Permission.create_if_not_exists(
  398. name: 'ticket',
  399. note: __('Ticket Interface'),
  400. preferences: {
  401. disabled: true
  402. },
  403. )
  404. Permission.create_if_not_exists(
  405. name: 'ticket.agent',
  406. note: __('Access to Agent Tickets based on Group Access'),
  407. preferences: {
  408. plugin: ['groups']
  409. },
  410. )
  411. Permission.create_if_not_exists(
  412. name: 'ticket.customer',
  413. note: __('Access to Customer Tickets based on current_user and organization'),
  414. preferences: {},
  415. allow_signup: true,
  416. )
  417. Permission.create_if_not_exists(
  418. name: 'chat',
  419. note: __('Access to %s'),
  420. preferences: {
  421. translations: [__('Chat')],
  422. disabled: true,
  423. },
  424. )
  425. Permission.create_if_not_exists(
  426. name: 'chat.agent',
  427. note: __('Access to %s'),
  428. preferences: {
  429. translations: [__('Chat')],
  430. },
  431. )
  432. Permission.create_if_not_exists(
  433. name: 'cti',
  434. note: __('CTI'),
  435. preferences: {
  436. disabled: true
  437. },
  438. )
  439. Permission.create_if_not_exists(
  440. name: 'cti.agent',
  441. note: __('Access to %s'),
  442. preferences: {
  443. translations: [__('CTI')],
  444. },
  445. )
  446. Permission.create_if_not_exists(
  447. name: 'admin.knowledge_base',
  448. note: __('Create and set up %s'),
  449. preferences: {
  450. translations: [__('Knowledge Base')]
  451. }
  452. )
  453. Permission.create_if_not_exists(
  454. name: 'knowledge_base',
  455. note: __('Manage %s'),
  456. preferences: {
  457. translations: [__('Knowledge Base')],
  458. disabled: true,
  459. }
  460. )
  461. Permission.create_if_not_exists(
  462. name: 'knowledge_base.editor',
  463. note: __('Manage %s'),
  464. preferences: {
  465. translations: [__('Knowledge Base Editor')]
  466. }
  467. )
  468. Permission.create_if_not_exists(
  469. name: 'knowledge_base.reader',
  470. note: __('Manage %s'),
  471. preferences: {
  472. translations: [__('Knowledge Base Reader')]
  473. },
  474. allow_signup: true,
  475. )
  476. admin = Role.find_by(name: 'Admin')
  477. admin.permission_grant('user_preferences')
  478. admin.permission_grant('admin')
  479. admin.permission_grant('report')
  480. admin.permission_grant('knowledge_base.editor')
  481. agent = Role.find_by(name: 'Agent')
  482. agent.permission_grant('user_preferences')
  483. agent.permission_grant('ticket.agent')
  484. agent.permission_grant('chat.agent')
  485. agent.permission_grant('cti.agent')
  486. agent.permission_grant('knowledge_base.reader')
  487. customer = Role.find_by(name: 'Customer')
  488. customer.permission_grant('user_preferences.password')
  489. customer.permission_grant('user_preferences.language')
  490. customer.permission_grant('user_preferences.linked_accounts')
  491. customer.permission_grant('user_preferences.avatar')
  492. customer.permission_grant('user_preferences.appearance')
  493. customer.permission_grant('ticket.customer')