Flarum info
Flarum core: 1.8.9
PHP version: 8.3.14
MySQL version: 10.3.39-MariaDB-0ubuntu0.20.04.2
Loaded extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, random, Reflection, SPL, session, standard, sodium, mysqlnd, PDO, xml, bcmath, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, iconv, imagick, intl, exif, msgpack, mysqli, pdo_mysql, Phar, posix, readline, shmop, SimpleXML, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, Zend OPcache
+----------------------+------------+--------+
| Flarum Extensions | | |
+----------------------+------------+--------+
| ID | Version | Commit |
+----------------------+------------+--------+
| flarum-flags | v1.8.2 | |
| flarum-approval | v1.8.2 | |
| flarum-tags | v1.8.3 | |
| flarum-markdown | v1.8.1 | |
| flarum-suspend | v1.8.4 | |
| flarum-subscriptions | v1.8.1 | |
| flarum-sticky | v1.8.2 | |
| flarum-statistics | v1.8.1 | |
| flarum-mentions | v1.8.5 | |
| flarum-lock | v1.8.2 | |
| flarum-likes | v1.8.1 | |
| flarum-lang-russian | 1.40.0 | |
| flarum-emoji | v1.8.1 | |
| flarum-bbcode | v1.8.0 | |
| askvortsov-rich-text | v2.1.7 | |
| acme-hello-world | dev-master | |
+----------------------+------------+--------+
Base URL: http://forums.ser5lexx.ru/flarum
Installation path: /var/www/forums/htdocs/flarum
Queue driver: sync
Session driver: file
Mail driver: mail
Debug mode: ON
!<
I'm trying to build a custom extension, following instructions from https://docs.flarum.org/extend/start
Currently stuck with adding custom permissions in admin.js. I copypasted the code from likes package and modified slightly with my data:
import app from 'flarum/admin/app';
console.log('This file is included');
app.initializers.add('acme-flarum-hello-world', () => {
app.extensionData
.for('acme-flarum-hello-world')
.registerPermission({
icon: 'far fa-thumbs-up',
label: 'blabla',
permission: 'discussion.blabla',
}, 'reply');
});
Then I navigated to /flarum/admin/#/extension/acme-hello-world, but I see a message saying that the extension doesn't have any permissions.
So, I have a few questions:
- What am I doing wrong?
- Does the name
add('acme-flarum-hello-world') matters. What's its purpose?
- I see
for('acme-flarum-hello-world') has the same name as in add(). I suppose it indicates a [my] package for which the data should be applied, right?
- Does the prefix discussion in
permission: 'discussion.blabla' matters? What if I want to add a general permission applicable everywhere?
- Same question for
reply parameter: is it possible to register a general permission for entire forum or something?
- Where I can read about
registerPermission() in detail? I can't find the info online.
I guess for the start I can set the permissions directly in PHP code, but obviously that's highly undesirable for future production.