permissions.rb 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. # Copyright (C) 2012-2024 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_twitter',
  160. label: __('Twitter'),
  161. description: __('Manage Twitter channel of your system.'),
  162. preferences: { prio: 1260 }
  163. )
  164. Permission.create_if_not_exists(
  165. name: 'admin.channel_facebook',
  166. label: __('Facebook'),
  167. description: __('Manage Facebook channel of your system.'),
  168. preferences: { prio: 1270 }
  169. )
  170. Permission.create_if_not_exists(
  171. name: 'admin.channel_telegram',
  172. label: __('Telegram'),
  173. description: __('Manage Telegram channel of your system.'),
  174. preferences: { prio: 1280 }
  175. )
  176. Permission.create_if_not_exists(
  177. name: 'admin.channel_whatsapp',
  178. label: __('WhatsApp'),
  179. description: __('Manage WhatsApp channel of your system.'),
  180. preferences: { prio: 1290 }
  181. )
  182. Permission.create_if_not_exists(
  183. name: 'admin.branding',
  184. label: __('Branding'),
  185. description: __('Manage branding settings of your system.'),
  186. preferences: { prio: 1300 }
  187. )
  188. Permission.create_if_not_exists(
  189. name: 'admin.setting_system',
  190. label: __('System'),
  191. description: __('Manage core system settings.'),
  192. preferences: { prio: 1310 }
  193. )
  194. Permission.create_if_not_exists(
  195. name: 'admin.security',
  196. label: __('Security'),
  197. description: __('Manage security settings of your system.'),
  198. preferences: { prio: 1320 }
  199. )
  200. Permission.create_if_not_exists(
  201. name: 'admin.ticket',
  202. label: __('Ticket'),
  203. description: __('Manage ticket settings of your system.'),
  204. preferences: { prio: 1330 }
  205. )
  206. Permission.create_if_not_exists(
  207. name: 'admin.integration',
  208. label: __('Integrations'),
  209. description: __('Manage integrations of your system.'),
  210. preferences: { prio: 1340 }
  211. )
  212. Permission.create_if_not_exists(
  213. name: 'admin.api',
  214. label: __('API'),
  215. description: __('Manage API of your system.'),
  216. preferences: { prio: 1350 }
  217. )
  218. Permission.create_if_not_exists(
  219. name: 'admin.object',
  220. label: __('Objects'),
  221. description: __('Manage object attributes of your system.'),
  222. preferences: { prio: 1360 }
  223. )
  224. Permission.create_if_not_exists(
  225. name: 'admin.ticket_state',
  226. label: __('Ticket States'),
  227. description: __('Manage ticket states of your system.'),
  228. preferences: { prio: 1370 }
  229. )
  230. Permission.create_if_not_exists(
  231. name: 'admin.ticket_priority',
  232. label: __('Ticket Priorities'),
  233. description: __('Manage ticket priorities of your system.'),
  234. preferences: { prio: 1380 }
  235. )
  236. Permission.create_if_not_exists(
  237. name: 'admin.core_workflow',
  238. label: __('Core Workflows'),
  239. description: __('Manage core workflows of your system.'),
  240. preferences: { prio: 1390 }
  241. )
  242. Permission.create_if_not_exists(
  243. name: 'admin.translation',
  244. label: __('Translations'),
  245. description: __('Manage translations of your system.'),
  246. preferences: { prio: 1400 }
  247. )
  248. Permission.create_if_not_exists(
  249. name: 'admin.data_privacy',
  250. label: __('Data Privacy'),
  251. description: __('Delete existing data of your system.'),
  252. preferences: { prio: 1410 }
  253. )
  254. Permission.create_if_not_exists(
  255. name: 'admin.maintenance',
  256. label: __('Maintenance'),
  257. description: __('Manage maintenance mode of your system.'),
  258. preferences: { prio: 1420 }
  259. )
  260. Permission.create_if_not_exists(
  261. name: 'admin.monitoring',
  262. label: __('Monitoring'),
  263. description: __('Manage monitoring of your system.'),
  264. preferences: { prio: 1430 }
  265. )
  266. Permission.create_if_not_exists(
  267. name: 'admin.package',
  268. label: __('Packages'),
  269. description: __('Manage packages of your system.'),
  270. preferences: { prio: 1440 }
  271. )
  272. Permission.create_if_not_exists(
  273. name: 'admin.session',
  274. label: __('Sessions'),
  275. description: __('Manage active user sessions of your system.'),
  276. preferences: { prio: 1450 }
  277. )
  278. Permission.create_if_not_exists(
  279. name: 'admin.system_report',
  280. label: __('System Report'),
  281. description: __('Manage system report of your system.'),
  282. preferences: { prio: 1460 }
  283. )
  284. Permission.create_if_not_exists(
  285. name: 'chat',
  286. label: __('Chat'),
  287. description: __('Access to the chat interface.'),
  288. preferences: {
  289. prio: 1470,
  290. disabled: true,
  291. },
  292. )
  293. Permission.create_if_not_exists(
  294. name: 'chat.agent',
  295. label: __('Agent chat'),
  296. description: __('Access the agent chat features.'),
  297. preferences: { prio: 1480 }
  298. )
  299. Permission.create_if_not_exists(
  300. name: 'cti',
  301. label: __('Phone'),
  302. description: __('Access to the phone interface.'),
  303. preferences: {
  304. prio: 1490,
  305. disabled: true
  306. },
  307. )
  308. Permission.create_if_not_exists(
  309. name: 'cti.agent',
  310. label: __('Agent phone'),
  311. description: __('Access the agent phone features.'),
  312. preferences: { prio: 1500 }
  313. )
  314. Permission.create_if_not_exists(
  315. name: 'knowledge_base',
  316. label: __('Knowledge Base'),
  317. description: __('Access to the knowledge base interface.'),
  318. preferences: {
  319. prio: 1510,
  320. disabled: true,
  321. }
  322. )
  323. Permission.create_if_not_exists(
  324. name: 'knowledge_base.editor',
  325. label: __('Knowledge Base Editor'),
  326. description: __('Access the knowledge base editor features.'),
  327. preferences: { prio: 1520 }
  328. )
  329. Permission.create_if_not_exists(
  330. name: 'knowledge_base.reader',
  331. label: __('Knowledge Base Reader'),
  332. description: __('Access the knowledge base reader features.'),
  333. allow_signup: true,
  334. preferences: { prio: 1530 }
  335. )
  336. Permission.create_if_not_exists(
  337. name: 'report',
  338. label: __('Report'),
  339. description: __('Access to the report interface.'),
  340. preferences: { prio: 1540 }
  341. )
  342. Permission.create_if_not_exists(
  343. name: 'ticket',
  344. label: __('Ticket'),
  345. description: __('Access to the ticket interface.'),
  346. preferences: {
  347. prio: 1550,
  348. disabled: true
  349. },
  350. )
  351. Permission.create_if_not_exists(
  352. name: 'ticket.agent',
  353. label: __('Agent tickets'),
  354. description: __('Access the tickets as agent based on group access.'),
  355. preferences: {
  356. prio: 1560,
  357. plugin: ['groups']
  358. },
  359. )
  360. Permission.create_if_not_exists(
  361. name: 'ticket.customer',
  362. label: __('Customer tickets'),
  363. description: __('Access tickets as customer.'),
  364. allow_signup: true,
  365. preferences: { prio: 1570 }
  366. )
  367. Permission.create_if_not_exists(
  368. name: 'user_preferences',
  369. label: __('Profile settings'),
  370. description: __('Manage personal settings.'),
  371. allow_signup: true,
  372. preferences: { prio: 1580 }
  373. )
  374. Permission.create_if_not_exists(
  375. name: 'user_preferences.appearance',
  376. label: __('Appearance'),
  377. description: __('Manage personal appearance settings.'),
  378. allow_signup: true,
  379. preferences: { prio: 1590 }
  380. )
  381. Permission.create_if_not_exists(
  382. name: 'user_preferences.language',
  383. label: __('Language'),
  384. description: __('Manage personal language settings.'),
  385. allow_signup: true,
  386. preferences: { prio: 1600 }
  387. )
  388. Permission.create_if_not_exists(
  389. name: 'user_preferences.avatar',
  390. label: __('Avatar'),
  391. description: __('Manage personal avatar settings.'),
  392. allow_signup: true,
  393. preferences: { prio: 1610 }
  394. )
  395. Permission.create_if_not_exists(
  396. name: 'user_preferences.out_of_office',
  397. label: __('Out of Office'),
  398. description: __('Manage personal out of office settings.'),
  399. preferences: {
  400. prio: 1620,
  401. required: ['ticket.agent'],
  402. },
  403. allow_signup: true,
  404. )
  405. Permission.create_if_not_exists(
  406. name: 'user_preferences.password',
  407. label: __('Password'),
  408. description: __('Change personal account password.'),
  409. allow_signup: true,
  410. preferences: { prio: 1630 }
  411. )
  412. Permission.create_if_not_exists(
  413. name: 'user_preferences.two_factor_authentication',
  414. label: __('Two-factor Authentication'),
  415. description: __('Manage personal two-factor authentication methods.'),
  416. allow_signup: true,
  417. preferences: { prio: 1640 }
  418. )
  419. Permission.create_if_not_exists(
  420. name: 'user_preferences.device',
  421. label: __('Devices'),
  422. description: __('Manage personal devices and sessions.'),
  423. allow_signup: true,
  424. preferences: { prio: 1650 }
  425. )
  426. Permission.create_if_not_exists(
  427. name: 'user_preferences.access_token',
  428. label: __('Token Access'),
  429. description: __('Manage personal API tokens.'),
  430. allow_signup: true,
  431. preferences: { prio: 1660 }
  432. )
  433. Permission.create_if_not_exists(
  434. name: 'user_preferences.linked_accounts',
  435. label: __('Linked Accounts'),
  436. description: __('Manage personal linked accounts.'),
  437. allow_signup: true,
  438. preferences: { prio: 1670 }
  439. )
  440. Permission.create_if_not_exists(
  441. name: 'user_preferences.notifications',
  442. label: __('Notifications'),
  443. description: __('Manage personal notifications settings.'),
  444. preferences: {
  445. prio: 1680,
  446. required: ['ticket.agent'],
  447. },
  448. allow_signup: true,
  449. )
  450. Permission.create_if_not_exists(
  451. name: 'user_preferences.overview_sorting',
  452. label: __('Overviews'),
  453. description: __('Manage personal overviews.'),
  454. preferences: {
  455. prio: 1690,
  456. required: ['ticket.agent'],
  457. },
  458. allow_signup: true,
  459. )
  460. Permission.create_if_not_exists(
  461. name: 'user_preferences.calendar',
  462. label: __('Calendar'),
  463. description: __('Manage personal calendar.'),
  464. preferences: {
  465. prio: 1700,
  466. required: ['ticket.agent'],
  467. },
  468. allow_signup: true,
  469. )
  470. admin = Role.find_by(name: 'Admin')
  471. admin.permission_grant('user_preferences')
  472. admin.permission_grant('admin')
  473. admin.permission_grant('report')
  474. admin.permission_grant('knowledge_base.editor')
  475. agent = Role.find_by(name: 'Agent')
  476. agent.permission_grant('user_preferences')
  477. agent.permission_grant('ticket.agent')
  478. agent.permission_grant('chat.agent')
  479. agent.permission_grant('cti.agent')
  480. agent.permission_grant('knowledge_base.reader')
  481. customer = Role.find_by(name: 'Customer')
  482. customer.permission_grant('user_preferences.password')
  483. customer.permission_grant('user_preferences.two_factor_authentication')
  484. customer.permission_grant('user_preferences.language')
  485. customer.permission_grant('user_preferences.linked_accounts')
  486. customer.permission_grant('user_preferences.avatar')
  487. customer.permission_grant('user_preferences.appearance')
  488. customer.permission_grant('ticket.customer')