permissions.rb 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. Permission.create_if_not_exists(
  3. name: 'admin',
  4. label: __('Admin interface'),
  5. description: __('Configure your system.'),
  6. preferences: { prio: 1000 }
  7. )
  8. Permission.create_if_not_exists(
  9. name: 'admin.user',
  10. label: __('Users'),
  11. description: __('Manage all users of your system.'),
  12. preferences: { prio: 1010 }
  13. )
  14. Permission.create_if_not_exists(
  15. name: 'admin.group',
  16. label: __('Groups'),
  17. description: __('Manage groups of your system.'),
  18. preferences: { prio: 1020 }
  19. )
  20. Permission.create_if_not_exists(
  21. name: 'admin.role',
  22. label: __('Roles'),
  23. description: __('Manage roles of your system.'),
  24. preferences: { prio: 1030 }
  25. )
  26. Permission.create_if_not_exists(
  27. name: 'admin.organization',
  28. label: __('Organizations'),
  29. description: __('Manage all organizations of your system.'),
  30. preferences: { prio: 1040 }
  31. )
  32. Permission.create_if_not_exists(
  33. name: 'admin.overview',
  34. label: __('Overviews'),
  35. description: __('Manage ticket overviews of your system.'),
  36. preferences: { prio: 1050 }
  37. )
  38. Permission.create_if_not_exists(
  39. name: 'admin.text_module',
  40. label: __('Text modules'),
  41. description: __('Manage text modules of your system.'),
  42. preferences: { prio: 1060 }
  43. )
  44. Permission.create_if_not_exists(
  45. name: 'admin.macro',
  46. label: __('Macros'),
  47. description: __('Manage ticket macros of your system.'),
  48. preferences: { prio: 1070 }
  49. )
  50. Permission.create_if_not_exists(
  51. name: 'admin.template',
  52. label: __('Templates'),
  53. description: __('Manage ticket templates of your system.'),
  54. preferences: { prio: 1080 }
  55. )
  56. Permission.create_if_not_exists(
  57. name: 'admin.tag',
  58. label: __('Tags'),
  59. description: __('Manage ticket tags of your system.'),
  60. preferences: { prio: 1090 }
  61. )
  62. Permission.create_if_not_exists(
  63. name: 'admin.calendar',
  64. label: __('Calendars'),
  65. description: __('Manage calendars of your system.'),
  66. preferences: { prio: 1100 }
  67. )
  68. Permission.create_if_not_exists(
  69. name: 'admin.sla',
  70. label: __('SLAs'),
  71. description: __('Manage Service Level Agreements of your system.'),
  72. preferences: { prio: 1110 }
  73. )
  74. Permission.create_if_not_exists(
  75. name: 'admin.trigger',
  76. label: __('Trigger'),
  77. description: __('Manage triggers of your system.'),
  78. preferences: { prio: 1120 }
  79. )
  80. Permission.create_if_not_exists(
  81. name: 'admin.public_links',
  82. label: __('Public Links'),
  83. description: __('Manage public links of your system.'),
  84. preferences: { prio: 1130 }
  85. )
  86. Permission.create_if_not_exists(
  87. name: 'admin.webhook',
  88. label: __('Webhook'),
  89. description: __('Manage webhooks of your system.'),
  90. preferences: { prio: 1140 }
  91. )
  92. Permission.create_if_not_exists(
  93. name: 'admin.scheduler',
  94. label: __('Scheduler'),
  95. description: __('Manage schedulers of your system.'),
  96. preferences: { prio: 1150 }
  97. )
  98. Permission.create_if_not_exists(
  99. name: 'admin.report_profile',
  100. label: __('Report Profiles'),
  101. description: __('Manage report profiles of your system.'),
  102. preferences: { prio: 1160 }
  103. )
  104. Permission.create_if_not_exists(
  105. name: 'admin.time_accounting',
  106. label: __('Time Accounting'),
  107. description: __('Manage time accounting settings of your system.'),
  108. preferences: { prio: 1170 }
  109. )
  110. Permission.create_if_not_exists(
  111. name: 'admin.knowledge_base',
  112. label: __('Knowledge Base'),
  113. description: __('Create and set up Knowledge Base.'),
  114. preferences: { prio: 1180 }
  115. )
  116. Permission.create_if_not_exists(
  117. name: 'admin.channel_web',
  118. label: __('Web'),
  119. description: __('Manage web channel of your system.'),
  120. preferences: { prio: 1190 }
  121. )
  122. Permission.create_if_not_exists(
  123. name: 'admin.channel_formular',
  124. label: __('Form'),
  125. description: __('Manage form channel of your system.'),
  126. preferences: { prio: 1200 }
  127. )
  128. Permission.create_if_not_exists(
  129. name: 'admin.channel_email',
  130. label: __('Email'),
  131. description: __('Manage email channel of your system.'),
  132. preferences: { prio: 1210 }
  133. )
  134. Permission.create_if_not_exists(
  135. name: 'admin.channel_sms',
  136. label: __('SMS'),
  137. description: __('Manage SMS channel of your system.'),
  138. preferences: { prio: 1220 }
  139. )
  140. Permission.create_if_not_exists(
  141. name: 'admin.channel_chat',
  142. label: __('Chat'),
  143. description: __('Manage chat channel of your system.'),
  144. preferences: { prio: 1230 }
  145. )
  146. Permission.create_if_not_exists(
  147. name: 'admin.channel_google',
  148. label: __('Google'),
  149. description: __('Manage Google mail channel of your system.'),
  150. preferences: { prio: 1240 }
  151. )
  152. Permission.create_if_not_exists(
  153. name: 'admin.channel_microsoft365',
  154. label: __('Microsoft 365'),
  155. description: __('Manage Microsoft 365 mail channel of your system.'),
  156. preferences: { prio: 1250 }
  157. )
  158. Permission.create_if_not_exists(
  159. name: 'admin.channel_microsoft_graph',
  160. label: __('Microsoft Graph'),
  161. description: __('Manage Microsoft Graph mail channel of your system.'),
  162. preferences: { prio: 1255 }
  163. )
  164. Permission.create_if_not_exists(
  165. name: 'admin.channel_twitter',
  166. label: __('Twitter'),
  167. description: __('Manage Twitter channel of your system.'),
  168. preferences: { prio: 1260 }
  169. )
  170. Permission.create_if_not_exists(
  171. name: 'admin.channel_facebook',
  172. label: __('Facebook'),
  173. description: __('Manage Facebook channel of your system.'),
  174. preferences: { prio: 1270 }
  175. )
  176. Permission.create_if_not_exists(
  177. name: 'admin.channel_telegram',
  178. label: __('Telegram'),
  179. description: __('Manage Telegram channel of your system.'),
  180. preferences: { prio: 1280 }
  181. )
  182. Permission.create_if_not_exists(
  183. name: 'admin.channel_whatsapp',
  184. label: __('WhatsApp'),
  185. description: __('Manage WhatsApp channel of your system.'),
  186. preferences: { prio: 1290 }
  187. )
  188. Permission.create_if_not_exists(
  189. name: 'admin.branding',
  190. label: __('Branding'),
  191. description: __('Manage branding settings of your system.'),
  192. preferences: { prio: 1300 }
  193. )
  194. Permission.create_if_not_exists(
  195. name: 'admin.setting_system',
  196. label: __('System'),
  197. description: __('Manage core system settings.'),
  198. preferences: { prio: 1310 }
  199. )
  200. Permission.create_if_not_exists(
  201. name: 'admin.security',
  202. label: __('Security'),
  203. description: __('Manage security settings of your system.'),
  204. preferences: { prio: 1320 }
  205. )
  206. Permission.create_if_not_exists(
  207. name: 'admin.ticket',
  208. label: __('Ticket'),
  209. description: __('Manage ticket settings of your system.'),
  210. preferences: { prio: 1330 }
  211. )
  212. Permission.create_if_not_exists(
  213. name: 'admin.ticket_auto_assignment',
  214. label: __('Ticket Auto Assignment'),
  215. description: __('Manage ticket auto assignment settings of your system.'),
  216. preferences: { prio: 1331 }
  217. )
  218. Permission.create_if_not_exists(
  219. name: 'admin.ticket_duplicate_detection',
  220. label: __('Ticket Duplicate Detection'),
  221. description: __('Manage ticket duplicate detection settings of your system.'),
  222. preferences: { prio: 1332 }
  223. )
  224. Permission.create_if_not_exists(
  225. name: 'admin.integration',
  226. label: __('Integrations'),
  227. description: __('Manage integrations of your system.'),
  228. preferences: { prio: 1340 }
  229. )
  230. Permission.create_if_not_exists(
  231. name: 'admin.api',
  232. label: __('API'),
  233. description: __('Manage API of your system.'),
  234. preferences: { prio: 1350 }
  235. )
  236. Permission.create_if_not_exists(
  237. name: 'admin.object',
  238. label: __('Objects'),
  239. description: __('Manage object attributes of your system.'),
  240. preferences: { prio: 1360 }
  241. )
  242. Permission.create_if_not_exists(
  243. name: 'admin.ticket_state',
  244. label: __('Ticket States'),
  245. description: __('Manage ticket states of your system.'),
  246. preferences: { prio: 1370 }
  247. )
  248. Permission.create_if_not_exists(
  249. name: 'admin.ticket_priority',
  250. label: __('Ticket Priorities'),
  251. description: __('Manage ticket priorities of your system.'),
  252. preferences: { prio: 1380 }
  253. )
  254. Permission.create_if_not_exists(
  255. name: 'admin.core_workflow',
  256. label: __('Core Workflows'),
  257. description: __('Manage core workflows of your system.'),
  258. preferences: { prio: 1390 }
  259. )
  260. Permission.create_if_not_exists(
  261. name: 'admin.translation',
  262. label: __('Translations'),
  263. description: __('Manage translations of your system.'),
  264. preferences: { prio: 1400 }
  265. )
  266. Permission.create_if_not_exists(
  267. name: 'admin.data_privacy',
  268. label: __('Data Privacy'),
  269. description: __('Delete existing data of your system.'),
  270. preferences: { prio: 1410 }
  271. )
  272. Permission.create_if_not_exists(
  273. name: 'admin.maintenance',
  274. label: __('Maintenance'),
  275. description: __('Manage maintenance mode of your system.'),
  276. preferences: { prio: 1420 }
  277. )
  278. Permission.create_if_not_exists(
  279. name: 'admin.monitoring',
  280. label: __('Monitoring'),
  281. description: __('Manage monitoring of your system.'),
  282. preferences: { prio: 1430 }
  283. )
  284. Permission.create_if_not_exists(
  285. name: 'admin.package',
  286. label: __('Packages'),
  287. description: __('Manage packages of your system.'),
  288. preferences: { prio: 1440 }
  289. )
  290. Permission.create_if_not_exists(
  291. name: 'admin.session',
  292. label: __('Sessions'),
  293. description: __('Manage active user sessions of your system.'),
  294. preferences: { prio: 1450 }
  295. )
  296. Permission.create_if_not_exists(
  297. name: 'admin.system_report',
  298. label: __('System Report'),
  299. description: __('Manage system report of your system.'),
  300. preferences: { prio: 1460 }
  301. )
  302. Permission.create_if_not_exists(
  303. name: 'admin.checklist',
  304. label: __('Checklists'),
  305. description: __('Manage ticket checklists of your system.'),
  306. preferences: { prio: 1465 }
  307. )
  308. Permission.create_if_not_exists(
  309. name: 'chat',
  310. label: __('Chat'),
  311. description: __('Access to the chat interface.'),
  312. preferences: {
  313. prio: 1470,
  314. disabled: true,
  315. },
  316. )
  317. Permission.create_if_not_exists(
  318. name: 'chat.agent',
  319. label: __('Agent chat'),
  320. description: __('Access the agent chat features.'),
  321. preferences: { prio: 1480 }
  322. )
  323. Permission.create_if_not_exists(
  324. name: 'cti',
  325. label: __('Phone'),
  326. description: __('Access to the phone interface.'),
  327. preferences: {
  328. prio: 1490,
  329. disabled: true
  330. },
  331. )
  332. Permission.create_if_not_exists(
  333. name: 'cti.agent',
  334. label: __('Agent phone'),
  335. description: __('Access the agent phone features.'),
  336. preferences: { prio: 1500 }
  337. )
  338. Permission.create_if_not_exists(
  339. name: 'knowledge_base',
  340. label: __('Knowledge Base'),
  341. description: __('Access to the knowledge base interface.'),
  342. preferences: {
  343. prio: 1510,
  344. disabled: true,
  345. }
  346. )
  347. Permission.create_if_not_exists(
  348. name: 'knowledge_base.editor',
  349. label: __('Knowledge Base Editor'),
  350. description: __('Access the knowledge base editor features.'),
  351. preferences: { prio: 1520 }
  352. )
  353. Permission.create_if_not_exists(
  354. name: 'knowledge_base.reader',
  355. label: __('Knowledge Base Reader'),
  356. description: __('Access the knowledge base reader features.'),
  357. allow_signup: true,
  358. preferences: { prio: 1530 }
  359. )
  360. Permission.create_if_not_exists(
  361. name: 'report',
  362. label: __('Report'),
  363. description: __('Access to the report interface.'),
  364. preferences: { prio: 1540 }
  365. )
  366. Permission.create_if_not_exists(
  367. name: 'ticket',
  368. label: __('Ticket'),
  369. description: __('Access to the ticket interface.'),
  370. preferences: {
  371. prio: 1550,
  372. disabled: true
  373. },
  374. )
  375. Permission.create_if_not_exists(
  376. name: 'ticket.agent',
  377. label: __('Agent tickets'),
  378. description: __('Access the tickets as agent based on group access.'),
  379. preferences: {
  380. prio: 1560,
  381. plugin: ['groups']
  382. },
  383. )
  384. Permission.create_if_not_exists(
  385. name: 'ticket.customer',
  386. label: __('Customer tickets'),
  387. description: __('Access tickets as customer.'),
  388. allow_signup: true,
  389. preferences: { prio: 1570 }
  390. )
  391. Permission.create_if_not_exists(
  392. name: 'user_preferences',
  393. label: __('Profile settings'),
  394. description: __('Manage personal settings.'),
  395. allow_signup: true,
  396. preferences: { prio: 1580 }
  397. )
  398. Permission.create_if_not_exists(
  399. name: 'user_preferences.appearance',
  400. label: __('Appearance'),
  401. description: __('Manage personal appearance settings.'),
  402. allow_signup: true,
  403. preferences: { prio: 1590 }
  404. )
  405. Permission.create_if_not_exists(
  406. name: 'user_preferences.language',
  407. label: __('Language'),
  408. description: __('Manage personal language settings.'),
  409. allow_signup: true,
  410. preferences: { prio: 1600 }
  411. )
  412. Permission.create_if_not_exists(
  413. name: 'user_preferences.avatar',
  414. label: __('Avatar'),
  415. description: __('Manage personal avatar settings.'),
  416. allow_signup: true,
  417. preferences: { prio: 1610 }
  418. )
  419. Permission.create_if_not_exists(
  420. name: 'user_preferences.out_of_office',
  421. label: __('Out of Office'),
  422. description: __('Manage personal out of office settings.'),
  423. preferences: {
  424. prio: 1620,
  425. required: ['ticket.agent'],
  426. },
  427. allow_signup: true,
  428. )
  429. Permission.create_if_not_exists(
  430. name: 'user_preferences.password',
  431. label: __('Password'),
  432. description: __('Change personal account password.'),
  433. allow_signup: true,
  434. preferences: { prio: 1630 }
  435. )
  436. Permission.create_if_not_exists(
  437. name: 'user_preferences.two_factor_authentication',
  438. label: __('Two-factor Authentication'),
  439. description: __('Manage personal two-factor authentication methods.'),
  440. allow_signup: true,
  441. preferences: { prio: 1640 }
  442. )
  443. Permission.create_if_not_exists(
  444. name: 'user_preferences.device',
  445. label: __('Devices'),
  446. description: __('Manage personal devices and sessions.'),
  447. allow_signup: true,
  448. preferences: { prio: 1650 }
  449. )
  450. Permission.create_if_not_exists(
  451. name: 'user_preferences.access_token',
  452. label: __('Token Access'),
  453. description: __('Manage personal API tokens.'),
  454. allow_signup: true,
  455. preferences: { prio: 1660 }
  456. )
  457. Permission.create_if_not_exists(
  458. name: 'user_preferences.linked_accounts',
  459. label: __('Linked Accounts'),
  460. description: __('Manage personal linked accounts.'),
  461. allow_signup: true,
  462. preferences: { prio: 1670 }
  463. )
  464. Permission.create_if_not_exists(
  465. name: 'user_preferences.notifications',
  466. label: __('Notifications'),
  467. description: __('Manage personal notifications settings.'),
  468. preferences: {
  469. prio: 1680,
  470. required: ['ticket.agent'],
  471. },
  472. allow_signup: true,
  473. )
  474. Permission.create_if_not_exists(
  475. name: 'user_preferences.overview_sorting',
  476. label: __('Overviews'),
  477. description: __('Manage personal overviews.'),
  478. preferences: {
  479. prio: 1690,
  480. required: ['ticket.agent'],
  481. },
  482. allow_signup: true,
  483. )
  484. Permission.create_if_not_exists(
  485. name: 'user_preferences.calendar',
  486. label: __('Calendar'),
  487. description: __('Manage personal calendar.'),
  488. preferences: {
  489. prio: 1700,
  490. required: ['ticket.agent'],
  491. },
  492. allow_signup: true,
  493. )
  494. admin = Role.find_by(name: 'Admin')
  495. admin.permission_grant('user_preferences')
  496. admin.permission_grant('admin')
  497. admin.permission_grant('report')
  498. admin.permission_grant('knowledge_base.editor')
  499. agent = Role.find_by(name: 'Agent')
  500. agent.permission_grant('user_preferences')
  501. agent.permission_grant('ticket.agent')
  502. agent.permission_grant('chat.agent')
  503. agent.permission_grant('cti.agent')
  504. agent.permission_grant('knowledge_base.reader')
  505. customer = Role.find_by(name: 'Customer')
  506. customer.permission_grant('user_preferences.password')
  507. customer.permission_grant('user_preferences.two_factor_authentication')
  508. customer.permission_grant('user_preferences.language')
  509. customer.permission_grant('user_preferences.linked_accounts')
  510. customer.permission_grant('user_preferences.avatar')
  511. customer.permission_grant('user_preferences.appearance')
  512. customer.permission_grant('ticket.customer')